var Ft=Object.defineProperty;var it=R=>{throw TypeError(R)};var qt=(R,g,C)=>g in R?Ft(R,g,{enumerable:!0,configurable:!0,writable:!0,value:C}):R[g]=C;var T=(R,g,C)=>qt(R,typeof g!="symbol"?g+"":g,C),Ot=(R,g,C)=>g.has(R)||it("Cannot "+C);var rt=(R,g,C)=>g.has(R)?it("Cannot add the same private member more than once"):g instanceof WeakSet?g.add(R):g.set(R,C);var ce=(R,g,C)=>(Ot(R,g,"access private method"),C);(function(){"use strict";var F,Te,st;var R,g,C,U,Se,ze,Re,Ie,pe,ue,he,K={},Y=[],ot=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,V=Array.isArray;function H(i,e){for(var t in e)i[t]=e[t];return i}function fe(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function lt(i,e,t){var n,s,r,o={};for(r in e)r=="key"?n=e[r]:r=="ref"?s=e[r]:o[r]=e[r];if(arguments.length>2&&(o.children=arguments.length>3?R.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(r in i.defaultProps)o[r]===void 0&&(o[r]=i.defaultProps[r]);return G(i,o,n,s,null)}function G(i,e,t,n,s){var r={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++C,__i:-1,__u:0};return s==null&&g.vnode!=null&&g.vnode(r),r}function q(i){return i.children}function X(i,e){this.props=i,this.context=e}function O(i,e){if(e==null)return i.__?O(i.__,i.__i+1):null;for(var t;ee&&U.sort(Re),i=U.shift(),e=U.length,at(i);J.__r=0}function Ae(i,e,t,n,s,r,o,l,c,p,u){var a,h,f,m,w,$,x,k=n&&n.__k||Y,z=e.length;for(c=ct(t,e,k,c,z),a=0;a0?o=i.__k[r]=G(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):i.__k[r]=o,c=r+h,o.__=i,o.__b=i.__b+1,l=null,(p=o.__i=pt(o,t,c,a))!=-1&&(a--,(l=t[p])&&(l.__u|=2)),l==null||l.__v==null?(p==-1&&(s>u?h--:sc?h--:h++,o.__u|=4))):i.__k[r]=null;if(a)for(r=0;r(u?1:0)){for(s=t-1,r=t+1;s>=0||r=0?s--:r++])!=null&&(2&p.__u)==0&&l==p.key&&c==p.type)return o}return-1}function Pe(i,e,t){e[0]=="-"?i.setProperty(e,t??""):i[e]=t==null?"":typeof t!="number"||ot.test(e)?t:t+"px"}function ee(i,e,t,n,s){var r,o;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||Pe(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||Pe(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")r=e!=(e=e.replace(Ie,"$1")),o=e.toLowerCase(),e=o in i||e=="onFocusOut"||e=="onFocusIn"?o.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+r]=t,t?n?t.u=n.u:(t.u=pe,i.addEventListener(e,r?he:ue,r)):i.removeEventListener(e,r?he:ue,r);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{i[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function Me(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=pe++;else if(e.t0?i:V(i)?i.map(He):H({},i)}function ut(i,e,t,n,s,r,o,l,c){var p,u,a,h,f,m,w,$=t.props||K,x=e.props,k=e.type;if(k=="svg"?s="http://www.w3.org/2000/svg":k=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),r!=null){for(p=0;p=t.__.length&&t.__.push({}),t.__[i]}function ke(i){return te=1,dt(Ye,i)}function dt(i,e,t){var n=me(j++,2);if(n.t=i,!n.__c&&(n.__=[Ye(void 0,e),function(l){var c=n.__N?n.__N[0]:n.__[0],p=n.t(c,l);c!==p&&(n.__N=[p,n.__[1]],n.__c.setState({}))}],n.__c=S,!S.__f)){var s=function(l,c,p){if(!n.__c.__H)return!0;var u=n.__c.__H.__.filter(function(h){return h.__c});if(u.every(function(h){return!h.__N}))return!r||r.call(this,l,c,p);var a=n.__c.props!==l;return u.some(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(a=!0)}}),r&&r.call(this,l,c,p)||a};S.__f=!0;var r=S.shouldComponentUpdate,o=S.componentWillUpdate;S.componentWillUpdate=function(l,c,p){if(this.__e){var u=r;r=void 0,s(l,c,p),r=u}o&&o.call(this,l,c,p)},S.shouldComponentUpdate=s}return n.__N||n.__}function xe(i,e){var t=me(j++,3);!I.__s&&Ke(t.__H,e)&&(t.__=i,t.u=e,S.__H.__h.push(t))}function Q(i){return te=5,gt(function(){return{current:i}},[])}function gt(i,e){var t=me(j++,7);return Ke(t.__H,e)&&(t.__=i(),t.__H=e,t.__h=i),t.__}function bt(){for(var i;i=Ne.shift();){var e=i.__H;if(i.__P&&e)try{e.__h.some(ne),e.__h.some(ye),e.__h=[]}catch(t){e.__h=[],I.__e(t,i.__v)}}}I.__b=function(i){S=null,Fe&&Fe(i)},I.__=function(i,e){i&&e.__k&&e.__k.__m&&(i.__m=e.__k.__m),Qe&&Qe(i,e)},I.__r=function(i){qe&&qe(i),j=0;var e=(S=i.__c).__H;e&&(be===S?(e.__h=[],S.__h=[],e.__.some(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(e.__h.some(ne),e.__h.some(ye),e.__h=[],j=0)),be=S},I.diffed=function(i){Oe&&Oe(i);var e=i.__c;e&&e.__H&&(e.__H.__h.length&&(Ne.push(e)!==1&&Be===I.requestAnimationFrame||((Be=I.requestAnimationFrame)||mt)(bt)),e.__H.__.some(function(t){t.u&&(t.__H=t.u),t.u=void 0})),be=S=null},I.__c=function(i,e){e.some(function(t){try{t.__h.some(ne),t.__h=t.__h.filter(function(n){return!n.__||ye(n)})}catch(n){e.some(function(s){s.__h&&(s.__h=[])}),e=[],I.__e(n,t.__v)}}),Ze&&Ze(i,e)},I.unmount=function(i){je&&je(i);var e,t=i.__c;t&&t.__H&&(t.__H.__.some(function(n){try{ne(n)}catch(s){e=s}}),t.__H=void 0,e&&I.__e(e,t.__v))};var We=typeof requestAnimationFrame=="function";function mt(i){var e,t=function(){clearTimeout(n),We&&cancelAnimationFrame(e),setTimeout(i)},n=setTimeout(t,35);We&&(e=requestAnimationFrame(t))}function ne(i){var e=S,t=i.__c;typeof t=="function"&&(i.__c=void 0,t()),S=e}function ye(i){var e=S;i.__c=i.__(),S=e}function Ke(i,e){return!i||i.length!==e.length||e.some(function(t,n){return t!==i[n]})}function Ye(i,e){return typeof e=="function"?e(i):e}async function kt(){return new Promise(i=>{const e=()=>{window.ChatbotConfig?i(window.ChatbotConfig):setTimeout(e,50)};e()})}function xt(){const[i,e]=ke([]),[t,n]=ke(!1),s=Q(null),r=Q(null);async function o(){return r.current||(r.current=await kt()),r.current}async function l(){await o(),e([{id:Date.now(),sender:"bot",text:"Hello! How can I help you today? 您好!今天我能为您做些什么?"}])}async function c(p){var a,h,f;if(t||!p.trim())return;const u=await o();e(m=>[...m,{id:Date.now(),sender:"user",text:p}]),n(!0);try{const m={message:p};s.current&&(m.session_id=s.current);const w=new AbortController,$=setTimeout(()=>w.abort(),u.REQUEST_TIMEOUT_MS),x=Date.now(),k=await fetch(`${u.API_URL}/chat`,{method:"POST",headers:{"X-API-Key":u.API_KEY,"Content-Type":"application/json"},body:JSON.stringify(m),signal:w.signal});if(clearTimeout($),!k.ok)throw new Error(`HTTP ${k.status}: ${k.statusText}`);const z=await k.json(),A=z.thinking?((Date.now()-x)/1e3).toFixed(1):null;s.current=z.session_id;let D=null;u.SHOW_DEBUG_INFO&&(D={intent:z.intent,confidence:(a=z.confidence)==null?void 0:a.toFixed(2),entities:z.entities,language:(h=z.debug_info)==null?void 0:h.language,environment:(f=z.debug_info)==null?void 0:f.environment}),e(le=>[...le,{id:Date.now(),sender:"bot",text:z.response,thinking:z.thinking||null,thinkingDuration:A,debugInfo:D}])}catch(m){const w=r.current,$=w!=null&&w.DEBUG?`Error: ${m.message}`:"Sorry, I encountered an error. Please try again.";e(x=>[...x,{id:Date.now(),sender:"bot",text:$}])}finally{n(!1)}}return{messages:i,isTyping:t,initialize:l,sendMessage:c}}function yt({onClose:i}){return b("div",{class:"chat-header",children:[b("h1",{children:"Smart Chatbot"}),b("button",{class:"chat-close-btn",onClick:i,"aria-label":"Close chat",children:"✕"})]})}function we(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let B=we();function Ve(i){B=i}const Ge=/[&<>"']/,wt=new RegExp(Ge.source,"g"),Xe=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vt=new RegExp(Xe.source,"g"),$t={"&":"&","<":"<",">":">",'"':""","'":"'"},Je=i=>$t[i];function E(i,e){if(e){if(Ge.test(i))return i.replace(wt,Je)}else if(Xe.test(i))return i.replace(vt,Je);return i}const Tt=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function St(i){return i.replace(Tt,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const zt=/(^|[^\[])\^/g;function y(i,e){i=typeof i=="string"?i:i.source,e=e||"";const t={replace:(n,s)=>(s=typeof s=="object"&&"source"in s?s.source:s,s=s.replace(zt,"$1"),i=i.replace(n,s),t),getRegex:()=>new RegExp(i,e)};return t}function et(i){try{i=encodeURI(i).replace(/%25/g,"%")}catch{return null}return i}const ie={exec:()=>null};function tt(i,e){const t=i.replace(/\|/g,(r,o,l)=>{let c=!1,p=o;for(;--p>=0&&l[p]==="\\";)c=!c;return c?"|":" |"}),n=t.split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length{const r=s.match(/^\s+/);if(r===null)return s;const[o]=r;return o.length>=n.length?s.slice(n.length):s}).join(` `)}class se{constructor(e){T(this,"options");T(this,"rules");T(this,"lexer");this.options=e||B}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const n=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:re(n,` `)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const n=t[0],s=It(n,t[3]||"");return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:s}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(/#$/.test(n)){const s=re(n,"#");(this.options.pedantic||!s||/ $/.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const n=re(t[0].replace(/^ *>[ \t]?/gm,""),` `),s=this.lexer.state.top;this.lexer.state.top=!0;const r=this.lexer.blockTokens(n);return this.lexer.state.top=s,{type:"blockquote",raw:t[0],tokens:r,text:n}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");const o=new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);let l="",c="",p=!1;for(;e;){let u=!1;if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;l=t[0],e=e.substring(l.length);let a=t[2].split(` `,1)[0].replace(/^\t+/,x=>" ".repeat(3*x.length)),h=e.split(` `,1)[0],f=0;this.options.pedantic?(f=2,c=a.trimStart()):(f=t[2].search(/[^ ]/),f=f>4?1:f,c=a.slice(f),f+=t[1].length);let m=!1;if(!a&&/^ *$/.test(h)&&(l+=h+` `,e=e.substring(h.length+1),u=!0),!u){const x=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),k=new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),z=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),A=new RegExp(`^ {0,${Math.min(3,f-1)}}#`);for(;e;){const D=e.split(` `,1)[0];if(h=D,this.options.pedantic&&(h=h.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),z.test(h)||A.test(h)||x.test(h)||k.test(e))break;if(h.search(/[^ ]/)>=f||!h.trim())c+=` `+h.slice(f);else{if(m||a.search(/[^ ]/)>=4||z.test(a)||A.test(a)||k.test(a))break;c+=` `+h}!m&&!h.trim()&&(m=!0),l+=D+` `,e=e.substring(D.length+1),a=h.slice(f)}}r.loose||(p?r.loose=!0:/\n *\n *$/.test(l)&&(p=!0));let w=null,$;this.options.gfm&&(w=/^\[[ xX]\] /.exec(c),w&&($=w[0]!=="[ ] ",c=c.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:l,task:!!w,checked:$,loose:!1,text:c,tokens:[]}),r.raw+=l}r.items[r.items.length-1].raw=l.trimEnd(),r.items[r.items.length-1].text=c.trimEnd(),r.raw=r.raw.trimEnd();for(let u=0;uf.type==="space"),h=a.length>0&&a.some(f=>/\n.*\n/.test(f.raw));r.loose=h}if(r.loose)for(let u=0;u$/,"$1").replace(this.rules.inline._escapes,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(t){if(!/[:|]/.test(t[2]))return;const n={type:"table",raw:t[0],header:tt(t[1]).map(s=>({text:s,tokens:[]})),align:t[2].replace(/^\||\| *$/g,"").split("|"),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(` `):[]};if(n.header.length===n.align.length){let s=n.align.length,r,o,l,c;for(r=0;r({text:p,tokens:[]}));for(s=n.header.length,o=0;o/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const n=t[2].trim();if(!this.options.pedantic&&/^$/.test(n))return;const o=re(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{const o=Rt(t[2],"()");if(o>-1){const c=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);o&&(s=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),/^$/.test(n)?s=s.slice(1):s=s.slice(1,-1)),nt(t,{href:s&&s.replace(this.rules.inline._escapes,"$1"),title:r&&r.replace(this.rules.inline._escapes,"$1")},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(/\s+/g," ");if(s=t[s.toLowerCase()],!s){const r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return nt(n,s,n[0],this.lexer)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrong.lDelim.exec(e);if(!s||s[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const o=[...s[0]].length-1;let l,c,p=o,u=0;const a=s[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+o);(s=a.exec(t))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(c=[...l].length,s[3]||s[4]){p+=c;continue}else if((s[5]||s[6])&&o%3&&!((o+c)%3)){u+=c;continue}if(p-=c,p>0)continue;c=Math.min(c,c+p+u);const h=[...s[0]][0].length,f=e.slice(0,o+s.index+h+c);if(Math.min(o,c)%2){const w=f.slice(1,-1);return{type:"em",raw:f,text:w,tokens:this.lexer.inlineTokens(w)}}const m=f.slice(2,-2);return{type:"strong",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(/\n/g," ");const s=/[^ ]/.test(n),r=/^ /.test(n)&&/ $/.test(n);return s&&r&&(n=n.substring(1,n.length-1)),n=E(n,!0),{type:"codespan",raw:t[0],text:n}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=E(t[1]),s="mailto:"+n):(n=E(t[1]),s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=E(t[0]),s="mailto:"+n;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])[0];while(r!==t[0]);n=E(t[0]),t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let n;return this.lexer.state.inRawBlock?n=t[0]:n=E(t[0]),{type:"text",raw:t[0],text:n}}}}const d={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:ie,lheading:/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};d._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,d._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,d.def=y(d.def).replace("label",d._label).replace("title",d._title).getRegex(),d.bullet=/(?:[*+-]|\d{1,9}[.)])/,d.listItemStart=y(/^( *)(bull) */).replace("bull",d.bullet).getRegex(),d.list=y(d.list).replace(/bull/g,d.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+d.def.source+")").getRegex(),d._tag="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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",d._comment=/|$)/,d.html=y(d.html,"i").replace("comment",d._comment).replace("tag",d._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),d.lheading=y(d.lheading).replace(/bull/g,d.bullet).getRegex(),d.paragraph=y(d._paragraph).replace("hr",d.hr).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",")|<(?:script|pre|style|textarea|!--)").replace("tag",d._tag).getRegex(),d.blockquote=y(d.blockquote).replace("paragraph",d.paragraph).getRegex(),d.normal={...d},d.gfm={...d.normal,table:"^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},d.gfm.table=y(d.gfm.table).replace("hr",d.hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",d._tag).getRegex(),d.gfm.paragraph=y(d._paragraph).replace("hr",d.hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",d.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",d._tag).getRegex(),d.pedantic={...d.normal,html:y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",d._comment).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:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ie,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:y(d.normal._paragraph).replace("hr",d.hr).replace("heading",` *#{1,6} *[^ ]`).replace("lheading",d.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const _={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ie,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,rDelimAst:/^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:ie,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`^|~",_.punctuation=y(_.punctuation,"u").replace(/punctuation/g,_._punctuation).getRegex(),_.blockSkip=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,_.anyPunctuation=/\\[punct]/g,_._escapes=/\\([punct])/g,_._comment=y(d._comment).replace("(?:-->|$)","-->").getRegex(),_.emStrong.lDelim=y(_.emStrong.lDelim,"u").replace(/punct/g,_._punctuation).getRegex(),_.emStrong.rDelimAst=y(_.emStrong.rDelimAst,"gu").replace(/punct/g,_._punctuation).getRegex(),_.emStrong.rDelimUnd=y(_.emStrong.rDelimUnd,"gu").replace(/punct/g,_._punctuation).getRegex(),_.anyPunctuation=y(_.anyPunctuation,"gu").replace(/punct/g,_._punctuation).getRegex(),_._escapes=y(_._escapes,"gu").replace(/punct/g,_._punctuation).getRegex(),_._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,_._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])?)+(?![-_])/,_.autolink=y(_.autolink).replace("scheme",_._scheme).replace("email",_._email).getRegex(),_._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,_.tag=y(_.tag).replace("comment",_._comment).replace("attribute",_._attribute).getRegex(),_._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,_._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,_._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,_.link=y(_.link).replace("label",_._label).replace("href",_._href).replace("title",_._title).getRegex(),_.reflink=y(_.reflink).replace("label",_._label).replace("ref",d._label).getRegex(),_.nolink=y(_.nolink).replace("ref",d._label).getRegex(),_.reflinkSearch=y(_.reflinkSearch,"g").replace("reflink",_.reflink).replace("nolink",_.nolink).getRegex(),_.normal={..._},_.pedantic={..._.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:y(/^!?\[(label)\]\((.*?)\)/).replace("label",_._label).getRegex(),reflink:y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",_._label).getRegex()},_.gfm={..._.normal,escape:y(_.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\c+" ".repeat(p.length));let n,s,r,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(n=l.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length),n.raw.length===1&&t.length>0?t[t.length-1].raw+=` `:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length),s=t[t.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=` `+n.raw,s.text+=` `+n.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length),s=t[t.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=` `+n.raw,s.text+=` `+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(r=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const c=e.slice(1);let p;this.options.extensions.startBlock.forEach(u=>{p=u.call({lexer:this},c),typeof p=="number"&&p>=0&&(l=Math.min(l,p))}),l<1/0&&l>=0&&(r=e.substring(0,l+1))}if(this.state.top&&(n=this.tokenizer.paragraph(r))){s=t[t.length-1],o&&s.type==="paragraph"?(s.raw+=` `+n.raw,s.text+=` `+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n),o=r.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length),s=t[t.length-1],s&&s.type==="text"?(s.raw+=` `+n.raw,s.text+=` `+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,s,r,o=e,l,c,p;if(this.tokens.links){const u=Object.keys(this.tokens.links);if(u.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)u.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(o))!=null;)o=o.slice(0,l.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(c||(p=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(u=>(n=u.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),s=t[t.length-1],s&&n.type==="text"&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length),s=t[t.length-1],s&&n.type==="text"&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,o,p)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}if(r=e,this.options.extensions&&this.options.extensions.startInline){let u=1/0;const a=e.slice(1);let h;this.options.extensions.startInline.forEach(f=>{h=f.call({lexer:this},a),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(r=e.substring(0,u+1))}if(n=this.tokenizer.inlineText(r)){e=e.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(p=n.raw.slice(-1)),c=!0,s=t[t.length-1],s&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):t.push(n);continue}if(e){const u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return t}}class oe{constructor(e){T(this,"options");this.options=e||B}code(e,t,n){var r;const s=(r=(t||"").match(/^\S*/))==null?void 0:r[0];return e=e.replace(/\n$/,"")+` `,s?'
'+(n?e:E(e,!0))+`
`:"
"+(n?e:E(e,!0))+`
`}blockquote(e){return`
${e}
`}html(e,t){return e}heading(e,t,n){return`${e} `}hr(){return`
`}list(e,t,n){const s=t?"ol":"ul",r=t&&n!==1?' start="'+n+'"':"";return"<"+s+r+`> `+e+" `}listitem(e,t,n){return`
  • ${e}
  • `}checkbox(e){return"'}paragraph(e){return`

    ${e}

    `}table(e,t){return t&&(t=`${t}`),` `+e+` `+t+`
    `}tablerow(e){return` ${e} `}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+` `}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return"
    "}del(e){return`${e}`}link(e,t,n){const s=et(e);if(s===null)return n;e=s;let r='",r}image(e,t,n){const s=et(e);if(s===null)return n;e=s;let r=`${n}0&&h.tokens[0].type==="paragraph"?(h.tokens[0].text=$+" "+h.tokens[0].text,h.tokens[0].tokens&&h.tokens[0].tokens.length>0&&h.tokens[0].tokens[0].type==="text"&&(h.tokens[0].tokens[0].text=$+" "+h.tokens[0].tokens[0].text)):h.tokens.unshift({type:"text",text:$+" "}):w+=$+" "}w+=this.parse(h.tokens,p),u+=this.renderer.listitem(w,m,!!f)}n+=this.renderer.list(u,l,c);continue}case"html":{const o=r;n+=this.renderer.html(o.text,o.block);continue}case"paragraph":{const o=r;n+=this.renderer.paragraph(this.parseInline(o.tokens));continue}case"text":{let o=r,l=o.tokens?this.parseInline(o.tokens):o.text;for(;s+1{n=n.concat(this.walkTokens(l[c],t))}):l.tokens&&(n=n.concat(this.walkTokens(l.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){const o=t.renderers[r.name];o?t.renderers[r.name]=function(...l){let c=r.renderer.apply(this,l);return c===!1&&(c=o.apply(this,l)),c}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),n.renderer){const r=this.defaults.renderer||new oe(this.defaults);for(const o in n.renderer){const l=n.renderer[o],c=o,p=r[c];r[c]=(...u)=>{let a=l.apply(r,u);return a===!1&&(a=p.apply(r,u)),a||""}}s.renderer=r}if(n.tokenizer){const r=this.defaults.tokenizer||new se(this.defaults);for(const o in n.tokenizer){const l=n.tokenizer[o],c=o,p=r[c];r[c]=(...u)=>{let a=l.apply(r,u);return a===!1&&(a=p.apply(r,u)),a}}s.tokenizer=r}if(n.hooks){const r=this.defaults.hooks||new W;for(const o in n.hooks){const l=n.hooks[o],c=o,p=r[c];W.passThroughHooks.has(o)?r[c]=u=>{if(this.defaults.async)return Promise.resolve(l.call(r,u)).then(h=>p.call(r,h));const a=l.call(r,u);return p.call(r,a)}:r[c]=(...u)=>{let a=l.apply(r,u);return a===!1&&(a=p.apply(r,u)),a}}s.hooks=r}if(n.walkTokens){const r=this.defaults.walkTokens,o=n.walkTokens;s.walkTokens=function(l){let c=[];return c.push(o.call(this,l)),r&&(c=c.concat(r.call(this,l))),c}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return P.lex(e,t??this.defaults)}parser(e,t){return M.parse(e,t??this.defaults)}}F=new WeakSet,Te=function(e,t){return(n,s)=>{const r={...s},o={...this.defaults,...r};this.defaults.async===!0&&r.async===!1&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);const l=ce(this,F,st).call(this,!!o.silent,!!o.async);if(typeof n>"u"||n===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(n):n).then(c=>e(c,o)).then(c=>o.walkTokens?Promise.all(this.walkTokens(c,o.walkTokens)).then(()=>c):c).then(c=>t(c,o)).then(c=>o.hooks?o.hooks.postprocess(c):c).catch(l);try{o.hooks&&(n=o.hooks.preprocess(n));const c=e(n,o);o.walkTokens&&this.walkTokens(c,o.walkTokens);let p=t(c,o);return o.hooks&&(p=o.hooks.postprocess(p)),p}catch(c){return l(c)}}},st=function(e,t){return n=>{if(n.message+=` Please report this to https://github.com/markedjs/marked.`,e){const s="

    An error occurred:

    "+E(n.message+"",!0)+"
    ";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}};const N=new Ct;function v(i,e){return N.parse(i,e)}v.options=v.setOptions=function(i){return N.setOptions(i),v.defaults=N.defaults,Ve(v.defaults),v},v.getDefaults=we,v.defaults=B,v.use=function(...i){return N.use(...i),v.defaults=N.defaults,Ve(v.defaults),v},v.walkTokens=function(i,e){return N.walkTokens(i,e)},v.parseInline=N.parseInline,v.Parser=M,v.parser=M.parse,v.Renderer=oe,v.TextRenderer=ve,v.Lexer=P,v.lexer=P.lex,v.Tokenizer=se,v.Hooks=W,v.parse=v,v.options,v.setOptions,v.use,v.walkTokens,v.parseInline,M.parse,P.lex;function Et({thinking:i,duration:e}){return i?b("details",{class:"thinking-details",children:[b("summary",{children:["Drafted in ",e,"s"]}),b("div",{class:"thinking-block",children:i})]}):null}function At({message:i}){const{sender:e,text:t,thinking:n,debugInfo:s}=i,r=e==="user";let o="";return s&&(o=`Intent: ${s.intent} (${s.confidence})`,s.entities&&Object.keys(s.entities).length>0&&(o+=` | Entities: ${JSON.stringify(s.entities)}`),s.language&&(o+=` | Language: ${s.language}`),s.environment&&(o+=` | Env: ${s.environment}`)),b(q,{children:[!r&&b(Et,{thinking:n,duration:i.thinkingDuration}),b("div",{class:`message ${r?"user-message":"bot-message"}`,children:[b("div",{class:"message-avatar",children:r?"👤":"🤖"}),b("div",{class:"message-content",children:[b("div",{dangerouslySetInnerHTML:{__html:v.parse(t)}}),s&&b("div",{class:"debug-info",children:o})]})]})]})}function Dt({messages:i}){const e=Q(null);return xe(()=>{var t;(t=e.current)==null||t.scrollIntoView({behavior:"smooth"})},[i]),b("div",{class:"chat-messages",children:[b("div",{class:"messages-spacer"}),i.map(t=>b(At,{message:t},t.id)),b("div",{ref:e})]})}function Pt({active:i}){return i?b("div",{class:"typing-indicator",children:[b("div",{class:"message-avatar",children:"🤖"}),b("div",{class:"message-content typing-content",style:"display:flex; align-items:center;",children:[b("span",{style:"font-style: italic; margin-right: 6px; opacity: 0.8;",children:"Pondering"}),b("div",{class:"typing-dots",children:[b("span",{}),b("span",{}),b("span",{})]})]})]}):null}function Mt({onSend:i,disabled:e}){const t=Q(null);xe(()=>{var o;e||(o=t.current)==null||o.focus()},[e]);function n(){var l;const o=(l=t.current)==null?void 0:l.value.trim();!o||e||(i(o),t.current.value="",t.current.style.height="38px")}function s(o){o.key==="Enter"&&!o.shiftKey&&!e&&(o.preventDefault(),n())}function r(){const o=t.current;o.style.height="38px",o.scrollHeight>38&&(o.style.height=o.scrollHeight+"px")}return b("div",{class:"chat-input",children:[b("div",{class:"input-container",children:b("textarea",{ref:t,placeholder:"Type your message...",onKeyDown:s,onInput:r,disabled:e})}),b("button",{class:"send-button",onClick:n,disabled:e,"aria-label":"Send message",children:"➤"})]})}function Lt({isOpen:i,onClose:e}){const{messages:t,isTyping:n,initialize:s,sendMessage:r}=xt(),o=Q(!1);return xe(()=>{i&&!o.current&&(o.current=!0,s())},[i]),b("div",{class:`chat-panel${i?" open":""}`,children:[b(yt,{onClose:e}),b(Dt,{messages:t}),b(Pt,{active:n}),b(Mt,{onSend:r,disabled:n})]})}function Ht(){const i=window.ChatbotConfig;return i!=null&&i.DEBUG?b("div",{class:`env-badge ${i.DETECTED_ENVIRONMENT||""}`,children:["Environment: ",i.ENVIRONMENT," | API: ",i.API_URL||"(same-origin)"]}):null}function Ut(){const[i,e]=ke(!1);return b(q,{children:[b(Ht,{}),b("button",{class:"chat-widget-btn",onClick:()=>e(t=>!t),"aria-label":"Toggle chat",children:i?"✕":"💬"}),b(Lt,{isOpen:i,onClose:()=>e(!1)})]})}const Bt=":host{display:block;--chatbot-btn-bg: rgba(255, 255, 255, .2);--chatbot-btn-border: rgba(255, 255, 255, .35);--chatbot-btn-hover-bg: rgba(255, 255, 255, .28);--chatbot-panel-bg: rgba(255, 255, 255, .15);--chatbot-panel-border: rgba(255, 255, 255, .25);--chatbot-header-bg: rgba(102, 126, 234, .5);--chatbot-messages-bg: rgba(255, 255, 255, .06);--chatbot-bot-msg-bg: rgba(255, 255, 255, .65);--chatbot-bot-msg-border: rgba(255, 255, 255, .5);--chatbot-bot-msg-color: #1a1a2e;--chatbot-input-bg: rgba(255, 255, 255, .75);--chatbot-input-color: #1a1a2e;--chatbot-input-placeholder: rgba(80, 80, 120, .55);--chatbot-thinking-bg: rgba(0, 0, 0, .04);--chatbot-thinking-border: rgba(0, 0, 0, .12);--chatbot-thinking-color: rgba(0, 0, 0, .5);--chatbot-typing-color: rgba(0, 0, 0, .45);--chatbot-typing-dot-bg: rgba(0, 0, 0, .3)}*{box-sizing:border-box;margin:0;padding:0}.chat-widget-btn{position:fixed;bottom:24px;right:24px;width:60px;height:60px;background:var(--chatbot-btn-bg);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);border:1px solid var(--chatbot-btn-border);border-radius:50%;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:26px;box-shadow:0 4px 24px #0003,inset 0 1px #ffffff73;transition:transform .2s,box-shadow .2s,background .2s;z-index:9999;-webkit-user-select:none;user-select:none}.chat-widget-btn:hover{transform:scale(1.08);background:var(--chatbot-btn-hover-bg);box-shadow:0 6px 32px #00000047,inset 0 1px #ffffff80}.chat-panel{position:fixed;bottom:96px;right:24px;width:370px;height:520px;background:var(--chatbot-panel-bg);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--chatbot-panel-border);border-radius:18px;box-shadow:0 8px 40px #00000040,inset 0 1px #ffffff4d;display:flex;flex-direction:column;overflow:hidden;z-index:9998;opacity:0;pointer-events:none;transform:scale(.88) translateY(16px);transform-origin:bottom right;transition:opacity .25s ease,transform .25s cubic-bezier(.175,.885,.32,1.275)}.chat-panel.open{opacity:1;pointer-events:all;transform:scale(1) translateY(0)}.chat-header{background:var(--chatbot-header-bg);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid rgba(255,255,255,.2);color:#fff;padding:16px 20px;border-radius:18px 18px 0 0;position:relative;flex-shrink:0}.chat-header h1{font-size:1.1rem;font-weight:600;margin-bottom:2px;text-shadow:0 1px 4px rgba(0,0,0,.15)}.chat-close-btn{position:absolute;top:12px;right:14px;background:#ffffff26;border:1px solid rgba(255,255,255,.25);color:#fff;font-size:16px;cursor:pointer;opacity:.9;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:opacity .15s,background .15s}.chat-close-btn:hover{opacity:1;background:#ffffff47}.chat-messages{flex:1;padding:14px;overflow-y:auto;background:var(--chatbot-messages-bg);display:flex;flex-direction:column;gap:10px}.messages-spacer{flex:1}.chat-messages::-webkit-scrollbar{width:4px}.chat-messages::-webkit-scrollbar-track{background:transparent}.chat-messages::-webkit-scrollbar-thumb{background:#ffffff4d;border-radius:2px}.message{display:flex;align-items:flex-start;gap:8px;max-width:88%;animation:slideIn .25s ease-out}@keyframes slideIn{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.message.user-message{align-self:flex-end;flex-direction:row-reverse}.message.bot-message{align-self:flex-start}.message-avatar{width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:14px;flex-shrink:0;border:1px solid rgba(255,255,255,.3)}.user-message .message-avatar{background:#667eea99}.bot-message .message-avatar{background:#fff3}.message-content{padding:9px 13px;border-radius:14px;font-size:13.5px;line-height:1.45;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}.user-message .message-content{background:#667eeabf;border:1px solid rgba(255,255,255,.2);color:#fff;box-shadow:0 2px 10px #667eea4d}.bot-message .message-content{background:var(--chatbot-bot-msg-bg);border:1px solid var(--chatbot-bot-msg-border);color:var(--chatbot-bot-msg-color);box-shadow:0 2px 10px #00000014}.message-content ul,.message-content ol{padding-left:18px}.message-content p{margin-bottom:6px}.message-content p:last-child{margin-bottom:0}.message-content h1,.message-content h2,.message-content h3{margin-top:8px;margin-bottom:4px}.debug-info{font-size:10px;color:#6c757d;margin-top:6px;padding:5px 8px;background:#fff6;border-radius:6px;border:1px solid rgba(255,255,255,.3)}.thinking-details{align-self:flex-start;max-width:88%;font-size:12px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;color:var(--chatbot-thinking-color);background:var(--chatbot-thinking-bg);border:1px solid var(--chatbot-thinking-border);border-radius:10px;padding:6px 10px;animation:slideIn .25s ease-out}.thinking-details summary{cursor:pointer;font-style:italic;-webkit-user-select:none;user-select:none}.thinking-block{margin-top:6px;font-size:11px;opacity:.85;white-space:pre-wrap;line-height:1.4}.typing-indicator{display:flex;align-items:center;gap:5px;padding:5px 14px;color:var(--chatbot-typing-color);font-style:italic;font-size:12px;background:var(--chatbot-thinking-bg);flex-shrink:0}.typing-content{background:var(--chatbot-thinking-bg)!important;border:1px solid var(--chatbot-thinking-border)!important;color:var(--chatbot-typing-color)!important}.typing-dots{display:flex;gap:3px}.typing-dots span{width:5px;height:5px;background:var(--chatbot-typing-dot-bg);border-radius:50%;animation:typingBounce 1.4s infinite}.typing-dots span:nth-child(2){animation-delay:.2s}.typing-dots span:nth-child(3){animation-delay:.4s}@keyframes typingBounce{0%,60%,to{transform:translateY(0);opacity:.35}30%{transform:translateY(-6px);opacity:1}}.chat-input{display:flex;padding:10px 12px;border-top:1px solid rgba(255,255,255,.15);background:#ffffff1a;gap:8px;align-items:flex-end;flex-shrink:0}.input-container{flex:1}.chat-input textarea{width:100%;padding:9px 13px;line-height:1.4;height:38px;max-height:110px;border:1px solid rgba(255,255,255,.4);border-radius:18px;font-size:13.5px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;outline:none;transition:border-color .2s,background .2s;overflow-y:auto;resize:none;scrollbar-width:none;-ms-overflow-style:none;background:var(--chatbot-input-bg);color:var(--chatbot-input-color)}.chat-input textarea::-webkit-scrollbar{display:none}.chat-input textarea:focus{border-color:#ffffffb3;background:var(--chatbot-input-bg)}.chat-input textarea::placeholder{color:var(--chatbot-input-placeholder)}.send-button{width:38px;height:38px;background:#667eeacc;border:1px solid rgba(255,255,255,.25);color:#fff;border-radius:50%;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .2s,transform .1s;font-size:15px;flex-shrink:0;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}.send-button:hover{background:#667eea;transform:scale(1.06)}.send-button:disabled{background:#b4b4c866;cursor:not-allowed;transform:none}.env-badge{position:fixed;top:12px;right:12px;background:#fff3;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);padding:6px 10px;border-radius:16px;font-size:11px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;color:#fff;border:1px solid rgba(255,255,255,.3);z-index:10000}.env-badge.development{background:#90ee9040;border-color:#90ee9066}.env-badge.production{background:#ff646440;border-color:#ff646466}@media(max-width:480px){.chat-panel{width:calc(100vw - 20px);height:75vh;right:10px;bottom:86px}.chat-widget-btn{bottom:16px;right:16px;width:54px;height:54px;font-size:22px}}";class Nt extends HTMLElement{connectedCallback(){const e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=Bt,e.appendChild(t);const n=document.createElement("div");e.appendChild(n),ft(b(Ut,{}),n)}}customElements.get("smart-chatbot")||customElements.define("smart-chatbot",Nt)})();