PageSourceSearch

https://www.pcmag.com/js/new-app.js?id=bbb20be58dac80e87a2bcdc738b1b660

js pcmag.com collected 2026-09-24 06:04:06 UTC 694,837 bytes, 2 lines download raw bytes

1/*! For license information please see new-app.js.LICENSE.txt */
2(()=>{var __webpack_modules__={6592:function(e,t,n){e.exports=function(){function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(n){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(Object(i),!0).forEach((function(t){e(n,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}function i(e){var t={exports:{}};return e(t,t.exports),t.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self&&self;var a=i((function(e,t){!function(t,n){e.exports=n()}(0,(function(){var e=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;function t(e,t){return-1===e.indexOf(t)?e.length:e.indexOf(t)}function n(e){var n=e.replace(/^v/,"").replace(/\+.*$/,""),r=t(n,"-"),i=n.substring(0,r).split(".");return i.push(n.substring(r+1)),i}function r(e){return isNaN(Number(e))?e:Number(e)}function i(t){if("string"!=typeof t)throw new TypeError("Invalid argument expected string");if(!e.test(t))throw new Error("Invalid argument not valid semver 
2('"+t+"' received)")}function a(e,t){[e,t].forEach(i);for(var a=n(e),s=n(t),o=0;o<Math.max(a.length-1,s.length-1);o++){var l=parseInt(a[o]||0,10),c=parseInt(s[o]||0,10);if(l>c)return 1;if(c>l)return-1}var u=a[a.length-1],d=s[s.length-1];if(u&&d){var h=u.split(".").map(r),p=d.split(".").map(r);for(o=0;o<Math.max(h.length,p.length);o++){if(void 0===h[o]||"string"==typeof p[o]&&"number"==typeof h[o])return-1;if(void 0===p[o]||"string"==typeof h[o]&&"number"==typeof p[o])return 1;if(h[o]>p[o])return 1;if(p[o]>h[o])return-1}}else if(u||d)return u?-1:1;return 0}var s=[">",">=","=","<","<="],o={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]};function l(e){if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===s.indexOf(e))throw new TypeError("Invalid operator, expected one of "+s.join("|"))}return a.validate=function(t){return"string"==typeof t&&e.test(t)},a.compare=function(e,t,n){l(n);var r=a(e,t);return o[n].indexOf(r)>-1},a}))}));const s=e=>null==e,o=e=>Object.getPrototypeOf(e)===Object.prototype,l=e=>Array.isArray(e),c=e=>{let t={};return Object.entries(e).filter((([e,t])=>
2"function"==typeof t)).forEach((([e,n])=>t[e]=n)),t},u=()=>navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"),d=()=>!!u()||!!window.Alpine&&a.compare(window.Alpine.version,"2.7.0",">="),h=(e,t)=>(Object.entries(e).forEach((([n,r])=>{s(r)||!o(r)&&!l(r)||(e[n]=h(r,t))})),new Proxy(e,{get:(e,n,r)=>t.get(e,n,r),set(e,n,r,i){s(r)||!o(r)&&!l(r)||(r=h(r,t));let a=e[n];return e[n]=r,s(a)||s(a.__watchers)||(e[n].__watchers=a.__watchers),t.set(e,n,e[n],i),!0}})),p={stores:{},persistenceDriver:window.localStorage,persisted:[],persistedDrivers:{},subscribers:[],pendingWatchers:{},disableReactivity:!1,startingCallbacks:[],startedCallbacks:[],hasStarted:!1,start(){this.startingCallbacks.forEach((e=>e())),this.attach(),this.stores=h(this.stores,{get:(e,t,n)=>Object.is(n,this.stores)&&["get","set","toggle","call","clear"].includes(t)?this[t].bind(this):Reflect.get(e,t,n),set:(e,t,n,r)=>{if(!this.disableReactivity){this.updateSubscribers(),this.runWatchers(e,t,n,r),this.disableReactivity=!0;try{this.persisted.forEach(this.updateLocalStorage.bind(this))}catch(e){}this.disableReactivity=!1}}}),this.hasStarted=!0,this.disableReactivity=!0,Object.entries(this.pendingWatchers).forEach((([e,t])=>{t.forEach((t=>this.watch(e,t)))})),this.disableReactivity=!1,this.startedCallbacks.forEach((e=>e()))},starting(e){this.startingCallbacks.push(e)},started(e){this.startedCallbacks.push(e)},attach(){if(!d())throw new Error("[Spruce] You must be using Alpine >= 2.5.0 to use Spruce.");const e=this;window.Alpine.addMagicProperty("store",(t=>(e.subscribe(t),e.stores)))},store(e,t,n=!1){"function"==typeof t&&(t=t());const r=this.isValidDriver(n);if(!0===n||r)try{this.stores[e]=this.retrieveFromLocalStorage(e,c(t),r?n:void 0),r&&(this.persistedDrivers[e]=n),this.persisted.includes(e)||this.persisted.push(e)}catch(e){}return this.stores[e]||(this.stores[e]=t),this.stores[e]},reset(e,t){void 0!==this.stores[e]&&(this.stores[e]=t)},delete(e,t=!0){return void 0!==this.stores[e]&&(delete this.stores[e],t&&this.updateSubscribers(),!0)},deleteAll(){const e=Object.keys(this.stores).map((e=>this.delete(e,!1)));return this.updateSubscribers(),!e.some((e=>!e))},subscribe(e){return this.subscribers.includes(e)||this.subscribers.push(e),this.stores},updateSubscribers(){this.subscribers.filter((e=>!!e.__x)).forEach((e=>{e.__x.updateElements(e)}))},retrieveFromLocalStorage(e,t={},n){let r=this.persistenceDriver;void 0!==n&&(this.guardAgainstInvalidDrivers(n),r=n);const i=r.getItem(`__spruce:${e}`);if(!i)return null;let a=JSON.parse(i);return"object"==typeof a&&(a=Object.assign(t,a),delete a.__watchers,delete a.__key_name),a},updateLocalStorage(e){const t=r({},this.store(e));delete t.__watchers,delete t.__key_name,(this.persistedDrivers[e]||this.persistenceDriver).setItem(`__spruce:${e}`,JSON.stringify(this.store(e)))},get(e,t=this.stores){return e.split(".").reduce(((e,t)=>e[t]),t)},set(e,t,n=this.stores){return l(e)||(e=e.split(".")),1===e.length?n[e[0]]=t:(n[e[0]]||(n[e[0]]={}),this.set(e.slice(1),t,n[e[0]]))},toggle(e){return this.set(e,!this.get(e))},call(e,...t){return this.get(e)(...t)},clear(e){return this.persistenceDriver.removeItem(`__spruce:${e}`)},watch(e,t){if(!this.hasStarted)return this.pendingWatchers[e]||(this.pendingWatchers[e]=[]),this.pendingWatchers[e].push(t),[()=>this.unwatch(e,t)];const n=e.split("."),r=n.reduce(((e,t)=>{const n=e[t];return s(n)||!o(n)&&!l(n)?e:n}),this.stores),i=Object.is(r,this.get(e))?"__self":n[n.length-1];return r.hasOwnProperty("__watchers")||Object.defineProperty(r,"__watchers",{enumerable:!1,value:new Map,configurable:!0}),r.__watchers.has(i)||r.__watchers.set(i,new Set),r.__watchers.get(i).add(t),[()=>this.unwatch(e,t)]},unwatch(e,t){const n=e.split("."),r=n.reduce(((e,t)=>{const n=e[t];return s(n)||!o(n)&&!l(n)?e:n}),this.stores),i=Object.is(r,this.get(e))?"__self":n[n.length-1],a=r.__watchers;a.has(i)&&a.get(i).delete(t)},watchers(e){const t=e.split("."),n=t.reduce(((e,t)=>{const n=e[t];return s(n)||!o(n)&&!l(n)?e:n}),this.stores),r=Object.is(n,this.get(e))?"__self":t[t.length-1];return n.__watchers?n.__watchers.get(r):{}},runWatchers(e,t,n){e.__watchers&&(e.__watchers.has(t)&&e.__watchers.get(t).forEach((e=>e(n))),e.__watchers.has("__self")&&e.__watchers.get("__self").forEach((e=>e(n,t))))},persistUsing(e){this.persisted.length>0&&console.warn("[Spruce] You have already initialised a persisted store. Changing the driver may cause issues."),this.guardAgainstInvalidDrivers(e),this.persistenceDriver=e},guardAgainstInvalidDrivers(e){if("function"!=typeof e.getItem)throw new Error("[Spruce] The persistence driver must have a `getItem(key)` method.");if("function"!=typeof e.setItem)throw new Error("[Spruce] The persistence driver must have a `setItem(key, value)` method.");if("function"!=typeof e.removeItem)throw new Error("[Spruce] The persistence driver must have a `removeItem(name)` method.")},isValidDriver(e){try{this.guardAgainstInvalidDrivers(e)}catch(e){return!1}return!0}};window.Spruce=p;const f=window.deferLoadingAlpine||function(e){e()};return window.deferLoadingAlpine=function(e){window.Spruce.start(),f(e)},p}()},9529:()=>{document.querySelectorAll("[x-bind-one-true-click]:not([data-processed])").forEach((function(e){"undefined"!=typeof gtag&&null!==gtag&&gtag((function(t){e.setAttribute("data-processed","true");e.href.indexOf("?"),e.href;var n=[];n._ga=window.clientId,n.u=encodeURIComponent(document.location.toString()),n.template=window.template||null,n.module=e.dataset.module||null,n.element=e.dataset.element||null,n.item=e.dataset.item||null,n.position=e.dataset.position||null,
2n.element_label=e.innerText.replace(/\n/g," ")||null,n.object_type=window.object_type||null,n.object_uuid=window.object_uuid||null,n.product_uuid=e.dataset.productUuid||null;var r=e.getAttribute("href"),i=r.indexOf("?")?r.substr(r.indexOf("?")+1):"";i.length>1&&i.split("&").forEach((function(e){var t=e.split("=")[0];null!=n[t]&&delete n[t]}));var a=[];for(var s in n)null!=n[s]&&a.push(s+"="+n[s]);e.hasAttribute("data-commerce")||e.addEventListener("click",(function(){-1!==["article-page","review-page"].indexOf(window.template)&&(window.liQ=window.liQ||[],window.liQ.push({event:"conversion",name:"commerce_click"}))})),e.addEventListener("click",(function(){window.__taboolaPixelEnabled&&(window._tfa=window._tfa||[],window._tfa.push({notify:"event",name:"pcmagaffiliatebuttonclick",id:window.__taboolaPixelId}))})),e.href=e.href+(-1===e.href.indexOf("?")?"?":a.length>0?"&":"")+a.join("&")}))}))},3050:()=>{window.debounce=function(e){var t=arguments.length<=1||void 0===arguments[1]?100:arguments[1],n=void 0;return function(){for(var r=this,i=arguments.length,a=Array(i),s=0;s<i;s++)a[s]=arguments[s];clearTimeout(n),n=setTimeout((function(){e.apply(r,a)}),t)}}},6340:(e,t,n)=>{"use strict";n.r(t);var r=n(7955),i=n.n(r),a=n(1609),s=n.n(a);window._unescape=function(e){return i()(e)},window._isEmpty=function(e){return s()(e)}},3282:()=>{window.throttle=function(e,t){var n=!1;return function(){n||(e.apply(this,arguments),n=!0,setTimeout((function(){n=!1}),t))}}},3349:()=>{var e=document.querySelectorAll("[data-image-loader], [v-image-loader]"),t={rootMargin:window.innerHeight+"px"};window.onIntersection=function(e){e.forEach((function(e){e.isIntersecting&&preloadImage(e.target)}))},window.preloadImage=function(e){var t,n=e.getAttribute("data-image-loader");n||(n=(t=e.getAttribute("v-image-loader"),Function('"use strict";return ('+t+")")()).imageSrc);for(var r=0,i=e.parentElement,a=1;r<=0&&a<5;)r=i.clientWidth,i=i.parentElement,a++;if(null!=e.dataset.lazySized)if(-1!==n.indexOf("size_")){var s=n.match(/size_(\d+)x(\d+)/),o=parseFloat(s[1]),l=r>50&&r<=o?50*Math.ceil(r/50):Math.ceil(o),c=Math.ceil(l/(parseFloat(s[1])/parseFloat(s[2])));-1===n.indexOf("lpad")?e.newSrc=n.replace(/size_(\d+)x(\d+)/,"size_"+Math.ceil(l*window.devicePixelRatio)+"x"+Math.ceil(c*window.devicePixelRatio)):e.newSrc=n.replace(/size_(\d+)x(\d+)/,"size_"+Math.ceil(l)+"x"+Math.ceil(c)),e.width=l,e.height=c}else{var u=n.lastIndexOf("."),d=r>50&&r<=e.clientWidth?50*Math.ceil(r/50):Math.ceil(e.clientWidth);-1===n.indexOf("lpad")?e.newSrc=n.substring(0,u)+".fit_lim.size_"+Math.ceil(d*window.devicePixelRatio)+"x"+n.slice(n.lastIndexOf(".")):e.newSrc=n}else if(-1!==n.indexOf("size_")){var h=n.match(/size_(\d+)x(\d+)/);if(h)e.newSrc=n.replace(/size_(\d+)x(\d+)/,"size_"+Math.ceil(parseInt(h[1])*window.devicePixelRatio)+"x"+Math.ceil(parseInt(h[2])*window.devicePixelRatio)),e.width=parseInt(h[1]),e.height=parseInt(h[2]);else{var p=n.match(/size_(\d+)x/);e.newSrc=n.replace(/size_(\d+)x/,"size_"+Math.ceil(parseInt(p[1])*window.devicePixelRatio)+"x"),e.width=parseInt(p[1])}}else e.newSrc=n;e.onload=e.onerror=function(){e.style.opacity="1",e.style.background="transparent"},e.src=e.newSrc,"IntersectionObserver"in window&&(e.setAttribute("data-viewed",!0),window.imageObserver.unobserve(e))},"IntersectionObserver"in window?(window.imageObserver=new window.IntersectionObserver(window.onIntersection,t),e.forEach((function(e){window.imageObserver.observe(e)}))):Array.from(e).forEach((function(e){return preloadImage(e)}));var n=[];window.mutationsObserver=new window.MutationObserver((function(e){e.forEach((function(e){for(var t=0;t<e.addedNodes.length;t++)void 0===e.addedNodes[t].querySelector||null===e.addedNodes[t].querySelector("[data-image-loader]:not([data-viewed])")&&!e.addedNodes[t].getAttribute("data-image-loader")||(e.addedNodes[t].getAttribute("data-image-loader")?n.push(e.addedNodes[t]):e.addedNodes[t].querySelectorAll("[data-image-loader]:not([data-viewed])").forEach((function(e){n.push(e)})))})),"IntersectionObserver"in window?n.forEach((function(e){window.imageObserver.observe(e)}
2)):Array.from(n).forEach((function(e){return preloadImage(e)})),n=[]})),window.mutationsObserver.observe(document,{childList:!0,subtree:!0})},6051:(e,t,n)=>{"use strict";function r(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function i(e,t){void 0===e&&(e={}),void 0===t&&(t={});const n=["__proto__","constructor","prototype"];Object.keys(t).filter((e=>n.indexOf(e)<0)).forEach((n=>{void 0===e[n]?e[n]=t[n]:r(t[n])&&r(e[n])&&Object.keys(t[n]).length>0&&i(e[n],t[n])}))}n.r(t);const a={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function s(){const e="undefined"!=typeof document?document:{};return i(e,a),e}const o={document:a,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function l(){const e="undefined"!=typeof window?window:{};return i(e,o),e}function c(e){let t,n=e;if(n){for(t=0;null!==(n=n.previousSibling);)1===n.nodeType&&(t+=1);return t}}function u(e,t){const n=[];let r=e.parentElement;for(;r;)t?r.matches(t)&&n.push(r):n.push(r),r=r.parentElement;return n}function d(e){return(Array.isArray(e)?e:[e]).filter((e=>!!e))}function h(e){let{swiper:t,extendParams:n,on:r,emit:i}=e;const a=s(),o=l();function c(e){if(!t.enabled)return;const{rtlTranslate:n}=t;let r=e;r.originalEvent&&(r=r.originalEvent);const c=r.keyCode||r.charCode,d=t.params.keyboard.pageUpDown,h=d&&33===c,p=d&&34===c,f=37===c,m=39===c,g=38===c,v=40===c;if(!t.allowSlideNext&&(t.isHorizontal()&&m||t.isVertical()&&v||p))return!1;if(!t.allowSlidePrev&&(t.isHorizontal()&&f||t.isVertical()&&g||h))return!1;if(!(r.shiftKey||r.altKey||r.ctrlKey||r.metaKey||a.activeElement&&a.activeElement.nodeName&&("input"===a.activeElement.nodeName.toLowerCase()||"textarea"===a.activeElement.nodeName.toLowerCase()))){if(t.params.keyboard.onlyInViewport&&(h||p||f||m||g||v)){let e=!1;if(u(t.el,`.${t.params.slideClass}, swiper-slide`).length>0&&0===u(t.el,`.${t.params.slideActiveClass}`).length)return;const r=t.el,i=r.clientWidth,a=r.clientHeight,c=o.innerWidth,d=o.innerHeight,h=function(e){const t=l(),n=s(),r=e.getBoundingClientRect(),i=n.body,a=e.clientTop||i.clientTop||0,o=e.clientLeft||i.clientLeft||0,c=e===t?t.scrollY:e.scrollTop,u=e===t?t.scrollX:e.scrollLeft;return{top:r.top+c-a,left:r.left+u-o}}(r);n&&(h.left-=r.scrollLeft);const p=[[h.left,h.top],[h.left+i,h.top],[h.left,h.top+a],[h.left+i,h.top+a]];for(let t=0;t<p.length;t+=1){const n=p[t];if(n[0]>=0&&n[0]<=c&&n[1]>=0&&n[1]<=d){if(0===n[0]&&0===n[1])continue;e=!0}}if(!e)return}t.isHorizontal()?((h||p||f||m)&&(r.preventDefault?r.preventDefault():r.returnValue=!1),((p||m)&&!n||(h||f)&&n)&&t.slideNext(),((h||f)&&!n||(p||m)&&n)&&t.slidePrev()):((h||p||g||v)&&(r.preventDefault?r.preventDefault():r.returnValue=!1),(p||v)&&t.slideNext(),(h||g)&&t.slidePrev()),i("keyPress",c)}}function d(){t.keyboard.enabled||(a.addEventListener("keydown",c),t.keyboard.enabled=!0)}function h(){t.keyboard.enabled&&(a.removeEventListener("keydown",c),t.keyboard.enabled=!1)}t.keyboard={enabled:!1},n({keyboard:{enabled:!1,onlyInViewport:!0,pageUpDown:!0}}),r("init",(()=>{t.params.keyboard.enabled&&d()})),r("destroy",(()=>{t.keyboard.enabled&&h()})),Object.assign(t.keyboard,{enable:d,disable:h})}function p(e,t,n,r){return e.params.createElements&&Object.keys(r).forEach((i=>{if(!n[i]&&!0===n.auto){let a=function(e,t){void 0===t&&(t="");const n=l(),r=[...e.children];return n.HTMLSlotElement&&e instanceof HTMLSlotElement&&r.push(...e.assignedElements()),t?r.filter((e=>e.matches(t))):r}(e.el,`.${r[i]}`)[0];a||(a=function(e,t){void 0===t&&(t=[]);const n=document.createElement(e);return n.classList.add(...Array.isArray(t)?t:function(e){return void 0===e&&(e=""),e.trim().split(" ").filter((e=>!!e.trim()))}(t)),n}("div",r[i]),a.className=r[i],e.el.append(a)),n[i]=a,t[i]=a}})),n}function f(e){let{swiper:t,extendParams:n,on:r,emit:i}=e;function a(e){let n;return e&&"string"==typeof e&&t.isElement&&(n=t.el.querySelector(e)||t.hostEl.querySelector(e),n)?n:(e&&("string"==typeof e&&(n=[...document.querySelectorAll(e)]),t.params.uniqueNavElements&&"string"==typeof e&&n&&n.length>1&&1===t.el.querySelectorAll(e).length?n=t.el.querySelector(e):n&&1===n.length&&(n=n[0])),e&&!n?e:n)}function s(e,n){const r=t.params.navigation;
2(e=d(e)).forEach((e=>{e&&(e.classList[n?"add":"remove"](...r.disabledClass.split(" ")),"BUTTON"===e.tagName&&(e.disabled=n),t.params.watchOverflow&&t.enabled&&e.classList[t.isLocked?"add":"remove"](r.lockClass))}))}function o(){const{nextEl:e,prevEl:n}=t.navigation;if(t.params.loop)return s(n,!1),void s(e,!1);s(n,t.isBeginning&&!t.params.rewind),s(e,t.isEnd&&!t.params.rewind)}function l(e){e.preventDefault(),(!t.isBeginning||t.params.loop||t.params.rewind)&&(t.slidePrev(),i("navigationPrev"))}function c(e){e.preventDefault(),(!t.isEnd||t.params.loop||t.params.rewind)&&(t.slideNext(),i("navigationNext"))}function u(){const e=t.params.navigation;if(t.params.navigation=p(t,t.originalParams.navigation,t.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"}),!e.nextEl&&!e.prevEl)return;let n=a(e.nextEl),r=a(e.prevEl);Object.assign(t.navigation,{nextEl:n,prevEl:r}),n=d(n),r=d(r);const i=(n,r)=>{n&&n.addEventListener("click","next"===r?c:l),!t.enabled&&n&&n.classList.add(...e.lockClass.split(" "))};n.forEach((e=>i(e,"next"))),r.forEach((e=>i(e,"prev")))}function h(){let{nextEl:e,prevEl:n}=t.navigation;e=d(e),n=d(n);const r=(e,n)=>{e.removeEventListener("click","next"===n?c:l),e.classList.remove(...t.params.navigation.disabledClass.split(" "))};e.forEach((e=>r(e,"next"))),n.forEach((e=>r(e,"prev")))}n({navigation:{nextEl:null,prevEl:null,hideOnClick:!1,disabledClass:"swiper-button-disabled",hiddenClass:"swiper-button-hidden",lockClass:"swiper-button-lock",navigationDisabledClass:"swiper-navigation-disabled"}}),t.navigation={nextEl:null,prevEl:null},r("init",(()=>{!1===t.params.navigation.enabled?f():(u(),o())})),r("toEdge fromEdge lock unlock",(()=>{o()})),r("destroy",(()=>{h()})),r("enable disable",(()=>{let{nextEl:e,prevEl:n}=t.navigation;e=d(e),n=d(n),t.enabled?o():[...e,...n].filter((e=>!!e)).forEach((e=>e.classList.add(t.params.navigation.lockClass)))})),r("click",((e,n)=>{let{nextEl:r,prevEl:a}=t.navigation;r=d(r),a=d(a);const s=n.target;let o=a.includes(s)||r.includes(s);if(t.isElement&&!o){const e=n.path||n.composedPath&&n.composedPath();e&&(o=e.find((e=>r.includes(e)||a.includes(e))))}if(t.params.navigation.hideOnClick&&!o){if(t.pagination&&t.params.pagination&&t.params.pagination.clickable&&(t.pagination.el===s||t.pagination.el.contains(s)))return;let e;r.length?e=r[0].classList.contains(t.params.navigation.hiddenClass):a.length&&(e=a[0].classList.contains(t.params.navigation.hiddenClass)),i(!0===e?"navigationShow":"navigationHide"),[...r,...a].filter((e=>!!e)).forEach((e=>e.classList.toggle(t.params.navigation.hiddenClass)))}}));const f=()=>{t.el.classList.add(...t.params.navigation.navigationDisabledClass.split(" ")),h()};Object.assign(t.navigation,{enable:()=>{t.el.classList.remove(...t.params.navigation.navigationDisabledClass.split(" ")),u(),o()},disable:f,update:o,init:u,destroy:h})}function m(e){return void 0===e&&(e=""),`.${e.trim().replace(/([\.:!+\/])/g,"\\$1").replace(/ /g,".")}`}function g(e){let{swiper:t,extendParams:n,on:r,emit:i}=e;const a="swiper-pagination";let s;n({pagination:{el:null,bulletElement:"span",clickable:!1,hideOnClick:!1,renderBullet:null,renderProgressbar:null,renderFraction:null,renderCustom:null,progressbarOpposite:!1,type:"bullets",dynamicBullets:!1,dynamicMainBullets:1,formatFractionCurrent:e=>e,formatFractionTotal:e=>e,bulletClass:`${a}-bullet`,bulletActiveClass:`${a}-bullet-active`,modifierClass:`${a}-`,currentClass:`${a}-current`,totalClass:`${a}-total`,hiddenClass:`${a}-hidden`,progressbarFillClass:`${a}-progressbar-fill`,progressbarOppositeClass:`${a}-progressbar-opposite`,clickableClass:`${a}-clickable`,lockClass:`${a}-lock`,horizontalClass:`${a}-horizontal`,verticalClass:`${a}-vertical`,paginationDisabledClass:`${a}-disabled`}}),t.pagination={el:null,bullets:[]};let o=0;function h(){return!t.params.pagination.el||!t.pagination.el||Array.isArray(t.pagination.el)&&0===t.pagination.el.length}function f(e,n){const{bulletActiveClass:r}=t.params.pagination;e&&(e=e[("prev"===n?"previous":"next")+"ElementSibling"])&&(e.classList.add(`${r}-${n}`),(e=e[("prev"===n?"previous":"next")+"ElementSibling"])&&e.classList.add(`${r}-${n}-${n}`))}function g(e){const n=e.target.closest(m(t.params.pagination.bulletClass));if(!n)return;e.preventDefault();const r=c(n)*t.params.slidesPerGroup;if(t.params.loop){if(t.realIndex===r)return;const e=(i=t.realIndex,a=r,s=t.slides.length,(a%=s)==1+(i%=s)?"next":a===i-1?"previous":void 0);"next"===e?t.slideNext():"previous"===e?t.slidePrev():t.slideToLoop(r)}else t.slideTo(r);var i,a,s}function v(){const e=t.rtl,n=t.params.pagination;if(h())return;let r,a,u=t.pagination.el;u=d(u);const p=t.virtual&&t.params.virtual.enabled?t.virtual.slides.length:t.slides.length,g=t.params.loop?Math.
2ceil(p/t.params.slidesPerGroup):t.snapGrid.length;if(t.params.loop?(a=t.previousRealIndex||0,r=t.params.slidesPerGroup>1?Math.floor(t.realIndex/t.params.slidesPerGroup):t.realIndex):void 0!==t.snapIndex?(r=t.snapIndex,a=t.previousSnapIndex):(a=t.previousIndex||0,r=t.activeIndex||0),"bullets"===n.type&&t.pagination.bullets&&t.pagination.bullets.length>0){const i=t.pagination.bullets;let d,h,p;if(n.dynamicBullets&&(s=function(e,t,n){const r=l();return n?e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(r.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(r.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom")):e.offsetWidth}(i[0],t.isHorizontal()?"width":"height",!0),u.forEach((e=>{e.style[t.isHorizontal()?"width":"height"]=s*(n.dynamicMainBullets+4)+"px"})),n.dynamicMainBullets>1&&void 0!==a&&(o+=r-(a||0),o>n.dynamicMainBullets-1?o=n.dynamicMainBullets-1:o<0&&(o=0)),d=Math.max(r-o,0),h=d+(Math.min(i.length,n.dynamicMainBullets)-1),p=(h+d)/2),i.forEach((e=>{const t=[...["","-next","-next-next","-prev","-prev-prev","-main"].map((e=>`${n.bulletActiveClass}${e}`))].map((e=>"string"==typeof e&&e.includes(" ")?e.split(" "):e)).flat();e.classList.remove(...t)})),u.length>1)i.forEach((e=>{const i=c(e);i===r?e.classList.add(...n.bulletActiveClass.split(" ")):t.isElement&&e.setAttribute("part","bullet"),n.dynamicBullets&&(i>=d&&i<=h&&e.classList.add(...`${n.bulletActiveClass}-main`.split(" ")),i===d&&f(e,"prev"),i===h&&f(e,"next"))}));else{const e=i[r];if(e&&e.classList.add(...n.bulletActiveClass.split(" ")),t.isElement&&i.forEac
2h(((e,t)=>{e.setAttribute("part",t===r?"bullet-active":"bullet")})),n.dynamicBullets){const e=i[d],t=i[h];for(let e=d;e<=h;e+=1)i[e]&&i[e].classList.add(...`${n.bulletActiveClass}-main`.split(" "));f(e,"prev"),f(t,"next")}}if(n.dynamicBullets){const r=Math.min(i.length,n.dynamicMainBullets+4),a=(s*r-s)/2-p*s,o=e?"right":"left";i.forEach((e=>{e.style[t.isHorizontal()?o:"top"]=`${a}px`}))}}u.forEach(((e,a)=>{if("fraction"===n.type&&(e.querySelectorAll(m(n.currentClass)).forEach((e=>{e.textContent=n.formatFractionCurrent(r+1)})),e.querySelectorAll(m(n.totalClass)).forEach((e=>{e.textContent=n.formatFractionTotal(g)}))),"progressbar"===n.type){let i;i=n.progressbarOpposite?t.isHorizontal()?"vertical":"horizontal":t.isHorizontal()?"horizontal":"vertical";const a=(r+1)/g;let s=1,o=1;"horizontal"===i?s=a:o=a,e.querySelectorAll(m(n.progressbarFillClass)).forEach((e=>{e.style.transform=`translate3d(0,0,0) scaleX(${s}) scaleY(${o})`,e.style.transitionDuration=`${t.params.speed}ms`}))}"custom"===n.type&&n.renderCustom?(e.innerHTML=n.renderCustom(t,r+1,g),0===a&&i("paginationRender",e)):(0===a&&i("paginationRender",e),i("paginationUpdate",e)),t.params.watchOverflow&&t.enabled&&e.classList[t.isLocked?"add":"remove"](n.lockClass)}))}function y(){const e=t.params.pagination;if(h())return;const n=t.virtual&&t.params.virtual.enabled?t.virtual.slides.length:t.grid&&t.params.grid.rows>1?t.slides.length/Math.ceil(t.params.grid.rows):t.slides.length;let r=t.pagination.el;r=d(r);let a="";if("bullets"===e.type){let r=t.params.loop?Math.ceil(n/t.params.slidesPerGroup):t.snapGrid.length;t.params.freeMode&&t.params.freeMode.enabled&&r>n&&(r=n);for(let n=0;n<r;n+=1)e.renderBullet?a+=e.renderBullet.call(t,n,e.bulletClass):a+=`<${e.bulletElement} ${t.isElement?'part="bullet"':""} class="${e.bulletClass}"></${e.bulletElement}>`}"fraction"===e.type&&(a=e.renderFraction?e.renderFraction.call(t,e.currentClass,e.totalClass):`<span class="${e.currentClass}"></span> / <span class="${e.totalClass}"></span>`),"progressbar"===e.type&&(a=e.renderProgressbar?e.renderProgressbar.call(t,e.progressbarFillClass):`<span class="${e.progressbarFillClass}"></span>`),t.pagination.bullets=[],r.forEach((n=>{"custom"!==e.type&&(n.innerHTML=a||""),"bullets"===e.type&&t.pagination.bullets.push(...n.querySelectorAll(m(e.bulletClass)))})),"custom"!==e.type&&i("paginationRender",r[0])}function b(){t.params.pagination=p(t,t.originalParams.pagination,t.params.pagination,{el:"swiper-pagination"});const e=t.params.pagination;if(!e.el)return;let n;"string"==typeof e.el&&t.isElement&&(n=t.el.querySelector(e.el)),n||"string"!=typeof e.el||(n=[...document.querySelectorAll(e.el)]),n||(n=e.el),n&&0!==n.length&&(t.params.uniqueNavElements&&"string"==typeof e.el&&Array.isArray(n)&&n.length>1&&(n=[...t.el.querySelectorAll(e.el)],n.length>1&&(n=n.find((e=>u(e,".swiper")[0]===t.el)))),Array.isArray(n)&&1===n.length&&(n=n[0]),Object.assign(t.pagination,{el:n}
2),n=d(n),n.forEach((n=>{"bullets"===e.type&&e.clickable&&n.classList.add(...(e.clickableClass||"").split(" ")),n.classList.add(e.modifierClass+e.type),n.classList.add(t.isHorizontal()?e.horizontalClass:e.verticalClass),"bullets"===e.type&&e.dynamicBullets&&(n.classList.add(`${e.modifierClass}${e.type}-dynamic`),o=0,e.dynamicMainBullets<1&&(e.dynamicMainBullets=1)),"progressbar"===e.type&&e.progressbarOpposite&&n.classList.add(e.progressbarOppositeClass),e.clickable&&n.addEventListener("click",g),t.enabled||n.classList.add(e.lockClass)})))}function _(){const e=t.params.pagination;if(h())return;let n=t.pagination.el;n&&(n=d(n),n.forEach((n=>{n.classList.remove(e.hiddenClass),n.classList.remove(e.modifierClass+e.type),n.classList.remove(t.isHorizontal()?e.horizontalClass:e.verticalClass),e.clickable&&(n.classList.remove(...(e.clickableClass||"").split(" ")),n.removeEventListener("click",g))}))),t.pagination.bullets&&t.pagination.bullets.forEach((t=>t.classList.remove(...e.bulletActiveClass.split(" "))))}r("changeDirection",(()=>{if(!t.pagination||!t.pagination.el)return;const e=t.params.pagination;let{el:n}=t.pagination;
2n=d(n),n.forEach((n=>{n.classList.remove(e.horizontalClass,e.verticalClass),n.classList.add(t.isHorizontal()?e.horizontalClass:e.verticalClass)}))})),r("init",(()=>{!1===t.params.pagination.enabled?w():(b(),y(),v())})),r("activeIndexChange",(()=>{void 0===t.snapIndex&&v()})),r("snapIndexChange",(()=>{v()})),r("snapGridLengthChange",(()=>{y(),v()})),r("destroy",(()=>{_()})),r("enable disable",(()=>{let{el:e}=t.pagination;e&&(e=d(e),e.forEach((e=>e.classList[t.enabled?"remove":"add"](t.params.pagination.lockClass))))})),r("lock unlock",(()=>{v()})),r("click",((e,n)=>{const r=n.target,a=d(t.pagination.el);if(t.params.pagination.el&&t.params.pagination.hideOnClick&&a&&a.length>0&&!r.classList.contains(t.params.pagination.bulletClass)){if(t.navigation&&(t.navigation.nextEl&&r===t.navigation.nextEl||t.navigation.prevEl&&r===t.navigation.prevEl))return;const e=a[0].classList.contains(t.params.pagination.hiddenClass);i(!0===e?"paginationShow":"paginationHide"),a.forEach((e=>e.classList.toggle(t.params.pagination.hiddenClass)))}}));const w=()=>{t.el.classList.add(t.params.pagination.paginationDisabledClass);let{el:e}=t.pagination;e&&(e=d(e),e.forEach((e=>e.classList.add(t.params.pagination.paginationDisabledClass)))),_()};Object.assign(t.pagination,{enable:()=>{t.el.classList.remove(t.params.pagination.paginationDisabledClass);let{el:e}=t.pagination;e&&(e=d(e),e.forEach((e=>e.classList.remove(t.params.pagination.paginationDisabledClass)))),b(),y(),v()},disable:w,render:y,update:v,init:b,destroy:_})}function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){_(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function k(e){var t=function(e,t){if("object"!==v(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==v(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===v(t)?t:String(t)}document.addEventListener("alpine:init",(function(){var e={modules:[f,h],keyboard:{enabled:!0,onlyInViewport:!0,pageUpDown:!0},grabCursor:!0,slidesPerView:1,spaceBetween:32},t={selectedProduct:null,isGalleryVisible:!1,modalGalleries:{},productGalleries:{},openModalAtSlide:function(e,t){var n=this;this.selectedProduct=e,this.$nextTick((function(){var r;null===(r=n.$refs.modal)||void 0===r||r.focus(),n.initModalGallery(e,t)}))},closeModal:function(){var e;if(this.isGalleryVisible=!1,this.selectedProduct&&null!==(e=this.modalGalleries[this.selectedProduct])&&void 0!==e&&e.destroy){this.modalGalleries[this.selectedProduct].destroy(!0,!0);var t=this.modalGalleries,n=this.selectedProduct,r=(t[n],w(t,[n].map(k)));this.modalGalleries=r}this.selectedProduct=null},initModalGallery:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(this.modalGalleries[t])return this.modalGalleries[t].slideTo(r),void setTimeout((function(){return n.isGalleryVisible=!0}),25);var i="modal-gallery-".concat(t),a=document.getElementById(i);a&&(this.modalGalleries[t]=this.createSwiper(i,b(b({},e),{},{initialSlide:r,on:{init:function(){return setTimeout((function(){return n.isGalleryVisible=!0}),25)},slideChange:function(e){var t,n,r,i,s=window.innerWidth<1024,o=s?null==a||null===(t=a.closest("dialog"))||void 0===t?void 0:t.querySelector(".swiper-button-prev"):null==a||null===(n=a.closest("dialog"))||void 0===n?void 0:n.previousElementSibling,l=s?null==a||null===(r=a.closest("dialog"))||void 0===r?void 0:r.querySelector(".swiper-button-next"):null==a||null===(i=a.closest("dialog"))||void 0===i?void 0:i.nextElementSibling;o&&o.setAttribute("data-position",e.realIndex+1),l&&l.setAttribute("data-position",e.realIndex+1)}}})))},initProductGallery:function(e){if(!this.productGalleries[e]){var t,n,r,i="hero-gallery"===e?"hero-gallery":"product-gallery-".concat(e),a=document.getElementById(i),s={};if(a)s.module=null===(t=a.querySelector("[data-module]"))||void 0===t?void 0:t.dataset.module,s.element=null===(n=a.querySelector("[data-element]"))||void 0===n?void 0:n.dataset.element,s.title=null===(r=a.querySelector("[data-title]"))||void 0===r?void 0:r.dataset.title;this.productGalleries[e]=this.createSwiper(i,b(b({},function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.module,n=e.element,r=e.title,i=void 0===r?"circle":r;return{modules:[f,g],grabCursor:!0,slidesPerView:1,spaceBetween:0,pagination:{el:".swiper-pagination",bulletElement:"button",clickable:!0,renderBullet:function(e,r){return'<button class="swiper-pagination-bullet" data-module="'.concat(t,'" data-element="').
2concat(n,'" data-item="pagination-circle" data-title="').concat(i,'" data-position="').concat(e+1,'" x-track-ga-click>')}}}}(s)),{},{on:{init:function(){this.slides.forEach((function(e){return e.removeAttribute("x-cloak")})),"function"==typeof window.preloadNextSlideImages&&window.preloadNextSlideImages(this)},slideChange:function(e){var t=document.querySelector("#".concat(i," .swiper-button-prev")),n=document.querySelector("#".concat(i," .swiper-button-next"));t&&t.setAttribute("data-position",e.realIndex+1),n&&n.setAttribute("data-position",e.realIndex+1),"function"==typeof window.preloadNextSlideImages&&window.preloadNextSlideImages(e)}}}))}},createSwiper:function(e,t){var n=document.getElementById(e);if(!n)return null;var r=n.querySelectorAll(".swiper-slide").length,i=b({},t);if(i.loop=r>1,e.startsWith("modal-gallery-")){var a=n.closest("dialog"),s=[null==a?void 0:a.previousElementSibling,null==a?void 0:a.querySelector(".swiper-button-prev")].filter(Boolean),o=[null==a?void 0:a.nextElementSibling,null==a?void 0:a.querySelector(".swiper-button-next")].filter(Boolean);i.navigation={prevEl:s.length?s:void 0,nextEl:o.length?o:void 0}}else i.navigation={prevEl:"#".concat(e," .swiper-button-prev"),nextEl:"#".concat(e," .swiper-button-next")};return t.pagination&&(i.pagination=b(b({},t.pagination),{},{el:"#".concat(e," .swiper-pagination")})),new Swiper("#".concat(e),b({},i))},init:function(){var e=this;this.$nextTick((function(){document.getElementById("hero-gallery")&&e.initProductGallery("hero-gallery");var t=document.querySelectorAll('[id^="product-gallery-"]');t.length>0&&t.forEach((function(t){if(null!=t&&t.id&&null!==t.offsetParent){var n=t.id.replace("product-gallery-","");e.initProductGallery(n)}}))}))}};Alpine.data("productGallery",(function(){return t})),Alpine.data("heroGallery",(function(){return t}))}))},4278:()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function r(){"use strict";r=function(){return t};var t={},n=Object.prototype,i=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",l=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function d(e,t,n,r){var i=t&&t.prototype instanceof f?t:f,s=Object.create(i.prototype),o=new T(r||[]);return a(s,"_invoke",{value:S(e,n,o)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var p={};function f(){}function m(){}function g(){}var v={};u(v,o,(function(){return this}));var y=Object.getPrototypeOf,b=y&&y(y(A([])));b&&b!==n&&i.call(b,o)&&(v=b);var _=g.prototype=f.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function k(t,n){function r(a,s,o,l){var c=h(t[a],t,s);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==e(d)&&i.call(d,"__await")?n.resolve(d.__await).then((function(e){r("next",e,o,l)}),(function(e){r("throw",e,o,l)})):n.resolve(d).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,l)}))}l(c.arg)}var s;a(this,"_invoke",{value:function(e,t){function i(){return new n((function(n,i){r(e,t,n,i)}))}return s=s?s.then(i,i):i()}})}function S(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return M()}
vendor: 4,503 bytes, line 2
2for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var o=x(s,n);if(o){if(o===p)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=h(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===p)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function x(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var r=h(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,p;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function A(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(i.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:M}}function M(){return{value:void 0,done:!0}}return m.prototype=g,a(_,"constructor",{value:g,configurable:!0}),a(g,"constructor",{value:m,configurable:!0}),m.displayName=u(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,u(e,c,"GeneratorFunction")),e.prototype=Object.create(_),e},t.awrap=function(e){return{__await:e}},w(k.prototype),u(k.prototype,l,(function(){return this})),t.AsyncIterator=k,t.async=function(e,n,r,i,a){void 0===a&&(a=Promise);var s=new k(d(e,n,r,i),a);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},w(_),u(_,c,"Generator"),u(_,o,(function(){return this})),u(_,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,r){return s.type="throw",s.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var o=i.call(a,"catchLoc"),l=i.call(a,"finallyLoc");if(o&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var a=r;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];
2if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),C(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;C(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},t}function i(e,t,n,r,i,a,s){try{var o=e[a](s),l=o.value}catch(e){return void n(e)}o.done?t(l):Promise.resolve(l).then(r,i)}function a(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var s=e.apply(t,n);function o(e){i(s,r,a,o,l,"next",e)}function l(e){i(s,r,a,o,l,"throw",e)}o(void 0)}))}}var s="product-picker";window.productPicker=function(){return{deepChat:null,input:"",debug:!1,showModal:!1,sourceModule:s,sponsors:[],maxMessageHistory:3,currentMessageCount:0,messages:[],rawResponse:[],eventQueue:[],status:{isProcessingEvent:!1,isStreamingResponse:!1,isTypingResponse:!1},connectionSettings:{url:"https://productpicker.pcmag.com/pick/v4",method:"POST",stream:!0},scoreTiers:[{score:5,text:"Exemplary",description:"Near perfection, ground-breaking"},{score:4.5,text:"Outstanding",description:"Best in class, acts as a benchmark for measuring competitors"},{score:4,text:"Excellent",description:"A performance, feature, or value leader in its class, with few shortfalls"},{score:3.5,text:"Good",description:"Does what the product should do, and does so better than many competitors"},{score:3,text:"Average",description:"This product meets basic expectations but lacks standout features"},{score:2.5,text:"Fair",description:"We have some reservations, buy with caution"},{score:2,text:"Subpar",description:"We do not recommend, buy with extreme caution"},{score:1.5,text:"Poor",description:"Do not buy this product"},{score:1,text:"Dismal",description:"Don't even think about buying this product"}],initDeepChat:function(e){var t,n,r=this;this.messages=[],this.showModal=!0,this.sponsors=this.$refs.sponsorData?JSON.parse(this.$refs.sponsorData.innerText):[],void 0!==e&&void 0!==e.detail&&void 0!==e.detail.text&&null!==e.detail.text&&(this.input=e.detail.text),this.sourceModule=null!==(t=null==e||null===(n=e.detail)||void 0===n?void 0:n.module)&&void 0!==t?t:s;var i=document.createElement("deep-chat");i.setAttribute("id","deep-chat-product-picker"),i.setAttribute("connect",JSON.stringify(this.connectionSettings)),i.setAttribute("style","display:none;visibility:hidden;"),this.$refs.deepChatContainer.appendChild(i),this.deepChat=document.getElementById("deep-chat-product-picker"),this.deepChat.requestInterceptor=this.requestInterceptor.bind(this),this.deepChat.responseInterceptor=this.responseInterceptor.bind(this),this.deepChat.onComponentRender=function(){r.queryDeepChat()},this.deepChat.onError=function(e){console.error(e),r.status.isStreamingResponse=!1},this.$nextTick((function(){r.$refs.inputField.focus()})),window.gtag&&gtag("event","impression",{element:"modal",item:this.input?"engaged":"pre-engaged",action:"impression",module:this.sourceModule,element_label:"modal-"+(this.input?"engaged":"post-engaged"),non_interaction:!1})},queryDeepChat:function(){var e=this.stripHtml(this.input);null!==e&&""!==e&&"string"==typeof e&&!1===this.isLoading()&&(this.deepChat.submitUserMessage({text:e}),this.messages.push({role:"user",text:e}),this.analyticsTracking({label:this.input,element:"ai-interface",item:"user-query",action:"user-query",position:this.messages.filter((function(e){return"user"===e.role})).length}),this.analyticsTracking({name:"module_clicks",label:"Ask Me",element:"Ask Me Button",item:"user-query",action:"user-query",position:this.messages.filter((function(e){return"user"===e.role})).length}),this.input=null,this.autoscrollChat())},requestInterceptor:function(e){if(1===e.body.messages.length&&null===e.body.messages[0])return{error:"Request cancelled by user"};for(var t=this.deepChat.getMessages(),n=1,r=0;r<t.length;r++)"user"===t[r].role?(t[r].text+=" [".concat(n,"/").concat(this.maxMessageHistory,"]"),n=n===this.maxMessageHistory?1:n+1):"ai"===t[r].role&&(t[r]={role:"ai",text:this.stripHtml(t[r].html)});return e.body.messages=t,e},responseInterceptor:function(e){if(!1===this.showModal||0===this.messages.length)return this.status.isStreamingResponse=!1,this.rawResponse=[],null;this.debug&&this.rawResponse.push(structuredClone(e)),this.eventQueue.push(e),this.processEventsQueue()},processEventsQueue:(n=a(r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.status.isProcessingEvent){e.next=2;break}return e.abrupt("return");case 2:this.status.isProcessingEvent=!0;case 3:if(!(this.eventQueue.length>0)){e.next=15;break}return t=this.eventQueue.shift(),e.prev=5,e.next=8,this.processEvent(t);case 8:e.next=13;break;case 10:e.prev=10,e.t0=e.catch(5),console.error("Error processing event:",e.t0);case 13:e.next=3;break;case 15:this.status.isProcessingEvent=!1,this.eventQueue.length>0&&this.processEventsQueue();case 17:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(){return n.apply(this,arguments)}),processEvent:(e=a(r().mark((function e(t){var n,i,a,s,o,l,c,u,d,h,p,f,m,g,v,y,b,_,w,k=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasOwnProperty("event")||!t.hasOwnProperty("type")){e.next=26;break}if(a=this.messages.findLast((function(e){return"ai"===e.role})),"status_update"===t.event&&("begin_response"===t.type?(this.status.isStreamingResponse=!0,(s=new this.aiMessage)._parent=this,this.messages.push(s)):"end_response"===t.type&&(this.status.isStreamingResponse=!1,0!==this.messages.length&&(a.pushText("*I'm always learning, and I try to make it clear why I deliver a particular result.&nbsp;If it's not what you're looking for, you can always refine your query or ask me something else instead.*"),this.sortProducts(a),this.analyticsTracking({label:null!==(o="user: "+(null===(l=this.messages.findLast((function(e){return"user"===e.role})))||void 0===l?void 0:l.text))&&void 0!==o?o:"",element:"ai-end-response",item:[].concat(a.productsFeature,a.productsSimple,a.productsFullReport).map((function(e){return e.name})).sort().toString().replaceAll(",",", "),action:"ai_generated_response",type:a.decisionType,categories:a.getCategoriesAsString()})),this.debug&&console.table("RawAiResponse:",this.rawResponse,"Messages",this.messages))),"decision"===t.event&&"response_type"===t.type&&t.hasOwnProperty("value")&&(a.decisionType=t.value.replace("_"," "),t.vamp&&a.pushText(t.vamp),this.debug&&console.log("Decision Type:",t.value)),"output_item"!==t.event){e.next=26;break}if("CHAT"===t.type?void 0!==t.caveat&&t.caveat?a.pushText("*"+this.stripHtml(null!==(u=t.answer)&&void 0!==u?u:t.value)+"*"):a.pushText(null!==(d=null!==(h=t.answer)&&void 0!==h?h:t.value)&&void 0!==d?d:""):"ANSWERED"===t.type?a.pushText(null!==(p=t.answer)&&void 0!==p?p:t.value):"CONFUSED"===t.type?(a.pushText(null!==(f=t.answer)&&void 0!==f?f:t.value),y=null!==(m=null===(g=this.messages.findLast((function(e){return"user"===e.role})))||void 0===g?void 0:g.text)&&void 0!==m?m:"",this.analyticsTracking({label:"ai: "+(null!==(v=t.answer)&&void 0!==v?v:t.value)+"- user: "+y,element:"ai-interface",item:"ai-confused",action:"ai-confused",position:0,type:a.decisionType,categories:a.getCategoriesAsString()})):t.value&&t.value.answer&&a.pushText(t.value.answer),null==t||null===(c=t.value)||void 0===c||!c.products){e.next=24;break}b=t.value.products.length-1;case 8:if(!(b>=0)){e.next=23;break}return e.next=11,this.fetchProduct(t.value.products[b].uuid,"",t.value.products[b].citations||[]);case 11:if(!(_=e.sent).ok){e.next=19;break}return e.next=15,_.json();case 15:void 0!==(w=e.sent).product?t.value.products[b]=w.product:t.value.products.splice(b,1),e.next=20;break;case 19:t.value.products.splice(b,1);case 20:b--,e.next=8;break;case 23:a.products=a.products.concat(t.value.products.reverse());case 24:if(!(this.sponsors.length>0&&a.products.length>0)){e.next=26;break}return e.delegateYield(r().mark((function e(){var t,n,i,s,o,l,c,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=a.getCategories(),n=k.sponsors.filter((function(e){return"category"===e.type})),i=k.sponsors.filter((function(e){return"product"===e.type})),!(n.length>0&&0===a.sponsoredCategory.length)){e.next=12;break}s=0;case 5:if(!(s<n.length)){e.next=12;break}if(!n[s].categories.some((function(e){return t.includes(e)}))){e.next=9;break}return a.sponsoredCategory=[n[s]],e.abrupt("break",12);case 9:s++,e.next=5;break;case 12:if(!(i.length>0)){e.next=34;break}o=0;case 14:if(!(o<i.length)){e.next=34;break}if(!i[o].categories.some((function(e){return t.includes(e)}))||void 0===i[o].offerUuids){e.next=31;break}l=0;case 17:if(!(l<i[o].offerUuids.length)){e.next=31;break}if(!a.sponsoredProducts.map((function(e){return e.offer.uuid})).includes(i[o].offerUuids[l])){e.next=20;break}return e.abrupt("continue",28);case 20:return e.next=22,k.fetchProduct("",i[o].offerUuids[l],[]);case 22:if(!(c=e.sent).ok){e.next=28;break}return e.next=26,c.json();case 26:void 0!==(u=e.sent).product&&(u.product.sponsor=i[o],a.sponsoredProducts=a.sponsoredProducts.concat(u.product));case 28:l++,e.next=17;break;case 31:o++,e.next=14;break;case 34:case"end":return e.stop()}}),e)}))(),"t0",26);case 26:return e.abrupt("return",{html:this.formatTextResponse(null!==(n=null===(i=this.messages.findLast((function(e){return"ai"===e.role})))||void 0===i?void 0:i.text)&&void 0!==n?n:""),overwrite:!0,role:"ai"});case 27:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)}),aiMessage:function(){return{role:"ai",decisionType:null,text:"",upcomingText:[],processingText:!1,citations:[],products:[],productsFullReport:[],productsSimple:[],productsFeature:[],sponsoredCategory:[],sponsoredProducts:[],pushText:function(e){var n;if(null!=e&&""!==e){var r=e.replaceAll(/\. ([A-Za-z1-9])/gi,(function(e,t){return". \n\n ".concat(t)})),i=(new showdown.Converter).makeHtml(" \n \n"+r);(n=this.upcomingText).push.apply(n,t(i.split(""))),this.processText()}},processText:function(){var e=this;if(!this.processingText)if(this.processingText=!0,this._parent.status.isTypingResponse=!0,this.upcomingText.length>0){var t="<"===this.upcomingText[0]&&this.upcomingText.indexOf(">")>0?this.upcomingText.indexOf(">"):1;this.text+=this.upcomingText.splice(0,t).join(""),this._parent.autoscrollChat(),setTimeout((function(){e.processingText=!1,e.processText()}),4)}else this.processingText=!1,this._parent.status.isTypingResponse=!1},getCategoriesAsString:function(){return this.getCategories().toString().replaceAll(",",", ")},getCategories:function(){var e=[];
2return this.products.forEach((function(t){t.citations.forEach((function(t){t.categories&&(e=e.concat(t.categories))}))})),e.length>0&&(e=t(new Set(e))),e.sort()}}},sortProducts:function(e){var t=function(e){return e.citations.filter((function(e){return"review"===e.type})).map((function(e){return e.categories})).flat()},n=e.products.map((function(e){return t(e)})).flat().reduce((function(e,t){return e[t]=(e[t]||0)+1,e}),{});return e.products.sort((function(e,r){var i=t(e)[0],a=t(r)[0];if(i&&a&&i!==a)return(n[a]||0)-(n[i]||0);var s=Number(e.score||0),o=Number(r.score||0);if(s&&o&&s!==o)return o-s;if(e.isEditorsChoice!==r.isEditorsChoice)return r.isEditorsChoice-e.isEditorsChoice;var l=new Date(e.reviewDate),c=new Date(r.reviewDate);return l&&c&&l.getTime()!==c.getTime()?c.getTime()-l.getTime():void 0})),e.products.forEach((function(t){e.citations=e.citations.concat(t.citations||[])})),e.sponsoredProducts.length>0&&"FULL REPORT"!==e.decisionType&&(e.productsSimple=e.productsSimple.concat(e.sponsoredProducts)),"LIST OF PRODUCTS"===e.decisionType?(0===e.productsFeature.length&&(e.productsFeature=e.products.splice(0,1)),e.productsSimple=e.productsSimple.concat(e.products)):"BEST PRODUCT"===e.decisionType?(0===e.productsFullReport.length&&(e.productsFullReport=e.products.splice(0,1)),e.productsSimple=e.productsSimple.concat(e.products)):"FULL REPORT"!==e.decisionType&&"PRODUCT COMPARISON"!==e.decisionType&&"PRODUCT ATTRIBUTE"!==e.decisionType||(e.productsFullReport=e.productsFullReport.concat(e.products)),e},stripHtml:function(e){return((new DOMParser).parseFromString(e,"text/html").body.textContent||"").replaceAll(/[ ]+/gi," ").replaceAll(/( \n)+/gi,"\n").replaceAll(/[\n\r]+/gi,"\n")},trackCommerceUrl:function(e,t,n){var r,i=new URL(e),a=i.searchParams;return a.set("template",window.template),a.set("element",t),a.set("position",n),a.set("module",this.sourceModule),a.set("item","see-it"),null!==(r=i.toString())&&void 0!==r?r:e},fetchProduct:function(e,t,n){var r={productUuid:e,offerUuid:t,citations:[]};return n.forEach((function(e){e.url&&e.type&&r.citations.push(e.type+"|"+e.url)})),fetch("/api/product-picker/get-product?"+new URLSearchParams(r).toString(),{headers:{"X-CSRF-TOKEN":document.querySelector('meta[name="csrf-token"]').getAttribute("content")}}).catch((function(e){return console.error("Error fetching offers:",e),null}))},isLoading:function(){return this.status.isProcessingEvent||this.status.isStreamingResponse||this.status.isTypingResponse},filterCitations:function(e){var t=e.citations.filter((function(e,t,n){return t===n.findIndex((function(t){return t.uuid===e.uuid}))})).sort((function(e,t){return"review"===e.type?-1:1})),n=e.decisionType,r={"LIST OF PRODUCTS":["roundup"],"BEST PRODUCT":["review","roundup"],"PRODUCT ATTRIBUTE":["review","roundup"],"FULL REPORT":["review","roundup"],"PRODUCT COMPARISON":["review","roundup"]};return t.filter((function(e){return r[n]&&r[n].includes(e.type)}))},extractCitations:function(e){var t=[];return e.value.products.length>0&&e.value.products.forEach((function(e){e.citations.forEach((function(e){t.push(e)}))})),t},formatTextResponse:function(e){return(new showdown.Converter).makeHtml(e)},textToArray:function(e){return e.split(/\r?\n|\r|\n/g).filter((function(e){return""!==e}))},scoreTierMetaData:function(e){return null!==e?(e=parseFloat(e),this.scoreTiers.find((function(t){return e===parseFloat(t.score)}))):null},convertScore:function(e){var t=[];if(null!==e)for(var n=parseFloat(e),r=1;r<=5;r++)r-n<=0?t.push("full"):r-n==.5?t.push("half"):r-n>=1&&t.push("empty");return t},formatImage:function(e,t,n){return null!==e?e.replace("size_200","size_"+t+"x"+n):"/images/PCMag_NavLogo.png"},autoscrollChat:function(){var e=this.$el.querySelectorAll(".chat-message-user");e.length>1&&e[e.length-1].scrollIntoView(!0)},modalIsShowing:function(e){document.body.style.overflow=e?"hidden":null},analyticsTracking:function(e){var t;e&&window.gtag&&window.gtag("event",null!==(t=e.name)&&void 0!==t?t:"ai_engagement",{event_label:e.label,event_category:"product-picker",element:e.element||null,item:e.item||null,position:e.position||null,action:e.action||"click",module:this.sourceModule,label:e.label,non_interaction:!1,maggie_ai_output_category:e.categories||null,maggie_ai_output_flow:e.type||null})},closeDeepChat:function(){this.deepChat.clearMessages(),this.messages=[],this.currentMessageCount=0,this.input="",this.showModal=!1,this.isStreamingResponse=!1,this.deepChat.remove()}};var e,n}},9677:()=>{function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}
vendor: 4,235 bytes, line 2
2try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,i){var a=t&&t.prototype instanceof h?t:h,s=Object.create(a.prototype),o=new E(i||[]);return r(s,"_invoke",{value:w(e,n,o)}),s}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d={};function h(){}function p(){}function f(){}var m={};l(m,a,(function(){return this}));var g=Object.getPrototypeOf,v=g&&g(g(C([])));v&&v!==t&&n.call(v,a)&&(m=v);var y=f.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function i(r,a,s,o){var l=u(e[r],e,a);if("throw"!==l.type){var c=l.arg,d=c.value;return d&&"object"==_typeof(d)&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){i("next",e,s,o)}),(function(e){i("throw",e,s,o)})):t.resolve(d).then((function(e){c.value=e,s(c)}),(function(e){return i("throw",e,s,o)}))}o(l.arg)}var a;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){i(e,n,t,r)}))}return a=a?a.then(r,r):r()}})}function w(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return T()}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var o=k(s,n);if(o){if(o===d)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=u(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===d)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function k(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,d;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function C(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:T}}function T(){return{value:void 0,done:!0}}return p.prototype=f,r(y,"constructor",{value:f,configurable:!0}),r(f,"constructor",{value:p,configurable:!0}),p.displayName=l(f,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,o,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},b(_.prototype),l(_.prototype,s,(function(){return this})),e.AsyncIterator=_,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var s=new _(c(t,n,r,i),a);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(y),l(y,o,"Generator"),l(y,a,(function(){return this})),l(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=C,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEac
vendor: 4,088 bytes, line 2
2h(x),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return s.type="throw",s.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(o&&l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:C(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function asyncGeneratorStep(e,t,n,r,i,a,s){try{var o=e[a](s),l=o.value}catch(e){return void n(e)}o.done?t(l):Promise.resolve(l).then(r,i)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function s(e){asyncGeneratorStep(a,r,i,s,o,"next",e)}function o(e){asyncGeneratorStep(a,r,i,s,o,"throw",e)}s(void 0)}))}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}document.addEventListener("alpine:init",(function(){Alpine.data("seamlessScroll",(function(){var seamlessContent=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{seamlessContent,currentContentSlug:null,changeCurrentContentObserver:null,loadNextContentThresholdObserver:null,contentScrollDepthObserver:null,seamlessContentContainer:null,firstPage:!0,lastCustomPageViewLocation:null,init:function(){this.seamlessContentContainer=this.$el,this.initializeObservers(),this.initializeSeamlessScroll(),this.updateViewInstanceGA()},initializeObservers:function(){var e=this,t=this;this.changeCurrentContentObserver=new IntersectionObserver((function(e){var n=e.filter((function(e){return e.isIntersecting}));if(n.length){var r=null;
2n.forEach((function(e){r?e.boundingClientRect.bottom>r.boundingClientRect.bottom&&(r=e):r=e}));var i=r.target.closest("[data-content-container]");if(t.firstPage||i.dataset.contentSlug!==t.currentContentSlug)if(i.dataset.contentSlug!==t.currentContentSlug&&t.updateCurrentContent(i),t.firstPage)t.firstPage=!1,t.dispatchGtagPageViewEvent(i);else if(t.lastCustomPageViewLocation!==i.dataset.contentSlug){t.lastCustomPageViewLocation=i.dataset.contentSlug;var a=t.currentContentSlug;clearTimeout(t.cutomPageViewTimeout),t.cutomPageViewTimeout=setTimeout((function(){t.waitFor((function(){return a===t.currentContentSlug&&document.location.pathname===i.dataset.contentSlug}),(function(){t.dispatchGtagPageViewEvent(i)}))}),200)}}}),{threshold:.1}),this.loadNextContentThresholdObserver=new IntersectionObserver((function(t){t.forEach((function(t){t.isIntersecting&&"0"==t.target.dataset.loadingNextContentState&&(t.target.dataset.loadingNextContentState="1",e.loadSeamlessContent(t.target.dataset.nextContent))}))})),this.contentScrollDepthObserver=new IntersectionObserver((function(t){t.forEach((function(t){t.isIntersecting&&(e.dispatchGtagScrollEvent(t.target),t.target.remove())}))}))},initializeSeamlessScroll:function(){var e=this.seamlessContentContainer.querySelector("[data-content-container]");this.prepareContent(e,this.seamlessContent[0]),this.currentContentSlug=e.dataset.contentSlug},waitFor:function(e,t){var n=0;return new Promise((function t(r){e()?r():++n<20&&setTimeout((function(e){return t(r)}),400)})).then(t)},loadSeamlessContent:function(e){var t=this,n=this.seamlessContentContainer.querySelector('[data-content-slug="'.concat(this.currentContentSlug,'"] [data-seamless-scroll-load-next-content-threshold]')),r=new URL(e,window.location.origin);r.searchParams.set("as-embeddable","1"),window.splitTestIdentifier&&window.splitTestVariant&&(r.searchParams.set("test_uuid",window.splitTestIdentifier),r.searchParams.set("test_variant",window.splitTestVariant)),fetch(r.toString()).then((function(e){return e.text()})).then((function(n){var r=document.createElement("div");r.innerHTML=n;var i=r.firstElementChild,a=t.seamlessContent.find((function(t){return t.slug===e})),s=i.querySelectorAll('a[data-element="link-injector"]'),o=Array.from(s).map((function(e){return e.textContent.trim().toLowerCase()})).join(",")||null;a.analytics.linked_phrases=o,t.prepareContent(i,a),t.initializeNewContent(i)})).then((function(){return n.remove()})).catch((function(){n.dataset.loadingNextContentState="0"}))},updateViewInstanceGA:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.isNotFirstTimeloaded&&t&&(window.viewInstanceUuid=window.generateUUIDv4()),e?(this.isNotFirstTimeloaded=!0,this.seamlessInstanceId?window.seamlessInstanceId=this.seamlessInstanceId:this.seamlessInstanceId=window.viewInstanceUuid,window.seamlessPosition=this.seamlessContent.findIndex((function(t){return t.slug===e.dataset.contentSlug}))):(window.seamlessPosition=0,window.seamlessInstanceId=window.viewInstanceUuid);var r={seamless_index:window.seamlessPosition,view_instance_uuid:window.viewInstanceUuid,seamless_instance_id:window.seamlessInstanceId,update:!0};n&&Object.assign(r,{template:n.template||null,object_type:n.object_type||null,object_uuid:n.object_uuid||null,content_id:n.object_uuid||null,author:n.author||null,category:n.category||null,published_at:n.published_at||null,first_published_at:n.first_published_at||null,updated_at:n.updated_at||null,word_count:n.word_count||null,days_since_updated:n.days_since_updated||null,weeks_since_updated:n.weeks_since_updated||null,days_since_originally_published:n.days_since_originally_published||null,weeks_since_originally_published:n.weeks_since_originally_published||null,deal_methodology_badge:n.deal_methodology_badge||null,focus_keyword:n.focus_keyword||null,linked_phrases:n.linked_phrases||null,zd_event:n.event||null,series:n.series||null}),gtag("config","G-2Y85WP1X8R",r)},prepareContent:function(e,t){var n=this;e.style.position="relative",e.dataset.contentSlug=t.slug;for(var r=25;r<=100;r+=25)e.insertAdjacentHTML("afterbegin",'<div data-content-scroll-depth="'.concat(r,'" style="position: absolute; top: ').concat(r,'%; height: 1px; width: 100%"></div>'));e.querySelectorAll("[data-content-scroll-depth]").forEach((function(e){return n.contentScrollDepthObserver.observe(e)}));[{percentages:[0,5,10,15,20],position:"afterbegin",reverse:!0},{percentages:[80,85,90,95,100],position:"beforeend",reverse:!1}
2].forEach((function(t){var n=t.percentages,r=t.position;(t.reverse?_toConsumableArray(n).reverse():n).forEach((function(t){e.insertAdjacentHTML(r,'<div data-content-breakpoint="'.concat(t,'" class="absolute w-full h-px" style="top: ').concat(t,'%"></div>'))}))})),e.querySelectorAll("[data-content-breakpoint]").forEach((function(e){return n.changeCurrentContentObserver.observe(e)}));var i,a=this.seamlessContent.findIndex((function(e){return e.slug===t.slug}));if(a!==this.seamlessContent.length-1){e.insertAdjacentHTML("afterbegin",'<div\n                        data-seamless-scroll-load-next-content-threshold\n                        data-next-content="'.concat(this.seamlessContent[a+1].slug,'"\n                        data-loading-next-content-state="0"\n                        style="position: absolute; top: 70%; height: 1px; width: 100%"\n                    ></div>'));var s=e.querySelector("[data-seamless-scroll-load-next-content-threshold]");this.loadNextContentThresholdObserver.observe(s);var o=document.querySelector("[data-seamless-scroll-loading-indicator]").cloneNode(!0);o.classList.remove("hidden"),o.classList.add("flex"),e.appendChild(o)}a===this.seamlessContent.length-1||(null===(i=e.querySelector("#related-recirc"))||void 0===i||i.remove())},initializeNewContent:function initializeNewContent(newContentElement){return _asyncToGenerator(_regeneratorRuntime().mark((function _callee(){var allScripts,scriptsToInject,scriptsToEval,ev;return _regeneratorRuntime().wrap((function _callee$(_context){for(;;)switch(_context.prev=_context.next){case 0:return allScripts=newContentElement.querySelectorAll("script[src]"),allScripts.forEach((function(e){return e.parentNode.removeChild(e)})),scriptsToInject=Array.from(allScripts).filter((function(e){var t=e.src.includes(window.location.origin)?e.src.split(window.location.origin)[1]:e.src;return!document.querySelector('script[src="'.concat(t,'"]'))})),_context.next=5,Promise.all(scriptsToInject.map((function(e){return new Promise((function(t,n){var r=document.createElement("script");Array.from(e.attributes).forEach((function(e){r.setAttribute(e.name,e.value)})),r.onload=t,r.onerror=n,document.head.appendChild(r)}))})));case 5:document.querySelector("#app").appendChild(newContentElement),scriptsToEval=new Set(Array.from(newContentElement.querySelectorAll('script:not([src]):not([type="application/ld+json"])')).map((function(e){return e.innerHTML}))),scriptsToEval.forEach((function(script){return eval(script)})),window.videoPlayer&&setTimeout((function(){window.videoPlayer.loadPlayers()}),0),window.initSimilarProductsCarousel&&window.initSimilarProductsCarousel(),ev=null,"function"==typeof Event?ev=new Event("pogoseamlessnav"):document.createEvent&&(ev=document.createEvent("Event"),ev.initEvent("pogoseamlessnav",!0,!0)),ev&&window.dispatchEvent(ev),document.dispatchEvent(new Event("alpine:init"));case 14:case"end":return _context.stop()}}),_callee)})))()},updateCurrentContent:function(e){var t=this.seamlessContent.find((function(t){return t.slug===e.dataset.contentSlug}));this.currentContentSlug=t.slug,window.document.title=t.title;var n=new URL(t.canonical_url,window.location.origin);window.splitTestIdentifier&&window.splitTestVariant&&(n.searchParams.set("test_uuid",window.splitTestIdentifier),n.searchParams.set("test_variant",window.splitTestVariant)),this.updateViewInstanceGA(e,!0,t.analytics),window.history.pushState({},"",n.toString()),document.querySelector("link[rel='canonical']").setAttribute("href",t.canonical_url)},dispatchGtagPageViewEvent:function(e){var t=this;setTimeout((function(){var n=t.seamlessContent.find((function(t){return t.slug===e.dataset.contentSlug}));t.updateViewInstanceGA(e,!1,n.analytics);var r={object_type:n.analytics.object_type||null,object_uuid:n.analytics.object_uuid||null,content_id:n.analytics.object_uuid||null,author:n.analytics.author||null,category:n.analytics.category||null,published_at:n.analytics.published_at||null,first_published_at:n.analytics.first_published_at||null,updated_at:n.analytics.updated_at||null,word_count:n.analytics.word_count||null,days_since_updated:n.analytics.days_since_updated||null,weeks_since_updated:n.analytics.weeks_since_updated||null,days_since_originally_published:n.analytics.days_since_originally_published||null,weeks_since_originally_published:n.analytics.weeks_since_originally_published||null,deal_methodology_badge:n.analytics.deal_methodology_badge||null,focus_keyword:n.analytics.focus_keyword||null,linked_phrases:n.analytics.linked_phrases||null,zd_event:n.analytics.event||null,series:n.analytics.series||null,view_instance_uuid:window.viewInstanceUuid,seamless_instance_id:window.seamlessInstanceId,seamless_index:window.seamlessPosition};gtag("event","page_view_custom",r)}),1e3)},dispatchGtagScrollEvent:function(e){var t=this.seamlessContent.find((function(t){return t.slug===e.closest("[data-content-container]").dataset.contentSlug})),n=this.seamlessContent.findIndex((function(e){return e.slug===t.slug})),r=e.dataset.contentScrollDepth+"%";gtag("event","scroll_custom",{seamless_index:n,depth:r,seamless_location:t.canonical_url,seamless_title:t.title})}}}))}))},924:()=>{window.initSearch=function(e){return{query:"",loading:!1,results:[],isFocused:!1,template:window.template?window.template:"",disableBlurOnSearchButtonClick:!1,allowsSearchResultsPage:["autocomplete"].includes(e),search:function(){var t=this;if(this.query){var n="".concat(window.location.protocol,"//").concat(window.location.host,"/search/").concat(e,"?query=")+encodeURIComponent(this.query.trim().replace(/\s+/g," ")).substring(0,512);fetch(n).then((function(e){return e.json()})).then((function(e){t.results=[],t.selectedIndex=null,e.hits.length&&t.compileResults(e.hits);var n=t;setTimeout((function(){0==n.loading&&window.ga&&(n.sendGARequest("autocomplete",n.query,e.hits.length?e.hits.length:0),n.loading=!0)}),250),t.loading=!1}))}},compileResults:function(e){var t=this;this.results=[],e.forEach((function(e){var n=e.url,r=e.name,i=e._highlightResult.title.value;return i=(i=i.replace("<em>",'<span class="font-bold">')).replace("</em>","</span>"),t.results.push({url:n,name:r,display_name:i}),!0}))},sendGARequest:function(e,t,n){gtag("event","search",{search_term:t,action:e,value:n,non_interaction:!1})},debounceSearch:window.debounce((function(){this.search()}),150),searchBlur:function(e){var t=this;setTimeout((function(){!1===t.disableBlurOnSearchButtonClick&&(t.isFocused=!1,t.clearSearch(),e.target.value=""),t.disableBlurOnSearchButtonClick=!1}),250)},searchFocus:function(){this.isFocused=!0},clearSearch:function(){this.query="",this.results=[],this.selectedIndex=null},selectNextItem:function(){0!==this.results.length&&(null===this.selectedIndex?this.selectedIndex=0:this.selectedIndex=this.selectedIndex!==this.results.length-1?Math.min(this.selectedIndex+1,this.results.length-1):null)},selectPrevItem:function(){0!==this.results.length&&(null===this.selectedIndex?this.selectedIndex=this.results.length-1:this.selectedIndex=this.selectedIndex>0?Math.max(0,this.selectedIndex-1):null)},submitSearch:function(){if(!0===this.allowsSearchResultsPage)if(this.query=this.query.trim().slice(0,256),null!==this.selectedIndex&&window.ga){var e=this.results[this.selectedIndex];this.sendGARequest("selected-search",this.query,this.selectedIndex),window.location.href=e.url}else this.query.trim().length>0&&(window.location.href="/search/results?query=".concat(encodeURIComponent(this.query.trim())));else this.disableBlurOnSearchButtonClick=!0}
2,onKeyUp:function(e){27===e.keyCode?this.blur():38!==e.keyCode&&40!==e.keyCode?this.debounceSearch():13===e.keyCode&&e.preventDefault()},onKeyDown:function(e){38===e.keyCode?this.selectPrevItem():40===e.keyCode?this.selectNextItem():13==e.keyCode&&this.submitSearch()}}}},8377:()=>{function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,a=[],s=!0,o=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);s=!0);}catch(e){o=!0,i=e}finally{try{s||null==n.return||n.return()}finally{if(o)throw i}}return a}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}window.sendGaClick=function(r){if(gtag){var i,a,s,o,l,c,u,d=r.dataset.title?r.dataset.title:r.innerText?r.innerText:null!==(i=null===(a=r.value)||void 0===a?void 0:a.replace(/(<([^>]+)>)/gi,""))&&void 0!==i?i:null,h={};Object.entries(Object.assign({},r.dataset)).forEach((function(e){var t=n(e,2),r=t[0],i=t[1];if(r.startsWith("custom")){var a=r.replace("custom","").split(/(?=[A-Z])/).join("_").toLowerCase();h[a]=i}})),(r.dataset.pageType||window.page_type)&&(h.page_type=null!==(s=r.dataset.pageType)&&void 0!==s?s:window.page_type),(r.dataset.pageUuid||window.page_uuid)&&(h.page_uuid=null!==(o=r.dataset.pageUuid)&&void 0!==o?o:window.page_uuid),(r.dataset.objectType||window.object_type)&&(h.object_type=null!==(l=r.dataset.objectType)&&void 0!==l?l:window.object_type),(r.dataset.objectUuid||window.object_uuid)&&(h.object_uuid=null!==(c=r.dataset.objectUuid)&&void 0!==c?c:window.object_uuid),gtag("event","module_clicks",function(n){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){t(n,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}({element:r.dataset.element||null,item:r.dataset.item||null,position:r.dataset.position||null,module:r.dataset.module||null,element_label:null!==(u=null==d?void 0:d.replace(/\s+/g," "))&&void 0!==u?u:null,non_interaction:!1},h))}},document.body.addEventListener("click",(function(e){var t=e.target.hasAttribute("x-track-ga-click")?e.target:e.target.closest("[x-track-ga-click]");t&&sendGaClick(t)}))},4339:()=>{window.trackGAImpressionEvents=function(e,t,n){"undefined"!=typeof gtag&&null!==gtag&&gtag("event","impression",{action:"impression",element:n.dataset.element||null,item:n.dataset.item||null,module:e||null,element_label:t,position:n.dataset.position||null,template:n.dataset.template||null,non_interaction:!1})}},6909:()=>{window.addEventListener("message",(function(e){var t;try{t=JSON.parse(e.data)}catch(e){return!1}if("iframe.resize"!==t.context)return!1;var n=document.querySelector('iframe[src="'+t.src+'"]');if(!n)return!1;n.height=t.height,n.width=document.documentElement.clientWidth-50>750?750:document.documentElement.clientWidth-50}))},5381:(e,t,n)=>{var r=n(852)(n(5639),"DataView");e.exports=r},7071:(e,t,n)=>{var r=n(852)(n(5639),"Map");e.exports=r},3818:(e,t,n)=>{var r=n(852)(n(5639),"Promise");e.exports=r},8525:(e,t,n)=>{var r=n(852)(n(5639),"Set");e.exports=r},2705:(e,t,n)=>{var r=n(5639).Symbol;e.exports=r},577:(e,t,n)=>{var r=n(852)(n(5639),"WeakMap");e.exports=r},9932:e=>{e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}}
2,4239:(e,t,n)=>{var r=n(2705),i=n(9607),a=n(2333),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?i(e):a(e)}},9454:(e,t,n)=>{var r=n(4239),i=n(7005);e.exports=function(e){return i(e)&&"[object Arguments]"==r(e)}},8458:(e,t,n)=>{var r=n(3560),i=n(5346),a=n(3218),s=n(346),o=/^\[object .+?Constructor\]$/,l=Function.prototype,c=Object.prototype,u=l.toString,d=c.hasOwnProperty,h=RegExp("^"+u.call(d).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!a(e)||i(e))&&(r(e)?h:o).test(s(e))}},8749:(e,t,n)=>{var r=n(4239),i=n(1780),a=n(7005),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,e.exports=function(e){return a(e)&&i(e.length)&&!!s[r(e)]}},280:(e,t,n)=>{var r=n(5726),i=n(6916),a=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=[];for(var n in Object(e))a.call(e,n)&&"constructor"!=n&&t.push(n);return t}},8674:e=>{e.exports=function(e){return function(t){return null==e?void 0:e[t]}}},531:(e,t,n)=>{var r=n(2705),i=n(9932),a=n(1469),s=n(3448),o=r?r.prototype:void 0,l=o?o.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(a(t))return i(t,e)+"";if(s(t))return l?l.call(t):"";var n=t+"";return"0"==n&&1/t==-Infinity?"-0":n}},7518:e=>{e.exports=function(e){return function(t){return e(t)}}},4429:(e,t,n)=>{var r=n(5639)["__core-js_shared__"];e.exports=r},1957:(e,t,n)=>{var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},852:(e,t,n)=>{var r=n(8458),i=n(7801);e.exports=function(e,t){var n=i(e,t);return r(n)?n:void 0}},9607:(e,t,n)=>{var r=n(2705),i=Object.prototype,a=i.hasOwnProperty,s=i.toString,o=r?r.toStringTag:void 0;e.exports=function(e){var t=a.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch(e){}var i=s.call(e);return r&&(t?e[o]=n:delete e[o]),i}},4160:(e,t,n)=>{var r=n(5381),i=n(7071),a=n(3818),s=n(8525),o=n(577),l=n(4239),c=n(346),u="[object Map]",d="[object Promise]",h="[object Set]",p="[object WeakMap]",f="[object DataView]",m=c(r),g=c(i),v=c(a),y=c(s),b=c(o),_=l;(r&&_(new r(new ArrayBuffer(1)))!=f||i&&_(new i)!=u||a&&_(a.resolve())!=d||s&&_(new s)!=h||o&&_(new o)!=p)&&(_=function(e){var t=l(e),n="[object Object]"==t?e.constructor:void 0,r=n?c(n):"";if(r)switch(r){case m:return f;case g:return u;case v:return d;case y:return h;case b:return p}return t}),e.exports=_},7801:e=>{e.exports=function(e,t){return null==e?void 0:e[t]}},5346:(e,t,n)=>{var r,i=n(4429),a=(r=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!a&&a in e}},5726:e=>{var t=Object.prototype;e.exports=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}},6916:(e,t,n)=>{var r=n(5569)(Object.keys,Object);e.exports=r},1167:(e,t,n)=>{e=n.nmd(e);var r=n(1957),i=t&&!t.nodeType&&t,a=i&&e&&!e.nodeType&&e,s=a&&a.exports===i&&r.process,o=function(){try{var e=a&&a.require&&a.require("util").types;return e||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=o},2333:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},5569:e=>{e.exports=function(e,t){return function(n){return e(t(n))}}},5639:(e,t,n)=>{var r=n(1957),i="object"==typeof self&&self&&self.Object===Object&&self,a=r||i||Function("return this")();e.exports=a},346:e=>{var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},3729:(e,t,n)=>{var r=n(8674)({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});e.exports=r},5694:(e,t,n)=>{var r=n(9454),i=n(7005),a=Object.prototype,s=a.hasOwnProperty,o=a.propertyIsEnumerable,l=r(function(){return arguments}())?r:function(e){return i(e)&&s.call(e,"callee")&&!o.call(e,"callee")};e.exports=l},1469:e=>{var t=Array.isArray;e.exports=t}
2,8612:(e,t,n)=>{var r=n(3560),i=n(1780);e.exports=function(e){return null!=e&&i(e.length)&&!r(e)}},4144:(e,t,n)=>{e=n.nmd(e);var r=n(5639),i=n(5062),a=t&&!t.nodeType&&t,s=a&&e&&!e.nodeType&&e,o=s&&s.exports===a?r.Buffer:void 0,l=(o?o.isBuffer:void 0)||i;e.exports=l},1609:(e,t,n)=>{var r=n(280),i=n(4160),a=n(5694),s=n(1469),o=n(8612),l=n(4144),c=n(5726),u=n(6719),d=Object.prototype.hasOwnProperty;e.exports=function(e){if(null==e)return!0;if(o(e)&&(s(e)||"string"==typeof e||"function"==typeof e.splice||l(e)||u(e)||a(e)))return!e.length;var t=i(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(c(e))return!r(e).length;for(var n in e)if(d.call(e,n))return!1;return!0}},3560:(e,t,n)=>{var r=n(4239),i=n(3218);e.exports=function(e){if(!i(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1780:e=>{e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},3218:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},7005:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},3448:(e,t,n)=>{var r=n(4239),i=n(7005);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==r(e)}},6719:(e,t,n)=>{var r=n(8749),i=n(7518),a=n(1167),s=a&&a.isTypedArray,o=s?i(s):r;e.exports=o},5062:e=>{e.exports=function(){return!1}},9833:(e,t,n)=>{var r=n(531);e.exports=function(e){return null==e?"":r(e)}},7955:(e,t,n)=>{var r=n(9833),i=n(3729),a=/&(?:amp|lt|gt|quot|#39);/g,s=RegExp(a.source);e.exports=function(e){return(e=r(e))&&s.test(e)?e.replace(a,i):e}},3787:function(e,t,n){var r;(function(){function i(e){"use strict";var t={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 
2with 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(t));var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]=t[r].defaultValue);return n}var a={},s={},o={},l=i(!0),c="vanilla",u={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:i(!0),allOn:function(){"use strict";var e=i(!0),t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=!0);return t}()};function d(e,t){"use strict";var n=t?"Error in "+t+" extension->":"Error in unnamed extension",r={valid:!0,error:""};a.helper.isArray(e)||(e=[e]);for(var i=0;i<e.length;++i){var s=n+" sub-extension "+i+": ",o=e[i];if("object"!=typeof o)return r.valid=!1,r.error=s+"must be an object, but "+typeof o+" given",r;if(!a.helper.isString(o.type))return r.valid=!1,r.error=s+'property "type" must be a string, but '+typeof o.type+" given",r;var l=o.type=o.type.toLowerCase();if("language"===l&&(l=o.type="lang"),"html"===l&&(l=o.type="output"),"lang"!==l&&"output"!==l&&"listener"!==l)return r.valid=!1,r.error=s+"type "+l+' is not recognized. Valid values: "lang/language", "output/html" or "listener"',r;if("listener"===l){if(a.helper.isUndefined(o.listeners))return r.valid=!1,r.error=s+'. Extensions of type "listener" must have a property called "listeners"',r}else if(a.helper.isUndefined(o.filter)&&a.helper.isUndefined(o.regex))return r.valid=!1,r.error=s+l+' extensions must define either a "regex" property or a "filter" method',r;if(o.listeners){if("object"!=typeof o.listeners)return r.valid=!1,r.error=s+'"listeners" property must be an object but '+typeof o.listeners+" given",r;for(var c in o.listeners)if(o.listeners.hasOwnProperty(c)&&"function"!=typeof o.listeners[c])return r.valid=!1,r.error=s+'"listeners" property must be an hash of [event name]: [callback]. listeners.'+c+" must be a function but "+typeof o.listeners[c]+" given",r}if(o.filter){if("function"!=typeof o.filter)return r.valid=!1,r.error=s+'"filter" must be a function, but '+typeof o.filter+" given",r}else if(o.regex){if(a.helper.isString(o.regex)&&(o.regex=new RegExp(o.regex,"g")),!(o.regex instanceof RegExp))return r.valid=!1,r.error=s+'"regex" property must either be a string or a RegExp object, but '+typeof o.regex+" given",r;if(a.helper.isUndefined(o.replace))return r.valid=!1,r.error=s+'"regex" extensions must implement a replace string or function',r}}return r}function h(e,t){"use strict";return"¨E"+t.charCodeAt(0)+"E"}a.helper={},a.extensions={},a.setOption=function(e,t){"use strict";return l[e]=t,this},a.getOption=function(e){"use strict";return l[e]},a.getOptions=function(){"use strict";return l},a.resetOptions=function(){"use strict";l=i(!0)},a.setFlavor=function(e){"use strict";if(!u.hasOwnProperty(e))throw Error(e+" flavor was not found");a.resetOptions();var t=u[e];for(var n in c=e,t)t.hasOwnProperty(n)&&(l[n]=t[n])},a.getFlavor=function(){"use strict";return c},a.getFlavorOptions=function(e){"use strict";if(u.hasOwnProperty(e))return u[e]},a.getDefaultOptions=function(e){"use strict";return i(e)},a.subParser=function(e,t){"use strict";if(a.helper.isString(e)){if(void 0===t){if(s.hasOwnProperty(e))return s[e];throw Error("SubParser named "+e+" not registered!")}s[e]=t}},a.extension=function(e,t){"use strict";if(!a.helper.isString(e))throw Error("Extension 'name' must be a string");if(e=a.helper.stdExtName(e),a.helper.isUndefined(t)){if(!o.hasOwnProperty(e))throw Error("Extension named "+e+" is not registered!");return o[e]}"function"==typeof t&&(t=t()),a.helper.isArray(t)||(t=[t]);var n=d(t,e);if(!n.valid)throw Error(n.error);o[e]=t},a.getAllExtensions=function(){"use strict";return o},a.removeExtension=function(e){"use strict";delete o[e]},a.resetExtensions=function(){"use strict";o={}},a.validateExtension=function(e){"use strict";var t=d(e,null);return!!t.valid||(console.warn(t.error),!1)},a.hasOwnProperty("helper")||(a.helper={}),a.helper.isString=function(e){"use strict";return"string"==typeof e||e instanceof String},a.helper.isFunction=function(e){"use strict";return e&&"[object Function]"==={}.toString.call(e)},a.helper.isArray=function(e){"use strict";return Array.isArray(e)},a.helper.isUndefined=function(e){"use strict";return void 0===e},a.helper.forEach=function(e,t){"use strict";if(a.helper.isUndefined(e))throw new Error("obj param is required");if(a.helper.isUndefined(t))throw new Error("callback param is required");if(!a.helper.isFunction(t))throw new Error("callback param must be a function/closure");if("function"==typeof e.forEach)e.forEach(t);else if(a.helper.isArray(e))for(var n=0;n<e.length;n++)t(e[n],n,e);else{if("object"!=typeof e)throw new Error("obj does not seem to be an array or an iterable object");for(var r in e)e.hasOwnProperty(r)&&t(e[r],r,e)}},a.helper.stdExtName=function(e){"use strict";return e.replace(/[_?*+\/\\.^-]/g,"").replace(/\s/g,"").toLowerCase()},a.helper.escapeCharactersCallback=h,a.helper.escapeCharacters=function(e,t,n){"use strict";var r="(["+t.replace(/([\[\]\\])/g,"\\$1")+"])";n&&(r="\\\\"+r);var i=new RegExp(r,"g");return e=e.replace(i,h)},a.helper.unescapeHTMLEntities=function(e){"use strict";return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")};var p=function(e,t,n,r){"use strict";var i,a,s,o,l,c=r||"",u=c.indexOf("g")>-1,d=new RegExp(t+"|"+n,"g"+c.replace(/g/g,"")),h=new RegExp(t,c.replace(/g/g,"")),p=[];do{for(i=0;s=d.exec(e);)if(h.test(s[0]))i++||(o=(a=d.lastIndex)-s[0].length);else if(i&&!--i){l=s.index+s[0].length;var f={left:{start:o,end:a},match:{start:a,end:s.index},right:{start:s.index,end:l},wholeMatch:{start:o,end:l}};if(p.push(f),!u)return p}}while(i&&(d.lastIndex=a));return p};a.helper.matchRecursiveRegExp=function(e,t,n,r){"use strict";for(var i=p(e,t,n,r),a=[],s=0;s<i.length;++s)a.push([e.slice(i[s].wholeMatch.start,i[s].wholeMatch.end),e.slice(i[s].match.start,i[s].match.end),e.slice(i[s].left.start,i[s].left.end),e.slice(i[s].right.start,i[s].right.end)]);return a},a.helper.replaceRecursiveRegExp=function(e,t,n,r,i){"use strict";if(!a.helper.isFunction(t)){var s=t;t=function(){return s}}var o=p(e,n,r,i),l=e,c=o.length;if(c>0){var u=[];0!==o[0].wholeMatch.start&&u.push(e.slice(0,o[0].wholeMatch.start));for(var d=0;d<c;++d)u.push(t(e.slice(o[d].wholeMatch.start,o[d].wholeMatch.end),e.slice(o[d].match.start,o[d].match.end),e.slice(o[d].left.start,o[d].left.end),e.slice(o[d].right.start,o[d].right.end))),d<c-1&&u.push(e.slice(o[d].wholeMatch.end,o[d+1].wholeMatch.start));o[c-1].wholeMatch.end<e.length&&u.push(e.slice(o[c-1].wholeMatch.end)),l=u.join("")}return l},a.helper.regexIndexOf=function(e,t,n){"use strict";
2if(!a.helper.isString(e))throw"InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string";if(t instanceof RegExp==!1)throw"InvalidArgumentError: second parameter of showdown.helper.regexIndexOf function must be an instance of RegExp";var r=e.substring(n||0).search(t);return r>=0?r+(n||0):r},a.helper.splitAtIndex=function(e,t){"use strict";if(!a.helper.isString(e))throw"InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string";return[e.substring(0,t),e.substring(t)]},a.helper.encodeEmailAddress=function(e){"use strict";var t=[function(e){return"&#"+e.charCodeAt(0)+";"},function(e){return"&#x"+e.charCodeAt(0).toString(16)+";"},function(e){return e}];return e=e.replace(/./g,(function(e){if("@"===e)e=t[Math.floor(2*Math.random())](e);else{var n=Math.random();e=n>.9?t[2](e):n>.45?t[1](e):t[0](e)}return e}))},a.helper.padEnd=function(e,t,n){"use strict";return t>>=0,n=String(n||" "),e.length>t?String(e):((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),String(e)+n.slice(0,t))},"undefined"==typeof console&&(console={warn:function(e){"use strict";alert(e)},log:function(e){"use strict";alert(e)},error:function(e){"use strict";throw e}}),a.helper.regexes={asteriskDashAndColon:/([*_:~])/g},a
vendor: 23,477 bytes, line 2
2.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>"},
2a.Converter=function(e){"use strict";var t={},n=[],r=[],i={},s=c,h={parsed:{},raw:"",format:""};function p(e,t){if(t=t||null,a.helper.isString(e)){if(t=e=a.helper.stdExtName(e),a.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,t){"function"==typeof e&&(e=e(new a.Converter));a.helper.isArray(e)||(e=[e]);var i=d(e,t);if(!i.valid)throw Error(i.error);for(var s=0;s<e.length;++s)switch(e[s].type){case"lang":n.push(e[s]);break;case"output":r.push(e[s]);break;default:throw Error("Extension loader error: Type unrecognized!!!")}}(a.extensions[e],e);if(a.helper.isUndefined(o[e]))throw Error('Extension "'+e+'" could not be loaded. It was either not found or is not a valid extension.');e=o[e]}"function"==typeof e&&(e=e()),a.helper.isArray(e)||(e=[e]);var i=d(e,t);if(!i.valid)throw Error(i.error);for(var s=0;s<e.length;++s){switch(e[s].type){case"lang":n.push(e[s]);break;case"output":r.push(e[s])}if(e[s].hasOwnProperty("listeners"))for(var l in e[s].listeners)e[s].listeners.hasOwnProperty(l)&&f(l,e[s].listeners[l])}}function f(e,t){if(!a.helper.isString(e))throw Error("Invalid argument in converter.listen() method: name must be a string, but "+typeof e+" given");if("function"!=typeof t)throw Error("Invalid argument in converter.listen() method: callback must be a function, but "+typeof t+" given");i.hasOwnProperty(e)||(i[e]=[]),i[e].push(t)}!function(){for(var n in e=e||{},l)l.hasOwnProperty(n)&&(t[n]=l[n]);if("object"!=typeof e)throw Error("Converter expects the passed parameter to be an object, but "+typeof e+" was passed instead.");for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.extensions&&a.helper.forEach(t.extensions,p)}(),this._dispatch=function(e,t,n,r){if(i.hasOwnProperty(e))for(var a=0;a<i[e].length;++a){var s=i[e][a](e,t,this,n,r);s&&void 0!==s&&(t=s)}return t},this.listen=function(e,t){return f(e,t),this},this.makeHtml=function(e){if(!e)return e;var i={gHtmlBlocks:[],gHtmlMdBlocks:[],gHtmlSpans:[],gUrls:{},gTitles:{},gDimensions:{},gListLevel:0,hashLinkCounts:{},langExtensions:n,outputModifiers:r,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;"),t.smartIndentationFix&&(e=function(e){var t=e.match(/^\s*/)[0].length,n=new RegExp("^\\s{0,"+t+"}","gm");return e.replace(n,"")}(e)),e="\n\n"+e+"\n\n",e=(e=a.subParser("detab")(e,t,i)).replace(/^[ \t]+$/gm,""),a.helper.forEach(n,(function(n){e=a.subParser("runExtension")(n,e,t,i)})),e=a.subParser("metadata")(e,t,i),e=a.subParser("hashPreCodeTags")(e,t,i),e=a.subParser("githubCodeBlocks")(e,t,i),e=a.subParser("hashHTMLBlocks")(e,t,i),e=a.subParser("hashCodeTags")(e,t,i),e=a.subParser("stripLinkDefinitions")(e,t,i),e=a.subParser("blockGamut")(e,t,i),e=a.subParser("unhashHTMLSpans")(e,t,i),e=(e=(e=a.subParser("unescapeSpecialChars")(e,t,i)).replace(/¨D/g,"$$")).replace(/¨T/g,"¨"),e=a.subParser("completeHTMLDocument")(e,t,i),a.helper.forEach(r,(function(n){e=a.subParser("runExtension")(n,e,t,i)})),h=i.metadata,e},this.makeMarkdown=this.makeMd=function(e,t){if(e=(e=(e=e.replace(/\r\n/g,"\n")).replace(/\r/g,"\n")).replace(/>[ \t]+</,">¨NBSP;<"),!t){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");t=window.document}var n=t.createElement("div");n.innerHTML=e;var r={preList:function(e){for(var t=e.querySelectorAll("pre"),n=[],r=0;r<t.length;++r)if(1===t[r].childElementCount&&"code"===t[r].firstChild.tagName.toLowerCase()){var i=t[r].firstChild.innerHTML.trim(),s=t[r].firstChild.getAttribute("data-language")||"";if(""===s)for(var o=t[r].firstChild.className.split(" "),l=0;l<o.length;++l){var c=o[l].match(/^language-(.+)$/);if(null!==c){s=c[1];break}}i=a.helper.unescapeHTMLEntities(i),n.push(i),t[r].outerHTML='<precode language="'+s+'" precodenum="'+r.toString()+'"></precode>'}else n.push(t[r].innerHTML),t[r].innerHTML="",t[r].setAttribute("prenum",r.toString());return n}(n)};!function e(t){for(var n=0;n<t.childNodes.length;++n){var r=t.childNodes[n];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")):(t.removeChild(r),--n):1===r.nodeType&&e(r)}}(n);for(var i=n.childNodes,s="",o=0;o<i.length;o++)s+=a.subParser("makeMarkdown.node")(i[o],r);return s},this.setOption=function(e,n){t[e]=n},this.getOption=function(e){return t[e]},this.getOptions=function(){return t},this.addExtension=function(e,t){p(e,t=t||null)},this.useExtension=function(e){p(e)},this.setFlavor=function(e){if(!u.hasOwnProperty(e))throw Error(e+" flavor was not found");var n=u[e];for(var r in s=e,n)n.hasOwnProperty(r)&&(t[r]=n[r])},this.getFlavor=function(){return s},this.removeExtension=function(e){a.helper.isArray(e)||(e=[e]);for(var t=0;t<e.length;++t){for(var i=e[t],s=0;s<n.length;++s)n[s]===i&&n.splice(s,1);for(var o=0;o<r.length;++o)r[o]===i&&r.splice(o,1)}},this.getAllExtensions=function(){return{language:n,output:r}},this.getMetadata=function(e){return e?h.raw:h.parsed},this.getMetadataFormat=function(){return h.format},this._setMetadataPair=function(e,t){h.parsed[e]=t},this._setMetadataFormat=function(e){h.format=e},this._setMetadataRaw=function(e){h.raw=e}},a.subParser("anchors",(function(e,t,n){"use strict";var r=function(e,r,i,s,o,l,c){if(a.helper.isUndefined(c)&&(c=""),i=i.toLowerCase(),e.search(/\(<?\s*>? ?(['"].*['"])?\)$/m)>-1)s="";
2else if(!s){if(i||(i=r.toLowerCase().replace(/ ?\n/g," ")),s="#"+i,a.helper.isUndefined(n.gUrls[i]))return e;s=n.gUrls[i],a.helper.isUndefined(n.gTitles[i])||(c=n.gTitles[i])}var u='<a href="'+(s=s.replace(a.helper.regexes.asteriskDashAndColon,a.helper.escapeCharactersCallback))+'"';return""!==c&&null!==c&&(u+=' title="'+(c=(c=c.replace(/"/g,"&quot;")).replace(a.helper.regexes.asteriskDashAndColon,a.helper.escapeCharactersCallback))+'"'),t.openLinksInNewWindow&&!/^#/.test(s)&&(u+=' rel="noopener noreferrer" target="¨E95Eblank"'),u+=">"+r+"</a>"};return e=(e=(e=(e=(e=n.converter._dispatch("anchors.before",e,t,n)).replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g,r)).replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,r)).replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,r)).replace(/\[([^\[\]]+)]()()()()()/g,r),t.ghMentions&&(e=e.replace(/(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d.-]+?[a-z\d]+)*))/gim,(function(e,n,r,i,s){if("\\"===r)return n+i;if(!a.helper.isString(t.ghMentionsLink))throw new Error("ghMentionsLink option must be a string");var o=t.ghMentionsLink.replace(/\{u}/g,s),l="";return t.openLinksInNewWindow&&(l=' rel="noopener noreferrer" target="¨E95Eblank"'),n+'<a href="'+o+'"'+l+">"+i+"</a>"}))),e=n.converter._dispatch("anchors.after",e,t,n)}));var f=/([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'">\s]+?)()(\1)?(?=\s|$)(?!["<>])/gi,m=/([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?,()\[\]])?(\1)?(?=\s|$)(?!["<>])/gi,g=/()<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)()>()/gi,v=/(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gim,y=/<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,b=function(e){"use strict";return function(t,n,r,i,s,o,l){var c=r=r.replace(a.helper.regexes.asteriskDashAndColon,a.helper.escapeCharactersCallback),u="",d="",h=n||"",p=l||"";return/^www\./i.test(r)&&(r=r.replace(/^www\./i,"http://www.")),e.excludeTrailingPunctuationFromURLs&&o&&(u=o),e.openLinksInNewWindow&&(d=' rel="noopener noreferrer" target="¨E95Eblank"'),h+'<a href="'+r+'"'+d+">"+c+"</a>"+u+p}},_=function(e,t){"use strict";return function(n,r,i){var s="mailto:";return r=r||"",i=a.subParser("unescapeSpecialChars")(i,e,t),e.encodeEmails?(s=a.helper.encodeEmailAddress(s+i),i=a.helper.encodeEmailAddress(i)):s+=i,r+'<a href="'+s+'">'+i+"</a>"}};a.subParser("autoLinks",(function(e,t,n){"use strict";return e=(e=(e=n.converter._dispatch("autoLinks.before",e,t,n)).replace(g,b(t))).replace(y,_(t,n)),e=n.converter._dispatch("autoLinks.after",e,t,n)})),a.subParser("simplifiedAutoLinks",(function(e,t,n){"use strict";return t.simplifiedAutoLink?(e=n.converter._dispatch("simplifiedAutoLinks.before",e,t,n),e=(e=t.excludeTrailingPunctuationFromURLs?e.replace(m,b(t)):e.replace(f,b(t))).replace(v,_(t,n)),e=n.converter._dispatch("simplifiedAutoLinks.after",e,t,n)):e})),a.subParser("blockGamut",(function(e,t,n){"use strict";return e=n.converter._dispatch("blockGamut.before",e,t,n),e=a.subParser("blockQuotes")(e,t,n),e=a.subParser("headers")(e,t,n),e=a.subParser("horizontalRule")(e,t,n),e=a.subParser("lists")(e,t,n),e=a.subParser("codeBlocks")(e,t,n),e=a.subParser("tables")(e,t,n),e=a.subParser("hashHTMLBlocks")(e,t,n),e=a.subParser("paragraphs")(e,t,n),e=n.converter._dispatch("blockGamut.after",e,t,n)})),a.subParser("blockQuotes",(function(e,t,n){"use strict";e=n.converter._dispatch("blockQuotes.before",e,t,n),e+="\n\n";var r=/(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm;return t.splitAdjacentBlockquotes&&(r=/^ {0,3}>[\s\S]*?(?:\n\n)/gm),e=e.replace(r,(function(e){return e=(e=(e=e.replace(/^[ \t]*>[ \t]?/gm,"")).replace(/¨0/g,"")).replace(/^[ \t]+$/gm,""),e=a.subParser("githubCodeBlocks")(e,t,n),e=(e=(e=a.subParser("blockGamut")(e,t,n)).replace(/(^|\n)/g,"$1  ")).replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,(function(e,t){var n=t;return n=(n=n.replace(/^  /gm,"¨0")).replace(/¨0/g,"")})),a.subParser("hashBlock")("<blockquote>\n"+e+"\n</blockquote>",t,n)})),e=n.converter._dispatch("blockQuotes.after",e,t,n)})),a.subParser("codeBlocks",(function(e,t,n){"use strict";e=n.converter._dispatch("codeBlocks.before",e,t,n);return e=(e=(e+="¨0").replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}
2[^ \t\n]|(?=¨0))/g,(function(e,r,i){var s=r,o=i,l="\n";return s=a.subParser("outdent")(s,t,n),s=a.subParser("encodeCode")(s,t,n),s=(s=(s=a.subParser("detab")(s,t,n)).replace(/^\n+/g,"")).replace(/\n+$/g,""),t.omitExtraWLInCodeBlocks&&(l=""),s="<pre><code>"+s+l+"</code></pre>",a.subParser("hashBlock")(s,t,n)+o}))).replace(/¨0/,""),e=n.converter._dispatch("codeBlocks.after",e,t,n)})),a.subParser("codeSpans",(function(e,t,n){"use strict";return void 0===(e=n.converter._dispatch("codeSpans.before",e,t,n))&&(e=""),e=e.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,(function(e,r,i,s){var o=s;return o=(o=o.replace(/^([ \t]*)/g,"")).replace(/[ \t]*$/g,""),o=r+"<code>"+(o=a.subParser("encodeCode")(o,t,n))+"</code>",o=a.subParser("hashHTMLSpans")(o,t,n)})),e=n.converter._dispatch("codeSpans.after",e,t,n)})),a.subParser("completeHTMLDocument",(function(e,t,n){"use strict";if(!t.completeHTMLDocument)return e;e=n.converter._dispatch("completeHTMLDocument.before",e,t,n);var r="html",i="<!DOCTYPE HTML>\n",a="",s='<meta charset="utf-8">\n',o="",l="";for(var c in void 0!==n.metadata.parsed.doctype&&(i="<!DOCTYPE "+n.metadata.parsed.doctype+">\n","html"!==(r=n.metadata.parsed.doctype.toString().toLowerCase())&&"html5"!==r||(s='<meta charset="utf-8">')),n.metadata.parsed)if(n.metadata.parsed.hasOwnProperty(c))switch(c.toLowerCase()){case"doctype":break;case"title":a="<title>"+n.metadata.parsed.title+"</title>\n";break;case"charset":s="html"===r||"html5"===r?'<meta charset="'+n.metadata.parsed.charset+'">\n':'<meta name="charset" content="'+n.metadata.parsed.charset+'">\n';break;case"language":case"lang":o=' lang="'+n.metadata.parsed[c]+'"',l+='<meta name="'+c+'" content="'+n.metadata.parsed[c]+'">\n';break;default:l+='<meta name="'+c+'" content="'+n.metadata.parsed[c]+'">\n'}return e=i+"<html"+o+">\n<head>\n"+a+s+l+"</head>\n<body>\n"+e.trim()+"\n</body>\n</html>",e=n.converter._dispatch("completeHTMLDocument.after",e,t,n)})),a.subParser("detab",(function(e,t,n){"use strict";return e=(e=(e=(e=(e=(e=n.converter._dispatch("detab.before",e,t,n)).replace(/\t(?=\t)/g,"    ")).replace(/\t/g,"¨A¨B")).replace(/¨B(.+?)¨A/g,(function(e,t){for(var n=t,r=4-n.length%4,i=0;i<r;i++)n+=" ";return n}))).replace(/¨A/g,"    ")).replace(/¨B/g,""),e=n.converter._dispatch("detab.after",e,t,n)})),a.subParser("ellipsis",(function(e,t,n){"use strict";return t.ellipsis?(e=(e=n.converter._dispatch("ellipsis.before",e,t,n)).replace(/\.\.\./g,"…"),e=n.converter._dispatch("ellipsis.after",e,t,n)):e})),a.subParser("emoji",(function(e,t,n){"use strict";if(!t.emoji)return e;return e=(e=n.converter._dispatch("emoji.before",e,t,n)).replace(/:([\S]+?):/g,(function(e,t){return a.helper.emojis.hasOwnProperty(t)?a.helper.emojis[t]:e})),e=n.converter._dispatch("emoji.after",e,t,n)})),a.subParser("encodeAmpsAndAngles",(function(e,t,n){"use strict";return e=(e=(e=(e=(e=n.converter._dispatch("encodeAmpsAndAngles.before",e,t,n)).replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;")).replace(/<(?![a-z\/?$!])/gi,"&lt;")).replace(/</g,"&lt;")).replace(/>/g,"&gt;"),e=n.converter._dispatch("encodeAmpsAndAngles.after",e,t,n)})),a.subParser("encodeBackslashEscapes",(function(e,t,n){"use strict";return e=(e=(e=n.converter._dispatch("encodeBackslashEscapes.before",e,t,n)).replace(/\\(\\)/g,a.helper.escapeCharactersCallback)).replace(/\\([`*_{}\[\]()>#+.!~=|:-])/g,a.helper.escapeCharactersCallback),e=n.converter._dispatch("encodeBackslashEscapes.after",e,t,n)})),a.subParser("encodeCode",(function(e,t,n){"use strict";return e=(e=n.converter._dispatch("encodeCode.before",e,t,n)).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/([*_{}\[\]\\=~-])/g,a.helper.escapeCharactersCallback),e=n.converter._dispatch("encodeCode.after",e,t,n)})),a.subParser("escapeSpecialCharsWithinTagAttributes",(function(e,t,n){"use strict";return e=(e=(e=n.converter._dispatch("escapeSpecialCharsWithinTagAttributes.before",e,t,n)).replace(/<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,(function(e){return e.replace(/(.)<\/?code>(?=.)/g,"$1`").replace(/([\\`*_~=|])/g,a.helper.escapeCharactersCallback)}))).replace(/<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi,(function(e){return e.replace(/([\\`*_~=|])/g,a.helper.escapeCharactersCallback)})),e=n.converter._dispatch("escapeSpecialCharsWithinTagAttributes.after",e,t,n)})),a.subParser("githubCodeBlocks",(function(e,t,n){"use strict";return t.ghCodeBlocks?(e=n.converter._dispatch("githubCodeBlocks.before",e,t,n),e=(e=(e+="¨0").replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g,(function(e,r,i,s){var o=t.omitExtraWLInCodeBlocks?"":"\n";return s=a.subParser("encodeCode")(s,t,n),s="<pre><code"+(i?' class="'+i+" language-"+i+'"':"")+">"+(s=(s=(s=a.subParser("detab")(s,t,n)).replace(/^\n+/g,"")).replace(/\n+$/g,""))+o+"</code></pre>",s=a.subParser("hashBlock")(s,t,n),"\n\n¨G"+(n.ghCodeBlocks.push({text:e,codeblock:s})-1)+"G\n\n"}))).replace(/¨0/,""),n.converter._dispatch("githubCodeBlocks.after",e,t,n)):e})),a.subParser("hashBlock",(function(e,t,n){"use strict";return e=(e=n.converter._dispatch("hashBlock.before",e,t,n)).replace(/(^\n+|\n+$)/g,""),e="\n\n¨K"+(n.gHtmlBlocks.push(e)-1)+"K\n\n",e=n.converter._dispatch("hashBlock.after",e,t,n)})),a.subParser("hashCodeTags",(function(e,t,n){"use strict";e=n.converter._dispatch("hashCodeTags.before",e,t,n);return e=a.helper.replaceRecursiveRegExp(e,(function(e,r,i,s){var o=i+a.subParser("encodeCode")(r,t,n)+s;return"¨C"+(n.gHtmlSpans.push(o)-1)+"C"}),"<code\\b[^>]*>","</code>","gim"),e=n.converter._dispatch("hashCodeTags.after",e,t,n)})),a.subParser("hashElement",(function(e,t,n){"use strict";return function(e,t){var r=t;return r=(r=(r=r.replace(/\n\n/g,"\n")).replace(/^\n/,"")).replace(/\n+$/g,""),r="\n\n¨K"+(n.gHtmlBlocks.push(r)-1)+"K\n\n"}})),a.subParser("hashHTMLBlocks",(function(e,t,n){"use strict";e=n.converter._dispatch("hashHTMLBlocks.before",e,t,n);var r=["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"],i=function(e,t,r,i){var a=e;return-1!==r.search(/\bmarkdown\b/)&&(a=r+n.converter.makeHtml(t)+i),"\n\n¨K"+(n.gHtmlBlocks.push(a)-1)+"K\n\n"};t.backslashEscapesHTMLTags&&(e=e.replace(/\\<(\/?[^>]+?)>/g,(function(e,t){return"&lt;"+t+"&gt;"})));for(var s=0;s<r.length;++s)for(var o,l=new RegExp("^ {0,3}(<"+r[s]+"\\b[^>]*>)","im"),c="<"+r[s]+"\\b[^>]*>",u="</"+r[s]+">";-1!==(o=a.helper.regexIndexOf(e,l));){var d=a.helper.splitAtIndex(e,o),h=a.helper.replaceRecursiveRegExp(d[1],i,c,u,"im");if(h===d[1])break;
2e=d[0].concat(h)}return e=e.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,a.subParser("hashElement")(e,t,n)),e=(e=a.helper.replaceRecursiveRegExp(e,(function(e){return"\n\n¨K"+(n.gHtmlBlocks.push(e)-1)+"K\n\n"}),"^ {0,3}\x3c!--","--\x3e","gm")).replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,a.subParser("hashElement")(e,t,n)),e=n.converter._dispatch("hashHTMLBlocks.after",e,t,n)})),a.subParser("hashHTMLSpans",(function(e,t,n){"use strict";function r(e){return"¨C"+(n.gHtmlSpans.push(e)-1)+"C"}return e=(e=(e=(e=(e=n.converter._dispatch("hashHTMLSpans.before",e,t,n)).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)})),e=n.converter._dispatch("hashHTMLSpans.after",e,t,n)})),a.subParser("unhashHTMLSpans",(function(e,t,n){"use strict";e=n.converter._dispatch("unhashHTMLSpans.before",e,t,n);for(var r=0;r<n.gHtmlSpans.length;++r){for(var i=n.gHtmlSpans[r],a=0;/¨C(\d+)C/.test(i);){var s=RegExp.$1;if(i=i.replace("¨C"+s+"C",n.gHtmlSpans[s]),10===a){console.error("maximum nesting of 10 spans reached!!!");break}++a}e=e.replace("¨C"+r+"C",i)}return e=n.converter._dispatch("unhashHTMLSpans.after",e,t,n)})),a.subParser("hashPreCodeTags",(function(e,t,n){"use strict";e=n.converter._dispatch("hashPreCodeTags.before",e,t,n);return e=a.helper.replaceRecursiveRegExp(e,(function(e,r,i,s){var o=i+a.subParser("encodeCode")(r,t,n)+s;return"\n\n¨G"+(n.ghCodeBlocks.push({text:e,codeblock:o})-1)+"G\n\n"}),"^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>","^ {0,3}</code>\\s*</pre>","gim"),e=n.converter._dispatch("hashPreCodeTags.after",e,t,n)})),a.subParser("headers",(function(e,t,n){"use strict";e=n.converter._dispatch("headers.before",e,t,n);var r=isNaN(parseInt(t.headerLevelStart))?1:parseInt(t.headerLevelStart),i=t.smoothLivePreview?/^(.+)[ \t]*\n={2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n=+[ \t]*\n+/gm,s=t.smoothLivePreview?/^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n-+[ \t]*\n+/gm;e=(e=e.replace(i,(function(e,i){var s=a.subParser("spanGamut")(i,t,n),o=t.noHeaderId?"":' id="'+l(i)+'"',c="<h"+r+o+">"+s+"</h"+r+">";return a.subParser("hashBlock")(c,t,n)}))).replace(s,(function(e,i){var s=a.subParser("spanGamut")(i,t,n),o=t.noHeaderId?"":' id="'+l(i)+'"',c=r+1,u="<h"+c+o+">"+s+"</h"+c+">";
2return a.subParser("hashBlock")(u,t,n)}));var o=t.requireSpaceBeforeHeadingText?/^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm:/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm;function l(e){var r,i;if(t.customizedHeaderId){var s=e.match(/\{([^{]+?)}\s*$/);s&&s[1]&&(e=s[1])}return r=e,i=a.helper.isString(t.prefixHeaderId)?t.prefixHeaderId:!0===t.prefixHeaderId?"section-":"",t.rawPrefixHeaderId||(r=i+r),r=t.ghCompatibleHeaderId?r.replace(/ /g,"-").replace(/&amp;/g,"").replace(/¨T/g,"").replace(/¨D/g,"").replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g,"").toLowerCase():t.rawHeaderId?r.replace(/ /g,"-").replace(/&amp;/g,"&").replace(/¨T/g,"¨").replace(/¨D/g,"$").replace(/["']/g,"-").toLowerCase():r.replace(/[^\w]/g,"").toLowerCase(),t.rawPrefixHeaderId&&(r=i+r),n.hashLinkCounts[r]?r=r+"-"+n.hashLinkCounts[r]++:n.hashLinkCounts[r]=1,r}return e=e.replace(o,(function(e,i,s){var o=s;t.customizedHeaderId&&(o=s.replace(/\s?\{([^{]+?)}\s*$/,""));var c=a.subParser("spanGamut")(o,t,n),u=t.noHeaderId?"":' id="'+l(s)+'"',d=r-1+i.length,h="<h"+d+u+">"+c+"</h"+d+">";return a.subParser("hashBlock")(h,t,n)})),e=n.converter._dispatch("headers.after",e,t,n)})),a.subParser("horizontalRule",(function(e,t,n){"use strict";e=n.converter._dispatch("horizontalRule.before",e,t,n);var r=a.subParser("hashBlock")("<hr />",t,n);return e=(e=(e=e.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm,r)).replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm,r)).replace(/^ {0,2}( ?_){3,}[ \t]*$/gm,r),e=n.converter._dispatch("horizontalRule.after",e,t,n)})),a.subParser("images",(function(e,t,n){"use strict";function r(e,t,r,i,s,o,l,c){var u=n.gUrls,d=n.gTitles,h=n.gDimensions;if(r=r.toLowerCase(),c||(c=""),e.search(/\(<?\s*>? ?(['"].*['"])?\)$/m)>-1)i="";else if(""===i||null===i){if(""!==r&&null!==r||(r=t.toLowerCase().replace(/ ?\n/g," ")),i="#"+r,a.helper.isUndefined(u[r]))return e;i=u[r],a.helper.isUndefined(d[r])||(c=d[r]),a.helper.isUndefined(h[r])||(s=h[r].width,o=h[r].height)}t=t.replace(/"/g,"&quot;").replace(a.helper.regexes.asteriskDashAndColon,a.helper.escapeCharactersCallback);var p='<img src="'+(i=i.replace(a.helper.regexes.asteriskDashAndColon,a.helper.escapeCharactersCallback))+'" alt="'+t+'"';return c&&a.helper.isString(c)&&(p+=' title="'+(c=c.replace(/"/g,"&quot;").replace(a.helper.regexes.asteriskDashAndColon,a.helper.escapeCharactersCallback))+'"'),s&&o&&(p+=' width="'+(s="*"===s?"auto":s)+'"',p+=' height="'+(o="*"===o?"auto":o)+'"'),p+=" />"}return e=(e=(e=(e=(e=(e=n.converter._dispatch("images.before",e,t,n)).replace(/!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g,r)).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,t,n,i,a,s,o,l){return r(e,t,n,i=i.replace(/\s/g,""),a,s,o,l)}))).replace(/!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,r)).replace(/!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,r)).replace(/!\[([^\[\]]+)]()()()()()/g,r),e=n.converter._dispatch("images.after",e,t,n)})),a.subParser("italicsAndBold",(function(e,t,n){"use strict";function r(e,t,n){return t+e+n}return e=n.converter._dispatch("italicsAndBold.before",e,t,n),e=t.literalMidWordUnderscores?(e=(e=e.replace(/\b___(\S[\s\S]*?)___\b/g,(function(e,t){return r(t,"<strong><em>","</em></strong>")}))).replace(/\b__(\S[\s\S]*?)__\b/g,(function(e,t){return r(t,"<strong>","</strong>")}))).replace(/\b_(\S[\s\S]*?)_\b/g,(function(e,t){return r(t,"<em>","</em>")})):(e=(e=e.replace(/___(\S[\s\S]*?)___/g,(function(e,t){return/\S$/.test(t)?r(t,"<strong><em>","</em></strong>"):e}))).replace(/__(\S[\s\S]*?)__/g,(function(e,t){return/\S$/.test(t)?r(t,"<strong>","</strong>"):e}))).replace(/_([^\s_][\s\S]*?)_/g,(function(e,t){return/\S$/.test(t)?r(t,"<em>","</em>"):e})),e=t.literalMidWordAsterisks?(e=(e=e.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g,(function(e,t,n){return r(n,t+"<strong><em>","</em></strong>")}))).replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g,(function(e,t,n){return r(n,t+"<strong>","</strong>")}))).replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g,(function(e,t,n){return r(n,t+"<em>","</em>")})):(e=(e=e.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g,(function(e,t){return/\S$/.test(t)?r(t,"<strong><em>","</em></strong>"):e}))).replace(/\*\*(\S[\s\S]*?)\*\*/g,(function(e,t){return/\S$/.test(t)?r(t,"<strong>","</strong>"):e}))).replace(/\*([^\s*][\s\S]*?)\*/g,(function(e,t){return/\S$/.test(t)?r(t,"<em>","</em>"):e})),e=n.converter._dispatch("italicsAndBold.after",e,t,n)})),a.subParser("lists",(function(e,t,n){"use strict";function r(e,r){n.gListLevel++,e=e.replace(/\n{2,}$/,"\n");var i=/(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm,s=/\n[ \t]*\n(?!¨0)/.test(e+="¨0");
2return t.disableForced4SpacesIndentedSublists&&(i=/(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm),e=(e=e.replace(i,(function(e,r,i,o,l,c,u){u=u&&""!==u.trim();var d=a.subParser("outdent")(l,t,n),h="";return c&&t.tasklists&&(h=' class="task-list-item" style="list-style-type: none;"',d=d.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+=">"}))),d=d.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g,(function(e){return"¨A"+e})),r||d.search(/\n{2,}/)>-1?(d=a.subParser("githubCodeBlocks")(d,t,n),d=a.subParser("blockGamut")(d,t,n)):(d=(d=a.subParser("lists")(d,t,n)).replace(/\n$/,""),d=(d=a.subParser("hashHTMLBlocks")(d,t,n)).replace(/\n\n+/g,"\n\n"),d=s?a.subParser("paragraphs")(d,t,n):a.subParser("spanGamut")(d,t,n)),d="<li"+h+">"+(d=d.replace("¨A",""))+"</li>\n"}))).replace(/¨0/g,""),n.gListLevel--,r&&(e=e.replace(/\s+$/,"")),e}function i(e,t){if("ol"===t){var n=e.match(/^ *(\d+)\./);if(n&&"1"!==n[1])return' start="'+n[1]+'"'}return""}function s(e,n,a){var s=t.disableForced4SpacesIndentedSublists?/^ ?\d+\.[ \t]/gm:/^ {0,3}\d+\.[ \t]/gm,o=t.disableForced4SpacesIndentedSublists?/^ ?[*+-][ \t]/gm:/^ {0,3}[*+-][ \t]/gm,l="ul"===n?s:o,c="";if(-1!==e.search(l))!function t(u){var d=u.search(l),h=i(e,n);-1!==d?(c+="\n\n<"+n+h+">\n"+r(u.slice(0,d),!!a)+"</"+n+">\n",l="ul"===(n="ul"===n?"ol":"ul")?s:o,t(u.slice(d))):c+="\n\n<"+n+h+">\n"+r(u,!!a)+"</"+n+">\n"}(e);else{var u=i(e,n);c="\n\n<"+n+u+">\n"+r(e,!!a)+"</"+n+">\n"}return c}return e=n.converter._dispatch("lists.before",e,t,n),e+="¨0",e=(e=n.gListLevel?e.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,(function(e,t,n){return s(t,n.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,t,n,r){return s(n,r.search(/[*+-]/g)>-1?"ul":"ol",!1)}))).replace(/¨0/,""),e=n.converter._dispatch("lists.after",e,t,n)})),a.subParser("metadata",(function(e,t,n){"use strict";if(!t.metadata)return e;function r(e){n.metadata.raw=e,(e=(e=e.replace(/&/g,"&amp;").replace(/"/g,"&quot;")).replace(/\n {4}/g," ")).replace(/^([\S ]+): +([\s\S]+?)$/gm,(function(e,t,r){return n.metadata.parsed[t]=r,""}))}return e=(e=(e=(e=n.converter._dispatch("metadata.before",e,t,n)).replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/,(function(e,t,n){return r(n),"¨M"}))).replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/,(function(e,t,i){return t&&(n.metadata.format=t),r(i),"¨M"}))).replace(/¨M/g,""),e=n.converter._dispatch("metadata.after",e,t,n)})),a.subParser("outdent",(function(e,t,n){"use strict";return e=(e=(e=n.converter._dispatch("outdent.before",e,t,n)).replace(/^(\t|[ ]{1,4})/gm,"¨0")).replace(/¨0/g,""),e=n.converter._dispatch("outdent.after",e,t,n)})),a.subParser("paragraphs",(function(e,t,n){"use strict";for(var r=(e=(e=(e=n.converter._dispatch("paragraphs.before",e,t,n)).replace(/^\n+/g,"")).replace(/\n+$/g,"")).split(/\n{2,}/g),i=[],s=r.length,o=0;o<s;o++){var l=r[o];l.search(/¨(K|G)(\d+)\1/g)>=0?i.push(l):l.search(/\S/)>=0&&(l=(l=a.subParser("spanGamut")(l,t,n)).replace(/^([ \t]*)/g,"<p>"),l+="</p>",i.push(l))}for(s=i.length,o=0;o<s;o++){for(var c="",u=i[o],d=!1;/¨(K|G)(\d+)\1/.test(u);){var h=RegExp.$1,p=RegExp.$2;c=(c="K"===h?n.gHtmlBlocks[p]:d?a.subParser("encodeCode")(n.ghCodeBlocks[p].text,t,n):n.ghCodeBlocks[p].codeblock).replace(/\$/g,"$$$$"),u=u.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/,c),/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(u)&&(d=!0)}i[o]=u}return e=(e=(e=i.join("\n")).replace(/^\n+/g,"")).replace(/\n+$/g,""),n.converter._dispatch("paragraphs.after",e,t,n)})),a.subParser("runExtension",(function(e,t,n,r){"use strict";if(e.filter)t=e.filter(t,r.converter,n);else if(e.regex){var i=e.regex;i instanceof RegExp||(i=new RegExp(i,"g")),t=t.replace(i,e.replace)}return t})),a.subParser("spanGamut",(function(e,t,n){"use strict";return e=n.converter._dispatch("spanGamut.before",e,t,n),e=a.subParser("codeSpans")(e,t,n),e=a.subParser("escapeSpecialCharsWithinTagAttributes")(e,t,n),e=a.subParser("encodeBackslashEscapes")(e,t,n),e=a.subParser("images")(e,t,n),e=a.subParser("anchors")(e,t,n),e=a.subParser("autoLinks")(e,t,n),e=a.subParser("simplifiedAutoLinks")(e,t,n),e=a.subParser("emoji")(e,t,n),e=a.subParser("underline")(e,t,n),e=a.subParser("italicsAndBold")(e,t,n),e=a.subParser("strikethrough")(e,t,n),e=a.subParser("ellipsis")(e,t,n),e=a.subParser("hashHTMLSpans")(e,t,n),e=a.subParser("encodeAmpsAndAngles")(e,t,n),t.simpleLineBreaks?/\n\n¨K/.test(e)||(e=e.replace(/\n+/g,"<br />\n")):e=e.replace(/  +\n/g,"<br />\n"),e=n.converter._dispatch("spanGamut.after",e,t,n)})),a.subParser("strikethrough",(function(e,t,n){"use strict";return t.strikethrough&&(e=(e=n.converter._dispatch("strikethrough.before",e,t,n)).replace(/(?:~){2}([\s\S]+?)(?:~){2}/g,(function(e,r){return function(e){return t.simplifiedAutoLink&&(e=a.subParser("simplifiedAutoLinks")(e,t,n)),"<del>"+e+"</del>"}(r)})),e=n.converter._dispatch("strikethrough.after",e,t,n)),e})),a.subParser("stripLinkDefinitions",(function(e,t,n){"use strict";var r=function(r,i,s,o,l,c,u){return i=i.toLowerCase(),e.toLowerCase().split(i).length-1<2?r:(s.match(/^data:.+?\/.+?;base64,/)?n.gUrls[i]=s.replace(/\s/g,""):n.gUrls[i]=a.subParser("encodeAmpsAndAngles")(s,t,n),c?c+u:(u&&(n.gTitles[i]=u.replace(/"|'/g,"&quot;")),t.parseImgDimensions&&o&&l&&(n.gDimensions[i]={width:o,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,r)).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))
2/gm,r)).replace(/¨0/,"")})),a.subParser("tables",(function(e,t,n){"use strict";if(!t.tables)return e;function r(e,r){return"<td"+r+">"+a.subParser("spanGamut")(e,t,n)+"</td>\n"}function i(e){var i,s=e.split("\n");for(i=0;i<s.length;++i)/^ {0,3}\|/.test(s[i])&&(s[i]=s[i].replace(/^ {0,3}\|/,"")),/\|[ \t]*$/.test(s[i])&&(s[i]=s[i].replace(/\|[ \t]*$/,"")),s[i]=a.subParser("codeSpans")(s[i],t,n);var o,l,c,u,d=s[0].split("|").map((function(e){return e.trim()})),h=s[1].split("|").map((function(e){return e.trim()})),p=[],f=[],m=[],g=[];for(s.shift(),s.shift(),i=0;i<s.length;++i)""!==s[i].trim()&&p.push(s[i].split("|").map((function(e){return e.trim()})));if(d.length<h.length)return e;for(i=0;i<h.length;++i)m.push((o=h[i],/^:[ \t]*--*$/.test(o)?' style="text-align:left;"':/^--*[ \t]*:[ \t]*$/.test(o)?' style="text-align:right;"':/^:[ \t]*--*[ \t]*:$/.test(o)?' style="text-align:center;"':""));for(i=0;i<d.length;++i)a.helper.isUndefined(m[i])&&(m[i]=""),f.push((l=d[i],c=m[i],u=void 0,u="",l=l.trim(),(t.tablesHeaderId||t.tableHeaderId)&&(u=' id="'+l.replace(/ /g,"_").toLowerCase()+'"'),"<th"+u+c+">"+(l=a.subParser("spanGamut")(l,t,n))+"</th>\n"));for(i=0;i<p.length;++i){for(var v=[],y=0;y<f.length;++y)a.helper.isUndefined(p[i][y]),v.push(r(p[i][y],m[y]));g.push(v)}return function(e,t){for(var n="<table>\n<thead>\n<tr>\n",r=e.length,i=0;i<r;++i)n+=e[i];for(n+="</tr>\n</thead>\n<tbody>\n",i=0;i<t.length;++i){n+="<tr>\n";for(var a=0;a<r;++a)n+=t[i][a];n+="</tr>\n"}return n+"</tbody>\n</table>\n"}(f,g)}return e=(e=(e=(e=n.converter._dispatch("tables.before",e,t,n)).replace(/\\(\|)/g,a.helper.escapeCharactersCallback)).replace(/^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm,i)).replace(/^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm,i),e=n.converter._dispatch("tables.after",e,t,n)})),a.subParser("underline",(function(e,t,n){"use strict";return t.underline?(e=n.converter._dispatch("underline.before",e,t,n),e=(e=t.literalMidWordUnderscores?(e=e.replace(/\b___(\S[\s\S]*?)___\b/g,(function(e,t){return"<u>"+t+"</u>"}))).replace(/\b__(\S[\s\S]*?)__\b/g,(function(e,t){return"<u>"+t+"</u>"})):(e=e.replace(/___(\S[\s\S]*?)___/g,(function(e,t){return/\S$/.test(t)?"<u>"+t+"</u>":e}))).replace(/__(\S[\s\S]*?)__/g,(function(e,t){return/\S$/.test(t)?"<u>"+t+"</u>":e}))).replace(/(_)/g,a.helper.escapeCharactersCallback),e=n.converter._dispatch("underline.after",e,t,n)):e})),a.subParser("unescapeSpecialChars",(function(e,t,n){"use strict";return e=(e=n.converter._dispatch("unescapeSpecialChars.before",e,t,n)).replace(/¨E(\d+)E/g,(function(e,t){var n=parseInt(t);return String.fromCharCode(n)})),e=n.converter._dispatch("unescapeSpecialChars.after",e,t,n)})),a.subParser("makeMarkdown.blockquote",(function(e,t){"use strict";var n="";if(e.hasChildNodes())for(var r=e.childNodes,i=r.length,s=0;s<i;++s){var o=a.subParser("makeMarkdown.node")(r[s],t);""!==o&&(n+=o)}return n="> "+(n=n.trim()).split("\n").join("\n> ")})),a.subParser("makeMarkdown.codeBlock",(function(e,t){"use strict";var n=e.getAttribute("language"),r=e.getAttribute("precodenum");return"```"+n+"\n"+t.preList[r]+"\n```"})),a.subParser("makeMarkdown.codeSpan",(function(e){"use strict";return"`"+e.innerHTML+"`"})),a.subParser("makeMarkdown.emphasis",(function(e,t){"use strict";var n="";if(e.hasChildNodes()){n+="*";for(var r=e.childNodes,i=r.length,s=0;s<i;++s)n+=a.subParser("makeMarkdown.node")(r[s],t);n+="*"}return n})),a.subParser("makeMarkdown.header",(function(e,t,n){"use strict";var r=new Array(n+1).join("#"),i="";if(e.hasChildNodes()){i=r+" ";for(var s=e.childNodes,o=s.length,l=0;l<o;++l)i+=a.subParser("makeMarkdown.node")(s[l],t)}return i})),a.subParser("makeMarkdown.hr",(function(){"use strict";return"---"})),a.subParser("makeMarkdown.image",(function(e){"use strict";var t="";return e.hasAttribute("src")&&(t+="!["+e.getAttribute("alt")+"](",t+="<"+e.getAttribute("src")+">",e.hasAttribute("width")&&e.hasAttribute("height")&&(t+=" ="+e.getAttribute("width")+"x"+e.getAttribute("height")),e.hasAttribute("title")&&(t+=' "'+e.getAttribute("title")+'"'),t+=")"),t})),a.subParser("makeMarkdown.links",(function(e,t){"use strict";var n="";if(e.hasChildNodes()&&e.hasAttribute("href")){var r=e.childNodes,i=r.length;n="[";for(var s=0;s<i;++s)n+=a.subParser("makeMarkdown.node")(r[s],t);n+="](",n+="<"+e.getAttribute("href")+">",e.hasAttribute("title")&&(n+=' "'+e.getAttribute("title")+'"'),n+=")"}return n})),a.subParser("makeMarkdown.list",(function(e,t,n){"use strict";var r="";if(!e.hasChildNodes())return"";for(var i=e.childNodes,s=i.length,o=e.getAttribute("start")||1,l=0;l<s;++l)if(void 0!==i[l].tagName&&"li"===i[l].tagName.toLowerCase()){r+=("ol"===n?o.toString()+". ":"- ")+a.subParser("makeMarkdown.listItem")(i[l],t),++o}return(r+="\n\x3c!-- --\x3e\n").trim()})),a.subParser("makeMarkdown.listItem",(function(e,t){"use strict";for(var n="",r=e.childNodes,i=r.length,s=0;s<i;++s)n+=a.subParser("makeMarkdown.node")(r[s],t);return/\n$/.test(n)?n=n.split("\n").join("\n    ").replace(/^ {4}$/gm,"").replace(/\n\n+/g,"\n\n"):n+="\n",n})),a.subParser("makeMarkdown.node",(function(e,t,n){"use strict";n=n||!1;var r="";if(3===e.nodeType)return a.subParser("makeMarkdown.txt")(e,t);if(8===e.nodeType)return"\x3c!--"+e.data+"--\x3e\n\n";if(1!==e.nodeType)return"";switch(e.tagName.toLowerCase()){case"h1":n||(r=a.subParser("makeMarkdown.header")(e,t,1)+"\n\n");break;case"h2":n||(r=a.subParser("makeMarkdown.header")(e,t,2)+"\n\n");break;case"h3":n||(r=a.subParser("makeMarkdown.header")(e,t,3)+"\n\n");break;case"h4":n||(r=a.subParser("makeMarkdown.header")(e,t,4)+"\n\n");break;case"h5":n||(r=a.subParser("makeMarkdown.header")(e,t,5)+"\n\n");break;case"h6":n||(r=a.subParser("makeMarkdown.header")(e,t,6)+"\n\n");break;case"p":n||(r=a.subParser("makeMarkdown.paragraph")(e,t)+"\n\n");break;case"blockquote":n||(r=a.subParser("makeMarkdown.blockquote")(e,t)+"\n\n");break;case"hr":n||(r=a.subParser("makeMarkdown.hr")(e,t)+"\n\n");break;case"ol":n||(r=a.subParser("makeMarkdown.list")(e,t,"ol")+"\n\n");break;case"ul":n||(r=a.subParser("makeMarkdown.list")(e,t,"ul")+"\n\n");break;case"precode":n||(r=a.subParser("makeMarkdown.codeBlock")(e,t)+"\n\n");break;case"pre":n||(r=a.subParser("makeMarkdown.pre")(e,t)+"\n\n");break;case"table":n||(r=a.subParser("makeMarkdown.table")(e,t)+"\n\n");break;case"code":r=a.subParser("makeMarkdown.codeSpan")(e,t);break;case"em":case"i":r=a.subParser("makeMarkdown.emphasis")(e,t);break;case"strong":case"b":r=a.subParser("makeMarkdown.strong")(e,t);break;case"del":r=a.subParser("makeMarkdown.strikethrough")(e,t);break;case"a":r=a.subParser("makeMarkdown.links")(e,t);break;case"img":r=a.subParser("makeMarkdown.image")(e,t);break;default:r=e.outerHTML+"\n\n"}return r})),a.subParser("makeMarkdown.paragraph",(function(e,t){"use strict";var n="";if(e.hasChildNodes())for(var r=e.childNodes,i=r.length,s=0;s<i;++s)n+=a.subParser("makeMarkdown.node")(r[s],t);return n=n.trim()})),a.subParser("makeMarkdown.pre",(function(e,t){"use strict";var n=e.getAttribute("prenum");return"<pre>"+t.preList[n]+"</pre>"})),a.subParser("makeMarkdown.strikethrough",(function(e,t){"use strict";var n="";if(e.hasChildNodes()){n+="~~";for(var r=e.childNodes,i=r.length,s=0;s<i;++s)n+=a.subParser("makeMarkdown.node")(r[s],t);n+="~~"}return n})),a.subParser("makeMarkdown.strong",(function(e,t){"use strict";var n="";if(e.hasChildNodes()){n+="**";for(var r=e.childNodes,i=r.length,s=0;s<i;++s)n+=a.subParser("makeMarkdown.node")(r[s],t);n+="**"}return n})),a.subParser("makeMarkdown.table",(function(e,t){"use strict";var n,r,i="",s=[[],[]],o=e.querySelectorAll("thead>tr>th"),l=e.querySelectorAll("tbody>tr");for(n=0;n<o.length;++n){var c=a.subParser("makeMarkdown.tableCell")(o[n],t),u="---";if(o[n].hasAttribute("style"))switch(o[n].getAttribute("style").toLowerCase().replace(/\s/g,"")){case"text-align:left;":u=":---";break;case"text-align:right;":u="---:";break;case"text-align:center;":u=":---:"}s[0][n]=c.trim(),s[1][n]=u}for(n=0;n<l.length;++n){var d=s.push([])-1,h=l[n].getElementsByTagName("td");for(r=0;r<o.length;++r){var p=" ";void 0!==h[r]&&(p=a.subParser("makeMarkdown.tableCell")(h[r],t)),s[d].push(p)}}var f=3;for(n=0;n<s.length;++n)for(r=0;r<s[n].length;++r){var m=s[n][r].length;m>f&&(f=m)}for(n=0;n<s.length;++n){for(r=0;r<s[n].length;++r)1===n?":"===s[n][r].slice(-1)?s[n][r]=a.helper.padEnd(s[n][r].slice(-1),f-1,"-")+":":s[n][r]=a.helper.padEnd(s[n][r],f,"-"):s[n][r]=a.helper.padEnd(s[n][r],f);i+="| "+s[n].join(" | ")+" |\n"}return i.trim()})),a.subParser("makeMarkdown.tableCell",(function(e,t){"use strict";var n="";if(!e.hasChildNodes())return"";for(var r=e.childNodes,i=r.length,s=0;s<i;++s)n+=a.subParser("makeMarkdown.node")(r[s],t,!0);return n.trim()})),a.subParser("makeMarkdown.txt",(function(e){"use strict";var t=e.nodeValue;return t=(t=t.replace(/ +/g," ")).replace(/¨NBSP;/g," "),t=(t=(t=(t=(t=(t=(t=(t=(t=a.helper.unescapeHTMLEntities(t)).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]:")}));void 0===(r=function(){"use strict";return a}.call(t,n,t,e))||(e.exports=r)}).call(this)}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.loaded=!0,n.exports}__webpack_require__.n=e=>
vendor: 4,142 bytes, line 2
2{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__={};(()=>{"use strict";var e={};__webpack_require__.r(e),__webpack_require__.d(e,{DeepChat:()=>cs});var t={};__webpack_require__.r(t),__webpack_require__.d(t,{DateTime:()=>Cu,Duration:()=>Rc,FixedOffsetZone:()=>po,IANAZone:()=>Js,Info:()=>jc,Interval:()=>Nc,InvalidZone:()=>fo,Settings:()=>Mo,SystemZone:()=>Gs,VERSION:()=>Au,Zone:()=>Hs});var n=__webpack_require__(6592);const r=__webpack_require__.n(n)().store("emailStore",{state:{userIsInEu:!1,isSubscribed:!1},subscribeUser:function(){0===document.cookie.split(";").filter((function(e){return e.includes("PCM_isSubscribed=true")})).length&&(document.cookie="PCM_isSubscribed=true;path=/;samesite=strict;max-age=31536000;",this.state.isSubscribed=!0)},checkIsUserEu:function(){var e=this;if(window.location.href.indexOf("?iseu=1")>-1)return this.state.userIsInEu=!0;fetch("https://www.pcmag.com/user/eu-check").then((function(e){return e.json()})).then((function(t){t&&t.hasOwnProperty("eu")&&(e.state.userIsInEu=t.eu)})).catch((function(e){console.log(e)}))},checkIsSubscribed:function(){document.cookie.split(";").filter((function(e){return e.trim().startsWith("PCM_isSubscribed=")})).length&&(this.state.isSubscribed=!0)}});function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function a(){a=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",l=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function d(e,t,n,i){var a=t&&t.prototype instanceof f?t:f,s=Object.create(a.prototype),o=new T(i||[]);return r(s,"_invoke",{value:S(e,n,o)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=d;var p={};function f(){}function m(){}function g(){}var v={};u(v,o,(function(){return this}));var y=Object.getPrototypeOf,b=y&&y(y(A([])));b&&b!==t&&n.call(b,o)&&(v=b);var _=g.prototype=f.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function a(r,s,o,l){var c=h(e[r],e,s);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==i(d)&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){a("next",e,o,l)}),(function(e){a("throw",e,o,l)})):t.resolve(d).then((function(e){u.value=e,o(u)}),(function(e){return a("throw",e,o,l)}))}l(c.arg)}var s;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return s=s?s.then(r,r):r()}})}function S(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return M()}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var o=x(s,n);if(o){if(o===p)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";
vendor: 4,196 bytes, line 2
2var l=h(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===p)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function x(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var r=h(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,p;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function A(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:M}}function M(){return{value:void 0,done:!0}}return m.prototype=g,r(_,"constructor",{value:g,configurable:!0}),r(g,"constructor",{value:m,configurable:!0}),m.displayName=u(g,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,u(e,c,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},w(k.prototype),u(k.prototype,l,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var s=new k(d(t,n,r,i),a);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},w(_),u(_,c,"Generator"),u(_,o,(function(){return this})),u(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=A,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return s.type="throw",s.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(o&&l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];
2if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),C(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;C(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},e}function s(e,t,n,r,i,a,s){try{var o=e[a](s),l=o.value}catch(e){return void n(e)}o.done?t(l):Promise.resolve(l).then(r,i)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var l=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.sticky=-1===window.location.href.indexOf("disableSticky"),this.loadPlayers()}var t,n,r,i;return t=e,n=[{key:"loadPlayers",value:function(){var e,t=this,n=(null!==(e=window.videoEmbeds)&&void 0!==e?e:[]).filter((function(e){return!e.playerInited&&(e.data.excoPlayListId||e.data.relatedPlaylistVideos||e.data.url&&!e.data.url.includes("youtube.com")&&!e.data.url.includes("youtu.be")&&!e.data.url.includes("facebook")&&!e.data.url.includes("fb.watch"))}));if(n.length>0){var r=function(){n.forEach((function(e){return t.initializeVideoPlayer(e)}))};n.forEach((function(e){t.loadVideoPlayerScript(r,e.videoPlayerType),console.time("videoPlayer-created-"+e.elemId)}))}}},{key:"getPlayerIdByVideoPlayerType",value:function(e){return"hero"===e?"99e02fef-552a-4b38-a7f1-802ad2b112d4":"d8d0aab1-1279-491a-949a-f47bb57ce270"}},{key:"loadVideoPlayerScript",value:function(e,t){var n=this.getPlayerIdByVideoPlayerType(t),r=this;r.loaddedPlayers&&"loaded"===r.loaddedPlayers[n]?setTimeout(e,0):(r.loaddedPlayers=r.loaddedPlayers||{},r.loaddedPlayers[n]?r.loaddedPlayers[n].push(e):(r.loaddedPlayers[n]=[],r.loaddedPlayers[n].push(e),function(e,t,i){var a,s=e.getElementsByTagName(t)[0];(a=e.createElement(t)).className="exco-player",a.src="//ziff-player.ex.co/player/"+n,a.setAttribute("programmatic","true"),a.setAttribute("multiple","true"),a.async=!0,a.onload=function(){r.loaddedPlayers[n].forEach((function(e){return setTimeout(e,0)})),r.loaddedPlayers[n]="loaded"},s.parentNode.insertBefore(a,s)}(document,"script")))}},{key:"initializeVideoPlayer",value:function(e){var t=this;e.playerInited||(e.playerInited=!0,window.PogoExco=window.PogoExco||{cmd:[]},window.PogoExco.cmd.push((function(){if(!e._started){e._started=!0;var n=t.setupConfig(e,!0);t.startVideoPlayer(e,n)}})),setTimeout((function(){if(!e._started){console.log("Pogo did NOT start video within 10000ms, starting manually..."),e._started=!0;var n=t.setupConfig(e,!1);t.startVideoPlayer(e,n)}}),1e4))}},{key:"startVideoPlayer",value:(i=function(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){s(a,r,i,o,l,"next",e)}function l(e){s(a,r,i,o,l,"throw",e)}o(void 0)}))}}(a().mark((function e(t,n){var r,i,s;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=ExCoPlayer.connect(this.getPlayerIdByVideoPlayerType(t.videoPlayerType)),e.next=3,r.create({selector:"#"+t.elemId});case 3:for(i=e.sent,(s=document.getElementById(t.elemId)).getElementsByTagName("img").length>0&&(s.style.height=s.offsetHeight+"px",s.style.width=s.offsetWidth+"px"),i.on("player-load",(function(){s.removeAttribute("style")}));s.firstChild;)s.removeChild(s.lastChild);this.setupTrackingEvents(i,t),this.setupLogicEvents(i,t),i.type="EX.CO",i.config=n,console.log("Right before video player init"),window._cbv=window._cbv||[],window._cbv.push(i),i.init(n);case 16:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"setupConfig",value:function(e,t){var n,r,i={playbackMode:"play-in-view",autoPlay:!1,content:e.data.excoPlayListId?{playlistId:e.data.excoPlayListId,loop:!1}:{playFirst:[{title:e.data.title,src:e.data.url,poster:e.data.thumbnail_url,duration:1e3*e.data.duration}],replacePlaylist:!0,loop:!1},sticky:{desktop:{enabled:null!==(n=this.sticky)&&void 0!==n&&n},mobile:{enabled:null!==(r=this.sticky)&&void 0!==r&&r}}};return e.variation&&(i.variation=e.variation),this.sticky=!1,t&&window.Pogo.getExcoVideoConfig&&(i=window.Pogo.getExcoVideoConfig(i)),i}},{key:"setupLogicEvents",value:function(e,t){e.on("ad-skipped",(function(t){e.unmute()}
2))}},{key:"setupTrackingEvents",value:function(e,t){var n=this;if(t.dimensionData={video_id:t.data.slug,video_play_type:!1===t.data.autostart?"Manual":"AutoPlay",video_player_type:t.videoPlayerType?t.videoPlayerType:"in-content",video_url:document.location.href,video_duration:t.data.duration,video_title:t.data.title,object_uuid:window.object_uuid},t.videoPlayerType&&"related"==t.videoPlayerType){var r=document.getElementsByTagName("main")[0].getBoundingClientRect().top+window.pageYOffset,i=document.getElementById("related-video").getBoundingClientRect().top+window.pageYOffset-r,a=document.getElementsByTagName("main")[0].clientHeight,s=Math.ceil(i/(a/4));t.dimensionData.position=s}var o=function(e){t.dimensionData.video_play_type=["manual","interaction"].includes(e.toLowerCase())?"Manual":"AutoPlay"},l=[10,30];e.on("content-time",(function(e){if(l.length>0){var r=l[0];if(e.currentTime>=r&&e.currentTime<=r+5){var i=Object.assign({},{video_percent:r+" Seconds"},t.dimensionData);n.sendGaEvent("video_progress",i),l.splice(l.indexOf(r),1)}}})),e.on("ad-impression",(function(){return n.sendGaEvent("video_ad_start",t.dimensionData)})),e.on("ad-completed",(function(){return n.sendGaEvent("video_ad_complete",t.dimensionData)})),e.on("ad-skipped ",(function(){return n.sendGaEvent("video_ad_skip",t.dimensionData)})),e.on("content-start",(function(){l=[10,30],window.location.href.indexOf("videoDebug")>-1&&console.log("videoPlayer content-start");var r=new Promise((function(e){return e()}));if(t.data.excoPlayListId&&t.data.excoPlayListVideos){var i=e.getPlaylistItem();t.dimensionData.video_duration=i.duration,t.dimensionData.video_title=i.title,t.data.excoPlayListVideos[i.id]?t.dimensionData.video_id=t.data.excoPlayListVideos[i.id]:r=fetch("/api/resolve-video-asset-slug/".concat(i.id)).then((function(e){return e.json()})).then((function(e){t.dimensionData.video_id=e.slug})).catch((function(e){return console.error("Error:",e)}))}r.then((function(){n.sendGaEvent("video_start",t.dimensionData)}))})),e.on("content-end",(function(){n.sendGaEvent("video_complete",t.dimensionData)})),e.on("player-paused",(function(e){o(e.reason),n.sendGaEvent("video_pause",t.dimensionData)})),e.on("player-playing",(function(e){o(e.reason)}))}},{key:"sendGaEvent",value:function(e,t){window.gtag&&gtag("event",e,t)}}],n&&o(t.prototype,n),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function c(e){var t=this;this._startViewTime=new Date,this._player=e,this._playerReady=!1,this._currentContentType=this.ContentType.AD,this._currentVideoState=this.VideoState.UNPLAYED,this._currentPlayTime=0,this._player.on("player-ready",(function(){t._playerReady=!0})),this._player.on("slot-start",(function(){t._starFirstAdTime||(t._starFirstAdTime=new Date)})),this._player.on("content-start",(function(){t._startPlayTime=new Date,t._currentContentType=t.ContentType.CONTENT,t._currentVideoState=t.VideoState.PLAYED})),this._player.on("player-paused",(function(){t._currentVideoState=t.VideoState.STOPPED})),this._player.on("player-playing",(function(){t._currentVideoState=t.VideoState.PLAYED})),this._player.on("content-end",(function(){t._currentVideoState=t.VideoState.COMPLETED})),this._player.on("content-time",(function(e){t._currentPlayTime=e.currentTime}))}c.prototype.ContentType={AD:"ad",CONTENT:"ct"},c.prototype.AdPosition={PREROLL:"a1",MIDROLL:"a2",POSTROLL:"a3",OVERLAY:"a4",SPECIAL:"a5"},c.prototype.VideoState={UNPLAYED:"s1",PLAYED:"s2",STOPPED:"s3",COMPLETED:"s4"},c.prototype.getCurrentItem=function(){var e,t={};return null!==(e=this._player.config.content.playFirst)&&void 0!==e&&e.length?t=this._player.config.content.playFirst[0]:this._playerReady&&(t=this._player.getPlaylistItem()),window.location.href.indexOf("videoDebug")>-1&&console.log("Chartbeat getCurrentItem",{id:t.id,src:t.src,title:t.title,duration:t.duration,poster:t.poster}),t},c.prototype.isReady=function(){return this._playerReady},c.prototype.getTitle=function(){return this.getCurrentItem().title},c.prototype.getVideoPath=function(){return this.getCurrentItem().src},c.prototype.getContentType=function(){return this._currentContentType},c.prototype.getAdPosition=function(){return this.AdPosition.PREROLL},c.prototype.getTotalDuration=function(){return this.getCurrentItem().duration},c.prototype.getState=function(){return this._currentVideoState},c.prototype.getCurrentPlayTime=function(){return this._currentPlayTime},c.prototype.getBitrate=function(){return 5e3},c.prototype.getThumbnailPath=function(){return this.getCurrentItem().poster},c.prototype.getPlayerType=function(){return this._player.type},c.prototype.getViewStartTime=function(){return new Date-this._startViewTime},c.prototype.getViewPlayTime=function(){var e;return new Date-(null!==(e=this._startPlayTime)&&void 0!==e?e:new Date)},c.prototype.getViewAdPlayTime=function(){var e;return new Date-(null!==(e=this._starFirstAdTime)&&void 0!==e?e:new Date)},c.verify=function(e){return"EX.CO"===e.type};const u=c;var d=__webpack_require__(3787),h=__webpack_require__.n(d);function p(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];
vendor: 7,537 bytes, line 2
2if(!n){if(Array.isArray(e)||(n=y(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return m(e,arguments,S(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),E(n,e)},f(e)}function m(e,t,n){if(k())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&E(i,n.prototype),i}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,s,o=[],l=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(e,t)||y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){if(e){if("string"==typeof e)return b(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _(e,t,n){return t=S(t),function(e,t){if(t&&("object"==O(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return w(e)}(e,k()?Reflect.construct(t,n||[],S(e).constructor):t.apply(e,n))}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(k=function(){return!!e})()}function S(e){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},S(e)}function x(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&E(e,t)}function E(e,t){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},E(e,t)}function C(){C=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a=t&&t.prototype instanceof g?t:g,s=Object.create(a.prototype),o=new I(r||[]);return i(s,"_invoke",{value:E(e,n,o)}),s}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var h="suspendedStart",p="executing",f="completed",m={};function g(){}function v(){}function y(){}var b={};c(b,s,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(L([])));w&&w!==n&&r.call(w,s)&&(b=w);var k=y.prototype=g.prototype=Object.create(b);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function n(i,a,s,o){var l=d(e[i],e,a);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==O(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(u).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,o)}))}o(l.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function E(t,n,r){var i=h;return function(a,s){if(i===p)throw Error("Generator is already running");if(i===f){if("throw"===a)throw s;return{value:e,done:!0}}for(r.method=a,r.arg=s;;){var o=r.delegate;if(o){var l=T(o,r);if(l){if(l===m)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=f,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?f:"suspendedYield",c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=f,r.method="throw",r.arg=c.arg)}}}function T(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,T(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var a=d(i,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,m;var s=a.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function L(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}throw new TypeError(O(t)+" is not iterable")}return v.prototype=y,i(k,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:v,configurable:!0}),v.displayName=c(y,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,c(e,l,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}}
2,S(x.prototype),c(x.prototype,o,(function(){return this})),t.AsyncIterator=x,t.async=function(e,n,r,i,a){void 0===a&&(a=Promise);var s=new x(u(e,n,r,i),a);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},S(k),c(k,l,"Generator"),c(k,s,(function(){return this})),c(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=L,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return o.type="throw",o.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var s=this.tryEntries[a],o=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var l=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(l&&c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(l){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),M(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;M(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:L(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m}},t}function T(e,t,n,r,i,a,s){try{var o=e[a](s),l=o.value}catch(e){return void n(e)}o.done?t(l):Promise.resolve(l).then(r,i)}function A(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function s(e){T(a,r,i,s,o,"next",e)}function o(e){T(a,r,i,s,o,"throw",e)}s(void 0)}))}}function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function I(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach((function(t){L(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function L(e,t,n){return(t=j(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function R(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function P(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,j(r.key),r)}}function N(e,t,n){return t&&P(e.prototype,t),n&&P(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function j(e){var t=function(e,t){if("object"!=O(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=O(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==O(t)?t:t+""}var D=function(){return N((function e(){R(this,e)}),null,[{key:"render",value:function(e,t){var n=document.createElement("div");n.id="error-view",n.innerText=t,e.replaceChildren(n)}}])}(),B=function(){function e(){R(this,e)}return N(e,null,[{key:"onLoad",value:function(e){e.innerHTML='<div id="loading-validate-key-property"></div>'}},{key:"createElements",value:function(){var e=document.createElement("div");return e.id="validate-property-key-view",e}},{key:"render",value:function(t,n,r){var i=e.createElements(),a={onSuccess:n,onFail:D.render.bind(this,t,"Your 'key' has failed authentication"),onLoad:e.onLoad.bind(this,i)};r.key&&r.verifyKey(r.key,a),t.replaceChildren(i)}}])}(),F=function(){function e(){R(this,e)}return N(e,null,[{key:"unsetStyle",value:function(e,t){var n=Object.keys(t).reduce((function(e,t){return e[t]="",e}),{});Object.assign(e.style,n)}},{key:"unsetActivityCSSMouseStates",value:function(t,n){n.click&&e.unsetStyle(t,n.click),n.hover&&e.unsetStyle(t,n.hover)}},{key:"unsetAllCSSMouseStates",value:function(t,n){e.unsetActivityCSSMouseStates(t,n),n.default&&e.unsetStyle(t,n.default)}},{key:"processStateful",value:function(e){var t=e.default||{},n=Object.assign(JSON.parse(JSON.stringify(t)),null==e?void 0:e.hover);return{default:t,hover:n,click:Object.assign(JSON.parse(JSON.stringify(n)),null==e?void 0:e.click)}}},{key:"mergeStatefulStyles",value:function(e){var t={default:{},hover:{},click:{}};return e.forEach((function(e){t.default=Object.assign(t.default,e.default),t.hover=Object.assign(t.hover,e.hover),t.click=Object.assign(t.click,e.click)})),t}}
2,{key:"overwriteDefaultWithAlreadyApplied",value:function(e,t){Object.keys(e.default||[]).forEach((function(n){var r,i=n;t.style[i]&&null!=(r=e.default)&&r[i]&&(e.default[n]=t.style[i])}))}},{key:"applyToStyleIfNotDefined",value:function(e,t){for(var n in t){var r=t[n];""===e[n]&&r&&(e[n]=r)}}}])}(),U=function(){function e(){R(this,e)}return N(e,null,[{key:"attemptAppendStyleSheetToHead",value:function(t){if(!t.fontFamily||t.fontFamily===e.DEFAULT_FONT_FAMILY){var n=document.getElementsByTagName("head")[0];if(!Array.from(n.getElementsByTagName("link")).some((function(t){return t.getAttribute("href")===e.FONT_URL}))){var r=document.createElement("link");r.rel="stylesheet",r.href=e.FONT_URL,n.appendChild(r)}}}}])}();U.FONT_URL="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap",U.DEFAULT_FONT_FAMILY="'Inter', sans-serif, Avenir, Helvetica, Arial";var z=U,q=function(){function e(){R(this,e)}return N(e,null,[{key:"apply",value:function(t,n){if(n)try{e.applyStyleSheet(t,n)}catch(r){e.addStyleElement(t,n)}}},{key:"applyStyleSheet",value:function(e,t){var n=new CSSStyleSheet;n.replaceSync(e),t.adoptedStyleSheets.push(n)}},{key:"addStyleElement",value:function(e,t){var n=document.createElement("style");n.innerHTML=e,t.appendChild(n)}},{key:"applyDefaultStyleToComponent",value:function(t,n){n&&F.applyToStyleIfNotDefined(t,n),F.applyToStyleIfNotDefined(t,e.DEFAULT_COMPONENT_STYLE)}}])}();q.DEFAULT_COMPONENT_STYLE={height:"350px",width:"320px",borderTop:"1px solid #cacaca",borderRight:"1px solid #cacaca",borderLeft:"1px solid #cacaca",borderBottom:"1px solid #cacaca",fontFamily:z.DEFAULT_FONT_FAMILY,fontSize:"0.9rem",backgroundColor:"white",position:"relative",overflow:"hidden"};var H=q,V=N((function e(){R(this,e)}));V.IS_SAFARI=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),V.IS_CHROMIUM=window.chrome,V.IS_MOBILE=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent);var G=V,W=function(e){return e.ESCAPE="Escape",e.ENTER="Enter",e.TAB="Tab",e.ARROW_UP="ArrowUp",e.ARROW_DOWN="ArrowDown",e.ARROW_RIGHT="ArrowRight",e.ARROW_LEFT="ArrowLeft",e.BACKSPACE="Backspace",e.DELETE="Delete",e.META="Meta",e.CONTROL="Control",e}(W||{}),$=function(){function e(){R(this,e)}return N(e,null,[{key:"add",value:function(t,n,r,i){void 0!==r&&t.addEventListener("keydown",e.onKeyDown.bind(this,r)),t.oninput=e.onInput.bind(this,r,i),t.addEventListener("paste",(function(e){var t;e.preventDefault(),null!=(t=e.clipboardData)&&t.files.length&&n.addFilesToAnyType(Array.from(e.clipboardData.files))}))}},{key:"onKeyDown",value:function(t,n){var r=n.target.textContent;r&&r.length>=t&&!e.PERMITTED_KEYS.has(n.key)&&!e.isKeyCombinationPermitted(n)&&n.preventDefault()}},{key:"isKeyCombinationPermitted",value:function(e){return"a"===e.key&&(e.ctrlKey||e.metaKey)}},{key:"onInput",value:function(e,t,n){var r=n.target,i=r.textContent||"";void 0!==e&&i.length>e&&(r.textContent=i.substring(0,e),X.focusEndOfInput(r)),null==t||t()}}])}();$.PERMITTED_KEYS=new Set([W.BACKSPACE,W.DELETE,W.ARROW_RIGHT,W.ARROW_LEFT,W.ARROW_DOWN,W.ARROW_UP,W.META,W.CONTROL,W.ENTER]);var K=$,J=function(){return N((function e(){R(this,e)}),null,[{key:"sanitizePastedTextContent",value:function(e){var t,n;e.preventDefault();var r=null==(t=e.clipboardData)?void 0:t.getData("text/plain");r&&(null==(n=document.execCommand)||n.call(document,"insertText",!1,r))}}])}(),Z=function(){function e(t,n,r){var i,a,s=this;R(this,e),this._isComposing=!1;var o=e.processConfig(n,t.textInput);this.elementRef=e.createContainerElement(null==(i=null==o?void 0:o.styles)?void 0:i.container),this._config=o,this.inputElementRef=this.createInputElement(),this.elementRef.appendChild(this.inputElementRef),t.setPlaceholderText=this.setPlaceholderText.bind(this),t.setPlaceholderText((null==(a=this._config.placeholder)?void 0:a.text)||"Ask me anything!"),setTimeout((function(){K.add(s.inputElementRef,r,s._config.characterLimit,t._validationHandler)}))}return N(e,[{key:"clear",value:function(){var e,t=window.scrollY;this.inputElementRef.classList.contains("text-input-disabled")||(Object.assign(this.inputElementRef.style,null==(e=this._config.placeholder)?void 0:e.style),this.inputElementRef.textContent="",X.focusEndOfInput(this.inputElementRef)),G.IS_CHROMIUM&&window.scrollTo({top:t})}},{key:"createInputElement",value:function(){var t,n,r,i,a=document.createElement("div");return a.id=e.TEXT_INPUT_ID,a.classList.add("text-input-styling"),a.role="textbox",G.IS_CHROMIUM&&e.preventAutomaticScrollUpOnNewLine(a),"boolean"==typeof this._config.disabled&&!0===this._config.disabled?(a.contentEditable="false",a.classList.add("text-input-disabled"),a.setAttribute("aria-disabled","true")):(a.contentEditable="true",a.removeAttribute("aria-disabled"),this.addEventListeners(a)),Object.assign(a.style,null==(t=this._config.styles)?void 0:t.text),Object.assign(a.style,null==(n=this._config.placeholder)?void 0:n.style),null!=(i=null==(r=this._config.placeholder)?void 0:r.style)&&i.color||a.setAttribute("textcolor",""),a}},{key:"removePlaceholderStyle",value:function(){var e,t,n,r;!this.inputElementRef.classList.contains("text-input-disabled")&&null!=(e=this._config.placeholder)&&e.style&&(F.unsetStyle(this.inputElementRef,null==(t=this._config.placeholder)?void 0:t.style),Object.assign(this.inputElementRef.style,null==(r=null==(n=this._config)?void 0:n.styles)?void 0:r.text))}},{key:"addEventListeners",value:function(e){var t,n,r=this;
2null!=(t=this._config.styles)&&t.focus&&(e.onfocus=function(){var e;return Object.assign(r.elementRef.style,null==(e=r._config.styles)?void 0:e.focus)},e.onblur=this.onBlur.bind(this,this._config.styles.focus,null==(n=this._config.styles)?void 0:n.container)),e.addEventListener("keydown",this.onKeydown.bind(this)),e.addEventListener("input",this.onInput.bind(this)),e.addEventListener("paste",J.sanitizePastedTextContent),e.addEventListener("compositionstart",(function(){return r._isComposing=!0})),e.addEventListener("compositionend",(function(){return r._isComposing=!1}))}},{key:"onBlur",value:function(e,t){F.unsetStyle(this.elementRef,e),t&&Object.assign(this.elementRef.style,t)}},{key:"onKeydown",value:function(e){var t;e.key===W.ENTER&&!G.IS_MOBILE&&!this._isComposing&&!e.ctrlKey&&!e.shiftKey&&(e.preventDefault(),null==(t=this.submit)||t.call(this))}},{key:"onInput",value:function(){var e;this.isTextInputEmpty()?Object.assign(this.inputElementRef.style,null==(e=this._config.placeholder)?void 0:e.style):this.removePlaceholderStyle()}},{key:"setPlaceholderText",value:function(e){this.inputElementRef.setAttribute("deep-chat-placeholder-text",e),this.inputElementRef.setAttribute("aria-label",e)}},{key:"isTextInputEmpty",value:function(){return""===this.inputElementRef.textContent}}],[{key:"processConfig",value:function(e,t){var n,r,i,a;return null!=t||(t={}),null!==(n=t.disabled)&&void 0!==n||(t.disabled=e.isTextInputDisabled),null!==(r=t.placeholder)&&void 0!==r||(t.placeholder={}),null!==(i=(a=t.placeholder).text)&&void 0!==i||(a.text=e.textInputPlaceholderText),t}},{key:"createContainerElement",value:function(e){var t=document.createElement("div");return t.id="text-input-container",Object.assign(t.style,e),t}},{key:"preventAutomaticScrollUpOnNewLine",value:function(e){var t;e.addEventListener("keydown",(function(){t=window.scrollY})),e.addEventListener("input",(function(){t!==window.scrollY&&window.scrollTo({top:t})}))}}])}();Z.TEXT_INPUT_ID="text-input";var Y=Z,X=function(){function e(){R(this,e)}return N(e,null,[{key:"focusEndOfInput",value:function(e){var t=document.createRange();t.selectNodeContents(e),t.collapse(!1);var n=window.getSelection();null==n||n.removeAllRanges(),null==n||n.addRange(t)}},{key:"focusFromParentElement",value:function(t){var n=t.querySelector("#".concat(Y.TEXT_INPUT_ID));n&&(G.IS_SAFARI&&n.focus(),e.focusEndOfInput(n))}}])}();function Q(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ee(e,t,n,r){var i="\n".concat(Q(t)," message: ").concat(JSON.stringify(e)," \n"),a=n?"".concat(Q(t)," message after interceptor: ").concat(function(e){return e&&JSON.stringify(e)}(r)," \n"):"";return i+a}var te="Make sure the events are using {text: string} or {html: string} format.\nYou can also augment them using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor",ne={INVALID_KEY:"Invalid API Key",CONNECTION_FAILED:"Failed to connect",INVALID_RESPONSE:function(e,t,n,r){return"".concat(ee(e,t,n,r),"Make sure the ").concat(t," message is using the Response format: https://deepchat.dev/docs/connect/#Response \nYou can also augment it using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor")},INVALID_MODEL_REQUEST:function(e,t){var n="request";return"".concat(ee(e,n,t),"Make sure the ").concat(n,' message is using the {body: {text: string}} format, e.g: {body: {text: "Model Response"}}')},INVALID_MODEL_RESPONSE:function(e,t,n){var r="response";return"".concat(ee(e,r,t,n),"Make sure the ").concat(r,' message is using the {text: string} format, e.g: {text: "Model Response"}')},INVALID_STREAM_ARRAY_RESPONSE:"Multi-response arrays are not supported for streaming",INVALID_STREAM_EVENT:te,INVALID_STREAM_EVENT_MIX:"Cannot mix {text: string} and {html: string} responses.",NO_VALID_STREAM_EVENTS_SENT:"No valid stream events were sent.\n".concat(te),READABLE_STREAM_CONNECTION_ERROR:"Readable Stream connection error."},re=function(){function e(){R(this,e)}return N(e,null,[{key:"addElements",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];
2n.forEach((function(t){return e.appendChild(t)}))}},{key:"isScrollbarAtBottomOfElement",value:function(t){var n=t.scrollHeight,r=t.clientHeight;return t.scrollTop>=n-r-e.CODE_SNIPPET_GENERATION_JUMP}},{key:"cloneElement",value:function(e){var t=e.cloneNode(!0);return e.parentNode.replaceChild(t,e),t}},{key:"scrollToBottom",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?e.scrollTo({left:0,top:e.scrollHeight,behavior:"smooth"}):e.scrollTop=e.scrollHeight}},{key:"scrollToTop",value:function(e){e.scrollTop=0}}])}();re.CODE_SNIPPET_GENERATION_JUMP=.5;var ie=re,ae=function(){function e(){R(this,e)}return N(e,null,[{key:"speak",value:function(e,t){if(window.SpeechSynthesisUtterance){var n=new SpeechSynthesisUtterance(e);Object.assign(n,t),speechSynthesis.speak(n)}}},{key:"processConfig",value:function(t,n){var r={};setTimeout((function(){if("object"==O(t)&&(t.lang&&(r.lang=t.lang),t.pitch&&(r.pitch=t.pitch),t.rate&&(r.rate=t.rate),t.volume&&(r.volume=t.volume),t.voiceName)){var e=window.speechSynthesis.getVoices().find((function(e){var n;return e.name.toLocaleLowerCase()===(null==(n=t.voiceName)?void 0:n.toLocaleLowerCase())}));e&&(r.voice=e)}n(r)}),e.LOAD_VOICES_MS)}}])}();ae.LOAD_VOICES_MS=200;var se=ae,oe=function(){function e(){R(this,e)}return N(e,null,[{key:"colorToHex",value:function(e){var t=document.createElement("div");return t.style.color=e,document.body.appendChild(t),"#".concat(window.getComputedStyle(t).color.match(/\d+/g).map((function(e){return parseInt(e).toString(16).padStart(2,"0")})).join(""))}},{key:"setDots",value:function(t,n){var r,i,a,s;if(null!=(s=null==(a=null==(i=null==(r=null==n?void 0:n.loading)?void 0:r.message)?void 0:i.styles)?void 0:a.bubble)&&s.color){var o=e.colorToHex(n.loading.message.styles.bubble.color);t.style.setProperty("--loading-message-color",o),t.style.setProperty("--loading-message-color-fade","".concat(o,"33"))}else t.style.setProperty("--loading-message-color","#848484"),t.style.setProperty("--loading-message-color-fade","#55555533")}},{key:"setRing",value:function(t,n){var r=n||{},i=r.color,a=r.width,s=r.height,o=r.margin,l=r.border;if(i){var c=e.colorToHex(i);t.style.setProperty("--loading-history-color",c)}else t.style.setProperty("--loading-history-color","#dbdbdb");t.style.setProperty("--loading-history-height",s||"57px"),t.style.setProperty("--loading-history-width",a||"57px"),t.style.setProperty("--loading-history-margin",o||"7px"),t.style.setProperty("--loading-history-border",l||"6px solid")}}])}();oe.BUBBLE_CLASS="deep-chat-loading-message-bubble",oe.DOTS_CONTAINER_CLASS="deep-chat-loading-message-dots-container";var le=oe,ce=function(){function e(){R(this,e)}return N(e,null,[{key:"setElementProps",value:function(t,n,r,i){var a;"loading"!==r&&(t.applyCustomStyles(n,i,!0,null==(a=t.messageStyles)?void 0:a[r]),n.bubbleElement.classList.add(e.FILE_BUBBLE_CLASS))}},{key:"addMessage",value:function(t,n,r,i,a){e.setElementProps(t,n,r,i),a||(t.appendOuterContainerElemet(n.outerContainer),t.focusMode||(t.elementRef.scrollTop=t.elementRef.scrollHeight))}},{key:"wrapInLink",value:function(t,n,r){var i=document.createElement("a");return i.href=n,i.download=r||e.DEFAULT_FILE_NAME,i.target="_blank",i.appendChild(t),i}},{key:"isNonLinkableDataUrl",value:function(e,t){return!(!t.startsWith("data")||"image"===e)&&("any"===e&&t.startsWith("data:text/javascript")||!t.startsWith("data:image")&&!t.startsWith("data:application"))}},{key:"processContent",value:function(t,n,r,i){return!r||e.isNonLinkableDataUrl(t,r)?n:e.wrapInLink(n,r,i)}},{key:"waitToLoadThenScroll",value:function(e){setTimeout((function(){e.scrollTop=e.scrollHeight}),60)}},{key:"scrollDownOnImageLoad",value:function(t,n){if(t.startsWith("data"))e.waitToLoadThenScroll(n);else try{fetch(t,{mode:"no-cors"}).catch((function(){})).finally((function(){e.waitToLoadThenScroll(n)}))}catch(e){n.scrollTop=n.scrollHeight}}},{key:"reAddFileRefToObject",value:function(e,t){var n;null==(n=e.files)||n.forEach((function(e,n){var r;e.ref&&null!=(r=t.message.files)&&r[n]&&(t.message.files[n].ref=e.ref)}))}},{key:"removeFileRef",value:function(e){var t=I({},e);return delete t.ref,t}},{key:"isAudioFile",value:function(e){var t=e.type,n=e.src;return"audio"===t||(null==n?void 0:n.startsWith("data:audio"))||n&&/\.(mp3|ogg|wav|aac|webm|4a)$/i.test(n)}},{key:"isImageFile",value:function(t){var n=t.type,r=t.src;return"image"===n||(null==r?void 0:r.startsWith("data:image"))||r&&e.isImageFileExtension(r)}},{key:"isImageFileExtension",value:function(e){return/\.(jpg|jpeg|png|gif|bmp)$/i.test(e)}}])}();ce.DEFAULT_FILE_NAME="file",ce.FILE_BUBBLE_CLASS="file-message";var ue=ce,de=function(){return N((function e(){R(this,e)}),null,[{key:"checkForContainerStyles",value:function(e,t){var n=e.containerStyle;n&&(Object.assign(t.style,n),console.error("The containerStyle property is deprecated since version 1.3.14."),console.error("Please change to using the style property instead: https://deepchat.dev/docs/styles#style"))}},{key:"handleResponseProperty",value:function(e){return console.error("The {result: ....} response object type is deprecated since version 1.3.0."),console.error("Please change to using the new response object: https://deepchat.dev/docs/connect#Response"),e.result}},{key:"processHistory",value:function(e){var t=e.initialMessages;if(t)return console.error("The initialMessages property is deprecated since version 2.0.0."),console.error("Please change to using the history property instead: https://deepchat.dev/docs/messages/#history"),t}},{key:"processHistoryFile",value:function(e){var t=e.file;t&&(console.error("The file property in MessageContent is deprecated since version 1.3.17."),console.error("Please change to using the files array property: https://deepchat.dev/docs/messages/#MessageContent"),e.files=[t])}},{key:"processValidateInput",value:function(e){var t=e.validateMessageBeforeSending;if(t)return console.error("The validateMessageBeforeSending property is deprecated since version 1.3.24."),console.error("Please change to using validateInput: https://deepchat.dev/docs/interceptors#validateInput"),t}},{key:"processSubmitUserMessage",value:function(e){return console.error("The submitUserMessage(text: string) argument string type is deprecated since version 1.4.4."),console.error("Please change to using the new argument type: https://deepchat.dev/docs/methods#submitUserMessage"),{text:e}}},{key:"flagHTMLUpdateClass",value:function(e){var t;null!=(t=e.children[0])&&t.classList.contains("deep-chat-update-message")&&(console.error('The "deep-chat-update-message" html class is deprecated since version 1.4.4.'),console.error("Please change to using {..., overwrite: true} object: https://deepchat.dev/docs/connect#Response"))}},{key:"processConnect",value:function(e){var t=e;t.request&&(t.connect?Object.assign(t.connect,t.request):t.connect=t.request,console.error("The request property is deprecated since version 2.0.0."),console.error("Please see the connect object: https://deepchat.dev/docs/connect#connect-1"))}},{key:"checkForStream",value:function(e){var t=e.stream;if(t)return console.error("The stream property has been moved to the connect object in ver
2sion 2.0.0."),console.error("Please see the connect object: https://deepchat.dev/docs/connect#connect-1"),t}},{key:"fireOnNewMessage",value:function(e,t){var n,r=e;r.onNewMessage&&(console.error("The onNewMessage event has been deprecated since version 2.0.0."),console.error("Please see the onMessage event: https://deepchat.dev/docs/events#onMessage"),null==(n=r.onNewMessage)||n.call(r,t)),e.dispatchEvent(new CustomEvent("new-message",{detail:t}))}},{key:"processFileConfigConnect",value:function(e){var t=e;t.request&&(console.error("The request property in file configuration is deprecated since version 2.0.0."),console.error("Please use the connect property instead: https://deepchat.dev/docs/files"),t.connect||(t.connect=t.request))}},{key:"processMessageStyles",value:function(e){if(e){var t=JSON.parse(JSON.stringify(e)),n=t.loading;return n&&(n.outerContainer||n.innerContainer||n.bubble||n.media)&&(console.error("The loading message styles are defined using LoadingMessageStyles interface since version 2.1.0."),console.error("Check it out here: https://deepchat.dev/docs/messages/styles#LoadingMessageStyles"),t.loading={message:{styles:n}}),t}}},{key:"processDemo",value:function(e){return"boolean"==typeof e||e.displayLoadingBubble&&(console.error("The demo displayLoadingBubble property is deprecated since version 2.1.0."),console.error("Please use displayLoading instead: https://deepchat.dev/docs/modes#demo"),e.displayLoading={message:!0}),e}}])}(),he=function(){function e(){R(this,e)}return N(e,null,[{key:"mouseUp",value:function(e,t){F.unsetAllCSSMouseStates(e,t),Object.assign(e.style,t.default),Object.assign(e.style,t.hover)}},{key:"mouseDown",value:function(e,t){Object.assign(e.style,t.click)}},{key:"mouseLeave",value:function(e,t){F.unsetAllCSSMouseStates(e,t),Object.assign(e.style,t.default)}},{key:"mouseEnter",value:function(e,t){Object.assign(e.style,t.hover)}},{key:"add",value:function(t,n){t.addEventListener("mouseenter",e.mouseEnter.bind(this,t,n)),t.addEventListener("mouseleave",e.mouseLeave.bind(this,t,n)),t.addEventListener("mousedown",e.mouseDown.bind(this,t,n)),t.addEventListener("mouseup",e.mouseUp.bind(this,t,n))}}])}(),pe={"deep-chat-button":{styles:{default:{backgroundColor:"white",padding:"5px",paddingLeft:"7px",paddingRight:"7px",border:"1px solid #c2c2c2",borderRadius:"6px",cursor:"pointer"},hover:{backgroundColor:"#fafafa"},click:{backgroundColor:"#f1f1f1"}}}},fe=Object.keys(pe),me=function(){function e(){R(this,e)}return N(e,null,[{key:"applySuggestionEvent",value:function(e,t){setTimeout((function(){t.addEventListener("click",(function(){var n,r;null==(r=e.submitUserMessage)||r.call(e,{text:(null==(n=t.textContent)?void 0:n.trim())||""})}))}))}},{key:"isElementTemporary",value:function(e){var t;return!!e&&(null==(t=e.bubbleElement.children[0])?void 0:t.classList.contains("deep-chat-temporary-message"))}},{key:"doesElementContainDeepChatClass",value:function(e){return fe.find((function(t){return e.classList.contains(t)}))}},{key:"applyEvents",value:function(e,t){var n=pe[t].events;Object.keys(n||[]).forEach((function(t){e.addEventListener(t,null==n?void 0:n[t])}))}},{key:"getProcessedStyles",value:function(e,t,n){var r=Array.from(t.classList).reduce((function(t,n){var r,i=null==(r=e[n])?void 0:r.styles;return i&&e[n].styles&&t.push(i),t}),[]),i=pe[n].styles;if(i){var a=JSON.parse(JSON.stringify(i));a.default&&F.overwriteDefaultWithAlreadyApplied(a,t),r.unshift(a)}var s=F.mergeStatefulStyles(r);return F.processStateful(s)}},{key:"applyDeepChatUtilities",value:function(t,n,r){fe.forEach((function(t){var i=r.getElementsByClassName(t);Array.from(i||[]).forEach((function(r){var i=e.getProcessedStyles(n,r,t);ge.applyStylesToElement(r,i),e.applyEvents(r,t)}))}));var i=r.getElementsByClassName("deep-chat-suggestion-button");Array.from(i).forEach((function(n){return e.applySuggestionEvent(t,n)}))}}])}(),ge=function(){function e(){R(this,e)}return N(e,null,[{key:"applyStylesToElement",value:function(e,t){var n=F.processStateful(t);he.add(e,n),Object.assign(e.style,n.default)}},{key:"applyEventsToElement",value:function(e,t){Object.keys(t).forEach((function(n){var r=t[n];r&&e.addEventListener(n,r)}))}},{key:"applyClassUtilitiesToElement",value:function(t,n){var r=n.events,i=n.styles;r&&e.applyEventsToElement(t,r),i&&!me.doesElementContainDeepChatClass(t)&&e.applyStylesToElement(t,i)}},{key:"applyCustomClassUtilities",value:function(t,n){Object.keys(t).forEach((function(r){var i=n.getElementsByClassName(r);
2Array.from(i).forEach((function(n){t[r]&&e.applyClassUtilitiesToElement(n,t[r])}))}))}},{key:"apply",value:function(t,n){me.applyDeepChatUtilities(t,t.htmlClassUtilities,n),e.applyCustomClassUtilities(t.htmlClassUtilities,n)}},{key:"traverseNodes",value:function(t,n){t.nodeType===Node.ELEMENT_NODE&&n.push(t.outerHTML),t.childNodes.forEach((function(t){e.traverseNodes(t,n)}))}},{key:"splitHTML",value:function(t){var n=(new DOMParser).parseFromString(t,"text/html"),r=[];return n.body.childNodes.forEach((function(t){e.traverseNodes(t,r)})),r}},{key:"isTemporaryBasedOnHTML",value:function(e){var t=document.createElement("div");return t.innerHTML=e,me.isElementTemporary({outerContainer:t,bubbleElement:t,innerContainer:t})}},{key:"replaceElementWithNewClone",value:function(e,t){var n,r=(t||e).cloneNode(!0);return null==(n=e.parentNode)||n.replaceChild(r,e),r}}])}(),ve=function(){function e(){R(this,e)}return N(e,null,[{key:"addElement",value:function(e,t){e.appendOuterContainerElemet(t),e.focusMode||(e.elementRef.scrollTop=e.elementRef.scrollHeight)}},{key:"createElements",value:function(t,n,r,i){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=t.createMessageElementsOnOrientation("",r,i,a);return s.bubbleElement.classList.add(e.HTML_BUBBLE_CLASS),s.bubbleElement.innerHTML=n,s}},{key:"overwriteElements",value:function(e,t,n){n.bubbleElement.innerHTML=t,ge.apply(e,n.outerContainer),de.flagHTMLUpdateClass(n.bubbleElement)}},{key:"overwrite",value:function(t,n,r,i){var a=t.messageToElements,s=on.overwriteMessage(
vendor: 25,319 bytes, line 2
2a,i,n,r,"html",e.HTML_BUBBLE_CLASS);return s&&e.overwriteElements(t,n,s),s}},{key:"create",value:function(t,n,r){var i,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=e.createElements(t,n,r,a);return on.fillEmptyMessageElement(s.bubbleElement,n),ge.apply(t,s.outerContainer),de.flagHTMLUpdateClass(s.bubbleElement),t.applyCustomStyles(s,r,!1,null==(i=t.messageStyles)?void 0:i.html),s}},{key:"add",value:function(t,n,r,i){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(null!=i&&i.status){var s=this.overwrite(t,n,r,t.messageElementRefs);if(s)return s;i.status=!1}if(!(a&&t.messageElementRefs.length>0&&ge.isTemporaryBasedOnHTML(n))){var o=e.create(t,n,r,a);return a||e.addElement(t,o.outerContainer),o}}}])}();ve.HTML_BUBBLE_CLASS="html-message";var ye,be=ve;function _e(e){return(ye=ye||document.createElement("textarea")).innerHTML="&"+e+";",ye.value}var we=Object.prototype.hasOwnProperty;function ke(e){var t=[].slice.call(arguments,1);return t.forEach((function(t){if(t){if("object"!=O(t))throw new TypeError(t+"must be object");Object.keys(t).forEach((function(n){e[n]=t[n]}))}})),e}var Se=/\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;function xe(e){return e.indexOf("\\")<0?e:e.replace(Se,"$1")}function Ee(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||65535==(65535&e)||65534==(65535&e)||e>=0&&e<=8||11===e||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function Ce(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}var Te=/&([a-z#][a-z0-9]{1,31});/gi,Ae=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;function Me(e,t){var n=0,r=_e(t);return t!==r?r:35===t.charCodeAt(0)&&Ae.test(t)&&Ee(n="x"===t[1].toLowerCase()?parseInt(t.slice(2),16):parseInt(t.slice(1),10))?Ce(n):e}function Ie(e){return e.indexOf("&")<0?e:e.replace(Te,Me)}var Le=/[&<>"]/,Oe=/[&<>"]/g,Re={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function Pe(e){return Re[e]}function Ne(e){return Le.test(e)?e.replace(Oe,Pe):e}var je={};function De(e,t){return++t>=e.length-2?t:"paragraph_open"===e[t].type&&e[t].tight&&"inline"===e[t+1].type&&0===e[t+1].content.length&&"paragraph_close"===e[t+2].type&&e[t+2].tight?De(e,t+2):t}je.blockquote_open=function(){return"<blockquote>\n"},je.blockquote_close=function(e,t){return"</blockquote>"+Be(e,t)},je.code=function(e,t){return e[t].block?"<pre><code>"+Ne(e[t].content)+"</code></pre>"+Be(e,t):"<code>"+Ne(e[t].content)+"</code>"},je.fence=function(e,t,n,r,i){var a,s,o=e[t],l="",c=n.langPrefix;if(o.params){if(s=(a=o.params.split(/\s+/g)).join(" "),function(e,t){return!!e&&we.call(e,t)}(i.rules.fence_custom,a[0]))return i.rules.fence_custom[a[0]](e,t,n,r,i);l=' class="'+c+Ne(Ie(xe(s)))+'"'}return"<pre><code"+l+">"+(n.highlight&&n.highlight.apply(n.highlight,[o.content].concat(a))||Ne(o.content))+"</code></pre>"+Be(e,t)},je.fence_custom={},je.heading_open=function(e,t){return"<h"+e[t].hLevel+">"},je.heading_close=function(e,t){return"</h"+e[t].hLevel+">\n"},je.hr=function(e,t,n){return(n.xhtmlOut?"<hr />":"<hr>")+Be(e,t)},je.bullet_list_open=function(){return"<ul>\n"},je.bullet_list_close=function(e,t){return"</ul>"+Be(e,t)},je.list_item_open=function(){return"<li>"},je.list_item_close=function(){return"</li>\n"},je.ordered_list_open=function(e,t){var n=e[t];return"<ol"+(n.order>1?' start="'+n.order+'"':"")+">\n"},je.ordered_list_close=function(e,t){return"</ol>"+Be(e,t)},je.paragraph_open=function(e,t){return e[t].tight?"":"<p>"},je.paragraph_close=function(e,t){var n=!(e[t].tight&&t&&"inline"===e[t-1].type&&!e[t-1].content);return(e[t].tight?"":"</p>")+(n?Be(e,t):"")},je.link_open=function(e,t,n){var r=e[t].title?' title="'+Ne(Ie(e[t].title))+'"':"",i=n.linkTarget?' target="'+n.linkTarget+'"':"";return'<a href="'+Ne(e[t].href)+'"'+r+i+">"},je.link_close=function(){return"</a>"},je.image=function(e,t,n){var r=' src="'+Ne(e[t].src)+'"',i=e[t].title?' title="'+Ne(Ie(e[t].title))+'"':"";return"<img"+r+(' alt="'+(e[t].alt?Ne(Ie(xe(e[t].alt))):"")+'"')+i+(n.xhtmlOut?" /":"")+">"},je.table_open=function(){return"<table>\n"},je.table_close=function(){return"</table>\n"},je.thead_open=function(){return"<thead>\n"},je.thead_close=function(){return"</thead>\n"},je.tbody_open=function(){return"<tbody>\n"},je.tbody_close=function(){return"</tbody>\n"},je.tr_open=function(){return"<tr>"},je.tr_close=function(){return"</tr>\n"},je.th_open=function(e,t){var n=e[t];return"<th"+(n.align?' style="text-align:'+n.align+'"':"")+">"},je.th_close=function(){return"</th>"},je.td_open=function(e,t){var n=e[t];return"<td"+(n.align?' style="text-align:'+n.align+'"':"")+">"},je.td_close=function(){return"</td>"},je.strong_open=function(){return"<strong>"},je.strong_close=function(){return"</strong>"},je.em_open=function(){return"<em>"},je.em_close=function(){return"</em>"},je.del_open=function(){return"<del>"},je.del_close=function(){return"</del>"},je.ins_open=function(){return"<ins>"},je.ins_close=function(){return"</ins>"},je.mark_open=function(){return"<mark>"},je.mark_close=function(){return"</mark>"},je.sub=function(e,t){return"<sub>"+Ne(e[t].content)+"</sub>"},je.sup=function(e,t){return"<sup>"+Ne(e[t].content)+"</sup>"},je.hardbreak=function(e,t,n){return n.xhtmlOut?"<br />\n":"<br>\n"},je.softbreak=function(e,t,n){return n.breaks?n.xhtmlOut?"<br />\n":"<br>\n":"\n"},je.text=function(e,t){return Ne(e[t].content)},je.htmlblock=function(e,t){return e[t].content},je.htmltag=function(e,t){return e[t].content},je.abbr_open=function(e,t){return'<abbr title="'+Ne(Ie(e[t].title))+'">'},je.abbr_close=function(){return"</abbr>"},je.footnote_ref=function(e,t){var n=Number(e[t].id+1).toString(),r="fnref"+n;return e[t].subId>0&&(r+=":"+e[t].subId),'<sup class="footnote-ref"><a href="#fn'+n+'" id="'+r+'">['+n+"]</a></sup>"},je.footnote_block_open=function(e,t,n){return(n.xhtmlOut?'<hr class="footnotes-sep" />\n':'<hr class="footnotes-sep">\n')+'<section class="footnotes">\n<ol class="footnotes-list">\n'},je.footnote_block_close=function(){return"</ol>\n</section>\n"},je.footnote_open=function(e,t){return'<li id="fn'+Number(e[t].id+1).toString()+'"  class="footnote-item">'},je.footnote_close=function(){return"</li>\n"},je.footnote_anchor=function(e,t){var n="fnref"+Number(e[t].id+1).toString();return e[t].subId>0&&(n+=":"+e[t].subId),' <a href="#'+n+'" class="footnote-backref">↩</a>'},je.dl_open=function(){return"<dl>\n"},je.dt_open=function(){return"<dt>"},je.dd_open=function(){return"<dd>"},je.dl_close=function(){return"</dl>\n"},je.dt_close=function(){return"</dt>\n"},je.dd_close=function(){return"</dd>\n"};var Be=je.getBreak=function(e,t){return(t=De(e,t))<e.length&&"list_item_close"===e[t].type?"":"\n"};function Fe(){this.rules=ke({},je),this.getBreak=je.getBreak}function Ue(){this.__rules__=[],this.__cache__=null}function ze(e,t,n,r,i){this.src=e,this.env=r,this.options=n,this.parser=t,this.tokens=i,this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache=[],this.isInLabel=!1,this.linkLevel=0,this.linkContent="",this.labelUnmatchedScopes=0}function qe(e,t){var n,r,i,a=-1,s=e.posMax,o=e.pos,l=e.isInLabel;if(e.isInLabel)return-1;if(e.labelUnmatchedScopes)return e.labelUnmatchedScopes--,-1;for(e.pos=t+1,e.isInLabel=!0,n=1;e.pos<s;){if(91===(i=e.src.charCodeAt(e.pos)))n++;else if(93===i&&0===--n){r=!0;break}e.parser.skipToken(e)}return r?(a=e.pos,e.labelUnmatchedScopes=0):e.labelUnmatchedScopes=n-1,e.pos=o,e.isInLabel=l,a}function He(e,t,n,r){var i,a,s,o,l,c;if(42!==e.charCodeAt(0)||91!==e.charCodeAt(1)||-1===e.indexOf("]:")||((a=qe(i=new ze(e,t,n,r,[]),1))<0||58!==e.charCodeAt(a+1)))return-1;for(o=i.posMax,s=a+2;s<o&&10!==i.src.charCodeAt(s);s++);return l=e.slice(2,a),0===(c=e.slice(a+2,s).trim()).length?-1:(r.abbreviations||(r.abbreviations={}),O(r.abbreviations[":"+l])>"u"&&(r.abbreviations[":"+l]=c),s)}function Ve(e){var t=Ie(e);try{t=decodeURI(t)}catch(e){}return encodeURI(t)}function Ge(e,t){var n,r,i,a=t,s=e.posMax;if(60===e.src.charCodeAt(t)){for(t++;t<s;){if(10===(n=e.src.charCodeAt(t)))return!1;if(62===n)return i=Ve(xe(e.src.slice(a+1,t))),!!e.parser.validateLink(i)&&(e.pos=t+1,e.linkContent=i,!0);92===n&&t+1<s?t+=2:t++}return!1}for(r=0;t<s&&!(32===(n=e.src.charCodeAt(t))||n<32||127===n);)if(92===n&&t+1<s)t+=2;else{if(40===n&&++r>1||41===n&&--r<0)break;t++}return!(a===t||(i=xe(e.src.slice(a,t)),!e.parser.validateLink(i)))&&(e.linkContent=i,e.pos=t,!0)}function We(e,t){var n,r=t,i=e.posMax,a=e.src.charCodeAt(t);if(34!==a&&39!==a&&40!==a)return!1;for(t++,40===a&&(a=41);t<i;){if((n=e.src.charCodeAt(t))===a)return e.pos=t+1,e.linkContent=xe(e.src.slice(r+1,t)),!0;92===n&&t+1<i?t+=2:t++}return!1}function $e(e){return e.trim().replace(/\s+/g," ").toUpperCase()}function Ke(e,t,n,r){var i,a,s,o,l,c,u,d,h;if(91!==e.charCodeAt(0)||-1===e.indexOf("]:")||((a=qe(i=new ze(e,t,n,r,[]),0))<0||58!==e.charCodeAt(a+1)))return-1;for(o=i.posMax,s=a+2;s<o&&(32===(l=i.src.charCodeAt(s))||10===l);s++);if(!Ge(i,s))return-1;for(u=i.linkContent,c=s=i.pos,s+=1;s<o&&(32===(l=i.src.charCodeAt(s))||10===l);s++);for(s<o&&c!==s&&We(i,s)?(d=i.linkContent,s=i.pos):(d="",s=c);s<o&&32===i.src.charCodeAt(s);)s++;return s<o&&10!==i.src.charCodeAt(s)?-1:(h=$e(e.slice(1,a)),O(r.references[h])>"u"&&(r.references[h]={title:d,href:u}),s)}Fe.prototype.renderInline=function(e,t,n){for(var r=this.rules,i=e.length,a=0,s="";i--;)s+=r[e[a].type](e,a++,t,n,this);return s},Fe.prototype.render=function(e,t,n){for(var r=this.rules,i=e.length,a=-1,s="";++a<i;)"inline"===e[a].type?s+=this.renderInline(e[a].children,t,n):s+=r[e[a].type](e,a,t,n,this);return s},Ue.prototype.__find__=function(e){for(var t=this.__rules__.length,n=-1;t--;)if(this.__rules__[++n].name===e)return n;return-1},Ue.prototype.__compile__=function(){var e=this,t=[""];e.__rules__.forEach((function(e){e.enabled&&e.alt.forEach((function(e){t.indexOf(e)<0&&t.push(e)}))})),e.__cache__={},t.forEach((function(t){e.__cache__[t]=[],e.__rules__.forEach((function(n){n.enabled&&(t&&n.alt.indexOf(t)<0||e.__cache__[t].push(n.fn))}))}))},Ue.prototype.at=function(e,t,n){var r=this.__find__(e),i=n||{};if(-1===r)throw new Error("Parser rule not found: "+e);this.__rules__[r].fn=t,this.__rules__[r].alt=i.alt||[],this.__cache__=null},Ue.prototype.before=function(e,t,n,r){var i=this.__find__(e),a=r||{};if(-1===i)throw new Error("Parser rule not found: "+e);this.__rules__.splice(i,0,{name:t,enabled:!0,fn:n,alt:a.alt||[]}),this.__cache__=null},Ue.prototype.after=function(e,t,n,r){var i=this.__find__(e),a=r||{};if(-1===i)throw new Error("Parser rule not found: "+e);this.__rules__.splice(i+1,0,{name:t,enabled:!0,fn:n,alt:a.alt||[]}),this.__cache__=null},Ue.prototype.push=function(e,t,n){var r=n||{};this.__rules__.push({name:e,enabled:!0,fn:t,alt:r.alt||[]}),this.__cache__=null},Ue.prototype.enable=function(e,t){e=Array.isArray(e)?e:[e],t&&this.__rules__.forEach((function(e){e.enabled=!1})),e.forEach((function(e){var t=this.__find__(e);if(t<0)throw new Error("Rules manager: invalid rule name "+e);this.__rules__[t].enabled=!0}),this),this.__cache__=null},Ue.prototype.disable=function(e){(e=Array.isArray(e)?e:[e]).forEach((function(e){var t=this.__find__(e);if(t<0)throw new Error("Rules manager: invalid rule name "+e);this.__rules__[t].enabled=!1}),this),this.__cache__=null},Ue.prototype.getRules=function(e){return null===this.__cache__&&this.__compile__(),this.__cache__[e]||[]},ze.prototype.pushPending=function(){this.tokens.push({type:"text",content:this.pending,level:this.pendingLevel}),this.pending=""},ze.prototype.push=function(e){this.pending&&this.pushPending(),this.tokens.push(e),this.pendingLevel=this.level},ze.prototype.cacheSet=function(e,t){for(var n=this.cache.length;n<=e;n++)this.cache.push(0);this.cache[e]=t},ze.prototype.cacheGet=function(e){return e<this.cache.length?this.cache[e]:0};var Je=" \n()[]'\".,!?-";function Ze(e){return e.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1")}var Ye=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Xe=/\((c|tm|r|p)\)/gi,Qe={c:"©",r:"®",p:"§",tm:"™"};function et(e){return e.indexOf("(")<0?e:e.replace(Xe,(function(e,t){return Qe[t.toLowerCase()]}))}var tt=/['"]/,nt=/['"]/g,rt=/[-\s()\[\]]/;function it(e,t){return!(t<0||t>=e.length)&&!rt.test(e[t])}function at(e,t,n){return e.substr(0,t)+n+e.substr(t+1)}var st=[["block",function(e){e.inlineMode?e.tokens.push({type:"inline",content:e.src.replace(/\n/g," ").trim(),level:0,lines:[0,1],children:[]}):e.block.parse(e.src,e.options,e.env,e.tokens)}],["abbr",function(e){var t,n,r,i,a=e.tokens;if(!e.inlineMode)for(t=1,n=a.length-1;t<n;t++)if("paragraph_open"===a[t-1].type&&"inline"===a[t].type&&"paragraph_close"===a[t+1].type){for(r=a[t].content;r.length&&!((i=He(r,e.inline,e.options,e.env))<0);)r=r.slice(i).trim();a[t].content=r,r.length||(a[t-1].tight=!0,a[t+1].tight=!0)}}],["references",function(e){var t,n,r,i,a=e.tokens;if(e.env.references=e.env.references||{},!e.inlineMode)for(t=1,n=a.length-1;t<n;t++)if("inline"===a[t].type&&"paragraph_open"===a[t-1].type&&"paragraph_close"===a[t+1].type){for(r=a[t].content;r.length&&!((i=Ke(r,e.inline,e.options,e.env))<0);)r=r.slice(i).trim();a[t].content=r,r.length||(a[t-1].tight=!0,a[t+1].tight=!0)}}],["inline",function(e){var t,n,r,i=e.tokens;for(n=0,r=i.length;n<r;n++)"inline"===(t=i[n]).type&&e.inline.parse(t.content,e.options,e.env,t.children)}],["footnote_tail",function(e){var t,n,r,i,a,s,o,l,c,u=0,d=!1,h={};if(e.env.footnotes&&(e.tokens=e.tokens.filter((function(e){return"footnote_reference_open"===e.type?(d=!0,l=[],c=e.label,!1):"footnote_reference_close"===e.type?(d=!1,h[":"+c]=l,!1):(d&&l.push(e),!d)})),e.env.footnotes.list)){for(s=e.env.footnotes.list,e.tokens.push({type:"footnote_block_open",level:u++}),t=0,n=s.length;t<n;t++){for(e.tokens.push({type:"footnote_open",id:t,level:u++}),s[t].tokens?((o=[]).push({type:"paragraph_open",tight:!1,level:u++}),o.push({type:"inline",content:"",level:u,children:s[t].tokens}),o.push({type:"paragraph_close",tight:!1,level:--u})):s[t].label&&(o=h[":"+s[t].label]),e.tokens=e.tokens.concat(o),a="paragraph_close"===e.tokens[e.tokens.length-1].type?e.tokens.pop():null,i=s[t].count>0?s[t].count:1,r=0;r<i;r++)e.tokens.push({type:"footnote_anchor",id:t,subId:r,level:u});a&&e.tokens.push(a),e.tokens.push({type:"footnote_close",level:--u})}e.tokens.push({type:"footnote_block_close",level:--u})}}],["abbr2",function(e){var t,n,r,i,a,s,o,l,c,u,d,h,p=e.tokens;if(e.env.abbreviations)for(e.env.abbrRegExp||(h="(^|["+Je.split("").map(Ze).join("")+"])("+Object.keys(e.env.abbreviations).map((function(e){return e.substr(1)})).sort((function(e,t){return t.length-e.length})).map(Ze).join("|")+")($|["+Je.split("").map(Ze).join("")+"])",e.env.abbrRegExp=new RegExp(h,"g")),u=e.env.abbrRegExp,n=0,r=p.length;n<r;n++)if("inline"===p[n].type)for(t=(i=p[n].children).length-1;t>=0;t--)if("text"===(a=i[t]).type){for(l=0,s=a.content,u.lastIndex=0,c=a.level,o=[];d=u.exec(s);)u.lastIndex>l&&o.push({type:"text",content:s.slice(l,d.index+d[1].length),level:c}),o.push({type:"abbr_open",title:e.env.abbreviations[":"+d[2]],level:c++}),o.push({type:"text",content:d[2],level:c}),o.push({type:"abbr_close",level:--c}),l=u.lastIndex-d[3].length;o.length&&(l<s.length&&o.push({type:"text",content:s.slice(l),level:c}),p[n].children=i=[].concat(i.slice(0,t),o,i.slice(t+1)))}}],["replacements",function(e){var t,n,r,i,a;if(e.options.typographer)for(a=e.tokens.length-1;a>=0;a--)if("inline"===e.tokens[a].type)for(t=(i=e.tokens[a].children).length-1;t>=0;t--)"text"===(n=i[t]).type&&(r=et(r=n.content),Ye.test(r)&&(r=r.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---([^-]|$)/gm,"$1—$2").replace(/(^|\s)--(\s|$)/gm,"$1–$2").replace(/(^|[^-\s])--([^-\s]|$)/gm,"$1–$2")),n.content=r)}],["smartquotes",function(e){var t,n,r,i,a,s,o,l,c,u,d,h,p,f,m,g,v;if(e.options.typographer)for(v=[],m=e.tokens.length-1;m>=0;m--)if("inline"===e.tokens[m].type)for(g=e.tokens[m].children,v.length=0,t=0;t<g.length;t++)if("text"===(n=g[t]).type&&!tt.test(n.text)){for(o=g[t].level,p=v.length-1;p>=0&&!(v[p].level<=o);p--);v.length=p+1,a=0,s=(r=n.content).length;e:for(;a<s&&(nt.lastIndex=a,i=nt.exec(r),i);)if(l=!it(r,i.index-1),a=i.index+1,f="'"===i[0],(c=!it(r,a))||l){if(d=!c,h=!l)for(p=v.length-1;p>=0&&(u=v[p],!(v[p].level<o));p--)if(u.single===f&&v[p].level===o){u=v[p],f?(g[u.token].content=at(g[u.token].content,u.pos,e.options.quotes[2]),n.content=at(n.content,i.index,e.options.quotes[3])):(g[u.token].content=at(g[u.token].content,u.pos,e.options.quotes[0]),n.content=at(n.content,i.index,e.options.quotes[1])),v.length=p;continue e}d?v.push({token:t,pos:i.index,single:f,level:o}):h&&f&&(n.content=at(n.content,i.index,"’"))}else f&&(n.content=at(n.content,i.index,"’"))}}]];function ot(){this.options={},this.ruler=new Ue;for(var e=0;e<st.length;e++)this.ruler.push(st[e][0],st[e][1])}function lt(e,t,n,r,i){var a,s,o,l,c,u,d;for(this.src=e,this.parser=t,this.options=n,this.env=r,this.tokens=i,this.bMarks=[],this.eMarks=[],this.tShift=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.parentType="root",this.ddIndent=-1,this.level=0,this.result="",u=0,d=!1,o=l=u=0,c=(s=this.src).length;l<c;l++){if(a=s.charCodeAt(l),!d){if(32===a){u++;continue}d=!0}(10===a||l===c-1)&&(10!==a&&l++,this.bMarks.push(o),this.eMarks.push(l),this.tShift.push(u),d=!1,u=0,o=l+1)}this.bMarks.push(s.length),this.eMarks.push(s.length),this.tShift.push(0),this.lineMax=this.bMarks.length-1}function ct(e,t){var n,r,i;return(r=e.bMarks[t]+e.tShift[t])>=(i=e.eMarks[t])||42!==(n=e.src.charCodeAt(r++))&&45!==n&&43!==n||r<i&&32!==e.src.charCodeAt(r)?-1:r}function ut(e,t){var n,r=e.bMarks[t]+e.tShift[t],i=e.eMarks[t];if(r+1>=i||((n=e.src.charCodeAt(r++))<48||n>57))return-1;for(;;){if(r>=i)return-1;if(!((n=e.src.charCodeAt(r++))>=48&&n<=57)){if(41===n||46===n)break;return-1}}return r<i&&32!==e.src.charCodeAt(r)?-1:r}ot.prototype.process=function(e){var t,n,r;for(t=0,n=(r=this.ruler.getRules("")).length;t<n;t++)r[t](e)},lt.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]},lt.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e},lt.prototype.skipSpaces=function(e){for(var t=this.src.length;e<t&&32===this.src.charCodeAt(e);e++);return e},lt.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e},lt.prototype.skipCharsBack=function(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e},lt.prototype.getLines=function(e,t,n,r){var i,a,s,o,l,c=e;if(e>=t)return"";if(c+1===t)return a=this.bMarks[c]+Math.min(this.tShift[c],n),s=r?this.eMarks[c]+1:this.eMarks[c],this.src.slice(a,s);for(o=new Array(t-e),i=0;c<t;c++,i++)(l=this.tShift[c])>n&&(l=n),l<0&&(l=0),a=this.bMarks[c]+l,s=c+1<t||r?this.eMarks[c]+1:this.eMarks[c],o[i]=this.src.slice(a,s);return o.join("")};var dt={};["article","aside","button","blockquote","body","canvas","caption","col","colgroup","dd","div","dl","dt","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","iframe","li","map","object","ol","output","p","pre","progress","script","section","style","table","tbody","td","textarea","tfoot","th","tr","thead","ul","video"].forEach((function(e){dt[e]=!0}));var ht=/^<([a-zA-Z]{1,15})[\s\/>]/,pt=/^<\/([a-zA-Z]{1,15})[\s>]/;function ft(e,t){var n=e.bMarks[t]+e.blkIndent,r=e.eMarks[t];return e.src.substr(n,r-n)}function mt(e,t){var n,r,i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];return i>=a||126!==(r=e.src.charCodeAt(i++))&&58!==r||i===(n=e.skipSpaces(i))||n>=a?-1:n}var gt=[["code",function(e,t,n){var r,i;if(e.tShift[t]-e.blkIndent<4)return!1;for(i=r=t+1;r<n;)if(e.isEmpty(r))r++;else{if(!(e.tShift[r]-e.blkIndent>=4))break;i=++r}return e.line=r,e.tokens.push({type:"code",content:e.getLines(t,i,4+e.blkIndent,!0),block:!0,lines:[t,e.line],level:e.level}),!0}],["fences",function(e,t,n,r){var i,a,s,o,l,c=!1,u=e.bMarks[t]+e.tShift[t],d=e.eMarks[t];if(u+3>d||126!==(i=e.src.charCodeAt(u))&&96!==i||(l=u,(a=(u=e.skipChars(u,i))-l)<3)||(s=e.src.slice(u,d).trim()).indexOf("`")>=0)return!1;if(r)return!0;for(o=t;!(++o>=n||(u=l=e.bMarks[o]+e.tShift[o],d=e.eMarks[o],u<d&&e.tShift[o]<e.blkIndent));)if(!(e.src.charCodeAt(u)!==i||e.tShift[o]-e.blkIndent>=4||(u=e.skipChars(u,i),u-l<a||(u=e.skipSpaces(u),u<d)))){c=!0;break}return a=e.tShift[t],e.line=o+(c?1:0),e.tokens.push({type:"fence",params:s,content:e.getLines(t+1,o,a,!0),lines:[t,e.line],level:e.level}),!0},["paragraph","blockquote","list"]],["blockquote",function(e,t,n,r){var i,a,s,o,l,c,u,d,h,p,f,m=e.bMarks[t]+e.tShift[t],g=e.eMarks[t];if(m>g||62!==e.src.charCodeAt(m++)||e.level>=e.options.maxNesting)return!1;if(r)return!0;for(32===e.src.charCodeAt(m)&&m++,l=e.blkIndent,e.blkIndent=0,o=[e.bMarks[t]],e.bMarks[t]=m,a=(m=m<g?e.skipSpaces(m):m)>=g,s=[e.tShift[t]],e.tShift[t]=m-e.bMarks[t],d=e.parser.ruler.getRules("blockquote"),i=t+1;i<n&&!((m=e.bMarks[i]+e.tShift[i])>=(g=e.eMarks[i]));i++)if(62!==e.src.charCodeAt(m++)){if(a)break;for(f=!1,h=0,p=d.length;h<p;h++)if(d[h](e,i,n,!0)){f=!0;break}if(f)break;o.push(e.bMarks[i]),s.push(e.tShift[i]),e.tShift[i]=-1337}else 32===e.src.charCodeAt(m)&&m++,o.push(e.bMarks[i]),e.bMarks[i]=m,a=(m=m<g?e.skipSpaces(m):m)>=g,s.push(e.tShift[i]),e.tShift[i]=m-e.bMarks[i];for(c=e.parentType,e.parentType="blockquote",e.tokens.push({type:"blockquote_open",lines:u=[t,0],level:e.level++}),e.parser.tokenize(e,t,i),e.tokens.push({type:"blockquote_close",level:--e.level}),e.parentType=c,u[1]=e.line,h=0;h<s.length;h++)e.bMarks[h+t]=o[h],e.tShift[h+t]=s[h];return e.blkIndent=l,!0},["paragraph","blockquote","list"]],["hr",function(e,t,n,r){var i,a,s,o=e.bMarks[t],l=e.eMarks[t];if((o+=e.tShift[t])>l||42!==(i=e.src.charCodeAt(o++))&&45!==i&&95!==i)return!1;for(a=1;o<l;){if((s=e.src.charCodeAt(o++))!==i&&32!==s)return!1;s===i&&a++}return!(a<3)&&(r||(e.line=t+1,e.tokens.push({type:"hr",lines:[t,e.line],level:e.level})),!0)},["paragraph","blockquote","list"]],["list",function(e,t,n,r){var i,a,s,o,l,c,u,d,h,p,f,m,g,v,y,b,_,w,k,S,x,E=!0;if((d=ut(e,t))>=0)m=!0;else{if(!((d=ct(e,t))>=0))return!1;m=!1}if(e.level>=e.options.maxNesting)return!1;if(f=e.src.charCodeAt(d-1),r)return!0;for(v=e.tokens.length,m?(u=e.bMarks[t]+e.tShift[t],p=Number(e.src.substr(u,d-u-1)),e.tokens.push({type:"ordered_list_open",order:p,lines:b=[t,0],level:e.level++})):e.tokens.push({type:"bullet_list_open",lines:b=[t,0],level:e.level++}),i=t,y=!1,w=e.parser.ruler.getRules("list");i<n&&((h=(g=e.skipSpaces(d))>=e.eMarks[i]?1:g-d)>4&&(h=1),h<1&&(h=1),a=d-e.bMarks[i]+h,e.tokens.push({type:"list_item_open",lines:_=[t,0],level:e.level++}),o=e.blkIndent,l=e.tight,s=e.tShift[t],c=e.parentType,e.tShift[t]=g-e.bMarks[t],e.blkIndent=a,e.tight=!0,e.parentType="list",e.parser.tokenize(e,t,n,!0),(!e.tight||y)&&(E=!1),y=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=o,e.tShift[t]=s,e.tight=l,e.parentType=c,e.tokens.push({type:"list_item_close",level:--e.level}),i=t=e.line,_[1]=i,g=e.bMarks[t],!(i>=n||e.isEmpty(i)||e.tShift[i]<e.blkIndent));){for(x=!1,k=0,S=w.length;k<S;k++)if(w[k](e,i,n,!0)){x=!0;break}if(x)break;if(m){if((d=ut(e,i))<0)break}else if((d=ct(e,i))<0)break;if(f!==e.src.charCodeAt(d-1))break}return e.tokens.push({type:m?"ordered_list_close":"bullet_list_close",level:--e.level}),b[1]=i,e.line=i,E&&function(e,t){var n,r,i=e.level+2;for(n=t+2,r=e.tokens.length-2;n<r;n++)e.tokens[n].level===i&&"paragraph_open"===e.tokens[n].type&&(e.tokens[n+2].tight=!0,e.tokens[n].tight=!0,n+=2)}(e,v),!0},["paragraph","blockquote"]],["footnote",function(e,t,n,r){var i,a,s,o,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(c+4>u||91!==e.src.charCodeAt(c)||94!==e.src.charCodeAt(c+1)||e.level>=e.options.maxNesting)return!1;for(o=c+2;o<u;o++){if(32===e.src.charCodeAt(o))return!1;if(93===e.src.charCodeAt(o))break}return!(o===c+2||o+1>=u||58!==e.src.charCodeAt(++o))&&(r||(o++,e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.refs||(e.env.footnotes.refs={}),l=e.src.slice(c+2,o-2),e.env.footnotes.refs[":"+l]=-1,e.tokens.push({type:"footnote_reference_open",label:l,level:e.level++}),i=e.bMarks[t],a=e.tShift[t],s=e.parentType,e.tShift[t]=e.skipSpaces(o)-o,e.bMarks[t]=o,e.blkIndent+=4,e.parentType="footnote",e.tShift[t]<e.blkIndent&&(e.tShift[t]+=e.blkIndent,e.bMarks[t]-=e.blkIndent),e.parser.tokenize(e,t,n,!0),e.parentType=s,e.blkIndent-=4,e.tShift[t]=a,e.bMarks[t]=i,e.tokens.push({type:"footnote_reference_close",level:--e.level})),!0)},["paragraph"]],["heading",function(e,t,n,r){var i,a,s,o=e.bMarks[t]+e.tShift[t],l=e.eMarks[t];if(o>=l||(35!==(i=e.src.charCodeAt(o))||o>=l))return!1;for(a=1,i=e.src.charCodeAt(++o);35===i&&o<l&&a<=6;)a++,i=e.src.charCodeAt(++o);return!(a>6||o<l&&32!==i)&&(r||(l=e.skipCharsBack(l,32,o),(s=e.skipCharsBack(l,35,o))>o&&32===e.src.charCodeAt(s-1)&&(l=s),e.line=t+1,e.tokens.push({type:"heading_open",hLevel:a,lines:[t,e.line],level:e.level}),o<l&&e.tokens.push({type:"inline",content:e.src.slice(o,l).trim(),level:e.level+1,lines:[t,e.line],children:[]}),e.tokens.push({type:"heading_close",hLevel:a,level:e.level})),!0)},["paragraph","blockquote"]],["lheading",function(e,t,n){var r,i,a,s=t+1;return!(s>=n||e.tShift[s]<e.blkIndent||e.tShift[s]-e.blkIndent>3||(i=e.bMarks[s]+e.tShift[s],a=e.eMarks[s],i>
2=a)||(r=e.src.charCodeAt(i),45!==r&&61!==r)||(i=e.skipChars(i,r),i=e.skipSpaces(i),i<a))&&(i=e.bMarks[t]+e.tShift[t],e.line=s+1,e.tokens.push({type:"heading_open",hLevel:61===r?1:2,lines:[t,e.line],level:e.level}),e.tokens.push({type:"inline",content:e.src.slice(i,e.eMarks[t]).trim(),level:e.level+1,lines:[t,e.line-1],children:[]}),e.tokens.push({type:"heading_close",hLevel:61===r?1:2,level:e.level}),!0)}],["htmlblock",function(e,t,n,r){var i,a,s,o=e.bMarks[t],l=e.eMarks[t],c=e.tShift[t];if(o+=c,!e.options.html||c>3||o+2>=l||60!==e.src.charCodeAt(o))return!1;if(33===(i=e.src.charCodeAt(o+1))||63===i){if(r)return!0}else{if(47!==i&&!function(e){var t=32|e;return t>=97&&t<=122}(i))return!1;if(47===i){if(!(a=e.src.slice(o,l).match(pt)))return!1}else if(!(a=e.src.slice(o,l).match(ht)))return!1;if(!0!==dt[a[1].toLowerCase()])return!1;if(r)return!0}for(s=t+1;s<e.lineMax&&!e.isEmpty(s);)s++;return e.line=s,e.tokens.push({type:"htmlblock",level:e.level,lines:[t,e.line],content:e.getLines(t,s,0,!0)}),!0},["paragraph","blockquote"]],["table",function(e,t,n,r){var i,a,s,o,l,c,u,d,h,p,f;if(t+2>n||(l=t+1,e.tShift[l]<e.blkIndent)||(s=e.bMarks[l]+e.tShift[l])>=e.eMarks[l]||124!==(i=e.src.charCodeAt(s))&&45!==i&&58!==i||(a=ft(e,t+1),!/^[-:| ]+$/.test(a))||(c=a.split("|"))<=2)return!1;for(d=[],o=0;o<c.length;o++){if(!(h=c[o].trim())){if(0===o||o===c.length-1)continue;return!1}if(!/^:?-+:?$/.test(h))return!1;
vendor: 12,485 bytes, line 2
258===h.charCodeAt(h.length-1)?d.push(58===h.charCodeAt(0)?"center":"right"):58===h.charCodeAt(0)?d.push("left"):d.push("")}if(-1===(a=ft(e,t).trim()).indexOf("|")||(c=a.replace(/^\||\|$/g,"").split("|"),d.length!==c.length))return!1;if(r)return!0;for(e.tokens.push({type:"table_open",lines:p=[t,0],level:e.level++}),e.tokens.push({type:"thead_open",lines:[t,t+1],level:e.level++}),e.tokens.push({type:"tr_open",lines:[t,t+1],level:e.level++}),o=0;o<c.length;o++)e.tokens.push({type:"th_open",align:d[o],lines:[t,t+1],level:e.level++}),e.tokens.push({type:"inline",content:c[o].trim(),lines:[t,t+1],level:e.level,children:[]}),e.tokens.push({type:"th_close",level:--e.level});for(e.tokens.push({type:"tr_close",level:--e.level}),e.tokens.push({type:"thead_close",level:--e.level}),e.tokens.push({type:"tbody_open",lines:f=[t+2,0],level:e.level++}),l=t+2;l<n&&!(e.tShift[l]<e.blkIndent||(a=ft(e,l).trim(),-1===a.indexOf("|")));l++){for(c=a.replace(/^\||\|$/g,"").split("|"),e.tokens.push({type:"tr_open",level:e.level++}),o=0;o<c.length;o++)e.tokens.push({type:"td_open",align:d[o],level:e.level++}),u=c[o].substring(124===c[o].charCodeAt(0)?1:0,124===c[o].charCodeAt(c[o].length-1)?c[o].length-1:c[o].length).trim(),e.tokens.push({type:"inline",content:u,level:e.level,children:[]}),e.tokens.push({type:"td_close",level:--e.level});e.tokens.push({type:"tr_close",level:--e.level})}return e.tokens.push({type:"tbody_close",level:--e.level}),e.tokens.push({type:"table_close",level:--e.level}),p[1]=f[1]=l,e.line=l,!0},["paragraph"]],["deflist",function(e,t,n,r){var i,a,s,o,l,c,u,d,h,p,f,m,g,v;if(r)return!(e.ddIndent<0)&&mt(e,t)>=0;if(u=t+1,e.isEmpty(u)&&++u>n||e.tShift[u]<e.blkIndent||(i=mt(e,u))<0||e.level>=e.options.maxNesting)return!1;c=e.tokens.length,e.tokens.push({type:"dl_open",lines:l=[t,0],level:e.level++}),s=t,a=u;e:for(;;){for(v=!0,g=!1,e.tokens.push({type:"dt_open",lines:[s,s],level:e.level++}),e.tokens.push({type:"inline",content:e.getLines(s,s+1,e.blkIndent,!1).trim(),level:e.level+1,lines:[s,s],children:[]}),e.tokens.push({type:"dt_close",level:--e.level});;){if(e.tokens.push({type:"dd_open",lines:o=[u,0],level:e.level++}),m=e.tight,h=e.ddIndent,d=e.blkIndent,f=e.tShift[a],p=e.parentType,e.blkIndent=e.ddIndent=e.tShift[a]+2,e.tShift[a]=i-e.bMarks[a],e.tight=!0,e.parentType="deflist",e.parser.tokenize(e,a,n,!0),(!e.tight||g)&&(v=!1),g=e.line-a>1&&e.isEmpty(e.line-1),e.tShift[a]=f,e.tight=m,e.parentType=p,e.blkIndent=d,e.ddIndent=h,e.tokens.push({type:"dd_close",level:--e.level}),o[1]=u=e.line,u>=n||e.tShift[u]<e.blkIndent)break e;if((i=mt(e,u))<0)break;a=u}if(u>=n||(s=u,e.isEmpty(s))||e.tShift[s]<e.blkIndent||(a=s+1)>=n||(e.isEmpty(a)&&a++,a>=n)||e.tShift[a]<e.blkIndent||(i=mt(e,a))<0)break}return e.tokens.push({type:"dl_close",level:--e.level}),l[1]=u,e.line=u,v&&function(e,t){var n,r,i=e.level+2;for(n=t+2,r=e.tokens.length-2;n<r;n++)e.tokens[n].level===i&&"paragraph_open"===e.tokens[n].type&&(e.tokens[n+2].tight=!0,e.tokens[n].tight=!0,n+=2)}(e,c),!0},["paragraph"]],["paragraph",function(e,t){var n,r,i,a,s,o,l=t+1;if(l<(n=e.lineMax)&&!e.isEmpty(l))for(o=e.parser.ruler.getRules("paragraph");l<n&&!e.isEmpty(l);l++)if(!(e.tShift[l]-e.blkIndent>3)){for(i=!1,a=0,s=o.length;a<s;a++)if(o[a](e,l,n,!0)){i=!0;break}if(i)break}return r=e.getLines(t,l,e.blkIndent,!1).trim(),e.line=l,r.length&&(e.tokens.push({type:"paragraph_open",tight:!1,lines:[t,e.line],level:e.level}),e.tokens.push({type:"inline",content:r,level:e.level+1,lines:[t,e.line],children:[]}),e.tokens.push({type:"paragraph_close",tight:!1,level:e.level})),!0}]];function vt(){this.ruler=new Ue;for(var e=0;e<gt.length;e++)this.ruler.push(gt[e][0],gt[e][1],{alt:(gt[e][2]||[]).slice()})}vt.prototype.tokenize=function(e,t,n){for(var r,i=this.ruler.getRules(""),a=i.length,s=t,o=!1;s<n&&(e.line=s=e.skipEmptyLines(s),!(s>=n||e.tShift[s]<e.blkIndent));){for(r=0;r<a&&!i[r](e,s,n,!1);r++);if(e.tight=!o,e.isEmpty(e.line-1)&&(o=!0),(s=e.line)<n&&e.isEmpty(s)){if(o=!0,++s<n&&"list"===e.parentType&&e.isEmpty(s))break;e.line=s}}};var yt=/[\n\t]/g,bt=/\r[\n\u0085]|[\u2424\u2028\u0085]/g,_t=/\u00a0/g;function wt(e){switch(e){case 10:case 92:case 96:case 42:case 95:case 94:case 91:case 93:case 33:case 38:case 60:case 62:case 123:case 125:case 36:case 37:case 64:case 126:case 43:case 61:case 58:return!0;default:return!1}}vt.prototype.parse=function(e,t,n,r){var i,a=0,s=0;if(!e)return[];(e=(e=e.replace(_t," ")).replace(bt,"\n")).indexOf("\t")>=0&&(e=e.replace(yt,(function(t,n){var r;return 10===e.charCodeAt(n)?(a=n+1,s=0,t):(r="    ".slice((n-a-s)%4),s=n-a+1,r)}))),i=new lt(e,this,t,n,r),this.tokenize(i,i.line,i.lineMax)};for(var kt=[],St=0;St<256;St++)kt.push(0);function xt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122}function Et(e,t){var n,r,i,a=t,s=!0,o=!0,l=e.posMax,c=e.src.charCodeAt(t);for(n=t>0?e.src.charCodeAt(t-1):-1;a<l&&e.src.charCodeAt(a)===c;)a++;return a>=l&&(s=!1),(i=a-t)>=4?s=o=!1:((32===(r=a<l?e.src.charCodeAt(a):-1)||10===r)&&(s=!1),(32===n||10===n)&&(o=!1),95===c&&(xt(n)&&(s=!1),xt(r)&&(o=!1))),{can_open:s,can_close:o,delims:i}}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(e){kt[e.charCodeAt(0)]=1}));var Ct=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;var Tt=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;var At=["coap","doi","javascript","aaa","aaas","about","acap","cap","cid","crid","data","dav","dict","dns","file","ftp","geo","go","gopher","h323","http","https","iax","icap","im","imap","info","ipp","iris","iris.beep","iris.xpc","iris.xpcs","iris.lwz","ldap","mailto","mid","msrp","msrps","mtqp","mupdate","news","nfs","ni","nih","nntp","opaquelocktoken","pop","pres","rtsp","service","session","shttp","sieve","sip","sips","sms","snmp","soap.beep","soap.beeps","tag","tel","telnet","tftp","thismessage","tn3270","tip","tv","urn","vemmi","ws","wss","xcon","xcon-userid","xmlrpc.beep","xmlrpc.beeps","xmpp","z39.50r","z39.50s","adiumxtra","afp","afs","aim","apt","attachment","aw","beshare","bitcoin","bolo","callto","chrome","chrome-extension","com-eventbrite-attendee","content","cvs","dlna-playsingle","dlna-playcontainer","dtn","dvb","ed2k","facetime","feed","finger","fish","gg","git","gizmoproject","gtalk","hcp","icon","ipn","irc","irc6","ircs","itms","jar","jms","keyparc","lastfm","ldaps","magnet","maps","market","message","mms","ms-help","msnim","mumble","mvn","notes","oid","palm","paparazzi","platform","proxy","psyc","query","res","resource","rmi","rsync","rtmp","secondlife","sftp","sgn","skype","smb","soldat","spotify","ssh","steam","svn","teamspeak","things","udp","unreal","ut2004","ventrilo","view-source","webcal","wtai","wyciwyg","xfire","xri","ymsgr"],Mt=/^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/,It=/^<([a-zA-Z.\-]{1,25}):([^<>\x00-\x20]*)>/;function Lt(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,e=e.replace(r,i),n):new RegExp(e,t)}}var Ot=Lt(/(?:unquoted|single_quoted|double_quoted)/)("unquoted",/[^"'=<>`\x00-\x20]+/)("single_quoted",/'[^']*'/)("double_quoted",/"[^"]*"/)(),Rt=Lt(/(?:\s+attr_name(?:\s*=\s*attr_value)?)/)("attr_name",/[a-zA-Z_:][a-zA-Z0-9:._-]*/)("attr_value",Ot)(),Pt=Lt(/<[A-Za-z][A-Za-z0-9]*attribute*\s*\/?>/)("attribute",Rt)(),Nt=Lt(/^(?:open_tag|close_tag|comment|processing|declaration|cdata)/)("open_tag",Pt)("close_tag",/<\/[A-Za-z][A-Za-z0-9]*\s*>/)("comment",/<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->/)("processing",/<[?].*?[?]>/)("declaration",/<![A-Z]+\s+[^>]*>/)("cdata",/<!\[CDATA\[[\s\S]*?\]\]>/)();var jt=/^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i,Dt=/^&([a-z][a-z0-9]{1,31});/i;var Bt=[["text",function(e,t){for(var n=e.pos;n<e.posMax&&!wt(e.src.charCodeAt(n));)n++;return n!==e.pos&&(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}],["newline",function(e,t){var n,r,i=e.pos;if(10!==e.src.charCodeAt(i))return!1;if(n=e.pending.length-1,r=e.posMax,!t)if(n>=0&&32===e.pending.charCodeAt(n))if(n>=1&&32===e.pending.charCodeAt(n-1)){for(var a=n-2;a>=0;a--)if(32!==e.pending.charCodeAt(a)){e.pending=e.pending.substring(0,a+1);break}e.push({type:"hardbreak",level:e.level})}else e.pending=e.pending.slice(0,-1),e.push({type:"softbreak",level:e.level});else e.push({type:"softbreak",level:e.level});for(i++;i<r&&32===e.src.charCodeAt(i);)i++;return e.pos=i,!0}],["escape",function(e,t){var n,r=e.pos,i=e.posMax;if(92!==e.src.charCodeAt(r))return!1;if(++r<i){if((n=e.src.charCodeAt(r))<256&&0!==kt[n])return t||(e.pending+=e.src[r]),e.pos+=2,!0;if(10===n){for(t||e.push({type:"hardbreak",level:e.level}),r++;r<i&&32===e.src.charCodeAt(r);)r++;return e.pos=r,!0}}return t||(e.pending+="\\"),e.pos++,!0}],["backticks",function(e,t){var n,r,i,a,s,o=e.pos;if(96!==e.src.charCodeAt(o))return!1;for(n=o,o++,r=e.posMax;o<r&&96===e.src.charCodeAt(o);)o++;for(i=e.src.slice(n,o),a=s=o;-1!==(a=e.src.indexOf("`",s));){for(s=a+1;s<r&&96===e.src.charCodeAt(s);)s++;if(s-a===i.length)return t||e.push({type:"code",content:e.src.slice(o,a).replace(/[ \n]+/g," ").trim(),block:!1,level:e.level}),e.pos=s,!0}return t||(e.pending+=i),e.pos+=i.length,!0}],["del",function(e,t){var n,r,i,a,s,o=e.posMax,l=e.pos;if(126!==e.src.charCodeAt(l)||t||l+4>=o||126!==e.src.charCodeAt(l+1)||e.level>=e.options.maxNesting||(a=l>0?e.src.charCodeAt(l-1):-1,s=e.src.charCodeAt(l+2),126===a)||126===s||32===s||10===s)return!1;for(r=l+2;r<o&&126===e.src.charCodeAt(r);)r++;if(r>l+3)return e.pos+=r-l,t||(e.pending+=e.src.slice(l,r)),!0;for(e.pos=l+2,i=1;e.pos+1<o;){if(126===e.src.charCodeAt(e.pos)&&126===e.src.charCodeAt(e.pos+1)&&(a=e.src.charCodeAt(e.pos-1),126!==(s=e.pos+2<o?e.src.charCodeAt(e.pos+2):-1)&&126!==a&&(32!==a&&10!==a?i--:32!==s&&10!==s&&i++,i<=0))){n=!0;break}e.parser.skipToken(e)}return n?(e.posMax=e.pos,e.pos=l+2,t||(e.push({type:"del_open",level:e.level++}),e.parser.tokenize(e),e.push({type:"del_close",level:--e.level})),e.pos=e.posMax+2,e.posMax=o,!0):(e.pos=l,!1)}],["ins",function(e,t){var n,r,i,a,s,o=e.posMax,l=e.pos;if(43!==e.src.charCodeAt(l)||t||l+4>=o||43!==e.src.charCodeAt(l+1)||e.level>=e.options.maxNesting||(a=l>0?e.src.charCodeAt(l-1):-1,s=e.src.charCodeAt(l+2),43===a)||43===s||32===s||10===s)return!1;for(r=l+2;r<o&&43===e.src.charCodeAt(r);)r++;if(r!==l+2)return e.pos+=r-l,t||(e.pending+=e.src.slice(l,r)),!0;for(e.pos=l+2,i=1;e.pos+1<o;){if(43===e.src.charCodeAt(e.pos)&&43===e.src.charCodeAt(e.pos+1)&&(a=e.src.charCodeAt(e.pos-1),43!==(s=e.pos+2<o?e.src.charCodeAt(e.pos+2):-1)&&43!==a&&(32!==a&&10!==a?i--:32!==s&&10!==s&&i++,i<=0))){n=!0;break}e.parser.skipToken(e)}return n?(e.posMax=e.pos,e.pos=l+2,t||(e.push({type:"ins_open",level:e.level++}),e.parser.tokenize(e),e.push({type:"ins_close",level:--e.level})),e.pos=e.posMax+2,e.posMax=o,!0):(e.pos=l,!1)}],["mark",function(e,t){var n,r,i,a,s,o=e.posMax,l=e.pos;if(61!==e.src.charCodeAt(l)||t||l+4>=o||61!==e.src.charCodeAt(l+1)||e.level>=e.options.maxNesting||(a=l>0?e.src.charCodeAt(l-1):-1,s=e.src.charCodeAt(l+2),61===a)||61===s||32===s||10===s)return!1;for(r=l+2;r<o&&61===e.src.charCodeAt(r);)r++;if(r!==l+2)return e.pos+=r-l,t||(e.pending+=e.src.slice(l,r)),!0;for(e.pos=l+2,i=1;e.pos+1<o;){if(61===e.src.charCodeAt(e.pos)&&61===e.src.charCodeAt(e.pos+1)&&(a=e.src.charCodeAt(e.pos-1),61!==(s=e.pos+2<o?e.src.charCodeAt(e.pos+2):-1)&&61!==a&&(32!==a&&10!==a?i--:32!==s&&10!==s&&i++,i<=0))){n=!0;break}e.parser.skipToken(e)}return n?(e.posMax=e.pos,e.pos=l+2,t||(e.push({type:"mark_open",level:e.level++}),e.parser.tokenize(e),e.push({type:"mark_close",level:--e.level})),e.pos=e.posMax+2,e.posMax=o,!0):(e.pos=l,!1)}],["emphasis",function(e,t){var n,r,i,a,s,o,l,c=e.posMax,u=e.pos,d=e.src.charCodeAt(u);if(95!==d&&42!==d||t)return!1;if(n=(l=Et(e,u)).delims,!l.can_open)return e.pos+=n,t||(e.pending+=e.src.slice(u,e.pos)),!0;if(e.level>=e.options.maxNesting)return!1;for(e.pos=u+n,o=[n];e.pos<c;)if(e.src.charCodeAt(e.pos)!==d)e.parser.skipToken(e);else{if(r=(l=Et(e,e.pos)).delims,l.can_close){for(a=o.pop(),s=r;a!==s;){if(s<a){o.push(a-s);break}if(s-=a,0===o.length)break;e.pos+=a,a=o.pop()}if(0===o.length){n=a,i=!0;break}e.pos+=r;continue}l.can_open&&o.push(r),e.pos+=r}return i?(e.posMax=e.pos,e.pos=u+n,t||((2===n||3===n)&&e.push({type:"strong_open",level:e.level++}),(1===n||3===n)&&e.push({type:"em_open",level:e.level++}),e.parser.tokenize(e),(1===n||3===n)&&e.push({type:"em_close",level:--e.level}),(2===n||3===n)&&e.push({type:"strong_close",level:--e.level})),e.pos=e.posMax+n,e.posMax=c,!0):(e.pos=u,!1)}],["sub",function(e,t){var n,r,i=e.posMax,a=e.pos;
2if(126!==e.src.charCodeAt(a)||t||a+2>=i||e.level>=e.options.maxNesting)return!1;for(e.pos=a+1;e.pos<i;){if(126===e.src.charCodeAt(e.pos)){n=!0;break}e.parser.skipToken(e)}return!n||a+1===e.pos||(r=e.src.slice(a+1,e.pos)).match(/(^|[^\\])(\\\\)*\s/)?(e.pos=a,!1):(e.posMax=e.pos,e.pos=a+1,t||e.push({type:"sub",level:e.level,content:r.replace(Ct,"$1")}),e.pos=e.posMax+1,e.posMax=i,!0)}],["sup",function(e,t){var n,r,i=e.posMax,a=e.pos;if(94!==e.src.charCodeAt(a)||t||a+2>=i||e.level>=e.options.maxNesting)return!1;for(e.pos=a+1;e.pos<i;){if(94===e.src.charCodeAt(e.pos)){n=!0;break}e.parser.skipToken(e)}return!n||a+1===e.pos||(r=e.src.slice(a+1,e.pos)).match(/(^|[^\\])(\\\\)*\s/)?(e.pos=a,!1):(e.posMax=e.pos,e.pos=a+1,t||e.push({type:"sup",level:e.level,content:r.replace(Tt,"$1")}),e.pos=e.posMax+1,e.posMax=i,!0)}],["links",function(e,t){var n,r,i,a,s,o,l,c,u=!1,d=e.pos,h=e.posMax,p=e.pos,f=e.src.charCodeAt(p);if(33===f&&(u=!0,f=e.src.charCodeAt(++p)),91!==f||e.level>=e.options.maxNesting||(n=p+1,(r=qe(e,p))<0))return!1;if((o=r+1)<h&&40===e.src.charCodeAt(o)){for(o++;o<h&&(32===(c=e.src.charCodeAt(o))||10===c);o++);if(o>=h)return!1;for(p=o,Ge(e,o)?(a=e.linkContent,o=e.pos):a="",p=o;o<h&&(32===(c=e.src.charCodeAt(o))||10===c);o++);if(o<h&&p!==o&&We(e,o))for(s=e.linkContent,o=e.pos;o<h&&(32===(c=e.src.charCodeAt(o))||10===c);o++);else s="";if(o>=h||41!==e.src.charCodeAt(o))return e.pos=d,!1;o++}else{if(e.linkLevel>0)return!1;for(;o<h&&(32===(c=e.src.charCodeAt(o))||10===c);o++);if(o<h&&91===e.src.charCodeAt(o)&&(p=o+1,(o=qe(e,o))>=0?i=e.src.slice(p,o++):o=p-1),i||(O(i)>"u"&&(o=r+1),i=e.src.slice(n,r)),!(l=e.env.references[$e(i)]))return e.pos=d,!1;a=l.href,s=l.title}return t||(e.pos=n,e.posMax=r,u?e.push({type:"image",src:a,title:s,alt:e.src.substr(n,r-n),level:e.level}):(e.push({type:"link_open",href:a,title:s,level:e.level++}),e.linkLevel++,e.parser.tokenize(e),e.linkLevel--,e.push({type:"link_close",level:--e.level}))),e.pos=o,e.posMax=h,!0}],["footnote_inline",function(e,t){var n,r,i,a,s=e.posMax,o=e.pos;return!(o+2>=s||94!==e.src.charCodeAt(o)||91!==e.src.charCodeAt(o+1)||e.level>=e.options.maxNesting||(n=o+2,r=qe(e,o+1),r<0))&&(t||(e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.list||(e.env.footnotes.list=[]),i=e.env.footnotes.list.length,e.pos=n,e.posMax=r,e.push({type:"footnote_ref",id:i,level:e.level}),e.linkLevel++,a=e.tokens.length,e.parser.tokenize(e),e.env.footnotes.list[i]={tokens:e.tokens.splice(a)},e.linkLevel--),e.pos=r+1,e.posMax=s,!0)}],["footnote_ref",function(e,t){var n,r,i,a,s=e.posMax,o=e.pos;if(o+3>s||!e.env.footnotes||!e.env.footnotes.refs||91!==e.src.charCodeAt(o)||94!==e.src.charCodeAt(o+1)||e.level>=e.options.maxNesting)return!1;for(r=o+2;r<s;r++){if(32===e.src.charCodeAt(r)||10===e.src.charCodeAt(r))return!1;if(93===e.src.charCodeAt(r))break}return!(r===o+2||r>=s||(r++,n=e.src.slice(o+2,r-1),O(e.env.footnotes.refs[":"+n])>"u"))&&(t||(e.env.footnotes.list||(e.env.footnotes.list=[]),e.env.footnotes.refs[":"+n]<0?(i=e.env.footnotes.list.length,e.env.footnotes.list[i]={label:n,count:0},e.env.footnotes.refs[":"+n]=i):i=e.env.footnotes.refs[":"+n],a=e.env.footnotes.list[i].count,e.env.footnotes.list[i].count++,e.push({type:"footnote_ref",id:i,subId:a,level:e.level})),e.pos=r,e.posMax=s,!0)}],["autolink",function(e,t){var n,r,i,a,s,o=e.pos;return!(60!==e.src.charCodeAt(o)||(n=e.src.slice(o),n.indexOf(">")<0))&&((r=n.match(It))?!(At.indexOf(r[1].toLowerCase())<0||(a=r[0].slice(1,-1),s=Ve(a),!e.parser.validateLink(a)))&&(t||(e.push({type:"link_open",href:s,level:e.level}),e.push({type:"text",content:a,level:e.level+1}),e.push({type:"link_close",level:e.level})),e.pos+=r[0].length,!0):!!(i=n.match(Mt))&&(s=Ve("mailto:"+(a=i[0].slice(1,-1))),!!e.parser.validateLink(s)&&(t||(e.push({type:"link_open",href:s,level:e.level}),e.push({type:"text",content:a,level:e.level+1}),e.push({type:"link_close",level:e.level})),e.pos+=i[0].length,!0)))}],["htmltag",function(e,t){var n,r,i,a=e.pos;return!(!e.options.html||(i=e.posMax,60!==e.src.charCodeAt(a)||a+2>=i)||(n=e.src.charCodeAt(a+1),33!==n&&63!==n&&47!==n&&!function(e){var t=32|e;return t>=97&&t<=122}(n))||(r=e.src.slice(a).match(Nt),!r))&&(t||e.push({type:"htmltag",content:e.src.slice(a,a+r[0].length),level:e.level}),e.pos+=r[0].length,!0)}],["entity",function(e,t){var n,r,i=e.pos,a=e.posMax;
2if(38!==e.src.charCodeAt(i))return!1;if(i+1<a)if(35===e.src.charCodeAt(i+1)){if(r=e.src.slice(i).match(jt))return t||(n="x"===r[1][0].toLowerCase()?parseInt(r[1].slice(1),16):parseInt(r[1],10),e.pending+=Ee(n)?Ce(n):Ce(65533)),e.pos+=r[0].length,!0}else if(r=e.src.slice(i).match(Dt)){var s=_e(r[1]);if(r[1]!==s)return t||(e.pending+=s),e.pos+=r[0].length,!0}return t||(e.pending+="&"),e.pos++,!0}]];function Ft(){this.ruler=new Ue;for(var e=0;e<Bt.length;e++)this.ruler.push(Bt[e][0],Bt[e][1]);this.validateLink=Ut}function Ut(e){var t=e.trim().toLowerCase();return!(-1!==(t=Ie(t)).indexOf(":")&&-1!==["vbscript","javascript","file","data"].indexOf(t.split(":")[0]))}Ft.prototype.skipToken=function(e){var t,n,r=this.ruler.getRules(""),i=r.length,a=e.pos;if((n=e.cacheGet(a))>0)e.pos=n;else{for(t=0;t<i;t++)if(r[t](e,!0))return void e.cacheSet(a,e.pos);e.pos++,e.cacheSet(a,e.pos)}},Ft.prototype.tokenize=function(e){for(var t,n,r=this.ruler.getRules(""),i=r.length,a=e.posMax;e.pos<a;){for(n=0;n<i&&!(t=r[n](e,!1));n++);if(t){if(e.pos>=a)break}else e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()},Ft.prototype.parse=function(e,t,n,r){var i=new ze(e,this,t,n,r);this.tokenize(i)};var zt={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkTarget:"",typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["block","inline","references","replacements","smartquotes","references","abbr2","footnote_tail"]},block:{rules:["blockquote","code","fences","footnote","heading","hr","htmlblock","lheading","list","paragraph","table"]},inline:{rules:["autolink","backticks","del","emphasis","entity","escape","footnote_ref","htmltag","links","newline","text"]}}},full:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkTarget:"",typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{},block:{},inline:{}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkTarget:"",typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["block","inline","references","abbr2"]},block:{rules:["blockquote","code","fences","heading","hr","htmlblock","lheading","list","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","htmltag","links","newline","text"]}}}};function qt(e,t,n){this.src=t,this.env=n,this.options=e.options,this.tokens=[],this.inlineMode=!1,this.inline=e.inline,this.block=e.block,this.renderer=e.renderer,this.typographer=e.typographer}function Ht(e,t){"string"!=typeof e&&(t=e,e="default"),t&&null!=t.linkify&&console.warn("linkify option is removed. Use linkify plugin instead:\n\nimport Remarkable from 'remarkable';\nimport linkify from 'remarkable/linkify';\nnew Remarkable().use(linkify)\n"),this.inline=new Ft,this.block=new vt,this.core=new ot,this.renderer=new Fe,this.ruler=new Ue,this.options={},this.configure(zt[e]),this.set(t||{})}Ht.prototype.set=function(e){ke(this.options,e)},Ht.prototype.configure=function(e){var t=this;if(!e)throw new Error("Wrong `remarkable` preset, check name/content");e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach((function(n){e.components[n].rules&&t[n].ruler.enable(e.components[n].rules,!0)}))},Ht.prototype.use=function(e,t){return e(this,t),this},Ht.prototype.parse=function(e,t){var n=new qt(this,e,t);return this.core.process(n),n.tokens},Ht.prototype.render=function(e,t){return t=t||{},this.renderer.render(this.parse(e,t),this.options,t)},Ht.prototype.parseInline=function(e,t){var n=new qt(this,e,t);return n.inlineMode=!0,this.core.process(n),n.tokens},Ht.prototype.renderInline=function(e,t){return t=t||{},this.renderer.render(this.parseInline(e,t),this.options,t)};var Vt=function(){function e(){R(this,e)}return N(e,null,[{key:"instantiate",value:function(t){if(t)return new Ht(I(I({},e.DEFAULT_PROPERTIES),t));if(window.hljs){var n=window.hljs;return new Ht({highlight:function(e,t){if(t&&n.getLanguage(t))try{return n.highlight(e,{language:t}).value}catch(e){console.error("failed to setup the highlight dependency")}try{return n.highlightAuto(e).value}catch(e){console.error("failed to automatically highlight messages")}return""},html:!1,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkTarget:"_blank",typographer:!0})}return new Ht(e.DEFAULT_PROPERTIES)}},{key:"createNew",value:function(t){var n=e.instantiate(t);return n.inline.validateLink=function(){return!0},n}}])}();Vt.DEFAULT_PROPERTIES={breaks:!0,linkTarget:"_blank"};var Gt=Vt,Wt=function(){function e(){R(this,e)}return N(e,null,[{key:"applyCustomStylesToElements",value:function(e,t,n){if(n&&(Object.assign(e.outerContainer.style,n.outerContainer),Object.assign(e.innerContainer.style,n.innerContainer),Object.assign(e.bubbleElement.style,n.bubble),t)){var r=e.bubbleElement.children[0],i="a"!==r.tagName.toLocaleLowerCase()?r:r.children[0];Object.assign(i.style,n.media)}}},{key:"applySideStyles",value:function(t,n,r,i){i&&(e.applyCustomStylesToElements(t,r,i.shared),n===on.USER_ROLE?e.applyCustomStylesToElements(t,r,i.user):(e.applyCustomStylesToElements(t,r,i.ai),e.applyCustomStylesToElements(t,r,i[n])))}},{key:"isElementsStyles",value:function(e){return!!(e.outerContainer||e.innerContainer||e.bubble||e.media)}},{key:"applyCustomStyles",value:function(t,n,r,i,a){var s;a&&t.default!==a?e.isElementsStyles(a)?(e.applyCustomStylesToElements(n,i,null==(s=t.default)?void 0:s.shared),e.applyCustomStylesToElements(n,i,a)):(e.applySideStyles(n,r,i,t.default),e.applySideStyles(n,r,i,a)):e.applySideStyles(n,r,i,t.default)}},{key:"extractParticularSharedStyles",value:function(e,t){if(null!=t&&t.shared){var n=t.shared,r={outerContainer:{},innerContainer:{},bubble:{},media:{}};return e.forEach((function(e){var t,i,a,s;r.outerContainer[e]=(null==(t=n.outerContainer)?void 0:t[e])||"",r.innerContainer[e]=(null==(i=n.innerContainer)?void 0:i[e])||"",r.bubble[e]=(null==(a=n.bubble)?void 0:a[e])||"",r.media[e]=(null==(s=n.media)?void 0:s[e])||""})),r}}}])}(),$t=function(){return N((function e(){R(this,e)}),null,[{key:"onMessage",value:function(e,t,n){var r,i=JSON.parse(JSON.stringify({message:t,isHistory:n,isInitial:n}));ue.reAddFileRefToObject(t,i),null==(r=e.onMessage)||r.call(e,i),e.dispatchEvent(new CustomEvent("message",{detail:i})),de.fireOnNewMessage(e,i)}},{key:"onClearMessages",value:function(e){var t;null==(t=e.onClearMessages)||t.call(e),e.dispatchEvent(new CustomEvent("clear-messages"))}},{key:"onRender",value:function(e){var t;null==(t=e.onComponentRender)||t.call(e,e),e.dispatchEvent(new CustomEvent("render",{detail:e}))}},{key:"onError",value:function(e,t){var n;null==(n=e.onError)||n.call(e,t),e.dispatchEvent(new CustomEvent("error",{detail:t}))}}])}(),Kt=function(){function e(){R(this,e)}return N(e,null,[{key:"generateLoadingRingElement",value:function(){var e=document.createElement("div");
2return e.classList.add("loading-history"),e.appendChild(document.createElement("div")),e.appendChild(document.createElement("div")),e.appendChild(document.createElement("div")),e.appendChild(document.createElement("div")),e}},{key:"apply",value:function(e,t,n){le.setRing(t.bubbleElement,null==n?void 0:n.bubble),null!=n&&n.bubble&&delete(n=JSON.parse(JSON.stringify(n))).bubble,e.applyCustomStyles(t,"history",!1,n)}},{key:"addLoadHistoryMessage",value:function(t,n){var r,i,a,s,o,l,c,u,d=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t.bubbleElement.classList.add(e.CLASS);var h=d?e.FULL_VIEW_CLASS:e.SMALL_CLASS;t.outerContainer.classList.add(h);var p=d?null==(s=null==(a=null==(i=null==(r=n.messageStyles)?void 0:r.loading)?void 0:i.history)?void 0:a.full)?void 0:s.styles:null==(u=null==(c=null==(l=null==(o=n.messageStyles)?void 0:o.loading)?void 0:l.history)?void 0:c.small)?void 0:u.styles;e.apply(n,t,p),n.elementRef.prepend(t.outerContainer)}},{key:"createDefaultElements",value:function(t){var n=t.createMessageElements("",on.AI_ROLE),r=n.bubbleElement,i=e.generateLoadingRingElement();return r.appendChild(i),n}},{key:"addMessage",value:function(t){var n,r,i,a,s=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=null==(a=null==(i=null==(r=null==(n=t.messageStyles)?void 0:n.loading)?void 0:r.history)?void 0:i.full)?void 0:a.html,l=o?be.createElements(t,o,on.AI_ROLE,!0,!0):e.createDefaultElements(t);return e.addLoadHistoryMessage(l,t,s),on.softRemRoleElements(l.innerContainer,t.avatar,t.name),l}},{key:"tryChangeViewToSmall",value:function(t,n){var r,i,a,s,o,l,c,u;if(null!=n&&n.outerContainer.classList.contains(e.FULL_VIEW_CLASS)){n.outerContainer.classList.replace(e.FULL_VIEW_CLASS,e.SMALL_CLASS);var d=null==(s=null==(a=null==(i=null==(r=t.messageStyles)?void 0:r.loading)?void 0:i.history)?void 0:a.small)?void 0:s.styles;d&&e.apply(t,n,d);var h=null==(u=null==(c=null==(l=null==(o=t.messageStyles)?void 0:o.loading)?void 0:l.history)?void 0:c.small)?void 0:u.html;return h&&(n.bubbleElement.innerHTML=h),!0}return!1}},{key:"changeFullViewToSmall",value:function(t){var n=t.messageElementRefs[t.messageElementRefs.length-1];e.tryChangeViewToSmall(t,n)||e.tryChangeViewToSmall(t,t.messageElementRefs[0])}}])}();Kt.CLASS="loading-history-message",Kt.FULL_VIEW_CLASS="loading-history-message-full-view",Kt.SMALL_CLASS="loading-history-message-small";var Jt=Kt,Zt=function(){function e(){R(this,e)}return N(e,null,[{key:"setFade",value:function(t,n){t.style.transitionDuration="".concat("number"==typeof n?n:e.DEFAULT_FADE_MS,"ms")}},{key:"fadeAnimation",value:(t=A(C().mark((function t(n,r){var i;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.style.opacity="0",i="number"==typeof r?r:e.DEFAULT_FADE_MS,t.next=4,new Promise((function(e){setTimeout((function(){return e()}),i)}));case 4:n.style.opacity="1";case 5:case"end":return t.stop()}}),t)}))),function(e,n){return t.apply(this,arguments)})}]);var t}();Zt.DEFAULT_FADE_MS=500;var Yt=Zt,Xt="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='iso-8859-1'?%3e%3csvg%20fill='%23000000'%20version='1.1'%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%2032%2032'%20xml:space='preserve'%3e%3cpath%20d='M23,30.36H9c-2.404,0-4.36-1.956-4.36-4.36V15c0-2.404,1.956-4.36,4.36-4.36h3.659%20c0.167-1.566,1.415-2.813,2.981-2.981V5.333c-1.131-0.174-2-1.154-2-2.333c0-1.301,1.059-2.36,2.36-2.36%20c1.302,0,2.36,1.059,2.36,2.36c0,1.179-0.869,2.159-2,2.333V7.66c1.566,0.167,2.814,1.415,2.981,2.981H23%20c2.404,0,4.36,1.956,4.36,4.36v11C27.36,28.404,25.404,30.36,23,30.36z%20M9,11.36c-2.007,0-3.64,1.633-3.64,3.64v11%20c0,2.007,1.633,3.64,3.64,3.64h14c2.007,0,3.64-1.633,3.64-3.64V15c0-2.007-1.633-3.64-3.64-3.64H9z%20M13.384,10.64h5.231%20C18.439,9.354,17.334,8.36,16,8.36C14.667,8.36,13.561,9.354,13.384,10.64z%20M16,1.36c-0.904,0-1.64,0.736-1.64,1.64%20S15.096,4.64,16,4.64c0.904,0,1.64-0.736,1.64-1.64S16.904,1.36,16,1.36z%20M20,27.36h-8c-1.301,0-2.36-1.059-2.36-2.36%20s1.059-2.36,2.36-2.36h8c1.302,0,2.36,1.059,2.36,2.36S21.302,27.36,20,27.36z%20M12,23.36c-0.904,0-1.64,0.735-1.64,1.64%2
20s0.736,1.64,1.64,1.64h8c0.904,0,1.64-0.735,1.64-1.64s-0.735-1.64-1.64-1.64H12z%20M31,23.86h-2c-0.199,0-0.36-0.161-0.36-0.36V15%20c0-0.199,0.161-0.36,0.36-0.36h2c0.199,0,0.36,0.161,0.36,0.36v8.5C31.36,23.699,31.199,23.86,31,23.86z%20M29.36,23.14h1.279v-7.78%20H29.36V23.14z%20M3,23.86H1c-0.199,0-0.36-0.161-0.36-0.36V15c0-0.199,0.161-0.36,0.36-0.36h2c0.199,0,0.36,0.161,0.36,0.36v8.5%20C3.36,23.699,3.199,23.86,3,23.86z%20M1.36,23.14h1.28v-7.78H1.36V23.14z%20M20,20.36c-1.302,0-2.36-1.059-2.36-2.36%20s1.059-2.36,2.36-2.36s2.36,1.059,2.36,2.36C22.36,19.302,21.302,20.36,20,20.36z%20M20,16.36c-0.904,0-1.64,0.736-1.64,1.64%20s0.735,1.64,1.64,1.64s1.64-0.735,1.64-1.64S20.904,16.36,20,16.36z%20M12,20.36c-1.301,0-2.36-1.059-2.36-2.36s1.059-2.36,2.36-2.36%20s2.36,1.059,2.36,2.36C14.36,19.302,13.301,20.36,12,20.36z%20M12,16.36c-0.904,0-1.64,0.736-1.64,1.64s0.736,1.64,1.64,1.64%20s1.64-0.735,1.64-1.64S12.904,16.36,12,16.36z'/%3e%3crect%20style='fill:none;'%20width='32'%20height='32'/%3e%3c/svg%3e",Qt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6CAMAAAC/MqoPAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////9vX18vLy/Pz86enp4+Li2tnZ1tbWzczM+fn57Ozs4N/f09LS0M/P5uXl7+/v3dzcwtncCAAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAEgAAABIAEbJaz4AAAZNSURBVHja7d3bdtsqEABQYABZSLH9/3+ZpnUsIcF5iOM6PfElNoMHMfPQdq3GmL0GkLhEUqLaUExnOtOZznSmM53pTGc605nOdKYznelMZzrTmV4LXSqllKyJDkob26xWq8Zae/iH0QoWTm9d1xur4WuypQJtTd+5dqn0VjcxzNO5/57mEBvdLo8Oron6aseWOjYOFkVvjQs3DmgyONMuht52EfztP+4hdu0i6LCO808/M8c1lE/fuPGej41uUzgdtoO/75N+2ELJ9I3b3//hPXbiMenm3pR/Jt4USgcLBIp4Bh10gqKVhvLo0klCxeSky96nKcj3siw6pJIL4XsoiQ7apyvMY/V3HHrSRioLopvEhSpTCn2TPEuwKYMOIX0tAxRBf/Hpa+lfSqBv9gi1FPsNfTrMAiVmIE/vJhz61FGnQxRIEYE4vfNYdN8Rp6MlHaHotHTn8ejekaZPAjEmyvQWdZFTtYTpXqCGJ0zvcek9Yfoel76nS0ffv1NMp1ca+pkgyfRCGind4L7OWWc605l+cxjsyhqy9AGbPpClc1/nvl5VX0c/3Alk6RU3+Am7shNZ+h6bvidLr7jBB+zKBrL0irOOudmIUDzTmf5gIP+iEuXtRuTVaEmY/oZLfyNMrzjryPc0gerMTdpVg0tvjJUU6bLPcGOoUv46SLL6Wi8yhLf06C7TUyekI0efRaaYqdFltkeNpPumRPSMDxgBYvSM035FrKAmH72hRW99PrpvSdEHkTEGUvSsK3yKVDkuJ92RohcZaehzzirPpOg+J92Tolfc4Cumx5xVXpGiZ34+ICX6W84qv5GiR5NPbiIpOv6BCoSvSkTX+eiaGP092zINvBOj4x8mSf9FqejvNo/cvpOji19ZbmviL0GPLsYMFzgzCor0+Bv/ePDvSJKOb9dJ5UlnbnEHiHgzv6cdTpJOWuc/u3FEucLDOL75xGtBiefrcwgoC9NDSH/jkH6pAuXmBqPQ9HSUPVdZBH1GGOrMXAQdYxcKZfxAoK+KKBKFLosoEoX+u4giUehz8jlcnAuhp78I46yDYNAd+QLR6K+pr+yvxdBTHyVDubQh0UfSxaHSd0lbvNkVRE87JGOtc+PQd2QLQ6fHhJkKsSh6yg13tO08JPprsgrrXWH0dJd2vH1MLPprot4eXoujpzrdhngiD40ek2y92lggPcnWa8qN1Yz0BFuvZhRl0uOfR0v4Ewuli/Bg4Qr3lArqGdndQ3UPO1EunXYwnelMZzrTmc50pjOd6UxnOtOZznSmM53pTGf6kuj6oedFKV0s3fX6sX1S3bsi6a4PD7+/YAqYeBw6pIB/4qEgOqxdSPbGiim4NRRCbzs3Jj0L4UfXtQXQVRfn5IdA/Bw7RZzurEV6EtdsLeGXkIPuA+K1UoVeA0l62zmN/LqfSSft9KkepmoRuvi3nd5uKNFB9zbbXEANqdr941XO0NJx2v2jdJenpf+/3bvn0ts16ph+sd6hX7dPo2+2cZzE02Ia43bzDHqr+2Evnhz74ZHU30ffbKOeng1/NPV30Ns1gYQnSP2P6e65Pfxc6h02XZqXQCjhJ6kPL6bFo4NrGvAU4UII4SE2P1vQuZkuOxckVfehisF1MjUddN/MZBN+kvq5uf0O/xa66gyNS9ktMWlz44rO1Z8C19i5FPdHzPamXn+F3hryPfxMr78+4F+kq22kO6Rf6fUQt+puuustyWv4rbG3l/duztFB96GYoe1cTBdXMr+nw9qVM6ZfxOvzezff0nXi/ZOndvrR6Zvpm0c3h6nhdb+5iS7tsIim/qXZD9+97/Jf+rpZ5BET1ayv0GUzLhEuhBBjIy/RdVPgndutIRt9nt7p5cKFEEJ3Z+jQFDZL+XnMDXxHB73gxn5s9Kc3d3/pFciFkN/QTSXHJpX5l66gDrkQoP6hL3xsPw39la4qOiV8tH78XeSbue6N9mvWa6J/ybpc1CT1Wnh5Qq9meP8IOKH3ddH7E/ri1iYux/SXDrXR4UiPdck/wUpU+FtPf6/orja6O9KL3l56LOvVxe5Ib2qjN0d6Vbex4ghWlU3bPqI90If66MNng680FNpbJijH6kCvaF3uMzQ3+IrpFerV4Y9dffQdN3im10ivbuImhD3Qq5u4HdZkua8znelMZ/pS4z9CPVKkxowNxgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNy0wMy0yN1QxNTo0NToxNSswMDowMN1xSg4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTctMDMtMjdUMTU6NDU6MTUrMDA6MDCsLPKyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAABJRU5ErkJggg==",en=function(){return N((function e(t){R(this,e),this.className=t}),[{key:"tryHide",value:function(e){var t;(t=e.getElementsByClassName(this.className)[0].style).visibility||(t.visibility="hidden")}},{key:"tryReveal",value:function(e){e.getElementsByClassName(this.className)[0].style.visibility=""}},{key:"trySoftRem",value:function(e){e.getElementsByClassName(this.className)[0].classList.add("role-hidden")}}])}(),tn=function(e){function t(e){var n;return R(this,t),(n=_(this,t,["avatar-container"]))._avatars=e,n}return x(t,e),N(t,[{key:"addBesideMsg",value:function(e,t){var n="boolean"==typeof this._avatars?void 0:this._avatars,r=this.createAvatar(t,n),i=this.getPosition(t,n);r.classList.add("left"===i?"left-item-position":"right-item-position"),e.insertAdjacentElement("left"===i?"beforebegin":"afterend",r)}}
2,{key:"createAvatar",value:function(e,n){var r,i,a,s,o,l=document.createElement("img");e===on.USER_ROLE?(l.src=(null==(r=null==n?void 0:n.user)?void 0:r.src)||(null==(i=null==n?void 0:n.default)?void 0:i.src)||Qt,l.onerror=t.errorFallback.bind(this,Qt)):(l.src=(null==(a=null==n?void 0:n[e])?void 0:a.src)||(null==(s=null==n?void 0:n.ai)?void 0:s.src)||(null==(o=null==n?void 0:n.default)?void 0:o.src)||Xt,l.onerror=t.errorFallback.bind(this,Xt)),l.classList.add("avatar"),l.alt="".concat(e," avatar");var c=document.createElement("div");return c.classList.add(this.className),c.appendChild(l),n&&t.applyCustomStyles(c,l,n,e),c}},{key:"getPosition",value:function(e,t){var n,r,i,a,s,o,l=null==(r=null==(n=null==t?void 0:t[e])?void 0:n.styles)?void 0:r.position;return e!==on.USER_ROLE&&(null!=l||(l=null==(a=null==(i=null==t?void 0:t.ai)?void 0:i.styles)?void 0:a.position)),null!=l||(l=null==(o=null==(s=null==t?void 0:t.default)?void 0:s.styles)?void 0:o.position),null!=l||(l=e===on.USER_ROLE?"right":"left"),l}}],[{key:"errorFallback",value:function(e,t){var n=t.target;n.onerror=null,n.src=e}},{key:"applyCustomStylesToElements",value:function(e,t,n){Object.assign(e.style,n.container),Object.assign(t.style,n.avatar)}},{key:"applyCustomStyles",value:function(e,n,r,i){var a,s,o,l;if(null!=(a=r.default)&&a.styles&&t.applyCustomStylesToElements(e,n,r.default.styles),i===on.USER_ROLE)null!=(s=r.user)&&s.styles&&t.applyCustomStylesToElements(e,n,r.user.styles);else{null!=(o=r.ai)&&o.styles&&t.applyCustomStylesToElements(e,n,r.ai.styles);var c=null==(l=r[i])?void 0:l.styles;c&&t.applyCustomStylesToElements(e,n,c)}}}])}(en),nn=function(e){function t(e){var n;return R(this,t),(n=_(this,t,["name"]))._names=e,n}return x(t,e),N(t,[{key:"addBesideMsg",value:function(e,n){var r="boolean"==typeof this._names?{}:this._names,i=this.createName(n,r),a=t.getPosition(n,r);i.classList.add("left"===a?"left-item-position":"right-item-position"),e.insertAdjacentElement("left"===a?"beforebegin":"afterend",i)}},{key:"createName",value:function(e,n){var r=document.createElement("div");return r.classList.add(this.className),r.textContent=t.getNameText(e,n),t.applyStyle(r,e,n),r}}],[{key:"getPosition",value:function(e,t){var n,r,i,a=null==(n=null==t?void 0:t[e])?void 0:n.position;return e!==on.USER_ROLE&&(null!=a||(a=null==(r=null==t?void 0:t.ai)?void 0:r.position)),null!=a||(a=null==(i=null==t?void 0:t.default)?void 0:i.position),null!=a||(a=e===on.USER_ROLE?"right":"left"),a}},{key:"applyStyle",value:function(e,t,n){var r,i,a,s;Object.assign(e.style,null==(r=n.default)?void 0:r.style),t===on.USER_ROLE?Object.assign(e.style,null==(i=n.user)?void 0:i.style):(Object.assign(e.style,null==(a=n.ai)?void 0:a.style),Object.assign(e.style,null==(s=n[t])?void 0:s.style))}},{key:"getNameText",value:function(e,t){var n,r,i,a,s,o;return e===on.USER_ROLE?(null==(n=t.user)?void 0:n.text)||(null==(r=t.default)?void 0:r.text)||"User":e===on.AI_ROLE?(null==(i=t.ai)?void 0:i.text)||(null==(a=t.default)?void 0:a.text)||"AI":(null==(s=t[e])?void 0:s.text)||(null==(o=t.default)?void 0:o.text)||e}}])}(en),rn=function(){function e(t){var n,r=this;R(this,e),this.messageElementRefs=[],this.htmlClassUtilities={},this.messageToElements=[],this.elementRef=e.createContainerElement(),this.messageStyles=de.processMessageStyles(t.messageStyles),this._remarkable=Gt.createNew(t.remarkable),t.avatars&&(this.avatar=new tn(t.avatars)),t.names&&(this.name=new nn(t.names)),this._onMessage=$t.onMessage.bind(this,t),t.htmlClassUtilities&&(this.htmlClassUtilities=t.htmlClassUtilities),this.focusMode=t.focusMode,this.focusMode||(this._lastGroupMessagesElement=document.createElement("div")),"boolean"!=typeof this.focusMode&&null!=(n=this.focusMode)&&n.fade&&Yt.setFade(this.elementRef,this.focusMode.fade),setTimeout((function(){r.submitUserMessage=t.submitUserMessage}))}return N(e,[{key:"addNewTextMessage",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(null!=r&&r.status){var a=this.overwriteText(n,t,this.messageElementRefs);if(a)return a;r.status=!1}var s=i?this.createAndPrependNewMessageElement(t,n,i):this.createAndAppendNewMessageElement(t,n);return s.bubbleElement.classList.add(e.TEXT_BUBBLE_CLASS),this.applyCustomStyles(s,n,!1),on.fillEmptyMessageElement(s.bubbleElement,t),s}}
2,{key:"overwriteText",value:function(t,n,r){var i=on.overwriteMessage(this.messageToElements,r,n,t,"text",e.TEXT_BUBBLE_CLASS);return i&&this.renderText(i.bubbleElement,n),i}},{key:"createAndAppendNewMessageElement",value:function(e,t){return this.focusMode?this.appendNewMessageElementFocusMode(e,t):this.createAndAppendNewMessageElementDefault(e,t)}},{key:"appendNewMessageElementFocusMode",value:function(e,t){var n,r=this,i=this.createNewMessageElement(e,t);if(this.appendOuterContainerElemet(i.outerContainer,t),"user"===t){var a="boolean"!=typeof this.focusMode&&(null==(n=this.focusMode)?void 0:n.scroll);setTimeout((function(){return ie.scrollToBottom(r.elementRef,a)}))}return i}},{key:"createNewGroupElementFocusMode",value:function(){var t;null==(t=this._lastGroupMessagesElement)||t.classList.remove(e.LAST_GROUP_MESSAGES_ACTIVE);var n=document.createElement("div");this._lastGroupMessagesElement&&n.classList.add(e.LAST_GROUP_MESSAGES_ACTIVE),this._lastGroupMessagesElement=n}},{key:"createAndAppendNewMessageElementDefault",value:function(e,t){var n=this,r=this.createNewMessageElement(e,t);return this.appendOuterContainerElemet(r.outerContainer),setTimeout((function(){return ie.scrollToBottom(n.elementRef)})),r}},{key:"appendOuterContainerElemet",value:function(e,t){var n;this.focusMode&&("user"===t||!this._lastGroupMessagesElement)&&this.createNewGroupElementFocusMode(),null==(n=this._lastGroupMessagesElement)||n.appendChild(e),this.elementRef.appendChild(this._lastGroupMessagesElement)}},{key:"createAndPrependNewMessageElement",value:function(t,n,r){var i,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=this.createNewMessageElement(t,n,r,a);if(r&&null!=(i=this.elementRef.firstChild)&&i.classList.contains(e.INTRO_CLASS)){this.elementRef.firstChild.insertAdjacentElement("afterend",s.outerContainer);var o=this.messageElementRefs[0];this.messageElementRefs[0]=this.messageElementRefs[1],this.messageElementRefs[1]=o}else this.elementRef.insertBefore(s.outerContainer,this.elementRef.firstChild);return s}},{key:"createMessageElementsOnOrientation",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return n?this.createAndPrependNewMessageElement(e,t,!0,r):this.createNewMessageElement(e,t,r)}},{key:"createNewMessageElement",value:function(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];a||null==(r=this._introPanel)||r.hide();var s=this.messageElementRefs[this.messageElementRefs.length-1];return Jt.changeFullViewToSmall(this),!i&&e.isTemporaryElement(s)&&(this.revealRoleElementsIfTempRemoved(s,n),this.removeLastMessage()),this.createMessageElements(t,n,i)}},{key:"revealRoleElementsIfTempRemoved",value:function(e,t){if((this.avatar||this.name)&&me.isElementTemporary(e)){var n=this.messageElementRefs[this.messageElementRefs.length-2];n&&this.messageToElements.length>0&&!e.bubbleElement.classList.contains(on.getRoleClass(t))&&on.revealRoleElements(n.innerContainer,this.avatar,this.name)}}},{key:"createElements",value:function(t,n){var r=e.createBaseElements(n),i=r.outerContainer,a=r.innerContainer,s=r.bubbleElement;return i.appendChild(a),this.addInnerContainerElements(s,t,n),r}},{key:"createMessageElements",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.createElements(e,t);return on.updateRefArr(this.messageElementRefs,r,n),on.classifyRoleMessages(this.messageElementRefs,t),r}},{key:"addInnerContainerElements",value:function(e,t,n){var r=this.messageElementRefs[this.messageElementRefs.length-1];return on.areOuterContainerClassRolesSame(n,r)&&!this.isLastMessageError()&&on.hideRoleElements(r.innerContainer,this.avatar,this.name),e.classList.add("message-bubble",on.getRoleClass(n),n===on.USER_ROLE?"user-message-text":"ai-message-text"),this.renderText(e,t),on.addRoleElements(e,n,this.avatar,this.name),{bubbleElement:e}}},{key:"applyCustomStyles",value:function(e,t,n,r){e&&this.messageStyles&&Wt.applyCustomStyles(this.messageStyles,e,t,n,r)}},{key:"removeMessage",value:function(e){e.outerContainer.remove();var t=this.messageElementRefs.findIndex((function(t){return t===e}));this.messageElementRefs.splice(t,1)}},{key:"removeLastMessage",value:function(){this.messageElementRefs[this.messageElementRefs.length-1].outerContainer.remove(),this.messageElementRefs.pop()}},{key:"isLastMessageError",value:function(){var e;return null==(e=on.getLastMessageBubbleElement(this.elementRef))?void 0:e.classList.contains(on.ERROR_MESSAGE_TEXT_CLASS)}},{key:"sendClientUpdate",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null==(t=this._onMessage)||t.call(this,e,n)}},{key:"renderText",value:function(e,t){e.innerHTML=this._remarkable.render(t),0===e.innerText.trim().length&&(e.innerText=t)}},{key:"refreshTextMessages",value:function(e){var t=this;
2this._remarkable=Gt.createNew(e),this.messageToElements.forEach((function(e){e[1].text&&e[0].text&&t.renderText(e[1].text.bubbleElement,e[0].text)}))}}],[{key:"createContainerElement",value:function(){var e=document.createElement("div");return e.id="messages",e}},{key:"isTemporaryElement",value:function(t){return e.isLoadingMessage(t)||me.isElementTemporary(t)}},{key:"createBaseElements",value:function(e){var t=document.createElement("div"),n=document.createElement("div");n.classList.add("inner-message-container"),t.appendChild(n),t.classList.add("outer-message-container"),t.classList.add(on.buildRoleOuterContainerClass(e));var r=document.createElement("div");return r.classList.add("message-bubble"),n.appendChild(r),{outerContainer:t,innerContainer:n,bubbleElement:r}}},{key:"createMessageContent",value:function(e){var t=e.text,n=e.files,r=e.html,i=e.custom,a=e._sessionId,s={role:e.role||on.AI_ROLE};return t&&(s.text=t),n&&(s.files=n),r&&(s.html=r),!t&&!n&&!r&&(s.text=""),i&&(s.custom=i),a&&(s._sessionId=a),s}},{key:"isLoadingMessage",value:function(e){return null==e?void 0:e.bubbleElement.classList.contains(le.BUBBLE_CLASS)}}])}();rn.TEXT_BUBBLE_CLASS="text-message",rn.INTRO_CLASS="deep-chat-intro",rn.LAST_GROUP_MESSAGES_ACTIVE="deep-chat-last-group-messages-active";var an=rn,sn=function(){function e(){R(this,e)}return N(e,null,[{key:"getLastElementsByClass",value:function(e,t,n){for(var r,i=function(){var r=e[a];if(r.bubbleElement.classList.contains(t[0])&&!t.slice(1).find((function(e){return!r.bubbleElement.classList.contains(e)}))){if(!n)return{v:r};if(!n.find((function(e){return r.bubbleElement.classList.contains(e)})))return{v:r}}},a=e.length-1;a>=0;a-=1)if(r=i())return r.v}},{key:"getLastMessage",value:function(e,t,n){for(var r=e.length-1;r>=0;r-=1)if(e[r][0].role===t){if(!n)return e[r][0];if(e[r][0][n])return e[r][0]}}},{key:"getLastTextToElement",value:function(e,t){for(var n=e.length-1;n>=0;n-=1)if(e[n][0]===t)return e[n]}},{key:"overwriteMessage",value:function(t,n,r,i,a,s){var o=e.getLastElementsByClass(n,[e.getRoleClass(i),s],[le.BUBBLE_CLASS]),l=e.getLastMessage(t,i,a);return l&&(l[a]=r),o}},{key:"getRoleClass",value:function(e){return"".concat(e,"-message")}},{key:"fillEmptyMessageElement",value:function(t,n){0===n.trim().length&&(t.classList.add(e.EMPTY_MESSAGE_CLASS),t.innerHTML='<div style="color:#00000000">.</div>')}},{key:"unfillEmptyMessageElement",value:function(t,n){t.classList.contains(e.EMPTY_MESSAGE_CLASS)&&n.trim().length>0&&t.replaceChildren()}},{key:"getLastMessageBubbleElement",value:function(t){var n,r,i,a;return null==(a=Array.from((null==(i=null==(r=null==(n=e.getLastMessageElement(t))?void 0:n.children)?void 0:r[0])?void 0:i.children)||[]).map((function(e){return Array.from((null==e?void 0:e.children)||[]).find((function(e){return e.classList.contains("message-bubble")}))})))?void 0:a[0]}},{key:"getLastMessageElement",value:function(e){return e.children[e.children.length-1]}},{key:"addRoleElements",value:function(e,t,n,r){null==n||n.addBesideMsg(e,t),null==r||r.addBesideMsg(e,t)}},{key:"hideRoleElements",value:function(e,t,n){null==t||t.tryHide(e),null==n||n.tryHide(e)}},{key:"revealRoleElements",value:function(e,t,n){null==t||t.tryReveal(e),null==n||n.tryReveal(e)}},{key:"softRemRoleElements",value:function(e,t,n){null==t||t.trySoftRem(e),null==n||n.trySoftRem(e)}},{key:"updateRefArr",value:function(e,t,n){n?e.unshift(t):e.push(t)}},{key:"buildRoleOuterContainerClass",value:function(t){return"".concat(e.OUTER_CONTAINER_CLASS_ROLE_PREFIX).concat(t)}},{key:"addNewPositionClasses",value:function(t,n){var r;t.outerContainer.classList.remove(e.POSITION_TOP_MESSAGE_CLASS,e.POSITION_MIDDLE_MESSAGE_CLASS,e.POSITION_BOTTOM_MESSAGE_CLASS),(r=t.outerContainer.classList).add.apply(r,v(n))}},{key:"getNumberOfElements",value:function(e){var t=0;return void 0!==e.text&&(t+=1),void 0!==e.html&&(t+=1),e.files&&(t+=e.files.length),t}},{key:"filterdMessageElements",value:function(e,t){return e.filter((function(e){return e.bubbleElement.classList.contains(t)}))}},{key:"findMessageElements",value:function(e,t){return e.find((function(e){return e.bubbleElement.classList.contains(t)}))}},{key:"generateMessageBodyElements",value:function(t,n){var r={};return t.text&&(r.text=e.findMessageElements(n,an.TEXT_BUBBLE_CLASS)),t.html&&(r.html=e.findMessageElements(n,be.HTML_BUBBLE_CLASS)),t.files&&(r.files=e.filterdMessageElements(n,ue.FILE_BUBBLE_CLASS)),r}},{key:"generateMessageBody",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e.getNumberOfElements(t),a=r?n.slice(0,i):n.slice(n.length-i);return e.generateMessageBodyElements(t,a)}},{key:"classifyRoleMessages",value:function(t,n){for(var r=n?e.buildRoleOuterContainerClass(n):void 0,i=t.length-1;i>=0;i-=1)if(n||(r=Array.from(t[i].outerContainer.classList).find((function(t){return t.startsWith(e.OUTER_CONTAINER_CLASS_ROLE_PREFIX)}))),r){var a=t[i],s=a.outerContainer.classList.contains(r),o=t[i-1],l=t[i+1],c=null==o?void 0:o.outerContainer.classList.contains(r),u=null==l?void 0:l.outerContainer.classList.contains(r);
2if(s)!c&&u?e.addNewPositionClasses(a,[e.POSITION_TOP_MESSAGE_CLASS]):c&&u?e.addNewPositionClasses(a,[e.POSITION_MIDDLE_MESSAGE_CLASS]):c&&!u?e.addNewPositionClasses(a,[e.POSITION_BOTTOM_MESSAGE_CLASS]):!c&&!u&&e.addNewPositionClasses(a,[e.POSITION_TOP_MESSAGE_CLASS,e.POSITION_BOTTOM_MESSAGE_CLASS]);else if(n)break}}},{key:"areOuterContainerClassRolesSame",value:function(t,n){return!!n&&Array.from(n.outerContainer.classList).find((function(t){return t.startsWith(e.OUTER_CONTAINER_CLASS_ROLE_PREFIX)}))===e.buildRoleOuterContainerClass(t)}},{key:"resetAllRoleElements",value:function(t,n,r){if(n||r){var i="";t.forEach((function(a,s){a.bubbleElement.classList.contains(e.ERROR_MESSAGE_TEXT_CLASS)||e.revealRoleElements(a.innerContainer,n,r);var o=Array.from(a.outerContainer.classList).find((function(t){return t.startsWith(e.OUTER_CONTAINER_CLASS_ROLE_PREFIX)}));i===o&&e.hideRoleElements(t[s-1].innerContainer,n,r),i=o}))}}}])}();sn.AI_ROLE="ai",sn.USER_ROLE="user",sn.ERROR_MESSAGE_TEXT_CLASS="error-message-text",sn.OUTER_CONTAINER_CLASS_ROLE_PREFIX="deep-chat-outer-container-role-",sn.EMPTY_MESSAGE_CLASS="empty-message",sn.POSITION_TOP_MESSAGE_CLASS="deep-chat-top-message",sn.POSITION_MIDDLE_MESSAGE_CLASS="deep-chat-middle-message",sn.POSITION_BOTTOM_MESSAGE_CLASS="deep-chat-bottom-message";var on=sn,ln=function(){function e(t){R(this,e),this._fileAdded=!1,this._streamType="",this._hasStreamEnded=!1,this._messages=t}return N(e,[{key:"upsertStreamedMessage",value:function(e){var t;if(!this._hasStreamEnded){if(void 0===(null==e?void 0:e.text)&&void 0===(null==e?void 0:e.html))return console.error(ne.INVALID_STREAM_EVENT);null!=e&&e.custom&&this._message&&(this._message.custom=e.custom);var n=(null==e?void 0:e.text)||(null==e?void 0:e.html)||"",r=ie.isScrollbarAtBottomOfElement(this._messages.elementRef),i=void 0!==(null==e?void 0:e.text)?"text":"html";if(this._elements||this._message){if(this._streamType!==i)return console.error(ne.INVALID_STREAM_EVENT_MIX);this.updateBasedOnType(n,i,null==(t=this._elements)?void 0:t.bubbleElement,null==e?void 0:e.overwrite)}else this.setInitialState(i,n,null==e?void 0:e.role);r&&ie.scrollToBottom(this._messages.elementRef)}}},{key:"setInitialState",value:function(t,n,r){this._streamType=t,null!=r||(r=on.AI_ROLE),this._elements="text"===t?this._messages.addNewTextMessage(n,r):be.add(this._messages,n,r),this._elements&&(this._elements.bubbleElement.classList.add(e.MESSAGE_CLASS),this._activeMessageRole=r,this._message=L({role:this._activeMessageRole},t,n),this._messages.messageToElements.push([this._message,L({},t,this._elements)]))}},{key:"updateBasedOnType",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];on.unfillEmptyMessageElement(n,e),("text"===t?this.updateText:this.updateHTML).bind(this)(e,n,r)}},{key:"updateText",value:function(e,t,n){this._message&&(this._message.text=n?e:this._message.text+e,this._messages.renderText(t,this._message.text))}},{key:"updateHTML",value:function(e,t,n){if(this._message)if(n)this._message.html=e,t.innerHTML=e;else{var r=document.createElement("span");r.innerHTML=e,t.appendChild(r),this._message.html=(null==t?void 0:t.innerHTML)||""}}},{key:"finaliseStreamedMessage",value:function(){var t;if(!this._endStreamAfterOperation&&this._message&&(!this._fileAdded||this._elements)){if(!this._elements)throw Error(ne.NO_VALID_STREAM_EVENTS_SENT);null!=(t=this._elements.bubbleElement)&&t.classList.contains(e.MESSAGE_CLASS)&&("text"===this._streamType?this._messages.textToSpeech&&se.speak(this._message.text||"",this._messages.textToSpeech):"html"===this._streamType&&this._elements&&ge.apply(this._messages,this._elements.outerContainer),this._elements.bubbleElement.classList.remove(e.MESSAGE_CLASS),this._message&&this._messages.sendClientUpdate(an.createMessageContent(this._message),!1),this._hasStreamEnded=!0)}}},{key:"markFileAdded",value:function(){this._fileAdded=!0}},{key:"newMessage",value:function(){this.finaliseStreamedMessage(),this._elements=void 0,delete this._message,this._fileAdded=!1,this._hasStreamEnded=!1,this._activeMessageRole=void 0}},{key:"endStreamAfterFileDownloaded",value:(t=A(C().mark((function e(t,n){var r,i,a,s;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._endStreamAfterOperation=!0,e.next=3,n();case 3:i=e.sent,a=i.text,s=i.files,a&&this.updateBasedOnType(a,"text",null==(r=this._elements)?void 0:r.bubbleElement,!0),this._endStreamAfterOperation=!1,this.finaliseStreamedMessage(),s&&t.addNewMessage({files:s});case 7:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})}]);var t}();ln.MESSAGE_CLASS="streamed-message";var cn=ln,un=function(){function e(){R(this,e)}return N(e,null,[{key:"tempRemoveContentHeader",value:(r=A(C().mark((function t(n,r,i){var a,s;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=n&&n.headers){t.next=2;break}throw new Error("Request settings have not been set up");case 2:return a=n.headers[e.CONTENT_TYPE],delete n.headers[e.CONTENT_TYPE],t.prev=4,t.next=7,r(i);case 7:s=t.sent,t.next=13;break;case 10:throw t.prev=10,t.t0=t.catch(4),n.headers[e.CONTENT_TYPE]=a,t.t0;case 13:return t.abrupt("return",(n.headers[e.CONTENT_TYPE]=a,s));case 14:case"end":return t.stop()}}),t,null,[[4,10]])}))),function(e,t,n){return r.apply(this,arguments)})},{key:"displayError",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Service error, please try again.";if(console.error(t),"object"==O(t))return t instanceof Error?e.addNe
2wErrorMessage("service",t.message):Array.isArray(t)||"string"==typeof t.error?e.addNewErrorMessage("service",t):0===Object.keys(t).length?e.addNewErrorMessage("service",n):e.addNewErrorMessage("service",JSON.stringify(t));e.addNewErrorMessage("service",t)}},{key:"fetch",value:function(e){function t(t,n,r,i){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,t,n,r){var i,a,s={method:(null==(i=e.connectSettings)?void 0:i.method)||"POST",headers:t};return"GET"!==s.method&&(s.body=n?JSON.stringify(r):r),e.connectSettings.credentials&&(s.credentials=e.connectSettings.credentials),fetch((null==(a=e.connectSettings)?void 0:a.url)||e.url||"",s)}))},{key:"processResponseByType",value:function(e){var t=e.headers.get("content-type");return null!=t&&t.includes("application/json")?e.json():null!=t&&t.includes("text/plain")||!t?e:e.blob()}},{key:"processRequestInterceptor",value:(n=A(C().mark((function e(t,n){var r,i,a,s;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null==(r=t.requestInterceptor)?void 0:r.call(t,n);case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=n;case 5:return i=e.t0,a=i,s=i,e.abrupt("return",{body:a.body,headers:a.headers,error:s.error});case 9:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"validateResponseFormat",value:function(e,t){if(!e)return!1;var n=Array.isArray(e)?e:[e];return t&&n.length>1?(console.error(ne.INVALID_STREAM_ARRAY_RESPONSE),!1):!n.find((function(e){return"object"!=O(e)||!("string"==typeof e.error||"string"==typeof e.text||"string"==typeof e.html||Array.isArray(e.files))}))}},{key:"onInterceptorError",value:function(e,t,n){e.addNewErrorMessage("service",t),null==n||n()}},{key:"basicResponseProcessing",value:(t=A(C().mark((function t(n,r){var i,a,s,o,l,c,u,d,h,p,f=arguments;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=f.length>2&&void 0!==f[2]?f[2]:{},a=i.io,s=i.displayError,o=void 0===s||s,l=i.useRI,c=void 0===l||l,null!=a&&a.extractResultData){t.next=4;break}return t.abrupt("return",r);case 4:return u=c?a.deepChat.responseInterceptor:void 0,t.next=7,null==u?void 0:u(r);case 7:if(t.t0=t.sent,t.t0){t.next=10;break}t.t0=r;case 10:return d=t.t0,t.next=13,a.extractResultData(d);case 13:if((h=t.sent)&&("object"==O(h)||Array.isArray(h))){t.next=17;break}return o&&(p=ne.INVALID_RESPONSE(r,"response",!!u,d),e.displayError(n,p)),t.abrupt("return");case 17:return t.abrupt("return",h);case 18:case"end":return t.stop()}}),t)}))),function(e,n){return t.apply(this,arguments)})}]);var t,n,r}();un.CONTENT_TYPE="Content-Type";var dn=un;function hn(e,t){return pn.apply(this,arguments)}function pn(){return pn=A(C().mark((function e(t,n){var r,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.getReader();case 1:return e.next=3,r.read();case 3:if((i=e.sent).done){e.next=7;break}n(i.value);case 5:e.next=1;break;case 7:case"end":return e.stop()}}),e)}))),pn.apply(this,arguments)}function fn(e){var t,n,r,i=!1;return function(a){void 0===t?(t=a,n=0,r=-1):t=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}(t,a);for(var s=t.length,o=0;n<s;){i&&(10===t[n]&&(o=++n),i=!1);for(var l=-1;n<s&&-1===l;++n)switch(t[n]){case 58:-1===r&&(r=n-o);break;case 13:i=!0;case 10:l=n}if(-1===l)break;e(t.subarray(o,l),r),o=n,r=-1}o===s?t=void 0:0!==o&&(t=t.subarray(o),n-=o)}}function mn(e,t,n){var r={data:"",event:"",id:"",retry:void 0},i=new TextDecoder;return function(a,s){if(0===a.length)null==n||n(r),r={data:"",event:"",id:"",retry:void 0};else if(s>0){var o=i.decode(a.subarray(0,s)),l=s+(32===a[s+1]?2:1),c=i.decode(a.subarray(l));switch(o){case"data":r.data=r.data?r.data+"\n"+c:c;break;case"event":r.event=c;break;case"id":e(r.id=c);break;case"retry":var u=parseInt(c,10);isNaN(u)||t(r.retry=u)}}}}var gn="text/event-stream",vn="last-event-id";function yn(e,t){var n=t.signal,r=t.headers,i=t.onopen,a=t.onmessage,s=t.onclose,o=t.onerror,l=t.openWhenHidden,c=t.fetch,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((function(t,d){var h,p=Object.assign({},r);function f(){h.abort(),document.hidden||_()}p.accept||(p.accept=gn),l||document.addEventListener("visibilitychange",f);var m=1e3,g=0;function v(){document.removeEventListener("visibilitychange",f),window.clearTimeout(g),h.abort()}null==n||n.addEventListener("abort",(function(){v(),t()}));var y=null!=c?c:window.fetch,b=null!=i?i:bn;function _(){return w.apply(this,arguments)}function w(){return(w=A(C().mark((function n(){var r,i,l;return C().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return h=new AbortController,n.prev=1,n.next=4,y(e,Object.assign(Object.assign({},u),{headers:p,signal:h.signal}));case 4:return i=n.sent,n.next=7,b(i);case 7:return n.next=9,hn(i.body,fn(mn((function(e){e?p[vn]=e:delete p[vn]}),(function(e){m=e}),a)));case 9:null==s||s(),v(),t(),n.next=17;break;case 14:if(n.prev=14,n.t0=n.catch(1),!h.signal.aborted)try{l=null!==(r=null==o?void 0:o(n.t0))&&void 0!==r?r:m,window.clearTimeout(g),g=window.setTimeout(_,l)}catch(e){v(),d(e)}case 17:case"end":return n.stop()}}),n,null,[[1,14]])}
2)))).apply(this,arguments)}_()}))}function bn(e){var t=e.headers.get("content-type");if(null==t||!t.startsWith(gn))throw new Error("Expected content-type to be ".concat(gn,", Actual: ").concat(t))}var _n=function(){function e(){R(this,e)}return N(e,null,[{key:"request",value:(r=A(C().mark((function t(n,r,i){var a,s,o,l,c,u,d,h,p,f,m,g,v,y,b,_=arguments;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=!(_.length>3&&void 0!==_[3])||_[3],s=_.length>4&&void 0!==_[4]&&_[4],h={body:r,headers:null==(o=n.connectSettings)?void 0:o.headers},t.next=5,dn.processRequestInterceptor(n.deepChat,h);case 5:if(p=t.sent,f=p.body,m=p.headers,!(g=p.error)){t.next=11;break}return t.abrupt("return",dn.onInterceptorError(i,g,n.streamHandlers.onClose));case 11:if(null==(l=n.connectSettings)||!l.handler){t.next=13;break}return t.abrupt("return",xn.stream(n,f,i));case 13:if((null==(c=n.connectSettings)?void 0:c.url)!==kn.URL){t.next=15;break}return t.abrupt("return",kn.requestStream(i,n));case 15:return v=new cn(i),y=dn.fetch.bind(this,n,m,a),b={method:(null==(u=n.connectSettings)?void 0:u.method)||"POST",headers:m,credentials:null==(d=n.connectSettings)?void 0:d.credentials,body:a?JSON.stringify(f):f},t.abrupt("return",("object"==O(n.stream)&&n.stream.readable?e.handleReadableStream(n,i,v,b,s,y,f):e.handleEventStream(n,i,v,b,s,y,f),v));case 17:case"end":return t.stop()}}),t,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"handleReadableStream",value:function(t,n,r,i,a,s,o){var l,c=t.streamHandlers,u=c.onOpen,d=c.onClose,h=c.abortStream,p=!1;fetch((null==(l=t.connectSettings)?void 0:l.url)||t.url||"",i).then(function(){var i=A(C().mark((function i(l){var c,h,f,m,g,v,y,b,_,w,k;return C().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(l.body){i.next=2;break}throw new Error(ne.READABLE_STREAM_CONNECTION_ERROR);case 2:f=l.body.getReader(),m=new TextDecoder,u(),g=!1;case 5:if(g||p){i.next=26;break}return i.next=8,f.read();case 8:if(v=i.sent,y=v.value,b=v.done,!(g=b)){i.next=15;break}e.handleClose(t,r,d,a),i.next=24;break;case 15:return _=m.decode(y,{stream:!0}),i.next=18,null==(h=(c=t.deepChat).responseInterceptor)?void 0:h.call(c,_);case 18:if(i.t0=i.sent,i.t0){i.next=21;break}i.t0=_;case 21:w=i.t0,k="object"==O(w)?w:{text:_},e.handleMessage(t,n,r,d,k,s,o);case 24:i.next=5;break;case 26:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}()).catch((function(r){e.handleError(t,n,r)})),h.abort=function(){p=!0}}},{key:"handleEventStream",value:function(t,n,r,i,a,s,o){var l,c=t.streamHandlers,u=c.onOpen,d=c.onClose,h=c.abortStream;yn((null==(l=t.connectSettings)?void 0:l.url)||t.url||"",I(I({},i),{},{openWhenHidden:!0,onopen:function(e){return A(C().mark((function t(){return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.ok){t.next=2;break}return t.abrupt("return",u());case 2:return t.next=4,dn.processResponseByType(e);case 4:throw t.sent;case 5:case"end":return t.stop()}}),t)})))()},onmessage:function(i){return A(C().mark((function a(){var l,c,u,h;return C().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(JSON.stringify(i.data)===JSON.stringify("[DONE]")){a.next=9;break}try{u=JSON.parse(i.data)}catch(e){u={}}return a.next=4,null==(c=(l=t.deepChat).responseInterceptor)?void 0:c.call(l,u);case 4:if(a.t0=a.sent,a.t0){a.next=7;break}a.t0=u;case 7:h=a.t0,e.handleMessage(t,n,r,d,h,s,o);case 9:case"end":return a.stop()}}),a)})))()},onerror:function(e){throw d(),e},onclose:function(){e.handleClose(t,r,d,a)},signal:h.signal})).catch((function(r){e.handleError(t,n,r)}))}},{key:"handleMessage",value:function(t,n,r,i,a,s,o){var l;null==(l=t.extractResultData)||l.call(t,a,s,o).then((function(a){t.asyncCallInProgress&&a&&""!==a.text?(e.simulate(n,t.streamHandlers,a),i(),t.asyncCallInProgress=!1):e.upsertWFiles(n,r.upsertStreamedMessage.bind(r),r,a)})).catch((function(e){return dn.displayError(n,e)}))}},{key:"handleError",value:function(e,t,n){var r;t.isLastMessageError()||null==(r=e.extractResultData)||r.call(e,n).then((function(){dn.displayError(t,n)})).catch((function(e){dn.displayError(t,e)}))}},{key:"handleClose",value:function(e,t,n,r){if(!e.asyncCallInProgress)try{t.f
2inaliseStreamedMessage(),n()}catch(e){if(!r)throw e}}},{key:"simulate",value:(n=A(C().mark((function t(n,r,i,a){var s,o,l,c;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=r,t.next=3,dn.basicResponseProcessing(n,i,{io:a,useRI:!1});case 3:if(t.sent){t.next=5;break}return t.abrupt("return",r.onClose());case 5:if(Array.isArray(i)&&(i=i[0]),!i.files){t.next=10;break}return t.next=8,dn.basicResponseProcessing(n,{files:i.files},{io:a});case 8:o=t.sent,n.addNewMessage(I({sendUpdate:!1,ignoreText:!0},o),!1);case 10:i.text&&(r.onOpen(),l=i.text.split(""),e.populateMessages(n,l,new cn(n),s,"text",0,a)),i.html&&(r.onOpen(),0===(c=ge.splitHTML(i.html)).length&&(c=i.html.split("")),e.populateMessages(n,c,new cn(n),s,"html",0,a)),i.error&&(dn.displayError(n,i.error),r.onClose());case 13:case"end":return t.stop()}}),t)}))),function(e,t,r,i){return n.apply(this,arguments)})},{key:"populateMessages",value:(t=A(C().mark((function t(n,r,i,a,s,o,l){var c,u,d;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(c=r[o])){t.next=10;break}return t.next=4,dn.basicResponseProcessing(n,L({},s,c),{io:l});case 4:u=t.sent,e.upsertWFiles(n,i.upsertStreamedMessage.bind(i),i,u),d=setTimeout((function(){e.populateMessages(n,r,i,a,s,o+1,l)}),a.simulationInterim||6),a.abortStream.abort=function(){e.abort(d,i,a.onClose)},t.next=11;break;case 10:i.finaliseStreamedMessage(),a.onClose();case 11:case"end":return t.stop()}}),t)}))),function(e,n,r,i,a,s,o){return t.apply(this,arguments)})},{key:"isSimulation",value:function(e){return"object"==O(e)&&!!e.simulation}},{key:"isSimulatable",value:function(t,n){return e.isSimulation(t)&&n&&(n.text||n.html)}},{key:"abort",value:function(e,t,n){clearTimeout(e),t.finaliseStreamedMessage(),n()}},{key:"upsertWFiles",value:function(e,t,n,r){if(r&&Array.isArray(r)&&(r=r[0]),null!=r&&r.text||null!=r&&r.html){var i=t(r);null!=n||(n=i||void 0)}null!=r&&r.files&&(e.addNewMessage({files:r.files}),null==n||n.markFileAdded())}}]);var t,n,r}(),wn=function(){function e(){R(this,e)}return N(e,null,[{key:"generateResponse",value:function(e){var t=e[e.length-1][0];if(t.files&&t.files.length>0){if(t.files.length>1)return"These are interesting files!";var n=t.files[0];return n.src&&n.src.startsWith("data:image/gif")?"That is a nice gif!":"image"===n.type?"That is a nice image!":"audio"===n.type?"I like the sound of that!":"That is an interesting file!"}if(t.text){if("?"===t.text.charAt(t.text.length-1))return"I'm sorry but I can't answer that question...";if(t.text.includes("updog"))return"What's updog?"}return"Hi there! This is a demo response!"}},{key:"getCustomResponse",value:function(e,t){return"function"==typeof e?e(t):e}},{key:"getResponse",value:function(t){var n=t.customDemoResponse,r=t.messageToElements;return n?e.getCustomResponse(n,r[r.length-1][0]):{text:e.generateResponse(r)}}},{key:"request",value:function(t,n){var r=e.getResponse(n);setTimeout(A(C().mark((function e(){var i,a,s;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,dn.basicResponseProcessing(n,r,{io:t});case 2:if(i=e.sent){e.next=5;break}return e.abrupt("return",t.completionsHandlers.onFinish());case 5:a=Array.isArray(i)?i:[i],(s=a.find((function(e){return"string"==typeof e.error})))?(n.addNewErrorMessage("service",s.error),t.completionsHandlers.onFinish()):_n.isSimulatable(t.stream,i)?_n.simulate(n,t.streamHandlers,i):(a.forEach((function(e){return n.addNewMessage(e)})),t.completionsHandlers.onFinish());case 7:case"end":return e.stop()}}),e)}))),400)}},{key:"requestStream",value:function(t,n){setTimeout((function(){var r=e.getResponse(t);_n.simulate(t,n.streamHandlers,r,n)}),400)}}])}();wn.URL="deep-chat-demo";var kn=wn,Sn=function(){function e(){R(this,e)}return N(e,null,[{key:"setup",value:function(e){e.permittedErrorPrefixes=["Connection error","Error in server message"],e.websocket="pending"}},{key:"isElementPresentInDOM",value:function(e){return e.getRootNode({composed:!0})instanceof Document}},{key:"createConnection",value:function(t,n){if(e.isElementPresentInDOM(t.deepChat)){var r=t.connectSettings.websocket;if(r){if(t.connectSettings.handler)return xn.websocket(t,n);try{var i="boolean"!=typeof r?r:void 0,a=new WebSocket(t.connectSettings.url||"",i);t.websocket=a,t.websocket.onopen=function(){var r,i;n.removeError(),t.websocket&&"object"==O(t.websocket)&&e.assignListeners(t,a,n),null==(i=(r=t.deepChat)._validationHandler)||i.call(r)},t.websocket.onerror=function(r){console.error(r),e.retryConnection(t,n)}}catch(i){console.error(i),e.retryConnection(t,n)}}}}},{key:"retryConnection",value:function(t,n){var r,i;null==(i=(r=t.deepChat)._validationHandler)||i.call(r),e.isElementPresentInDOM(t.deepChat)&&(t.websocket="pending",n.isLastMessageError()||n.addNewErrorMessage("service","Connection error"),setTimeout((function(){e.createConnection(t,n)}),5e3))}},{key:"assignListeners",value:function(t,n,r){var i=this,a={};n.onmessage=function(){var n=A(C().mark((function n(s){var o,l,c,u,d,h;return C().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!t.extractResultData){n.next=22;break}return n.prev=1,o=JSON.parse(s.data),n.next=5,dn.basicResponseProcessing(r,o,{io:t,displayError:!1});case 5:if(l=n.sent){n.next=8;break}throw Error(ne.INVALID_RESPONSE(o,"server",!!t.deepChat.responseInterceptor,l));case 8:if(!_n.isSimulation(t.stream)){n.next=13;break}c=e.stream.bind(i,t,r,a),u=a[o.role||on.AI_ROLE],_n.upsertWFiles(r,c,u,l),n.next=17;break;case 13:if(d=Array.isArray(l)?l:[l],!(h=d.find((function(e){return"string"==typeof e.error})))){n.next=16;break}throw h.error;
2case 16:d.forEach((function(e){return r.addNewMessage(e)}));case 17:n.next=22;break;case 19:n.prev=19,n.t0=n.catch(1),dn.displayError(r,n.t0,"Error in server message");case 22:case"end":return n.stop()}}),n,null,[[1,19]])})));return function(e){return n.apply(this,arguments)}}(),n.onclose=function(){console.error("Connection closed"),r.isLastMessageError()||r.addNewErrorMessage("service","Connection error"),t.stream&&t.streamHandlers.abortStream.abort(),e.createConnection(t,r)}}},{key:"sendWebsocket",value:(t=A(C().mark((function t(n,r,i){var a,s,o,l,c,u,d,h,p,f=arguments;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=!(f.length>3&&void 0!==f[3])||f[3],(null==(s=n.connectSettings)?void 0:s.url)!==kn.URL){t.next=3;break}return t.abrupt("return",kn.request(n,i));case 3:if((l=n.websocket)&&"pending"!==l){t.next=6;break}return t.abrupt("return");case 6:return c={body:r,headers:null==(o=n.connectSettings)?void 0:o.headers},t.next=9,dn.processRequestInterceptor(n.deepChat,c);case 9:if(u=t.sent,d=u.body,!(h=u.error)){t.next=14;break}return t.abrupt("return",i.addNewErrorMessage("service",h));case 14:if(e.isWebSocket(l)){t.next=16;break}return t.abrupt("return",l.newUserMessage.listener(d));case 16:p=a?JSON.stringify(d):d,void 0===l.readyState||l.readyState!==l.OPEN?(console.error("Connection is not open"),i.isLastMessageError()||i.addNewErrorMessage("service","Connection error")):(l.send(JSON.stringify(p)),n.completionsHandlers.onFinish());case 18:case"end":return t.stop()}}),t)}))),function(e,n,r){return t.apply(this,arguments)})},{key:"canSendMessage",value:function(t){return!t||"pending"!==t&&(e.isWebSocket(t)?void 0!==t.readyState&&t.readyState===t.OPEN:t.isOpen)}},{key:"isWebSocket",value:function(e){return void 0!==e.send}},{key:"stream",value:function(e,t,n,r){if(r){var i=e.stream.simulation;if("string"==typeof i){var a,s=r.role||on.AI_ROLE,o=n[s];r.text===i||r.html===i?(null==o||o.finaliseStreamedMessage(),delete n[s]):(null!==(a=n[s])&&void 0!==a||(n[s]=new cn(t)),n[s].upsertStreamedMessage(r))}else _n.simulate(t,e.streamHandlers,r)}}}]);var t}(),xn=function(){function e(){R(this,e)}return N(e,null,[{key:"request",value:(t=A(C().mark((function t(n,r,i){var a,s,o,l,c;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=!0,l=function(){var e=A(C().mark((function e(t){var r,a,s;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o){e.next=2;break}return e.abrupt("return");case 2:return o=!1,e.next=5,dn.basicResponseProcessing(i,t,{io:n,displayError:!1});case 5:(r=e.sent)?(a=Array.isArray(r)?r:[r],(s=a.find((function(e){return"string"==typeof e.error})))?(console.error(s.error),i.addNewErrorMessage("service",s.error),n.completionsHandlers.onFinish()):_n.isSimulatable(n.stream,r)?_n.simulate(i,n.streamHandlers,r):(a.forEach((function(e){return i.addNewMessage(e)})),n.completionsHandlers.onFinish())):(console.error(ne.INVALID_RESPONSE(t,"server",!!n.deepChat.responseInterceptor,r)),i.addNewErrorMessage("service","Error in server message"),n.completionsHandlers.onFinish());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),c=e.generateOptionalSignals(),null==(s=(a=n.connectSettings).handler)||s.call(a,r,I(I({},c),{},{onResponse:l}));case 3:case"end":return t.stop()}}),t)}))),function(e,n,r){return t.apply(this,arguments)})},{key:"attemptToFinaliseStream",value:function(e,t){try{var n=t.messageElementRefs[t.messageElementRefs.length-1];an.isLoadingMessage(n)?t.removeLastMessage():e.finaliseStreamedMessage()}catch(n){console.error(n),t.addNewErrorMessage("service",n)}}},{key:"stream",value:function(t,n,r){var i,a,s=!0,o=!1,l=new cn(r),c=function(){var n=A(C().mark((function n(i){var a,o;return C().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(s){n.next=2;break}return n.abrupt("return");case 2:return n.next=4,dn.basicResponseProcessing(r,i,{io:t,displayError:!1});case 4:(a=n.sent)?a.error?(e.streamError(a.error,l,t,r),s=!1):_n.upsertWFiles(r,l.upsertStreamedMessage.bind(l),l,a):(o=ne.INVALID_RESPONSE(i,"server",!!t.deepChat.responseInterceptor,a),e.streamError(o,l,t,r),s=!1);case 6:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}();t.streamHandlers.abortStream.abort=function(){e.attemptToFinaliseStream(l,r),t.streamHandlers.onClose(),s=!1};var u=e.generateOptionalSignals();null==(a=(i=t.connectSettings).handler)||a.call(i,n,I(I({},u),{},{onOpen:function(){o||!s||(t.streamHandlers.onOpen(),o=!0)},onResponse:c,onClose:function(){s&&(e.attemptToFinaliseStream(l,r),t.streamHandlers.onClose(),s=!1)},stopClicked:t.streamHandlers.stopClicked}))}},{key:"streamError",value:function(e,t,n,r){console.error(e),t.finaliseStreamedMessage(),r.addNewErrorMessage("service",e),n.streamHandlers.onClose()}},{key:"websocket",value:function(t,n){var r,i,a=this,s={isOpen:!1,newUserMessage:{listener:function(){}},roleToStream:{}};t.websocket=s;var o=function(){var e=A(C().mark((function e(r){var i,o,l,c,u,d;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s.isOpen){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,dn.basicResponseProcessing(n,r,{io:t,displayError:!1});case 4:(i=e.sent)?(o=Array.isArray(i)?i:[i],l=o.find((function(e){return"string"==typeof e.error})),l?(console.error(l.error),n.isLastMessageError()||n.addNewErrorMessage("service",l.error)):_n.isSimulation(t.stream)?(c=i,u=Sn.stream.bind(a,t,n,s.roleToStream),d=s.roleToStream[c.role||on.AI_ROLE],_n.upsertWFiles(n,u,d,c)):o.forEac
2h((function(e){return n.addNewMessage(e)}))):(console.error(ne.INVALID_RESPONSE(r,"server",!!t.deepChat.responseInterceptor,i)),n.addNewErrorMessage("service","Error in server message"));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),l=e.generateOptionalSignals();null==(i=(r=t.connectSettings).handler)||i.call(r,void 0,I(I({},l),{},{onOpen:function(){n.removeError(),s.isOpen=!0},onResponse:o,onClose:function(){s.isOpen=!1},newUserMessage:s.newUserMessage}))}},{key:"generateOptionalSignals",value:function(){return{onClose:function(){},onOpen:function(){},stopClicked:{listener:function(){}},newUserMessage:{listener:function(){}}}}}]);var t}(),En=function(){function e(){R(this,e)}return N(e,null,[{key:"request",value:(n=A(C().mark((function e(t,n,r){var i,a,s,o,l,c,u,d,h,p,f,m,g=arguments;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=!(g.length>3&&void 0!==g[3])||g[3],l={body:n,headers:null==(a=t.connectSettings)?void 0:a.headers},e.next=4,dn.processRequestInterceptor(t.deepChat,l);case 4:if(c=e.sent,u=c.body,d=c.headers,h=c.error,p=t.completionsHandlers.onFinish,!h){e.next=11;break}return e.abrupt("return",dn.onInterceptorError(r,h,p));case 11:if(null==(s=t.connectSettings)||!s.handler){e.next=13;break}return e.abrupt("return",xn.request(t,u,r));case 13:if((null==(o=t.connectSettings)?void 0:o.url)!==kn.URL){e.next=15;break}return e.abrupt("return",kn.request(t,r));case 15:f=!0,(m=dn.fetch.bind(this,t,d,i))(u).then((function(e){return f=!!e.ok,e})).then((function(e){return dn.processResponseByType(e)})).then(function(){var e=A(C().mark((function e(n){var i,a,s,o;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.extractResultData){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,null==(a=(i=t.deepChat).responseInterceptor)?void 0:a.call(i,n);case 4:if(e.t0=e.sent,e.t0){e.next=7;break}e.t0=n;case 7:return s=e.t0,e.next=10,t.extractResultData(s,m,u);case 10:if(o=e.sent,f){e.next=13;break}throw n;case 13:if(o&&("object"==O(o)||Array.isArray(o))){e.next=15;break}throw Error(ne.INVALID_RESPONSE(n,"response",!!t.deepChat.responseInterceptor,s));case 15:o.makingAnotherRequest||(_n.isSimulatable(t.stream,o)?_n.simulate(r,t.streamHandlers,o):((Array.isArray(o)?o:[o]).forEach((function(e){return r.addNewMessage(e)})),p()));case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){dn.displayError(r,e),p()}));case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"executePollRequest",value:function(t,n,r,i){var a=t.completionsHandlers.onFinish;fetch(n,r).then((function(e){return e.json()})).then(function(){var s=A(C().mark((function s(o){var l,c,u;return C().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(t.extractPollResultData){s.next=2;break}return s.abrupt("return");case 2:return s.t0=t,s.next=5,null==(c=(l=t.deepChat).responseInterceptor)?void 0:c.call(l,o);case 5:if(s.t1=s.sent,s.t1){s.next=8;break}s.t1=o;case 8:return s.t2=s.t1,s.next=11,s.t0.extractPollResultData.call(s.t0,s.t2);case 11:(u=s.sent).timeoutMS?setTimeout((function(){e.executePollRequest(t,n,r,i)}),u.timeoutMS):_n.isSimulatable(t.stream,u)?_n.simulate(i,t.streamHandlers,u):(i.addNewMessage(u),a());case 13:case"end":return s.stop()}}),s)})));return function(e){return s.apply(this,arguments)}}()).catch((function(e){dn.displayError(i,e),a()}))}},{key:"poll",value:(t=A(C().mark((function t(n,r,i){var a,s,o,l,c,u,d,h,p,f,m,g,v,y=arguments;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=!(y.length>3&&void 0!==y[3])||y[3],c={body:r,headers:null==(s=n.connectSettings)?void 0:s.headers},t.next=4,dn.processRequestInterceptor(n.deepChat,c);case 4:if(u=t.sent,d=u.body,h=u.headers,!(p=u.error)){t.next=10;break}return t.abrupt("return",dn.onInterceptorError(i,p));case 10:f=(null==(o=n.connectSettings)?void 0:o.url)||n.url||"",m=(null==(l=n.connectSettings)?void 0:l.method)||"POST",g=a?JSON.stringify(d):d,v={method:m,body:g,headers:h},n.connectSettings.credentials&&(v.credentials=n.connectSettings.credentials),e.executePollRequest(n,f,v,i);case 12:case"end":return t.stop()}}),t)}))),function(e,n,r){return t.apply(this,arguments)})},{key:"verifyKey",value:function(e,t,n,r,i,a,s,o,l){if(""===e)return a(ne.INVA
2LID_KEY);s(),fetch(t,{method:r,headers:n,body:l||null}).then((function(e){return dn.processResponseByType(e)})).then((function(t){o(t,e,i,a)})).catch((function(e){a(ne.CONNECTION_FAILED),console.error(e)}))}}]);var t,n}(),Cn=function(){function e(t,n,r){R(this,e),this._isLoading=!1,this._isPaginationComplete=!1,this._index=0,this._messages=n,r.fetchHistory&&this.fetchHistory(r.fetchHistory),t.loadHistory&&this.setupLoadHistoryOnScroll(t.loadHistory),this.setupInitialHistory(t)}return N(e,[{key:"fetchHistory",value:(i=A(C().mark((function t(n){var r,i,a=this;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Jt.addMessage(this._messages),t.next=3,n();case 3:i=t.sent,this._messages.removeMessage(r),e.displayIntroMessages(this._messages.messageElementRefs),i.forEach((function(e){return a._messages.addAnyMessage(e,!0)})),setTimeout((function(){return ie.scrollToBottom(a._messages.elementRef)}),0);case 5:case"end":return t.stop()}}),t,this)}))),function(e){return i.apply(this,arguments)})},{key:"processLoadedHistory",value:function(e){var t,n=this,r=this._messages,i=r.messageElementRefs,a=r.messageToElements,s=r.elementRef,o=null==(t=i.find((function(e){return!e.outerContainer.classList.contains(an.INTRO_CLASS)})))?void 0:t.outerContainer,l=s.scrollTop;null==e||e.reverse().map((function(e){var t=n._messages.addAnyMessage(I(I({},e),{},{sendUpdate:!0}),!0,!0);if(t){var r=on.generateMessageBody(t,i,!0);a.unshift([t,r])}return t})).filter((function(e){return!!e})).reverse().forEach((function(e){return n._messages.sendClientUpdate(e,!0)})),o&&(s.scrollTop=l+o.offsetTop-40)}},{key:"populateMessages",value:function(e,t){this._messages.removeMessage(e),this._isPaginationComplete=t.findIndex((function(e){return!e}))<0;var n=t.filter((function(e){return!!e}));this.processLoadedHistory(n);var r=this._messages,i=r.messageElementRefs,a=r.avatar,s=r.name;on.resetAllRoleElements(i,a,s)}},{key:"setupLoadHistoryOnScroll",value:(r=A(C().mark((function t(n){var r=this;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._messages.elementRef.onscroll=A(C().mark((function t(){var i,a;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r._isLoading||r._isPaginationComplete||0!==r._messages.elementRef.scrollTop){t.next=13;break}return r._isLoading=!0,i=Jt.addMessage(r._messages,!1),t.prev=3,t.next=6,n(r._index++);case 6:a=t.sent,r.populateMessages(i,a),r._isLoading=!1,t.next=13;break;case 10:t.prev=10,t.t0=t.catch(3),r._messages.removeMessage(i),r._isPaginationComplete=!0,r._messages.addNewErrorMessage("service",e.FAILED_ERROR_MESSAGE,!0),console.error(t.t0);case 13:case"end":return t.stop()}}),t,null,[[3,10]])})));case 1:case"end":return t.stop()}}),t,this)}))),function(e){return r.apply(this,arguments)})},{key:"populateInitialHistory",value:function(e){var t=this;e.forEach((function(e){de.processHistoryFile(e),t._messages.addAnyMessage(e,!0)}))}},{key:"loadInitialHistory",value:(n=A(C().mark((function t(n){var r,i,a,s=this;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._isLoading=!0,r=Jt.addMessage(this._messages),t.prev=2,t.next=5,n(this._index++);case 5:i=t.sent,a=this._messages.elementRef.scrollTop,this.populateMessages(r,i),0===a&&setTimeout((function(){return ie.scrollToBottom(s._messages.elementRef)}),0),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),this._messages.removeMessage(r),this._isPaginationComplete=!0,this._messages.addNewErrorMessage("service",e.FAILED_ERROR_MESSAGE,!0),console.error(t.t0);case 13:e.displayIntroMessages(this._messages.messageElementRefs),this._isLoading=!1;case 14:case"end":return t.stop()}}),t,this,[[2,10]])}))),function(e){return n.apply(this,arguments)})},{key:"setupInitialHistory",value:(t=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.loadHistory&&this.loadInitialHistory(t.loadHistory),(n=t.history||de.processHistory(t))&&(this.populateInitialHistory(n),this._index+=1);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"addErrorPrefix",value:function(t){var n;
2null!==(n=t.permittedErrorPrefixes)&&void 0!==n||(t.permittedErrorPrefixes=[]),t.permittedErrorPrefixes.push(e.FAILED_ERROR_MESSAGE)}},{key:"displayIntroMessages",value:function(e){for(var t=0;t<e.length;t+=1){var n=e[0];if(!n.outerContainer.classList.contains(an.INTRO_CLASS))break;n.outerContainer.style.display=""}}}]);var t,n,r,i}();Cn.FAILED_ERROR_MESSAGE="Failed to load history";var Tn=Cn,An=function(){function e(){R(this,e)}return N(e,null,[{key:"getCharacterLimitMessages",value:function(e,t){var n;if(-1===t)return e;for(var r=0,i=e.length-1;i>=0;i-=1){var a=null==(n=e[i])?void 0:n.text;if(void 0!==a&&(r+=a.length)>t){e[i].text=a.substring(0,a.length-(r-t));break}}return e.slice(Math.max(i,0))}},{key:"getMaxMessages",value:function(e,t){return e.slice(Math.max(e.length-t,0))}},{key:"processMessages",value:function(t,n,r){return void 0!==n?n>0&&(t=e.getMaxMessages(t,n)):t=[t[t.length-1]],t=JSON.parse(JSON.stringify(t)),void 0===r?t:e.getCharacterLimitMessages(t,r)}}])}(),Mn=function(){function e(){R(this,e)}return N(e,null,[{key:"parseConfig",value:function(e,t,n,r){var i,a={files:t};if("object"==O(r)){de.processFileConfigConnect(r);var s=r.files,o=r.connect,l=r.button;s&&(s.infoModal&&(a.files.infoModal=s.infoModal,null!=(i=s.infoModal)&&i.textMarkDown&&(a.infoModalTextMarkUp=n.render(s.infoModal.textMarkDown))),s.acceptedFormats&&(a.files.acceptedFormats=s.acceptedFormats),s.maxNumberOfFiles&&(a.files.maxNumberOfFiles=s.maxNumberOfFiles)),a.button=l,o&&(o.headers||o.method||o.url||o.credentials||e.headers||e.method||e.url||e.credentials)&&(a.connect={url:(null==o?void 0:o.url)||e.url,method:(null==o?void 0:o.method)||e.method,headers:(null==o?void 0:o.headers)||e.headers,credentials:(null==o?void 0:o.credentials)||e.credentials})}return a}},{key:"processMixedFiles",value:function(t,n,r){if(r){t.fileTypes.mixedFiles=e.parseConfig(t.connectSettings,{acceptedFormats:""},n,r)}}},{key:"processMicrophone",value:function(t,n,r,i){var a,s,o,l,c,u,d,h,p=I({acceptedFormats:"audio/*"},(null==(o=t.fileTypes.audio)?void 0:o.files)||{});r&&(void 0!==navigator.mediaDevices.getUserMedia?(t.recordAudio=e.parseConfig(t.connectSettings,p,n,r),"object"==O(r)&&r.files&&(null!==(a=(l=t.recordAudio).files)&&void 0!==a||(l.files={}),t.recordAudio.files.format=null==(c=r.files)?void 0:c.format,t.recordAudio.files.maxDurationSeconds=null==(u=r.files)?void 0:u.maxDurationSeconds,null!=(d=t.fileTypes.audio)&&d.files&&(null!==(s=(h=t.fileTypes.audio.files).maxNumberOfFiles)&&void 0!==s||(h.maxNumberOfFiles=r.files.maxNumberOfFiles)))):i||(t.fileTypes.audio=e.parseConfig(t.connectSettings,p,n,r)))}},{key:"processAudioConfig",value:function(t,n,r,i){if(r||i){var a=I({acceptedFormats:"audio/*"},(null==i?void 0:i.files)||{});t.fileTypes.audio=e.parseConfig(t.connectSettings,a,n,r)}}},{key:"processGifConfig",value:function(t,n,r,i){if(r||i){var a=I({acceptedFormats:"image/gif"},(null==i?void 0:i.files)||{});t.fileTypes.gifs=e.parseConfig(t.connectSettings,a,n,r)}}},{key:"processCamera",value:function(t,n,r,i){var a,s,o,l,c,u=I({acceptedFormats:"image/*"},(null==(s=t.fileTypes.images)?void 0:s.files)||{});r&&(void 0!==navigator.mediaDevices.getUserMedia?(t.camera=e.parseConfig(t.connectSettings,u,n,r),"object"==O(r)&&(t.camera.modalContainerStyle=r.modalContainerStyle,r.files&&(null!==(a=(o=t.camera).files)&&void 0!==a||(o.files={}),t.camera.files.format=null==(l=r.files)?void 0:l.format,t.camera.files.dimensions=null==(c=r.files)?void 0:c.dimensions))):i||(t.fileTypes.images=e.parseConfig(t.connectSettings,u,n,r)))}},{key:"processImagesConfig",value:function(t,n,r,i){if(r||i){var a=I({acceptedFormats:"image/*"},(null==i?void 0:i.files)||{});t.fileTypes.images=e.parseConfig(t.connectSettings,a,n,r)}}},{key:"populateDefaultFileIO",value:function(e,t){var n,r,i,a,s;e&&(null!==(n=e.files)&&void 0!==n||(e.files={}),null!==(r=(a=e.files).acceptedFormats)&&void 0!==r||(a.acceptedFormats=t),null!==(i=(s=e.files).maxNumberOfFiles)&&void 0!==i||(s.maxNumberOfFiles=1))}},{key:"set",value:function(t,n,r){e.populateDefaultFileIO(null==r?void 0:r.audio,".4a,.mp3,.webm,.mp4,.mpga,.wav,.mpeg,.m4a"),e.populateDefaultFileIO(null==r?void 0:r.images,".png,.jpg");var i=Gt.createNew(t.remarkable);e.processImagesConfig(n,i,t.images,null==r?void 0:r.images),e.processCamera(n,i,t.camera,t.images),e.processGifConfig(n,i,t.gifs,null==r?void 0:r.gifs),e.processAudioConfig(n,i,t.audio,null==r?void 0:r.audio),e.processMicrophone(n,i,t.microphone,t.audio),e.processMixedFiles(n,i,t.mixedFiles)}}])}(),In=function(){function e(t,n,r){var i,a,s,o,l,c;R(this,e),this.rawBody={},this.validateKeyProperty=!1,this.canSendMessage=e.canSendMessage,this.connectSettings={},this.fileTypes={},this.completionsHandlers={},this.streamHandlers={},this.deepChat=t,this.demo=r,Object.assign(this.rawBody,null==(a=t.connect)?void 0:a.additionalBodyProps),this.totalMessagesMaxCharLength=null==(s=null==t?void 0:t.requestBodyLimits)?void 0:s.totalMessagesMaxCharLength,this.maxMessages=null==(o=null==t?void 0:t.requestBodyLimits)?void 0:o.maxMessages,Mn.set(t,this,n),t.connect&&(this.connectSettings=t.connect),this.demo&&(null!==(i=(l=this.connectSettings).url)&&void 0!==i||(l.url=kn.URL)),this.connectSettings.websocket&&Sn.setup(this),this.stream=(null==(c=this.deepChat.connect)?void 0:c.stream)||de.checkForStream(this.deepChat),t.loadHistory&&Tn.addErrorPrefix(this)}return N(e,[{key:"verifyKey",value:function(e,t){}},{key:"getServiceIOByType",value:function(e){if(e.type.startsWith("audio")&&this.fileTypes.audio)return this.fileTypes.audio;if(e.type.startsWith("image")){if(this.fileTypes.gifs&&e.type.endsWith("/gif"))return this.fileTypes.gifs;if(this.fileTypes.images)return this.fileTypes.images;if(this.camera)return this.camera}return this.fileTypes.mixedFiles}},{key:"request",value:(s=A(C().mark((function e(t,n){var r,i=arguments;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=!(i.length>2&&void 0!==i[2])||i[2],e.abrupt("return",this.stream&&!_n.isSimulation(this.stream)?_n.request(this,t,n,r):En.request(this,t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"callAPIWithText",value:(a=A(C().mark((function e(t,n){var r,i,a,s,o,l,c,u;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=I({messages:n},this.rawBody),u=!1,null!=(a=this.connectSettings.headers)&&a["Content-Type"]||(null!==(r=(s=this.connectSettings).headers)&&void 0!==r||(s.headers={}),null!==(i=(o=this.connectSettings.headers)["Content-Type"])&&void 0!==i||(o["Content-Type"]="application/json"),u=!0),e.next=5,this.request(c,t);case 5:u&&(null==(l=this.connectSettings.headers)||delete l["Content-Type"]);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"callApiWithFiles",value:(i=A(C().mark((function t(n,r,i){var a,s,o;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.createCustomFormDataBody(this.rawBody,r,i),s=this.connectSettings,o=this.getServiceIOByType(i[0]),this.connectSettings=(null==o?void 0:o.connect)||this.connectSettings,t.next=4,this.request(a,n,!1);case 4:this.connectSettings=s;case 5:case"end":return t.stop()}}),t,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n,r){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r?this.callApiWithFiles(t,n,r):this.callAPIWithText(t,n);case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"callAPI",value:(n=A(C().mark((function e(t,n){var r,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=An.processMessages(n.messageToElements.map((function(e){return g(e,1)[0]})),this.maxMessages,this.totalMessagesMaxCharLength),!this.connectSettings.websocket||this.connectSettings.handler&&this.connectSettings.url===kn.URL?this.callServiceAPI(n,r,t.files):(i=I({messages:r},this.rawBody),Sn.sendWebsocket(this,i,n,!1));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"extractResultData",value:(t=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.result){e.next=2;break}return e.abrupt("return",de.handleResponseProperty(t));case 2:if(!dn.validateResponseFormat(t,!!this.stream)){e.next=4;break}return e.abrupt("return",t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"isDirectConnection",value:function(){return!1}},{key:"isWebModel",value:function(){return!1}},{key:"isCustomView",value:function(){return!1}}],[{key:"canSendMessage",value:function(e,t,n){return!!n||(!(!e||""===e.trim())||!!(t&&t.length>0))}},{key:"createCustomFormDataBody",value:function(e,t,n){var r=new FormData;
2n.forEach((function(e){return r.append("files",e)})),Object.keys(e).forEach((function(t){return r.append(t,String(e[t]))}));var i=0;t.slice(0,t.length-1).forEach((function(e){r.append("message".concat(i+=1),JSON.stringify(e))}));var a=t[t.length-1];return a.text&&(delete a.files,r.append("message".concat(i+=1),JSON.stringify(a))),r}}]);var t,n,r,i,a,s}(),Ln=function(e){function t(e,n,r,i,a){var s,o;return R(this,t),(s=_(this,t,[e,a])).insertKeyPlaceholderText="API Key",s.keyHelpUrl="",Object.assign(s.rawBody,null==(o=e.connect)?void 0:o.additionalBodyProps),s.keyVerificationDetails=n,s.buildHeadersFunc=r,i&&s.setApiKeyProperties(i),s.connectSettings=s.buildConnectSettings(s.key||"",e.connect),s}return x(t,e),N(t,[{key:"setApiKeyProperties",value:function(e){this.key=e.key,e.validateKeyProperty&&(this.validateKeyProperty=e.validateKeyProperty)}},{key:"buildConnectSettings",value:function(e,t){var n,r=null!=t?t:{};return null!==(n=r.headers)&&void 0!==n||(r.headers={}),Object.assign(r.headers,this.buildHeadersFunc(e)),r}},{key:"keyAuthenticated",value:function(e,t){this.connectSettings=this.buildConnectSettings(t,this.connectSettings),this.key=t,e()}},{key:"verifyKey",value:function(e,t){var n=this.keyVerificationDetails,r=n.url,i=n.method,a=n.handleVerificationResult,s=n.createHeaders,o=n.body,l=(null==s?void 0:s(e))||this.buildHeadersFunc(e);En.verifyKey(e,r,l,i,this.keyAuthenticated.bind(this,t.onSuccess),t.onFail,t.onLoad,a,o)}},{key:"isDirectConnection",value:function(){return!0}}])}(In),On=function(){function e(){R(this,e)}return N(e,null,[{key:"waitForPropertiesToBeUpdatedBeforeRender",value:function(t){t._propUpdated_=!1,setTimeout((function(){t._propUpdated_?e.waitForPropertiesToBeUpdatedBeforeRender(t):(t._waitingToRender_=!1,t.onRender())}))}},{key:"attemptRender",value:function(t){t._propUpdated_=!0,t._waitingToRender_||(t._waitingToRender_=!0,e.waitForPropertiesToBeUpdatedBeforeRender(t))}}])}(),Rn=function(e){function t(){var e;return R(this,t),(e=_(this,t))._waitingToRender_=!1,e._propUpdated_=!1,Object.keys(t._attributeToProperty_).forEach((function(n){var r=t._attributeToProperty_[n];e.constructPropertyAccessors(r),e.hasOwnProperty(n)||e.constructPropertyAccessors(r,n)})),e}return x(t,e),N(t,[{key:"constructPropertyAccessors",value:function(e,t){var n;Object.defineProperty(this,t||e,{get:function(){return n},set:function(r){n=r,t?this[e]=r:On.attemptRender(this)}})}},{key:"attributeChangedCallback",value:function(e,n,r){if(n!==r){var i=t._attributes_[e](r);this[t._attributeToProperty_[e]]=i}}},{key:"onRender",value:function(){}}],[{key:"observedAttributes",get:function(){return Object.keys(t._attributes_)||[]}}])}(f(HTMLElement));Rn._attributes_={},Rn._attributeToProperty_={};var Pn=Rn,Nn=function(){return N((function e(){R(this,e)}),null,[{key:"createSVGElement",value:function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}}])}(),jn=function(){function e(){R(this,e)}return N(e,null,[{key:"changeVisibility",value:function(t,n,r,i){i.target.id===e.VISIBLE_ICON_ID?(n.style.display="none",r.style.display="block",t.type="password"):(n.style.display="block",r.style.display="none",t.type="text")}},{key:"createIconElement",value:function(e,t){var n=Nn.createSVGElement(e);return n.id=t,n.classList.add("visibility-icon"),n}},{key:"create",value:function(t){var n=document.createElement("div");n.id="visibility-icon-container";var r=e.createIconElement('<?xml version="1.0" standalone="no"?>\n<svg version="1.1"\n\txmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n\txmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="0.9em" height="0.9em"\n\tviewBox="0 0 1200 1200" enable-background="new 0 0 1200 1200">\n\t\t<path id="path6686" inkscape:connector-curvature="0" d="M779.843,599.925c0,95.331-80.664,172.612-180.169,172.612\n\t\t\tc-99.504,0-180.168-77.281-180.168-172.612c0-95.332,80.664-172.612,180.168-172.612\n\t\t\tC699.179,427.312,779.843,504.594,779.843,599.925z M600,240.521c-103.025,0.457-209.814,25.538-310.9
204,73.557\n\t\t\tc-75.058,37.122-148.206,89.496-211.702,154.141C46.208,501.218,6.431,549,0,599.981c0.76,44.161,48.13,98.669,77.394,131.763\n\t\t\tc59.543,62.106,130.786,113.018,211.702,154.179c94.271,45.751,198.616,72.092,310.904,73.557\n\t\t\tc103.123-0.464,209.888-25.834,310.866-73.557c75.058-37.122,148.243-89.534,211.74-154.179\n\t\t\tc31.185-32.999,70.962-80.782,77.394-131.763c-0.76-44.161-48.13-98.671-77.394-131.764\n\t\t\tc-59.543-62.106-130.824-112.979-211.74-154.141C816.644,268.36,712.042,242.2,600,240.521z M599.924,329.769\n\t\t\tc156.119,0,282.675,120.994,282.675,270.251c0,149.256-126.556,270.25-282.675,270.25S317.249,749.275,317.249,600.02\n\t\t\tC317.249,450.763,443.805,329.769,599.924,329.769L599.924,329.769z"/>\n</svg>\n',e.VISIBLE_ICON_ID);r.style.display="none",n.appendChild(r);var i=e.createIconElement('<?xml version="1.0" standalone="no"?>\n<svg version="1.1"\n\txmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n\txmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="0.9em" height="0.9em"\n\tviewBox="0 0 1200 1200" enable-background="new 0 0 1200 1200">\n\t\t<path d="\n\t\t\tM669.727,273.516c-22.891-2.476-46.15-3.895-69.727-4.248c-103.025,0.457-209.823,25.517-310.913,73.536\n\t\t\tc-75.058,37.122-148.173,89.529-211.67,154.174C46.232,529.978,6.431,577.76,0,628.74c0.76,44.162,48.153,98.67,77.417,131.764\n\t\t\tc59.543,62.106,130.754,113.013,211.67,154.174c2.75,1.335,5.51,2.654,8.276,3.955l-75.072,131.102l102.005,60.286l551.416-960.033\n\t\t\tl-98.186-60.008L669.727,273.516z M902.563,338.995l-74.927,129.857c34.47,44.782,54.932,100.006,54.932,159.888\n\t\t\tc0,149.257-126.522,270.264-282.642,270.264c-6.749,0-13.29-0.728-19.922-1.172l-49.585,85.84c22.868,2.449,45.99,4.233,69.58,4.541\n\t\t\tc103.123-0.463,209.861-25.812,310.84-73.535c75.058-37.122,148.246-89.529,211.743-154.174\n\t\t\tc31.186-32.999,70.985-80.782,77.417-131.764c-0.76-44.161-48.153-98.669-77.417-131.763\n\t\t\tc-59.543-62.106-130.827-113.013-211.743-154.175C908.108,341.478,905.312,340.287,902.563,338.995L902.563,338.995z\n\t\t\tM599.927,358.478c6.846,0,13.638,0.274,20.361,0.732l-58.081,100.561c-81.514,16.526-142.676,85.88-142.676,168.897\n\t\t\tc0,20.854,3.841,40.819,10.913,59.325c0.008,0.021-0.008,0.053,0,0.074l-58.228,100.854\n\t\t\tc-34.551-44.823-54.932-100.229-54.932-160.182C317.285,479.484,443.808,358.477,599.927,358.478L599.927,358.478z M768.896,570.513\n\t\t\tL638.013,797.271c81.076-16.837,141.797-85.875,141.797-168.603C779.81,608.194,775.724,588.729,768.896,570.513L768.896,570.513z"\n\t\t\t/>\n</svg>\n',"not-visible-icon");return n.appendChild(i),n.onclick=e.changeVisibility.bind(this,t,r,i),n}}])}();jn.VISIBLE_ICON_ID="visible-icon";var Dn=jn,Bn=function(){function e(){R(this,e)}return N(e,null,[{key:"createCautionText",value:function(){var e=document.createElement("a");return e.classList.add("insert-key-input-help-text"),e.innerText="Please exercise CAUTION when inserting your API key outside of deepchat.dev or localhost!!",e}},{key:"createHelpLink",value:function(e){var t=document.createElement("a");return t.classList.add("insert-key-input-help-text"),t.href=e,t.innerText="Find more info here",t.target="_blank",t}},{key:"createFailText",value:function(){var e=document.createElement("div");return e.id="insert-key-input-invalid-text",e.style.display="none",e}},{key:"createHelpTextContainer",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=document.createElement("div");r.id="insert-key-help-text-container";var i=document.createElement("div");i.id="insert-key-help-text-contents";var a=e.createFailText();if(i.appendChild(a),t){var s=e.createHelpLink(t);i.appendChild(s)}if(!0===n){var o=e.createCautionText();i.appendChild(o)}return r.appendChild(i),{helpTextContainerElement:r,failTextElement:a}}},{key:"onFail",value:function(e,t,n,r){e.classList.replace("insert-key-input-valid","insert-key-input-invalid"),n.innerText=r,n.style.display="block",t.innerText="Start",e.classList.remove("loading")}},{key:"onLoad",value:function(e,t){e.classList.add("loading"),t.innerHTML='<div id="loading-key"></div>'}},{key:"verifyKey",value:function(e,t,n){var r=e.value.trim();n.verifyKey(r,t)}},{key:"addVerificationEvents",value:function(t,n,r,i,a){var s={onSuccess:i,onFail:e.onFail.bind(this,t,n,r),onLoad:e.onLoad.bind(this,t,n)},o=e.verifyKey.bind(this,t,s,a);n.onclick=o,t.onkeydown=function(e){!t.classList.contains("loading")&&e.key===W.ENTER&&o()}}},{key:"createStartButton",value:function(){var e=document.createElement("div");return e.id="start-button",e.innerText="Start",e}},{key:"onInputFocus",value:function(e){e.target.classList.replace("insert-key-input-invalid","insert-key-input-valid")}},{key:"createInput",value:function(t){var n=document.createElement("div");n.id="insert-key-input-container";var r=document.createElement("input");return r.id="insert-key-input",r.placeholder=t||"API Key",r.type="password",r.classList.add("insert-key-input-valid"),r.onfocus=e.onInputFocus,n.appendChild(r),n}},{key:"createContents",value:function(t,n){var r,i=document.createElement("div");i.id="insert-key-contents";var a=e.createInput(n.insertKeyPlaceholderText),s=a.children[0],o=Dn.create(s);a.appendChild(o),i.appendChild(a);var l=e.createStartButton(),c=e.createHelpTextContainer(n.keyHelpUrl,null==(r=n.deepChat._insertKeyViewStyles)?void 0:r.displayCautionText),u=c.helpTextContainerElement,d=c.failTextElement;return i.appendChild(l),i.appendChild(u),e.addVerificationEvents(s,l,d,t,n),i}},{key:"createElements",value:function(t,n){var r=document.createElement("div");r.id="insert-key-view";var i=e.createContents(t,n);return r.appendChild(i),r}},{key:"render",value:function(t,n,r){var i=e.createElements(n,r);t.replaceChildren(i)}}])}(),Fn=function(){function e(){R(this,e)}return N(e,null,[{key:"enableButtons",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;window.webLLM?(t&&(t.disabled=!1),n&&(n.disabled=!1)):r<4*Hn.MODULE_SEARCH_LIMIT_S&&setTimeout((function(){return e.enableButtons(t,n,r+1)}),250)}},{key:"setUpInitial",value:function(t,n,r,i){var a=(null==n?void 0:n.downloadClass)||e.DOWNLOAD_BUTTON_CLASS,s=(null==n?void 0:n.uploadClass)||e.UPLOAD_BUTTON_CLASS,o=(null==n?void 0:n.fileInputClass)||e.FILE_INPUT_CLASS;return setTimeout((function(){var n=null==r?void 0:r.getElementsByClassName(a)[0],i=null==r?void 0:r.getElementsByClassName(o)[
20],l=null==r?void 0:r.getElementsByClassName(s)[0];n&&(n.onclick=function(){return t()}),i&&(i.onchange=function(){i.files&&i.files.length>0&&t(i.files)}),l&&(l.onclick=function(){return i.click()}),(n||l)&&e.enableButtons(n,l)})),(null==n?void 0:n.initialHtml)||'<div>\n        Download or upload a web model that will run entirely on your browser: <br/> \n        <button disabled class="'.concat(a,' deep-chat-button deep-chat-web-model-button">Download</button>\n        ').concat(i?"":'<input type="file" class="'.concat(o,'" hidden multiple />\n          <button disabled class="').concat(s,' deep-chat-button deep-chat-web-model-button">Upload</button>'),"\n      </div>")}},{key:"exportFile",value:function(e){for(var t=document.createElement("a"),n=function(n){setTimeout((function(){for(var r=4*n,i=r;i<Math.min(r+4,e.length);i+=1){var a=URL.createObjectURL(e[i]);t.href=a,t.download=e[i].name,document.body.appendChild(t),t.click(),URL.revokeObjectURL(a)}}),500*n)},r=0;r<e.length/4;r+=1)n(r)}},{key:"setUpAfterLoad",value:function(t,n,r,i){var a=(null==n?void 0:n.exportFilesClass)||e.EXPORT_BUTTON_CLASS;return setTimeout((function(){var n=null==r?void 0:r.getElementsByClassName(a)[0];n&&(n.onclick=function(){return e.exportFile(t)})})),(null==n?void 0:n.afterLoadHtml)||"<div>\n        Model loaded successfully and has been cached for future requests.\n        ".concat(i?"":'<br/> <button style="margin-top: 5px" class="'.concat(a,' deep-chat-button">Export</button>'),"\n      </div>")}}])}();Fn.DOWNLOAD_BUTTON_CLASS="deep-chat-download-button",Fn.UPLOAD_BUTTON_CLASS="deep-chat-upload-button",Fn.FILE_INPUT_CLASS="deep-chat-file-input",Fn.EXPORT_BUTTON_CLASS="deep-chat-export-button";var Un=Fn,zn={model_list:[{model_url:"https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f32_1-MLC/resolve/main/",local_id:"Llama-2-7b-chat-hf-q4f32_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f32_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:9109.03,low_resource_required:!1},{model_url:"https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-7b-chat-hf-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f16_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:6749.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-7b-chat-hf-q4f16_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f16_1-ctx1k-webgpu.wasm",vram_required_MB:4618.52,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Llama-2-13b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-13b-chat-hf-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-13b-chat-hf/Llama-2-13b-chat-hf-q4f16_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:11814.09,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Llama-2-70b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-70b-chat-hf-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-70b-chat-hf/Llama-2-70b-chat-hf-q4f16_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:43729.05,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/RedPajama-INCITE-Chat-3B-v1-q4f16_1-MLC/resolve/main/",local_id:"RedPajama-INCITE-Chat-3B-v1-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/RedPajama-INCITE-Chat-3B-v1/RedPajama-INCITE-Chat-3B-v1-q4f16_1-ctx2k-webgpu.wasm",vram_required_MB:2972.09,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/RedPajama-INCITE-Chat-3B-v1-q4f32_1-MLC/resolve/main/",local_id:"RedPajama-INCITE-Chat-3B-v1-q4f32_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/RedPajama-INCITE-Chat-3B-v1/RedPajama-INCITE-Chat-3B-v1-q4f32_1-ctx2k-webgpu.wasm",vram_required_MB:3928.09,low_resource_required:!1},{model_url:"https://huggingface.co/mlc-ai/RedPajama-INCITE-Chat-3B-v1-q4f16_1-MLC/resolve/main/",local_id:"RedPajama-INCITE-Chat-3B-v1-q4f16_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/RedPajama-INCITE-Chat-3B-v1/RedPajama-INCITE-Chat-3B-v1-q4f16_1-ctx1k-webgpu.wasm",vram_required_MB:2041.09,low_resource_required:!0,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/RedPajama-INCITE-Chat-3B-v1-q4f32_1-MLC/resolve/main/",local_id:"RedPajama-INCITE-Chat-3B-v1-q4f32_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/RedPajama-INCITE-Chat-3B-v1/RedPajama-INCITE-Chat-3B-v1-q4f32_1-ctx1k-webgpu.wasm",vram_required_MB:2558.09,low_resource_required:!0},{model_url:"https://huggingface.co/mlc-ai/WizardMath-7B-V1.1-q4f16_1-MLC/resolve/main/",local_id:"WizardMath-7B-V1.1-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Mistral-7B-Instruct-v0.2/Mistral-7B-Instruct-v0.2-q4f16_1-sw4k_cs1k-webgpu.wasm",vram_required_MB:6079.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Mistral-7B-Instruct-v0.2-q4f16_1-MLC/resolve/main/",local_id:"Mistral-7B-Instruct-v0.2-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Mistral-7B-Instruct-v0.2/Mistral-7B-Instruct-v0.2-q4f16_1-sw4k_cs1k-webgpu.wasm",vram_required_MB:6079.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/OpenHermes-2.5-Mistral-7B-q4f16_1-MLC/resolve/main/",local_id:"OpenHermes-2.5-Mistral-7B-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Mistral-7B-Instruct-v0.2/Mistral-7B-Instruct-v0.2-q4f16_1-sw4k_cs1k-webgpu.wasm",vram_required_MB:6079.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/NeuralHermes-2.5-Mistral-7B-q4f16_1-MLC/resolve/main/",local_id:"NeuralHermes-2.5-Mistral-7B-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Mistral-7B-Instruct-v0.2/Mistral-7B-Instruct-v0.2-q4f16_1-sw4k_cs1k-webgpu.wasm",vram_required_MB:6079.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/TinyLlama-1.1B-Chat-v0.4-q0f16-MLC/resolve/main/",local_id:"TinyLlama-1.1B-Chat-v0.4-q0f16",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/TinyLlama-1.1B-Chat-v0.4/TinyLlama-1.1B-Chat-v0.4-q0f16-ctx2k-webgpu.wasm",vram_required_MB:5063.52,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/TinyLlama-1.1B-Chat-v0.4-q0f32-MLC/resolve/main/",local_id:"TinyLlama-1.1B-Chat-v0.4-q0f32",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/TinyLlama-1.1B-Chat-v0.4/TinyLlama-1.1B-Chat-v0.4-q0f32-ctx2k-webgpu.wasm",vram_required_MB:5394.53,low_resource_required:!1},{model_url:"https://huggingface.co/mlc-ai/TinyLlama-1.1B-Chat-v0.4-q4f16_1-MLC/resolve/main/",local_id:"TinyLlama-1.1B-Chat-v0.4-q4f16_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/TinyLlama-1.1B-Chat-v0.4/TinyLlama-1.1B-Chat-v0.4-q4f16_1-ctx1k-webgpu.wasm",vram_required_MB:899.11,low_resource_required:!0,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/TinyLlama-1.1B-Chat-v0.4-q4f32_1-MLC/resolve/main/",local_id:"TinyLlama-1.1B-Chat-v0.4-q4f32_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/TinyLlama-1.1B-Chat-v0.4/TinyLlama-1.1B-Chat-v0.4-q4f32_1-ctx1k-webgpu.wasm",vram_required_MB:992.11,low_resource_required:!0}],use_web_worker:!0},qn=function(e){function t(e){var n,r,i;return R(this,t),(n=_(this,t,[e]))._isModelLoaded=!1,n._isModelLoading=!1,n._loadOnFirstMessage=!1,n._webModel={}
2,n.permittedErrorPrefixes=[t.MULTIPLE_MODELS_ERROR,t.WEB_LLM_NOT_FOUND_ERROR,t.GENERIC_ERROR],n._conversationHistory=[],"object"==O(e.webModel)&&(n._webModel=e.webModel),null!=(r=n._webModel.load)&&r.clearCache&&t.clearAllCache(),n.findModelInWindow(e),n.canSendMessage=n.canSubmit.bind(w(n)),n._chatEl=null==(i=e.shadowRoot)?void 0:i.children[0],e.history&&t.setUpHistory(n._conversationHistory,e.history),n}return x(t,e),N(t,[{key:"setUpMessages",value:function(e){var t=this;this._messages=e,this._removeIntro=function(){e.removeIntroductoryMessage(),t._removeIntro=void 0}}},{key:"findModelInWindow",value:function(e){var n,r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;window.webLLM?this.configureInit(this.shouldAddIntroMessage(e.introMessage)):i>t.MODULE_SEARCH_LIMIT_S?(null==(n=this._messages)||n.addNewErrorMessage("service",t.WEB_LLM_NOT_FOUND_ERROR),console.error("The deep-chat-web-llm module has not been attached to the window object. Please see the following guide:"),console.error("https://deepchat.dev/examples/externalModules")):setTimeout((function(){return r.findModelInWindow(e,i+1)}),1e3)}},{key:"shouldAddIntroMessage",value:function(e){var t;return!e&&this._webModel&&!1!==(null==(t=this._webModel.introMessage)?void 0:t.displayed)}},{key:"scrollToTop",value:function(e){var t,n=this;!1!==(null==(t=this._webModel.introMessage)?void 0:t.autoScroll)&&setTimeout((function(){var e,t;null!=(e=n._messages)&&e.elementRef&&ie.scrollToTop(null==(t=n._messages)?void 0:t.elementRef)}),e)}},{key:"getIntroMessage",value:function(e){if(this.shouldAddIntroMessage(e)&&this._chatEl){var t=Un.setUpInitial(this.init.bind(this),this._webModel.introMessage,this._chatEl,!!this._webModel.worker);return this.scrollToTop(1),{role:on.AI_ROLE,html:t,sendUpdate:!1}}}},{key:"configureInit",value:(d=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this._webModel.load)){e.next=8;break}if(!n.onInit){e.next=5;break}return this.init(),e.abrupt("return");case 5:if(!n.onMessage){e.next=8;break}return this._loadOnFirstMessage=!0,e.abrupt("return");case 8:t||this.init();case 9:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"init",value:(u=A(C().mark((function e(t){var n,r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=this._messages)||n.removeError(),r=this.attemptToCreateChat(),e.t0=r,!e.t0){e.next=6;break}return e.next=6,this.loadModel(r,t);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"attemptToCreateChat",value:function(){var e;if(t.chat)return null==(e=this._messages)||e.addNewErrorMessage("service",t.MULTIPLE_MODELS_ERROR),void console.error(t.MULTIPLE_MODELS_ERROR);if(!this._isModelLoaded&&!this._isModelLoading){var n=this._webModel.worker;return zn.use_web_worker&&n?new window.webLLM.ChatWorkerClient(n):new window.webLLM.ChatModule}}},{key:"getConfig",value:function(){var e,n=t.DEFAULT_MODEL;this._webModel.model&&(n=this._webModel.model);var r=JSON.parse(JSON.stringify(zn));if(this._webModel.urls){var i=r.model_list.find((function(e){return e.local_id=n}));i&&(this._webModel.urls.model&&(i.model_url=this._webModel.urls.model),this._webModel.urls.wasm&&(i.model_lib_url=this._webModel.urls.wasm))}return null!=(e=this._webModel.load)&&e.skipCache&&(r.use_cache=!1),{model:n,appConfig:r}}},{key:"loadModel",value:(c=A(C().mark((function e(n,r){var i,a,s,o,l,c,u,d,h,p,f,m,g,v,y,b=this;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.scrollToTop(),t.chat=n,this._isModelLoading=!0,d=!1===(null==(i=this._webModel.introMessage)?void 0:i.displayed),h=function(e){var t;null==(t=b._messages)||t.addNewMessage({html:"<div>".concat(e.text,"</div>"),overwrite:!0,sendUpdate:!1}),d&&(setTimeout((function(){var e;return ie.scrollToBottom(null==(e=b._messages)?void 0:e.elementRef)})),d=!1)},t.chat.setInitProgressCallback(h),e.prev=4,f=this.getConfig(),m=f.model,g=f.appConfig,v={},this._webModel.instruction&&(v.conv_config={system:this._webModel.instruction}),this._conversationHistory.length>0&&(v.conversation_history=this._conversationHistory),e.next=10,t.chat.reload(m,v,g,r);case 10:p=e.sent,e.next=16;break;case 13:return e.prev=13,e.t0=e.catch(4),e.abrupt("return",this.unloadChat(e.t0));case 16:null==(s=(a=this.deepChat)._validationHandler)||s.call(a),null!=(o=this._webModel.introMessage)&&o.removeAfterLoad?!1===this._webModel.introMessage.displayed?null==(c=this._messages)||c.removeLastMessage():null==(u=this._removeIntro)||u.call(this):(y=Un.setUpAfterLoad(p,this._webModel.introMessage,this._chatEl,!!this._webModel.worker),null==(l=this._messages)||l.addNe
2wMessage({html:y,overwrite:!0,sendUpdate:!1})),this._isModelLoaded=!0,this._isModelLoading=!1;case 18:case"end":return e.stop()}}),e,this,[[4,13]])}))),function(e,t){return c.apply(this,arguments)})},{key:"unloadChat",value:(l=A(C().mark((function e(n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(r=this._messages)||r.addNewErrorMessage("service",t.GENERIC_ERROR),console.error(n),this._isModelLoaded=!1,this._isModelLoading=!1,e.t0=t.chat,!e.t0){e.next=9;break}return e.next=8,t.chat.unload();case 8:t.chat=void 0;case 9:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"immediateResp",value:(o=A(C().mark((function e(n,r,i){var a,s;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.generate(r,void 0,0);case 2:return e.t0=e.sent,a={text:e.t0},e.next=6,t.processResponse(this.deepChat,n,a);case 6:(s=e.sent)&&s.forEach((function(e){return n.addNewMessage(e)})),this.completionsHandlers.onFinish();case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return o.apply(this,arguments)})},{key:"streamResp",value:(s=A(C().mark((function e(n,r,i){var a,s=this;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.streamHandlers.abortStream.abort=function(){i.interruptGenerate()},this.streamHandlers.onOpen(),a=new cn(n),e.next=4,i.generate(r,function(){var e=A(C().mark((function e(r,i){var o;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.processResponse(s.deepChat,n,{text:i});case 2:(o=e.sent)&&a.upsertStreamedMessage({text:o[0].text,overwrite:!0});case 4:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}());case 4:a.finaliseStreamedMessage(),this.streamHandlers.onClose();case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return s.apply(this,arguments)})},{key:"generateRespByType",value:(a=A(C().mark((function e(t,n,r,i){var a;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!r){e.next=6;break}return e.next=4,this.streamResp(t,n,i);case 4:e.next=8;break;case 6:return e.next=8,this.immediateResp(t,n,i);case 8:e.next=13;break;case 10:e.prev=10,e.t0=e.catch(0),null==(a=this._messages)||a.addNewErrorMessage("service"),console.log(e.t0);case 13:case"end":return e.stop()}}),e,this,[[0,10]])}))),function(e,t,n,r){return a.apply(this,arguments)})},{key:"generateResp",value:(i=A(C().mark((function e(t,n,r){var i,a,s,o,l,c,u;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n[n.length-1].text,e.next=3,dn.processRequestInterceptor(this.deepChat,{body:{text:i}});case 3:a=e.sent,s=a.body,o=a.error,l=!!this.stream;try{o?(dn.displayError(t,new Error(o)),(l?this.streamHandlers.onClose:this.completionsHandlers.onFinish)()):s&&s.text?this.generateRespByType(t,s.text,!!this.stream,r):(c=ne.INVALID_MODEL_REQUEST({body:s},!1),console.error(c),u=l?this.streamHandlers.onClose:this.completionsHandlers.onFinish,dn.onInterceptorError(t,c,u))}catch(e){this.unloadChat(e)}case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"callServiceAPI",value:(r=A(C().mark((function e(n,r){var i,a;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._isModelLoaded){e.next=7;break}if(!this._loadOnFirstMessage){e.next=6;break}return e.next=4,this.init();case 4:e.next=7;break;case 6:return e.abrupt("return");case 7:!t.chat||this._isModelLoading||(null!=(i=this._webModel.introMessage)&&i.removeAfterMessage&&(null==(a=this._removeIntro)||a.call(this)),n.addLoadingMessage(),this.generateResp(n,r,t.chat));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"canSubmit",value:function(e){return!(null==e||!e.trim()||this._isModelLoading)&&(!!this._loadOnFirstMessage||!!this._isModelLoaded)}},{key:"isWebModel",value:function(){return!0}}],[{key:"setUpHistory",value:function(e,t){t.forEach((function(n,r){if(n.role===on.USER_ROLE&&n.text){var i=t[r+1];null!=i&&i.text&&i.role!==on.USER_ROLE&&e.push([n.text,i.text])}}))}},{key:"processResponse",value:(n=A(C().mark((function e(t,n,r){var i,a,s,o,l,c;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null==(i=t.responseInterceptor)?void 0:i.call(t,r);case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=r;case 5:if(s=e.t0,!(null!=(a=t.connect)&&a.stream&&Array.isArray(s)&&s.length>1)){e.next=9;break}return console.error(ne.INVALID_STREAM_ARRAY_RESPONSE),e.abrupt("return");
2case 9:if(o=Array.isArray(s)?s:[s],!(l=o.find((function(e){return"string"==typeof e.error})))){e.next=15;break}return dn.displayError(n,new Error(l.error)),e.abrupt("return");case 15:if(!o.find((function(e){return!e||!e.text}))){e.next=19;break}return c=ne.INVALID_MODEL_RESPONSE(r,!!t.responseInterceptor,s),dn.displayError(n,new Error(c)),e.abrupt("return");case 19:return e.abrupt("return",o);case 20:case"end":return e.stop()}}),e)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"clearAllCache",value:function(){t.clearCache("webllm/model"),t.clearCache("webllm/wasm")}},{key:"clearCache",value:function(e){caches.open(e).then((function(e){e.keys().then((function(t){t.forEach((function(t){e.delete(t)}))}))}))}}]);var n,r,i,a,s,o,l,c,u,d}(In);qn.GENERIC_ERROR="Error, please check the [troubleshooting](https://deepchat.dev/docs/webModel#troubleshooting) section of documentation for help.",qn.MULTIPLE_MODELS_ERROR="Cannot run multiple web models",qn.WEB_LLM_NOT_FOUND_ERROR="WebLLM module not found",qn.DEFAULT_MODEL="Llama-2-7b-chat-hf-q4f32_1",qn.MODULE_SEARCH_LIMIT_S=5;var Hn=qn,Vn=function(){function e(){R(this,e)}return N(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i=e;Array.isArray(i.error)&&"Error in `parameters`: field required"===i.error[0]?n(t):r(ne.INVALID_KEY)}},{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api-inference.huggingface.co/models/gpt2",method:"POST",handleVerificationResult:e.handleVerificationResult}}}])}(),Gn=function(e){function t(e,n,r,i,a,s){var o;return R(this,t),(o=_(this,t,[e,Vn.buildKeyVerificationDetails(),Vn.buildHeaders,a,s])).insertKeyPlaceholderText="Hugging Face Token",o.keyHelpUrl="https://huggingface.co/settings/tokens",o.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>Hugging Face</b></div>\n    <p>First message may take an extented amount of time to complete as the model needs to be initialized.</p>',o.permittedErrorPrefixes=["Authorization header"],o.url="".concat(t.URL_PREFIX).concat(r),o.textInputPlaceholderText=n,"object"==O(i)&&(i.model&&(o.url="".concat(t.URL_PREFIX).concat(i.model)),i.options&&(o.rawBody.options=i.options),i.parameters&&(o.rawBody.parameters=i.parameters)),o}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t,n){var r,i=JSON.parse(JSON.stringify(e)),a=t[t.length-1].text;if(a)return null!==(r=i.options)&&void 0!==r||(i.options={}),i.options.wait_for_model=!0,I({inputs:a},i)}},{key:"callServiceAPI",value:(n=A(C().mark((function e(t,n,r){var i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:i=this.preprocessBody(this.rawBody,n,r),En.request(this,i,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})}]);var n}(Ln);Gn.URL_PREFIX="https://api-inference.huggingface.co/models/";var Wn=Gn,$n=function(e){function t(e,n,r,i,a,s){var o;return R(this,t),(o=_(this,t,[e,n,r,i,a,s])).isTextInputDisabled=!0,o.canSendMessage=t.canSendFile,o}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t,n){return n[0]}},{key:"callServiceAPI",value:(n=A(C().mark((function e(t,n,r){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null!=r&&r[0]){e.next=4;break}throw new Error("No file was added");case 4:En.poll(this,r[0],t,!1);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})}],[{key:"canSendFile",value:function(e,t){return!(null==t||!t[0])}}]);var n}(Wn),Kn=function(e){function t(e){var n,r,i;return R(this,t),_(this,t,[e,"Attach an audio file","ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.audioClassification,null==(i=e.directConnection)?void 0:i.huggingFace,{audio:{}}])}return x(t,e),N(t,[{key:"extractPollResultData",value:(n=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.estimated_time){e.next=2;break}return e.abrupt("return",{timeoutMS:1e3*(t.estimated_time+1)});case 2:if(!t.error){e.next=4;break}throw t.error;case 4:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.label)||""});case 5:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}($n),Jn=function(e){function t(e){var n,r,i;return R(this,t),_(this,t,[e,"Attach an image file","google/vit-base-patch16-224",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.imageClassification,null==(i=e.directConnection)?void 0:i.huggingFace,{images:{}}])}return x(t,e),N(t,[{key:"extractPollResultData",value:(n=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.estimated_time){e.next=2;break}return e.abrupt("return",{timeoutMS:1e3*(t.estimated_time+1)});case 2:if(!t.error){e.next=4;break}throw t.error;case 4:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.label)||""});case 5:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}($n),Zn="data:image/png;base64,",Yn=function(){function e(){R(this,e)}return N(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){e.message?r(ne.INVALID_KEY):n(t)}}
2,{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.stability.ai/v1/engines/list",method:"GET",handleVerificationResult:e.handleVerificationResult}}}])}(),Xn=function(e){function t(e,n,r,i,a){var s;return R(this,t),(s=_(this,t,[e,n,r,i,a])).insertKeyPlaceholderText="Stability AI API Key",s.keyHelpUrl="https://platform.stability.ai/docs/getting-started/authentication",s.permittedErrorPrefixes=["Incorrect","invalid_"],s}return x(t,e),N(t)}(Ln),Qn=function(e){function t(e){var n,r;R(this,t);var i=JSON.parse(JSON.stringify(e.directConnection)),a=null==i?void 0:i.stabilityAI;(n=_(this,t,[e,Yn.buildKeyVerificationDetails(),Yn.buildHeaders,a,{images:{files:{acceptedFormats:".png",maxNumberOfFiles:1}}}])).url="https://api.stability.ai/v1/generation/esrgan-v1-x2plus/image-to-image/upscale",n.textInputPlaceholderText="Describe image changes",n.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>Stability AI</b></div>\n    <div style="width: 100%; text-align: center; margin-left: -10px; margin-top: 5px"><b>Image to Image Upscale</b></div>\n    <p>Upload an image to generate a new one with higher resolution.</p>\n    <p>Click <a href="https://platform.stability.ai/">here</a> for more info.</p>';var s=null==(r=null==i?void 0:i.stabilityAI)?void 0:r.imageToImageUpscale;return"object"==O(s)&&(s.engine_id&&(n.url="https://api.stability.ai/v1/generation/".concat(s.engine_id,"/image-to-image/upscale")),t.cleanConfig(s),Object.assign(n.rawBody,s)),n.canSendMessage=t.canSendFileMessage,n}return x(t,e),N(t,[{key:"createFormDataBody",value:function(e,t){var n=new FormData;return n.append("image",t),Object.keys(e).forEach((function(t){n.append(t,String(e[t]))})),n}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n,r){var i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(r){e.next=4;break}throw new Error("Image was not found");case 4:i=this.createFormDataBody(this.rawBody,r[0]),dn.tempRemoveContentHeader(this.connectSettings,En.request.bind(this,this,i,t),!1);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{files:t.artifacts.map((function(e){return{src:"".concat(Zn).concat(e.base64),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"cleanConfig",value:function(e){delete e.engine_id}},{key:"canSendFileMessage",value:function(e,t){return!(null==t||!t[0])}}]);var n,r}(Xn),er=function(e){function t(e){var n,r;R(this,t);var i=JSON.parse(JSON.stringify(e.directConnection)),a=null==i?void 0:i.stabilityAI;(n=_(this,t,[e,Yn.buildKeyVerificationDetails(),Yn.buildHeaders,a,{images:{files:{acceptedFormats:".png",maxNumberOfFiles:2}}}])).url="https://api.stability.ai/v1/generation/stable-diffusion-xl-1024-v1-0/image-to-image/masking",n._maskSource="MASK_IMAGE_WHITE",n.textInputPlaceholderText="Describe image changes",n.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>Stability AI</b></div>\n    <div style="width: 100%; text-align: center; margin-left: -10px; margin-top: 5px"><b>Image to Image Masking</b></div>\n    <p>Upload an image, its mask image to create a new one based on the changes you have described for the mask area.</p>\n    <p>Click <a href="https://platform.stability.ai/">here</a> for more info.</p>';var s=null==(r=null==i?void 0:i.stabilityAI)?void 0:r.imageToImageMasking;return"object"==O(s)&&(s.engine_id&&(n.url="https://api.stability.ai/v1/generation/".concat(s.engine_id,"/image-to-image/masking")),void 0!==s.weight&&null!==s.weight&&(n._imageWeight=s.weight),void 0!==s.mask_source&&null!==s.mask_source&&(n._maskSource=s.mask_source),t.cleanConfig(s),Object.assign(n.rawBody,s)),n.canSendMessage=t.canSendFileTextMessage,n}return x(t,e),N(t,[{key:"createFormDataBody",value:function(e,t,n,r){var i=new FormData;return i.append("init_image",t),i.append("mask_source",String(this._maskSource)),i.append("mask_image",n),r&&""!==r&&i.append("text_prompts[0][text]",r),void 0!==this._imageWeight&&null!==this._imageWeight&&i.append("text_prompts[0][weight]",String(this._imageWeight)),Object.keys(e).forEach((function(t){i.append(t,String(e[t]))})),void 0===i.get("weight")&&i.append("weight",String(1)),i}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n,r){var i,a,s,o;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(r&&r[0]&&r[1]){e.next=4;break}throw new Error("Image was not found");case 4:s=null==(a=null==(i=n[n.length-1])?void 0:i.text)?void 0:a.trim(),o=this.createFormDataBody(this.rawBody,r[0],r[1],s),dn.tempRemoveContentHeader(this.connectSettings,En.request.bind(this,this,o,t),!1);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{files:t.artifacts.map((function(e){return{src:"".concat(Zn).concat(e.base64),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"cleanConfig",value:function(e){delete e.engine_id,delete e.weight}},{key:"canSendFileTextMessage",value:function(e,t){return!(null==t||!t[0]||
2!e||""===e.trim())}}]);var n,r}(Xn),tr=function(e){function t(e){var n,r,i;return R(this,t),_(this,t,[e,"Attach an audio file","facebook/wav2vec2-large-960h-lv60-self",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.audioSpeechRecognition,null==(i=e.directConnection)?void 0:i.huggingFace,{audio:{}}])}return x(t,e),N(t,[{key:"extractPollResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.estimated_time){e.next=2;break}return e.abrupt("return",{timeoutMS:1e3*(t.estimated_time+1)});case 2:if(!t.error){e.next=4;break}throw t.error;case 4:return e.abrupt("return",{text:t.text||""});case 5:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}($n),nr=function(e){function t(e){var n,r,i;return R(this,t),_(this,t,[e,"Once upon a time","gpt2",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.textGeneration,null==(i=e.directConnection)?void 0:i.huggingFace])}return x(t,e),N(t,[{key:"extractResultData",value:(n=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.generated_text)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Wn),rr=function(e){function t(e){var n,r,i,a;R(this,t);var s=null==(i=null==(r=e.directConnection)?void 0:r.huggingFace)?void 0:i.questionAnswer;return(n=_(this,t,[e,"Ask a question","bert-large-uncased-whole-word-masking-finetuned-squad",s,null==(a=e.directConnection)?void 0:a.huggingFace])).permittedErrorPrefixes=["Authorization header","Error in"],n.context=s.context,n}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t){var n=t[t.length-1].text;if(n)return{inputs:{question:n,context:this.context,options:{wait_for_model:!0}}}}},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:t.answer||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Wn),ir=function(e){function t(e){var n,r,i;return R(this,t),_(this,t,[e,"Insert text to summarize","facebook/bart-large-cnn",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.summarization,null==(i=e.directConnection)?void 0:i.huggingFace])}return x(t,e),N(t,[{key:"extractResultData",value:(n=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.summary_text)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Wn),ar=function(e){function t(e){var n,r,i,a,s;return R(this,t),null!==(n=(r=_(this,t,[e,"Ask me anything!","facebook/blenderbot-400M-distill",null==(a=null==(i=e.directConnection)?void 0:i.huggingFace)?void 0:a.conversation,null==(s=e.directConnection)?void 0:s.huggingFace])).maxMessages)&&void 0!==n||(r.maxMessages=-1),r}return x(t,e),N(t,[{key:"processMessages",value:function(e){var t=e.filter((function(e){return e.text})),n=t[t.length-1].text,r=t.slice(0,t.length-1);if(n)return{past_user_inputs:r.filter((function(e){return"user"===e.role})).map((function(e){return e.text})),generated_responses:r.filter((function(e){return"ai"===e.role})).map((function(e){return e.text})),mostRecentMessageText:n}}},{key:"preprocessBody",value:function(e,t){var n,r=JSON.parse(JSON.stringify(e)),i=this.processMessages(t);if(i)return null!==(n=r.options)&&void 0!==n||(r.options={}),r.options.wait_for_model=!0,I({inputs:{past_user_inputs:i.past_user_inputs,generated_responses:i.generated_responses,text:i.mostRecentMessageText}},r)}},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:t.generated_text||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Wn),sr=function(e){function t(e){var n,r;R(this,t);var i=JSON.parse(JSON.stringify(e.directConnection)),a=i.stabilityAI;
2(n=_(this,t,[e,Yn.buildKeyVerificationDetails(),Yn.buildHeaders,a,{images:{files:{acceptedFormats:".png",maxNumberOfFiles:1}}}])).url="https://api.stability.ai/v1/generation/stable-diffusion-v1-6/image-to-image",n.textInputPlaceholderText="Describe image changes",n.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>Stability AI: Image to Image</b></div>\n    <p>Upload an image to create a new one with the changes you have described.</p>\n    <p>Click <a href="https://platform.stability.ai/">here</a> for more info.</p>';var s=null==(r=i.stabilityAI)?void 0:r.imageToImage;return"object"==O(s)&&(s.engine_id&&(n.url="https://api.stability.ai/v1/generation/".concat(s.engine_id,"/text-to-image")),void 0!==s.weight&&null!==s.weight&&(n._imageWeight=s.weight),t.cleanConfig(s),Object.assign(n.rawBody,s)),n.canSendMessage=t.canSendFileTextMessage,n}return x(t,e),N(t,[{key:"createFormDataBody",value:function(e,t,n){var r=new FormData;return r.append("init_image",t),n&&""!==n&&r.append("text_prompts[0][text]",n),void 0!==this._imageWeight&&null!==this._imageWeight&&r.append("text_prompts[0][weight]",String(this._imageWeight)),Object.keys(e).forEach((function(t){r.append(t,String(e[t]))})),void 0===r.get("weight")&&r.append("weight",String(1)),r}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n,r){var i,a,s,o;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(r){e.next=4;break}throw new Error("Image was not found");case 4:s=null==(a=null==(i=n[n.length-1])?void 0:i.text)?void 0:a.trim(),o=this.createFormDataBody(this.rawBody,r[0],s),dn.tempRemoveContentHeader(this.connectSettings,En.request.bind(this,this,o,t),!1);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{files:t.artifacts.map((function(e){return{src:"".concat(Zn).concat(e.base64),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"cleanConfig",value:function(e){delete e.engine_id,delete e.weight}},{key:"canSendFileTextMessage",value:function(e,t){return!(null==t||!t[0]||
2!e||""===e.trim())}}]);var n,r}(Xn),or=function(e){function t(e){var n,r,i;return R(this,t),_(this,t,[e,"Insert text to translate","Helsinki-NLP/opus-tatoeba-en-ja",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.translation,null==(i=e.directConnection)?void 0:i.huggingFace])}return x(t,e),N(t,[{key:"extractResultData",value:(n=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.translation_text)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Wn),lr=function(e){function t(e){var n,r;R(this,t);var i=JSON.parse(JSON.stringify(e.directConnection)),a=i.stabilityAI;(n=_(this,t,[e,Yn.buildKeyVerificationDetails(),Yn.buildHeaders,a])).url="https://api.stability.ai/v1/generation/stable-diffusion-v1-6/text-to-image",n.textInputPlaceholderText="Describe an image",n.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>Stability AI: Text to Image</b></div>\n    <p>Insert text to generate an image.</p>\n    <p>Click <a href="https://platform.stability.ai/">here</a> for more info.</p>';var s=null==(r=i.stabilityAI)?void 0:r.textToImage;return"object"==O(s)&&(s.engine_id&&(n.url="https://api.stability.ai/v1/generation/".concat(s.engine_id,"/text-to-image")),void 0!==s.weight&&null!==s.weight&&(n._imageWeight=s.weight),t.cleanConfig(s),Object.assign(n.rawBody,s)),n.canSendMessage=t.canSendTextMessage,n}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r={text:t};return this._imageWeight&&(r.weight=this._imageWeight),n.text_prompts=[r],n}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n[n.length-1].text),En.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{files:t.artifacts.map((function(e){return{src:"".concat(Zn).concat(e.base64),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"cleanConfig",value:function(e){delete e.engine_id,delete e.weight}},{key:"canSendTextMessage",value:function(e){return!(!e||""===e.trim())}}]);var n,r}(Xn),cr=function(e){function t(e){var n,r,i,a;return R(this,t),(n=_(this,t,[e,"The goal of life is [MASK].","bert-base-uncased",null==(i=null==(r=e.directConnection)?void 0:r.huggingFace)?void 0:i.fillMask,null==(a=e.directConnection)?void 0:a.huggingFace])).introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>Hugging Face</b></div>\n    <p>Insert a sentence with the word [MASK] and the model will try to fill it for you. E.g. I want [MASK].</p>\n    <p>First message may take an extented amount of time to complete as the model needs to be initialized.</p>',n.permittedErrorPrefixes=["Authorization header","No mask_token"],n}return x(t,e),N(t,[{key:"extractResultData",value:(n=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.sequence)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Wn),ur=function(){function e(){R(this,e)}return N(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i=e;i.error?"invalid_api_key"===i.error.code?r(ne.INVALID_KEY):r(ne.CONNECTION_FAILED):n(t)}}
2,{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.openai.com/v1/models",method:"GET",handleVerificationResult:e.handleVerificationResult}}},{key:"directFetch",value:(t=A(C().mark((function e(t,n,r){var i,a,s=arguments;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=!(s.length>3&&void 0!==s[3])||s[3],t.connectSettings.method=r,e.next=4,dn.fetch(t,t.connectSettings.headers,i,n).then((function(e){return dn.processResponseByType(e)}));case 4:if(!(a=e.sent).error){e.next=7;break}throw a.error.message;case 7:return e.abrupt("return",a);case 8:case"end":return e.stop()}}),e)}))),function(e,n,r){return t.apply(this,arguments)})}]);var t}();ur.FUNCTION_TOOL_RESP_ERROR="Response object must either be {response: string}[] for each individual function or {text: string} for a direct response, see https://deepchat.dev/docs/directConnection/OpenAI#FunctionHandler.",ur.FUNCTION_TOOL_RESP_ARR_ERROR="Arrays are not accepted in handler responses";var dr=ur,hr=function(){function e(){R(this,e)}return N(e,null,[{key:"storeFiles",value:(s=A(C().mark((function e(t,n,r,i){var a,s,o,l;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=t.connectSettings.headers){e.next=3;break}return e.abrupt("return");case 3:return t.url=i,s=a[dn.CONTENT_TYPE],delete a[dn.CONTENT_TYPE],o=r.map(function(){var e=A(C().mark((function e(n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new FormData,e.abrupt("return",(r.append("purpose","assistants"),r.append("file",n),new Promise((function(e){e(dr.directFetch(t,r,"POST",!1))}))));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.prev=7,e.next=10,Promise.all(o);case 10:return l=e.sent.map((function(e){return{id:e.id,name:e.filename}})),e.abrupt("return",(a[dn.CONTENT_TYPE]=s,l));case 14:throw e.prev=14,e.t0=e.catch(7),a[dn.CONTENT_TYPE]=s,dn.displayError(n,e.t0),t.completionsHandlers.onFinish(),e.t0;case 17:case"end":return e.stop()}}),e,null,[[7,14]])}))),function(e,t,n,r){return s.apply(this,arguments)})},{key:"getType",value:function(e,t){var n=e[t].path;return!n||n.endsWith("png")?"image":"any"}},{key:"getFiles",value:(a=A(C().mark((function t(n,r,i,a){var s,o;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=r.map((function(e){var t=e.fileId;return n.url="".concat(i).concat(t).concat(a),new Promise((function(e){e(dr.directFetch(n,void 0,"GET",!1))}))})),t.next=3,Promise.all(s);case 3:return o=t.sent.map((function(t,n){return new Promise((function(i){var a=new FileReader;a.readAsDataURL(t),a.onload=function(t){i({src:t.target.result,name:r[n].name,type:e.getType(r,n)})}}))})),t.next=6,Promise.all(o);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)}))),function(e,t,n,r){return a.apply(this,arguments)})},{key:"getFileName",value:function(e){var t=e.split("/");return t[t.length-1]}},{key:"getFilesAndNewText",value:(i=A(C().mark((function t(n,r,i,a,s){var o,l,c,u,d;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u=i.getFilesPrefix,d=i.getFilesPostfix,t.t0=r.length>0,!t.t0){t.next=7;break}return t.next=5,e.getFiles(n,r,u,d);case 5:c=t.sent,null!=(o=null==s?void 0:s.text)&&o.value&&c.forEach((function(e,t){var n;if(e.src){var i=r[t].path;null!=(n=null==s?void 0:s.text)&&n.value&&i&&(s.text.value=s.text.value.replace(i,e.src))}}));case 7:return t.abrupt("return",null!=(l=null==s?void 0:s.text)&&l.value?{text:s.text.value,role:a}:{files:c,role:a});case 8:case"end":return t.stop()}}),t)}))),function(e,t,n,r,a){return i.apply(this,arguments)})},{key:"getFileDetails",value:function(t,n){var r,i=[];return null!=(r=null==n?void 0:n.text)&&r.value&&t.content.forEach((function(t){var n,r;null==(r=null==(n=t.text)?void 0:n.annotations)||r.forEach((function(t){var n;t.text&&t.text.startsWith("sandbox:")&&null!=(n=t.file_path)&&n.file_id&&i.push({path:t.text,fileId:t.file_path.file_id,name:e.getFileName(t.text)})}))}
2)),null!=n&&n.image_file&&i.push({fileId:n.image_file.file_id}),i}},{key:"getFilesAndText",value:(r=A(C().mark((function t(n,r,i,a){var s;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=e.getFileDetails(r,a),t.next=3,e.getFilesAndNewText(n,s,i,r.role,a);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"parseResult",value:function(e,t){var n=[];if(t)n=e.data;else for(var r=0;r<e.data.length;r+=1){var i=e.data[r];if("assistant"!==i.role)break;n.push(i)}return n.reverse()}},{key:"parseMessages",value:function(t,n,r){var i=[];return n.forEach(function(){var n=A(C().mark((function n(a){return C().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:a.content.filter((function(e){return!!e.text||!!e.image_file})).sort((function(e){return e.text?-1:e.image_file?1:0})).forEach(function(){var n=A(C().mark((function n(s){return C().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:i.push(e.getFilesAndText(t,a,r,s));case 1:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}());case 1:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()),Promise.all(i)}},{key:"processStreamMessages",value:(n=A(C().mark((function t(n,r,i){return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.parseMessages(n,[{content:r,role:"assistant"}],i));case 1:case"end":return t.stop()}}),t)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"processAPIMessages",value:(t=A(C().mark((function t(n,r,i,a){var s;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=e.parseResult(r,i),t.abrupt("return",e.parseMessages(n,s,a));case 2:case"end":return t.stop()}}),t)}))),function(e,n,r,i){return t.apply(this,arguments)})}]);var t,n,r,i,a,s}();hr.FILES_WITH_TEXT_ERROR="content with type `text` must have `text` values",hr.FUNCTION_TOOL_RESP_ERROR="Response must contain an array of strings for each individual function/tool_call, see https://deepchat.dev/docs/directConnection/OpenAI/#assistant-functions.";var pr=hr,fr=function(e){function t(e,n,r,i,a,s){var o;if(R(this,t),(o=_(this,t,[e,i,a,s])).insertKeyPlaceholderText="OpenAI API Key",o.keyHelpUrl="https://platform.openai.com/account/api-keys",o.url="",o.permittedErrorPrefixes=["Incorrect","Please send text",Tn.FAILED_ERROR_MESSAGE],o.shouldFetchHistory=!1,o.searchedForThreadId=!1,o.config={},o.newAssistantDetails={model:"gpt-4"},o.waitingForStreamResponse=!1,o.isSSEStream=!1,o.urlSegments=r,"object"==O(n)){o.config=n;var l=o.config,c=l.new_assistant,u=l.thread_id,d=l.load_thread_history;Object.assign(o.newAssistantDetails,c),u&&(o.sessionId=u),d&&(o.shouldFetchHistory=!0)}return o.maxMessages=1,o.isSSEStream=!(!o.stream||"object"==O(o.stream)&&o.stream.simulation),o}return x(t,e),N(t,[{key:"fetchHistoryFunc",value:(h=A(C().mark((function e(){var t,n=this;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return setTimeout((function(){return n.deepChat.disableSubmitButton()}),2),e.prev=1,e.next=4,this.getThreadMessages(this.sessionId,!0);case 4:return t=e.sent,e.abrupt("return",(this.deepChat.disableSubmitButton(!1),t));case 8:return e.prev=8,e.t0=e.catch(1),e.abrupt("return",[{error:"Failed to fetch history"}]);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(){return h.apply(this,arguments)})},{key:"processMessage",value:function(e,n){var r=this.totalMessagesMaxCharLength||-1,i=An.getCharacterLimitMessages(e,r)[0];if(n&&n.length>0){var a=this.filesToolType;if("function"==typeof this.filesToolType){var s=this.filesToolType(n.map((function(e){return e.name})));"code_interpreter"===s||"file_search"===s||"images"===s?a=s:(console.error('Tool type "'.concat(s,'" is not valid')),console.error('Expected "code_interpreter" or "file_search" or "images". Going to default to "images"'))}if("file_search"===a)return t.processAttachmentsMessage(i,n,"file_search");if("code_interpreter"===a)return t.processAttachmentsMessage(i,n,"code_interpreter");if(n.find((function(e){var t=e.name;return!ue.isImageFileExtension(t)})))console.error("The uploaded files contained a non-image file"),console.error('Make sure only images can be uploaded or define a "code_interpreter" or "file_search" value in the "files_tool_type" property'),console.warn('Make sure your existing assistant supports these "tools" or specify them in the "new_assistant" property');else{var o=t.processImageMessage(i,n);if(o)return o}}return{content:i.text||"",role:"user"}}},{key:"createNewThreadMessages",value:function(e,t,n){var r=JSON.parse(JSON.stringify(e)),i=this.processMessage(t,n);return r.thread={messages:[i]},r}},{key:"callService",value:function(e,t,n){if(this.messages=e,this.sessionId){this.url="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId,"/messages").concat(this.urlSegments.createMessagePostfix);var r=this.processMessage(t,n);En.request(this,r,e)}else{this.url="".concat(this.urlSegments.threadsPrefix,"/runs").concat(this.urlSegments.threadsPosfix);var i=this.createNewThreadMessages(this.rawBody,t,n);this.isSSEStream?this.createStreamRun(i):En.request(this,i,e)}}},{key:"callServiceAPI",value:(d=A(C().mark((function e(t,n,r){var i,a,s;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.waitingForStreamResponse=!1,this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null===(i=(a=this.rawBody).assistant_id)||void 0===i){e.next=6;break}e.next=12;break;case 6:if(e.t0=this.config.assistant_id,e.t0){e.next=11;break}return e.next=10,this.createNewAssistant();case 10:e.t0=e.sent;case 11:a.assistant_id=e.t0;
2case 12:if(this.searchedForThreadId||this.searchPreviousMessagesForThreadId(t.messageToElements),!r){e.next=19;break}return e.next=16,pr.storeFiles(this,t,r,this.urlSegments.storeFiles);case 16:e.t1=e.sent,e.next=20;break;case 19:e.t1=void 0;case 20:s=e.t1,this.connectSettings.method="POST",this.callService(t,n,s);case 22:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return d.apply(this,arguments)})},{key:"createNewAssistant",value:(u=A(C().mark((function e(){var t;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.url=this.urlSegments.newAssistantUrl,e.next=4,dr.directFetch(this,JSON.parse(JSON.stringify(this.newAssistantDetails)),"POST");case 4:return t=e.sent,e.abrupt("return",(this.config.assistant_id=t.id,this.config.assistant_id));case 8:e.prev=8,e.t0=e.catch(0),console.error(e.t0),console.error("Failed to create a new assistant");case 11:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(){return u.apply(this,arguments)})},{key:"searchPreviousMessagesForThreadId",value:function(e){var t=e.find((function(e){return g(e,1)[0]._sessionId}));t&&(this.sessionId=t[0]._sessionId),this.searchedForThreadId=!0}},{key:"extractResultData",value:(c=A(C().mark((function e(t){var n,r,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.waitingForStreamResponse||this.isSSEStream&&this.sessionId)){e.next=4;break}return e.next=3,this.handleStream(t);case 3:return e.abrupt("return",e.sent);case 4:if(!t.error){e.next=6;break}throw t.error.message.startsWith(pr.FILES_WITH_TEXT_ERROR)?Error("Please send text with your file(s)"):t.error.message;case 6:return e.next=8,this.assignThreadAndRun(t);case 8:return r="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId,"/runs/").concat(this.run_id).concat(this.urlSegments.threadsPosfix),i={method:"GET",headers:null==(n=this.connectSettings)?void 0:n.headers},e.abrupt("return",(En.executePollRequest(this,r,i,this.messages),{makingAnotherRequest:!0}));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"assignThreadAndRun",value:(l=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.sessionId){e.next=8;break}return this.url="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId,"/runs").concat(this.urlSegments.threadsPosfix),e.next=4,dr.directFetch(this,JSON.parse(JSON.stringify(this.rawBody)),"POST");case 4:n=e.sent,this.run_id=n.id,e.next=9;break;case 8:this.sessionId=t.thread_id,this.run_id=t.id,this.messages&&this.messages.messageToElements.length>0&&(this.messages.messageToElements[this.messages.messageToElements.length-1][0]._sessionId=this.sessionId);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"getThreadMessages",value:(o=A(C().mark((function e(t){var n,r,i,a,s=arguments;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.length>1&&void 0!==s[1]&&s[1],this.url="".concat(this.urlSegments.threadsPrefix,"/").concat(t,"/messages?").concat(this.urlSegments.listMessagesPostfix),e.next=4,dr.directFetch(this,{},"GET");case 4:if(a=e.sent,e.t0=!n&&this.deepChat.responseInterceptor,!e.t0){e.next=10;break}return e.next=9,null==(i=(r=this.deepChat).responseInterceptor)?void 0:i.call(r,a);case 9:a=e.sent;case 10:return e.abrupt("return",pr.processAPIMessages(this,a,n,this.urlSegments));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"extractPollResultData",value:(s=A(C().mark((function e(n){var r,i,a,s,o,l,c,u,d=this;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.status,a=n.required_action,"queued"!==i&&"in_progress"!==i){e.next=3;break}return e.abrupt("return",{timeoutMS:t.POLLING_TIMEOUT_MS});case 3:if("completed"!==i||!this.messages){e.next=11;break}return e.next=6,this.getThreadMessages(n.thread_id);case 6:return s=e.sent,o=s.shift(),l=o.text,c=o.files,e.abrupt("return",(setTimeout((function(){s.forEach((function(e){return d.deepChat.addMessage(e)}))})),{text:l,_sessionId:this.sessionId,files:c}));case 11:if(u=null==(r=null==a?void 0:a.submit_tool_outputs)?void 0:r.tool_calls,"requires_action"!==i||!u){e.next=16;break}return e.next=15,this.handleTools(u);case 15:return e.abrupt("return",e.sent);case 16:throw Error("Thread run status: ".concat(i));case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"handleTools",value:(a=A(C().mark((function e(n){var r,i,a,s,o,l;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.functionHandler){e.next=2;break}throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/openAI#Assistant) object.");case 2:return r=n.map((function(e){return{name:e.function.name,arguments:e.function.arguments}})),e.next=5,this.functionHandler(r);case 5:if(i=e.sent,Array.isArray(i)&&n.length===i.length){e.next=8;break}throw Error(pr.FUNCTION_TOOL_RESP_ERROR);case 8:return e.next=10,Promise.all(i);case 10:if(!(a=e.sent).find((function(e){return"string"!=typeof e}))){e.next=13;break}throw Error(pr.FUNCTION_TOOL_RESP_ERROR);case 13:if(s=a.map((function(e,t){return{tool_call_id:n[t].id,output:e}})),o="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId),l="/runs/".concat(this.run_id,"/submit_tool_outputs").concat(this.urlSegments.threadsPosfix),this.url="".concat(o).concat(l),!this.isSSEStream){e.next=20;break}return e.next=18,this.createStreamRun({tool_outputs:s});case 18:e.next=22;break;case 20:return e.next=22,dr.directFetch(this,{tool_outputs:s},"POST");case 22:return e.abrupt("return",{timeoutMS:t.POLLING_TIMEOUT_MS});case 23:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"handleStream",value:(i=A(C().mark((function e(t){var n,r,i,a;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==(r=null==(n=t.required_action)?void 0:n.submit_tool_outputs)?void 0:r.tool_calls,"requires_action"!==t.status||!i){e.next=6;break}return this.run_id=t.id,e.next=5,this.handleTools(i);case 5:return e.abrupt("return",e.sent);case 6:if(!this.waitingForStreamResponse){e.next=8;break}return e.abrupt("return",this.parseStreamResult(t));case 8:return this.isSSEStream&&this.sessionId&&(this.url="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId,"/runs").concat(this.urlSegments.threadsPosfix),a=JSON.parse(JSON.stringify(this.rawBody)),this.createStreamRun(a)),e.abrupt("return",{makingAnotherRequest:!0});case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"parseStreamResult",value:(r=A(C().mark((function e(t){var n,r,i,a,s,o,l,c,u,d;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.content&&t.content.length>0&&this.messages)){e.next=5;break}if(o=t.content.find((function(e){return e.text})),!(null!=(n=null==o?void 0:o.text)&&n.annotations&&o.text.annotations.length>0)){e.next=5;break}return l=t.content.find((function(e){return!!e.text}))||t.content[0],c=pr.getFilesAndText.bind(this,this,{role:"assistant",content:t.content},this.urlSegments,l),e.abrupt("return",(null==(r=this.messageStream)||r.endStreamAfterFileDownloaded(this.messages,c),{text:""}));case 5:if(null==(i=t.delta)||!i.content){e.next=14;break}if(!(t.delta.content.length>1)){e.next=13;break}if(u=t.delta.content.find((function(e){return e.text})),null==(a=null==u?void 0:u.text)||!a.annotations||0!==u.text.annotations.length){e.next=13;break}return e.next=11,pr.processStreamMessages(this,t.delta.content,this.urlSegments);case 11:return d=e.sent,e.abrupt("return",{text:d[0].text,files:d[1].files});case 13:return e.abrupt("return",{text:null==(s=t.delta.content[0].text)?void 0:s.value});case 14:return e.abrupt("return",(!this.sessionId&&t.thread_id&&
2(this.sessionId=t.thread_id),{makingAnotherRequest:!0}));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createStreamRun",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.stream=!0,this.waitingForStreamResponse=!0,e.next=4,_n.request(this,t,this.messages,!0,!0);case 4:this.messageStream=e.sent;case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})}],[{key:"processImageMessage",value:function(e,t){var n=null==t?void 0:t.filter((function(e){return ue.isImageFileExtension(e.name)})).map((function(e){return{type:"image_file",image_file:{file_id:e.id}}}));if(n&&n.length>0)return e.text&&e.text.length>0&&n.push({type:"text",text:e.text}),{content:n,role:"user"}}},{key:"processAttachmentsMessage",value:function(e,t,n){return{attachments:t.map((function(e){return{tools:[{type:n}],file_id:e.id}})),content:[{type:"text",text:e.text}],role:"user"}}}]);var n,r,i,a,s,o,l,c,u,d,h}(Ln);fr.POLLING_TIMEOUT_MS=500;var mr=fr,gr=function(e){function t(e){var n,r,i,a,s,o,l,c;R(this,t);var u=JSON.parse(JSON.stringify(e.directConnection)),d=u.openAI,h=null==(a=u.openAI)?void 0:a.assistant,p=t.buildUrlSegments(h);if(null!==(n=(s=(i=_(this,t,[e,h,p,dr.buildKeyVerificationDetails(),dr.buildHeaders,d])).connectSettings).headers)&&void 0!==n||(s.headers={}),null!==(r=(o=i.connectSettings.headers)["OpenAI-Beta"])&&void 0!==r||(o["OpenAI-Beta"]="assistants=v2"),i.shouldFetchHistory&&i.sessionId&&(i.fetchHistory=i.fetchHistoryFunc.bind(w(i))),"object"==O(h)){var f=null==(c=null==(l=e.directConnection)?void 0:l.openAI)?void 0:c.assistant,m=f.function_handler,g=f.files_tool_type;m&&(i.functionHandler=m),g&&(i.filesToolType=g)}return i}return x(t,e),N(t,null,[{key:"buildUrlSegments",value:function(e){var t="object"==O(e)&&e.custom_base_url||"https://api.openai.com/v1";return{threadsPrefix:"".concat(t,"/threads"),threadsPosfix:"",newAssistantUrl:"".concat(t,"/assistants"),createMessagePostfix:"",listMessagesPostfix:"order=desc",storeFiles:"".concat(t,"/files"),getFilesPrefix:"".concat(t,"/files/"),getFilesPostfix:"/content"}}}])}(mr),vr=function(){function e(){R(this,e)}return N(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json",accept:"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i;null!=(i=e.message)&&i.includes("invalid request: prompt must be at least 1 token long")?n(t):r(ne.INVALID_KEY)}},{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.cohere.ai/v1/generate",method:"POST",handleVerificationResult:e.handleVerificationResult,body:JSON.stringify({prompt:""})}}}])}(),yr=function(e){function t(e,n,r,i,a){var s;return R(this,t),(s=_(this,t,[e,vr.buildKeyVerificationDetails(),vr.buildHeaders,a])).insertKeyPlaceholderText="Cohere API Key",s.keyHelpUrl="https://dashboard.cohere.ai/api-keys",s.permittedErrorPrefixes=["invalid"],s.url=n,s.textInputPlaceholderText=r,i&&"object"==O(i)&&Object.assign(s.rawBody,i),s}return x(t,e),N(t)}(Ln),br=function(e){function t(e){var n,r,i;return R(this,t),_(this,t,[e,"https://api.cohere.ai/v1/generate","Once upon a time",null==(r=null==(n=e.directConnection)?void 0:n.cohere)?void 0:r.textGeneration,null==(i=e.directConnection)?void 0:i.cohere])}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r=t[t.length-1].text;if(r)return I({prompt:r},n)}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),En.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{text:(null==(n=t.generations)?void 0:n[0].text)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(yr),_r=function(){return N((function e(){R(this,e)}),null,[{key:"buildHeaders",value:function(e){return{"api-key":e,"Content-Type":"application/json"}}}
2,{key:"buildKeyVerificationDetails",value:function(e){return{url:"".concat(e.endpoint,"/openai/models?api-version=").concat(e.version),method:"GET",handleVerificationResult:dr.handleVerificationResult}}},{key:"validateURLDetails",value:function(e){var t=e.endpoint,n=e.version,r=e.deploymentId;return t&&n&&r}}])}();_r.URL_DETAILS_ERROR_MESSAGE="Please define the Azure URL Details. [More Information](https://deepchat.dev/docs/directConnection/Azure)";var wr=_r,kr=function(e){function t(e){var n,r,i,a,s,o,l,c,u,d;R(this,t);var h=JSON.parse(JSON.stringify(e.directConnection)),p=h.azure,f=null==(i=h.azure)?void 0:i.openAI,m=(null==f?void 0:f.urlDetails)||{},g="".concat(null==(a=null==f?void 0:f.urlDetails)?void 0:a.endpoint,"/openai/"),v="?api-version=".concat(null==(s=null==f?void 0:f.urlDetails)?void 0:s.version),y={threadsPrefix:"".concat(g).concat(t.THREAD_RESOURCE),threadsPosfix:v,newAssistantUrl:"".concat(g).concat(t.NEW_ASSISTANT_RESOURCE).concat(v),createMessagePostfix:v,listMessagesPostfix:"order=desc&api-version=".concat(null==(o=null==f?void 0:f.urlDetails)?void 0:o.version),storeFiles:"".concat(g,"files").concat(v),getFilesPrefix:"".concat(g,"files/"),getFilesPostfix:"/content".concat(v)};if((r=_(this,t,[e,null==f?void 0:f.assistant,y,wr.buildKeyVerificationDetails(m),wr.buildHeaders,p])).permittedErrorPrefixes=[wr.URL_DETAILS_ERROR_MESSAGE],r.insertKeyPlaceholderText="Azure OpenAI API Key",r.keyHelpUrl="https://learn.microsoft.com/en-us/answers/questions/1193991/how-to-get-the-value-of-openai-api-key",r.isTextInputDisabled=!1,"object"==O(null==f?void 0:f.assistant)){var b=null==(u=null==(c=null==(l=e.directConnection)?void 0:l.azure)?void 0:c.openAI)?void 0:u.assistant,w=b.function_handler,k=b.files_tool_type;w&&(r.functionHandler=w),k&&(r.filesToolType=k)}return wr.validateURLDetails(m)?null!==(n=(d=r.connectSettings).headers)&&void 0!==n||(d.headers={}):(r.isTextInputDisabled=!0,r.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:wr.URL_DETAILS_ERROR_MESSAGE})}))),r}return x(t,e),N(t)}(mr);kr.THREAD_RESOURCE="threads",kr.NEW_ASSISTANT_RESOURCE="assistants";var Sr=kr,xr=function(e){function t(e){var n,r,i;return R(this,t),_(this,t,[e,"https://api.cohere.ai/v1/summarize","Insert text to summarize",null==(r=null==(n=e.directConnection)?void 0:n.cohere)?void 0:r.summarization,null==(i=e.directConnection)?void 0:i.cohere])}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r=t[t.length-1].text;if(r)return I({text:r},n)}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),En.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{text:t.summary||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(yr),Er=function(){function e(){R(this,e)}return N(e,null,[{key:"addAttributes",value:function(e){e.role="button",e.setAttribute("tabindex","0")}},{key:"addAriaBusy",value:function(e){e.setAttribute("aria-busy","true")}},{key:"removeAriaBusy",value:function(e){e.removeAttribute("aria-busy")}},{key:"addAriaDisabled",value:function(e){e.setAttribute("aria-disabled","true")}},{key:"removeAriaDisabled",value:function(e){e.removeAttribute("aria-disabled")}},{key:"removeAriaAttributes",value:function(t){e.removeAriaBusy(t),e.removeAriaDisabled(t)}}])}(),Cr='<?xml version="1.0" encoding="iso-8859-1"?>\n<svg height="1.4em" width="1.4em" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"\n\t viewBox="0 0 490.9 490.9" xml:space="preserve">\n\t<g>\n\t\t<g>\n\t\t\t<path d="M245.5,322.9c53,0,96.2-43.2,96.2-96.2V96.2c0-53-43.2-96.2-96.2-96.2s-96.2,43.2-96.2,96.2v
2130.5\n\t\t\t\tC149.3,279.8,192.5,322.9,245.5,322.9z M173.8,96.2c0-39.5,32.2-71.7,71.7-71.7s71.7,32.2,71.7,71.7v130.5\n\t\t\t\tc0,39.5-32.2,71.7-71.7,71.7s-71.7-32.2-71.7-71.7V96.2z"/>\n\t\t\t<path d="M94.4,214.5c-6.8,0-12.3,5.5-12.3,12.3c0,85.9,66.7,156.6,151.1,162.8v76.7h-63.9c-6.8,0-12.3,5.5-12.3,12.3\n\t\t\t\ts5.5,12.3,12.3,12.3h152.3c6.8,0,12.3-5.5,12.3-12.3s-5.5-12.3-12.3-12.3h-63.9v-76.7c84.4-6.3,151.1-76.9,151.1-162.8\n\t\t\t\tc0-6.8-5.5-12.3-12.3-12.3s-12.3,5.5-12.3,12.3c0,76.6-62.3,138.9-138.9,138.9s-138.9-62.3-138.9-138.9\n\t\t\t\tC106.6,220,101.2,214.5,94.4,214.5z"/>\n\t\t</g>\n\t</g>\n</svg>\n',Tr=function(){function e(){R(this,e)}return N(e,null,[{key:"createTextElement",value:function(t){var n=document.createElement("div");return n.classList.add(e.INPUT_BUTTON_INNER_TEXT_CLASS),n.innerText=t,n}},{key:"tryAddSVGElement",value:function(e,t,n,r){n?e.push(Nn.createSVGElement(n)):""!==n&&r&&e.push(t)}},{key:"createCustomElements",value:function(t,n,r){var i,a,s=null==r?void 0:r[t],o=null==(i=null==s?void 0:s.text)?void 0:i.content,l=null==(a=null==s?void 0:s.svg)?void 0:a.content,c=[];return e.tryAddSVGElement(c,n,l,o),o&&c.push(e.createTextElement(o)),c.length>0?c:void 0}}
2,{key:"reassignClassBasedOnChildren",value:function(t,n){t.classList.remove(e.INPUT_BUTTON_SVG_CLASS,e.INPUT_BUTTON_SVG_TEXT_CLASS),n.find((function(t){return t.classList.contains(e.INPUT_BUTTON_INNER_TEXT_CLASS)}))?n.length>1&&t.classList.add(e.INPUT_BUTTON_SVG_TEXT_CLASS):t.classList.add(e.INPUT_BUTTON_SVG_CLASS)}}])}();Tr.INPUT_BUTTON_SVG_TEXT_CLASS="input-button-svg-text",Tr.INPUT_BUTTON_INNER_TEXT_CLASS="text-button",Tr.INPUT_BUTTON_SVG_CLASS="input-button-svg";var Ar=Tr,Mr=function(){return N((function e(){R(this,e)}),null,[{key:"parseSVGTextElements",value:function(e){return{svg:e.find((function(e){return"svg"===e.tagName.toLowerCase()})),text:e.find((function(e){return"div"===e.tagName.toLowerCase()}))}}}])}(),Ir=function(){function e(){R(this,e)}return N(e,null,[{key:"unsetAllCSS",value:function(e,t){var n,r;t.container&&F.unsetAllCSSMouseStates(e,t.container);var i=Mr.parseSVGTextElements(Array.from(e.children)),a=i.svg,s=i.text;null!=(n=t.svg)&&n.styles&&a&&F.unsetAllCSSMouseStates(a,t.svg.styles),null!=(r=t.text)&&r.styles&&s&&F.unsetAllCSSMouseStates(s,t.text.styles)}},{key:"unsetActionCSS",value:function(e,t){var n,r;t.container&&F.unsetActivityCSSMouseStates(e,t.container);var i=Mr.parseSVGTextElements(Array.from(e.children)),a=i.svg,s=i.text;null!=(n=t.svg)&&n.styles&&a&&F.unsetActivityCSSMouseStates(a,t.svg.styles),null!=(r=t.text)&&r.styles&&s&&F.unsetActivityCSSMouseStates(s,t.text.styles)}},{key:"setElementsCSS",value:function(e,t,n){var r,i,a,s,o;Object.assign(e.style,null==(r=t.container)?void 0:r[n]);var l=Mr.parseSVGTextElements(Array.from(e.children)),c=l.svg,u=l.text;c&&Object.assign(c.style,null==(a=null==(i=t.svg)?void 0:i.styles)?void 0:a[n]),u&&Object.assign(u.style,null==(o=null==(s=t.text)?void 0:s.styles)?void 0:o[n])}},{key:"setElementCssUpToState",value:function(t,n,r){e.setElementsCSS(t,n,"default"),"default"!==r&&(e.setElementsCSS(t,n,"hover"),"hover"!==r&&e.setElementsCSS(t,n,"click"))}}])}(),Lr=function(){return N((function e(t,n,r,i,a){R(this,e),this._mouseState={state:"default"},this.isCustom=!1,Er.addAttributes(t),this.elementRef=t,this.svg=Nn.createSVGElement(n),this.customStyles=i,this.position=r,this.dropupText=a}),[{key:"buttonMouseLeave",value:function(e){this._mouseState.state="default",e&&(Ir.unsetAllCSS(this.elementRef,e),Ir.setElementsCSS(this.elementRef,e,"default"))}},{key:"buttonMouseEnter",value:function(e){this._mouseState.state="hover",e&&Ir.setElementsCSS(this.elementRef,e,"hover")}},{key:"buttonMouseUp",value:function(e){e&&Ir.unsetActionCSS(this.elementRef,e),this.buttonMouseEnter(e)}},{key:"buttonMouseDown",value:function(e){this._mouseState.state="click",e&&Ir.setElementsCSS(this.elementRef,e,"click")}},{key:"setEvents",value:function(e){this.elementRef.onmousedown=this.buttonMouseDown.bind(this,e),this.elementRef.onmouseup=this.buttonMouseUp.bind(this,e),this.elementRef.onmouseenter=this.buttonMouseEnter.bind(this,e),this.elementRef.onmouseleave=this.buttonMouseLeave.bind(this,e)}},{key:"unsetCustomStateStyles",value:function(e){if(this.customStyles)for(var t=0;t<e.length;t+=1){var n=e[t],r=n&&this.customStyles[n];r&&Ir.unsetActionCSS(this.elementRef,r)}}},{key:"reapplyStateStyle",value:function(e,t){if(this.customStyles){t&&this.unsetCustomStateStyles(t);var n=this.customStyles[e];n&&Ir.setElementCssUpToState(this.elementRef,n,this._mouseState.state),this.setEvents(n)}}},{key:"changeElementsByState",value:function(e){var t;(t=this.elementRef).replaceChildren.apply(t,v(e)),Ar.reassignClassBasedOnC
2hildren(this.elementRef,e)}},{key:"buildDefaultIconElement",value:function(e){var t=this.svg.cloneNode(!0);return t.id=e,[t]}},{key:"createInnerElements",value:function(e,t,n){var r=Ar.createCustomElements(t,this.svg,n);if(r&&r.length>0){if("dropup-menu"===this.position){var i=this.svg.cloneNode(!0);i.id=r[0]===this.svg?e:"dropup-menu-item-icon-element-custom",r[0]=i}return r}return this.buildDefaultIconElement(e)}}])}(),Or=function(e){function t(e){var n,r,i;R(this,t);var a=(null==(i=null==(r=null==e?void 0:e.default)?void 0:r.svg)?void 0:i.content)||t.EMPTY_SVG;return(n=_(this,t,[document.createElement("div"),a,void 0,e])).isActive=!1,n._innerElements=n.createInnerElementsForStates(n.customStyles),n.changeToDefault(),n}return x(t,e),N(t,[{key:"createInnerElementsForStates",value:function(e){return{default:this.createInnerButtonElements("default",e),active:this.createInnerButtonElements("active",e),unavailable:this.createInnerButtonElements("unavailable",e)}}},{key:"createInnerButtonElements",value:function(e,t){return Ar.createCustomElements(e,this.svg,t)||[this.svg]}},{key:"changeState",value:function(e){this.changeElementsByState(e),this.elementRef.classList.replace(Ar.INPUT_BUTTON_SVG_CLASS,"deep-chat-openai-realtime-button")}},{key:"changeToActive",value:function(){this.changeState(this._innerElements.active),this.reapplyStateStyle("active",["unavailable","default"]),this.isActive=!0}},{key:"changeToDefault",value:function(){var e,t,n,r;this.changeState(this._innerElements.default),null!=(e=this.customStyles)&&e.active&&Ir.unsetAllCSS(this.elementRef,null==(t=this.customStyles)?void 0:t.active),null!=(n=this.customStyles)&&n.unavailable&&Ir.unsetAllCSS(this.elementRef,null==(r=this.customStyles)?void 0:r.unavailable),this.reapplyStateStyle("default",["active","unavailable"]),this.isActive=!1}},{key:"changeToUnavailable",value:function(){var e,t,n,r;this.changeState(this._innerElements.unavailable),null!=(e=this.customStyles)&&e.active&&Ir.unsetAllCSS(this.elementRef,null==(t=this.customStyles)?void 0:t.active),null!=(n=this.customStyles)&&n.default&&Ir.unsetAllCSS(this.elementRef,null==(r=this.customStyles)?void 0:r.default),this.reapplyStateStyle("unavailable",["default","active"]),this.isActive=!1}}])}(Lr);Or.EMPTY_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"></svg>';var Rr=Or,Pr=function(){function e(){R(this,e)}return N(e,null,[{key:"setPropertyValueIfDoesNotExist",value:function(t,n,r){var i,a,s=n[0];1===n.length?null!==(i=t[s])&&void 0!==i||(t[s]=r):(null!==(a=t[s])&&void 0!==a||(t[s]={}),n.shift(),e.setPropertyValueIfDoesNotExist(t[s],n,r))}},{key:"setPropertyValue",value:function(t,n,r){var i,a=n[0];1===n.length?t[a]=r:(null!==(i=t[a])&&void 0!==i||(t[a]={}),n.shift(),e.setPropertyValue(t[a],n,r))}},{key:"getObjectValue",value:function(t,n){var r=t[n[0]];return void 0===r||1===n.length?r:e.getObjectValue(r,n.slice(1))}},{key:"overwritePropertyObjectFromAnother",value:function(t,n,r){var i=e.getObjectValue(n,r);if(i){var a=I(I({},i),e.getObjectValue(t,r)||{});e.setPropertyValue(t,r,a)}}},{key:"isJson",value:function(e){try{return JSON.stringify(e),!0}catch(e){return!1}}},{key:"assignPropertyFromOneToAnother",value:function(e,t,n){var r;null!==(r=t[e])&&void 0!==r||(t[e]={}),Object.assign(t[e],null==n?void 0:n[e])}}])}(),Nr='<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">\n  <path d="M5.92 24.096q0 1.088 0.928 1.728 0.512 0.288 1.088 0.288 0.448 0 0.896-0.224l16.16-8.064q0.48-0.256 0.8-0.736t0.288-1.088-0.288-1.056-0.8-0.736l-16.16-8.064q-0.448-0.224-0.896-0.224-0.544 0-1.088 0.288-0.928 0.608-0.928 1.728v16.16z"></path>\n</svg>',jr='<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.92 24.096q0 0.832 0.576 1.408t1.44 0.608h16.128q0.832 0 1.44-0.608t0.576-1.408v-16.16q0-0.832-0.576-1.44t-1.44-0.576h-16.128q-0.832 0-1.44 0.576t-0.576 1.44v16.16z"></path>\n</svg>',Dr=function(e){function t(e){var n,r,i,a,s,o;R(this,t);var l=JSON.parse(JSON.stringify(e.directConnection)),c=t.getKey(e);
2(r=_(this,t,[e,dr.buildKeyVerificationDetails(),dr.buildHeaders,{key:c}])).insertKeyPlaceholderText="OpenAI API Key",r.keyHelpUrl="https://platform.openai.com/account/api-keys",r._microphoneButton=null,r._toggleButton=null,r._errorElement=null,r._loadingElement=null,r._pc=null,r._mediaStream=null,r._isMuted=!1;var u=null==(i=l.openAI)?void 0:i.realtime;if("object"==O(u)){r._avatarConfig=u.avatar,r._ephemeralKey=u.ephemeralKey,r._errorConfig=u.error,r._loadingConfig=u.loading,Object.assign(r.rawBody,u.config);var d=((null==(s=null==(a=e.directConnection)?void 0:a.openAI)?void 0:s.realtime).config||{}).function_handler;d&&(r._functionHandler=d)}return null!==(n=(o=r.rawBody).model)&&void 0!==n||(o.model="gpt-4o-realtime-preview-2024-12-17"),r._avatarConfig=t.buildAvatarConfig(u),r._buttonsConfig=t.buildButtonsConfig(u),r._avatarEl=t.createAvatar(r._avatarConfig),r._containerEl=r.createContainer(),r._deepChat=e,r}return x(t,e),N(t,[{key:"setUpView",value:function(e,t){e.style.display="none",t.appendChild(this._containerEl),this.setup()}},{key:"setup",value:(s=A(C().mark((function e(){var t,n,r,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=null==(t=this._deepChat.directConnection)?void 0:t.openAI){e.next=3;break}return e.abrupt("return");case 3:if("object"==O(r=null==n?void 0:n.realtime)&&(r.autoStart||r.autoFetchEphemeralKey)){e.next=6;break}return e.abrupt("return");case 6:i=this.key||n.key,(r.fetchEphemeralKey||i)&&r.autoStart&&(this.changeToUnavailable(),this.displayLoading()),this.fetchEphemeralKey(r.autoStart);case 8:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"fetchEphemeralKey",value:(a=A(C().mark((function e(t){var n,r,i,a,s,o;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=null==(n=this._deepChat.directConnection)?void 0:n.openAI,i="object"==O(null==r?void 0:r.realtime)?null==r?void 0:r.realtime.fetchEphemeralKey:void 0,a=null==r?void 0:r.realtime,s=this.key||r.key,"object"!=O(a)){e.next=26;break}if(this._ephemeralKey){e.next=23;break}if(e.prev=3,!i){e.next=12;break}return(o=i()).then&&(this._retrievingEphemeralKey=o),e.next=9,o;case 9:this._ephemeralKey=e.sent,e.next=18;break;case 12:if(e.t0=s,!e.t0){e.next=18;break}return this._retrievingEphemeralKey=this.getEphemeralKey(s),e.next=17,this._retrievingEphemeralKey;case 17:this._ephemeralKey=e.sent;case 18:e.next=23;break;case 20:e.prev=20,e.t1=e.catch(3),this.displayFailedToRetrieveEphemeralKey(e.t1);case 23:this._ephemeralKey&&(t?this.init(this._ephemeralKey):this.changeToAvailable()),e.next=38;break;case 26:if(!s){e.next=38;break}return e.prev=27,this._retrievingEphemeralKey=this.getEphemeralKey(s),e.next=31,this._retrievingEphemeralKey;case 31:this._ephemeralKey=e.sent,t&&this.init(this._ephemeralKey),e.next=38;break;case 35:e.prev=35,e.t2=e.catch(27),this.displayFailedToRetrieveEphemeralKey(e.t2);case 38:case"end":return e.stop()}}),e,this,[[3,20],[27,35]])}))),function(e){return a.apply(this,arguments)})},{key:"getEphemeralKey",value:(i=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("https://api.openai.com/v1/realtime/sessions",{method:"POST",body:JSON.stringify(this.rawBody),headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)}});case 2:return e.next=4,e.sent.json();case 4:return e.abrupt("return",e.sent.client_secret.value);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"createContainer",value:function(){var e=document.createElement("div");return e.id="deep-chat-openai-realtime-container",e.appendChild(this.createAvatarContainer()),e.appendChild(this.createButtonsContainer()),e.appendChild(this.createError()),e}},{key:"createAvatarContainer",value:function(){var e,t,n=document.createElement("div");return n.id="deep-chat-openai-realtime-avatar-container",Object.assign(n.style,null==(t=null==(e=this._avatarConfig)?void 0:e.styles)?void 0:t.container),n.appendChild(this._avatarEl),n}},{key:"createButtonsContainer",value:function(){var e,n=document.createElement("div");n.id="deep-chat-openai-realtime-buttons-container",Object.assign(n.style,null==(e=this._buttonsConfig)?void 0:e.container),this._microphoneButton=this.createMicophoneButton();var r=t.createButtonContainer(this._microphoneButton.elementRef);this._toggleButton=this.createToggleButton();var i=t.createButtonContainer(this._toggleButton.elementRef);return n.appendChild(r),n.appendChild(i),n.appendChild(this.createLoading()),n}},{key:"createMicophoneButton",value:function(){var e,n=this,r=new Rr(null==(e=this._buttonsConfig)?void 0:e.microphone);return r.elementRef.classList.add(t.BUTTON_DEFAULT,"deep-chat-openai-realtime-microphone"),r.elementRef.onclick=function(){r.isActive?(n.toggleMicorphone(!0),r.elementRef.classList.replace(t.MICROPHONE_ACTIVE,t.BUTTON_DEFAULT),r.changeToDefault(),n._isMuted=!1):(n.toggleMicorphone(!1),r.elementRef.classList.replace(t.BUTTON_DEFAULT,t.MICROPHONE_ACTIVE),Er.removeAriaAttributes(r.elementRef),r.changeToActive(),n._isMuted=!0)},r}},{key:"toggleMicorphone",value:function(e){var t;
2null==(t=this._mediaStream)||t.getAudioTracks().forEach((function(t){return t.enabled=e}))}},{key:"createToggleButton",value:function(){var e,n=this,r=new Rr(null==(e=this._buttonsConfig)?void 0:e.toggle);return r.elementRef.classList.add(t.BUTTON_DEFAULT,"deep-chat-openai-realtime-toggle"),r.elementRef.onclick=A(C().mark((function e(){var t,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.isActive){e.next=4;break}r.changeToDefault(),n.stop(),e.next=30;break;case 4:if(e.prev=4,!n._ephemeralKey){e.next=11;break}return n.displayLoading(),e.next=9,n.init(n._ephemeralKey);case 9:e.next=25;break;case 11:if(!n._retrievingEphemeralKey){e.next=22;break}return n.displayLoading(),e.next=15,n._retrievingEphemeralKey;case 15:if(i=e.sent,e.t0=null!=(t=n._toggleButton)&&t.isActive,!e.t0){e.next=20;break}return e.next=20,n.init(i);case 20:e.next=25;break;case 22:return n.displayLoading(),e.next=25,n.fetchEphemeralKey(!0);case 25:e.next=30;break;case 27:e.prev=27,e.t1=e.catch(4),console.error("Failed to start conversation:",e.t1),n.displayError(),n.hideLoading();case 30:case"end":return e.stop()}}),e,null,[[4,27]])}))),r}},{key:"init",value:(r=A(C().mark((function e(t){var n,r,i,a,s,o,l,c,u,d=this;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new RTCPeerConnection,this._pc=n,(r=document.createElement("audio")).autoplay=!0,i=new AudioContext,(a=i.createAnalyser()).fftSize=256,s=new Uint8Array(a.frequencyBinCount),this._pc.ontrack=function(){var e=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.streams[0]){e.next=11;break}if(r.srcObject=t.streams[0],n=i.createMediaStreamSource(t.streams[0]),e.t0="suspended"===i.state,!e.t0){e.next=7;break}return e.next=7,i.resume();case 7:n.connect(a),d.monitorFrequencies(a,s),e.next=12;break;case 11:console.error("No streams found in the ontrack event."),d.displayError();case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=10,navigator.mediaDevices.getUserMedia({audio:!0}).then((function(e){var t;n===d._pc&&(d._mediaStream=e,null==(t=d._pc)||t.addTrack(d._mediaStream.getTracks()[0]),d._isMuted&&d.toggleMicorphone(!1))})).catch((function(e){console.error("Error accessing microphone:",e),d.displayError()}));case 10:return(o=this._pc.createDataChannel("oai-events")).addEventListener("message",function(){var e=A(C().mark((function e(t){var n,r,i,a,s;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("session.created"!==(r=JSON.parse(t.data)).type){e.next=5;break}d.removeUnavailable(),d._toggleButton&&(Er.removeAriaAttributes(d._toggleButton.elementRef),d._toggleButton.changeToActive()),d.hideLoading(),e.next=20;break;case 5:if("response.done"!==r.type){e.next=19;break}if("function_call"!==(null==(i=null==(n=JSON.parse(t.data).response.output)?void 0:n[0])?void 0:i.type)){e.next=17;break}return a=i.name,s=i.call_id,e.prev=9,e.next=12,d.handleTool(a,i.arguments,s,o);case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(9),d.stopOnError(e.t0);case 17:e.next=20;break;case 19:"error"===r.type?d.stopOnError(r.error.message):"invalid_request_error"===r.type?d.stopOnError(r.message):r.type;case 20:case"end":return e.stop()}}),e,null,[[9,14]])})));return function(t){return e.apply(this,arguments)}}()),e.prev=12,e.next=15,this._pc.createOffer();case 15:if(l=e.sent,e.t0=n!==this._pc,e.t0){e.next=21;break}return e.next=20,this._pc.setLocalDescription(l);case 20:e.t0=n!==this._pc;case 21:if(!e.t0){e.next=23;break}return e.abrupt("return");case 23:return e.next=25,fetch("https://api.openai.com/v1/realtime",{method:"POST",body:l.sdp,headers:{Authorization:"Bearer ".concat(t),"Content-Type":"application/sdp"}});case 25:if(c=e.sent,n===this._pc){e.next=28;break}return e.abrupt("return");case 28:return e.next=30,c.text();case 30:if(e.t1=e.sent,u={type:"answer",sdp:e.t1},e.t2=n!==this._pc,e.t2){e.next=37;break}return e.next=36,this._pc.setRemoteDescription(u);case 36:e.t2=n!==this._pc;case 37:if(!e.t2){e.next=39;break}return e.abrupt("return");case 39:e.next=44;break;case 41:e.prev=41,e.t3=e.catch(12),console.error(e.t3),this.displayError();case 44:case"end":return e.stop()}}),e,this,[[12,41]])}))),function(e){return r.apply(this,arguments)})},{key:"monitorFrequencies",value:function(e,t){var n=this,r=function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(){var i;e.getByteFrequencyData(t);var a=1+t.reduce((function(e,t){return e+t}),0)/(255*t.length)*100/100*((null==(i=n._avatarConfig)?void 0:i.maxScale)-1);n._avatarEl.style.transform="scale(".concat(a,")"),requestAnimationFrame(r)}));r()}},{key:"stopOnError",value:function(e){this.stop(),console.error(e),this.displayError()}},{key:"stop",value:function(){var e;
2null==(e=this._mediaStream)||e.getTracks().forEach((function(e){return e.stop()})),this._mediaStream=null,this._pc&&(this._pc.close(),this._pc=null)}},{key:"changeToUnavailable",value:function(){this._microphoneButton&&t.changeButtonToUnavailable(this._microphoneButton),this._toggleButton&&t.changeButtonToUnavailable(this._toggleButton)}},{key:"changeToAvailable",value:function(){this._microphoneButton&&t.changeButtonToAvailable(this._microphoneButton),this._toggleButton&&t.changeButtonToAvailable(this._toggleButton)}},{key:"removeUnavailable",value:function(){this._microphoneButton&&t.removeButtonUnavailable(this._microphoneButton),this._toggleButton&&t.removeButtonUnavailable(this._toggleButton)}},{key:"createError",value:function(){var e,t=document.createElement("div");return t.id="deep-chat-openai-realtime-error",Object.assign(t.style,null==(e=this._errorConfig)?void 0:e.style),this._errorElement=t,t}},{key:"displayFailedToRetrieveEphemeralKey",value:function(e){console.error("Failed to retrieve ephemeral key"),console.error(e),this.displayError()}},{key:"displayError",value:function(){var e;this._errorElement&&(this._errorElement.style.display="block",this._errorElement.textContent=(null==(e=this._errorConfig)?void 0:e.text)||"Error",this.changeToUnavailable()),this.hideLoading()}},{key:"createLoading",value:function(){var e,t,n=document.createElement("div");return n.id="deep-chat-openai-realtime-loading",this._loadingElement=n,null!=(e=this._loadingConfig)&&e.html&&(this._loadingElement.innerHTML=this._loadingConfig.html),Object.assign(n.style,null==(t=this._loadingConfig)?void 0:t.style),n.style.display="none",n}},{key:"displayLoading",value:function(){var e,n,r;this._toggleButton&&(this._toggleButton.changeToActive(),this._toggleButton.elementRef.classList.add(t.BUTTON_LOADING),Er.removeAriaDisabled(this._toggleButton.elementRef),Er.addAriaBusy(this._toggleButton.elementRef)),("boolean"!=typeof(null==(e=this._loadingConfig)?void 0:e.display)||this._loadingConfig.display)&&this._loadingElement&&(this._loadingElement.style.display="block",null!=(n=this._loadingConfig)&&n.html||(this._loadingElement.textContent=(null==(r=this._loadingConfig)?void 0:r.text)||"Loading"))}},{key:"hideLoading",value:function(){this._toggleButton&&(this._toggleButton.elementRef.classList.remove(t.BUTTON_LOADING),Er.removeAriaBusy(this._toggleButton.elementRef)),this._loadingElement&&(this._loadingElement.style.display="none")}},{key:"handleTool",value:(n=A(C().mark((function e(t,n,r,i){var a,s,o;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._functionHandler){e.next=2;break}throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/OpenAI/OpenAIRealtime#OpenAIRealtimeFunction) object.");case 2:return e.next=4,this._functionHandler({name:t,arguments:n});case 4:if("object"==O(a=e.sent)&&Pr.isJson(a)){e.next=7;break}throw Error('The `function_handler` response must be a JSON object, e.g. {response: "My response"}');case 7:s=JSON.stringify({type:"conversation.item.create",item:{type:"function_call_output",call_id:r,output:JSON.stringify(a)}}),i.send(s),o={type:"response.create"},i.send(JSON.stringify(o));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i){return n.apply(this,arguments)})},{key:"isCustomView",value:function(){return!0}}],[{key:"getKey",value:function(e){var t=e.directConnection.openAI;if(null!=t&&t.key)return t.key;var n=null==t?void 0:t.realtime;return"object"==O(n)&&(n.ephemeralKey||n.fetchEphemeralKey)?"placeholder":void 0}},{key:"buildAvatarConfig",value:function(e){var t="object"==O(e)&&e.avatar?JSON.parse(JSON.stringify(e.avatar)):{};return t.maxScale=t.maxScale&&t.maxScale>=1?t.maxScale:2.5,t}},{key:"buildButtonsConfig",value:function(e){var t,n,r,i,a,s,o,l,c,u,d,h,p,f,m,g,v,y,b,_,w,k,S,x,E,C,T="object"==O(e)&&e.buttons?JSON.parse(JSON.stringify(e.buttons)):{};return null!=(f=null==(p=null==(h=T.microphone)?void 0:h.default)?void 0:p.text)&&f.content||(null!==(t=T.microphone)&&void 0!==t||(T.microphone={}),null!==(n=(m=T.microphone).default)&&void 0!==n||(m.default={}),null!==(r=(g=T.microphone.default).svg)&&void 0!==r||(g.svg={}),null!==(i=(v=T.microphone.default.svg).content)&&void 0!==i||(v.content=Cr)),null!=(_=null==(b=null==(y=T.toggle)?void 0:y.default)?void 0:b.text)&&_.content||(null!==(a=T.toggle)&&void 0!==a||(T.toggle={}),null!==(s=(w=T.toggle).default)&&void 0!==s||(w.default={}),null!==(o=(k=T.toggle.default).svg)&&void 0!==o||(k.svg={}),null!==(l=(S=T.toggle.default.svg).content)&&void 0!==l||(S.content=Nr),null!==(c=(x=T.toggle).active)&&void 0!==c||(x.active={}),null!==(u=(E=T.toggle.active).svg)&&void 0!==u||(E.svg={}),null!==(d=(C=T.toggle.active.svg).content)&&void 0!==d||(C.content=jr)),T}},{key:"createAvatar",value:function(e){var t,n=document.createElement("img");return n.id="deep-chat-openai-realtime-avatar",Object.assign(n.style,null==(t=null==e?void 0:e.styles)?void 0:t.image),n.src=(null==e?void 0:e.src)||Qt,n}},{key:"createButtonContainer",value:function(e){var t=document.createElement("div");return t.classList.add("deep-chat-openai-realtime-button-container"),t.appendChild(e),t}},{key:"changeButtonToUnavailable",value:function(e){e.elementRef.classList.add(t.UNAVAILABLE),Er.removeAriaBusy(e.elementRef),Er.addAriaDisabled(e.elementRef),e.changeToUnavailable()}},{key:"changeButtonToAvailable",value:function(e){t.removeButtonUnavailable(e),e.changeToDefault()}},{key:"removeButtonUnavailable",value:function(e){Er.removeAriaDisabled(e.elementRef),e.elementRef.classList.remove(t.UNAVAILABLE)}}]);var n,r,i,a,s}(Ln);Dr.BUTTON_DEFAULT="deep-chat-openai-realtime-button-default",Dr.BUTTON_LOADING="deep-chat-openai-realtime-button-loading",Dr.MICROPHONE_ACTIVE="deep-chat-openai-realtime-microphone-active",Dr.UNAVAILABLE="deep-chat-openai-realtime-button-unavailable";var Br=Dr,Fr=function(e){function t(e){var n,r,i,a,s,o;R(this,t);var l=JSON.parse(JSON.stringify(e.directConnection)),c=null==l?void 0:l.openAI;
2(i=_(this,t,[e,dr.buildKeyVerificationDetails(),dr.buildHeaders,c])).insertKeyPlaceholderText="OpenAI API Key",i.keyHelpUrl="https://platform.openai.com/account/api-keys",i.url="https://api.openai.com/v1/audio/speech",i.permittedErrorPrefixes=["Invalid"],i.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>OpenAI : Text To Speech</b></div>\n    <p>Generate an audio file based on your text input.</p>\n    <p>Click <a href="https://platform.openai.com/docs/guides/text-to-speech">here</a> for more information.</p>';var u=null==(a=null==l?void 0:l.openAI)?void 0:a.textToSpeech;return"object"==O(u)&&Object.assign(i.rawBody,u),null!==(n=(s=i.rawBody).model)&&void 0!==n||(s.model=t.DEFAULT_MODEL),null!==(r=(o=i.rawBody).voice)&&void 0!==r||(o.voice=t.DEFAULT_VOIDE),i.textInputPlaceholderText="Insert text to generate audio",i.rawBody.response_format="mp3",i}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t){var n,r,i=JSON.parse(JSON.stringify(e)),a=null==(r=null==(n=t[t.length-1])?void 0:n.text)?void 0:r.trim();return a&&""!==a&&(i.input=a),i}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n){var r,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=this.connectSettings)&&r.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:this.url=this.connectSettings.url||this.url,i=this.preprocessBody(this.rawBody,n),En.request(this,i,t);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t instanceof Blob)){e.next=2;break}return e.abrupt("return",new Promise((function(e){var n=new FileReader;n.readAsDataURL(t),n.onload=function(t){e({files:[{src:t.target.result,type:"audio"}]})}})));case 2:if(!t.error){e.next=4;break}throw t.error.message;case 4:return e.abrupt("return",{error:"error"});case 5:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(Ln);Fr.DEFAULT_MODEL="tts-1",Fr.DEFAULT_VOIDE="alloy";var Ur=Fr,zr=function(e){function t(e){var n,r,i,a;R(this,t);var s=JSON.parse(JSON.stringify(e.directConnection)),o=null==s?void 0:s.openAI;(r=_(this,t,[e,dr.buildKeyVerificationDetails(),dr.buildHeaders,o,{audio:{}}])).insertKeyPlaceholderText="OpenAI API Key",r.keyHelpUrl="https://platform.openai.com/account/api-keys",r.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>OpenAI : Speech To Text</b></div>\n    <p><b>Upload an audio file</b> to transcribe it into text. You can optionally provide text to guide the audio\n      processing.\n    <p>Click <a href="https://platform.openai.com/docs/guides/speech-to-text">here</a> for more info.</p>',r.url="",r.permittedErrorPrefixes=["Invalid"],r.textInputPlaceholderText="Upload an audio file",r._service_url=t.AUDIO_TRANSCRIPTIONS_URL;var l=null==(i=null==s?void 0:s.openAI)?void 0:i.audio;return"object"==O(l)&&(r.processConfig(l),t.cleanConfig(l),Object.assign(r.rawBody,l)),null!==(n=(a=r.rawBody).model)&&void 0!==n||(a.model=t.DEFAULT_MODEL),r.rawBody.response_format="json",r.canSendMessage=t.canSendFileMessage,r}return x(t,e),N(t,[{key:"processConfig",value:function(e){null!=e&&e.type&&"translation"===e.type&&(this._service_url=t.AUDIO_TRANSLATIONS_URL,delete e.language)}},{key:"preprocessBody",value:function(e,t){var n,r,i=JSON.parse(JSON.stringify(e)),a=null==(r=null==(n=t[t.length-1])?void 0:n.text)?void 0:r.trim();return a&&""!==a&&(i.prompt=a),i}},{key:"callServiceAPI",value:(r=A(C().mark((function e(n,r,i){var a,s,o;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(a=this.connectSettings)&&a.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null!=i&&i[0]){e.next=4;break}throw new Error("No file was added");case 4:this.url=this.connectSettings.url||this._service_url,s=this.preprocessBody(this.rawBody,r),o=t.createFormDataBody(s,i[0]),dn.tempRemoveContentHeader(this.connectSettings,En.request.bind(this,this,o,n),!1);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error.message;case 2:return e.abrupt("return",{text:t.text});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"canSendFileMessage",value:function(e,t){return!(null==t||!t[0])}},{key:"cleanConfig",value:function(e){delete e.type}},{key:"createFormDataBody",value:function(e,t){var n=new FormData;return n.append("file",t),Object.keys(e).forEach((function(t){n.append(t,String(e[t]))})),n}}]);var n,r}(Ln);zr.AUDIO_TRANSCRIPTIONS_URL="https://api.openai.com/v1/audio/transcriptions",zr.AUDIO_TRANSLATIONS_URL="https://api.openai.com/v1/audio/translations",zr.DEFAULT_MODEL="whisper-1";var qr=zr,Hr=function(){function e(){R(this,e)}return N(e,null,[{key:"buildTextToSpeechHeaders",value:function(e,t){return{"Ocp-Apim-Subscription-Key":t,"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":e}}
2},{key:"buildSpeechToTextHeaders",value:function(e){return{"Ocp-Apim-Subscription-Key":e,Accept:"application/json"}}},{key:"handleSpeechVerificationResult",value:function(e,t,n,r){e.error?r(ne.INVALID_KEY):n(t)}},{key:"buildSpeechKeyVerificationDetails",value:function(t){return{url:"https://".concat(t,".api.cognitive.microsoft.com/sts/v1.0/issuetoken"),method:"POST",createHeaders:function(e){return{"Ocp-Apim-Subscription-Key":"".concat(e)}},handleVerificationResult:e.handleSpeechVerificationResult}}},{key:"buildSummarizationHeader",value:function(e){return{"Ocp-Apim-Subscription-Key":e,"Content-Type":"application/json"}}},{key:"handleLanguageVerificationResult",value:function(e,t,n,r){var i;"401"===(null==(i=e.error)?void 0:i.code)?r(ne.INVALID_KEY):n(t)}},{key:"buildLanguageKeyVerificationDetails",value:function(t){return{url:"".concat(t,"/language/analyze-text/jobs?api-version=2022-10-01-preview"),method:"POST",createHeaders:function(e){return{"Ocp-Apim-Subscription-Key":"".concat(e)}},handleVerificationResult:e.handleLanguageVerificationResult}}},{key:"handleTranslationVerificationResult",value:function(e,t,n,r){e.json().then((function(e){Array.isArray(e)||401e3!==e.error.code?n(t):r(ne.INVALID_KEY)}))}},{key:"buildTranslationKeyVerificationDetails",value:function(t){return{url:"https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es",method:"POST",createHeaders:function(n){return e.buildTranslationHeaders(t,n)},handleVerificationResult:e.handleTranslationVerificationResult}}},{key:"buildTranslationHeaders",value:function(e,t){var n={"Ocp-Apim-Subscription-Key":t,"Content-Type":"application/json"};return e&&(n["Ocp-Apim-Subscription-Region"]=e),n}}])}(),Vr=function(e){function t(e,n,r,i,a){var s;return R(this,t),(s=_(this,t,[e,Hr.buildLanguageKeyVerificationDetails(r),n,i,a])).insertKeyPlaceholderText="Azure Language Subscription Key",s.keyHelpUrl="https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",s.permittedErrorPrefixes=["Access"],s}return x(t,e),N(t)}(Ln),Gr=function(e){function t(e){var n,r,i,a,s,o;R(this,t);var l=null==(a=null==(i=e.directConnection)?void 0:i.azure)?void 0:a.summarization,c=null==(s=e.directConnection)?void 0:s.azure;return(r=_(this,t,[e,Hr.buildSummarizationHeader,l.endpoint,c])).permittedErrorPrefixes=[t.ENDPOINT_ERROR_MESSAGE],r.url="",r.textInputPlaceholderText="Insert text to summarize",r.isTextInputDisabled=!1,l.endpoint?(null!==(n=(o=r.rawBody).language)&&void 0!==n||(o.language="en"),Object.assign(r.rawBody,l),r.url="".concat(l.endpoint,"/language/analyze-text/jobs?api-version=2022-10-01-preview")):(r.isTextInputDisabled=!0,r.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:t.ENDPOINT_ERROR_MESSAGE})}))),r}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t){var n=t[t.length-1].text;if(n)return{analysisInput:{documents:[{id:"1",language:e.language,text:n}]},tasks:[{kind:"ExtractiveSummarization"}]}}},{key:"callServiceAPI",value:(i=A(C().mark((function e(t,n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),En.request(this,r,t),this.messages=t;case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"extractResultData",value:(r=A(C().mark((function e(t){var n,r,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error.message;case 2:return this.messages&&this.completionsHandlers&&(r=t.headers.get("operation-location"),i={method:"GET",headers:null==(n=this.connectSettings)?void 0:n.headers},En.executePollRequest(this,r,i,this.messages)),e.abrupt("return",{makingAnotherRequest:!0});case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"extractPollResultData",value:(n=A(C().mark((function e(t){var n,r,i,a;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:if("running"!==t.status){e.next=4;break}return e.abrupt("return",{timeoutMS:2e3});case 4:if(!(t.errors.length>0)){e.next=6;break}throw t.errors[0];case 6:if(!(t.tasks.items[0].results.errors.length>0)){e.next=8;break}throw t.tasks.items[0].results.errors[0];case 8:n="",r=p(t.tasks.items[0].results.documents[0].sentences);try{for(r.s();!(i=r.n()).done;
2)a=i.value,n+=a.text}catch(e){r.e(e)}finally{r.f()}return e.abrupt("return",{text:n||""});case 12:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r,i}(Vr);Gr.ENDPOINT_ERROR_MESSAGE="Please define the azure endpoint. [More Information](https://deepchat.dev/docs/directConnection/Azure#Summarization)";var Wr=Gr,$r=function(){function e(){R(this,e)}return N(e,null,[{key:"poll",value:(t=A(C().mark((function e(t,n){var r,i,a,s;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={authorization:t,"content-type":"application/json"},e.t0="https://api.assemblyai.com/v2/transcript/",e.next=4,fetch("https://api.assemblyai.com/v2/transcript",{method:"POST",body:JSON.stringify({audio_url:n}),headers:r});case 4:return e.next=6,e.sent.json();case 6:e.t1=e.sent.id,i=e.t0.concat.call(e.t0,e.t1);case 8:if(a){e.next=24;break}return e.next=11,fetch(i,{headers:r});case 11:return e.next=13,e.sent.json();case 13:if("completed"!==(s=e.sent).status){e.next=18;break}a=s,e.next=22;break;case 18:if("error"!==s.status){e.next=20;break}throw new Error("Transcription failed: ".concat(s.error));case 20:return e.next=22,new Promise((function(e){return setTimeout(e,3e3)}));case 22:e.next=8;break;case 24:return e.abrupt("return",a);case 25:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"buildHeaders",value:function(e){return{Authorization:e,"Content-Type":"application/octet-stream"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i=e;i.error?"invalid_api_key"===i.error.code?r(ne.INVALID_KEY):r(ne.CONNECTION_FAILED):n(t)}},{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.assemblyai.com/v2/upload",method:"POST",handleVerificationResult:e.handleVerificationResult}}}]);var t}(),Kr=function(e){function t(e){var n,r;R(this,t);var i=null==(r=e.directConnection)?void 0:r.assemblyAI;return(n=_(this,t,[e,$r.buildKeyVerificationDetails(),$r.buildHeaders,i,{audio:{}}])).insertKeyPlaceholderText="AssemblyAI API Key",n.keyHelpUrl="https://www.assemblyai.com/app/account",n.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>AssemblyAI Audio</b></div>\n    <p><b>Upload an audio file</b> to transcribe it into text.\n    <p>\n      Click <a href="https://www.assemblyai.com/docs/Guides/transcribing_an_audio_file#get-started">here</a> for more info.\n    </p>',n.url="https://api.assemblyai.com/v2/upload",n.isTextInputDisabled=!0,n.textInputPlaceholderText="Upload an audio file",n.permittedErrorPrefixes=["Authentication","Invalid"],n.canSendMessage=t.canFileSendMessage,n}return x(t,e),N(t,[{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n,r){var i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(i=this.connectSettings)&&i.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null!=r&&r[0]){e.next=4;break}throw new Error("No file was added");case 4:En.request(this,r[0],t,!1);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){var n,r,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return i=null==(r=null==(n=this.connectSettings)?void 0:n.headers)?void 0:r.Authorization,e.next=5,$r.poll(i,t.upload_url);case 5:return e.t0=e.sent.text,e.abrupt("return",{text:e.t0});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})}],[{key:"canFileSendMessage",value:function(e,t){return!(null==t||!t[0])}}]);var n,r}(Ln),Jr=function(e){function t(e,n,r,i,a){var s;return R(this,t),(s=_(this,t,[e,Hr.buildSpeechKeyVerificationDetails(r),n,i,a])).insertKeyPlaceholderText="Azure Speech Subscription Key",s.keyHelpUrl="https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",s}return x(t,e),N(t)}(Ln),Zr=function(e){function t(e){var n,r,i,a,s,o,l,c,u,d;R(this,t);var h=null==(o=null==(s=e.directConnection)?void 0:s.azure)?void 0:o.textToSpeech,p=null==(l=e.directConnection)?void 0:l.azure;return(a=_(this,t,[e,Hr.buildTextToSpeechHeaders.bind({},(null==h?void 0:h.outputFormat)||"audio-16khz-128kbitrate-mono-mp3"),h.region,p])).permittedErrorPrefixes=[t.REGION_ERROR_MESSAGE],a.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>Azure Text To Speech</b></div>\n    <p>
2Insert text to synthesize it to audio.\n    <p>\n      Click <a href="'.concat(t.HELP_LINK,'">here</a> for more info.\n    </p>'),a.isTextInputDisabled=!1,a.url="",h.region?(Object.assign(a.rawBody,h),null!==(n=(c=a.rawBody).lang)&&void 0!==n||(c.lang="en-US"),null!==(r=(u=a.rawBody).name)&&void 0!==r||(u.name="en-US-JennyNeural"),null!==(i=(d=a.rawBody).gender)&&void 0!==i||(d.gender="Female"),a.url="https://".concat(h.region,".tts.speech.microsoft.com/cognitiveservices/v1")):(a.isTextInputDisabled=!0,a.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:t.REGION_ERROR_MESSAGE})}))),a}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t){var n=t[t.length-1].text;if(n)return"<speak version='1.0' xml:lang='".concat(e.lang,"'>\n      <voice xml:lang='").concat(e.lang,"' xml:gender='").concat(e.gender,"' name='").concat(e.name,"'>\n        ").concat(n,"\n      </voice>\n    </speak>")}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),En.request(this,r,t,!1);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){var n=new FileReader;n.readAsDataURL(t),n.onload=function(t){e({files:[{src:t.target.result,type:"audio"}]})}})));case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(Jr);Zr.HELP_LINK="https://learn.microsoft.com/en-GB/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal&pivots=programming-language-rest",Zr.REGION_ERROR_MESSAGE="Please define a region config property. [More Information](https://deepchat.dev/docs/directConnection/Azure#TextToSpeech)";var Yr=Zr,Xr=function(e){function t(e){var n,r,i,a;R(this,t);var s=null==(i=null==(r=e.directConnection)?void 0:r.azure)?void 0:i.speechToText,o=null==(a=e.directConnection)?void 0:a.azure;if((n=_(this,t,[e,Hr.buildSpeechToTextHeaders,s.region,o,{audio:{files:{acceptedFormats:".wav,.ogg"}}}])).permittedErrorPrefixes=[t.REGION_ERROR_MESSAGE],n.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>Azure Speech To Text</b></div>\n    <p><b>Upload a .wav or .ogg audio file</b> to transcribe it into text.\n    <p>\n      Click <a href="'.concat(t.HELP_LINK,'">here</a> for more info.\n    </p>'),n.url="",n.isTextInputDisabled=!0,n.textInputPlaceholderText="Upload an audio file",s.region){n.canSendMessage=t.canFileSendMessage;var l=s.lang||"en-US";n.url="https://".concat(s.region,".stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=").concat(l,"&format=detailed"),n.recordAudio=void 0}else n.isTextInputDisabled=!0,n.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:t.REGION_ERROR_MESSAGE})}));return n}return x(t,e),N(t,[{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n,r){var i,a;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(i=this.connectSettings)&&i.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null!=r&&r[0]){e.next=4;break}throw new Error("No file was added");case 4:null!=(a=this.connectSettings)&&a.headers&&(this.connectSettings.headers["Content-Type"]=r[0].name.toLocaleLowerCase().endsWith(".wav")?"audio/wav; codecs=audio/pcm; samplerate=16000":"audio/ogg; codecs=opus"),En.request(this,r[0],t,!1);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:t.DisplayText||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"canFileSendMessage",value:function(e,t){return!(null==t||!t[0])}}]);var n,r}(Jr);Xr.HELP_LINK="https://learn.microsoft.com/en-GB/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal&pivots=programming-language-rest",Xr.REGION_ERROR_MESSAGE="Please define a region config property. [More Information](https://deepchat.dev/docs/directConnection/Azure#SpeechToText)";var Qr=Xr,ei=function(e){function t(e){var n,r,i,a;R(this,t);var s=null==(i=null==(r=e.directConnection)?void 0:r.azure)?void 0:i.translation,o=null==(a=e.directConnection)?void 0:a.azure;
2return(n=_(this,t,[e,Hr.buildTranslationKeyVerificationDetails(s.region),Hr.buildTranslationHeaders.bind({},null==s?void 0:s.region),o])).insertKeyPlaceholderText="Azure Translate Subscription Key",n.keyHelpUrl="https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",n.url="",n.url="https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=".concat(s.language||"es"),n}return x(t,e),N(t,[{key:"preprocessBody",value:function(e){var t=e[e.length-1].text;if(t)return[{Text:t}]}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(n),En.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Array.isArray(t)){e.next=2;break}return e.abrupt("return",{text:(null==(n=t[0].translations)?void 0:n[0].text)||""});case 2:throw t.error;case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(Ln),ti=function(e){function t(e,n,r,i,a){var s,o,l,c,u,d,h,p;R(this,t);var f=JSON.parse(JSON.stringify(e.directConnection));(l=_(this,t,[e,n||dr.buildKeyVerificationDetails(),r||dr.buildHeaders,i||f.openAI])).insertKeyPlaceholderText="OpenAI API Key",l.keyHelpUrl="https://platform.openai.com/account/api-keys",l.url="https://api.openai.com/v1/chat/completions",l.permittedErrorPrefixes=["Incorrect"],l.asyncCallInProgress=!1,l._systemMessage=t.generateSystemMessage("You are a helpful assistant.");var m=a||(null==(c=f.openAI)?void 0:c.chat);if("object"==O(m)){m.system_prompt&&(l._systemMessage=t.generateSystemMessage(m.system_prompt));var g=null==(h=null==(d=null==(u=e.directConnection)?void 0:u.openAI)?void 0:d.chat)?void 0:h.function_handler;g&&(l._functionHandler=g),l.cleanConfig(m),Object.assign(l.rawBody,m)}return null!==(s=l.maxMessages)&&void 0!==s||(l.maxMessages=-1),null!==(o=(p=l.rawBody).model)&&void 0!==o||(p.model="gpt-4o"),l}return x(t,e),N(t,[{key:"cleanConfig",value:function(e){delete e.system_prompt,delete e.function_handler}},{key:"preprocessBody",value:function(e,n){var r,i=JSON.parse(JSON.stringify(e)),a=An.getCharacterLimitMessages(n,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.content.length:-1).map((function(e){return{content:t.getContent(e),role:e.role===on.USER_ROLE?"user":"assistant"}}));return n.find((function(e){return e.files&&e.files.length>0}))&&(null!==(r=i.max_tokens)&&void 0!==r||(i.max_tokens=300)),i.messages=[this._systemMessage].concat(v(a)),i}},{key:"callServiceAPI",value:(a=A(C().mark((function e(t,n){var r,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),(i=this.stream)&&("object"!=O(i)||!i.simulation)||r.stream?(r.stream=!0,_n.request(this,r,t)):En.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"extractResultData",value:(i=A(C().mark((function e(t,n,r){var i,a,s,o;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error.message;case 2:return e.abrupt("return",null!=(a=null==(i=t.choices)?void 0:i[0])&&a.delta?this.extractStreamResult(t.choices[0],n,r):null!=(o=null==(s=t.choices)?void 0:s[0])&&o.message?t.choices[0].message.tool_calls?this.handleTools(t.choices[0].message,n,r):{text:t.choices[0].message.content}:{text:""});case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"extractStreamResult",value:(r=A(C().mark((function e(t,n,r){var i,a,s=this;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.delta,"tool_calls"!==t.finish_reason){e.next=7;break}return this.asyncCallInProgress=!0,a={tool_calls:this._streamToolCalls},e.abrupt("return",(this._streamToolCalls=void 0,this.handleTools(a,n,r)));case 7:null!=i&&i.tool_calls&&(this._streamToolCalls?i.tool_calls.forEac
2h((function(e,t){s._streamToolCalls&&(s._streamToolCalls[t].function.arguments+=e.function.arguments)})):this._streamToolCalls=i.tool_calls);case 8:return e.abrupt("return",{text:(null==i?void 0:i.content)||""});case 9:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"handleTools",value:(n=A(C().mark((function e(t,n,r){var i,a,s,o,l,c,u,d,h,p,f,m;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.tool_calls&&n&&r&&this._functionHandler){e.next=2;break}throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/openAI#Chat) object.");case 2:return c=JSON.parse(JSON.stringify(r)),u=t.tool_calls.map((function(e){return{name:e.function.name,arguments:e.function.arguments}})),e.next=6,null==(i=this._functionHandler)?void 0:i.call(this,u);case 6:if(d=e.sent,Array.isArray(d)){e.next=20;break}if(!d.text){e.next=19;break}return h={text:d.text},e.next=12,null==(s=(a=this.deepChat).responseInterceptor)?void 0:s.call(a,h);case 12:if(e.t0=e.sent,e.t0){e.next=15;break}e.t0=h;case 15:if(p=e.t0,!Array.isArray(p)){e.next=18;break}throw Error(dr.FUNCTION_TOOL_RESP_ARR_ERROR);case 18:return e.abrupt("return",p);case 19:throw Error(dr.FUNCTION_TOOL_RESP_ERROR);case 20:return e.next=22,Promise.all(d);case 22:if(f=e.sent,c.messages.push({tool_calls:t.tool_calls,role:"assistant",content:null}),f.find((function(e){return"string"!=typeof e.response}))||u.length!==f.length){e.next=43;break}return f.forEach((function(e,n){var r,i=null==(r=t.tool_calls)?void 0:r[n];null==c||c.messages.push({role:"tool",tool_call_id:null==i?void 0:i.id,name:null==i?void 0:i.function.name,content:e.response})})),delete c.tools,delete c.tool_choice,delete c.stream,e.prev=25,e.next=28,null==n?void 0:n(c).then((function(e){return dn.processResponseByType(e)}));case 28:return m=e.sent,e.next=31,null==(l=(o=this.deepChat).responseInterceptor)?void 0:l.call(o,m);case 31:if(e.t1=e.sent,e.t1){e.next=34;break}e.t1=m;case 34:if(!(m=e.t1).error){e.next=37;break}throw m.error.message;case 37:return e.abrupt("return",{text:m.choices[0].message.content||""});case 40:throw e.prev=40,e.t2=e.catch(25),this.asyncCallInProgress=!1,e.t2;case 43:throw Error(dr.FUNCTION_TOOL_RESP_ERROR);case 44:case"end":return e.stop()}}),e,this,[[25,40]])}))),function(e,t,r){return n.apply(this,arguments)})}],[{key:"generateSystemMessage",value:function(e){return{role:"system",content:e}}},{key:"getContent",value:function(e){if(e.files&&e.files.length>0){var t=e.files.map((function(e){return{type:"image_url",image_url:{url:e.src}}}));return e.text&&e.text.trim().length>0&&t.unshift({type:"text",text:e.text}),t}return e.text}}]);var n,r,i,a}(Ln),ni=function(e){function t(e){var n,r,i,a,s,o,l,c;R(this,t);var u=JSON.parse(JSON.stringify(e.directConnection)),d=u.azure,h=(null==(i=null==(r=u.azure)?void 0:r.openAI)?void 0:i.urlDetails)||{},p=null==(s=null==(a=u.azure)?void 0:a.openAI)?void 0:s.chat;if((n=_(this,t,[e,wr.buildKeyVerificationDetails(h),wr.buildHeaders,d,p])).permittedErrorPrefixes=[wr.URL_DETAILS_ERROR_MESSAGE],n.isTextInputDisabled=!1,"object"==O(p)){var f=(null==(c=null==(l=null==(o=e.directConnection)?void 0:o.azure)?void 0:l.openAI)?void 0:c.chat).function_handler;f&&(n._functionHandler=f)}return wr.validateURLDetails(h)?n.url=t.buildURL(h):(n.isTextInputDisabled=!0,n.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:wr.URL_DETAILS_ERROR_MESSAGE})}))),n}return x(t,e),N(t,null,[{key:"buildURL",value:function(e){var t=e.endpoint,n=e.deploymentId,r=e.version;return"".concat(t,"/openai/deployments/").concat(n,"/completions?api-version=").concat(r)}}])}(ti),ri=function(e){function t(e){var n,r;R(this,t);var i=e.directConnection,a=null==i?void 0:i.openAI;(n=_(this,t,[e,dr.buildKeyVerificationDetails(),dr.buildHeaders,a,{images:{files:{acceptedFormats:".png",maxNumberOfFiles:2}}}])).insertKeyPlaceholderText="OpenAI API Key",n.keyHelpUrl="https://platform.openai.com/account/api-keys",n.introPanelMarkUp='\n    <div style="width: 100%; text-align: center; margin-left: -10px"><b>OpenAI DALL·E</b></div>\n    <p><b>Insert text</b> to generate an image.</p>\n    <p><b>Upload 1</b> PNG image to generate its variation and optionally insert text to specify the change.</p>\n    <p><b>Upload 2</b> PNG images where the second is a copy of the first with a transparent area where the edit should\n      take place and text to specify the edit.</p>\n    <p>Click <a href="https://platform.openai.com/docs/guides/images/introduction">here</a> for more info.</p>',n.url="",n.permittedErrorPrefixes=["Incorrect","Invalid input image"];var s=null==(r=null==i?void 0:i.openAI)?void 0:r.images;if(n.camera){var o="object"==O(s)&&s.size?Number.parseInt(s.size):1024;n.camera.files={dimensions:{width:o,height:o}}}return"object"==O(s)&&Object.assign(n.rawBody,s),n.canSendMessage=t.canFileSendMessage,n}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&""!==t&&(n.prompt=t),n}},{key:"callApiWithImage",value:function(e,n,r){var i,a,s,o=null==(a=null==(i=n[n.length-1])?void 0:i.text)?void 0:a.trim();if(r[1]||o&&""!==o){this.url=t.IMAGE_EDIT_URL;var l=this.preprocessBody(this.rawBody,o);s=t.createFormDataBody(l,r[0],r[1])}else this.url=t.IMAGE_VARIATIONS_URL,s=t.createFormDataBody(this.rawBody,r[0]);dn.tempRemoveContentHeader(this.connectSettings,En.request.bind(this,this,s,e),!1)}},{key:"callServiceAPI",value:(r=A(C().mark((function e(n,r,i){var a,s;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(a=this.connectSettings)&&a.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null==i||!i[0]){e.next=6;break}this.callApiWithImage(n,r,i),e.next=11;break;case 6:if(this.connectSettings){e.next=8;break}throw new Error("Request settings have not been set up");case 8:this.url=t.IMAGE_GENERATION_URL,s=this.preprocessBody(this.rawBody,r[r.length-1].text),En.request(this,s,n);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error.message;case 2:return e.abrupt("return",{files:t.data.map((function(e){return e.url?{src:e.url,type:"image"}:{src:"".concat(Zn).concat(e.b64_json),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"canFileSendMessage",value:function(e,t){return!(null==t||!t[0])||!(!e||""===e.trim())}},{key:"createFormDataBody",value:function(e,t,n){var r=new FormData;return r.append("image",t),n&&r.append("mask",n),Object.keys(e).forEach((function(t){r.append(t,String(e[t]))})),r}}]);var n,r}(Ln);ri.IMAGE_GENERATION_URL="https://api.openai.com/v1/images/generations",ri.IMAGE_VARIATIONS_URL="https://api.openai.com/v1/images/variations",ri.IMAGE_EDIT_URL="https://api.openai.com/v1/images/edits";var ii=ri,ai=function(e){function t(e){var n,r,i;R(this,t);var a=JSON.parse(JSON.stringify(e.directConnection)),s=null==(i=a.cohere)?void 0:i.chat;return r=_(this,t,[e,"https://api.cohere.ai/v1/chat","Ask me anything!",s,a.cohere]),"object"==O(s)&&Object.assign(r.rawBody,s),null!==(n=r.maxMessages)&&void 0!==n||(r.maxMessages=-1),r}return x(t,e),N(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r=t.filter((function(e){return e.text}));return n.query=r[r.length-1].text,n.chat_history=r.slice(0,r.length-1).map((function(e){return{text:e.text,user_name:"ai"===e.role?"CHATBOT":"USER"}})),n}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),En.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{text:t.text});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(yr),si=function(){function e(){R(this,e)}return N(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json",accept:"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i;null!=(i=e.message)&&i.includes("invalid request: prompt must be at least 1 token long")?n(t):r(ne.INVALID_KEY)}}
2,{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.mistral.ai/v1/models",method:"GET",handleVerificationResult:e.handleVerificationResult}}}])}(),oi=function(e){function t(e){var n,r,i,a;R(this,t);var s=JSON.parse(JSON.stringify(e.directConnection)).mistral;return(i=_(this,t,[e,si.buildKeyVerificationDetails(),si.buildHeaders,s])).insertKeyPlaceholderText="Mistral API Key",i.keyHelpUrl="https://console.mistral.ai/api-keys/",i.url="https://api.mistral.ai/v1/chat/completions",i.permittedErrorPrefixes=["invalid"],s&&(i.cleanConfig(s),Object.assign(i.rawBody,s)),null!==(n=i.maxMessages)&&void 0!==n||(i.maxMessages=-1),null!==(r=(a=i.rawBody).model)&&void 0!==r||(a.model="open-mistral-7b"),i}return x(t,e),N(t,[{key:"cleanConfig",value:function(e){delete e.key}},{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r=t.filter((function(e){return e.text}));return n.messages=r.slice(0,r.length-1).map((function(e){return{text:e.text,user_name:"ai"===e.role?"system":"user"}})),n}},{key:"callServiceAPI",value:(r=A(C().mark((function e(t,n){var r;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),En.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{text:t.text});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(Ln),li=function(){return N((function e(){R(this,e)}),null,[{key:"create",value:function(e){var t=e.directConnection,n=e.connect,r=e.demo;if(e.webModel)return new Hn(e);if(t){if(t.openAI)return t.openAI.images?new ii(e):t.openAI.speechToText?new qr(e):t.openAI.textToSpeech?new Ur(e):t.openAI.assistant?new gr(e):t.openAI.realtime?new Br(e):new ti(e);if(t.assemblyAI)return new Kr(e);if(t.cohere)return t.cohere.textGeneration?new br(e):t.cohere.summarization?new xr(e):new ai(e);if(t.huggingFace)return t.huggingFace.textGeneration?new nr(e):t.huggingFace.summarization?new ir(e):t.huggingFace.translation?new or(e):t.huggingFace.fillMask?new cr(e):t.huggingFace.questionAnswer?new rr(e):t.huggingFace.audioSpeechRecognition?new tr(e):t.huggingFace.audioClassification?new Kn(e):t.huggingFace.imageClassification?new Jn(e):new ar(e);if(t.azure){if(t.azure.openAI){if(t.azure.openAI.chat)return new ni(e);if(t.azure.openAI.assistant)return new Sr(e)}if(t.azure.speechToText)return new Qr(e);if(t.azure.textToSpeech)return new Yr(e);if(t.azure.summarization)return new Wr(e);if(t.azure.translation)return new ei(e)}if(t.stabilityAI)return t.stabilityAI.imageToImage?new sr(e):t.stabilityAI.imageToImageUpscale?new Qn(e):t.stabilityAI.imageToImageMasking?new er(e):new lr(e);if(t.mistral)return new oi(e)}return n&&Object.keys(n).length>0&&!r?new In(e):new In(e,void 0,r||!0)}}])}(),ci=N((function e(){R(this,e)}));ci.attibutes={string:function(e){return e},number:function(e){return parseFloat(e)},boolean:function(e){return"true"===e},object:function(e){return JSON.parse(e)},array:function(e){return JSON.parse(e)},function:function(e){return new Function("return ".concat(e))()}};var ui=ci;function di(e){return function(t,n){Object.defineProperty(t,n,{});var r=t.constructor,i=n.toLocaleLowerCase();r._attributes_[i]=ui.attibutes[e],r._attributeToProperty_[i]=n}}var hi=function(){function e(t,n,r){R(this,e),this._isDisplayed=!1,t?(this._elementRef=this.createIntroPanelWithChild(t,r),this._isDisplayed=!0):n&&(this._elementRef=this.createInternalIntroPanel(n,r),this._isDisplayed=!0)}return N(e,[{key:"createIntroPanelWithChild",value:function(t,n){var r=e.createIntroPanel(n);return"none"===t.style.display&&(t.style.display="block"),r.appendChild(t),r}},{key:"createInternalIntroPanel",value:function(t,n){var r=e.createIntroPanel(n);return r.id="internal-intro-panel",r.innerHTML=t,r}},{key:"hide",value:function(){this._isDisplayed&&this._elementRef&&(this._elementRef.style.display="none",this._isDisplayed=!1)}},{key:"display",value:function(){!this._isDisplayed&&this._elementRef&&(this._elementRef.style.display="",this._isDisplayed=!0)}}],[{key:"createIntroPanel",value:function(e){var t=document.createElement("div");return t.classList.add("intro-panel"),Object.assign(t.style,e),t}}])}(),pi=function(){function e(){R(this,e)}return N(e,null,[{key:"createImage",value:function(e,t,n){var r=new Image;return r.src=e.src,n&&ue.scrollDownOnImageLoad(r.src,t),ue.processContent("image",r,r.src,e.name)}},{key:"createImageMessage",value:function(t,n,r,i){var a=e.createImage(n,t.elementRef,!i&&!t.focusMode),s=t.createNewMessageElement("",r);return s.bubbleElement.appendChild(a),s.bubbleElement.classList.add(e.IMAGE_BUBBLE_CLASS),{type:"image",elements:s}}},{key:"createAudioElement",value:function(e,t){var n=document.createElement("audio");return n.src=e.src,n.classList.add("audio-player"),n.controls=!0,G.IS_SAFARI&&(n.classList.add("audio-player-safari"),n.classList.add(t===on.USER_ROLE?"audio-player-safari-right":"audio-player-safari-left")),n}},{key:"createNewAudioMessage",value:function(t,n,r,i){var a=e.createAudioElement(n,r),s=t.createMessageElementsOnOrientation("",r,i);return s.bubbleElement.appendChild(a),s.bubbleElement.classList.add(e.AUDIO_BUBBLE_CLASS),{type:"audio",elements:s}}},{key:"createAnyFile",value:function(e){var t=document.createElement("div");t.classList.add("any-file-message-contents");var n=document.createElement("div");n.classList.add("any-file-message-icon-container");var r=Nn.createSVGElement('<?xml version="1.0" encoding="iso-8859-1"?>\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" \n\t viewBox="50 30 420 450" xml:space="preserve">\n<g filter="brightness(0) saturate(100%) invert(16%) sepia(0%) saturate(1942%) hue-rotate(215deg) brightness(99%) contrast(93%)">\n\t<g>\n\t\t<path d="M447.933,103.629c-0.034-3.076-1.224-6.09-3.485-8.352L352.683,3.511c-0.004-0.004-0.007-0.005-0.011-0.008\n\t\t\tC350.505,1.338,347.511,0,344.206,0H89.278C75.361,0,64.04,11.32,64.04,25.237v461.525c0,13.916,11.32,25.237,25.237,25.237\n\t\t\th333.444c13.916,0,25.237-11.32,25.237-25.237V103.753C447.96,103.709,447.937,103.672,447.933,103.629z M356.194,40.931\n\t\t\tl50.834,50.834h-49.572c-0.695,0-1.262-0.567-1.262-1.262V40.931z M423.983,486.763c0,0.695-0.566,1.261-1.261,1.261H89.278\n\t\t\tc-0.695,0-1.261-0.566-1.261-1.261V25.237c0-0.695,0.566-1.261,1.261-1.261h242.94v66.527c0,13.916,11.322,25.239,25.239,25.239\n\t\t\th66.527V486.763z"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d="M362.088,164.014H149.912c-6.62,0-11.988,5.367-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,169.381,368.707,164.014,362.088,164.014z"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d="M362.088,236.353H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,241.721,368.707,236.353,362.088,236.353z"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d="M362.088,308.691H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C374.076,314.06,368.707,308.691,362.088,308.691z"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d="M256,381.031H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988H256\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C267.988,386.398,262.62,381.031,256,381.031z"/>\n\t</g>\n</g>\n</svg>');r.classList.add("any-file-message-icon"),n.appendChild(r);var i=document.createElement("div");return i.classList.add("any-file-message-text"),i.textContent=e.name||ue.DEFAULT_FILE_NAME,t.appendChild(n),t.appendChild(i),ue.processContent("any",t,e.src,i.textContent)}},{key:"createNewAnyFileMessage",value:function(t,n,r,i){var a=t.createMessageElementsOnOrientation("",r,i),s=e.createAnyFile(n);return a.bubbleElement.classList.add(e.ANY_FILE_BUBBLE_CLASS),a.bubbleElement.appendChild(s),{type:"file",elements:a}}},{key:"createMessages",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return n.map((function(n){return n.ref&&(n=ue.removeFileRef(n)),ue.isAudioFile(n)?e.createNewAudioMessage(t,n,r,i):ue.isImageFile(n)?e.createImageMessage(t,n,r,i):e.createNewAnyFileMessage(t,n,r,i)}))}}
2,{key:"addMessages",value:function(t,n,r,i){e.createMessages(t,n,r,i).forEach((function(e){var n=e.type,a=e.elements;ue.addMessage(t,a,n,r,i)}))}}])}();pi.IMAGE_BUBBLE_CLASS="image-message",pi.AUDIO_BUBBLE_CLASS="audio-message",pi.ANY_FILE_BUBBLE_CLASS="any-file-message";var fi=pi,mi=function(){function e(){R(this,e)}return N(e,null,[{key:"removeElements",value:function(e,t){if(t){var n=e.findIndex((function(e){return e===t}));e.splice(n,1),null==t||t.outerContainer.remove()}}},{key:"removeFilesMessages",value:function(t,n){var r;null==(r=n[1].files)||r.forEach((function(n){e.removeElements(t.messageElementRefs,n)})),delete n[0].files,delete n[1].files}},{key:"removeTextHTMLMessage",value:function(t,n,r){var i=n[1][r];e.removeElements(t.messageElementRefs,i),delete n[0][r],delete n[1][r]}},{key:"updateHTMLMessage",value:function(e,t,n){var r,i,a;if(t[1].html)be.overwriteElements(e,n,t[1].html);else{var s=be.create(e,n,t[0].role),o=(null==(i=t[1].files)?void 0:i[(null==(r=t[1].files)?void 0:r.length)-1])||t[1].text,l=o.outerContainer.nextSibling;null==(a=null==l?void 0:l.parentElement)||a.insertBefore(s.outerContainer,l),e.messageElementRefs.splice(e.messageElementRefs.length-1,1);var c=e.messageElementRefs.findIndex((function(e){return e===o}));e.messageElementRefs.splice(c+1,0,s),t[1].html=s}t[0].html=n}},{key:"updateFileMessages",value:function(t,n,r){var i,a,s=n[0].role,o=fi.createMessages(t,r,s),l=n[1].html,c=(null==(a=n[1].files)?void 0:a[(null==(i=n[1].files)?void 0:i.length)-1])||n[1].text,u=l||c,d=t.messageElementRefs.findIndex((function(e){return e===u}));c&&(d+=1);var h=(null==l?void 0:l.outerContainer)||(null==c?void 0:c.outerContainer.nextSibling);o.forEach((function(e,n){var r,i=e.type,a=e.elements;ue.setElementProps(t,a,i,s),null==(r=h.parentElement)||r.insertBefore(a.outerContainer,h),t.messageElementRefs.splice(t.messageElementRefs.length-1,1),t.messageElementRefs.splice(d+n,0,a)})),e.removeFilesMessages(t,n),n[1].files=o.map((function(e){return e.elements})),n[0].files=r}},{key:"updateTextMessage",value:function(e,t,n){var r,i;if(t[1].text)e.renderText(t[1].text.bubbleElement,n);else{var a=e.createElements(n,t[0].role),s=(null==(r=t[1].files)?void 0:r[0])||t[1].html;null==(i=s.outerContainer.parentElement)||i.insertBefore(a.outerContainer,s.outerContainer);var o=e.messageElementRefs.findIndex((function(e){return e===s}));e.messageElementRefs.splice(o,0,a),t[1].text=a}t[0].text=n}},{key:"isElementActive",value:function(e){var t,n;return vi.isActiveElement(null==(t=e.text)?void 0:t.bubbleElement.classList)||vi.isActiveElement(null==(n=e.html)?void 0:n.bubbleElement.classList)}},{key:"update",value:function(t,n,r){var i=t.messageToElements[r];if(i){if(e.isElementActive(i[1]))return console.error("Cannot update a message that is being streamed");n.text&&e.updateTextMessage(t,i,n.text),n.files?e.updateFileMessages(t,i,n.files):e.removeFilesMessages(t,i),n.html&&e.updateHTMLMessage(t,i,n.html),!n.text&&i[1].text&&e.removeTextHTMLMessage(t,i,"text"),!n.html&&i[1].html&&e.removeTextHTMLMessage(t,i,"html");var a=t.messageElementRefs,s=t.avatar,o=t.name;on.classifyRoleMessages(a),on.resetAllRoleElements(a,s,o)}else console.error("Message index not found. Please use the `getMessages` method to find the correct index")}}])}(),gi=function(){return N((function e(){R(this,e)}),null,[{key:"getText",value:function(e,t){var n;if(!(e.directConnection||e.connect||e.webModel||e.demo))return"Connect to any API using the [connect](https://deepchat.dev/docs/connect#connect-1) property or a popular service via [directConnection](https://deepchat.dev/docs/directConnection/#directConnection).\n Host AI entirely on your browser via a [webModel](https://deepchat.dev/docs/webModel).\n To get started checkout the [Start](https://deepchat.dev/start) page and live code [examples](https://deepchat.dev/examples/frameworks).\n To remove this message set the [demo](https://deepchat.dev/docs/modes#demo) property to true.";if(e.directConnection){if(!t.isDirectConnection())return"Please define a valid service inside\n          the [directConnection](https://deepchat.dev/docs/directConnection/#directConnection) object.";var r=null==(n=e.directConnection.openAI)?void 0:n.chat;if("object"==O(r)&&r.tools&&!r.function_handler)return"Please define the `function_handler` property inside the openAI [chat](https://deepchat.dev/docs/directConnection/openAI#Chat) object."}else if(e.connect&&!e.connect.url&&!e.connect.handler)return"Please define a `url` or a `handler` property inside the [connect](https://deepchat.dev/docs/connect#connect-1) object.";return null}}])}(),vi=function(e){function t(e,n,r){var i,a,s;R(this,t),i=_(this,t,[e]);var o=n.permittedErrorPrefixes,l=n.introPanelMarkUp,c=n.demo;return i._errorMessageOverrides=null==(a=e.errorMessages)?void 0:a.overrides,i._onClearMessages=$t.onClearMessages.bind(i,e),i._onError=$t.onError.bind(i,e),i._isLoadingMessageAllowed=t.getDefaultDisplayLoadingMessage(e,n),"object"==O(e.displayLoadingBubble)&&e.displayLoadingBubble.toggle&&(e.dis
2playLoadingBubble.toggle=i.setLoadingToggle.bind(i)),i._permittedErrorPrefixes=o,i.addSetupMessageIfNeeded(e,n)||i.populateIntroPanel(r,l,e.introPanelStyle),c&&i.prepareDemo(de.processDemo(c),e.loadHistory),i.addIntroductoryMessages(e,n),new Tn(e,i,n),i._displayServiceErrorMessages=null==(s=e.errorMessages)?void 0:s.displayServiceErrorMessages,e.getMessages=function(){return JSON.parse(JSON.stringify(i.messageToElements.map((function(e){return g(e,1)[0]}))))},e.clearMessages=i.clearMessages.bind(i,n),e.refreshMessages=i.refreshTextMessages.bind(i,e.remarkable),e.scrollToBottom=ie.scrollToBottom.bind(i,i.elementRef),e.addMessage=function(e,t){i.addAnyMessage(I(I({},e),{},{sendUpdate:!!t}),!t)},e.updateMessage=function(e,t){return mi.update(i,e,t)},n.isWebModel()&&n.setUpMessages(i),e.textToSpeech&&se.processConfig(e.textToSpeech,(function(e){i.textToSpeech=e})),i}return x(t,e),N(t,[{key:"setLoadingToggle",value:function(){var e=this.messageElementRefs[this.messageElementRefs.length-1];an.isLoadingMessage(e)?this.removeLastMessage():this.addLoadingMessage(!0)}},{key:"prepareDemo",value:function(e,t){var n;if("object"==O(e)){if(!t&&e.displayLoading){var r=e.displayLoading.history;null!=r&&r.small&&Jt.addMessage(this,!1),null!=r&&r.full&&Jt.addMessage(this)}e.displayErrors&&(e.displayErrors.default&&this.addNewErrorMessage("",""),e.displayErrors.service&&this.addNewErrorMessage("service",""),e.displayErrors.speechToText&&this.addNewErrorMessage("speechToText","")),null!=(n=e.displayLoading)&&n.message&&this.addLoadingMessage(),e.response&&(this.customDemoResponse=e.response)}}},{key:"addSetupMessageIfNeeded",value:function(e,t){var n=gi.getText(e,t);if(n){var r=this.createAndAppendNewMessageElement(n,on.AI_ROLE);this.applyCustomStyles(r,on.AI_ROLE,!1)}return!!n}},{key:"addIntroductoryMessages",value:function(e,t){var n=this;null!=e&&e.shadowRoot&&(this._introMessage=e.introMessage);var r=this._introMessage;null!=t&&t.isWebModel()&&(null!=r||(r=t.getIntroMessage(r)));var i=!(null!=e&&e.history||!(null!=e&&e.loadHistory||null!=t&&t.fetchHistory)
2);r&&(Array.isArray(r)?r.forEach((function(e,t){if(0!==t){var r=n.messageElementRefs[n.messageElementRefs.length-1].innerContainer;on.hideRoleElements(r,n.avatar,n.name)}n.addIntroductoryMessage(e,i)})):this.addIntroductoryMessage(r,i))}},{key:"addIntroductoryMessage",value:function(e,t){var n,r;return null!=e&&e.text?r=this.createAndAppendNewMessageElement(e.text,on.AI_ROLE):null!=e&&e.html&&(r=be.add(this,e.html,on.AI_ROLE)),r&&(this.applyCustomStyles(r,on.AI_ROLE,!1,null==(n=this.messageStyles)?void 0:n.intro),r.outerContainer.classList.add(an.INTRO_CLASS),t&&(r.outerContainer.style.display="none")),r}},{key:"removeIntroductoryMessage",value:function(){var e=this.messageElementRefs[0];e.outerContainer.classList.contains(an.INTRO_CLASS)&&(e.outerContainer.remove(),this.messageElementRefs.shift())}},{key:"addAnyMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e.error?this.addNewErrorMessage("service",e.error,n):this.addNewMessage(e,t,n)}},{key:"tryAddTextMessage",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];!n.ignoreText&&void 0!==e.text&&null!==n.text&&(this.addNewTextMessage(e.text,e.role,t,i),!r&&this.textToSpeech&&e.role!==on.USER_ROLE&&se.speak(e.text,this.textToSpeech))}},{key:"tryAddFileMessages",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.files&&Array.isArray(e.files)&&fi.addMessages(this,e.files,e.role,t)}},{key:"tryAddHTMLMessage",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(void 0!==e.html&&null!==e.html){var r=be.add(this,e.html,e.role,t,n);n&&me.isElementTemporary(r)&&delete e.html}}},{key:"addNewMessage",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=t.createMessageContent(e),a={status:e.overwrite};return r?(this.tryAddHTMLMessage(i,a,r),this.tryAddFileMessages(i,r),this.tryAddTextMessage(i,a,e,n,r)):(this.tryAddTextMessage(i,a,e,n,r),this.tryAddFileMessages(i,r),this.tryAddHTMLMessage(i,a,r)),this.isValidMessageContent(i)&&!r&&this.updateStateOnMessage(i,e.overwrite,e.sendUpdate,n),i}},{key:"isValidMessageContent",value:function(e){return e.text||e.html||e.files&&e.files.length>0}},{key:"updateStateOnMessage",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!t){var i=on.generateMessageBody(e,this.messageElementRefs);this.messageToElements.push([e,i])}n&&this.sendClientUpdate(e,r)}},{key:"removeMessageOnError",value:function(){var e=this.messageElementRefs[this.messageElementRefs.length-1],n=null==e?void 0:e.bubbleElement;(null!=n&&n.classList.contains(cn.MESSAGE_CLASS)&&""===n.textContent||t.isTemporaryElement(e))&&this.removeLastMessage()}},{key:"addNewErrorMessage",value:function(e,t){var n,r,i,a,s,o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.removeMessageOnError();var l=this.getPermittedMessage(t)||(null==(n=this._errorMessageOverrides)?void 0:n[e])||(null==(r=this._errorMessageOverrides)?void 0:r.default)||"Error, please try again.",c=this.createMessageElementsOnOrientation(l,"error",o);on.hideRoleElements(c.innerContainer,this.avatar,this.name);var u=c.bubbleElement,d=c.outerContainer;u.classList.add(on.ERROR_MESSAGE_TEXT_CLASS),this.renderText(u,l);var h=Wt.extractParticularSharedStyles(["fontSize","fontFamily"],null==(i=this.messageStyles)?void 0:i.default);Wt.applyCustomStylesToElements(c,!1,h),Wt.applyCustomStylesToElements(c,!1,null==(a=this.messageStyles)?void 0:a.error),o||this.appendOuterContainerElemet(d),this.textToSpeech&&se.speak(l,this.textToSpeech),null==(s=this._onError)||s.call(this,l)}},{key:"getPermittedMessage",value:function(e){if(e)for(var n=t.extractErrorMessages(e),r=0;r<n.length;r+=1){var i=n[r];if("string"==typeof i){if(this._displayServiceErrorMessages)return i;if(this._permittedErrorPrefixes){var a=t.checkPermittedErrorPrefixes(this._permittedErrorPrefixes,i);if(a)return a}}}}},{key:"removeError",value:function(){this.isLastMessageError()&&on.getLastMessageElement(this.elementRef).remove()}},{key:"addDefaultLoadingMessage",value:function(){var e=this.createMessageElements("",on.AI_ROLE),t=e.bubbleElement;e.bubbleElement.classList.add(le.DOTS_CONTAINER_CLASS);var n=document.createElement("div");return n.classList.add("loading-message-dots"),t.appendChild(n),le.setDots(t,this.messageStyles),e}},{key:"addLoadingMessage",value:function(){var e,t,n,r,i,a,s=arguments.length>0&&void 0!==arguments[0]&&arguments[0],o=this.messageElementRefs[this.messageElementRefs.length-1];if(!an.isLoadingMessage(o)&&(s||this._isLoadingMessageAllowed)){var l=null==(n=null==(t=null==(e=this.messageStyles)?void 0:e.loading)?void 0:t.message)?void 0:n.html,c=l?be.createElements(this,l,on.AI_ROLE,!1):this.addDefaultLoadingMessage();this.appendOuterContainerElemet(c.outerContainer),c.bubbleElement.classList.add(le.BUBBLE_CLASS),this.applyCustomStyles(c,on.AI_ROLE,!1,null==(a=null==(i=null==(r=this.messageStyles)?void 0:r.loading)?void 0:i.message)?void 0:a.styles),this.focusMode||ie.scrollToBottom(this.elementRef)}}},{key:"populateIntroPanel",value:function(e,t,n){(e||t)&&(this._introPanel=new hi(e,t,n),this._introPanel._elementRef&&(ge.apply(this,this._introPanel._elementRef),this.elementRef.appendChild(this._introPanel._elementRef)))}},{key:"addMultipleFiles",value:(n=A(C().mark((function e(t){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.all((t||[]).map((function(e){return new Promise((function(t){if(e.type&&"any"!==e.type){var n=new FileReader;n.readAsDataURL(e.file),n.onload=function(){t({src:n.result,type:e.type,ref:e.file})}}else{var r=e.file.name||ue.DEFAULT_FILE_NAME;t({name:r,type:"any",ref:e.file})}}))}))));case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"clearMessages",value:function(e,n){var r,i,a,s=[];
2this.messageElementRefs.forEach((function(e){t.isActiveElement(e.bubbleElement.classList)?s.push(e):e.outerContainer.remove()})),Array.from(this.elementRef.children).forEach((function(e){var t,n=null==(t=e.children[0])?void 0:t.children[0];null!=n&&n.classList.contains(on.ERROR_MESSAGE_TEXT_CLASS)&&e.remove()})),this.messageElementRefs=s;var o=this.messageToElements.filter((function(e){return e[1].text&&t.isActiveElement(e[1].text.bubbleElement.classList)||e[1].html&&t.isActiveElement(e[1].html.bubbleElement.classList)}));(r=this.messageToElements).splice.apply(r,[0,this.messageToElements.length].concat(v(o))),!1!==n&&(null!=(i=this._introPanel)&&i._elementRef&&this._introPanel.display(),this.addIntroductoryMessages()),null==(a=this._onClearMessages)||a.call(this),delete e.sessionId}}],[{key:"getDefaultDisplayLoadingMessage",value:function(e,t){var n;return t.websocket?!!e.displayLoadingBubble:null===(n="object"==O(e.displayLoadingBubble)||e.displayLoadingBubble)||void 0===n||n}},{key:"checkPermittedErrorPrefixes",value:function(e,t){for(var n=0;n<e.length;n+=1)if(t.startsWith(e[n]))return t}},{key:"extractErrorMessages",value:function(e){return Array.isArray(e)?e:e instanceof Error?[e.message]:"string"==typeof e?[e]:"object"==O(e)&&e.error?[e.error]:[]}},{key:"isActiveElement",value:function(e){return!!e&&(e.contains(le.BUBBLE_CLASS)||e.contains(Jt.CLASS)||e.contains(cn.MESSAGE_CLASS))}}]);var n}(an),yi=function(){function e(){R(this,e)}return N(e,null,[{key:"adjustInputPadding",value:function(e,t){t["inside-left"].length>0&&e.classList.add("text-input-inner-left-adjustment"),t["inside-right"].length>0&&e.classList.add("text-input-inner-right-adjustment")}},{key:"adjustForOutsideButton",value:function(t,n,r){0===r["outside-right"].length&&r["outside-left"].length>0?(t[0].classList.add(e.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS),n.classList.add(e.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS)):0===r["outside-left"].length&&r["outside-right"].length>0&&(t[3].classList.add(e.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS),n.classList.add(e.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS))}},{key:"adjustOutsideSubmit",value:function(t,n,r){if(!(r["inside-left"].length>0||r["inside-right"].length>0)){if(0===r["outside-right"].length&&r["outside-left"].length>0)return t[0].classList.add(e.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS),n.classList.add(e.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS),r["outside-left"].map((function(e){return e.button.elementRef.classList.add("submit-button-enlarged")}));if(0===r["outside-left"].length&&r["outside-right"].length>0)return t[3].classList.add(e.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS),n.classList.add(e.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS),r["outside-right"].map((function(e){return e.button.elementRef.classList.add("submit-button-enlarged")}))}}},{key:"set",value:function(t,n,r,i){!!e.adjustOutsideSubmit(n,r,i)||e.adjustForOutsideButton(n,r,i),e.adjustInputPadding(t,i)}}])}();yi.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS="text-input-container-left-adjustment",yi.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS="text-input-container-right-adjustment",yi.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS="text-input-container-left-small-adjustment",yi.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS="text-input-container-right-small-adjustment";var bi=yi,_i=function(){function e(){R(this,e)}return N(e,null,[{key:"create",value:function(){return Array.from({length:4}).map((function(e,t){var n=document.createElement("div");return n.classList.add("input-button-container"),(0===t||3===t)&&n.classList.add("outer-button-container"),(1===t||2===t)&&n.classList.add("inner-button-container"),n}))}},{key:"add",value:function(e,t){e.insertBefore(t[1],e.firstChild),e.insertBefore(t[0],e.firstChild),e.appendChild(t[2]),e.appendChild(t[3])}},{key:"getContainerIndex",value:function(e){return"outside-left"===e?0:"inside-left"===e?1:"inside-right"===e?2:3}},{key:"addButton",value:function(t,n,r){n.classList.add(r);var i=e.getContainerIndex(r);t[i].appendChild(n),3===i&&n.classList.add("outside-right")}}])}(),wi=["camera","gifs","images","audio","mixedFiles","submit","microphone"],ki=function(){function e(){R(this,e)}return N(e,null,[{key:"addItemEvents",value:function(e,t,n,r){he.add(t,r),t.addEventListener("click",(function(){n.click()})),t.addEventListener("mouseenter",(function(t){e.highlightedItem=t.target})),t.addEventListener("mouseleave",(function(){e.highlightedItem=void 0}))}},{key:"createItemText",value:function(t,n){var r=document.createElement("div");return Object.assign(r.style,n),r.classList.add(e.TEXT_CLASS),r.textContent=t||"File",r}},{key:"createItemIcon",value:function(t,n){var r=document.createElement("div");return Object.assign(r.style,n),r.classList.add(e.ICON_CLASS),r.appendChild(t),r}},{key:"populateItem",value:function(t,n,r){var i=t.elementRef,a=t.dropupText,s=t.svg,o=t.customStyles,l=i.children[0],c=o&&Object.values(o).find((function(e){var t;return""===(null==(t=e.svg)?void 0:t.content)}));l.classList.contains(Ar.INPUT_BUTTON_INNER_TEXT_CLASS)?(c||n.appendChild(e.createItemIcon(s,null==r?void 0:r.iconContainer)),n.appendChild(e.createItemText(l.textContent,null==r?void 0:r.text))):(c||n.appendChild(e.createItemIcon(i.children[0],null==r?void 0:r.iconContainer)),n.appendChild(e.createItemText(a,null==r?void 0:r.text)))}},{key:"createItem",value:function(t,n,r){var i,a=document.createElement("div");Object.assign(a.style,null==(i=null==r?void 0:r.item)?void 0:i.default),e.populateItem(n,a,r),a.classList.add(e.MENU_ITEM_CLASS);var s=n.elementRef;if(n.isCustom)n.setDropupItem(a);else{var o=F.processStateful((null==r?void 0:r.item)||{});e.addItemEvents(t,a,s,o)}return a}}])}();ki.MENU_ITEM_CLASS="dropup-menu-item",ki.TEXT_CLASS="dropup-menu-item-text",ki.ICON_CLASS="dropup-menu-item-icon";var Si=ki,xi=function(e){function t(e,n,r,i){var a,s,o,l,c,u,d;R(this,t);var h=(null==(c=null==(l=null==(o=null==(s=null==e?void 0:e.styles)?void 0:s.button)?void 0:o.default)?void 0:l.text)?void 0:c.content)||"Custom ".concat(n);return(a=_(this,t,[t.createButtonElement(),'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" fill="none">\n  <rect x="2.5" y="2.5" width="17" height="17" rx="2" stroke="#000000" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>\n',null==e?void 0:e.position,null==(u=null==e?void 0:e.styles)?void 0:u.button,h]))._state="default",a.isCustom=!0,a._innerElements=a.createInnerElementsForStates(a.customStyles),a._menuStyles=i,a._onClick=e.onClick,a._dropupStyles=null==(d=e.styles)?void 0:d.dropup,a.setSetState(e),a.addClickListener(r),a.changeState(e.initialState,!0),a}return x(t,e),N(t,[{key:"createInnerElementsForStates",value:function(e){var t="custom-icon",n=this.createInnerElements(t,"default",e);return{default:n,active:this.genStateInnerElements(t,"active",n,e),disabled:this.genStateInnerElements(t,"disabled",n,e)}}},{key:"setSetState",value:function(e){var t=this;e.setState=function(e){"default"===e&&t.changeToDefault(),"active"===e&&t.changeToActive(),"disabled"===e&&t.changeToDisabled()}}},{key:"addClickListener",value:function(e){var t=this;this.elementRef.addEventListener("click",(function(){var n,r=null==(n=t._onClick)?void 0:n.call(t,t._state);null==e||e(),("default"===r||"active"===r||"disabled"===r)&&t.changeState(r)}))}},{key:"changeState",value:function(e,t){"disabled"===e?this.changeToDisabled(t):"active"===e?this.changeToActive(t):this.changeToDefault(t)}},{key:"applyDropupContentStyles",value:function(e){var t=Array.from(this.elementRef.children);if(null!=e&&e.text){var n=t.find((function(e){return e.classList.contains(Si.TEXT_CLASS)}));n&&Object.assign(n.style,e.text)}if(null!=e&&e.iconContainer){var r=t.find((function(e){return e.classList.contains(Si.ICON_CLASS)}));r&&Object.assign(r.style,e.iconContainer)}}},{key:"resetDropupItem",value:function(e){var t,n,r;this.elementRef=ge.replaceElementWithNewClone(this.elementRef,this._originalElementRef),this.elementRef.innerHTML="",""===(null==(t=null==e?void 0:e.svg)?void 0:t.content)||this.elementRef.appendChild(Si.createItemIcon(this.svg,null==(n=this._menuStyles)?void 0:n.iconContainer)),this.elementRef.appendChild(Si.createItemText(this.dropupText,null==(r=this._menuStyles)?void 0:r.text))}},{key:"assignDropupItemStyle",value:function(e,t){var n;this.elementRef.parentElement&&this._originalElementRef&&this.resetDropupItem(t),this.applyDropupContentStyles(e),Object.assign(this.elementRef.style,null==(n=null==e?void 0:e.item)?void 0:n.default);var r=F.processStateful((null==e?void 0:e.item)||{});he.add(this.elementRef,r),this.addClickListener()}},{key:"changeToDefault",value:function(e){var n,r,i,a,s,o;!e&&"default"===this._state||(this.elementRef.classList.contains(Si.MENU_ITEM_CLASS)?this.assignDropupItemStyle(null==(n=this._dropupStyles)?void 0:n.default,null==(r=this.customStyles)?void 0:r.default):(this.changeElementsByState(this._innerElements.default),null!=(i=this.customStyles)&&i.active&&Ir.unsetAllCSS(this.elementRef,null==(a=this.customStyles)?void 0:a.active),null!=(s=this.customStyles)&&s.disabled&&Ir.unsetAllCSS(this.elementRef,null==(o=this.customStyles)?void 0:o.disabled),this.reapplyStateStyle("default",["active","disabled"])),this.elementRef.classList.remove(t.DISABLED_CONTAINER_CLASS,t.ACTIVE_CONTAINER_CLASS),this.elementRef.classList.add(t.DEFAULT_CONTAINER_CLASS),Er.removeAriaDisabled(this.elementRef),this._state="default")}},{key:"changeToActive",value:function(e){var n,r;!e&&"active"===this._state||(this.elementRef.classList.contains(Si.MENU_ITEM_CLASS)?this.assignDropupItemStyle(null==(n=this._dropupStyles)?void 0:n.active,null==(r=this.customStyles)?void 0:r.active):(this.changeElementsByState(this._innerElements.active),this.reapplyStateStyle("active",["disabled","default"])),this.elementRef.classList.remove(t.DISABLED_CONTAINER_CLASS,t.DEFAULT_CONTAINER_CLASS),this.elementRef.classList.add(t.ACTIVE_CONTAINER_CLASS),Er.removeAriaDisabled(this.elementRef),this._state="active")}},{key:"changeToDisabled",value:function(e){var n,r,i,a,s,o;!e&&"disabled"===this._state||(this.elementRef.classList.contains(Si.MENU_ITEM_CLASS)?this.assignDropupItemStyle(null==(n=this._dropupStyles)?void 0:n.disabled,null==(r=this.customStyles)?void 0:r.disabled):(this.changeElementsByState(this._innerElements.disabled),null!=(i=this.customStyles)&&i.active&&Ir.unsetAllCSS(this.elementRef,null==(a=this.customStyles)?void 0:a.active),null!=(s=this.customStyles)&&s.default&&Ir.unsetAllCSS(this.elementRef,null==(o=this.customStyles)?void 0:o.default),this.reapplyStateStyle("disabled",["default","active"])),this.elementRef.classList.remove(t.ACTIVE_CONTAINER_CLASS,t.DEFAULT_CONTAINER_CLASS),this.elementRef.classList.add(t.DISABLED_CONTAINER_CLASS),Er.addAriaDisabled(this.elementRef),this._state="disabled")}},{key:"setDropupItem",value:function(e){this.elementRef=e,this._originalElementRef=e.cloneNode(!0),this.changeState(this._state,!0)}},{key:"genStateInnerElements",value:function(e,n,r,i){var a,s,o,l,c=this.createInnerElements(e,n,i),u=null==(s=null==(a=null==i?void 0:i[n])?void 0:a.svg)?void 0:s.content,d=null==(l=null==(o=null==i?void 0:i[n])?void 0:o.text)?void 0:l.content;if(void 0===u||void 0===d){var h=Mr.parseSVGTextElements(r),p=h.svg,f=h.text,m=Mr.parseSVGTextElements(c),g=m.svg,v=m.text,y=[];t.addToInnerElements(y,u,p,g),t.addToInnerElements(y,d,f,v),c=y}return c}}],[{key:"createButtonElement",value:function(){var e=document.createElement("div");return e.classList.add("input-button",t.BUTTON_CLASS),e}},{key:"addToInnerElements",value:function(e,t,n,r){void 0===t&&n?e.push(n.cloneNode(!0)):r&&e.push(r)}},{key:"add",value:function(e,n){var r=e.customButtons,i=e.focusInput,a=e.dropupStyles;null==r||r.forEach((function(e,r){var s={button:new t(e,r+1,i,null==a?void 0:a.menu)};n["".concat(t.INDICATOR_PREFIX).concat(r+1)]=s}))}}])}(Lr);xi.INDICATOR_PREFIX="custom",xi.BUTTON_CLASS="custom-button",xi.DISABLED_CONTAINER_CLASS="custom-button-container-disabled",xi.DEFAULT_CONTAINER_CLASS="custom-button-container-default",xi.ACTIVE_CONTAINER_CLASS="custom-button-container-active";var Ei=xi,Ci=function(){function e(){R(this,e)}return N(e,null,[{key:"focusItemWhenOnEdge",value:function(t,n){var r=n?t.children[0]:t.children[t.children.length-1];e.focusSiblingItem(r,t,n,!0)}},{key:"focusSiblingItem",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=i?t:t[r?"nextSibling":"previousSibling"];a?(t.dispatchEvent(new MouseEvent("mouseleave")),a.dispatchEvent(new MouseEvent("mouseenter"))):(t.dispatchEvent(new MouseEvent("mouseleave")),e.focusItemWhenOnEdge(n,r))}}])}(),Ti=function(){return N((function e(t,n){var r,i=this;R(this,e),this._isOpen=!0,this._styles=n,this.elementRef=e.createElement(null==(r=this._styles)?void 0:r.container),this.close(),setTimeout((function(){return i.addWindowEvents(t)}))}),[{key:"open",value:function(){this.elementRef.style.display="block",this._isOpen=!0}},{key:"close",value:function(){this._isOpen&&(this.elementRef.style.display="none",this._isOpen=!1)}},{key:"toggle",value:function(){this._isOpen?this.close():this.open()}},{key:"addItem",value:function(e){var t=Si.createItem(this,e,this._styles);this.elementRef.appendChild(t)}},{key:"addWindowEvents",value:function(e){this.clickEvent=this.windowClick.bind(this,e),window.addEventListener("click",this.clickEvent),this.keyDownEvent=this.windowKeyDown.bind(this,e),window.addEventListener("keydown",this.keyDownEvent)}},{key:"windowClick",value:function(e,t){var n;!e.isConnected&&this.clickEvent?window.removeEventListener("click",this.clickEvent):e.parentElement!==(null==(n=t.target.shadowRoot)?void 0:n.children[0])&&this.close()}},{key:"windowKeyDown",value:function(e,t){var n,r,i;!e.isConnected&&this.keyDownEvent?window.removeEventListener("keydown",this.keyDownEvent):this._isOpen&&(t.key===W.ESCAPE?(this.close(),null==(n=this.highlightedItem)||n.dispatchEvent(new MouseEvent("mouseleave"))):t.key===W.ENTER?(null==(r=this.highlightedItem)||r.click(),null==(i=this.highlightedItem)||i.dispatchEvent(new MouseEvent("mouseleave"))):t.key===W.ARROW_DOWN?Ci.focusSiblingItem(this.highlightedItem||this.elementRef.children[this.elementRef.children.length-1],this.elementRef,!0):t.key===W.ARROW_UP&&Ci.focusSiblingItem(this.highlightedItem||this.elementRef.children[0],this.elementRef,!1))}}],[{key:"createElement",value:function(e){var t=document.createElement("div");return t.id="dropup-menu",Object.assign(t.style,e),t}}])}(),Ai=function(e){function t(e,n){var r,i;R(this,t);var a=(r=_(this,t,[t.createButtonElement(),'<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">\n    <path d="M16 0c-8.836 0-16 7.163-16 16s7.163 16 16 16c8.837 0 16-7.163 16-16s-7.163-16-16-16zM16 30.032c-7.72 0-14-6.312-14-14.032s6.28-14 14-14 14 6.28 14 14-6.28 14.032-14 14.032zM23 15h-6v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1v6h-6c-0.552 0-1 0.448-1 1s0.448 1 1 1h6v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6h6c0.552 0 1-0.448 1-1s-0.448-1-1-1z"></path>\n</svg>',void 0,{styles:null==(i=null==n?void 0:n.button)?void 0:i.styles}
2])).createInnerElementsForStates(r.customStyles);return r._menu=new Ti(e,null==n?void 0:n.menu),r.addClickEvent(),r.buttonContainer=t.createButtonContainer(),r.changeElementsByState(a.styles),r.buttonContainer.appendChild(r.elementRef),r.elementRef.classList.add(t.BUTTON_ICON_CLASS),r.buttonContainer.appendChild(r._menu.elementRef),r.reapplyStateStyle("styles"),r.addContainerEvents(e),r}return x(t,e),N(t,[{key:"createInnerElementsForStates",value:function(e){return{styles:this.createInnerElements("dropup-icon","styles",e)}}},{key:"addClickEvent",value:function(){this.elementRef.onclick=this._menu.toggle.bind(this._menu)}},{key:"addItem",value:function(e){this._menu.addItem(e)}},{key:"addContainerEvents",value:function(e){var n=this;e.addEventListener("click",(function(e){var r=e.target.classList;!r.contains(t.BUTTON_ICON_CLASS)&&!r.contains(Ei.DISABLED_CONTAINER_CLASS)&&n._menu.close()}))}}],[{key:"createButtonElement",value:function(){var e=document.createElement("div");return e.classList.add("input-button"),e}},{key:"createButtonContainer",value:function(){var e=document.createElement("div");return e.id="dropup-container",e}},{key:"getPosition",value:function(e,t){var n,r;return null!=(n=null==t?void 0:t.button)&&n.position?null==(r=null==t?void 0:t.button)?void 0:r.position:e["outside-left"].length>0&&0===e["outside-right"].length?"outside-right":"outside-left"}}])}(Lr);Ai.BUTTON_ICON_CLASS="dropup-button";var Mi=Ai,Ii=function(){function e(){R(this,e)}return N(e,null,[{key:"addToDropup",value:function(e,t,n,r){var i=new Mi(n,r);wi.forEach((function(e){var n=t["dropup-menu"].findIndex((function(t){return t.buttonType===e})),r=t["dropup-menu"][n];r&&(i.addItem(r.button),t["dropup-menu"].splice(n,1))})),t["dropup-menu"].forEach((function(e){var t=e.button;return i.addItem(t)}));var a=Mi.getPosition(t,r);_i.addButton(e,i.buttonContainer,a),t[a].push({})}},{key:"addToSideContainer",value:function(e,t){["inside-left","inside-right","outside-left","outside-right"].forEach((function(n){var r=n;t[r].forEach((function(t){_i.addButton(e,t.button.elementRef,r)}))}))}},{key:"setPosition",value:function(e,t,n){var r=I(I({},e[t]),{},{buttonType:t});n.push(r),delete e[t]}},{key:"createPositionsToButtonsObj",value:function(){return{"dropup-menu":[],"outside-left":[],"inside-left":[],"inside-right":[],"outside-right":[]}}},{key:"generatePositionToButtons",value:function(t){var n=e.createPositionsToButtonsObj();Object.keys(t).forEach((function(r){var i,a=null==(i=t[r])?void 0:i.button.position;a&&e.setPosition(t,r,n[a])})),0===n["inside-right"].length&&t.submit&&e.setPosition(t,"submit",n["inside-right"]),0===n["outside-right"].length&&(t.submit?e.setPosition(t,"submit",n["outside-right"]):t.microphone?e.setPosition(t,"microphone",n["outside-right"]):t.camera?e.setPosition(t,"camera",n["outside-right"]):t["".concat(Ei.INDICATOR_PREFIX,"1")]&&e.setPosition(t,"".concat(Ei.INDICATOR_PREFIX,"1"),n["outside-right"])),t.submit&&e.setPosition(t,"submit",0===n["outside-left"].length?n["outside-left"]:n["inside-right"]),t.microphone&&e.setPosition(t,"microphone",0===n["outside-left"].length?n["outside-left"]:n["inside-right"]);var r=Object.keys(t);return r.length>1||n["dropup-menu"].length>0?(wi.forEach((function(e){t[e]&&n["dropup-menu"].push(I(I({},t[e]),{},{buttonType:e}))})),r.forEach((function(e){var r=e;r.startsWith(Ei.INDICATOR_PREFIX)&&t[r]&&n["dropup-menu"].push(I(I({},t[r]),{},{customType:r}))}))):1===r.length&&e.setPosition(t,r[0],0===n["outside-right"].length?n["outside-right"]:n["outside-left"]),n}},{key:"addButtons",value:function(t,n,r,i){var a=e.generatePositionToButtons(n);return e.addToSideContainer(t,a),a["dropup-menu"].length>0&&e.addToDropup(t,a,r,i),a}}])}(),Li={images:{id:"upload-images-icon",svgString:'<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">\n  <path d="M20,15.2928932 L20,5.5 C20,4.67157288 19.3284271,4 18.5,4 L5.5,4 C4.67157288,4 4,4.67157288 4,5.5 L4,12.2928932 L7.14644661,9.14644661 C7.34170876,8.95118446 7.65829124,8.95118446 7.85355339,9.14644661 L13.5,14.7928932 L16.1464466,12.1464466 C16.3417088,11.9511845 16.6582912,11.9511845 16.8535534,12.1464466 L20,15.2928932 Z M20,16.7071068 L16.5,13.2071068 L13.8535534,15.8535534 C13.6582912,16.0488155 13.3417088,16.0488155 13.1464466,15.8535534 L7.5,10.2071068 L4,13.7071068 L4,18.5 C4,19.3284271 4.67157288,20 5.5,20 L18.5,20 C19.3284271,20 20,19.3284271 20,18.5 L20,16.7071068 Z M3,5.5 C3,4.11928813 4.11928813,3 5.5,3 L18.5,3 C19.8807119,3 21,4.11928813 21,5.5 L21,18.5 C21,19.8807119 19.8807119,21 18.5,21 L5.5,21 C4.11928813,21 3,19.8807119 3,18.5 L3,5.5 Z M15,6 L1
27,6 C17.5522847,6 18,6.44771525 18,7 L18,9 C18,9.55228475 17.5522847,10 17,10 L15,10 C14.4477153,10 14,9.55228475 14,9 L14,7 C14,6.44771525 14.4477153,6 15,6 Z M15,7 L15,9 L17,9 L17,7 L15,7 Z"/>\n</svg>\n',dropupText:"Image"},gifs:{id:"upload-gifs-icon",svgString:'<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 5.9266752 5.6408391" height="21.31971" width="22.4">\n  <g>\n    <path d="m 5.2564627,1.548212 c -3.1136005,-0.4796804 -1.5568006,-0.2398402 0,0 z M 2.0001198,2.0922063 c 0.1556781,0 0.2657489,0.020893 0.3917849,0.080366 0.081154,0.038347 0.1153492,0.134065 0.076377,0.2138602 -0.038973,0.07979 -0.1363527,0.1134129 -0.2175069,0.075091 -0.078199,-0.036919 -0.1407455,-0.048792 -0.250655,-0.048792 -0.2260486,0 -0.3921482,0.2042182 -0.3921482,0.4801409 0,0.2761822 0.1663188,0.4810688 0.3921482,0.4810688 0.1117901,0 0.2064255,-0.046133 0.255659,-0.1284198 l 0.00162,-0.00389 V 3.0534032 l -0.098011,1.75e-4 c -0.081844,0 -0.1495979,-0.059305 -0.1612403,-0.1365887 l -0.00175,-0.023683 c 0,-0.08047 0.060311,-0.1470874 0.1389194,-0.1585331 l 0.024085,-0.00195 h 0.2612303 c 0.081842,0 0.149598,0.059305 0.1612404,0.1365891 l 0.00175,0.023683 -3.398e-4,0.3968809 v 0 l -0.00168,0.014211 v 0 l -0.00553,0.023034 v 0 l -0.00532,0.014145 c -0.098178,0.22826 -0.3236506,0.3528713 -0.5706303,0.3528713 -0.4240855,0 -0.7181621,-0.3622714 -0.7181621,-0.8016063 0,-0.4391857 0.2940275,-0.8006848 0.7181621,-0.8006848 z m 1.2034759,0.031275 c 0.081843,0 0.1495977,0.059305 0.1612403,0.1365891 l 0.00175,0.023683 v 1.2211775 c 0,0.088516 -0.07298,0.1602721 -0.1630073,0.1602721 -0.081841,0 -0.1495972,-0.059305 -0.1612397,-0.1365892 L 3.040589,3.5049308 V 2.2837527 c 0,-0.088516 0.07298,-0.1602721 0.1630067,-0.1602714 z m 0.7813442,0 0.5209469,0.00195 c 0.090025,3.048e-4 0.1627543,0.072306 0.1624458,0.1608234 -2.809e-4,0.08047 -0.06083,0.1468798 -0.1394772,0.158066 l -0.024092,0.00195 -0.3575326,-0.0013 v 0.4497782 l 0.2928918,2.27e-4 c 0.081842,0 0.1495979,0.059305 0.1612403,0.136589 l 0.00175,0.023683 c 0,0.080469 -0.06031,0.1470871 -0.1389193,0.1585393 l -0.024092,0.00195 -0.2928919,-2.336e-4 1.563e-4,0.2860316 c 0,0.080471 -0.06031,0.1470873 -0.1389193,0.1585395 l -0.024085,0.00195 c -0.081843,0 -0.1495979,-0.059305 -0.1612403,-0.1365826 l -0.00175,-0.023691 V 2.2841354 c 2.798e-4,-0.08047 0.060829,-0.1468797 0.1394758,-0.1580594 z"/>\n    <path d="m 5.0894191,1.0943261 c 0,-0.21918999 -0.177687,-0.39686999 -0.396876,-0.39686999 h -3.43959 c -0.2191879,0 -0.391262,0.1777519 -0.3968759,0.39686999 l -0.027082,3.4379266 c 0.040152,0.2939927 0.4235456,0.409415 0.4235456,0.409415 l 3.4785583,-0.00851 c 0,0 0.3008506,-0.1402998 0.3236271,-0.4201576 0.042911,-0.5272495 0.034693,-1.6106146 0.034693,-3.4186761 z m -4.49792494,0 c 0,-0.36530999 0.29614504,-0.66145999 0.66145894,-0.66145999 h 3.43959 c 0.365314,0 0.66146,0.29615 0.66146,0.66145999 v 3.43959 c 0,0.36532 -0.296146,0.66146 -0.66146,0.66146 h -3.43959 c -0.3653139,0 -0.66145894,-0.29614 -0.66145894,-0.66146 z"/>\n  </g>\n</svg>\n',dropupText:"GIF"},audio:{id:"upload-audio-icon",svgString:'<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-49.49 -49.49 593.87 593.87" stroke-width="3.95908" transform="rotate(0)">\n  <g stroke-width="0"></g>\n  <g stroke-linecap="round" stroke-linejoin="round" stroke-width="0.98977"></g>\n  <g>\n    <g>\n      <g>\n        <path d="M163.205,76.413v293.301c-3.434-3.058-7.241-5.867-11.486-8.339c-21.38-12.452-49.663-15.298-77.567-7.846 c-49.038,13.096-80.904,54.519-71.038,92.337c4.019,15.404,14.188,28.221,29.404,37.087c13.553,7.894,29.87,11.933,47.115,11.933 c9.962,0,20.231-1.356,30.447-4.087c42.74-11.406,72.411-44.344,72.807-77.654h0.011v-0.162c0.002-0.166,0-0.331,0-0.496V187.072 l290.971-67.3v178.082c-3.433-3.055-7.238-5.863-11.481-8.334c-21.385-12.452-49.654-15.308-77.567-7.846 c-49.038,13.087-80.904,54.519-71.038,92.356c4.019,15.385,14.183,28.212,29.404,37.067c13.548,7.894,29.875,11.933,47.115,11.933 c9.962,0,20.231-1.356,30.452-4.087c42.74-11.413,72.411-44.346,72.804-77.654h0.004v-0.065c0.003-0.236,0.001-0.469,0-0.704V0 L163.205,76.413z M104.999,471.779c-22.543,6.038-45.942,3.846-62.572-5.846c-10.587-6.163-17.591-14.817-20.255-25.038 c-7.144-27.375,18.452-58.029,57.062-68.346c8.409-2.25,16.938-3.346,25.188-3.346c13.87,0,26.962,3.115,37.389,9.192 c10.587,6.163,17.591,14.817,20.255,25.029c0.809,3.102,1.142,6.248,1.139,9.4v0.321h0.014 C162.99,437.714,139.082,462.678,104.999,471.779z M182.898,166.853V92.067l290.971-67.298v74.784L182.898,166.853z M415.677,399.923c-22.558,6.038-45.942,3.837-62.587-5.846c-10.587-6.163-17.587-14.817-20.25-25.019 c-7.144-27.385,18.452-58.058,57.058-68.365c8.414-2.25,16.942-3.346,25.192-3.346c13.875,0,26.962,3.115,37.385,9.192 c10.596,6.163,17.596,14.817,20.26,25.029v0.01c0.796,3.05,1.124,6.144,1.135,9.244v0.468h0.02 C473.668,365.851,449.763,390.814,415.677,399.923z">\n        </path>\n      </g>\n    </g>\n  </g>\n</svg>',dropupText:"Audio"},mixedFiles:{id:"upload-mixed-files-icon",svgString:'<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M20 10.9696L11.9628 18.5497C10.9782 19.4783 9.64274 20 8.25028 20C6.85782 20 5.52239 19.4783 4.53777 18.5497C3.55315 17.6211 3 16.3616 3 15.0483C3 13.7351 3.55315 12.4756 4.53777 11.547L12.575 3.96687C13.2314 3.34779 14.1217 3 15.05 3C15.9783 3 16.8686 3.34779 17.525 3.96687C18.1814 4.58595 18.5502 5.4256 18.5502 6.30111C18.5502 7.17662 18.1814 8.01628 17.525 8.63535L9.47904 16.2154C9.15083 16.525 8.70569 16.6989 8.24154 16.6989C7.77738 16.6989 7.33224 16.525 7.00403 16.2154C6.67583 15.9059 6.49144 15.4861 6.49144 15.0483C6.49144 14.6106 6.67583 14.1907 7.00403 13.8812L14.429 6.88674" stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>',dropupText:"File"}},Oi=function(e){function t(e){var n;return R(this,t),"dropup-menu"===(null==e?void 0:e.position)&&(e.position="outside-right"),(n=_(this,t,[t.createMicrophoneElement(),Cr,
2null==e?void 0:e.position,e])).isActive=!1,n._innerElements=n.createInnerElementsForStates(n.customStyles),n.changeToDefault(),n}return x(t,e),N(t,[{key:"createInnerElementsForStates",value:function(e){var t="microphone-icon";return{default:this.createInnerElements(t,"default",e),active:this.createInnerElements(t,"active",e),unsupported:this.createInnerElements(t,"unsupported",e),commandMode:this.createInnerElements(t,"commandMode",e)}}},{key:"changeToActive",value:function(){this.changeElementsByState(this._innerElements.active),this.toggleIconFilter("active"),this.reapplyStateStyle("active",["default","commandMode"]),this.isActive=!0}},{key:"changeToDefault",value:function(){this.changeElementsByState(this._innerElements.default),this.toggleIconFilter("default"),this.reapplyStateStyle("default",["active","commandMode"]),this.isActive=!1}},{key:"changeToCommandMode",value:function(){this.changeElementsByState(this._innerElements.commandMode),this.toggleIconFilter("command"),this.reapplyStateStyle("commandMode",["active"])}},{key:"changeToUnsupported",value:function(){this.changeElementsByState(this._innerElements.unsupported),this.elementRef.classList.add("unsupported-microphone"),this.reapplyStateStyle("unsupported",["active"])}},{key:"toggleIconFilter",value:function(e){var t=this.elementRef.children[0];if("svg"===t.tagName.toLocaleLowerCase())switch(e){case"default":t.classList.remove("active-microphone-icon","command-microphone-icon"),t.classList.add("default-microphone-icon");break;case"active":t.classList.remove("default-microphone-icon","command-microphone-icon"),t.classList.add("active-microphone-icon");break;case"command":t.classList.remove("active-microphone-icon","default-microphone-icon"),t.classList.add("command-microphone-icon")}}}],[{key:"createMicrophoneElement",value:function(){var e=document.createElement("div");return e.id="microphone-button",e.classList.add("input-button"),e}}])}(Lr);function Ri(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pi,Ni,ji,Di={},Bi={},Fi={},Ui={},zi={};function qi(){if(Pi)return zi;Pi=1,Object.defineProperty(zi,"__esModule",{value:!0}),zi.Text=void 0;var e=function(){function e(){R(this,e)}return N(e,null,[{key:"capitalize",value:function(t){return t.replace(e.FIRST_CHAR_REGEX,(function(e){return e.toUpperCase()}))}},{key:"lineBreak",value:function(t){return t.replace(e.DOUBLE_LINE,"<p></p>").replace(e.ONE_LINE,"<br>")}},{key:"isCharDefined",value:function(e){return void 0!==e&&" "!==e&&" "!==e&&"\n"!==e&&""!==e}},{key:"breakupIntoWordsArr",value:function(e){return e.split(/(\W+)/)}}])}();return zi.Text=e,e.FIRST_CHAR_REGEX=/\S/,e.DOUBLE_LINE=/\n\n/g,e.ONE_LINE=/\n/g,zi}function Hi(){if(Ni)return Ui;Ni=1,Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.Translate=void 0;var e=qi(),t=function(){return N((function e(){R(this,e)}),null,[{key:"translate",value:function(t,n){for(var r=e.Text.breakupIntoWordsArr(t),i=0;i<r.length;i+=1)n[r[i]]&&(r[i]=n[r[i]]);return r.join("")}}])}();return Ui.Translate=t,Ui}var Vi,Gi={};function Wi(){if(Vi)return Gi;Vi=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.Browser=void 0;var e=N((function e(){R(this,e)}));return Gi.Browser=e,e.IS_SAFARI=function(){return void 0===e._IS_SAFARI&&(e._IS_SAFARI=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),e._IS_SAFARI},Gi}var $i,Ki={},Ji={};var Zi,Yi={};var Xi,Qi={},ea={};function ta(){if(Xi)return ea;Xi=1,Object.defineProperty(ea,"__esModule",{value:!0}),ea.AutoScroll=void 0;var e=function(){function e(){R(this,e)}return N(e,null,[{key:"changeStateIfNeeded",value:function(e,t){t&&!e.isCursorAtEnd&&(e.endPadding="",e.scrollingSpan.innerHTML="&nbsp;")}},{key:"scrollGeneric",value:function(e,t){e.isCursorAtEnd?t.scrollTop=t.scrollHeight:e.scrollingSpan.scrollIntoView({block:"nearest"})}},{key:"scrollSafariPrimitiveToEnd",value:function(e){e.scrollLeft=e.scrollWidth,e.scrollTop=e.scrollHeight}},{key:"isElementOverflown",value:function(e){return e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth}},{key:"isRequired",value:function(t,n){return t&&e.isElementOverflown(n)}}])}();return ea.AutoScroll=e,ea}var na,ra={};function ia(){if(na)return ra;na=1,Object.defineProperty(ra,"__esModule",{value:!0}),ra.Elements=void 0;var e=function(){return N((function e(){R(this,e)}),null,[{key:"isPrimitiveElement",value:function(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName}},{key:"createInterimSpan",value:function(){var e=document.createElement("span");return e.style.color="grey",e.style.pointerEvents="none",e}},{key:"createGenericSpan",value:function(){var e=document.createElement("span");return e.style.pointerEvents="none",e}},{key:"appendSpans",value:function(e,t){if(e.spansPopulated=!0,e.insertInCursorLocation&&document.activeElement===t){var n=window.getSelection();if(null!=n&&n.focusNode){var r=n.getRangeAt(0);
2return r.insertNode(e.scrollingSpan),r.insertNode(e.interimSpan),r.insertNode(e.finalSpan),r.collapse(!1),n.removeAllRanges(),void n.addRange(r)}}t.appendChild(e.finalSpan),t.appendChild(e.interimSpan),t.appendChild(e.scrollingSpan)}},{key:"applyCustomColors",value:function(e,t){t.interim&&(e.interimSpan.style.color=t.interim),t.final&&(e.finalSpan.style.color=t.final)}},{key:"isInsideShadowDOM",value:function(e){return e.getRootNode()instanceof ShadowRoot}}])}();return ra.Elements=e,ra}var aa,sa,oa={};function la(){if(aa)return oa;aa=1,Object.defineProperty(oa,"__esModule",{value:!0}),oa.Cursor=void 0;var e=function(){function e(){R(this,e)}return N(e,null,[{key:"setOffsetForGeneric",value:function(t,n){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=0,a=0;a<t.childNodes.length;a+=1){var s=t.childNodes[a];if(s.childNodes.length>0){var o=e.setOffsetForGeneric(s,n,r);if(-1===o)return-1;r+=o}else if(null!==s.textContent){if(r+s.textContent.length>n){var l=document.createRange();l.setStart(s,n-r),l.collapse(!0);var c=window.getSelection();return null==c||c.removeAllRanges(),null==c||c.addRange(l),t.focus(),-1}r+=s.textContent.length,i+=s.textContent.length}}return i}},{key:"focusEndOfGeneric",value:function(e){var t=document.createRange();t.selectNodeContents(e),t.collapse(!1);var n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}},{key:"setOffsetForSafariGeneric",value:function(t,n){var r=window.getSelection();if(r){var i=e.getGenericElementCursorOffset(t,r,!0);e.setOffsetForGeneric(t,i+n)}}},{key:"setOffsetForPrimitive",value:function(e,t,n){n&&e.blur(),e.setSelectionRange(t,t),e.focus()}},{key:"getGenericElementCursorOffset",value:function(e,t,n){var r=0;if(t.rangeCount>0){var i=t.getRangeAt(0),a=i.cloneRange();a.selectNodeContents(e),n?a.setEnd(i.startContainer,i.startOffset):a.setEnd(i.endContainer,i.endOffset),r=a.toString().length}return r}}])}();return oa.Cursor=e,oa}function ca(){if(sa)return Qi;sa=1,Object.defineProperty(Qi,"__esModule",{value:!0}),Qi.CommandUtils=void 0;var e=ta(),t=ia(),n=Wi(),r=la(),i=qi(),a=function(){function a(){R(this,a)}return N(a,null,[{key:"processCommand",value:function(e,t){return(!t||!t.caseSensitive)&&(e=e.toLowerCase()),!1===(null==t?void 0:t.substrings)?i.Text.breakupIntoWordsArr(e):e}},{key:"process",value:function(e){var t;return!0===(null===(t=e.settings)||void 0===t?void 0:t.caseSensitive)?e:Object.keys(e).reduce((function(t,n){var r=e[n];return t[n]="string"==typeof r?a.processCommand(r,e.settings):r,t}),{})}},{key:"toggleCommandModeOn",value:function(e){var t;e.isWaitingForCommand=!0,null===(t=e.onCommandModeTrigger)||void 0===t||t.call(e,!0)}},{key:"toggleCommandModeOff",value:function(e){var t;e.isWaitingForCommand&&(null===(t=e.onCommandModeTrigger)||void 0===t||t.call(e,!1),e.isWaitingForCommand=!1)}},{key:"setText",value:function(i,s,o,l){a.toggleCommandModeOff(i),t.Elements.isPrimitiveElement(l)?(l.value=o,i.isTargetInShadow||r.Cursor.setOffsetForPrimitive(l,o.length,!0),n.Browser.IS_SAFARI()&&i.autoScroll&&e.AutoScroll.scrollSafariPrimitiveToEnd(l)):(l.textContent=o,i.isTargetInShadow||r.Cursor.focusEndOfGeneric(l),setTimeout((function(){return e.AutoScroll.scrollGeneric(i,l)}))),i.resetRecording(s)}},{key:"checkIfMatchesSubstring",value:function(e,t){return t.includes(e)}},{key:"checkIfMatchesWord",value:function(e,t,n){for(var r=e,i=n.length-1;i>=0;i-=1){for(var a=i,s=r.length-1;n[a]===r[s]&&s>=0;)a-=1,s-=1;if(s<0)return!0}return!1}},{key:"execCommand",value:function(e,t,n,r,s){var o,l,c,u=e.commands;if(u&&r&&n){var d=!0===(null===(o=u.settings)||void 0===o?void 0:o.caseSensitive)?t:t.toLowerCase(),h=i.Text.breakupIntoWordsArr(d),p=!1===(null===(l=u.settings)||void 0===l?void 0:l.substrings)?a.checkIfMatchesWord:a.checkIfMatchesSubstring;if(u.commandMode&&p(u.commandMode,d,h))return e.setInterimColorToFinal(),setTimeout((function(){return a.toggleCommandModeOn(e)})),{doNotProcessTranscription:!1};if(!u.commandMode||e.isWaitingForCommand){if(u.stop&&p(u.stop,d,h))return a.toggleCommandModeOff(e),setTimeout((function(){return e.stop()})),{doNotProcessTranscription:!1};if(u.pause&&p(u.pause,d,h))return a.toggleCommandModeOff(e),e.setInterimColorToFinal(),setTimeout((function(){var t;
2e.isPaused=!0,null===(t=e.onPauseTrigger)||void 0===t||t.call(e,!0)})),{doNotProcessTranscription:!1};if(u.resume&&p(u.resume,d,h))return e.isPaused=!1,null===(c=e.onPauseTrigger)||void 0===c||c.call(e,!1),a.toggleCommandModeOff(e),e.resetRecording(n),{doNotProcessTranscription:!0};if(u.reset&&p(u.reset,d,h))return void 0!==s&&a.setText(e,n,s,r),{doNotProcessTranscription:!0};if(u.removeAllText&&p(u.removeAllText,d,h))return a.setText(e,n,"",r),{doNotProcessTranscription:!0}}}}}])}();return Qi.CommandUtils=a,Qi}var ua,da={};var ha,pa,fa,ma={};function ga(){if(pa)return Ki;pa=1,Object.defineProperty(Ki,"__esModule",{value:!0}),Ki.Speech=void 0;var e=function(){if($i)return Ji;$i=1,Object.defineProperty(Ji,"__esModule",{value:!0}),Ji.EventListeners=void 0;var e=function(){function e(){R(this,e)}return N(e,null,[{key:"getElementIfFocusedOnAvailable",value:function(e,t){return Array.isArray(e)?e.find((function(e){return t===e})):t===e?e:void 0}},{key:"keyDownWindow",value:function(t){var n=this;t.element&&e.getElementIfFocusedOnAvailable(t.element,document.activeElement)&&(null!==e.KEY_DOWN_TIMEOUT&&clearTimeout(e.KEY_DOWN_TIMEOUT),e.KEY_DOWN_TIMEOUT=setTimeout((function(){e.KEY_DOWN_TIMEOUT=null,n.resetRecording(t)}),500))}},{key:"mouseDownWindow",value:function(t,n){this.mouseDownElement=e.getElementIfFocusedOnAvailable(t,n.target)}},{key:"mouseUpWindow",value:function(e){this.mouseDownElement&&this.resetRecording(e),this.mouseDownElement=void 0}},{key:"add",value:function(t,n){var r=void 0===(null==n?void 0:n.insertInCursorLocation)||(null==n?void 0:n.insertInCursorLocation);null!=n&&n.element&&r&&(t.mouseDownEvent=e.mouseDownWindow.bind(t,n.element),document.addEventListener("mousedown",t.mouseDownEvent),t.mouseUpEvent=e.mouseUpWindow.bind(t,n),document.addEventListener("mouseup",t.mouseUpEvent),t.keyDownEvent=e.keyDownWindow.bind(t,n),document.addEventListener("keydown",t.keyDownEvent))}},{key:"remove",value:function(e){document.removeEventListener("mousedown",e.mouseDownEvent),document.removeEventListener("mouseup",e.mouseUpEvent),document.removeEventListener("keydown",e.keyDownEvent)}}])}();return Ji.EventListeners=e,e.KEY_DOWN_TIMEOUT=null,Ji}(),t=function(){if(Zi)return Yi;Zi=1,Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.PreResultUtils=void 0;var e=function(){return N((function e(){R(this,e)}),null,[{key:"process",value:function(e,t,n,r,i){var a=null==r?void 0:r(t,n);return!!a&&(setTimeout((function(){a.restart?e.resetRecording(i):a.stop&&e.stop()})),(a.stop||a.restart)&&a.removeNewText)}}])}();return Yi.PreResultUtils=e,Yi}(),n=ca(),r=ta(),i=function(){if(ua)return da;ua=1,Object.defineProperty(da,"__esModule",{value:!0}),da.Highlight=void 0;var e=ia(),t=la(),n=function(){function n(){R(this,n)}return N(n,null,[{key:"setStateForPrimitive",value:function(e,t){var n,r;null!==t.selectionStart&&(n=t.selectionStart),null!==t.selectionEnd&&(r=t.selectionEnd),e.isHighlighted=n!==r}},{key:"setStateForGeneric",value:function(e,n){var r=window.getSelection();if(null!=r&&r.focusNode){var i=t.Cursor.getGenericElementCursorOffset(n,r,!0),a=t.Cursor.getGenericElementCursorOffset(n,r,!1);e.isHighlighted=i!==a}}},{key:"setState",value:function(t,r){document.activeElement===r&&(e.Elements.isPrimitiveElement(r)?n.setStateForPrimitive(t,r):n.setStateForGeneric(t,r))}},{key:"removeForGeneric",value:function(e,n){var r=window.getSelection();if(r){var i=t.Cursor.getGenericElementCursorOffset(n,r,!0);r.deleteFromDocument(),t.Cursor.setOffsetForGeneric(n,i),e.isHighlighted=!1}}},{key:"removeForPrimitive",value:function(e,n){var r=n.selectionStart,i=n.selectionEnd,a=n.value;if(r&&i){var s=a.substring(0,r)+a.substring(i);n.value=s,t.Cursor.setOffsetForPrimitive(n,r,e.autoScroll)}e.isHighlighted=!1}}])}();return da.Highlight=n,da}(),a=ia(),s=function(){if(ha)return ma;ha=1,Object.defineProperty(ma,"__esModule",{value:!0}),ma.Padding=void 0;var e=ia(),t=la(),n=qi(),r=function(){function r(){R(this,r)}return N(r,null,[{key:"setStateForPrimitiveElement",value:function(e,t){if(document.activeElement===t&&null!==t.selectionStart){var r=t.selectionStart,i=t.value[r-1],a=null===t.selectionEnd?r:t.selectionEnd,s=t.value[a];return n.Text.isCharDefined(i)&&(e.startPadding=" ",e.numberOfSpacesBeforeNewText=1),n.Text.isCharDefined(s)&&(e.endPadding=" ",e.numberOfSpacesAfterNewText=1),void(e.isCursorAtEnd=t.value.length===a)}var o=t.value[t.value.length-1];n.Text.isCharDefined(o)&&(e.startPadding=" ",e.numberOfSpacesBeforeNewText=1),e.isCursorAtEnd=!0}},{key:"setStateForGenericElement",value:function(e,r){var i,a,s;if(document.activeElement===r){var o=window.getSelection();if(null!=o&&o.focusNode){var l=t.Cursor.getGenericElementCursorOffset(r,o,!0),c=null===(i=r.textContent)||void 0===i?void 0:i[l-1],u=t.Cursor.getGenericElementCursorOffset(r,o,!1),d=null===(a=r.textContent)||void 0===a?void 0:a[u];return n.Text.isCharDefined(c)&&(e.startPadding=" "),n.Text.isCharDefined(d)&&(e.endPadding=" "),void(e.isCursorAtEnd=(null===(s=r.textContent)||void 0===s?void 0:s.length)===u)}}var h=r.innerText.charAt(r.innerText.length-1);n.Text.isCharDefined(h)&&(e.startPadding=" "),e.isCursorAtEnd=!0}},{key:"setState",value:function(t,n){e.Elements.isPrimitiveElement(n)?r.setStateForPrimitiveElement(t,n):r.setStateForGenericElement(t,n)}}
2,{key:"adjustStateAfterRecodingPrimitiveElement",value:function(e,t){e.primitiveTextRecorded=!0,e.insertInCursorLocation&&document.activeElement===t&&(null!==t.selectionEnd&&(e.endPadding=e.endPadding+t.value.slice(t.selectionEnd)),null!==t.selectionStart)?e.startPadding=t.value.slice(0,t.selectionStart)+e.startPadding:e.startPadding=t.value+e.startPadding}},{key:"adjustSateForNoTextPrimitiveElement",value:function(e){1===e.numberOfSpacesBeforeNewText&&(e.startPadding=e.startPadding.substring(0,e.startPadding.length-1),e.numberOfSpacesBeforeNewText=0),1===e.numberOfSpacesAfterNewText&&(e.endPadding=e.endPadding.substring(1),e.numberOfSpacesAfterNewText=0)}}])}();return ma.Padding=r,ma}(),o=Wi(),l=la(),c=qi(),u=function(){return N((function e(){R(this,e),this.finalTranscript="",this.interimSpan=a.Elements.createInterimSpan(),this.finalSpan=a.Elements.createGenericSpan(),this.scrollingSpan=a.Elements.createGenericSpan(),this.isCursorAtEnd=!1,this.spansPopulated=!1,this.startPadding="",this.endPadding="",this.numberOfSpacesBeforeNewText=0,this.numberOfSpacesAfterNewText=0,this.isHighlighted=!1,this.primitiveTextRecorded=!1,this.recognizing=!1,this._displayInterimResults=!0,this.insertInCursorLocation=!0,this.autoScroll=!0,this.isRestarting=!1,this.isPaused=!1,this.isWaitingForCommand=!1,this.isTargetInShadow=!1,this.cannotBeStopped=!1,this.resetState()}),[{key:"prepareBeforeStart",value:function(t){var r,i;if(null!=t&&t.element)if(e.EventListeners.add(this,t),Array.isArray(t.element)){var s=t.element.find((function(e){return e===document.activeElement}))||t.element[0];if(!s)return;this.prepare(s)}else this.prepare(t.element);void 0!==(null==t?void 0:t.displayInterimResults)&&(this._displayInterimResults=t.displayInterimResults),null!=t&&t.textColor&&(this._finalTextColor=null===(r=null==t?void 0:t.textColor)||void 0===r?void 0:r.final,a.Elements.applyCustomColors(this,t.textColor)),void 0!==(null==t?void 0:t.insertInCursorLocation)&&(this.insertInCursorLocation=t.insertInCursorLocation),void 0!==(null==t?void 0:t.autoScroll)&&(this.autoScroll=t.autoScroll),this._onResult=null==t?void 0:t.onResult,this._onPreResult=null==t?void 0:t.onPreResult,this._onStart=null==t?void 0:t.onStart,this._onStop=null==t?void 0:t.onStop,this._onError=null==t?void 0:t.onError,this.onCommandModeTrigger=null==t?void 0:t.onCommandModeTrigger,this.onPauseTrigger=null==t?void 0:t.onPauseTrigger,this._options=t,null!==(i=this._options)&&void 0!==i&&i.commands&&(this.commands=n.CommandUtils.process(this._options.commands))}},{key:"prepare",value:function(e){s.Padding.setState(this,e),i.Highlight.setState(this,e),this.isTargetInShadow=a.Elements.isInsideShadowDOM(e),a.Elements.isPrimitiveElement(e)?(this._primitiveElement=e,this._originalText=this._primitiveElement.value):(this._genericElement=e,this._originalText=this._genericElement.textContent)}},{key:"resetRecording",value:function(e){this.isRestarting=!0,this.stop(!0),this.resetState(!0),this.start(e,!0)}},{key:"updateElements",value:function(e,r,i){var a,s=c.Text.capitalize(r);if(this.finalTranscript!==s||""!==e){t.PreResultUtils.process(this,i,""===e,this._onPreResult,this._options)&&(e="",i="");var o=this.commands&&n.CommandUtils.execCommand(this,i,this._options,this._primitiveElement||this._genericElement,this._originalText);if(o){if(o.doNotProcessTranscription)return;e="",i=""}if(!this.isPaused&&!this.isWaitingForCommand){null===(a=this._onResult)||void 0===a||a.call(this,i,""===e),this.finalTranscript=s,this._displayInterimResults||(e="");var l=""===this.finalTranscript&&""===e;this._primitiveElement?this.updatePrimitiveElement(this._primitiveElement,e,l):this._genericElement&&this.updateGenericElement(this._genericElement,e,l)}}}},{key:"updatePrimitiveElement",value:function(e,t,n){this.isHighlighted&&i.Highlight.removeForPrimitive(this,e),this.primitiveTextRecorded||s.Padding.adjustStateAfterRecodingPrimitiveElement(this,e),n&&s.Padding.adjustSateForNoTextPrimitiveElement(this);var a=this.startPadding+this.finalTranscript+t;if(e.value=a+this.endPadding,!this.isTargetInShadow){var c=a.length+this.numberOfSpacesAfterNewText;l.Cursor.setOffsetForPrimitive(e,c,this.autoScroll)}this.autoScroll&&o.Browser.IS_SAFARI()&&this.isCursorAtEnd&&r.AutoScroll.scrollSafariPrimitiveToEnd(e)}},{key:"updateGenericElement",value:function(e,t,n){this.isHighlighted&&i.Highlight.removeForGeneric(this,e),this.spansPopulated||a.Elements.appendSpans(this,e);
2var s=(n?"":this.startPadding)+c.Text.lineBreak(this.finalTranscript);this.finalSpan.innerHTML=s;var u=r.AutoScroll.isRequired(this.autoScroll,e);r.AutoScroll.changeStateIfNeeded(this,u);var d=c.Text.lineBreak(t)+(n?"":this.endPadding);this.interimSpan.innerHTML=d,o.Browser.IS_SAFARI()&&this.insertInCursorLocation&&l.Cursor.setOffsetForSafariGeneric(e,s.length+d.length),u&&r.AutoScroll.scrollGeneric(this,e),n&&(this.scrollingSpan.innerHTML="")}},{key:"finalise",value:function(t){this._genericElement&&(t?(this.finalSpan=a.Elements.createGenericSpan(),this.setInterimColorToFinal(),this.interimSpan=a.Elements.createInterimSpan(),this.scrollingSpan=a.Elements.createGenericSpan()):this._genericElement.textContent=this._genericElement.textContent,this.spansPopulated=!1),e.EventListeners.remove(this)}},{key:"setInterimColorToFinal",value:function(){this.interimSpan.style.color=this._finalTextColor||"black"}},{key:"resetState",value:function(e){this._primitiveElement=void 0,this._genericElement=void 0,this.finalTranscript="",this.finalSpan.innerHTML="",this.interimSpan.innerHTML="",this.scrollingSpan.innerHTML="",this.startPadding="",this.endPadding="",this.isHighlighted=!1,this.primitiveTextRecorded=!1,this.numberOfSpacesBeforeNewText=0,this.numberOfSpacesAfterNewText=0,e||(this.stopTimeout=void 0)}},{key:"setStateOnStart",value:function(){var e;this.recognizing=!0,this.isRestarting?this.isRestarting=!1:null===(e=this._onStart)||void 0===e||e.call(this)}},{key:"setStateOnStop",value:function(){var e;this.recognizing=!1,this.isRestarting||null===(e=this._onStop)||void 0===e||e.call(this)}},{key:"setStateOnError",value:function(e){var t;null===(t=this._onError)||void 0===t||t.call(this,e),this.recognizing=!1}}])}();return Ki.Speech=u,Ki}function va(){if(fa)return Bi;fa=1,Object.defineProperty(Bi,"__esModule",{value:!0}),Bi.WebSpeech=void 0;var e=function(){if(ji)return Fi;ji=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.WebSpeechTranscript=void 0;var e=Hi(),t=function(){return N((function e(){R(this,e)}),null,[{key:"extract",value:function(t,n,r){for(var i="",a=t.resultIndex;a<t.results.length;++a){var s=t.results[a][0].transcript;r&&(s=e.Translate.translate(s,r)),t.results[a].isFinal?n+=s:i+=s}return{interimTranscript:i,finalTranscript:n,newText:i||n}}},{key:"extractSafari",value:function(t,n,r){for(var i="",a=t.resultIndex;a<t.results.length;++a){var s=t.results[a][0].transcript;r&&(s=e.Translate.translate(s,r)),i+=s}return{interimTranscript:"",finalTranscript:i,newText:i}}}])}();return Fi.WebSpeechTranscript=t,Fi}(),t=Wi(),n=function(n){function r(){return R(this,r),_(this,r)}return x(r,n),N(r,[{key:"start",value:function(n){var r;void 0===this._extractText&&(this._extractText=t.Browser.IS_SAFARI()?e.WebSpeechTranscript.extractSafari:e.WebSpeechTranscript.extract),this.validate()&&(this.prepareBeforeStart(n),this.instantiateService(n),null===(r=this._service)||void 0===r||r.start(),this._translations=null==n?void 0:n.translations)}},{key:"validate",value:function(){return!!r.getAPI()||(this.error("Speech Recognition is unsupported"),!1)}},{key:"instantiateService",value:function(e){var t,n,i=r.getAPI();this._service=new i,this._service.continuous=!0,this._service.interimResults=null===(t=null==e?void 0:e.displayInterimResults)||void 0===t||t,this._service.lang=(null===(n=null==e?void 0:e.language)||void 0===n?void 0:n.trim())||"en-US",this.setEvents()}},{key:"setEvents",value:function(){var e=this;this._service&&(this._service.onstart=function(){e.setStateOnStart()},this._service.onerror=function(n){t.Browser.IS_SAFARI()&&"Another request is started"===n.message||"aborted"===n.error&&e.isRestarting||"no-speech"!==n.error&&e.error(n.message||n.error)},this._service.onaudioend=function(){e.setStateOnStop()},this._service.onend=function(){e._stopping=!1},this._service.onresult=function(t){if(O(t.results)>"u"&&e._service)e._service.onend=null,e._service.stop();else if(e._extractText&&!e._stopping){var n=e._extractText(t,e.finalTranscript,e._translations),r=n.interimTranscript,i=n.finalTranscript,a=n.newText;e.updateElements(r,i,a)}})}},{key:"stop",value:function(e){var t;this._stopping=!0,null===(t=this._service)||void 0===t||t.stop(),this.finalise(e)}},{key:"error",value:function(e){console.error(e),this.setStateOnError(e),this.stop()}}],[{key:"getAPI",value:function(){return window.webkitSpeechRecognition||window.SpeechRecognition}}])}(ga().Speech);return Bi.WebSpeech=n,Bi}var ya,ba={};var _a,wa={},ka={};var Sa,xa,Ea={},Ca={};function Ta(){if(xa)return Ea;xa=1,Object.defineProperty(Ea,"__esModule",{value:!0}),Ea.AzureSpeechConfig=void 0;var e=(Sa||(Sa=1,Object.defineProperty(Ca,"__esModule",{value:!0}),Ca.README_URL=void 0,Ca.README_URL="https://github.com/OvidijusParsiunas/speech-to-element"),Ca),t=function(){function t(){R(this,t)}return N(t,null,[{key:"validateOptions",value:function(t,n){return n?n.subscriptionKey||n.token||n.retrieveToken?!!n.region||(t("Please define a 'region' property - more info: ".concat(e.README_URL)),!1):(t("Please define a 'subscriptionKey', 'token' or 'retrieveToken' property - more info: ".concat(e.README_URL)),!1):(t("Please provide subscription details - more info: ".concat(e.README_URL)),!1)}},{key:"getNewSpeechConfig",value:(r=A(C().mark((function e(t,n){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.region){e.next=2;break}return e.abrupt("return",n.subscriptionKey?t.fromSubscription(n.subscriptionKey.trim(),n.region.trim()):n.token?t.fromAuthorizationToken(n.token.trim(),n.region.trim()):n.retrieveToken?n.retrieveToken().then((function(e){return n.region?t.fromAuthorizationToken((null==e?void 0:e.trim())||"",n.region.trim()):null})).catch((function(e){return console.error(e),null})):null);case 2:case"end":return e.stop()}}),e)}))),function(e,t){return r.apply(this,arguments)})},{key:"process",value:function(e,t){t.endpointId&&(e.endpointId=t.endpointId.trim()),t.language&&(e.speechRecognitionLanguage=t.language.trim())}},{key:"get",value:(n=A(C().mark((function e(n,r){var i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getNewSpeechConfig(n,r);case 2:return i=e.sent,e.abrupt("return",(i&&t.process(i,r),i));case 4:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})}]);var n,r}();return Ea.AzureSpeechConfig=t,Ea}var Aa,Ma={};var Ia,La={};var Oa,Ra,Pa,Na={};function ja(){if(Ra)return wa;Ra=1,Object.defineProperty(wa,"__esModule",{value:!0}),wa.Azure=void 0;var e=function(){if(_a)return ka;_a=1,Object.defineProperty(ka,"__esModule",{value:!0}),ka.PreventConnectionStop=void 0;var e=function(){return N((function e(){R(this,e)}),null,[{key:"applyPrevention",value:function(e){clearTimeout(e._manualConnectionStopPrevention),e.cannotBeStopped=!0,e._manualConnectionStopPrevention=setTimeout((function(){e.cannotBeStopped=!1}),800)}},{key:"clearPrevention",value:function(e){clearTimeout(e._manualConnectionStopPrevention),e.cannotBeStopped=!1}}])}();return ka.PreventConnectionStop=e,ka}(),t=Ta(),n=function(){if(Aa)return Ma;Aa=1,Object.defineProperty(Ma,"__esModule",{value:!0}),Ma.StopTimeout=void 0;var e=function(){function e(){R(this,e)}return N(e,null,[{key:"set",value:function(e){e.stopTimeout=setTimeout((function(){return e.stop()}),e.stopTimeoutMS)}},{key:"reset",value:function(t,n){t.stopTimeoutMS=n||e.DEFAULT_MS,e.stop(t),e.set(t)}},{key:"stop",value:function(e){e.stopTimeout&&clearTimeout(e.stopTimeout)}}])}();return Ma.StopTimeout=e,e.DEFAULT_MS=2e4,Ma}(),r=function(){if(Ia)return La;Ia=1,Object.defineProperty(La,"__esModule",{value:!0}),La.AzureAudioConfig=void 0;var e=function(){return N((function e(){R(this,e)}),null,[{key:"get",value:function(e,t){return t?e.fromMicrophoneInput(t):e.fromDefaultMicrophoneInput()}}])}();return La.AzureAudioConfig=e,La}(),i=function(){if(Oa)return Na;Oa=1,Object.defineProperty(Na,"__esModule",{value:!0}),Na.AzureTranscript=void 0;var e=Hi(),t=function(){return N((function e(){R(this,e)}),null,[{key:"extract",value:function(t,n,r,i){return i&&(t=e.Translate.translate(t,i)),r?{interimTranscript:"",finalTranscript:n+t,newText:t}:{interimTranscript:t,finalTranscript:n,newText:t}}}])}();return Na.AzureTranscript=t,Na}(),a=function(a){function s(){var e;return R(this,s),(e=_(this,s,arguments))._newTextPadding="",e}return x(s,a),N(s,[{key:"start",value:function(t,r){this._newTextPadding="",void 0===this.stopTimeout&&n.StopTimeout.reset(this,null==t?void 0:t.stopAfterSilenceMs),this.prepareBeforeStart(t),this.startAsync(t),r||e.PreventConnectionStop.applyPrevention(this)}},{key:"startAsync",value:(l=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.validate(t),!e.t0){e.next=6;break}return e.next=4,this.instantiateService(t);case 4:this._translations=null==t?void 0:t.translations,null===(n=this._service)||void 0===n||n.startContinuousRecognitionAsync((function(){}),this.error);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"validate",value:function(e){return s.getAPI()?t.AzureSpeechConfig.validateOptions(this.error.bind(this),e):(this.moduleNotFound(),!1)}},{key:"instantiateService",value:(o=A(C().mark((function e(n){var i,a,o,l,c,u,d,h,p;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=s.getAPI(),a=r.AzureAudioConfig.get(i.AudioConfig,n.deviceId),e.next=4,t.AzureSpeechConfig.get(i.SpeechConfig,n);case 4:(o=e.sent)?(n.autoLanguage&&n.autoLanguage.languages.length>0?(c=n.autoLanguage,u=c.type,d=c.languages,h=d.slice(0,"Continuous"===u?10:4),p=i.AutoDetectSourceLanguageConfig.fromLanguages(h),"Continuous"===u&&(p.mode=1),l=i.SpeechRecognizer.FromConfig(o,p,a)):l=new i.SpeechRecognizer(o,a),this.setEvents(l),this._service=l,n.retrieveToken&&this.retrieveTokenInterval(n.retrieveToken)):this.error("Unable to contact Azure server");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setEvents",value:function(e){e.recognizing=this.onRecognizing.bind(this),e.recognized=this.onRecognized.bind(this),e.sessionStarted=this.onSessionStarted.bind(this),e.canceled=this.onCanceled.bind(this),e.sessionStopped=this.onSessionStopped.bind(this)}},{key:"onRecognizing",value:function(e,t){if(!this._stopping){var r=i.AzureTranscript.extract(this._newTextPadding+t.result.text,this.finalTranscript,!1,this._translations),a=r.interimTranscript,s=r.finalTranscript,o=r.newText;n.StopTimeout.reset(this,this.stopTimeoutMS),this.updateElements(a,s,o)}}},{key:"onRecognized",value:function(e,t){var r=t.result;switch(r.reason){case window.SpeechSDK.ResultReason.Canceled:break;case window.SpeechSDK.ResultReason.RecognizedSpeech:if(r.text&&!this._stopping){var a=i.AzureTranscript.extract(this._newTextPadding+r.text,this.finalTranscript,!0,this._translations),s=a.interimTranscript,o=a.finalTranscript,l=a.newText;n.StopTimeout.reset(this,this.stopTimeoutMS),this.updateElements(s,o,l),""!==o&&(this._newTextPadding=" ")}}}},{key:"onCanceled",value:function(e,t){t.reason===window.SpeechSDK.CancellationReason.Error&&this.error(t.errorDetails)}},{key:"onSessionStarted",value:function(){e.PreventConnectionStop.clearPrevention(this),this.setStateOnStart()}},{key:"onSessionStopped",value:function(){this._retrieveTokenInterval||clearInterval(this._retrieveTokenInterval),this._stopping=!1,this.setStateOnStop()}},{key:"retrieveTokenInterval",value:function(e){var t=this;this._retrieveTokenInterval=setInterval((function(){null==e||e().then((function(e){t._service&&(t._service.authorizationToken=(null==e?void 0:e.trim())||"")})).catch((function(e){t.error(e)}))}),1e4)}},{key:"stop",value:function(e){var t;!e&&this._retrieveTokenInterval&&clearInterval(this._retrieveTokenInterval),this._stopping=!0,null===(t=this._service)||void 0===t||t.stopContinuousRecognitionAsync(),n.StopTimeout.stop(this),this.finalise(e)}},{key:"moduleNotFound",value:function(){console.error("speech recognition module not found:"),console.error("please install the 'microsoft-cognitiveservices-speech-sdk' npm package or add a script tag: <script src=\"https://aka.ms/csspeech/jsbrowserpackageraw\"><\/script>"),this.setStateOnError("speech recognition module not found")}},{key:"error",value:function(e){this._retrieveTokenInterval&&clearInterval(this._retrieveTokenInterval),console.error(e),this.setStateOnError(e),this.stop()}}],[{key:"getAPI",value:function(){return window.SpeechSDK}}]);var o,l}(ga().Speech);return wa.Azure=a,wa}var Da=function(){if(Pa)return Di;Pa=1,Object.defineProperty(Di,"__esModule",{value:!0});var e=va(),t=ca(),n=function(){if(ya)return ba;ya=1,Object.defineProperty(ba,"__esModule",{value:!0}),ba.GlobalState=void 0;var e=function(){function e(){R(this,e)}return N(e,null,[{key:"doubleClickDetector",value:function(){return!!e.doubleClickPending||(e.doubleClickPending=!0,setTimeout((function(){e.doubleClickPending=!1}),300),!1)}}])}();return ba.GlobalState=e,e.doubleClickPending=!1,ba}(),r=ja(),i=function(){function i(){R(this,i)}return N(i,null,[{key:"toggle",value:function(e,t){var r,a,s=e.toLocaleLowerCase().trim();null!==(r=n.GlobalState.service)&&void 0!==r&&r.recognizing?this.stop():"webspeech"===s?i.startWebSpeech(t):"azure"===s?i.startAzure(t):(console.error("service not found - must be either 'webspeech' or 'azure'"),null===(a=null==t?void 0:t.onError)||void 0===a||a.call(t,"service not found - must be either 'webspeech' or 'azure'"))}},{key:"startWebSpeech",value:function(t){i.stop()||(n.GlobalState.service=new e.WebSpeech,n.GlobalState.service.start(t))}},{key:"isWebSpeechSupported",value:function(){return!!e.WebSpeech.getAPI()}},{key:"startAzure",value:function(e){var t;i.stop()||null!==(t=n.GlobalState.service)&&void 0!==t&&t.cannotBeStopped||(n.GlobalState.service=new r.Azure,n.GlobalState.service.start(e))}},{key:"stop",value:function(){var e;return!!n.GlobalState.doubleClickDetector()||(!(null===(e=n.GlobalState.service)||void 0===e)&&e.recognizing&&n.GlobalState.service.stop(),!1)}},{key:"endCommandMode",value:function(){n.GlobalState.service&&t.CommandUtils.toggleCommandModeOff(n.GlobalState.service)}}])}();return Di.default=i,Di}(),Ba=Ri(Da),Fa=function(){return N((function e(t,n){R(this,e),this.silenceMS=2e3,this.stop=!0,"boolean"==typeof n&&!1===n&&(this.stop=!1),"number"==typeof t&&(this.silenceMS=t)}),[{key:"setSilenceTimeout",value:function(e,t){var n=this;this._silenceTimeout=setTimeout((function(){var r;null==(r=e.submit)||r.call(e),Ba.stop(),n.stop||setTimeout(t,za.MICROPHONE_RESET_TIMEOUT_MS)}),this.silenceMS)}},{key:"clearSilenceTimeout",value:function(){this._silenceTimeout&&clearTimeout(this._silenceTimeout)}},{key:"resetSilenceTimeout",value:function(e,t){this.clearSilenceTimeout(),this.setSilenceTimeout(e,t)}},{key:"onPause",value:function(e,t,n){e?this.resetSilenceTimeout(t,n):this.clearSilenceTimeout()}}])}(),Ua=function(e){function t(e,n,r){var i;R(this,t);var a="object"==O(e.speechToText)?e.speechToText:{},s=(i=_(this,t,[null==a?void 0:a.button])).processConfiguration(n,e.speechToText),o=s.serviceName,l=s.processedConfig;if(i._addErrorMessage=r,"webspeech"!==o||Ba.isWebSpeechSupported()){var c=!e.textInput||!e.textInput.disabled;i.elementRef.onclick=i.buttonClick.bind(i,n,c,o,l)}else i.changeToUnsupported();return setTimeout((function(){i._validationHandler=e._validationHandler})),i}return x(t,e),N(t,[{key:"processConfiguration",value:function(e,n){var r,i,a,s,o,l,c="object"==O(n)?n:{},u="object"==O(c.webSpeech)?c.webSpeech:{},d=c.azure||{},h=I(I({displayInterimResults:null!==(r=c.displayInterimResults)&&void 0!==r?r:void 0,textColor:null!==(i=c.textColor)&&void 0!==i?i:void 0,translations:null!==(a=c.translations)&&void 0!==a?a:void 0,commands:null!==(s=c.commands)&&void 0!==s?s:void 0,events:null!==(o=c.events)&&void 0!==o?o:void 0},u),d),p=null==(l=c.commands)?void 0:l.submit;return p&&(h.onPreResult=function(t){return t.toLowerCase().includes(p)?(setTimeout((function(){var t;return null==(t=e.submit)?void 0:t.call(e)})),Ba.endCommandMode(),{restart:!0,removeNewText:!0}):null}),c.submitAfterSilence&&(this._silenceSubmit=new Fa(c.submitAfterSilence,c.stopAfterSubmit)),{serviceName:t.getServiceName(c),processedConfig:h}}},{key:"buttonClick",value:function(e,t,n,r){var i=this,a=null==r?void 0:r.events;e.removePlaceholderStyle(),Ba.toggle(n,I({insertInCursorLocatio
2n:!1,element:t?e.inputElementRef:void 0,onError:function(){var e;i.onError(),null==(e=i._silenceSubmit)||e.clearSilenceTimeout()},onStart:function(){var e;i.changeToActive(),null==(e=null==a?void 0:a.onStart)||e.call(a)},onStop:function(){var e,t,n;null==(e=i._validationHandler)||e.call(i),null==(t=i._silenceSubmit)||t.clearSilenceTimeout(),i.changeToDefault(),null==(n=null==a?void 0:a.onStop)||n.call(a)},onPauseTrigger:function(t){var n,r;null==(n=i._silenceSubmit)||n.onPause(t,e,i.elementRef.onclick),null==(r=null==a?void 0:a.onPauseTrigger)||r.call(a,t)},onPreResult:function(e,t){var n;null==(n=null==a?void 0:a.onPreResult)||n.call(a,e,t)},onResult:function(t,n){var r,s,o;n&&(null==(r=i._validationHandler)||r.call(i)),null==(s=i._silenceSubmit)||s.resetSilenceTimeout(e,i.elementRef.onclick),null==(o=null==a?void 0:a.onResult)||o.call(a,t,n)},onCommandModeTrigger:function(e){var t;i.onCommandModeTrigger(e),null==(t=null==a?void 0:a.onCommandModeTrigger)||t.call(a,e)}},r))}},{key:"onCommandModeTrigger",value:function(e){e?this.changeToCommandMode():this.changeToActive()}},{key:"onError",value:function(){this._addErrorMessage("speechToText","speech input error")}}],[{key:"getServiceName",value:function(e){return e.azure?"azure":"webspeech"}},{key:"toggleSpeechAfterSubmit",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e.click(),n||setTimeout((function(){return e.click()}),t.MICROPHONE_RESET_TIMEOUT_MS)}}])}(Oi);Ua.MICROPHONE_RESET_TIMEOUT_MS=300;var za=Ua,qa=function(){function e(t,n,r,i){var a=this;R(this,e),this._attachments=[],this._fileCountLimit=99,this._acceptedFormat="",n.maxNumberOfFiles&&(this._fileCountLimit=n.maxNumberOfFiles),this._toggleContainerDisplay=r,this._fileAttachmentsContainerRef=i,n.acceptedFormats&&(this._acceptedFormat=n.acceptedFormats),setTimeout((function(){a._val
2idationHandler=t._validationHandler}))}return N(e,[{key:"attemptAddFile",value:function(t,n){return!!e.isFileTypeValid(t,this._acceptedFormat)&&(this.addAttachmentBasedOnType(t,n,!0),!0)}},{key:"addAttachmentBasedOnType",value:function(t,n,r){var i=e.getTypeFromBlob(t);if("image"===i){var a=e.createImageAttachment(n);this.addFileAttachment(t,"image",a,r)}else if("audio"===i){var s=Va.createAudioAttachment(n);this.addFileAttachment(t,"audio",s,r)}else{var o=e.createAnyFileAttachment(t.name);this.addFileAttachment(t,"any",o,r)}}},{key:"addFileAttachment",value:function(t,n,r,i){var a,s=e.createContainer(r);if(this._attachments.length>=this._fileCountLimit){var o=this._attachments[this._attachments.length-1].removeButton;null==o||o.click();var l=this._fileAttachmentsContainerRef.children;this._fileAttachmentsContainerRef.insertBefore(s,l[0])}else this._fileAttachmentsContainerRef.appendChild(s);var c={file:t,attachmentContainerElement:s,fileType:n};return i&&(c.removeButton=this.createRemoveAttachmentButton(c),s.appendChild(c.removeButton)),this._toggleContainerDisplay(!0),this._attachments.push(c),this._fileAttachmentsContainerRef.scrollTop=this._fileAttachmentsContainerRef.scrollHeight,null==(a=this._validationHandler)||a.call(this),c}},{key:"createRemoveAttachmentButton",value:function(e){var t=document.createElement("div");t.classList.add("remove-file-attachment-button"),t.onclick=this.removeAttachment.bind(this,e);var n=document.createElement("div");return n.classList.add("x-icon"),n.innerText="×",t.appendChild(n),t}},{key:"removeAttachment",value:function(e){var t,n=this._attachments.findIndex((function(t){return t===e})),r=this._attachments[n].attachmentContainerElement;this._attachments.splice(n,1),Va.stopAttachmentPlayback(r),r.remove(),this._toggleContainerDisplay(!1),null==(t=this._val
2idationHandler)||t.call(this)}},{key:"getFiles",value:function(){return Array.from(this._attachments).map((function(e){return{file:e.file,type:e.fileType}}))}},{key:"removeAllAttachments",value:function(){this._attachments.forEach((function(e){setTimeout((function(){var t;return null==(t=e.removeButton)?void 0:t.click()}))}))}}],[{key:"isFileTypeValid",value:function(e,t){if(""===t)return!0;for(var n=t.split(","),r=0;r<n.length;r++){var i=n[r].trim();if(e.type===i)return!0;if(i.startsWith(".")){var a=i.slice(1);if(e.name.endsWith(a))return!0}else{if(e.name.endsWith(i))return!0;if(i.endsWith("/*")&&e.type.startsWith(i.slice(0,-2)))return!0}}return!1}},{key:"getTypeFromBlob",value:function(e){var t=e.type;return t.startsWith("image")?"image":t.startsWith("audio")?"audio":"any"}},{key:"createImageAttachment",value:function(e){var t=new Image;return t.src=e,t.classList.add("image-attachment"),t}},{key:"createAnyFileAttachment",value:function(e){var t=document.createElement("div");t.classList.add("border-bound-attachment"),G.IS_SAFARI&&t.classList.add("border-bound-attachment-safari");var n=document.createElement("div");n.classList.add("any-file-attachment-text");var r=document.createElement("div");return r.classList.add("file-attachment-text-container"),r.appendChild(n),n.textContent=e,t.appendChild(r),t}},{key:"createContainer",value:function(e){var t=document.createElement("div");return t.classList.add("file-attachment"),t.appendChild(e),t}}])}(),Ha=function(e){function t(e,n,r,i){return R(this,t),_(this,t,[e,n,r,i])}return x(t,e),N(t,[{key:"createTimer",value:function(e,n){var r=this,i=0,a=void 0!==n&&n<t.TIMER_LIMIT_S?n:t.TIMER_LIMIT_S;return setInterval((function(){var t;(i+=1)===a&&(null==(t=r.stopPlaceholderCallback)||t.call(r),r.clearTimer()),600===i&&e.classList.add("audio-placeholder-text-4-digits");var n=Math.floor(i/60),s=(i%60).toString().padStart(2,"0");e.textContent="".concat(n,":").concat(s)}),1e3)}},{key:"createPlaceholderAudioAttachment",value:function(e){var n=t.createAudioContainer(),r=document.createElement("div");r.classList.add("audio-placeholder-text-3-digits");var i=document.createElement("div");i.classList.add("file-attachment-text-container","audio-placeholder-text-3-digits-container"),i.appendChild(r);var a=Nn.createSVGElement(jr);return a.classList.add("attachment-icon","stop-icon","not-removable-attachment-icon"),r.textContent="0:00",this._activePlaceholderTimer=this.createTimer(r,e),n.appendChild(i),this.addPlaceholderAudioAttachmentEvents(n,a,i),n}},{key:"addPlaceholderAudioAttachmentEvents",value:function(e,t,n){var r=this;e.addEventListener("mouseenter",(function(){return e.replaceChildren(t)}));e.addEventListener("mouseleave",(function(){return e.replaceChildren(n)}));e.addEventListener("click",(function(){var e;return null==(e=r.stopPlaceholderCallback)?void 0:e.call(r)}))}},{key:"addPlaceholderAttachment",value:function(e,t){var n=this.createPlaceholderAudioAttachment(t);this._activePlaceholderAttachment=this.addFileAttachment(new File([],""),"audio",n,!1),this.stopPlaceholderCallback=e}},{key:"completePlaceholderAttachment",value:function(e,n){var r=this._activePlaceholderAttachment;r&&(r.file=e,t.addAudioElements(r.attachmentContainerElement.children[0],n),r.removeButton=this.createRemoveAttachmentButton(r),r.attachmentContainerElement.appendChild(r.removeButton),this._activePlaceholderAttachment=void 0,this.clearTimer())}},{key:"removePlaceholderAttachment",value:function(){this._activePlaceholderAttachment&&(this.removeAttachment(this._activePlaceholderAttachment),this._activePlaceholderAttachment=void 0,this.clearTimer())}},{key:"clearTimer",value:function(){void 0!==this._activePlaceholderTimer&&(clearInterval(this._activePlaceholderTimer),this._activePlaceholderTimer=void 0,this.stopPlaceholderCallback=void 0)}}],[{key:"createAudioContainer",value:function(){var e=document.createElement("div");return e.classList.add("border-bound-attachment","audio-attachment-icon-container"),G.IS_SAFARI&&e.classList.add("border-bound-attachment-safari"),e}},{key:"addAudioElements",value:function(e,t){var n=e.parentElement?ie.cloneElement(e):e,r=document.createElement("audio");r.src=t;var i=Nn.createSVGElement(Nr);i.classList.add("attachment-icon","play-icon");var a=Nn.createSVGElement(jr);a.classList.add("attachment-icon","stop-icon"),n.replaceChildren(i),r.onplay=function(){n.replaceChildren(a)},r.onpause=function(){n.replaceChildren(i),r.currentTime=0},r.onended=function(){n.replaceChildren(i)},n.onclick=function(){r.paused?r.play():r.pause()}}},{key:"createAudioAttachment",value:function(e){var n=t.createAudioContainer();return t.addAudioElements(n,e),n}},{key:"stopAttachmentPlayback",value:function(e){var t,n,r;null!=(r=null==(n=null==(t=e.children[0])?void 0:t.children)?void 0:n[0])&&r.classList.contains("stop-icon")&&e.children[0].click()}}])}(qa);Ha.TIMER_LIMIT_S=5999;var Va=Ha,Ga=function(){return N((function e(){R(this,e)}),null,[{key:"create",value:function(e,t,n,r,i){return"audio"===i?new Va(e,t,n,r):new qa(e,t,n,r)}}])}(),Wa=function(){function e(t,n,r){R(this,e),this._fileAttachmentsTypes=[],this.elementRef=this.createAttachmentContainer();var i="object"==O(r)&&!!r.displayFileAttachmentContainer;this.toggleContainerDisplay(i),t.appendChild(this.elementRef),n&&Object.assign(this.elementRef.style,n)}return N(e,[{key:"addType",value:function(e,t,n){var r=Ga.create(e,t,this.toggleContainerDisplay.bind(this),this.elementRef,n);return this._fileAttachmentsTypes.push(r),r}},{key:"createAttachmentContainer",value:function(){var e=document.createElement("div");return e.id="file-attachment-container",e}},{key:"toggleContainerDisplay",value:function(e){e?this.elementRef.style.display="block":0===this.elementRef.children.length&&(this.elementRef.style.display="none")}},{key:"getAllFileData",value:function(){var e=this._fileAttachmentsTypes.map((function(e){return e.getFiles()})).flat();return e.length>0?e:void 0}},{key:"completePlaceholders",value:(t=A(C().mark((function e(){return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(this._fileAttachmentsTypes.map(function(){var e=A(C().mark((function e(t){var n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null==(n=t.stopPlaceholderCallback)?void 0:n.call(t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"addFilesToAnyType",value:function(t){e.addFilesToType(t,this._fileAttachmentsTypes)}},{key:"removeAllFiles",value:function(){this._fileAttachmentsTypes.forEac
2h((function(e){return e.removeAllAttachments()})),this.elementRef.replaceChildren(),this.toggleContainerDisplay(!1)}},{key:"getNumberOfTypes",value:function(){return this._fileAttachmentsTypes.length}}],[{key:"addFilesToType",value:function(e,t){e.forEach((function(e){var n=new FileReader;n.readAsDataURL(e),n.onload=function(n){for(var r=0;r<t.length&&!t[r].attemptAddFile(e,n.target.result);r+=1);}}))}}]);var t}(),$a=function(){function e(t,n,r){R(this,e),this._isOpen=!1,this._contentRef=e.createModalContent(n,null==r?void 0:r.backgroundColor),this._buttonPanel=e.createButtonPanel(null==r?void 0:r.backgroundColor),this._elementRef=e.createContainer(this._contentRef,r),this._elementRef.appendChild(this._buttonPanel),t.appendChild(this._elementRef),this._backgroundPanelRef=e.createDarkBackgroundPanel(),t.appendChild(this._backgroundPanelRef),this.addWindowEvents(t)}return N(e,[{key:"isOpen",value:function(){return this._isOpen}},{key:"addButtons",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){Er.addAttributes(t),e._buttonPanel.appendChild(t)}))}},{key:"close",value:function(){var t=this;this._elementRef.classList.remove("show-modal"),this._elementRef.classList.add("hide-modal"),this._backgroundPanelRef.classList.remove("show-modal-background"),this._backgroundPanelRef.classList.add("hide-modal-background"),this._isOpen=!1,setTimeout((function(){t._elementRef.style.display="none",t._backgroundPanelRef.style.display="none"}),e.MODAL_CLOSE_TIMEOUT_MS)}},{key:"displayModalElements",value:function(){this._elementRef.style.display="flex",this._elementRef.classList.remove("hide-modal"),this._elementRef.classList.add("show-modal"),this._backgroundPanelRef.style.display="block",this._backgroundPanelRef.classList.remove("hide-modal-background"),this._backgroundPanelRef.classList.add("show-modal-background"),this._isOpen=!0}},{key:"openTextModal",value:function(e){this._contentRef.innerHTML=e,this.displayModalElements()}},{key:"addCloseButton",value:function(t,n,r){var i=this,a=n?e.createSVGButton(t):e.createTextButton(t);return this.addButtons(a),a.onclick=function(){i.close(),setTimeout((function(){null==r||r()}),140)},a}},{key:"addWindowEvents",value:function(e){this.keyDownEvent=this.windowKeyDown.bind(this,e),window.addEventListener("keydown",this.keyDownEvent)}},{key:"windowKeyDown",value:function(e,t){var n,r;!e.isConnected&&this.keyDownEvent?window.removeEventListener("keydown",this.keyDownEvent):this._isOpen&&(t.key===W.ESCAPE?(this.close(),null==(n=this.extensionCloseCallback)||n.call(this)):t.key===W.ENTER&&(this.close(),null==(r=this.extensionCloseCallback)||r.call(this)))}}],[{key:"createContainer",value:function(e,t){var n=document.createElement("div");return n.classList.add("modal"),n.appendChild(e),t&&delete t.backgroundColor,Object.assign(n.style,t),n}},{key:"createModalContent",value:function(e,t){var n,r=document.createElement("div");return(n=r.classList).add.apply(n,v(e)),t&&(r.style.backgroundColor=t),document.createElement("div").appendChild(r),r}},{key:"createButtonPanel",value:function(e){var t=document.createElement("div");return t.classList.add("modal-button-panel"),e&&(t.style.backgroundColor=e),t}},{key:"createDarkBackgroundPanel",value:function(){var e=document.createElement("div");return e.id="modal-background-panel",e}},{key:"createTextButton",value:function(e){var t=document.createElement("div");return t.classList.add("modal-button"),t.textContent=e,t}},{key:"createSVGButton",value:function(e){var t=document.createElement("div");t.classList.add("modal-button","modal-svg-button");var n=Nn.createSVGElement(e);return n.classList.add("modal-svg-button-icon"),t.appendChild(n),t}},{key:"createTextModalFunc",value:function(t,n,r){var i;if("object"==O(n)&&null!=(i=n.files)&&i.infoModal){var a=new e(t,["modal-content"],n.files.infoModal.containerStyle);return a.addCloseButton("OK",!1,r),a.openTextModal.bind(a,n.infoModalTextMarkUp||"")}}}])}();$a.MODAL_CLOSE_TIMEOUT_MS=190;var Ka=$a,Ja=function(e){function t(e,n,r,i,a,s){var o,l,c,u,d,h,p,f,m,g;R(this,t);var v=null==(l=null==r?void 0:r.button)?void 0:l.position,y=(null==(d=null==(u=null==(c=null==r?void 0:r.button)?void 0:c.styles)?void 0:u.text)?void 0:d.content)||s,b=(o=_(this,t,[t.createButtonElement(),a,v,r.button,y])).createInnerElementsForStates(i,o.customStyles);return o._inputElement=t.createInputElement(null==(h=null==r?void 0:r.files)?void 0:h.acceptedFormats),o.addClickEvent(e,r),o.changeElementsByState(b.styles),o.reapplyStateStyle("styles"),o._fileAttachmentsType=n,o._openModalOnce=!1===(null==(f=null==(p=r.files)?void 0:p.infoModal)?void 0:f.openModalOnce)||null==(g=null==(m=r.files)?void 0:m.infoModal)?void 0:g.openModalOnce,o}return x(t,e),N(t,[{key:"createInnerElementsForStates",value:function(e,t){return{styles:this.createInnerElements(e,"styles",t)}}},{key:"triggerImportPrompt",value:function(e){e.onchange=this.import.bind(this,e),e.click()}},{key:"import",value:function(e){Wa.addFilesToType(Array.from(e.files||[]),[this._fileAttachmentsType]),e.value=""}},{key:"addClickEvent",value:function(e,t){var n=this.triggerImportPrompt.bind(this,this._inputElement),r=Ka.createTextModalFunc(e,t,n);this.elementRef.onclick=this.click.bind(this,r)}},{key:"click",value:function(e){!e||void 0!==this._openModalOnce&&!0!==this._openModalOnce?this.triggerImportPrompt(this._inputElement):(e(),!0===this._openModalOnce&&(this._openModalOnce=!1))}}],[{key:"createInputElement",value:function(e){var t=document.createElement("input");return t.type="file",t.accept=e||"",t.hidden=!0,t.multiple=!0,t}},{key:"createButtonElement",value:function(){var e=document.createElement("div");return e.classList.add("input-button"),e}}])}(Lr),Za=function(){function e(){R(this,e)}return N(e,null,[{key:"create",value:function(t,n,r){var i=e.createElement(r);e.addEvents(i,t,n),t.appendChild(i)}},{key:"createElement",value:function(e){var t=document.createElement("div");return t.id="drag-and-drop","object"==O(e)&&Object.assign(t.style,e),t}},{key:"addEvents",value:function(t,n,r){n.ondragenter=function(n){n.preventDefault(),e.display(t)},t.ondragleave=function(n){n.preventDefault(),e.hide(t)},t.ondragover=function(e){e.preventDefault()},t.ondrop=function(n){n.preventDefault(),e.uploadFile(r,n),e.hide(t)}}},{key:"uploadFile",value:function(e,t){var n,r=null==(n=t.dataTransfer)?void 0:n.files;r&&e.addFilesToAnyType(Array.from(r))}},{key:"display",value:function(e){e.style.display="block"}},{key:"hide",value:function(e){e.style.display="none"}},{key:"isEnabled",value:function(e,t){return(void 0===t||!1!==t)&&(!!t||e.getNumberOfTypes()>0)}}])}(),Ya=function(){function e(){R(this,e)}return N(e,null,[{key:"validate",value:function(e,t,n,r,i){var a=e(n,r,i);return a?t.changeToSubmitIcon():t.changeToDisabledIcon(),a}},{key:"useValidationFunc",value:(n=A(C().mark((function t(n,r,i,a){var s,o,l;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=r.isTextInputEmpty()?"":r.inputElementRef.textContent,t.next=3,i.completePlaceholders();case 3:return o=i.getAllFileData(),l=null==o?void 0:o.map((function(e){return e.file})),t.abrupt("return",e.validate(n,a,s,l));case 5:case"end":return t.stop()}}),t)}))),function(e,t,r,i){return n.apply(this,arguments)})},{key:"useValidationFuncProgrammatic",value:(t=A(C().mark((function t(n,r,i){var a,s;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=null==(a=r.files)?void 0:a.map((function(e){return e.file})),t.abrupt("return",e.validate(n,i,r.text,s,!0));case 2:case"end":return t.stop()}}),t)}))),function(e,n,r){return t.apply(this,arguments)})},{key:"validateWebsocket",value:function(e,t){var n=e.websocket,r=e.connectSettings;return!(n&&r.url!==kn.URL&&!Sn.canSendMessage(n))||(t.changeToDisabledIcon(),!1)}},{key:"attach",value:function(t,n,r,i,a){var s=t.validateInput||de.processValidateInput(t);t._validationHandler=function(){var t=A(C().mark((function t(o){var l;return C().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!a.status.loadingActive&&!a.status.requestInProgress&&!0!==n.isSubmitProgrammaticallyDisabled&&e.validateWebsocket(n,a)){t.next=2;break}return t.abrupt("return",!1);case 2:return l=s||n.canSendMessage,t.abrupt("return",l?o?e.useValidationFuncProgrammatic(l,o,a):e.useValidationFunc(l,r,i,a):null);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()}}]);var t,n}
2(),Xa=function(){return N((function e(){R(this,e)}),null,[{key:"getFileName",value:function(e,t){var n=new Date,r=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0"),a=String(n.getSeconds()).padStart(2,"0");return"".concat(e,"-").concat(r,"-").concat(i,"-").concat(a,".").concat(t)}}])}(),Qa=function(e){function t(e,n){var r,i,a;return R(this,t),(r=_(this,t,[n.button]))._waitingForBrowserApproval=!1,r._audioType=e,r._extension=(null==(i=n.files)?void 0:i.format)||"mp3",r._maxDurationSeconds=null==(a=n.files)?void 0:a.maxDurationSeconds,r.elementRef.onclick=r.buttonClick.bind(w(r)),r}return x(t,e),N(t,[{key:"buttonClick",value:function(){this._waitingForBrowserApproval||(this.isActive?this.stop():(this._waitingForBrowserApproval=!0,this.record()))}},{key:"stop",value:function(){var e=this;return new Promise((function(t){var n,r;e.changeToDefault(),null==(n=e._mediaRecorder)||n.stop(),null==(r=e._mediaStream)||r.getTracks().forEach((function(e){return e.stop()})),setTimeout((function(){t()}),10)}))}},{key:"record",value:function(){var e=this;navigator.mediaDevices.getUserMedia({audio:!0}).then((function(t){e.changeToActive(),e._mediaRecorder=new MediaRecorder(t),e._audioType.addPlaceholderAttachment(e.stop.bind(e),e._maxDurationSeconds),e._mediaStream=t,e._mediaRecorder.addEventListener("dataavailable",(function(t){e.createFile(t)})),e._mediaRecorder.start()})).catch((function(t){console.error(t),e.stop()})).finally((function(){e._waitingForBrowserApproval=!1}))}},{key:"createFile",value:function(e){var t=this,n=new Blob([e.data],{type:"audio/".concat(this._extension)}),r=Xa.getFileName(this._newFilePrefix||"audio",this._extension),i=new File([n],r,{type:n.type}),a=new FileReader;a.readAsDataURL(i),a.onload=function(e){t._audioType.completePlaceholderAttachment(i,e.target.result)}}}])}(Oi),es=function(){function e(){R(this,e)}return N(e,null,[{key:"resetSubmit",value:function(e,t){t?e.unsetCustomStateStyles(["loading","submit"]):e.unsetCustomStateStyles(["stop","loading","submit"]),e.reapplyStateStyle("submit")}},{key:"overwriteDefaultStyleWithSubmit",value:function(e,t){if(e.submit){var n=JSON.parse(JSON.stringify(e[t]||{}));Pr.overwritePropertyObjectFromAnother(n,e.submit,["container","default"]),Pr.overwritePropertyObjectFromAnother(n,e.submit,["text","styles","default"]),Pr.overwritePropertyObjectFromAnother(n,e.submit,["svg","styles","default"]),e[t]=n}}},{key:"setUpDisabledButton",value:function(t){Pr.setPropertyValueIfDoesNotExist(t,["submit","container","default","backgroundColor"],""),Pr.setPropertyValueIfDoesNotExist(t,["disabled","container","default","backgroundColor"],"unset"),Pr.setPropertyValueIfDoesNotExist(t.submit,["svg","styles","default","filter"],""),Pr.setPropertyValueIfDoesNotExist(t.disabled,["svg","styles","default","filter"],"brightness(0) saturate(100%) invert(70%) sepia(0%) saturate(5564%) hue-rotate(207deg) brightness(100%) contrast(97%)"),Pr.setPropertyValueIfDoesNotExist(t.disabled,["text","styles","default","color"],"grey"),e.overwriteDefaultStyleWithSubmit(t,"disabled")}},{key:"process",value:function(t){var n=JSON.parse(JSON.stringify(t||{}));return e.overwriteDefaultStyleWithSubmit(n,"loading"),e.overwriteDefaultStyleWithSubmit(n,"stop"),null!=t&&t.alwaysEnabled||e.setUpDisabledButton(n),n}}])}(),ts=function(e){function t(e,n,r,i,a,s){var o;R(this,t);var l=es.process(e.submitButtonStyles);return(o=_(this,t,[t.createButtonContainerElement(),'<?xml version="1.0" standalone="no"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">\n<svg xmlns="http://www.w3.org/2000/svg" stroke="currentColor" fill="none" stroke-width="1" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round">\n  <line x1="22" y1="2" x2="11" y2="14"></line>\n  <polygon points="22 2 15 22 11 14 2 10 22 2"></polygon>\n</svg>\n',null==l?void 0:l.position,l]))._isSVGLoadingIconOverriden=!1,o.status={requestInProgress:!1,loadingActive:!1},o._messages=r,o._textInput=n,o._fileAttachments=a,o._innerElements=o.createInnerElementsForStates(),o._abortStream=new AbortController,o._stopClicked={listener:function(){}},o._serviceIO=i,o._alwaysEnabled=!(null==l||!l.alwaysEnabled),e.disableSubmitButton=o.disableSubmitButton.bind(w(o),i),o.attemptOverwriteLoadingStyle(e),s.microphone&&o.setUpSpeechToText(s.microphone.button,e.speechToText),setTimeout((function(){var t;o._validationHandler=e._validationHandler,o.assignHandlers(o._validationHandler),null==(t=o._validationHandler)||t.call(w(o))})),o}return x(t,e),N(t,[{key:"createInnerElementsForStates",value:function(){var e=this.createCustomElements(),n=e.submit,r=e.loading,i=e.stop;return{submit:n,loading:r||[t.createLoadingIconElement()],stop:i||[t.createStopIconElement()],disabled:this.createDisabledIconElement(n)}}},{key:"createCustomElements",value:function(){var e=this,t=Ar.createCustomElements("submit",this.svg,this.customStyles),n={loading:void 0,stop:void 0};
2return Object.keys(n).forEach((function(t){var r=t,i=Ar.createCustomElements(r,e.svg,e.customStyles);i&&(n[r]=i)})),n.submit=t||this.buildDefaultIconElement("submit-icon"),n}},{key:"createDisabledIconElement",value:function(e){return Ar.createCustomElements("disabled",this.svg,this.customStyles)||[e[0].cloneNode(!0)]}},{key:"attemptOverwriteLoadingStyle",value:function(e){var t,n,r,i,a,s,o,l,c;if(!(null!=(n=null==(t=this.customStyles)?void 0:t.submit)&&n.svg||null!=(a=null==(i=null==(r=this.customStyles)?void 0:r.loading)?void 0:i.svg)&&a.content||null!=(l=null==(o=null==(s=this.customStyles)?void 0:s.loading)?void 0:o.text)&&l.content||void 0!==e.displayLoadingBubble&&!0!==e.displayLoadingBubble)){var u=document.createElement("style");u.textContent="\n        .loading-button > * {\n          filter: brightness(0) saturate(100%) invert(72%) sepia(0%) saturate(3044%) hue-rotate(322deg) brightness(100%)\n            contrast(96%) !important;\n        }",null==(c=e.shadowRoot)||c.appendChild(u),this._isSVGLoadingIconOverriden=!0}}},{key:"assignHandlers",value:function(e){this._serviceIO.completionsHandlers={onFinish:this.resetSubmit.bind(this,e)},this._serviceIO.streamHandlers={onOpen:this.changeToStopIcon.bind(this),onClose:this.resetSubmit.bind(this,e),abortStream:this._abortStream,stopClicked:this._stopClicked};var t=this._serviceIO.stream;"object"==O(t)&&"number"==typeof t.simulation&&(this._serviceIO.streamHandlers.simulationInterim=t.simulation)}},{key:"setUpSpeechToText",value:function(e,t){this._microphoneButton=e,this._stopSTTAfterSubmit="object"==O(t)&&t.stopAfterSubmit}},{key:"resetSubmit",value:function(e){this.status.requestInProgress=!1,this.status.loadingActive=!1,e()}},{key:"submitFromInput",value:(a=A(C().mark((function e(){var t,n;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._fileAttachments.completePlaceholders();case 2:t=this._fileAttachments.getAllFileData(),this._textInput.isTextInputEmpty()?this.attemptSubmit({text:"",files:t}):(n=this._textInput.inputElementRef.innerText.trim(),this.attemptSubmit({text:n,files:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"programmaticSubmit",value:(i=A(C().mark((function e(t){var n,r=this;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:"string"==typeof t&&(t=de.processSubmitUserMessage(t)),n={text:t.text},t.files&&(n.files=Array.from(t.files).map((function(e){return{file:e,type:qa.getTypeFromBlob(e)}}))),setTimeout((function(){return r.attemptSubmit(n,!0)}));case 3:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"attemptSubmit",value:(r=A(C().mark((function e(t){var n,r,i,a,s,o,l,c=arguments;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=c.length>1&&void 0!==c[1]&&c[1],e.next=3,null==(r=this._validationHandler)?void 0:r.call(this,n?t:void 0);case 3:if(e.t0=e.sent,e.t1=!1,e.t0!==e.t1){e.next=7;break}return e.abrupt("return");case 7:if(this.changeToLoadingIcon(),this._textInput.clear(),e.t2="boolean"!=typeof this._messages.focusMode&&null!=(i=this._messages.focusMode)&&i.fade,!e.t2){e.next=13;break}return e.next=13,Yt.fadeAnimation(this._messages.elementRef,this._messages.focusMode.fade);case 13:return e.next=15,this.addNewMessage(t);case 15:return this._serviceIO.isWebModel()||this._messages.addLoadingMessage(),o=null==(a=t.files)?void 0:a.map((function(e){return e.file})),l={text:""===t.text?void 0:t.text,files:o},e.next=19,this._serviceIO.callAPI(l,this._messages);case 19:null==(s=this._fileAttachments)||s.removeAllFiles();case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"addNewMessage",value:(n=A(C().mark((function e(t){var n,r,i;return C().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.text,r=t.files,i={role:on.USER_ROLE},n&&(i.text=n),e.t0=r,!e.t0){e.next=8;break}return e.next=7,this._messages.addMultipleFiles(r);case 7:i.files=e.sent;case 8:this._serviceIO.sessionId&&(i._sessionId=this._serviceIO.sessionId),Object.keys(i).length>0&&this._messages.addNewMessage(i);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"stopStream",value:function(){var e;this._abortStream.abort(),null==(e=this._stopClicked)||e.listener(),this._val
2idationHandler&&this.resetSubmit(this._validationHandler)}},{key:"changeToStopIcon",value:function(){this._serviceIO.websocket||(this.elementRef.classList.remove(t.LOADING_CLASS,t.DISABLED_CLASS,t.SUBMIT_CLASS),Er.removeAriaAttributes(this.elementRef),this.changeElementsByState(this._innerElements.stop),this.reapplyStateStyle("stop",["loading","submit"]),this.elementRef.onclick=this.stopStream.bind(this),this.status.loadingActive=!1)}},{key:"changeToLoadingIcon",value:function(){this._serviceIO.websocket||(this._isSVGLoadingIconOverriden||this.changeElementsByState(this._innerElements.loading),this.elementRef.classList.remove(t.SUBMIT_CLASS,t.DISABLED_CLASS),Er.removeAriaDisabled(this.elementRef),this.elementRef.classList.add(t.LOADING_CLASS),Er.addAriaBusy(this.elementRef),this.reapplyStateStyle("loading",["submit"]),this.elementRef.onclick=function(){},this.status.requestInProgress=!0,this.status.loadingActive=!0)}},{key:"changeToSubmitIcon",value:function(){var e=this;this.elementRef.classList.contains(t.SUBMIT_CLASS)||(this.elementRef.classList.remove(t.LOADING_CLASS,t.DISABLED_CLASS),Er.removeAriaAttributes(this.elementRef),this.elementRef.classList.add(t.SUBMIT_CLASS),this.changeElementsByState(this._innerElements.submit),es.resetSubmit(this,this.status.loadingActive),this.elementRef.onclick=function(){var t;e.submitFromInput(),null!=(t=e._microphoneButton)&&t.isActive&&za.toggleSpeechAfterSubmit(e._microphoneButton.elementRef,!!e._stopSTTAfterSubmit)})}},{key:"changeToDisabledIcon",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._alwaysEnabled&&!e?this.changeToSubmitIcon():this.elementRef.classList.contains(t.DISABLED_CLASS)||(this.elementRef.classList.remove(t.LOADING_CLASS,t.SUBMIT_CLASS),Er.removeAriaBusy(this.elementRef),this.elementRef.classList.add(t.DISABLED_CLASS),Er.addAriaDisabled(this.elementRef),this.changeElementsByState(this._innerElements.disabled),this.reapplyStateStyle("disabled",["submit"]),this.elementRef.onclick=function(){})}},{key:"disableSubmitButton",value:function(e,t){var n;e.isSubmitProgrammaticallyDisabled=!1!==t,!this.status.requestInProgress&&!this.status.loadingActive&&(!1===t?null==(n=this._validationHandler)||n.call(this):this.changeToDisabledIcon(!0))}}],[{key:"createButtonContainerElement",value:function(){var e=document.createElement("div");return e.classList.add("input-button"),e}},{key:"createLoadingIconElement",value:function(){var e=document.createElement("div");return e.classList.add("loading-submit-button"),e}},{key:"createStopIconElement",value:function(){var e=document.createElement("div");return e.id="stop-icon",e}}]);var n,r,i,a}(Lr);ts.SUBMIT_CLASS="submit-button",ts.LOADING_CLASS="loading-button",ts.DISABLED_CLASS="disabled-button";var ns=ts,rs=function(e){function t(e,n,r,i){var a;R(this,t),(a=_(this,t,[e,["modal-content","modal-camera-content"],r]))._stopped=!1,a._format="image/png",a._canvas=document.createElement("canvas"),a._canvas.classList.add("camera-modal-canvas");var s=a.addButtonsAndTheirEvents(n),o=s.captureButton,l=s.submitButton;return a._captureButton=o,a._submitButton=l,a._captureIcon=a._captureButton.children[0],a._refreshIcon=Nn.createSVGElement('<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">\n  <path d="M27.1 14.313V5.396L24.158 8.34c-2.33-2.325-5.033-3.503-8.11-3.503C9.902 4.837 4.901 9.847 4.899 16c.001 6.152 5.003 11.158 11.15 11.16 4.276 0 9.369-2.227 10.836-8.478l.028-.122h-3.23l-.022.068c-1.078 3.242-4.138 5.421-7.613 5.421a8 8 0 0 1-5.691-2.359A7.993 7.993 0 0 1 8 16.001c0-4.438 3.611-8.049 8.05-8.049 2.069 0 3.638.58 5.924 2.573l-3.792 3.789H27.1z"/>\n</svg>\n'),a._refreshIcon.classList.add("modal-svg-button-icon","modal-svg-refresh-icon"),"jpeg"===(null==i?void 0:i.format)&&(a._format="image/jpeg"),null!=i&&i.dimensions&&(a._dimensions=i.dimensions),a._contentRef.appendChild(a._canvas),a.extensionCloseCallback=a.stop,a}return x(t,e),N(t,[{key:"addButtonsAndTheirEvents",value:function(e){var t=Ka.createSVGButton('<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">\n  <path d="M0 16q0 3.264 1.28 6.208t3.392 5.12 5.12 3.424 6.208 1.248 6.208-1.248 5.12-3.424 3.392-5.12 1.28-6.208-1.28-6.208-3.392-5.12-5.088-3.392-6.24-1.28q-3.264 0-6.208 1.28t-5.12 3.392-3.392 5.12-1.28 6.208zM4 16q0-3.264 1.6-6.016t4.384-4.352 6.016-1.632 6.016 1.632 4.384 4.352 1.6 6.016-1.6 6.048-4.384 4.352-6.016 1.6-6.016-1.6-4.384-4.352-1.6-6.048z"></path>\n</svg>\n');t.classList.add("modal-svg-camera-button"),t.children[0].classList.add("modal-svg-camera-icon");var n=this.addCloseButton('<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n  <path d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"/>\n</svg>',!0);n.classList.add("modal-svg-close-button"),n.children[0].classList.add("modal-svg-close-icon");var r=Ka.createSVGButton('<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n  <path d="M4.89163 13.2687L9.16582 17.5427L18.7085 8" stroke="#000000" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>');return r.classList.add("modal-svg-submit-button"),this.addButtons(t,r),this.addButtonEvents(t,n,r,e),{captureButton:t,submitButton:r}}},{key:"addButtonEvents",value:function(e,t,n,r){var i=this;e.onclick=function(){i.capture()},t.addEventListener("click",this.stop.bind(this)),n.onclick=function(){var e=i.getFile();e&&Wa.addFilesToType([e],[r]),i.stop(),i.close()}}},{key:"stop",value:function(){var e=this;
2this._mediaStream&&this._mediaStream.getTracks().forEach((function(e){return e.stop()})),this._stopped=!0,setTimeout((function(){e._captureButton.replaceChildren(e._captureIcon),e._captureButton.classList.replace("modal-svg-refresh-button","modal-svg-camera-button");var t=e._canvas.getContext("2d");null==t||t.clearRect(0,0,e._canvas.width,e._canvas.height)}),Ka.MODAL_CLOSE_TIMEOUT_MS)}},{key:"start",value:function(){var e=this;this._dataURL=void 0,this._submitButton.classList.add("modal-svg-submit-disabled"),this._stopped=!1,navigator.mediaDevices.getUserMedia({video:this._dimensions||!0}).then((function(t){if(e._mediaStream=t,!e.isOpen())return e.stop();var n=document.createElement("video");n.srcObject=t,n.play(),requestAnimationFrame(e.updateCanvas.bind(e,n,e._canvas))})).catch((function(t){console.error(t),e.stop(),e.close()}))}},{key:"capture",value:function(){this._dataURL?(this._captureButton.replaceChildren(this._captureIcon),this._captureButton.classList.replace("modal-svg-refresh-button","modal-svg-camera-button"),this._submitButton.classList.add("modal-svg-submit-disabled"),this._dataURL=void 0):(this._captureButton.replaceChildren(this._refreshIcon),this._captureButton.classList.replace("modal-svg-camera-button","modal-svg-refresh-button"),this._submitButton.classList.remove("modal-svg-submit-disabled"),this._dataURL=this._canvas.toDataURL())}},{key:"getFile",value:function(){if(this._dataURL){for(var e=atob(this._dataURL.split(",")[1]),t=new Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);var r=new Uint8Array(t),i=new Blob([r],{type:this._format}),a="image/jpeg"===this._format?"jpeg":"png",s=Xa.getFileName(this._newFilePrefix||"photo",a);return new File([i],s,{type:i.type})}}},{key:"updateCanvas",value:function(e,t){if(!this._stopped){if(!this._dataURL){t.width=e.videoWidth,t.height=e.videoHeight;var n=t.getContext("2d");null==n||n.drawImage(e,0,0,t.width,t.height)}requestAnimationFrame(this.updateCanvas.bind(this,e,t))}}},{key:"openCameraModal",value:function(e){this.displayModalElements(),e.start()}}],[{key:"createCameraModalFunc",value:function(e,n,r,i){var a=new t(e,n,r,i);return a.openCameraModal.bind(a,a)}}])}(Ka),is=function(e){function t(e,n,r){var i,a,s,o,l;R(this,t);var c=null==(a=null==r?void 0:r.button)?void 0:a.position,u=(null==(l=null==(o=null==(s=null==r?void 0:r.button)?void 0:s.styles)?void 0:o.text)?void 0:l.content)||"Photo",d=(i=_(this,t,[t.createButtonElement(),'<?xml version="1.0" encoding="utf-8"?>\n<svg viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">\n  <path d="M29 7h-4.599l-2.401-4h-12l-2.4 4h-4.6c-1 0-3 1-3 2.969v16.031c0 1.657 1.5 3 2.792 3h26.271c1.313 0 2.938-1.406 2.938-2.968v-16.032c0-1-1-3-3-3zM30 26.032c0 0.395-0.639 0.947-0.937 0.969h-26.265c-0.232-0.019-0.797-0.47-0.797-1v-16.031c0-0.634 0.851-0.953 1-0.969h5.732l2.4-4h9.802l1.785 3.030 0.55 0.97h5.731c0.705 0 0.99 0.921 1 1v16.032zM16 10c-3.866 0-7 3.134-7 7s3.134 7 7 7 7-3.134 7-7-3.134-7-7-7zM16 22c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z"></path>\n</svg>',c,(null==r?void 0:r.button)||{},u])).createInnerElementsForStates(i.customStyles);return r&&i.addClickEvent(e,n,r.modalContainerStyle,r.files),i.changeElementsByState(d.styles),i.reapplyStateStyle("styles"),i}return x(t,e),N(t,[{key:"createInnerElementsForStates",value:function(e){return{styles:this.createInnerElements("camera-icon","styles",e)}}},{key:"addClickEvent",value:function(e,t,n,r){var i=rs.createCameraModalFunc(e,t,n,r);this.elementRef.onclick=i}}],[{key:"createButtonElement",value:function(){var e=document.createElement("div");return e.classList.add("input-button"),e}}])}(Lr),as=function(){function e(t,n,r,i){R(this,e),this.elementRef=e.createPanelElement(t.inputAreaStyle);var a={},s=this.createFileUploadComponents(t,r,i,a),o=new Y(t,r,s);t.speechToText&&!a.microphone&&(a.microphone={button:new za(t,o,n.addNewErrorMessage.bind(n))});var l=new ns(t,o,n,r,s,a);o.submit=l.submitFromInput.bind(l),Ya.attach(t,r,o,s,l),t.submitUserMessage=l.programmaticSubmit.bind(l),a.submit={button:l},t.customButtons&&Ei.add(t,a),e.addElements(this.elementRef,o,a,i,s,t.dropupStyles)}return N(e,[{key:"createFileUploadComponents",value:function(t,n,r,i){var a,s,o,l,c=new Wa(this.elementRef,t.attachmentContainerStyle,n.demo);if(e.createUploadButtons(t,n.fileTypes||{},c,r,i),null!=(a=n.camera)&&a.files){var u=(null==(s=i.images)?void 0:s.fileType)||c.addT
2ype(t,n.camera.files,"images");i.camera={button:new is(r,u,n.camera)}}if(null!=(o=n.recordAudio)&&o.files){var d=(null==(l=i.audio)?void 0:l.fileType)||c.addType(t,n.recordAudio.files,"audio");i.microphone={button:new Qa(d,n.recordAudio)}}return Za.isEnabled(c,t.dragAndDrop)&&Za.create(r,c,t.dragAndDrop),c}}],[{key:"createPanelElement",value:function(e){var t=document.createElement("div");return t.id="input",Object.assign(t.style,e),t}},{key:"createUploadButtons",value:function(e,t,n,r,i){Object.keys(t).forEach((function(a){var s=a,o=t[s];if(o.files){var l=n.addType(e,o.files,s),c=Li[s],u=c.id,d=c.svgString,h=c.dropupText,p=new Ja(r,l,o,u,d,h);i[s]={button:p,fileType:l}}}))}},{key:"addElements",value:function(e,t,n,r,i,a){ie.addElements(e,t.elementRef);var s=_i.create(),o=Ii.addButtons(s,n,r,a);bi.set(t.inputElementRef,s,i.elementRef,o),_i.add(e,s)}}])}(),ss=function(){function e(){R(this,e)}return N(e,null,[{key:"createElements",value:function(e,t,n){var r=document.createElement("div");r.id="chat-view";var i=new vi(e,t,n);t.websocket&&Sn.createConnection(t,i);var a=new as(e,i,t,r);return ie.addElements(r,i.elementRef,a.elementRef),r}},{key:"render",value:function(t,n,r,i){var a=e.createElements(t,r,i);n.replaceChildren(a),r.isCustomView()&&r.setUpView(a,n)}}])}(),os=Object.defineProperty,ls=function(e,t,n,r){for(var i,a=void 0,s=e.length-1;s>=0;s--)(i=e[s])&&(a=i(t,n,a)||a);return a&&os(t,n,a),a},cs=function(e){function t(){var e;return R(this,t),(e=_(this,t)).getMessages=function(){return[]},e.submitUserMessage=function(){return console.warn("submitUserMessage failed - please wait for chat view to render before calling this property.")},e.addMessage=function(){return console.warn("addMessage failed - please wait for chat view to render before calling this property.")},e.updateMessage=function(){},e.clearMessages=function(){},e.focusInput=function(){return X.focusFromParentElement(e._elementRef)},e.refreshMessages=function(){},e.scrollToBottom=function(){},e.disableSubmitButton=function(){},e.setPlaceholderText=function(){},e._hasBeenRendered=!1,e._auxiliaryStyleApplied=!1,e._elementRef=document.createElement("div"),e._elementRef.id="container",e.attachShadow({mode:"open"}).appendChild(e._elementRef),H.apply('#validate-property-key-view{height:100%;position:relative;display:flex;justify-content:center;align-items:center;padding:8px}#loading-validate-key-property{display:inline-block;width:50px;height:50px}#loading-validate-key-property:after{content:" ";display:block;width:38px;height:38px;margin:1px;border-radius:50%;border:5px solid #5fb2ff;border-color:#5fb2ff transparent #5fb2ff transparent;animation:loading-spinner 1.4s linear infinite}#deep-chat-openai-realtime-container{height:100%;width:100%}#deep-chat-openai-realtime-avatar-container{height:60%;width:100%;display:flex;justify-content:center;align-items:center}#deep-chat-openai-realtime-avatar{border-radius:50%;height:110px;border:1px solid rgb(215,215,215);padding:8px;-webkit-user-select:none;user-select:none;margin-top:20px}#deep-chat-openai-realtime-buttons-container{height:40%;display:flex;position:relative}.deep-chat-openai-realtime-button-container{height:100%;width:50%;display:flex;justify-content:center;align-items:center}.deep-chat-openai-realtime-button{width:70px;height:70px;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer}.deep-chat-openai-realtime-button-default{background-color:#e3e3e3}.deep-chat-openai-realtime-button-default:hover{background-color:#d4d4d4}.deep-chat-openai-realtime-button-default:active{background-color:#c5c5c5}.deep-chat-openai-realtime-button-loading{opacity:.7;pointer-events:none}.deep-chat-openai-realtime-microphone-active{background-color:#ffe7e7}.deep-chat-openai-realtime-microphone-active:hover{background-color:#ffdede}.deep-chat-openai-realtime-microphone-active:active{background-color:#ffd2d2}.deep-chat-openai-realtime-microphone>*{height:30px;width:30px}.deep-chat-openai-realtime-microphone-active>*{filter:brightness(0) saturate(100%) invert(35%) sepia(60%) saturate(1360%) hue-rotate(325deg) brightness(95%) contrast(92%)}.deep-chat-openai-realtime-toggle>*{height:32px;width:32px;padding-left:3px;filter:brightness(0) saturate(100%) invert(22%) sepia(0%) saturate(4537%) hue-rotate(208deg) brightness(105%) contrast(91%)}.deep-chat-openai-realtime-button-unavailable{opacity:.45;pointer-events:none}#deep-chat-openai-realtime-error{color:red;position:absolute;top:calc(50% + 40px);left:50%;transform:translate(-50%,-50%);font-size:17px}#deep-chat-openai-realtime-loading{position:absolute;font-size:15px;top:50%;left:50%;transform:translate(-50%,-50%)}#insert-key-view{height:100%;position:relative}#insert-key-contents{text-align:center;position:absolute;top:44%;left:50%;transform:translate(-50%,-50%);width:82%;display:flex;max-width:700px}#insert-key-title{margin-bottom:15px}#insert-key-input-container{margin-right:2.7em;width:calc(100% - 80px)}#insert-key-input{padding:.3em 1.7em .3em .3em;border-width:1px;border-style:solid;border-radius:3px;width:100%;font-size:inherit}.insert-key-input-valid{border-color:gray}.insert-key-input-invalid{border-color:red}#visibility-icon-container{position:relative;float:right;cursor:pointer;-webkit-user-select:none;user-select:none}.visibility-icon{filter:brightness(0) saturate(100%) invert(63%) sepia(1%) saturate(9%) hue-rotate(43deg) brightness(98%) contrast(92%);position:absolute;right:-1.7em;top:-1.43em}#visible-icon{top:-1.4em}.visibility-icon:hover{filter:unset}.visibility-icon>*{pointer-events:none}#start-button{border:1px solid grey;color:#454545;border-radius:4px;width:3em;display:flex;justify-content:center;align-items:center;cursor:pointer;padding:.28em .3em;-webkit-user-select:none;user-select:none;background-color:#fff}#start-button:hover{background-color:#f2f2f2}#start-button:active{background-color:#d2d2d2}#insert-key-help-text-container{width:100%;position:absolute;margin-top:32px;margin-bottom:20px}#insert-key-help-text-contents{width:100%;position:absolute}#insert-key-input-invalid-text{display:block;margin-top:1em;margin-bottom:.5em;color:red}.insert-key-input-help-text{display:block;margin-top:16px}#loading-key{display:inline-block;width:16px;height:16px}#loading-key:after{content:" ";display:block;width:11px;height:11px;margin:1px;border-radius:50%;border:2px solid #0084ff;border-color:#0084ff transparent #0084ff transparent;animation:loading-spinner 1.2s linear infinite}#error-view{color:red;font-size:1.2em;line-height:1.3em;margin-top:-5px;text-align:center;height:100%;display:flex;justify-content:center;align-items:center;padding-left:8px;padding-right:8px}@keyframes loading-spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.intro-panel{position:absolute;display:flex;justify-content:center;right:0;bottom:0;left:0;margin:auto;height:fit-content;top:-2.5em}#internal-intro-panel{width:250px;height:min-content;display:block;border-radius:5px;overflow:auto;border:1px solid rgb(203,203,203);padding:10px;max-height:calc(100% - 6.8em)}#internal-intro-panel>p{margin-block-start:.8em;margin-block-end:.8em}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!\n  Theme: a11y-dark\n  Author: @ericwbailey\n  Maintainer: @ericwbailey\n\n  Based on the Tomorrow Night Eighties theme: https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css\n*/.hljs{background:#2b2b2b;color:#f8f8f2}.hljs-comment,.hljs-quote{color:#d4d0ab}.hljs-deletion,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#ffa07a}.hljs-built_in,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-type{color:#f5ab35}.hljs-attribute{color:gold}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#abe338}.hljs-section,.hljs-title{color:#00e0e0}
2.hljs-keyword,.hljs-selector-tag{color:#dcc6e0}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}@media screen and (-ms-high-contrast: active){.hljs-addition,.hljs-attribute,.hljs-built_in,.hljs-bullet,.hljs-comment,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-quote,.hljs-string,.hljs-symbol,.hljs-type{color:highlight}.hljs-keyword,.hljs-selector-tag{font-weight:700}}#messages{overflow:auto}.outer-message-container:last-child{margin-bottom:5px}.inner-message-container{display:flex;margin-left:auto;margin-right:auto;width:calc(97.5% - 24px);max-width:100%}.message-bubble{margin-top:10px;word-wrap:break-word;width:fit-content;max-width:60%;border-radius:10px;padding:.42em .55em;height:fit-content;line-height:1.26em}.user-message-text{color:#fff;background-color:#0084ff;margin-right:0;margin-left:auto}.ai-message-text{color:#000;background-color:#e4e6eb;margin-left:0;margin-right:auto}.deep-chat-last-group-messages-active{height:100%}.loading-history-message-full-view{position:absolute;height:70%;width:100%;display:flex;align-items:center}.loading-history-message-small{height:20px;margin-bottom:30px}.loading-history-message-small>div>div{scale:.6}.loading-history-message{margin-top:0;width:100%;max-width:100%;display:flex;justify-content:center;background-color:unset}.loading-history{width:70px}.loading-history div{position:absolute;width:var(--loading-history-width);height:var(--loading-history-height);margin:var(--loading-history-margin);border:var(--loading-history-border);border-radius:50%;animation:loading-spinner 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:var(--loading-history-color) transparent transparent transparent}.loading-history div:nth-child(1){animation-delay:-.45s}.loading-history div:nth-child(2){animation-delay:-.3s}.loading-history div:nth-child(3){animation-delay:-.15s}.html-message{max-width:unset}.error-message-text{margin:14px auto 10px;background-color:#f4c0c0;color:#474747;text-align:center;max-width:95%}.deep-chat-loading-message-dots-container{width:1em;padding:.6em .75em .6em 1.3em}.loading-message-dots{position:relative;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite linear alternate;animation-delay:.5s}.loading-message-dots:before,.loading-message-dots:after{content:"";display:inline-block;position:absolute;top:0}.loading-message-dots:before{left:-.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:0s}.loading-message-dots:after{left:.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:1s}@keyframes loading-message-dots{0%{background-color:var(--loading-message-color)}50%,to{background-color:var(--loading-message-color-fade)}}.message-bubble>p:first-child{margin-top:0}.message-bubble>p:last-child{margin-bottom:0}pre{overflow:auto;display:block;word-break:break-all;word-wrap:break-word;border-radius:7px;background:#2b2b2b;color:#f8f8f2;margin-top:.8em;margin-bottom:.8em;padding:.6em;font-size:.9em;line-height:1.5em}.image-message{padding:0;display:flex;background-color:#ddd}.image-message>*,.image-message>*>*{width:100%;border-radius:8px;display:flex}.audio-message{width:60%;max-width:300px;height:2.2em;max-height:54px;padding:0;background-color:unset}.audio-player{width:100%;height:100%}.audio-player-safari{height:fit-content;width:40px}.audio-player-safari-left{float:left}.audio-player-safari-right{float:right}.any-file-message{padding:1px}.any-file-message-contents{display:flex}.any-file-message-icon-container{width:1.3em;min-width:1.3em;position:relative;border-radius:4px;margin-left:6px;margin-right:2px}.any-file-message-icon{background-color:#fff;border-radius:4px;position:absolute;width:1em;height:1.25em;padding:1px;margin-top:auto;margin-bottom:auto;top:0;bottom:0}.any-file-message-text{padding-top:5px;overflow-wrap:anywhere;padding-bottom:5px;padding-right:7px}.message-bubble>a{color:inherit}.left-item-position{margin-right:10px}.right-item-position{margin-left:10px}.role-hidden{display:none}.avatar{padding-top:5px;width:1.5em;height:1.5em;border-radius:1px}.avatar-container{margin-top:9px}.name{margin-top:16px;font-size:15px}#drag-and-drop{position:absolute;display:none;z-index:10;
2height:calc(100% - 10px);width:calc(100% - 10px);background-color:#70c6ff4d;border:5px dashed #6dafff}#file-attachment-container{position:absolute;height:3.6em;width:calc(80% - 4px);top:-2.5em;border-radius:5px;overflow:auto;text-align:left;background-color:#d7d7d73b;padding-left:4px}.file-attachment{width:2.85em;height:2.85em;display:inline-flex;margin-right:.6em;margin-bottom:.44em;margin-top:4px;position:relative;background-color:#fff;border-radius:5px}.image-attachment{width:100%;height:100%;object-fit:cover;border-radius:5px}.border-bound-attachment{width:calc(100% - 2px);height:calc(100% - 2px);border:1px solid #c3c3c3;border-radius:5px;overflow:hidden}.border-bound-attachment-safari{width:calc(100% - 1px);height:calc(100% - 1px)}.audio-attachment-icon-container{cursor:pointer}.audio-attachment-icon-container:hover{background-color:#f8f8f8}.attachment-icon{left:0;right:0;bottom:0;top:2px;margin:auto;position:absolute;width:25px;-webkit-user-select:none;user-select:none}.not-removable-attachment-icon{top:0;right:0;bottom:0;left:0}.play-icon{filter:brightness(0) saturate(100%) invert(17%) sepia(0%) saturate(1392%) hue-rotate(67deg) brightness(98%) contrast(97%)}.stop-icon{filter:brightness(0) saturate(100%) invert(29%) sepia(90%) saturate(1228%) hue-rotate(198deg) brightness(93%) contrast(98%)}.audio-placeholder-text-3-digits{padding-left:.26rem}.audio-placeholder-text-4-digits{padding-left:.1rem}.any-file-attachment{padding:2px 0}.file-attachment-text-container{position:absolute;width:inherit;display:flex;align-items:center;height:100%;top:-1px}.audio-placeholder-text-3-digits-container{padding-top:1px;cursor:default}.any-file-attachment-text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding-left:.13em;margin-left:auto;margin-right:auto}.remove-file-attachment-button{height:1.25em;width:1.25em;border:1px solid #cfcfcf;border-radius:25px;background-color:#fff;top:-4px;right:-5px;position:absolute;display:flex;justify-content:center;cursor:pointer;-webkit-user-select:none;user-select:none}.remove-file-attachment-button:hover{background-color:#e4e4e4}.remove-file-attachment-button:active{background-color:#d7d7d7}.x-icon{color:#4e4e4e;top:-.075em;position:relative;font-size:1.05em}.modal{display:none;flex-direction:column;align-items:center;justify-content:center;position:absolute;width:80%;max-width:420px;max-height:80%;margin:auto;top:0;right:0;bottom:0;left:0;z-index:3}.modal-content{border-top:1px solid rgb(217,217,217);border-left:1px solid rgb(217,217,217);border-right:1px solid rgb(217,217,217);border-top-left-radius:inherit;border-top-right-radius:inherit;background-color:#fff;overflow-y:auto;height:fit-content;max-height:calc(100% - 3.3em);width:100%}.modal-content>p{margin-left:1em;margin-right:1em}.modal-content>ul{margin-right:1em}.modal-button-panel{height:3.3em;border:1px solid;border-color:rgb(223,223,223) rgb(217,217,217) rgb(217,217,217);border-bottom-left-radius:inherit;border-bottom-right-radius:inherit;background-color:#fff;text-align:center;justify-content:center;display:flex;width:100%}.modal-button{min-width:2.5em;text-align:center;color:#fff;border-radius:5px;padding:.4em .4em .3em;height:1.25em;background-color:#3279b2;top:0;bottom:0;cursor:pointer;-webkit-user-select:none;user-select:none;margin:auto .31em}.modal-button:hover{background-color:#276da7}.modal-button:active{background-color:#1b5687}.modal-svg-button{padding:0 0 2px;width:2em;height:1.8em}.modal-svg-button-icon{width:100%;height:100%;filter:brightness(0) saturate(100%) invert(100%) sepia(15%) saturate(4%) hue-rotate(346deg) brightness(101%) contrast(102%)}#modal-background-panel{position:absolute;width:100%;height:100%;background-color:#00000042;z-index:2;display:none}.show-modal-background{animation:fadeInBackground .3s ease-in-out}@keyframes fadeInBackground{0%{opacity:0}to{opacity:1}}.show-modal{animation:fadeInModal .3s ease-in-out}@keyframes fadeInModal{0%{opacity:0;scale:.95}to{opacity:1;scale:1}}.hide-modal-background{animation:fadeOutBackground .2s ease-in-out}@keyframes fadeOutBackground{0%{opacity:1}to{opacity:0}
2}.hide-modal{animation:fadeOutModal .2s ease-in-out}@keyframes fadeOutModal{0%{opacity:1;scale:1}to{opacity:0;scale:.95}}.modal-camera-content{overflow:hidden;text-align:center;border:unset;height:100%;background-color:#2a2a2a;display:flex;justify-content:center}.camera-modal-canvas{max-width:100%;max-height:100%;margin-top:auto;margin-bottom:auto}.modal-svg-submit-button{background-color:green}.modal-svg-submit-button:hover{background-color:#007500}.modal-svg-submit-button:active{background-color:#006500}.modal-svg-submit-disabled{pointer-events:none;background-color:#747474}.modal-svg-close-button{height:1.56em;padding-top:.37em;padding-bottom:0;background-color:#c13e3e}.modal-svg-close-button:hover{background-color:#b43434}.modal-svg-close-button:active{background-color:#972929}.modal-svg-close-icon{width:80%;height:80%}.modal-svg-camera-button{height:1.6em;padding-top:.38em;padding-bottom:0}.modal-svg-camera-icon{height:76%}.modal-svg-refresh-icon{height:105%}.modal-svg-refresh-button{height:1.66em;padding-top:.11em;padding-bottom:.21em}.input-button-container{position:relative;z-index:1}.inside-right{position:absolute;right:calc(10% + .35em);bottom:.85em}.inside-left{position:absolute;left:calc(10% + .35em);bottom:.85em}.outside-left{position:absolute;right:calc(11px - .55em);bottom:.88em}.outside-right{position:absolute;left:calc(11px - .55em);bottom:.88em}#upload-images-icon{position:absolute;pointer-events:none;width:1.45em;height:1.45em;left:.11em;bottom:.08em;filter:brightness(0) saturate(100%) invert(43%) sepia(0%) saturate(740%) hue-rotate(77deg) brightness(99%) contrast(92%)}#upload-gifs-icon{position:absolute;pointer-events:none;width:1.5em;height:1.48em;left:.07em;bottom:.08em;filter:brightness(0) saturate(100%) invert(49%) sepia(0%) saturate(2586%) hue-rotate(12deg) brightness(93%) contrast(90%)}#upload-audio-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.17em;bottom:.2em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%);transform:scaleX(.95)}#camera-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.23em;bottom:.2em;filter:brightness(0) saturate(100%) invert(52%) sepia(0%) saturate(161%) hue-rotate(164deg) brightness(91%) contrast(92%);transform:scaleX(.95)}#upload-mixed-files-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.25em;bottom:.2em;filter:brightness(0) saturate(100%) invert(53%) sepia(0%) saturate(36%) hue-rotate(74deg) brightness(98%) contrast(93%);transform:scaleX(.95)}#interim-text{color:gray}#microphone-button{padding-top:.5px}.outer-button-container>#microphone-button{padding-bottom:1px}#microphone-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.25em;bottom:.25em}.default-microphone-icon{filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%)}.active-microphone-icon{filter:brightness(0) saturate(100%) invert(10%) sepia(97%) saturate(7495%) hue-rotate(0deg) brightness(101%) contrast(107%);border-radius:10px}.command-microphone-icon{filter:brightness(0) saturate(100%) invert(42%) sepia(96%) saturate(1067%) hue-rotate(77deg) brightness(99%) contrast(102%)}.unsupported-microphone{display:none}#submit-icon{height:100%;filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%);width:1.21em}#stop-icon{background-color:#acacac;position:absolute;width:.95em;height:.95em;left:.35em;bottom:.35em;border-radius:2px}.submit-button-enlarged{scale:1.1;margin-right:.3em;margin-left:.3em}.loading-submit-button{position:relative;left:calc(-9990px + .275em);width:.22em;height:.22em;border-radius:5px;background-color:#848484;color:#848484;box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484;animation:loading-submit-button 1.5s infinite linear;bottom:-.75em}@keyframes loading-submit-button{0%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}16.667%{box-shadow:9990px -6px #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}33.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}50%{box-shadow:9990px 0 #848484,calc(9990px + .44em) -6px 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}66.667%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}83.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) -6px 0 0 #848484}to{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}}.input-button{border-radius:4px;cursor:pointer;margin-bottom:.2em;-webkit-user-select:none;user-select:none}.input-button-svg{width:1.65em;height:1.65em}.input-button-svg-text{padding:1px;height:1.65em;display:flex}.input-button-svg-text>svg{padding:.22rem}.input-button-svg-text>div{margin-left:2px}.input-button:hover,.input-button:focus-visible{background-color:#9c9c9c2e}.input-button:active{background-color:#9c9c9c5e}.input-button:active:not(:hover){background-color:transparent}
2.loading-button{cursor:auto}.loading-button:hover{background-color:unset}.text-button{filter:unset!important;display:flex;justify-content:center;align-items:center;margin-left:4px;margin-right:4px;height:1.6em;width:max-content}#custom-icon{height:100%;width:1.2em}.custom-button-container-default{color:#505050}.custom-button-container-default>.dropup-menu-item-icon{color:unset}.custom-button-container-default>svg{filter:brightness(0) saturate(100%) invert(39%) sepia(1%) saturate(0%) hue-rotate(83deg) brightness(93%) contrast(90%)}.custom-button-container-default>.dropup-menu-item-icon>svg{position:absolute;left:.2em}.custom-button-container-active{background-color:#edf7ff;color:#0285ff}.custom-button-container-active:hover,.custom-button-container-active:focus-visible{background-color:#def0ff}.custom-button-container-active:active{background-color:#d2eaff}.custom-button-container-active>svg{filter:brightness(0) saturate(100%) invert(32%) sepia(34%) saturate(4196%) hue-rotate(196deg) brightness(107%) contrast(104%)}.custom-button-container-disabled{color:#aeaeae;cursor:auto}.custom-button-container-disabled>div{pointer-events:none}.custom-button-container-disabled:hover,.custom-button-container-disabled:focus-visible{background-color:transparent}.custom-button-container-disabled:active{background-color:transparent}.custom-button-container-disabled>svg{filter:brightness(0) saturate(100%) invert(67%) sepia(0%) saturate(818%) hue-rotate(28deg) brightness(102%) contrast(100%)}#text-input-container{background-color:#fff;width:80%;display:flex;border:1px solid #0000001a;border-radius:5px;margin-top:.8em;margin-bottom:.8em;box-shadow:#959da533 0 1px 12px;overflow-y:auto;max-height:200px;position:relative}.text-input-container-left-adjustment{margin-left:1.5em}.text-input-container-right-adjustment{margin-right:1.5em}.text-input-container-left-small-adjustment{margin-left:1.1em}.text-input-container-left-small-adjustment>.outside-left{right:calc(14px - .55em)}.text-input-container-right-small-adjustment{margin-right:1.1em}.text-input-container-right-small-adjustment>.outside-right{left:calc(14px - .55em)}#text-input{text-align:left;outline:none;word-wrap:break-word;line-break:auto}.text-input-styling{padding:.4em .5em;overflow:overlay;width:100%}.text-input-inner-left-adjustment{padding-left:2.2em}.text-input-inner-right-adjustment{padding-right:2em}.text-input-disabled{pointer-events:none;-webkit-user-select:none;user-select:none}[contenteditable]:empty:before{content:attr(deep-chat-placeholder-text);pointer-events:none}[contenteditable][textcolor]:empty:before{color:gray}.outside-right>#dropup-menu,.inside-right>#dropup-menu{right:0}#dropup-icon{position:absolute;pointer-events:none;width:1.16em;height:1.2em;left:.265em;bottom:.43em;filter:brightness(0) saturate(100%) invert(54%) sepia(0%) saturate(724%) hue-rotate(6deg) brightness(92%) contrast(90%)}.dropup-button>*{pointer-events:none}#dropup-menu{background-color:#fff;position:absolute;transform:translateY(-100%);border-radius:5px;z-index:1;top:-.49em;box-shadow:#0003 -1px 2px 10px,#0000001a 0 2px 4px;cursor:pointer;-webkit-user-select:none;user-select:none}.dropup-menu-item{height:1.4em;padding:.28em .84em .28em .35em;display:flex;position:relative}.dropup-menu-item:hover,.dropup-menu-item:focus-visible{background-color:#f3f3f3}.dropup-menu-item:active{background-color:#ebebeb}.dropup-menu-item:active:not(:hover){background-color:transparent}.dropup-menu-item:first-child{padding-top:.49em;border-top-left-radius:inherit;border-top-right-radius:inherit}.dropup-menu-item:last-child{padding-bottom:.45em;border-bottom-left-radius:inherit;border-bottom-right-radius:inherit}.dropup-menu-item-icon{width:1.39em;position:relative}.dropup-menu-item-icon>svg{bottom:0!important;top:0!important;margin-bottom:auto;margin-top:auto}#dropup-menu-item-icon-element-custom{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.28em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%)}.dropup-menu-item-text{margin-left:.56em;margin-top:.08em;width:max-content}#input{width:100%;display:inline-flex;text-align:center;margin-left:auto;margin-right:auto;margin-top:auto;position:relative;justify-content:center}#chat-view{height:100%;display:grid;grid-template-columns:100%}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background-color:#d0d0d0;border-radius:5px}::-webkit-scrollbar-track{background-color:#f2f2f2}.deep-chat-web-model-button{margin-top:10px;margin-bottom:5px;margin-left:1px}:host{all:initial;display:table-cell}#container{height:inherit;width:inherit;overflow:hidden}
2',e.shadowRoot),setTimeout((function(){e._hasBeenRendered||e.onRender()}),20),e}return x(t,e),N(t,[{key:"changeToChatView",value:function(){this._activeService&&(this._activeService.validateKeyProperty=!1),this.onRender()}},{key:"onRender",value:function(){var e;z.attemptAppendStyleSheetToHead(this.style),de.processConnect(this),(!this._activeService||this._activeService.demo)&&(this._activeService=li.create(this)),this.auxiliaryStyle&&!this._auxiliaryStyleApplied&&(H.apply(this.auxiliaryStyle,this.shadowRoot),this._auxiliaryStyleApplied=!0),H.applyDefaultStyleToComponent(this.style,this.chatStyle),de.checkForContainerStyles(this,this._elementRef),this._activeService.key&&this._activeService.validateKeyProperty?B.render(this._elementRef,this.changeToChatView.bind(this),this._activeService):this._activeService instanceof Ln&&!this._activeService.key?this._activeService instanceof Ln&&Bn.render(this._elementRef,this.changeToChatView.bind(this),this._activeService):(null!==(e=this._childElement)&&void 0!==e||(this._childElement=this.children[0]),ss.render(this,this._elementRef,this._activeService,this._childElement)),this._hasBeenRendered||$t.onRender(this),this._hasBeenRendered=!0}},{key:"disconnectedCallback",value:function(){Hn.chat=void 0}}])}(Pn);ls([di("object")],cs.prototype,"connect"),ls([di("object")],cs.prototype,"directConnection"),ls([di("object")],cs.prototype,"webModel"),ls([di("object")],cs.prototype,"requestBodyLimits"),ls([di("function")],cs.prototype,"requestInterceptor"),ls([di("function")],cs.prototype,"responseInterceptor"),ls([di("function")],cs.prototype,"validateInput"),ls([di("function")],cs.prototype,"loadHistory"),ls([di("object")],cs.prototype,"chatStyle"),ls([di("object")],cs.prototype,"attachmentContainerStyle"),ls([di("object")],cs.prototype,"dropupStyles"),ls([di("object")],cs.prototype,"inputAreaStyle"),ls([di("object")],cs.prototype,"textInput"),ls([di("object")],cs.prototype,"submitButtonStyles"),ls([di("object")],cs.prototype,"customButtons"),ls([di("string")],cs.prototype,"auxiliaryStyle"),ls([di("array")],cs.prototype,"history"),ls([di("object")],cs.prototype,"introMessage"),ls([di("object")],cs.prototype,"avatars"),ls([di("object")],cs.prototype,"names"),ls([di("object")],cs.prototype,"displayLoadingBubble"),ls([di("object")],cs.prototype,"errorMessages"),ls([di("object")],cs.prototype,"messageStyles"),ls([di("object")],cs.prototype,"textToSpeech"),ls([di("object")],cs.prototype,"speechToText"),ls([di("object")],cs.prototype,"images"),ls([di("object")],cs.prototype,"gifs"),ls([di("object")],cs.prototype,"camera"),ls([di("object")],cs.prototype,"audio"),ls([di("object")],cs.prototype,"microphone"),ls([di("object")],cs.prototype,"mixedFiles"),ls([di("object")],cs.prototype,"dragAndDrop"),ls([di("object")],cs.prototype,"introPanelStyle"),ls([di("object")],cs.prototype,"htmlClassUtilities"),ls([di("object")],cs.prototype,"remarkable"),ls([di("object")],cs.prototype,"focusMode"),ls([di("function")],cs.prototype,"onMessage"),ls([di("function")],cs.prototype,"onClearMessages"),ls([di("function")],cs.prototype,"onComponentRender"),ls([di("function")],cs.prototype,"onError"),ls([di("object")],cs.prototype,"demo"),ls([di("object")],cs.prototype,"_insertKeyViewStyles"),customElements.define("deep-chat",cs);class us extends Error{}class ds extends us{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class hs extends us{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class ps extends us{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class fs extends us{}class ms extends us{constructor(e){super(`Invalid unit ${e}`)}}class gs extends us{}class vs extends us{constructor(){super("Zone is an abstract class")}}const ys="numeric",bs="short",_s="long",ws={year:ys,month:ys,day:ys},ks={year:ys,month:bs,day:ys},Ss={year:ys,month:bs,day:ys,weekday:bs},xs={year:ys,month:_s,day:ys},Es={year:ys,month:_s,day:ys,weekday:_s},Cs={hour:ys,minute:ys},Ts={hour:ys,minute:ys,second:ys},As={hour:ys,minute:ys,second:ys,timeZoneName:bs},Ms={hour:ys,minute:ys,second:ys,timeZoneName:_s},Is={hour:ys,minute:ys,hourCycle:"h23"},Ls={hour:ys,minute:ys,second:ys,hourCycle:"h23"},Os={hour:ys,minute:ys,second:ys,hourCycle:"h23",timeZoneName:bs},Rs={hour:ys,minute:ys,second:ys,hourCycle:"h23",timeZoneName:_s},Ps={year:ys,month:ys,day:ys,hour:ys,minute:ys},Ns={year:ys,month:ys,day:ys,hour:ys,minute:ys,second:ys},js={year:ys,month:bs,day:ys,hour:ys,minute:ys},Ds={year:ys,month:bs,day:ys,hour:ys,minute:ys,second:ys},Bs={year:ys,month:bs,day:ys,weekday:bs,hour:ys,minute:ys},Fs={year:ys,month:_s,day:ys,hour:ys,minute:ys,timeZoneName:bs},Us={year:ys,month:_s,day:ys,hour:ys,minute:ys,second:ys,timeZoneName:bs},zs={year:ys,month:_s,day:ys,weekday:_s,hour:ys,minute:ys,timeZoneName:_s},qs={year:ys,month:_s,day:ys,weekday:_s,hour:ys,minute:ys,second:ys,timeZoneName:_s};class Hs{get type(){throw new vs}get name(){throw new vs}get ianaName(){return this.name}get isUniversal(){throw new vs}offsetName(e,t){throw new vs}formatOffset(e,t){throw new vs}offset(e){throw new vs}equals(e){throw new vs}get isValid(){throw new vs}}let Vs=null;class Gs extends Hs{static get instance(){return null===Vs&&(Vs=new Gs),Vs}get type(){return"system"}get name(){return(new Intl.DateTimeFormat).resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return hl(e,t,n)}formatOffset(e,t){return gl(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return"system"===e.type}get isValid(){return!0}}const Ws=new Map;const $s={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};const Ks=new Map;class Js extends Hs{static create(e){let t=Ks.get(e);return void 0===t&&Ks.set(e,t=new Js(e)),t}static resetCache(){Ks.clear(),Ws.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch(e){return!1}}constructor(e){super(),this.zoneName=e,this.valid=Js.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return hl(e,t,n,this.name)}formatOffset(e,t){return gl(this.offset(e),t)}offset(e){if(!this.valid)return NaN;const t=new Date(e);if(isNaN(t))return NaN;const n=function(e){let t=Ws.get(e);return void 0===t&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,
vendor: 66,903 bytes, line 2
2year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),Ws.set(e,t)),t}(this.name);let[r,i,a,s,o,l,c]=n.formatToParts?function(e,t){const n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){const{type:t,value:i}=n[e],a=$s[t];"era"===t?r[a]=i:Go(a)||(r[a]=parseInt(i,10))}return r}(n,t):function(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,i,a,s,o,l,c,u]=r;return[s,i,a,o,l,c,u]}(n,t);"BC"===s&&(r=1-Math.abs(r));let u=+t;const d=u%1e3;return u-=d>=0?d:1e3+d,(ll({year:r,month:i,day:a,hour:24===o?0:o,minute:l,second:c,millisecond:0})-u)/6e4}equals(e){return"iana"===e.type&&e.name===this.name}get isValid(){return this.valid}}let Zs={};const Ys=new Map;function Xs(e,t={}){const n=JSON.stringify([e,t]);let r=Ys.get(n);return void 0===r&&(r=new Intl.DateTimeFormat(e,t),Ys.set(n,r)),r}const Qs=new Map;const eo=new Map;let to=null;const no=new Map;function ro(e){let t=no.get(e);return void 0===t&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),no.set(e,t)),t}const io=new Map;function ao(e,t,n,r){const i=e.listingMode();return"error"===i?null:"en"===i?n(t):r(t)}class so{constructor(e,t,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;const{padTo:r,floor:i,...a}=n;if(!t||Object.keys(a).length>0){const t={useGrouping:!1,...n};n.padTo>0&&(t.minimumIntegerDigits=n.padTo),this.inf=function(e,t={}){const n=JSON.stringify([e,t]);let r=Qs.get(n);return void 0===r&&(r=new Intl.NumberFormat(e,t),Qs.set(n,r)),r}(e,t)}}format(e){if(this.inf){const t=this.floor?Math.floor(e):e;return this.inf.format(t)}return el(this.floor?Math.floor(e):il(e,3),this.padTo)}}class oo{constructor(e,t,n){let r;if(this.opts=n,this.originalZone=void 0,this.opts.timeZone)this.dt=e;else if("fixed"===e.zone.type){const t=e.offset/60*-1,n=t>=0?`Etc/GMT+${t}`:`Etc/GMT${t}`;0!==e.offset&&Js.create(n).valid?(r=n,this.dt=e):(r="UTC",this.dt=0===e.offset?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else"system"===e.zone.type?this.dt=e:"iana"===e.zone.type?(this.dt=e,r=e.zone.name):(r="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=Xs(t,i)}format(){return this.originalZone?this.formatToParts().map((({value:e})=>e)).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map((e=>{if("timeZoneName"===e.type){const t=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...e,value:t}}return e})):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class lo{constructor(e,t,n){this.opts={style:"long",...n},!t&&Ko()&&(this.rtf=function(e,t={}){const{base:n,...r}=t,i=JSON.stringify([e,r]);let a=eo.get(i);return void 0===a&&(a=new Intl.RelativeTimeFormat(e,t),eo.set(i,a)),a}(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):function(e,t,n="always",r=!1){const i={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=-1===["hours","minutes","seconds"].indexOf(e);if("auto"===n&&a){const n="days"===e;switch(t){case 1:return n?"tomorrow":`next ${i[e][0]}`;case-1:return n?"yesterday":`last ${i[e][0]}`;case 0:return n?"today":`this ${i[e][0]}`}}const s=Object.is(t,-0)||t<0,o=Math.abs(t),l=1===o,c=i[e],u=r?l?c[1]:c[2]||c[1]:l?i[e][0]:e;return s?`${o} ${u} ago`:`in ${o} ${u}`}(t,e,this.opts.numeric,"long"!==this.opts.style)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}}const co={firstDay:1,minimalDays:4,weekend:[6,7]};class uo{static fromOpts(e){return uo.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,t,n,r,i=!1){const a=e||Mo.defaultLocale,s=a||(i?"en-US":to||(to=(new Intl.DateTimeFormat).resolvedOptions().locale,to)),o=t||Mo.defaultNumberingSystem,l=n||Mo.defaultOutputCalendar,c=Xo(r)||Mo.defaultWeekSettings;return new uo(s,o,l,c,a)}static resetCache(){to=null,Ys.clear(),Qs.clear(),eo.clear(),no.clear(),io.clear()}static fromObject({locale:e,numberingSystem:t,outputCalendar:n,weekSettings:r}={}){return uo.create(e,t,n,r)}constructor(e,t,n,r,i){const[a,s,o]=function(e){const t=e.indexOf("-x-");-1!==t&&(e=e.substring(0,t));const n=e.indexOf("-u-");if(-1===n)return[e];{let t,r;try{t=Xs(e).resolvedOptions(),r=e}catch(i){const a=e.substring(0,n);t=Xs(a).resolvedOptions(),r=a}const{numberingSystem:i,calendar:a}=t;return[r,i,a]}}(e);this.locale=a,this.numberingSystem=t||s||null,this.outputCalendar=n||o||null,this.weekSettings=r,this.intl=function(e,t,n){return n||t?(e.includes("-u-")||(e+="-u"),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){var e;return null==this.fastNumbersCached&&(this.fastNumbersCached=(!(e=this).numberingSystem||"latn"===e.numberingSystem)&&("latn"===e.numberingSystem||!e.locale||e.locale.startsWith("en")||"latn"===ro(e.locale).numberingSystem)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),t=!(null!==this.numberingSystem&&"latn"!==this.numberingSystem||null!==this.outputCalendar&&"gregory"!==this.outputCalendar);return e&&t?"en":"intl"}clone(e){return e&&0!==Object.getOwnPropertyNames(e).length?uo.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,Xo(e.weekSettings)||this.weekSettings,e.defaultToEN||!1):this}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,t=!1){return ao(this,e,wl,(()=>{const n="ja"===this.intl||this.intl.startsWith("ja-"),r=(t&=!n)?{month:e,day:"numeric"}:{month:e},i=t?"format":"standalone";if(!this.monthsCache[i][e]){const t=n?e=>this.dtFormatter(e,r).format():e=>this.extract(e,r,"month");this.monthsCache[i][e]=function(e){const t=[];for(let n=1;n<=12;n++){const r=Cu.utc(2009,n,1);t.push(e(r))}return t}(t)}return this.monthsCache[i][e]}))}weekdays(e,t=!1){return ao(this,e,El,(()=>{const n=t?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},r=t?"format":"standalone";return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=function(e){const t=[];for(let n=1;n<=7;n++){const r=Cu.utc(2016,11,13+n);t.push(e(r))}return t}((e=>this.extract(e,n,"weekday")))),this.weekdaysCache[r][e]}))}meridiems(){return ao(this,void 0,(()=>Cl),(()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[Cu.utc(2016,11,13,9),Cu.utc(2016,11,13,19)].map((t=>this.extract(t,e,"dayperiod")))}return this.meridiemCache}))}eras(e){return ao(this,e,Il,(()=>{const t={era:e};return this.eraCache[e]||(this.eraCache[e]=[Cu.utc(-40,1,1),Cu.utc(2017,1,1)].map((e=>this.extract(e,t,"era")))),this.eraCache[e]}))}extract(e,t,n){const r=this.dtFormatter(e,t).formatToParts().find((e=>e.type.toLowerCase()===n));return r?r.value:null}numberFormatter(e={}){return new so(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new oo(e,this.intl,t)}relFormatter(e={}){return new lo(this.intl,this.isEnglish(),e)}listFormatter(e={}){return function(e,t={}){const n=JSON.stringify([e,t]);let r=Zs[n];return r||(r=new Intl.ListFormat(e,t),Zs[n]=r),r}(this.intl,e)}isEnglish(){return"en"===this.locale||"en-us"===this.locale.toLowerCase()||ro(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Jo()?function(e){let t=io.get(e);if(!t){const n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in t||(t={...co,...t}),io.set(e,t)}return t}(this.locale):co}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let ho=null;class po extends Hs{static get utcInstance(){return null===ho&&(ho=new po(0)),ho}static instance(e){return 0===e?po.utcInstance:new po(e)}static parseSpecifier(e){if(e){const t=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(t)return new po(pl(t[1],t[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return 0===this.fixed?"UTC":`UTC${gl(this.fixed,"narrow")}`}get ianaName(){return 0===this.fixed?"Etc/UTC":`Etc/GMT${gl(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,t){return gl(this.fixed,t)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return"fixed"===e.type&&e.fixed===this.fixed}get isValid(){return!0}}class fo extends Hs{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function mo(e,t){if(Go(e)||null===e)return t;if(e instanceof Hs)return e;if("string"==typeof e){const n=e.toLowerCase();return"default"===n?t:"local"===n||"system"===n?Gs.instance:"utc"===n||"gmt"===n?po.utcInstance:po.parseSpecifier(n)||Js.create(e)}return Wo(e)?po.instance(e):"object"==typeof e&&"offset"in e&&"function"==typeof e.offset?e:new fo(e)}const go={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},vo={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},yo=go.hanidec.replace(/[\[|\]]/g,"").split("");const bo=new Map;function _o({numberingSystem:e},t=""){const n=e||"latn";let r=bo.get(n);void 0===r&&(r=new Map,bo.set(n,r));let i=r.get(t);return void 0===i&&(i=new RegExp(`${go[n]}${t}`),r.set(t,i)),i}let wo,ko=()=>Date.now(),So="system",xo=null,Eo=null,Co=null,To=60,Ao=null;class Mo{static get now(){return ko}static set now(e){ko=e}static set defaultZone(e){So=e}static get defaultZone(){return mo(So,Gs.instance)}static get defaultLocale(){return xo}static set defaultLocale(e){xo=e}static get defaultNumberingSystem(){return Eo}static set defaultNumberingSystem(e){Eo=e}static get defaultOutputCalendar(){return Co}static set defaultOutputCalendar(e){Co=e}static get defaultWeekSettings(){return Ao}static set defaultWeekSettings(e){Ao=Xo(e)}static get twoDigitCutoffYear(){return To}static set twoDigitCutoffYear(e){To=e%100}static get throwOnInvalid(){return wo}static set throwOnInvalid(e){wo=e}static resetCaches(){uo.resetCache(),Js.resetCache(),Cu.resetCache(),bo.clear()}}class Io{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Lo=[0,31,59,90,120,151,181,212,243,273,304,334],Oo=[0,31,60,91,121,152,182,213,244,274,305,335];function Ro(e,t){return new Io("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function Po(e,t,n){const r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);const i=r.getUTCDay();return 0===i?7:i}function No(e,t,n){return n+(al(e)?Oo:Lo)[t-1]}function jo(e,t){const n=al(e)?Oo:Lo,r=n.findIndex((e=>e<t));return{month:r+1,day:t-n[r]}}function Do(e,t){return(e-t+7)%7+1}function Bo(e,t=4,n=1){const{year:r,month:i,day:a}=e,s=No(r,i,a),o=Do(Po(r,i,a),n);let l,c=Math.floor((s-o+14-t)/7);return c<1?(l=r-1,c=ul(l,t,n)):c>ul(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:o,...vl(e)}}function Fo(e,t=4,n=1){const{weekYear:r,weekNumber:i,weekday:a}=e,s=Do(Po(r,1,t),n),o=sl(r);let l,c=7*i+a-s-7+t;c<1?(l=r-1,c+=sl(l)):c>o?(l=r+1,c-=sl(r)):l=r;const{month:u,day:d}=jo(l,c);return{year:l,month:u,day:d,...vl(e)}}function Uo(e){const{year:t,month:n,day:r}=e;return{year:t,ordinal:No(t,n,r),...vl(e)}}function zo(e){const{year:t,ordinal:n}=e,{month:r,day:i}=jo(t,n);return{year:t,month:r,day:i,...vl(e)}}function qo(e,t){if(!Go(e.localWeekday)||!Go(e.localWeekNumber)||!Go(e.localWeekYear)){if(!Go(e.weekday)||!Go(e.weekNumber)||!Go(e.weekYear))throw new fs("Cannot mix locale-based week fields with ISO-based week fields");return Go(e.localWeekday)||(e.weekday=e.localWeekday),Go(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),Go(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}return{minDaysInFirstWeek:4,startOfWeek:1}}function Ho(e){const t=$o(e.year),n=Qo(e.month,1,12),r=Qo(e.day,1,ol(e.year,e.month));return t?n?!r&&Ro("day",e.day):Ro("month",e.month):Ro("year",e.year)}function Vo(e){const{hour:t,minute:n,second:r,millisecond:i}=e,a=Qo(t,0,23)||24===t&&0===n&&0===r&&0===i,s=Qo(n,0,59),o=Qo(r,0,59),l=Qo(i,0,999);return a?s?o?!l&&Ro("millisecond",i):Ro("second",r):Ro("minute",n):Ro("hour",t)}function Go(e){return void 0===e}function Wo(e){return"number"==typeof e}function $o(e){return"number"==typeof e&&e%1==0}function Ko(){try{return"undefined"!=typeof Intl&&!!Intl.RelativeTimeFormat}catch(e){return!1}}function Jo(){try{return"undefined"!=typeof Intl&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch(e){return!1}}function Zo(e,t,n){if(0!==e.length)return e.reduce(((e,r)=>{const i=[t(r),r];return e&&n(e[0],i[0])===e[0]?e:i}),null)[1]}function Yo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Xo(e){if(null==e)return null;if("object"!=typeof e)throw new gs("Week settings must be an object");if(!Qo(e.firstDay,1,7)||!Qo(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some((e=>!Qo(e,1,7))))throw new gs("Invalid week settings");return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Qo(e,t,n){return $o(e)&&e>=t&&e<=n}function el(e,t=2){let n;return n=e<0?"-"+(""+-e).padStart(t,"0"):(""+e).padStart(t,"0"),n}function tl(e){return Go(e)||null===e||""===e?void 0:parseInt(e,10)}function nl(e){return Go(e)||null===e||""===e?void 0:parseFloat(e)}function rl(e){if(!Go(e)&&null!==e&&""!==e){const t=1e3*parseFloat("0."+e);return Math.floor(t)}}function il(e,t,n="round"){const r=10**t;switch(n){case"expand":return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case"trunc":return Math.trunc(e*r)/r;case"round":return Math.round(e*r)/r;case"floor":return Math.floor(e*r)/r;case"ceil":return Math.ceil(e*r)/r;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function al(e){return e%4==0&&(e%100!=0||e%400==0)}function sl(e){return al(e)?366:365}function ol(e,t){const n=function(e,t){return e-t*Math.floor(e/t)}(t-1,12)+1;return 2===n?al(e+(t-n)/12)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function ll(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function cl(e,t,n){return-Do(Po(e,1,t),n)+t-1}function ul(e,t=4,n=1){const r=cl(e,t,n),i=cl(e+1,t,n);return(sl(e)-r+i)/7}function dl(e){return e>99?e:e>Mo.twoDigitCutoffYear?1900+e:2e3+e}function hl(e,t,n,r=null){const i=new Date(e),a={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(a.timeZone=r);const s={timeZoneName:t,...a},o=new Intl.DateTimeFormat(n,s).formatToParts(i).find((e=>"timezonename"===e.type.toLowerCase()));return o?o.value:null}function pl(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);const r=parseInt(t,10)||0;return 60*n+(n<0||Object.is(n,-0)?-r:r)}function fl(e){const t=Number(e);if("boolean"==typeof e||""===e||!Number.isFinite(t))throw new gs(`Invalid unit value ${e}`);return t}function ml(e,t){const n={};for(const r in e)if(Yo(e,r)){const i=e[r];if(null==i)continue;n[t(r)]=fl(i)}return n}function gl(e,t){const n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),i=e>=0?"+":"-";switch(t){case"short":return`${i}${el(n,2)}:${el(r,2)}`;case"narrow":return`${i}${n}${r>0?`:${r}`:""}`;case"techie":return`${i}${el(n,2)}${el(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function vl(e){return function(e,t){return t.reduce(((t,n)=>(t[n]=e[n],t)),{})}(e,["hour","minute","second","millisecond"])}const yl=["January","February","March","April","May","June","July","August","September","October","November","December"],bl=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],_l=["J","F","M","A","M","J","J","A","S","O","N","D"];function wl(e){switch(e){case"narrow":return[..._l];case"short":return[...bl];case"long":return[...yl];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const kl=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Sl=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],xl=["M","T","W","T","F","S","S"];function El(e){switch(e){case"narrow":return[...xl];case"short":return[...Sl];case"long":return[...kl];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Cl=["AM","PM"],Tl=["Before Christ","Anno Domini"],Al=["BC","AD"],Ml=["B","A"];function Il(e){switch(e){case"narrow":return[...Ml];case"short":return[...Al];case"long":return[...Tl];default:return null}}function Ll(e,t){let n="";for(const r of e)r.literal?n+=r.val:n+=t(r.val);return n}const Ol={D:ws,DD:ks,DDD:xs,DDDD:Es,t:Cs,tt:Ts,ttt:As,tttt:Ms,T:Is,TT:Ls,TTT:Os,TTTT:Rs,f:Ps,ff:js,fff:Fs,ffff:zs,F:Ns,FF:Ds,FFF:Us,FFFF:qs};class Rl{static create(e,t={}){return new Rl(e,t)}static parseFormat(e){let t=null,n="",r=!1;const i=[];for(let a=0;a<e.length;a++){const s=e.charAt(a);"'"===s?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:""===n?"'":n}),t=null,n="",r=!r):r||s===t?n+=s:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=s,t=s)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return Ol[e]}constructor(e,t){this.opts=t,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,t){null===this.systemLoc&&(this.systemLoc=this.loc.redefaultToSystem());return this.systemLoc.dtFormatter(e,{...this.opts,...t}).format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){return this.dtFormatter(e.start,t).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0,n){if(this.opts.forceSimple)return el(e,t);const r={...this.opts};return t>0&&(r.padTo=t),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,t){const n="en"===this.loc.listingMode(),r=this.loc.outputCalendar&&"gregory"!==this.loc.outputCalendar,i=(t,n)=>this.loc.extract(e,t,n),a=t=>e.isOffsetFixed&&0===e.offset&&t.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,t.format):"",s=()=>n?function(e){return Cl[e.hour<12?0:1]}(e):i({hour:"numeric",hourCycle:"h12"},"dayperiod"),o=(t,r)=>n?function(e,t){return wl(t)[e.month-1]}(e,t):i(r?{month:t}:{month:t,day:"numeric"},"month"),l=(t,r)=>n?function(e,t){return El(t)[e.weekday-1]}(e,t):i(r?{weekday:t}:{weekday:t,month:"long",day:"numeric"},"weekday"),c=t=>{const n=Rl.macroTokenToFormatOpts(t);return n?this.formatWithSystemDefault(e,n):t},u=t=>n?function(e,t){return Il(t)[e.year<0?0:1]}(e,t):i({era:t},"era");return Ll(Rl.parseFormat(t),(t=>{switch(t){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12==0?12:e.hour%12);case"hh":return this.num(e.hour%12==0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return a({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return a({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return a({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return s();case"d":return r?i({day:"numeric"},"day"):this.num(e.day);case"dd":return r?i({day:"2-digit"},"day"):this.num(e.day,2);case"c":case"E":return this.num(e.weekday);case"ccc":return l("short",!0);case"cccc":return l("long",!0);case"ccccc":return l("narrow",!0);case"EEE":return l("short",!1);case"EEEE":return l("long",!1);case"EEEEE":return l("narrow",!1);case"L":return r?i({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return r?i({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return o("short",!0);case"LLLL":return o("long",!0);case"LLLLL":return o("narrow",!0);case"M":return r?i({month:"numeric"},"month"):this.num(e.month);case"MM":return r?i({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return o("short",!1);case"MMMM":return o("long",!1);case"MMMMM":return o("narrow",!1);case"y":return r?i({year:"numeric"},"year"):this.num(e.year);case"yy":return r?i({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return r?i({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return r?i({year:"numeric"},"year"):this.num(e.year,6);case"G":return u("short");case"GG":return u("long");case"GGGGG":return u("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return c(t)}}))}formatDurationFromString(e,t){const n="negativeLargestOnly"===this.opts.signMode?-1:1,r=e=>{switch(e[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},i=Rl.parseFormat(t),a=i.reduce(((e,{literal:t,val:n})=>t?e:e.concat(n)),[]),s=e.shiftTo(...a.map(r).filter((e=>e)));return Ll(i,((e,t)=>i=>{const a=r(i);if(a){const r=t.isNegativeDuration&&a!==t.largestUnit?n:1;let s;return s="negativeLargestOnly"===this.opts.signMode&&a!==t.largestUnit?"never":"all"===this.opts.signMode?"always":"auto",this.num(e.get(a)*r,i.length,s)}return i})(s,{isNegativeDuration:s<0,largestUnit:Object.keys(s.values)[0]}))}}const Pl=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Nl(...e){const t=e.reduce(((e,t)=>e+t.source),"");return RegExp(`^${t}$`)}function jl(...e){return t=>e.reduce((([e,n,r],i)=>{const[a,s,o]=i(t,r);return[{...e,...a},s||n,o]}),[{},null,1]).slice(0,2)}function Dl(e,...t){if(null==e)return[null,null];for(const[n,r]of t){const t=n.exec(e);if(t)return r(t)}return[null,null]}function Bl(...e){return(t,n)=>{const r={};let i;for(i=0;i<e.length;i++)r[e[i]]=tl(t[n+i]);return[r,null,n+i]}}const Fl=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Ul=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,zl=RegExp(`${Ul.source}${`(?:${Fl.source}?(?:\\[(${Pl.source})\\])?)?`}`),ql=RegExp(`(?:[Tt]${zl.source})?`),Hl=Bl("weekYear","weekNumber","weekDay"),Vl=Bl("year","ordinal"),Gl=RegExp(`${Ul.source} ?(?:${Fl.source}|(${Pl.source}))?`),Wl=RegExp(`(?: ${Gl.source})?`);function $l(e,t,n){const r=e[t];return Go(r)?n:tl(r)}function Kl(e,t){return[{hours:$l(e,t,0),minutes:$l(e,t+1,0),seconds:$l(e,t+2,0),milliseconds:rl(e[t+3])},null,t+4]}function Jl(e,t){const n=!e[t]&&!e[t+1],r=pl(e[t+1],e[t+2]);return[{},n?null:po.instance(r),t+3]}function Zl(e,t){return[{},e[t]?Js.create(e[t]):null,t+1]}const Yl=RegExp(`^T?${Ul.source}$`),Xl=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Ql(e){const[t,n,r,i,a,s,o,l,c]=e,u="-"===t[0],d=l&&"-"===l[0],h=(e,t=!1)=>void 0!==e&&(t||e&&u)?-e:e;return[{years:h(nl(n)),months:h(nl(r)),weeks:h(nl(i)),days:h(nl(a)),hours:h(nl(s)),minutes:h(nl(o)),seconds:h(nl(l),"-0"===l),milliseconds:h(rl(c),d)}]}const ec={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function tc(e,t,n,r,i,a,s){const o={year:2===t.length?dl(tl(t)):tl(t),month:bl.indexOf(n)+1,day:tl(r),hour:tl(i),minute:tl(a)};return s&&(o.second=tl(s)),e&&(o.weekday=e.length>3?kl.indexOf(e)+1:Sl.indexOf(e)+1),o}const nc=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function rc(e){const[,t,n,r,i,a,s,o,l,c,u,d]=e,h=tc(t,i,r,n,a,s,o);let p;return p=l?ec[l]:c?0:pl(u,d),[h,new po(p)]}const ic=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,ac=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,sc=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function oc(e){const[,t,n,r,i,a,s,o]=e;return[tc(t,i,r,n,a,s,o),po.utcInstance]}function lc(e){const[,t,n,r,i,a,s,o]=e;return[tc(t,o,n,r,i,a,s),po.utcInstance]}const cc=Nl(/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,ql),uc=Nl(/(\d{4})-?W(\d\d)(?:-?(\d))?/,ql),dc=Nl(/(\d{4})-?(\d{3})/,ql),hc=Nl(zl),pc=jl((function(e,t){return[{year:$l(e,t),month:$l(e,t+1,1),day:$l(e,t+2,1)},null,t+3]}),Kl,Jl,Zl),fc=jl(Hl,Kl,Jl,Zl),mc=jl(Vl,Kl,Jl,Zl),gc=jl(Kl,Jl,Zl);const vc=jl(Kl);const yc=Nl(/(\d{4})-(\d\d)-(\d\d)/,Wl),bc=Nl(Gl),_c=jl(Kl,Jl,Zl);const wc="Invalid Duration",kc={weeks:{days:7,hours:168,minutes:10080,seconds:604800,milliseconds:6048e5},days:{hours:24,minutes:1440,seconds:86400,milliseconds:864e5},hours:{minutes:60,seconds:3600,milliseconds:36e5},minutes:{seconds:60,milliseconds:6e4},seconds:{milliseconds:1e3}},Sc={years:{quarters:4,months:12,weeks:52,days:365,hours:8760,minutes:525600,seconds:31536e3,milliseconds:31536e6},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:131040,seconds:7862400,milliseconds:78624e5},months:{weeks:4,days:30,hours:720,minutes:43200,seconds:2592e3,milliseconds:2592e6},...kc},xc=365.2425,Ec=30.436875,Cc={years:{quarters:4,months:12,weeks:52.1775,days:xc,hours:8765.82,minutes:525949.2,seconds:525949.2*60,milliseconds:525949.2*60*1e3},quarters:{months:3,weeks:13.044375,days:91.310625,hours:2191.455,minutes:131487.3,seconds:525949.2*60/4,milliseconds:7889237999.999999},months:{weeks:4.3481250000000005,days:Ec,hours:730.485,minutes:43829.1,seconds:2629746,milliseconds:2629746e3},...kc},Tc=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Ac=Tc.slice(0).reverse();function Mc(e,t,n=!1){const r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new Rc(r)}function Ic(e,t){let n=t.milliseconds??0;for(const r of Ac.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function Lc(e,t){const n=Ic(e,t)<0?-1:1;Tc.reduceRight(((r,i)=>{if(Go(t[i]))return r;if(r){const a=t[r]*n,s=e[i][r],o=Math.floor(a/s);t[i]+=o*n,t[r]-=o*s*n}return i}),null),Tc.reduce(((n,r)=>{if(Go(t[r]))return n;if(n){const i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r}),null)}function Oc(e){const t={};for(const[n,r]of Object.entries(e))0!==r&&(t[n]=r);return t}class Rc{constructor(e){const t="longterm"===e.conversionAccuracy||!1;let n=t?Cc:Sc;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||uo.create(),this.conversionAccuracy=t?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,t){return Rc.fromObject({milliseconds:e},t)}static fromObject(e,t={}){if(null==e||"object"!=typeof e)throw new gs("Duration.fromObject: argument expected to be an object, got "+(null===e?"null":typeof e));return new Rc({values:ml(e,Rc.normalizeUnit),loc:uo.fromObject(t),conversionAccuracy:t.conversionAccuracy,matrix:t.matrix})}static fromDurationLike(e){if(Wo(e))return Rc.fromMillis(e);if(Rc.isDuration(e))return e;if("object"==typeof e)return Rc.fromObject(e);throw new gs(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,t){const[n]=function(e){return Dl(e,[Xl,Ql])}(e);return n?Rc.fromObject(n,t):Rc.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,t){const[n]=function(e){return Dl(e,[Yl,vc])}(e);return n?Rc.fromObject(n,t):Rc.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,t=null){if(!e)throw new gs("need to specify a reason the Duration is invalid");const n=e instanceof Io?e:new Io(e,t);if(Mo.throwOnInvalid)throw new ps(n);return new Rc({invalid:n})}static normalizeUnit(e){const t={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e?e.toLowerCase():e];if(!t)throw new ms(e);return t}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){const n={...t,floor:!1!==t.round&&!1!==t.floor};return this.isValid?Rl.create(this.loc,n).formatDurationFromString(this,e):wc}toHuman(e={}){if(!this.isValid)return wc;const t=!1!==e.showZeros,n=Tc.map((n=>{const r=this.values[n];return Go(r)||0===r&&!t?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:n.slice(0,-1)}).format(r)})).filter((e=>e));return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return 0!==this.years&&(e+=this.years+"Y"),0===this.months&&0===this.quarters||(e+=this.months+3*this.quarters+"M"),0!==this.weeks&&(e+=this.weeks+"W"),0!==this.days&&(e+=this.days+"D"),0===this.hours&&0===this.minutes&&0===this.seconds&&0===this.milliseconds||(e+="T"),0!==this.hours&&(e+=this.hours+"H"),0!==this.minutes&&(e+=this.minutes+"M"),0===this.seconds&&0===this.milliseconds||(e+=il(this.seconds+this.milliseconds/1e3,3)+"S"),"P"===e&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const t=this.toMillis();if(t<0||t>=864e5)return null;e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1};return Cu.fromMillis(t,{zone:"UTC"}).toISOTime(e)}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?Ic(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const t=Rc.fromDurationLike(e),n={};for(const e of Tc)(Yo(t.values,e)||Yo(this.values,e))&&(n[e]=t.get(e)+this.get(e));return Mc(this,{values:n},!0)}minus(e){if(!this.isValid)return this;const t=Rc.fromDurationLike(e);return this.plus(t.negate())}mapUnits(e){if(!this.isValid)return this;const t={};for(const n of Object.keys(this.values))t[n]=fl(e(this.values[n],n));return Mc(this,{values:t},!0)}get(e){return this[Rc.normalizeUnit(e)]}set(e){if(!this.isValid)return this;return Mc(this,{values:{...this.values,...ml(e,Rc.normalizeUnit)}})}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:r}={}){return Mc(this,{loc:this.loc.clone({locale:e,numberingSystem:t}),matrix:r,conversionAccuracy:n})}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return Lc(this.matrix,e),Mc(this,{values:e},!0)}rescale(){if(!this.isValid)return this;return Mc(this,{values:Oc(this.normalize().shiftToAll().toObject())},!0)}shiftTo(...e){if(!this.isValid)return this;if(0===e.length)return this;e=e.map((e=>Rc.normalizeUnit(e)));const t={},n={},r=this.toObject();let i;for(const a of Tc)if(e.indexOf(a)>=0){i=a;let e=0;for(const t in n)e+=this.matrix[t][a]*n[t],n[t]=0;Wo(r[a])&&(e+=r[a]);const s=Math.trunc(e);t[a]=s,n[a]=(1e3*e-1e3*s)/1e3}else Wo(r[a])&&(n[a]=r[a]);for(const e in n)0!==n[e]&&(t[i]+=e===i?n[e]:n[e]/this.matrix[i][e]);return Lc(this.matrix,t),Mc(this,{values:t},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const t of Object.keys(this.values))e[t]=0===this.values[t]?0:-this.values[t];return Mc(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;return Mc(this,{values:Oc(this.values)},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return null===this.invalid}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid)return!1;if(!this.loc.equals(e.loc))return!1;for(const r of Tc)if(t=this.values[r],n=e.values[r],!(void 0===t||0===t?void 0===n||0===n:t===n))return!1;var t,n;return!0}}const Pc="Invalid Interval";class Nc{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,t=null){if(!e)throw new gs("need to specify a reason the Interval is invalid");const n=e instanceof Io?e:new Io(e,t);if(Mo.throwOnInvalid)throw new hs(n);return new Nc({invalid:n})}static fromDateTimes(e,t){const n=Tu(e),r=Tu(t),i=function(e,t){return e&&e.isValid?t&&t.isValid?t<e?Nc.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null:Nc.invalid("missing or invalid end"):Nc.invalid("missing or invalid start")}(n,r);return null==i?new Nc({start:n,end:r}):i}static after(e,t){const n=Rc.fromDurationLike(t),r=Tu(e);return Nc.fromDateTimes(r,r.plus(n))}static before(e,t){const n=Rc.fromDurationLike(t),r=Tu(e);return Nc.fromDateTimes(r.minus(n),r)}static fromISO(e,t){const[n,r]=(e||"").split("/",2);if(n&&r){let e,i,a,s;try{e=Cu.fromISO(n,t),i=e.isValid}catch(r){i=!1}try{a=Cu.fromISO(r,t),s=a.isValid}catch(r){s=!1}if(i&&s)return Nc.fromDateTimes(e,a);if(i){const n=Rc.fromISO(r,t);if(n.isValid)return Nc.after(e,n)}else if(s){const e=Rc.fromISO(n,t);if(e.isValid)return Nc.before(a,e)}}return Nc.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return null===this.invalidReason}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",t){if(!this.isValid)return NaN;const n=this.start.startOf(e,t);let r;return r=t?.useLocaleWeeks?this.end.reconfigure({locale:n.locale}):this.end,r=r.startOf(e,t),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return!!this.isValid&&(this.isEmpty()||this.e.minus(1).hasSame(this.s,e))}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return!!this.isValid&&this.s>e}isBefore(e){return!!this.isValid&&this.e<=e}contains(e){return!!this.isValid&&(this.s<=e&&this.e>e)}set({start:e,end:t}={}){return this.isValid?Nc.fromDateTimes(e||this.s,t||this.e):this}splitAt(...e){if(!this.isValid)return[];const t=e.map(Tu).filter((e=>this.contains(e))).sort(((e,t)=>e.toMillis()-t.toMillis())),n=[];let{s:r}=this,i=0;for(;r<this.e;){const e=t[i]||this.e,a=+e>+this.e?this.e:e;n.push(Nc.fromDateTimes(r,a)),r=a,i+=1}return n}splitBy(e){const t=Rc.fromDurationLike(e);if(!this.isValid||!t.isValid||0===t.as("milliseconds"))return[];let n,{s:r}=this,i=1;const a=[];for(;r<this.e;){const e=this.start.plus(t.mapUnits((e=>e*i)));n=+e>+this.e?this.e:e,a.push(Nc.fromDateTimes(r,n)),r=n,i+=1}return a}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return!!this.isValid&&+this.e==+e.s}abutsEnd(e){return!!this.isValid&&+e.e==+this.s}engulfs(e){return!!this.isValid&&(this.s<=e.s&&this.e>=e.e)}equals(e){return!(!this.isValid||!e.isValid)&&(this.s.equals(e.s)&&this.e.equals(e.e))}intersection(e){if(!this.isValid)return this;const t=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return t>=n?null:Nc.fromDateTimes(t,n)}union(e){if(!this.isValid)return this;const t=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return Nc.fromDateTimes(t,n)}static merge(e){const[t,n]=e.sort(((e,t)=>e.s-t.s)).reduce((([e,t],n)=>t?t.overlaps(n)||t.abutsStart(n)?[e,t.union(n)]:[e.concat([t]),n]:[e,n]),[[],null]);return n&&t.push(n),t}static xor(e){let t=null,n=0;const r=[],i=e.map((e=>[{time:e.s,type:"s"},{time:e.e,type:"e"}])),a=Array.prototype.concat(...i).sort(((e,t)=>e.time-t.time));for(const e of a)n+="s"===e.type?1:-1,1===n?t=e.time:(t&&+t!=+e.time&&r.push(Nc.fromDateTimes(t,e.time)),t=null);return Nc.merge(r)}difference(...e){return Nc.xor([this].concat(e)).map((e=>this.intersection(e))).filter((e=>e&&!e.isEmpty()))}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Pc}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=ws,t={}){return this.isValid?Rl.create(this.s.loc.clone(t),e).formatInterval(this):Pc}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Pc}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Pc}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Pc}toFormat(e,{separator:t=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:Pc}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):Rc.invalid(this.invalidReason)}mapEndpoints(e){return Nc.fromDateTimes(e(this.s),e(this.e))}}class jc{static hasDST(e=Mo.defaultZone){const t=Cu.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return Js.isValidZone(e)}static normalizeZone(e){return mo(e,Mo.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||uo.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||uo.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||uo.create(e)).getWeekendDays().slice()}static months(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||uo.create(t,n,i)).months(e)}static monthsFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i="gregory"}={}){return(r||uo.create(t,n,i)).months(e,!0)}static weekdays(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||uo.create(t,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||uo.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return uo.create(e).meridiems()}static eras(e="short",{locale:t=null}={}){return uo.create(t,null,"gregory").eras(e)}static features(){return{relative:Ko(),localeWeek:Jo()}}}function Dc(e,t){const n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(t)-n(e);return Math.floor(Rc.fromMillis(r).as("days"))}function Bc(e,t,n,r){let[i,a,s,o]=function(e,t,n){const r=[["years",(e,t)=>t.year-e.year],["quarters",(e,t)=>t.quarter-e.quarter+4*(t.year-e.year)],["months",(e,t)=>t.month-e.month+12*(t.year-e.year)],["weeks",(e,t)=>{const n=Dc(e,t);return(n-n%7)/7}],["days",Dc]],i={},a=e;let s,o;for(const[l,c]of r)n.indexOf(l)>=0&&(s=l,i[l]=c(e,t),o=a.plus(i),o>t?(i[l]--,(e=a.plus(i))>t&&(o=e,i[l]--,e=a.plus(i))):e=o);return[e,i,o,s]}(e,t,n);const l=t-i,c=n.filter((e=>["hours","minutes","seconds","milliseconds"].indexOf(e)>=0));0===c.length&&(s<t&&(s=i.plus({[o]:1})),s!==i&&(a[o]=(a[o]||0)+l/(s-i)));const u=Rc.fromObject(a,r);return c.length>0?Rc.fromMillis(l,r).shiftTo(...c).plus(u):u}function Fc(e,t=(e=>e)){return{regex:e,deser:([e])=>t(function(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(-1!==e[n].search(go.hanidec))t+=yo.indexOf(e[n]);else for(const e in vo){const[n,i]=vo[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}return t}(e))}}const Uc=`[ ${String.fromCharCode(160)}]`,zc=new RegExp(Uc,"g");function qc(e){return e.replace(/\./g,"\\.?").replace(zc,Uc)}function Hc(e){return e.replace(/\./g,"").replace(zc," ").toLowerCase()}function Vc(e,t){return null===e?null:{regex:RegExp(e.map(qc).join("|")),deser:([n])=>e.findIndex((e=>Hc(n)===Hc(e)))+t}}function Gc(e,t){return{regex:e,deser:([,e,t])=>pl(e,t),groups:t}}function Wc(e){return{regex:e,deser:([e])=>e}}const $c={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};let Kc=null;function Jc(e,t){return Array.prototype.concat(...e.map((e=>function(e,t){if(e.literal)return e;const n=Xc(Rl.macroTokenToFormatOpts(e.val),t);return null==n||n.includes(void 0)?e:n}(e,t))))}class Zc{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=Jc(Rl.parseFormat(t),e),this.units=this.tokens.map((t=>function(e,t){const n=_o(t),r=_o(t,"{2}"),i=_o(t,"{3}"),a=_o(t,"{4}"),s=_o(t,"{6}"),o=_o(t,"{1,2}"),l=_o(t,"{1,3}"),c=_o(t,"{1,6}"),u=_o(t,"{1,9}"),d=_o(t,"{2,4}"),h=_o(t,"{4,6}"),p=e=>{return{regex:RegExp((t=e.val,t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&"))),deser:([e])=>e,literal:!0};var t},f=(f=>{if(e.literal)return p(f);switch(f.val){case"G":return Vc(t.eras("short"),0);case"GG":return Vc(t.eras("long"),0);case"y":return Fc(c);case"yy":case"kk":return Fc(d,dl);case"yyyy":case"kkkk":return Fc(a);case"yyyyy":return Fc(h);case"yyyyyy":return Fc(s);case"M":case"L":case"d":case"H":case"h":case"m":case"q":case"s":case"W":return Fc(o);case"MM":case"LL":case"dd":case"HH":case"hh":case"mm":case"qq":case"ss":case"WW":return Fc(r);case"MMM":return Vc(t.months("short",!0),1);case"MMMM":return Vc(t.months("long",!0),1);case"LLL":return Vc(t.months("short",!1),1);case"LLLL":return Vc(t.months("long",!1),1);case"o":case"S":return Fc(l);case"ooo":case"SSS":return Fc(i);case"u":return Wc(u);case"uu":return Wc(o);case"uuu":case"E":case"c":return Fc(n);case"a":return Vc(t.meridiems(),0);case"EEE":return Vc(t.weekdays("short",!1),1);case"EEEE":return Vc(t.weekdays("long",!1),1);case"ccc":return Vc(t.weekdays("short",!0),1);case"cccc":return Vc(t.weekdays("long",!0),1);case"Z":case"ZZ":return Gc(new RegExp(`([+-]${o.source})(?::(${r.source}))?`),2);case"ZZZ":return Gc(new RegExp(`([+-]${o.source})(${r.source})?`),2);case"z":return Wc(/[a-z_+-/]{1,256}?/i);case" ":return Wc(/[^\S\n\r]/);default:return p(f)}})(e)||{invalidReason:"missing Intl.DateTimeFormat.formatToParts support"};return f.token=e,f}(t,e))),this.disqualifyingUnit=this.units.find((e=>e.invalidReason)),!this.disqualifyingUnit){const[e,t]=[`^${(n=this.units).map((e=>e.regex)).reduce(((e,t)=>`${e}(${t.source})`),"")}$`,n];this.regex=RegExp(e,"i"),this.handlers=t}var n}explainFromTokens(e){if(this.isValid){const[t,n]=function(e,t,n){const r=e.match(t);if(r){const e={};let t=1;for(const i in n)if(Yo(n,i)){const a=n[i],s=a.groups?a.groups+1:1;!a.literal&&a.token&&(e[a.token.val[0]]=a.deser(r.slice(t,t+s))),t+=s}return[r,e]}return[r,{}]}(e,this.regex,this.handlers),[r,i,a]=n?function(e){let t,n=null;Go(e.z)||(n=Js.create(e.z)),Go(e.Z)||(n||(n=new po(e.Z)),t=e.Z),Go(e.q)||(e.M=3*(e.q-1)+1),Go(e.h)||(e.h<12&&1===e.a?e.h+=12:12===e.h&&0===e.a&&(e.h=0)),0===e.G&&e.y&&(e.y=-e.y),Go(e.u)||(e.S=rl(e.u));const r=Object.keys(e).reduce(((t,n)=>{const r=(e=>{switch(e){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}})(n);return r&&(t[r]=e[n]),t}),{});return[r,n,t]}(n):[null,null,void 0];if(Yo(n,"a")&&Yo(n,"H"))throw new fs("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:t,matches:n,result:r,zone:i,specificOffset:a}}return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function Yc(e,t,n){return new Zc(e,n).explainFromTokens(t)}function Xc(e,t){if(!e)return null;const n=Rl.create(t,e).dtFormatter((Kc||(Kc=Cu.fromMillis(1555555555555)),Kc)),r=n.formatToParts(),i=n.resolvedOptions();return r.map((t=>function(e,t,n){const{type:r,value:i}=e;if("literal"===r){const e=/^\s+$/.test(i);return{literal:!e,val:e?" ":i}}const a=t[r];let s=r;"hour"===r&&(s=null!=t.hour12?t.hour12?"hour12":"hour24":null!=t.hourCycle?"h11"===t.hourCycle||"h12"===t.hourCycle?"hour12":"hour24":n.hour12?"hour12":"hour24");let o=$c[s];if("object"==typeof o&&(o=o[a]),o)return{literal:!1,val:o}}(t,e,i)))}const Qc="Invalid DateTime",eu=864e13;function tu(e){return new Io("unsupported zone",`the zone "${e.name}" is not supported`)}function nu(e){return null===e.weekData&&(e.weekData=Bo(e.c)),e.weekData}function ru(e){return null===e.localWeekData&&(e.localWeekData=Bo(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function iu(e,t){const n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new Cu({...n,...t,old:n})}function au(e,t,n){let r=e-60*t*1e3;const i=n.offset(r);if(t===i)return[r,t];r-=60*(i-t)*1e3;const a=n.offset(r);return i===a?[r,i]:[e-60*Math.min(i,a)*1e3,Math.max(i,a)]}function su(e,t){const n=new Date(e+=60*t*1e3);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function ou(e,t,n){return au(ll(e),t,n)}function lu(e,t){const n=e.o,r=e.c.year+Math.trunc(t.years),i=e.c.month+Math.trunc(t.months)+3*Math.trunc(t.quarters),a={...e.c,year:r,month:i,day:Math.min(e.c.day,ol(r,i))+Math.trunc(t.days)+7*Math.trunc(t.weeks)},s=Rc.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),o=ll(a);let[l,c]=au(o,n,e.zone);return 0!==s&&(l+=s,c=e.zone.offset(l)),{ts:l,o:c}}function cu(e,t,n,r,i,a){const{setZone:s,zone:o}=n;if(e&&0!==Object.keys(e).length||t){const r=t||o,i=Cu.fromObject(e,{...n,zone:r,specificOffset:a});return s?i:i.setZone(o)}return Cu.invalid(new Io("unparsable",`the input "${i}" can't be parsed as ${r}`))}function uu(e,t,n=!0){return e.isValid?Rl.create(uo.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function du(e,t,n){const r=e.c.year>9999||e.c.year<0;let i="";if(r&&e.c.year>=0&&(i+="+"),i+=el(e.c.year,r?6:4),"year"===n)return i;if(t){if(i+="-",i+=el(e.c.month),"month"===n)return i;i+="-"}else if(i+=el(e.c.month),"month"===n)return i;return i+=el(e.c.day),i}function hu(e,t,n,r,i,a,s){let o=!n||0!==e.c.millisecond||0!==e.c.second,l="";switch(s){case"day":case"month":case"year":break;default:if(l+=el(e.c.hour),"hour"===s)break;if(t){if(l+=":",l+=el(e.c.minute),"minute"===s)break;o&&(l+=":",l+=el(e.c.second))}else{if(l+=el(e.c.minute),"minute"===s)break;o&&(l+=el(e.c.second))}if("second"===s)break;!o||r&&0===e.c.millisecond||(l+=".",l+=el(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&0===e.offset&&!a?l+="Z":e.o<0?(l+="-",l+=el(Math.trunc(-e.o/60)),l+=":",l+=el(Math.trunc(-e.o%60))):(l+="+",l+=el(Math.trunc(e.o/60)),l+=":",l+=el(Math.trunc(e.o%60)))),a&&(l+="["+e.zone.ianaName+"]"),l}const pu={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},fu={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},mu={ordinal:1,hour:0,minute:0,second:0,millisecond:0},gu=["year","month","day","hour","minute","second","millisecond"],vu=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],yu=["year","ordinal","hour","minute","second","millisecond"];function bu(e){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new ms(e);return t}function _u(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return bu(e)}}function wu(e,t){const n=mo(t.zone,Mo.defaultZone);if(!n.isValid)return Cu.invalid(tu(n));const r=uo.fromObject(t);let i,a;if(Go(e.year))i=Mo.now();else{for(const t of gu)Go(e[t])&&(e[t]=pu[t]);const t=Ho(e)||Vo(e);if(t)return Cu.invalid(t);const r=function(e){if(void 0===xu&&(xu=Mo.now()),"iana"!==e.type)return e.offset(xu);const t=e.name;let n=Eu.get(t);return void 0===n&&(n=e.offset(xu),Eu.set(t,n)),n}(n);[i,a]=ou(e,r,n)}return new Cu({ts:i,zone:n,loc:r,o:a})}function ku(e,t,n){const r=!!Go(n.round)||n.round,i=Go(n.rounding)?"trunc":n.rounding,a=(e,a)=>{e=il(e,r||n.calendary?0:2,n.calendary?"round":i);return t.loc.clone(n).relFormatter(n).format(e,a)},s=r=>n.calendary?t.hasSame(e,r)?0:t.startOf(r).diff(e.startOf(r),r).get(r):t.diff(e,r).get(r);if(n.unit)return a(s(n.unit),n.unit);for(const e of n.units){const t=s(e);if(Math.abs(t)>=1)return a(t,e)}return a(e>t?-0:0,n.units[n.units.length-1])}function Su(e){let t,n={};return e.length>0&&"object"==typeof e[e.length-1]?(n=e[e.length-1],t=Array.from(e).slice(0,e.length-1)):t=Array.from(e),[n,t]}let xu;const Eu=new Map;class Cu{constructor(e){const t=e.zone||Mo.defaultZone;let n=e.invalid||(Number.isNaN(e.ts)?new Io("invalid input"):null)||(t.isValid?null:tu(t));this.ts=Go(e.ts)?Mo.now():e.ts;let r=null,i=null;if(!n){if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(t))[r,i]=[e.old.c,e.old.o];else{const a=Wo(e.o)&&!e.old?e.o:t.offset(this.ts);r=su(this.ts,a),n=Number.isNaN(r.year)?new Io("invalid input"):null,r=n?null:r,i=n?null:a}}this._zone=t,this.loc=e.loc||uo.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new Cu({})}static local(){const[e,t]=Su(arguments),[n,r,i,a,s,o,l]=t;return wu({year:n,month:r,day:i,hour:a,minute:s,second:o,millisecond:l},e)}static utc(){const[e,t]=Su(arguments),[n,r,i,a,s,o,l]=t;return e.zone=po.utcInstance,wu({year:n,month:r,day:i,hour:a,minute:s,second:o,millisecond:l},e)}static fromJSDate(e,t={}){const n=(r=e,"[object Date]"===Object.prototype.toString.call(r)?e.valueOf():NaN);var r;if(Number.isNaN(n))return Cu.invalid("invalid input");const i=mo(t.zone,Mo.defaultZone);return i.isValid?new Cu({ts:n,zone:i,loc:uo.fromObject(t)}):Cu.invalid(tu(i))}static fromMillis(e,t={}){if(Wo(e))return e<-eu||e>eu?Cu.invalid("Timestamp out of range"):new Cu({ts:e,zone:mo(t.zone,Mo.defaultZone),loc:uo.fromObject(t)});throw new gs(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,t={}){if(Wo(e))return new Cu({ts:1e3*e,zone:mo(t.zone,Mo.defaultZone),loc:uo.fromObject(t)});throw new gs("fromSeconds requires a numerical input")}static fromObject(e,t={}){e=e||{};const n=mo(t.zone,Mo.defaultZone);if(!n.isValid)return Cu.invalid(tu(n));const r=uo.fromObject(t),i=ml(e,_u),{minDaysInFirstWeek:a,startOfWeek:s}=qo(i,r),o=Mo.now(),l=Go(t.specificOffset)?n.offset(o):t.specificOffset,c=!Go(i.ordinal),u=!Go(i.year),d=!Go(i.month)||!Go(i.day),h=u||d,p=i.weekYear||i.weekNumber;if((h||c)&&p)throw new fs("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(d&&c)throw new fs("Can't mix ordinal dates with month/day");const f=p||i.weekday&&!h;let m,g,v=su(o,l);f?(m=vu,g=fu,v=Bo(v,a,s)):c?(m=yu,g=mu,v=Uo(v)):(m=gu,g=pu);let y=!1;for(const e of m){Go(i[e])?i[e]=y?g[e]:v[e]:y=!0}const b=f?function(e,t=4,n=1){const r=$o(e.weekYear),i=Qo(e.weekNumber,1,ul(e.weekYear,t,n)),a=Qo(e.weekday,1,7);return r?i?!a&&Ro("weekday",e.weekday):Ro("week",e.weekNumber):Ro("weekYear",e.weekYear)}(i,a,s):c?function(e){const t=$o(e.year),n=Qo(e.ordinal,1,sl(e.year));return t?!n&&Ro("ordinal",e.ordinal):Ro("year",e.year)}(i):Ho(i),_=b||Vo(i);if(_)return Cu.invalid(_);const w=f?Fo(i,a,s):c?zo(i):i,[k,S]=ou(w,l,n),x=new Cu({ts:k,zone:n,o:S,loc:r});return i.weekday&&h&&e.weekday!==x.weekday?Cu.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${x.toISO()}`):x.isValid?x:Cu.invalid(x.invalid)}static fromISO(e,t={}){const[n,r]=function(e){return Dl(e,[cc,pc],[uc,fc],[dc,mc],[hc,gc])}(e);return cu(n,r,t,"ISO 8601",e)}static fromRFC2822(e,t={}){const[n,r]=function(e){return Dl(function(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}(e),[nc,rc])}(e);return cu(n,r,t,"RFC 2822",e)}static fromHTTP(e,t={}){const[n,r]=function(e){return Dl(e,[ic,oc],[ac,oc],[sc,lc])}(e);return cu(n,r,t,"HTTP",t)}static fromFormat(e,t,n={}){if(Go(e)||Go(t))throw new gs("fromFormat requires an input string and a format");const{locale:r=null,numberingSystem:i=null}=n,a=uo.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),[s,o,l,c]=function(e,t,n){const{result:r,zone:i,specificOffset:a,invalidReason:s}=Yc(e,t,n);return[r,i,a,s]}(a,e,t);return c?Cu.invalid(c):cu(s,o,n,`format ${t}`,e,l)}static fromString(e,t,n={}){return Cu.fromFormat(e,t,n)}static fromSQL(e,t={}){const[n,r]=function(e){return Dl(e,[yc,pc],[bc,_c])}(e);return cu(n,r,t,"SQL",e)}static invalid(e,t=null){if(!e)throw new gs("need to specify a reason the DateTime is invalid");const n=e instanceof Io?e:new Io(e,t);if(Mo.throwOnInvalid)throw new ds(n);return new Cu({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){const n=Xc(e,uo.fromObject(t));return n?n.map((e=>e?e.val:null)).join(""):null}static expandFormat(e,t={}){return Jc(Rl.parseFormat(e),uo.fromObject(t)).map((e=>e.val)).join("")}static resetCache(){xu=void 0,Eu.clear()}get(e){return this[e]}get isValid(){return null===this.invalid}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?nu(this).weekYear:NaN}get weekNumber(){return this.isValid?nu(this).weekNumber:NaN}get weekday(){return this.isValid?nu(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?ru(this).weekday:NaN}get localWeekNumber(){return this.isValid?ru(this).weekNumber:NaN}get localWeekYear(){return this.isValid?ru(this).weekYear:NaN}get ordinal(){return this.isValid?Uo(this.c).ordinal:NaN}get monthShort(){return this.isValid?jc.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?jc.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?jc.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?jc.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return!this.isOffsetFixed&&(this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset)}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,t=6e4,n=ll(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),a=this.zone.offset(n-r*t),s=this.zone.offset(n-i*t);if(a===s)return[this];const o=n-a*t,l=n-s*t,c=su(o,a),u=su(l,s);return c.hour===u.hour&&c.minute===u.minute&&c.second===u.second&&c.millisecond===u.millisecond?[iu(this,{ts:o}),iu(this,{ts:l})]:[this]}get isInLeapYear(){return al(this.year)}get daysInMonth(){return ol(this.year,this.month)}get daysInYear(){return this.isValid?sl(this.year):NaN}get weeksInWeekYear(){return this.isValid?ul(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?ul(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:t,numberingSystem:n,calendar:r}=Rl.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(po.instance(e),t)}toLocal(){return this.setZone(Mo.defaultZone)}setZone(e,{keepLocalTime:t=!1,keepCalendarTime:n=!1}={}){if((e=mo(e,Mo.defaultZone)).equals(this.zone))return this;if(e.isValid){let r=this.ts;if(t||n){const t=e.offset(this.ts),n=this.toObject();[r]=ou(n,t,e)}return iu(this,{ts:r,zone:e})}return Cu.invalid(tu(e))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){return iu(this,{loc:this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n})})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const t=ml(e,_u),{minDaysInFirstWeek:n,startOfWeek:r}=qo(t,this.loc),i=!Go(t.weekYear)||!Go(t.weekNumber)||!Go(t.weekday),a=!Go(t.ordinal),s=!Go(t.year),o=!Go(t.month)||!Go(t.day),l=s||o,c=t.weekYear||t.weekNumber;if((l||a)&&c)throw new fs("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(o&&a)throw new fs("Can't mix ordinal dates with month/day");let u;i?u=Fo({...Bo(this.c,n,r),...t},n,r):Go(t.ordinal)?(u={...this.toObject(),...t},Go(t.day)&&(u.day=Math.min(ol(u.year,u.month),u.day))):u=zo({...Uo(this.c),...t});const[d,h]=ou(u,this.o,this.zone);return iu(this,{ts:d,o:h})}plus(e){if(!this.isValid)return this;return iu(this,lu(this,Rc.fromDurationLike(e)))}minus(e){if(!this.isValid)return this;return iu(this,lu(this,Rc.fromDurationLike(e).negate()))}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;const n={},r=Rc.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0}if("weeks"===r)if(t){const e=this.loc.getStartOfWeek(),{weekday:t}=this;t<e&&(n.weekNumber=this.weekNumber-1),n.weekday=e}else n.weekday=1;if("quarters"===r){const e=Math.ceil(this.month/3);n.month=3*(e-1)+1}return this.set(n)}endOf(e,t){return this.isValid?this.plus({[e]:1}).startOf(e,t).minus(1):this}toFormat(e,t={}){return this.isValid?Rl.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):Qc}toLocaleString(e=ws,t={}){return this.isValid?Rl.create(this.loc.clone(t),e).formatDateTime(this):Qc}toLocaleParts(e={}){return this.isValid?Rl.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:t=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:i=!1,precision:a="milliseconds"}={}){if(!this.isValid)return null;const s="extended"===e;let o=du(this,s,a=bu(a));return gu.indexOf(a)>=3&&(o+="T"),o+=hu(this,s,t,n,r,i,a),o}toISODate({format:e="extended",precision:t="day"}={}){return this.isValid?du(this,"extended"===e,bu(t)):null}toISOWeekDate(){return uu(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:t=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:i=!1,format:a="extended",precision:s="milliseconds"}={}){if(!this.isValid)return null;return s=bu(s),(r&&gu.indexOf(s)>=3?"T":"")+hu(this,"extended"===a,t,e,n,i,s)}toRFC2822(){return uu(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return uu(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?du(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:t=!1,includeOffsetSpace:n=!0}={}){let r="HH:mm:ss.SSS";return(t||e)&&(n&&(r+=" "),t?r+="z":e&&(r+="ZZ")),uu(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Qc}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const t={...this.c};return e.includeConfig&&(t.outputCalendar=this.outputCalendar,t.numberingSystem=this.loc.numberingSystem,t.locale=this.loc.locale),t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t="milliseconds",n={}){if(!this.isValid||!e.isValid)return Rc.invalid("created by diffing an invalid DateTime");const r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=(o=t,Array.isArray(o)?o:[o]).map(Rc.normalizeUnit),a=e.valueOf()>this.valueOf(),s=Bc(a?this:e,a?e:this,i,r);var o;return a?s.negate():s}diffNow(e="milliseconds",t={}){return this.diff(Cu.now(),e,t)}until(e){return this.isValid?Nc.fromDateTimes(this,e):this}hasSame(e,t,n){if(!this.isValid)return!1;const r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(t,n)<=r&&r<=i.endOf(t,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const t=e.base||Cu.fromObject({},{zone:this.zone}),n=e.padding?this<t?-e.padding:e.padding:0;let r=["years","months","days","hours","minutes","seconds"],i=e.unit;return Array.isArray(e.unit)&&(r=e.unit,i=void 0),ku(t,this.plus(n),{...e,numeric:"always",units:r,unit:i})}toRelativeCalendar(e={}){return this.isValid?ku(e.base||Cu.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(Cu.isDateTime))throw new gs("min requires all arguments be DateTimes");return Zo(e,(e=>e.valueOf()),Math.min)}static max(...e){if(!e.every(Cu.isDateTime))throw new gs("max requires all arguments be DateTimes");return Zo(e,(e=>e.valueOf()),Math.max)}static fromFormatExplain(e,t,n={}){const{locale:r=null,numberingSystem:i=null}=n;return Yc(uo.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),e,t)}static fromStringExplain(e,t,n={}){return Cu.fromFormatExplain(e,t,n)}static buildFormatParser(e,t={}){const{locale:n=null,numberingSystem:r=null}=t,i=uo.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0});return new Zc(i,e)}static fromFormatParser(e,t,n={}){if(Go(e)||Go(t))throw new gs("fromFormatParser requires an input string and a format parser");const{locale:r=null,numberingSystem:i=null}=n,a=uo.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});if(!a.equals(t.locale))throw new gs(`fromFormatParser called with a locale of ${a}, but the format parser was created for ${t.locale}`);const{result:s,zone:o,specificOffset:l,invalidReason:c}=t.explainFromTokens(e);return c?Cu.invalid(c):cu(s,o,n,`format ${t.format}`,e,l)}static get DATE_SHORT(){return ws}static get DATE_MED(){return ks}static get DATE_MED_WITH_WEEKDAY(){return Ss}
2static get DATE_FULL(){return xs}static get DATE_HUGE(){return Es}static get TIME_SIMPLE(){return Cs}static get TIME_WITH_SECONDS(){return Ts}static get TIME_WITH_SHORT_OFFSET(){return As}static get TIME_WITH_LONG_OFFSET(){return Ms}static get TIME_24_SIMPLE(){return Is}static get TIME_24_WITH_SECONDS(){return Ls}static get TIME_24_WITH_SHORT_OFFSET(){return Os}static get TIME_24_WITH_LONG_OFFSET(){return Rs}static get DATETIME_SHORT(){return Ps}static get DATETIME_SHORT_WITH_SECONDS(){return Ns}static get DATETIME_MED(){return js}static get DATETIME_MED_WITH_SECONDS(){return Ds}static get DATETIME_MED_WITH_WEEKDAY(){return Bs}static get DATETIME_FULL(){return Fs}static get DATETIME_FULL_WITH_SECONDS(){return Us}static get DATETIME_HUGE(){return zs}static get DATETIME_HUGE_WITH_SECONDS(){return qs}}function Tu(e){if(Cu.isDateTime(e))return e;if(e&&e.valueOf&&Wo(e.valueOf()))return Cu.fromJSDate(e);if(e&&"object"==typeof e)return Cu.fromObject(e);throw new gs(`Unknown datetime argument: ${e}, of type ${typeof e}`)}const Au="3.7.1";window.popImage=function(e,t,n,r){t=0==t.length?"PCMag":t+" | PCMag";return window.open("","_blank").document.write("<title>"+t+"</title><style>body{font-family:'-apple-system','BlinkMacSystemFont','Roboto','\"Helvetica Neue\"','Arial','sans-serif';display: flex;justify-content:center;align-items:center;}figcaption{font-size:14px;margin:8px 0;color:#a5a5a5;}</style><figure><img src='"+e+"' alt='"+n+"'/><figcaption>"+r+"</figcaption></figure>"),!1},"undefined"!=typeof URLSearchParams&&(window.searchParams=new URLSearchParams(window.location.search)),window.DeepChat=e,window.luxon=t,__webpack_require__(6340),__webpack_require__(3050),__webpack_require__(3282),__webpack_require__(3349),__webpack_require__(8377),__webpack_require__(4339),__webpack_require__(9529),__webpack_require__(924),__webpack_require__(6909),__webpack_require__(4278),__webpack_require__(9677),__webpack_require__(6051),function(){window.videoPlayer=new l,window.EmailStore=r,window.showdown=h();var e=new URLSearchParams(window.location.search);if(e.has("maggie-product-finder")){var t,n=null!==(t=e.get("maggie-product-finder").trim())&&void 0!==t?t:null;document.addEventListener("DOMContentLoaded",(function(){var e=new CustomEvent("product-picker-init",{detail:{text:n}});window.dispatchEvent(e)}))}}(),window._cbv_strategies=window._cbv_strategies||[],window._cbv_strategies.push(u)})()})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.