(()=>{var po=Object.defineProperty,mo=Object.defineProperties;var go=Object.getOwnPropertyDescriptors;var Gt=Object.getOwnPropertySymbols;var hr=Object.prototype.hasOwnProperty,cr=Object.prototype.propertyIsEnumerable;var ns=(t,e,i)=>e in t?po(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,D=(t,e)=>{for(var i in e||(e={}))hr.call(e,i)&&ns(t,i,e[i]);if(Gt)for(var i of Gt(e))cr.call(e,i)&&ns(t,i,e[i]);return t},ce=(t,e)=>mo(t,go(e));var dr=(t,e)=>{var i={};for(var s in t)hr.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(t!=null&&Gt)for(var s of Gt(t))e.indexOf(s)<0&&cr.call(t,s)&&(i[s]=t[s]);return i};var Qt=(t,e,i)=>(ns(t,typeof e!="symbol"?e+"":e,i),i);var P=(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 Oe=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 ur="layer";function fr(t,e){document.dispatchEvent(new CustomEvent("doofinder.register",{detail:{name:t,entrypoint:e}}))}var At=t=>typeof t=="function"?t:function(){return t},_o=typeof self!="undefined"?self:null,Tt=typeof window!="undefined"?window:null,ot=_o||Tt||ot,vo="2.0.0",Pe={connecting:0,open:1,closing:2,closed:3},bo=1e4,So=1e3,me={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},He={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},os={longpoll:"longpoll",websocket:"websocket"},yo={complete:4},Zt=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})}},pr=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))}},Eo=class{constructor(t,e,i){this.state=me.closed,this.topic=t,this.params=At(e||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Zt(this,He.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new pr(()=>{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=me.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=me.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=me.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=me.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 Zt(this,He.leave,At({}),this.timeout).send(),this.state=me.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(He.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(He.close,t)}onError(t){return this.on(He.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 Zt(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=me.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(He.close,"leave")},i=new Zt(this,He.leave,At({}),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=me.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===yo.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)}`}},wo=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("(.*)/"+os.websocket),"$1/"+os.longpoll)}endpointURL(){return ei.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,i){this.close(t,e,i),this.readyState=Pe.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Pe.open||this.readyState===Pe.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=Pe.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=wo(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=Pe.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=ei.request(t,this.endpointURL(),e,i,this.timeout,o,a=>{this.reqs.delete(n),this.isActive()&&r(a)}),this.reqs.add(n)}};var ti={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:He.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}}},mr=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=e.timeout||bo,this.transport=e.transport||ot.WebSocket||Ct,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=e.sessionStorage||ot.sessionStorage,this.establishedConnections=0,this.defaultEncoder=ti.encode.bind(ti),this.defaultDecoder=ti.decode.bind(ti),this.closeWasClean=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.transport!==Ct?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;Tt&&Tt.addEventListener&&(Tt.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),Tt.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=At(e.params||{}),this.endPoint=`${t}/${os.websocket}`,this.vsn=e.vsn||vo,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new pr(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return Ct}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=ei.appendParams(ei.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=At(t)),!this.conn&&(this.longPollFallbackMs&&this.transport!==Ct?this.connectWithFallback(Ct,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(),So,"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===Pe.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(He.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case Pe.connecting:return"connecting";case Pe.open:return"open";case Pe.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 Eo(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 gr=(t,e,i)=>{e.forEach(s=>{t.addEventListener(s,i)})},_r=(t,e,i)=>{e.forEach(s=>{t.removeEventListener(s,i)})},as=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),gr(window,this.settings.events,this.idlenessEventsHandler),(this.settings.onShow||this.settings.onHide)&&gr(document,this.visibilityEvents,this.visibilityEventsHandler),this}stop(){return window.removeEventListener("idle:stop",this.stopListener),_r(window,this.settings.events,this.idlenessEventsHandler),this.resetTimeout(this.settings,!1),(this.settings.onShow||this.settings.onHide)&&_r(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 ls=class extends mr{constructor(e,i={}){super(e,i);this.preventReconnect=!1,this.shouldReconnect=!1,this.idleMonitor=new as({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",ii="consecutive-reloads",vr=10,br=5e3,Sr=1e4,yr=3e4,si=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],ge="data-phx-component";var Er="track-static";var oe="data-phx-ref",Re="data-phx-ref-src",ri="track-uploads",_e="data-phx-upload-ref",at="data-phx-preflighted-refs",wr="data-phx-done-refs",hs="drop-target",xt="data-phx-active-refs",lt=`${U}:live-file:updated`,ni="data-phx-skip",oi="data-phx-id",cs="data-phx-prune",ds="page-loading",us="phx-connected",ht="phx-loading",kt="phx-no-feedback",Pt="phx-error",fs="phx-client-error",ai="phx-server-error",ze="data-phx-parent-id",li="data-phx-main",Le="data-dfd-root-id",hi="viewport-top",ci="viewport-bottom",Ar="trigger-action",Ye="feedback-for",Ge="feedback-group",Rt="phx-has-focused",Tr=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],di=["checkbox","radio"],ct="phx-has-submitted",be="data-dfd-view",Me=`[${be}]`,ps="data-phx-sticky",$e="data-phx-static",ui="data-phx-readonly",Qe="data-phx-disabled",Lt="disable-with",It="data-phx-disable-with-restore",dt="hook",Cr="debounce",xr="throttle",ut="update",fi="stream",pi="data-phx-stream",kr="key",we="phxPrivate",ms="auto-recover",Dt="phx:live-socket:debug",mi="phx:live-socket:profiling",gi="phx:live-socket:latency-sim",Pr="progress",gs="mounted",Rr=1,Lr=200,Ir="dfd-",Dr=3e4;var ft="debounce-trigger",pt="throttled",_s="debounce-prev-key",Or={debounce:300,throttle:300},Ot="d",Ae="s",_i="r",ae="c",vs="e",bs="r",Ss="t",Hr="p",ys="stream";var vi=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 ie("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 ie=(t,e)=>console.error&&console.error(t,e),Se=t=>{let e=typeof t;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(t)};function Mr(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)},bi=t=>typeof t=="function"?t:function(){return t},mt=t=>JSON.parse(JSON.stringify(t)),gt=(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(Me)));return null},Ze=t=>t!==null&&typeof t=="object"&&!(t instanceof Array),Fr=(t,e)=>JSON.stringify(t)===JSON.stringify(e),Es=t=>{for(let e in t)return!1;return!0},Te=(t,e)=>t&&e(t),Ur=function(t,e,i,s){t.forEach(r=>{new vi(r,i.config.chunk_size,s).upload()})};var $r={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&&$r.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}"]`)}},Ie=$r;var Ao={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}}},Be=Ao;var Si=null,Br=200,To={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,(I,L)=>{if(!!I.isConnected())if(t==="change"){let{newCid:B,_target:q}=n;q=q||(p.isFormInput(s)?s.name:void 0),q&&(b._target=q),I.pushInput(s,L,B,o||e,b,E)}else if(t==="submit"){let{submitter:B}=n;I.submitForm(s,L,o||e,B,b,E)}else I.pushEvent(t,s,L,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(()=>Be.attemptFocus(r))},exec_focus_first(t,e,i,s,r){window.requestAnimationFrame(()=>Be.focusFirstInteractive(r)||Be.focusFirst(r))},exec_push_focus(t,e,i,s,r){window.requestAnimationFrame(()=>Si=r||s)},exec_pop_focus(t,e,i,s,r){window.requestAnimationFrame(()=>{Si&&Si.focus(),Si=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||Br;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||Br;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=To;var ye={byId(t){return document.getElementById(t)||ie(`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(_e)!==null},isAutoUpload(t){return t.hasAttribute("data-phx-auto-upload")},findUploadInputs(t){let e=t.id,i=this.all(document,`input[type="file"][${_e}][form="${e}"]`);return this.all(t,`input[type="file"][${_e}]`).concat(i)},findComponentNodeList(t,e){return this.filterWithinSameLiveView(this.all(t,`[${ge}="${e}"]`),t)},isPhxDestroyed(t){return!!(t.id&&ye.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(be,""),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,`[${ps}]`)},findPhxChildren(t,e){return this.all(t,`${Me}[${ze}="${e}"]`)},findParentCIDs(t,e){let i=new Set(e),s=e.reduce((r,n)=>{let o=`[${ge}="${n}"] [${ge}]`;return this.filterWithinSameLiveView(this.all(t,o),t).map(a=>parseInt(a.getAttribute(ge))).forEach(a=>r.delete(a)),r},i);return s.size===0?new Set(e):s},filterWithinSameLiveView(t,e){return e.querySelector(Me)?t.filter(i=>this.withinSameLiveView(i,e)):t},withinSameLiveView(t,e){for(;t=t.parentNode;){if(t.isSameNode(e))return!0;if(t.getAttribute(be)!==null)return!1}},private(t,e){return t[we]&&t[we][e]},deletePrivate(t,e){t[we]&&delete t[we][e]},putPrivate(t,e,i){t[we]||(t[we]={}),t[we][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[we]&&(t[we]=e[we])},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,pt):a(),E=this.incCycle(t,ft,v);if(isNaN(m))return ie(`invalid throttle/debounce value: ${f}`);if(c){let w=!1;if(e.type==="keydown"){let N=this.private(t,_s);this.putPrivate(t,_s,e.key),w=N!==e.key}if(!w&&this.private(t,pt))return!1;{a();let N=setTimeout(()=>{o()&&this.triggerCycle(t,ft)},m);this.putPrivate(t,pt,N)}}else setTimeout(()=>{o()&&this.triggerCycle(t,ft,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,ft),this.deletePrivate(N,pt)})}),this.once(t,"bind-debounce")&&t.addEventListener("blur",()=>{clearTimeout(this.private(t,pt)),this.triggerCycle(t,ft)})}},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,[],[kt]);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,[kt],[])},shouldHideFeedback(t,e,i){let s=`[name="${e}"], [name="${e}[]"], [${i}="${e}"]`,r=!1;return ye.all(t,s,n=>{(this.private(n,Rt)||this.private(n,ct))&&(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,Rt),this.deletePrivate(s,ct),this.all(document,r,n=>{ee.addOrRemoveClasses(n,[kt],[])})})},showError(t,e,i){if(t.name){let s=this.feedbackSelector(t,e,i);this.all(document,s,r=>{ee.addOrRemoveClasses(r,[],[kt])})}},isPhxChild(t){return t.getAttribute&&t.getAttribute(ze)},isPhxSticky(t){return t.getAttribute&&t.getAttribute(ps)!==null},isChildOfAny(t,e){return!!e.find(i=>i.contains(t))},firstPhxChild(t){return this.isPhxChild(t)?t:this.all(t,`[${ze}]`)[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)&&![oe,Re].includes(l)&&t.removeAttribute(l):e.hasAttribute(l)||t.removeAttribute(l)}},mergeFocusedInput(t,e){t instanceof HTMLSelectElement||ye.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(),!ye.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&&di.indexOf(t.type.toLocaleLowerCase())>=0&&(t.checked=t.getAttribute("checked")!==null)},isTextualInput(t){return Tr.indexOf(t.type)>=0},isNowTriggerFormExternal(t,e){return t.getAttribute&&t.getAttribute(e)!==null},syncPendingRef(t,e,i){let s=t.getAttribute(oe);if(s===null)return!0;let r=t.getAttribute(Re);return ye.isFormInput(t)||t.getAttribute(i)!==null?(ye.isUploadInput(t)&&ye.mergeAttrs(t,e,{isIgnored:!0}),ye.putPrivate(t,oe,e),!1):(si.forEach(n=>{t.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(oe,s),e.setAttribute(Re,r),!0)},cleanChildNodes(t,e){if(ye.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&&ie(`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",be,$e,li,Le]);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=(ye.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=ye.private(t,"sticky");!e||e.forEach(([i,s,r])=>this.putSticky(t,i,s))}},p=ye;var De=class{static isActive(e,i){let s=i._phxRef===void 0,r=De.isPreflightInProgress(i),o=e.getAttribute(xt).split(",").indexOf(X.genFileRef(i))>=0;return i.size>0&&(s||o||!r)}static isPreflighted(e,i){return e.getAttribute(at).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(lt,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(lt,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(lt,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(xt).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]||ie(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:i}}else return{name:"channel",callback:Ur}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||ie(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Co=0,X=class{static genFileRef(e){let i=e._phxRef;return i!==void 0?i:(e._phxRef=(Co++).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(at)!==s.getAttribute(wr)&&i++}),i>0}static serializeUploads(e){let i=this.activeFiles(e),s={};return i.forEach(r=>{let n={path:e.name},o=e.getAttribute(_e);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(_e),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=>De.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=>!De.isPreflighted(e,i)&&!De.isPreflightInProgress(i))}static markPreflightInProgress(e){e.forEach(i=>De.markPreflightInProgress(i.file))}constructor(e,i,s){this.view=i,this.onComplete=s,this._entries=Array.from(X.filesAwaitingPreflight(e)||[]).map(r=>new De(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 xo={LiveFileUpload:{activeRefs(){return this.el.getAttribute(xt)},preflightedRefs(){return this.el.getAttribute(at)},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(lt))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(_e)),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",()=>Be.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>Be.focusFirst(this.el)),this.el.addEventListener(`${U}:show-end`,()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&Be.focusFirst(this.el)}}},Vr=xo;var yi=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?Te(document.getElementById(i.previousElementId),s=>{Te(document.getElementById(i.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==s.id||s.insertAdjacentElement("afterend",r)})}):Te(document.getElementById(i.elementId),s=>{s.previousElementSibling==null||e.insertAdjacentElement("afterbegin",s)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(i=>{Te(document.getElementById(i),s=>e.insertAdjacentElement("afterbegin",s))})}};var jr=11;function ko(t,e){var i=e.attributes,s,r,n,o,a;if(!(e.nodeType===jr||t.nodeType===jr)){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 Ei,Po="http://www.w3.org/1999/xhtml",de=typeof document=="undefined"?void 0:document,Ro=!!de&&"content"in de.createElement("template"),Lo=!!de&&de.createRange&&"createContextualFragment"in de.createRange();function Io(t){var e=de.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function Do(t){Ei||(Ei=de.createRange(),Ei.selectNode(de.body));var e=Ei.createContextualFragment(t);return e.childNodes[0]}function Oo(t){var e=de.createElement("body");return e.innerHTML=t,e.childNodes[0]}function Ho(t){return t=t.trim(),Ro?Io(t):Lo?Do(t):Oo(t)}function wi(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 Mo(t,e){return!e||e===Po?de.createElement(t):de.createElementNS(e,t)}function No(t,e){for(var i=t.firstChild;i;){var s=i.nextSibling;e.appendChild(i),i=s}return e}function ws(t,e,i){t[i]!==e[i]&&(t[i]=e[i],t[i]?t.setAttribute(i,""):t.removeAttribute(i))}var Xr={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)}ws(t,e,"selected")},INPUT:function(t,e){ws(t,e,"checked"),ws(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}}},Ht=1,Jr=11,qr=3,Wr=8;function Ve(){}function Fo(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}function Uo(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=de.createElement("html"),s.innerHTML=n}else s=Ho(s);else s.nodeType===Jr&&(s=s.firstElementChild);var o=r.getNodeKey||Fo,a=r.onBeforeNodeAdded||Ve,l=r.onNodeAdded||Ve,c=r.onBeforeElUpdated||Ve,f=r.onElUpdated||Ve,m=r.onBeforeNodeDiscarded||Ve,v=r.onNodeDiscarded||Ve,E=r.onBeforeElChildrenUpdated||Ve,b=r.skipFromChildren||Ve,w=r.addChild||function(x,C){return x.appendChild(C)},N=r.childrenOnly===!0,I=Object.create(null),L=[];function B(x){L.push(x)}function q(x,C){if(x.nodeType===Ht)for(var J=x.firstChild;J;){var R=void 0;C&&(R=o(J))?B(R):(v(J),J.firstChild&&q(J,C)),J=J.nextSibling}}function Z(x,C,J){m(x)!==!1&&(C&&C.removeChild(x),v(x),q(x,J))}function W(x){if(x.nodeType===Ht||x.nodeType===Jr)for(var C=x.firstChild;C;){var J=o(C);J&&(I[J]=C),W(C),C=C.nextSibling}}W(i);function V(x){l(x);for(var C=x.firstChild;C;){var J=C.nextSibling,R=o(C);if(R){var $=I[R];$&&wi(C,$)?(C.parentNode.replaceChild($,C),g($,C)):V(C)}else V(C);C=J}}function ve(x,C,J){for(;C;){var R=C.nextSibling;(J=o(C))?B(J):Z(C,x,!0),C=R}}function g(x,C,J){var R=o(C);R&&delete I[R],!(!J&&(c(x,C)===!1||(t(x,C),f(x),E(x,C)===!1)))&&(x.nodeName!=="TEXTAREA"?k(x,C):Xr.TEXTAREA(x,C))}function k(x,C){var J=b(x,C),R=C.firstChild,$=x.firstChild,Ue,pe,ke,We,re;e:for(;R;){for(We=R.nextSibling,Ue=o(R);!J&&$;){if(ke=$.nextSibling,R.isSameNode&&R.isSameNode($)){R=We,$=ke;continue e}pe=o($);var nt=$.nodeType,Ee=void 0;if(nt===R.nodeType&&(nt===Ht?(Ue?Ue!==pe&&((re=I[Ue])?ke===re?Ee=!1:(x.insertBefore(re,$),pe?B(pe):Z($,x,!0),$=re,pe=o($)):Ee=!1):pe&&(Ee=!1),Ee=Ee!==!1&&wi($,R),Ee&&g($,R)):(nt===qr||nt==Wr)&&(Ee=!0,$.nodeValue!==R.nodeValue&&($.nodeValue=R.nodeValue))),Ee){R=We,$=ke;continue e}pe?B(pe):Z($,x,!0),$=ke}if(Ue&&(re=I[Ue])&&wi(re,R))J||w(x,re),g(re,R);else{var Et=a(R);Et!==!1&&(Et&&(R=Et),R.actualize&&(R=R.actualize(x.ownerDocument||de)),w(x,R),V(R))}R=We,$=ke}ve(x,$,pe);var Wt=Xr[x.nodeName];Wt&&Wt(x,C)}var H=i,G=H.nodeType,fe=s.nodeType;if(!N){if(G===Ht)fe===Ht?wi(i,s)||(v(i),H=No(i,Mo(s.nodeName,s.namespaceURI))):H=s;else if(G===qr||G===Wr){if(fe===G)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),L)for(var yt=0,zi=L.length;yt{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=Se(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(ut);p.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,i=>{i.setAttribute(cs,"")})}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(ut),m=s.binding(Ye),v=s.binding(Ge),E=s.binding(Lt),b=s.binding(hi),w=s.binding(ci),N=s.binding(Ar),I=[],L=[],B=[],q=[],Z=null;function W(V,ve){As(V,ve,{childrenOnly:V.getAttribute(ge)===null,getNodeKey:g=>p.isPhxDestroyed(g)?null:e?g.id:g.id||g.getAttribute&&g.getAttribute(oi),skipFromChildren:g=>g.getAttribute(f)===fi,addChild:(g,k)=>{let{ref:H,streamAt:G}=this.getStreamInsert(k);if(H===void 0)return g.appendChild(k);if(this.setStreamRef(k,H),G===0)g.insertAdjacentElement("afterbegin",k);else if(G===-1)g.appendChild(k);else if(G>0){let fe=Array.from(g.children)[G];g.insertBefore(k,fe)}},onBeforeNodeAdded:g=>{this.trackBefore("added",g);let k=g;return!e&&this.streamComponentRestore[g.id]&&(k=this.streamComponentRestore[g.id],delete this.streamComponentRestore[g.id],W.bind(this)(k,g)),k},onNodeAdded:g=>{g.getAttribute&&this.maybeReOrderStream(g,!0),p.isFeedbackContainer(g,m)&&L.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),I.push(g)},onNodeDiscarded:g=>this.onNodeDiscarded(g),onBeforeNodeDiscarded:g=>g.getAttribute&&g.getAttribute(cs)!==null?!0:!(g.parentElement!==null&&g.id&&p.isPhxUpdate(g.parentElement,f,[fi,"append","prepend"])||this.maybePendingRemove(g)||this.skipCIDSibling(g)),onElUpdated:g=>{p.isNowTriggerFormExternal(g,N)&&(Z=g),B.push(g),this.maybeReOrderStream(g,!1)},onBeforeElUpdated:(g,k)=>{if((p.isFeedbackContainer(g,m)||p.isFeedbackContainer(k,m))&&(L.push(g),L.push(k)),p.cleanChildNodes(k,f),this.skipCIDSibling(k))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,k),p.mergeAttrs(g,k,{isIgnored:!0}),B.push(g),p.applyStickyOperations(g),!1;if(g.type==="number"&&g.validity&&g.validity.badInput)return!1;if(!p.syncPendingRef(g,k,E))return p.isUploadInput(g)&&(this.trackBefore("updated",g,k),B.push(g)),p.applyStickyOperations(g),!1;if(p.isPhxChild(k)){let fe=g.getAttribute(be);return p.mergeAttrs(g,k,{exclude:[$e]}),fe!==""&&g.setAttribute(be,fe),g.setAttribute(Le,this.rootID),p.applyStickyOperations(g),!1}p.copyPrivates(k,g);let H=a&&g.isSameNode(a)&&p.isFormInput(g),G=H&&this.isChangedSelect(g,k);return H&&g.type!=="hidden"&&!G?(this.trackBefore("updated",g,k),p.mergeFocusedInput(g,k),p.syncAttrsToProps(g),B.push(g),p.applyStickyOperations(g),!1):(G&&g.blur(),p.isPhxUpdate(k,f,["append","prepend"])&&q.push(new yi(g,k,k.getAttribute(f))),p.syncAttrsToProps(k),p.applyStickyOperations(k),this.trackBefore("updated",g,k),!0)}})}return this.trackBefore("added",r),this.trackBefore("updated",r,r),s.time("morphdom",()=>{this.streams.forEach(([V,ve,g,k])=>{ve.forEach(([H,G,fe])=>{this.streamInserts[H]={ref:V,streamAt:G,limit:fe,reset:k}}),k!==void 0&&p.all(r,`[${pi}="${V}"]`,H=>{this.removeStreamChildElement(H)}),g.forEach(H=>{let G=r.querySelector(`[id="${H}"]`);G&&this.removeStreamChildElement(G)})}),e&&p.all(this.container,`[${f}=${fi}]`,V=>{this.liveSocket.owner(V,ve=>{ve===this.view&&Array.from(V.children).forEach(g=>{this.removeStreamChildElement(g)})})}),W.bind(this)(o,n)}),s.isDebugEnabled()&&Mr(s.doofinderMount),q.length>0&&s.time("post-morph append/prepend restoration",()=>{q.forEach(V=>V.perform())}),p.maybeHideFeedback(o,L,m,v),s.silenceEvents(()=>p.restoreFocus(a,l,c)),p.dispatchEvent(document,`${U}:update`),I.forEach(V=>this.trackAfter("added",V)),B.forEach(V=>this.trackAfter("updated",V)),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,pi,s=>s.setAttribute(pi,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(ni)}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 Bo=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Vo=new Set(["'",'"']),Kr=(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(Vo.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}"`:"";Bo.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]},Mt=class{static extract(e){let{[bs]:i,[vs]:s,[Ss]:r}=e;return delete e[bs],delete e[vs],delete e[Ss],{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[ae],e,!0,{});return[i,s]}recursiveToString(e,i=e[ae],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[ae]||{}).map(i=>parseInt(i))}isComponentOnlyDiff(e){return e[ae]?Object.keys(e).length===1:!1}getComponent(e,i){return e[ae][i]}resetRender(e){this.rendered[ae][e]&&(this.rendered[ae][e].reset=!0)}mergeDiff(e){let i=e[ae],s={};if(delete e[ae],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[ae]=this.rendered[ae]||{},i){let r=this.rendered[ae];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[ae]=i}}cachedFindComponent(e,i,s,r,n){if(n[e])return n[e];{let o,a,l=i[Ae];if(Se(l)){let c;l>0?c=this.cachedFindComponent(l,r[l],s,r,n):c=s[-l],a=c[Ae],o=this.cloneMerge(c,i,!0),o[Ae]=a}else o=i[Ae]!==void 0||s[e]===void 0?i:this.cloneMerge(s[e],i,!1);return n[e]=o,o}}mutableMerge(e,i){return i[Ae]!==void 0?i:(this.doMutableMerge(e,i),e)}doMutableMerge(e,i){for(let s in i){let r=i[s],n=e[s];Ze(r)&&r[Ae]===void 0&&Ze(n)?this.doMutableMerge(n,r):e[s]=r}e[_i]&&(e.newRender=!0)}cloneMerge(e,i,s){let r=D(D({},e),i);for(let n in r){let o=i[n],a=e[n];Ze(o)&&o[Ae]===void 0&&Ze(a)?r[n]=this.cloneMerge(a,o,s):o===void 0&&Ze(a)&&(r[n]=this.cloneMerge(a,{},s))}return s?(delete r.magicId,delete r.newRender):e[_i]&&(r.newRender=!0),r}componentToString(e){let[i,s]=this.recursiveCIDToString(this.rendered[ae],e,null),[r,n,o]=Kr(i,{});return[r,s]}pruneCIDs(e){e.forEach(i=>delete this.rendered[ae][i])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[Ae]}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[Ot])return this.comprehensionToBuffer(e,i,s);let{[Ae]:o}=e;o=this.templateStatic(o,i);let a=e[_i],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[ys],e[Ot]=[],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 Ze(e)?this.toOutputBuffer(e,i,s,r,{}):s.buffer+=e}recursiveCIDToString(e,i,s){let r=e[i]||ie(`no component for CID ${i}`,e),n={[ge]: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 jo=1,je=class{static makeID(){return jo++}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 Ai=(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()},_t=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(li)}connectParams(e){let i=this.liveSocket.params(this.el),s=p.all(document,`[${this.binding(Er)}]`).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(be)}getStatic(){let e=this.el.getAttribute($e);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(us,ht,Pt,fs,ai),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(ht)}}execAll(e){p.all(this.el,`[${e}]`,i=>this.liveSocket.execJS(i,i.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(us),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(Se(e))p.findComponentNodeList(this.el,e).length===0?ie(`no component found matching phx-target of ${e}`):i(this,parseInt(e));else{let s=Array.from(document.querySelectorAll(e));s.length===0&&ie(`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,()=>["",mt(i)]);let{diff:r,reply:n,events:o,title:a}=Mt.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,Ie.dropLocal(this.liveSocket.localStorage,window.location.pathname,ii),this.applyDiff("mount",i,({diff:r,events:n})=>{this.rendered=new Mt(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,`[${Re}="${this.id}"][${oe}]`,e=>{e.removeAttribute(oe),e.removeAttribute(Re)})}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($e);return l&&o.setAttribute($e,l),a&&a.setAttribute(Le,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(Le,this.root.id)}execNewMounted(){let e=this.binding(hi),i=this.binding(ci);p.all(this.el,`[${e}], [${i}]`,s=>{this.maybeAddNewHook(s)}),p.all(this.el,`[${this.binding(dt)}], [data-phx-${dt}]`,s=>{this.maybeAddNewHook(s)}),p.all(this.el,`[${this.binding(gs)}]`,s=>this.maybeMounted(s))}applyJoinPatch(e,i,s,r){this.attachTrueDocEl();let n=new et(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(ut));if(s&&!e.isEqualNode(i)&&!(r&&Fr(e.dataset,i.dataset)))return s.__beforeUpdate(),s}maybeMounted(e){let i=e.getAttribute(this.binding(gs)),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,`[${ge}]`),o=p.all(r,`[${this.binding(dt)}]`);n.concat(r).forEach(a=>{let l=this.componentID(a);Se(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(ze)][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 _t(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)})}):Es(e)||this.liveSocket.time("full patch complete",()=>{let[r,n]=this.renderContainer(e,"update"),o=new et(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(Es(e))return!1;let[s,r]=this.rendered.componentToString(i),n=new et(this,this.el,this.id,s,r,i);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[je.elementID(e)]}addHook(e){if(je.elementID(e)||!e.getAttribute)return;let i=e.getAttribute(`data-phx-${dt}`)||e.getAttribute(this.binding(dt));if(i&&!this.ownsElement(e))return;let s=this.liveSocket.getHookCallbacks(i);if(s){e.id||ie(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);let r=new je(this,e,s);return this.viewHooks[je.elementID(r.el)]=r,r}else i!==null&&ie(`unknown hook found for "${i}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[je.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([ht,Pt,ai]),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(Lr)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([ht,Pt,ai]):this.displayError([ht,Pt,fs]))}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(ds))!==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,Dr).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,`[${Re}="${this.id}"][${oe}="${e}"]`,i=>{let s=i.getAttribute(Qe),r=i.getAttribute(ui);i.removeAttribute(oe),i.removeAttribute(Re),r!==null&&(i.readOnly=r==="true",i.removeAttribute(ui)),s!==null&&(i.disabled=s==="true",i.removeAttribute(Qe)),si.forEach(a=>p.removeClass(i,a));let n=i.getAttribute(It);n!==null&&(i.innerText=n,i.removeAttribute(It));let o=p.private(i,oe);if(o){let a=this.triggerBeforeUpdateHook(i,o);et.patchEl(i,o,this.liveSocket.getActiveElement()),a&&a.__updated(),p.deletePrivate(i,oe)}})}putRef(e,i,s={}){let r=this.ref++,n=this.binding(Lt);return s.loading&&(e=e.concat(p.all(document,s.loading))),e.forEach(o=>{o.classList.add(`phx-${i}-loading`),o.setAttribute(oe,r),o.setAttribute(Re,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(It)||o.setAttribute(It,o.innerText),a!==""&&(o.innerText=a),o.setAttribute(Qe,o.getAttribute(Qe)||o.disabled),o.setAttribute("disabled",""))}),[r,e,s]}componentID(e){let i=e.getAttribute&&e.getAttribute(ge);return i?parseInt(i):null}targetComponentID(e,i,s={}){if(Se(i))return i;let r=s.target||e.getAttribute(this.binding("target"));return Se(r)?parseInt(r):i&&(r!==null||s.target)?this.closestComponentID(i):null}closestComponentID(e){return Se(e)?e:e?Te(e.closest(`[${ge}]`),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(Pr)),ref:e.getAttribute(_e),entry_ref:i,progress:s,cid:n.targetComponentID(e.form,o)},r)})}pushInput(e,i,s,r,n,o){let a,l=Se(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=Ai(e.form,D({_target:n._target},m),[e.name]):f=Ai(e.form,D({_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(Ye),this.liveSocket.binding(Ge)),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=>!(gt(m,`${this.binding(ut)}=ignore`,m.form)||gt(m,"data-phx-update=ignore",m.form)),r=m=>m.hasAttribute(this.binding(Lt)),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(Qe,m.disabled),m.disabled=!0}),f.forEach(m=>{m.setAttribute(ui,m.readOnly),m.readOnly=!0,m.files&&(m.setAttribute(Qe,m.disabled),m.disabled=!0)}),e.setAttribute(this.binding(ds),""),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=Ai(e,D({submitter:r},E));this.pushWithReply(m,"event",{type:"form",event:s,value:b,cid:l},o)})}else if(!(e.hasAttribute(oe)&&e.classList.contains("phx-submit-loading"))){let c=this.extractMeta(e),f=Ai(e,D({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(_e),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?ie(`no live file inputs found matching the name "${i}"`):n.length>1?ie(`duplicate live file inputs found matching the name "${i}"`):p.dispatchEvent(n[0],ri,{detail:{files:s}})}targetCtxElement(e){if(Se(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(_e)&&X.clearFiles(f));let l=a.find(f=>f.type!=="hidden")||a[0],c=e.getAttribute(this.binding(ms))||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(ms))!=="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(Me);return e.getAttribute(ze)===this.id||i&&i.id===this.id||!i&&this.isDead}submitForm(e,i,s,r,n={}){p.putPrivate(e,ct,!0);let o=this.liveSocket.binding(Ye),a=this.liveSocket.binding(Ge),l=Array.from(e.elements);l.forEach(c=>p.putPrivate(c,ct,!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 Nt=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||Ir,this.opts=s,this.params=bi(s.params||{}),this.viewLogger=s.viewLogger,this.metadataCallbacks=s.metadata||{},this.defaults=Object.assign(mt(Or),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=mt(window.location),this.hooks=s.hooks||{},this.uploaders=s.uploaders||{},this.loaderTimeout=s.loaderTimeout||Rr,this.reloadWithJitterTimer=null,this.maxReloads=s.maxReloads||vr,this.reloadJitterMin=s.reloadJitterMin||br,this.reloadJitterMax=s.reloadJitterMax||Sr,this.failsafeJitter=s.failsafeJitter||yr,this.localStorage=s.localStorage||window.localStorage,this.sessionStorage=s.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:bi(),onBeforeElUpdated:bi()},s.dom||{}),this.doofinderMount=s.doofinderMount,this.connectCallback=s.connectCallback||(()=>{}),this.disconnectCallback=s.disconnectCallback||(()=>{}),this.unbindFunctions=[],this.transitions=new zr,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(mi)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Dt)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Dt)==="false"}enableDebug(){this.sessionStorage.setItem(Dt,"true")}enableProfiling(){this.sessionStorage.setItem(mi,"true")}disableDebug(){this.sessionStorage.setItem(Dt,"false")}disableProfiling(){this.sessionStorage.removeItem(mi)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(gi,e)}disableLatencySim(){this.sessionStorage.removeItem(gi)}getLatencySim(){let e=this.sessionStorage.getItem(gi);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();Nr(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;Ie.updateLocal(this.localStorage,window.location.pathname,ii,0,a=>a+1)>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{this.disconnectCallback()},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?Vr[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),Ie.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(be)!==null}newRootView(e,i,s){let r=new _t(e,this,null,i,s);return this.roots[r.id]=r,r}owner(e,i){let s=Te(e.closest(Me),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(Le);return Te(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(Le));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(kr)),c=i.key&&i.key.toLowerCase();if(l&&l.toLowerCase()!==c)return;let f=D({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=D({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=Te(gt(s.target,this.binding(hs)),a=>a.getAttribute(this.binding(hs))),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(ri,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=gt(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(oe)&&(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 Ie.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)||(Ie.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 Ie.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&&(Ie.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(){Ie.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=mt(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,Rt,!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(Ye),this.binding(Ge));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(Cr),o=this.binding(xr),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)})}},zr=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 Ts=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 Nt(i,ls,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 Xo="df-cookies-allowed",Jo=window.localStorage;function Yr(){return JSON.parse(Jo.getItem(Xo)||"false")}var vt=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){!Yr()||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 Cs="dfd-animate",xs="dfd-fixed-layout",Ne="hidden",Ti="floating",Ci="fullscreen",tt="static";function xi(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=ce(D({},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=ce(D({},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=ce(D({},i),{clientWidth:s.clientWidth,clientHeight:s.clientHeight,scrollLeft:s.scrollLeft,scrollTop:s.scrollTop,scrollWidth:s.scrollWidth,scrollHeight:s.scrollHeight})}return i}function Gr(t){let e=t;for(;e&&getComputedStyle(e).position!=="fixed";)e=e.offsetParent;return!!e}"use strict";var ks=class{constructor(e,i={}){this.options=D({align:i.align,offsetX:0,offsetY:4,marginY:20,marginX:20,fillViewPortWidth:768},i),this.element=e}__origin__(e){let i=xi(e),s=xi(document),r=s.width<=this.options.fillViewPortWidth,n={width:i.width,top:i.top+i.height,left:i.left,fixed:Gr(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 ki(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 it=class{constructor(e){this.mount=e,this._positionReference=null}__animate__(){return new Promise(e=>{setTimeout(()=>{this.mount.classList.add(Cs),e()},10)})}get positionReference(){return this._positionReference}show(){return P(this,null,function*(){let e=this.hidden();return e&&(this.mount.removeAttribute(Ne),yield this.__animate__()),e})}hide(){return P(this,null,function*(){let e=!this.hidden();return e&&(this.mount.setAttribute(Ne,""),this.mount.classList.remove(Cs),this.mount.innerHTML=""),e})}updatePosition(e){return P(this,null,function*(){this._positionReference=e.positionReference})}destroy(){this.mount=void 0}hidden(){return this.mount.hasAttribute(Ne)}};var Ps=class extends it{constructor(e,i={}){super(e);this.handleWindowChange=ki(this.handleWindowChange.bind(this)),this._position=new ks(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 P(this,null,function*(){let s=this.hidden();return s&&(this.mount.style.opacity="0",this.mount.removeAttribute(Ne)),this._position.update(this._positionReference),s&&(this.mount.setAttribute(Ne,""),this.mount.style.opacity=null,yield e("show").call(this),this.__addListeners__()),s})}hide(){var e=i=>super[i];return P(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 P(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 Rs=class extends it{show(){var e=i=>super[i];return P(this,null,function*(){let s=this.hidden();return s&&(document.documentElement.classList.add(xs),yield e("show").call(this)),s})}hide(){var e=i=>super[i];return P(this,null,function*(){let s=yield e("hide").call(this);return s&&document.documentElement.classList.remove(xs),s})}};function bt(t=8){let e="";for(;e.length{let n=0,o=null,a=e.interval||Wo,l=e.times||qo;o=setInterval(function(){n++this.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!")}};var Qr=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)/`)},Zr=function(t){let e=t.slice(0,4);return RegExp(`#${e}/(category-pages|mobile-category-pages)/`)};var Hs="__DF_DEBUG_MODE__",en="true",Di=window.sessionStorage;function tn(){Di.setItem(Hs,en)}function sn(){Di.removeItem(Hs)}function rn(){return Di.getItem(Hs)===en}function Ms(t){return Di.getItem(t)||window[t]}function O(...t){rn()&&console.log("[doofinder]",...t)}"use strict";var Fe=window.history,Ce=class{constructor({installationId:e,autoload:i,urlHash:s}){this._installationId=e,this._autoload=i?Object.freeze(i):null,this._urlHash=s,this._initialState=null,this._currentState=null}getQueryParamValue(){return this._autoload?new URLSearchParams(window.location.search).get(this._autoload.param):null}get hasQueryParam(){return this.getQueryParamValue()!==null}get stateKey(){return Ce.STATE_KEY}get(e=!1){return this.__fromHash__()||this.__fromQuery__()||this.__fromURL__()||this.__fromCurrentState__(e)}getHash(e){return this.valid(e)?new URL(e).hash:""}static getQuery(e){if(e){let i=e.split("/"),s=i[i.length-1];return Object.fromEntries(new URLSearchParams(s)).q}return""}replace(e){O("[state] replace state:",e),e=this.absoluteURL(e),this._currentState=e,Fe.replaceState(this.__getNewStateObject__(e),"",this._urlHash?e:window.location.href)}save(e){O("[state] save state:",e),e=this.absoluteURL(e),this._currentState=e;let i=Fe.state&&Fe.state[Ce.STATE_KEY]?Fe.state[Ce.STATE_KEY]:null;e!==i&&(this.valid(i)||(this._initialState=i),Fe.pushState(this.__getNewStateObject__(e),"",this._urlHash?e:window.location.href))}removeStateFromURL(){let e=this.absoluteURL("");O("[state] removeStateFromURL state",e),Fe.pushState(this.__getNewStateObject__(e),"",this._urlHash?e:"")}absoluteURL(e){return window.location.origin+window.location.pathname+window.location.search+e}valid(e){return typeof e=="string"&&(Qr(this._installationId).test(e)||e.startsWith(`#/${this._installationId}/`))}validEvent({state:e}){let i=this.valid(e?e[Ce.STATE_KEY]:"");switch(!0){case(this._initialState===null&&!i):case this._initialState===e[Ce.STATE_KEY]:case(this._initialState&&e[Ce.STATE_KEY]&&this._initialState.toString()===e[Ce.STATE_KEY].toString()):return!1;default:return i}}__getNewStateObject__(e){return typeof Fe.state=="object"&&Fe.state!==null?ce(D({},Fe.state),{[Ce.STATE_KEY]:e}):{[Ce.STATE_KEY]:e}}__fromHash__(){let e=this.valid(window.location.hash)?`#${window.location.hash.split("#",2)[1]}`:null;return O("[state] __fromHash__ state:",e),e}__fromQuery__(){if(!this._autoload){O("[state] __fromQuery__ with autoload false - state:",null);return}let e=this.getQueryParamValue(),i=e!=null?`#/${this._autoload.screen}/q=${e.trim()}`:null;return O("[state] __fromQuery__ state:",i),i}__fromURL__(){if(!this._autoload){O("[state] __fromURL__ with autoload false - state:",null);return}let i=this._autoload.urls.find(s=>location.pathname.search(s)===0)?`#/${this._autoload.screen}/`:null;return O("[state] __fromURL__ state:",i),i}__fromCurrentState__(e){return e?(O("[state] __fromCurrentState__ with isTransient true - state:",this._currentState),this._currentState):(O("[state] __fromCurrentState__ with isTransient false - state:",null),null)}},Ft=Ce;Qt(Ft,"STATE_KEY","doofinderState");"use strict";var Oi=window.history,Ut=class{constructor({installationId:e,urlHash:i}){this._installationId=e,this._urlHash=i,this._dataStore=new vt(`${this._installationId}.category_merchandising.state`,window.sessionStorage)}get stateKey(){return Ut.STATE_KEY}get(){let e=this.__currentState__()||this.getFromURLHash();return this.__patchState__(e)}getHash(e){return this.__isStateValid__(e)?new URL(e).hash:""}getBackState(){if(!this.__loadBackState__())return null;let e=this.__popBackState__();return O("[category pages state] getBackState state",e),this.__patchState__(e)}getFromURLHash(){let e=window.location.hash;return this.__isStateValid__(e)?(e=e.split("#",2)[1],O("[category pages state] __fromHash__ ",e),this.__patchState__(e)):null}save(e){this.update(e)}replace(e){this.update(e)}update(e){if(!this.__isStateValid__(e))return;O("[category pages state] update state ",e),this._dataStore.setItem("currentState",e);let i=this.absoluteURL(e);Oi.replaceState(this.__getNewStateObject__(e),"",this._urlHash?i:"")}saveCurrentAsBackState(){this._dataStore.setItem("backState",this.__currentState__())}__currentState__(){return this._dataStore.getItem("currentState")}__loadBackState__(){return this._dataStore.getItem("backState")||!1}__popBackState__(){let e=this._dataStore.getItem("backState");return this._dataStore.removeItem("backState"),O("[category pages state] __popBackState__ ",e),e}absoluteURL(e){return window.location.origin+window.location.pathname+window.location.search+e}__getNewStateObject__(e){let i=this.absoluteURL(e);return typeof Oi.state=="object"&&Oi.state!==null?ce(D({},Oi.state),{[Ut.STATE_KEY]:i}):{[Ut.STATE_KEY]:i}}__isStateValid__(e){return typeof e=="string"&&Zr(this._installationId).test(e)}__patchState__(e){return this.__isStateValid__(e)?e.replace(/&m=[^&]*&/,"&").replace(/&m=[^&]*$/,""):null}},St=Ut;Qt(St,"STATE_KEY","doofinderCategoryPagesState");var Ns="df:trigger:click",$t="df:trigger:focus",Bt="df:trigger:input",Fs="df:trigger:submit";var st=1;"use strict";var zo="[dfd-carousel-btn-left]",Yo="[dfd-carousel-btn-right]",nn="[dfd-carousel-content]",Hi="ltr",on={mounted(){this.btnLeftEl=this.el.querySelector(zo),this.btnRightEl=this.el.querySelector(Yo),this.contentEl=this.el.querySelector(nn),getComputedStyle(this.contentEl).direction==="rtl"&&(Hi="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;Hi==="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;Hi==="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"&&(Hi="rtl"),this.tag.dispatch("doofinder.carousel.update")},destroyed(){this.btnLeftEl.removeEventListener("click",this.previousPage),this.btnRightEl.removeEventListener("click",this.nextPage)}};var Mi=240;function Go(t){return!!t.type.match(/image\/.*/)}function an(t){return P(this,null,function*(){if(!Go(t))throw"invalid image, can't search";let e=yield ln(t),i=yield Qo(e);return yield ln(i)})}function ln(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 Qo(t){return new Promise(function(e,i){let s=new Image;s.onload=function(){let r=document.createElement("canvas");r.width=Mi,r.height=Mi,r.getContext("2d").drawImage(s,0,0,Mi,Mi),r.toBlob(function(n){e(n)},"image/jpeg")},s.onerror=function(r){i("resize image error")},s.src=t})}var hn={mounted(){this.search=t=>P(this,null,function*(){this.el.dataset.status="loading";let e=yield an(t);this.pushEvent("search",{search:{image:e}})}),this.el.addEventListener("change",t=>this.search(t.target.files[0]))}};function Us(t){setTimeout(()=>{t.focus(),t.selectionStart=t.selectionEnd=t.value.length},0)}"use strict";var cn={mounted(){this.search=t=>{let e=this.el.dataset.dfdAction||"search";this.pushEvent(e,{search:{query:t}})},this.handleEvent("set-input-focus",()=>Us(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,Us(this.el),this.search(e))})}};"use strict";var dn={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 Oe({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 rt(t){return`${U}:${t}`}"use strict";var Ni="doofinder.cart.add.click",Zo="doofinder.cart.add",Fi="doofinder.cart.hide.price",Ui="doofinder.cart.display.price",$s="dfd-btn-loading",un="dfd-btn-done",fn="dfd-btn-error";function pn(t){t.addToCartResolveTimeout=3e3,t.addToCartRejectTimeout=5e3,t.addToCartButtonFeedback=function(i,s){let r=ea.bind(null,i,s),n=sa.bind(null,i,i.innerHTML),o=ta.bind(null,i,n),a=ia.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 Oe({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(Zo,ce(D({},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(Ni,t.handleCartAddClick),e.addEventListener(rt(Ni),t.handleCartAddClick),e.addEventListener(Fi,t.handleHidePrice),e.addEventListener(rt(Fi),t.handleHidePrice),e.addEventListener(Ui,t.handleDisplayPrice),e.addEventListener(rt(Ui),t.handleDisplayPrice)}function mn(t){let e=!!t.tag&&!!t.tag.dom?t.tag.dom.mount:t.tag.mount;e.removeEventListener(Ni,t.handleCartAddClick),e.removeEventListener(rt(Ni),t.handleCartAddClick),e.removeEventListener(Fi,t.handleHidePrice),e.removeEventListener(rt(Fi),t.handleHidePrice),e.removeEventListener(Ui,t.handleDisplayPrice),e.removeEventListener(rt(Ui),t.handleDisplayPrice)}function ea(t,e){return t.setAttribute("disabled",""),t.setAttribute("dfd-update","ignore"),t.innerHTML="",t.classList.add($s),e}function ta(t,e){t.classList.remove($s),t.classList.add(un),setTimeout(e,1e3)}function ia(t,e){t.classList.remove($s),t.classList.add(fn),setTimeout(e,2e3)}function sa(t,e){t.classList.remove(un),t.classList.remove(fn),t.innerHTML=e,t.removeAttribute("dfd-update"),t.removeAttribute("disabled")}"use strict";var gn={mounted(){this.close=()=>this.pushEvent("close-layer"),this.handleEvent("history-go",({n:t})=>{history.go(t)}),this.handleEvent("close",()=>{let t=this.tag.searchQueryRetention?this.tag.state.get():"";this.tag.updateQuery(t),this.tag.disconnect()}),this.handleEvent("save-state",({state:t})=>{this.tag.state.save(t)}),this.handleEvent("replace-state",({state:t})=>{this.tag.state.replace(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=>P(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",()=>P(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}),pn(this)},updated(){this.tag.dispatch("doofinder.layer.update")},destroyed(){mn(this)}},_n={mounted(){this.handleEvent("disconnect",t=>{t.errors.forEach(e=>console.error("[Doofinder] error:",e)),this.tag.destroy()})}};var vn=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 bn(t,e,i,s,r=vn.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 Sn=bn.bind(null,"scrollTop"),Mc=bn.bind(null,"scrollLeft");function ra(t){let e=t.scrollHeight>t.clientHeight,s=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!s}function $i(t){return!t||t===document.documentElement?document.documentElement:ra(t)?t:$i(t.parentNode)}function yn(t,e){return typeof t!="undefined"?t:e}var Vt=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:yn(r,0)})}observe(e){this._io.disconnect(),e&&this._io.observe(e),O("[ScrollObserver][observe]",e)}unobserve(){this._io.disconnect(),O("[ScrollObserver][unobserve]")}handleIntersection([e]){O("[ScrollObserver][intersection detected] target:",e.target),this._callback(e)}};var En='[data-dfd-role~="scroll-sentinel"]',wn='[data-dfd-role~="scroll-top-sentinel"]',na="div.dfd-card";function jt(t,e,i){i?t.scrollTop=e:Sn(t,e,250)}function oa(t){var s,r;let e=((s=document.querySelector(na))==null?void 0:s.offsetHeight)||0,i=((r=document.querySelector(En))==null?void 0:r.offsetHeight)||0;return t.scrollHeight-i-e*2.6}var An={mounted(){this.sentinel=()=>this.el.querySelector(En),this.scrollTopSentinel=()=>this.el.querySelector(wn),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 Vt(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 Vt(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();!aa(t.filter)&&i===1&&e===(s==null?void 0:s.dataset.index)&&(this.changeBackToTopVisibility(!1),jt(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)&&jt(this.el,0,!!e)}),this.handleEvent("change-current-index",()=>{this.scrollObserver.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel()),jt(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}},Bs={mounted(){this.hideVirtualKeyboard=ki(()=>{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)}},Vs={mounted(){this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.scrollTopSentinel=()=>this.el.querySelector(wn),this.transientTargetCard=()=>this.el.querySelector(`[dfd-value-dfid="${this.tag.popTargetItemId()}"]`),this.changeBackToTopVisibility=t=>{this.pushEvent("change-back-to-top-visibility",{visible:t})},this.scrollTopObserver=new Vt(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),e!=null?e.scrollIntoView({behavior:"smooth",block:"nearest"}):t.scroll_end&&jt($i(this.el),oa(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)&&jt($i(this.el),0,e)}),this.pushEvent("update-scroll")}};function aa(t){return!!t&&Object.keys(t).length>0}function Bi(t,e,i,s){return new Intl.NumberFormat(t,{style:"currency",maximumFractionDigits:parseInt(i,10),numberingSystem:s,currency:e})}function Vi(t,e,i){return new Intl.NumberFormat(t,{maximumFractionDigits:parseInt(e,10),numberingSystem:i})}var js=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 Xe;(function(t){t.Range="range",t.Steps="steps",t.Positions="positions",t.Count="count",t.Values="values"})(Xe||(Xe={}));var he;(function(t){t[t.None=-1]="None",t[t.NoValue=0]="NoValue",t[t.LargeValue=1]="LargeValue",t[t.SmallValue=2]="SmallValue"})(he||(he={}));function la(t){return ji(t)&&typeof t.from=="function"}function ji(t){return typeof t=="object"&&typeof t.to=="function"}function Tn(t){t.parentElement.removeChild(t)}function Xs(t){return t!=null}function Cn(t){t.preventDefault()}function ha(t){return t.filter(function(e){return this[e]?!1:this[e]=!0},{})}function ca(t,e){return Math.round(t/e)*e}function da(t,e){var i=t.getBoundingClientRect(),s=t.ownerDocument,r=s.documentElement,n=Pn(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 xe(t){return typeof t=="number"&&!isNaN(t)&&isFinite(t)}function xn(t,e,i){i>0&&(le(t,e),setTimeout(function(){Ji(t,e)},i))}function kn(t){return Math.max(Math.min(t,100),0)}function Xi(t){return Array.isArray(t)?t:[t]}function ua(t){t=String(t);var e=t.split(".");return e.length>1?e[1].length:0}function le(t,e){t.classList&&!/\s/.test(e)?t.classList.add(e):t.className+=" "+e}function Ji(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 fa(t,e){return t.classList?t.classList.contains(e):new RegExp("\\b"+e+"\\b").test(t.className)}function Pn(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 pa(){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 ma(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("test",null,e)}catch(i){}return t}function ga(){return window.CSS&&CSS.supports&&CSS.supports("touch-action","none")}function Js(t,e){return 100/(e-t)}function qs(t,e,i){return e*100/(t[i+1]-t[i])}function _a(t,e){return qs(t,t[0]<0?e+Math.abs(t[0]):e-t[0],0)}function va(t,e){return e*(t[1]-t[0])/100+t[0]}function Xt(t,e){for(var i=1;t>=e[i];)i+=1;return i}function ba(t,e,i){if(i>=t.slice(-1)[0])return 100;var s=Xt(i,t),r=t[s-1],n=t[s],o=e[s-1],a=e[s];return o+_a([r,n],i)/Js(o,a)}function Sa(t,e,i){if(i>=100)return t.slice(-1)[0];var s=Xt(i,e),r=t[s-1],n=t[s],o=e[s-1],a=e[s];return va([r,n],(i-o)*Js(o,a))}function ya(t,e,i,s){if(s===100)return s;var r=Xt(s,t),n=t[r-1],o=t[r];return i?s-n>(o-n)/2?o:n:e[r-1]?t[r-1]+ca(s-t[r-1],e[r-1]):s}var Rn=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([Xi(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=ba(this.xVal,this.xPct,e),e},t.prototype.fromStepping=function(e){return Sa(this.xVal,this.xPct,e)},t.prototype.getStep=function(e){return e=ya(this.xPct,this.xSteps,this.snap,e),e},t.prototype.getDefaultStep=function(e,i,s){var r=Xt(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=Xt(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(ua);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),!xe(s)||!xe(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]=qs([this.xVal[e],this.xVal[e+1]],i,0)/Js(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}(),Ln={to:function(t){return t===void 0?"":t.toFixed(2)},from:Number},In={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"},Je={tooltips:".__tooltips",aria:".__aria"};function Ea(t,e){if(!xe(e))throw new Error("noUiSlider: 'step' is not numeric.");t.singleStep=e}function wa(t,e){if(!xe(e))throw new Error("noUiSlider: 'keyboardPageMultiplier' is not numeric.");t.keyboardPageMultiplier=e}function Aa(t,e){if(!xe(e))throw new Error("noUiSlider: 'keyboardMultiplier' is not numeric.");t.keyboardMultiplier=e}function Ta(t,e){if(!xe(e))throw new Error("noUiSlider: 'keyboardDefaultStep' is not numeric.");t.keyboardDefaultStep=e}function Ca(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 Rn(e,t.snap||!1,t.singleStep)}function xa(t,e){if(e=Xi(e),!Array.isArray(e)||!e.length)throw new Error("noUiSlider: 'start' option is incorrect.");t.handles=e.length,t.start=e}function ka(t,e){if(typeof e!="boolean")throw new Error("noUiSlider: 'snap' option must be a boolean.");t.snap=e}function Pa(t,e){if(typeof e!="boolean")throw new Error("noUiSlider: 'animate' option must be a boolean.");t.animate=e}function Ra(t,e){if(typeof e!="number")throw new Error("noUiSlider: 'animationDuration' option must be a number.");t.animationDuration=e}function La(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 Ha(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 Ma(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");Dn(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 Na(t,e){if(e!==!1)if(e===!0||ji(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===Xe.Positions?R(h.values,h.stepped):h.mode===Xe.Values?h.stepped?h.values.map(function(y){return v.fromStepping(v.getStep(v.toStepping(y)))}):h.values:[]}function R(h,d){return h.map(function(u){return v.fromStepping(d?v.getStep(u):u)})}function $(h){function d(F,K){return Number((F+K).toFixed(7))}var u=J(h),_={},y=v.xVal[0],S=v.xVal[v.xVal.length-1],T=!1,A=!1,j=0;return u=ha(u.slice().sort(function(F,K){return F-K})),u[0]!==y&&(u.unshift(y),T=!0),u[u.length-1]!==S&&(u.push(S),A=!0),u.forEach(function(F,K){var z,M,Q,ne=F,te=u[K+1],se,ts,is,ss,or,rs,ar,lr=h.mode===Xe.Steps;for(lr&&(z=v.xNumSteps[K]),z||(z=te-ne),te===void 0&&(te=ne),z=Math.max(z,1e-7),M=ne;M<=te;M=d(M,z)){for(se=v.toStepping(M),ts=se-j,or=ts/(h.density||1),rs=Math.round(or),ar=ts/rs,Q=1;Q<=rs;Q+=1)is=j+Q*ar,_[is.toFixed(5)]=[v.fromStepping(is),0];ss=u.indexOf(M)>-1?he.LargeValue:lr?he.SmallValue:he.NoValue,!K&&T&&M!==te&&(ss=0),M===te&&A||(_[se.toFixed(5)]=[M,ss]),j=se}}),_}function Ue(h,d,u){var _,y,S=L.createElement("div"),T=(_={},_[he.None]="",_[he.NoValue]=e.cssClasses.valueNormal,_[he.LargeValue]=e.cssClasses.valueLarge,_[he.SmallValue]=e.cssClasses.valueSub,_),A=(y={},y[he.None]="",y[he.NoValue]=e.cssClasses.markerNormal,y[he.LargeValue]=e.cssClasses.markerLarge,y[he.SmallValue]=e.cssClasses.markerSub,y),j=[e.cssClasses.valueHorizontal,e.cssClasses.valueVertical],F=[e.cssClasses.markerHorizontal,e.cssClasses.markerVertical];le(S,e.cssClasses.pips),le(S,e.ort===0?e.cssClasses.pipsHorizontal:e.cssClasses.pipsVertical);function K(M,Q){var ne=Q===e.cssClasses.value,te=ne?j:F,se=ne?T:A;return Q+" "+te[e.ort]+" "+se[M]}function z(M,Q,ne){if(ne=d?d(Q,ne):ne,ne!==he.None){var te=W(S,!1);te.className=K(ne,e.cssClasses.marker),te.style[e.style]=M+"%",ne>he.NoValue&&(te=W(S,!1),te.className=K(ne,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])}),S}function pe(){f&&(Tn(f),f=null)}function ke(h){pe();var d=$(h),u=h.filter,_=h.format||{to:function(y){return String(Math.round(y))}};return f=o.appendChild(Ue(d,u,_)),f}function We(){var h=a.getBoundingClientRect(),d="offset"+["Width","Height"][e.ort];return e.ort===0?h.width||a[d]:h.height||a[d]}function re(h,d,u,_){var y=function(T){var A=nt(T,_.pageOffset,_.target||d);if(!A||G()&&!_.doNotReject||fa(o,e.cssClasses.tap)&&!_.doNotReject||h===s.start&&A.buttons!==void 0&&A.buttons>1||_.hover&&A.buttons)return!1;n||A.preventDefault(),A.calcPoint=A.points[e.ort],u(A,_)},S=[];return h.split(" ").forEach(function(T){d.addEventListener(T,y,n?{passive:!0}:!1),S.push([T,y])}),S}function nt(h,d,u){var _=h.type.indexOf("touch")===0,y=h.type.indexOf("mouse")===0,S=h.type.indexOf("pointer")===0,T=0,A=0;if(h.type.indexOf("MSPointer")===0&&(S=!0),h.type==="mousedown"&&!h.buttons&&!h.touches)return!1;if(_){var j=function(z){var M=z.target;return M===u||u.contains(M)||h.composed&&h.composedPath().shift()===u};if(h.type==="touchstart"){var F=Array.prototype.filter.call(h.touches,j);if(F.length>1)return!1;T=F[0].pageX,A=F[0].pageY}else{var K=Array.prototype.find.call(h.changedTouches,j);if(!K)return!1;T=K.pageX,A=K.pageY}}return d=d||Pn(L),(y||S)&&(T=h.clientX+d.x,A=h.clientY+d.y),h.pageOffset=d,h.points=[T,A],h.cursor=y||S,h}function Ee(h){var d=h-da(a,e.ort),u=d*100/We();return u=kn(u),e.dir?100-u:u}function Et(h){var d=100,u=!1;return l.forEach(function(_,y){if(!fe(y)){var S=b[y],T=Math.abs(S-h),A=T===100&&d===100,j=TS;(j||F||A)&&(u=y,d=T)}}),u}function Wt(h,d){h.type==="mouseout"&&h.target.nodeName==="HTML"&&h.relatedTarget===null&&Yi(h,d)}function eo(h,d){if(navigator.appVersion.indexOf("MSIE 9")===-1&&h.buttons===0&&d.buttonsProperty!==0)return Yi(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 Yi(h,d){d.handle&&(Ji(d.handle,e.cssClasses.active),N-=1),d.listeners.forEach(function(u){B.removeEventListener(u[0],u[1])}),N===0&&(Ji(o,e.cssClasses.drag),es(),h.cursor&&(q.style.cursor="",q.removeEventListener("selectstart",Cn))),e.events.smoothSteps&&(d.handleNumbers.forEach(function(u){Ke(u,b[u],!0,!0,!1,!1)}),d.handleNumbers.forEach(function(u){Y("update",u)})),d.handleNumbers.forEach(function(u){Y("change",u),Y("set",u),Y("end",u)})}function Gi(h,d){if(!d.handleNumbers.some(fe)){var u;if(d.handleNumbers.length===1){var _=l[d.handleNumbers[0]];u=_.children[0],N+=1,le(u,e.cssClasses.active)}h.stopPropagation();var y=[],S=re(s.move,B,eo,{target:h.target,handle:u,connect:d.connect,listeners:y,startCalcPoint:h.calcPoint,baseSize:We(),pageOffset:h.pageOffset,handleNumbers:d.handleNumbers,buttonsProperty:h.buttons,locations:b.slice()}),T=re(s.end,B,Yi,{target:h.target,handle:u,listeners:y,doNotReject:!0,handleNumbers:d.handleNumbers}),A=re("mouseout",B,Wt,{target:h.target,handle:u,listeners:y,doNotReject:!0,handleNumbers:d.handleNumbers});y.push.apply(y,S.concat(T,A)),h.cursor&&(q.style.cursor=getComputedStyle(h.target).cursor,l.length>1&&le(o,e.cssClasses.drag),q.addEventListener("selectstart",Cn,!1)),d.handleNumbers.forEach(function(j){Y("start",j)})}}function to(h){h.stopPropagation();var d=Ee(h.calcPoint),u=Et(d);u!==!1&&(e.events.snap||xn(o,e.cssClasses.tap,e.animationDuration),Ke(u,d,!0,!0),es(),Y("slide",u,!0),Y("update",u,!0),e.events.snap?Gi(h,{handleNumbers:[u]}):(Y("change",u,!0),Y("set",u,!0)))}function io(h){var d=Ee(h.calcPoint),u=v.getStep(d),_=v.fromStepping(u);Object.keys(I).forEach(function(y){y.split(".")[0]==="hover"&&I[y].forEach(function(S){S.call(Yt,_)})})}function so(h,d){if(G()||fe(d))return!1;var u=["Left","Right"],_=["Down","Up"],y=["PageDown","PageUp"],S=["Home","End"];e.dir&&!e.ort?u.reverse():e.ort&&!e.dir&&(_.reverse(),y.reverse());var T=h.key.replace("Arrow",""),A=T===y[0],j=T===y[1],F=T===_[0]||T===u[0]||A,K=T===_[1]||T===u[1]||j,z=T===S[0],M=T===S[1];if(!F&&!K&&!z&&!M)return!0;h.preventDefault();var Q;if(K||F){var ne=F?0:1,te=nr(d),se=te[ne];if(se===null)return!1;se===!1&&(se=v.getDefaultStep(b[d],F,e.keyboardDefaultStep)),j||A?se*=e.keyboardPageMultiplier:se*=e.keyboardMultiplier,se=Math.max(se,1e-7),se=(F?-1:1)*se,Q=E[d]+se}else M?Q=e.spectrum.xVal[e.spectrum.xVal.length-1]:Q=e.spectrum.xVal[0];return Ke(d,v.toStepping(Q),!0,!0),Y("slide",d),Y("update",d),Y("change",d),Y("set",d),!1}function ro(h){h.fixed||l.forEach(function(d,u){re(s.start,d.children[0],Gi,{handleNumbers:[u]})}),h.tap&&re(s.start,a,to,{}),h.hover&&re(s.move,a,io,{hover:!0}),h.drag&&c.forEach(function(d,u){if(!(d===!1||u===0||u===c.length-1)){var _=l[u-1],y=l[u],S=[d],T=[_,y],A=[u-1,u];le(d,e.cssClasses.draggable),h.fixed&&(S.push(_.children[0]),S.push(y.children[0])),h.dragAll&&(T=l,A=w),S.forEach(function(j){re(s.start,j,Gi,{handles:T,handleNumbers:A,connect:d})})}})}function Qi(h,d){I[h]=I[h]||[],I[h].push(d),h.split(".")[0]==="update"&&l.forEach(function(u,_){Y("update",_)})}function no(h){return h===Je.aria||h===Je.tooltips}function wt(h){var d=h&&h.split(".")[0],u=d?h.substring(d.length):h;Object.keys(I).forEach(function(_){var y=_.split(".")[0],S=_.substring(y.length);(!d||d===y)&&(!u||u===S)&&(!no(S)||u===S)&&delete I[_]})}function Y(h,d,u){Object.keys(I).forEach(function(_){var y=_.split(".")[0];h===y&&I[_].forEach(function(S){S.call(Yt,E.map(e.format.to),d,E.slice(),u||!1,b.slice(),Yt)})})}function Kt(h,d,u,_,y,S,T){var A;return l.length>1&&!e.events.unconstrained&&(_&&d>0&&(A=v.getAbsoluteDistance(h[d-1],e.margin,!1),u=Math.max(u,A)),y&&d1&&e.limit&&(_&&d>0&&(A=v.getAbsoluteDistance(h[d-1],e.limit,!1),u=Math.min(u,A)),y&&d1?_.forEach(function(z,M){var Q=Kt(S,z,S[z]+d,j[M],F[M],!1,A);Q===!1?d=0:(d=Q-S[z],S[z]=Q)}):j=F=[!0];var K=!1;_.forEach(function(z,M){K=Ke(z,u[z]+d,j[M],F[M],!1,A)||K}),K&&(_.forEach(function(z){Y("update",z),Y("slide",z)}),y!=null&&Y("drag",T))}function tr(h,d){return e.dir?100-h-d:h}function oo(h,d){b[h]=d,E[h]=v.fromStepping(d);var u=tr(d,0)-Z,_="translate("+Zi(u+"%","0")+")";l[h].style[e.transformRule]=_,ir(h),ir(h+1)}function es(){w.forEach(function(h){var d=b[h]>50?-1:1,u=3+(l.length+d*h);l[h].style.zIndex=String(u)})}function Ke(h,d,u,_,y,S){return y||(d=Kt(b,h,d,u,_,!1,S)),d===!1?!1:(oo(h,d),!0)}function ir(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,y="translate("+Zi(tr(d,_)+"%","0")+")",S="scale("+Zi(_/100,"1")+")";c[h].style[e.transformRule]=y+" "+S}}function sr(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 zt(h,d,u){var _=Xi(h),y=b[0]===void 0;d=d===void 0?!0:d,e.animate&&!y&&xn(o,e.cssClasses.tap,e.animationDuration),w.forEach(function(A){Ke(A,sr(_[A],A),!0,!1,u)});var S=w.length===1?0:1;if(y&&v.hasNoSize()&&(u=!0,b[0]=0,w.length>1)){var T=100/(w.length-1);w.forEach(function(A){b[A]=A*T})}for(;S=0&&hu.stepAfter.startValue&&(y=u.stepAfter.startValue-_),_>u.thisStep.startValue?S=u.thisStep.step:u.stepBefore.step===!1?S=!1:S=_-u.stepBefore.highestStep,d===100?y=null:d===0&&(S=null);var T=v.countStepDecimals();return y!==null&&y!==!1&&(y=Number(y.toFixed(T))),S!==null&&S!==!1&&(S=Number(S.toFixed(T))),[S,y]}function co(){return w.map(nr)}function uo(h,d){var u=rr(),_=["margin","limit","padding","range","animate","snap","step","format","pips","tooltips"];_.forEach(function(S){h[S]!==void 0&&(i[S]=h[S])});var y=On(i);_.forEach(function(S){h[S]!==void 0&&(e[S]=y[S])}),v=y.spectrum,e.margin=y.margin,e.limit=y.limit,e.padding=y.padding,e.pips?ke(e.pips):pe(),e.tooltips?x():qe(),b=[],zt(Xs(h.start)?h.start:u,d)}function fo(){a=k(o),g(e.connect,a),ro(e.events),zt(e.start),e.pips&&ke(e.pips),e.tooltips&&x(),C()}fo();var Yt={destroy:ho,steps:co,on:Qi,off:wt,get:rr,set:zt,setHandle:lo,reset:ao,disable:yt,enable:zi,__moveHandles:function(h,d,u){er(h,d,b,u)},options:i,updateOptions:uo,target:o,removePips:pe,removeTooltips:qe,getPositions:function(){return b.slice()},getTooltips:function(){return m},getOrigins:function(){return l},pips:ke};return Yt}function qa(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=On(e),s=Ja(t,i,e);return t.noUiSlider=s,s}var Hn={__spectrum:Rn,cssClasses:In,create:qa};function Mn(t){return t.filter((e,i)=>t.indexOf(e)===i)}function Nn(t){let e={};return{to(i){let s=t.format(i);return e[s]=i,s},from(i){return e[i]}}}function Ws(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 Fn(t,e,i,s={}){return Hn.create(t,D({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 Un(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=[[]],I=0;a[0]&&(b[0][0]=0,w[0][0]=E[0],N[0][0]=c[0]);for(let L=1;Le)&&(I++,b[I]=[],N[I]=[],w[I]=[]),a[L]&&(b[I].push(L),N[I].push(c[L]),w[I].push(E[L]));b.forEach(function(L,B){let q=L.length;for(let Z=0;Ztypeof r=="string"?new js(r,o,a,s,parseInt(n,10)):i?Bi(e,i,parseInt(n,10),w):Vi(e,parseInt(l,10),w))();this.format=Nn(I),this.slider=Fn(this.el,this.format,Ws({min:c,max:f,from:m,to:v},this.format),{rtl:N}),this.slider.on("change",L=>{let[B,q]=L,W={index:this.el.dataset.index,range:{[t]:{from:this.format.from(B),to:this.format.from(q)}}};E?this.pushEventTo(E,"slide",W):this.pushEvent("slide",W)}),b||Un(this.el,25," - ")},updated(){let{min:t,max:e,from:i,to:s}=this.el.dataset;this.slider.updateOptions(Ws({min:t,max:e,from:i,to:s},this.format))},destroyed(){this.el.noUiSlider.destroy()}};"use strict";var Bn={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 qi=window.SpeechRecognition||window.webkitSpeechRecognition||null,Vn=["click"],jn=["start","end","error","result"],Wa="voice-search",Xn="voice-status-change";function Ka(t){return t.results.length>0?t.results[0][0].transcript:null}var Jn={mounted(){!qi||(this.recording=!1,this.driver=new qi,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(Xn,{recording:!1});break;case"click":this.driver[this.recording?"stop":"start"](),this.recording=!this.recording,this.pushEvent(Xn,{recording:this.recording});break;case"result":{let e=Ka(t);e&&this.pushEvent(Wa,{query:e});break}}},Vn.forEach(t=>this.el.addEventListener(t,this.handleVoiceEvent)),jn.forEach(t=>this.driver.addEventListener(t,this.handleVoiceEvent)))},destroyed(){Vn.forEach(t=>this.el.removeEventListener(t,this.handleVoiceEvent)),jn.forEach(t=>this.driver.removeEventListener(t,this.handleVoiceEvent)),this.driver=null}};"use strict";var qn={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 ue(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){O(`[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 Wn(t){return JSON.parse(JSON.stringify(t))}function Ks(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 Jt(t,e=!1){let i=Ms("__DF_LAYER_SERVER__")||`https://${t.toLowerCase()}-layer.doofinder.com`;return e?i.replace(/^http/,"ws"):i}function Kn(){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 zs(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));if(e)return decodeURIComponent(e[1])}function zn(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&&za(s))}return!1}function za(t){return t.getAttribute("type")==="submit"&&(t.tagName==="BUTTON"||t.tagName==="INPUT")}function Ys(t){return typeof t=="undefined"?null:t}var Ya="Search",Yn=Kn(),Gn="latestSearches",Ga="dfd-root",Gs="dfdTarget",Qa=10,qt="transientState",Qs="isTransient",Wi=class{constructor(e){this.__handleTriggerEvent__=this.__handleTriggerEvent__.bind(this),this.__handlePopstate__=this.__handlePopstate__.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 Os(this._mount.id),this._eventBusSubscriptions=[Ns,$t,Bt,Fs].map(w=>this._eventBus.on(w,this.__handleTriggerEvent__)),this._trigger=v,this._trigger.setEventBus(this._eventBus),this._display=new Ds(this._mount),this._state=this._layerType!=="category_pages"?new Ft({installationId:a,autoload:i,urlHash:E}):new St({installationId:a,urlHash:E}),this._data=new vt(`${a}.data`),this._sessionData=new vt(`${a}.data`,window.sessionStorage),this._params=this.__buildSocketParams__(e),this._hooks=this.__buildSocketHooks__(e),this._connection=null,this._connectedPromise=new Oe,this._theme=null,m==null?this._searchQueryRetention=E:this._searchQueryRetention=m,this._transientQuery=null,this.closable&&this.mount.classList.add("dfd-closable"),window.addEventListener("popstate",this.__handlePopstate__),this._trigger.flushMessages(),this.__applyTransientState__(),this.__loadState__().then(()=>this.dispatch("doofinder.ready"))}__createMount__(e){let i=document.createElement("div");return i.id=e||`df-${bt(32)}`,i.dataset.dfdView=Ya,i.setAttribute(Ne,""),i.classList.add(Ga),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!==tt||!this.state.hasQueryParam}enableDebug(){return this._connection?(this._connection.enableDebug(),!0):!1}debug(...e){O("[tag]",...e)}saveTransientState(e){this._sessionData.setItem(qt,e),this._sessionData.setItem(Qs,!0),this.debug("save transient state:",e)}__popTransientState__(){let e=this._sessionData.getItem(qt)||null;return this._sessionData.removeItem(qt),this.debug("pop transient state:",e),e}__handleTriggerEvent__(e){let{source:i,originalEvent:s}=e.detail,{query:r}=e.detail;!r&&this._transientQuery&&(r=this._transientQuery);let n=r?{query:r}:{};this.connect(n).then(()=>{this.__shouldDisplay__(e)?(this.show(i),e.type===Bt&&this.search(r)):e.type===Fs&&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())})})}__applyTransientState__(){let e=this._sessionData.getItem(qt),i=this._sessionData.getItem(Qs);this.debug("__applyTransientState__","isTransient:",i,"searchQueryRetention:",this._searchQueryRetention),i&&(this._searchQueryRetention?(this.debug("apply transient state - search query retention true:",e),this.updateQuery(e)):(this.debug("apply transient state - search query retention false:",""),this._state.replace(""),this.updateQuery("")),this._sessionData.removeItem(Qs),this._sessionData.removeItem(qt))}__shouldDisplay__(e){let{query:i}=e.detail;switch(this._display.type){case Ti:return(e.type===Bt||e.type===$t)&&(this._display.screenType==="classic-initial"||!!i);case tt:return(e.type===Bt||e.type===$t)&&!!i;case Ci:return e.type===Ns||e.type===$t;default:return!1}}__handlePopstate__(e){this._layerType!=="category_pages"&&(this.debug("handle pop state event:",e),this._connection?this._state.validEvent(e)?this.__changeState__(e.state[this._state.stateKey]):this.disconnect():this.__loadState__())}__changeState__(e){var i;this.debug("[tag] change state: ",e,"connection: ",this._connection),(i=this._connection)==null||i.pushEvent("change-state",{state:this._state.getHash(e)})}__handleLinkClick__(e){var i,s;if(this._layerType==="category_pages"){if(!e.target.href)return;this._state.saveCurrentAsBackState();return}if(e.target.href){let r=e.target.closest("[dfd-value-dfid]"),n=r==null?void 0:r.getAttribute("dfd-value-dfid");n&&this._sessionData.setItem(Gs,n),(i=this._connection)==null||i.setPreventReconnect(!0);let o=!0;this.saveTransientState(this._state.get(o))}else(s=this._connection)==null||s.setPreventReconnect(!1)}popTargetItemId(){return this.debug("popTargetItemId",this._sessionData.getItem(Gs)),this._sessionData.popItem(Gs)}__handleDocumentMousedown__(e){if(this._display.type===tt||!zn(e))return;let{clientX:i,clientY:s}=e;if(Ks(i,s,this._mount.getBoundingClientRect()))return;let r=this._display.method.positionReference;!!r&&(Ks(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")return Promise.resolve();let e=this._state.get();return this.debug("load state:",e),e?(this._state.removeStateFromURL(),this.updateQuery(e),e&&e.match("^#([A-Za-z0-9-]+)/(embedded|classic)/$")?Promise.resolve(this.close()):this.connect({state:e}).then(()=>this.show())):Promise.resolve()}updateQuery(e){let i=Ft.getQuery(e);this._trigger.updateQuery(i),this._transientQuery=i}getLatestSearches(){return this._data.getItem(Gn)||[]}updateLatestSearches(e){this._data.setItem(Gn,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 P(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 P(this,null,function*(){yield this.updatePosition(e),yield this._display.show(),this.dispatch("doofinder.show")})}hide(){return P(this,null,function*(){this._display&&(yield this._display.hide()),this.dispatch("doofinder.hide")})}dispatch(e,i={}){let s=ce(D({},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 Ts(this.__connectionSetup__(e)),this._connection.connect(this.__afterConnect__)),this._connectedPromise}isConnected(){return this._connection?this._connection.connected:!1}open(){return P(this,arguments,function*(e={}){let{search:i,screen:s}=e,r=D({},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 P(this,null,function*(){let{search:i}=e,s={search:i},r=this._state.getBackState()||this._state.getFromURLHash();r&&(s.state=r),O("[category pages] connect with",s),yield this.connect(s),yield this.show(),r||(O("[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}`),(e=this._connection)==null||e.disconnect(this.__afterDisconnect__),this._connection=null,this._connectedPromise=new Oe)}destroy(){return P(this,null,function*(){var e;this.debug(`destroy: ${this._mount.id}`),(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,window.removeEventListener("popstate",this.__handlePopstate__),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}=e,a={hashid:this._hashid,origin:window.location.hostname,indices:n,params:i,sort:s,vars:r,state:o};return["indices","search-server"].filter(l=>!a[l]).forEach(l=>delete a[l]),a}__buildSocketHooks__(e){let i=e.hooks||{},s={Carousel:ue("Carousel",this,on,i.Carousel||{}),ImageSearch:ue("ImageSearch",this,hn),Input:ue("Input",this,cn,i.Input||{}),Layer:ue("Layer",this,gn,i.Layer||{}),LayerNotAvailable:ue("LayerNotAvailable",this,_n),AddToCart:ue("AddToCart",this,dn,i.AddToCart||{}),EmbeddedResults:ue("EmbeddedResults",this,Vs,Yn?Bs:{},i.EmbeddedResults||{}),Results:ue("Results",this,An,Yn?Bs:{},Vs,i.Results||{}),Slider:ue("Slider",this,$n,i.Slider||{}),Swipe:ue("Swipe",this,Bn,i.Swipe||{}),VoiceSearch:ue("VoiceSearch",this,Jn,i.VoiceSearch||{}),SortSelect:ue("SortSelect",this,qn)};return O("[tag] Hooks created:",this._mount.id,s),Object.keys(i).filter(r=>!s[r]).forEach(r=>{s[r]=ue(r,this,i[r]||{})}),s}__connectionSetup__(e){let s=`${Jt(this._zone,!0)}/layer/${st}`,r=this._state.get(),n=this.__popTransientState__();return r?e.state=r:n&&!e.state&&(e.state=n),{url:s,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=ce(D({},Wn(this._params)),{zone:this.zone,installation_id:this.installationId,language:this.language,currency:this.currency,session_id:Doofinder.Session.getSessionId(),session_alive:Doofinder.Session.isLive("layer"),user_id:Doofinder.Session.getUserId(),latest_searches:this.getLatestSearches(),voice_supported:!!qi,export_results_data:Ys((s=this.exportResultsData)==null?void 0:s.slice(0,Qa)),ga_client_id:Ys((r=zs("_ga"))==null?void 0:r.substring(6)),layer_type:this.layerType,state:this._state.get()});return this._layerType==="category_pages"&&(i.search=e.search),((n=this._connection)==null?void 0:n.connected)||(i=D(D({},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.get()),i}__afterConnect__(){document.addEventListener("mousedown",this.__handleDocumentMousedown__),document.addEventListener("keyup",this.__handleDocumentKeyup__,{passive:!0})}__afterDisconnect__(){this.hide(),document.removeEventListener("keyup",this.__handleDocumentKeyup__),document.removeEventListener("mousedown",this.__handleDocumentMousedown__),this.dispatch("doofinder.disconnect")}};var Za=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 Zs(t){return P(this,null,function*(){let e=document.createElement("style");e.appendChild(document.createTextNode((t||"").trim())),document.head.appendChild(e)})}function Qn(t){return P(this,null,function*(){var o;let e=tl(t);O("[category pages] displayForSeo options: ",t,"params: ",e);let i=yield il(e);if(O("[category pages] displayForSeo htmlContent: ",i),!i)return;let s=el(i);t.device=="mobile"&&(s.classList.remove("dfd-embedded"),s.classList.add("dfd-mobile_embedded")),t.custom_css.forEach(Zs);let r=(o=t.custom_properties)==null?void 0:o.join(` `);Zs(`#${s.id} { ${r||""} }`);let n=document.querySelector(t.insertion_point);n&&n.replaceWith(s)})}function el(t){let e=document.createElement("div");return e.id=`df-${bt(32)}`,e.dataset.dfdView="Search",e.classList.add("dfd-root"),e.classList.add("dfd-embedded"),e.setAttribute("data-dfd-screen","category-pages"),e.insertAdjacentHTML("afterbegin",t),e}function tl(t){let{installationId:e,hashid:i,language:s,currency:r,zone:n,search:o,sort:a,urlHash:l}=t,c=Doofinder.Session.getSessionId(),f=Doofinder.Session.getUserId(),m=new St({installationId:e,urlHash:l}).get();return{installationId:e,hashid:i,language:s,currency:r,zone:n,state:m,search:o,sort:a,session_id:c,user_id:f}}function il(t){return P(this,null,function*(){let{zone:e}=t,i=Jt(e),s=new URL(`${i}/api/${st}/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 Ki=[];document.addEventListener("doofinder.destroy",t=>{Ki=Ki.filter(e=>e!==t.detail)});var Zn={getTags(){return Ki.slice(0)},create(t){let e=new Wi(t);return t.forceOpen&&t.layerType==="category_pages"&&(Qn(t),e.openCategoryPages(t)),Ki.push(e),e},destroy(t){var e;t instanceof Wi?t.destroy():(e=t==null?void 0:t.doofinderTag)==null||e.destroy()},enableDebug:tn,disableDebug:sn,debug:O,utils:{buildNumericFormatter:Vi,buildCurrencyFormatter:Bi}};Object.defineProperty(Zn,"__version__",{value:st});fr(ur,Zn);})();