(()=>{var ra=Object.defineProperty,na=Object.defineProperties;var oa=Object.getOwnPropertyDescriptors;var ni=Object.getOwnPropertySymbols;var Ir=Object.prototype.hasOwnProperty,Lr=Object.prototype.propertyIsEnumerable;var gs=(t,e,i)=>e in t?ra(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,I=(t,e)=>{for(var i in e||(e={}))Ir.call(e,i)&&gs(t,i,e[i]);if(ni)for(var i of ni(e))Lr.call(e,i)&&gs(t,i,e[i]);return t},Te=(t,e)=>na(t,oa(e));var Dr=(t,e)=>{var i={};for(var s in t)Ir.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(t!=null&&ni)for(var s of ni(t))e.indexOf(s)<0&&Lr.call(t,s)&&(i[s]=t[s]);return i};var _s=(t,e,i)=>(gs(t,typeof e!="symbol"?e+"":e,i),i);var T=(t,e,i)=>new Promise((s,r)=>{var n=l=>{try{a(i.next(l))}catch(c){r(c)}},o=l=>{try{a(i.throw(l))}catch(c){r(c)}},a=l=>l.done?s(l.value):Promise.resolve(l.value).then(n,o);a((i=i.apply(t,e)).next())});var Ie=class{constructor(e={}){e=Object.assign({resolveTimeout:null,resolveValue:!0,rejectTimeout:null,rejectValue:!1},e),this._promise=new Promise((o,a)=>{this.resolve=o,this.reject=a}),this.then=this._promise.then.bind(this._promise),this.catch=this._promise.catch.bind(this._promise),this.finally=this._promise.finally.bind(this._promise),this[Symbol.toStringTag]="Promise";let{resolveTimeout:i,resolveValue:s,rejectTimeout:r,rejectValue:n}=e;i&&setTimeout(()=>this.resolve(s),i),r&&setTimeout(()=>this.reject(n),r)}};var vs="layer",bs="chat",ys="quiz";function Or(t){return t.reduce(function(e,i){return e[i]=new Ie,e},{})}function Hr(t){return function(e,i){return T(this,null,function*(){if(!t[e])throw new Error(`unknown "${e}" app!`);i(yield t[e])})}}var Ss="__DF_DEBUG_MODE__",Mr="true",Pt=window.sessionStorage;function Nr(){Pt.setItem(Ss,Mr)}function $r(){Pt.removeItem(Ss)}function Es(){return Pt.getItem(Ss)===Mr}function oi(t){return Pt.getItem(t)||window[t]}function ai(t,e){Pt.setItem(t,e)}function L(...t){Es()&&console.log("[doofinder]",...t)}var aa=10,la=500;function li(t,e={}){let i=document.querySelector(t);return i?Promise.resolve(i):new Promise((s,r)=>{let n=0,o=null,a=e.interval||la,l=e.times||aa;o=setInterval(function(){n++i.offsetWidth>0&&i.offsetHeight>0)}updateQuery(e=""){return T(this,null,function*(){let i=yield this.getElement();i instanceof HTMLInputElement&&(i.value=e)})}focus(){return T(this,null,function*(){let e=yield this.getElement();e instanceof HTMLInputElement&&e.focus()})}setCaptureLength(e){this._minCaptureLength=e||Ur}getElement(){return T(this,null,function*(){if(!(!this._enabled||!this._elementSelector)){if(!this._element)try{this._element=yield li(this._elementSelector)}catch(e){this._element=void 0}return this._element}})}get enabled(){return this._enabled}set enabled(e){if(this._enabled!==!!e){this._enabled=!!e;let i=document[`${this._enabled?"add":"remove"}EventListener`];this._events.forEach(s=>i(...s))}}get captureSubmit(){return this._handleSubmit}set captureSubmit(e){this._handleSubmit=!!e}get redirection(){return this._redirection}set redirection(e){this._redirection=e}setEventBus(e){this._eventBus=e}flushMessages(){var e;if(this._eventsQueue=[...new Map(this._eventsQueue).entries()],this._eventsQueue.length>0){let i=this._eventsQueue.shift();for(;i&&i.length===2;)L("trigger:emit",i),(e=this._eventBus)==null||e.emit(...i),i=this._eventsQueue.shift()}else document.activeElement===this._element&&this.notify(Rt,this.getPayload())}destroy(){this._events.forEach(e=>window.removeEventListener(...e))}shouldHandle(e){let i=this.getElementFromEvent(e);return i?(this._element=i,!0):!1}getPayload(e){let i={source:this._element,originalEvent:e};if(this._element instanceof HTMLInputElement){let s=this._element.value.trim();(s.length>=this._minCaptureLength||(e==null?void 0:e.type)==="keydown")&&(i.query=s)}return i}getElementFromEvent(e){if(!e.target||e.target===document||e.target===window)return;let i=e.type==="submit"?"querySelector":"closest",s=e.target[i](this._elementSelector);if(s&&!s.closest("[dfd-hook]"))return s}handleClick(e){this.shouldHandle(e)&&(e.preventDefault(),e.stopImmediatePropagation(),this.notify(Rt,this.getPayload(e)))}handleFocus(e){this.shouldHandle(e)&&(e.stopImmediatePropagation(),this.notify(dt,this.getPayload(e)))}handleInput(e){this.shouldHandle(e)&&this.notify(ut,this.getPayload(e))}handleSubmit(e){this._handleSubmit&&this.shouldHandle(e)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.notify(It,this.getPayload(e)))}handleKeypress(e){e.key==="Enter"&&this.shouldHandle(e)&&(!!this._redirection||this._handleSubmit)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this._redirection?window.location=this._redirection.url:e.type==="keydown"&&this.notify(It,this.getPayload(e)))}notify(e,i){this._eventBus?this._eventBus.emit(e,i):this._eventsQueue.push([e,i]),L("[trigger]",this._eventBus?"[emit]":"[queue]",e,i)}};function Lt(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));if(e)return decodeURIComponent(e[1])}var xs=Object.freeze({language(t){let e=(t==null?void 0:t.replaceAll("_","-").trim().split("-"))||[];function i(s){return s?`-${s.toUpperCase()}`:""}if(e.length<3){let[s,r]=e;return`${s==null?void 0:s.toLowerCase()}${i(r)}`}else{let[s,r,n]=e;return`${s==null?void 0:s.toLowerCase()}-${r.toUpperCase()}${i(n)}`}},currency(t){return t==null?void 0:t.trim().toUpperCase()}});function Ts(){return oi("__DF_CDN_PREFIX__")}function Be(t,e=!1){let i=oi("__DF_LAYER_SERVER__")||`https://${t.toLowerCase()}-layer.doofinder.com`;return e?i.replace(/^http/,"ws"):i}var ft=1;function Fr(){var e;let t=[];return ie(t,"source_url",encodeURIComponent(window.location.href)),ie(t,"session_id",Doofinder.Session.getSessionId()),ie(t,"user_id",Doofinder.Session.getUserId()),ie(t,"session_alive",Doofinder.Session.isLive("chat","layer","quiz")),ie(t,"last_used_apps",Doofinder.Session.getLastUsedApps()),ie(t,"ga_client_id",(e=Lt("_ga"))==null?void 0:e.substring(6)),ie(t,"vsn","1.5.5"),t}function ie(t,e,i){i!=null&&(typeof i!="string"||!!i.trim())&&t.push(`${e}=${i}`)}function ha(t,e){var c;let{installationId:i,zone:s,language:r,currency:n}=t,a=`${Be(s)}/api/${ft}/installation/${i}`,l=[];return ie(l,"source_url",encodeURIComponent(window.location.href)),ie(l,"session_id",Doofinder.Session.getSessionId()),ie(l,"session_alive",Doofinder.Session.isLive("layer","quiz","chat")),ie(l,"last_used_apps",Doofinder.Session.getLastUsedApps()),ie(l,"user_id",Doofinder.Session.getUserId()),ie(l,"language",xs.language(r||document.documentElement.getAttribute("lang"))||""),ie(l,"currency",xs.currency(n)||""),ie(l,"ga_client_id",(c=Lt("_ga"))==null?void 0:c.substring(6)),ie(l,"vsn","1.5.5"),ie(l,"layer_type",e),ie(l,"zone",s),`${a}?${l.join("&")}`}function jr(t){let e=Ts()||t.cdn_prefix;e=="https://cdn.doofinder.com/livelayer"&&(e+="/1");let i=t.vsn;return Vr(t,r=>({url:`${e}${r}?vsn=${i}`}))}function Br(t){if(!t.cdn_fallback_prefix)return jr(t);let e=t.vsn,i=Ts()||t.cdn_prefix+"/"+e;return Vr(t,r=>{let n=`${i}${r}`;n=i.includes("staging")?`${n}?vsn=${e}`:n;let o=`${t.cdn_fallback_prefix}${r}`;return{url:n,fallbackUrl:o}})}function Vr(t,e){return Es()&&(t.js=t.js.map(i=>i.replace(/\.min\.js/i,".js"))),t.css=t.css.map(e),t.js=t.js.map(e),t}function Xr(t,e){return new Promise(function(i,s){fetch(ha(t,e),{redirect:"follow"}).then(function(r){r.ok?r.json().then(function(n){i(Br(n))}):s(`HTTP ${r.status} error response from server`)}).catch(r=>s(r))})}function Jr(t){return T(this,null,function*(){let{chat_id:e,zone:i}=t,s=`${Be(i)}/chat/${e}`,r=Fr(),o=yield(yield fetch(`${s}?${r.join("&")}`,{redirect:"follow"})).json();return jr(o)})}function qr(t){return T(this,null,function*(){let{quiz_id:e,zone:i}=t,s=`${Be(i)}/quiz/${e}`,r=Fr(),o=yield(yield fetch(`${s}?${r.join("&")}`,{redirect:"follow"})).json();return Br(o)})}function Dt(t){return T(this,null,function*(){let{url:e,fallbackUrl:i}=t;if(!document.querySelector(`script[src="${e}"]`)){let s=document.createElement("script");s.src=e,s.async=1,i&&(s.onerror=()=>Dt({url:i})),document.head.appendChild(s)}})}function Ot(t){return T(this,null,function*(){let{url:e,fallbackUrl:i}=t;if(!document.querySelector(`link[rel="stylesheet"][href="${e}"]`)){let s=document.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href",e),i&&(s.onerror=()=>Ot({url:i})),document.head.appendChild(s)}})}function Qe(t){return T(this,null,function*(){let e=document.createElement("style");e.appendChild(document.createTextNode((t||"").trim())),document.head.appendChild(e)})}function Wr(t,e){let i=e.options,s=t.hashid||i.hashid,{autoload:r,insertion_point:n,is_checkout:o}=e,a="urlHash"in t?!!t.urlHash:!!i.url_hash,l=e.layer_type;return delete t.urlHash,delete i.url_hash,Te(I(I({},t),i),{autoload:r,urlHash:a,hashid:s,layerType:l,insertion_point:n,is_checkout:o})}var hi=new Promise((t,e)=>{document.readyState!="loading"?t():document.addEventListener("DOMContentLoaded",()=>{t()})});function Kr(t){return ai("__DF_CDN_PREFIX__",t)}function zr(t){return ai("__DF_LAYER_SERVER__",t)}function Ht(){try{decodeURIComponent(location.href)}catch(t){throw new Error("invalid UTF-8 on url-encoded query params")}}var As="df-cookies-allowed",Cs=window.localStorage;function ks(){Cs.setItem(As,"true")}function Gr(){Cs.removeItem(As)}function ci(){return JSON.parse(Cs.getItem(As)||"false")}var pt=class{constructor(e,i){this._bucket=e,this._store=i||window.localStorage}get data(){return JSON.parse(this._store.getItem(this._bucket))||{}}set data(e){!ci()||this._store.setItem(this._bucket,JSON.stringify(e))}getItem(e){return this.data[e]}setItem(e,i){let s=this.data;s[e]=i,this.data=s}removeItem(e){let i=this.data;delete i[e],this.data=i}clear(){this.data={}}destroy(){this._store.removeItem(this._bucket)}popItem(e){let i=this.data,s=i[e];return delete i[e],this.data=i,s}};var Yr=function(t){let e=t.slice(0,4);return RegExp(`#${e}/(brand-categories|classic|classic-initial|embedded|fullscreen|fullscreen-brand-categories|fullscreen-initial|mobile|mobile-brand-categories|mobile-initial)/`)},Qr=function(t){let e=t.slice(0,4);return RegExp(`#${e}/(category-pages|mobile-category-pages)/`)};"use strict";var Me=window.history,di=class{constructor({installationId:e,autoload:i,urlHash:s,layerType:r}){this._installationId=e,this._layerType=r,this._autoload=i?Object.freeze(i):null,this._urlHash=s,this._storage=new pt(`${e}.data`,window.sessionStorage),this.__initialSetup__()}get hasAutoloadQueryParam(){return this.__getQueryFromAutoload__()!==null}get isTransitory(){return this._isTransitory}get query(){return this.__getQuery__()}get targetItemId(){return this._targetItemId}get value(){return this._value}set targetItemId(e){this._targetItemId=e}saveTransitory(e){if(!this.__valid__(this._value)){L(`[state] [${this._layerType}] saveTransitory: not valid for `,this._value);return}L(`[state] [${this._layerType}] saveTransitory:`,this._value),this._storage.setItem(this.__getStateKey__(),{value:this.__simplify__(this._value),location:e})}update(e,i,s){if(!this.__hasChanged__(e,i,s))return L(`[state] [${this._layerType}] update not performed, the state has not changed.`,e,i,s),!1;this.__valid__(e)&&(L(`[state] [${this._layerType}] new state value: `,e),this._value=e),this._targetItemId=i,this._isTransitory=s;let r=window.location.origin+window.location.pathname+window.location.search;this._urlHash&&(r=r+this._value),L(`[state] [${this._layerType}] replaceState:`,r),Me.replaceState(this.__getNewStateObject__(),"",r)}__hasChanged__(e,i,s){return e!=this._value||i!=this._targetItemId||s!=this._isTransitory}__initialSetup__(){let e=this.__fromHistory__(),i=this.__fromStorage__(),s=e||i||this.__fromHash__()||this.__fromAutoload__()||"";s=s.match("^#([A-Za-z0-9-]+)/(embedded|classic)/$")?"":s,this._value=s,this._targetItemId=this.__getTargetItem__(),this._isTransitory=this.__isTransitory__(!!i),i&&Me.replaceState(this.__getNewStateObject__(),"",window.location.href)}__fromAutoload__(){if(!this._autoload)return L(`[state] [${this._layerType}] __fromAutoload__ with autoload false - state:`,null),null;let e=this.__getQueryFromAutoload__(),i=e!=null?`#/${this._autoload.screen}/q=${e.trim()}`:null;return L(`[state] [${this._layerType}] __fromAutoload__ (query) state:`,i),i}__fromHash__(){let e=this.__validHash__(window.location.hash)?`#${window.location.hash.split("#",2)[1]}`:null;return L(`[state] [${this._layerType}] __fromHash__ state:`,e),e}__fromHistory__(){let e=null;return this.__validDoofinderStateInHistory__()&&(e=Me.state[this.__getStateKey__()].value),L(`[state] [${this._layerType}] __fromHistory__ state:`,e),e}__fromStorage__(){let e=this._storage.popItem(this.__getStateKey__());return!!e&&!window.location.href.includes(e.location)?(L(`[state] [${this._layerType}] __fromStorage__ discarded as it is from diferent location:`,e),null):(L(`[state] [${this._layerType}] __fromStorage__ state:`,e),!!e&&e.value)}__getNewStateObject__(){let e={[this.__getStateKey__()]:{value:this._value,transitory:this._isTransitory,targetItemId:this._targetItemId}};return L(`[state] [${this._layerType}] __getNewStateObject__:`,e),this.__validHistoryState__()?I(I({},Me.state),e):e}__getQuery__(){if(this._value){let e=this._value.split("/"),i=e[e.length-1];return Object.fromEntries(new URLSearchParams(i)).q}return""}__getQueryFromAutoload__(){return this._autoload?new URLSearchParams(window.location.search).get(this._autoload.param):null}__getTargetItem__(){let e=null;return this.__validDoofinderStateInHistory__()&&(e=Me.state[this.__getStateKey__()].targetItemId),L(`[state] [${this._layerType}] __getTargetItem__:`,e),e}__getStateKey__(){return this._layerType=="category_pages"?di.CP_STATE_KEY:di.STATE_KEY}__isTransitory__(e){let i=e;return this.__validDoofinderStateInHistory__()&&(i=Me.state[this.__getStateKey__()].transitory),L(`[state] [${this._layerType}] __isTransitory__:`,i),i}__simplify__(e){let s=new URL(window.location.origin+window.location.pathname+window.location.search+e).hash.split("/"),r=new URLSearchParams(s.pop());return r.get("q")?`${s.join("/")}/m=${r.get("m")}&q=${r.get("q")}`:""}__valid__(e){return this.__validHash__(e)||e===""}__validHistoryState__(){return typeof Me.state=="object"&&Me.state!==null}__validDoofinderStateInHistory__(){return this.__validHistoryState__()&&Me.state[this.__getStateKey__()]!=null}__validHash__(e){let i=this._layerType!=="category_pages"?Yr(this._installationId):Qr(this._installationId);return typeof e=="string"&&(i.test(e)||e.startsWith(`#/${this._installationId}/`))}},Ze=di;_s(Ze,"STATE_KEY","dfState"),_s(Ze,"CP_STATE_KEY","dfCpState");var Mt=t=>typeof t=="function"?t:function(){return t},ca=typeof self!="undefined"?self:null,Nt=typeof window!="undefined"?window:null,et=ca||Nt||et,da="2.0.0",Le={connecting:0,open:1,closing:2,closed:3},ua=1e4,fa=1e3,ge={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},Ne={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},Ps={longpoll:"longpoll",websocket:"websocket"},pa={complete:4},ui=class{constructor(t,e,i,s){this.channel=t,this.event=e,this.payload=i||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:t,response:e,_ref:i}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(e))}cancelRefEvent(){!this.refEvent||this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},Zr=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},ma=class{constructor(t,e,i){this.state=ge.closed,this.topic=t,this.params=Mt(e||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new ui(this,Ne.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Zr(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=ge.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=ge.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=ge.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=ge.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new ui(this,Ne.leave,Mt({}),this.timeout).send(),this.state=ge.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(Ne.reply,(s,r)=>{this.trigger(this.replyEventName(r),s)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(t){this.on(Ne.close,t)}onError(t){return this.on(Ne.error,e=>t(e))}on(t,e){let i=this.bindingRef++;return this.bindings.push({event:t,ref:i,callback:e}),i}off(t,e){this.bindings=this.bindings.filter(i=>!(i.event===t&&(typeof e=="undefined"||e===i.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,i=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new ui(this,t,function(){return e},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=ge.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(Ne.close,"leave")},i=new ui(this,Ne.leave,Mt({}),t);return i.receive("ok",()=>e()).receive("timeout",()=>e()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(t,e,i){return e}isMember(t,e,i,s){return this.topic!==t?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:i,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=ge.joining,this.joinPush.resend(t))}trigger(t,e,i,s){let r=this.onMessage(t,e,i,s);if(e&&!r)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let n=this.bindings.filter(o=>o.event===t);for(let o=0;o{let a=this.parseJSON(t.responseText);o&&o(a)},n&&(t.ontimeout=n),t.onprogress=()=>{},t.send(s),t}static xhrRequest(t,e,i,s,r,n,o,a){return t.open(e,i,!0),t.timeout=n,t.setRequestHeader("Content-Type",s),t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===pa.complete&&a){let l=this.parseJSON(t.responseText);a(l)}},o&&(t.ontimeout=o),t.send(r),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch(e){return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let i=[];for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let r=e?`${e}[${s}]`:s,n=t[s];typeof n=="object"?i.push(this.serialize(n,r)):i.push(encodeURIComponent(r)+"="+encodeURIComponent(n))}return i.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let i=t.match(/\?/)?"&":"?";return`${t}${i}${this.serialize(e)}`}},ga=t=>{let e="",i=new Uint8Array(t),s=i.byteLength;for(let r=0;rthis.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+Ps.websocket),"$1/"+Ps.longpoll)}endpointURL(){return fi.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,i){this.close(t,e,i),this.readyState=Le.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Le.open||this.readyState===Le.connecting}poll(){this.ajax("GET","application/json",null,()=>this.ontimeout(),t=>{if(t){var{status:e,token:i,messages:s}=t;this.token=i}else e=0;switch(e){case 200:s.forEach(r=>{setTimeout(()=>this.onmessage({data:r}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=Le.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${e}`)}})}send(t){typeof t!="string"&&(t=ga(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t){this.awaitingBatchAck=!0,this.ajax("POST","application/x-ndjson",t.join(` `),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,!e||e.status!==200?(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(t,e,i){for(let r of this.reqs)r.abort();this.readyState=Le.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent!="undefined"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(t,e,i,s,r){let n,o=()=>{this.reqs.delete(n),s()};n=fi.request(t,this.endpointURL(),e,i,this.timeout,o,a=>{this.reqs.delete(n),this.isActive()&&r(a)}),this.reqs.add(n)}};var pi={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let i=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(i))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[i,s,r,n,o]=JSON.parse(t);return e({join_ref:i,ref:s,topic:r,event:n,payload:o})}},binaryEncode(t){let{join_ref:e,ref:i,event:s,topic:r,payload:n}=t,o=this.META_LENGTH+e.length+i.length+r.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),c=0;l.setUint8(c++,this.KINDS.push),l.setUint8(c++,e.length),l.setUint8(c++,i.length),l.setUint8(c++,r.length),l.setUint8(c++,s.length),Array.from(e,m=>l.setUint8(c++,m.charCodeAt(0))),Array.from(i,m=>l.setUint8(c++,m.charCodeAt(0))),Array.from(r,m=>l.setUint8(c++,m.charCodeAt(0))),Array.from(s,m=>l.setUint8(c++,m.charCodeAt(0)));var f=new Uint8Array(a.byteLength+n.byteLength);return f.set(new Uint8Array(a),0),f.set(new Uint8Array(n),a.byteLength),f.buffer},binaryDecode(t){let e=new DataView(t),i=e.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(t,e,s);case this.KINDS.reply:return this.decodeReply(t,e,s);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,s)}},decodePush(t,e,i){let s=e.getUint8(1),r=e.getUint8(2),n=e.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=i.decode(t.slice(o,o+s));o=o+s;let l=i.decode(t.slice(o,o+r));o=o+r;let c=i.decode(t.slice(o,o+n));o=o+n;let f=t.slice(o,t.byteLength);return{join_ref:a,ref:null,topic:l,event:c,payload:f}},decodeReply(t,e,i){let s=e.getUint8(1),r=e.getUint8(2),n=e.getUint8(3),o=e.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=i.decode(t.slice(a,a+s));a=a+s;let c=i.decode(t.slice(a,a+r));a=a+r;let f=i.decode(t.slice(a,a+n));a=a+n;let m=i.decode(t.slice(a,a+o));a=a+o;let v=t.slice(a,t.byteLength),E={status:m,response:v};return{join_ref:l,ref:c,topic:f,event:Ne.reply,payload:E}},decodeBroadcast(t,e,i){let s=e.getUint8(1),r=e.getUint8(2),n=this.HEADER_LENGTH+2,o=i.decode(t.slice(n,n+s));n=n+s;let a=i.decode(t.slice(n,n+r));n=n+r;let l=t.slice(n,t.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},en=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=e.timeout||ua,this.transport=e.transport||et.WebSocket||$t,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=e.sessionStorage||et&&et.sessionStorage,this.establishedConnections=0,this.defaultEncoder=pi.encode.bind(pi),this.defaultDecoder=pi.decode.bind(pi),this.closeWasClean=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.transport!==$t?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;Nt&&Nt.addEventListener&&(Nt.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),Nt.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect())})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>e.rejoinAfterMs?e.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>e.reconnectAfterMs?e.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(s,r,n)=>{console.log(`${s}: ${r}`,n)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=Mt(e.params||{}),this.endPoint=`${t}/${Ps.websocket}`,this.vsn=e.vsn||da,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Zr(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return $t}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=fi.appendParams(fi.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,i){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(t,e,i)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Mt(t)),!this.conn&&(this.longPollFallbackMs&&this.transport!==$t?this.connectWithFallback($t,this.longPollFallbackMs):this.transportConnect())}log(t,e,i){this.logger&&this.logger(t,e,i)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let s=this.onMessage(r=>{r.ref===e&&(this.off([s]),t(Date.now()-i))});return!0}transportConnect(){this.connectClock++,this.closeWasClean=!1,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=t=>this.onConnError(t),this.conn.onmessage=t=>this.onConnMessage(t),this.conn.onclose=t=>this.onConnClose(t)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let i=!1,s=!0,r,n,o=a=>{this.log("transport",`falling back to ${t.name}...`,a),this.off([r,n]),s=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${t.name}`))return o("memorized");this.fallbackTimer=setTimeout(o,e),n=this.onError(a=>{this.log("transport","error",a),s&&!i&&(clearTimeout(this.fallbackTimer),o(a))}),this.onOpen(()=>{if(i=!0,!s)return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t.name}`,"true"),this.log("transport",`established ${t.name} fallback`);clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,e),this.ping(a=>{this.log("transport","connected to primary after",a),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transport.name} connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,t])=>t())}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),fa,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,i){if(!this.conn)return t&&t();this.waitForBufferDone(()=>{this.conn&&(e?this.conn.close(e,i||""):this.conn.close()),this.waitForSocketClosed(()=>{this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e=1){if(e===5||!this.conn||!this.conn.bufferedAmount){t();return}setTimeout(()=>{this.waitForBufferDone(t,e+1)},150*e)}waitForSocketClosed(t,e=1){if(e===5||!this.conn||this.conn.readyState===Le.closed){t();return}setTimeout(()=>{this.waitForSocketClosed(t,e+1)},150*e)}onConnClose(t){let e=t&&t.code;this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&e!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(t))}onConnError(t){this.hasLogger()&&this.log("transport",t);let e=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(t,e,i)}),(e===this.transport||i>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(Ne.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case Le.connecting:return"connecting";case Le.open:return"open";case Le.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([i])=>t.indexOf(i)===-1)}channel(t,e={}){let i=new ma(t,e,this);return this.channels.push(i),i}push(t){if(this.hasLogger()){let{topic:e,event:i,payload:s,ref:r,join_ref:n}=t;this.log("push",`${e} ${i} (${n}, ${r})`,s)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:i,event:s,payload:r,ref:n,join_ref:o}=e;n&&n===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${r.status||""} ${i} ${s} ${n&&"("+n+")"||""}`,r);for(let a=0;ai.topic===t&&(i.isJoined()||i.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}};var tn=(t,e,i)=>{e.forEach(s=>{t.addEventListener(s,i)})},sn=(t,e,i)=>{e.forEach(s=>{t.removeEventListener(s,i)})},Rs=class{constructor(e){this.defaults={idle:1e4,events:["mousemove","scroll","keydown","mousedown","touchstart"],onIdle:null,onActive:null,onHide:null,onShow:null,keepTracking:!0,startAtIdle:!1,recurIdleCall:!1},this.throwOnBadKey(Object.keys(e),Object.keys(this.defaults)),this.settings=Object.assign({},this.defaults,e),this.visibilityEvents=["visibilitychange","webkitvisibilitychange","mozvisibilitychange","msvisibilitychange"],this.clearTimeout=null,this.reset(),this.stopListener=i=>{this.stop()},this.idlenessEventsHandler=i=>{this.idle&&(this.idle=!1,this.settings.onActive&&this.settings.onActive.call()),this.resetTimeout(this.settings)},this.visibilityEventsHandler=i=>{document.hidden||document.webkitHidden||document.mozHidden||document.msHidden?this.visible&&(this.visible=!1,this.settings.onHide&&this.settings.onHide.call()):this.visible||(this.visible=!0,this.settings.onShow&&this.settings.onShow.call())}}resetTimeout(e,i=this.settings.keepTracking){this.clearTimeout&&(this.clearTimeout(),this.clearTimeout=null),i&&this.timeout(this.settings)}timeout(e){var i=this.settings.recurIdleCall?{set:setInterval.bind(window),clear:clearInterval.bind(window)}:{set:setTimeout.bind(window),clear:clearTimeout.bind(window)},s=i.set(function(){this.idle=!0,this.settings.onIdle&&this.settings.onIdle.call()}.bind(this),this.settings.idle);this.clearTimeout=()=>i.clear(s)}start(){return window.addEventListener("idle:stop",this.stopListener),this.timeout(this.settings),tn(window,this.settings.events,this.idlenessEventsHandler),(this.settings.onShow||this.settings.onHide)&&tn(document,this.visibilityEvents,this.visibilityEventsHandler),this}stop(){return window.removeEventListener("idle:stop",this.stopListener),sn(window,this.settings.events,this.idlenessEventsHandler),this.resetTimeout(this.settings,!1),(this.settings.onShow||this.settings.onHide)&&sn(document,this.visibilityEvents,this.visibilityEventsHandler),this}reset({idle:e=this.settings.startAtIdle,visible:i=!this.settings.startAtIdle}={}){return this.idle=e,this.visible=i,this}throwOnBadKey(e,i){e.forEach(function(s){if(!i.includes(s))throw`set: Unknown key ${s}`})}set(e){this.throwOnBadKey(Object.keys(e),Object.keys(this.defaults)),this.settings=Object.assign(this.settings,e)}};var Is=class extends en{constructor(e,i={}){super(e,i);this.preventReconnect=!1,this.shouldReconnect=!1,this.idleMonitor=new Rs({idle:3*60*1e3,onActive:this.onShowOrActive.bind(this),onShow:this.onShowOrActive.bind(this)}),this.idleMonitor.start()}onShowOrActive(){this.shouldReconnect&&this.idleMonitor.visible&&!this.idleMonitor.idle&&(this.shouldReconnect=!1,this.reconnectTimer.scheduleTimeout())}onConnClose(e){this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),this.preventReconnect||(this.closeWasClean?this.idleMonitor.stop():this.scheduleReconnect()),this.stateChangeCallbacks.close.forEach(([,i])=>i(e))}scheduleReconnect(){!this.idleMonitor.idle&&this.idleMonitor.visible?this.reconnectTimer.scheduleTimeout():(this.reconnectTimer.reset(),this.shouldReconnect=!0)}};var U="search",mi="consecutive-reloads",rn=10,nn=5e3,on=1e4,an=3e4,gi=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],_e="data-phx-component";var ln="track-static";var le="data-phx-ref",De="data-phx-ref-src",_i="track-uploads",ve="data-phx-upload-ref",mt="data-phx-preflighted-refs",hn="data-phx-done-refs",Ls="drop-target",Ut="data-phx-active-refs",gt=`${U}:live-file:updated`,vi="data-phx-skip",bi="data-phx-id",Ds="data-phx-prune",Os="page-loading",Hs="phx-connected",_t="phx-loading",Ft="phx-no-feedback",jt="phx-error",Ms="phx-client-error",yi="phx-server-error",tt="data-phx-parent-id",Si="data-phx-main",Oe="data-dfd-root-id",Ei="viewport-top",wi="viewport-bottom",cn="trigger-action",it="feedback-for",st="feedback-group",Bt="phx-has-focused",dn=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],xi=["checkbox","radio"],vt="phx-has-submitted",Se="data-dfd-view",$e=`[${Se}]`,Ns="data-phx-sticky",Ve="data-phx-static",Ti="data-phx-readonly",rt="data-phx-disabled",Vt="disable-with",Xt="data-phx-disable-with-restore",bt="hook",un="debounce",fn="throttle",yt="update",Ai="stream",Ci="data-phx-stream",pn="key",Ae="phxPrivate",$s="auto-recover",Jt="phx:live-socket:debug",ki="phx:live-socket:profiling",Pi="phx:live-socket:latency-sim",mn="progress",Us="mounted",gn=1,_n=200,vn="dfd-",bn=3e4;var St="debounce-trigger",Et="throttled",Fs="debounce-prev-key",yn={debounce:300,throttle:300},qt="d",Ce="s",Ri="r",he="c",js="e",Bs="r",Vs="t",Sn="p",Xs="stream";var Ii=class{constructor(e,i,s){this.liveSocket=s,this.entry=e,this.offset=0,this.chunkSize=i,this.chunkTimer=null,this.errored=!1,this.uploadChannel=s.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(e))}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,i=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=s=>{if(s.target.error===null)this.offset+=s.target.result.byteLength,this.pushChunk(s.target.result);else return se("Read error: "+s.target.error)},e.readAsArrayBuffer(i)}pushChunk(e){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))}).receive("error",({reason:i})=>this.error(i))}};var se=(t,e)=>console.error&&console.error(t,e),Ee=t=>{let e=typeof t;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(t)};function En(t=document){let e=new Set,i=t.querySelectorAll("*[id]");for(let s=0,r=i.length;s{t.liveSocket.isDebugEnabled()&&console.log(`${t.id} ${e}: ${i} - `,s)},Li=t=>typeof t=="function"?t:function(){return t},wt=t=>JSON.parse(JSON.stringify(t)),xt=(t,e,i)=>{do{if(t.matches(`[${e}]`)&&!t.disabled)return t;t=t.parentElement||t.parentNode}while(t!==null&&t.nodeType===1&&!(i&&i.isSameNode(t)||t.matches($e)));return null},nt=t=>t!==null&&typeof t=="object"&&!(t instanceof Array),xn=(t,e)=>JSON.stringify(t)===JSON.stringify(e),Js=t=>{for(let e in t)return!1;return!0},ke=(t,e)=>t&&e(t),Tn=function(t,e,i,s){t.forEach(r=>{new Ii(r,i.config.chunk_size,s).upload()})};var An={canPushState(){return typeof history.pushState!="undefined"},dropLocal(t,e,i){return t.removeItem(this.localKey(e,i))},updateLocal(t,e,i,s,r){let n=this.getLocal(t,e,i),o=this.localKey(e,i),a=n===null?s:r(n);return t.setItem(o,JSON.stringify(a)),a},getLocal(t,e,i){return JSON.parse(t.getItem(this.localKey(e,i)))},updateCurrentState(t){!this.canPushState()||history.replaceState(t(history.state||{}),"",window.location.href)},pushState(t,e,i){if(this.canPushState()){if(i!==window.location.href){if(e.type=="redirect"&&e.scroll){let r=history.state||{};r.scroll=e.scroll,history.replaceState(r,"",window.location.href)}delete e.scroll,history[t+"State"](e,"",i||null);let s=this.getHashTargetEl(window.location.hash);s?s.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)}}else this.redirect(i)},setCookie(t,e){document.cookie=`${t}=${e}`},getCookie(t){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${t}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(t,e){e&&An.setCookie("__phoenix_flash__",e+"; max-age=60000; path=/"),window.location=t},localKey(t,e){return`${t}-${e}`},getHashTargetEl(t){let e=t.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},be=An;var _a={focusMain(){let t=document.querySelector("main h1, main, h1");if(t){let e=t.tabIndex;t.tabIndex=-1,t.focus(),t.tabIndex=e}},anyOf(t,e){return e.find(i=>t instanceof i)},isFocusable(t,e){return t instanceof HTMLAnchorElement&&t.rel!=="ignore"||t instanceof HTMLAreaElement&&t.href!==void 0||!t.disabled&&this.anyOf(t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||t instanceof HTMLIFrameElement||t.tabIndex>0||!e&&t.getAttribute("tabindex")!==null&&t.getAttribute("aria-hidden")!=="true"},attemptFocus(t,e){if(this.isFocusable(t,e))try{t.focus()}catch(i){}return!!document.activeElement&&document.activeElement.isSameNode(t)},focusFirstInteractive(t){let e=t.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(t){let e=t.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(t){let e=t.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},Xe=_a;var Di=null,Cn=200,va={exec(t,e,i,s,r){let[n,o]=r||[null,{callback:r&&r.callback}];(e.charAt(0)==="["?JSON.parse(e):[[n,o]]).forEach(([l,c])=>{l===n&&o.data&&(c.data=Object.assign(c.data||{},o.data),c.callback=c.callback||o.callback),this.filterToEls(s,c).forEach(f=>{this[`exec_${l}`](t,e,i,s,f,c)})})},isVisible(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length>0)},isInViewport(t){let e=t.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth;return e.right>0&&e.bottom>0&&e.left{let c=l.getAttribute(n);if(!c)throw new Error(`expected ${n} to contain JS command on "${o}"`);i.liveSocket.execJS(l,c,t)})},exec_dispatch(t,e,i,s,r,{to:n,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=s,p.dispatchEvent(r,o,{detail:a,bubbles:l})},exec_push(t,e,i,s,r,n){let{event:o,data:a,target:l,page_loading:c,loading:f,value:m,dispatcher:v,callback:E}=n,b={loading:f,value:m,target:l,page_loading:!!c},w=t==="change"&&v?v:s,N=l||w.getAttribute(i.binding("target"))||w;i.withinTargets(N,(O,D)=>{if(!!O.isConnected())if(t==="change"){let{newCid:j,_target:q}=n;q=q||(p.isFormInput(s)?s.name:void 0),q&&(b._target=q),O.pushInput(s,D,j,o||e,b,E)}else if(t==="submit"){let{submitter:j}=n;O.submitForm(s,D,o||e,j,b,E)}else O.pushEvent(t,s,D,o||e,a,b,E)})},exec_navigate(t,e,i,s,r,{href:n,replace:o}){i.liveSocket.historyRedirect(n,o?"replace":"push")},exec_patch(t,e,i,s,r,{href:n,replace:o}){i.liveSocket.pushHistoryPatch(n,o?"replace":"push",s)},exec_focus(t,e,i,s,r){window.requestAnimationFrame(()=>Xe.attemptFocus(r))},exec_focus_first(t,e,i,s,r){window.requestAnimationFrame(()=>Xe.focusFirstInteractive(r)||Xe.focusFirst(r))},exec_push_focus(t,e,i,s,r){window.requestAnimationFrame(()=>Di=r||s)},exec_pop_focus(t,e,i,s,r){window.requestAnimationFrame(()=>{Di&&Di.focus(),Di=null})},exec_add_class(t,e,i,s,r,{names:n,transition:o,time:a}){this.addOrRemoveClasses(r,n,[],o,a,i)},exec_remove_class(t,e,i,s,r,{names:n,transition:o,time:a}){this.addOrRemoveClasses(r,[],n,o,a,i)},exec_toggle_class(t,e,i,s,r,{to:n,names:o,transition:a,time:l}){this.toggleClasses(r,o,a,i)},exec_toggle_attr(t,e,i,s,r,{attr:[n,o,a]}){r.hasAttribute(n)?a!==void 0?r.getAttribute(n)===o?this.setOrRemoveAttrs(r,[[n,a]],[]):this.setOrRemoveAttrs(r,[[n,o]],[]):this.setOrRemoveAttrs(r,[],[n]):this.setOrRemoveAttrs(r,[[n,o]],[])},exec_transition(t,e,i,s,r,{time:n,transition:o}){this.addOrRemoveClasses(r,[],[],o,n,i)},exec_toggle(t,e,i,s,r,{display:n,ins:o,outs:a,time:l}){this.toggle(t,i,r,n,o,a,l)},exec_show(t,e,i,s,r,{display:n,transition:o,time:a}){this.show(t,i,r,n,o,a)},exec_hide(t,e,i,s,r,{display:n,transition:o,time:a}){this.hide(t,i,r,n,o,a)},exec_set_attr(t,e,i,s,r,{attr:[n,o]}){this.setOrRemoveAttrs(r,[[n,o]],[])},exec_remove_attr(t,e,i,s,r,{attr:n}){this.setOrRemoveAttrs(r,[],[n])},show(t,e,i,s,r,n){this.isVisible(i)||this.toggle(t,e,i,s,r,null,n)},hide(t,e,i,s,r,n){this.isVisible(i)&&this.toggle(t,e,i,s,null,r,n)},toggle(t,e,i,s,r,n,o){o=o||Cn;let[a,l,c]=r||[[],[],[]],[f,m,v]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(i)){let E=()=>{this.addOrRemoveClasses(i,m,a.concat(l).concat(c)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,v,m))})};i.dispatchEvent(new Event(`${U}:hide-start`)),e.transition(o,E,()=>{this.addOrRemoveClasses(i,[],f.concat(v)),p.putSticky(i,"toggle",b=>b.style.display="none"),i.dispatchEvent(new Event(`${U}:hide-end`))})}else{if(t==="remove")return;let E=()=>{this.addOrRemoveClasses(i,l,f.concat(m).concat(v));let b=s||this.defaultDisplay(i);p.putSticky(i,"toggle",w=>w.style.display=b),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,c,l))})};i.dispatchEvent(new Event(`${U}:show-start`)),e.transition(o,E,()=>{this.addOrRemoveClasses(i,[],a.concat(c)),i.dispatchEvent(new Event(`${U}:show-end`))})}else this.isVisible(i)?window.requestAnimationFrame(()=>{i.dispatchEvent(new Event(`${U}:hide-start`)),p.putSticky(i,"toggle",E=>E.style.display="none"),i.dispatchEvent(new Event(`${U}:hide-end`))}):window.requestAnimationFrame(()=>{i.dispatchEvent(new Event(`${U}:show-start`));let E=s||this.defaultDisplay(i);p.putSticky(i,"toggle",b=>b.style.display=E),i.dispatchEvent(new Event(`${U}:show-end`))})},toggleClasses(t,e,i,s,r){window.requestAnimationFrame(()=>{let[n,o]=p.getSticky(t,"classes",[[],[]]),a=e.filter(c=>n.indexOf(c)<0&&!t.classList.contains(c)),l=e.filter(c=>o.indexOf(c)<0&&t.classList.contains(c));this.addOrRemoveClasses(t,a,l,i,s,r)})},addOrRemoveClasses(t,e,i,s,r,n){r=r||Cn;let[o,a,l]=s||[[],[],[]];if(o.length>0){let c=()=>{this.addOrRemoveClasses(t,a,[].concat(o).concat(l)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,o,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,l,a))})},f=()=>this.addOrRemoveClasses(t,e.concat(l),i.concat(o).concat(a));return n.transition(r,c,f)}window.requestAnimationFrame(()=>{let[c,f]=p.getSticky(t,"classes",[[],[]]),m=e.filter(w=>c.indexOf(w)<0&&!t.classList.contains(w)),v=i.filter(w=>f.indexOf(w)<0&&t.classList.contains(w)),E=c.filter(w=>i.indexOf(w)<0).concat(m),b=f.filter(w=>e.indexOf(w)<0).concat(v);p.putSticky(t,"classes",w=>(w.classList.remove(...b),w.classList.add(...E),[E,b]))})},setOrRemoveAttrs(t,e,i){let[s,r]=p.getSticky(t,"attrs",[[],[]]),n=e.map(([l,c])=>l).concat(i),o=s.filter(([l,c])=>!n.includes(l)).concat(e),a=r.filter(l=>!n.includes(l)).concat(i);p.putSticky(t,"attrs",l=>(a.forEach(c=>l.removeAttribute(c)),o.forEach(([c,f])=>l.setAttribute(c,f)),[o,a]))},hasAllClasses(t,e){return e.every(i=>t.classList.contains(i))},isToggledOut(t,e){return!this.isVisible(t)||this.hasAllClasses(t,e)},filterToEls(t,{to:e}){return e?p.all(document,e):[t]},defaultDisplay(t){return{tr:"table-row",td:"table-cell"}[t.tagName.toLowerCase()]||"block"}},ee=va;var we={byId(t){return document.getElementById(t)||se(`no id found for ${t}`)},removeClass(t,e){t.classList.remove(e),t.classList.length===0&&t.removeAttribute("class")},all(t,e,i){if(!t)return[];let s=Array.from(t.querySelectorAll(e));return i?s.forEach(i):s},childNodeLength(t){let e=document.createElement("template");return e.innerHTML=t,e.content.childElementCount},isUploadInput(t){return t.type==="file"&&t.getAttribute(ve)!==null},isAutoUpload(t){return t.hasAttribute("data-phx-auto-upload")},findUploadInputs(t){let e=t.id,i=this.all(document,`input[type="file"][${ve}][form="${e}"]`);return this.all(t,`input[type="file"][${ve}]`).concat(i)},findComponentNodeList(t,e){return this.filterWithinSameLiveView(this.all(t,`[${_e}="${e}"]`),t)},isPhxDestroyed(t){return!!(t.id&&we.private(t,"destroyed"))},wantsNewTab(t){let e=t.ctrlKey||t.shiftKey||t.metaKey||t.button&&t.button===1,i=t.target instanceof HTMLAnchorElement&&t.target.hasAttribute("download"),s=t.target.hasAttribute("target")&&t.target.getAttribute("target").toLowerCase()==="_blank";return e||s||i},isUnloadableFormSubmit(t){return t.target&&t.target.getAttribute("method")==="dialog"||t.submitter&&t.submitter.getAttribute("formmethod")==="dialog"?!1:!t.defaultPrevented&&!this.wantsNewTab(t)},isNewPageClick(t,e){let i=t.target instanceof HTMLAnchorElement?t.target.getAttribute("href"):null,s;if(t.defaultPrevented||i===null||this.wantsNewTab(t)||i.startsWith("mailto:")||i.startsWith("tel:")||t.target.isContentEditable)return!1;try{s=new URL(i)}catch(r){try{s=new URL(i,e)}catch(n){return!0}}return s.host===e.host&&s.protocol===e.protocol&&s.pathname===e.pathname&&s.search===e.search?s.hash===""&&!s.href.endsWith("#"):s.protocol.startsWith("http")},markPhxChildDestroyed(t){this.isPhxChild(t)&&t.setAttribute(Se,""),this.putPrivate(t,"destroyed",!0)},findPhxChildrenInFragment(t,e){let i=document.createElement("template");return i.innerHTML=t,this.findPhxChildren(i.content,e)},isIgnored(t,e){return(t.getAttribute(e)||t.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(t,e,i){return t.getAttribute&&i.indexOf(t.getAttribute(e))>=0},findPhxSticky(t){return this.all(t,`[${Ns}]`)},findPhxChildren(t,e){return this.all(t,`${$e}[${tt}="${e}"]`)},findParentCIDs(t,e){let i=new Set(e),s=e.reduce((r,n)=>{let o=`[${_e}="${n}"] [${_e}]`;return this.filterWithinSameLiveView(this.all(t,o),t).map(a=>parseInt(a.getAttribute(_e))).forEach(a=>r.delete(a)),r},i);return s.size===0?new Set(e):s},filterWithinSameLiveView(t,e){return e.querySelector($e)?t.filter(i=>this.withinSameLiveView(i,e)):t},withinSameLiveView(t,e){for(;t=t.parentNode;){if(t.isSameNode(e))return!0;if(t.getAttribute(Se)!==null)return!1}},private(t,e){return t[Ae]&&t[Ae][e]},deletePrivate(t,e){t[Ae]&&delete t[Ae][e]},putPrivate(t,e,i){t[Ae]||(t[Ae]={}),t[Ae][e]=i},updatePrivate(t,e,i,s){let r=this.private(t,e);r===void 0?this.putPrivate(t,e,s(i)):this.putPrivate(t,e,s(r))},copyPrivates(t,e){e[Ae]&&(t[Ae]=e[Ae])},putTitle(t){let e=document.querySelector("title");if(e){let{prefix:i,suffix:s}=e.dataset;document.title=`${i||""}${t}${s||""}`}else document.title=t},debounce(t,e,i,s,r,n,o,a){let l=t.getAttribute(i),c=t.getAttribute(r);l===""&&(l=s),c===""&&(c=n);let f=l||c;switch(f){case null:return a();case"blur":this.once(t,"debounce-blur")&&t.addEventListener("blur",()=>a());return;default:let m=parseInt(f),v=()=>c?this.deletePrivate(t,Et):a(),E=this.incCycle(t,St,v);if(isNaN(m))return se(`invalid throttle/debounce value: ${f}`);if(c){let w=!1;if(e.type==="keydown"){let N=this.private(t,Fs);this.putPrivate(t,Fs,e.key),w=N!==e.key}if(!w&&this.private(t,Et))return!1;{a();let N=setTimeout(()=>{o()&&this.triggerCycle(t,St)},m);this.putPrivate(t,Et,N)}}else setTimeout(()=>{o()&&this.triggerCycle(t,St,E)},m);let b=t.form;b&&this.once(b,"bind-debounce")&&b.addEventListener("submit",()=>{Array.from(new FormData(b).entries(),([w])=>{let N=b.querySelector(`[name="${w}"]`);this.incCycle(N,St),this.deletePrivate(N,Et)})}),this.once(t,"bind-debounce")&&t.addEventListener("blur",()=>{clearTimeout(this.private(t,Et)),this.triggerCycle(t,St)})}},triggerCycle(t,e,i){let[s,r]=this.private(t,e);i||(i=s),i===s&&(this.incCycle(t,e),r())},once(t,e){return this.private(t,e)===!0?!1:(this.putPrivate(t,e,!0),!0)},incCycle(t,e,i=function(){}){let[s]=this.private(t,e)||[0,i];return s++,this.putPrivate(t,e,[s,i]),s},isFeedbackContainer(t,e){return t.hasAttribute&&t.hasAttribute(e)},maybeHideFeedback(t,e,i,s){let r={};e.forEach(n=>{if(!t.contains(n))return;let o=n.getAttribute(i);if(!o){ee.addOrRemoveClasses(n,[],[Ft]);return}if(r[o]===!0){this.hideFeedback(n);return}r[o]=this.shouldHideFeedback(t,o,s),r[o]===!0&&this.hideFeedback(n)})},hideFeedback(t){ee.addOrRemoveClasses(t,[Ft],[])},shouldHideFeedback(t,e,i){let s=`[name="${e}"], [name="${e}[]"], [${i}="${e}"]`,r=!1;return we.all(t,s,n=>{(this.private(n,Bt)||this.private(n,vt))&&(r=!0)}),!r},feedbackSelector(t,e,i){let s=`[${e}="${t.name}"], [${e}="${t.name.replace(/\[\]$/,"")}"]`;return t.getAttribute(i)&&(s+=`,[${e}="${t.getAttribute(i)}"]`),s},resetForm(t,e,i){Array.from(t.elements).forEach(s=>{let r=this.feedbackSelector(s,e,i);this.deletePrivate(s,Bt),this.deletePrivate(s,vt),this.all(document,r,n=>{ee.addOrRemoveClasses(n,[Ft],[])})})},showError(t,e,i){if(t.name){let s=this.feedbackSelector(t,e,i);this.all(document,s,r=>{ee.addOrRemoveClasses(r,[],[Ft])})}},isPhxChild(t){return t.getAttribute&&t.getAttribute(tt)},isPhxSticky(t){return t.getAttribute&&t.getAttribute(Ns)!==null},isChildOfAny(t,e){return!!e.find(i=>i.contains(t))},firstPhxChild(t){return this.isPhxChild(t)?t:this.all(t,`[${tt}]`)[0]},dispatchEvent(t,e,i={}){let s=!0;t.nodeName==="INPUT"&&t.type==="file"&&e==="click"&&(s=!1);let o={bubbles:i.bubbles===void 0?s:!!i.bubbles,cancelable:!0,detail:i.detail||{}},a=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);t.dispatchEvent(a)},cloneNode(t,e){if(typeof e=="undefined")return t.cloneNode(!0);{let i=t.cloneNode(!1);return i.innerHTML=e,i}},mergeAttrs(t,e,i={}){let s=new Set(i.exclude||[]),r=i.isIgnored,n=e.attributes;for(let a=n.length-1;a>=0;a--){let l=n[a].name;if(s.has(l))l==="value"&&t.value===e.value&&t.setAttribute("value",e.getAttribute(l));else{let c=e.getAttribute(l);t.getAttribute(l)!==c&&(!r||r&&l.startsWith("data-"))&&t.setAttribute(l,c)}}let o=t.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;r?l.startsWith("data-")&&!e.hasAttribute(l)&&![le,De].includes(l)&&t.removeAttribute(l):e.hasAttribute(l)||t.removeAttribute(l)}},mergeFocusedInput(t,e){t instanceof HTMLSelectElement||we.mergeAttrs(t,e,{exclude:["value"]}),e.readOnly?t.setAttribute("readonly",!0):t.removeAttribute("readonly")},hasSelectionRange(t){return t.setSelectionRange&&(t.type==="text"||t.type==="textarea")},restoreFocus(t,e,i){if(t instanceof HTMLSelectElement&&t.focus(),!we.isTextualInput(t))return;let s=t.matches(":focus");t.readOnly&&t.blur(),s||t.focus(),this.hasSelectionRange(t)&&t.setSelectionRange(e,i)},isFormInput(t){return/^(?:input|select|textarea)$/i.test(t.tagName)&&t.type!=="button"},syncAttrsToProps(t){t instanceof HTMLInputElement&&xi.indexOf(t.type.toLocaleLowerCase())>=0&&(t.checked=t.getAttribute("checked")!==null)},isTextualInput(t){return dn.indexOf(t.type)>=0},isNowTriggerFormExternal(t,e){return t.getAttribute&&t.getAttribute(e)!==null},syncPendingRef(t,e,i){let s=t.getAttribute(le);if(s===null)return!0;let r=t.getAttribute(De);return we.isFormInput(t)||t.getAttribute(i)!==null?(we.isUploadInput(t)&&we.mergeAttrs(t,e,{isIgnored:!0}),we.putPrivate(t,le,e),!1):(gi.forEach(n=>{t.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(le,s),e.setAttribute(De,r),!0)},cleanChildNodes(t,e){if(we.isPhxUpdate(t,e,["append","prepend"])){let i=[];t.childNodes.forEach(s=>{s.id||(!(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()==="")&&s.nodeType!==s.COMMENT_NODE&&se(`only HTML element tags with an id are allowed inside containers with phx-update. removing illegal node: "${(s.outerHTML||s.nodeValue).trim()}" `),i.push(s))}),i.forEach(s=>s.remove())}},replaceRootContainer(t,e,i){let s=new Set(["id",Se,Ve,Si,Oe]);if(t.tagName.toLowerCase()===e.toLowerCase())return Array.from(t.attributes).filter(r=>!s.has(r.name.toLowerCase())).forEach(r=>t.removeAttribute(r.name)),Object.keys(i).filter(r=>!s.has(r.toLowerCase())).forEach(r=>t.setAttribute(r,i[r])),t;{let r=document.createElement(e);return Object.keys(i).forEach(n=>r.setAttribute(n,i[n])),s.forEach(n=>r.setAttribute(n,t.getAttribute(n))),r.innerHTML=t.innerHTML,t.replaceWith(r),r}},getSticky(t,e,i){let s=(we.private(t,"sticky")||[]).find(([r])=>e===r);if(s){let[r,n,o]=s;return o}else return typeof i=="function"?i():i},deleteSticky(t,e){this.updatePrivate(t,"sticky",[],i=>i.filter(([s,r])=>s!==e))},putSticky(t,e,i){let s=i(t);this.updatePrivate(t,"sticky",[],r=>{let n=r.findIndex(([o])=>e===o);return n>=0?r[n]=[e,i,s]:r.push([e,i,s]),r})},applyStickyOperations(t){let e=we.private(t,"sticky");!e||e.forEach(([i,s,r])=>this.putSticky(t,i,s))}},p=we;var He=class{static isActive(e,i){let s=i._phxRef===void 0,r=He.isPreflightInProgress(i),o=e.getAttribute(Ut).split(",").indexOf(X.genFileRef(i))>=0;return i.size>0&&(s||o||!r)}static isPreflighted(e,i){return e.getAttribute(mt).split(",").indexOf(X.genFileRef(i))>=0&&this.isActive(e,i)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,i,s){this.ref=X.genFileRef(i),this.fileEl=e,this.file=i,this.view=s,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(gt,this._onElUpdated)}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{X.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}cancel(){this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(gt,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),p.isAutoUpload(this.fileEl)||X.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(gt,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Ut).split(",").indexOf(this.ref)===-1&&this.cancel()}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let i=e[this.meta.uploader]||se(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:i}}else return{name:"channel",callback:Tn}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||se(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var ba=0,X=class{static genFileRef(e){let i=e._phxRef;return i!==void 0?i:(e._phxRef=(ba++).toString(),e._phxRef)}static getEntryDataURL(e,i,s){let r=this.activeFiles(e).find(n=>this.genFileRef(n)===i);s(URL.createObjectURL(r))}static hasUploadsInProgress(e){let i=0;return p.findUploadInputs(e).forEach(s=>{s.getAttribute(mt)!==s.getAttribute(hn)&&i++}),i>0}static serializeUploads(e){let i=this.activeFiles(e),s={};return i.forEach(r=>{let n={path:e.name},o=e.getAttribute(ve);s[o]=s[o]||[],n.ref=this.genFileRef(r),n.last_modified=r.lastModified,n.name=r.name||n.ref,n.relative_path=r.webkitRelativePath,n.type=r.type,n.size=r.size,typeof r.meta=="function"&&(n.meta=r.meta()),s[o].push(n)}),s}static clearFiles(e){e.value=null,e.removeAttribute(ve),p.putPrivate(e,"files",[])}static untrackFile(e,i){p.putPrivate(e,"files",p.private(e,"files").filter(s=>!Object.is(s,i)))}static trackFiles(e,i,s){if(e.getAttribute("multiple")!==null){let r=i.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));p.putPrivate(e,"files",this.activeFiles(e).concat(r)),e.value=null}else s&&s.files.length>0&&(e.files=s.files),p.putPrivate(e,"files",i)}static activeFileInputs(e){let i=p.findUploadInputs(e);return Array.from(i).filter(s=>s.files&&this.activeFiles(s).length>0)}static activeFiles(e){return(p.private(e,"files")||[]).filter(i=>He.isActive(e,i))}static inputsAwaitingPreflight(e){let i=p.findUploadInputs(e);return Array.from(i).filter(s=>this.filesAwaitingPreflight(s).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(i=>!He.isPreflighted(e,i)&&!He.isPreflightInProgress(i))}static markPreflightInProgress(e){e.forEach(i=>He.markPreflightInProgress(i.file))}constructor(e,i,s){this.view=i,this.onComplete=s,this._entries=Array.from(X.filesAwaitingPreflight(e)||[]).map(r=>new He(e,r,i)),X.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,i,s){this._entries=this._entries.map(n=>(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),n));let r=this._entries.reduce((n,o)=>{if(!o.meta)return n;let{name:a,callback:l}=o.uploader(s.uploaders);return n[a]=n[a]||{callback:l,entries:[]},n[a].entries.push(o),n},{});for(let n in r){let{callback:o,entries:a}=r[n];o(a,i,e,s)}}};var ya={LiveFileUpload:{activeRefs(){return this.el.getAttribute(Ut)},preflightedRefs(){return this.el.getAttribute(mt)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let t=this.preflightedRefs();this.preflightedWas!==t&&(this.preflightedWas=t,t===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(gt))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(ve)),X.getEntryDataURL(this.inputEl,this.ref,t=>{this.url=t,this.el.src=t})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>Xe.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>Xe.focusFirst(this.el)),this.el.addEventListener(`${U}:show-end`,()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&Xe.focusFirst(this.el)}}},kn=ya;var Oi=class{constructor(e,i,s){let r=new Set,n=new Set([...i.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(r.add(a.id),n.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=i.id,this.updateType=s,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!r.has(a))}perform(){let e=p.byId(this.containerId);this.elementsToModify.forEach(i=>{i.previousElementId?ke(document.getElementById(i.previousElementId),s=>{ke(document.getElementById(i.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==s.id||s.insertAdjacentElement("afterend",r)})}):ke(document.getElementById(i.elementId),s=>{s.previousElementSibling==null||e.insertAdjacentElement("afterbegin",s)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(i=>{ke(document.getElementById(i),s=>e.insertAdjacentElement("afterbegin",s))})}};var Pn=11;function Sa(t,e){var i=e.attributes,s,r,n,o,a;if(!(e.nodeType===Pn||t.nodeType===Pn)){for(var l=i.length-1;l>=0;l--)s=i[l],r=s.name,n=s.namespaceURI,o=s.value,n?(r=s.localName||r,a=t.getAttributeNS(n,r),a!==o&&(s.prefix==="xmlns"&&(r=s.name),t.setAttributeNS(n,r,o))):(a=t.getAttribute(r),a!==o&&t.setAttribute(r,o));for(var c=t.attributes,f=c.length-1;f>=0;f--)s=c[f],r=s.name,n=s.namespaceURI,n?(r=s.localName||r,e.hasAttributeNS(n,r)||t.removeAttributeNS(n,r)):e.hasAttribute(r)||t.removeAttribute(r)}}var Hi,Ea="http://www.w3.org/1999/xhtml",ue=typeof document=="undefined"?void 0:document,wa=!!ue&&"content"in ue.createElement("template"),xa=!!ue&&ue.createRange&&"createContextualFragment"in ue.createRange();function Ta(t){var e=ue.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function Aa(t){Hi||(Hi=ue.createRange(),Hi.selectNode(ue.body));var e=Hi.createContextualFragment(t);return e.childNodes[0]}function Ca(t){var e=ue.createElement("body");return e.innerHTML=t,e.childNodes[0]}function ka(t){return t=t.trim(),wa?Ta(t):xa?Aa(t):Ca(t)}function Mi(t,e){var i=t.nodeName,s=e.nodeName,r,n;return i===s?!0:(r=i.charCodeAt(0),n=s.charCodeAt(0),r<=90&&n>=97?i===s.toUpperCase():n<=90&&r>=97?s===i.toUpperCase():!1)}function Pa(t,e){return!e||e===Ea?ue.createElement(t):ue.createElementNS(e,t)}function Ra(t,e){for(var i=t.firstChild;i;){var s=i.nextSibling;e.appendChild(i),i=s}return e}function qs(t,e,i){t[i]!==e[i]&&(t[i]=e[i],t[i]?t.setAttribute(i,""):t.removeAttribute(i))}var Rn={OPTION:function(t,e){var i=t.parentNode;if(i){var s=i.nodeName.toUpperCase();s==="OPTGROUP"&&(i=i.parentNode,s=i&&i.nodeName.toUpperCase()),s==="SELECT"&&!i.hasAttribute("multiple")&&(t.hasAttribute("selected")&&!e.selected&&(t.setAttribute("selected","selected"),t.removeAttribute("selected")),i.selectedIndex=-1)}qs(t,e,"selected")},INPUT:function(t,e){qs(t,e,"checked"),qs(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),e.hasAttribute("value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var i=e.value;t.value!==i&&(t.value=i);var s=t.firstChild;if(s){var r=s.nodeValue;if(r==i||!i&&r==t.placeholder)return;s.nodeValue=i}},SELECT:function(t,e){if(!e.hasAttribute("multiple")){for(var i=-1,s=0,r=t.firstChild,n,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")n=r,r=n.firstChild;else{if(o==="OPTION"){if(r.hasAttribute("selected")){i=s;break}s++}r=r.nextSibling,!r&&n&&(r=n.nextSibling,n=null)}t.selectedIndex=i}}},Wt=1,In=11,Ln=3,Dn=8;function Je(){}function Ia(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}function La(t){return function(i,s,r){if(r||(r={}),typeof s=="string")if(i.nodeName==="#document"||i.nodeName==="HTML"||i.nodeName==="BODY"){var n=s;s=ue.createElement("html"),s.innerHTML=n}else s=ka(s);else s.nodeType===In&&(s=s.firstElementChild);var o=r.getNodeKey||Ia,a=r.onBeforeNodeAdded||Je,l=r.onNodeAdded||Je,c=r.onBeforeElUpdated||Je,f=r.onElUpdated||Je,m=r.onBeforeNodeDiscarded||Je,v=r.onNodeDiscarded||Je,E=r.onBeforeElChildrenUpdated||Je,b=r.skipFromChildren||Je,w=r.addChild||function(k,C){return k.appendChild(C)},N=r.childrenOnly===!0,O=Object.create(null),D=[];function j(k){D.push(k)}function q(k,C){if(k.nodeType===Wt)for(var J=k.firstChild;J;){var R=void 0;C&&(R=o(J))?j(R):(v(J),J.firstChild&&q(J,C)),J=J.nextSibling}}function Z(k,C,J){m(k)!==!1&&(C&&C.removeChild(k),v(k),q(k,J))}function W(k){if(k.nodeType===Wt||k.nodeType===In)for(var C=k.firstChild;C;){var J=o(C);J&&(O[J]=C),W(C),C=C.nextSibling}}W(i);function B(k){l(k);for(var C=k.firstChild;C;){var J=C.nextSibling,R=o(C);if(R){var F=O[R];F&&Mi(C,F)?(C.parentNode.replaceChild(F,C),g(F,C)):B(C)}else B(C);C=J}}function ye(k,C,J){for(;C;){var R=C.nextSibling;(J=o(C))?j(J):Z(C,k,!0),C=R}}function g(k,C,J){var R=o(C);R&&delete O[R],!(!J&&(c(k,C)===!1||(t(k,C),f(k),E(k,C)===!1)))&&(k.nodeName!=="TEXTAREA"?P(k,C):Rn.TEXTAREA(k,C))}function P(k,C){var J=b(k,C),R=C.firstChild,F=k.firstChild,je,me,Re,Ge,oe;e:for(;R;){for(Ge=R.nextSibling,je=o(R);!J&&F;){if(Re=F.nextSibling,R.isSameNode&&R.isSameNode(F)){R=Ge,F=Re;continue e}me=o(F);var ct=F.nodeType,xe=void 0;if(ct===R.nodeType&&(ct===Wt?(je?je!==me&&((oe=O[je])?Re===oe?xe=!1:(k.insertBefore(oe,F),me?j(me):Z(F,k,!0),F=oe,me=o(F)):xe=!1):me&&(xe=!1),xe=xe!==!1&&Mi(F,R),xe&&g(F,R)):(ct===Ln||ct==Dn)&&(xe=!0,F.nodeValue!==R.nodeValue&&(F.nodeValue=R.nodeValue))),xe){R=Ge,F=Re;continue e}me?j(me):Z(F,k,!0),F=Re}if(je&&(oe=O[je])&&Mi(oe,R))J||w(k,oe),g(oe,R);else{var Ct=a(R);Ct!==!1&&(Ct&&(R=Ct),R.actualize&&(R=R.actualize(k.ownerDocument||ue)),w(k,R),B(R))}R=Ge,F=Re}ye(k,F,me);var ti=Rn[k.nodeName];ti&&ti(k,C)}var H=i,Y=H.nodeType,pe=s.nodeType;if(!N){if(Y===Wt)pe===Wt?Mi(i,s)||(v(i),H=Ra(i,Pa(s.nodeName,s.namespaceURI))):H=s;else if(Y===Ln||Y===Dn){if(pe===Y)return H.nodeValue!==s.nodeValue&&(H.nodeValue=s.nodeValue),H;H=s}}if(H===s)v(i);else{if(s.isSameNode&&s.isSameNode(H))return;if(g(H,s,N),D)for(var At=0,os=D.length;At{if(s&&s.isSameNode(r)&&p.isFormInput(r))return p.mergeFocusedInput(r,n),!1}})}constructor(e,i,s,r,n,o){this.view=e,this.liveSocket=e.liveSocket,this.container=i,this.id=s,this.rootID=e.root.id,this.html=r,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=o,this.cidPatch=Ee(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,i){this.callbacks[`before${e}`].push(i)}after(e,i){this.callbacks[`after${e}`].push(i)}trackBefore(e,...i){this.callbacks[`before${e}`].forEach(s=>s(...i))}trackAfter(e,...i){this.callbacks[`after${e}`].forEach(s=>s(...i))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(yt);p.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,i=>{i.setAttribute(Ds,"")})}perform(e){let{view:i,liveSocket:s,container:r,html:n}=this,o=this.isCIDPatch()?this.targetCIDContainer(n):r;if(this.isCIDPatch()&&!o)return;let a=s.getActiveElement(),{selectionStart:l,selectionEnd:c}=a&&p.hasSelectionRange(a)?a:{},f=s.binding(yt),m=s.binding(it),v=s.binding(st),E=s.binding(Vt),b=s.binding(Ei),w=s.binding(wi),N=s.binding(cn),O=[],D=[],j=[],q=[],Z=null;function W(B,ye){Ws(B,ye,{childrenOnly:B.getAttribute(_e)===null,getNodeKey:g=>p.isPhxDestroyed(g)?null:e?g.id:g.id||g.getAttribute&&g.getAttribute(bi),skipFromChildren:g=>g.getAttribute(f)===Ai,addChild:(g,P)=>{let{ref:H,streamAt:Y}=this.getStreamInsert(P);if(H===void 0)return g.appendChild(P);if(this.setStreamRef(P,H),Y===0)g.insertAdjacentElement("afterbegin",P);else if(Y===-1)g.appendChild(P);else if(Y>0){let pe=Array.from(g.children)[Y];g.insertBefore(P,pe)}},onBeforeNodeAdded:g=>{this.trackBefore("added",g);let P=g;return!e&&this.streamComponentRestore[g.id]&&(P=this.streamComponentRestore[g.id],delete this.streamComponentRestore[g.id],W.bind(this)(P,g)),P},onNodeAdded:g=>{g.getAttribute&&this.maybeReOrderStream(g,!0),p.isFeedbackContainer(g,m)&&D.push(g),g instanceof HTMLImageElement&&g.srcset?g.srcset=g.srcset:g instanceof HTMLVideoElement&&g.autoplay&&g.play(),p.isNowTriggerFormExternal(g,N)&&(Z=g),(p.isPhxChild(g)&&i.ownsElement(g)||p.isPhxSticky(g)&&i.ownsElement(g.parentNode))&&this.trackAfter("phxChildAdded",g),O.push(g)},onNodeDiscarded:g=>this.onNodeDiscarded(g),onBeforeNodeDiscarded:g=>g.getAttribute&&g.getAttribute(Ds)!==null?!0:!(g.parentElement!==null&&g.id&&p.isPhxUpdate(g.parentElement,f,[Ai,"append","prepend"])||this.maybePendingRemove(g)||this.skipCIDSibling(g)),onElUpdated:g=>{p.isNowTriggerFormExternal(g,N)&&(Z=g),j.push(g),this.maybeReOrderStream(g,!1)},onBeforeElUpdated:(g,P)=>{if((p.isFeedbackContainer(g,m)||p.isFeedbackContainer(P,m))&&(D.push(g),D.push(P)),p.cleanChildNodes(P,f),this.skipCIDSibling(P))return this.maybeReOrderStream(g),!1;if(p.isPhxSticky(g))return!1;if(p.isIgnored(g,f)||g.form&&g.form.isSameNode(Z))return this.trackBefore("updated",g,P),p.mergeAttrs(g,P,{isIgnored:!0}),j.push(g),p.applyStickyOperations(g),!1;if(g.type==="number"&&g.validity&&g.validity.badInput)return!1;if(!p.syncPendingRef(g,P,E))return p.isUploadInput(g)&&(this.trackBefore("updated",g,P),j.push(g)),p.applyStickyOperations(g),!1;if(p.isPhxChild(P)){let pe=g.getAttribute(Se);return p.mergeAttrs(g,P,{exclude:[Ve]}),pe!==""&&g.setAttribute(Se,pe),g.setAttribute(Oe,this.rootID),p.applyStickyOperations(g),!1}p.copyPrivates(P,g);let H=a&&g.isSameNode(a)&&p.isFormInput(g),Y=H&&this.isChangedSelect(g,P);return H&&g.type!=="hidden"&&!Y?(this.trackBefore("updated",g,P),p.mergeFocusedInput(g,P),p.syncAttrsToProps(g),j.push(g),p.applyStickyOperations(g),!1):(Y&&g.blur(),p.isPhxUpdate(P,f,["append","prepend"])&&q.push(new Oi(g,P,P.getAttribute(f))),p.syncAttrsToProps(P),p.applyStickyOperations(P),this.trackBefore("updated",g,P),!0)}})}return this.trackBefore("added",r),this.trackBefore("updated",r,r),s.time("morphdom",()=>{this.streams.forEach(([B,ye,g,P])=>{ye.forEach(([H,Y,pe])=>{this.streamInserts[H]={ref:B,streamAt:Y,limit:pe,reset:P}}),P!==void 0&&p.all(r,`[${Ci}="${B}"]`,H=>{this.removeStreamChildElement(H)}),g.forEach(H=>{let Y=r.querySelector(`[id="${H}"]`);Y&&this.removeStreamChildElement(Y)})}),e&&p.all(this.container,`[${f}=${Ai}]`,B=>{this.liveSocket.owner(B,ye=>{ye===this.view&&Array.from(B.children).forEach(g=>{this.removeStreamChildElement(g)})})}),W.bind(this)(o,n)}),s.isDebugEnabled()&&En(s.doofinderMount),q.length>0&&s.time("post-morph append/prepend restoration",()=>{q.forEach(B=>B.perform())}),p.maybeHideFeedback(o,D,m,v),s.silenceEvents(()=>p.restoreFocus(a,l,c)),p.dispatchEvent(document,`${U}:update`),O.forEach(B=>this.trackAfter("added",B)),j.forEach(B=>this.trackAfter("updated",B)),this.transitionPendingRemoves(),Z&&(s.unload(),Object.getPrototypeOf(Z).submit.call(Z)),!0}onNodeDiscarded(e){(p.isPhxChild(e)||p.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e){this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,i){p.putSticky(e,Ci,s=>s.setAttribute(Ci,i))}maybeReOrderStream(e,i){let{ref:s,streamAt:r,reset:n}=this.getStreamInsert(e);if(r!==void 0&&(this.setStreamRef(e,s),!(!n&&!i)&&!!e.parentElement)){if(r===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(r>0){let o=Array.from(e.parentElement.children),a=o.indexOf(e);if(r>=o.length-1)e.parentElement.appendChild(e);else{let l=o[r];a>r?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:i}=this.getStreamInsert(e),s=i!==null&&Array.from(e.parentElement.children);i&&i<0&&s.length>i*-1?s.slice(0,s.length+i).forEach(r=>this.removeStreamChildElement(r)):i&&i>=0&&s.length>i&&s.slice(i).forEach(r=>this.removeStreamChildElement(r))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:i}=this;e.length>0&&(i.transitionRemoves(e),i.requestDOMUpdate(()=>{e.forEach(s=>{let r=p.firstPhxChild(s);r&&i.destroyViewByEl(r),s.remove()}),this.trackAfter("transitionsDiscarded",e)}))}isChangedSelect(e,i){if(!(e instanceof HTMLSelectElement)||e.multiple)return!1;if(e.options.length!==i.options.length)return!0;let s=e.selectedOptions[0],r=i.selectedOptions[0];return s&&s.hasAttribute("selected")&&r.setAttribute("selected",s.getAttribute("selected")),!e.isEqualNode(i)}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(vi)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[i,...s]=p.findComponentNodeList(this.container,this.targetCID);return s.length===0&&p.childNodeLength(e)===1?i:i&&i.parentNode}indexOf(e,i){return Array.from(e.children).indexOf(i)}};var Oa=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Ha=new Set(["'",'"']),On=(t,e,i)=>{let s=0,r=!1,n,o,a,l,c,f,m=t.match(/^(\s*(?:\s*)*)<([^\s\/>]+)/);if(m===null)throw new Error(`malformed html ${t}`);for(s=m[0].length,n=m[1],a=m[2],l=s,s;s";s++)if(t.charAt(s)==="="){let b=t.slice(s-3,s)===" id";s++;let w=t.charAt(s);if(Ha.has(w)){let N=s;for(s++,s;s=n.length+a.length;){let b=t.charAt(v);if(r)b==="-"&&t.slice(v-3,v)===""&&t.slice(v-2,v)==="--")r=!0,v-=3;else{if(b===">")break;v-=1}}o=t.slice(v+1,t.length);let E=Object.keys(e).map(b=>e[b]===!0?b:`${b}="${e[b]}"`).join(" ");if(i){let b=c?` id="${c}"`:"";Oa.has(a)?f=`<${a}${b}${E===""?"":" "}${E}/>`:f=`<${a}${b}${E===""?"":" "}${E}>`}else{let b=t.slice(l,v+1);f=`<${a}${E===""?"":" "}${E}${b}`}return[f,n,o]},Kt=class{static extract(e){let{[Bs]:i,[js]:s,[Vs]:r}=e;return delete e[Bs],delete e[js],delete e[Vs],{diff:e,title:r,reply:i||null,events:s||[]}}constructor(e,i){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(i)}parentViewId(){return this.viewId}toString(e){let[i,s]=this.recursiveToString(this.rendered,this.rendered[he],e,!0,{});return[i,s]}recursiveToString(e,i=e[he],s,r,n){s=s?new Set(s):null;let o={buffer:"",components:i,onlyCids:s,streams:new Set};return this.toOutputBuffer(e,null,o,r,n),[o.buffer,o.streams]}componentCIDs(e){return Object.keys(e[he]||{}).map(i=>parseInt(i))}isComponentOnlyDiff(e){return e[he]?Object.keys(e).length===1:!1}getComponent(e,i){return e[he][i]}resetRender(e){this.rendered[he][e]&&(this.rendered[he][e].reset=!0)}mergeDiff(e){let i=e[he],s={};if(delete e[he],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[he]=this.rendered[he]||{},i){let r=this.rendered[he];for(let n in i)i[n]=this.cachedFindComponent(n,i[n],r,i,s);for(let n in i)r[n]=i[n];e[he]=i}}cachedFindComponent(e,i,s,r,n){if(n[e])return n[e];{let o,a,l=i[Ce];if(Ee(l)){let c;l>0?c=this.cachedFindComponent(l,r[l],s,r,n):c=s[-l],a=c[Ce],o=this.cloneMerge(c,i,!0),o[Ce]=a}else o=i[Ce]!==void 0||s[e]===void 0?i:this.cloneMerge(s[e],i,!1);return n[e]=o,o}}mutableMerge(e,i){return i[Ce]!==void 0?i:(this.doMutableMerge(e,i),e)}doMutableMerge(e,i){for(let s in i){let r=i[s],n=e[s];nt(r)&&r[Ce]===void 0&&nt(n)?this.doMutableMerge(n,r):e[s]=r}e[Ri]&&(e.newRender=!0)}cloneMerge(e,i,s){let r=I(I({},e),i);for(let n in r){let o=i[n],a=e[n];nt(o)&&o[Ce]===void 0&&nt(a)?r[n]=this.cloneMerge(a,o,s):o===void 0&&nt(a)&&(r[n]=this.cloneMerge(a,{},s))}return s?(delete r.magicId,delete r.newRender):e[Ri]&&(r.newRender=!0),r}componentToString(e){let[i,s]=this.recursiveCIDToString(this.rendered[he],e,null),[r,n,o]=On(i,{});return[r,s]}pruneCIDs(e){e.forEach(i=>delete this.rendered[he][i])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[Ce]}templateStatic(e,i){return typeof e=="number"?i[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,i,s,r,n={}){if(e[qt])return this.comprehensionToBuffer(e,i,s);let{[Ce]:o}=e;o=this.templateStatic(o,i);let a=e[Ri],l=s.buffer;a&&(s.buffer=""),r&&a&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),s.buffer+=o[0];for(let c=1;c0||c.length>0||f)&&(delete e[Xs],e[qt]=[],s.streams.add(o))}dynamicToBuffer(e,i,s,r){if(typeof e=="number"){let[n,o]=this.recursiveCIDToString(s.components,e,s.onlyCids);s.buffer+=n,s.streams=new Set([...s.streams,...o])}else nt(e)?this.toOutputBuffer(e,i,s,r,{}):s.buffer+=e}recursiveCIDToString(e,i,s){let r=e[i]||se(`no component for CID ${i}`,e),n={[_e]:i},o=s&&!s.has(i);r.newRender=!o,r.magicId=`c${i}-${this.parentViewId()}`;let a=!r.reset,[l,c]=this.recursiveToString(r,e,s,a,n);return delete r.reset,[l,c]}};var Ma=1,qe=class{static makeID(){return Ma++}static elementID(e){return e.phxHookId}constructor(e,i,s){this.__view=e,this.liveSocket=e.liveSocket,this.__callbacks=s,this.__listeners=new Set,this.__isDisconnected=!1,this.el=i,this.el.phxHookId=this.constructor.makeID();for(let r in this.__callbacks)this[r]=this.__callbacks[r]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,i={},s=function(){}){return this.__view.pushHookEvent(this.el,null,e,i,s)}pushEventTo(e,i,s={},r=function(){}){return this.__view.withinTargets(e,(n,o)=>n.pushHookEvent(this.el,o,i,s,r))}handleEvent(e,i){let s=(r,n)=>n?e:i(r.detail);return this.liveSocket.doofinderMount.addEventListener(`${U}:${e}`,s),this.__listeners.add(s),s}removeHandleEvent(e){let i=e(null,!0);this.liveSocket.doofinderMount.removeEventListener(`${U}:${i}`,e),this.__listeners.delete(e)}upload(e,i){return this.__view.dispatchUploads(null,e,i)}uploadTo(e,i,s){return this.__view.withinTargets(e,(r,n)=>{r.dispatchUploads(n,i,s)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var Ni=(t,e,i=[])=>{let c=e,{submitter:s}=c,r=Dr(c,["submitter"]),n;if(s&&s.name){let f=document.createElement("input");f.type="hidden";let m=s.getAttribute("form");m&&f.setAttribute("form",m),f.name=s.name,f.value=s.value,s.parentElement.insertBefore(f,s),n=f}let o=new FormData(t),a=[];o.forEach((f,m,v)=>{f instanceof File&&a.push(m)}),a.forEach(f=>o.delete(f));let l=new URLSearchParams;for(let[f,m]of o.entries())(i.length===0||i.indexOf(f)>=0)&&l.append(f,m);s&&n&&s.parentElement.removeChild(n);for(let f in r)l.append(f,r[f]);return l.toString()},Tt=class{constructor(e,i,s,r,n){this.isDead=!1,this.liveSocket=i,this.flash=r,this.parent=s,this.root=s?s.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let o=this.href&&this.expandURL(this.href);return{redirect:this.redirect?o:void 0,url:this.redirect?void 0:o||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}})}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(Si)}connectParams(e){let i=this.liveSocket.params(this.el),s=p.all(document,`[${this.binding(ln)}]`).map(r=>r.src||r.href).filter(r=>typeof r=="string");return s.length>0&&(i._track_static=s),i._mounts=this.joinCount,i._live_referer=e,i}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(Se)}getStatic(){let e=this.el.getAttribute(Ve);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let i=()=>{e();for(let s in this.viewHooks)this.destroyHook(this.viewHooks[s])};p.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",i).receive("error",i).receive("timeout",i)}setContainerClasses(...e){this.el.classList.remove(Hs,_t,jt,Ms,yi),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let i in this.viewHooks)this.viewHooks[i].__disconnected();this.setContainerClasses(_t)}}execAll(e){p.all(this.el,`[${e}]`,i=>this.liveSocket.execJS(i,i.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(Hs),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,i){this.liveSocket.log(this,e,i)}transition(e,i,s=function(){}){this.liveSocket.transition(e,i,s)}withinTargets(e,i){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,s=>i(s,e));if(Ee(e))p.findComponentNodeList(this.el,e).length===0?se(`no component found matching phx-target of ${e}`):i(this,parseInt(e));else{let s=Array.from(document.querySelectorAll(e));s.length===0&&se(`nothing found matching the phx-target selector "${e}"`),s.forEach(r=>this.liveSocket.owner(r,n=>i(n,r)))}}applyDiff(e,i,s){this.log(e,()=>["",wt(i)]);let{diff:r,reply:n,events:o,title:a}=Kt.extract(i);s({diff:r,reply:n,events:o}),a&&window.requestAnimationFrame(()=>p.putTitle(a))}onJoin(e){let{rendered:i,container:s}=e;if(s){let[r,n]=s;this.el=p.replaceRootContainer(this.el,r,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,be.dropLocal(this.liveSocket.localStorage,window.location.pathname,mi),this.applyDiff("mount",i,({diff:r,events:n})=>{this.rendered=new Kt(this.id,r);let[o,a]=this.renderContainer(null,"join");this.dropPendingRefs();let l=this.formsForRecovery(o);this.joinCount++,l.length>0?l.forEach(([c,f,m],v)=>{this.pushFormRecovery(c,m,E=>{v===l.length-1&&this.onJoinComplete(E,o,a,n)})}):this.onJoinComplete(e,o,a,n)})}dropPendingRefs(){p.all(document,`[${De}="${this.id}"][${le}]`,e=>{e.removeAttribute(le),e.removeAttribute(De)})}onJoinComplete({live_patch:e},i,s,r){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,i,s,r);p.findPhxChildrenInFragment(i,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(Ve);return l&&o.setAttribute(Ve,l),a&&a.setAttribute(Oe,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,i,s,r)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,i,s,r)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,i,s,r)])}attachTrueDocEl(){this.el=p.byId(this.id),this.el.setAttribute(Oe,this.root.id)}execNewMounted(){let e=this.binding(Ei),i=this.binding(wi);p.all(this.el,`[${e}], [${i}]`,s=>{this.maybeAddNewHook(s)}),p.all(this.el,`[${this.binding(bt)}], [data-phx-${bt}]`,s=>{this.maybeAddNewHook(s)}),p.all(this.el,`[${this.binding(Us)}]`,s=>this.maybeMounted(s))}applyJoinPatch(e,i,s,r){this.attachTrueDocEl();let n=new ot(this,this.el,this.id,i,s,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(r),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,i){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,i]);let s=this.getHook(e),r=s&&p.isIgnored(e,this.binding(yt));if(s&&!e.isEqualNode(i)&&!(r&&xn(e.dataset,i.dataset)))return s.__beforeUpdate(),s}maybeMounted(e){let i=e.getAttribute(this.binding(Us)),s=i&&p.private(e,"mounted");i&&!s&&(this.liveSocket.execJS(e,i),p.putPrivate(e,"mounted",!0))}maybeAddNewHook(e,i){let s=this.addHook(e);s&&s.__mounted()}performPatch(e,i,s=!1){let r=[],n=!1,o=new Set;return e.after("added",a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.after("phxChildAdded",a=>{p.isPhxSticky(a)?this.liveSocket.joinRootViews():n=!0}),e.before("updated",(a,l)=>{this.triggerBeforeUpdateHook(a,l)&&o.add(a.id)}),e.after("updated",a=>{o.has(a.id)&&this.getHook(a).__updated()}),e.after("discarded",a=>{a.nodeType===Node.ELEMENT_NODE&&r.push(a)}),e.after("transitionsDiscarded",a=>this.afterElementsRemoved(a,i)),e.perform(s),this.afterElementsRemoved(r,i),n}afterElementsRemoved(e,i){let s=[];e.forEach(r=>{let n=p.all(r,`[${_e}]`),o=p.all(r,`[${this.binding(bt)}]`);n.concat(r).forEach(a=>{let l=this.componentID(a);Ee(l)&&s.indexOf(l)===-1&&s.push(l)}),o.concat(r).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),i&&this.maybePushComponentsDestroyed(s)}joinNewChildren(){p.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(tt)][e.id]}destroyDescendent(e){for(let i in this.root.children)for(let s in this.root.children[i])if(s===e)return this.root.children[i][s].destroy()}joinChild(e){if(!this.getChildById(e.id)){let s=new Tt(e,this.liveSocket,this);return this.root.children[this.id][s.id]=s,s.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,i])=>{e.isDestroyed()||i()}),this.pendingJoinOps=[]})}update(e,i){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:i});this.rendered.mergeDiff(e);let s=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{p.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(s=!0)})}):Js(e)||this.liveSocket.time("full patch complete",()=>{let[r,n]=this.renderContainer(e,"update"),o=new ot(this,this.el,this.id,r,n,null);s=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(i),s&&this.joinNewChildren()}renderContainer(e,i){return this.liveSocket.time(`toString diff (${i})`,()=>{let s=this.el.tagName,r=e?this.rendered.componentCIDs(e):null,[n,o]=this.rendered.toString(r);return[`<${s}>${n}`,o]})}componentPatch(e,i){if(Js(e))return!1;let[s,r]=this.rendered.componentToString(i),n=new ot(this,this.el,this.id,s,r,i);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[qe.elementID(e)]}addHook(e){if(qe.elementID(e)||!e.getAttribute)return;let i=e.getAttribute(`data-phx-${bt}`)||e.getAttribute(this.binding(bt));if(i&&!this.ownsElement(e))return;let s=this.liveSocket.getHookCallbacks(i);if(s){e.id||se(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);let r=new qe(this,e,s);return this.viewHooks[qe.elementID(r.el)]=r,r}else i!==null&&se(`unknown hook found for "${i}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[qe.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:i})=>this.update(e,i)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let i=this.root.children[this.id]||{};for(let s in i)e(this.getChildById(s))}onChannel(e,i){this.liveSocket.onChannel(this.channel,e,s=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>i(s)]):this.liveSocket.requestDOMUpdate(()=>i(s))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:i,events:s})=>this.update(i,s))})}),this.onChannel("redirect",({to:e,flash:i})=>this.onRedirect({to:e,flash:i})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:i,kind:s,flash:r}=e,n=this.expandURL(i);this.liveSocket.historyRedirect(n,s,r)}onLivePatch(e){let{to:i,kind:s}=e;this.href=this.expandURL(i),this.liveSocket.historyPatch(i,s)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:i}){this.liveSocket.redirect(e,i)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=i=>{i=i||function(){},e?e(this.joinCount,i):i()},this.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",i=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(i))}).receive("error",i=>!this.isDestroyed()&&this.onJoinError(i)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page request`,e]),this.isMain()&&this.onRedirect({to:this.href});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.isMain()&&this.onRedirect({to:this.href});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);this.displayError([_t,jt,yi]),this.log("error",()=>["unable to join",e]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this)}onClose(e){if(!this.isDestroyed()){if(this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(_n)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([_t,jt,yi]):this.displayError([_t,jt,Ms]))}displayError(e){this.isMain()&&p.dispatchEvent(window,`${U}:page-loading-start`,{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.execAll(this.binding("disconnected"))}pushWithReply(e,i,s,r=function(){}){if(!this.isConnected())return;let[n,[o],a]=e?e():[null,[],{}],l=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(Os))!==null)&&(l=this.liveSocket.withPageLoading({kind:"element",target:o})),typeof s.cid!="number"&&delete s.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(i,s,bn).receive("ok",c=>{let f=m=>{c.redirect&&this.onRedirect(c.redirect),c.live_patch&&this.onLivePatch(c.live_patch),c.live_redirect&&this.onLiveRedirect(c.live_redirect),l(),r(c,m)};c.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",c.diff,({diff:m,reply:v,events:E})=>{n!==null&&this.undoRefs(n),this.update(m,E),f(v)})}):(n!==null&&this.undoRefs(n),f(null))}))}undoRefs(e){!this.isConnected()||p.all(document,`[${De}="${this.id}"][${le}="${e}"]`,i=>{let s=i.getAttribute(rt),r=i.getAttribute(Ti);i.removeAttribute(le),i.removeAttribute(De),r!==null&&(i.readOnly=r==="true",i.removeAttribute(Ti)),s!==null&&(i.disabled=s==="true",i.removeAttribute(rt)),gi.forEach(a=>p.removeClass(i,a));let n=i.getAttribute(Xt);n!==null&&(i.innerText=n,i.removeAttribute(Xt));let o=p.private(i,le);if(o){let a=this.triggerBeforeUpdateHook(i,o);ot.patchEl(i,o,this.liveSocket.getActiveElement()),a&&a.__updated(),p.deletePrivate(i,le)}})}putRef(e,i,s={}){let r=this.ref++,n=this.binding(Vt);return s.loading&&(e=e.concat(p.all(document,s.loading))),e.forEach(o=>{o.classList.add(`phx-${i}-loading`),o.setAttribute(le,r),o.setAttribute(De,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(Xt)||o.setAttribute(Xt,o.innerText),a!==""&&(o.innerText=a),o.setAttribute(rt,o.getAttribute(rt)||o.disabled),o.setAttribute("disabled",""))}),[r,e,s]}componentID(e){let i=e.getAttribute&&e.getAttribute(_e);return i?parseInt(i):null}targetComponentID(e,i,s={}){if(Ee(i))return i;let r=s.target||e.getAttribute(this.binding("target"));return Ee(r)?parseInt(r):i&&(r!==null||s.target)?this.closestComponentID(i):null}closestComponentID(e){return Ee(e)?e:e?ke(e.closest(`[${_e}]`),i=>this.ownsElement(i)&&this.componentID(i)):null}pushHookEvent(e,i,s,r,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",s,r]),!1;let[o,a,l]=this.putRef([e],"hook");return this.pushWithReply(()=>[o,a,l],"event",{type:"hook",event:s,value:r,cid:this.closestComponentID(i)},(c,f)=>n(f,o)),o}extractMeta(e,i,s){let r=this.binding("value-");for(let n=0;n=0&&!e.checked&&delete i.value),s){i||(i={});for(let n in s)i[n]=s[n]}return i}pushEvent(e,i,s,r,n,o={},a){this.pushWithReply(()=>this.putRef([i],e,o),"event",{type:e,event:r,value:this.extractMeta(i,n,o.value),cid:this.targetComponentID(i,s,o)},(l,c)=>a&&a(c))}pushFileProgress(e,i,s,r=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(mn)),ref:e.getAttribute(ve),entry_ref:i,progress:s,cid:n.targetComponentID(e.form,o)},r)})}pushInput(e,i,s,r,n,o){let a,l=Ee(s)?s:this.targetComponentID(e.form,i,n),c=()=>this.putRef([e,e.form],"change",n),f,m=this.extractMeta(e.form);e instanceof HTMLButtonElement&&(m.submitter=e),e.getAttribute(this.binding("change"))?f=Ni(e.form,I({_target:n._target},m),[e.name]):f=Ni(e.form,I({_target:n._target},m)),p.isUploadInput(e)&&e.files&&e.files.length>0&&X.trackFiles(e,Array.from(e.files)),a=X.serializeUploads(e);let v={type:"form",event:r,value:f,uploads:a,cid:l};this.pushWithReply(c,"event",v,E=>{if(p.showError(e,this.liveSocket.binding(it),this.liveSocket.binding(st)),p.isUploadInput(e)&&p.isAutoUpload(e)){if(X.filesAwaitingPreflight(e).length>0){let[b,w]=c();this.uploadFiles(e.form,i,b,l,N=>{o&&o(E),this.triggerAwaitingSubmit(e.form),this.undoRefs(b)})}}else o&&o(E)})}triggerAwaitingSubmit(e){let i=this.getScheduledSubmit(e);if(i){let[s,r,n,o]=i;this.cancelSubmit(e),o()}}getScheduledSubmit(e){return this.formSubmits.find(([i,s,r,n])=>i.isSameNode(e))}scheduleSubmit(e,i,s,r){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,i,s,r])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([i,s,r])=>i.isSameNode(e)?(this.undoRefs(s),!1):!0)}disableForm(e,i={}){let s=m=>!(xt(m,`${this.binding(yt)}=ignore`,m.form)||xt(m,"data-phx-update=ignore",m.form)),r=m=>m.hasAttribute(this.binding(Vt)),n=m=>m.tagName=="BUTTON",o=m=>["INPUT","TEXTAREA","SELECT"].includes(m.tagName),a=Array.from(e.elements),l=a.filter(r),c=a.filter(n).filter(s),f=a.filter(o).filter(s);return c.forEach(m=>{m.setAttribute(rt,m.disabled),m.disabled=!0}),f.forEach(m=>{m.setAttribute(Ti,m.readOnly),m.readOnly=!0,m.files&&(m.setAttribute(rt,m.disabled),m.disabled=!0)}),e.setAttribute(this.binding(Os),""),this.putRef([e].concat(l).concat(c).concat(f),"submit",i)}pushFormSubmit(e,i,s,r,n,o){let a=()=>this.disableForm(e,n),l=this.targetComponentID(e,i);if(X.hasUploadsInProgress(e)){let[c,f]=a(),m=()=>this.pushFormSubmit(e,i,s,r,n,o);return this.scheduleSubmit(e,c,n,m)}else if(X.inputsAwaitingPreflight(e).length>0){let[c,f]=a(),m=()=>[c,f,n];this.uploadFiles(e,i,c,l,v=>{let E=this.extractMeta(e),b=Ni(e,I({submitter:r},E));this.pushWithReply(m,"event",{type:"form",event:s,value:b,cid:l},o)})}else if(!(e.hasAttribute(le)&&e.classList.contains("phx-submit-loading"))){let c=this.extractMeta(e),f=Ni(e,I({submitter:r},c));this.pushWithReply(a,"event",{type:"form",event:s,value:f,cid:l},o)}}uploadFiles(e,i,s,r,n){let o=this.joinCount,a=X.activeFileInputs(e),l=a.length;a.forEach(c=>{let f=new X(c,this,()=>{l--,l===0&&n()}),m=f.entries().map(E=>E.toPreflightPayload());if(m.length===0){l--;return}let v={ref:c.getAttribute(ve),entries:m,cid:this.targetComponentID(c.form,i)};this.log("upload",()=>["sending preflight request",v]),this.pushWithReply(null,"allow_upload",v,E=>{if(this.log("upload",()=>["got preflight response",E]),E.error){this.undoRefs(s);let[b,w]=E.error;this.log("upload",()=>[`error for entry ${b}`,w])}else{let b=w=>{this.channel.onError(()=>{this.joinCount===o&&w()})};f.initAdapterUpload(E,b,this.liveSocket)}})})}dispatchUploads(e,i,s){let r=this.targetCtxElement(e)||this.el,n=p.findUploadInputs(r).filter(o=>o.name===i);n.length===0?se(`no live file inputs found matching the name "${i}"`):n.length>1?se(`duplicate live file inputs found matching the name "${i}"`):p.dispatchEvent(n[0],_i,{detail:{files:s}})}targetCtxElement(e){if(Ee(e)){let[i]=p.findComponentNodeList(this.el,e);return i}else return e||null}pushFormRecovery(e,i,s){this.liveSocket.withinOwners(e,(r,n)=>{let o=this.binding("change"),a=Array.from(e.elements).filter(f=>p.isFormInput(f)&&f.name&&!f.hasAttribute(o));if(a.length===0)return;a.forEach(f=>f.hasAttribute(ve)&&X.clearFiles(f));let l=a.find(f=>f.type!=="hidden")||a[0],c=e.getAttribute(this.binding($s))||e.getAttribute(this.binding("change"));ee.exec("change",c,r,l,["push",{_target:l.name,newCid:i,callback:s}])})}pushLinkPatch(e,i,s){let r=this.liveSocket.setPendingLink(e),n=i?()=>this.putRef([i],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=e.startsWith("/")?`${location.protocol}//${location.host}${e}`:e,l=this.pushWithReply(n,"live_patch",{url:a},c=>{this.liveSocket.requestDOMUpdate(()=>{c.link_redirect?this.liveSocket.replaceMain(e,null,s,r):(this.liveSocket.commitPendingLink(r)&&(this.href=e),this.applyPendingUpdates(),s&&s(r))})});l?l.receive("timeout",o):o()}formsForRecovery(e){if(this.joinCount===0)return[];let i=this.binding("change"),s=document.createElement("template");return s.innerHTML=e,p.all(this.el,`form[${i}]`).filter(r=>r.id&&this.ownsElement(r)).filter(r=>r.elements.length>0).filter(r=>r.getAttribute(this.binding($s))!=="ignore").map(r=>{let n=CSS.escape(r.getAttribute(i)),o=s.content.querySelector(`form[id="${r.id}"][${i}="${n}"]`);return o?[r,o,this.targetComponentID(o)]:[r,r,this.targetComponentID(r)]}).filter(([r,n,o])=>n)}maybePushComponentsDestroyed(e){let i=e.filter(s=>p.findComponentNodeList(this.el,s).length===0);i.length>0&&(i.forEach(s=>this.rendered.resetRender(s)),this.pushWithReply(null,"cids_will_destroy",{cids:i},()=>{let s=i.filter(r=>p.findComponentNodeList(this.el,r).length===0);s.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:s},r=>{this.rendered.pruneCIDs(r.cids)})}))}ownsElement(e){let i=e.closest($e);return e.getAttribute(tt)===this.id||i&&i.id===this.id||!i&&this.isDead}submitForm(e,i,s,r,n={}){p.putPrivate(e,vt,!0);let o=this.liveSocket.binding(it),a=this.liveSocket.binding(st),l=Array.from(e.elements);l.forEach(c=>p.putPrivate(c,vt,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,i,s,r,n,()=>{l.forEach(c=>p.showError(c,o,a)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var zt=class{constructor(e,i,s={}){if(this.unloaded=!1,!i||i.constructor.name==="Object")throw new Error(` a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example: import {Socket} from "phoenix" import {LiveSocket} from "phoenix_live_view" let liveSocket = new LiveSocket("/live", Socket, {...}) `);this.socket=new i(e,s),this.bindingPrefix=s.bindingPrefix||vn,this.opts=s,this.params=Li(s.params||{}),this.viewLogger=s.viewLogger,this.metadataCallbacks=s.metadata||{},this.defaults=Object.assign(wt(yn),s.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=wt(window.location),this.hooks=s.hooks||{},this.uploaders=s.uploaders||{},this.loaderTimeout=s.loaderTimeout||gn,this.reloadWithJitterTimer=null,this.maxReloads=s.maxReloads||rn,this.reloadJitterMin=s.reloadJitterMin||nn,this.reloadJitterMax=s.reloadJitterMax||on,this.failsafeJitter=s.failsafeJitter||an,this.localStorage=s.localStorage||window.localStorage,this.sessionStorage=s.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:Li(),onBeforeElUpdated:Li()},s.dom||{}),this.doofinderMount=s.doofinderMount,this.connectCallback=s.connectCallback||(()=>{}),this.disconnectCallback=s.disconnectCallback||(()=>{}),this.unbindFunctions=[],this.transitions=new Hn,window.addEventListener("pagehide",r=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()}),this.socket.onOpen(()=>{this.connectCallback()})}isProfileEnabled(){return this.sessionStorage.getItem(ki)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Jt)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Jt)==="false"}enableDebug(){this.sessionStorage.setItem(Jt,"true")}enableProfiling(){this.sessionStorage.setItem(ki,"true")}disableDebug(){this.sessionStorage.setItem(Jt,"false")}disableProfiling(){this.sessionStorage.removeItem(ki)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(Pi,e)}disableLatencySim(){this.sessionStorage.removeItem(Pi)}getLatencySim(){let e=this.sessionStorage.getItem(Pi);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug(),this.joinRootViews()&&(this.bindTopLevelEvents(),this.socket.connect())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,i,s=null){this.owner(e,r=>ee.exec(s,i,r,e))}execJSHookPush(e,i,s,r){this.withinOwners(e,n=>{ee.exec("hook",i,n,e,["push",{data:s,callback:r}])})}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(e,i){this.domCallbacks[e](...i)}time(e,i){if(!this.isProfileEnabled()||!console.time)return i();console.time(e);let s=i();return console.timeEnd(e),s}log(e,i,s){if(this.viewLogger){let[r,n]=s();this.viewLogger(e,i,r,n)}else if(this.isDebugEnabled()){let[r,n]=s();wn(e,i,r,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,i,s=function(){}){this.transitions.addTransition(e,i,s)}onChannel(e,i,s){e.on(i,r=>{let n=this.getLatencySim();n?setTimeout(()=>s(r),n):s(r)})}wrapPush(e,i,s){let r=this.getLatencySim(),n=e.joinCount;if(!r)return this.isConnected()&&i.timeout?s().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):s();let o={receives:[],receive(a,l){this.receives.push([a,l])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[l,c])=>a.receive(l,c),s())},r),o}reloadWithJitter(e,i){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let s=this.reloadJitterMin,r=this.reloadJitterMax,n=Math.floor(Math.random()*(r-s+1))+s;be.updateLocal(this.localStorage,window.location.pathname,mi,0,a=>a+1)>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{this.disconnectCallback()},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?kn[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,i){return this.socket.channel(e,i)}joinRootViews(){if(this.doofinderMount){let e=this.newRootView(this.doofinderMount);return e.setHref(this.getHref()),e.join(),this.main=e,!0}else return!1}redirect(e,i){this.disconnect(this.disconnectCallback),be.redirect(e,i)}replaceMain(e,i,s=null,r=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=p.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(o,i,n),this.main.setRedirect(e),this.transitionRemoves(null,!0),this.main.join((a,l)=>{a===1&&this.commitPendingLink(r)&&this.requestDOMUpdate(()=>{p.findPhxSticky(document).forEach(c=>o.appendChild(c)),this.outgoingMainEl.replaceWith(o),this.outgoingMainEl=null,s&&s(r),l()})})}transitionRemoves(e,i){let s=this.binding("remove");if(e=e||p.all(document,`[${s}]`),i){let r=p.findPhxSticky(document)||[];e=e.filter(n=>!p.isChildOfAny(n,r))}e.forEach(r=>{this.execJS(r,r.getAttribute(s),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(Se)!==null}newRootView(e,i,s){let r=new Tt(e,this,null,i,s);return this.roots[r.id]=r,r}owner(e,i){let s=ke(e.closest($e),r=>this.getViewByEl(r))||this.main;s&&i(s)}withinOwners(e,i){this.owner(e,s=>i(s,e))}getViewByEl(e){let i=e.getAttribute(Oe);return ke(this.getRootById(i),s=>s.getDescendentByEl(e))}getRootById(e){return this.roots[e]}destroyAllViews(){for(let e in this.roots)this.roots[e].destroy(),delete this.roots[e];this.main=null}destroyViewByEl(e){let i=this.getRootById(e.getAttribute(Oe));i&&i.id===e.id?(i.destroy(),delete this.roots[i.id]):i&&i.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let i=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",i),e.addEventListener("touchend",i)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.socket.onClose(i=>{if(i&&i.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),this.unbindFunctions.push((()=>{let i=function(){};return document.body.addEventListener("click",i),function(){document.body.removeEventListener("click",i)}})()),window.addEventListener("pageshow",i=>{i.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(i,s,r,n,o,a)=>{let l=n.getAttribute(this.binding(pn)),c=i.key&&i.key.toLowerCase();if(l&&l.toLowerCase()!==c)return;let f=I({key:i.key},this.eventMeta(s,i,n));ee.exec(s,o,r,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(i,s,r,n,o,a)=>{if(!a){let l=I({key:i.key},this.eventMeta(s,i,n));ee.exec(s,o,r,n,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(i,s,r,n,o,a)=>{if(a==="window"){let l=this.eventMeta(s,i,n);ee.exec(s,o,r,n,["push",{data:l}])}}),this.unbindFunctions.push((()=>{let i=s=>s.preventDefault();return this.doofinderMount.addEventListener("dragover",i),()=>this.doofinderMount.removeEventListener("dragover",i)})()),this.unbindFunctions.push((()=>{let i=s=>{s.preventDefault();let r=ke(xt(s.target,this.binding(Ls)),a=>a.getAttribute(this.binding(Ls))),n=r&&document.getElementById(r),o=Array.from(s.dataTransfer.files||[]);!n||n.disabled||o.length===0||!(n.files instanceof FileList)||(X.trackFiles(n,o,s.dataTransfer),n.dispatchEvent(new Event("input",{bubbles:!0})))};return this.doofinderMount.addEventListener("drop",i),()=>this.doofinderMount.removeEventListener("drop",i)})()),this.on(_i,i=>{let s=i.target;if(!p.isUploadInput(s))return;let r=Array.from(i.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);X.trackFiles(s,r),s.dispatchEvent(new Event("input",{bubbles:!0}))},this.doofinderMount))}unbindTopLevelEvents(){this.unbindFunctions.forEach(e=>e()),this.unbindFunctions=[]}eventMeta(e,i,s){let r=this.metadataCallbacks[e];return r?r(i,s):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.linkRef}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,i){for(let s in e){let r=e[s];this.on(r,n=>{let o=this.binding(s),a=this.binding(`window-${s}`),l=n.target.getAttribute&&n.target.getAttribute(o);l?this.debounce(n.target,n,r,()=>{this.withinOwners(n.target,c=>{i(n,s,c,n.target,l,null)})}):p.all(document,`[${a}]`,c=>{let f=c.getAttribute(a);this.debounce(c,n,r,()=>{this.withinOwners(c,m=>{i(n,s,m,c,f,"window")})})})},this.doofinderMount)}}bindClicks(){let e=i=>{this.clickStartedAtTarget=i.target};this.doofinderMount.addEventListener("click",e),this.unbindFunctions.push(()=>this.doofinderMount.removeEventListener("click",e)),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,i,s){let r=this.binding(i),n=o=>{if(!this.isConnected())return;let a=null;if(s)a=o.target.matches(`[${r}]`)?o.target:o.target.querySelector(`[${r}]`);else{o.detail===0&&(this.clickStartedAtTarget=o.target);let c=this.clickStartedAtTarget||o.target;a=xt(c,r),this.dispatchClickAway(o,c),this.clickStartedAtTarget=null}let l=a&&a.getAttribute(r);if(!l){!s&&p.isNewPageClick(o,window.location)&&this.unload();return}a.getAttribute("href")==="#"&&o.preventDefault(),!a.hasAttribute(le)&&(a.disabled||this.debounce(a,o,"click",()=>{this.withinOwners(a,c=>{ee.exec("click",l,c,a,["push",{data:this.eventMeta("click",o,a)}])})}))};this.doofinderMount.addEventListener(e,n,s),this.unbindFunctions.push(()=>this.doofinderMount.removeEventListener(e,n,s))}dispatchClickAway(e,i){let s=this.binding("click-away");p.all(document,`[${s}]`,r=>{r.isSameNode(i)||r.contains(i)||this.withinOwners(r,n=>{let o=r.getAttribute(s);ee.isVisible(r)&&ee.isInViewport(r)&&ee.exec("click",o,n,r,["push",{data:this.eventMeta("click",e,e.target)}])})})}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,i={}){p.dispatchEvent(this.doofinderMount,`${U}:${e}`,{detail:i})}dispatchEvents(e){e.forEach(([i,s])=>this.dispatchEvent(i,s))}withPageLoading(e,i){p.dispatchEvent(this.doofinderMount,`${U}:page-loading-start`,{detail:e});let s=()=>p.dispatchEvent(this.doofinderMount,`${U}:page-loading-stop`,{detail:e});return i?i(s):s}pushHistoryPatch(e,i,s){if(!this.isConnected()||!this.main.isMain())return be.redirect(e);this.withPageLoading({to:e,kind:"patch"},r=>{this.main.pushLinkPatch(e,s,n=>{this.historyPatch(e,i,n),r()})})}historyPatch(e,i,s=this.setPendingLink(e)){!this.commitPendingLink(s)||(be.pushState(i,{type:"patch",id:this.main.id},e),p.dispatchEvent(window,`${U}:navigate`,{detail:{patch:!0,href:e,pop:!1}}),this.registerNewLocation(window.location))}historyRedirect(e,i,s){if(!this.isConnected()||!this.main.isMain())return be.redirect(e,s);if(/^\/$|^\/[^\/]+.*$/.test(e)){let{protocol:n,host:o}=window.location;e=`${n}//${o}${e}`}let r=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,s,o=>{o===this.linkRef&&(be.pushState(i,{type:"redirect",id:this.main.id,scroll:r},e),p.dispatchEvent(window,`${U}:navigate`,{detail:{href:e,patch:!1,pop:!1}}),this.registerNewLocation(window.location)),n()})})}replaceRootHistory(){be.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:i,search:s}=this.currentLocation;return i+s===e.pathname+e.search?!1:(this.currentLocation=wt(e),!0)}bindForms(){let e=0,i=!1;this.on("submit",s=>{let r=s.target.getAttribute(this.binding("submit")),n=s.target.getAttribute(this.binding("change"));!i&&n&&!r&&(i=!0,s.preventDefault(),s.stopPropagation(),this.withinOwners(s.target,o=>{o.disableForm(s.target),window.requestAnimationFrame(()=>{p.isUnloadableFormSubmit(s)&&this.unload(),s.target.submit()})}))},this.doofinderMount),this.on("submit",s=>{let r=s.target.getAttribute(this.binding("submit"));if(!r){p.isUnloadableFormSubmit(s)&&this.unload();return}s.preventDefault(),s.stopPropagation(),s.target.disabled=!0,this.withinOwners(s.target,n=>{ee.exec("submit",r,n,s.target,["push",{submitter:s.submitter}])})},this.doofinderMount);for(let s of["change","input"])this.on(s,r=>{r.stopPropagation();let n=this.binding("change"),o=r.target,a=o.getAttribute(n),l=o.form&&o.form.getAttribute(n),c=a||l;if(!c||o.type==="number"&&o.validity&&o.validity.badInput)return;let f=a?o:o.form,m=e;e++;let{at:v,type:E}=p.private(o,"prev-iteration")||{};v===m-1&&s==="change"&&E==="input"||(p.putPrivate(o,"prev-iteration",{at:m,type:s}),this.debounce(o,r,s,()=>{this.withinOwners(f,b=>{p.putPrivate(o,Bt,!0),p.isTextualInput(o)||this.setActiveElement(o),ee.exec("change",c,b,o,["push",{_target:r.target.name,dispatcher:f}])})}))},this.doofinderMount);this.on("reset",s=>{let r=s.target;p.resetForm(r,this.binding(it),this.binding(st));let n=Array.from(r.elements).find(o=>o.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,i,s,r){if(s==="blur"||s==="focusout")return r();let n=this.binding(un),o=this.binding(fn),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,c=>{let f=()=>!c.isDestroyed()&&document.body.contains(e);p.debounce(e,i,n,a,o,l,f,()=>{r()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,i,s=window){let r=n=>{this.silenced||i(n)};s.addEventListener(e,r),this.unbindFunctions.push(function(){s.removeEventListener(e,r)})}},Hn=class{constructor(){this.transitions=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,i,s){i();let r=setTimeout(()=>{this.transitions.delete(r),s(),this.flushPendingOps()},e);this.transitions.add(r)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};var Ks=class{constructor(e){let{url:i,mount:s,hooks:r,params:n,mainHook:o,appName:a,disconnectCallback:l}=e,c={hooks:r,doofinderMount:s,params:n,metadata:{click:function(f){return{keys:{altKey:f.altKey,shiftKey:f.shiftKey,ctrlKey:f.ctrlKey,metaKey:f.metaKey}}}},disconnectCallback:l};this.__mainHook=o,this.__socket=new zt(i,Is,c),this.__appName=a}get connected(){return this.__socket.isConnected()}enableDebug(){this.__socket.enableDebug()}disableDebug(){this.__socket.disableDebug()}setPreventReconnect(e=!1){this.__socket.preventReconnect=e}getHooksByName(e){if(this.connected){let i=this.__socket.doofinderMount,s=this.__socket.getViewByEl(i);return Array.from(i.querySelectorAll(`[dfd-hook="${e}"]`)).map(n=>s.getHook(n))}else return[]}connect(e){this.connected||this.__socket.connect(),Doofinder.Session.setLive(this.__appName),e()}disconnect(e){this.__socket.unbindTopLevelEvents(),this.__socket.destroyAllViews(),this.__socket.disconnect(e),this.__socket=null}pushEvent(e,i={},s=void 0){let[r]=this.getHooksByName(this.__mainHook);if(!r)throw new Error(`${this.__mainHook} hook is not ready!`);r.pushEvent(e,i,s)}};var zs="dfd-animate",Gs="dfd-fixed-layout",Ue="hidden",$i="floating",Ui="fullscreen",at="static";function Fi(t){let e=["left","top","right","bottom","width","height","scrollLeft","scrollTop","scrollWidth","scrollHeight"],i=e.reduce((r,n)=>(r[n]=0,r),{}),s=t;if(s===window)i=Te(I({},i),{width:s.outerWidth,height:s.outerHeight,clientWidth:s.innerWidth,clientHeight:s.innerHeight,scrollLeft:s.scrollX,scrollTop:s.scrollY,scrollWidth:document.scrollWidth,scrollHeight:document.scrollHeight});else{if(s===document)s=document.documentElement,i=Te(I({},i),{width:s.offsetWidth,height:s.offsetHeight});else if(s.getBoundingClientRect){let r=s.getBoundingClientRect();i=e.reduce((n,o)=>(n[o]=r[o],n),{})}i=Te(I({},i),{clientWidth:s.clientWidth,clientHeight:s.clientHeight,scrollLeft:s.scrollLeft,scrollTop:s.scrollTop,scrollWidth:s.scrollWidth,scrollHeight:s.scrollHeight})}return i}function Mn(t){let e=t;for(;e&&getComputedStyle(e).position!=="fixed";)e=e.offsetParent;return!!e}"use strict";var Ys=class{constructor(e,i={}){this.options=I({align:i.align,offsetX:0,offsetY:4,marginY:20,marginX:20,fillViewPortWidth:768},i),this.element=e}__origin__(e){let i=Fi(e),s=Fi(document),r=s.width<=this.options.fillViewPortWidth,n={width:i.width,top:i.top+i.height,left:i.left,fixed:Mn(e),align:function(){let o=Math.abs(i.left)*100/s.width,a=Math.abs(s.clientWidth-i.right)*100/s.width;switch(!0){case r:case Math.abs(o-a)<=15:return"center";case on-a&&(this.element.style.height=`${n-a}px`):this.element.style.height=`${n-a}px`}destroy(){["position","top","left","right","height","maxWidth","marginLeft"].forEach(e=>this.element.style[e]=null),this.options=null,this.element=null}};function ji(t,e=66,i=!1){let s;return function(...r){s?Date.now()-s>=e?(t(...r),s=Date.now()):i&&console.log("throttle: discard execution"):(t(...r),s=Date.now())}}var lt=class{constructor(e){this.mount=e,this._positionReference=null}__animate__(){return new Promise(e=>{setTimeout(()=>{this.mount.classList.add(zs),e()},10)})}get positionReference(){return this._positionReference}show(){return T(this,null,function*(){let e=this.hidden();return e&&(this.mount.removeAttribute(Ue),yield this.__animate__()),e})}hide(){return T(this,null,function*(){let e=!this.hidden();return e&&(this.mount.setAttribute(Ue,""),this.mount.classList.remove(zs),this.mount.innerHTML=""),e})}updatePosition(e){return T(this,null,function*(){this._positionReference=e.positionReference})}destroy(){this.mount=void 0}hidden(){return this.mount.hasAttribute(Ue)}};var Qs=class extends lt{constructor(e,i={}){super(e);this.handleWindowChange=ji(this.handleWindowChange.bind(this)),this._position=new Ys(this.mount,i)}__addListeners__(){window.addEventListener("resize",this.handleWindowChange,{passive:!0})}__removeListeners__(){window.removeEventListener("resize",this.handleWindowChange)}get position(){return this._position}handleWindowChange(){this._position.update(this._positionReference)}show(){var e=i=>super[i];return T(this,null,function*(){let s=this.hidden();return s&&(this.mount.style.opacity="0",this.mount.removeAttribute(Ue)),this._position.update(this._positionReference),s&&(this.mount.setAttribute(Ue,""),this.mount.style.opacity=null,yield e("show").call(this),this.__addListeners__()),s})}hide(){var e=i=>super[i];return T(this,null,function*(){let s=!this.hidden();return s&&(this.__removeListeners__(),yield e("hide").call(this)),s})}updatePosition(e){var i=s=>super[s];return T(this,null,function*(){i("updatePosition").call(this,e),setTimeout(()=>{this._position.update(this._positionReference)},100)})}destroy(){this.__removeListeners__(),this._position.destroy(),this._position=null,super.destroy()}};var Zs=class extends lt{show(){var e=i=>super[i];return T(this,null,function*(){let s=this.hidden();return s&&(document.documentElement.classList.add(Gs),yield e("show").call(this)),s})}hide(){var e=i=>super[i];return T(this,null,function*(){let s=yield e("hide").call(this);return s&&document.documentElement.classList.remove(Gs),s})}};function Bi(t=8){let e="";for(;e.lengththis.off(e,i)}once(e,i){if(this._checkReady())return this.el.addEventListener(e,i,{once:!0,passive:!0}),()=>this.off(e,i)}off(e,i){this._checkReady()&&this.el.removeEventListener(e,i)}emit(e,i){if(this._checkReady()){let s=new CustomEvent(e,{detail:i,bubbles:!1,cancelable:!1,composed:!1});this.el.dispatchEvent(s)}}teardown(){this._checkReady()&&(this.el=this.el.remove())}_checkReady(){if(this.el)return!0;throw new Error("tried to access a dead event bus!")}};"use strict";var $a="[dfd-carousel-btn-left]",Ua="[dfd-carousel-btn-right]",Nn="[dfd-carousel-content]",Wi="ltr",$n={mounted(){this.btnLeftEl=this.el.querySelector($a),this.btnRightEl=this.el.querySelector(Ua),this.contentEl=this.el.querySelector(Nn),getComputedStyle(this.contentEl).direction==="rtl"&&(Wi="rtl"),this.getVisibleChildren=()=>{let t=this.contentEl.getBoundingClientRect();return Array.from(this.contentEl.children).filter(e=>{let i=e.getBoundingClientRect();return t.left<=i.left&&t.right>=i.right})},this.nextPage=()=>{let t=this.getVisibleChildren();if(t.length<=0)return;let e=t.slice(-1).pop(),i=e.nextElementSibling;if(!i)return;let s=this.contentEl.getBoundingClientRect(),r=e.getBoundingClientRect(),n=i.getBoundingClientRect(),o=r.width,a=i?n.x-r.x-r.width:0,l;Wi==="ltr"?l=this.contentEl.scrollLeft+(r.x-s.x):l=this.contentEl.scrollLeft-(r.x+s.x),this.contentEl.scroll({left:l+o+a/2,behavior:"smooth"})},this.previousPage=()=>{let t=this.getVisibleChildren();if(t.length<=0)return;let e=t[0],i=e.previousElementSibling;if(!i)return;let s=this.contentEl.getBoundingClientRect(),r=e.getBoundingClientRect(),n=i.getBoundingClientRect(),o=n.width-(s.x-n.x),a=i?r.x-n.x-n.width:0,l;Wi==="ltr"?l=this.contentEl.scrollLeft-s.width:l=this.contentEl.scrollLeft+s.width,this.contentEl.scroll({left:l+o+a/2,behavior:"smooth"})},this.btnLeftEl.addEventListener("click",this.previousPage),this.btnRightEl.addEventListener("click",this.nextPage),this.tag.dispatch("doofinder.carousel.load")},updated(){this.contentEl=this.el.querySelector(Nn),getComputedStyle(this.contentEl).direction==="rtl"&&(Wi="rtl"),this.tag.dispatch("doofinder.carousel.update")},destroyed(){this.btnLeftEl.removeEventListener("click",this.previousPage),this.btnRightEl.removeEventListener("click",this.nextPage)}};var Ki=240;function Fa(t){return!!t.type.match(/image\/.*/)}function Un(t){return T(this,null,function*(){if(!Fa(t))throw"invalid image, can't search";let e=yield Fn(t),i=yield ja(e);return yield Fn(i)})}function Fn(t){return new Promise(function(e,i){let s=new FileReader;s.onload=function(){e(s.result)},s.onerror=function(){i(s.error)},s.readAsDataURL(t)})}function ja(t){return new Promise(function(e,i){let s=new Image;s.onload=function(){let r=document.createElement("canvas");r.width=Ki,r.height=Ki,r.getContext("2d").drawImage(s,0,0,Ki,Ki),r.toBlob(function(n){e(n)},"image/jpeg")},s.onerror=function(r){i("resize image error")},s.src=t})}var jn={mounted(){this.search=t=>T(this,null,function*(){this.el.dataset.status="loading";let e=yield Un(t);this.pushEvent("search",{search:{image:e}})}),this.el.addEventListener("change",t=>this.search(t.target.files[0]))}};function sr(t){setTimeout(()=>{t.focus()},0)}function Bn(t){setTimeout(()=>{t.select()},0)}"use strict";var Vn={mounted(){Bn(this.el),this.search=t=>{let e=this.el.dataset.dfdAction||"search";this.pushEvent(e,{search:{query:t}})},this.handleEvent("set-input-value",t=>this.el.value=t.query),this.handleEvent("set-input-focus",()=>sr(this.el)),this.handleEvent("unset-input-focus",()=>{setTimeout(()=>{var t;(t=document.activeElement)==null||t.blur()},0)}),this.el.addEventListener("input",()=>this.search(this.el.value)),this.el.addEventListener("keydown",t=>{let e=this.el.getAttribute("dfd-value-suggestion");t.key==="Tab"&&e&&e!==this.el.value&&(this.el.value=e,sr(this.el),this.search(e))})}};"use strict";var Xn={mounted(){let t={add_to_cart:e=>()=>{let i=JSON.parse(e.dataset.item);if(this.el.querySelectorAll("[data-role=variant_selected][value='']").length>0){let s=this.el.querySelector("[data-role=variant_selected][value='']").dataset.variant,r=this.evaluate_filters(s);this.pushEvent("get-variants",{item:i,filters:r},()=>{this.execJS(`[data-role=selector][data-variant="${s}"]`,"show")})}else this.el.dataset.quantity=="true"&&this.el.dataset.status=="initial"?(this.execJS(null,"set_attr",["data-status","quantity"]),this.execJS("[data-role=decrease_quantity]","hide"),this.execJS("[data-role=delete_quantity]","show"),this.execJS("[data-role=amount_selected]","set_attr",["value","1"])):(this.send(i),this.execJS(null,"set_attr",["data-status","initial"]),this.execJS("[data-role=amount_selected]","set_attr",["value",1]),this.el.querySelector("[data-role=select_variant].selected")&&this.execJS("[data-role=select_variant].selected","remove_class","selected"),this.el.querySelectorAll("[data-role=open_selector]").forEach(r=>{this.execJS(`[data-role=open_selector][data-variant="${r.dataset.variant}"] input`,"set_attr",["value",r.dataset.variant])}),this.el.querySelectorAll("[data-role=open_selector]").forEach(r=>{this.execJS(`[data-role=variant_selected][data-variant="${r.dataset.variant}"]`,"remove_attr","data-index"),this.execJS(`[data-role=variant_selected][data-variant="${r.dataset.variant}"]`,"set_attr",["value",""])}))},increase_quantity:e=>()=>{let i=this.el.querySelector("[data-role=amount_selected]"),s=parseInt(i.value)+1;this.update_quantity(i,s)},decrease_quantity:e=>()=>{let i=this.el.querySelector("[data-role=amount_selected]"),s=parseInt(i.value)-1;this.update_quantity(i,s)},delete_quantity:e=>()=>{this.execJS(null,"set_attr",["data-status","initial"])},open_selector:e=>()=>{if(!e.dataset.item){this.execJS(`[data-role=selector][data-variant="${e.dataset.variant}"]`,"show");return}let i=this.evaluate_filters(e.dataset.variant),s=JSON.parse(e.dataset.item);this.pushEvent("get-variants",{item:s,filters:i},()=>{this.execJS(`[data-role=selector][data-variant="${e.dataset.variant}"]`,"show")})},select_variant:e=>()=>{let i=e.closest("[data-role=selector]").dataset.variant;this.el.querySelector("[data-role=select_variant].selected")&&this.execJS("[data-role=select_variant].selected","remove_class","selected"),this.execJS(`[data-role=selector][data-variant="${i}"]`,"hide"),this.execJS(`[data-role=selector][data-variant="${i}"] [data-id="${e.dataset.id}"]`,"add_class","selected"),this.execJS(`[data-role=open_selector][data-variant="${i}] input`,"set_attr",["value",e.dataset.val]),this.execJS(`[data-role=variant_selected][data-variant="${i}"]`,"set_attr",["value",e.dataset.val]),this.restore_filters(i),this.execJS(null,"set_attr",["data-status","initial"])},close_selector:e=>()=>{let i=e.closest("[data-role=selector]").dataset.variant;this.execJS(`[data-role=selector][data-variant="${i}"]`,"hide"),this.execJS(null,"set_attr",["data-status","initial"])},send:e=>()=>{let i=Array.from(this.el.querySelectorAll("[data-role=variant_selected]")).map(n=>n.value),s=this.el.querySelector("[data-role=amount_selected]").value,r=JSON.parse(e.dataset.item);s&&!i.includes("")?this.send(r):alert("Falta alg\xFAn dato")}};this.el.addEventListener("click",e=>{if(e.target.closest("[data-role]")){let i=Object.keys(t).find(s=>e.target.closest("[data-role]").dataset.role.match(s));i&&t[i](e.target.closest("[data-role]"))()}}),this.el.addEventListener("input",e=>{let i=e.target.closest("[data-role=amount_selected]");i&&i.value!=""&&this.update_quantity(i,parseInt(i.value))}),this.execJS=(e,i,s)=>{let r=this.el.querySelector(e);e==null&&(r=this.el),r!=null&&(i=="set_attr"?this.liveSocket.execJS(r,'[["'+i+'",{"to": null, "attr":["'+s[0]+'","'+s[1]+'"]}]]'):i=="remove_class"||i=="add_class"?this.liveSocket.execJS(r,'[["'+i+'",{"to": null, "time":200,"names":["'+s+'"],"transition":[[],[],[]]}]]'):this.liveSocket.execJS(r,'[["'+i+'",{"to": null}]]'))},this.update_quantity=(e,i)=>{this.execJS("[data-role=amount_selected]","set_attr",["value",parseInt(i)]),e.value=i,this.evaluate_quantity(i)},this.evaluate_quantity=e=>{e<=1?(this.execJS("[data-role=decrease_quantity]","hide"),this.execJS("[data-role=delete_quantity]","show"),this.execJS("[data-role=increase_quantity]","show")):(this.execJS("[data-role=decrease_quantity]","show"),this.execJS("[data-role=delete_quantity]","hide"),this.execJS("[data-role=increase_quantity]","show"))},this.evaluate_filters=e=>{let i=this.el.querySelector(`[data-role=variant_selected][data-variant="${e}"]`).dataset.index;return Array.from(this.el.querySelectorAll("[data-role=variant_selected][data-index]")).filter(s=>i==null||parseInt(s.dataset.index)({key:s.dataset.variant,value:s.value}))},this.restore_filters=e=>{let i=this.el.querySelector(`[data-role=variant_selected][data-variant="${e}"]`).dataset.index,s=this.el.querySelectorAll("[data-role=variant_selected][data-index]").length;i===void 0&&this.execJS(`[data-role=variant_selected][data-variant="${e}"]`,"set_attr",["data-index",s+1]);for(let r=parseInt(i)+1;r<=s;r++){let n=this.el.querySelector(`[data-role=variant_selected][data-index="${r}"]`).dataset.variant;this.execJS(`[data-role=variant_selected][data-variant="${n}"]`,"set_attr",["value",""]),this.execJS(`[data-role=variant_selected][data-variant="${n}]`,"remove_attr","data-index"),this.execJS(`[data-role=open_selector][data-variant="${n}"] input`,"set_attr",["value",n])}},this.send=e=>{let i=Array.from(this.el.querySelectorAll("[data-role=variant_selected][data-index]")).map(r=>({key:r.dataset.variant,value:r.value})),s=this.el.querySelector("[data-role=amount_selected]").value;this.start_add_to_cart(),this.pushEvent("add-to-cart-beta",{item:e,amount:s,filters:i},r=>{r.statusPromise=new Ie({resolveTimeout:3e3,rejectTimeout:5e3}),r.statusPromise.then(this.finish_add_to_cart,this.finish_add_to_cart),document.dispatchEvent(new CustomEvent("doofinder.cart.add",{detail:r}))})},this.start_add_to_cart=()=>{this.execJS(".dfd-cart-check-button[data-role=add_to_cart]","add_class","dfd-btn-loading"),this.execJS(".dfd-cart-add-button [data-role=add_to_cart]","add_class","dfd-btn-loading")},this.finish_add_to_cart=e=>{this.execJS(".dfd-cart-check-button[data-role=add_to_cart]","remove_class","dfd-btn-loading"),this.execJS(".dfd-cart-add-button [data-role=add_to_cart]","remove_class","dfd-btn-loading"),this.execJS(".dfd-cart-check-button[data-role=add_to_cart]","add_class","dfd-btn-done"),this.execJS(".dfd-cart-add-button [data-role=add_to_cart]","add_class","dfd-btn-done"),setTimeout(()=>{this.execJS(".dfd-cart-check-button[data-role=add_to_cart]","remove_class","dfd-btn-done"),this.execJS(".dfd-cart-add-button [data-role=add_to_cart]","remove_class","dfd-btn-done")},500),typeof e=="function"&&e()}}};function ht(t){return`${U}:${t}`}"use strict";var zi="doofinder.cart.add.click",Ba="doofinder.cart.add",Gi="doofinder.cart.hide.price",Yi="doofinder.cart.display.price",rr="dfd-btn-loading",Jn="dfd-btn-done",qn="dfd-btn-error";function Wn(t){t.addToCartResolveTimeout=3e3,t.addToCartRejectTimeout=5e3,t.addToCartButtonFeedback=function(i,s){let r=Va.bind(null,i,s),n=qa.bind(null,i,i.innerHTML),o=Xa.bind(null,i,n),a=Ja.bind(null,i,n);r().then(o,a)},t.handleCartAddClick=i=>{let s=i.detail.target?document.getElementById(i.detail.target.id):i.target,r=new Ie({resolveTimeout:t.addToCartResolveTimeout,rejectTimeout:t.addToCartRejectTimeout});r.then(n=>{t.pushEvent("add-to-cart",{item:i.detail.item,dfid:i.detail.dfid},()=>{typeof n=="function"&&n()}),t.pushEvent("close-add-to-cart-button",{item:i.detail.item,dfid:i.detail.dfid})},n=>{typeof n=="function"&&n(),t.pushEvent("close-add-to-cart-button",{item:i.detail.item,dfid:i.detail.dfid})}),setTimeout(()=>t.tag.dispatch(Ba,Te(I({},i.detail.item),{statusPromise:r})),1e3),t.addToCartButtonFeedback&&t.addToCartButtonFeedback(s,r)},t.handleHidePrice=i=>{let s=i.detail.target?document.getElementById(i.detail.target.id):i.target;s.closest(".dfd-card-row").querySelector(".dfd-card-pricing").style.display="none"},t.handleDisplayPrice=i=>{let s=i.detail.target?document.getElementById(i.detail.target.id):i.target;s.closest(".dfd-card-row").querySelector(".dfd-card-pricing").style.display="flex"};let e=!!t.tag&&!!t.tag.dom?t.tag.dom.mount:t.tag.mount;e.addEventListener(zi,t.handleCartAddClick),e.addEventListener(ht(zi),t.handleCartAddClick),e.addEventListener(Gi,t.handleHidePrice),e.addEventListener(ht(Gi),t.handleHidePrice),e.addEventListener(Yi,t.handleDisplayPrice),e.addEventListener(ht(Yi),t.handleDisplayPrice)}function Kn(t){let e=!!t.tag&&!!t.tag.dom?t.tag.dom.mount:t.tag.mount;e.removeEventListener(zi,t.handleCartAddClick),e.removeEventListener(ht(zi),t.handleCartAddClick),e.removeEventListener(Gi,t.handleHidePrice),e.removeEventListener(ht(Gi),t.handleHidePrice),e.removeEventListener(Yi,t.handleDisplayPrice),e.removeEventListener(ht(Yi),t.handleDisplayPrice)}function Va(t,e){return t.setAttribute("disabled",""),t.setAttribute("dfd-update","ignore"),t.innerHTML="",t.classList.add(rr),e}function Xa(t,e){t.classList.remove(rr),t.classList.add(Jn),setTimeout(e,1e3)}function Ja(t,e){t.classList.remove(rr),t.classList.add(qn),setTimeout(e,2e3)}function qa(t,e){t.classList.remove(Jn),t.classList.remove(qn),t.innerHTML=e,t.removeAttribute("dfd-update"),t.removeAttribute("disabled")}"use strict";var zn={mounted(){this.close=()=>this.pushEvent("close-layer"),this.handleEvent("close",()=>{this.tag.disconnect()}),this.handleEvent("change-state",({state:t})=>{this.tag.updateState({value:t})}),this.handleEvent("disconnect",t=>{t.errors.forEach(e=>console.error("[Doofinder] error:",e)),this.tag.destroy()}),this.handleEvent("load",t=>{this.tag.onLoad(t),this.tag.dispatch("doofinder.layer.load",{display_type:t.display_type}),this.pushEvent("ready")}),this.handleEvent("click-suggestion",t=>T(this,null,function*(){var e;this.tag.trigger.updateQuery((e=t==null?void 0:t.search)==null?void 0:e.query)})),this.handleEvent("set-trigger-focus",()=>T(this,null,function*(){this.tag.trigger.focus()})),this.handleEvent("search",t=>{this.tag.dispatch("doofinder.layer.search",t)}),this.handleEvent("item-click",t=>{this.tag.dispatch("doofinder.layer.itemClick",t)}),this.handleEvent("update-latest-searches",({entries:t})=>{this.tag.updateLatestSearches(t)}),this.el.addEventListener("contextmenu",t=>{let e=t.target.closest('[dfd-click="item-click"]');if(e){let i=e.getAttribute("dfd-value-link"),s=e.getAttribute("dfd-value-dfid");this.pushEvent("item-click",{link:i,dfid:s},()=>{this.debug(`item-click sent for ${s} to ${i}`)})}}),this.el.addEventListener("error",({target:t})=>{if(t.tagName!=="IMG")return;let e=t.closest('[data-dfd-role="card-thumbnail"]');setTimeout(()=>{e==null||e.parentElement.setAttribute("dfd-update","ignore"),e==null||e.classList.add("dfd-card-thumbnail-404")},1)},!0),this.applyOperationBySelector=function(t,e){if(t.startsWith("#")){let i=document.getElementById(t);e(i)}else this.el.querySelectorAll(t).forEach(i=>{e(i)})},this.handleEvent("dom:add-class",({target:t,newClass:e})=>{this.applyOperationBySelector(t.selector,i=>i==null?void 0:i.classList.add(e))}),this.handleEvent("dom:remove-class",({target:t,oldClass:e})=>{this.applyOperationBySelector(t.selector,i=>i==null?void 0:i.classList.remove(e))}),this.handleEvent("dom:add-attribute",({target:t,name:e,value:i})=>{this.applyOperationBySelector(t.selector,s=>s==null?void 0:s.setAttribute(e,i))}),this.handleEvent("dom:remove-attribute",({target:t,name:e})=>{this.applyOperationBySelector(t.selector,i=>i==null?void 0:i.removeAttribute(e))}),this.handleEvent("redirection:update",({redirection:t})=>{this.tag.trigger.redirection=t}),Wn(this)},updated(){this.tag.dispatch("doofinder.layer.update")},destroyed(){Kn(this)}},Gn={mounted(){this.handleEvent("disconnect",t=>{t.errors.forEach(e=>console.error("[Doofinder] error:",e)),this.tag.destroy()})}};var Yn=Object.freeze({Linear:function(t){return t},EaseInQuad:function(t){return t*t},EaseOutQuad:function(t){return t*(2-t)},EaseInOutQuad:function(t){return t<.5?2*t*t:-1+(4-2*t)*t},EaseInCubic:function(t){return t*t*t},EaseOutCubic:function(t){return--t*t*t+1},EaseInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},EaseInQuart:function(t){return t*t*t*t},EaseOutQuart:function(t){return 1- --t*t*t*t},EaseInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},EaseInQuint:function(t){return t*t*t*t*t},EaseOutQuint:function(t){return 1+--t*t*t*t*t},EaseInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t}});function Qn(t,e,i,s,r=Yn.EaseInQuint){let n=Date.now(),o=e[t];return new Promise((a,l)=>{function c(){let f=Date.now(),m=Math.min(1,(f-n)/s),v=r(m);e[t]=o+v*(i-o),m<1?requestAnimationFrame(c):a()}o===i?a():requestAnimationFrame(c)})}var Zn=Qn.bind(null,"scrollTop"),zd=Qn.bind(null,"scrollLeft");function Wa(t){let e=t.scrollHeight>t.clientHeight,s=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!s}function Qi(t){return!t||t===document.documentElement?document.documentElement:Wa(t)?t:Qi(t.parentNode)}function eo(t,e){return typeof t!="undefined"?t:e}var Gt=class{constructor(e,i,s={}){let{threshold:r}=s;this.handleIntersection=this.handleIntersection.bind(this),this._callback=i,this._io=new IntersectionObserver(this.handleIntersection,{root:e,threshold:eo(r,0)})}observe(e){this._io.disconnect(),e&&this._io.observe(e),L("[ScrollObserver][observe]",e)}unobserve(){this._io.disconnect(),L("[ScrollObserver][unobserve]")}handleIntersection([e]){L("[ScrollObserver][intersection detected] target:",e.target),this._callback(e)}};var to='[data-dfd-role~="scroll-sentinel"]',io='[data-dfd-role~="scroll-top-sentinel"]',Ka="div.dfd-card";function Yt(t,e,i){i?t.scrollTop=e:Zn(t,e,250)}function za(t){var s,r;let e=((s=document.querySelector(Ka))==null?void 0:s.offsetHeight)||0,i=((r=document.querySelector(to))==null?void 0:r.offsetHeight)||0;return t.scrollHeight-i-e*2.6}var so={mounted(){this.sentinel=()=>this.el.querySelector(to),this.scrollTopSentinel=()=>this.el.querySelector(io),this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.refreshObservers=()=>{this.scrollObserver.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel())},this.changeBackToTopVisibility=t=>{this.pushEvent("change-back-to-top-visibility",{visible:t})},this.scrollObserver=new Gt(this.el,({target:t,isIntersecting:e})=>{if(!e)return;let i={index:t.dataset.index};this.debug('[push] "load-more", params:',i),this.pushEvent("load-more",i)}),this.scrollTopObserver=new Gt(this.el,({isIntersecting:t})=>{this.changeBackToTopVisibility(!t)}),this.handleEvent("search",t=>{this.debug('[handle] "search", params:',t);let{index:e,page:i}=t,s=this.sentinel();!Ga(t.filter)&&i===1&&e===(s==null?void 0:s.dataset.index)&&(this.changeBackToTopVisibility(!1),Yt(this.el,0,!0)),this.refreshObservers()}),this.handleEvent("back-to-top",({id:t,fast:e})=>{this.debug(`[handle] "back-to-top", id: ${t}, fast: ${e}`),this.scrollTarget()==="window"?window.scrollTo(0,0):(!t||t===this.el.id)&&Yt(this.el,0,!!e)}),this.handleEvent("change-current-index",()=>{this.scrollObserver.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel()),Yt(this.el,0,!0)}),this.scrollObserver.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel())},destroyed(){this.scrollObserver.unobserve(),this.scrollObserver=null,this.scrollTopObserver.unobserve(),this.scrollTopObserver=null}},nr={mounted(){this.hideVirtualKeyboard=ji(()=>{let t=document.querySelector("input:focus");t?(this.debug("[hideVirtualKeyboard][blur] input:",t),t.blur()):this.debug("[hideVirtualKeyboard][noop]")},100),this.debug("[observe][touchstart] hideVirtualKeyboard()"),this.el.addEventListener("touchstart",this.hideVirtualKeyboard)},destroyed(){this.debug("[unobserve][touchstart] hideVirtualKeyboard()"),this.el.removeEventListener("touchstart",this.hideVirtualKeyboard)}},or={mounted(){this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.scrollTopSentinel=()=>this.el.querySelector(io),this.transientTargetCard=()=>this.el.querySelector(`[dfd-value-dfid="${this.tag.state.targetItemId}"]`),this.changeBackToTopVisibility=t=>{this.pushEvent("change-back-to-top-visibility",{visible:t})},this.scrollTopObserver=new Gt(null,({isIntersecting:t})=>{this.changeBackToTopVisibility(!t)}),this.scrollTopObserver.observe(this.scrollTopSentinel()),this.handleEvent("update-scroll",t=>{setTimeout((()=>{let e=this.transientTargetCard();this.debug('[handle] "update-scroll"',"params:",t,"card:",e),this.tag.targetItemId=null,e!=null?e.scrollIntoView({behavior:"smooth",block:"nearest"}):t.scroll_end&&Yt(Qi(this.el),za(this.el),!1)}).bind(this),1e3)}),this.handleEvent("back-to-top",({id:t,fast:e})=>{this.debug(`[handle] "back-to-top", id: ${t}, fast: ${e}`),this.scrollTarget()==="window"?window.scrollTo(0,0):(!t||t===this.el.id)&&Yt(Qi(this.el),0,e)})}};function Ga(t){return!!t&&Object.keys(t).length>0}function ro(t,e,i,s){return new Intl.NumberFormat(t,{style:"currency",maximumFractionDigits:parseInt(i,10),numberingSystem:s,currency:e})}function no(t,e,i){return new Intl.NumberFormat(t,{maximumFractionDigits:parseInt(e,10),numberingSystem:i})}var ar=class{constructor(e,i,s,r,n){this.template=e,this.symbol=i,this.thousand=s,this.decimal=r,this.precision=n}format(e){let i=e<0,s=Math.pow(10,this.precision),r=(Math.round(e*s)/s).toFixed(this.precision),n=`${parseInt(Math.abs(r||0).toFixed(this.precision),10)}`,o=n.length>3?n.length%3:0,a=r.split(".")[1],l=[];return o>0&&l.push(`${n.substring(0,o)}${this.thousand}`),l.push(n.substring(o).replace(/(\d{3})(?=\d)/g,"$1"+this.thousand)),this.precision>0&&parseInt(a,10)>0&&l.push(`${this.decimal}${a}`),l=this.template.replace(/%s/g,this.symbol).replace(/%v/g,l.join("")),i&&(l=`-${l}`),l}};"use strict";var We;(function(t){t.Range="range",t.Steps="steps",t.Positions="positions",t.Count="count",t.Values="values"})(We||(We={}));var de;(function(t){t[t.None=-1]="None",t[t.NoValue=0]="NoValue",t[t.LargeValue=1]="LargeValue",t[t.SmallValue=2]="SmallValue"})(de||(de={}));function Ya(t){return Zi(t)&&typeof t.from=="function"}function Zi(t){return typeof t=="object"&&typeof t.to=="function"}function oo(t){t.parentElement.removeChild(t)}function lr(t){return t!=null}function ao(t){t.preventDefault()}function Qa(t){return t.filter(function(e){return this[e]?!1:this[e]=!0},{})}function Za(t,e){return Math.round(t/e)*e}function el(t,e){var i=t.getBoundingClientRect(),s=t.ownerDocument,r=s.documentElement,n=co(s);return/webkit.*Chrome.*Mobile/i.test(navigator.userAgent)&&(n.x=0),e?i.top+n.y-r.clientTop:i.left+n.x-r.clientLeft}function Pe(t){return typeof t=="number"&&!isNaN(t)&&isFinite(t)}function lo(t,e,i){i>0&&(ce(t,e),setTimeout(function(){ts(t,e)},i))}function ho(t){return Math.max(Math.min(t,100),0)}function es(t){return Array.isArray(t)?t:[t]}function tl(t){t=String(t);var e=t.split(".");return e.length>1?e[1].length:0}function ce(t,e){t.classList&&!/\s/.test(e)?t.classList.add(e):t.className+=" "+e}function ts(t,e){t.classList&&!/\s/.test(e)?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}function il(t,e){return t.classList?t.classList.contains(e):new RegExp("\\b"+e+"\\b").test(t.className)}function co(t){var e=window.pageXOffset!==void 0,i=(t.compatMode||"")==="CSS1Compat",s=e?window.pageXOffset:i?t.documentElement.scrollLeft:t.body.scrollLeft,r=e?window.pageYOffset:i?t.documentElement.scrollTop:t.body.scrollTop;return{x:s,y:r}}function sl(){return window.navigator.pointerEnabled?{start:"pointerdown",move:"pointermove",end:"pointerup"}:window.navigator.msPointerEnabled?{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:{start:"mousedown touchstart",move:"mousemove touchmove",end:"mouseup touchend"}}function rl(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("test",null,e)}catch(i){}return t}function nl(){return window.CSS&&CSS.supports&&CSS.supports("touch-action","none")}function hr(t,e){return 100/(e-t)}function cr(t,e,i){return e*100/(t[i+1]-t[i])}function ol(t,e){return cr(t,t[0]<0?e+Math.abs(t[0]):e-t[0],0)}function al(t,e){return e*(t[1]-t[0])/100+t[0]}function Qt(t,e){for(var i=1;t>=e[i];)i+=1;return i}function ll(t,e,i){if(i>=t.slice(-1)[0])return 100;var s=Qt(i,t),r=t[s-1],n=t[s],o=e[s-1],a=e[s];return o+ol([r,n],i)/hr(o,a)}function hl(t,e,i){if(i>=100)return t.slice(-1)[0];var s=Qt(i,e),r=t[s-1],n=t[s],o=e[s-1],a=e[s];return al([r,n],(i-o)*hr(o,a))}function cl(t,e,i,s){if(s===100)return s;var r=Qt(s,t),n=t[r-1],o=t[r];return i?s-n>(o-n)/2?o:n:e[r-1]?t[r-1]+Za(s-t[r-1],e[r-1]):s}var uo=function(){function t(e,i,s){this.xPct=[],this.xVal=[],this.xSteps=[],this.xNumSteps=[],this.xHighestCompleteStep=[],this.xSteps=[s||!1],this.xNumSteps=[!1],this.snap=i;var r,n=[];for(Object.keys(e).forEach(function(o){n.push([es(e[o]),o])}),n.sort(function(o,a){return o[0][0]-a[0][0]}),r=0;rthis.xPct[r+1];)r++;else e===this.xPct[this.xPct.length-1]&&(r=this.xPct.length-2);!s&&e===this.xPct[r+1]&&r++,i===null&&(i=[]);var n,o=1,a=i[r],l=0,c=0,f=0,m=0;for(s?n=(e-this.xPct[r])/(this.xPct[r+1]-this.xPct[r]):n=(this.xPct[r+1]-e)/(this.xPct[r+1]-this.xPct[r]);a>0;)l=this.xPct[r+1+m]-this.xPct[r+m],i[r+m]*o+100-n*100>100?(c=l*n,o=(a-100*n)/i[r+m],n=1):(c=i[r+m]*l/100*o,o=0),s?(f=f-c,this.xPct.length+m>=1&&m--):(f=f+c,this.xPct.length-m>=1&&m++),a=i[r+m]*o;return e+f},t.prototype.toStepping=function(e){return e=ll(this.xVal,this.xPct,e),e},t.prototype.fromStepping=function(e){return hl(this.xVal,this.xPct,e)},t.prototype.getStep=function(e){return e=cl(this.xPct,this.xSteps,this.snap,e),e},t.prototype.getDefaultStep=function(e,i,s){var r=Qt(e,this.xPct);return(e===100||i&&e===this.xPct[r-1])&&(r=Math.max(r-1,1)),(this.xVal[r]-this.xVal[r-1])/s},t.prototype.getNearbySteps=function(e){var i=Qt(e,this.xPct);return{stepBefore:{startValue:this.xVal[i-2],step:this.xNumSteps[i-2],highestStep:this.xHighestCompleteStep[i-2]},thisStep:{startValue:this.xVal[i-1],step:this.xNumSteps[i-1],highestStep:this.xHighestCompleteStep[i-1]},stepAfter:{startValue:this.xVal[i],step:this.xNumSteps[i],highestStep:this.xHighestCompleteStep[i]}}},t.prototype.countStepDecimals=function(){var e=this.xNumSteps.map(tl);return Math.max.apply(null,e)},t.prototype.hasNoSize=function(){return this.xVal[0]===this.xVal[this.xVal.length-1]},t.prototype.convert=function(e){return this.getStep(this.toStepping(e))},t.prototype.handleEntryPoint=function(e,i){var s;if(e==="min"?s=0:e==="max"?s=100:s=parseFloat(e),!Pe(s)||!Pe(i[0]))throw new Error("noUiSlider: 'range' value isn't numeric.");this.xPct.push(s),this.xVal.push(i[0]);var r=Number(i[1]);s?this.xSteps.push(isNaN(r)?!1:r):isNaN(r)||(this.xSteps[0]=r),this.xHighestCompleteStep.push(0)},t.prototype.handleStepPoint=function(e,i){if(!!i){if(this.xVal[e]===this.xVal[e+1]){this.xSteps[e]=this.xHighestCompleteStep[e]=this.xVal[e];return}this.xSteps[e]=cr([this.xVal[e],this.xVal[e+1]],i,0)/hr(this.xPct[e],this.xPct[e+1]);var s=(this.xVal[e+1]-this.xVal[e])/this.xNumSteps[e],r=Math.ceil(Number(s.toFixed(3))-1),n=this.xVal[e]+this.xNumSteps[e]*r;this.xHighestCompleteStep[e]=n}},t}(),fo={to:function(t){return t===void 0?"":t.toFixed(2)},from:Number},po={target:"target",base:"base",origin:"origin",handle:"handle",handleLower:"handle-lower",handleUpper:"handle-upper",touchArea:"touch-area",horizontal:"horizontal",vertical:"vertical",background:"background",connect:"connect",connects:"connects",ltr:"ltr",rtl:"rtl",textDirectionLtr:"txt-dir-ltr",textDirectionRtl:"txt-dir-rtl",draggable:"draggable",drag:"state-drag",tap:"state-tap",active:"active",tooltip:"tooltip",pips:"pips",pipsHorizontal:"pips-horizontal",pipsVertical:"pips-vertical",marker:"marker",markerHorizontal:"marker-horizontal",markerVertical:"marker-vertical",markerNormal:"marker-normal",markerLarge:"marker-large",markerSub:"marker-sub",value:"value",valueHorizontal:"value-horizontal",valueVertical:"value-vertical",valueNormal:"value-normal",valueLarge:"value-large",valueSub:"value-sub"},Ke={tooltips:".__tooltips",aria:".__aria"};function dl(t,e){if(!Pe(e))throw new Error("noUiSlider: 'step' is not numeric.");t.singleStep=e}function ul(t,e){if(!Pe(e))throw new Error("noUiSlider: 'keyboardPageMultiplier' is not numeric.");t.keyboardPageMultiplier=e}function fl(t,e){if(!Pe(e))throw new Error("noUiSlider: 'keyboardMultiplier' is not numeric.");t.keyboardMultiplier=e}function pl(t,e){if(!Pe(e))throw new Error("noUiSlider: 'keyboardDefaultStep' is not numeric.");t.keyboardDefaultStep=e}function ml(t,e){if(typeof e!="object"||Array.isArray(e))throw new Error("noUiSlider: 'range' is not an object.");if(e.min===void 0||e.max===void 0)throw new Error("noUiSlider: Missing 'min' or 'max' in 'range'.");t.spectrum=new uo(e,t.snap||!1,t.singleStep)}function gl(t,e){if(e=es(e),!Array.isArray(e)||!e.length)throw new Error("noUiSlider: 'start' option is incorrect.");t.handles=e.length,t.start=e}function _l(t,e){if(typeof e!="boolean")throw new Error("noUiSlider: 'snap' option must be a boolean.");t.snap=e}function vl(t,e){if(typeof e!="boolean")throw new Error("noUiSlider: 'animate' option must be a boolean.");t.animate=e}function bl(t,e){if(typeof e!="number")throw new Error("noUiSlider: 'animationDuration' option must be a number.");t.animationDuration=e}function yl(t,e){var i=[!1],s;if(e==="lower"?e=[!0,!1]:e==="upper"&&(e=[!1,!0]),e===!0||e===!1){for(s=1;s1)throw new Error("noUiSlider: 'padding' option must not exceed 100% of the range.")}}function xl(t,e){switch(e){case"ltr":t.dir=0;break;case"rtl":t.dir=1;break;default:throw new Error("noUiSlider: 'direction' option was not recognized.")}}function Tl(t,e){if(typeof e!="string")throw new Error("noUiSlider: 'behaviour' must be a string containing options.");var i=e.indexOf("tap")>=0,s=e.indexOf("drag")>=0,r=e.indexOf("fixed")>=0,n=e.indexOf("snap")>=0,o=e.indexOf("hover")>=0,a=e.indexOf("unconstrained")>=0,l=e.indexOf("drag-all")>=0,c=e.indexOf("smooth-steps")>=0;if(r){if(t.handles!==2)throw new Error("noUiSlider: 'fixed' behaviour must be used with 2 handles");mo(t,t.start[1]-t.start[0])}if(a&&(t.margin||t.limit))throw new Error("noUiSlider: 'unconstrained' behaviour cannot be used with margin or limit");t.events={tap:i||n,drag:s,dragAll:l,smoothSteps:c,fixed:r,snap:n,hover:o,unconstrained:a}}function Al(t,e){if(e!==!1)if(e===!0||Zi(e)){t.tooltips=[];for(var i=0;i= 2) required for mode 'count'.");for(var d=h.values-1,u=100/d,_=[];d--;)_[d]=d*u;return _.push(100),R(_,h.stepped)}return h.mode===We.Positions?R(h.values,h.stepped):h.mode===We.Values?h.stepped?h.values.map(function(S){return v.fromStepping(v.getStep(v.toStepping(S)))}):h.values:[]}function R(h,d){return h.map(function(u){return v.fromStepping(d?v.getStep(u):u)})}function F(h){function d($,K){return Number(($+K).toFixed(7))}var u=J(h),_={},S=v.xVal[0],y=v.xVal[v.xVal.length-1],A=!1,x=!1,V=0;return u=Qa(u.slice().sort(function($,K){return $-K})),u[0]!==S&&(u.unshift(S),A=!0),u[u.length-1]!==y&&(u.push(y),x=!0),u.forEach(function($,K){var z,M,Q,ae=$,te=u[K+1],re,us,fs,ps,kr,ms,Pr,Rr=h.mode===We.Steps;for(Rr&&(z=v.xNumSteps[K]),z||(z=te-ae),te===void 0&&(te=ae),z=Math.max(z,1e-7),M=ae;M<=te;M=d(M,z)){for(re=v.toStepping(M),us=re-V,kr=us/(h.density||1),ms=Math.round(kr),Pr=us/ms,Q=1;Q<=ms;Q+=1)fs=V+Q*Pr,_[fs.toFixed(5)]=[v.fromStepping(fs),0];ps=u.indexOf(M)>-1?de.LargeValue:Rr?de.SmallValue:de.NoValue,!K&&A&&M!==te&&(ps=0),M===te&&x||(_[re.toFixed(5)]=[M,ps]),V=re}}),_}function je(h,d,u){var _,S,y=D.createElement("div"),A=(_={},_[de.None]="",_[de.NoValue]=e.cssClasses.valueNormal,_[de.LargeValue]=e.cssClasses.valueLarge,_[de.SmallValue]=e.cssClasses.valueSub,_),x=(S={},S[de.None]="",S[de.NoValue]=e.cssClasses.markerNormal,S[de.LargeValue]=e.cssClasses.markerLarge,S[de.SmallValue]=e.cssClasses.markerSub,S),V=[e.cssClasses.valueHorizontal,e.cssClasses.valueVertical],$=[e.cssClasses.markerHorizontal,e.cssClasses.markerVertical];ce(y,e.cssClasses.pips),ce(y,e.ort===0?e.cssClasses.pipsHorizontal:e.cssClasses.pipsVertical);function K(M,Q){var ae=Q===e.cssClasses.value,te=ae?V:$,re=ae?A:x;return Q+" "+te[e.ort]+" "+re[M]}function z(M,Q,ae){if(ae=d?d(Q,ae):ae,ae!==de.None){var te=W(y,!1);te.className=K(ae,e.cssClasses.marker),te.style[e.style]=M+"%",ae>de.NoValue&&(te=W(y,!1),te.className=K(ae,e.cssClasses.value),te.setAttribute("data-value",String(Q)),te.style[e.style]=M+"%",te.innerHTML=String(u.to(Q)))}}return Object.keys(h).forEach(function(M){z(M,h[M][0],h[M][1])}),y}function me(){f&&(oo(f),f=null)}function Re(h){me();var d=F(h),u=h.filter,_=h.format||{to:function(S){return String(Math.round(S))}};return f=o.appendChild(je(d,u,_)),f}function Ge(){var h=a.getBoundingClientRect(),d="offset"+["Width","Height"][e.ort];return e.ort===0?h.width||a[d]:h.height||a[d]}function oe(h,d,u,_){var S=function(A){var x=ct(A,_.pageOffset,_.target||d);if(!x||Y()&&!_.doNotReject||il(o,e.cssClasses.tap)&&!_.doNotReject||h===s.start&&x.buttons!==void 0&&x.buttons>1||_.hover&&x.buttons)return!1;n||x.preventDefault(),x.calcPoint=x.points[e.ort],u(x,_)},y=[];return h.split(" ").forEach(function(A){d.addEventListener(A,S,n?{passive:!0}:!1),y.push([A,S])}),y}function ct(h,d,u){var _=h.type.indexOf("touch")===0,S=h.type.indexOf("mouse")===0,y=h.type.indexOf("pointer")===0,A=0,x=0;if(h.type.indexOf("MSPointer")===0&&(y=!0),h.type==="mousedown"&&!h.buttons&&!h.touches)return!1;if(_){var V=function(z){var M=z.target;return M===u||u.contains(M)||h.composed&&h.composedPath().shift()===u};if(h.type==="touchstart"){var $=Array.prototype.filter.call(h.touches,V);if($.length>1)return!1;A=$[0].pageX,x=$[0].pageY}else{var K=Array.prototype.find.call(h.changedTouches,V);if(!K)return!1;A=K.pageX,x=K.pageY}}return d=d||co(D),(S||y)&&(A=h.clientX+d.x,x=h.clientY+d.y),h.pageOffset=d,h.points=[A,x],h.cursor=S||y,h}function xe(h){var d=h-el(a,e.ort),u=d*100/Ge();return u=ho(u),e.dir?100-u:u}function Ct(h){var d=100,u=!1;return l.forEach(function(_,S){if(!pe(S)){var y=b[S],A=Math.abs(y-h),x=A===100&&d===100,V=Ay;(V||$||x)&&(u=S,d=A)}}),u}function ti(h,d){h.type==="mouseout"&&h.target.nodeName==="HTML"&&h.relatedTarget===null&&as(h,d)}function Jo(h,d){if(navigator.appVersion.indexOf("MSIE 9")===-1&&h.buttons===0&&d.buttonsProperty!==0)return as(h,d);var u=(e.dir?-1:1)*(h.calcPoint-d.startCalcPoint),_=u*100/d.baseSize;Er(u>0,_,d.locations,d.handleNumbers,d.connect)}function as(h,d){d.handle&&(ts(d.handle,e.cssClasses.active),N-=1),d.listeners.forEach(function(u){j.removeEventListener(u[0],u[1])}),N===0&&(ts(o,e.cssClasses.drag),ds(),h.cursor&&(q.style.cursor="",q.removeEventListener("selectstart",ao))),e.events.smoothSteps&&(d.handleNumbers.forEach(function(u){Ye(u,b[u],!0,!0,!1,!1)}),d.handleNumbers.forEach(function(u){G("update",u)})),d.handleNumbers.forEach(function(u){G("change",u),G("set",u),G("end",u)})}function ls(h,d){if(!d.handleNumbers.some(pe)){var u;if(d.handleNumbers.length===1){var _=l[d.handleNumbers[0]];u=_.children[0],N+=1,ce(u,e.cssClasses.active)}h.stopPropagation();var S=[],y=oe(s.move,j,Jo,{target:h.target,handle:u,connect:d.connect,listeners:S,startCalcPoint:h.calcPoint,baseSize:Ge(),pageOffset:h.pageOffset,handleNumbers:d.handleNumbers,buttonsProperty:h.buttons,locations:b.slice()}),A=oe(s.end,j,as,{target:h.target,handle:u,listeners:S,doNotReject:!0,handleNumbers:d.handleNumbers}),x=oe("mouseout",j,ti,{target:h.target,handle:u,listeners:S,doNotReject:!0,handleNumbers:d.handleNumbers});S.push.apply(S,y.concat(A,x)),h.cursor&&(q.style.cursor=getComputedStyle(h.target).cursor,l.length>1&&ce(o,e.cssClasses.drag),q.addEventListener("selectstart",ao,!1)),d.handleNumbers.forEach(function(V){G("start",V)})}}function qo(h){h.stopPropagation();var d=xe(h.calcPoint),u=Ct(d);u!==!1&&(e.events.snap||lo(o,e.cssClasses.tap,e.animationDuration),Ye(u,d,!0,!0),ds(),G("slide",u,!0),G("update",u,!0),e.events.snap?ls(h,{handleNumbers:[u]}):(G("change",u,!0),G("set",u,!0)))}function Wo(h){var d=xe(h.calcPoint),u=v.getStep(d),_=v.fromStepping(u);Object.keys(O).forEach(function(S){S.split(".")[0]==="hover"&&O[S].forEach(function(y){y.call(ri,_)})})}function Ko(h,d){if(Y()||pe(d))return!1;var u=["Left","Right"],_=["Down","Up"],S=["PageDown","PageUp"],y=["Home","End"];e.dir&&!e.ort?u.reverse():e.ort&&!e.dir&&(_.reverse(),S.reverse());var A=h.key.replace("Arrow",""),x=A===S[0],V=A===S[1],$=A===_[0]||A===u[0]||x,K=A===_[1]||A===u[1]||V,z=A===y[0],M=A===y[1];if(!$&&!K&&!z&&!M)return!0;h.preventDefault();var Q;if(K||$){var ae=$?0:1,te=Cr(d),re=te[ae];if(re===null)return!1;re===!1&&(re=v.getDefaultStep(b[d],$,e.keyboardDefaultStep)),V||x?re*=e.keyboardPageMultiplier:re*=e.keyboardMultiplier,re=Math.max(re,1e-7),re=($?-1:1)*re,Q=E[d]+re}else M?Q=e.spectrum.xVal[e.spectrum.xVal.length-1]:Q=e.spectrum.xVal[0];return Ye(d,v.toStepping(Q),!0,!0),G("slide",d),G("update",d),G("change",d),G("set",d),!1}function zo(h){h.fixed||l.forEach(function(d,u){oe(s.start,d.children[0],ls,{handleNumbers:[u]})}),h.tap&&oe(s.start,a,qo,{}),h.hover&&oe(s.move,a,Wo,{hover:!0}),h.drag&&c.forEach(function(d,u){if(!(d===!1||u===0||u===c.length-1)){var _=l[u-1],S=l[u],y=[d],A=[_,S],x=[u-1,u];ce(d,e.cssClasses.draggable),h.fixed&&(y.push(_.children[0]),y.push(S.children[0])),h.dragAll&&(A=l,x=w),y.forEach(function(V){oe(s.start,V,ls,{handles:A,handleNumbers:x,connect:d})})}})}function hs(h,d){O[h]=O[h]||[],O[h].push(d),h.split(".")[0]==="update"&&l.forEach(function(u,_){G("update",_)})}function Go(h){return h===Ke.aria||h===Ke.tooltips}function kt(h){var d=h&&h.split(".")[0],u=d?h.substring(d.length):h;Object.keys(O).forEach(function(_){var S=_.split(".")[0],y=_.substring(S.length);(!d||d===S)&&(!u||u===y)&&(!Go(y)||u===y)&&delete O[_]})}function G(h,d,u){Object.keys(O).forEach(function(_){var S=_.split(".")[0];h===S&&O[_].forEach(function(y){y.call(ri,E.map(e.format.to),d,E.slice(),u||!1,b.slice(),ri)})})}function ii(h,d,u,_,S,y,A){var x;return l.length>1&&!e.events.unconstrained&&(_&&d>0&&(x=v.getAbsoluteDistance(h[d-1],e.margin,!1),u=Math.max(u,x)),S&&d1&&e.limit&&(_&&d>0&&(x=v.getAbsoluteDistance(h[d-1],e.limit,!1),u=Math.min(u,x)),S&&d1?_.forEach(function(z,M){var Q=ii(y,z,y[z]+d,V[M],$[M],!1,x);Q===!1?d=0:(d=Q-y[z],y[z]=Q)}):V=$=[!0];var K=!1;_.forEach(function(z,M){K=Ye(z,u[z]+d,V[M],$[M],!1,x)||K}),K&&(_.forEach(function(z){G("update",z),G("slide",z)}),S!=null&&G("drag",A))}function wr(h,d){return e.dir?100-h-d:h}function Yo(h,d){b[h]=d,E[h]=v.fromStepping(d);var u=wr(d,0)-Z,_="translate("+cs(u+"%","0")+")";l[h].style[e.transformRule]=_,xr(h),xr(h+1)}function ds(){w.forEach(function(h){var d=b[h]>50?-1:1,u=3+(l.length+d*h);l[h].style.zIndex=String(u)})}function Ye(h,d,u,_,S,y){return S||(d=ii(b,h,d,u,_,!1,y)),d===!1?!1:(Yo(h,d),!0)}function xr(h){if(!!c[h]){var d=0,u=100;h!==0&&(d=b[h-1]),h!==c.length-1&&(u=b[h]);var _=u-d,S="translate("+cs(wr(d,_)+"%","0")+")",y="scale("+cs(_/100,"1")+")";c[h].style[e.transformRule]=S+" "+y}}function Tr(h,d){return h===null||h===!1||h===void 0||(typeof h=="number"&&(h=String(h)),h=e.format.from(h),h!==!1&&(h=v.toStepping(h)),h===!1||isNaN(h))?b[d]:h}function si(h,d,u){var _=es(h),S=b[0]===void 0;d=d===void 0?!0:d,e.animate&&!S&&lo(o,e.cssClasses.tap,e.animationDuration),w.forEach(function(x){Ye(x,Tr(_[x],x),!0,!1,u)});var y=w.length===1?0:1;if(S&&v.hasNoSize()&&(u=!0,b[0]=0,w.length>1)){var A=100/(w.length-1);w.forEach(function(x){b[x]=x*A})}for(;y=0&&hu.stepAfter.startValue&&(S=u.stepAfter.startValue-_),_>u.thisStep.startValue?y=u.thisStep.step:u.stepBefore.step===!1?y=!1:y=_-u.stepBefore.highestStep,d===100?S=null:d===0&&(y=null);var A=v.countStepDecimals();return S!==null&&S!==!1&&(S=Number(S.toFixed(A))),y!==null&&y!==!1&&(y=Number(y.toFixed(A))),[y,S]}function ta(){return w.map(Cr)}function ia(h,d){var u=Ar(),_=["margin","limit","padding","range","animate","snap","step","format","pips","tooltips"];_.forEach(function(y){h[y]!==void 0&&(i[y]=h[y])});var S=go(i);_.forEach(function(y){h[y]!==void 0&&(e[y]=S[y])}),v=S.spectrum,e.margin=S.margin,e.limit=S.limit,e.padding=S.padding,e.pips?Re(e.pips):me(),e.tooltips?k():ze(),b=[],si(lr(h.start)?h.start:u,d)}function sa(){a=P(o),g(e.connect,a),zo(e.events),si(e.start),e.pips&&Re(e.pips),e.tooltips&&k(),C()}sa();var ri={destroy:ea,steps:ta,on:hs,off:kt,get:Ar,set:si,setHandle:Zo,reset:Qo,disable:At,enable:os,__moveHandles:function(h,d,u){Er(h,d,b,u)},options:i,updateOptions:ia,target:o,removePips:me,removeTooltips:ze,getPositions:function(){return b.slice()},getTooltips:function(){return m},getOrigins:function(){return l},pips:Re};return ri}function Hl(t,e){if(!t||!t.nodeName)throw new Error("noUiSlider: create requires a single element, got: "+t);if(t.noUiSlider)throw new Error("noUiSlider: Slider was already initialized.");var i=go(e),s=Ol(t,i,e);return t.noUiSlider=s,s}var _o={__spectrum:uo,cssClasses:po,create:Hl};function vo(t){return t.filter((e,i)=>t.indexOf(e)===i)}function bo(t){let e={};return{to(i){let s=t.format(i);return e[s]=i,s},from(i){return e[i]}}}function dr(t,e){let{min:i,max:s,from:r,to:n}=t;return i=parseFloat(i),s=parseFloat(s),i===s&&s++,r=parseFloat(r)||i,n=parseFloat(n)||s,{range:{min:i,max:s},start:[e.to(r),e.to(n)]}}function yo(t,e,i,s={}){return _o.create(t,I({cssPrefix:"dfd-slider-",orientation:"horizontal",direction:s.rtl?"rtl":"ltr",tooltips:!0,padding:0,connect:!0,animate:!0,step:1,keyboardSupport:!0,format:e,pips:{mode:"count",values:3,density:6,stepped:!0,format:e}},i))}function So(t,e,i){let s=getComputedStyle(t).direction==="rtl",r=t.noUiSlider.options.direction==="rtl",n=t.noUiSlider.options.orientation==="vertical",a=t.noUiSlider.getTooltips().map(c=>c.cloneNode(!0)),l=t.noUiSlider.getOrigins();a.forEach(function(c,f){c&&l[f].appendChild(c)}),t.noUiSlider.on("update",function(c,f,m,v,E){let b=[[]],w=[[]],N=[[]],O=0;a[0]&&(b[0][0]=0,w[0][0]=E[0],N[0][0]=c[0]);for(let D=1;De)&&(O++,b[O]=[],N[O]=[],w[O]=[]),a[D]&&(b[O].push(D),N[O].push(c[D]),w[O].push(E[D]));b.forEach(function(D,j){let q=D.length;for(let Z=0;Ztypeof r=="string"?new ar(r,o,a,s,parseInt(n,10)):i?ro(e,i,parseInt(n,10),w):no(e,parseInt(l,10),w))();this.format=bo(O),this.slider=yo(this.el,this.format,dr({min:c,max:f,from:m,to:v},this.format),{rtl:N}),this.slider.on("change",D=>{let[j,q]=D,W={index:this.el.dataset.index,range:{[t]:{from:this.format.from(j),to:this.format.from(q)}}};E?this.pushEventTo(E,"slide",W):this.pushEvent("slide",W)}),b||So(this.el,25," - ")},updated(){let{min:t,max:e,from:i,to:s}=this.el.dataset;this.slider.updateOptions(dr({min:t,max:e,from:i,to:s},this.format))},destroyed(){this.el.noUiSlider.destroy()}};"use strict";var wo={mounted(){let t=0,e=0;this.el.addEventListener("touchstart",i=>{t=i.changedTouches[0].screenY},!1),this.el.addEventListener("touchend",i=>{e=i.changedTouches[0].screenY,e>t&&this.pushEvent(this.el.dataset.action,{index:""})},!1)}};var is=window.SpeechRecognition||window.webkitSpeechRecognition||null,xo=["click"],To=["start","end","error","result"],Ml="voice-search",Ao="voice-status-change";function Nl(t){return t.results.length>0?t.results[0][0].transcript:null}var Co={mounted(){!is||(this.recording=!1,this.driver=new is,this.driver.continuous=!1,this.driver.interimResults=!1,this.handleVoiceEvent=t=>{switch(t.type){case"end":case"error":this.driver.stop(),this.recording=!1,this.pushEvent(Ao,{recording:!1});break;case"click":this.driver[this.recording?"stop":"start"](),this.recording=!this.recording,this.pushEvent(Ao,{recording:this.recording});break;case"result":{let e=Nl(t);e&&this.pushEvent(Ml,{query:e});break}}},xo.forEach(t=>this.el.addEventListener(t,this.handleVoiceEvent)),To.forEach(t=>this.driver.addEventListener(t,this.handleVoiceEvent)))},destroyed(){xo.forEach(t=>this.el.removeEventListener(t,this.handleVoiceEvent)),To.forEach(t=>this.driver.removeEventListener(t,this.handleVoiceEvent)),this.driver=null}};"use strict";var ko={mounted(){this.sort=t=>{let e=t.target.selectedOptions[0];this.pushEvent("sort",{index:e.getAttribute("dfd-data-index"),field:e.getAttribute("dfd-data-field"),order:e.getAttribute("dfd-data-order")})},this.el.addEventListener("change",this.sort)},destroyed(){this.el.removeEventListener("change",this.sort)}};function fe(t,e,...i){var o;let s=((o=i.find(a=>!!a.options))==null?void 0:o.options)||{},r={get tag(){return e},get options(){return s},debug(...a){L(`[hook][${t}]`,...a)}};return["mounted","beforeUpdate","updated","destroyed","disconnected","reconnected"].forEach(a=>{let l=i.map(c=>c[a]).filter(c=>!!c);r[a]=function(){l.length>0&&this.debug(`${a}()`),l.forEach(c=>c.call(this))}}),r}function Po(t){return JSON.parse(JSON.stringify(t))}function ur(t,e,i){let s=i.x,r=s+i.width,n=i.y,o=n+i.height;return t>=s&&t<=r&&e>=n&&e<=o}function Ro(){var t;if("maxTouchPoints"in navigator)return navigator.maxTouchPoints>0;if("msMaxTouchPoints"in navigator)return navigator.msMaxTouchPoints>0;{let e=(t=window.matchMedia)==null?void 0:t.call(window,"(pointer:coarse)");if((e==null?void 0:e.media)==="(pointer:coarse)")return!!e.matches;if("orientation"in window)return!0;{let i=navigator.userAgent;return/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(i)||/\b(Android|Windows Phone|iPad|iPod)\b/i.test(i)}}}function Io(t){if(t instanceof PointerEvent)switch(t.pointerType){case"mouse":case"pen":case"touch":return!0;default:return!1}else if(t instanceof MouseEvent){let{pageX:e,pageY:i,target:s}=t;return!(e===i&&e===0&&$l(s))}return!1}function $l(t){return t.getAttribute("type")==="submit"&&(t.tagName==="BUTTON"||t.tagName==="INPUT")}function fr(t){return typeof t=="undefined"?null:t}var Ul="Search",Lo=Ro(),Do="latestSearches",Fl=10,jl="dfd-root",pr=class{constructor(e){this.__handleTriggerEvent__=this.__handleTriggerEvent__.bind(this),this.__handleLinkClick__=this.__handleLinkClick__.bind(this),this.__handleDocumentMousedown__=this.__handleDocumentMousedown__.bind(this),this.__handleDocumentKeyup__=this.__handleDocumentKeyup__.bind(this),this.__updateSocketParams__=this.__updateSocketParams__.bind(this),this.__afterConnect__=this.__afterConnect__.bind(this),this.__afterDisconnect__=this.__afterDisconnect__.bind(this);let{autoload:i,currency:s,exportResultsData:r,hashid:n,id:o,installationId:a,is_checkout:l,language:c,layerType:f,search_query_retention:m,trigger:v,urlHash:E,zone:b}=e;this._installationId=a,this._zone=b,this._hashid=n,this._language=c,this._currency=s,this._exportResultsData=r,this._layerType=f,l&&this.dispatch("doofinder.layer.checkout",{url:window.location.href}),this._mount=this.__createMount__(o),this._mount.addEventListener("click",this.__handleLinkClick__),this._eventBus=new ir(this._mount.id),this._eventBusSubscriptions=[Rt,dt,ut,It].map(w=>this._eventBus.on(w,this.__handleTriggerEvent__)),this._trigger=v,this._trigger.setEventBus(this._eventBus),this._display=new tr(this._mount),this._state=this.__defineNewState__(a,i,E,f),this._data=new pt(`${a}.data`),this._sessionData=new pt(`${a}.data`,window.sessionStorage),this._params=this.__buildSocketParams__(e),this._hooks=this.__buildSocketHooks__(e),this._connection=null,this._connectedPromise=new Ie,this._theme=null,this._searchQueryRetention=m,this._urlHash=E,this._autoload=i,this.closable&&this.mount.classList.add("dfd-closable"),this._trigger.flushMessages(),this.__loadState__().then(()=>this.dispatch("doofinder.ready"))}__createMount__(e){let i=document.createElement("div");return i.id=e||`df-${Bi(32)}`,i.dataset.dfdView=Ul,i.setAttribute(Ue,""),i.classList.add(jl),Object.defineProperty(i,"doofinderTag",{value:this,writable:!1}),i}get mount(){return this._mount}get trigger(){return this._trigger}get display(){return this._display}get hashid(){return this._hashid}get installationId(){return this._installationId}get zone(){return this._zone}get language(){return this._language}get currency(){return this._currency}get exportResultsData(){return this._exportResultsData}get layerType(){return this._layerType}get searchQueryRetention(){return this._searchQueryRetention}get data(){return this._data}get state(){return this._state}get closable(){return this.display.type!==at||!this._state.hasAutoloadQueryParam}set targetItemId(e){this.state.targetItemId=e}enableDebug(){return this._connection?(this._connection.enableDebug(),!0):!1}debug(...e){L("[tag]",...e)}updateState({value:e=this._state.targetItemId,itemId:i=this._state.targetItemId,isTransitory:s=this._state.isTransitory}){this._state.update(e,i,s)}__handleTriggerEvent__(e){let{source:i,originalEvent:s}=e.detail,{query:r}=e.detail,n=r?{query:r}:{};this.connect(n).then(()=>{this.__shouldDisplay__(e)?(this.show(i),e.type===ut&&this.search(r)):e.type===It&&this.submit(r,o=>{var l;if(!o)return;let{submit:a}=o||{};a&&((l=s==null?void 0:s.target.closest("form"))==null||l.submit())})})}__shouldDisplay__(e){let{query:i}=e.detail;switch(this._display.type){case $i:return(e.type===ut||e.type===dt)&&(this._display.screenType==="classic-initial"||!!i);case at:return(e.type===ut||e.type===dt)&&!!i;case Ui:return e.type===Rt||e.type===dt;default:return!1}}__handleLinkClick__(e){var r,n;if(this._layerType==="category_pages")return;if(!e.target.href){(r=this._connection)==null||r.setPreventReconnect(!1);return}let i=e.target.closest("[dfd-value-dfid]"),s=i==null?void 0:i.getAttribute("dfd-value-dfid");s&&this.updateState({itemId:s}),(n=this._connection)==null||n.setPreventReconnect(!0),this._searchQueryRetention&&this._state.saveTransitory(e.target.href)}__handleDocumentMousedown__(e){if(this._display.hidden||this._display.type===at||!Io(e))return;let{clientX:i,clientY:s}=e;if(ur(i,s,this._mount.getBoundingClientRect()))return;let r=this._display.method.positionReference;!!r&&(ur(i,s,r.getBoundingClientRect())||e.target.closest('button[type="submit"]')&&e.target.closest("form")===r.closest("form"))||this.close()}__handleDocumentKeyup__(e){var i;e.key==="Escape"&&this.layerType!=="category_pages"&&((i=document.activeElement)==null||i.blur(),this.close())}__loadState__(){if(this._layerType==="category_pages"||(this.debug("load state:",this._state.value),this._trigger.updateQuery(this._searchQueryRetention?this._state.query:""),!this._state.value))return Promise.resolve();let e=this._state.value;return this.connect({state:e}).then(()=>{this._state.isTransitory?this.debug("Layer not opened because the state is transitory"):this.show()})}getLatestSearches(){return this._data.getItem(Do)||[]}updateLatestSearches(e){this._data.setItem(Do,e)}onLoad(e){let{min_capture_length:i,capture_submit:s,align:r,display_type:n,insertion_point:o,insertion_method:a,screen_type:l,theme:c}=e;this.__updateTrigger__({min_capture_length:i,capture_submit:s}),this.__updateDisplay__({display_type:n,insertion_point:o,insertion_method:a,screen_type:l,theme:c,align:r}),this._connectedPromise.resolve(e)}__updateTrigger__({min_capture_length:e,capture_submit:i}){this._trigger.setCaptureLength(e),this._trigger.captureSubmit=i}__updateDisplay__({display_type:e,insertion_point:i,insertion_method:s,screen_type:r,theme:n,align:o}){this._display.setType(e,{placement:{insertionPoint:i,insertionMethod:s},align:o}),this._display.screenType=r,this._display.updateTheme(n),this._display.hidden||this.updatePosition()}updatePosition(e){return T(this,null,function*(){this._display.updatePosition({positionReference:e||(yield this._trigger.getElement())})})}close(){var e,i;this.closable&&((i=(e=this.getHooksByName("Layer"))==null?void 0:e.pop())==null||i.close())}show(e){return T(this,null,function*(){yield this.updatePosition(e),yield this._display.show(),this.updateState({isTransitory:!1}),setTimeout(()=>{var i;return(i=this._connection)==null?void 0:i.pushEvent("update-scroll")},200),this.dispatch("doofinder.show")})}hide(){return T(this,null,function*(){this._display&&(yield this._display.hide()),this.dispatch("doofinder.hide")})}dispatch(e,i={}){let s=Te(I({},i),{tag:this});document.dispatchEvent(new CustomEvent(e,{detail:s}))}connect(e){return this._connection||(this.debug(`creating live socket for layer: ${this._mount.id}`),this._connection=new Ks(this.__connectionSetup__(e)),this._connection.connect(this.__afterConnect__)),this._connectedPromise}isConnected(){return this._connection?this._connection.connected:!1}open(){return T(this,arguments,function*(e={}){let{search:i,screen:s}=e,r=I({},e);i!=null&&!s&&(r.screen="fallback"),typeof i=="string"&&(delete r.search,r.query=i),yield this.connect(r),yield this.show(),typeof i=="object"&&this.search(i)})}openCategoryPages(e){return T(this,null,function*(){let{search:i}=e,s={search:i},r=this._state.value;r&&(s.state=r),L("[category pages] connect with",s),yield this.connect(s),yield this.show(),r||(L("[category pages] no state, opening with: ",i),this.search(i))})}disconnect(){var e;this.layerType!=="category_pages"&&(this.debug(`disconnecting from live socket: ${this._mount.id}`),this._trigger.updateQuery(""),this.updateState({value:"",itemId:null,isTransitory:!1}),this.hide(),(e=this._connection)==null||e.disconnect(this.__afterDisconnect__),this._connection=null,this._connectedPromise=new Ie)}destroy(){return T(this,null,function*(){var e;this.debug(`destroy: ${this._mount.id}`),this.hide(),(e=this._connection)==null||e.disconnect(this.__afterDisconnect__),this._connection=null,this._eventBusSubscriptions.forEach(i=>i()),this._eventBusSubscriptions=null,this._eventBus.teardown(),this._eventBus=null,yield this._display.destroy(),this._display=null,this._trigger.destroy(),this._mount.replaceChildren(),this.dispatch("doofinder.destroy")})}getHooksByName(e){var i;return(i=this._connection)==null?void 0:i.getHooksByName(e)}search(e,i){var r;let s=typeof e=="string"?{query:e}:e;(r=this._connection)==null||r.pushEvent("search-suggest",{search:s},i)}changeLocale(e,i,s){var r;(r=this._connection)==null||r.pushEvent("change-locale",{language:e,currency:i},s)}submit(e,i){var s;(s=this._connection)==null||s.pushEvent("search-submit",{search:{query:e}},i)}__buildSocketParams__(e){let{params:i,sort:s,vars:r,indices:n,state:o,priceName:a}=e,l={hashid:this._hashid,origin:window.location.hostname,indices:n,params:i,sort:s,vars:r,state:o,price_name:a};return["indices","search-server"].filter(c=>!l[c]).forEach(c=>delete l[c]),l}__buildSocketHooks__(e){let i=e.hooks||{},s={Carousel:fe("Carousel",this,$n,i.Carousel||{}),ImageSearch:fe("ImageSearch",this,jn),Input:fe("Input",this,Vn,i.Input||{}),Layer:fe("Layer",this,zn,i.Layer||{}),LayerNotAvailable:fe("LayerNotAvailable",this,Gn),AddToCart:fe("AddToCart",this,Xn,i.AddToCart||{}),EmbeddedResults:fe("EmbeddedResults",this,or,Lo?nr:{},i.EmbeddedResults||{}),Results:fe("Results",this,so,Lo?nr:{},or,i.Results||{}),Slider:fe("Slider",this,Eo,i.Slider||{}),Swipe:fe("Swipe",this,wo,i.Swipe||{}),VoiceSearch:fe("VoiceSearch",this,Co,i.VoiceSearch||{}),SortSelect:fe("SortSelect",this,ko)};return L("[tag] Hooks created:",this._mount.id,s),Object.keys(i).filter(r=>!s[r]).forEach(r=>{s[r]=fe(r,this,i[r]||{})}),s}__connectionSetup__(e){return{url:`${Be(this._zone,!0)}/layer/${ft}`,mount:this._mount,hooks:this._hooks,mainHook:"Layer",params:()=>this.__updateSocketParams__(e),appName:"layer",disconnectCallback:(()=>{this.debug("layer died and can't reconnect automatically! \u{1F92C}"),this.__afterDisconnect__()}).bind(this)}}__updateSocketParams__(e){var s,r,n,o;let i=Te(I({},Po(this._params)),{zone:this.zone,installation_id:this.installationId,language:this.language,currency:this.currency,session_id:Doofinder.Session.getSessionId(),tab_id:"getTabId"in Doofinder.Session?Doofinder.Session.getTabId():null,session_alive:Doofinder.Session.isLive("layer"),user_id:Doofinder.Session.getUserId(),latest_searches:this.getLatestSearches(),voice_supported:!!is,export_results_data:fr((s=this.exportResultsData)==null?void 0:s.slice(0,Fl)),ga_client_id:fr((r=Lt("_ga"))==null?void 0:r.substring(6)),layer_type:this.layerType,state:this._state.value,mount_id:this._mount.id,current_url:window.location.href});return this._layerType==="category_pages"&&(i.search=e.search),((n=this._connection)==null?void 0:n.connected)||(i=I(I({},i),e)),this.debug(`__updateSocketParams__ for layer: ${this._mount.id}`,i," socket connected? ",(o=this._connection)==null?void 0:o.connected," overrides: ",e," current state",this._state.value),i}__afterConnect__(){document.addEventListener("mousedown",this.__handleDocumentMousedown__),document.addEventListener("keyup",this.__handleDocumentKeyup__,{passive:!0})}__afterDisconnect__(){document.removeEventListener("keyup",this.__handleDocumentKeyup__),document.removeEventListener("mousedown",this.__handleDocumentMousedown__),this.dispatch("doofinder.disconnect")}__defineNewState__(e,i,s,r){return new Ze({installationId:e,autoload:i,urlHash:s,layerType:r})}};function Oo(t){return T(this,null,function*(){var o;let e=Vl(t);L("[category pages] displayForSeo options: ",t,"params: ",e);let i=yield Xl(e);if(L("[category pages] displayForSeo htmlContent: ",i),!i)return;let s=Bl(t.id,i);t.device=="mobile"&&(s.classList.remove("dfd-embedded"),s.classList.add("dfd-mobile_embedded")),t.custom_css.forEach(Qe);let r=(o=t.custom_properties)==null?void 0:o.join(` `);Qe(`#${s.id} { ${r||""} }`);let n=document.querySelector(t.insertion_point);n&&n.replaceWith(s)})}function Bl(t,e){let i=pr.__createMount__(t);return i.insertAdjacentHTML("afterbegin",e),i}function Vl(t){let{installationId:e,hashid:i,language:s,currency:r,zone:n,search:o,sort:a,urlHash:l,vars:c,layerType:f,autoload:m,priceName:v}=t,E=Doofinder.Session.getSessionId(),b=Doofinder.Session.getUserId(),w=new Ze({installationId:e,autoload:m,urlHash:l,layerType:f}).value;return{installationId:e,hashid:i,language:s,currency:r,zone:n,state:w,search:o,sort:a,price_name:v,session_id:E,user_id:b,vars:c}}function Xl(t){return T(this,null,function*(){let{zone:e}=t,i=Be(e),s=new URL(`${i}/api/${ft}/categorypage`);return Object.keys(t).forEach(function(n){let o=t[n];typeof o=="undefined"||o==null||(typeof o=="object"&&(o=JSON.stringify(o)),s.searchParams.append(n,o))}),yield fetch(s).then(function(n){return n.ok?n.text():""})})}var ss,Jl=new Uint8Array(16);function mr(){if(!ss&&(ss=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ss))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ss(Jl)}var ne=[];for(let t=0;t<256;++t)ne.push((t+256).toString(16).slice(1));function Ho(t,e=0){return ne[t[e+0]]+ne[t[e+1]]+ne[t[e+2]]+ne[t[e+3]]+"-"+ne[t[e+4]]+ne[t[e+5]]+"-"+ne[t[e+6]]+ne[t[e+7]]+"-"+ne[t[e+8]]+ne[t[e+9]]+"-"+ne[t[e+10]]+ne[t[e+11]]+ne[t[e+12]]+ne[t[e+13]]+ne[t[e+14]]+ne[t[e+15]]}var ql=typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),gr={randomUUID:ql};function Wl(t,e,i){if(gr.randomUUID&&!e&&!t)return gr.randomUUID();t=t||{};let s=t.random||(t.rng||mr)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){i=i||0;for(let r=0;r<16;++r)e[i+r]=s[r];return e}return Ho(s)}var Zt=Wl;var Mo=12*60*60*1e3,No="df",$o="random-userid",_r="session",Uo="apps",Fo="tab-id",jo=window.localStorage,Bo=window.sessionStorage;function rs(t,e=jo){return be.getLocal(e,No,t)}function ei(t,e,i=jo){return ci()?be.updateLocal(i,No,t,e,()=>e):null}function Kl(){return{id:Zt().replaceAll("-",""),expiry:new Date().getTime()+Mo,live:[]}}function vr(){let t=rs(_r);return(!t||zl(t))&&(t=Kl()),ei(_r,t)}function zl({expiry:t}){return te.live.includes(s))}};function Gl(){return{"content-type":"application/json"}}function ns(i){return T(this,arguments,function*(t,e={}){return(yield fetch(t,I({method:"GET",cache:"no-cache",mode:"cors",headers:Gl()},e))).json()})}var br=class{constructor(e){this.zone=e}add(a,l,c){return T(this,arguments,function*(e,i,{id:s,title:r,price:n},o=1){let f=`${this.url(e)}/cart/${Fe.getSessionId()||""}`,m=JSON.stringify({amount:o,id:s,title:r,price:n,index:i});return ns(f,{method:"PUT",body:m})})}remove(e,i,s,r=1){return T(this,null,function*(){let n=`${this.url(e)}/cart/${Fe.getSessionId()||""}`,o=JSON.stringify({amount:r,id:s,index:i});return ns(n,{method:"PATCH",body:o})})}clear(e){return T(this,null,function*(){let i=`${this.url(e)}/cart/${Fe.getSessionId()||""}`;return ns(i,{method:"DELETE"})})}checkout(e){return T(this,null,function*(){let i=JSON.stringify({session_id:Fe.getSessionId(),user_id:Fe.getUserId(),sources:Fe.getLastUsedApps().split(",")});return ns(`${this.url(e)}/checkout`,{method:"PUT",body:i})})}url(e){return`https://${this.zone}-search.doofinder.com/6/${e}/stats`}};var Yl={get Session(){return Fe},buildCart(t){return new br(t)}},Vo=Yl;var yr=Or([vs,bs,ys]),Sr=Hr(yr);document.addEventListener("doofinder.register",t=>{let{name:e,entrypoint:i}=t.detail;yr[e].resolve(i)});var Ql={vsn:"1.5.5",getRegistry(t){return yr[t]},load(t,e){Ht(),ks(),Xo(t,e,"search")},loadCategoryPages(t,e){Ht(),Oo(t),Xo(t,e,"category_pages")},loadChat(t,e){Ht(),Jr(t).then(i=>{i.css.forEach(Ot),Sr(bs,function(s){hi.then(()=>{let r=s.create(t);typeof e=="function"&&e(r)})}),i.js.forEach(Dt)})},loadQuiz(t,e){Ht(),qr(t).then(i=>{i.css.forEach(Ot),Qe(i.custom_css),Sr(ys,function(s){hi.then(()=>{let r=s.create(t);typeof e=="function"&&e(r)})}),i.js.forEach(Dt)})},enableDebug:Nr,disableDebug:$r,setLayerServerUrl:zr,setCDNServerUrl:Kr,enableCookies:ks,disableCookies:Gr};function Xo(t,e,i){Xr(t,i).then(s=>{var n;s.css.forEach(Ot),s.custom_css.forEach(Qe);let r=(n=s.custom_properties)==null?void 0:n.join(` `);t=Wr(t,s),t.trigger=Zl(t),Sr(vs,function(o){hi.then(()=>{let a=o.create(t);Qe(`#${a.mount.id} { ${r||""} }`),i=="category_pages"&&a.open(t),typeof e=="function"&&e(a)})}),s.js.forEach(Dt)}).catch(s=>{console.error("[Doofinder] error retrieving resources:",s)})}function Zl(t){let{autoload:e,trigger:i}=t,s=new ws(i);return s.enabled=!e||e.trigger,s}Object.defineProperty(window,"Doofinder",{value:Vo,writable:!1});Object.defineProperty(window,"doofinderLoader",{value:Ql,writable:!1});})();