ai12z 3.13.3 → 3.14.2

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.
Files changed (115) hide show
  1. package/dist/cjs/ai12z-bot.cjs.entry.js +107 -19
  2. package/dist/cjs/ai12z-chat-message.cjs.entry.js +17 -46
  3. package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +14 -60
  4. package/dist/cjs/index.cjs.js +1 -0
  5. package/dist/cjs/styleSheetRegistry-7aecMygn.js +175 -0
  6. package/dist/collection/components/ai12z-bot/ai12z-bot.js +32 -13
  7. package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +15 -61
  8. package/dist/collection/components/ai12z-knowledge-box/components/ai12z-chat-message.js +16 -46
  9. package/dist/collection/utils/liveagents/providers/salesforce.js +75 -6
  10. package/dist/collection/utils/styleSheetRegistry.js +169 -0
  11. package/dist/components/ai12z-bot.js +1 -1
  12. package/dist/components/ai12z-chat-message.js +1 -1
  13. package/dist/components/ai12z-chat.js +1 -1
  14. package/dist/components/ai12z-container.js +1 -1
  15. package/dist/components/ai12z-cta.js +1 -1
  16. package/dist/components/ai12z-form.js +1 -1
  17. package/dist/components/ai12z-inline-search.js +1 -1
  18. package/dist/components/ai12z-input-form.js +1 -1
  19. package/dist/components/ai12z-knowledge-box.js +1 -1
  20. package/dist/components/ai12z-search-panel.js +1 -1
  21. package/dist/components/audio-recorder.js +1 -1
  22. package/dist/components/dynamic-form.js +1 -1
  23. package/dist/components/index.js +1 -1
  24. package/dist/components/interaction-buttons.js +1 -1
  25. package/dist/components/item-list.js +1 -1
  26. package/dist/components/{p-DKxaam7U.js → p-3j2aDKYq.js} +1 -1
  27. package/dist/components/{p-BP8ig03d.js → p-AQ1MS6Ps.js} +1 -1
  28. package/dist/components/p-B9IJbo4G.js +1 -0
  29. package/dist/components/{p-DsZWeAcM.js → p-BWMhH2R1.js} +1 -1
  30. package/dist/components/{p-5UYwpNzl.js → p-BaXs0IIw.js} +1 -1
  31. package/dist/components/{p-Gr6Q2s96.js → p-Bnj1LjUJ.js} +1 -1
  32. package/dist/components/p-BwpiW24r.js +1 -0
  33. package/dist/components/{p-Bo3Ig8oX.js → p-BwqXbNCx.js} +1 -1
  34. package/dist/components/{p-D2nUK4Pa.js → p-COqFEHJ7.js} +1 -1
  35. package/dist/components/{p-DA32xa7d.js → p-Ci85xHWQ.js} +1 -1
  36. package/dist/components/{p-DUaZgAhA.js → p-CrfXJRIo.js} +1 -1
  37. package/dist/components/{p-DJ68HDol.js → p-DkRAkHLI.js} +2 -2
  38. package/dist/components/{p-ha1wIlZ-.js → p-Dubjoiw6.js} +1 -1
  39. package/dist/components/{p-C2wKkcYa.js → p-DvtUY5FW.js} +1 -1
  40. package/dist/components/{p-J--erGbY.js → p-dQEvevXk.js} +1 -1
  41. package/dist/{library/p-DAGa-uHD.js → components/p-g36mIk7k.js} +1 -1
  42. package/dist/components/p-m0Ed3g6I.js +1 -0
  43. package/dist/components/p-mBjDeFh_.js +1 -0
  44. package/dist/components/{p-q7YWDP9B.js → p-pOVc-eI8.js} +1 -1
  45. package/dist/components/{p-BCJzelr9.js → p-qwKoi5kn.js} +1 -1
  46. package/dist/components/{p-CKAp10SJ.js → p-xTOLReQF.js} +1 -1
  47. package/dist/components/privacy-modal.js +1 -1
  48. package/dist/components/search-results-page.js +1 -1
  49. package/dist/esm/ai12z-bot.entry.js +115 -27
  50. package/dist/esm/ai12z-category_2.entry.js +3 -3
  51. package/dist/esm/ai12z-chat-message.entry.js +17 -46
  52. package/dist/esm/ai12z-chat_2.entry.js +8 -8
  53. package/dist/esm/ai12z-container.entry.js +3 -3
  54. package/dist/esm/ai12z-cta.entry.js +4 -4
  55. package/dist/esm/ai12z-form.entry.js +2 -2
  56. package/dist/esm/ai12z-inline-search.entry.js +2 -2
  57. package/dist/esm/ai12z-knowledge-box.entry.js +18 -64
  58. package/dist/esm/ai12z-search-panel.entry.js +1 -1
  59. package/dist/esm/chat-avatar_6.entry.js +1 -1
  60. package/dist/esm/{ctaHelpers-BhM8KbEY.js → ctaHelpers-DrH6S5iU.js} +1 -1
  61. package/dist/esm/dynamic-form.entry.js +1 -1
  62. package/dist/esm/{index-BQKLwW-C.js → index-VWr-8RG8.js} +1 -1
  63. package/dist/esm/index.js +10 -9
  64. package/dist/esm/item-list.entry.js +2 -2
  65. package/dist/esm/{keyboard-shortcuts-Bd3LDe9j.js → keyboard-shortcuts-BhKv64FZ.js} +2 -2
  66. package/dist/esm/{parseHelper-9rP0JS7J.js → parseHelper-kOGOndOe.js} +1 -1
  67. package/dist/esm/{processCarouselData-Bf2pDFsV.js → processCarouselData-DX152a4X.js} +1 -1
  68. package/dist/esm/{reCaptchaHelpers-CUcgfdqX.js → reCaptchaHelpers-DUpCzUFb.js} +1 -1
  69. package/dist/esm/search-results-page.entry.js +4 -4
  70. package/dist/esm/{socket-service-B1OMbkCM.js → socket-service-D_h5x8Gr.js} +1 -1
  71. package/dist/esm/styleSheetRegistry-Bfi9VkqK.js +172 -0
  72. package/dist/esm/{surveyHelpers-CvrZlir1.js → surveyHelpers-D-00eWjv.js} +1 -1
  73. package/dist/esm/{utils-BTLjNTwP.js → utils-DK_Yhmpx.js} +1 -1
  74. package/dist/library/index.esm.js +1 -1
  75. package/dist/library/library.esm.js +1 -1
  76. package/dist/library/{p-cd764f70.entry.js → p-11c1f91d.entry.js} +1 -1
  77. package/dist/library/{p-806bfb3d.entry.js → p-1d382046.entry.js} +1 -1
  78. package/dist/library/{p-0641ba91.entry.js → p-252bb713.entry.js} +2 -2
  79. package/dist/library/p-25a678ca.entry.js +1 -0
  80. package/dist/library/p-53edf210.entry.js +1 -0
  81. package/dist/library/p-646a7eae.entry.js +1 -0
  82. package/dist/library/p-675d0243.entry.js +1 -0
  83. package/dist/library/{p-60d5d99f.entry.js → p-6ea05db1.entry.js} +1 -1
  84. package/dist/library/{p-7f0e306c.entry.js → p-7154a204.entry.js} +1 -1
  85. package/dist/library/{p-07f11cb8.entry.js → p-72a5eaf2.entry.js} +1 -1
  86. package/dist/library/{p-2d262192.entry.js → p-8f238b3f.entry.js} +1 -1
  87. package/dist/library/p-9cffb6fa.entry.js +1 -0
  88. package/dist/library/{p-y3Go1NSi.js → p-BCkDiHIY.js} +1 -1
  89. package/dist/{components/p-BhV62IFF.js → library/p-By1gJKXA.js} +1 -1
  90. package/dist/library/{p-Bbow4UZX.js → p-C0wNDqKO.js} +1 -1
  91. package/dist/library/p-C3yxqbFh.js +1 -0
  92. package/dist/library/p-CwZwG6gL.js +1 -0
  93. package/dist/library/{p-D5m1leH0.js → p-D1IPrgJe.js} +3 -3
  94. package/dist/library/{p-NAKC5NP9.js → p-KSKiM1sy.js} +1 -1
  95. package/dist/library/{p-C1eU4fpM.js → p-TJuczvVq.js} +1 -1
  96. package/dist/library/{p-CnadO0kA.js → p-ZyOWOLs5.js} +1 -1
  97. package/dist/library/{p-94bf0c7f.entry.js → p-cbfc9f73.entry.js} +1 -1
  98. package/dist/library/{p-014d5664.entry.js → p-d8506e43.entry.js} +1 -1
  99. package/dist/library/{p-BZ_koFpE.js → p-n8ydBHE4.js} +1 -1
  100. package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +1 -0
  101. package/dist/types/components/ai12z-knowledge-box/ai12z-knowledge-box.d.ts +0 -3
  102. package/dist/types/components/ai12z-knowledge-box/components/ai12z-chat-message.d.ts +0 -2
  103. package/dist/types/utils/liveagents/providers/salesforce.d.ts +2 -0
  104. package/dist/types/utils/styleSheetRegistry.d.ts +40 -0
  105. package/package.json +2 -2
  106. package/dist/components/p-B3lv_O-6.js +0 -1
  107. package/dist/components/p-CLdlCTTp.js +0 -1
  108. package/dist/components/p-DT0Uarfg.js +0 -1
  109. package/dist/components/p-zVXADzTq.js +0 -1
  110. package/dist/library/p-29cd4edc.entry.js +0 -1
  111. package/dist/library/p-6f3727d3.entry.js +0 -1
  112. package/dist/library/p-83a71da9.entry.js +0 -1
  113. package/dist/library/p-DoBD_KPG.js +0 -1
  114. package/dist/library/p-d3a2acee.entry.js +0 -1
  115. package/dist/library/p-dc131a5c.entry.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e,E as t,h as a,d as s}from"./p-BNpVu1WU.js";import{i,O as r}from"./p-y3Go1NSi.js";import{S as o}from"./p-CkF7XHob.js";const c=class{constructor(a){e(this,a),this.dataKey=t.DATA_KEY||"",this.dataMode=t.DATA_MODE||"prod",this.categorize=!0,this.placeholder="AI Search...",this.redirectUrl="/search",this.query="",this.searchResults=[],this.hideAllButtons=!1,this.handleKeyDown=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleFormSubmit(e))}}componentWillLoad(){i("https://cdn.ai12z.net/assets/bot/v2/tailwind.min.css",this.el)}async fetchSearchResults(){const e=await r(this.dataKey,this.dataMode,this.query),t=e.docs?[...e.docs]:[];this.searchResults=[],setTimeout((()=>{this.searchResults=t}),0)}async handleInput(e){this.query=e.target.value,this.query.trim().length>3?this.fetchSearchResults():this.searchResults=[]}async handleFormSubmit(e){e.preventDefault();const t=new URLSearchParams({searchText:this.query,page:"1"}).toString();window.location.href=`${this.redirectUrl}?${t}`}render(){var e;return a("div",{key:"4db66cb3af053593b6f49cfd279c62133b5bc59b",class:"flex flex-col rounded-2xl relative",id:"searchPanel"},a("form",{key:"c1b63bac4323c03d968d0a333a6263789065306f",class:"flex flex-col rounded-2xl p-2.5 search-container",onSubmit:e=>this.handleFormSubmit(e),id:"searchForm"},a("div",{key:"241e155dc1090bdf4cab2ff22208d56554cdf2aa",class:"flex"},!this.hideAllButtons&&a("div",{key:"289e07a334a25d82e3318a411732471cb82c6f4a",class:"w-11/12 mt-1 search-input-container"},a("label",{key:"19a47260434e8512a24475d240e831be5c55e185",htmlFor:"search-input",class:"sr-only"},"Your message"),a("input",{key:"a4e7ccc16b5e207eb4d8392916b295370b3f26d8",id:"search-input",class:`bg-inherit w-full outline-none resize-none ${(null===(e=this.searchResults)||void 0===e?void 0:e.length)>0?"input-border":""} search-input`,ref:e=>{this.searchInputElem=e,null==e||e.focus()},placeholder:this.placeholder,value:this.query,onInput:e=>this.handleInput(e),onKeyDown:this.handleKeyDown,onFocus:()=>{this.el.shadowRoot.querySelector("#searchPanel").classList.add("input-focus-color")},onBlur:()=>this.el.shadowRoot.querySelector("#searchPanel").classList.remove("input-focus-color")})),a("div",{key:"388956b4c95944b10a114b7c7049e0a34d73169b",class:"icons flex items-center "+(this.hideAllButtons?"w-full":"w-auto")},a("span",{key:"f80bf5faa8e37155b8ee157abdf38472eb7fa253",class:"w-full mic-icon"},a("audio-recorder",{key:"edb5905ea21aa922b9981dd950ab07643a1af54a","component-type":"search",onStartRecord:()=>{this.hideAllButtons=!0},onStopRecord:()=>{this.hideAllButtons=!1},onSendTranscript:e=>{setTimeout((()=>{if(this.searchInputElem){this.searchInputElem.value=e.detail,this.query=e.detail;const t=this.el.shadowRoot.querySelector("#search-input");if(t){const a=new Event("input",{bubbles:!0});Object.defineProperty(a,"target",{writable:!1,value:t}),t.value=e.detail,this.handleInput(a),t.dispatchEvent(a)}}}),500)},style:{width:"100%"}})),a("div",{key:"71f504092ad5d289f5013b113bcba7c98508754e",class:"search-icon"},a("button",{key:"cd7a2a00747106a42d4a6ee58525d6ace1eb79fc",id:"send-message-button",class:"text-white transition rounded-lg p-1.5 self-center search-btn-bg-color",onClick:e=>this.handleFormSubmit(e),"aria-label":"Search"},a("svg",{key:"9719aae24e90a64d202c6eacaf7d0512d304ed72",xmlns:"http://www.w3.org/2000/svg",class:"w-6 h-6",viewBox:"0 0 24 24"},a("path",{key:"8ea5557a92714c394f103551dbe1cb3a1da8e1c7",fill:"currentColor",d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 17 9.5 6.5 6.5 0 1 0 10.5 16a6.471 6.471 0 0 0 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-5 0A4.5 4.5 0 1 1 14 9.5 4.5 4.5 0 0 1 10.5 14z"})))))),this.searchResults&&this.searchResults.length>0&&a("div",{key:"4e9ae924150fb065d2e703f09df47d15f7b782be",class:"rounded-b-2xl overflow-hidden search-results"},this.categorize&&a("ai12z-category",{key:"ee52f905f7e06abd6f5b55f2680fb71d4b98ef27",categoryList:this.searchResults,linkTarget:"_blank"}),!this.categorize&&a(o,{key:"4a03deb24440e25d5532fb038565aa4d89398385",results:this.searchResults}))))}get el(){return s(this)}};c.style=":host{display:block;width:100%;font-family:var(--ai12z-font-family);font-size:var(--ai12z-font-size)}.input-focus-color{border:1px solid var(--ai12z-search-panel-focus-color)}.search-btn-bg-color{background-color:var(--ai12z-search-panel-button-bgcolor)}.input-border{border-bottom:1px solid var(--ai12z-search-panel-input-border-color)}.search-container{background-color:var(--ai12z-search-panel-bg)}.search-icon svg{width:20px;height:20px;color:var(--ai12z-search-panel-icon-color);}.search-input::-moz-placeholder{color:#999}.search-input::placeholder{color:#999}.search-results{width:100%;text-align:left}.cta-search-results{border-top-width:1px;border-bottom-width:0px;border-color:rgb(243 244 246)}.cta-search-results-list{position:relative;padding-bottom:1.25rem;padding-top:1.25rem}.cta-search-results-list:hover{background-color:var(--ai12z-hover-bg-color)}.cta-search-container{margin-left:auto;margin-right:auto;display:flex;max-width:56rem;justify-content:space-between;-moz-column-gap:1.5rem;column-gap:1.5rem}.cta-search-container-two{display:flex;min-width:0px;-moz-column-gap:1rem;column-gap:1rem}.cta-search-container-three{min-width:0px;flex:1 1 auto}.cta-search-text{font-weight:600;line-height:1.5rem;font-size:var(--ai12z-search-result-title-font-size);color:var(--ai12z-search-result-title-color)}.cta-search-text-position{position:absolute;left:0px;right:0px;top:-1px;bottom:0px}.cta-search-description{margin-top:0.25rem;display:flex;font-size:var(--ai12z-search-result-description-font-size);line-height:1rem;line-height:1.25rem;color:var(--ai12z-search-result-description-color)}.cta-search-list-arrow{display:flex;align-items:center;flex-shrink:0;-moz-column-gap:1rem;column-gap:1rem}.custom-icon-width{width:4rem}.results-icon svg{width:1.5rem;height:1.5rem}";export{c as ai12z_search_panel}
@@ -1 +0,0 @@
1
- import{r as i,a as t,E as s,e as o,h as e,f as a,d as l}from"./p-BNpVu1WU.js";import{O as n,i as h,I as r,K as d,o as c}from"./p-y3Go1NSi.js";import{S as u}from"./p-CkF7XHob.js";import{S as v}from"./p-BZ_koFpE.js";import{b as p}from"./p-odmyXuxx.js";import{e as m}from"./p-Bbow4UZX.js";import{d as g,l as f,a as b,f as w,b as y,r as x,v as k,c as z,g as C,u as S,i as A,e as T,h as M,j,k as I,m as E,n as N}from"./p-C1eU4fpM.js";import{a as O}from"./p-BQ6J3hmg.js";import"./p-SyQT2Pr3.js";const H=class{constructor(o){i(this,o),this.errored=t(this,"errored",7),this.buttonClicked=t(this,"buttonClicked",7),this.messageSent=t(this,"messageSent",7),this.messageReceived=t(this,"messageReceived",7),this.open=t(this,"open",7),this.close=t(this,"close",7),this.stateChanged=t(this,"stateChanged",7),this.clearResults=t(this,"clearResults",7),this.clearInput=t(this,"clearInput",7),this.stopStream=t(this,"stopStream",7),this.startStream=t(this,"startStream",7),this.survey=t(this,"survey",7),this.formSubmitted=t(this,"formSubmitted",7),this.streamResponse=t(this,"streamResponse",7),this.endResponse=t(this,"endResponse",7),this.isElementAvailable=t(this,"isElementAvailable",7),this.test="123",this.cdnPath="https://cdn.ai12z.net/assets/cta",this.dirty=!1,this.isSubmitted=!1,this.pButtonText="Ask AI",this.pPlaceholder="AI search...",this.pHelpText="Enter text to get started",this.pNoResultsText="No results found",this.errorMsg="Error please try again!",this.pheading="",this.isCta=!1,this.dataKey=s.DATA_KEY||"",this.dataMode=s.DATA_MODE||"prod",this.options={},this.excludeTags=[],this.includeTags=[],this.ctaSettings={},this.showModal=!1,this.questionCounter=0,this.formData={search:"",displayText:""},this.searchResults=[],this.error=null,this.conversationId=null,this.canRender=!0,this.chatHistory=[],this.isChat=!1,this.aiMessageId=null,this.announceMessage="",this.showHistory=!1,this.conversationHistory=[],this.isRendered=!1,this.sendSurveyData=async i=>{this.sendJSON("This JSON is from a form submission"+i.results,i.completeText)},this.detectTextByLang=()=>{const i=g();f(i).then((i=>{this.pButtonText=i.button_text,this.pPlaceholder=i.placeholder_text,this.pHelpText=i.help_text,this.pNoResultsText=i.results_text,this.errorMsg=i.error_message})).catch((i=>{console.error("Error loading language file:",i)}))},this.handleSubmit=async(i,t,s,o,e,a={isHide:!1})=>{var l,h,r,d,c,u;if("history"!==s){if("ask-ai"===s&&(this.questionCounter++,y("ai12z-cta-data",{qCounter:this.questionCounter})),this.dirty=!0,this.isSubmitted=!0,null==i||i.preventDefault(),this.formData=Object.assign(Object.assign({},this.formData),{search:t}),0===this.chatHistory.length&&(null===(h=this.ctaSettings)||void 0===h?void 0:h.autoResetTimer)>0&&"ask-ai"===s&&this.startTimer(),o||"follow-up"!==s||(this.chatHistory=[],this.isChat=!1,this.showHistory=!1,this.displayMessage()),"survey"===s&&(this.chatHistory=x(this.chatHistory)),k(this.formData.search,e))return this.isSubmitted=!1,void this.stateChanged.emit(!1);try{let i={answer:"",formModel:null,insight_id:null};if("ask-ai"===s||this.isChat){this.socketService||(this.socketService=v.createInstance(this.dataMode,this.dataKey),await this.socketService.waitForConnection()),this.isChat=!0,this.chatHistory.push(z(""!==this.formData.displayText?this.formData.displayText:this.formData.search,"user","success",e)),this.chatHistory[this.chatHistory.length-1].isHide=null!==(r=a.isHide)&&void 0!==r&&r,this.aiMessageId="",this.thumbsId=C(),this.chatHistory.push(z('<div class="animate-ping">...</div>',"ai","pending",void 0,this.aiMessageId)),this.imgFiles=e&&e.length>0?e:[],this.chatHistory=x(this.chatHistory),i.answer=(null===(d=this.ctaSettings)||void 0===d?void 0:d.maxQuestion)>0&&this.questionCounter>(null===(c=this.ctaSettings)||void 0===c?void 0:c.maxQuestion)?this.ctaSettings.msgLimit:null==i?void 0:i.answer;const t=z(null==i?void 0:i.answer,"ai","success",void 0,this.aiMessageId,null==i?void 0:i.insight_id,this.thumbsId,null==i?void 0:i.formModel);this.chatHistory=S(this.chatHistory,t),requestAnimationFrame((()=>{var i;A(this.questionCounter,null===(i=this.ctaSettings)||void 0===i?void 0:i.maxQuestion)?this.startStream.emit({search:this.formData.search,maxQuestion:!0,chatData:this.chatHistory[this.chatHistory.length-1]}):this.startStream.emit({search:this.formData.search,imgFiles:this.imgFiles})}))}else(null===(u=this.ctaSettings)||void 0===u?void 0:u.autoSearch)&&(i=await n(this.dataKey,this.dataMode,this.formData.search),this.displaySearchResults(i))}catch(i){console.error(i),this.error=i}finally{this.isSubmitted=!1,this.stateChanged.emit(!1),this.formData.displayText=""}}else{this.showHistory=!0,this.isChat=!1;const i=b("ai12z-cta-history");this.conversationHistory=w(i,null===(l=this.ctaSettings._id)||void 0===l?void 0:l.$oid,this.ctaSettings.pId)}},this.displaySearchResults=i=>{this.searchResults=i.docs,this.isSubmitted=!1,this.showHistory=!1}}async openModal(){var i;this.showModal=!0,this.dirty=!1,o.setActive("cta"),(null===(i=this.ctaSettings)||void 0===i?void 0:i.clearMemory)&&this.clearSearchHistory(),requestAnimationFrame((()=>{var i;this.el.shadowRoot.querySelector("ai12z-input-form").querySelector("textarea").focus(),this.el.shadowRoot.querySelector(".modal-wrapper").classList.add("show-modal"),document.querySelector("ai12z-bot")&&(null===(i=document.querySelector("ai12z-bot").shadowRoot.querySelector(".layout"))||void 0===i||i.classList.add("hide-chatbot"))})),this.open.emit(),this.setLocalData(),this.isElementAvailable.emit(!0)}setLocalData(){y("ai12z-cta-data",{qCounter:this.questionCounter})}async sendMessage(i,t){this.formData.search=i,this.formData.displayText=null!=t?t:i,this.handleSubmit(null,this.formData.search,"ask-ai",!1,null),this.messageSent.emit(i)}async sendJSON(i,t){this.formData.search=JSON.stringify(i),this.formData.displayText=t,this.handleSubmit(null,this.formData.search,"ask-ai",!1,null),this.messageSent.emit(i)}async closeModal(){var i;this.el.shadowRoot.querySelector(".modal-wrapper").classList.remove("show-modal"),document.querySelector("ai12z-bot")&&(null===(i=document.querySelector("ai12z-bot").shadowRoot.querySelector(".layout"))||void 0===i||i.classList.remove("hide-chatbot")),setTimeout((()=>{var i;this.showModal=!1,this.stopStream.emit({socketId:null===(i=this.socketService)||void 0===i?void 0:i.getSocketId()}),this.socketService=null,this.close.emit(),T(this.timer)}),300)}handleKeyDown(i){var t;this.showModal&&((i.metaKey||i.ctrlKey)&&"k"===i.key&&(i.preventDefault(),this.openModal()),"Escape"===i.key&&(i.preventDefault(),(null===(t=this.ctaSettings)||void 0===t?void 0:t.allowClose)?this.closeModal():this.announce("This dialog cannot be closed with Escape. Please complete your interaction.")))}surveyHandler(i){if("button"===i.detail.type)this.formData.displayText="",this.handleSubmit(null,i.detail.results,i.detail.type,!1,null),this.buttonClicked.emit(i.detail.results);else if("carousel"===i.detail.type)this.chatHistory=[...this.chatHistory,i.detail.results];else if("update"===i.detail.type){const t=this.chatHistory.findIndex((t=>t.id===i.detail.results.id));this.chatHistory=S(this.chatHistory,i.detail.results,t)}else if("sendMessage"===i.detail.type)i.detail.results.length>1?this.sendMessage(i.detail.results[0],i.detail.results[1]):this.sendMessage(i.detail.results[0]);else if("sendJSON"===i.detail.type)this.sendJSON(i.detail.results[0],i.detail.results[1]);else{const t=i.detail,s=`This JSON is from a form submission [${t.keyName}]: ${JSON.stringify(t.results,null,2)}. There is no need to show the form [${t.keyName}] again.`;this.formData.search=s,this.formData.displayText=t.completeText,this.handleSubmit(null,this.formData.search,"ask-ai",!1,null,{isHide:!0})}}formSubmittedHandler(i){i.stopPropagation(),this.formSubmitted.emit(i.detail.data)}async componentWillLoad(){h("https://cdn.ai12z.net/assets/bot/v2/tailwind.min.css",this.el),O("cta",this.dataKey,this.dataMode),await this.configCtaSettings();const i=this.el.children;let t=i&&i.length>0;if(this.detectTextByLang(),t)for(var s=0;s<i.length;s++)"cta"!==i[s].tagName.toLowerCase()&&"cta"!==i[s].getAttribute("slot")||(this.isCta=!0)}onDataKeyChange(i){O("cta",this.dataKey,this.dataMode)}onDataModeChange(i){O("cta",this.dataKey,this.dataMode)}clearSearchHistory(){this.searchResults&&this.searchResults.length>0&&(this.searchResults.splice(0,this.searchResults.length),this.searchResults=[...this.searchResults]),this.chatHistory=[],this.isChat=!1,this.clearInput.emit(!1),this.clearResults.emit(!1)}handleOutsideClick(i){var t;M(i,"modal-wrapper")&&((null===(t=this.ctaSettings)||void 0===t?void 0:t.allowClose)?this.closeModal():this.announce("This dialog cannot be closed by clicking outside. Please complete your interaction."))}announce(i){this.announceMessage=i,setTimeout((()=>{this.announceMessage=""}),1e3)}startTimer(){var i;this.timer=j((()=>{this.questionCounter=0,y("ai12z-cta-data",{qCounter:this.questionCounter})}),null===(i=this.ctaSettings)||void 0===i?void 0:i.autoResetTimer)}connectedCallback(){r(this.dataKey,this.dataMode).then((i=>{this.canRender=i}))}async configCtaSettings(){d({apiKey:this.dataKey,configId:this.configId,configType:"search"},this.dataMode).then((i=>{var t,s,o,e,a,l,n,h,r,d,c,u,v;if(i){if(this.ctaSettings=i,(null===(t=null==i?void 0:i.v3)||void 0===t?void 0:t.siteKey)?m(i._id,i.v3.siteKey,"search",this.dataKey,this.dataMode,(i=>{this.errored.emit(i)})).then((i=>{i&&(this.isRendered=!0)})).catch((i=>{console.error("Recaptcha verification failed:",i),this.isRendered=!1})):this.isRendered=!0,void 0===(null===(s=this.ctaSettings)||void 0===s?void 0:s.autoSearch)&&(this.ctaSettings.autoSearch=!0),void 0===(null===(o=this.ctaSettings)||void 0===o?void 0:o.allowClose)&&(this.ctaSettings.allowClose=!0),void 0!==(null===(e=this.options)||void 0===e?void 0:e.allowClose)&&(this.ctaSettings.allowClose=this.options.allowClose),void 0===(null===(a=this.ctaSettings)||void 0===a?void 0:a.clearMemory)&&(this.ctaSettings.clearMemory=!0),void 0===(null===(l=this.ctaSettings)||void 0===l?void 0:l.enableMobileView)&&(this.ctaSettings.enableMobileView=!0),void 0===(null===(n=this.ctaSettings)||void 0===n?void 0:n.categorize)&&(this.ctaSettings.categorize=!0),this.ctaSettings.customCSS&&this.insertCustomCSS(this.ctaSettings.customCSS),this.ctaSettings.customJS&&I(this.el.shadowRoot,this.ctaSettings.customJS),(null===(h=this.ctaSettings.welcome)||void 0===h?void 0:h.styles)&&this.insertCustomCSS(this.ctaSettings.welcome.styles),(null===(r=this.ctaSettings.welcome)||void 0===r?void 0:r.scripts)&&I(this.el.shadowRoot,this.ctaSettings.welcome.scripts),(null!==(d=this.ctaSettings.helpText)&&void 0!==d?d:null===(c=this.ctaSettings.welcome)||void 0===c?void 0:c.message)&&(this.pHelpText=null!==(u=this.ctaSettings.helpText)&&void 0!==u?u:null===(v=this.ctaSettings.welcome)||void 0===v?void 0:v.message),this.ctaSettings.theme){let i="";i="custom"!==this.ctaSettings.theme?`${this.cdnPath}/v2/themes/theme-${this.ctaSettings.theme}.css`:this.ctaSettings.customTheme;const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("href",i),document.head.appendChild(t)}else{const i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("href",`${this.cdnPath}/v2/themes/theme-default.css`),document.head.appendChild(i)}this.ctaSettings.textareaAtBottom="bottom"===this.ctaSettings.inputFieldPosition}})).catch((i=>{console.error("Error loading configuration:",i)}))}insertCustomCSS(i){E(this.el.shadowRoot,i)}componentDidLoad(){p(this.el),o.register("cta",this)}deleteChatHistoryHandler(i){var t,s,o;const e=b("ai12z-cta-history"),a=w(e,null===(s=null===(t=this.ctaSettings)||void 0===t?void 0:t._id)||void 0===s?void 0:s.$oid,this.ctaSettings.pId),l=e.filter((t=>!a.includes(t)||t.conversationId!==i.detail.conversationId));localStorage.setItem("ai12z-cta-history",JSON.stringify(l)),this.conversationHistory=w(l,null===(o=this.ctaSettings._id)||void 0===o?void 0:o.$oid,this.ctaSettings.pId)}chatClickHandler(i){i.detail.length>0&&(this.chatHistory=i.detail,this.isChat=!0,requestAnimationFrame((()=>{var i;const t=null===(i=this.el.shadowRoot)||void 0===i?void 0:i.querySelector("ai12z-chat");null==t||t.hydrateMessagesFromState()}))),this.showHistory=!1}defaultTemplate(){const i=N();return e("button",{type:"button",class:"flex ring-1 ring-slate-900/10 hover:ring-slate-300 focus:outline-none focus:ring-2 focus:ring-sky-500 shadow-sm custom-button","aria-label":"Open AI Search"},e("svg",{width:"24",height:"24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"flex-none text-slate-300 dark:text-slate-400"},e("path",{d:"m19 19-3.5-3.5"}),e("circle",{cx:"11",cy:"11",r:"6"})),e("span",{class:"flex-auto"},this.pPlaceholder),e("kbd",{class:"font-sans font-semibold text-slate-400"},e("abbr",{title:"Command",class:"no-underline text-slate-400"},i&&e("span",null,"⌘"),!i&&e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",class:"inline w-4 h-4 mb-1"},e("path",{d:"M3.5 2A1.5 1.5 0 0 0 2 3.5v2A1.5 1.5 0 0 0 3.5 7h2A1.5 1.5 0 0 0 7 5.5v-2A1.5 1.5 0 0 0 5.5 2h-2ZM3.5 9A1.5 1.5 0 0 0 2 10.5v2A1.5 1.5 0 0 0 3.5 14h2A1.5 1.5 0 0 0 7 12.5v-2A1.5 1.5 0 0 0 5.5 9h-2ZM9 3.5A1.5 1.5 0 0 1 10.5 2h2A1.5 1.5 0 0 1 14 3.5v2A1.5 1.5 0 0 1 12.5 7h-2A1.5 1.5 0 0 1 9 5.5v-2ZM10.5 9A1.5 1.5 0 0 0 9 10.5v2a1.5 1.5 0 0 0 1.5 1.5h2a1.5 1.5 0 0 0 1.5-1.5v-2A1.5 1.5 0 0 0 12.5 9h-2Z"}))),"K"))}displayMessage(){var i,t,s,o,a,l;let n=null;return this.error?n=e("p",{class:"text-red-500"},this.errorMsg):this.isSubmitted?n=e("svg",{class:"animate-spin -ml-1 mr-3 h-5 w-5 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})):(this.dirty&&(n=null!==(t=null===(i=this.ctaSettings)||void 0===i?void 0:i.noResultsText)&&void 0!==t?t:this.pNoResultsText),n=null!==(o=null===(s=this.ctaSettings)||void 0===s?void 0:s.helpText)&&void 0!==o?o:this.pHelpText),(null===(a=this.searchResults)||void 0===a?void 0:a.length)>0||(null===(l=this.chatHistory)||void 0===l?void 0:l.length)>0?null:"string"==typeof n?e("div",{class:"flex prose custom-msg",innerHTML:n}):e("p",{class:"custom-msg flex"},n)}render(){var i,t,s,o,l,n,h,r,d,v,p,m,g,f,b,w,y,x,k,z,C,S,A,T,M,j,I,E,N,O,H,B,F,D,J,q,K,L,U,Z,$,R,P;const _={width:(null===(i=this.ctaSettings)||void 0===i?void 0:i.enableMobileView)?"100%":null===(t=this.ctaSettings)||void 0===t?void 0:t.dialogWidth,"max-width":null===(s=this.ctaSettings)||void 0===s?void 0:s.dialogMaxWidth,"min-height":this.chatHistory.length>0?"unset":null!==(l=null===(o=this.ctaSettings)||void 0===o?void 0:o.dialogMinHeight)&&void 0!==l?l:"300px","margin-top":null!==(h=null===(n=this.ctaSettings)||void 0===n?void 0:n.dialogTopMargin)&&void 0!==h?h:"5rem"};return this.canRender?e(a,null,this.isRendered&&e("div",{class:"custom-container",onClick:()=>this.openModal()},!this.isCta&&this.defaultTemplate(),this.isCta&&e("slot",{name:"cta"})),e("div",{class:{"bg-smoke-light":!0,"modal-wrapper":!0,"custom-model":!0,"hide-dialog":!this.showModal},onClick:i=>this.handleOutsideClick(i),role:"dialog","aria-modal":"true","aria-label":"Search modal","aria-describedby":(null===(r=this.ctaSettings)||void 0===r?void 0:r.allowClose)?void 0:"modal-close-info"},e("div",{"aria-live":"assertive","aria-atomic":"true",class:"sr-only"},this.announceMessage),!(null===(d=this.ctaSettings)||void 0===d?void 0:d.allowClose)&&e("div",{id:"modal-close-info",class:"sr-only"},"This dialog cannot be closed with Escape key or by clicking outside. Please complete your interaction."),e("div",{class:"skip-links"},e("a",{class:"skip-link",href:"#main-content",onClick:i=>{var t;i.preventDefault();const s=null===(t=this.el.shadowRoot.querySelector("ai12z-chat"))||void 0===t?void 0:t.shadowRoot.querySelector("#main-content");s&&s.focus()}},"Skip to main content"),e("a",{class:"skip-link",href:"#searchInput",onClick:i=>{i.preventDefault();const t=this.el.shadowRoot.querySelector("ai12z-input-form").querySelector("#searchInput");t&&t.focus()}},"Skip to message input")),e("div",{class:"overscroll-contain modal-content-wrapper model-content modal-position",style:_},this.chatHistory.length>0&&e("span",{class:"btn-left"},e("button",{title:"New Chat","aria-label":"New Chat",onClick:()=>{this.chatHistory=[],this.isChat=!1,this.displayMessage()},class:"modal-home"},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},e("path",{d:"M21 12a9 9 0 1 1-3-6.7"}),e("polyline",{points:"21 3 21 9 15 9"})))),e("span",{class:"btn-position"},(null===(v=this.ctaSettings)||void 0===v?void 0:v.allowClose)&&e("button",{onClick:()=>this.closeModal(),class:"modal-close","aria-label":"Close AI Search",tabindex:"0",title:"Close AI Search"},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"},e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e("div",{class:"modal-body flex flex-col"},e("h1",{class:"model-heading"},null!==(m=null===(p=this.ctaSettings)||void 0===p?void 0:p.heading)&&void 0!==m?m:this.pheading),e("div",{class:"cta-layout flex flex-col flex-1 "+((null===(g=this.ctaSettings)||void 0===g?void 0:g.textareaAtBottom)?"reverse":"normal")},e("div",{class:"input-wrapper"},e("ai12z-input-form",{onAction:async i=>{const{value:t,type:s,followUp:o,imgFiles:e}=i.detail;await this.handleSubmit(i,t,s,o,e)},isChat:this.isChat,componentType:"cta",chatLength:this.chatHistory.length,placeholder:null!==(b=null===(f=this.ctaSettings)||void 0===f?void 0:f.placeholder)&&void 0!==b?b:this.pPlaceholder,buttonText:(null===(w=this.ctaSettings)||void 0===w?void 0:w.buttonText)?null===(y=this.ctaSettings)||void 0===y?void 0:y.buttonText:""==(null===(x=this.ctaSettings)||void 0===x?void 0:x.buttonText)||!(null===(k=this.ctaSettings)||void 0===k?void 0:k.buttonText)||""==(null===(z=this.ctaSettings)||void 0===z?void 0:z.buttonText)&&""==(null===(C=this.ctaSettings)||void 0===C?void 0:C.iconSrc)?!(null===(S=this.ctaSettings)||void 0===S?void 0:S.buttonText)&&(null===(A=this.ctaSettings)||void 0===A?void 0:A.iconSrc)?"":this.pButtonText:null===(T=this.ctaSettings)||void 0===T?void 0:T.buttonText,iconSrc:null!==(j=null===(M=this.ctaSettings)||void 0===M?void 0:M.iconSrc)&&void 0!==j?j:"",followUpLabel:null!==(E=null===(I=this.ctaSettings)||void 0===I?void 0:I.followUpLabel)&&void 0!==E?E:"Do you have a follow up question?",isImageUpload:null===(O=null===(N=this.ctaSettings)||void 0===N?void 0:N.imageUpload)||void 0===O||O,isEnableMic:null===(B=null===(H=this.ctaSettings)||void 0===H?void 0:H.enableMic)||void 0===B||B,"data-key":this.dataKey,"data-mode":this.dataMode})),e("div",{id:"main-content",class:"content-area"},!this.showHistory&&this.displayMessage(),e("div",{class:"custom-results"},!this.isChat&&!(null===(F=this.ctaSettings)||void 0===F?void 0:F.categorize)&&e(u,{results:this.searchResults}),!this.isChat&&(null===(D=this.ctaSettings)||void 0===D?void 0:D.categorize)&&e("ai12z-category",{categoryList:this.searchResults,linkTarget:null===(J=this.ctaSettings)||void 0===J?void 0:J.linkTarget})),this.isChat&&e("ai12z-chat",{chats:this.chatHistory,env:this.dataMode,query:this.formData.search,apiKey:this.dataKey,aiMessageId:this.aiMessageId,imgFiles:this.imgFiles,target:""===(null===(q=this.ctaSettings)||void 0===q?void 0:q.linkTarget)?"_blank":null===(K=this.ctaSettings)||void 0===K?void 0:K.linkTarget,voiceType:(null===(L=this.ctaSettings)||void 0===L?void 0:L.audioType)||"default",voice:(null===(U=this.ctaSettings)||void 0===U?void 0:U.voice)||"Google US English",onFeedback:async i=>{const{feedback:t,insightId:s}=i.detail;c(this.dataKey,this.dataMode,s,t)},componentType:"ctasearch",socketIn:this.socketService,dataAttributes:this.dataAttributes,chatExcludeTags:this.excludeTags,chatIncludeTags:this.includeTags,customstyle:null===(Z=this.ctaSettings)||void 0===Z?void 0:Z.customCSS,customJS:null===($=this.ctaSettings)||void 0===$?void 0:$.customJS,settings:null!==(R=this.ctaSettings)&&void 0!==R?R:{}}),this.showHistory&&e("chatbot-history",{chatList:this.conversationHistory,botName:null===(P=this.ctaSettings)||void 0===P?void 0:P.name}),!this.isChat&&e("div",{class:"custom-privacy"},e("slot",{name:"custom-privacy"})))))))):e(a,null,e("span",{style:{display:"none"}},"Failed to load ai12z control due to insufficient fund"))}get el(){return l(this)}static get watchers(){return{dataKey:[{onDataKeyChange:0}],dataMode:[{onDataModeChange:0}]}}};H.style=":host{--bg-smoke-light:rgba(0, 0, 0, 0.5);margin-left:20px;font-family:var(--ai12z-search-font-family) var(--ai12z-font-family) !important;font-size:var(--ai12z-search-font-size, var(--ai12z-font-size)) !important;color:var(--ai12z-font-color, black);text-align:var(--ai12z-text-align, left)}.keyboard-shortcuts-btn{vertical-align:middle;padding-right:5px;color:#666}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.skip-links{position:relative;z-index:9999}.skip-link{position:absolute;top:-40px;left:0;background-color:var(--ai12z-primary-color, #007bff);color:white;padding:8px 16px;text-decoration:none;border-radius:4px;font-weight:500;z-index:10000;opacity:0;pointer-events:none;transition:top 0.2s, opacity 0.2s}.skip-link:focus{top:8px;opacity:1;pointer-events:auto;outline:3px solid var(--ai12z-secondary-accent, #0056b3);outline-offset:2px}.bg-smoke-light{transition:opacity 300ms ease-in-out;position:fixed;top:0;left:0;z-index:200;height:100vh;width:100vw;cursor:auto;flex-direction:column;background-color:#0003;--tw-backdrop-blur:blur(4px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.modal-content{transition:transform 300ms ease-in-out, opacity 300ms ease-in-out;transform:scale(0.9);opacity:0}.modal-position{position:relative;padding:2rem 1rem 0.5rem 1rem;flex-direction:column}.modal-close:hover{color:rgb(31 41 55)}.model-heading{color:var(--ai12z-heading-color);font-size:var(--ai12z-heading-font-size)}:host(.show-modal) .bg-smoke-light{opacity:1}:host(.show-modal) .modal-content{transform:scale(1);opacity:1}.modal-content-wrapper{background-color:rgb(255 255 255);width:100%;max-width:48rem;border-radius:0.5rem;}.model-wrapper{position:fixed;top:0;left:0;z-index:200;height:100vh;width:100vw;cursor:auto;flex-direction:column;background-color:#0003;padding:1rem;--tw-backdrop-blur:blur(4px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.custom-model{overflow:auto;inset:0px;position:fixed;min-height:100vh;display:flex;align-items:center;justify-items:center}.hide-dialog{display:none !important}.modal-position .btn-position{position:absolute;right:0px;top:0px;padding:0.25rem 1rem;color:var(--ai12z-secondary-accent, #0056B3)}@media (max-width: 768px){.modal-content-wrapper{width:100%;height:100vh;height:100svh !important;margin:0 !important;border-radius:0;overflow:auto}.custom-privacy{position:fixed !important;bottom:0;left:0;width:100%;padding:10px}.modal-position .btn-position{padding:0.45rem 0.75rem 0.45rem 1rem;position:fixed}.content-area{padding:0px !important}}.btn-left{top:0;left:0;position:absolute;padding:0.35rem 1rem;color:var(--ai12z-secondary-accent, #0056B3)}.custom-privacy{color:var(--ai12z-knowledge-box-privacy-color);text-align:center;margin-top:auto;bottom:0;left:0;right:0}.custom-button{align-items:center;text-align:left;background-color:rgb(255 255 255);color:rgb(148 163 184);border-radius:0.5rem;width:18rem;min-height:3rem;padding-left:1rem;padding-right:1rem;}.custom-msg{text-align:center;color:var(--ai12z-font-mute);justify-content:center;max-width:none !important;}.cta-search-results{border-top-width:1px;border-bottom-width:0px;border-color:rgb(243 244 246)}.cta-search-results-list{position:relative;padding-bottom:1.25rem;padding-top:1.25rem}.cta-search-results-list:hover{background-color:var(--ai12z-hover-bg-color)}.cta-search-container{margin-left:auto;margin-right:auto;display:flex;max-width:56rem;justify-content:space-between;-moz-column-gap:1.5rem;column-gap:1.5rem}.cta-search-container-two{display:flex;min-width:0px;-moz-column-gap:1rem;column-gap:1rem}.cta-search-container-three{min-width:0px;flex:1 1 auto}.cta-search-text{font-weight:600;line-height:1.5rem;font-size:var(--ai12z-search-result-title-font-size);color:var(--ai12z-search-result-title-color)}.cta-search-text-position{position:absolute;left:0px;right:0px;top:-1px;bottom:0px}.cta-search-description{margin-top:0.25rem;display:flex;font-size:var(--ai12z-search-result-description-font-size);line-height:1rem;line-height:1.25rem;color:var(--ai12z-search-result-description-color)}.cta-search-list-arrow{display:flex;align-items:center;flex-shrink:0;-moz-column-gap:1rem;column-gap:1rem}.custom-icon-width{width:4rem}.results-icon svg{width:1.5rem;height:1.5rem}.modal-body{display:flex;flex-direction:column}.cta-layout{display:flex;flex:1;min-height:0}.cta-layout.normal{flex-direction:column}.cta-layout.reverse{flex-direction:column-reverse}.input-wrapper{position:sticky;top:0;bottom:0;z-index:10;background:white;padding:1rem}.content-area{flex:1;padding:0.75rem}";export{H as ai12z_cta}
@@ -1 +0,0 @@
1
- import{g as e}from"./p-Dj2_voLF.js";import{n}from"./p-y3Go1NSi.js";var a,r,t={exports:{}},o=(a||(a=1,r=t,function(){function e(e){var n={omitExtraWLInCodeBlocks:{defaultValue:!1,describe:"Omit the default extra whiteline added to code blocks",type:"boolean"},noHeaderId:{defaultValue:!1,describe:"Turn on/off generated header id",type:"boolean"},prefixHeaderId:{defaultValue:!1,describe:"Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic 'section-' prefix",type:"string"},rawPrefixHeaderId:{defaultValue:!1,describe:'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)',type:"boolean"},ghCompatibleHeaderId:{defaultValue:!1,describe:"Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)",type:"boolean"},rawHeaderId:{defaultValue:!1,describe:"Remove only spaces, ' and \" from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids",type:"boolean"},headerLevelStart:{defaultValue:!1,describe:"The header blocks level start",type:"integer"},parseImgDimensions:{defaultValue:!1,describe:"Turn on/off image dimension parsing",type:"boolean"},simplifiedAutoLink:{defaultValue:!1,describe:"Turn on/off GFM autolink style",type:"boolean"},excludeTrailingPunctuationFromURLs:{defaultValue:!1,describe:"Excludes trailing punctuation from links generated with autoLinking",type:"boolean"},literalMidWordUnderscores:{defaultValue:!1,describe:"Parse midword underscores as literal underscores",type:"boolean"},literalMidWordAsterisks:{defaultValue:!1,describe:"Parse midword asterisks as literal asterisks",type:"boolean"},strikethrough:{defaultValue:!1,describe:"Turn on/off strikethrough support",type:"boolean"},tables:{defaultValue:!1,describe:"Turn on/off tables support",type:"boolean"},tablesHeaderId:{defaultValue:!1,describe:"Add an id to table headers",type:"boolean"},ghCodeBlocks:{defaultValue:!0,describe:"Turn on/off GFM fenced code blocks support",type:"boolean"},tasklists:{defaultValue:!1,describe:"Turn on/off GFM tasklist support",type:"boolean"},smoothLivePreview:{defaultValue:!1,describe:"Prevents weird effects in live previews due to incomplete input",type:"boolean"},smartIndentationFix:{defaultValue:!1,describe:"Tries to smartly fix indentation in es6 strings",type:"boolean"},disableForced4SpacesIndentedSublists:{defaultValue:!1,describe:"Disables the requirement of indenting nested sublists by 4 spaces",type:"boolean"},simpleLineBreaks:{defaultValue:!1,describe:"Parses simple line breaks as <br> (GFM Style)",type:"boolean"},requireSpaceBeforeHeadingText:{defaultValue:!1,describe:"Makes adding a space between `#` and the header text mandatory (GFM Style)",type:"boolean"},ghMentions:{defaultValue:!1,describe:"Enables github @mentions",type:"boolean"},ghMentionsLink:{defaultValue:"https://github.com/{u}",describe:"Changes the link generated by @mentions. Only applies if ghMentions option is enabled.",type:"string"},encodeEmails:{defaultValue:!0,describe:"Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities",type:"boolean"},openLinksInNewWindow:{defaultValue:!1,describe:"Open all links in new windows",type:"boolean"},backslashEscapesHTMLTags:{defaultValue:!1,describe:"Support for HTML Tag escaping. ex: <div>foo</div>",type:"boolean"},emoji:{defaultValue:!1,describe:"Enable emoji support. Ex: `this is a :smile: emoji`",type:"boolean"},underline:{defaultValue:!1,describe:"Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `<em>` and `<strong>`",type:"boolean"},ellipsis:{defaultValue:!0,describe:"Replaces three dots with the ellipsis unicode character",type:"boolean"},completeHTMLDocument:{defaultValue:!1,describe:"Outputs a complete html document, including `<html>`, `<head>` and `<body>` tags",type:"boolean"},metadata:{defaultValue:!1,describe:"Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).",type:"boolean"},splitAdjacentBlockquotes:{defaultValue:!1,describe:"Split adjacent blockquote blocks",type:"boolean"}};if(!1===e)return JSON.parse(JSON.stringify(n));var a={};for(var r in n)n.hasOwnProperty(r)&&(a[r]=n[r].defaultValue);return a}var n={},a={},t={},o=e(!0),i="vanilla",s={github:{omitExtraWLInCodeBlocks:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,disableForced4SpacesIndentedSublists:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghCompatibleHeaderId:!0,ghMentions:!0,backslashEscapesHTMLTags:!0,emoji:!0,splitAdjacentBlockquotes:!0},original:{noHeaderId:!0,ghCodeBlocks:!1},ghost:{omitExtraWLInCodeBlocks:!0,parseImgDimensions:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,smoothLivePreview:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghMentions:!1,encodeEmails:!0},vanilla:e(!0),allOn:function(){var n=e(!0),a={};for(var r in n)n.hasOwnProperty(r)&&(a[r]=!0);return a}()};function l(e,a){var r=a?"Error in "+a+" extension->":"Error in unnamed extension",t={valid:!0,error:""};n.helper.isArray(e)||(e=[e]);for(var o=0;o<e.length;++o){var i=r+" sub-extension "+o+": ",s=e[o];if("object"!=typeof s)return t.valid=!1,t.error=i+"must be an object, but "+typeof s+" given",t;if(!n.helper.isString(s.type))return t.valid=!1,t.error=i+'property "type" must be a string, but '+typeof s.type+" given",t;var l=s.type=s.type.toLowerCase();if("language"===l&&(l=s.type="lang"),"html"===l&&(l=s.type="output"),"lang"!==l&&"output"!==l&&"listener"!==l)return t.valid=!1,t.error=i+"type "+l+' is not recognized. Valid values: "lang/language", "output/html" or "listener"',t;if("listener"===l){if(n.helper.isUndefined(s.listeners))return t.valid=!1,t.error=i+'. Extensions of type "listener" must have a property called "listeners"',t}else if(n.helper.isUndefined(s.filter)&&n.helper.isUndefined(s.regex))return t.valid=!1,t.error=i+l+' extensions must define either a "regex" property or a "filter" method',t;if(s.listeners){if("object"!=typeof s.listeners)return t.valid=!1,t.error=i+'"listeners" property must be an object but '+typeof s.listeners+" given",t;for(var c in s.listeners)if(s.listeners.hasOwnProperty(c)&&"function"!=typeof s.listeners[c])return t.valid=!1,t.error=i+'"listeners" property must be an hash of [event name]: [callback]. listeners.'+c+" must be a function but "+typeof s.listeners[c]+" given",t}if(s.filter){if("function"!=typeof s.filter)return t.valid=!1,t.error=i+'"filter" must be a function, but '+typeof s.filter+" given",t}else if(s.regex){if(n.helper.isString(s.regex)&&(s.regex=new RegExp(s.regex,"g")),!(s.regex instanceof RegExp))return t.valid=!1,t.error=i+'"regex" property must either be a string or a RegExp object, but '+typeof s.regex+" given",t;if(n.helper.isUndefined(s.replace))return t.valid=!1,t.error=i+'"regex" extensions must implement a replace string or function',t}}return t}function c(e,n){return"¨E"+n.charCodeAt(0)+"E"}n.helper={},n.extensions={},n.setOption=function(e,n){return o[e]=n,this},n.getOption=function(e){return o[e]},n.getOptions=function(){return o},n.resetOptions=function(){o=e(!0)},n.setFlavor=function(e){if(!s.hasOwnProperty(e))throw Error(e+" flavor was not found");n.resetOptions();var a=s[e];for(var r in i=e,a)a.hasOwnProperty(r)&&(o[r]=a[r])},n.getFlavor=function(){return i},n.getFlavorOptions=function(e){if(s.hasOwnProperty(e))return s[e]},n.getDefaultOptions=function(n){return e(n)},n.subParser=function(e,r){if(n.helper.isString(e)){if(void 0===r){if(a.hasOwnProperty(e))return a[e];throw Error("SubParser named "+e+" not registered!")}a[e]=r}},n.extension=function(e,a){if(!n.helper.isString(e))throw Error("Extension 'name' must be a string");if(e=n.helper.stdExtName(e),n.helper.isUndefined(a)){if(!t.hasOwnProperty(e))throw Error("Extension named "+e+" is not registered!");return t[e]}"function"==typeof a&&(a=a()),n.helper.isArray(a)||(a=[a]);var r=l(a,e);if(!r.valid)throw Error(r.error);t[e]=a},n.getAllExtensions=function(){return t},n.removeExtension=function(e){delete t[e]},n.resetExtensions=function(){t={}},n.validateExtension=function(e){var n=l(e,null);return!!n.valid||(console.warn(n.error),!1)},n.hasOwnProperty("helper")||(n.helper={}),n.helper.isString=function(e){return"string"==typeof e||e instanceof String},n.helper.isFunction=function(e){return e&&"[object Function]"==={}.toString.call(e)},n.helper.isArray=function(e){return Array.isArray(e)},n.helper.isUndefined=function(e){return void 0===e},n.helper.forEach=function(e,a){if(n.helper.isUndefined(e))throw new Error("obj param is required");if(n.helper.isUndefined(a))throw new Error("callback param is required");if(!n.helper.isFunction(a))throw new Error("callback param must be a function/closure");if("function"==typeof e.forEach)e.forEach(a);else if(n.helper.isArray(e))for(var r=0;r<e.length;r++)a(e[r],r,e);else{if("object"!=typeof e)throw new Error("obj does not seem to be an array or an iterable object");for(var t in e)e.hasOwnProperty(t)&&a(e[t],t,e)}},n.helper.stdExtName=function(e){return e.replace(/[_?*+\/\\.^-]/g,"").replace(/\s/g,"").toLowerCase()},n.helper.escapeCharactersCallback=c,n.helper.escapeCharacters=function(e,n,a){var r="(["+n.replace(/([\[\]\\])/g,"\\$1")+"])";a&&(r="\\\\"+r);var t=new RegExp(r,"g");return e.replace(t,c)},n.helper.unescapeHTMLEntities=function(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")};var u=function(e,n,a,r){var t,o,i,s,l,c=r||"",u=c.indexOf("g")>-1,_=new RegExp(n+"|"+a,"g"+c.replace(/g/g,"")),d=new RegExp(n,c.replace(/g/g,"")),f=[];do{for(t=0;i=_.exec(e);)if(d.test(i[0]))t++||(s=(o=_.lastIndex)-i[0].length);else if(t&&! --t&&(f.push({left:{start:s,end:o},match:{start:o,end:i.index},right:{start:i.index,end:l=i.index+i[0].length},wholeMatch:{start:s,end:l}}),!u))return f}while(t&&(_.lastIndex=o));return f};n.helper.matchRecursiveRegExp=function(e,n,a,r){for(var t=u(e,n,a,r),o=[],i=0;i<t.length;++i)o.push([e.slice(t[i].wholeMatch.start,t[i].wholeMatch.end),e.slice(t[i].match.start,t[i].match.end),e.slice(t[i].left.start,t[i].left.end),e.slice(t[i].right.start,t[i].right.end)]);return o},n.helper.replaceRecursiveRegExp=function(e,a,r,t,o){if(!n.helper.isFunction(a)){var i=a;a=function(){return i}}var s=u(e,r,t,o),l=e,c=s.length;if(c>0){var _=[];0!==s[0].wholeMatch.start&&_.push(e.slice(0,s[0].wholeMatch.start));for(var d=0;d<c;++d)_.push(a(e.slice(s[d].wholeMatch.start,s[d].wholeMatch.end),e.slice(s[d].match.start,s[d].match.end),e.slice(s[d].left.start,s[d].left.end),e.slice(s[d].right.start,s[d].right.end))),d<c-1&&_.push(e.slice(s[d].wholeMatch.end,s[d+1].wholeMatch.start));s[c-1].wholeMatch.end<e.length&&_.push(e.slice(s[c-1].wholeMatch.end)),l=_.join("")}return l},n.helper.regexIndexOf=function(e,a,r){if(!n.helper.isString(e))throw"InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string";if(a instanceof RegExp==0)throw"InvalidArgumentError: second parameter of showdown.helper.regexIndexOf function must be an instance of RegExp";var t=e.substring(r||0).search(a);return t>=0?t+(r||0):t},n.helper.splitAtIndex=function(e,a){if(!n.helper.isString(e))throw"InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string";return[e.substring(0,a),e.substring(a)]},n.helper.encodeEmailAddress=function(e){var n=[function(e){return"&#"+e.charCodeAt(0)+";"},function(e){return"&#x"+e.charCodeAt(0).toString(16)+";"},function(e){return e}];return e.replace(/./g,(function(e){if("@"===e)e=n[Math.floor(2*Math.random())](e);else{var a=Math.random();e=a>.9?n[2](e):a>.45?n[1](e):n[0](e)}return e}))},n.helper.padEnd=function(e,n,a){return n|=0,a=String(a||" "),e.length>n?String(e):((n-=e.length)>a.length&&(a+=a.repeat(n/a.length)),String(e)+a.slice(0,n))},"undefined"==typeof console&&(console={warn:function(e){alert(e)},log:function(e){alert(e)},error:function(e){throw e}}),n.helper.regexes={asteriskDashAndColon:/([*_:~])/g},n.helper.emojis={"+1":"👍","-1":"👎",100:"💯",1234:"🔢","1st_place_medal":"🥇","2nd_place_medal":"🥈","3rd_place_medal":"🥉","8ball":"🎱",a:"🅰️",ab:"🆎",abc:"🔤",abcd:"🔡",accept:"🉑",aerial_tramway:"🚡",airplane:"✈️",alarm_clock:"⏰",alembic:"⚗️",alien:"👽",ambulance:"🚑",amphora:"🏺",anchor:"⚓️",angel:"👼",anger:"💢",angry:"😠",anguished:"😧",ant:"🐜",apple:"🍎",aquarius:"♒️",aries:"♈️",arrow_backward:"◀️",arrow_double_down:"⏬",arrow_double_up:"⏫",arrow_down:"⬇️",arrow_down_small:"🔽",arrow_forward:"▶️",arrow_heading_down:"⤵️",arrow_heading_up:"⤴️",arrow_left:"⬅️",arrow_lower_left:"↙️",arrow_lower_right:"↘️",arrow_right:"➡️",arrow_right_hook:"↪️",arrow_up:"⬆️",arrow_up_down:"↕️",arrow_up_small:"🔼",arrow_upper_left:"↖️",arrow_upper_right:"↗️",arrows_clockwise:"🔃",arrows_counterclockwise:"🔄",art:"🎨",articulated_lorry:"🚛",artificial_satellite:"🛰",astonished:"😲",athletic_shoe:"👟",atm:"🏧",atom_symbol:"⚛️",avocado:"🥑",b:"🅱️",baby:"👶",baby_bottle:"🍼",baby_chick:"🐤",baby_symbol:"🚼",back:"🔙",bacon:"🥓",badminton:"🏸",baggage_claim:"🛄",baguette_bread:"🥖",balance_scale:"⚖️",balloon:"🎈",ballot_box:"🗳",ballot_box_with_check:"☑️",bamboo:"🎍",banana:"🍌",bangbang:"‼️",bank:"🏦",bar_chart:"📊",barber:"💈",baseball:"⚾️",basketball:"🏀",basketball_man:"⛹️",basketball_woman:"⛹️&zwj;♀️",bat:"🦇",bath:"🛀",bathtub:"🛁",battery:"🔋",beach_umbrella:"🏖",bear:"🐻",bed:"🛏",bee:"🐝",beer:"🍺",beers:"🍻",beetle:"🐞",beginner:"🔰",bell:"🔔",bellhop_bell:"🛎",bento:"🍱",biking_man:"🚴",bike:"🚲",biking_woman:"🚴&zwj;♀️",bikini:"👙",biohazard:"☣️",bird:"🐦",birthday:"🎂",black_circle:"⚫️",black_flag:"🏴",black_heart:"🖤",black_joker:"🃏",black_large_square:"⬛️",black_medium_small_square:"◾️",black_medium_square:"◼️",black_nib:"✒️",black_small_square:"▪️",black_square_button:"🔲",blonde_man:"👱",blonde_woman:"👱&zwj;♀️",blossom:"🌼",blowfish:"🐡",blue_book:"📘",blue_car:"🚙",blue_heart:"💙",blush:"😊",boar:"🐗",boat:"⛵️",bomb:"💣",book:"📖",bookmark:"🔖",bookmark_tabs:"📑",books:"📚",boom:"💥",boot:"👢",bouquet:"💐",bowing_man:"🙇",bow_and_arrow:"🏹",bowing_woman:"🙇&zwj;♀️",bowling:"🎳",boxing_glove:"🥊",boy:"👦",bread:"🍞",bride_with_veil:"👰",bridge_at_night:"🌉",briefcase:"💼",broken_heart:"💔",bug:"🐛",building_construction:"🏗",bulb:"💡",bullettrain_front:"🚅",bullettrain_side:"🚄",burrito:"🌯",bus:"🚌",business_suit_levitating:"🕴",busstop:"🚏",bust_in_silhouette:"👤",busts_in_silhouette:"👥",butterfly:"🦋",cactus:"🌵",cake:"🍰",calendar:"📆",call_me_hand:"🤙",calling:"📲",camel:"🐫",camera:"📷",camera_flash:"📸",camping:"🏕",cancer:"♋️",candle:"🕯",candy:"🍬",canoe:"🛶",capital_abcd:"🔠",capricorn:"♑️",car:"🚗",card_file_box:"🗃",card_index:"📇",card_index_dividers:"🗂",carousel_horse:"🎠",carrot:"🥕",cat:"🐱",cat2:"🐈",cd:"💿",chains:"⛓",champagne:"🍾",chart:"💹",chart_with_downwards_trend:"📉",chart_with_upwards_trend:"📈",checkered_flag:"🏁",cheese:"🧀",cherries:"🍒",cherry_blossom:"🌸",chestnut:"🌰",chicken:"🐔",children_crossing:"🚸",chipmunk:"🐿",chocolate_bar:"🍫",christmas_tree:"🎄",church:"⛪️",cinema:"🎦",circus_tent:"🎪",city_sunrise:"🌇",city_sunset:"🌆",cityscape:"🏙",cl:"🆑",clamp:"🗜",clap:"👏",clapper:"🎬",classical_building:"🏛",clinking_glasses:"🥂",clipboard:"📋",clock1:"🕐",clock10:"🕙",clock1030:"🕥",clock11:"🕚",clock1130:"🕦",clock12:"🕛",clock1230:"🕧",clock130:"🕜",clock2:"🕑",clock230:"🕝",clock3:"🕒",clock330:"🕞",clock4:"🕓",clock430:"🕟",clock5:"🕔",clock530:"🕠",clock6:"🕕",clock630:"🕡",clock7:"🕖",clock730:"🕢",clock8:"🕗",clock830:"🕣",clock9:"🕘",clock930:"🕤",closed_book:"📕",closed_lock_with_key:"🔐",closed_umbrella:"🌂",cloud:"☁️",cloud_with_lightning:"🌩",cloud_with_lightning_and_rain:"⛈",cloud_with_rain:"🌧",cloud_with_snow:"🌨",clown_face:"🤡",clubs:"♣️",cocktail:"🍸",coffee:"☕️",coffin:"⚰️",cold_sweat:"😰",comet:"☄️",computer:"💻",computer_mouse:"🖱",confetti_ball:"🎊",confounded:"😖",confused:"😕",congratulations:"㊗️",construction:"🚧",construction_worker_man:"👷",construction_worker_woman:"👷&zwj;♀️",control_knobs:"🎛",convenience_store:"🏪",cookie:"🍪",cool:"🆒",policeman:"👮",copyright:"©️",corn:"🌽",couch_and_lamp:"🛋",couple:"👫",couple_with_heart_woman_man:"💑",couple_with_heart_man_man:"👨&zwj;❤️&zwj;👨",couple_with_heart_woman_woman:"👩&zwj;❤️&zwj;👩",couplekiss_man_man:"👨&zwj;❤️&zwj;💋&zwj;👨",couplekiss_man_woman:"💏",couplekiss_woman_woman:"👩&zwj;❤️&zwj;💋&zwj;👩",cow:"🐮",cow2:"🐄",cowboy_hat_face:"🤠",crab:"🦀",crayon:"🖍",credit_card:"💳",crescent_moon:"🌙",cricket:"🏏",crocodile:"🐊",croissant:"🥐",crossed_fingers:"🤞",crossed_flags:"🎌",crossed_swords:"⚔️",crown:"👑",cry:"😢",crying_cat_face:"😿",crystal_ball:"🔮",cucumber:"🥒",cupid:"💘",curly_loop:"➰",currency_exchange:"💱",curry:"🍛",custard:"🍮",customs:"🛃",cyclone:"🌀",dagger:"🗡",dancer:"💃",dancing_women:"👯",dancing_men:"👯&zwj;♂️",dango:"🍡",dark_sunglasses:"🕶",dart:"🎯",dash:"💨",date:"📅",deciduous_tree:"🌳",deer:"🦌",department_store:"🏬",derelict_house:"🏚",desert:"🏜",desert_island:"🏝",desktop_computer:"🖥",male_detective:"🕵️",diamond_shape_with_a_dot_inside:"💠",diamonds:"♦️",disappointed:"😞",disappointed_relieved:"😥",dizzy:"💫",dizzy_face:"😵",do_not_litter:"🚯",dog:"🐶",dog2:"🐕",dollar:"💵",dolls:"🎎",dolphin:"🐬",door:"🚪",doughnut:"🍩",dove:"🕊",dragon:"🐉",dragon_face:"🐲",dress:"👗",dromedary_camel:"🐪",drooling_face:"🤤",droplet:"💧",drum:"🥁",duck:"🦆",dvd:"📀","e-mail":"📧",eagle:"🦅",ear:"👂",ear_of_rice:"🌾",earth_africa:"🌍",earth_americas:"🌎",earth_asia:"🌏",egg:"🥚",eggplant:"🍆",eight_pointed_black_star:"✴️",eight_spoked_asterisk:"✳️",electric_plug:"🔌",elephant:"🐘",email:"✉️",end:"🔚",envelope_with_arrow:"📩",euro:"💶",european_castle:"🏰",european_post_office:"🏤",evergreen_tree:"🌲",exclamation:"❗️",expressionless:"😑",eye:"👁",eye_speech_bubble:"👁&zwj;🗨",eyeglasses:"👓",eyes:"👀",face_with_head_bandage:"🤕",face_with_thermometer:"🤒",fist_oncoming:"👊",factory:"🏭",fallen_leaf:"🍂",family_man_woman_boy:"👪",family_man_boy:"👨&zwj;👦",family_man_boy_boy:"👨&zwj;👦&zwj;👦",family_man_girl:"👨&zwj;👧",family_man_girl_boy:"👨&zwj;👧&zwj;👦",family_man_girl_girl:"👨&zwj;👧&zwj;👧",family_man_man_boy:"👨&zwj;👨&zwj;👦",family_man_man_boy_boy:"👨&zwj;👨&zwj;👦&zwj;👦",family_man_man_girl:"👨&zwj;👨&zwj;👧",family_man_man_girl_boy:"👨&zwj;👨&zwj;👧&zwj;👦",family_man_man_girl_girl:"👨&zwj;👨&zwj;👧&zwj;👧",family_man_woman_boy_boy:"👨&zwj;👩&zwj;👦&zwj;👦",family_man_woman_girl:"👨&zwj;👩&zwj;👧",family_man_woman_girl_boy:"👨&zwj;👩&zwj;👧&zwj;👦",family_man_woman_girl_girl:"👨&zwj;👩&zwj;👧&zwj;👧",family_woman_boy:"👩&zwj;👦",family_woman_boy_boy:"👩&zwj;👦&zwj;👦",family_woman_girl:"👩&zwj;👧",family_woman_girl_boy:"👩&zwj;👧&zwj;👦",family_woman_girl_girl:"👩&zwj;👧&zwj;👧",family_woman_woman_boy:"👩&zwj;👩&zwj;👦",family_woman_woman_boy_boy:"👩&zwj;👩&zwj;👦&zwj;👦",family_woman_woman_girl:"👩&zwj;👩&zwj;👧",family_woman_woman_girl_boy:"👩&zwj;👩&zwj;👧&zwj;👦",family_woman_woman_girl_girl:"👩&zwj;👩&zwj;👧&zwj;👧",fast_forward:"⏩",fax:"📠",fearful:"😨",feet:"🐾",female_detective:"🕵️&zwj;♀️",ferris_wheel:"🎡",ferry:"⛴",field_hockey:"🏑",file_cabinet:"🗄",file_folder:"📁",film_projector:"📽",film_strip:"🎞",fire:"🔥",fire_engine:"🚒",fireworks:"🎆",first_quarter_moon:"🌓",first_quarter_moon_with_face:"🌛",fish:"🐟",fish_cake:"🍥",fishing_pole_and_fish:"🎣",fist_raised:"✊",fist_left:"🤛",fist_right:"🤜",flags:"🎏",flashlight:"🔦",fleur_de_lis:"⚜️",flight_arrival:"🛬",flight_departure:"🛫",floppy_disk:"💾",flower_playing_cards:"🎴",flushed:"😳",fog:"🌫",foggy:"🌁",football:"🏈",footprints:"👣",fork_and_knife:"🍴",fountain:"⛲️",fountain_pen:"🖋",four_leaf_clover:"🍀",fox_face:"🦊",framed_picture:"🖼",free:"🆓",fried_egg:"🍳",fried_shrimp:"🍤",fries:"🍟",frog:"🐸",frowning:"😦",frowning_face:"☹️",frowning_man:"🙍&zwj;♂️",frowning_woman:"🙍",middle_finger:"🖕",fuelpump:"⛽️",full_moon:"🌕",full_moon_with_face:"🌝",funeral_urn:"⚱️",game_die:"🎲",gear:"⚙️",gem:"💎",gemini:"♊️",ghost:"👻",gift:"🎁",gift_heart:"💝",girl:"👧",globe_with_meridians:"🌐",goal_net:"🥅",goat:"🐐",golf:"⛳️",golfing_man:"🏌️",golfing_woman:"🏌️&zwj;♀️",gorilla:"🦍",grapes:"🍇",green_apple:"🍏",green_book:"📗",green_heart:"💚",green_salad:"🥗",grey_exclamation:"❕",grey_question:"❔",grimacing:"😬",grin:"😁",grinning:"😀",guardsman:"💂",guardswoman:"💂&zwj;♀️",guitar:"🎸",gun:"🔫",haircut_woman:"💇",haircut_man:"💇&zwj;♂️",hamburger:"🍔",hammer:"🔨",hammer_and_pick:"⚒",hammer_and_wrench:"🛠",hamster:"🐹",hand:"✋",handbag:"👜",handshake:"🤝",hankey:"💩",hatched_chick:"🐥",hatching_chick:"🐣",headphones:"🎧",hear_no_evil:"🙉",heart:"❤️",heart_decoration:"💟",heart_eyes:"😍",heart_eyes_cat:"😻",heartbeat:"💓",heartpulse:"💗",hearts:"♥️",heavy_check_mark:"✔️",heavy_division_sign:"➗",heavy_dollar_sign:"💲",heavy_heart_exclamation:"❣️",heavy_minus_sign:"➖",heavy_multiplication_x:"✖️",heavy_plus_sign:"➕",helicopter:"🚁",herb:"🌿",hibiscus:"🌺",high_brightness:"🔆",high_heel:"👠",hocho:"🔪",hole:"🕳",honey_pot:"🍯",horse:"🐴",horse_racing:"🏇",hospital:"🏥",hot_pepper:"🌶",hotdog:"🌭",hotel:"🏨",hotsprings:"♨️",hourglass:"⌛️",hourglass_flowing_sand:"⏳",house:"🏠",house_with_garden:"🏡",houses:"🏘",hugs:"🤗",hushed:"😯",ice_cream:"🍨",ice_hockey:"🏒",ice_skate:"⛸",icecream:"🍦",id:"🆔",ideograph_advantage:"🉐",imp:"👿",inbox_tray:"📥",incoming_envelope:"📨",tipping_hand_woman:"💁",information_source:"ℹ️",innocent:"😇",interrobang:"⁉️",iphone:"📱",izakaya_lantern:"🏮",jack_o_lantern:"🎃",japan:"🗾",japanese_castle:"🏯",japanese_goblin:"👺",japanese_ogre:"👹",jeans:"👖",joy:"😂",joy_cat:"😹",joystick:"🕹",kaaba:"🕋",key:"🔑",keyboard:"⌨️",keycap_ten:"🔟",kick_scooter:"🛴",kimono:"👘",kiss:"💋",kissing:"😗",kissing_cat:"😽",kissing_closed_eyes:"😚",kissing_heart:"😘",kissing_smiling_eyes:"😙",kiwi_fruit:"🥝",koala:"🐨",koko:"🈁",label:"🏷",large_blue_circle:"🔵",large_blue_diamond:"🔷",large_orange_diamond:"🔶",last_quarter_moon:"🌗",last_quarter_moon_with_face:"🌜",latin_cross:"✝️",laughing:"😆",leaves:"🍃",ledger:"📒",left_luggage:"🛅",left_right_arrow:"↔️",leftwards_arrow_with_hook:"↩️",lemon:"🍋",leo:"♌️",leopard:"🐆",level_slider:"🎚",libra:"♎️",light_rail:"🚈",link:"🔗",lion:"🦁",lips:"👄",lipstick:"💄",lizard:"🦎",lock:"🔒",lock_with_ink_pen:"🔏",lollipop:"🍭",loop:"➿",loud_sound:"🔊",loudspeaker:"📢",love_hotel:"🏩",love_letter:"💌",low_brightness:"🔅",lying_face:"🤥",m:"Ⓜ️",mag:"🔍",mag_right:"🔎",mahjong:"🀄️",mailbox:"📫",mailbox_closed:"📪",mailbox_with_mail:"📬",mailbox_with_no_mail:"📭",man:"👨",man_artist:"👨&zwj;🎨",man_astronaut:"👨&zwj;🚀",man_cartwheeling:"🤸&zwj;♂️",man_cook:"👨&zwj;🍳",man_dancing:"🕺",man_facepalming:"🤦&zwj;♂️",man_factory_worker:"👨&zwj;🏭",man_farmer:"👨&zwj;🌾",man_firefighter:"👨&zwj;🚒",man_health_worker:"👨&zwj;⚕️",man_in_tuxedo:"🤵",man_judge:"👨&zwj;⚖️",man_juggling:"🤹&zwj;♂️",man_mechanic:"👨&zwj;🔧",man_office_worker:"👨&zwj;💼",man_pilot:"👨&zwj;✈️",man_playing_handball:"🤾&zwj;♂️",man_playing_water_polo:"🤽&zwj;♂️",man_scientist:"👨&zwj;🔬",man_shrugging:"🤷&zwj;♂️",man_singer:"👨&zwj;🎤",man_student:"👨&zwj;🎓",man_teacher:"👨&zwj;🏫",man_technologist:"👨&zwj;💻",man_with_gua_pi_mao:"👲",man_with_turban:"👳",tangerine:"🍊",mans_shoe:"👞",mantelpiece_clock:"🕰",maple_leaf:"🍁",martial_arts_uniform:"🥋",mask:"😷",massage_woman:"💆",massage_man:"💆&zwj;♂️",meat_on_bone:"🍖",medal_military:"🎖",medal_sports:"🏅",mega:"📣",melon:"🍈",memo:"📝",men_wrestling:"🤼&zwj;♂️",menorah:"🕎",mens:"🚹",metal:"🤘",metro:"🚇",microphone:"🎤",microscope:"🔬",milk_glass:"🥛",milky_way:"🌌",minibus:"🚐",minidisc:"💽",mobile_phone_off:"📴",money_mouth_face:"🤑",money_with_wings:"💸",moneybag:"💰",monkey:"🐒",monkey_face:"🐵",monorail:"🚝",moon:"🌔",mortar_board:"🎓",mosque:"🕌",motor_boat:"🛥",motor_scooter:"🛵",motorcycle:"🏍",motorway:"🛣",mount_fuji:"🗻",mountain:"⛰",mountain_biking_man:"🚵",mountain_biking_woman:"🚵&zwj;♀️",mountain_cableway:"🚠",mountain_railway:"🚞",mountain_snow:"🏔",mouse:"🐭",mouse2:"🐁",movie_camera:"🎥",moyai:"🗿",mrs_claus:"🤶",muscle:"💪",mushroom:"🍄",musical_keyboard:"🎹",musical_note:"🎵",musical_score:"🎼",mute:"🔇",nail_care:"💅",name_badge:"📛",national_park:"🏞",nauseated_face:"🤢",necktie:"👔",negative_squared_cross_mark:"❎",nerd_face:"🤓",neutral_face:"😐",new:"🆕",new_moon:"🌑",new_moon_with_face:"🌚",newspaper:"📰",newspaper_roll:"🗞",next_track_button:"⏭",ng:"🆖",no_good_man:"🙅&zwj;♂️",no_good_woman:"🙅",night_with_stars:"🌃",no_bell:"🔕",no_bicycles:"🚳",no_entry:"⛔️",no_entry_sign:"🚫",no_mobile_phones:"📵",no_mouth:"😶",no_pedestrians:"🚷",no_smoking:"🚭","non-potable_water":"🚱",nose:"👃",notebook:"📓",notebook_with_decorative_cover:"📔",notes:"🎶",nut_and_bolt:"🔩",o:"⭕️",o2:"🅾️",ocean:"🌊",octopus:"🐙",oden:"🍢",office:"🏢",oil_drum:"🛢",ok:"🆗",ok_hand:"👌",ok_man:"🙆&zwj;♂️",ok_woman:"🙆",old_key:"🗝",older_man:"👴",older_woman:"👵",om:"🕉",on:"🔛",oncoming_automobile:"🚘",oncoming_bus:"🚍",oncoming_police_car:"🚔",oncoming_taxi:"🚖",open_file_folder:"📂",open_hands:"👐",open_mouth:"😮",open_umbrella:"☂️",ophiuchus:"⛎",orange_book:"📙",orthodox_cross:"☦️",outbox_tray:"📤",owl:"🦉",ox:"🐂",package:"📦",page_facing_up:"📄",page_with_curl:"📃",pager:"📟",paintbrush:"🖌",palm_tree:"🌴",pancakes:"🥞",panda_face:"🐼",paperclip:"📎",paperclips:"🖇",parasol_on_ground:"⛱",parking:"🅿️",part_alternation_mark:"〽️",partly_sunny:"⛅️",passenger_ship:"🛳",passport_control:"🛂",pause_button:"⏸",peace_symbol:"☮️",peach:"🍑",peanuts:"🥜",pear:"🍐",pen:"🖊",pencil2:"✏️",penguin:"🐧",pensive:"😔",performing_arts:"🎭",persevere:"😣",person_fencing:"🤺",pouting_woman:"🙎",phone:"☎️",pick:"⛏",pig:"🐷",pig2:"🐖",pig_nose:"🐽",pill:"💊",pineapple:"🍍",ping_pong:"🏓",pisces:"♓️",pizza:"🍕",place_of_worship:"🛐",plate_with_cutlery:"🍽",play_or_pause_button:"⏯",point_down:"👇",point_left:"👈",point_right:"👉",point_up:"☝️",point_up_2:"👆",police_car:"🚓",policewoman:"👮&zwj;♀️",poodle:"🐩",popcorn:"🍿",post_office:"🏣",postal_horn:"📯",postbox:"📮",potable_water:"🚰",potato:"🥔",pouch:"👝",poultry_leg:"🍗",pound:"💷",rage:"😡",pouting_cat:"😾",pouting_man:"🙎&zwj;♂️",pray:"🙏",prayer_beads:"📿",pregnant_woman:"🤰",previous_track_button:"⏮",prince:"🤴",princess:"👸",printer:"🖨",purple_heart:"💜",purse:"👛",pushpin:"📌",put_litter_in_its_place:"🚮",question:"❓",rabbit:"🐰",rabbit2:"🐇",racehorse:"🐎",racing_car:"🏎",radio:"📻",radio_button:"🔘",radioactive:"☢️",railway_car:"🚃",railway_track:"🛤",rainbow:"🌈",rainbow_flag:"🏳️&zwj;🌈",raised_back_of_hand:"🤚",raised_hand_with_fingers_splayed:"🖐",raised_hands:"🙌",raising_hand_woman:"🙋",raising_hand_man:"🙋&zwj;♂️",ram:"🐏",ramen:"🍜",rat:"🐀",record_button:"⏺",recycle:"♻️",red_circle:"🔴",registered:"®️",relaxed:"☺️",relieved:"😌",reminder_ribbon:"🎗",repeat:"🔁",repeat_one:"🔂",rescue_worker_helmet:"⛑",restroom:"🚻",revolving_hearts:"💞",rewind:"⏪",rhinoceros:"🦏",ribbon:"🎀",rice:"🍚",rice_ball:"🍙",rice_cracker:"🍘",rice_scene:"🎑",right_anger_bubble:"🗯",ring:"💍",robot:"🤖",rocket:"🚀",rofl:"🤣",roll_eyes:"🙄",roller_coaster:"🎢",rooster:"🐓",rose:"🌹",rosette:"🏵",rotating_light:"🚨",round_pushpin:"📍",rowing_man:"🚣",rowing_woman:"🚣&zwj;♀️",rugby_football:"🏉",running_man:"🏃",running_shirt_with_sash:"🎽",running_woman:"🏃&zwj;♀️",sa:"🈂️",sagittarius:"♐️",sake:"🍶",sandal:"👡",santa:"🎅",satellite:"📡",saxophone:"🎷",school:"🏫",school_satchel:"🎒",scissors:"✂️",scorpion:"🦂",scorpius:"♏️",scream:"😱",scream_cat:"🙀",scroll:"📜",seat:"💺",secret:"㊙️",see_no_evil:"🙈",seedling:"🌱",selfie:"🤳",shallow_pan_of_food:"🥘",shamrock:"☘️",shark:"🦈",shaved_ice:"🍧",sheep:"🐑",shell:"🐚",shield:"🛡",shinto_shrine:"⛩",ship:"🚢",shirt:"👕",shopping:"🛍",shopping_cart:"🛒",shower:"🚿",shrimp:"🦐",signal_strength:"📶",six_pointed_star:"🔯",ski:"🎿",skier:"⛷",skull:"💀",skull_and_crossbones:"☠️",sleeping:"😴",sleeping_bed:"🛌",sleepy:"😪",slightly_frowning_face:"🙁",slightly_smiling_face:"🙂",slot_machine:"🎰",small_airplane:"🛩",small_blue_diamond:"🔹",small_orange_diamond:"🔸",small_red_triangle:"🔺",small_red_triangle_down:"🔻",smile:"😄",smile_cat:"😸",smiley:"😃",smiley_cat:"😺",smiling_imp:"😈",smirk:"😏",smirk_cat:"😼",smoking:"🚬",snail:"🐌",snake:"🐍",sneezing_face:"🤧",snowboarder:"🏂",snowflake:"❄️",snowman:"⛄️",snowman_with_snow:"☃️",sob:"😭",soccer:"⚽️",soon:"🔜",sos:"🆘",sound:"🔉",space_invader:"👾",spades:"♠️",spaghetti:"🍝",sparkle:"❇️",sparkler:"🎇",sparkles:"✨",sparkling_heart:"💖",speak_no_evil:"🙊",speaker:"🔈",speaking_head:"🗣",speech_balloon:"💬",speedboat:"🚤",spider:"🕷",spider_web:"🕸",spiral_calendar:"🗓",spiral_notepad:"🗒",spoon:"🥄",squid:"🦑",stadium:"🏟",star:"⭐️",star2:"🌟",star_and_crescent:"☪️",star_of_david:"✡️",stars:"🌠",station:"🚉",statue_of_liberty:"🗽",steam_locomotive:"🚂",stew:"🍲",stop_button:"⏹",stop_sign:"🛑",stopwatch:"⏱",straight_ruler:"📏",strawberry:"🍓",stuck_out_tongue:"😛",stuck_out_tongue_closed_eyes:"😝",stuck_out_tongue_winking_eye:"😜",studio_microphone:"🎙",stuffed_flatbread:"🥙",sun_behind_large_cloud:"🌥",sun_behind_rain_cloud:"🌦",sun_behind_small_cloud:"🌤",sun_with_face:"🌞",sunflower:"🌻",sunglasses:"😎",sunny:"☀️",sunrise:"🌅",sunrise_over_mountains:"🌄",surfing_man:"🏄",surfing_woman:"🏄&zwj;♀️",sushi:"🍣",suspension_railway:"🚟",sweat:"😓",sweat_drops:"💦",sweat_smile:"😅",sweet_potato:"🍠",swimming_man:"🏊",swimming_woman:"🏊&zwj;♀️",symbols:"🔣",synagogue:"🕍",syringe:"💉",taco:"🌮",tada:"🎉",tanabata_tree:"🎋",taurus:"♉️",taxi:"🚕",tea:"🍵",telephone_receiver:"📞",telescope:"🔭",tennis:"🎾",tent:"⛺️",thermometer:"🌡",thinking:"🤔",thought_balloon:"💭",ticket:"🎫",tickets:"🎟",tiger:"🐯",tiger2:"🐅",timer_clock:"⏲",tipping_hand_man:"💁&zwj;♂️",tired_face:"😫",tm:"™️",toilet:"🚽",tokyo_tower:"🗼",tomato:"🍅",tongue:"👅",top:"🔝",tophat:"🎩",tornado:"🌪",trackball:"🖲",tractor:"🚜",traffic_light:"🚥",train:"🚋",train2:"🚆",tram:"🚊",triangular_flag_on_post:"🚩",triangular_ruler:"📐",trident:"🔱",triumph:"😤",trolleybus:"🚎",trophy:"🏆",tropical_drink:"🍹",tropical_fish:"🐠",truck:"🚚",trumpet:"🎺",tulip:"🌷",tumbler_glass:"🥃",turkey:"🦃",turtle:"🐢",tv:"📺",twisted_rightwards_arrows:"🔀",two_hearts:"💕",two_men_holding_hands:"👬",two_women_holding_hands:"👭",u5272:"🈹",u5408:"🈴",u55b6:"🈺",u6307:"🈯️",u6708:"🈷️",u6709:"🈶",u6e80:"🈵",u7121:"🈚️",u7533:"🈸",u7981:"🈲",u7a7a:"🈳",umbrella:"☔️",unamused:"😒",underage:"🔞",unicorn:"🦄",unlock:"🔓",up:"🆙",upside_down_face:"🙃",v:"✌️",vertical_traffic_light:"🚦",vhs:"📼",vibration_mode:"📳",video_camera:"📹",video_game:"🎮",violin:"🎻",virgo:"♍️",volcano:"🌋",volleyball:"🏐",vs:"🆚",vulcan_salute:"🖖",walking_man:"🚶",walking_woman:"🚶&zwj;♀️",waning_crescent_moon:"🌘",waning_gibbous_moon:"🌖",warning:"⚠️",wastebasket:"🗑",watch:"⌚️",water_buffalo:"🐃",watermelon:"🍉",wave:"👋",wavy_dash:"〰️",waxing_crescent_moon:"🌒",wc:"🚾",weary:"😩",wedding:"💒",weight_lifting_man:"🏋️",weight_lifting_woman:"🏋️&zwj;♀️",whale:"🐳",whale2:"🐋",wheel_of_dharma:"☸️",wheelchair:"♿️",white_check_mark:"✅",white_circle:"⚪️",white_flag:"🏳️",white_flower:"💮",white_large_square:"⬜️",white_medium_small_square:"◽️",white_medium_square:"◻️",white_small_square:"▫️",white_square_button:"🔳",wilted_flower:"🥀",wind_chime:"🎐",wind_face:"🌬",wine_glass:"🍷",wink:"😉",wolf:"🐺",woman:"👩",woman_artist:"👩&zwj;🎨",woman_astronaut:"👩&zwj;🚀",woman_cartwheeling:"🤸&zwj;♀️",woman_cook:"👩&zwj;🍳",woman_facepalming:"🤦&zwj;♀️",woman_factory_worker:"👩&zwj;🏭",woman_farmer:"👩&zwj;🌾",woman_firefighter:"👩&zwj;🚒",woman_health_worker:"👩&zwj;⚕️",woman_judge:"👩&zwj;⚖️",woman_juggling:"🤹&zwj;♀️",woman_mechanic:"👩&zwj;🔧",woman_office_worker:"👩&zwj;💼",woman_pilot:"👩&zwj;✈️",woman_playing_handball:"🤾&zwj;♀️",woman_playing_water_polo:"🤽&zwj;♀️",woman_scientist:"👩&zwj;🔬",woman_shrugging:"🤷&zwj;♀️",woman_singer:"👩&zwj;🎤",woman_student:"👩&zwj;🎓",woman_teacher:"👩&zwj;🏫",woman_technologist:"👩&zwj;💻",woman_with_turban:"👳&zwj;♀️",womans_clothes:"👚",womans_hat:"👒",women_wrestling:"🤼&zwj;♀️",womens:"🚺",world_map:"🗺",worried:"😟",wrench:"🔧",writing_hand:"✍️",x:"❌",yellow_heart:"💛",yen:"💴",yin_yang:"☯️",yum:"😋",zap:"⚡️",zipper_mouth_face:"🤐",zzz:"💤",octocat:'<img alt=":octocat:" height="20" width="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">',showdown:"<span style=\"font-family: 'Anonymous Pro', monospace; text-decoration: underline; text-decoration-style: dashed; text-decoration-color: #3e8b8a;text-underline-position: under;\">S</span>"},n.Converter=function(e){var a={},r=[],c=[],u={},_=i,d={parsed:{},raw:"",format:""};function f(e,a){if(a=a||null,n.helper.isString(e)){if(a=e=n.helper.stdExtName(e),n.extensions[e])return console.warn("DEPRECATION WARNING: "+e+" is an old extension that uses a deprecated loading method.Please inform the developer that the extension should be updated!"),void function(e,a){"function"==typeof e&&(e=e(new n.Converter)),n.helper.isArray(e)||(e=[e]);var t=l(e,a);if(!t.valid)throw Error(t.error);for(var o=0;o<e.length;++o)switch(e[o].type){case"lang":r.push(e[o]);break;case"output":c.push(e[o]);break;default:throw Error("Extension loader error: Type unrecognized!!!")}}(n.extensions[e],e);if(n.helper.isUndefined(t[e]))throw Error('Extension "'+e+'" could not be loaded. It was either not found or is not a valid extension.');e=t[e]}"function"==typeof e&&(e=e()),n.helper.isArray(e)||(e=[e]);var o=l(e,a);if(!o.valid)throw Error(o.error);for(var i=0;i<e.length;++i){switch(e[i].type){case"lang":r.push(e[i]);break;case"output":c.push(e[i])}if(e[i].hasOwnProperty("listeners"))for(var s in e[i].listeners)e[i].listeners.hasOwnProperty(s)&&m(s,e[i].listeners[s])}}function m(e,a){if(!n.helper.isString(e))throw Error("Invalid argument in converter.listen() method: name must be a string, but "+typeof e+" given");if("function"!=typeof a)throw Error("Invalid argument in converter.listen() method: callback must be a function, but "+typeof a+" given");u.hasOwnProperty(e)||(u[e]=[]),u[e].push(a)}!function(){for(var r in e=e||{},o)o.hasOwnProperty(r)&&(a[r]=o[r]);if("object"!=typeof e)throw Error("Converter expects the passed parameter to be an object, but "+typeof e+" was passed instead.");for(var t in e)e.hasOwnProperty(t)&&(a[t]=e[t]);a.extensions&&n.helper.forEach(a.extensions,f)}(),this._dispatch=function(e,n,a,r){if(u.hasOwnProperty(e))for(var t=0;t<u[e].length;++t){var o=u[e][t](e,n,this,a,r);o&&void 0!==o&&(n=o)}return n},this.listen=function(e,n){return m(e,n),this},this.makeHtml=function(e){if(!e)return e;var t={gHtmlBlocks:[],gHtmlMdBlocks:[],gHtmlSpans:[],gUrls:{},gTitles:{},gDimensions:{},gListLevel:0,hashLinkCounts:{},langExtensions:r,outputModifiers:c,converter:this,ghCodeBlocks:[],metadata:{parsed:{},raw:"",format:""}};return e=(e=(e=(e=(e=e.replace(/¨/g,"¨T")).replace(/\$/g,"¨D")).replace(/\r\n/g,"\n")).replace(/\r/g,"\n")).replace(/\u00A0/g,"&nbsp;"),a.smartIndentationFix&&(e=function(e){var n=e.match(/^\s*/)[0].length,a=new RegExp("^\\s{0,"+n+"}","gm");return e.replace(a,"")}(e)),e="\n\n"+e+"\n\n",e=(e=n.subParser("detab")(e,a,t)).replace(/^[ \t]+$/gm,""),n.helper.forEach(r,(function(r){e=n.subParser("runExtension")(r,e,a,t)})),e=n.subParser("metadata")(e,a,t),e=n.subParser("hashPreCodeTags")(e,a,t),e=n.subParser("githubCodeBlocks")(e,a,t),e=n.subParser("hashHTMLBlocks")(e,a,t),e=n.subParser("hashCodeTags")(e,a,t),e=n.subParser("stripLinkDefinitions")(e,a,t),e=n.subParser("blockGamut")(e,a,t),e=n.subParser("unhashHTMLSpans")(e,a,t),e=(e=(e=n.subParser("unescapeSpecialChars")(e,a,t)).replace(/¨D/g,"$$")).replace(/¨T/g,"¨"),e=n.subParser("completeHTMLDocument")(e,a,t),n.helper.forEach(c,(function(r){e=n.subParser("runExtension")(r,e,a,t)})),d=t.metadata,e},this.makeMarkdown=this.makeMd=function(e,a){if(e=(e=(e=e.replace(/\r\n/g,"\n")).replace(/\r/g,"\n")).replace(/>[ \t]+</,">¨NBSP;<"),!a){if(!window||!window.document)throw new Error("HTMLParser is undefined. If in a webworker or nodejs environment, you need to provide a WHATWG DOM and HTML such as JSDOM");a=window.document}var r=a.createElement("div");r.innerHTML=e;var t={preList:function(e){for(var a=e.querySelectorAll("pre"),r=[],t=0;t<a.length;++t)if(1===a[t].childElementCount&&"code"===a[t].firstChild.tagName.toLowerCase()){var o=a[t].firstChild.innerHTML.trim(),i=a[t].firstChild.getAttribute("data-language")||"";if(""===i)for(var s=a[t].firstChild.className.split(" "),l=0;l<s.length;++l){var c=s[l].match(/^language-(.+)$/);if(null!==c){i=c[1];break}}o=n.helper.unescapeHTMLEntities(o),r.push(o),a[t].outerHTML='<precode language="'+i+'" precodenum="'+t.toString()+'"></precode>'}else r.push(a[t].innerHTML),a[t].innerHTML="",a[t].setAttribute("prenum",t.toString());return r}(r)};!function e(n){for(var a=0;a<n.childNodes.length;++a){var r=n.childNodes[a];3===r.nodeType?/\S/.test(r.nodeValue)||/^[ ]+$/.test(r.nodeValue)?(r.nodeValue=r.nodeValue.split("\n").join(" "),r.nodeValue=r.nodeValue.replace(/(\s)+/g,"$1")):(n.removeChild(r),--a):1===r.nodeType&&e(r)}}(r);for(var o=r.childNodes,i="",s=0;s<o.length;s++)i+=n.subParser("makeMarkdown.node")(o[s],t);return i},this.setOption=function(e,n){a[e]=n},this.getOption=function(e){return a[e]},this.getOptions=function(){return a},this.addExtension=function(e,n){f(e,n=n||null)},this.useExtension=function(e){f(e)},this.setFlavor=function(e){if(!s.hasOwnProperty(e))throw Error(e+" flavor was not found");var n=s[e];for(var r in _=e,n)n.hasOwnProperty(r)&&(a[r]=n[r])},this.getFlavor=function(){return _},this.removeExtension=function(e){n.helper.isArray(e)||(e=[e]);for(var a=0;a<e.length;++a){for(var t=e[a],o=0;o<r.length;++o)r[o]===t&&r.splice(o,1);for(var i=0;i<c.length;++i)c[i]===t&&c.splice(i,1)}},this.getAllExtensions=function(){return{language:r,output:c}},this.getMetadata=function(e){return e?d.raw:d.parsed},this.getMetadataFormat=function(){return d.format},this._setMetadataPair=function(e,n){d.parsed[e]=n},this._setMetadataFormat=function(e){d.format=e},this._setMetadataRaw=function(e){d.raw=e}},n.subParser("anchors",(function(e,a,r){var t=function(e,t,o,i,s,l,c){if(n.helper.isUndefined(c)&&(c=""),o=o.toLowerCase(),e.search(/\(<?\s*>? ?(['"].*['"])?\)$/m)>-1)i="";else if(!i){if(o||(o=t.toLowerCase().replace(/ ?\n/g," ")),i="#"+o,n.helper.isUndefined(r.gUrls[o]))return e;i=r.gUrls[o],n.helper.isUndefined(r.gTitles[o])||(c=r.gTitles[o])}var u='<a href="'+(i=i.replace(n.helper.regexes.asteriskDashAndColon,n.helper.escapeCharactersCallback))+'"';return""!==c&&null!==c&&(u+=' title="'+(c=(c=c.replace(/"/g,"&quot;")).replace(n.helper.regexes.asteriskDashAndColon,n.helper.escapeCharactersCallback))+'"'),a.openLinksInNewWindow&&!/^#/.test(i)&&(u+=' rel="noopener noreferrer" target="¨E95Eblank"'),u+">"+t+"</a>"};return e=(e=(e=(e=(e=r.converter._dispatch("anchors.before",e,a,r)).replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g,t)).replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,t)).replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,t)).replace(/\[([^\[\]]+)]()()()()()/g,t),a.ghMentions&&(e=e.replace(/(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d.-]+?[a-z\d]+)*))/gim,(function(e,r,t,o,i){if("\\"===t)return r+o;if(!n.helper.isString(a.ghMentionsLink))throw new Error("ghMentionsLink option must be a string");var s=a.ghMentionsLink.replace(/\{u}/g,i),l="";return a.openLinksInNewWindow&&(l=' rel="noopener noreferrer" target="¨E95Eblank"'),r+'<a href="'+s+'"'+l+">"+o+"</a>"}))),r.converter._dispatch("anchors.after",e,a,r)}));var _=/([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'">\s]+?)()(\1)?(?=\s|$)(?!["<>])/gi,d=/([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?,()\[\]])?(\1)?(?=\s|$)(?!["<>])/gi,f=/()<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)()>()/gi,m=/(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gim,g=/<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,h=function(e){return function(a,r,t,o,i,s,l){var c=t=t.replace(n.helper.regexes.asteriskDashAndColon,n.helper.escapeCharactersCallback),u="",_="",d=r||"",f=l||"";return/^www\./i.test(t)&&(t=t.replace(/^www\./i,"http://www.")),e.excludeTrailingPunctuationFromURLs&&s&&(u=s),e.openLinksInNewWindow&&(_=' rel="noopener noreferrer" target="¨E95Eblank"'),d+'<a href="'+t+'"'+_+">"+c+"</a>"+u+f}},p=function(e,a){return function(r,t,o){var i="mailto:";return t=t||"",o=n.subParser("unescapeSpecialChars")(o,e,a),e.encodeEmails?(i=n.helper.encodeEmailAddress(i+o),o=n.helper.encodeEmailAddress(o)):i+=o,t+'<a href="'+i+'">'+o+"</a>"}};n.subParser("autoLinks",(function(e,n,a){return e=(e=(e=a.converter._dispatch("autoLinks.before",e,n,a)).replace(f,h(n))).replace(g,p(n,a)),a.converter._dispatch("autoLinks.after",e,n,a)})),n.subParser("simplifiedAutoLinks",(function(e,n,a){return n.simplifiedAutoLink?(e=(e=(e=a.converter._dispatch("simplifiedAutoLinks.before",e,n,a)).replace(n.excludeTrailingPunctuationFromURLs?d:_,h(n))).replace(m,p(n,a)),e=a.converter._dispatch("simplifiedAutoLinks.after",e,n,a)):e})),n.subParser("blockGamut",(function(e,a,r){return e=r.converter._dispatch("blockGamut.before",e,a,r),e=n.subParser("blockQuotes")(e,a,r),e=n.subParser("headers")(e,a,r),e=n.subParser("horizontalRule")(e,a,r),e=n.subParser("lists")(e,a,r),e=n.subParser("codeBlocks")(e,a,r),e=n.subParser("tables")(e,a,r),e=n.subParser("hashHTMLBlocks")(e,a,r),e=n.subParser("paragraphs")(e,a,r),r.converter._dispatch("blockGamut.after",e,a,r)})),n.subParser("blockQuotes",(function(e,a,r){e=r.converter._dispatch("blockQuotes.before",e,a,r);var t=/(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm;return a.splitAdjacentBlockquotes&&(t=/^ {0,3}>[\s\S]*?(?:\n\n)/gm),e=(e+="\n\n").replace(t,(function(e){return e=(e=(e=e.replace(/^[ \t]*>[ \t]?/gm,"")).replace(/¨0/g,"")).replace(/^[ \t]+$/gm,""),e=n.subParser("githubCodeBlocks")(e,a,r),e=(e=(e=n.subParser("blockGamut")(e,a,r)).replace(/(^|\n)/g,"$1 ")).replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,(function(e,n){var a=n;return(a=a.replace(/^ /gm,"¨0")).replace(/¨0/g,"")})),n.subParser("hashBlock")("<blockquote>\n"+e+"\n</blockquote>",a,r)})),r.converter._dispatch("blockQuotes.after",e,a,r)})),n.subParser("codeBlocks",(function(e,a,r){return e=r.converter._dispatch("codeBlocks.before",e,a,r),e=(e=(e+="¨0").replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g,(function(e,t,o){var i=t,s=o,l="\n";return i=n.subParser("outdent")(i,a,r),i=n.subParser("encodeCode")(i,a,r),i=(i=(i=n.subParser("detab")(i,a,r)).replace(/^\n+/g,"")).replace(/\n+$/g,""),a.omitExtraWLInCodeBlocks&&(l=""),i="<pre><code>"+i+l+"</code></pre>",n.subParser("hashBlock")(i,a,r)+s}))).replace(/¨0/,""),r.converter._dispatch("codeBlocks.after",e,a,r)})),n.subParser("codeSpans",(function(e,a,r){return void 0===(e=r.converter._dispatch("codeSpans.before",e,a,r))&&(e=""),e=e.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,(function(e,t,o,i){var s=i;return s=(s=s.replace(/^([ \t]*)/g,"")).replace(/[ \t]*$/g,""),s=t+"<code>"+(s=n.subParser("encodeCode")(s,a,r))+"</code>",n.subParser("hashHTMLSpans")(s,a,r)})),r.converter._dispatch("codeSpans.after",e,a,r)})),n.subParser("completeHTMLDocument",(function(e,n,a){if(!n.completeHTMLDocument)return e;e=a.converter._dispatch("completeHTMLDocument.before",e,n,a);var r="html",t="<!DOCTYPE HTML>\n",o="",i='<meta charset="utf-8">\n',s="",l="";for(var c in void 0!==a.metadata.parsed.doctype&&(t="<!DOCTYPE "+a.metadata.parsed.doctype+">\n","html"!==(r=a.metadata.parsed.doctype.toString().toLowerCase())&&"html5"!==r||(i='<meta charset="utf-8">')),a.metadata.parsed)if(a.metadata.parsed.hasOwnProperty(c))switch(c.toLowerCase()){case"doctype":break;case"title":o="<title>"+a.metadata.parsed.title+"</title>\n";break;case"charset":i="html"===r||"html5"===r?'<meta charset="'+a.metadata.parsed.charset+'">\n':'<meta name="charset" content="'+a.metadata.parsed.charset+'">\n';break;case"language":case"lang":s=' lang="'+a.metadata.parsed[c]+'"',l+='<meta name="'+c+'" content="'+a.metadata.parsed[c]+'">\n';break;default:l+='<meta name="'+c+'" content="'+a.metadata.parsed[c]+'">\n'}return e=t+"<html"+s+">\n<head>\n"+o+i+l+"</head>\n<body>\n"+e.trim()+"\n</body>\n</html>",a.converter._dispatch("completeHTMLDocument.after",e,n,a)})),n.subParser("detab",(function(e,n,a){return e=(e=(e=(e=(e=(e=a.converter._dispatch("detab.before",e,n,a)).replace(/\t(?=\t)/g," ")).replace(/\t/g,"¨A¨B")).replace(/¨B(.+?)¨A/g,(function(e,n){for(var a=n,r=4-a.length%4,t=0;t<r;t++)a+=" ";return a}))).replace(/¨A/g," ")).replace(/¨B/g,""),a.converter._dispatch("detab.after",e,n,a)})),n.subParser("ellipsis",(function(e,n,a){return n.ellipsis?(e=(e=a.converter._dispatch("ellipsis.before",e,n,a)).replace(/\.\.\./g,"…"),e=a.converter._dispatch("ellipsis.after",e,n,a)):e})),n.subParser("emoji",(function(e,a,r){return a.emoji?(e=(e=r.converter._dispatch("emoji.before",e,a,r)).replace(/:([\S]+?):/g,(function(e,a){return n.helper.emojis.hasOwnProperty(a)?n.helper.emojis[a]:e})),e=r.converter._dispatch("emoji.after",e,a,r)):e})),n.subParser("encodeAmpsAndAngles",(function(e,n,a){return e=(e=(e=(e=(e=a.converter._dispatch("encodeAmpsAndAngles.before",e,n,a)).replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;")).replace(/<(?![a-z\/?$!])/gi,"&lt;")).replace(/</g,"&lt;")).replace(/>/g,"&gt;"),a.converter._dispatch("encodeAmpsAndAngles.after",e,n,a)})),n.subParser("encodeBackslashEscapes",(function(e,a,r){return e=(e=(e=r.converter._dispatch("encodeBackslashEscapes.before",e,a,r)).replace(/\\(\\)/g,n.helper.escapeCharactersCallback)).replace(/\\([`*_{}\[\]()>#+.!~=|:-])/g,n.helper.escapeCharactersCallback),r.converter._dispatch("encodeBackslashEscapes.after",e,a,r)})),n.subParser("encodeCode",(function(e,a,r){return e=(e=r.converter._dispatch("encodeCode.before",e,a,r)).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/([*_{}\[\]\\=~-])/g,n.helper.escapeCharactersCallback),r.converter._dispatch("encodeCode.after",e,a,r)})),n.subParser("escapeSpecialCharsWithinTagAttributes",(function(e,a,r){return e=(e=(e=r.converter._dispatch("escapeSpecialCharsWithinTagAttributes.before",e,a,r)).replace(/<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,(function(e){return e.replace(/(.)<\/?code>(?=.)/g,"$1`").replace(/([\\`*_~=|])/g,n.helper.escapeCharactersCallback)}))).replace(/<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi,(function(e){return e.replace(/([\\`*_~=|])/g,n.helper.escapeCharactersCallback)})),r.converter._dispatch("escapeSpecialCharsWithinTagAttributes.after",e,a,r)})),n.subParser("githubCodeBlocks",(function(e,a,r){return a.ghCodeBlocks?(e=r.converter._dispatch("githubCodeBlocks.before",e,a,r),e=(e=(e+="¨0").replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g,(function(e,t,o,i){var s=a.omitExtraWLInCodeBlocks?"":"\n";return i=n.subParser("encodeCode")(i,a,r),i="<pre><code"+(o?' class="'+o+" language-"+o+'"':"")+">"+(i=(i=(i=n.subParser("detab")(i,a,r)).replace(/^\n+/g,"")).replace(/\n+$/g,""))+s+"</code></pre>",i=n.subParser("hashBlock")(i,a,r),"\n\n¨G"+(r.ghCodeBlocks.push({text:e,codeblock:i})-1)+"G\n\n"}))).replace(/¨0/,""),r.converter._dispatch("githubCodeBlocks.after",e,a,r)):e})),n.subParser("hashBlock",(function(e,n,a){return e=(e=a.converter._dispatch("hashBlock.before",e,n,a)).replace(/(^\n+|\n+$)/g,""),e="\n\n¨K"+(a.gHtmlBlocks.push(e)-1)+"K\n\n",a.converter._dispatch("hashBlock.after",e,n,a)})),n.subParser("hashCodeTags",(function(e,a,r){return e=r.converter._dispatch("hashCodeTags.before",e,a,r),e=n.helper.replaceRecursiveRegExp(e,(function(e,t,o,i){var s=o+n.subParser("encodeCode")(t,a,r)+i;return"¨C"+(r.gHtmlSpans.push(s)-1)+"C"}),"<code\\b[^>]*>","</code>","gim"),r.converter._dispatch("hashCodeTags.after",e,a,r)})),n.subParser("hashElement",(function(e,n,a){return function(e,n){var r=n;return r=(r=(r=r.replace(/\n\n/g,"\n")).replace(/^\n/,"")).replace(/\n+$/g,""),"\n\n¨K"+(a.gHtmlBlocks.push(r)-1)+"K\n\n"}})),n.subParser("hashHTMLBlocks",(function(e,a,r){e=r.converter._dispatch("hashHTMLBlocks.before",e,a,r);var t=["pre","div","h1","h2","h3","h4","h5","h6","blockquote","table","dl","ol","ul","script","noscript","form","fieldset","iframe","math","style","section","header","footer","nav","article","aside","address","audio","canvas","figure","hgroup","output","video","p"],o=function(e,n,a,t){var o=e;return-1!==a.search(/\bmarkdown\b/)&&(o=a+r.converter.makeHtml(n)+t),"\n\n¨K"+(r.gHtmlBlocks.push(o)-1)+"K\n\n"};a.backslashEscapesHTMLTags&&(e=e.replace(/\\<(\/?[^>]+?)>/g,(function(e,n){return"&lt;"+n+"&gt;"})));for(var i=0;i<t.length;++i)for(var s,l=new RegExp("^ {0,3}(<"+t[i]+"\\b[^>]*>)","im"),c="<"+t[i]+"\\b[^>]*>",u="</"+t[i]+">";-1!==(s=n.helper.regexIndexOf(e,l));){var _=n.helper.splitAtIndex(e,s),d=n.helper.replaceRecursiveRegExp(_[1],o,c,u,"im");if(d===_[1])break;e=_[0].concat(d)}return e=e.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,n.subParser("hashElement")(e,a,r)),e=(e=n.helper.replaceRecursiveRegExp(e,(function(e){return"\n\n¨K"+(r.gHtmlBlocks.push(e)-1)+"K\n\n"}),"^ {0,3}\x3c!--","--\x3e","gm")).replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,n.subParser("hashElement")(e,a,r)),r.converter._dispatch("hashHTMLBlocks.after",e,a,r)})),n.subParser("hashHTMLSpans",(function(e,n,a){function r(e){return"¨C"+(a.gHtmlSpans.push(e)-1)+"C"}return e=(e=(e=(e=(e=a.converter._dispatch("hashHTMLSpans.before",e,n,a)).replace(/<[^>]+?\/>/gi,(function(e){return r(e)}))).replace(/<([^>]+?)>[\s\S]*?<\/\1>/g,(function(e){return r(e)}))).replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g,(function(e){return r(e)}))).replace(/<[^>]+?>/gi,(function(e){return r(e)})),a.converter._dispatch("hashHTMLSpans.after",e,n,a)})),n.subParser("unhashHTMLSpans",(function(e,n,a){e=a.converter._dispatch("unhashHTMLSpans.before",e,n,a);for(var r=0;r<a.gHtmlSpans.length;++r){for(var t=a.gHtmlSpans[r],o=0;/¨C(\d+)C/.test(t);){var i=RegExp.$1;if(t=t.replace("¨C"+i+"C",a.gHtmlSpans[i]),10===o){console.error("maximum nesting of 10 spans reached!!!");break}++o}e=e.replace("¨C"+r+"C",t)}return a.converter._dispatch("unhashHTMLSpans.after",e,n,a)})),n.subParser("hashPreCodeTags",(function(e,a,r){return e=r.converter._dispatch("hashPreCodeTags.before",e,a,r),e=n.helper.replaceRecursiveRegExp(e,(function(e,t,o,i){var s=o+n.subParser("encodeCode")(t,a,r)+i;return"\n\n¨G"+(r.ghCodeBlocks.push({text:e,codeblock:s})-1)+"G\n\n"}),"^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>","^ {0,3}</code>\\s*</pre>","gim"),r.converter._dispatch("hashPreCodeTags.after",e,a,r)})),n.subParser("headers",(function(e,a,r){e=r.converter._dispatch("headers.before",e,a,r);var t=isNaN(parseInt(a.headerLevelStart))?1:parseInt(a.headerLevelStart),o=a.smoothLivePreview?/^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n-+[ \t]*\n+/gm;function i(e){var t,o;if(a.customizedHeaderId){var i=e.match(/\{([^{]+?)}\s*$/);i&&i[1]&&(e=i[1])}return t=e,o=n.helper.isString(a.prefixHeaderId)?a.prefixHeaderId:!0===a.prefixHeaderId?"section-":"",a.rawPrefixHeaderId||(t=o+t),t=a.ghCompatibleHeaderId?t.replace(/ /g,"-").replace(/&amp;/g,"").replace(/¨T/g,"").replace(/¨D/g,"").replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g,"").toLowerCase():a.rawHeaderId?t.replace(/ /g,"-").replace(/&amp;/g,"&").replace(/¨T/g,"¨").replace(/¨D/g,"$").replace(/["']/g,"-").toLowerCase():t.replace(/[^\w]/g,"").toLowerCase(),a.rawPrefixHeaderId&&(t=o+t),r.hashLinkCounts[t]?t=t+"-"+r.hashLinkCounts[t]++:r.hashLinkCounts[t]=1,t}return e=(e=(e=e.replace(a.smoothLivePreview?/^(.+)[ \t]*\n={2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n=+[ \t]*\n+/gm,(function(e,o){var s=n.subParser("spanGamut")(o,a,r),l=a.noHeaderId?"":' id="'+i(o)+'"',c="<h"+t+l+">"+s+"</h"+t+">";return n.subParser("hashBlock")(c,a,r)}))).replace(o,(function(e,o){var s=n.subParser("spanGamut")(o,a,r),l=a.noHeaderId?"":' id="'+i(o)+'"',c=t+1,u="<h"+c+l+">"+s+"</h"+c+">";return n.subParser("hashBlock")(u,a,r)}))).replace(a.requireSpaceBeforeHeadingText?/^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm:/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm,(function(e,o,s){var l=s;a.customizedHeaderId&&(l=s.replace(/\s?\{([^{]+?)}\s*$/,""));var c=n.subParser("spanGamut")(l,a,r),u=a.noHeaderId?"":' id="'+i(s)+'"',_=t-1+o.length,d="<h"+_+u+">"+c+"</h"+_+">";return n.subParser("hashBlock")(d,a,r)})),r.converter._dispatch("headers.after",e,a,r)})),n.subParser("horizontalRule",(function(e,a,r){e=r.converter._dispatch("horizontalRule.before",e,a,r);var t=n.subParser("hashBlock")("<hr />",a,r);return e=(e=(e=e.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm,t)).replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm,t)).replace(/^ {0,2}( ?_){3,}[ \t]*$/gm,t),r.converter._dispatch("horizontalRule.after",e,a,r)})),n.subParser("images",(function(e,a,r){function t(e,a,t,o,i,s,l,c){var u=r.gUrls,_=r.gTitles,d=r.gDimensions;if(t=t.toLowerCase(),c||(c=""),e.search(/\(<?\s*>? ?(['"].*['"])?\)$/m)>-1)o="";else if(""===o||null===o){if(""!==t&&null!==t||(t=a.toLowerCase().replace(/ ?\n/g," ")),o="#"+t,n.helper.isUndefined(u[t]))return e;o=u[t],n.helper.isUndefined(_[t])||(c=_[t]),n.helper.isUndefined(d[t])||(i=d[t].width,s=d[t].height)}a=a.replace(/"/g,"&quot;").replace(n.helper.regexes.asteriskDashAndColon,n.helper.escapeCharactersCallback);var f='<img src="'+(o=o.replace(n.helper.regexes.asteriskDashAndColon,n.helper.escapeCharactersCallback))+'" alt="'+a+'"';return c&&n.helper.isString(c)&&(f+=' title="'+(c=c.replace(/"/g,"&quot;").replace(n.helper.regexes.asteriskDashAndColon,n.helper.escapeCharactersCallback))+'"'),i&&s&&(f+=' width="'+(i="*"===i?"auto":i)+'"',f+=' height="'+(s="*"===s?"auto":s)+'"'),f+" />"}return e=(e=(e=(e=(e=(e=r.converter._dispatch("images.before",e,a,r)).replace(/!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g,t)).replace(/!\[([^\]]*?)][ \t]*()\([ \t]?<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,(function(e,n,a,r,o,i,s,l){return t(e,n,a,r=r.replace(/\s/g,""),o,i,0,l)}))).replace(/!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,t)).replace(/!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,t)).replace(/!\[([^\[\]]+)]()()()()()/g,t),r.converter._dispatch("images.after",e,a,r)})),n.subParser("italicsAndBold",(function(e,n,a){function r(e,n,a){return n+e+a}return e=a.converter._dispatch("italicsAndBold.before",e,n,a),e=n.literalMidWordUnderscores?(e=(e=e.replace(/\b___(\S[\s\S]*?)___\b/g,(function(e,n){return r(n,"<strong><em>","</em></strong>")}))).replace(/\b__(\S[\s\S]*?)__\b/g,(function(e,n){return r(n,"<strong>","</strong>")}))).replace(/\b_(\S[\s\S]*?)_\b/g,(function(e,n){return r(n,"<em>","</em>")})):(e=(e=e.replace(/___(\S[\s\S]*?)___/g,(function(e,n){return/\S$/.test(n)?r(n,"<strong><em>","</em></strong>"):e}))).replace(/__(\S[\s\S]*?)__/g,(function(e,n){return/\S$/.test(n)?r(n,"<strong>","</strong>"):e}))).replace(/_([^\s_][\s\S]*?)_/g,(function(e,n){return/\S$/.test(n)?r(n,"<em>","</em>"):e})),e=n.literalMidWordAsterisks?(e=(e=e.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g,(function(e,n,a){return r(a,n+"<strong><em>","</em></strong>")}))).replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g,(function(e,n,a){return r(a,n+"<strong>","</strong>")}))).replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g,(function(e,n,a){return r(a,n+"<em>","</em>")})):(e=(e=e.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g,(function(e,n){return/\S$/.test(n)?r(n,"<strong><em>","</em></strong>"):e}))).replace(/\*\*(\S[\s\S]*?)\*\*/g,(function(e,n){return/\S$/.test(n)?r(n,"<strong>","</strong>"):e}))).replace(/\*([^\s*][\s\S]*?)\*/g,(function(e,n){return/\S$/.test(n)?r(n,"<em>","</em>"):e})),a.converter._dispatch("italicsAndBold.after",e,n,a)})),n.subParser("lists",(function(e,a,r){function t(e,t){r.gListLevel++,e=e.replace(/\n{2,}$/,"\n");var o=/(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm,i=/\n[ \t]*\n(?!¨0)/.test(e+="¨0");return a.disableForced4SpacesIndentedSublists&&(o=/(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm),e=(e=e.replace(o,(function(e,t,o,s,l,c,u){u=u&&""!==u.trim();var _=n.subParser("outdent")(l,a,r),d="";return c&&a.tasklists&&(d=' class="task-list-item" style="list-style-type: none;"',_=_.replace(/^[ \t]*\[(x|X| )?]/m,(function(){var e='<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';return u&&(e+=" checked"),e+">"}))),_=_.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g,(function(e){return"¨A"+e})),t||_.search(/\n{2,}/)>-1?(_=n.subParser("githubCodeBlocks")(_,a,r),_=n.subParser("blockGamut")(_,a,r)):(_=(_=n.subParser("lists")(_,a,r)).replace(/\n$/,""),_=(_=n.subParser("hashHTMLBlocks")(_,a,r)).replace(/\n\n+/g,"\n\n"),_=i?n.subParser("paragraphs")(_,a,r):n.subParser("spanGamut")(_,a,r)),"<li"+d+">"+(_=_.replace("¨A",""))+"</li>\n"}))).replace(/¨0/g,""),r.gListLevel--,t&&(e=e.replace(/\s+$/,"")),e}function o(e,n){if("ol"===n){var a=e.match(/^ *(\d+)\./);if(a&&"1"!==a[1])return' start="'+a[1]+'"'}return""}function i(e,n,r){var i=a.disableForced4SpacesIndentedSublists?/^ ?\d+\.[ \t]/gm:/^ {0,3}\d+\.[ \t]/gm,s=a.disableForced4SpacesIndentedSublists?/^ ?[*+-][ \t]/gm:/^ {0,3}[*+-][ \t]/gm,l="ul"===n?i:s,c="";if(-1!==e.search(l))!function a(u){var _=u.search(l),d=o(e,n);-1!==_?(c+="\n\n<"+n+d+">\n"+t(u.slice(0,_),!!r)+"</"+n+">\n",l="ul"==(n="ul"===n?"ol":"ul")?i:s,a(u.slice(_))):c+="\n\n<"+n+d+">\n"+t(u,!!r)+"</"+n+">\n"}(e);else{var u=o(e,n);c="\n\n<"+n+u+">\n"+t(e,!!r)+"</"+n+">\n"}return c}return e=r.converter._dispatch("lists.before",e,a,r),e+="¨0",e=(e=r.gListLevel?e.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,(function(e,n,a){return i(n,a.search(/[*+-]/g)>-1?"ul":"ol",!0)})):e.replace(/(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,(function(e,n,a,r){return i(a,r.search(/[*+-]/g)>-1?"ul":"ol",!1)}))).replace(/¨0/,""),r.converter._dispatch("lists.after",e,a,r)})),n.subParser("metadata",(function(e,n,a){if(!n.metadata)return e;function r(e){a.metadata.raw=e,(e=(e=e.replace(/&/g,"&amp;").replace(/"/g,"&quot;")).replace(/\n {4}/g," ")).replace(/^([\S ]+): +([\s\S]+?)$/gm,(function(e,n,r){return a.metadata.parsed[n]=r,""}))}return e=(e=(e=(e=a.converter._dispatch("metadata.before",e,n,a)).replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/,(function(e,n,a){return r(a),"¨M"}))).replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/,(function(e,n,t){return n&&(a.metadata.format=n),r(t),"¨M"}))).replace(/¨M/g,""),a.converter._dispatch("metadata.after",e,n,a)})),n.subParser("outdent",(function(e,n,a){return e=(e=(e=a.converter._dispatch("outdent.before",e,n,a)).replace(/^(\t|[ ]{1,4})/gm,"¨0")).replace(/¨0/g,""),a.converter._dispatch("outdent.after",e,n,a)})),n.subParser("paragraphs",(function(e,a,r){for(var t=(e=(e=(e=r.converter._dispatch("paragraphs.before",e,a,r)).replace(/^\n+/g,"")).replace(/\n+$/g,"")).split(/\n{2,}/g),o=[],i=t.length,s=0;s<i;s++){var l=t[s];l.search(/¨(K|G)(\d+)\1/g)>=0?o.push(l):l.search(/\S/)>=0&&(l=(l=n.subParser("spanGamut")(l,a,r)).replace(/^([ \t]*)/g,"<p>"),o.push(l+="</p>"))}for(i=o.length,s=0;s<i;s++){for(var c="",u=o[s],_=!1;/¨(K|G)(\d+)\1/.test(u);){var d=RegExp.$1,f=RegExp.$2;c=(c="K"===d?r.gHtmlBlocks[f]:_?n.subParser("encodeCode")(r.ghCodeBlocks[f].text,a,r):r.ghCodeBlocks[f].codeblock).replace(/\$/g,"$$$$"),u=u.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/,c),/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(u)&&(_=!0)}o[s]=u}return e=(e=(e=o.join("\n")).replace(/^\n+/g,"")).replace(/\n+$/g,""),r.converter._dispatch("paragraphs.after",e,a,r)})),n.subParser("runExtension",(function(e,n,a,r){if(e.filter)n=e.filter(n,r.converter,a);else if(e.regex){var t=e.regex;t instanceof RegExp||(t=new RegExp(t,"g")),n=n.replace(t,e.replace)}return n})),n.subParser("spanGamut",(function(e,a,r){return e=r.converter._dispatch("spanGamut.before",e,a,r),e=n.subParser("codeSpans")(e,a,r),e=n.subParser("escapeSpecialCharsWithinTagAttributes")(e,a,r),e=n.subParser("encodeBackslashEscapes")(e,a,r),e=n.subParser("images")(e,a,r),e=n.subParser("anchors")(e,a,r),e=n.subParser("autoLinks")(e,a,r),e=n.subParser("simplifiedAutoLinks")(e,a,r),e=n.subParser("emoji")(e,a,r),e=n.subParser("underline")(e,a,r),e=n.subParser("italicsAndBold")(e,a,r),e=n.subParser("strikethrough")(e,a,r),e=n.subParser("ellipsis")(e,a,r),e=n.subParser("hashHTMLSpans")(e,a,r),e=n.subParser("encodeAmpsAndAngles")(e,a,r),a.simpleLineBreaks?/\n\n¨K/.test(e)||(e=e.replace(/\n+/g,"<br />\n")):e=e.replace(/ +\n/g,"<br />\n"),r.converter._dispatch("spanGamut.after",e,a,r)})),n.subParser("strikethrough",(function(e,a,r){return a.strikethrough&&(e=(e=r.converter._dispatch("strikethrough.before",e,a,r)).replace(/(?:~){2}([\s\S]+?)(?:~){2}/g,(function(e,t){return function(e){return a.simplifiedAutoLink&&(e=n.subParser("simplifiedAutoLinks")(e,a,r)),"<del>"+e+"</del>"}(t)})),e=r.converter._dispatch("strikethrough.after",e,a,r)),e})),n.subParser("stripLinkDefinitions",(function(e,a,r){var t=function(t,o,i,s,l,c,u){return o=o.toLowerCase(),e.toLowerCase().split(o).length-1<2?t:(r.gUrls[o]=i.match(/^data:.+?\/.+?;base64,/)?i.replace(/\s/g,""):n.subParser("encodeAmpsAndAngles")(i,a,r),c?c+u:(u&&(r.gTitles[o]=u.replace(/"|'/g,"&quot;")),a.parseImgDimensions&&s&&l&&(r.gDimensions[o]={width:s,height:l}),""))};return e=(e=(e=(e+="¨0").replace(/^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm,t)).replace(/^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,t)).replace(/¨0/,"")})),n.subParser("tables",(function(e,a,r){if(!a.tables)return e;function t(e,t){return"<td"+t+">"+n.subParser("spanGamut")(e,a,r)+"</td>\n"}function o(e){var o,i=e.split("\n");for(o=0;o<i.length;++o)/^ {0,3}\|/.test(i[o])&&(i[o]=i[o].replace(/^ {0,3}\|/,"")),/\|[ \t]*$/.test(i[o])&&(i[o]=i[o].replace(/\|[ \t]*$/,"")),i[o]=n.subParser("codeSpans")(i[o],a,r);var s,l,c,u,_=i[0].split("|").map((function(e){return e.trim()})),d=i[1].split("|").map((function(e){return e.trim()})),f=[],m=[],g=[],h=[];for(i.shift(),i.shift(),o=0;o<i.length;++o)""!==i[o].trim()&&f.push(i[o].split("|").map((function(e){return e.trim()})));if(_.length<d.length)return e;for(o=0;o<d.length;++o)g.push(/^:[ \t]*--*$/.test(s=d[o])?' style="text-align:left;"':/^--*[ \t]*:[ \t]*$/.test(s)?' style="text-align:right;"':/^:[ \t]*--*[ \t]*:$/.test(s)?' style="text-align:center;"':"");for(o=0;o<_.length;++o)n.helper.isUndefined(g[o])&&(g[o]=""),m.push((c=g[o],u=void 0,u="",l=(l=_[o]).trim(),(a.tablesHeaderId||a.tableHeaderId)&&(u=' id="'+l.replace(/ /g,"_").toLowerCase()+'"'),"<th"+u+c+">"+(l=n.subParser("spanGamut")(l,a,r))+"</th>\n"));for(o=0;o<f.length;++o){for(var p=[],w=0;w<m.length;++w)n.helper.isUndefined(f[o][w]),p.push(t(f[o][w],g[w]));h.push(p)}return function(e,n){for(var a="<table>\n<thead>\n<tr>\n",r=e.length,t=0;t<r;++t)a+=e[t];for(a+="</tr>\n</thead>\n<tbody>\n",t=0;t<n.length;++t){a+="<tr>\n";for(var o=0;o<r;++o)a+=n[t][o];a+="</tr>\n"}return a+"</tbody>\n</table>\n"}(m,h)}return e=(e=(e=(e=r.converter._dispatch("tables.before",e,a,r)).replace(/\\(\|)/g,n.helper.escapeCharactersCallback)).replace(/^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm,o)).replace(/^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm,o),r.converter._dispatch("tables.after",e,a,r)})),n.subParser("underline",(function(e,a,r){return a.underline?(e=r.converter._dispatch("underline.before",e,a,r),e=(e=a.literalMidWordUnderscores?(e=e.replace(/\b___(\S[\s\S]*?)___\b/g,(function(e,n){return"<u>"+n+"</u>"}))).replace(/\b__(\S[\s\S]*?)__\b/g,(function(e,n){return"<u>"+n+"</u>"})):(e=e.replace(/___(\S[\s\S]*?)___/g,(function(e,n){return/\S$/.test(n)?"<u>"+n+"</u>":e}))).replace(/__(\S[\s\S]*?)__/g,(function(e,n){return/\S$/.test(n)?"<u>"+n+"</u>":e}))).replace(/(_)/g,n.helper.escapeCharactersCallback),e=r.converter._dispatch("underline.after",e,a,r)):e})),n.subParser("unescapeSpecialChars",(function(e,n,a){return e=(e=a.converter._dispatch("unescapeSpecialChars.before",e,n,a)).replace(/¨E(\d+)E/g,(function(e,n){var a=parseInt(n);return String.fromCharCode(a)})),a.converter._dispatch("unescapeSpecialChars.after",e,n,a)})),n.subParser("makeMarkdown.blockquote",(function(e,a){var r="";if(e.hasChildNodes())for(var t=e.childNodes,o=t.length,i=0;i<o;++i){var s=n.subParser("makeMarkdown.node")(t[i],a);""!==s&&(r+=s)}return"> "+(r=r.trim()).split("\n").join("\n> ")})),n.subParser("makeMarkdown.codeBlock",(function(e,n){var a=e.getAttribute("language"),r=e.getAttribute("precodenum");return"```"+a+"\n"+n.preList[r]+"\n```"})),n.subParser("makeMarkdown.codeSpan",(function(e){return"`"+e.innerHTML+"`"})),n.subParser("makeMarkdown.emphasis",(function(e,a){var r="";if(e.hasChildNodes()){r+="*";for(var t=e.childNodes,o=t.length,i=0;i<o;++i)r+=n.subParser("makeMarkdown.node")(t[i],a);r+="*"}return r})),n.subParser("makeMarkdown.header",(function(e,a,r){var t=new Array(r+1).join("#"),o="";if(e.hasChildNodes()){o=t+" ";for(var i=e.childNodes,s=i.length,l=0;l<s;++l)o+=n.subParser("makeMarkdown.node")(i[l],a)}return o})),n.subParser("makeMarkdown.hr",(function(){return"---"})),n.subParser("makeMarkdown.image",(function(e){var n="";return e.hasAttribute("src")&&(n+="!["+e.getAttribute("alt")+"](",n+="<"+e.getAttribute("src")+">",e.hasAttribute("width")&&e.hasAttribute("height")&&(n+=" ="+e.getAttribute("width")+"x"+e.getAttribute("height")),e.hasAttribute("title")&&(n+=' "'+e.getAttribute("title")+'"'),n+=")"),n})),n.subParser("makeMarkdown.links",(function(e,a){var r="";if(e.hasChildNodes()&&e.hasAttribute("href")){var t=e.childNodes,o=t.length;r="[";for(var i=0;i<o;++i)r+=n.subParser("makeMarkdown.node")(t[i],a);r+="](",r+="<"+e.getAttribute("href")+">",e.hasAttribute("title")&&(r+=' "'+e.getAttribute("title")+'"'),r+=")"}return r})),n.subParser("makeMarkdown.list",(function(e,a,r){var t="";if(!e.hasChildNodes())return"";for(var o=e.childNodes,i=o.length,s=e.getAttribute("start")||1,l=0;l<i;++l)void 0!==o[l].tagName&&"li"===o[l].tagName.toLowerCase()&&(t+=("ol"===r?s.toString()+". ":"- ")+n.subParser("makeMarkdown.listItem")(o[l],a),++s);return(t+="\n\x3c!-- --\x3e\n").trim()})),n.subParser("makeMarkdown.listItem",(function(e,a){for(var r="",t=e.childNodes,o=t.length,i=0;i<o;++i)r+=n.subParser("makeMarkdown.node")(t[i],a);return/\n$/.test(r)?r=r.split("\n").join("\n ").replace(/^ {4}$/gm,"").replace(/\n\n+/g,"\n\n"):r+="\n",r})),n.subParser("makeMarkdown.node",(function(e,a,r){r=r||!1;var t="";if(3===e.nodeType)return n.subParser("makeMarkdown.txt")(e,a);if(8===e.nodeType)return"\x3c!--"+e.data+"--\x3e\n\n";if(1!==e.nodeType)return"";switch(e.tagName.toLowerCase()){case"h1":r||(t=n.subParser("makeMarkdown.header")(e,a,1)+"\n\n");break;case"h2":r||(t=n.subParser("makeMarkdown.header")(e,a,2)+"\n\n");break;case"h3":r||(t=n.subParser("makeMarkdown.header")(e,a,3)+"\n\n");break;case"h4":r||(t=n.subParser("makeMarkdown.header")(e,a,4)+"\n\n");break;case"h5":r||(t=n.subParser("makeMarkdown.header")(e,a,5)+"\n\n");break;case"h6":r||(t=n.subParser("makeMarkdown.header")(e,a,6)+"\n\n");break;case"p":r||(t=n.subParser("makeMarkdown.paragraph")(e,a)+"\n\n");break;case"blockquote":r||(t=n.subParser("makeMarkdown.blockquote")(e,a)+"\n\n");break;case"hr":r||(t=n.subParser("makeMarkdown.hr")(e,a)+"\n\n");break;case"ol":r||(t=n.subParser("makeMarkdown.list")(e,a,"ol")+"\n\n");break;case"ul":r||(t=n.subParser("makeMarkdown.list")(e,a,"ul")+"\n\n");break;case"precode":r||(t=n.subParser("makeMarkdown.codeBlock")(e,a)+"\n\n");break;case"pre":r||(t=n.subParser("makeMarkdown.pre")(e,a)+"\n\n");break;case"table":r||(t=n.subParser("makeMarkdown.table")(e,a)+"\n\n");break;case"code":t=n.subParser("makeMarkdown.codeSpan")(e,a);break;case"em":case"i":t=n.subParser("makeMarkdown.emphasis")(e,a);break;case"strong":case"b":t=n.subParser("makeMarkdown.strong")(e,a);break;case"del":t=n.subParser("makeMarkdown.strikethrough")(e,a);break;case"a":t=n.subParser("makeMarkdown.links")(e,a);break;case"img":t=n.subParser("makeMarkdown.image")(e,a);break;default:t=e.outerHTML+"\n\n"}return t})),n.subParser("makeMarkdown.paragraph",(function(e,a){var r="";if(e.hasChildNodes())for(var t=e.childNodes,o=t.length,i=0;i<o;++i)r+=n.subParser("makeMarkdown.node")(t[i],a);return r.trim()})),n.subParser("makeMarkdown.pre",(function(e,n){var a=e.getAttribute("prenum");return"<pre>"+n.preList[a]+"</pre>"})),n.subParser("makeMarkdown.strikethrough",(function(e,a){var r="";if(e.hasChildNodes()){r+="~~";for(var t=e.childNodes,o=t.length,i=0;i<o;++i)r+=n.subParser("makeMarkdown.node")(t[i],a);r+="~~"}return r})),n.subParser("makeMarkdown.strong",(function(e,a){var r="";if(e.hasChildNodes()){r+="**";for(var t=e.childNodes,o=t.length,i=0;i<o;++i)r+=n.subParser("makeMarkdown.node")(t[i],a);r+="**"}return r})),n.subParser("makeMarkdown.table",(function(e,a){var r,t,o="",i=[[],[]],s=e.querySelectorAll("thead>tr>th"),l=e.querySelectorAll("tbody>tr");for(r=0;r<s.length;++r){var c=n.subParser("makeMarkdown.tableCell")(s[r],a),u="---";if(s[r].hasAttribute("style"))switch(s[r].getAttribute("style").toLowerCase().replace(/\s/g,"")){case"text-align:left;":u=":---";break;case"text-align:right;":u="---:";break;case"text-align:center;":u=":---:"}i[0][r]=c.trim(),i[1][r]=u}for(r=0;r<l.length;++r){var _=i.push([])-1,d=l[r].getElementsByTagName("td");for(t=0;t<s.length;++t){var f=" ";void 0!==d[t]&&(f=n.subParser("makeMarkdown.tableCell")(d[t],a)),i[_].push(f)}}var m=3;for(r=0;r<i.length;++r)for(t=0;t<i[r].length;++t){var g=i[r][t].length;g>m&&(m=g)}for(r=0;r<i.length;++r){for(t=0;t<i[r].length;++t)i[r][t]=1===r?":"===i[r][t].slice(-1)?n.helper.padEnd(i[r][t].slice(-1),m-1,"-")+":":n.helper.padEnd(i[r][t],m,"-"):n.helper.padEnd(i[r][t],m);o+="| "+i[r].join(" | ")+" |\n"}return o.trim()})),n.subParser("makeMarkdown.tableCell",(function(e,a){var r="";if(!e.hasChildNodes())return"";for(var t=e.childNodes,o=t.length,i=0;i<o;++i)r+=n.subParser("makeMarkdown.node")(t[i],a,!0);return r.trim()})),n.subParser("makeMarkdown.txt",(function(e){var a=e.nodeValue;return a=(a=a.replace(/ +/g," ")).replace(/¨NBSP;/g," "),(a=(a=(a=(a=(a=(a=(a=(a=n.helper.unescapeHTMLEntities(a)).replace(/([*_~|`])/g,"\\$1")).replace(/^(\s*)>/g,"\\$1>")).replace(/^#/gm,"\\#")).replace(/^(\s*)([-=]{3,})(\s*)$/,"$1\\$2$3")).replace(/^( {0,3}\d+)\./gm,"$1\\.")).replace(/^( {0,3})([+-])/gm,"$1\\$2")).replace(/]([\s]*)\(/g,"\\]$1\\(")).replace(/^ {0,3}\[([\S \t]*?)]:/gm,"\\[$1]:")})),r.exports?r.exports=n:this.showdown=n}.call(t.exports)),t.exports),i=e(o);async function s(e,a,r,t,o,i,s,l,c="bot"){var u,_,d,f,m,g,h;await t(e),(null===(_=null===(u=a.controlData)||void 0===u?void 0:u.data)||void 0===_?void 0:_.source)&&(a.controlData.data.source.customCss=s||"",a.controlData.data.source.customJs=i||""),a.isExpanded=l;const p=n(a,c),w=null===(g=null===(m=null===(f=null===(d=a.controlData)||void 0===d?void 0:d.data)||void 0===f?void 0:f.source)||void 0===m?void 0:m.carousel)||void 0===g?void 0:g.type;let b=null===(h=r.shadowRoot)||void 0===h?void 0:h.querySelector(`#${e.id}`);var k;"kb"===c&&(b=r.shadowRoot.querySelector(`#${e.id}`).shadowRoot.querySelector(`#${e.controlDomId}`)),b&&p&&(b.appendChild(p),b.style.width="98%","custom"!==w&&"list"!==w&&"slider"!==w||(b.classList.remove("p-2.5"),b.classList.add("p-0"),b.classList.add("md:p-2.5")),await(k=p,new Promise((e=>{const n=()=>{k.removeEventListener("componentReady",n),e()};k.addEventListener("componentReady",n);const a=()=>{if("true"===k.getAttribute("data-component-ready"))return k.removeEventListener("componentReady",n),void e();setTimeout(a,100)};setTimeout(a,100),setTimeout((()=>{k.removeEventListener("componentReady",n),e()}),15e3)}))),e.itemComponent=a,e.controlType=a.controlType,e.isLoading=!1,o(e))}export{s as p,i as s}
@@ -1 +0,0 @@
1
- import{E as t,r as i,a as e,e as s,h as o,f as n,d as a}from"./p-BNpVu1WU.js";import{b as r,l as h}from"./p-SyQT2Pr3.js";import{s as l,p as d}from"./p-DoBD_KPG.js";import{L as c,a as v}from"./p-8-Jaom_c.js";import{c as u,j as p,H as g,h as m,I as f,J as b,u as w,e as y,K as x,k,L as C,b as S}from"./p-y3Go1NSi.js";import{H as A}from"./p-D5m1leH0.js";import{a as E}from"./p-odmyXuxx.js";import{e as z}from"./p-Bbow4UZX.js";import{i as T,g as I,b as L,p as N,r as M,c as B}from"./p-B_moTKAE.js";import{r as $}from"./p-DAGa-uHD.js";import{c as D}from"./p-DXBxSLgN.js";import{D as O,w as P,h as _}from"./p-NAKC5NP9.js";import{f as j,s as R}from"./p-C1eU4fpM.js";import{a as U}from"./p-BQ6J3hmg.js";import{e as H,p as F}from"./p-CnadO0kA.js";import"./p-Dj2_voLF.js";const G=t.DATA_MODE||"prod";class q extends Error{constructor(t="Live agent session authentication has expired"){super(t),this.name="LiveAgentAuthExpiredError"}}const J=new class{constructor(){this.events=new Map}on(t,i){this.events.has(t)||this.events.set(t,new Set),this.events.get(t).add(i)}off(t,i){var e;null===(e=this.events.get(t))||void 0===e||e.delete(i)}emit(t,i){var e;null===(e=this.events.get(t))||void 0===e||e.forEach((t=>t(i)))}},Z=new c("SalesforceLiveAgentProvider",{logLevel:v.Info,remoteLoggingUrl:""});class V{constructor(){this.configSettings=null,this.sessionContext=null,this.endpointSSE="",this.configSettings=null,this.sessionContext=null,this.endpointSSE=u(G)}async authenticate(){var t,i,e;const s=await fetch(`${null===(t=this.configSettings)||void 0===t?void 0:t.instanceUrl}/iamessage/api/v2/authorization/unauthenticated/access-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orgId:null===(i=this.configSettings)||void 0===i?void 0:i.orgId,esDeveloperName:null===(e=this.configSettings)||void 0===e?void 0:e.messagingChannelId,capabilitiesVersion:"1",platform:"Web",context:{appName:"DemoMessagingClient",clientVersion:"1.0.0"}})});if(!s.ok)throw new Error(`Failed to authenticate with Salesforce MIAW: [error]: ${s.status} ${s.statusText}`);const o=await s.json();this.sessionContext||(this.sessionContext={}),this.sessionContext.accessToken=o.accessToken,this.sessionContext.sessionId=o.lastEventId}async startSession(){var t,i,e,s,o,n,a,r,h,l,d,c;const v={};if(null===(i=null===(t=this.sessionContext)||void 0===t?void 0:t.extraPrechatFormDetails)||void 0===i?void 0:i.length)for(const t of this.sessionContext.extraPrechatFormDetails)(null==t?void 0:t.label)&&"string"==typeof t.value&&""!==t.value.trim()&&(v[t.label]=t.value);const u=crypto.randomUUID().toLowerCase(),p=await fetch(`${null===(e=this.configSettings)||void 0===e?void 0:e.instanceUrl}/iamessage/api/v2/conversation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${null===(s=this.sessionContext)||void 0===s?void 0:s.accessToken}`},body:JSON.stringify({conversationId:u,esDeveloperName:null===(o=this.configSettings)||void 0===o?void 0:o.messagingChannelId,routingAttributes:Object.assign({recordId:null===(n=this.sessionContext)||void 0===n?void 0:n.conversationId},v)})});if(!p.ok)throw new Error(`Conversation start failed: ${p.status} ${p.statusText}`);if(p.ok){this.sessionContext.conversationId=u,J.emit("liveAgentReady",void 0),J.emit("AGENT_SESSION_INFO",{sessionId:this.sessionContext.accessToken,conversationId:this.sessionContext.conversationId});let t="";if(null===(r=null===(a=this.sessionContext)||void 0===a?void 0:a.extraPrechatFormDetails)||void 0===r?void 0:r.length){const i=this.sessionContext.extraPrechatFormDetails.filter((t=>(null==t?void 0:t.label)&&"string"==typeof t.value&&""!==t.value.trim()&&!1!==t.displayToAgent)).map((t=>`${t.label}: ${t.value}`));i.length>0&&(t+=`Pre-chat details:\n${i.join("\n")}\n\n`)}(null===(h=this.sessionContext)||void 0===h?void 0:h.initialMessages)&&(null===(l=this.sessionContext)||void 0===l?void 0:l.initialMessages.length)>0&&(null===(d=this.sessionContext.initialMessages[0])||void 0===d||d.messages.forEach((i=>{(null==i?void 0:i.text)&&(i.text=i.text.replace(/<\/?p>/g,""),t+=(null==i?void 0:i.isUser)?`User: ${i.text}\n`:`Bot: ${i.text}\n`)}))),t&&this.sendMessage({isNewSession:!0,sessionId:(null===(c=this.sessionContext)||void 0===c?void 0:c.sessionId)||"",message:t}),this.listenToMessages()}}async initialize(t){var i,e,s;if(Z.debug("Initializing Salesforce Live Agent Provider"),this.configSettings||(this.configSettings=(null==t?void 0:t.config)||this.configSettings),!(null===(i=this.configSettings)||void 0===i?void 0:i.instanceUrl)||!(null===(e=this.configSettings)||void 0===e?void 0:e.orgId)||!(null===(s=this.configSettings)||void 0===s?void 0:s.messagingChannelId))throw new Error("Missing required configuration settings for Salesforce Live Agent Provider");this.sessionContext||(this.sessionContext={accessToken:"",lastMessageReadTime:0,sessionId:"",initialMessages:(null==t?void 0:t.messageHistory)||[],isActive:!1,conversationId:(null==t?void 0:t.conversationId)||crypto.randomUUID().toLowerCase(),userId:(null==t?void 0:t.userId)||"",extraPrechatFormDetails:(null==t?void 0:t.extraPrechatFormDetails)||[]});try{await this.authenticate(),await this.startSession()}catch(t){throw Z.error("Error initializing Salesforce Live Agent Provider:",t),t}}parseMessageEntries(t){return t.filter((t=>{var i,e,s,o;return"Message"===t.entryType&&(null===(s=null===(e=null===(i=t.entryPayload)||void 0===i?void 0:i.abstractMessage)||void 0===e?void 0:e.staticContent)||void 0===s?void 0:s.text)&&"EndUser"!=(null===(o=t.sender)||void 0===o?void 0:o.role)})).map((t=>({id:t.entryPayload.abstractMessage.id,content:t.entryPayload.abstractMessage.staticContent.text,sender:{role:this.mapSenderRole(t.sender.role),displayName:t.senderDisplayName||"Unknown"},timestamp:t.clientTimestamp})))}handleParticipantChange(t){try{if(Z.debug("Participant change event received:",t.data),!t.data)return;const i=JSON.parse(t.data),e=JSON.parse(i.conversationEntry.entryPayload).entries;let s=[];e.forEach((t=>{var i,e;const o=crypto.randomUUID();"add"===t.operation&&"agent"===t.participant.role.toLowerCase()&&s.push({id:o,isUser:!1,conversationId:o,type:"system",text:`${t.displayName} has joined the chat`,timestamp:new Date,sender:{role:"agent",displayName:null!==(i=null==t?void 0:t.displayName)&&void 0!==i?i:"System"}}),"remove"===t.operation&&"agent"===t.participant.role.toLowerCase()&&s.push({id:o,type:"system",text:`${t.displayName} has left the chat`,conversationId:o,isUser:!1,timestamp:new Date,sender:{role:"agent",displayName:null!==(e=null==t?void 0:t.displayName)&&void 0!==e?e:"System"}})})),(null==s?void 0:s.length)>0&&J.emit("AGENT_EVENT",s)}catch(t){Z.error("Error handling participant change event:",t)}}mapEntriesToMessages(t){return t.map((t=>({id:t.entryPayload.abstractMessage.id,text:t.entryPayload.abstractMessage.staticContent.text,sender:{role:this.mapSenderRole(t.sender.role),displayName:t.senderDisplayName||"Unknown"},type:"endUser"===t.sender.role?"user":"ai",timestamp:new Date(t.timestamp),isUser:!1,conversationId:t.entryPayload.abstractMessage.id})))}handleParticipantMessage(t){var i,e;try{if(!t.data)return;const s=JSON.parse(t.data);if("EndUser"===(null===(e=null===(i=null==s?void 0:s.conversationEntry)||void 0===i?void 0:i.sender)||void 0===e?void 0:e.role))return void Z.debug("Ignoring message from EndUser role");const o=JSON.parse(s.conversationEntry.entryPayload);s.conversationEntry.entryPayload=o;const n=this.mapEntriesToMessages([s.conversationEntry]);(null==n?void 0:n.length)>0&&J.emit("AGENT_MESSAGE",n)}catch(t){Z.error("Error handling participant message event:",t)}}mapSenderRole(t){const i=t.toLowerCase();return"chatbot"===i?"agent":"enduser"===i?"endUser":"unknown"}handleSessionStatusChange(t){try{if(!t.data)return;const i=JSON.parse(t.data),e=JSON.parse(i.conversationEntry.entryPayload);Z.debug("Session status changed:",null==e?void 0:e.sessionStatus),"Active"===(null==e?void 0:e.sessionStatus)&&J.emit("AGENT_SESSION_CREATED",!0)}catch(t){Z.error("Error handling session status change event:",t)}}listenToMessages(){var t,i,e;Z.debug("Listening to messages from Salesforce Live Agent");const s=new EventSource(`${this.endpointSSE}/bot/liveagent/sse?token=${null===(t=this.sessionContext)||void 0===t?void 0:t.accessToken}&org_id=${null===(i=this.configSettings)||void 0===i?void 0:i.orgId}&sse_url=${null===(e=this.configSettings)||void 0===e?void 0:e.instanceUrl}`,{withCredentials:!0});if(!s)throw Z.error("Failed to create EventSource"),new Error("Failed to create EventSource");s.onerror=()=>{Z.error("❌ SSE Error: Connection lost or error occurred"),J.emit("AGENT_ERROR",!0),s.close()},s.onopen=()=>{Z.debug("✅ SSE Connection Established")},s.onmessage=t=>{var i,e;try{const o=JSON.parse(t.data);switch(Z.debug("📡 Message Received on entrytype:",null===(i=null==o?void 0:o.conversationEntry)||void 0===i?void 0:i.entryType," --- ",t.data),null===(e=null==o?void 0:o.conversationEntry)||void 0===e?void 0:e.entryType){case"RoutingResult":case"RoutingWorkResult":Z.debug("Conversation Routing Result:",t.data),J.emit("FINDING_AGENT",t.data);break;case"ParticipantChanged":Z.debug("Conversation ParticipantChanged event received:",null==t?void 0:t.data),this.handleParticipantChange(t);break;case"Message":this.handleParticipantMessage(t);break;case"CloseConversation":J.emit("CONVERSATION_CLOSED",!0),s.close();break;case"DeliveryAcknowledgement":case"ReadAcknowledgement":Z.debug("Conversation event received:",null==t?void 0:t.data);break;case"TypingStartedIndicator":J.emit("TYPING_STARTED",!0);break;case"TypingStoppedIndicator":Z.debug("Typing indicator received:",t.data),J.emit("TYPING_STOPPED",!0);break;case"StreamingToken":Z.debug("Streaming token received",t.data);break;case"ProgressIndicator":Z.debug("Progress indicator received",t.data);break;case"SessionStatusChanged":Z.debug("Session status changed event received",t.data),this.handleSessionStatusChange(t)}}catch(t){return void Z.error("Failed to parse event data:",t)}}}async startChat(t){await this.initialize(t)}async resumeChat(t){var i,e,s;if(!(null==t?void 0:t.sessionId)||!(null==t?void 0:t.conversationId))throw new Error("resumeChat requires sessionId (accessToken) and conversationId");if(this.configSettings=(null==t?void 0:t.config)||this.configSettings,!(null===(i=this.configSettings)||void 0===i?void 0:i.instanceUrl)||!(null===(e=this.configSettings)||void 0===e?void 0:e.orgId)||!(null===(s=this.configSettings)||void 0===s?void 0:s.messagingChannelId))throw new Error("Missing required configuration settings for resuming Salesforce Live Agent session");this.sessionContext={accessToken:t.sessionId,conversationId:t.conversationId,userId:t.userId||"",isActive:!0,lastMessageReadTime:0};const o=new URL(`${this.configSettings.instanceUrl}/iamessage/api/v2/conversation/${this.sessionContext.conversationId}/entries`);o.searchParams.set("limit","1"),o.searchParams.set("direction","FromEnd");const n=await fetch(o.toString(),{method:"GET",headers:{Authorization:`Bearer ${this.sessionContext.accessToken}`}});if(401===n.status||403===n.status)throw new q;if(!n.ok)throw new Error(`Session probe failed: ${n.status} ${n.statusText}`);J.emit("liveAgentReady",void 0),this.listenToMessages()}async sendMessage(t){var i,e,s,o;if(!(await fetch(`${null===(i=this.configSettings)||void 0===i?void 0:i.instanceUrl}/iamessage/api/v2/conversation/${null===(e=this.sessionContext)||void 0===e?void 0:e.conversationId}/message`,{method:"POST",headers:{Authorization:`Bearer ${null===(s=this.sessionContext)||void 0===s?void 0:s.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({message:{id:crypto.randomUUID(),messageType:"StaticContentMessage",staticContent:{formatType:"Text",text:null==t?void 0:t.message}},esDeveloperName:null===(o=this.configSettings)||void 0===o?void 0:o.messagingChannelId,isNewMessagingSession:(null==t?void 0:t.isNewSession)||!1,language:""})})).ok)throw new Error("Failed to send message")}async pollMessages(t){return new Promise((async(t,i)=>{this.sessionContext.lastMessageReadTime=0;const e=async()=>{var s,o,n;try{const i=new URL(`${null===(s=this.configSettings)||void 0===s?void 0:s.instanceUrl}/iamessage/api/v2/conversation/${null===(o=this.sessionContext)||void 0===o?void 0:o.conversationId}/entries`);i.searchParams.append("limit","50"),i.searchParams.append("direction","FromEnd"),i.searchParams.append("startTimestamp",`${this.sessionContext.lastMessageReadTime}`);const a=await fetch(i.toString(),{method:"GET",headers:{Authorization:`Bearer ${null===(n=this.sessionContext)||void 0===n?void 0:n.accessToken}`}}),r=await a.json(),h=this.parseMessageEntries(r.conversationEntries).sort(((t,i)=>t.timestamp-i.timestamp)).map((t=>{var i;return{text:t.content,isUser:!1,id:t.id,timestamp:new Date(t.timestamp),images:[],conversationId:t.id,formModel:"",surveyDomId:"",sender:{role:"endUser"===t.sender.role?"user":"ai",displayName:null===(i=null==t?void 0:t.sender)||void 0===i?void 0:i.displayName}}}));(null==h?void 0:h.length)>0&&(this.sessionContext.lastMessageReadTime=(new Date).getTime(),J.emit("messageReceived",h)),t(h),setTimeout(e,5e3)}catch(t){Z.error("Error on Polling",t.toString()),i(t)}};await e()}))}async isChatActive(t){return Z.debug("sessionId",t),!!this.sessionContext&&this.sessionContext.isActive}async endChat(t){var i,e,s,o,n;if(null===(i=this.sessionContext)||void 0===i?void 0:i.conversationId){const t=await fetch(`${null===(e=this.configSettings)||void 0===e?void 0:e.instanceUrl}/iamessage/api/v2/conversation/${null===(s=this.sessionContext)||void 0===s?void 0:s.conversationId}?esDeveloperName=${null===(o=this.configSettings)||void 0===o?void 0:o.messagingChannelId}`,{method:"DELETE",headers:{Authorization:`Bearer ${null===(n=this.sessionContext)||void 0===n?void 0:n.accessToken}`,"Content-Type":"application/json"}});(null==t?void 0:t.ok)||Z.warn("Failed to end the chat")}}async getTranscript(t){return Z.debug("sessionId",t),this.sessionContext&&this.sessionContext.initialMessages||[]}}class K{constructor(){}static getProvider(t){if("salesforce"!==(null!=t?t:this.provider))throw new Error("Unsupported Live Agent provider");return this.providerInstance=new V,this.providerInstance}}K.provider="salesforce";class Y{constructor(){this.logger=new c("LiveAgentEventHandler",{logLevel:v.Warn}),this.handleAgentMessage=t=>{let i="";if((null==t?void 0:t.length)>0)for(const e of t)i+=(null==e?void 0:e.text)+"\n\n";return i},this.sendMessage=t=>{this.liveAgentProvider?(this.logger.debug("Sending message to Live Agent:",t.message),this.liveAgentProvider.sendMessage(t)):this.logger.warn("Live Agent provider is not initialized. Cannot send message.")},this.disconnectLiveAgent=()=>{this.liveAgentProvider?(this.logger.debug("Disconnecting from Live Agent"),this.liveAgentProvider.endChat("")):this.logger.warn("Live Agent provider is not initialized. Cannot disconnect.")}}addAgentEventMessage(t){const i=document.createElement("div");return t.forEach((t=>{const e=document.createElement("div");e.className="py-2 border-b border-gray-200 text-center";const s=document.createElement("span");s.className="text-[10px] font-medium text-gray-500 tracking-wide",s.textContent=(null==t?void 0:t.text)||"Agent event",e.appendChild(s),i.appendChild(e)})),i}async connectToLiveAgent(t="salesforce",i){try{switch(this.logger.debug("Connected to Live Agent",t," --- ",i),t){case"salesforce":this.logger.debug("Using Salesforce Live Agent Provider"),this.liveAgentProvider=K.getProvider(t),await this.liveAgentProvider.startChat(i);break;case"custom":this.logger.debug("Using Custom Live Agent Provider");break;case"liveagent":this.logger.debug("Using LiveAgent Live Agent Provider");break;default:throw new Error(`Unsupported Live Agent provider: ${t}`)}}catch(t){throw this.logger.error("Error connecting to Live Agent:",t),t}}async resumeLiveAgentSession(t="salesforce",i){try{if(this.logger.debug("Resuming Live Agent session",t," --- ",i),this.liveAgentProvider=K.getProvider(t),!this.liveAgentProvider.resumeChat)throw new Error(`Provider '${t}' does not support session resume`);await this.liveAgentProvider.resumeChat(i)}catch(t){throw this.logger.error("Error resuming Live Agent session:",t),t}}}function Q(t){return!!function(t){return"object"==typeof t&&null!==t}(t)&&Array.isArray(t.messages)&&"boolean"==typeof t.isMinimized&&"boolean"==typeof t.isOpened&&"boolean"==typeof t.isExpanded&&"string"==typeof t.conversationId&&"string"==typeof t.projectId&&"boolean"==typeof t.newChat}function X(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t).length:t.length}function W(t,i,e={}){var s,o,n,a;if("undefined"==typeof document)return!1;const r=null!==(s=e.path)&&void 0!==s?s:"/",h=null!==(o=e.sameSite)&&void 0!==o?o:"Lax",l=null!==(n=e.secure)&&void 0!==n?n:"undefined"!=typeof window&&"https:"===window.location.protocol,d=e.domain;let c=`${t}=${encodeURIComponent(i)}`;if(d){if(!/^[a-zA-Z0-9._-]+$/.test(d))return console.warn("AI12Z: Invalid cookie domain characters"),!1;c+=`; Domain=${d}`}c+=`; Path=${r}`,c+=`; SameSite=${h}`,c+="; Max-Age="+24*(null!==(a=e.maxAgeDays)&&void 0!==a?a:7)*60*60,l&&(c+="; Secure");const v=X(c);return v>4e3?(console.warn(`AI12Z: Cookie value exceeds safe limit (${v} bytes). Cookie not set.`),!1):(document.cookie=c,!0)}function tt(t,i,e={}){var s,o;const n=Object.assign({},i);(null===(s=n.messages)||void 0===s?void 0:s.length)>0&&(n.messages=[]);const a=JSON.stringify(n),r=encodeURIComponent(a),h=null!==(o=e.maxBytes)&&void 0!==o?o:3800;return X(r)>h?(console.warn(`AI12Z: Cookie '${t}' exceeds size limit and was skipped`),!1):W(t,a,e)}function it(t){if(!t)return;if("undefined"==typeof window)return;const i=t.replace(/^\./,""),e=window.location.hostname;if(e===i||e.endsWith("."+i))return t;console.warn("AI12Z: subDomain does not match current host")}const et=class{constructor(s){i(this,s),this.messageSent=e(this,"messageSent",7),this.messageReceived=e(this,"messageReceived",7),this.close=e(this,"close",7),this.open=e(this,"open",7),this.minimize=e(this,"minimize",7),this.errored=e(this,"errored",7),this.formSubmitted=e(this,"formSubmitted",7),this.isElementAvailable=e(this,"isElementAvailable",7),this.cdnPath="https://cdn.ai12z.net/assets/bot",this.surveyCDNPath="https://cdn.ai12z.net/pkg/surveyjs",this.styles=["https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.11.1/styles/default.min.css","https://cdn.ai12z.net/assets/bot/v2/tailwind.min.css"],this.liveAgentEventHandler=new Y,this.customStyle="",this.customJS="",this.dataOverrideFunction=null,this.ignoreChunks=!1,this.unreadCount=0,this.liveAgentButtonText="Talk to a Live Agent",this.isLiveAgentEnabled=!1,this.isTypingIndicatorVisible=!1,this.dataKey=t.DATA_KEY||"",this.dataMode=t.DATA_MODE||"prod",this.dataAttributes={},this.excludeTags=[],this.includeTags=[],this.botSettings={},this.canRender=!0,this.voiceType="default",this.voice="en-US",this.showSubmit=!1,this.hideAllButtons=!1,this.showMenu=!1,this.isProse=!0,this.isLiveAgent=!1,this.isConnectingLiveAgent=!1,this.showWelcomeScreen=!0,this.showHistory=!1,this.conversationId="",this.surveyDomId="",this.searchResults={},this.buttons=[],this.currentDomId="",this.messages=[],this.questionCounter=0,this.timestamp="",this.rowCount=1,this.isBot=!1,this.conversationHistory=[],this.query="",this.scriptArray=[],this.imagesBase64List=[],this.focusedIndex=-1,this.isAnimated=!1,this.isMinimized=!1,this.isStreaming=!1,this.showErrorMessage=!1,this.errorMessage="",this.emptyMessageError=!1,this.isOpened=!1,this.isContent=!1,this.isToggled=!1,this.showPrivacy=!1,this.isRendered=!1,this.showShortcutsDialog=!1,this.showLiveAgentEndDialog=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.liveAgentProviderName="salesforce",this.liveAgentListenersRegistered=!1,this.shortcuts=O,this.announceMessage="",this.messageRefs=[],this.handlePaste=t=>{var i;t.preventDefault();const e=(null===(i=t.clipboardData)||void 0===i?void 0:i.getData("text"))||"";if(this.inputEl&&e){const t=this.inputEl,i=t.selectionStart,s=t.selectionEnd,o=t.value,n=o.substring(0,i)+e+o.substring(s);t.value=n;const a=i+e.length;t.setSelectionRange(a,a),setTimeout((()=>{this.adjustHeight()}),0)}},this.checkHistory=()=>{const t=localStorage.getItem(`${this.visitorID}`);let i=[];t&&(i=JSON.parse(t),i=i.filter((t=>{var i;return t.projectId===(null===(i=this.botSettings)||void 0===i?void 0:i.pId)}))),this.showHistory=i.length>0&&"v1"===this.botSettings.botVersion},this.initializeScript=t=>T(t,this.mainObject),this.renderSurvey=async t=>{if(this.surveyDomId){await this.assetLoader.loadSurveyDependencies();try{await $({chat:t,surveyDomId:this.surveyDomId,shadowRoot:this.el.shadowRoot,config:{dataKey:this.dataKey,dataMode:this.dataMode,dataAttributes:this.dataAttributes,formSubmitRenderCallback:t=>{this.handleSurveyCompletionRender(t)},onSubmitError:t=>{var i;const e=null===(i=this.el.shadowRoot)||void 0===i?void 0:i.querySelector(`#${this.surveyDomId}`);e?e.innerHTML="Form submission blocked by validation"!==t?"Failed to submit form":"Submission blocked due to suspicious activity.":console.error(`Survey element not found for DOM ID: ${this.surveyDomId}`)}}})}catch(t){console.error("Error rendering survey:",t)}}else console.warn("Survey DOM ID is empty")},this.handleMessage=(t,i)=>{const e=new l.Converter,s=this.el.shadowRoot.querySelector(`#${i}`);if(!s)return void console.error(`Message bubble with ID ${i} not found.`);var o=s.getAttribute("data-bubbleText")||"";s.setAttribute("data-bubbleText",o+=t),s.setAttribute("aria-label",o),s.setAttribute("role","log"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","false");let n=e.makeHtml(o);s.innerHTML=n},this.updateScreenSize=()=>{window.innerWidth<=767&&(this.isMinimized=!this.isOpened)},this.handleSend=async(t,i={})=>{const{isHide:e=!1,isLiveChatEnded:s=!1}=i;this.emptyMessageError=!1,this.surveyDomId="",this.announce("Message sent successfully"),this.isLiveAgent||(this.questionCounter=this.questionCounter+1,localStorage.setItem("ai12z-bot-data",JSON.stringify({qCounter:this.questionCounter})));const o=t;this.inputEl&&(this.inputEl.value=o),0===this.messages.length&&this.botSettings.autoResetTimer>0&&this.startTimer(),this.showWelcomeScreen&&"v1"===this.botSettings.botVersion&&(this.showWelcomeScreen=!1),0===this.messages.length?await this.socketConnection():this.socket&&this.socket.connected||await this.socketConnection();const n=(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});this.messages=[...this.messages,{text:o,isUser:!0,id:`user-${p()}`,timestamp:n,images:this.imagesBase64List,conversationId:this.conversationId,isLoading:!1,formModel:{},surveyDomId:"",isHide:null!=e&&e},{text:this.botSettings.maxQuestion>0&&this.questionCounter>this.botSettings.maxQuestion&&!this.isLiveAgent&&!s?""!==this.botSettings.msgLimit?this.botSettings.msgLimit:"Sorry, you have reached the maximum number of questions.":"",isUser:!1,id:"",timestamp:"",isLoading:!(this.botSettings.maxQuestion>0&&this.questionCounter>this.botSettings.maxQuestion&&!this.isLiveAgent&&!s),images:[],conversationId:this.conversationId,formModel:{},surveyDomId:""}],2===this.messages.length&&(this.visitorID=g()),this.checkHistory(),setTimeout((()=>{this.scrollToBottom()}),100),this.botSettings.maxQuestion>0&&this.questionCounter>this.botSettings.maxQuestion&&!this.isLiveAgent&&!s?this.inputEl.value="":(this.currentDomId="",this.isLiveAgent?(this.messages=this.messages.slice(0,-1),this.liveAgentEventHandler.sendMessage({sessionId:"",message:this.inputEl.value}),this.updateBotState(),this.inputEl.value&&(this.inputEl.value=""),this.query=""):(this.checkLiveAgentMode(),this.isStreaming=!0,this.ignoreChunks=!1,this.invokeSocket()));const a=this.el.shadowRoot.querySelector("#previewContainer");a&&(a.innerHTML=""),this.imagesBase64List=[],this.rowCount=1,this.showSubmit=!1},this.agentMessageCreated=t=>{if(""===this.currentDomId){const t=this.messages[this.messages.length-1];if(t.sender&&null!==t.sender&&"system"!==t.type){const{id:t,idChanged:i}=H(this.currentDomId,this.messages,"chatbot");this.currentDomId=t,i&&(this.messages=[...this.messages])}else{const t=m(this.conversationId);this.currentDomId=`chatbot-${p()}`,t.id=this.currentDomId,t.isLoading=!1,this.messages=[...this.messages,t]}}const i=this.liveAgentEventHandler.handleAgentMessage(t);i&&(this.announce("New message received from live agent"),requestAnimationFrame((()=>{var e;const s=null===(e=this.el.shadowRoot)||void 0===e?void 0:e.querySelector(`#${this.currentDomId}`);if(s){const e=new l.Converter;let o=s.getAttribute("data-bubbleText")||"";o=`${o} \n\n ${i}`,s.setAttribute("data-bubbleText",o);let n=e.makeHtml(o);this.updateConversations(n,t[0]),this.updateBotState()}setTimeout((()=>{this.scrollToBottom()}),10)})))},this.addEventMessage=t=>{const i=this.liveAgentEventHandler.addAgentEventMessage([{text:t}]);if(""===this.currentDomId&&this.messages.length>0&&(this.currentDomId=this.messages[this.messages.length-1].id),i&&this.currentDomId){const t=this.el.shadowRoot.querySelector(`#${this.currentDomId}`);if(t)return t.parentNode.appendChild(i),i}return null},this.findingAgent=()=>{this.announce("Finding a live agent for you"),this.isTypingIndicatorVisible=!1,this.removeFindingAgentPlaceholder();const t=this.addEventMessage("Connecting to a live agent...");t&&t.setAttribute("data-finding-agent","true"),this.currentDomId=""},this.handleTypingStarted=t=>{this.isTypingIndicatorVisible=t},this.handleTypingStopped=()=>{this.isTypingIndicatorVisible=!1},this.handleAgentError=()=>{this.addEventMessage("Something went wrong with Live Agent, please try again later"),this.isLiveAgent=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.isTypingIndicatorVisible=!1,this.liveAgentEventHandler.disconnectLiveAgent(),this.clearEvents(),this.liveAgentButtonText="Talk to a Live Agent",this.announce("Live agent connection failed")},this.handleAgentConversationEnded=()=>{this.isLiveAgent&&(this.addEventMessage("Conversation closed with Live Agent"),this.announce("Live agent chat ended")),this.isLiveAgent=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.isTypingIndicatorVisible=!1,this.liveAgentButtonText="Talk to a Live Agent",this.clearEvents()},this.agentEventHandler=t=>{if(this.isTypingIndicatorVisible=!1,(null==t?void 0:t.length)>0){this.isLiveAgentEnabled&&""===this.currentDomId&&(this.currentDomId=this.messages[this.messages.length-1].id);const i=t.map((t=>({id:t.id||`system-${p()}`,text:t.text||"",type:"system",isUser:!1,isLoading:!1,timestamp:new Date,images:[],conversationId:this.conversationId,formModel:{},surveyDomId:"",sender:t.sender||null})));this.messages=[...this.messages,...i],this.updateBotState(),this.removeFindingAgentPlaceholder(),this.inputEl&&(this.inputEl.value=""),this.currentDomId=""}},this.handleAgentSessionCreated=()=>{this.announce("Connected to live agent"),this.isLiveAgent=!0,this.liveAgentButtonText="End Live Agent chat",requestAnimationFrame((()=>{var t;const i=null===(t=this.el.shadowRoot)||void 0===t?void 0:t.querySelector('[data-testid="user-input-textarea"]');i&&(this.inputEl=i)}))},this.handleAgentSessionInfo=t=>{this.liveAgentSessionId=(null==t?void 0:t.sessionId)||"",this.liveAgentConversationId=(null==t?void 0:t.conversationId)||"",this.isLiveAgent=!0,this.updateBotState()},this.toggleBot=()=>{this.isToggled=!this.isToggled},this.menuClick=t=>{switch(t.type){case"menu":this.toggleBot(t),this.showHistory=!1,this.showWelcomeScreen=!0,this.isStreaming||this.handleSend(t.button.label);break;case"history":this.toggleBot(t),this.showHistory=!0,this.loadConversation();break;case"end":this.messages=[],this.conversationId="",this.isOpened=!1,this.isMinimized=!this.isExpanded,this.showWelcomeScreen=!0,this.toggleBot(t),this.showHistory=!1,this.close.emit("close");break;case"startover":this.messages=[],this.conversationId="",this.isOpened=!0,this.isMinimized=!1,this.showWelcomeScreen=!0,this.toggleBot(t),this.showHistory=!1,this.updateBotState()}}}get mainObject(){return window.ai12z||(window.ai12z={}),window.ai12z}handleKeyDown(t){var i,e;if(!["Control","Shift","Alt","Meta"].includes(t.key)){if(("?"===t.key||"/"===t.key)&&t.shiftKey&&(t.metaKey||t.ctrlKey)&&!this.isInputFocused())return t.preventDefault(),void(this.showShortcutsDialog=!this.showShortcutsDialog);if(this.showShortcutsDialog&&("Escape"===t.key||("?"===t.key||"/"===t.key)&&t.shiftKey&&(t.metaKey||t.ctrlKey)))return t.preventDefault(),void(this.showShortcutsDialog=!1);if("k"===t.key&&(t.metaKey||t.ctrlKey))return t.preventDefault(),t.stopPropagation(),void this.action("open");if("h"===t.key&&(t.metaKey||t.ctrlKey))return t.preventDefault(),t.stopPropagation(),this.showHistory=!this.showHistory,this.showWelcomeScreen=!1,void this.loadConversation();if("n"===t.key&&(t.metaKey||t.ctrlKey))return t.preventDefault(),t.stopPropagation(),void this.handleNewConversation();"Enter"===t.key&&!t.shiftKey&&this.isOpened&&this.isInputFocused()&&(t.preventDefault(),t.stopPropagation(),(null===(i=this.inputEl)||void 0===i?void 0:i.value.trim().length)>0&&!this.isStreaming?this.handleSend(this.inputEl.value):0===(null===(e=this.inputEl)||void 0===e?void 0:e.value.trim().length)&&0===this.imagesBase64List.length&&(this.emptyMessageError=!0,this.announce("Message cannot be empty. Please enter a message."),this.inputEl&&this.inputEl.focus(),setTimeout((()=>{this.emptyMessageError=!1}),3e3))),"Escape"===t.key&&(this.action("minimize"),this.showPrivacy&&(this.showPrivacy=!1,t.preventDefault()))}}isInputFocused(){var t;const i=(null===(t=this.el.shadowRoot)||void 0===t?void 0:t.activeElement)||document.activeElement;return"TEXTAREA"===(null==i?void 0:i.tagName)||"INPUT"===(null==i?void 0:i.tagName)}handleNewConversation(){this.messages=[],this.conversationId="",this.showWelcomeScreen=!0,this.showHistory=!1,this.isOpened=!0,setTimeout((()=>{var t;null===(t=this.inputEl)||void 0===t||t.focus()}),100)}buttonClickHandler(t){this.showWelcomeScreen=!1,this.query=t.detail.action,this.handleSend(t.detail.label)}sendQueryToBotHandler(t){this.showWelcomeScreen=!1,this.query=t.detail,this.handleSend(t.detail)}deleteChatHistoryHandler(t){var i;const e=this.getConversationHistory().filter((i=>i.conversationId!==t.detail.conversationId));localStorage.setItem(`${this.visitorID}`,JSON.stringify(e)),this.conversationHistory=j(e,null===(i=this.botSettings._id)||void 0===i?void 0:i.$oid,this.botSettings.pId)}chatClickHandler(t){t.detail.length>0&&(this.messages=t.detail,requestAnimationFrame((()=>{this.hydrateMessagesFromState()}))),this.showWelcomeScreen=!1,this.showHistory=!1}openChatHandler(t){}formSubmittedHandler(t){t.stopPropagation(),this.formSubmitted.emit(t.detail.data)}async sendMessage(t,i,e){this.query=t,this.handleSend(null!=i?i:t,e)}async sendQuery(t){console.warn("sendQuery mehtdod is deprecated, use sendMessage instead"),this.handleSend(t)}async sendJSON(t,i){this.query=JSON.stringify(t),this.handleSend(i)}async openBot(t=!1){this.openChat(t)}async action(t,i){var e;"open"===t&&this.openChat(null!==(e=null==i?void 0:i.expanded)&&void 0!==e&&e),"minimize"===t&&this.isOpened&&this.minimizeChat(),this.checkHistory(),"close"===t&&(this.searchResults={},this.surveyDomId="",this.showWelcomeScreen=!0,this.showHistory=this.messages.length>0,this.messages=[],this.conversationId="",this.close.emit("close"),this.announce("Chat closed"),clearInterval(this.timer))}async setProcessDataOverride(t){this.dataOverrideFunction=t}async configureSettings(t){this.botSettings=Object.assign(Object.assign({},this.botSettings),t)}connectedCallback(){f(this.dataKey,this.dataMode).then((t=>{this.canRender=t}))}async componentWillLoad(){this.checkCustomSlot(),this.timestamp=b(new Date),this.updateScreenSize(),await this.configBot(),this.visitorID="ai12z-"+localStorage.getItem("ai12z-visitorId"),this.hydrateStateFromStorage(),U("bot",this.dataKey,this.dataMode)}onDataKeyChange(t){U("bot",this.dataKey,this.dataMode)}onDataModeChange(t){U("bot",this.dataKey,this.dataMode)}hydrateStateFromStorage(){var t,i,e;const s=null===(t=this.botSettings)||void 0===t?void 0:t.pId;if(!s)return void console.warn("AI12Z: Cannot hydrate state - projectId not available");const o=I(s,null===(i=this.botSettings._id)||void 0===i?void 0:i.$oid)||function(t,i){const e=function(t){if("undefined"==typeof document)return null;const i=t.replace(/([.*+?^${}()|[\]\\])/g,"\\$1"),e=document.cookie.match(new RegExp(`(?:^|; )${i}=([^;]*)`));return e?decodeURIComponent(e[1]):null}(t);if(!e)return null;try{const s=JSON.parse(e);return i&&!i(s)?(console.warn(`AI12Z: Cookie '${t}' failed validation`),null):s}catch(t){return console.warn("AI12Z: Failed to parse cookie JSON:",t),null}}(L(s,null===(e=this.botSettings._id)||void 0===e?void 0:e.$oid),Q);o&&(this.isOpened=o.isOpened,this.isMinimized=o.isMinimized,this.isExpanded=o.isExpanded,this.conversationId=o.conversationId,o.newChat||(this.messages=[...o.messages||[]]),o.isLiveAgent&&o.liveAgentSessionId&&o.liveAgentConversationId&&(this.isLiveAgent=o.isLiveAgent||!0,this.liveAgentSessionId=o.liveAgentSessionId,this.liveAgentConversationId=o.liveAgentConversationId,this.liveAgentProviderName=o.liveAgentProviderName||"salesforce",this.liveAgentButtonText="End Live Agent chat",setTimeout((()=>this.recoverLiveAgentSession()),0)),setTimeout((()=>{this.scrollToBottom()}),100))}async recoverLiveAgentSession(){var t,i,e,s,o,n;if(0===Object.keys(null!==(e=null===(i=null===(t=this.botSettings)||void 0===t?void 0:t.liveagent)||void 0===i?void 0:i.providers)&&void 0!==e?e:{}).length||!this.liveAgentSessionId||!this.liveAgentConversationId)return;const a=null!==(n=null===(o=null===(s=this.botSettings)||void 0===s?void 0:s.liveagent)||void 0===o?void 0:o.providers[this.liveAgentProviderName])&&void 0!==n?n:null;if(a)try{this.registerLiveAgentListeners(),await this.liveAgentEventHandler.resumeLiveAgentSession(this.liveAgentProviderName,{sessionId:this.liveAgentSessionId,conversationId:this.liveAgentConversationId,userId:this.visitorID,config:a})}catch(t){t instanceof q?(this.addEventMessage("Your live agent session has expired. Please reconnect."),this.announce("Live agent session expired")):console.warn("AI12Z: Failed to recover live agent session, ending gracefully:",t),this.isLiveAgent=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.liveAgentButtonText="Talk to a Live Agent",this.clearEvents()}}componentDidLoad(){E(this.el),"undefined"==typeof window||window.Handlebars||(window.Handlebars=A),s.register("bot",this),window.addEventListener("resize",this.updateScreenSize.bind(this)),document.addEventListener("click",this.handleClickOutside.bind(this));const t=document.createElement("script");t.text='\n var ai12zChat = window["ai12z"] = {}\n ',document.head.appendChild(t),this.el.shadowRoot.appendChild(t),this.assetLoader||this.initializeAssetLoader(),this.messages.length>0&&requestAnimationFrame((()=>{this.hydrateMessagesFromState()})),s.setActive("bot")}async hydrateMessagesFromState(){var t,i,e,s;if((null===(t=this.el)||void 0===t?void 0:t.shadowRoot)&&0!==this.messages.length){await new Promise((t=>requestAnimationFrame((()=>t()))));for(const t of this.messages)if(!t.isUser&&t.id){if("template"===t.controlType)this.processTemplateData(t,t.itemComponent);else if("form"===t.controlType){if(!t.surveyDomId)continue;if(this.surveyDomId=t.surveyDomId,!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(t.surveyDomId)){console.warn("Invalid surveyDomId, skipping render");continue}t.text=`<div id=${this.surveyDomId} style="width: 100%;" class="survey-container"></div>`,(await P(`#${t.id}`,this.el)).querySelector(`#${t.surveyDomId}`)||await P(`#${t.surveyDomId}`,this.el),await this.renderSurvey(t.itemComponent)}else if("carousel"===t.controlType&&"carousel"===(null===(i=t.itemComponent)||void 0===i?void 0:i.controlType))this.processChatData(t,t.itemComponent);else if(!t.controlType){t.text=w(t.text,(null===(e=this.botSettings)||void 0===e?void 0:e.linkTarget)||"_blank","ai12z-link",null===(s=this.botSettings)||void 0===s?void 0:s.utm,"answer");const i=y(t.text);t.text=i.body,this.buttons=i.buttons,this.addEventListeners(`#${t.id}`)}"form"!==t.controlType&&this.checkHighlightcode(t.id)}}}disconnectedCallback(){document.removeEventListener("click",this.handleClickOutside.bind(this)),window.removeEventListener("resize",this.updateScreenSize)}handleClickOutside(t){this.showMenu&&this.plusIconRef&&!this.plusIconRef.contains(t.target)&&(this.showMenu=!1)}async initializeAssetLoader(){try{this.assetLoader=D({shadowRoot:this.el.shadowRoot,cdnPath:this.cdnPath,surveyCDNPath:this.surveyCDNPath,customStyles:this.styles}),await this.assetLoader.loadBotAssets()}catch(t){console.error("❌ Failed to initialize asset loader:",t)}}async processDataOverride(t){if(this.dataOverrideFunction&&"function"==typeof this.dataOverrideFunction)try{return await this.dataOverrideFunction(t)}catch(t){throw console.error("Error in custom processDataOverride:",t),t}return t}announce(t){this.announceMessage=t,setTimeout((()=>{this.announceMessage=""}),1e3)}openChat(t=!1){var i,e;this.unreadCount=0,s.setActive("bot"),this.isExpanded=t,this.isMinimized=!1,this.isContent=!1,this.isOpened=!0;const o=L(this.botSettings.pId,null===(i=this.botSettings._id)||void 0===i?void 0:i.$oid);if(sessionStorage.getItem(o))this.updateBotState();else{const t={messages:[],isMinimized:this.isMinimized,isOpened:this.isOpened,isExpanded:this.isExpanded,conversationId:this.conversationId,projectId:this.botSettings.pId,configId:null===(e=this.botSettings._id)||void 0===e?void 0:e.$oid,newChat:!0};sessionStorage.setItem(o,JSON.stringify(t)),this.botSettings.cookies&&it(this.botSettings.subDomain)&&tt(o,t,{domain:this.botSettings.subDomain})}setTimeout((()=>{this.announce("Chat opened")}),600),requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.imageUploaderRef&&this.isElementAvailable.emit(!0)}))})),this.open.emit("open")}minimizeChat(){this.isOpened=!1,this.isContent=!!this.isExpanded,this.isMinimized=!this.isExpanded,this.isAnimated=!1,this.updateScreenSize(),this.announce("Chat minimized"),this.minimize.emit("minimize")}adjustHeight(){this.inputEl&&(this.inputEl.style.height="auto",this.inputEl.style.height=this.inputEl.scrollHeight+"px")}async configBot(){var t,i,e,s,o;const n={apiKey:this.dataKey,configId:this.configId,configType:"bot"};try{const a=await x(n,this.dataMode);if(a){if(this.botSettings=a,(null===(i=null===(t=this.botSettings)||void 0===t?void 0:t.v3)||void 0===i?void 0:i.siteKey)?z(a._id,a.v3.siteKey,"bot",this.dataKey,this.dataMode,(t=>{this.errored.emit(t),this.announce("An error occurred while loading the chat.")})).then((t=>{t&&(this.isRendered=!0)})).catch((t=>{console.error("Recaptcha verification failed:",t),this.isRendered=!1})):this.isRendered=!0,"v2"!==this.botSettings.botVersion||this.botSettings.isExpanded||this.isBot||this.isOpened||(this.isMinimized=!0),this.assetLoader||await this.initializeAssetLoader(),this.assetLoader)try{await this.assetLoader.loadBotTheme(this.botSettings)}catch(t){console.error("Failed to load bot theme:",t)}if(this.botSettings.isExpanded&&!this.isBot?(this.isExpanded=!0,this.isMinimized=!1):this.isOpened||(this.isMinimized=!0),this.botSettings.linkTarget||(this.botSettings.linkTarget="_blank"),this.botSettings.customCSS&&(this.customStyle=this.botSettings.customCSS),this.botSettings.customJS&&(this.customJS=this.botSettings.customJS),"v2"===this.botSettings.botVersion){const t=localStorage.getItem("ai12z-visitorId");this.visitorID="ai12z-"+t}if(this.botSettings.privacyTemplate&&""!==this.botSettings.privacyTemplate&&(this.showPrivacy=!0),this.botSettings.audioType&&(this.voiceType=this.botSettings.audioType,this.voice=this.botSettings.voice),this.botSettings&&!(null===(e=this.botSettings)||void 0===e?void 0:e.cookies)){const t=it(this.botSettings.subDomain);!function(t,i={}){const{path:e="/",domain:s}=i;"undefined"!=typeof document&&function(t,i="/",e){W(t,"",{maxAgeDays:0,path:i,domain:e})}(t,e,s)}(L(this.botSettings.pId,null===(o=null===(s=this.botSettings)||void 0===s?void 0:s._id)||void 0===o?void 0:o.$oid),{domain:t})}}}catch(t){console.error("Error loading bot configuration:",t)}}checkCustomSlot(){const t=this.el.children;if(t&&t.length>0)for(var i=0;i<t.length;i++)"bot"!==t[i].tagName.toLowerCase()&&"bot"!==t[i].getAttribute("slot")||(this.isBot=!0,this.isExpanded=!1)}handleSocketResponse(){this.socket.off("response"),this.socket.off("end_response"),this.socket.off("chunk"),this.socket.off("complete"),void 0===this.botSettings.maxQuestion||0===this.botSettings.maxQuestion?(this.botSettings.maxQuestion=0,this.handleBotMessages()):this.questionCounter<=this.botSettings.maxQuestion&&this.handleBotMessages()}hideSpinner(t){return new Promise((i=>{const e=this.el.shadowRoot.querySelector(`#${t.id}`);if(e){const t=e.querySelector("#spinner");t&&(t.style.display="none")}i(!0)}))}async processTemplateData(t,i){await N(t,i,this.el.shadowRoot,(t=>this.hideSpinner(t)),(t=>this.renderTemplateData(t)),(t=>{this.messages=this.messages.map((i=>i.id===t.id?t:i))}),A)}async renderTemplateData(t){await M(t,this.el,this.scriptArray,this.mainObject,this.initializeScript)}async processChatData(t,i){d(t,i,this.el,(t=>this.hideSpinner(t)),(t=>{this.messages=this.messages.map((i=>i.id===t.id?t:i)),this.updateBotState()}),this.customJS,this.customStyle,this.isExpanded)}handleBotMessages(){const t=S(this.dataMode),i="v2"===t?"complete":"end_response";this.socket.on("v2"===t?"chunk":"response",(async i=>{const{id:e,idChanged:s}=H(this.currentDomId,this.messages,"chatbot");this.currentDomId=e,s&&(this.messages=[...this.messages]);const o="v2"===t?i.content:i.data;requestAnimationFrame((()=>{this.ignoreChunks||(this.messages[this.messages.length-1].isLoading=!1,this.handleMessage(o,this.currentDomId))}))})),this.socket.on(i,(async i=>{const e="v2"===t?r(i):i;this.unreadCount++;const{id:s,idChanged:o,orphaned:n}=H(this.currentDomId,this.messages,"chatbot");this.currentDomId=s,o&&(this.messages=[...this.messages]),n||this.messageReceived.emit({data:e,domId:this.currentDomId}),this.announce(this.isOpened?"New message received":"New message received while chat is minimized"),requestAnimationFrame((async()=>{var t,i,s,o,n,a,r;try{const h={element:this.el,hideSpinner:t=>{this.hideSpinner(t)},updateConversations:(t,i)=>this.updateConversations(t,i),renderSurvey:t=>this.renderSurvey(t),processTemplateData:(t,i)=>this.processTemplateData(t,i),processChatData:(t,i)=>this.processChatData(t,i),checkHighlightcode:t=>this.checkHighlightcode(t),addEventListeners:t=>this.addEventListeners(t),customStyle:this.customStyle,customJS:this.customJS,controlSettings:this.botSettings,utmConfig:null===(t=this.botSettings)||void 0===t?void 0:t.utm,conversationId:this.conversationId};if(await _({data:e,currentDomId:this.currentDomId,inputType:"bot",setMessages:t=>{this.messages=[...this.messages,t],requestAnimationFrame((()=>{setTimeout((()=>{t&&t.id&&this.hideSpinner(t).then((()=>{}))}),0)}))},setSurveyDomId:t=>{this.surveyDomId=t},setButtons:t=>{this.buttons=t},config:h}),e.liveAgent&&!this.isLiveAgent&&!this.isConnectingLiveAgent){this.liveAgentDirective=e.liveAgent,this.isConnectingLiveAgent=!0;try{await this.connectLiveChat()}finally{this.isConnectingLiveAgent=!1}}if(e.liveAgent&&!this.isLiveAgent&&!this.isConnectingLiveAgent){this.isConnectingLiveAgent=!0;try{await this.connectLiveChat()}finally{this.isConnectingLiveAgent=!1}}if(this.conversationId=e.conversationId,R(null===(i=this.botSettings)||void 0===i?void 0:i.pId,this.messages,this.conversationId,null!==(o=null===(s=this.botSettings._id)||void 0===s?void 0:s.$oid)&&void 0!==o?o:"",this.visitorID,"bot",{isMinimized:this.isMinimized,isOpened:this.isOpened,isExpanded:this.isExpanded}),this.visitorID&&2===this.messages.length){const t=L(this.botSettings.pId,null===(n=this.botSettings._id)||void 0===n?void 0:n.$oid);sessionStorage.setItem(t,JSON.stringify({isMinimized:this.isMinimized,isOpened:this.isOpened,isExpanded:this.isExpanded,messages:this.messages,conversationId:this.conversationId,configId:null===(a=this.botSettings._id)||void 0===a?void 0:a.$oid,visitorID:this.visitorID,projectId:null===(r=this.botSettings)||void 0===r?void 0:r.pId,date:new Date}))}else this.updateBotState();this.scrollToBottom(),this.isStreaming=!1,this.currentDomId=""}catch(t){console.error("Error handling end_response:",t),this.isStreaming=!1}}))}))}updateConversations(t,i){var e,s,o,n,a,r;const h={id:this.currentDomId,text:t,isUser:!1,isLoading:!1,timestamp:(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),images:[],conversationId:this.conversationId,formModel:null!==(n=null!==(o=null===(s=null===(e=i.controlData)||void 0===e?void 0:e.data)||void 0===s?void 0:s.source)&&void 0!==o?o:i.controlData)&&void 0!==n?n:{},surveyDomId:this.surveyDomId,controlType:i.controlType,thumbsId:`${p()}`,showIcon:!i.controlType&&!this.surveyDomId,insightId:null!==(a=null==i?void 0:i.insightId)&&void 0!==a?a:null,sender:null!==(r=null==i?void 0:i.sender)&&void 0!==r?r:null,itemComponent:i};this.messages=this.messages.map((t=>t.id===this.currentDomId?h:t)),requestAnimationFrame((()=>{this.checkHighlightcode(this.currentDomId),this.currentDomId=""}))}checkHighlightcode(t=""){var i;try{if(!t)return console.warn("highlightcodeId is empty"),void(this.isProse=!0);const e=null===(i=this.el.shadowRoot)||void 0===i?void 0:i.querySelector(`#${t}`);if(!e)return console.warn(`Element with id '${t}' not found in shadowRoot`),void(this.isProse=!0);const s=e.querySelectorAll("pre");s.length>0?(e.classList.remove("prose"),import("./p-C3lNE7QP.js").then((function(t){return t.i})).then((({default:t})=>{t.configure({ignoreUnescapedHTML:!0}),s.forEach((i=>{i.dataset.highlighted?console.warn("Element previously highlighted..."):t.highlightElement(i)}))})).catch((t=>console.error("Failed to load highlight.js:",t)))):"form"!==this.messages[this.messages.length-1].controlType&&e.classList.add("prose")}catch(t){console.error("Error in highlightcode:",t),this.isProse=!0}}handleSurveyCompletionRender(t){const i=this.messages.findIndex((i=>i.surveyDomId===t.domId));-1!==i?(this.currentDomId=this.messages[i].id,this.surveyDomId=t.domId,this.updateConversations(t.completedHtml,{}),this.sendMessage(t.jsonData,t.completeText,{isHide:!0}),this.formSubmitted.emit(t.sender.data),this.scrollToBottom()):console.warn("Could not find message to update for survey completion")}addEventListeners(t){const i=this.el.shadowRoot.querySelector(t);i&&this.buttons.forEach((t=>{const e=i.querySelector(`#${t.id}`);if(e){const i=e.getAttribute("data-original-click");if(!i)return void console.warn(`originalClickHandler is not defined for button with id: ${t.id}`);const s=i.match(/^([\w.]+)\s*\(([\s\S]*)\)$/);if(s){const i=s[1],o=s[2],n=this,a=i.includes(".")?i.split(".").pop():i,r=n[a];e.addEventListener("click",(()=>{if("function"==typeof n[a])try{switch(a){case"sendQuery":console.warn("sendQuery is deprecated, use sendMessage instead");const i=F(o);if(!i)return;i[0]=t.label,r.apply(n,i);break;case"sendMessage":const e=F(o);if(!e)return;r.apply(n,e);break;case"sendJSON":const s=F(o);if(!s)return;r.apply(n,s);break;default:console.warn(`Unknown function: ${a}`)}}catch(t){console.error(`Error invoking ${i}:`,t)}else console.warn(`Function ${a} not found on this`)}))}}}))}async socketConnection(){const t=S(this.dataMode);let i=u(this.dataMode);this.socket=h(i,{transports:"v2"===t?["websocket","polling"]:["polling"]}),await new Promise(((i,e)=>{let s=!1;const o=setTimeout((()=>{if(!s){s=!0;const t="Unable to connect to server. Please try again later.";console.error("Socket connection timed out"),this.errored.emit({message:t,code:"CONNECTION_TIMEOUT"}),e(new Error(t))}}),3e4);this.socket.on("connect",(()=>{"v2"===t?(this.socket.emit("authenticate",{api_key:this.dataKey}),this.socket.once("authenticated",(()=>{s||(s=!0,clearTimeout(o)),this.handleSocketResponse(),i()})),this.socket.once("error",(t=>{"AUTH_FAILED"!==t.code&&"AUTH_REQUIRED"!==t.code&&"AUTH_ERROR"!==t.code||(s||(s=!0,clearTimeout(o)),this.errored.emit(t),e(new Error(t.message)))}))):(s||(s=!0,clearTimeout(o)),this.handleSocketResponse(),i())}))})).catch((t=>{console.error("Socket connection failed:",t.message),this.messages.length>0&&(this.messages[this.messages.length-1].text=t.message,this.messages[this.messages.length-1].isLoading=!1,this.messages=[...this.messages]),this.isStreaming=!1})),this.socket.on("connect_error",(t=>{this.errored.emit(t),this.announce("Unable to connect to chat server. Please try again."),console.error("Connection error:",t)})),this.socket.on("disconnect",(()=>{this.socket.off("response"),this.socket.off("chunk")}))}invokeSocket(){var t;let i,e;"v2"===S(this.dataMode)?(e="query",i={query:""!==this.query?this.query:this.inputEl.value,conversation_id:this.conversationId||"",base64_images:(null===(t=this.imagesBase64List)||void 0===t?void 0:t.length)>0?this.imagesBase64List:void 0}):(e="evaluate_query",i={apiKey:this.dataKey,query:""!==this.query?this.query:this.inputEl.value,conversationId:this.conversationId,event:"evaluate_query",attributes:this.dataAttributes,excludeTags:this.excludeTags,includeTags:this.includeTags,base64Images:this.imagesBase64List,meta:k()}),this.processDataOverride(i).then((t=>{null!=t&&(this.messageSent.emit(JSON.stringify(t)),this.socket.emit(e,t,(t=>{t&&(this.errored.emit(t),this.announce("Unable to send message. Please try again."),this.currentDomId=`chatbot-${p()}`,this.messages[this.messages.length-1].id=this.currentDomId,this.messages[this.messages.length-1].text="Error connecting to server. Please try again later.")})),this.inputEl&&(this.inputEl.value="",this.adjustHeight()),this.query="")})).catch((t=>{console.error("Error in processDataOverride:",t),this.errored.emit(t),this.announce("An error occurred while sending your message.")}))}getConversationHistory(){const t=localStorage.getItem(`${this.visitorID}`);return t?JSON.parse(t):[]}loadConversation(){var t;this.showWelcomeScreen=!1;const i=localStorage.getItem(`${this.visitorID}`);i&&(this.conversationHistory=JSON.parse(i),this.conversationHistory=j(this.conversationHistory,null===(t=this.botSettings._id)||void 0===t?void 0:t.$oid,this.botSettings.pId))}startTimer(){this.timer=setInterval((()=>{this.questionCounter=0,localStorage.setItem("ai12z-bot-data",JSON.stringify({qCounter:this.questionCounter}))}),this.botSettings.autoResetTimer)}stopResponse(){this.ignoreChunks=!0,this.isStreaming=!1,this.messages[this.messages.length-1].isLoading=!1}scrollToBottom(){const t=this.el.shadowRoot.querySelector(".chat-body");t&&t.scroll({top:t.scrollHeight,behavior:"smooth"}),this.isOpened&&(this.unreadCount=0)}checkLiveAgentMode(){var t,i,e,s;const o=(null===(i=null===(t=this.botSettings)||void 0===t?void 0:t.liveagent)||void 0===i?void 0:i.providers)&&Object.keys(null===(s=null===(e=this.botSettings)||void 0===e?void 0:e.liveagent)||void 0===s?void 0:s.providers).length>0;this.isLiveAgentEnabled=o&&this.messages.length>1}openEndLiveAgentDialog(){this.isToggled=!1,this.showLiveAgentEndDialog=!0}closeEndLiveAgentDialog(){this.showLiveAgentEndDialog=!1}async handleLiveAgentToolbarAction(){this.isLiveAgent?this.openEndLiveAgentDialog():await this.connectLiveChat()}confirmEndLiveAgent(){this.showLiveAgentEndDialog=!1,this.disconnectLiveChat()}disconnectLiveChat(){var t,i,e,s;this.liveAgentEventHandler.disconnectLiveAgent(),this.isLiveAgent=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.liveAgentButtonText="Talk to a Live Agent",this.sendMessage(""!==(null===(t=this.botSettings)||void 0===t?void 0:t.llmMessageOnDisconnect)?null===(i=this.botSettings)||void 0===i?void 0:i.llmMessageOnDisconnect:"The live agent has been disconnected. Please do not initiate the live agent directive again.",""!==(null===(e=this.botSettings)||void 0===e?void 0:e.userMessageOnDisconnect)?null===(s=this.botSettings)||void 0===s?void 0:s.userMessageOnDisconnect:"The live agent has ended the conversation.",{isLiveChatEnded:!0}),this.announce("Live agent chat ended"),this.clearEvents()}removeFindingAgentPlaceholder(){var t;const i=null===(t=this.el.shadowRoot)||void 0===t?void 0:t.querySelector('[data-finding-agent="true"]');if(null==i?void 0:i.parentNode){const t=i.parentNode;t.removeChild(i),t.parentNode&&0===t.childElementCount&&t.parentNode.removeChild(t)}}registerLiveAgentListeners(){this.liveAgentListenersRegistered||(this.liveAgentListenersRegistered=!0,J.on("FINDING_AGENT",this.findingAgent),J.on("AGENT_EVENT",this.agentEventHandler),J.on("TYPING_STARTED",this.handleTypingStarted),J.on("TYPING_STOPPED",this.handleTypingStopped),J.on("AGENT_MESSAGE",this.agentMessageCreated),J.on("AGENT_ERROR",this.handleAgentError),J.on("CONVERSATION_CLOSED",this.handleAgentConversationEnded),J.on("AGENT_SESSION_INFO",this.handleAgentSessionInfo))}clearEvents(){this.liveAgentListenersRegistered=!1,J.off("FINDING_AGENT",this.findingAgent),J.off("AGENT_EVENT",this.agentEventHandler),J.off("AGENT_MESSAGE",this.agentMessageCreated),J.off("AGENT_ERROR",this.handleAgentError),J.off("CONVERSATION_CLOSED",this.handleAgentConversationEnded),J.off("TYPING_STARTED",this.handleTypingStarted),J.off("TYPING_STOPPED",this.handleTypingStopped),J.off("AGENT_SESSION_CREATED",this.handleAgentSessionCreated),J.off("AGENT_SESSION_INFO",this.handleAgentSessionInfo)}async connectLiveChat(){var t,i,e,s,o,n,a,r,h,l,d,c,v,u,p,g,m,f;this.announce("Connecting to live agent"),this.clearEvents();const b=Object.keys(null!==(e=null===(i=null===(t=this.botSettings)||void 0===t?void 0:t.liveagent)||void 0===i?void 0:i.providers)&&void 0!==e?e:{});if(0===b.length)return console.error("No live agent provider found in bot settings"),void this.announce("Live agent is not configured");b.length>1&&console.warn("Multiple live agent providers found, using the first one");let w=null!==(a=null===(n=null===(o=null===(s=this.botSettings)||void 0===s?void 0:s.liveagent)||void 0===o?void 0:o.providers)||void 0===n?void 0:n[b[0]])&&void 0!==a?a:null,y=null!==(l=null===(h=null===(r=this.botSettings)||void 0===r?void 0:r.liveagent)||void 0===h?void 0:h.businessHours)&&void 0!==l?l:null,x=null!==(v=null===(c=null===(d=this.botSettings)||void 0===d?void 0:d.liveagent)||void 0===c?void 0:c.timezone)&&void 0!==v?v:null;if(!w)return console.error("No live agent settings found for the provider",b[0]),void this.announce("Live agent settings are unavailable");if(w){let t=this.getConversationHistory().filter((t=>{var i;return t.conversationId===this.conversationId&&t.projectId===(null===(i=this.botSettings)||void 0===i?void 0:i.pId)}));const i=Object.entries(this.liveAgentDirective&&"object"==typeof this.liveAgentDirective?this.liveAgentDirective:{}).map((([t,i])=>({label:t.charAt(0).toUpperCase()+t.slice(1),value:i,displayToAgent:!0})));if(this.isTypingIndicatorVisible=!0,w={config:w,userId:this.visitorID,conversationId:this.conversationId,messageHistory:t,extraPrechatFormDetails:i},this.liveAgentProviderName=b[0],y&&x){let t;try{t=B(y,x)}catch(t){return console.error("AI12Z: unexpected error evaluating business hours — blocking live agent connection",t),this.announce("Unexpected error evaluating business hours. Live agent connection blocked."),this.addEventMessage("Unexpected error evaluating business hours. Please try again later."),void(this.isTypingIndicatorVisible=!1)}if(!t){const t=null!==(p=null===(u=w.config)||void 0===u?void 0:u.outsideBusinessHoursMessage)&&void 0!==p?p:"Our live agents are currently offline. Please try again during our business hours.";return this.addEventMessage(t),this.announce("Live agents are currently offline"),void(this.isTypingIndicatorVisible=!1)}}if("liveagent"===b[0]){if(!this.liveAgentRef)return this.isTypingIndicatorVisible=!1,console.error("LiveAgent reference is not set"),void this.announce("Live agent is currently unavailable");await this.liveAgentRef.startChat(),this.isLiveAgent=!0,this.liveAgentButtonText="End Live Agent chat",this.announce("Connected to live agent")}else{const t=Number(null===(g=null==w?void 0:w.config)||void 0===g?void 0:g.maxWaitTime),i=1e3*(Number.isFinite(t)&&t>=5?t:300);this.registerLiveAgentListeners();try{await this.liveAgentEventHandler.connectToLiveAgent(b[0],w)}catch(t){return console.error("Live agent connection error:",t),this.isTypingIndicatorVisible=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.updateBotState(),this.addEventMessage("Issue connecting to live agent. Please try again later."),this.announce("Issue connecting to live agent. Please try again later."),this.liveAgentEventHandler.disconnectLiveAgent(),void this.clearEvents()}let e,s=()=>{};try{await new Promise(((t,o)=>{s=()=>{this.handleAgentSessionCreated(),t("SUCCESS")},J.on("AGENT_SESSION_CREATED",s),e=setTimeout((()=>o(new Error("TIMEOUT"))),i)}))}catch(t){this.liveAgentSessionId="",this.liveAgentConversationId="",this.isLiveAgent=!1,this.isTypingIndicatorVisible=!1;const i=null!==(f=null===(m=w.config)||void 0===m?void 0:m.maxWaitMessage)&&void 0!==f?f:"Sorry, no agents are available at the moment.";this.removeFindingAgentPlaceholder(),this.addEventMessage(i),this.liveAgentEventHandler.disconnectLiveAgent(),this.clearEvents(),this.updateBotState(),this.announce("Agents are not available at this time.")}finally{e&&clearTimeout(e),J.off("AGENT_SESSION_CREATED",s)}}}}handleMessageKeyNav(t,i){var e,s;if("ArrowDown"===t.key){t.preventDefault();const s=Math.min(this.messages.length-1,i+1);this.focusedIndex=s,null===(e=this.messageRefs[s])||void 0===e||e.focus()}else if("ArrowUp"===t.key){t.preventDefault();const e=Math.max(0,i-1);this.focusedIndex=e,null===(s=this.messageRefs[e])||void 0===s||s.focus()}}async updateBotState(){var t,i,e,s;const o=L(this.botSettings.pId,null===(t=this.botSettings._id)||void 0===t?void 0:t.$oid);let n=await C(o);if(n||(n=I(this.botSettings.pId,null===(i=this.botSettings._id)||void 0===i?void 0:i.$oid)),"string"==typeof n)try{n=JSON.parse(n)}catch(t){console.error("AI12Z: Failed to parse bot state from sessionStorage:",t)}Array.isArray(n)&&(n=n.find((t=>{var i;return t.projectId===(null===(i=this.botSettings)||void 0===i?void 0:i.pId)}))||null);const a={isMinimized:this.isMinimized,isOpened:this.isOpened,isExpanded:this.isExpanded,messages:this.messages,conversationId:this.conversationId,projectId:null===(e=this.botSettings)||void 0===e?void 0:e.pId,configId:null===(s=this.botSettings)||void 0===s?void 0:s._id.$oid,newChat:0===this.messages.length,isLiveAgent:this.isLiveAgent,liveAgentProviderName:this.liveAgentProviderName,liveAgentSessionId:this.liveAgentSessionId,liveAgentConversationId:this.liveAgentConversationId};0===this.messages.length&&(this.conversationId="");try{sessionStorage.setItem(o,JSON.stringify(a)),this.botSettings.cookies&&it(this.botSettings.subDomain)&&tt(o,function(t,i){var e={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.indexOf(s)<0&&(e[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)i.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(e[s[o]]=t[s[o]])}return e}(a,["liveAgentSessionId","liveAgentConversationId"]),{domain:this.botSettings.subDomain})}catch(t){console.error("AI12Z: Failed to update bot state in sessionStorage:",t)}}skipTo(t){var i;const e=null===(i=this.el.shadowRoot)||void 0===i?void 0:i.querySelector("#"+t);e&&e.focus()}render(){var t,i,e,s,a,r,h,l,d,c,v,u,p,g,m,f,b,w,y,x,k;return this.canRender?o("div",{lang:"en"},o("div",{class:"skip-links "+(this.isOpened?"visible":"hidden")},o("a",{class:"skip-link",href:"#main-content",onClick:()=>this.skipTo("main-content")},"Skip to main content"),o("a",{class:"skip-link",href:"#message-input",onClick:()=>{var t;null===(t=this.inputEl)||void 0===t||t.focus()}},"Skip to message input")),"v1"!==this.botSettings.botVersion&&this.isRendered&&o("div",{class:`pt-0 show-grid ${this.isAnimated?"transition ease-out duration-300":""} layout ${this.isOpened?"is-open":""} ${this.isExpanded?"is-expanded":""} search-flex`,style:{gridTemplateColumns:`0fr minmax(${null!==(t=this.botSettings.minWidth)&&void 0!==t?t:"340px"}, ${null!==(i=this.botSettings.maxWidth)&&void 0!==i?i:"375px"}) 0fr`,paddingTop:null!==(s=null===(e=this.botSettings)||void 0===e?void 0:e.paddingTop)&&void 0!==s?s:"96px"}},o("div",{class:"modal-overlay",role:"none","aria-label":"Close Modal",style:{display:this.isExpanded&&this.isOpened?"grid":"none",opacity:this.isExpanded&&this.isOpened?"1":"0",pointerEvents:this.isExpanded&&this.isOpened?"all":"none"}}),o("div",{class:"modal","data-testid":"modal","aria-hidden":"false",role:"dialog","aria-modal":"true",tabindex:"-1",style:{display:this.isOpened?"grid":"none",opacity:this.isOpened?"1":"0",transform:this.isOpened?"none":"translateY(100%)"}},o("header",{role:"banner"},o("div",{class:"flex bg-white overflow-hidden border-b border-gray-90 border-solid md:pl-3 pl-4 justify-end md:rounded-t-xl items-center toolbar"},o("div",{class:"flex gap-1 toolbar-overflow-actions"},this.isLiveAgentEnabled&&(null===(h=null===(r=null===(a=this.botSettings)||void 0===a?void 0:a.liveagent)||void 0===r?void 0:r.providers)||void 0===h?void 0:h.liveagent)&&o("live-agent-chat",{config:null===(c=null===(d=null===(l=this.botSettings)||void 0===l?void 0:l.liveagent)||void 0===d?void 0:d.providers)||void 0===c?void 0:c.liveagent,ref:t=>this.liveAgentRef=t}),!this.showHistory&&o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary",tabindex:"0","aria-label":"options menu","aria-haspopup":"menu","aria-expanded":this.isToggled?"true":"false","aria-controls":"dropdown-menu",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleBot(t)}},o("i",{class:"block wes-icon--loading text-body2 modal-toolbar-icon ",title:"Options Menu"},o("svg",{viewBox:"0 0 24 24",id:"align-left-2","data-name":"Flat Line",xmlns:"http://www.w3.org/2000/svg",class:"icon flat-line",fill:"currentColor","aria-hidden":"true"},o("g",{id:"SVGRepo_bgCarrier","stroke-width":"0"}),o("g",{id:"SVGRepo_tracerCarrier","stroke-linecap":"round","stroke-linejoin":"round"}),o("g",{id:"SVGRepo_iconCarrier"},o("path",{id:"primary",d:"M3,12H17M3,6H21M3,18H13",style:{fill:"none",stroke:"currentColor"}}))))),this.showHistory&&o("button",{class:"w-6 h-6 back-btn bot-btn-primary",tabindex:"0","aria-label":"Back",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.showHistory=!1,this.showWelcomeScreen=!0,this.isOpened=!0,this.isMinimized=!1,this.isAnimated=!0}},o("i",{title:"Back"},o("svg",{viewBox:"0 0 200 200","data-name":"Layer 1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20","aria-hidden":"true"},o("g",{id:"SVGRepo_bgCarrier","stroke-width":"0"}),o("g",{id:"SVGRepo_tracerCarrier","stroke-linecap":"round","stroke-linejoin":"round"}),o("g",{id:"SVGRepo_iconCarrier"},o("title",null),o("path",{d:"M160,89.75H56l53-53a9.67,9.67,0,0,0,0-14,9.67,9.67,0,0,0-14,0l-56,56a30.18,30.18,0,0,0-8.5,18.5c0,1-.5,1.5-.5,2.5a6.34,6.34,0,0,0,.5,3,31.47,31.47,0,0,0,8.5,18.5l56,56a9.9,9.9,0,0,0,14-14l-52.5-53.5H160a10,10,0,0,0,0-20Z"}))))),o("hamburger-menu",{isToggled:this.isToggled,botSettings:this.botSettings,messages:this.messages,liveAgentButtonText:this.liveAgentButtonText,isLiveAgentEnabled:this.isLiveAgentEnabled,onHamburgerMenuClick:t=>{this.menuClick(t.detail)},onHandleByLiveAgent:()=>{this.handleLiveAgentToolbarAction()},onToggledChange:t=>{this.isToggled=t.detail}})),(null===(v=this.botSettings)||void 0===v?void 0:v.botLogo)&&o("img",{src:null===(u=this.botSettings)||void 0===u?void 0:u.botLogo,class:"w-8 h-8 rounded-lg",alt:"Bot Logo"}),o("h2",{class:"flex-1 pl-2 heading text-body1"},null===(p=this.botSettings)||void 0===p?void 0:p.botName),o("div",{class:"buttons flex gap-2 p-[10px]"},this.isLiveAgent&&o("button",{"aria-label":"End Live Agent",title:"End Live Agent",onClick:()=>this.openEndLiveAgentDialog()},o("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 -960 960 960",width:"24px",fill:"#151313"},o("path",{d:"m136-304-92-90q-12-12-12-28t12-28q88-95 203-142.5T480-640q118 0 232.5 47.5T916-450q12 12 12 28t-12 28l-92 90q-11 11-25.5 12t-26.5-8l-116-88q-8-6-12-14t-4-18v-114q-38-12-78-19t-82-7q-42 0-82 7t-78 19v114q0 10-4 18t-12 14l-116 88q-12 9-26.5 8T136-304Zm104-198q-29 15-56 34.5T128-424l40 40 72-56v-62Zm480 2v60l72 56 40-38q-29-26-56-45t-56-33Zm-480-2Zm480 2Z"}))),this.messages.length>0&&o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary",tabindex:"0",onClick:t=>{t.preventDefault(),this.messages=[],this.isOpened=!0,this.isMinimized=!1,this.showWelcomeScreen=!0,this.showHistory=!1,this.updateBotState(),this.checkLiveAgentMode()},"aria-label":"Start New Conversation",title:"Start New Conversation"},o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"20",height:"20",class:"modal-toolbar-icon","aria-hidden":"true"},o("circle",{cx:"4",cy:"4",r:"1.5"}),o("circle",{cx:"10",cy:"4",r:"1.5"}),o("circle",{cx:"16",cy:"4",r:"1.5"}),o("circle",{cx:"4",cy:"10",r:"1.5"}),o("circle",{cx:"10",cy:"10",r:"1.5"}),o("circle",{cx:"16",cy:"10",r:"1.5"}),o("circle",{cx:"4",cy:"16",r:"1.5"}),o("circle",{cx:"10",cy:"16",r:"1.5"}),o("circle",{cx:"16",cy:"16",r:"1.5"}))),o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary",tabindex:"0",onClick:t=>{t.preventDefault(),this.showShortcutsDialog=!0},"aria-label":"Keyboard Shortcuts",title:"Keyboard Shortcuts (Press ? for help)"},o("i",{class:"wes-block wes-icon--loading wes-text-body2 modal-toolbar-icon",title:"Keyboard Shortcuts"},o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},o("path",{d:"M3 5C3 3.89543 3.89543 3 5 3H19C20.1046 3 21 3.89543 21 5V14C21 15.1046 20.1046 16 19 16H13L9 21V16H5C3.89543 16 3 15.1046 3 14V5Z",stroke:"currentColor","stroke-width":"2"}),o("circle",{cx:"12",cy:"10",r:"1",fill:"currentColor"}),o("path",{d:"M9 10C9 8.34315 10.3431 7 12 7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})))),o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 hidden md:flex bot-btn-primary",tabindex:"0",onClick:()=>{this.isExpanded=!this.isExpanded,this.isAnimated=!0,this.updateBotState()},"aria-label":"Collapse Bot to Side Panel","aria-expanded":this.isExpanded?"true":"false","aria-controls":"settings-panel"},o("i",{class:"wes-block wes-icon--loading wes-text-body2 modal-toolbar-icon",title:"Collapse Bot to Side Panel"},this.isExpanded&&o("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true"},o("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M18.215 14.7076H27.692C28.3074 14.7076 28.492 14.0307 27.9997 13.5383L24.9843 10.4614L30.5228 4.86149C30.8305 4.5538 30.8305 3.99995 30.5228 3.69226L28.2459 1.41536C27.9382 1.16921 27.4459 1.16921 27.0767 1.4769L21.5381 7.01532L18.3997 3.99995C17.9073 3.50765 17.2304 3.69226 17.2304 4.30764V13.7845C17.2304 14.2153 17.7843 14.7076 18.215 14.7076ZM13.7847 17.2308H4.30766C3.69227 17.2308 3.50765 17.9077 3.99996 18.4L7.01537 21.4769L1.47686 27.0769C1.16917 27.3846 1.16917 27.9384 1.47686 28.2461L3.75381 30.523C4.0615 30.8307 4.55381 30.8307 4.92305 30.523L10.5231 24.923L13.6616 27.9384C14.0924 28.4923 14.7693 28.3076 14.7693 27.6923V18.2769C14.7693 17.8462 14.2154 17.2308 13.7847 17.2308Z"})),!this.isExpanded&&o("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true"},o("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M30.0308 1.23071H20.4923C19.8769 1.23071 19.6923 1.78455 20.1846 2.27686L23.2 5.29222L17.6615 10.8306C17.3538 11.1383 17.3538 11.6306 17.6615 11.9999L19.9384 14.2768C20.2461 14.5845 20.7384 14.5845 21.1077 14.2768L26.7077 8.67681L29.7231 11.6922C30.2154 12.1845 30.7692 11.9999 30.7692 11.3845V1.90763C30.7692 1.5384 30.4 1.23071 30.0308 1.23071ZM2.15379 30.7692H11.6307C12.2461 30.7692 12.4307 30.0923 11.9384 29.6L8.92303 26.5231L14.4615 20.9231C14.7692 20.6154 14.7692 20.0616 14.4615 19.7539L12.1846 17.477C11.8769 17.1693 11.3846 17.1693 11.0153 17.477L5.47687 23.0154L2.39995 20C1.8461 19.5077 1.23071 19.6923 1.23071 20.3077V29.7846C1.23071 30.2153 1.72302 30.7692 2.15379 30.7692Z"})))),o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary","data-testid":"modal-minimize",tabindex:"0","aria-label":"Minimize",onClick:()=>{this.isOpened=!1,this.isContent=!(!this.isExpanded||!this.botSettings.isExpanded),this.isMinimized=!this.isExpanded||!this.botSettings.isExpanded,this.isAnimated=!1,this.updateScreenSize(),this.updateBotState(),this.announce("Chat minimized"),this.minimize.emit("minimize")}},o("i",{class:"block wes-icon--loading text-body2 modal-toolbar-icon",title:"Minimize Bot"},o("svg",{viewBox:"0 0 26 26",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true"},o("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M25 24.25C25 24.65 24.65 25 24.25 25H1.75C1.35 25 1 24.65 1 24.25V22.75C1 22.35 1.35 22 1.75 22H24.25C24.65 22 25 22.35 25 22.75V24.25Z"}))))))),o("div",{class:"flex-1 flex flex-col main",role:"main","aria-labelledby":"chat-main-heading",id:"main-content",tabindex:"-1"},o("h1",{id:"chat-main-heading",class:"sr-only"},"Chat"),o("div",{class:"h-full flex flex-col chat-body"},o("div",{class:"px-5 flex-[1_1_0] min-h-[calc(100%-1px)] flex flex-col gap-y-3 @md:px-3 messages-container",role:"region","aria-labelledby":"messages-region-heading"},o("h2",{id:"messages-region-heading",class:"sr-only"},"Messages"),this.showWelcomeScreen&&o("div",{class:"@md:px-6 pb-3 @md:pb-7 @md:pt-8 pt-5 text-display5",innerHTML:null===(m=null===(g=this.botSettings)||void 0===g?void 0:g.welcome)||void 0===m?void 0:m.message}),this.messages.length>0&&!this.showHistory&&this.messages.map(((t,i)=>{var e,s,n,a;return"system"===t.type?o("div",{class:"flex justify-center pb-3 message-item",role:"listitem",tabindex:-1,ref:t=>this.messageRefs[i]=t,"aria-label":t.text},o("span",{class:"text-[10px] font-medium text-gray-500 tracking-wide border-b border-gray-200 py-1 px-3 text-center"},t.text)):o("div",{class:`flex pb-3 gap-x-2 @md:gap-x-3 \n ${t.isUser?"self-end":""}\n ${t.isUser?"justify-end":""} end-user-message message-item`,style:{opacity:"1",transform:"none"},role:"listitem",tabindex:i===this.focusedIndex?0:-1,onKeyDown:t=>this.handleMessageKeyNav(t,i),ref:t=>this.messageRefs[i]=t,"aria-label":"Message from "+(t.isUser?"User":"Bot")},t.isUser&&!t.isHide&&o("div",{class:"flex flex-col items-end"},o("div",{"data-testid":"message",class:"break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg py-2 px-4 user-msg text-body3",innerHTML:t.text,id:t.id,"aria-live":"polite","aria-atomic":"false","aria-label":t.text,role:"log"},null===(e=null==t?void 0:t.images)||void 0===e?void 0:e.map((t=>o("img",{src:t,class:"thumbnail",alt:"thumbnail images"})))),o("div",{class:"text-gray-30 pt-2 text-right text-body4"},"Sent ",t.timestamp)),!t.isUser&&o("div",{class:"avatar-column"},o("chat-avatar",{id:`la${t.id}`,senderType:(null==t?void 0:t.sender)?"agent":"bot",avatarUrl:null===(s=this.botSettings)||void 0===s?void 0:s.botAvatar})),!t.isUser&&o("div",{class:"flex flex-col",style:{width:"100%"}},o("div",{"data-testid":"message",class:{prose:"form"!==t.controlType,"transition-all":!0,"duration-300":!0,"opacity-100":this.isProse,"opacity-90":!this.isProse,"max-w-full break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg text-gray-30 pr-2 text-body3":!0},innerHTML:t.text,id:t.id},t.isLoading&&o("div",{class:"w-full rounded-md",id:"spinner"},o("div",{class:"flex animate-pulse space-x-4"},o("div",{class:"flex-1 space-y-3 py-1"},o("div",{class:"h-4 rounded bg-gray-200"}),o("div",{class:"space-y-3"},o("div",{class:"grid grid-cols-3 gap-4"},o("div",{class:"col-span-2 h-4 rounded bg-gray-200"}),o("div",{class:"col-span-1 h-4 rounded bg-gray-200"})),o("div",{class:"h-4 rounded bg-gray-200"})))))),""!==t.text&&t.showIcon&&(null===(n=this.botSettings.showMessageIcons)||void 0===n||n)&&o("interaction-buttons",{message:t,chatArray:this.messages,currentIndex:i,dataKey:this.dataKey,dataMode:this.dataMode,voice:this.voice,voiceType:this.voiceType,source:"bot",conversationId:this.conversationId,projectId:(null===(a=this.botSettings)||void 0===a?void 0:a.pId)||""}),o("div",{class:"text-gray-30 pt-2 text-body4"},this.botSettings.botName," • ",t.timestamp)))})),this.showHistory&&o("chatbot-history",{chatList:this.conversationHistory,botName:null===(f=this.botSettings)||void 0===f?void 0:f.botName,styles:this.customStyle,scripts:this.customJS}),o("div",{class:"h-px pt-2px",style:{overflowAnchor:"auto"}})),o("div",{role:"status","aria-live":"polite","aria-atomic":"true",class:"sr-only"},this.announceMessage)))),o("form",{"data-testid":"user-input",class:`relative pointer-events-auto ${this.isOpened?"p-2.5":""} searchform user-input`,"aria-label":"Message Area","aria-hidden":"false",style:{opacity:this.isMinimized?"0":"1",transform:"translateX(0)",pointerEvents:this.isMinimized?"none":"auto"}},!this.isOpened&&o("div",{class:`absolute right-4 md:right-0 border-2 border-white border-solid rounded-full ${this.isContent?"":"top-0"} minimize-input`},o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-gray-500 bg-opacity-60 hover:bg-opacity-80 h-5 w-5 bot-btn-primary","aria-label":"Minimize Bot",tabindex:"0",onClick:t=>{t.preventDefault(),this.isMinimized=!this.isMinimized,this.isOpened=!this.isMinimized,this.updateBotState()}},o("i",{class:"block ai-minimize-icon ai-text-caption",title:"Minimize Bot"},o("svg",{xmlns:"http://www.w3.org/2000/svg",height:"52",width:"52",viewBox:"0 0 520 520",fill:"#fff","aria-hidden":"true"},o("path",{d:"M500 275c0 8-7 15-15 15H35c-8 0-15-7-15-15v-30c0-8 7-15 15-15h450c8 0 15 7 15 15z"}))))),o("fieldset",{class:"flex flex-col @md:mx-0 @md:rounded-t-xl transition-colors "+(this.isMinimized&&!this.isExpanded?"":"p-4 user-input-fieldset")},!this.isExpanded&&this.isOpened&&0===this.messages.length&&o("privacy-modal",{show:this.showPrivacy,message:this.botSettings.privacyTemplate}),o("div",{class:"flex-1 align-bottom"},o("div",{"aria-hidden":this.isTypingIndicatorVisible?"false":"true",class:"flex items-center justify-center w-full "+(this.isTypingIndicatorVisible?"h-12 opacity-100":"h-0 opacity-0 pointer-events-none")},o("typing-indicator",null)),o("div",{class:"grow-wrap show-grid after:whitespace-pre-wrap after:invisible relative","data-replicated-value":"","aria-disabled":"false"},this.botSettings.imageUpload&&o("div",{"aria-disabled":"true",class:`absolute flex items-center left-0 bottom-0 h-full pl-4 pr-2 ${this.hideAllButtons?"hidden":""} agent-input-icon`},o("button",{class:"plus-icon bot-btn-primary",tabindex:"0","aria-label":"Add Image",onClick:t=>{t.stopPropagation(),t.preventDefault(),this.showMenu=!this.showMenu}},o("i",{class:"plus-icon wes-block wes-text-body1",title:"Add Image"},o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"20",height:"20","aria-hidden":"true"},o("path",{d:"M10.75 4.75a.75.75 0 0 0-1.5 0v4.5h-4.5a.75.75 0 0 0 0 1.5h4.5v4.5a.75.75 0 0 0 1.5 0v-4.5h4.5a.75.75 0 0 0 0-1.5h-4.5v-4.5Z"})))),o("div",{class:"absolute bottom-6 left-0 w-44 bg-white rounded-lg shadow-lg transition-all duration-300 ease-in-out z-10\n "+(this.showMenu?"opacity-100 scale-100 pointer-events-auto":"opacity-0 scale-90 pointer-events-none")},o("ul",{class:"space-y-2",ref:t=>this.plusIconRef=t},o("li",{class:"px-4 py-2 hover:bg-gray-100 cursor-pointer flex",onClick:()=>{this.showMenu=!1}},o("image-uploader",{maxImages:10,images:this.imagesBase64List,targetElement:this.inputEl,onImagesChange:t=>{this.errorMessage="",this.showErrorMessage=!1,this.imagesBase64List=[...t.detail]},onImageUploadError:t=>{this.errorMessage=t.detail,this.showErrorMessage=!0,this.announce(t.detail||"Image upload failed")},ref:t=>this.imageUploaderRef=t}))))),o("div",{class:"textarea"},this.imagesBase64List.length>0&&o("div",{class:"flex flex-wrap gap-2 mx-1 mt-2.5 mb-1"},this.imagesBase64List.map(((t,i)=>o("div",{class:"image-Container sc-ai12z-input-form",key:i},o("img",{src:t,style:{width:"70px",height:"50px",borderRadius:".75rem"},alt:"uploaded image"}),o("span",{class:"delete-image sc-ai12z-input-form cursor-pointer ml-1",onClick:()=>{this.imagesBase64List=this.imagesBase64List.filter(((t,e)=>e!==i)),this.imageUploaderRef&&"function"==typeof this.imageUploaderRef.removeImageAtIndex&&this.imageUploaderRef.removeImageAtIndex(i),this.imagesBase64List=[...this.imagesBase64List]}},"×"))))),o("textarea",{id:"message-input","aria-invalid":this.emptyMessageError,"aria-describedby":[this.emptyMessageError?"empty-message-error":"","message-hint",0===this.messages.length?"input-enter-tip":""].filter(Boolean).join(" "),"aria-placeholder":this.isLiveAgent?"Type a message to the agent...":""!==(null===(b=this.botSettings)||void 0===b?void 0:b.botPlaceholderText)?null===(w=this.botSettings)||void 0===w?void 0:w.botPlaceholderText:"Ask me anything","aria-label":"Type your message here",class:"resize-none overflow-hidden text-ellipsis focus:outline-none w-full custom-input "+(this.hideAllButtons?"hidden":""),"data-testid":"user-input-textarea",rows:this.rowCount,name:"userMessage",placeholder:this.isLiveAgent?"Type a message to the agent...":""!==(null===(y=this.botSettings)||void 0===y?void 0:y.botPlaceholderText)?null===(x=this.botSettings)||void 0===x?void 0:x.botPlaceholderText:"Ask me anything",ref:t=>this.inputEl=t,onKeyUp:()=>{this.adjustHeight()},onKeyDown:t=>{this.handleKeyDown(t),"Enter"!==t.key||t.shiftKey||(this.isOpened=!0)},onPaste:t=>{this.handlePaste(t)}}),o("span",{id:"message-hint",class:"sr-only"},"Press Enter to send, Shift+Enter for new line")),this.botSettings.enableMic&&o("div",{class:"absolute bottom-0 "+(this.hideAllButtons?"w-full":"right-8")},o("audio-recorder",{"component-type":"bot",onStartRecord:()=>{this.hideAllButtons=!0},onStopRecord:()=>{this.hideAllButtons=!1},onSendTranscript:t=>{setTimeout((()=>{this.inputEl&&(this.inputEl.value=t.detail,this.adjustHeight(),this.showSubmit=!0)}),1e3)},style:{width:this.hideAllButtons?"100%":"10%"}})),o("div",{class:"absolute right-0 bottom-0 "+(this.hideAllButtons?"hidden":"")},!this.isStreaming&&o("button",{class:"text-white transition rounded-full p-1.5 self-center btn-bg-color bot-btn-primary","aria-label":"Send Message",tabindex:"0",id:"message-submit",onClick:t=>{var i,e;if(t.preventDefault(),""===(null===(i=this.inputEl)||void 0===i?void 0:i.value.trim())&&this.imagesBase64List&&0===this.imagesBase64List.length)return this.emptyMessageError=!0,this.announce("Message cannot be empty. Please enter a message."),this.inputEl&&this.inputEl.focus(),void setTimeout((()=>{this.emptyMessageError=!1}),3e3);this.isOpened=!0,this.handleSend(null===(e=this.inputEl)||void 0===e?void 0:e.value)}},o("i",{class:"block ai-icon text-body1",title:"Send Message"},o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",class:"size-6","aria-hidden":"true"},o("path",{"fill-rule":"evenodd",d:"M8 14a.75.75 0 0 1-.75-.75V4.56L4.03 7.78a.75.75 0 0 1-1.06-1.06l4.5-4.5a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.75 4.56v8.69A.75.75 0 0 1 8 14Z","clip-rule":"evenodd"})))),this.isStreaming&&o("button",{class:"text-white transition rounded-full p-1.5 self-center btn-bg-color bot-btn-primary","aria-label":"Stop Streaming",tabindex:"0",id:"message-submit",onClick:t=>{t.preventDefault(),this.isOpened=!0,this.stopResponse()}},o("i",{class:"block text-body1",title:"Stop Streaming"},o("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",class:"size-6","aria-hidden":"true"},o("path",{d:"M4.5 5.75C4.5 5.05964 5.05964 4.5 5.75 4.5H14.25C14.9404 4.5 15.5 5.05964 15.5 5.75V14.25C15.5 14.9404 14.9404 15.5 14.25 15.5H5.75C5.05964 15.5 4.5 14.9404 4.5 14.25V5.75Z"})))))),this.isExpanded&&!this.isOpened&&o("privacy-modal",{show:this.showPrivacy,message:this.botSettings.privacyTemplate}),0===this.messages.length&&o("div",{id:"input-enter-tip",role:"tooltip",class:"enter-tip"},"Tip: Press Enter to send, Shift+Enter for new line"),this.emptyMessageError&&o("div",{class:"error-message-container"},o("span",{id:"empty-message-error",class:"error-msg",role:"alert"},"Message cannot be empty. Please enter a message to send.")),this.showErrorMessage&&o("p",{class:"error-msg",innerHTML:this.errorMessage}),this.botSettings.buttons&&this.botSettings.buttons.length>0&&!this.isOpened&&o("div",{class:"bot-buttons-container flex flex-wrap gap-2 mt-2.5 mb-1"},this.botSettings.buttons.map(((t,i)=>o("button",{key:i,class:"px-4 py-2 ai12z-btn",onClick:i=>{i.preventDefault(),this.isOpened=!0,this.isContent=!1,this.handleSend(t.label)}},t.label))))))),o("div",{class:"pointer-events-auto fixed right-7 whitespace-nowrap transition-transform duration-300 ease-in-out fab",style:{opacity:this.isMinimized?"1":"0",transform:this.isMinimized?"translateX(0)":"translateX(-100%)",pointerEvents:this.isMinimized?"auto":"none",transformOrigin:"50% 50% 0px"},onClick:()=>{this.openChat()}},this.isBot&&o("slot",{name:"bot"}),!this.isBot&&o("button",{class:"rounded-full flex cursor-pointer items-center pr-[14px] md:gap-x-3 focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-blue-focused bot-btn-primary",tabindex:"0","aria-label":"open Bot"},o("div",{class:"w-10 h-10 flex items-center justify-center bg-white rounded-full border relative"},this.botSettings.botLaunchIcon&&o("img",{src:this.botSettings.botLaunchIcon,alt:"bot icon",class:"w-8 h-8 rounded-lg"}),!this.botSettings.botLaunchIcon&&o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"#2095ae","aria-hidden":"true"},o("g",{"stroke-width":"0"}),o("g",{"stroke-linecap":"round","stroke-linejoin":"round"}),o("g",null," ",o("path",{d:"M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",stroke:"#2095ae","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})," "))),o("span",{class:"bot-name"}," ",null===(k=this.botSettings)||void 0===k?void 0:k.botName," ")))),o("keyboard-shortcuts-dialog",{show:this.showShortcutsDialog,shortcuts:this.shortcuts,onCloseDialog:()=>{this.showShortcutsDialog=!1}}),o("delete-confirmation-modal",{show:this.showLiveAgentEndDialog,dialogTitle:"End live agent chat?",message:"You are about to end the current live agent conversation. You can continue chatting with the bot after ending it.",confirmButtonText:"End",onConfirmDelete:()=>{this.confirmEndLiveAgent()},onCancelDelete:()=>{this.closeEndLiveAgentDialog()}})):o(n,null,o("span",{style:{display:"none"}},"Failed to load ai12z bot control due to insufficient fund"))}get el(){return a(this)}static get watchers(){return{dataKey:[{onDataKeyChange:0}],dataMode:[{onDataModeChange:0}]}}};et.style=':host{font-family:var(--ai12zBot-v2-font-family) !important;font-size:var(--ai12zBot-v2-font-size) !important;color:var(--ai12zBot-v2-font-color, black);text-align:var(--ai12zBot-v2-text-align, left)}.chat-body{height:100%;overflow-y:auto;display:flex;flex-direction:column;gap:10px;overflow-x:hidden}.chat-body::-webkit-scrollbar{width:5px;height:5px;}.chat-body::-webkit-scrollbar-thumb{background-color:#888;border-radius:10px;}.message{padding:10px;border-radius:15px;font-size:14px;line-height:1.4;word-wrap:break-word}span.prose{font-size:14px;}.image-Container{position:relative;display:inline-block;margin-right:10px}.delete-image{opacity:3;position:absolute;right:3px;top:0;cursor:pointer;line-height:10px}.ai12zBtn{background-color:var(--ai12zBot-v2-button-background) !important;color:var(--ai12zBot-v2-button-font-color);padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}.ai12z-btn{background-color:var(--ai12zBot-v2-button-background) !important;color:var(--ai12zBot-v2-button-font-color);padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}.custom-privacy{color:var(--ai12z-bot-privacy-color);padding-bottom:10px;padding-left:5px;margin-top:auto;}@media (max-width: 768px){.hide-chatbot{display:none !important}}:host{--wes-c-icon-color:#fff;--fab-bottom:26px;--xsf-ai12z-zindex-isexpanded-10:20020;--ai-toolbar-icon-color:#2095ae;--xsf-ai12z-zindex-0:19979;--xsf-ai12z-zindex-10:19989;--xsf-ai12z-fab-bottom:26px}.modal-overlay{position:absolute;height:100%;width:100%;z-index:var(--xsf-ai12z-zindex-0);background-color:#2e2e2e99}.layout{pointer-events:none;position:fixed;inset:0;height:100dvh;width:99dvw;justify-content:flex-end;grid-template-rows:auto 1fr auto;grid-template-areas:"left toolbar right" "left main right" "left footer right";padding-top:96px;transition-property:grid-template-columns, padding-top;z-index:19979}.layout.is-open .modal{pointer-events:auto}.layout.is-expanded ai12z-bot{pointer-events:auto}.layout.is-open.is-expanded .modal{border-top-left-radius:0.75rem;border-top-right-radius:0.75rem;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);z-index:var(--xsf-ai12z-zindex-isexpanded-10)}.layout.is-open .user-input-fieldset{background-image:none;padding:0px;background:none}.layout.is-expanded .user-input-fieldset{border-top-left-radius:0.75rem;border-top-right-radius:0.75rem}.layout.is-open .grow-wrap>.textarea,.layout.is-open .grow-wrap>button,.layout.is-open .grow-wrap:after{border-color:var(--ai12zBot-v2-searchbar-open-border-color);}.layout.is-expanded .grow-wrap:after{display:none}.layout.is-open.is-expanded .user-input{z-index:var(--xsf-ai12z-zindex-isexpanded-10)}.layout.is-open .user-input{z-index:var(--xsf-ai12z-zindex-10)}.text-body2{font-size:16px;line-height:1.5;letter-spacing:-0.12px;font-weight:400}.modal-toolbar-icon{color:var(--ai12zBot-v2-toolbar-icon-color, inherit);width:1rem;height:1rem}.search-flex{flex:1 1 0%}.show-grid{display:grid}.hide-title{padding:0px;opacity:0;height:0px}.user-msg{background-color:var(--ai12zBot-v2-user-bubble-background);color:var(--ai12zBot-v2-user-bubble-font-color)}.text-body4{font-size:var(--ai12zBot-v2-timestamp-font-size);line-height:1.5;letter-spacing:0.03px;font-weight:400;color:var(--ai12zBot-v2-timestamp-font-color)}.isContent{background:var(--ai12zBot-v2-content-background);padding:10px}.default-botAvatar{color:var(--ai12zBot-v2-default-avatar-color)}.searchform{opacity:1;transform:none}.user-input{margin-left:auto;margin-right:auto;width:100%;max-width:840px;min-width:340px;grid-area:footer}.main{margin-left:auto;margin-right:auto;width:100%;max-width:840px;min-width:340px;margin-top:7px}.heading{color:var(--ai12zBot-v2-title-color)}.dropdown-item-button{display:flex;width:100%;cursor:pointer;align-items:center;-moz-column-gap:8px;column-gap:8px;border-radius:0.25rem;--tw-border-opacity:1;--tw-bg-opacity:1;background-color:var(--ai12zBot-v2-dropdown-bgcolor);padding:8px 24px;font-weight:500;--tw-text-opacity:1;color:var(--ai12zBot-v2-dropdown-font-color);transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:75ms}.helptext{padding:0px;opacity:0;height:0px}.minimize-input{transform:translateY(calc(-100% - 4px))}.ai-text-caption{font-size:12px;line-height:1.5;letter-spacing:0.2px;font-weight:400}.fab>button{background:var(--ai12zBot-v2-fab-button-background);}.user-input-fieldset{background:var(--ai12zBot-v2-searchbar-background)}.return-text-color{color:rgb(255, 255, 255)}.ai-minimize-icon svg{fill:currentColor;height:1em;width:1em}.hide-form{opacity:0;transform:none}.show-form{opacity:1;transform:none}.ai-minimize-icon{color:var(--wes-c-icon-color, inherit)}.fab{bottom:var(--fab-bottom, 30px)}.text-body1{font-size:var(--ai12zBot-v2-title-font-size);line-height:1.5;letter-spacing:-0.12px;font-weight:400}#message-submit{margin-right:6px;margin-bottom:7px;background-color:var(--ai12zBot-v2-searchbar-submit-bgcolor)}.ai-icon{color:var(--ai12zBot-v2-searchbar-submit-color);font-size:24px;width:1.5rem;height:1.5rem}.plus-icon{color:var(--ai12zBot-v2-searchbar-plus-icon-color);font-size:24px;width:1.5rem;height:1.5rem}.grow-wrap>.textarea,.grow-wrap:after{min-height:48px;align-content:center;border-radius:1.5rem;border-width:1px;border-style:solid;border:1px solid var(--ai12zBot-v2-searchbar-border-color);--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:8px 48px;text-indent:2px;font-size:16px;line-height:1.5;letter-spacing:-0.12px;font-weight:400;--tw-text-opacity:1;color:rgb(46 46 46 / var(--tw-text-opacity, 1));--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-ring-inset:inset;--tw-ring-offset-width:0px;transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:0.15s}.grow-wrap>.textarea,.grow-wrap:after{grid-area:1 / 1 / 2 / 2}.modal{position:relative;grid-column:span 1 / span 1;grid-column-start:2;grid-row:span 3 / span 3;grid-row-start:1;display:grid;border-top-left-radius:0;border-top-right-radius:0;background-position:center;box-shadow:0 16px 32px -4px #18181829, 0 12px 24px -4px #18181814;background-image:var(--ai12zBot-v2-modal-backgroundImage);background-repeat:no-repeat;background-size:100vw 100vh;grid-template-columns:subgrid;grid-template-rows:subgrid;z-index:var(--xsf-ai12z-zindex-10);transition:0.3sease-out;transition-property:grid-template-columns}.dropdown-menu{pointer-events:none;opacity:0;z-index:10;background-color:var(--ai12zBot-v2-dropdown-bgcolor);transform:translateY(-10px);transition:opacity 0.3s ease, transform 0.3s ease}.dropdown-menu.show{pointer-events:auto;opacity:1;pointer-events:auto;transform:translateY(0);background-color:var(--ai12zBot-v2-dropdown-bgcolor)}.copy-btn{color:var(--ai12zBot-v2-copy-btn-color)}.thumbs-up{fill:var(--ai12zBot-v2-feedback-selected);width:1.5rem}.thumbs-down{fill:var( --ai12zBot-v2-feedback-selected);width:1.5rem}.chat-thumbs-up{color:var(--ai12zBot-v2-feedback-color)}.thumbs-container{justify-content:flex-start;align-items:center}.back-btn svg{fill:var(--ai12zBot-v2-back-button-color)}.dropdown-item{background-color:var(--ai12zBot-v2-dropdown-bgcolor)}button:focus-visible{outline:2px solid var(--ai12zBot-v2-focus-visible-color, #0A2A43);outline-offset:2px}button.bot-btn-primary:focus-visible{outline:2px solid var(--ai12zBot-v2-focus-visible-color-primary, var(--ai12zBot-v2-focus-visible-color, #0A2A43));outline-offset:2px}button.bot-btn-secondary:focus-visible{outline:2px solid var(--ai12zBot-v2-focus-visible-color-secondary, var(--ai12zBot-v2-focus-visible-color, #0A2A43))}.bot-name{color:var(--ai12zBot-v2-fab-name-color, var(--ai12zBot-v2-bot-name-color));font-weight:var(--ai12zBot-v2-fab-font-weight, var(--ai12zBot-v2-bot-name-font-weight))}.ai12z-link{color:var(--ai12zBot-v2-link-color);text-decoration:underline}.ai12z-link:hover{color:var(--ai12zBot-v2-link-hover-color);text-decoration:underline}.toolbar{height:52px;border:#fff;grid-area:toolbar}.skip-link{position:absolute;left:-999px;top:auto;width:1px;height:1px;overflow:hidden}.skip-link:focus{left:10px;top:10px;width:auto;height:auto;z-index:1000}.enter-tip{font-size:12px;color:#666;margin-left:10px}.skip-links.hidden{position:absolute;left:-9999px;}.skip-links.visible{left:auto;position:static;}.error-message-container{margin-top:0.25rem}.error-msg{color:#dc2626;font-size:0.75rem;display:block;animation:slideIn 0.2s ease-out}.ai12z-form-honeypot{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}@keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media (min-width: 1024px){.modal{background-size:80vw 100vh}}@media (min-width: 1024px){.layout.is-expanded{grid-template-columns:1fr minmax(340px, 80dvw) 1fr !important}}@media (min-width: 768px){.layout.is-expanded{-moz-column-gap:48px;column-gap:48px}}@media (max-width: 767px){.layout.is-open{padding-top:0px !important;grid-template-columns:0fr minmax(340px, 1fr) 0fr !important}}@media (max-width: 767px){.fab{right:30px;bottom:var(--xsf-ai12z-fab-bottom, 26px)}}';export{et as ai12z_bot}