!function(){"use strict";if("object"==typeof window)if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});else{var t=function(t){for(var e=window.document,o=i(e);o;)o=i(e=o.ownerDocument);return e}(),e=[],o=null,n=null;s.prototype.THROTTLE_TIMEOUT=100,s.prototype.POLL_INTERVAL=null,s.prototype.USE_MUTATION_OBSERVER=!0,s._setupCrossOriginUpdater=function(){return o||(o=function(t,o){n=t&&o?l(t,o):{top:0,bottom:0,left:0,right:0,width:0,height:0},e.forEach((function(t){t._checkForIntersections()}))}),o},s._resetCrossOriginUpdater=function(){o=null,n=null},s.prototype.observe=function(t){if(!this._observationTargets.some((function(e){return e.element==t}))){if(!t||1!=t.nodeType)throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(t.ownerDocument),this._checkForIntersections()}},s.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter((function(e){return e.element!=t})),this._unmonitorIntersections(t.ownerDocument),0==this._observationTargets.length&&this._unregisterInstance()},s.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()},s.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},s.prototype._initThresholds=function(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter((function(t,e,o){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return t!==o[e-1]}))},s.prototype._parseRootMargin=function(t){var e=(t||"0px").split(/\s+/).map((function(t){var e=/^(-?\d*\.?\d+)(px|%)$/.exec(t);if(!e)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(e[1]),unit:e[2]}}));return e[1]=e[1]||e[0],e[2]=e[2]||e[0],e[3]=e[3]||e[1],e},s.prototype._monitorIntersections=function(e){var o=e.defaultView;if(o&&-1==this._monitoringDocuments.indexOf(e)){var n=this._checkForIntersections,r=null,s=null;this.POLL_INTERVAL?r=o.setInterval(n,this.POLL_INTERVAL):(h(o,"resize",n,!0),h(e,"scroll",n,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in o&&(s=new o.MutationObserver(n)).observe(e,{attributes:!0,childList:!0,characterData:!0,subtree:!0})),this._monitoringDocuments.push(e),this._monitoringUnsubscribes.push((function(){var t=e.defaultView;t&&(r&&t.clearInterval(r),c(t,"resize",n,!0)),c(e,"scroll",n,!0),s&&s.disconnect()}));var u=this.root&&(this.root.ownerDocument||this.root)||t;if(e!=u){var a=i(e);a&&this._monitorIntersections(a.ownerDocument)}}},s.prototype._unmonitorIntersections=function(e){var o=this._monitoringDocuments.indexOf(e);if(-1!=o){var n=this.root&&(this.root.ownerDocument||this.root)||t,r=this._observationTargets.some((function(t){var o=t.element.ownerDocument;if(o==e)return!0;for(;o&&o!=n;){var r=i(o);if((o=r&&r.ownerDocument)==e)return!0}return!1}));if(!r){var s=this._monitoringUnsubscribes[o];if(this._monitoringDocuments.splice(o,1),this._monitoringUnsubscribes.splice(o,1),s(),e!=n){var h=i(e);h&&this._unmonitorIntersections(h.ownerDocument)}}}},s.prototype._unmonitorAllIntersections=function(){var t=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var e=0;e<t.length;e++)t[e]()},s.prototype._checkForIntersections=function(){if(this.root||!o||n){var t=this._rootIsInDom(),e=t?this._getRootRect():{top:0,bottom:0,left:0,right:0,width:0,height:0};this._observationTargets.forEach((function(n){var i=n.element,s=u(i),h=this._rootContainsTarget(i),c=n.entry,a=t&&h&&this._computeTargetAndRootIntersection(i,s,e),l=null;this._rootContainsTarget(i)?o&&!this.root||(l=e):l={top:0,bottom:0,left:0,right:0,width:0,height:0};var f=n.entry=new r({time:window.performance&&performance.now&&performance.now(),target:i,boundingClientRect:s,rootBounds:l,intersectionRect:a});c?t&&h?this._hasCrossedThreshold(c,f)&&this._queuedEntries.push(f):c&&c.isIntersecting&&this._queuedEntries.push(f):this._queuedEntries.push(f)}),this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)}},s.prototype._computeTargetAndRootIntersection=function(e,i,r){if("none"!=window.getComputedStyle(e).display){for(var s,h,c,a,f,d,g,m,v=i,_=p(e),b=!1;!b&&_;){var w=null,y=1==_.nodeType?window.getComputedStyle(_):{};if("none"==y.display)return null;if(_==this.root||9==_.nodeType)if(b=!0,_==this.root||_==t)o&&!this.root?!n||0==n.width&&0==n.height?(_=null,w=null,v=null):w=n:w=r;else{var I=p(_),E=I&&u(I),T=I&&this._computeTargetAndRootIntersection(I,E,r);E&&T?(_=I,w=l(E,T)):(_=null,v=null)}else{var R=_.ownerDocument;_!=R.body&&_!=R.documentElement&&"visible"!=y.overflow&&(w=u(_))}if(w&&(s=w,h=v,c=void 0,a=void 0,f=void 0,d=void 0,g=void 0,m=void 0,c=Math.max(s.top,h.top),a=Math.min(s.bottom,h.bottom),f=Math.max(s.left,h.left),d=Math.min(s.right,h.right),m=a-c,v=(g=d-f)>=0&&m>=0&&{top:c,bottom:a,left:f,right:d,width:g,height:m}||null),!v)break;_=_&&p(_)}return v}},s.prototype._getRootRect=function(){var e;if(this.root&&!d(this.root))e=u(this.root);else{var o=d(this.root)?this.root:t,n=o.documentElement,i=o.body;e={top:0,left:0,right:n.clientWidth||i.clientWidth,width:n.clientWidth||i.clientWidth,bottom:n.clientHeight||i.clientHeight,height:n.clientHeight||i.clientHeight}}return this._expandRectByRootMargin(e)},s.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map((function(e,o){return"px"==e.unit?e.value:e.value*(o%2?t.width:t.height)/100})),o={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};return o.width=o.right-o.left,o.height=o.bottom-o.top,o},s.prototype._hasCrossedThreshold=function(t,e){var o=t&&t.isIntersecting?t.intersectionRatio||0:-1,n=e.isIntersecting?e.intersectionRatio||0:-1;if(o!==n)for(var i=0;i<this.thresholds.length;i++){var r=this.thresholds[i];if(r==o||r==n||r<o!=r<n)return!0}},s.prototype._rootIsInDom=function(){return!this.root||f(t,this.root)},s.prototype._rootContainsTarget=function(e){var o=this.root&&(this.root.ownerDocument||this.root)||t;return f(o,e)&&(!this.root||o==e.ownerDocument)},s.prototype._registerInstance=function(){e.indexOf(this)<0&&e.push(this)},s.prototype._unregisterInstance=function(){var t=e.indexOf(this);-1!=t&&e.splice(t,1)},window.IntersectionObserver=s,window.IntersectionObserverEntry=r}function i(t){try{return t.defaultView&&t.defaultView.frameElement||null}catch(t){return null}}function r(t){this.time=t.time,this.target=t.target,this.rootBounds=a(t.rootBounds),this.boundingClientRect=a(t.boundingClientRect),this.intersectionRect=a(t.intersectionRect||{top:0,bottom:0,left:0,right:0,width:0,height:0}),this.isIntersecting=!!t.intersectionRect;var e=this.boundingClientRect,o=e.width*e.height,n=this.intersectionRect,i=n.width*n.height;this.intersectionRatio=o?Number((i/o).toFixed(4)):this.isIntersecting?1:0}function s(t,e){var o,n,i,r=e||{};if("function"!=typeof t)throw new Error("callback must be a function");if(r.root&&1!=r.root.nodeType&&9!=r.root.nodeType)throw new Error("root must be a Document or Element");this._checkForIntersections=(o=this._checkForIntersections.bind(this),n=this.THROTTLE_TIMEOUT,i=null,function(){i||(i=setTimeout((function(){o(),i=null}),n))}),this._callback=t,this._observationTargets=[],this._queuedEntries=[],this._rootMarginValues=this._parseRootMargin(r.rootMargin),this.thresholds=this._initThresholds(r.threshold),this.root=r.root||null,this.rootMargin=this._rootMarginValues.map((function(t){return t.value+t.unit})).join(" "),this._monitoringDocuments=[],this._monitoringUnsubscribes=[]}function h(t,e,o,n){"function"==typeof t.addEventListener?t.addEventListener(e,o,n||!1):"function"==typeof t.attachEvent&&t.attachEvent("on"+e,o)}function c(t,e,o,n){"function"==typeof t.removeEventListener?t.removeEventListener(e,o,n||!1):"function"==typeof t.detatchEvent&&t.detatchEvent("on"+e,o)}function u(t){var e;try{e=t.getBoundingClientRect()}catch(t){}return e?(e.width&&e.height||(e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}),e):{top:0,bottom:0,left:0,right:0,width:0,height:0}}function a(t){return!t||"x"in t?t:{top:t.top,y:t.top,bottom:t.bottom,left:t.left,x:t.left,right:t.right,width:t.width,height:t.height}}function l(t,e){var o=e.top-t.top,n=e.left-t.left;return{top:o,left:n,height:e.height,width:e.width,bottom:o+e.height,right:n+e.width}}function f(t,e){for(var o=e;o;){if(o==t)return!0;o=p(o)}return!1}function p(e){var o=e.parentNode;return 9==e.nodeType&&e!=t?i(e):(o&&o.assignedSlot&&(o=o.assignedSlot.parentNode),o&&11==o.nodeType&&o.host?o.host:o)}function d(t){return t&&9===t.nodeType}}();
!function(){const e=function(){const e={rootMargin:"200px 0px",threshold:.01},t=[];let n,a,i;d();const o=document.querySelector("body");function d(){n=Array.from(document.querySelectorAll("img.jetpack-lazy-image:not(.jetpack-lazy-image--handled)")),i&&i.disconnect(),"IntersectionObserver"in window?(i=new IntersectionObserver(c,e),n.forEach((function(e){e.getAttribute("data-lazy-loaded")||i.observe(e)})),window.addEventListener("beforeprint",l),window.matchMedia&&window.matchMedia("print").addListener((function(e){e.matches&&l()}))):r()}function r(){for(i&&i.disconnect();n.length>0;)s(n[0])}function c(e){for(let t=0;t<e.length;t++){const n=e[t];n.intersectionRatio>0&&(i.unobserve(n.target),s(n.target))}0===n.length&&i.disconnect()}function l(){if(!a&&(n.length>0||t.length>0)){a=document.createElement("div"),a.id="loadingWarning",a.style.fontWeight="bold",a.innerText=jetpackLazyImagesL10n.loading_warning;const e=document.createElement("style");e.innerHTML="#loadingWarning { display: none; }\n@media print {\n#loadingWarning { display: block; }\nbody > #loadingWarning ~ * { display: none !important; }\n}",a.appendChild(e),o.insertBefore(a,o.firstChild)}n.length>0&&r(),a&&alert(jetpackLazyImagesL10n.loading_warning)}function s(e){let a;if(!(e instanceof HTMLImageElement))return;const i=e.getAttribute("data-lazy-srcset"),o=e.getAttribute("data-lazy-sizes");e.removeAttribute("data-lazy-srcset"),e.removeAttribute("data-lazy-sizes"),e.removeAttribute("data-lazy-src"),e.classList.add("jetpack-lazy-image--handled"),e.setAttribute("data-lazy-loaded",1),o&&e.setAttribute("sizes",o),i?e.setAttribute("srcset",i):e.removeAttribute("srcset"),e.setAttribute("loading","eager"),t.push(e);const d=n.indexOf(e);d>=0&&n.splice(d,1),e.complete?u.call(e,null):(e.addEventListener("load",u,{once:!0}),e.addEventListener("error",u,{once:!0})),"undefined"!=typeof safari&&(e.outerHTML=e.outerHTML);try{a=new Event("jetpack-lazy-loaded-image",{bubbles:!0,cancelable:!0})}catch(e){a=document.createEvent("Event"),a.initEvent("jetpack-lazy-loaded-image",!0,!0)}e.dispatchEvent(a)}function u(){const e=t.indexOf(this);e>=0&&t.splice(e,1),a&&0===n.length&&0===t.length&&(a.parentNode.removeChild(a),a=null)}o&&(o.addEventListener("is.post-load",d),o.addEventListener("jetpack-lazy-images-load",d))};"interactive"===document.readyState||"complete"===document.readyState?e():document.addEventListener("DOMContentLoaded",e)}();
window.elxTrack=function (n, p){
try { if(typeof gtag==='function') gtag('event', n, p||{});} catch (e){}
try { if(typeof clarity==='function') clarity('event', n); } catch (e){}};
(function (){
'use strict';
document.addEventListener('click', function (e){
var a=e.target.closest ? e.target.closest('a'):null;
if(a&&a.href){
if(a.href.indexOf('wa.me')!==-1) window.elxTrack('whatsapp_click', { link_url: a.href });
if(a.href.indexOf('add-to-cart')!==-1) window.elxTrack('add_to_cart_click', { link_url: a.href });
}
if(e.target.closest&&e.target.closest('.opt')) window.elxTrack('pack_selected');
if(e.target.closest&&e.target.closest('#elx-chat-bubble')) window.elxTrack('chat_open');
}, { passive: true });
if(document.body.classList.contains('woocommerce-order-received')){
window.elxTrack('purchase_thankyou');
}
if('IntersectionObserver' in window){
var io=new IntersectionObserver(function (entries){
entries.forEach(function (e){
if(e.isIntersecting){ e.target.classList.add('in'); io.unobserve(e.target); }});
}, { threshold: 0.12 });
document.querySelectorAll('.reveal').forEach(function (el){ io.observe(el); });
}else{
document.querySelectorAll('.reveal').forEach(function (el){ el.classList.add('in'); });
}
var toggle=document.querySelector('.menu-toggle');
if(toggle){
toggle.addEventListener('click', function (){
var ul=document.querySelector('nav.main ul');
if(ul) ul.classList.toggle('open');
});
}
var v=document.getElementById('herovid');
var sb=document.getElementById('soundbtn');
if(v&&sb){
sb.addEventListener('click', function (){
if(v.muted){ v.muted=false; v.currentTime=0; sb.textContent='🔇 Silenciar'; }else{ v.muted=true; sb.textContent='🔊 Escuchar'; }});
}
var opts=document.querySelectorAll('.opt');
if(opts.length){
opts.forEach(function (o){
o.addEventListener('click', function (){
opts.forEach(function (x){ x.classList.remove('active'); });
o.classList.add('active');
var url=o.dataset.url;
var pnow=document.getElementById('pnow');
var pwas=document.getElementById('pwas');
var addbtn=document.getElementById('addbtn');
var stickyadd=document.getElementById('stickyadd');
var stickyprice=document.getElementById('stickyprice');
if(pnow) pnow.textContent=o.dataset.price;
if(pwas){ pwas.textContent=o.dataset.was||''; pwas.style.display=o.dataset.was ? 'inline':'none'; }
if(addbtn) addbtn.href=url;
if(stickyadd) stickyadd.href=url;
if(stickyprice) stickyprice.textContent='· ' + o.dataset.price + ' MXN';
});
});
}
window.elxSetImg=function (btn, src){
var main=document.getElementById('mainimg');
if(main) main.src=src;
document.querySelectorAll('.thumbs button').forEach(function (b){ b.classList.remove('active'); });
btn.classList.add('active');
};
var sameBilling=document.getElementById('elx-same-billing');
if(sameBilling){
var billingCard=document.getElementById('elx-billing-card');
var campos=['first_name', 'last_name', 'company', 'country', 'address_1', 'address_2', 'city', 'state', 'postcode'];
function copiarEnvioAFacturacion(){
campos.forEach(function (c){
var s=document.getElementById('shipping_' + c);
var b=document.getElementById('billing_' + c);
if(!s||!b) return;
b.value=s.value;
if(b.tagName==='SELECT'&&window.jQuery){
window.jQuery(b).val(s.value).trigger('change');
}});
}
function actualizarToggle(){
if(sameBilling.checked){
billingCard.style.display='none';
copiarEnvioAFacturacion();
}else{
billingCard.style.display='';
}}
sameBilling.addEventListener('change', actualizarToggle);
campos.forEach(function (c){
var s=document.getElementById('shipping_' + c);
if(!s) return;
s.addEventListener('input', function (){ if(sameBilling.checked) copiarEnvioAFacturacion(); });
s.addEventListener('change', function (){ if(sameBilling.checked) copiarEnvioAFacturacion(); });
});
var form=document.querySelector('form.woocommerce-checkout');
if(form){
form.addEventListener('submit', function (){ if(sameBilling.checked) copiarEnvioAFacturacion(); });
}
if(window.jQuery){
window.jQuery(document.body).on('checkout_place_order', function (){
if(sameBilling.checked) copiarEnvioAFacturacion();
return true;
});
}
actualizarToggle();
}
var sticky=document.getElementById('stickybuy');
var box=document.getElementById('buybox');
if(sticky&&box){
window.addEventListener('scroll', function (){
var r=box.getBoundingClientRect();
sticky.classList.toggle('show', r.bottom < 0);
}, { passive: true });
}})();
(function (){
'use strict';
var CFG=window.ELX_CHAT||{};
var NONCE=CFG.nonce||'';
function endpoint(){
return (CFG.endpoint||'/wp-admin/admin-ajax.php') + '?action=elixie_chat&nonce=' + encodeURIComponent(NONCE);
}
function refreshNonce(){
return fetch('/wp-json/elixie/v1/nonce', { cache: 'no-store' })
.then(function (r){ return r.json(); })
.then(function (d){ if(d&&d.nonce) NONCE=d.nonce; });
}
var isOpen=false;
var isLoading=false;
var history=[];
var leadTracked=false;
var sessionId='';
try {
sessionId=localStorage.getItem('elx_chat_session')||'';
if(!sessionId){
sessionId='elx-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10);
localStorage.setItem('elx_chat_session', sessionId);
}} catch (e){ sessionId='elx-mem-' + Math.random().toString(36).slice(2, 12); }
var GREETING='¡Hola! Soy Lía, tu asesora de Elixie. 💜\n\n¿Buscas hidratar tu piel, tienes dudas del sérum o de tu envío? Cuéntame y te ayudo a elegir.';
var SUGGESTIONS=[
'¿Qué pack me conviene?',
'¿Para qué sirve el sérum?',
'¿Cómo se aplica?',
'Quiero hablar con una persona'
];
var bubble=document.getElementById('elx-chat-bubble');
var panel=document.getElementById('elx-chat-panel');
var messages=document.getElementById('elx-chat-messages');
var typingEl=document.getElementById('elx-chat-typing');
var inputEl=document.getElementById('elx-chat-input');
var sendBtn=document.getElementById('elx-chat-send');
var closeBtn=document.getElementById('elx-chat-close');
var dot=document.getElementById('elx-chat-dot');
if(!bubble) return;
function openChat(){
isOpen=true;
panel.classList.add('is-open');
bubble.setAttribute('aria-expanded', 'true');
document.getElementById('elx-bubble-icon-chat').style.display='none';
document.getElementById('elx-bubble-icon-close').style.display='';
dot.classList.remove('visible');
if(!messages.children.length){
appendBot(GREETING);
showSuggestions(SUGGESTIONS);
}
setTimeout(function (){ inputEl.focus(); }, 150);
}
function closeChat(){
isOpen=false;
panel.classList.remove('is-open');
bubble.setAttribute('aria-expanded', 'false');
document.getElementById('elx-bubble-icon-chat').style.display='';
document.getElementById('elx-bubble-icon-close').style.display='none';
}
bubble.addEventListener('click', function (){ isOpen ? closeChat():openChat(); });
closeBtn.addEventListener('click', closeChat);
document.addEventListener('keydown', function (e){ if(e.key==='Escape'&&isOpen) closeChat(); });
setTimeout(function (){ if(!isOpen) dot.classList.add('visible'); }, 20000);
function showSuggestions(items){
removeSuggestions();
var wrap=document.createElement('div');
wrap.className='elx-suggestions';
items.forEach(function (text){
var btn=document.createElement('button');
btn.className='elx-suggestion-btn';
btn.textContent=text;
btn.addEventListener('click', function (){ removeSuggestions(); sendMessage(text); });
wrap.appendChild(btn);
});
messages.appendChild(wrap);
scrollBottom();
}
function removeSuggestions(){
var nodes=messages.querySelectorAll('.elx-suggestions');
for (var i=0; i < nodes.length; i++) nodes[i].remove();
}
function appendBot(text, isError){
removeSuggestions();
var wrap=document.createElement('div');
wrap.className='elx-msg elx-msg-bot' + (isError ? ' elx-msg-error':'');
var av=document.createElement('div');
av.className='elx-msg-avatar';
av.textContent='L';
var body=document.createElement('div');
body.className='elx-msg-body';
body.innerHTML=renderMd(text);
wrap.appendChild(av);
wrap.appendChild(body);
messages.appendChild(wrap);
scrollBottom();
}
function appendUser(text){
var wrap=document.createElement('div');
wrap.className='elx-msg elx-msg-user';
var body=document.createElement('div');
body.className='elx-msg-body';
body.textContent=text;
wrap.appendChild(body);
messages.appendChild(wrap);
scrollBottom();
}
function scrollBottom(){ messages.scrollTop=messages.scrollHeight; }
function renderMd(text){
return text
.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>')
.replace(/\n/g, '<br>');
}
function showTyping(){ typingEl.style.display='flex'; scrollBottom(); }
function hideTyping(){ typingEl.style.display='none'; }
function sendMessage(text){
var msg=(text||inputEl.value).trim();
if(!msg||isLoading) return;
if(!leadTracked&&window.elxTrack){ window.elxTrack('chat_lead'); leadTracked=true; }
removeSuggestions();
appendUser(msg);
inputEl.value='';
autoResize();
sendBtn.disabled=true;
isLoading=true;
showTyping();
doSend(msg, true);
}
function doSend(msg, allowRetry){
fetch(endpoint(), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: msg,
history: history,
session_id: sessionId,
page_url: window.location.href,
page_title: document.title
})
})
.then(function (res){
if(res.status===403&&allowRetry){
return refreshNonce().then(function (){ doSend(msg, false); return null; });
}
return res.json().catch(function (){ return { error: 'Error inesperado.' };});
})
.then(function (data){
if(data===null) return;
hideTyping();
isLoading=false;
if(data.error){ appendBot('⚠ ' + data.error, true); return; }
var reply=data.reply||'';
appendBot(reply);
history.push({ role: 'user', content: msg });
history.push({ role: 'assistant', content: reply });
if(history.length > 40) history=history.slice(-40);
})
.catch(function (){
hideTyping();
isLoading=false;
appendBot('Error de red. Intenta de nuevo.', true);
});
}
inputEl.addEventListener('input', function (){
sendBtn.disabled = !inputEl.value.trim();
autoResize();
});
inputEl.addEventListener('keydown', function (e){
if(e.key==='Enter'&&!e.shiftKey){
e.preventDefault();
if(!sendBtn.disabled) sendMessage();
}});
sendBtn.addEventListener('click', function (){ sendMessage(); });
function autoResize(){
inputEl.style.height='auto';
inputEl.style.height=Math.min(inputEl.scrollHeight, 120) + 'px';
}})();
(()=>{var e={9885(e){function t(){this.listeners={}}t.prototype.emit=function(e,t){this.listeners[e]=this.listeners[e]??[],this.listeners[e].forEach(e=>e.apply(null,t))},t.prototype.on=function(e,t){this.listeners[e]=this.listeners[e]??[],this.listeners[e].push(t)},e.exports=t},5626(){function e(e){const t=!!e.getAttribute("data-show-if"),n=t?e.getAttribute("data-show-if").split(":"):e.getAttribute("data-hide-if").split(":"),r=n[0],i=(n.length>1?n[1]:"*").split("|"),o=function(e,t){const n=[],r=e.querySelectorAll('input[name="'+t+'"],select[name="'+t+'"],textarea[name="'+t+'"]');for(let e=0;e<r.length;e++)("radio"!==r[e].type&&"checkbox"!==r[e].type||r[e].checked)&&n.push(r[e].value);return n}(function(e){let t=e;for(;t.parentElement;)if(t=t.parentElement,"FORM"===t.tagName)return t;return null}(e),r);let s=!1;for(let e=0;e<o.length&&!s;e++)s=i.indexOf(o[e])>-1||i.indexOf("*")>-1&&o[e].length>0;e.style.display=t?s?"":"none":s?"none":"";const a=e.querySelectorAll("input,select,textarea");for(let e=0;e<a.length;e++)(s||t)&&a[e].getAttribute("data-was-required")&&(a[e].required=!0,a[e].removeAttribute("data-was-required")),s&&t||!a[e].required||(a[e].setAttribute("data-was-required","true"),a[e].required=!1)}function t(){const t=document.querySelectorAll(".mc4wp-form [data-show-if],.mc4wp-form [data-hide-if]");for(let n=0;n<t.length;n++)e(t[n])}function n(t){if(!t.target||!t.target.form||t.target.form.className.indexOf("mc4wp-form")<0)return;const n=t.target.form.querySelectorAll("[data-show-if],[data-hide-if]");for(let t=0;t<n.length;t++)e(n[t])}document.addEventListener("keyup",n,!0),document.addEventListener("change",n,!0),document.addEventListener("mc4wp-refresh",t,!0),window.addEventListener("load",t),t()},6942(e,t,n){const r=n(2076),i=n(6564),o=function(e,t){this.id=e,this.element=t||document.createElement("form"),this.name=this.element.getAttribute("data-name")||"Form #"+this.id,this.errors=[],this.started=!1};o.prototype.setData=function(e){try{i(this.element,e)}catch(e){console.error(e)}},o.prototype.getData=function(){return r(this.element,{hash:!0,empty:!0})},o.prototype.getSerializedData=function(){return r(this.element,{hash:!1,empty:!0})},o.prototype.setResponse=function(e){this.element.querySelector(".mc4wp-response").innerHTML=e},o.prototype.reset=function(){this.setResponse(""),this.element.querySelector(".mc4wp-form-fields").style.display="",this.element.reset()},e.exports=o},9685(e,t,n){const r=n(6942),i=[],o=new(n(9885));function s(e,t){t=t||parseInt(e.getAttribute("data-id"))||0;const n=new r(t,e);return i.push(n),n}e.exports={get:function(e){e=parseInt(e);for(let t=0;t<i.length;t++)if(i[t].id===e)return i[t];return s(document.querySelector(".mc4wp-form-"+e),e)},getByElement:function(e){const t=e.form||e;for(let e=0;e<i.length;e++)if(i[e].element===t)return i[e];return s(t)},on:function(e,t){o.on(e,t)},trigger:function(e,t){"submit"===e||e.indexOf(".submit")>0?(o.emit(t[0].id+"."+e,t),o.emit(e,t)):window.setTimeout(function(){o.emit(t[0].id+"."+e,t),o.emit(e,t)},10)}}},2076(e){var t=/^(?:submit|button|image|reset|file)$/i,n=/^(?:input|select|textarea|keygen)/i,r=/(\[[^\[\]]*\])/g;function i(e,t,n){if(0===t.length)return n;var r=t.shift(),o=r.match(/^\[(.+?)\]$/);if("[]"===r)return e=e||[],Array.isArray(e)?e.push(i(null,t,n)):(e._values=e._values||[],e._values.push(i(null,t,n))),e;if(o){var s=o[1],a=+s;isNaN(a)?(e=e||{})[s]=i(e[s],t,n):(e=e||[])[a]=i(e[a],t,n)}else e[r]=i(e[r],t,n);return e}function o(e,t,n){if(t.match(r))i(e,function(e){var t=[],n=new RegExp(r),i=/^([^\[\]]*)/.exec(e);for(i[1]&&t.push(i[1]);null!==(i=n.exec(e));)t.push(i[1]);return t}(t),n);else{var o=e[t];o?(Array.isArray(o)||(e[t]=[o]),e[t].push(n)):e[t]=n}return e}function s(e,t,n){return n=n.replace(/(\r)?\n/g,"\r\n"),n=(n=encodeURIComponent(n)).replace(/%20/g,"+"),e+(e?"&":"")+encodeURIComponent(t)+"="+n}e.exports=function(e,r){"object"!=typeof r?r={hash:!!r}:void 0===r.hash&&(r.hash=!0);for(var i=r.hash?{}:"",a=r.serializer||(r.hash?o:s),c=e&&e.elements?e.elements:[],l=Object.create(null),u=0;u<c.length;++u){var f=c[u];if((r.disabled||!f.disabled)&&f.name&&n.test(f.nodeName)&&!t.test(f.type)){var d=f.name,h=f.value;if("checkbox"!==f.type&&"radio"!==f.type||f.checked||(h=void 0),r.empty){if("checkbox"!==f.type||f.checked||(h=""),"radio"===f.type&&(l[f.name]||f.checked?f.checked&&(l[f.name]=!0):l[f.name]=!1),null==h&&"radio"==f.type)continue}else if(!h)continue;if("select-multiple"!==f.type)i=a(i,d,h);else{h=[];for(var p=f.options,m=!1,g=0;g<p.length;++g){var y=p[g],v=r.empty&&!y.value,w=y.value||v;y.selected&&w&&(m=!0,i=r.hash&&"[]"!==d.slice(d.length-2)?a(i,d+"[]",y.value):a(i,d,y.value))}!m&&r.empty&&(i=a(i,d,""))}}}if(r.empty)for(var d in l)l[d]||(i=a(i,d,""));return i}},6564(e){e.exports&&(e.exports=function e(t,n,r){for(const i in n){if(!n.hasOwnProperty(i))continue;const o=i;let s=n[i];if(void 0===s&&(s=""),null===s&&(s=""),void 0!==r&&(o=r+"["+i+"]"),s.constructor===Array)o+="[]";else if("object"==typeof s){e(t,s,o);continue}const a=t.elements.namedItem(o);if(!a)continue;const c=a.type||a[0].type;switch(c){default:a.value=s;break;case"radio":case"checkbox":{const e=s.constructor===Array?s:[s];for(let t=0;t<a.length;t++)a[t].checked=e.indexOf(a[t].value)>-1}break;case"select-multiple":{const e=s.constructor===Array?s:[s];for(let t=0;t<a.options.length;t++)a.options[t].selected=e.indexOf(a.options[t].value)>-1}break;case"select":case"select-one":a.value=s.toString()||s;break;case"date":a.value=new Date(s).toISOString().split("T")[0]}const l=new Event("change",{bubbles:!0});switch(c){default:a.dispatchEvent(l);break;case"radio":case"checkbox":for(let e=0;e<a.length;e++)a[e].checked&&a[e].dispatchEvent(l)}}})}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}const r=window.mc4wp||{},i=n(9685);function o(e,t){document.addEventListener(e,e=>{if(!e.target)return;const n=e.target;("string"==typeof n.className&&n.className.indexOf("mc4wp-form")>-1||"function"==typeof n.matches&&n.matches(".mc4wp-form *"))&&t.call(e,e)},!0)}n(5626),o("submit",function(e){if(e.defaultPrevented)return;const t=i.getByElement(e.target);i.trigger("submit",[t,e])}),o("focus",function(e){const t=i.getByElement(e.target);t.started||(i.trigger("started",[t,e]),t.started=!0)}),o("change",function(e){const t=i.getByElement(e.target);i.trigger("change",[t,e])}),r.listeners&&([].forEach.call(r.listeners,function(e){i.on(e.event,e.callback)}),delete r.listeners),r.forms=i,window.mc4wp=r})();