(()=>{var Ro=Object.defineProperty,Io=Object.defineProperties;var Ho=Object.getOwnPropertyDescriptors;var zt=Object.getOwnPropertySymbols;var cr=Object.prototype.hasOwnProperty,dr=Object.prototype.propertyIsEnumerable;var is=(t,e,i)=>e in t?Ro(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,H=(t,e)=>{for(var i in e||(e={}))cr.call(e,i)&&is(t,i,e[i]);if(zt)for(var i of zt(e))dr.call(e,i)&&is(t,i,e[i]);return t},xe=(t,e)=>Io(t,Ho(e));var ur=(t,e)=>{var i={};for(var s in t)cr.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(t!=null&&zt)for(var s of zt(t))e.indexOf(s)<0&&dr.call(t,s)&&(i[s]=t[s]);return i};var ss=(t,e,i)=>(is(t,typeof e!="symbol"?e+"":e,i),i);var R=(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 He=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 fr="layer";function pr(t,e){document.dispatchEvent(new CustomEvent("doofinder.register",{detail:{name:t,entrypoint:e}}))}var Tt=t=>typeof t=="function"?t:function(){return t},Do=typeof self!="undefined"?self:null,kt=typeof window!="undefined"?window:null,Ke=Do||kt||Ke,Oo="2.0.0",Te={connecting:0,open:1,closing:2,closed:3},Mo=1e4,No=1e3,fe={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},De={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},rs={longpoll:"longpoll",websocket:"websocket"},Fo={complete:4},Kt=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})}},mr=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))}},$o=class{constructor(t,e,i){this.state=fe.closed,this.topic=t,this.params=Tt(e||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Kt(this,De.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new mr(()=>{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=fe.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=fe.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=fe.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=fe.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 Kt(this,De.leave,Tt({}),this.timeout).send(),this.state=fe.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(De.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(De.close,t)}onError(t){return this.on(De.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 Kt(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=fe.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(De.close,"leave")},i=new Kt(this,De.leave,Tt({}),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=fe.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===Fo.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)}`}},Uo=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("(.*)/"+rs.websocket),"$1/"+rs.longpoll)}endpointURL(){return Yt.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,i){this.close(t,e,i),this.readyState=Te.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Te.open||this.readyState===Te.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=Te.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=Uo(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=Te.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=Yt.request(t,this.endpointURL(),e,i,this.timeout,o,a=>{this.reqs.delete(n),this.isActive()&&r(a)}),this.reqs.add(n)}};var Gt={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 w=t.slice(a,t.byteLength),_={status:m,response:w};return{join_ref:l,ref:c,topic:f,event:De.reply,payload:_}},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}}},gr=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=e.timeout||Mo,this.transport=e.transport||Ke.WebSocket||Pt,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=e.sessionStorage||Ke&&Ke.sessionStorage,this.establishedConnections=0,this.defaultEncoder=Gt.encode.bind(Gt),this.defaultDecoder=Gt.decode.bind(Gt),this.closeWasClean=!1,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.transport!==Pt?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;kt&&kt.addEventListener&&(kt.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),kt.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=Tt(e.params||{}),this.endPoint=`${t}/${rs.websocket}`,this.vsn=e.vsn||Oo,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new mr(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return Pt}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=Yt.appendParams(Yt.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.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,i)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Tt(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==Pt?this.connectWithFallback(Pt,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.disconnecting=!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(),No,"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();let s=this.connectClock;this.waitForBufferDone(()=>{s===this.connectClock&&(this.conn&&(e?this.conn.close(e,i||""):this.conn.close()),this.waitForSocketClosed(()=>{s===this.connectClock&&(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===Te.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(De.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case Te.connecting:return"connecting";case Te.open:return"open";case Te.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 $o(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 _r=(t,e,i)=>{e.forEach(s=>{t.addEventListener(s,i)})},vr=(t,e,i)=>{e.forEach(s=>{t.removeEventListener(s,i)})},ns=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),_r(window,this.settings.events,this.idlenessEventsHandler),(this.settings.onShow||this.settings.onHide)&&_r(document,this.visibilityEvents,this.visibilityEventsHandler),this}stop(){return window.removeEventListener("idle:stop",this.stopListener),vr(window,this.settings.events,this.idlenessEventsHandler),this.resetTimeout(this.settings,!1),(this.settings.onShow||this.settings.onHide)&&vr(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 os=class extends gr{constructor(e,i={}){super(e,i);this.preventReconnect=!1,this.shouldReconnect=!1,this.idleMonitor=new ns({idle:3*60*1e3,onActive:this.onShowOrActive.bind(this),onShow:this.onShowOrActive.bind(this)}),this.idleMonitor.start()}isIdle(){return this.idleMonitor.idle}onShowOrActive(){if(!this.idleMonitor.visible||this.idleMonitor.idle)return;let e=!this.isConnected()&&this.connectionState()!=="connecting";e&&this.connect(),(this.shouldReconnect||e)&&(this.shouldReconnect=!1,this.reconnectTimer.scheduleTimeout())}onConnClose(e){let i=e&&e.code===1001&&e.wasClean&&e.type==="close";this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),this.preventReconnect||(!this.closeWasClean&&!i?this.scheduleReconnect():this.idleMonitor.stop()),this.stateChangeCallbacks.close.forEach(([,s])=>s(e))}scheduleReconnect(){!this.idleMonitor.idle&&this.idleMonitor.visible?this.reconnectTimer.scheduleTimeout():(this.reconnectTimer.reset(),this.shouldReconnect=!0)}};var X="search",Zt="consecutive-reloads",br=10,yr=5e3,Sr=1e4,Er=3e4,Qt=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],pe="data-phx-component";var wr="track-static";var le="data-phx-ref",ke="data-phx-ref-src",ei="track-uploads",me="data-phx-upload-ref",ht="data-phx-preflighted-refs",Ar="data-phx-done-refs",as="drop-target",Lt="data-phx-active-refs",ct=`${X}:live-file:updated`,ti="data-phx-skip",ii="data-phx-id",ls="data-phx-prune",hs="page-loading",cs="phx-connected",dt="phx-loading",Rt="phx-no-feedback",It="phx-error",ds="phx-client-error",si="phx-server-error",Ye="data-phx-parent-id",ri="data-phx-main",Pe="data-dfd-root-id",ni="viewport-top",oi="viewport-bottom",Cr="trigger-action",Ge="feedback-for",Ze="feedback-group",Ht="phx-has-focused",xr=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],ai=["checkbox","radio"],ut="phx-has-submitted",_e="data-dfd-view",Oe=`[${_e}]`,us="data-phx-sticky",Ue="data-phx-static",li="data-phx-readonly",Qe="data-phx-disabled",Dt="disable-with",Ot="data-phx-disable-with-restore",ft="hook",Tr="debounce",kr="throttle",pt="update",hi="stream",ci="data-phx-stream",Pr="key",Ee="phxPrivate",fs="auto-recover",Mt="phx:live-socket:debug",di="phx:live-socket:profiling",ui="phx:live-socket:latency-sim",Lr="progress",ps="mounted",Rr=1,Ir=200,Hr="dfd-",Dr=3e4;var mt="debounce-trigger",gt="throttled",ms="debounce-prev-key",Or={debounce:300,throttle:300},Nt="d",we="s",fi="r",he="c",gs="e",_s="r",vs="t",Mr="p",bs="stream";var pi=class{constructor(e,i,s){this.liveSocket=s,this.entry=e,this.offset=0,this.chunkSize=i,this.chunkTimer=null,this.errored=!1,this.uploadChannel=s.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(e))}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,i=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=s=>{if(s.target.error===null)this.offset+=s.target.result.byteLength,this.pushChunk(s.target.result);else return se("Read error: "+s.target.error)},e.readAsArrayBuffer(i)}pushChunk(e){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))}).receive("error",({reason:i})=>this.error(i))}};var se=(t,e)=>console.error&&console.error(t,e),ve=t=>{let e=typeof t;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(t)};function Nr(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)},mi=t=>typeof t=="function"?t:function(){return t},_t=t=>JSON.parse(JSON.stringify(t)),vt=(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(Oe)));return null},et=t=>t!==null&&typeof t=="object"&&!(t instanceof Array),$r=(t,e)=>JSON.stringify(t)===JSON.stringify(e),ys=t=>{for(let e in t)return!1;return!0},Ae=(t,e)=>t&&e(t),Ur=function(t,e,i,s){t.forEach(r=>{new pi(r,i.config.chunk_size,s).upload()})};var Vr={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&&Vr.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}"]`)}},Le=Vr;var Vo={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}}},Ve=Vo;var gi=null,jr=200,jo={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:w,callback:_}=n,S={loading:f,value:m,target:l,page_loading:!!c},E=t==="change"&&w?w:s,P=l||E.getAttribute(i.binding("target"))||E;i.withinTargets(P,(F,I)=>{if(!!F.isConnected())if(t==="change"){let{newCid:U,_target:$}=n;$=$||(p.isFormInput(s)?s.name:void 0),$&&(S._target=$),F.pushInput(s,I,U,o||e,S,_)}else if(t==="submit"){let{submitter:U}=n;F.submitForm(s,I,o||e,U,S,_)}else F.pushEvent(t,s,I,o||e,a,S,_)})},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(()=>Ve.attemptFocus(r))},exec_focus_first(t,e,i,s,r){window.requestAnimationFrame(()=>Ve.focusFirstInteractive(r)||Ve.focusFirst(r))},exec_push_focus(t,e,i,s,r){window.requestAnimationFrame(()=>gi=r||s)},exec_pop_focus(t,e,i,s,r){window.requestAnimationFrame(()=>{gi&&gi.focus(),gi=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||jr;let[a,l,c]=r||[[],[],[]],[f,m,w]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(i)){let _=()=>{this.addOrRemoveClasses(i,m,a.concat(l).concat(c)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,w,m))})};i.dispatchEvent(new Event(`${X}:hide-start`)),e.transition(o,_,()=>{this.addOrRemoveClasses(i,[],f.concat(w)),p.putSticky(i,"toggle",S=>S.style.display="none"),i.dispatchEvent(new Event(`${X}:hide-end`))})}else{if(t==="remove")return;let _=()=>{this.addOrRemoveClasses(i,l,f.concat(m).concat(w));let S=s||this.defaultDisplay(i);p.putSticky(i,"toggle",E=>E.style.display=S),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,c,l))})};i.dispatchEvent(new Event(`${X}:show-start`)),e.transition(o,_,()=>{this.addOrRemoveClasses(i,[],a.concat(c)),i.dispatchEvent(new Event(`${X}:show-end`))})}else this.isVisible(i)?window.requestAnimationFrame(()=>{i.dispatchEvent(new Event(`${X}:hide-start`)),p.putSticky(i,"toggle",_=>_.style.display="none"),i.dispatchEvent(new Event(`${X}:hide-end`))}):window.requestAnimationFrame(()=>{i.dispatchEvent(new Event(`${X}:show-start`));let _=s||this.defaultDisplay(i);p.putSticky(i,"toggle",S=>S.style.display=_),i.dispatchEvent(new Event(`${X}: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||jr;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(E=>c.indexOf(E)<0&&!t.classList.contains(E)),w=i.filter(E=>f.indexOf(E)<0&&t.classList.contains(E)),_=c.filter(E=>i.indexOf(E)<0).concat(m),S=f.filter(E=>e.indexOf(E)<0).concat(w);p.putSticky(t,"classes",E=>(E.classList.remove(...S),E.classList.add(..._),[_,S]))})},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"}},te=jo;var be={byId(t){return document.getElementById(t)||se(`no id found for ${t}`)},removeClass(t,e){t.classList.remove(e),t.classList.length===0&&t.removeAttribute("class")},all(t,e,i){if(!t)return[];let s=Array.from(t.querySelectorAll(e));return i?s.forEach(i):s},childNodeLength(t){let e=document.createElement("template");return e.innerHTML=t,e.content.childElementCount},isUploadInput(t){return t.type==="file"&&t.getAttribute(me)!==null},isAutoUpload(t){return t.hasAttribute("data-phx-auto-upload")},findUploadInputs(t){let e=t.id,i=this.all(document,`input[type="file"][${me}][form="${e}"]`);return this.all(t,`input[type="file"][${me}]`).concat(i)},findComponentNodeList(t,e){return this.filterWithinSameLiveView(this.all(t,`[${pe}="${e}"]`),t)},isPhxDestroyed(t){return!!(t.id&&be.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(_e,""),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,`[${us}]`)},findPhxChildren(t,e){return this.all(t,`${Oe}[${Ye}="${e}"]`)},findParentCIDs(t,e){let i=new Set(e),s=e.reduce((r,n)=>{let o=`[${pe}="${n}"] [${pe}]`;return this.filterWithinSameLiveView(this.all(t,o),t).map(a=>parseInt(a.getAttribute(pe))).forEach(a=>r.delete(a)),r},i);return s.size===0?new Set(e):s},filterWithinSameLiveView(t,e){return e.querySelector(Oe)?t.filter(i=>this.withinSameLiveView(i,e)):t},withinSameLiveView(t,e){for(;t=t.parentNode;){if(t.isSameNode(e))return!0;if(t.getAttribute(_e)!==null)return!1}},private(t,e){return t[Ee]&&t[Ee][e]},deletePrivate(t,e){t[Ee]&&delete t[Ee][e]},putPrivate(t,e,i){t[Ee]||(t[Ee]={}),t[Ee][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[Ee]&&(t[Ee]=e[Ee])},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),w=()=>c?this.deletePrivate(t,gt):a(),_=this.incCycle(t,mt,w);if(isNaN(m))return se(`invalid throttle/debounce value: ${f}`);if(c){let E=!1;if(e.type==="keydown"){let P=this.private(t,ms);this.putPrivate(t,ms,e.key),E=P!==e.key}if(!E&&this.private(t,gt))return!1;{a();let P=setTimeout(()=>{o()&&this.triggerCycle(t,mt)},m);this.putPrivate(t,gt,P)}}else setTimeout(()=>{o()&&this.triggerCycle(t,mt,_)},m);let S=t.form;S&&this.once(S,"bind-debounce")&&S.addEventListener("submit",()=>{Array.from(new FormData(S).entries(),([E])=>{let P=S.querySelector(`[name="${E}"]`);this.incCycle(P,mt),this.deletePrivate(P,gt)})}),this.once(t,"bind-debounce")&&t.addEventListener("blur",()=>{clearTimeout(this.private(t,gt)),this.triggerCycle(t,mt)})}},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){te.addOrRemoveClasses(n,[],[Rt]);return}if(r[o]===!0){this.hideFeedback(n);return}r[o]=this.shouldHideFeedback(t,o,s),r[o]===!0&&this.hideFeedback(n)})},hideFeedback(t){te.addOrRemoveClasses(t,[Rt],[])},shouldHideFeedback(t,e,i){let s=`[name="${e}"], [name="${e}[]"], [${i}="${e}"]`,r=!1;return be.all(t,s,n=>{(this.private(n,Ht)||this.private(n,ut))&&(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,Ht),this.deletePrivate(s,ut),this.all(document,r,n=>{te.addOrRemoveClasses(n,[Rt],[])})})},showError(t,e,i){if(t.name){let s=this.feedbackSelector(t,e,i);this.all(document,s,r=>{te.addOrRemoveClasses(r,[],[Rt])})}},isPhxChild(t){return t.getAttribute&&t.getAttribute(Ye)},isPhxSticky(t){return t.getAttribute&&t.getAttribute(us)!==null},isChildOfAny(t,e){return!!e.find(i=>i.contains(t))},firstPhxChild(t){return this.isPhxChild(t)?t:this.all(t,`[${Ye}]`)[0]},dispatchEvent(t,e,i={}){let s=!0;t.nodeName==="INPUT"&&t.type==="file"&&e==="click"&&(s=!1);let o={bubbles:i.bubbles===void 0?s:!!i.bubbles,cancelable:!0,detail:i.detail||{}},a=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);t.dispatchEvent(a)},cloneNode(t,e){if(typeof e=="undefined")return t.cloneNode(!0);{let i=t.cloneNode(!1);return i.innerHTML=e,i}},mergeAttrs(t,e,i={}){let s=new Set(i.exclude||[]),r=i.isIgnored,n=e.attributes;for(let a=n.length-1;a>=0;a--){let l=n[a].name;if(s.has(l))l==="value"&&t.value===e.value&&t.setAttribute("value",e.getAttribute(l));else{let c=e.getAttribute(l);t.getAttribute(l)!==c&&(!r||r&&l.startsWith("data-"))&&t.setAttribute(l,c)}}let o=t.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;r?l.startsWith("data-")&&!e.hasAttribute(l)&&![le,ke].includes(l)&&t.removeAttribute(l):e.hasAttribute(l)||t.removeAttribute(l)}},mergeFocusedInput(t,e){t instanceof HTMLSelectElement||be.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(),!be.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&&ai.indexOf(t.type.toLocaleLowerCase())>=0&&(t.checked=t.getAttribute("checked")!==null)},isTextualInput(t){return xr.indexOf(t.type)>=0},isNowTriggerFormExternal(t,e){return t.getAttribute&&t.getAttribute(e)!==null},syncPendingRef(t,e,i){let s=t.getAttribute(le);if(s===null)return!0;let r=t.getAttribute(ke);return be.isFormInput(t)||t.getAttribute(i)!==null?(be.isUploadInput(t)&&be.mergeAttrs(t,e,{isIgnored:!0}),be.putPrivate(t,le,e),!1):(Qt.forEach(n=>{t.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(le,s),e.setAttribute(ke,r),!0)},cleanChildNodes(t,e){if(be.isPhxUpdate(t,e,["append","prepend"])){let i=[];t.childNodes.forEach(s=>{s.id||(!(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()==="")&&s.nodeType!==s.COMMENT_NODE&&se(`only HTML element tags with an id are allowed inside containers with phx-update. removing illegal node: "${(s.outerHTML||s.nodeValue).trim()}" `),i.push(s))}),i.forEach(s=>s.remove())}},replaceRootContainer(t,e,i){let s=new Set(["id",_e,Ue,ri,Pe]);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=(be.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=be.private(t,"sticky");!e||e.forEach(([i,s,r])=>this.putSticky(t,i,s))}},p=be;var Re=class{static isActive(e,i){let s=i._phxRef===void 0,r=Re.isPreflightInProgress(i),o=e.getAttribute(Lt).split(",").indexOf(W.genFileRef(i))>=0;return i.size>0&&(s||o||!r)}static isPreflighted(e,i){return e.getAttribute(ht).split(",").indexOf(W.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=W.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(ct,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,()=>{W.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(ct,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),p.isAutoUpload(this.fileEl)||W.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(ct,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Lt).split(",").indexOf(this.ref)===-1&&this.cancel()}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let i=e[this.meta.uploader]||se(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:i}}else return{name:"channel",callback:Ur}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||se(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Bo=0,W=class{static genFileRef(e){let i=e._phxRef;return i!==void 0?i:(e._phxRef=(Bo++).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(ht)!==s.getAttribute(Ar)&&i++}),i>0}static serializeUploads(e){let i=this.activeFiles(e),s={};return i.forEach(r=>{let n={path:e.name},o=e.getAttribute(me);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(me),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=>Re.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=>!Re.isPreflighted(e,i)&&!Re.isPreflightInProgress(i))}static markPreflightInProgress(e){e.forEach(i=>Re.markPreflightInProgress(i.file))}constructor(e,i,s){this.view=i,this.onComplete=s,this._entries=Array.from(W.filesAwaitingPreflight(e)||[]).map(r=>new Re(e,r,i)),W.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(Lt)},preflightedRefs(){return this.el.getAttribute(ht)},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(ct))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(me)),W.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",()=>Ve.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>Ve.focusFirst(this.el)),this.el.addEventListener(`${X}:show-end`,()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&Ve.focusFirst(this.el)}}},Br=Xo;var _i=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?Ae(document.getElementById(i.previousElementId),s=>{Ae(document.getElementById(i.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==s.id||s.insertAdjacentElement("afterend",r)})}):Ae(document.getElementById(i.elementId),s=>{s.previousElementSibling==null||e.insertAdjacentElement("afterbegin",s)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(i=>{Ae(document.getElementById(i),s=>e.insertAdjacentElement("afterbegin",s))})}};var Xr=11;function qo(t,e){var i=e.attributes,s,r,n,o,a;if(!(e.nodeType===Xr||t.nodeType===Xr)){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 vi,Jo="http://www.w3.org/1999/xhtml",ue=typeof document=="undefined"?void 0:document,Wo=!!ue&&"content"in ue.createElement("template"),zo=!!ue&&ue.createRange&&"createContextualFragment"in ue.createRange();function Ko(t){var e=ue.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function Yo(t){vi||(vi=ue.createRange(),vi.selectNode(ue.body));var e=vi.createContextualFragment(t);return e.childNodes[0]}function Go(t){var e=ue.createElement("body");return e.innerHTML=t,e.childNodes[0]}function Zo(t){return t=t.trim(),Wo?Ko(t):zo?Yo(t):Go(t)}function bi(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 Qo(t,e){return!e||e===Jo?ue.createElement(t):ue.createElementNS(e,t)}function ea(t,e){for(var i=t.firstChild;i;){var s=i.nextSibling;e.appendChild(i),i=s}return e}function Ss(t,e,i){t[i]!==e[i]&&(t[i]=e[i],t[i]?t.setAttribute(i,""):t.removeAttribute(i))}var qr={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)}Ss(t,e,"selected")},INPUT:function(t,e){Ss(t,e,"checked"),Ss(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}}},Ft=1,Jr=11,Wr=3,zr=8;function je(){}function ta(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}function ia(t){return function(i,s,r){if(r||(r={}),typeof s=="string")if(i.nodeName==="#document"||i.nodeName==="HTML"||i.nodeName==="BODY"){var n=s;s=ue.createElement("html"),s.innerHTML=n}else s=Zo(s);else s.nodeType===Jr&&(s=s.firstElementChild);var o=r.getNodeKey||ta,a=r.onBeforeNodeAdded||je,l=r.onNodeAdded||je,c=r.onBeforeElUpdated||je,f=r.onElUpdated||je,m=r.onBeforeNodeDiscarded||je,w=r.onNodeDiscarded||je,_=r.onBeforeElChildrenUpdated||je,S=r.skipFromChildren||je,E=r.addChild||function(L,k){return L.appendChild(k)},P=r.childrenOnly===!0,F=Object.create(null),I=[];function U(L){I.push(L)}function $(L,k){if(L.nodeType===Ft)for(var J=L.firstChild;J;){var O=void 0;k&&(O=o(J))?U(O):(w(J),J.firstChild&&$(J,k)),J=J.nextSibling}}function q(L,k,J){m(L)!==!1&&(k&&k.removeChild(L),w(L),$(L,J))}function Z(L){if(L.nodeType===Ft||L.nodeType===Jr)for(var k=L.firstChild;k;){var J=o(k);J&&(F[J]=k),Z(k),k=k.nextSibling}}Z(i);function V(L){l(L);for(var k=L.firstChild;k;){var J=k.nextSibling,O=o(k);if(O){var M=F[O];M&&bi(k,M)?(k.parentNode.replaceChild(M,k),g(M,k)):V(k)}else V(k);k=J}}function Y(L,k,J){for(;k;){var O=k.nextSibling;(J=o(k))?U(J):q(k,L,!0),k=O}}function g(L,k,J){var O=o(k);if(O&&delete F[O],!J){var M=c(L,k);if(M===!1||(M instanceof HTMLElement&&(L=M,Z(L)),t(L,k),f(L),_(L,k)===!1))return}L.nodeName!=="TEXTAREA"?T(L,k):qr.TEXTAREA(L,k)}function T(L,k){var J=S(L,k),O=k.firstChild,M=L.firstChild,Ie,Se,Fe,$e,ge;e:for(;O;){for($e=O.nextSibling,Ie=o(O);!J&&M;){if(Fe=M.nextSibling,O.isSameNode&&O.isSameNode(M)){O=$e,M=Fe;continue e}Se=o(M);var We=M.nodeType,oe=void 0;if(We===O.nodeType&&(We===Ft?(Ie?Ie!==Se&&((ge=F[Ie])?Fe===ge?oe=!1:(L.insertBefore(ge,M),Se?U(Se):q(M,L,!0),M=ge,Se=o(M)):oe=!1):Se&&(oe=!1),oe=oe!==!1&&bi(M,O),oe&&g(M,O)):(We===Wr||We==zr)&&(oe=!0,M.nodeValue!==O.nodeValue&&(M.nodeValue=O.nodeValue))),oe){O=$e,M=Fe;continue e}Se?U(Se):q(M,L,!0),M=Fe}if(Ie&&(ge=F[Ie])&&bi(ge,O))J||E(L,ge),g(ge,O);else{var wt=a(O);wt!==!1&&(wt&&(O=wt),O.actualize&&(O=O.actualize(L.ownerDocument||ue)),E(L,O),V(O))}O=$e,M=Fe}Y(L,M,Se);var At=qr[L.nodeName];At&&At(L,k)}var D=i,G=D.nodeType,ye=s.nodeType;if(!P){if(G===Ft)ye===Ft?bi(i,s)||(w(i),D=ea(i,Qo(s.nodeName,s.namespaceURI))):D=s;else if(G===Wr||G===zr){if(ye===G)return D.nodeValue!==s.nodeValue&&(D.nodeValue=s.nodeValue),D;D=s}}if(D===s)w(i);else{if(s.isSameNode&&s.isSameNode(D))return;if(g(D,s,P),I)for(var lt=0,St=I.length;lt{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=ve(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(pt);p.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,i=>{i.setAttribute(ls,"")})}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(pt),m=s.binding(Ge),w=s.binding(Ze),_=s.binding(Dt),S=s.binding(ni),E=s.binding(oi),P=s.binding(Cr),F=[],I=[],U=[],$=[],q=null;function Z(V,Y){Es(V,Y,{childrenOnly:V.getAttribute(pe)===null,getNodeKey:g=>p.isPhxDestroyed(g)?null:e?g.id:g.id||g.getAttribute&&g.getAttribute(ii),skipFromChildren:g=>g.getAttribute(f)===hi,addChild:(g,T)=>{let{ref:D,streamAt:G}=this.getStreamInsert(T);if(D===void 0)return g.appendChild(T);if(this.setStreamRef(T,D),G===0)g.insertAdjacentElement("afterbegin",T);else if(G===-1)g.appendChild(T);else if(G>0){let ye=Array.from(g.children)[G];g.insertBefore(T,ye)}},onBeforeNodeAdded:g=>{this.trackBefore("added",g);let T=g;return!e&&this.streamComponentRestore[g.id]&&(T=this.streamComponentRestore[g.id],delete this.streamComponentRestore[g.id],Z.bind(this)(T,g)),T},onNodeAdded:g=>{g.getAttribute&&this.maybeReOrderStream(g,!0),p.isFeedbackContainer(g,m)&&I.push(g),g instanceof HTMLImageElement&&g.srcset?g.srcset=g.srcset:g instanceof HTMLVideoElement&&g.autoplay&&g.play(),p.isNowTriggerFormExternal(g,P)&&(q=g),(p.isPhxChild(g)&&i.ownsElement(g)||p.isPhxSticky(g)&&i.ownsElement(g.parentNode))&&this.trackAfter("phxChildAdded",g),F.push(g)},onNodeDiscarded:g=>this.onNodeDiscarded(g),onBeforeNodeDiscarded:g=>g.getAttribute&&g.getAttribute(ls)!==null?!0:!(g.parentElement!==null&&g.id&&p.isPhxUpdate(g.parentElement,f,[hi,"append","prepend"])||this.maybePendingRemove(g)||this.skipCIDSibling(g)),onElUpdated:g=>{p.isNowTriggerFormExternal(g,P)&&(q=g),U.push(g),this.maybeReOrderStream(g,!1)},onBeforeElUpdated:(g,T)=>{if((p.isFeedbackContainer(g,m)||p.isFeedbackContainer(T,m))&&(I.push(g),I.push(T)),p.cleanChildNodes(T,f),this.skipCIDSibling(T))return this.maybeReOrderStream(g),!1;if(p.isPhxSticky(g))return!1;if(p.isIgnored(g,f)||g.form&&g.form.isSameNode(q))return this.trackBefore("updated",g,T),p.mergeAttrs(g,T,{isIgnored:!0}),U.push(g),p.applyStickyOperations(g),!1;if(g.type==="number"&&g.validity&&g.validity.badInput)return!1;if(!p.syncPendingRef(g,T,_))return p.isUploadInput(g)&&(this.trackBefore("updated",g,T),U.push(g)),p.applyStickyOperations(g),!1;if(p.isPhxChild(T)){let ye=g.getAttribute(_e);return p.mergeAttrs(g,T,{exclude:[Ue]}),ye!==""&&g.setAttribute(_e,ye),g.setAttribute(Pe,this.rootID),p.applyStickyOperations(g),!1}p.copyPrivates(T,g);let D=a&&g.isSameNode(a)&&p.isFormInput(g),G=D&&this.isChangedSelect(g,T);return D&&g.type!=="hidden"&&!G?(this.trackBefore("updated",g,T),p.mergeFocusedInput(g,T),p.syncAttrsToProps(g),U.push(g),p.applyStickyOperations(g),!1):(G&&g.blur(),p.isPhxUpdate(T,f,["append","prepend"])&&$.push(new _i(g,T,T.getAttribute(f))),p.syncAttrsToProps(T),p.applyStickyOperations(T),this.trackBefore("updated",g,T),!0)}})}return this.trackBefore("added",r),this.trackBefore("updated",r,r),s.time("morphdom",()=>{this.streams.forEach(([V,Y,g,T])=>{Y.forEach(([D,G,ye])=>{this.streamInserts[D]={ref:V,streamAt:G,limit:ye,reset:T}}),T!==void 0&&p.all(r,`[${ci}="${V}"]`,D=>{this.removeStreamChildElement(D)}),g.forEach(D=>{let G=r.querySelector(`[id="${D}"]`);G&&this.removeStreamChildElement(G)})}),e&&p.all(this.container,`[${f}=${hi}]`,V=>{this.liveSocket.owner(V,Y=>{Y===this.view&&Array.from(V.children).forEach(g=>{this.removeStreamChildElement(g)})})}),Z.bind(this)(o,n)}),s.isDebugEnabled()&&Nr(s.doofinderMount),$.length>0&&s.time("post-morph append/prepend restoration",()=>{$.forEach(V=>V.perform())}),p.maybeHideFeedback(o,I,m,w),s.silenceEvents(()=>p.restoreFocus(a,l,c)),p.dispatchEvent(document,`${X}:update`),F.forEach(V=>this.trackAfter("added",V)),U.forEach(V=>this.trackAfter("updated",V)),this.transitionPendingRemoves(),q&&(s.unload(),Object.getPrototypeOf(q).submit.call(q)),!0}onNodeDiscarded(e){(p.isPhxChild(e)||p.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e){this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,i){p.putSticky(e,ci,s=>s.setAttribute(ci,i))}maybeReOrderStream(e,i){let{ref:s,streamAt:r,reset:n}=this.getStreamInsert(e);if(r!==void 0&&(this.setStreamRef(e,s),!(!n&&!i)&&!!e.parentElement)){if(r===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(r>0){let o=Array.from(e.parentElement.children),a=o.indexOf(e);if(r>=o.length-1)e.parentElement.appendChild(e);else{let l=o[r];a>r?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:i}=this.getStreamInsert(e),s=i!==null&&Array.from(e.parentElement.children);i&&i<0&&s.length>i*-1?s.slice(0,s.length+i).forEach(r=>this.removeStreamChildElement(r)):i&&i>=0&&s.length>i&&s.slice(i).forEach(r=>this.removeStreamChildElement(r))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:i}=this;e.length>0&&(i.transitionRemoves(e),i.requestDOMUpdate(()=>{e.forEach(s=>{let r=p.firstPhxChild(s);r&&i.destroyViewByEl(r),s.remove()}),this.trackAfter("transitionsDiscarded",e)}))}isChangedSelect(e,i){if(!(e instanceof HTMLSelectElement)||e.multiple)return!1;if(e.options.length!==i.options.length)return!0;let s=e.selectedOptions[0],r=i.selectedOptions[0];return s&&s.hasAttribute("selected")&&r.setAttribute("selected",s.getAttribute("selected")),!e.isEqualNode(i)}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(ti)}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 ra=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),na=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 S=t.slice(s-3,s)===" id";s++;let E=t.charAt(s);if(na.has(E)){let P=s;for(s++,s;s=n.length+a.length;){let S=t.charAt(w);if(r)S==="-"&&t.slice(w-3,w)===""&&t.slice(w-2,w)==="--")r=!0,w-=3;else{if(S===">")break;w-=1}}o=t.slice(w+1,t.length);let _=Object.keys(e).map(S=>e[S]===!0?S:`${S}="${e[S]}"`).join(" ");if(i){let S=c?` id="${c}"`:"";ra.has(a)?f=`<${a}${S}${_===""?"":" "}${_}/>`:f=`<${a}${S}${_===""?"":" "}${_}>`}else{let S=t.slice(l,w+1);f=`<${a}${_===""?"":" "}${_}${S}`}return[f,n,o]},$t=class{static extract(e){let{[_s]:i,[gs]:s,[vs]:r}=e;return delete e[_s],delete e[gs],delete e[vs],{diff:e,title:r,reply:i||null,events:s||[]}}constructor(e,i){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(i)}parentViewId(){return this.viewId}toString(e){let[i,s]=this.recursiveToString(this.rendered,this.rendered[he],e,!0,{});return[i,s]}recursiveToString(e,i=e[he],s,r,n){s=s?new Set(s):null;let o={buffer:"",components:i,onlyCids:s,streams:new Set};return this.toOutputBuffer(e,null,o,r,n),[o.buffer,o.streams]}componentCIDs(e){return Object.keys(e[he]||{}).map(i=>parseInt(i))}isComponentOnlyDiff(e){return e[he]?Object.keys(e).length===1:!1}getComponent(e,i){return e[he][i]}resetRender(e){this.rendered[he][e]&&(this.rendered[he][e].reset=!0)}mergeDiff(e){let i=e[he],s={};if(delete e[he],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[he]=this.rendered[he]||{},i){let r=this.rendered[he];for(let n in i)i[n]=this.cachedFindComponent(n,i[n],r,i,s);for(let n in i)r[n]=i[n];e[he]=i}}cachedFindComponent(e,i,s,r,n){if(n[e])return n[e];{let o,a,l=i[we];if(ve(l)){let c;l>0?c=this.cachedFindComponent(l,r[l],s,r,n):c=s[-l],a=c[we],o=this.cloneMerge(c,i,!0),o[we]=a}else o=i[we]!==void 0||s[e]===void 0?i:this.cloneMerge(s[e],i,!1);return n[e]=o,o}}mutableMerge(e,i){return i[we]!==void 0?i:(this.doMutableMerge(e,i),e)}doMutableMerge(e,i){for(let s in i){let r=i[s],n=e[s];et(r)&&r[we]===void 0&&et(n)?this.doMutableMerge(n,r):e[s]=r}e[fi]&&(e.newRender=!0)}cloneMerge(e,i,s){let r=H(H({},e),i);for(let n in r){let o=i[n],a=e[n];et(o)&&o[we]===void 0&&et(a)?r[n]=this.cloneMerge(a,o,s):o===void 0&&et(a)&&(r[n]=this.cloneMerge(a,{},s))}return s?(delete r.magicId,delete r.newRender):e[fi]&&(r.newRender=!0),r}componentToString(e){let[i,s]=this.recursiveCIDToString(this.rendered[he],e,null),[r,n,o]=Kr(i,{});return[r,s]}pruneCIDs(e){e.forEach(i=>delete this.rendered[he][i])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[we]}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[Nt])return this.comprehensionToBuffer(e,i,s);let{[we]:o}=e;o=this.templateStatic(o,i);let a=e[fi],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[bs],e[Nt]=[],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 et(e)?this.toOutputBuffer(e,i,s,r,{}):s.buffer+=e}recursiveCIDToString(e,i,s){let r=e[i]||se(`no component for CID ${i}`,e),n={[pe]: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 oa=1,Be=class{static makeID(){return oa++}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(`${X}:${e}`,s),this.__listeners.add(s),s}removeHandleEvent(e){let i=e(null,!0);this.liveSocket.doofinderMount.removeEventListener(`${X}:${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 yi=(t,e,i=[])=>{let c=e,{submitter:s}=c,r=ur(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,w)=>{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()},bt=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(ri)}connectParams(e){let i=this.liveSocket.params(this.el),s=p.all(document,`[${this.binding(wr)}]`).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(_e)}getStatic(){let e=this.el.getAttribute(Ue);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(cs,dt,It,ds,si),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(dt)}}execAll(e){p.all(this.el,`[${e}]`,i=>this.liveSocket.execJS(i,i.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(cs),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(ve(e))p.findComponentNodeList(this.el,e).length===0?se(`no component found matching phx-target of ${e}`):i(this,parseInt(e));else{let s=Array.from(document.querySelectorAll(e));s.length===0&&se(`nothing found matching the phx-target selector "${e}"`),s.forEach(r=>this.liveSocket.owner(r,n=>i(n,r)))}}applyDiff(e,i,s){this.log(e,()=>["",_t(i)]);let{diff:r,reply:n,events:o,title:a}=$t.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,Le.dropLocal(this.liveSocket.localStorage,window.location.pathname,Zt),this.applyDiff("mount",i,({diff:r,events:n})=>{this.rendered=new $t(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],w)=>{this.pushFormRecovery(c,m,_=>{w===l.length-1&&this.onJoinComplete(_,o,a,n)})}):this.onJoinComplete(e,o,a,n)})}dropPendingRefs(){p.all(document,`[${ke}="${this.id}"][${le}]`,e=>{e.removeAttribute(le),e.removeAttribute(ke)})}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(Ue);return l&&o.setAttribute(Ue,l),a&&a.setAttribute(Pe,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(Pe,this.root.id)}execNewMounted(){let e=this.binding(ni),i=this.binding(oi);p.all(this.el,`[${e}], [${i}]`,s=>{this.maybeAddNewHook(s)}),p.all(this.el,`[${this.binding(ft)}], [data-phx-${ft}]`,s=>{this.maybeAddNewHook(s)}),p.all(this.el,`[${this.binding(ps)}]`,s=>this.maybeMounted(s))}applyJoinPatch(e,i,s,r){this.attachTrueDocEl();let n=new tt(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(pt));if(s&&!e.isEqualNode(i)&&!(r&&$r(e.dataset,i.dataset)))return s.__beforeUpdate(),s}maybeMounted(e){let i=e.getAttribute(this.binding(ps)),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,`[${pe}]`),o=p.all(r,`[${this.binding(ft)}]`);n.concat(r).forEach(a=>{let l=this.componentID(a);ve(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(Ye)][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 bt(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)})}):ys(e)||this.liveSocket.time("full patch complete",()=>{let[r,n]=this.renderContainer(e,"update"),o=new tt(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(ys(e))return!1;let[s,r]=this.rendered.componentToString(i),n=new tt(this,this.el,this.id,s,r,i);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[Be.elementID(e)]}addHook(e){if(Be.elementID(e)||!e.getAttribute)return;let i=e.getAttribute(`data-phx-${ft}`)||e.getAttribute(this.binding(ft));if(i&&!this.ownsElement(e))return;let s=this.liveSocket.getHookCallbacks(i);if(s){e.id||se(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);let r=new Be(this,e,s);return this.viewHooks[Be.elementID(r.el)]=r,r}else i!==null&&se(`unknown hook found for "${i}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[Be.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([dt,It,si]),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(Ir)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([dt,It,si]):this.displayError([dt,It,ds]))}displayError(e){this.isMain()&&p.dispatchEvent(window,`${X}: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(hs))!==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:w,events:_})=>{n!==null&&this.undoRefs(n),this.update(m,_),f(w)})}):(n!==null&&this.undoRefs(n),f(null))}))}undoRefs(e){!this.isConnected()||p.all(document,`[${ke}="${this.id}"][${le}="${e}"]`,i=>{let s=i.getAttribute(Qe),r=i.getAttribute(li);i.removeAttribute(le),i.removeAttribute(ke),r!==null&&(i.readOnly=r==="true",i.removeAttribute(li)),s!==null&&(i.disabled=s==="true",i.removeAttribute(Qe)),Qt.forEach(a=>p.removeClass(i,a));let n=i.getAttribute(Ot);n!==null&&(i.innerText=n,i.removeAttribute(Ot));let o=p.private(i,le);if(o){let a=this.triggerBeforeUpdateHook(i,o);tt.patchEl(i,o,this.liveSocket.getActiveElement()),a&&a.__updated(),p.deletePrivate(i,le)}})}putRef(e,i,s={}){let r=this.ref++,n=this.binding(Dt);return s.loading&&(e=e.concat(p.all(document,s.loading))),e.forEach(o=>{o.classList.add(`phx-${i}-loading`),o.setAttribute(le,r),o.setAttribute(ke,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(Ot)||o.setAttribute(Ot,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(pe);return i?parseInt(i):null}targetComponentID(e,i,s={}){if(ve(i))return i;let r=s.target||e.getAttribute(this.binding("target"));return ve(r)?parseInt(r):i&&(r!==null||s.target)?this.closestComponentID(i):null}closestComponentID(e){return ve(e)?e:e?Ae(e.closest(`[${pe}]`),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(Lr)),ref:e.getAttribute(me),entry_ref:i,progress:s,cid:n.targetComponentID(e.form,o)},r)})}pushInput(e,i,s,r,n,o){let a,l=ve(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=yi(e.form,H({_target:n._target},m),[e.name]):f=yi(e.form,H({_target:n._target},m)),p.isUploadInput(e)&&e.files&&e.files.length>0&&W.trackFiles(e,Array.from(e.files)),a=W.serializeUploads(e);let w={type:"form",event:r,value:f,uploads:a,cid:l};this.pushWithReply(c,"event",w,_=>{if(p.showError(e,this.liveSocket.binding(Ge),this.liveSocket.binding(Ze)),p.isUploadInput(e)&&p.isAutoUpload(e)){if(W.filesAwaitingPreflight(e).length>0){let[S,E]=c();this.uploadFiles(e.form,i,S,l,P=>{o&&o(_),this.triggerAwaitingSubmit(e.form),this.undoRefs(S)})}}else o&&o(_)})}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=>!(vt(m,`${this.binding(pt)}=ignore`,m.form)||vt(m,"data-phx-update=ignore",m.form)),r=m=>m.hasAttribute(this.binding(Dt)),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(li,m.readOnly),m.readOnly=!0,m.files&&(m.setAttribute(Qe,m.disabled),m.disabled=!0)}),e.setAttribute(this.binding(hs),""),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(W.hasUploadsInProgress(e)){let[c,f]=a(),m=()=>this.pushFormSubmit(e,i,s,r,n,o);return this.scheduleSubmit(e,c,n,m)}else if(W.inputsAwaitingPreflight(e).length>0){let[c,f]=a(),m=()=>[c,f,n];this.uploadFiles(e,i,c,l,w=>{let _=this.extractMeta(e),S=yi(e,H({submitter:r},_));this.pushWithReply(m,"event",{type:"form",event:s,value:S,cid:l},o)})}else if(!(e.hasAttribute(le)&&e.classList.contains("phx-submit-loading"))){let c=this.extractMeta(e),f=yi(e,H({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=W.activeFileInputs(e),l=a.length;a.forEach(c=>{let f=new W(c,this,()=>{l--,l===0&&n()}),m=f.entries().map(_=>_.toPreflightPayload());if(m.length===0){l--;return}let w={ref:c.getAttribute(me),entries:m,cid:this.targetComponentID(c.form,i)};this.log("upload",()=>["sending preflight request",w]),this.pushWithReply(null,"allow_upload",w,_=>{if(this.log("upload",()=>["got preflight response",_]),_.error){this.undoRefs(s);let[S,E]=_.error;this.log("upload",()=>[`error for entry ${S}`,E])}else{let S=E=>{this.channel.onError(()=>{this.joinCount===o&&E()})};f.initAdapterUpload(_,S,this.liveSocket)}})})}dispatchUploads(e,i,s){let r=this.targetCtxElement(e)||this.el,n=p.findUploadInputs(r).filter(o=>o.name===i);n.length===0?se(`no live file inputs found matching the name "${i}"`):n.length>1?se(`duplicate live file inputs found matching the name "${i}"`):p.dispatchEvent(n[0],ei,{detail:{files:s}})}targetCtxElement(e){if(ve(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(me)&&W.clearFiles(f));let l=a.find(f=>f.type!=="hidden")||a[0],c=e.getAttribute(this.binding(fs))||e.getAttribute(this.binding("change"));te.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(fs))!=="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(Oe);return e.getAttribute(Ye)===this.id||i&&i.id===this.id||!i&&this.isDead}submitForm(e,i,s,r,n={}){p.putPrivate(e,ut,!0);let o=this.liveSocket.binding(Ge),a=this.liveSocket.binding(Ze),l=Array.from(e.elements);l.forEach(c=>p.putPrivate(c,ut,!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 Ut=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||Hr,this.opts=s,this.params=mi(s.params||{}),this.viewLogger=s.viewLogger,this.metadataCallbacks=s.metadata||{},this.defaults=Object.assign(_t(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=_t(window.location),this.hooks=s.hooks||{},this.uploaders=s.uploaders||{},this.loaderTimeout=s.loaderTimeout||Rr,this.reloadWithJitterTimer=null,this.maxReloads=s.maxReloads||br,this.reloadJitterMin=s.reloadJitterMin||yr,this.reloadJitterMax=s.reloadJitterMax||Sr,this.failsafeJitter=s.failsafeJitter||Er,this.localStorage=s.localStorage||window.localStorage,this.sessionStorage=s.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:mi(),onBeforeElUpdated:mi()},s.dom||{}),this.doofinderMount=s.doofinderMount,this.connectCallback=s.connectCallback||(()=>{}),this.disconnectCallback=s.disconnectCallback||(()=>{}),this.unbindFunctions=[],this.transitions=new Yr,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(di)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Mt)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Mt)==="false"}enableDebug(){this.sessionStorage.setItem(Mt,"true")}enableProfiling(){this.sessionStorage.setItem(di,"true")}disableDebug(){this.sessionStorage.setItem(Mt,"false")}disableProfiling(){this.sessionStorage.removeItem(di)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(ui,e)}disableLatencySim(){this.sessionStorage.removeItem(ui)}getLatencySim(){let e=this.sessionStorage.getItem(ui);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=>te.exec(s,i,r,e))}execJSHookPush(e,i,s,r){this.withinOwners(e,n=>{te.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();Fr(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;Le.updateLocal(this.localStorage,window.location.pathname,Zt,0,a=>a+1)>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{this.disconnectCallback()},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?Br[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),Le.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(_e)!==null}newRootView(e,i,s){let r=new bt(e,this,null,i,s);return this.roots[r.id]=r,r}owner(e,i){let s=Ae(e.closest(Oe),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(Pe);return Ae(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(Pe));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(Pr)),c=i.key&&i.key.toLowerCase();if(l&&l.toLowerCase()!==c)return;let f=H({key:i.key},this.eventMeta(s,i,n));te.exec(s,o,r,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(i,s,r,n,o,a)=>{if(!a){let l=H({key:i.key},this.eventMeta(s,i,n));te.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);te.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=Ae(vt(s.target,this.binding(as)),a=>a.getAttribute(this.binding(as))),n=r&&document.getElementById(r),o=Array.from(s.dataTransfer.files||[]);!n||n.disabled||o.length===0||!(n.files instanceof FileList)||(W.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(ei,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);W.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=vt(c,r),this.dispatchClickAway(o,c),this.clickStartedAtTarget=null}let l=a&&a.getAttribute(r);if(!l){!s&&p.isNewPageClick(o,window.location)&&this.unload();return}a.getAttribute("href")==="#"&&o.preventDefault(),!a.hasAttribute(le)&&(a.disabled||this.debounce(a,o,"click",()=>{this.withinOwners(a,c=>{te.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);te.isVisible(r)&&te.isInViewport(r)&&te.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,`${X}:${e}`,{detail:i})}dispatchEvents(e){e.forEach(([i,s])=>this.dispatchEvent(i,s))}withPageLoading(e,i){p.dispatchEvent(this.doofinderMount,`${X}:page-loading-start`,{detail:e});let s=()=>p.dispatchEvent(this.doofinderMount,`${X}:page-loading-stop`,{detail:e});return i?i(s):s}pushHistoryPatch(e,i,s){if(!this.isConnected()||!this.main.isMain())return Le.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)||(Le.pushState(i,{type:"patch",id:this.main.id},e),p.dispatchEvent(window,`${X}:navigate`,{detail:{patch:!0,href:e,pop:!1}}),this.registerNewLocation(window.location))}historyRedirect(e,i,s){if(!this.isConnected()||!this.main.isMain())return Le.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&&(Le.pushState(i,{type:"redirect",id:this.main.id,scroll:r},e),p.dispatchEvent(window,`${X}:navigate`,{detail:{href:e,patch:!1,pop:!1}}),this.registerNewLocation(window.location)),n()})})}replaceRootHistory(){Le.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=_t(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=>{te.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:w,type:_}=p.private(o,"prev-iteration")||{};w===m-1&&s==="change"&&_==="input"||(p.putPrivate(o,"prev-iteration",{at:m,type:s}),this.debounce(o,r,s,()=>{this.withinOwners(f,S=>{p.putPrivate(o,Ht,!0),p.isTextualInput(o)||this.setActiveElement(o),te.exec("change",c,S,o,["push",{_target:r.target.name,dispatcher:f}])})}))},this.doofinderMount);this.on("reset",s=>{let r=s.target;p.resetForm(r,this.binding(Ge),this.binding(Ze));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(Tr),o=this.binding(kr),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)})}},Yr=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 ws=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 Ut(i,os,c),this.__appName=a}get liveSocket(){return this.__socket}get connected(){return this.__socket.isConnected()}enableDebug(){this.__socket.enableDebug()}disableDebug(){this.__socket.disableDebug()}setPreventReconnect(e=!1){var i;this.__socket.preventReconnect=e,e&&((i=this.__socket.reconnectTimer)==null||i.reset())}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 aa="df-cookies-allowed",la=window.localStorage;function Gr(){return JSON.parse(la.getItem(aa)||"false")}var yt=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){!Gr()||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 As="dfd-animate",Cs="dfd-fixed-layout",Me="hidden",Si="ai_fullscreen",Ei="floating",wi="fullscreen",it="static";function Ai(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=xe(H({},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=xe(H({},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=xe(H({},i),{clientWidth:s.clientWidth,clientHeight:s.clientHeight,scrollLeft:s.scrollLeft,scrollTop:s.scrollTop,scrollWidth:s.scrollWidth,scrollHeight:s.scrollHeight})}return i}function Zr(t){let e=t;for(;e&&getComputedStyle(e).position!=="fixed";)e=e.offsetParent;return!!e}"use strict";var xs=class{constructor(e,i={}){this.options=H({align:i.align,offsetX:0,offsetY:4,marginY:20,marginX:20,fillViewPortWidth:768},i),this.element=e}__origin__(e){let i=Ai(e),s=Ai(document),r=s.width<=this.options.fillViewPortWidth,n={width:i.width,top:i.top+i.height,left:i.left,fixed:Zr(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 Ci(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 st=class{constructor(e){this.mount=e,this._positionReference=null}__animate__(){return new Promise(e=>{setTimeout(()=>{this.mount.classList.add(As),e()},10)})}get positionReference(){return this._positionReference}show(){return R(this,null,function*(){let e=this.hidden();return e&&(this.mount.removeAttribute(Me),yield this.__animate__()),e})}hide(){return R(this,null,function*(){let e=!this.hidden();return e&&(this.mount.setAttribute(Me,""),this.mount.classList.remove(As),this.mount.innerHTML=""),e})}updatePosition(e){return R(this,null,function*(){this._positionReference=e.positionReference})}destroy(){this.mount=void 0}hidden(){return this.mount.hasAttribute(Me)}};var Ts=class extends st{constructor(e,i={}){super(e);this.handleWindowChange=Ci(this.handleWindowChange.bind(this)),this._position=new xs(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 R(this,null,function*(){let s=this.hidden();return s&&(this.mount.style.opacity="0",this.mount.removeAttribute(Me)),this._position.update(this._positionReference),s&&(this.mount.setAttribute(Me,""),this.mount.style.opacity="",yield e("show").call(this),this.__addListeners__()),s})}hide(){var e=i=>super[i];return R(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 R(this,null,function*(){i("updatePosition").call(this,e),setTimeout(()=>{var r;(r=this._position)==null||r.update(this._positionReference)},100)})}destroy(){this.__removeListeners__(),this._position.destroy(),this._position=null,super.destroy()}};var ks=class extends st{show(){var e=i=>super[i];return R(this,null,function*(){let s=this.hidden();return s&&(document.documentElement.classList.add(Cs),yield e("show").call(this)),s})}hide(){var e=i=>super[i];return R(this,null,function*(){let s=yield e("hide").call(this);return s&&document.documentElement.classList.remove(Cs),s})}};function Xe(t=8){let e="";for(;e.length{let n=0,o=null,a=e.interval||ca,l=e.times||ha;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 Hs="__DF_DEBUG_MODE__",Qr="true",Li=window.sessionStorage;function en(){Li.setItem(Hs,Qr)}function tn(){Li.removeItem(Hs)}function sn(){return Li.getItem(Hs)===Qr}function Ds(t){return Li.getItem(t)||window[t]}function x(...t){sn()&&console.log("[doofinder]",...t)}var rn=function(t){let e=t.slice(0,4);return RegExp(`#${e}/(brand-categories|classic|classic-initial|embedded|ai-fullscreen|ai-fullscreen-conversational|ai-fullscreen-initial|fullscreen|fullscreen-brand-categories|fullscreen-initial|mobile|mobile-brand-categories|mobile-initial|ai-mobile|ai-mobile-initial)/`)},nn=function(t){let e=t.slice(0,4);return RegExp(`#${e}/(category-pages|mobile-category-pages)/`)};"use strict";var Ne=window.history,Ri=class{constructor({installationId:e,autoload:i,urlHash:s,layerType:r}){this._installationId=e,this._layerType=r,this._autoload=i?Object.freeze(i):null,this._urlHash=s,this._storage=new yt(`${e}.data`,window.sessionStorage),this.__initialSetup__()}get hasAutoloadQueryParam(){return this.__getQueryFromAutoload__()!==null}get isTransitory(){return this._isTransitory}get query(){return this.__getQuery__()}get startPage(){var e;return(e=this._startPage)!=null?e:1}get targetItemId(){return this._targetItemId}get value(){return this._value}set targetItemId(e){this._targetItemId=e}saveTransitory(e){if(!this.__valid__(this._value)){x(`[state] [${this._layerType}] saveTransitory: not valid for `,this._value);return}x(`[state] [${this._layerType}] saveTransitory:`,this._value),this._storage.setItem(this.__getStateKey__(),{value:this.__simplify__(this._value),location:e})}update(e,i,s){if(!this.__hasChanged__(e,i,s))return x(`[state] [${this._layerType}] update not performed, the state has not changed.`,e,i,s),!1;this.__valid__(e)&&(x(`[state] [${this._layerType}] new state value: `,e),this._value=e),this._targetItemId=i,this._isTransitory=s;let r=window.location.origin+window.location.pathname+window.location.search;this._urlHash&&(r=r+this._value),x(`[state] [${this._layerType}] replaceState:`,r),Ne.replaceState(this.__getNewStateObject__(),"",r)}__hasChanged__(e,i,s){return e!=this._value||i!=this._targetItemId||s!=this._isTransitory}__initialSetup__(){let e=this.__fromStorage__(),i=this.__fromHistory__()||e||this.__fromHash__()||this.__fromAutoload__()||"";i=i.match("^#([A-Za-z0-9-]+)/(embedded|classic)/$")?"":i,this._value=i,this._targetItemId=this.__getTargetItem__(),this._isTransitory=this.__isTransitory__(!!e),this._startPage=this.__getPage__(),e&&Ne.replaceState(this.__getNewStateObject__(),"",window.location.href)}__fromAutoload__(){if(!this._autoload)return x(`[state] [${this._layerType}] __fromAutoload__ with autoload false - state:`,null),null;let e=this.__getQueryFromAutoload__(),i=e!=null?`#/${this._autoload.screen}/q=${e.trim()}`:null;return x(`[state] [${this._layerType}] __fromAutoload__ (query) state:`,i),i}__fromHash__(){let e=this.__validHash__(window.location.hash)?`#${window.location.hash.split("#",2)[1]}`:null;return x(`[state] [${this._layerType}] __fromHash__ state:`,e),e}__fromHistory__(){let e=null;return this.__validDoofinderStateInHistory__()&&(e=Ne.state[this.__getStateKey__()].value),x(`[state] [${this._layerType}] __fromHistory__ state:`,e),e}__fromStorage__(){let e=this._storage.popItem(this.__getStateKey__());return!!e&&!window.location.href.includes(e.location)?(x(`[state] [${this._layerType}] __fromStorage__ discarded as it is from diferent location:`,e),null):(x(`[state] [${this._layerType}] __fromStorage__ state:`,e),!!e&&e.value)}__getNewStateObject__(){let e={[this.__getStateKey__()]:{value:this._value,transitory:this._isTransitory,targetItemId:this._targetItemId}};return x(`[state] [${this._layerType}] __getNewStateObject__:`,e),this.__validHistoryState__()?H(H({},Ne.state),e):e}__getQuery__(){if(this._value){let e=this._value.split("/"),i=e[e.length-1];return Object.fromEntries(new URLSearchParams(i)).q}return""}__getPage__(){if(!this._value)return 1;let e=this._value.split("/"),i=e[e.length-1],{p:s}=Object.fromEntries(new URLSearchParams(i));return parseInt(s,10)||1}__getQueryFromAutoload__(){return this._autoload?new URLSearchParams(window.location.search).get(this._autoload.param):null}__getTargetItem__(){let e=null;return this.__validDoofinderStateInHistory__()&&(e=Ne.state[this.__getStateKey__()].targetItemId),x(`[state] [${this._layerType}] __getTargetItem__:`,e),e}__getStateKey__(){return this._layerType=="category_pages"?Ri.CP_STATE_KEY:Ri.STATE_KEY}__isTransitory__(e){let i=e;return this.__validDoofinderStateInHistory__()&&(i=Ne.state[this.__getStateKey__()].transitory),x(`[state] [${this._layerType}] __isTransitory__:`,i),i}__simplify__(e){var o;let s=new URL(window.location.origin+window.location.pathname+window.location.search+e).hash.split("/"),r=(o=s.pop())!=null?o:"",n=Object.fromEntries(r.split("&").map(a=>a.split("=")));return(n==null?void 0:n.q)?`${s.join("/")}/m=${n.m}&q=${n.q}`:""}__valid__(e){return this.__validHash__(e)||e===""}__validHistoryState__(){return typeof Ne.state=="object"&&Ne.state!==null}__validDoofinderStateInHistory__(){return this.__validHistoryState__()&&Ne.state[this.__getStateKey__()]!=null}__validHash__(e){let i=this._layerType!=="category_pages"?rn(this._installationId):nn(this._installationId);return typeof e=="string"&&(i.test(e)||e.startsWith(`#/${this._installationId}/`))}},rt=Ri;ss(rt,"STATE_KEY","dfState"),ss(rt,"CP_STATE_KEY","dfCpState");var Os=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab"];var Ms="df:trigger:click",Vt="df:trigger:focus",jt="df:trigger:input",Ns="df:trigger:submit";var nt=1;"use strict";var ua="[dfd-carousel-btn-left]",fa="[dfd-carousel-btn-right]",on="[dfd-carousel-content]",Ii="ltr",an={mounted(){this.btnLeftEl=this.el.querySelector(ua),this.btnRightEl=this.el.querySelector(fa),this.contentEl=this.el.querySelector(on),getComputedStyle(this.contentEl).direction==="rtl"&&(Ii="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;Ii==="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;Ii==="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(on),getComputedStyle(this.contentEl).direction==="rtl"&&(Ii="rtl"),this.tag.dispatch("doofinder.carousel.update")},destroyed(){this.btnLeftEl.removeEventListener("click",this.previousPage),this.btnRightEl.removeEventListener("click",this.nextPage)}};var Hi=240;function pa(t){return!!t.type.match(/image\/.*/)}function ln(t){return R(this,null,function*(){if(!pa(t))throw"invalid image, can't search";let e=yield hn(t),i=yield ma(e);return yield hn(i)})}function hn(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 ma(t){return new Promise(function(e,i){let s=new Image;s.onload=function(){let r=document.createElement("canvas");r.width=Hi,r.height=Hi,r.getContext("2d").drawImage(s,0,0,Hi,Hi),r.toBlob(function(n){e(n)},"image/jpeg")},s.onerror=function(r){i("resize image error")},s.src=t})}var cn={mounted(){this.search=t=>R(this,null,function*(){this.el.dataset.status="loading";try{let e=yield ln(t);this.pushEvent("search",{search:{image:e}},i=>{delete this.el.dataset.status})}catch(e){delete this.el.dataset.status}}),this.el.addEventListener("change",t=>this.search(t.target.files[0]))}};function Fs(t){setTimeout(()=>{t.focus()},0)}function dn(t){setTimeout(()=>{t.select()},0)}"use strict";var un={mounted(){dn(this.el),this.search=t=>{let e=this.el.dataset.dfdAction||"search";this.pushEvent(e,{search:{query:t}})},this.handleEvent("set-input-value",t=>this.el.value=t.query),this.handleEvent("set-input-focus",()=>Fs(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=>{if(t.key==="Enter"&&t.preventDefault(),this.charLimitReached(t))return;let e=this.el.getAttribute("dfd-value-suggestion");t.key==="Tab"&&e&&e!==this.el.value&&(this.el.value=e,Fs(this.el),this.search(e))}),this.el.addEventListener("keyup",t=>{if(t.key!=="Enter")return;let e=this.el.closest("form");if(e){let i=new Event("submit",{bubbles:!0,cancelable:!0});e.dispatchEvent(i)}}),this.charLimitReached=function(t){return t.type!=="keydown"||this.el.value.length<50||Os.includes(t.key)?!1:(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),!0)}}};"use strict";var fn={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 if(this.el.dataset.quantity=="true"&&this.el.dataset.status=="initial"&&this.el.dataset.quantityPinned=="false"){this.execJS(null,"set_attr",["data-status","quantity"]),this.execJS("[data-role=decrease_quantity]","hide"),this.execJS("[data-role=delete_quantity]","show");let s=this.el.querySelector("[data-role=amount_selected]"),r=parseInt(s==null?void 0:s.getAttribute("min"),10)||1;this.update_quantity(s,r)}else{this.send(i),this.execJS(null,"set_attr",["data-status","initial"]);let s=this.el.querySelector("[data-role=amount_selected]"),r=parseInt(s==null?void 0:s.getAttribute("min"),10)||1;this.update_quantity(s,r),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(o=>{this.execJS(`[data-role=open_selector][data-variant="${o.dataset.variant}"] input`,"set_attr",["value",o.dataset.variant])}),this.el.querySelectorAll("[data-role=open_selector]").forEach(o=>{this.execJS(`[data-role=variant_selected][data-variant="${o.dataset.variant}"]`,"remove_attr","data-index"),this.execJS(`[data-role=variant_selected][data-variant="${o.dataset.variant}"]`,"set_attr",["value",""])})}},increase_quantity:e=>()=>{var n;let i=this.el.querySelector("[data-role=amount_selected]"),s=parseInt((n=this.el.dataset)==null?void 0:n.quantityStep,10)||1,r=parseInt(i.value)+s;this.update_quantity(i,r)},decrease_quantity:e=>()=>{var l;let i=this.el.querySelector("[data-role=amount_selected]"),s=parseInt(i.value),r=parseInt((l=this.el.dataset)==null?void 0:l.quantityStep,10)||1,n=parseInt(i.getAttribute("min"),10)||1,o=s-r,a=o>=n?o:n;this.update_quantity(i,a)},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)}};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=>{var s;let i=parseInt((s=this.el.dataset)==null?void 0:s.quantityStep,10)||1;e<=i&&this.el.dataset.quantityPinned=="false"?(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_quantity(1),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 He({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 ot(t){return`${X}:${t}`}"use strict";var Di="doofinder.cart.add.click",ga="doofinder.cart.add",Oi="doofinder.cart.hide.price",Mi="doofinder.cart.display.price",$s="dfd-btn-loading",pn="dfd-btn-done",mn="dfd-btn-error";function gn(t){t.addToCartResolveTimeout=3e3,t.addToCartRejectTimeout=5e3,t.addToCartButtonFeedback=function(i,s){let r=_a.bind(null,i,s),n=ya.bind(null,i,i.innerHTML),o=va.bind(null,i,n),a=ba.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 He({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(ga,xe(H({},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(Di,t.handleCartAddClick),e.addEventListener(ot(Di),t.handleCartAddClick),e.addEventListener(Oi,t.handleHidePrice),e.addEventListener(ot(Oi),t.handleHidePrice),e.addEventListener(Mi,t.handleDisplayPrice),e.addEventListener(ot(Mi),t.handleDisplayPrice)}function _n(t){let e=!!t.tag&&!!t.tag.dom?t.tag.dom.mount:t.tag.mount;e.removeEventListener(Di,t.handleCartAddClick),e.removeEventListener(ot(Di),t.handleCartAddClick),e.removeEventListener(Oi,t.handleHidePrice),e.removeEventListener(ot(Oi),t.handleHidePrice),e.removeEventListener(Mi,t.handleDisplayPrice),e.removeEventListener(ot(Mi),t.handleDisplayPrice)}function _a(t,e){return t.setAttribute("disabled",""),t.setAttribute("dfd-update","ignore"),t.innerHTML="",t.classList.add($s),e}function va(t,e){t.classList.remove($s),t.classList.add(pn),setTimeout(e,1e3)}function ba(t,e){t.classList.remove($s),t.classList.add(mn),setTimeout(e,2e3)}function ya(t,e){t.classList.remove(pn),t.classList.remove(mn),t.innerHTML=e,t.removeAttribute("dfd-update"),t.removeAttribute("disabled")}function vn(t,e){return typeof t!="undefined"?t:e}var at=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:vn(r,0)})}observe(e){this._io.disconnect(),e&&this._io.observe(e),x("[ScrollObserver][observe]",e)}unobserve(){this._io.disconnect(),x("[ScrollObserver][unobserve]")}handleIntersection([e]){x("[ScrollObserver][intersection detected] target:",e.target),this._callback(e)}};"use strict";function Sa(t){var s;let[e]=document.getElementsByClassName("dfd-searchbox-input");if(!e){this.tag.trigger.updateQuery((s=t==null?void 0:t.search)==null?void 0:s.query);return}let i=e.value.length;e.focus(),e.setSelectionRange(i,i),e.click()}var bn={mounted(){this.__focusInput=Sa.bind(this),this.close=()=>this.pushEvent("close-layer"),this.handleEvent("close",()=>{this.tag.disconnect()}),this.handleEvent("change-state",({state:t})=>{this.tag.updateState({value:t})}),this.handleEvent("disconnect",t=>{t.errors.forEach(e=>console.error("[Doofinder] error:",e)),Doofinder.Session.removeLive("layer"),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=>R(this,null,function*(){this.__focusInput(t)})),this.handleEvent("set-trigger-focus",()=>R(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.handleEvent("check-activity",()=>{this.tag.updateLastActivity()}),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}),gn(this)},updated(){this.tag.dispatch("doofinder.layer.update")},destroyed(){_n(this)}},yn={mounted(){this.handleEvent("disconnect",t=>{t.errors.forEach(e=>console.error("[Doofinder] error:",e)),Doofinder.Session.removeLive("layer"),this.tag.destroy()})}},Sn={mounted(){En(this.el)},updated(){En(this.el)}};function En(t){let e=t.querySelector("[dfd-update=stream]"),i=e?e.querySelectorAll('[dfd-click="item-click"]:not([data-dfd-item-position])'):[];if(i.length===0)return;let s=null;if(e){let r=e.querySelectorAll('[id^="card-link-"][data-dfd-item-position]');s=r.length>0?r[r.length-1]:null}i.forEach(r=>{s?r.setAttribute("dfd-value-position",parseInt(s.getAttribute("dfd-value-position"))+1):r.setAttribute("dfd-value-position",1),s=r})}var wn={mounted(){this.layer=this.el.closest(".dfd-layer"),this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.layerObserver=new at(null,t=>{t.isIntersecting?(t.boundingClientRect.top<0&&this.pushEvent("change-back-to-top-visibility",{visible:!0}),this.pushEvent("change-filters-visibility",{visible:!0})):(this.pushEvent("change-back-to-top-visibility",{visible:!1}),this.pushEvent("change-filters-visibility",{visible:!1}))}),this.layerObserver.observe(this.layer)},destroyed(){var t;(t=this.layerObserver)==null||t.unobserve()}};var An=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 Cn(t,e,i,s,r=An.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),w=r(m);e[t]=o+w*(i-o),m<1?requestAnimationFrame(c):a()}o===i?a():requestAnimationFrame(c)})}var xn=Cn.bind(null,"scrollTop"),pd=Cn.bind(null,"scrollLeft");function Ea(t){let e=t.scrollHeight>t.clientHeight,s=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!s}function Ni(t){return!t||t===document.documentElement?document.documentElement:Ea(t)?t:Ni(t.parentNode)}var Tn='[data-dfd-role~="scroll-sentinel"]',kn='[data-dfd-role~="scroll-top-sentinel"]',wa="div.dfd-card";function Fi(t,e,i){i?t.scrollTop=e:xn(t,e,250)}function Aa(t){var s,r;let e=((s=document.querySelector(wa))==null?void 0:s.offsetHeight)||0,i=((r=document.querySelector(Tn))==null?void 0:r.offsetHeight)||0;return t.scrollHeight-i-e*2.6}function Us(t,e){t.pushEvent("change-back-to-top-visibility",{visible:e})}function Pn(t,e,i){t.debug(`[handle] "back-to-top", id: ${e}, fast: ${i}`),t.scrollTarget()==="window"?window.scrollTo(0,0):(!e||e===t.el.id)&&Fi(Ni(t.el),0,i)}var Ln={mounted(){this.sentinel=()=>this.el.querySelector(Tn),this.scrollTopSentinel=()=>this.el.querySelector(kn),this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.refreshObservers=()=>{this.scrollObserver.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel())},this.scrollObserver=new at(this.el,({target:t,isIntersecting:e})=>{var r;let i=(r=this.el.querySelector(".dfd-results-grid"))==null?void 0:r.children.length;if(!e||!i)return;let s={index:t.dataset.index};this.debug('[push] "load-more", params:',s),this.pushEvent("load-more",s)}),this.scrollTopObserver=new at(this.el,({isIntersecting:t})=>{Us(this,!t)}),this.handleEvent("search",t=>{this.debug('[handle] "search", params:',t);let{index:e,page:i}=t,s=this.sentinel();!Ca(t.filter)&&i===1&&e===(s==null?void 0:s.dataset.index)&&(Us(this,!1),Fi(this.el,0,!0)),this.refreshObservers()}),this.handleEvent("back-to-top",({id:t,fast:e})=>{Pn(this,t,e)}),this.handleEvent("change-current-index",()=>{this.scrollObserver.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel()),Fi(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}},Vs={mounted(){this.hideVirtualKeyboard=Ci(()=>{let t=document.querySelector("input:focus, textarea: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)}},js={mounted(){this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.scrollTopSentinel=()=>this.el.querySelector(kn),this.transientTargetCard=()=>this.el.querySelector(`[dfd-value-dfid="${this.tag.state.targetItemId}"]`),this.scrollTopObserver=new at(null,t=>{let e=!t.isIntersecting&&t.boundingClientRect.top<0;Us(this,e)}),this.scrollTopObserver.observe(this.scrollTopSentinel()),this.handleEvent("update-scroll",t=>{setTimeout((()=>{let e=this.transientTargetCard();this.debug('[handle] "update-scroll"',"params:",t,"card:",e),this.tag.targetItemId=null,e!==null?e.scrollIntoView({behavior:"smooth",block:"nearest"}):t.scroll_end&&Fi(Ni(this.el),Aa(this.el),!1)}).bind(this),1e3)}),this.handleEvent("back-to-top",({id:t,fast:e})=>{Pn(this,t,e)})}};function Ca(t){return!!t&&Object.keys(t).length>0}function $i(t,e,i,s){return new Intl.NumberFormat(t,{style:"currency",maximumFractionDigits:parseInt(i,10),numberingSystem:s,currency:e})}function Ui(t,e,i){return new Intl.NumberFormat(t,{maximumFractionDigits:parseInt(e,10),numberingSystem:i})}var Bs=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 qe;(function(t){t.Range="range",t.Steps="steps",t.Positions="positions",t.Count="count",t.Values="values"})(qe||(qe={}));var de;(function(t){t[t.None=-1]="None",t[t.NoValue=0]="NoValue",t[t.LargeValue=1]="LargeValue",t[t.SmallValue=2]="SmallValue"})(de||(de={}));function xa(t){return Vi(t)&&typeof t.from=="function"}function Vi(t){return typeof t=="object"&&typeof t.to=="function"}function Rn(t){t.parentElement.removeChild(t)}function Xs(t){return t!=null}function In(t){t.preventDefault()}function Ta(t){return t.filter(function(e){return this[e]?!1:this[e]=!0},{})}function ka(t,e){return Math.round(t/e)*e}function Pa(t,e){var i=t.getBoundingClientRect(),s=t.ownerDocument,r=s.documentElement,n=On(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 Ce(t){return typeof t=="number"&&!isNaN(t)&&isFinite(t)}function Hn(t,e,i){i>0&&(ce(t,e),setTimeout(function(){Bi(t,e)},i))}function Dn(t){return Math.max(Math.min(t,100),0)}function ji(t){return Array.isArray(t)?t:[t]}function La(t){t=String(t);var e=t.split(".");return e.length>1?e[1].length:0}function ce(t,e){t.classList&&!/\s/.test(e)?t.classList.add(e):t.className+=" "+e}function Bi(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 Ra(t,e){return t.classList?t.classList.contains(e):new RegExp("\\b"+e+"\\b").test(t.className)}function On(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 Ia(){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 Ha(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("test",null,e)}catch(i){}return t}function Da(){return window.CSS&&CSS.supports&&CSS.supports("touch-action","none")}function qs(t,e){return 100/(e-t)}function Js(t,e,i){return e*100/(t[i+1]-t[i])}function Oa(t,e){return Js(t,t[0]<0?e+Math.abs(t[0]):e-t[0],0)}function Ma(t,e){return e*(t[1]-t[0])/100+t[0]}function Bt(t,e){for(var i=1;t>=e[i];)i+=1;return i}function Na(t,e,i){if(i>=t.slice(-1)[0])return 100;var s=Bt(i,t),r=t[s-1],n=t[s],o=e[s-1],a=e[s];return o+Oa([r,n],i)/qs(o,a)}function Fa(t,e,i){if(i>=100)return t.slice(-1)[0];var s=Bt(i,e),r=t[s-1],n=t[s],o=e[s-1],a=e[s];return Ma([r,n],(i-o)*qs(o,a))}function $a(t,e,i,s){if(s===100)return s;var r=Bt(s,t),n=t[r-1],o=t[r];return i?s-n>(o-n)/2?o:n:e[r-1]?t[r-1]+ka(s-t[r-1],e[r-1]):s}var Mn=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([ji(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=Na(this.xVal,this.xPct,e),e},t.prototype.fromStepping=function(e){return Fa(this.xVal,this.xPct,e)},t.prototype.getStep=function(e){return e=$a(this.xPct,this.xSteps,this.snap,e),e},t.prototype.getDefaultStep=function(e,i,s){var r=Bt(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=Bt(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(La);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),!Ce(s)||!Ce(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]=Js([this.xVal[e],this.xVal[e+1]],i,0)/qs(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}(),Nn={to:function(t){return t===void 0?"":t.toFixed(2)},from:Number},Fn={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 Ua(t,e){if(!Ce(e))throw new Error("noUiSlider: 'step' is not numeric.");t.singleStep=e}function Va(t,e){if(!Ce(e))throw new Error("noUiSlider: 'keyboardPageMultiplier' is not numeric.");t.keyboardPageMultiplier=e}function ja(t,e){if(!Ce(e))throw new Error("noUiSlider: 'keyboardMultiplier' is not numeric.");t.keyboardMultiplier=e}function Ba(t,e){if(!Ce(e))throw new Error("noUiSlider: 'keyboardDefaultStep' is not numeric.");t.keyboardDefaultStep=e}function Xa(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 Mn(e,t.snap||!1,t.singleStep)}function qa(t,e){if(e=ji(e),!Array.isArray(e)||!e.length)throw new Error("noUiSlider: 'start' option is incorrect.");t.handles=e.length,t.start=e}function Ja(t,e){if(typeof e!="boolean")throw new Error("noUiSlider: 'snap' option must be a boolean.");t.snap=e}function Wa(t,e){if(typeof e!="boolean")throw new Error("noUiSlider: 'animate' option must be a boolean.");t.animate=e}function za(t,e){if(typeof e!="number")throw new Error("noUiSlider: 'animationDuration' option must be a number.");t.animationDuration=e}function $n(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 Za(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 Qa(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("invert-connects")>=0,c=e.indexOf("drag-all")>=0,f=e.indexOf("smooth-steps")>=0;if(r){if(t.handles!==2)throw new Error("noUiSlider: 'fixed' behaviour must be used with 2 handles");Un(t,t.start[1]-t.start[0])}if(l&&t.handles!==2)throw new Error("noUiSlider: 'invert-connects' behaviour must be used with 2 handles");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:c,smoothSteps:f,fixed:r,snap:n,hover:o,unconstrained:a,invertConnects:l}}function el(t,e){if(e!==!1)if(e===!0||Vi(e)){t.tooltips=[];for(var i=0;i= 2) required for mode 'count'.");for(var d=h.values-1,u=100/d,v=[];d--;)v[d]=d*u;return v.push(100),Ie(v,h.stepped)}return h.mode===qe.Positions?Ie(h.values,h.stepped):h.mode===qe.Values?h.stepped?h.values.map(function(b){return _.fromStepping(_.getStep(_.toStepping(b)))}):h.values:[]}function Ie(h,d){return h.map(function(u){return _.fromStepping(d?_.getStep(u):u)})}function Se(h){function d(B,z){return Number((B+z).toFixed(7))}var u=M(h),v={},b=_.xVal[0],y=_.xVal[_.xVal.length-1],C=!1,A=!1,j=0;return u=Ta(u.slice().sort(function(B,z){return B-z})),u[0]!==b&&(u.unshift(b),C=!0),u[u.length-1]!==y&&(u.push(y),A=!0),u.forEach(function(B,z){var K,N,ee,ae=B,ie=u[z+1],ne,Zi,Qi,es,ar,ts,lr,hr=h.mode===qe.Steps;for(hr&&(K=_.xNumSteps[z]),K||(K=ie-ae),ie===void 0&&(ie=ae),K=Math.max(K,1e-7),N=ae;N<=ie;N=d(N,K)){for(ne=_.toStepping(N),Zi=ne-j,ar=Zi/(h.density||1),ts=Math.round(ar),lr=Zi/ts,ee=1;ee<=ts;ee+=1)Qi=j+ee*lr,v[Qi.toFixed(5)]=[_.fromStepping(Qi),0];es=u.indexOf(N)>-1?de.LargeValue:hr?de.SmallValue:de.NoValue,!z&&C&&N!==ie&&(es=0),N===ie&&A||(v[ne.toFixed(5)]=[N,es]),j=ne}}),v}function Fe(h,d,u){var v,b,y=$.createElement("div"),C=(v={},v[de.None]="",v[de.NoValue]=e.cssClasses.valueNormal,v[de.LargeValue]=e.cssClasses.valueLarge,v[de.SmallValue]=e.cssClasses.valueSub,v),A=(b={},b[de.None]="",b[de.NoValue]=e.cssClasses.markerNormal,b[de.LargeValue]=e.cssClasses.markerLarge,b[de.SmallValue]=e.cssClasses.markerSub,b),j=[e.cssClasses.valueHorizontal,e.cssClasses.valueVertical],B=[e.cssClasses.markerHorizontal,e.cssClasses.markerVertical];ce(y,e.cssClasses.pips),ce(y,e.ort===0?e.cssClasses.pipsHorizontal:e.cssClasses.pipsVertical);function z(N,ee){var ae=ee===e.cssClasses.value,ie=ae?j:B,ne=ae?C:A;return ee+" "+ie[e.ort]+" "+ne[N]}function K(N,ee,ae){if(ae=d?d(ee,ae):ae,ae!==de.None){var ie=Y(y,!1);ie.className=z(ae,e.cssClasses.marker),ie.style[e.style]=N+"%",ae>de.NoValue&&(ie=Y(y,!1),ie.className=z(ae,e.cssClasses.value),ie.setAttribute("data-value",String(ee)),ie.style[e.style]=N+"%",ie.innerHTML=String(u.to(ee)))}}return Object.keys(h).forEach(function(N){K(N,h[N][0],h[N][1])}),y}function $e(){m&&(Rn(m),m=null)}function ge(h){$e();var d=Se(h),u=h.filter,v=h.format||{to:function(b){return String(Math.round(b))}};return m=o.appendChild(Fe(d,u,v)),m}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 oe(h,d,u,v){var b=function(C){var A=wt(C,v.pageOffset,v.target||d);if(!A||lt()&&!v.doNotReject||Ra(o,e.cssClasses.tap)&&!v.doNotReject||h===s.start&&A.buttons!==void 0&&A.buttons>1||v.hover&&A.buttons)return!1;n||A.preventDefault(),A.calcPoint=A.points[e.ort],u(A,v)},y=[];return h.split(" ").forEach(function(C){d.addEventListener(C,b,n?{passive:!0}:!1),y.push([C,b])}),y}function wt(h,d,u){var v=h.type.indexOf("touch")===0,b=h.type.indexOf("mouse")===0,y=h.type.indexOf("pointer")===0,C=0,A=0;if(h.type.indexOf("MSPointer")===0&&(y=!0),h.type==="mousedown"&&!h.buttons&&!h.touches)return!1;if(v){var j=function(K){var N=K.target;return N===u||u.contains(N)||h.composed&&h.composedPath().shift()===u};if(h.type==="touchstart"){var B=Array.prototype.filter.call(h.touches,j);if(B.length>1)return!1;C=B[0].pageX,A=B[0].pageY}else{var z=Array.prototype.find.call(h.changedTouches,j);if(!z)return!1;C=z.pageX,A=z.pageY}}return d=d||On($),(b||y)&&(C=h.clientX+d.x,A=h.clientY+d.y),h.pageOffset=d,h.points=[C,A],h.cursor=b||y,h}function At(h){var d=h-Pa(a,e.ort),u=d*100/We();return u=Dn(u),e.dir?100-u:u}function go(h){var d=100,u=!1;return c.forEach(function(v,b){if(!St(b)){var y=E[b],C=Math.abs(y-h),A=C===100&&d===100,j=Cy;(j||B||A)&&(u=b,d=C)}}),u}function _o(h,d){h.type==="mouseout"&&h.target.nodeName==="HTML"&&h.relatedTarget===null&&Wi(h,d)}function vo(h,d){if(navigator.appVersion.indexOf("MSIE 9")===-1&&h.buttons===0&&d.buttonsProperty!==0)return Wi(h,d);var u=(e.dir?-1:1)*(h.calcPoint-d.startCalcPoint),v=u*100/d.baseSize;tr(u>0,v,d.locations,d.handleNumbers,d.connect)}function Wi(h,d){d.handle&&(Bi(d.handle,e.cssClasses.active),F-=1),d.listeners.forEach(function(u){q.removeEventListener(u[0],u[1])}),F===0&&(Bi(o,e.cssClasses.drag),Gi(),h.cursor&&(Z.style.cursor="",Z.removeEventListener("selectstart",In))),e.events.smoothSteps&&(d.handleNumbers.forEach(function(u){ze(u,E[u],!0,!0,!1,!1)}),d.handleNumbers.forEach(function(u){Q("update",u)})),d.handleNumbers.forEach(function(u){Q("change",u),Q("set",u),Q("end",u)})}function zi(h,d){if(!d.handleNumbers.some(St)){var u;if(d.handleNumbers.length===1){var v=c[d.handleNumbers[0]];u=v.children[0],F+=1,ce(u,e.cssClasses.active)}h.stopPropagation();var b=[],y=oe(s.move,q,vo,{target:h.target,handle:u,connect:d.connect,listeners:b,startCalcPoint:h.calcPoint,baseSize:We(),pageOffset:h.pageOffset,handleNumbers:d.handleNumbers,buttonsProperty:h.buttons,locations:E.slice()}),C=oe(s.end,q,Wi,{target:h.target,handle:u,listeners:b,doNotReject:!0,handleNumbers:d.handleNumbers}),A=oe("mouseout",q,_o,{target:h.target,handle:u,listeners:b,doNotReject:!0,handleNumbers:d.handleNumbers});b.push.apply(b,y.concat(C,A)),h.cursor&&(Z.style.cursor=getComputedStyle(h.target).cursor,c.length>1&&ce(o,e.cssClasses.drag),Z.addEventListener("selectstart",In,!1)),d.handleNumbers.forEach(function(j){Q("start",j)})}}function bo(h){h.stopPropagation();var d=At(h.calcPoint),u=go(d);u!==!1&&(e.events.snap||Hn(o,e.cssClasses.tap,e.animationDuration),ze(u,d,!0,!0),Gi(),Q("slide",u,!0),Q("update",u,!0),e.events.snap?zi(h,{handleNumbers:[u]}):(Q("change",u,!0),Q("set",u,!0)))}function yo(h){var d=At(h.calcPoint),u=_.getStep(d),v=_.fromStepping(u);Object.keys(I).forEach(function(b){b.split(".")[0]==="hover"&&I[b].forEach(function(y){y.call(Wt,v)})})}function So(h,d){if(lt()||St(d))return!1;var u=["Left","Right"],v=["Down","Up"],b=["PageDown","PageUp"],y=["Home","End"];e.dir&&!e.ort?u.reverse():e.ort&&!e.dir&&(v.reverse(),b.reverse());var C=h.key.replace("Arrow",""),A=C===b[0],j=C===b[1],B=C===v[0]||C===u[0]||A,z=C===v[1]||C===u[1]||j,K=C===y[0],N=C===y[1];if(!B&&!z&&!K&&!N)return!0;h.preventDefault();var ee;if(z||B){var ae=B?0:1,ie=nr(d),ne=ie[ae];if(ne===null)return!1;ne===!1&&(ne=_.getDefaultStep(E[d],B,e.keyboardDefaultStep)),j||A?ne*=e.keyboardPageMultiplier:ne*=e.keyboardMultiplier,ne=Math.max(ne,1e-7),ne=(B?-1:1)*ne,ee=S[d]+ne}else N?ee=e.spectrum.xVal[e.spectrum.xVal.length-1]:ee=e.spectrum.xVal[0];return ze(d,_.toStepping(ee),!0,!0),Q("slide",d),Q("update",d),Q("change",d),Q("set",d),!1}function er(h){h.fixed||c.forEach(function(d,u){oe(s.start,d.children[0],zi,{handleNumbers:[u]})}),h.tap&&oe(s.start,a,bo,{}),h.hover&&oe(s.move,a,yo,{hover:!0}),h.drag&&f.forEach(function(d,u){if(!(d===!1||u===0||u===f.length-1)){var v=c[u-1],b=c[u],y=[d],C=[v,b],A=[u-1,u];ce(d,e.cssClasses.draggable),h.fixed&&(y.push(v.children[0]),y.push(b.children[0])),h.dragAll&&(C=c,A=P),y.forEach(function(j){oe(s.start,j,zi,{handles:C,handleNumbers:A,connect:d})})}})}function Ki(h,d){I[h]=I[h]||[],I[h].push(d),h.split(".")[0]==="update"&&c.forEach(function(u,v){Q("update",v)})}function Eo(h){return h===Je.aria||h===Je.tooltips}function Ct(h){var d=h&&h.split(".")[0],u=d?h.substring(d.length):h;Object.keys(I).forEach(function(v){var b=v.split(".")[0],y=v.substring(b.length);(!d||d===b)&&(!u||u===y)&&(!Eo(y)||u===y)&&delete I[v]})}function Q(h,d,u){Object.keys(I).forEach(function(v){var b=v.split(".")[0];h===b&&I[v].forEach(function(y){y.call(Wt,S.map(e.format.to),d,S.slice(),u||!1,E.slice(),Wt)})})}function qt(h,d,u,v,b,y,C){var A;return c.length>1&&!e.events.unconstrained&&(v&&d>0&&(A=_.getAbsoluteDistance(h[d-1],e.margin,!1),u=Math.max(u,A)),b&&d1&&e.limit&&(v&&d>0&&(A=_.getAbsoluteDistance(h[d-1],e.limit,!1),u=Math.min(u,A)),b&&d1?v.forEach(function(K,N){var ee=qt(y,K,y[K]+d,j[N],B[N],!1,A);ee===!1?d=0:(d=ee-y[K],y[K]=ee)}):j=B=[!0];var z=!1;v.forEach(function(K,N){z=ze(K,u[K]+d,j[N],B[N],!1,A)||z}),z&&(v.forEach(function(K){Q("update",K),Q("slide",K)}),b!=null&&Q("drag",C))}function ir(h,d){return e.dir?100-h-d:h}function wo(h,d){E[h]=d,S[h]=_.fromStepping(d);var u=ir(d,0)-V,v="translate("+Yi(u+"%","0")+")";if(c[h].style[e.transformRule]=v,e.events.invertConnects&&E.length>1){var b=E.every(function(y,C,A){return C===0||y>=A[C-1]});if(U!==!b){Po();return}}xt(h),xt(h+1),U&&(xt(h-1),xt(h+2))}function Gi(){P.forEach(function(h){var d=E[h]>50?-1:1,u=3+(c.length+d*h);c[h].style.zIndex=String(u)})}function ze(h,d,u,v,b,y){return b||(d=qt(E,h,d,u,v,!1,y)),d===!1?!1:(wo(h,d),!0)}function xt(h){if(!!f[h]){var d=E.slice();U&&d.sort(function(A,j){return A-j});var u=0,v=100;h!==0&&(u=d[h-1]),h!==f.length-1&&(v=d[h]);var b=v-u,y="translate("+Yi(ir(u,b)+"%","0")+")",C="scale("+Yi(b/100,"1")+")";f[h].style[e.transformRule]=y+" "+C}}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=_.toStepping(h)),h===!1||isNaN(h))?E[d]:h}function Jt(h,d,u){var v=ji(h),b=E[0]===void 0;d=d===void 0?!0:d,e.animate&&!b&&Hn(o,e.cssClasses.tap,e.animationDuration),P.forEach(function(A){ze(A,sr(v[A],A),!0,!1,u)});var y=P.length===1?0:1;if(b&&_.hasNoSize()&&(u=!0,E[0]=0,P.length>1)){var C=100/(P.length-1);P.forEach(function(A){E[A]=A*C})}for(;y=0&&hu.stepAfter.startValue&&(b=u.stepAfter.startValue-v),v>u.thisStep.startValue?y=u.thisStep.step:u.stepBefore.step===!1?y=!1:y=v-u.stepBefore.highestStep,d===100?b=null:d===0&&(y=null);var C=_.countStepDecimals();return b!==null&&b!==!1&&(b=Number(b.toFixed(C))),y!==null&&y!==!1&&(y=Number(y.toFixed(C))),[y,b]}function To(){return P.map(nr)}function ko(h,d){var u=rr(),v=["margin","limit","padding","range","animate","snap","step","format","pips","tooltips","connect"];v.forEach(function(y){h[y]!==void 0&&(i[y]=h[y])});var b=Vn(i);v.forEach(function(y){h[y]!==void 0&&(e[y]=b[y])}),_=b.spectrum,e.margin=b.margin,e.limit=b.limit,e.padding=b.padding,e.pips?ge(e.pips):$e(),e.tooltips?J():k(),E=[],Jt(Xs(h.start)?h.start:u,d),h.connect&&or()}function or(){for(;l.firstChild;)l.removeChild(l.firstChild);for(var h=0;h<=e.handles;h++)f[h]=T(l,e.connect[h]),xt(h);er({drag:e.events.drag,fixed:!0})}function Po(){U=!U,$n(e,e.connect.map(function(h){return!h})),or()}function Lo(){a=G(o),D(e.connect,a),er(e.events),Jt(e.start),e.pips&&ge(e.pips),e.tooltips&&J(),O()}Lo();var Wt={destroy:xo,steps:To,on:Ki,off:Ct,get:rr,set:Jt,setHandle:Co,reset:Ao,disable:Et,enable:L,__moveHandles:function(h,d,u){tr(h,d,E,u)},options:i,updateOptions:ko,target:o,removePips:$e,removeTooltips:k,getPositions:function(){return E.slice()},getTooltips:function(){return w},getOrigins:function(){return c},pips:ge};return Wt}function hl(t,e){if(!t||!t.nodeName)throw new Error("noUiSlider: create requires a single element, got: "+t);if(t.noUiSlider)throw new Error("noUiSlider: Slider was already initialized.");var i=Vn(e),s=ll(t,i,e);return t.noUiSlider=s,s}var jn={__spectrum:Mn,cssClasses:Fn,create:hl};function Bn(t){return t.filter((e,i)=>t.indexOf(e)===i)}function Xn(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 qn(t,e,i,s={}){let r=t.dataset.facetLabel||"";return t&&t.noUiSlider&&t.noUiSlider.destroy(),jn.create(t,H({cssPrefix:"dfd-slider-",orientation:"horizontal",direction:s.rtl?"rtl":"ltr",tooltips:!0,padding:0,connect:!0,animate:!0,step:1,keyboardSupport:!0,format:e,handleAttributes:[{"aria-label":`Minimum ${r}`},{"aria-label":`Maximum ${r}`}],pips:{mode:"count",values:3,density:6,stepped:!0,format:e}},i))}function Jn(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,w,_){let S=[[]],E=[[]],P=[[]],F=0;a[0]&&(S[0][0]=0,E[0][0]=_[0],P[0][0]=c[0]);for(let I=1;I<_.length;I++)(!a[I]||_[I]-_[I-1]>e)&&(F++,S[F]=[],P[F]=[],E[F]=[]),a[I]&&(S[F].push(I),P[F].push(c[I]),E[F].push(_[I]));S.forEach(function(I,U){let $=I.length;for(let q=0;q<$;q++){let Z=I[q];if(q===$-1){let V=0;E[U].forEach(function(D){V+=1e3-D});let Y=n?"bottom":"right",g=r?0:$-1,T=1e3-E[U][g];V=(s&&!n?100:0)+V/$-T,a[Z].innerHTML=Bn(P[U]).join(i),a[Z].style.display="block",a[Z].style[Y]=V+"%"}else a[Z].style.display="none"}})})}"use strict";var Wn={mounted(){let{facet:t,language:e,currency:i,currencyDecimal:s,currencyFormat:r,currencyPrecision:n,currencySymbol:o,currencyThousand:a,decimalPrecision:l,min:c,max:f,from:m,to:w,target:_}=this.el.dataset,S=this.el.dataset.autohideTooltips==="true",E=this.options.numberingSystem||"latn",P=(document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl",F=(()=>typeof r=="string"?new Bs(r,o,a,s,parseInt(n,10)):i?$i(e,i,parseInt(n,10),E):Ui(e,parseInt(l,10),E))();this.format=Xn(F),this.slider=qn(this.el,this.format,Ws({min:c,max:f,from:m,to:w},this.format),{rtl:P}),this.isUpdating=!1,this.slider.on("update",function(I,U){if(this.isUpdating)return;let[$,q]=I,Z=Math.floor(this.format.from($)),V=Math.ceil(this.format.from(q)),Y=parseFloat(this.el.dataset.actualMin),g=parseFloat(this.el.dataset.actualMax),T=!1,D=$,G=q;Z>g&&(D=this.format.to(g),T=!0),V{this.isUpdating=!1},0))}.bind(this)),this.slider.on("change",I=>{let[U,$]=I,Z={index:this.el.dataset.index,range:{[t]:{from:this.format.from(U),to:this.format.from($)}}};_?this.pushEventTo(_,"slide",Z):this.pushEvent("slide",Z)}),S||Jn(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 zn={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)}};"use strict";var Kn={mounted(){let t=0,e=0,i=null,s=50;/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&(this.touchMoveHandler=cl(),this.el.addEventListener("touchmove",this.touchMoveHandler)),this.el.addEventListener("touchstart",n=>{t=n.changedTouches[0].screenY,i=n.target},!1),this.el.addEventListener("touchend",n=>{if(i&&!dl(i))return;e=n.changedTouches[0].screenY;let o=e-t;if(!(Math.abs(o)<=s))if(o>0)switch(!0){case Yn():document.getElementById("dfd-ai-assistant-input").blur();break;case ul():this.pushEvent("medium-view",{});break;case Gn():this.pushEvent("reduced-view",{});break;case Zn():this.pushEvent("collapsed-view",{});break;default:this.pushEvent("medium-view",{});break}else switch(!0){case fl():this.pushEvent("medium-view",{});break;case Zn():this.pushEvent("medium-view",{});break;default:document.getElementById("dfd-ai-assistant-input").blur(),this.pushEvent("history-view",{});break}},!1)}};function cl(){let t=!1;return e=>{if(!t&&Yn()){let i=document.querySelector(".dfd-ai-input-textarea"),s=e.target;if(i&&s.closest(".dfd-ai-input-textarea"))return;t=!0,i&&document.activeElement===i&&i.blur(),setTimeout(()=>{t=!1},100)}}}function dl(t){return![".dfd-messages-list",".dfd-ai-assistant-suggestions",".dfd-compare-products"].some(i=>t.closest(i))}function Yn(){return window.innerHeight{let t=document.createElement("div");t.style.position="absolute",t.style.visibility="hidden",t.style.height="auto",t.style.width=this.el.offsetWidth+"px",t.style.fontSize=window.getComputedStyle(this.el).fontSize,t.style.fontFamily=window.getComputedStyle(this.el).fontFamily,t.style.lineHeight=window.getComputedStyle(this.el).lineHeight,t.style.padding=window.getComputedStyle(this.el).padding,t.style.border=window.getComputedStyle(this.el).border,t.innerHTML="A",document.body.appendChild(t);let e=t.offsetHeight;return document.body.removeChild(t),e},this.scrollMessagesToBottom=()=>{let t=document.querySelector(".dfd-messages-list");t&&t.scrollTo({top:t.scrollHeight,behavior:"smooth"}),this.isMobile||this.el.focus()},this.resize=()=>{this.el.style.height="auto";let t=this.el.scrollHeight,e=this.lineHeight*this.maxLines;t<=e?(t>0&&(this.el.style.height=t+"px"),this.el.style.overflowY="hidden"):(this.el.style.height=e+"px",this.el.style.overflowY="auto")},this.maxLines=4,this.originalHeight=this.el.scrollHeight,this.lineHeight=this.getLineHeight(),this.el.style.height="auto",this.el.style.overflowY="hidden",this.el.addEventListener("input",()=>this.resize()),this.el.addEventListener("change",()=>this.resize()),this.el.addEventListener("keyup",()=>this.resize()),this.el.addEventListener("paste",()=>{setTimeout(()=>this.resize(),0)}),this.el.addEventListener("keydown",t=>{if(t.key!="Enter"||t.shiftKey)return;t.preventDefault();let e=this.el.closest("form");if(e){let i=new Event("submit",{bubbles:!0,cancelable:!0});e.dispatchEvent(i)}}),this.handleEvent("set-textarea-value",t=>{t.id===this.el.id&&(this.el.value=t.value,this.resize())}),this.handleEvent("scroll-messages-to-bottom",()=>{this.scrollMessagesToBottom()}),this.resize()},updated(){this.resize()}};var Xi=window.SpeechRecognition||window.webkitSpeechRecognition||null,eo=["click"],to=["start","end","error","result"],pl="voice-search",io="voice-status-change";function ml(t){return t.results.length>0?t.results[0][0].transcript:null}var so={mounted(){if(!Xi){let t=window.isSecureContext===!0,e="SpeechRecognition"in window,i="webkitSpeechRecognition"in window;console.warn("VoiceSearch not supported: SpeechRecognition not available",{secureContext:t,hasSpeechRecognition:e,hasWebkitSpeechRecognition:i,userAgent:navigator.userAgent});return}this.recording=!1,this.query=null,this.driver=new Xi,this.driver.continuous=!1,this.driver.interimResults=!1,this.handleVoiceEvent=t=>{switch(t.type){case"end":case"error":if(console.error("VoiceSearch event error",{error:t.error,message:t.message}),this.driver.stop(),this.recording=!1,this.pushEvent(io,{recording:!1}),this.query){let e=this.el.dataset.dfdEvent||pl,i=this.el.getAttribute("dfd-target");i?this.pushEventTo(i,e,{query:this.query}):this.pushEvent(e,{query:this.query}),this.query=null}break;case"click":this.driver[this.recording?"stop":"start"](),this.recording=!this.recording,this.pushEvent(io,{recording:this.recording});break;case"result":{let e=ml(t);e&&(this.query=e);break}}},eo.forEach(t=>this.el.addEventListener(t,this.handleVoiceEvent)),to.forEach(t=>this.driver.addEventListener(t,this.handleVoiceEvent))},destroyed(){eo.forEach(t=>this.el.removeEventListener(t,this.handleVoiceEvent)),to.forEach(t=>this.driver.removeEventListener(t,this.handleVoiceEvent)),this.driver=null}};function re(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){x(`[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}var ro={mounted(){this.el.addEventListener("keydown",t=>{t.target===this.el&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),document.getElementById(this.el.dataset.cardLinkId).click())})}};"use strict";var no={mounted(){this.clearLoader=()=>{this.aiTextInterval&&(clearInterval(this.aiTextInterval),this.aiTextInterval=null)},this.initializeLoader=()=>{let t=this.el.querySelector(".dfd-loading-dynamic-text"),e=this.el.querySelectorAll(".dfd-loading-icon");if(!t||e.length===0)return;let i=JSON.parse(t.dataset.texts||"[]");if(i.length===0)return;let s=0;this.aiTextInterval=setInterval(()=>{s=s+1,s{n===s?r.classList.add("active"):r.classList.remove("active")})):this.clearLoader()},2500)},this.initializeLoader()},updated(){if(this.el.classList.contains("hidden")){this.clearLoader();return}this.el.querySelector(".dfd-loading-dynamic-text")&&!this.aiTextInterval&&this.initializeLoader()},destroyed(){this.clearLoader()}};var oo={mounted(){this.autoScrollInterval=null,this.isUserInteracting=!1,this.scrollTimeout=null,this.initialDelay=null,this.currentScrollElement=0,this.suggestions=this.el.children,this.startAutoScroll=()=>{if(this.autoScrollInterval||this.isUserInteracting||document.hidden)return;let t=this.el.scrollWidth,e=this.el.clientWidth;t<=e+10||(this.autoScrollInterval=setInterval(()=>{let i=window.getComputedStyle(this.el).visibility==="hidden";this.isUserInteracting||i||(this.currentScrollElement==this.suggestions.length-1?this.currentScrollElement=0:this.currentScrollElement++,this.suggestions[this.currentScrollElement].scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}))},3e3))},this.stopAutoScroll=()=>{this.autoScrollInterval&&(clearInterval(this.autoScrollInterval),this.autoScrollInterval=null)},this.pauseAutoScroll=()=>{this.isUserInteracting=!0,this.stopAutoScroll()},this.resumeAutoScrollDelayed=()=>{this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{this.isUserInteracting=!1,this.startAutoScroll()},3e3)},this.onUserScroll=()=>{this.pauseAutoScroll(),this.resumeAutoScrollDelayed()},this.handleVisibilityChange=()=>{document.hidden?this.stopAutoScroll():this.isUserInteracting||this.startAutoScroll()},this.initialDelay=setTimeout(()=>{this.startAutoScroll()},2e3),this.el.addEventListener("touchstart",this.pauseAutoScroll.bind(this)),this.el.addEventListener("mouseenter",this.pauseAutoScroll.bind(this)),this.el.addEventListener("scroll",this.onUserScroll.bind(this)),this.el.addEventListener("click",this.pauseAutoScroll.bind(this)),this.el.addEventListener("touchend",this.resumeAutoScrollDelayed.bind(this)),this.el.addEventListener("mouseleave",this.resumeAutoScrollDelayed.bind(this)),document.addEventListener("visibilitychange",this.handleVisibilityChange.bind(this))},destroyed(){this.stopAutoScroll(),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.initialDelay&&clearTimeout(this.initialDelay),document.removeEventListener("visibilitychange",this.handleVisibilityChange.bind(this))}};function ao(t){return JSON.parse(JSON.stringify(t))}function zs(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 Xt(t,e=!1){let i=Ds("__DF_LAYER_SERVER__")||`https://${t.toLowerCase()}-layer.doofinder.com`;return e?i.replace(/^http/,"ws"):i}function lo(){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 Ks(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));if(e)return decodeURIComponent(e[1])}function ho(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&&gl(s))}return!1}function gl(t){return t.getAttribute("type")==="submit"&&(t.tagName==="BUTTON"||t.tagName==="INPUT")}function Ys(t){return typeof t=="undefined"?null:t}var Gs=class{constructor(e,i){this.__options=H({id:`dfd-chat-bubble-${Xe()}`,tag:e},i),this.__triggerSetup(this.__options),this.__layerEventsSetup(),this.isMobile=/mobile/i.test(navigator.userAgent)}get tag(){return this.__options.tag}show(){!this.__trigger||this.__trigger.removeAttribute("hidden")}hide(){!this.__trigger||this.__trigger.setAttribute("hidden","")}destroy(){this.__triggerTeardown(),this.__layerEventsTeardown()}conversationalLayer(){return this.isMobile?"ai-mobile":"ai-fullscreen-initial"}__layerEventsSetup(){this.__eventAbortController=new AbortController,document.addEventListener("doofinder.show",e=>{this.hide()},{signal:this.__eventAbortController.signal}),document.addEventListener("doofinder.hide",e=>{this.show()},{signal:this.__eventAbortController.signal})}__layerEventsTeardown(){this.__eventAbortController&&(this.__eventAbortController.cancel(),delete this.__eventAbortController)}__triggerSetup({layerTrigger:e,bubble_extra_css:i}){let s=document.createElement("div");s.id=`${this.__options.id}-trigger`,s.classList.add("dfd-chat-trigger"),s.style.cssText=i||"";let r=document.createElement("template");r.innerHTML=this.__getBubbleIcon().trim(),s.appendChild(r.content.cloneNode(!0)),(e==null?void 0:e.backgroundColor)&&(s.style.backgroundColor=e.backgroundColor),(e==null?void 0:e.zIndex)&&(s.style.zIndex=e.zIndex),this.__trigger=s;let n=o=>R(this,null,function*(){o.preventDefault(),this.tag.open({screen:this.conversationalLayer()})});this.__trigger.addEventListener("click",n),document.body.append(this.__trigger)}__getBubbleIcon(){let e=this.__options.color||"#FFFFFF";return`
`}__triggerTeardown(){!this.__trigger||(this.__trigger.remove(),delete this.__trigger)}};var _l="Search",co=lo(),uo="latestSearches",vl=10,bl="dfd-root",qi=class{constructor(e){this.__handleTriggerEvent__=this.__handleTriggerEvent__.bind(this),this.__handleLinkClick__=this.__handleLinkClick__.bind(this),this.__handleDocumentMousedown__=this.__handleDocumentMousedown__.bind(this),this.__handleDocumentKeyup__=this.__handleDocumentKeyup__.bind(this),this.__updateSocketParams__=this.__updateSocketParams__.bind(this),this.__afterConnect__=this.__afterConnect__.bind(this),this.__afterDisconnect__=this.__afterDisconnect__.bind(this);let{autoload:i,currency:s,device:r,exportResultsData:n,hashid:o,id:a,installationId:l,is_checkout:c,language:f,layerType:m,search_query_retention:w,trigger:_,urlHash:S,zone:E}=e;this._installationId=l,this._zone=E,this._hashid=o,this._language=f,this._currency=s,this._exportResultsData=n,this._layerType=m,this._device=r,c&&this.dispatch("doofinder.layer.checkout",{url:window.location.href}),this._mount=this.__createMount__(a),this._mount.addEventListener("click",this.__handleLinkClick__),this._eventBus=new Is(this._mount.id),this._eventBusSubscriptions=[Ms,Vt,jt,Ns].map(P=>this._eventBus.on(P,this.__handleTriggerEvent__)),this._trigger=_,this._trigger.setEventBus(this._eventBus),this._display=new Rs(this._mount),this._state=this.__defineNewState__(l,i,S,m),this._data=new yt(`${l}.data`),this._sessionData=new yt(`${l}.data`,window.sessionStorage),this._params=this.__buildSocketParams__(e),this._hooks=this.__buildSocketHooks__(e),this._connection=null,this._connectedPromise=new He,this._theme=null,this._searchQueryRetention=w,this._urlHash=S,this._autoload=i,this.closable&&this.mount.classList.add("dfd-closable"),this._trigger.flushMessages(),this.__loadState__().then(()=>this.dispatch("doofinder.ready"))}__createMount__(e){let i=document.createElement("div");return i.id=e||`df-${Xe(32)}`,i.dataset.dfdView=_l,i.setAttribute(Me,""),i.classList.add(bl),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!==it||!this._state.hasAutoloadQueryParam}set targetItemId(e){this.state.targetItemId=e}enableDebug(){return this._connection?(this._connection.enableDebug(),!0):!1}debug(...e){x("[tag]",...e)}updateState({value:e=this._state.value,itemId:i=this._state.targetItemId,isTransitory:s=this._state.isTransitory}){this._state.update(e,i,s)}__handleTriggerEvent__(e){let{source:i,originalEvent:s}=e.detail,{query:r}=e.detail,n=r?{query:r}:{};this.connect(n).then(()=>{if(this.__shouldDisplay__(e)){this.show(i),e.type===jt&&this.search(r);return}e.type===Ns&&this.submit(r,o=>{var l;if(!o){this.show(i);return}let{submit:a}=o||{};a&&((l=s==null?void 0:s.target.closest("form"))==null||l.submit())})})}__shouldDisplay__(e){let{query:i,source:s={}}=e.detail,{tagName:r,role:n}=s,o=r==="BUTTON"||n==="button";switch(this._display.type){case Ei:return(e.type===jt||e.type===Vt)&&(this._display.screenType==="classic-initial"||!!i);case it:return(e.type===jt||e.type===Vt)&&!!i;case Si:case wi:return e.type===Ms||e.type===Vt&&!o;default:return!1}}__handleLinkClick__(e){var r,n;if(this.dispatch("doofinder.layer.click",{originalEvent:e}),e.target.href===window.location.href){e.preventDefault(),this.__closeAndPreserveQuery__();return}if(!e.target.href){(r=this._connection)==null||r.setPreventReconnect(!1);return}let i=e.target.closest("[dfd-value-dfid]"),s=i==null?void 0:i.getAttribute("dfd-value-dfid");s&&this.updateState({itemId:s}),(n=this._connection)==null||n.setPreventReconnect(!0),this._layerType!=="category_pages"&&this._searchQueryRetention&&this._state.saveTransitory(e.target.href)}__closeAndPreserveQuery__(){if(this.searchQueryRetention){let e=this._state.query;setTimeout(()=>{this._trigger.updateQuery(e)},300)}this.close()}__handleDocumentMousedown__(e){if(this._display.hidden||this._display.type===it||!ho(e))return;let{clientX:i,clientY:s}=e;if(zs(i,s,this._mount.getBoundingClientRect()))return;let r=this._display.method.positionReference;!!r&&(zs(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__(){return this._layerType==="category_pages"||(this.debug("load state:",this._state.value),this._trigger.updateQuery(this._searchQueryRetention?this._state.query:""),!this._state.value)?Promise.resolve():this._state.isTransitory?(x("didn't load the state because it is transitory"),Promise.resolve()):this.connect({state:this._state.value}).then(()=>this.show())}getLatestSearches(){return this._data.getItem(uo)||[]}updateLatestSearches(e){this._data.setItem(uo,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 R(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 R(this,null,function*(){yield this.updatePosition(e),yield this._display.show(),this.updateState({isTransitory:!1}),setTimeout(()=>{var i;return(i=this._connection)==null?void 0:i.pushEvent("update-scroll",{page:this.state.startPage,dfid:this.state.targetItemId})},200),this.dispatch("doofinder.show")})}hide(){return R(this,null,function*(){this._display&&(yield this._display.hide()),this.dispatch("doofinder.hide")})}dispatch(e,i={}){let s=xe(H({},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 ws(this.__connectionSetup__(e)),this._connection.connect(this.__afterConnect__)),this._connectedPromise}isConnected(){return this._connection?this._connection.connected:!1}open(){return R(this,arguments,function*(e={}){let{search:i,screen:s}=e,r=H({},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 R(this,null,function*(){let{search:i}=e,s={search:i},r=this._state.value;r&&(s.state=r),x("[category pages] connect with",s),yield this.connect(s),yield this.show(),r||(x("[category pages] no state, opening with: ",i),this.search(i))})}createChatBubble(e){this._bubble=new Gs(this,e),this._bubble.show()}disconnect(){var e;this.layerType!=="category_pages"&&(this.debug(`disconnecting from live socket: ${this._mount.id}`),this._trigger.updateQuery(""),this.updateState({value:"",itemId:null,isTransitory:!1}),this.hide(),(e=this._connection)==null||e.disconnect(this.__afterDisconnect__),this._connection=null,this._connectedPromise=new He)}destroy(){return R(this,null,function*(){var e,i;this.debug(`destroy: ${this._mount.id}`),this.hide(),(e=this._connection)==null||e.disconnect(this.__afterDisconnect__),this._connection=null,(i=this._bubble)==null||i.destroy(),this._bubble=null,this._eventBusSubscriptions.forEach(s=>s()),this._eventBusSubscriptions=null,this._eventBus.teardown(),this._eventBus=null,yield this._display.destroy(),this._display=null,this._trigger.destroy(),this._mount.replaceChildren(),this.dispatch("doofinder.destroy")})}getHooksByName(e){var i;return(i=this._connection)==null?void 0:i.getHooksByName(e)}search(e,i){var r;let s=typeof e=="string"?{query:e}:e;(r=this._connection)==null||r.pushEvent("search-suggest",{search:s},i)}changeLocale(e,i,s){var r;(r=this._connection)==null||r.pushEvent("change-locale",{language:e,currency:i},s)}submit(e,i){var s;(s=this._connection)==null||s.pushEvent("search-submit",{search:{query:e}},i)}updateLastActivity(){var i,s,r;let e=(s=(i=this._connection)==null?void 0:i.liveSocket)==null?void 0:s.socket.isIdle();x("update last activity. idle?:",e),(r=this._connection)==null||r.pushEvent("update-last-activity",{idle:e})}__buildSocketParams__(e){let{params:i,sort:s,vars:r,indices:n,state:o,priceName:a,hidePrices:l}=e,c={hashid:this._hashid,origin:window.location.hostname,indices:n,params:i,sort:s,vars:r,state:o,price_name:a,hide_prices:l,timezone_offset:new Date().getTimezoneOffset()};return["indices","search-server"].filter(f=>!c[f]).forEach(f=>delete c[f]),c}__buildSocketHooks__(e){let i=e.hooks||{},s={Carousel:re("Carousel",this,an,i.Carousel||{}),ImageSearch:re("ImageSearch",this,cn),Input:re("Input",this,un,i.Input||{}),Layer:re("Layer",this,bn,Sn,this.layerType==="category_pages"&&this._device==="mobile"?wn:{},i.Layer||{}),LayerNotAvailable:re("LayerNotAvailable",this,yn),AddToCart:re("AddToCart",this,fn,i.AddToCart||{}),AssistantLoading:re("AssistantLoading",this,no,i.AssistantLoading||{}),SuggestionsAutoScroll:re("SuggestionsAutoScroll",this,oo,i.SuggestionsAutoScroll||{}),EmbeddedResults:re("EmbeddedResults",this,js,co?Vs:{},i.EmbeddedResults||{}),Results:re("Results",this,Ln,co?Vs:{},js,i.Results||{}),Slider:re("Slider",this,Wn,i.Slider||{}),Swipe:re("Swipe",this,zn,i.Swipe||{}),MobileSwipe:re("MobileSwipe",this,Kn,i.MobileSwipe||{}),Textarea:re("Textarea",this,Qn,i.Textarea||{}),VoiceSearch:re("VoiceSearch",this,so,i.VoiceSearch||{}),CardTabNavigation:re("CardTabNavigation",this,ro,i.CardLink||{})};return x("[tag] Hooks created:",this._mount.id,s),Object.keys(i).filter(r=>!s[r]).forEach(r=>{s[r]=re(r,this,i[r]||{})}),s}__connectionSetup__(e){return{url:`${Xt(this._zone,!0)}/layer/${nt}`,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=xe(H({},ao(this._params)),{zone:this.zone,installation_id:this.installationId,language:this.language,currency:this.currency,session_id:Doofinder.Session.getSessionId(),tab_id:"getTabId"in Doofinder.Session?Doofinder.Session.getTabId():null,session_alive:Doofinder.Session.isLive("layer"),user_id:Doofinder.Session.getUserId(),latest_searches:this.getLatestSearches(),voice_supported:!!Xi,export_results_data:Ys((s=this.exportResultsData)==null?void 0:s.slice(0,vl)),ga_client_id:Ys((r=Ks("_ga"))==null?void 0:r.substring(6)),layer_type:this.layerType,state:this._state.value,mount_id:this._mount.id,current_url:window.location.href});return this._layerType==="category_pages"&&(i.search=e.search),((n=this._connection)==null?void 0:n.connected)||(i=H(H({},i),e)),this.debug(`__updateSocketParams__ for layer: ${this._mount.id}`,i," socket connected? ",(o=this._connection)==null?void 0:o.connected," overrides: ",e," current state",this._state.value),i}__afterConnect__(){document.addEventListener("mousedown",this.__handleDocumentMousedown__),document.addEventListener("keyup",this.__handleDocumentKeyup__,{passive:!0})}__afterDisconnect__(){document.removeEventListener("keyup",this.__handleDocumentKeyup__),document.removeEventListener("mousedown",this.__handleDocumentMousedown__),this.dispatch("doofinder.disconnect")}__defineNewState__(e,i,s,r){return new rt({installationId:e,autoload:i,urlHash:s,layerType:r})}};var yl=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 R(this,null,function*(){let e=document.createElement("style");e.appendChild(document.createTextNode((t||"").trim())),document.head.appendChild(e)})}function fo(t){return R(this,null,function*(){var o;let e=El(t);x("[category pages] displayForSeo options: ",t,"params: ",e);let i=yield wl(e);if(x("[category pages] displayForSeo htmlContent: ",i),!i)return;let s=Sl(t.id,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);x("[category pages] displayForSeo insertion point: ",n),n&&n.replaceWith(s)})}function Sl(t,e){let i=document.createElement("div");return i.id=t||`df-${Xe(32)}`,i.dataset.dfdView="Search",i.classList.add("dfd-root"),i.insertAdjacentHTML("afterbegin",e),i}function El(t){let{installationId:e,hashid:i,language:s,currency:r,zone:n,search:o,sort:a,urlHash:l,vars:c,layerType:f,autoload:m,priceName:w,hidePrices:_}=t,S=Doofinder.Session.getSessionId(),E=Doofinder.Session.getUserId(),P=new rt({installationId:e,autoload:m,urlHash:l,layerType:f}).value;return{installationId:e,hashid:i,language:s,currency:r,zone:n,state:P,search:o,sort:a,price_name:w,hide_prices:_,session_id:S,user_id:E,vars:c}}function wl(t){return R(this,null,function*(){let{zone:e}=t,i=Xt(e),s=new URL(`${i}/api/${nt}/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():""})})}function po(t){let{hashid:e,url_patterns:i}=t,s=window.location.toString();return x("[category merchandising] __getNewOptions__ category merchandising URL patterns: ",i," url: ",s),Al(e,i,s)}function Al(t,e,i){try{let s=Cl(t,e,i);if(!s)return x("[category merchandising] configuration not found for current location, urlStr: ",i),null;let r=Qs(s),n=[...i.matchAll(r)][0].groups,o=xl(s,n);return o.url_pattern_id=s.id,x("[category merchandising] configuration found for current location, urlStr: ",i,"URLPattern: ",s,"capturedValues from URL: ",n,"params to open the layer: ",o),o}catch(s){return x("[category merchandising] error trying to get category merchandising search options: ",s),null}}function Cl(t,e,i){let s=e.filter(r=>r.hashid===t).find(r=>{let n=Qs(r);return[...i.matchAll(n)].length>0});return s||e.filter(r=>!r.hashid).find(r=>{let n=Qs(r);return[...i.matchAll(n)].length>0})}function Qs(t){let[,,e,i]=t.pattern.match(/(\/?)(.+)\1([a-z]*)/i);i=i||"g";let s=new RegExp(e,i);return x("pattern ",e,"flags",i,"regexp",s),s}function xl(t,e){let i="{{",s="}}",{params:r}=t,n=JSON.stringify(r.search);for(let o in e){let a=`${i}${o}${s}`,l=Tl(t,o,`${e[o]}`);x("[category merchandising] replacing old value: ",a,", new value ",l,"at",n),n=n.replaceAll(a,l)}return JSON.parse(n)}function Tl(t,e,i){var r;let s=(r=t.params)==null?void 0:r.transformers;if(!s||!s[e])return x("[category merchandising] __applyTransformer__ transformers not found in URLPattern",t," for ",e),i;try{return Array.isArray(s[e])?kl(s[e],i):typeof s[e]=="string"?Pl(s[e],i):i}catch(n){x("[category merchandising] __applyTransformer__ error ","URLPattern: ",t,"key",e,"value",i,"error",n)}return i}function kl(t,e){x("[category merchandising] __applyTransformerDefinedAsArray__ ",t);let[i,s]=t,r=i.split("."),n=window[r[0]];return r.slice(1).forEach(o=>n=window[o]),typeof n=="function"?(x("[category merchandising] __applyTransformer__ call function ",i," args: ",[e,s]),n(e,s)):(x("[category merchandising] __applyTransformer__ transformer",i," is not a function. Type: ",typeof n),e)}function Pl(t,e){let i=(0,eval)(t);return x("[category merchandising] __applyTransformerDefinedAsString__ completionValue obtained with eval",i," evaluated code ",t),typeof i=="function"?i(e):e}var Ji=[];document.addEventListener("doofinder.destroy",t=>{Ji=Ji.filter(e=>e!==t.detail)});var mo={getTags(){return Ji.slice(0)},create(t){let e=new qi(t);return t.layerType==="category_pages"&&(t.search=po(t),t.search&&(fo(t),e.openCategoryPages(t))),"chat"in t&&t.chat.bubble_enabled&&e.createChatBubble(H({layerTrigger:t.trigger},t.chat)),Ji.push(e),e},destroy(t){var e;t instanceof qi?t.destroy():(e=t==null?void 0:t.doofinderTag)==null||e.destroy()},enableDebug:en,disableDebug:tn,debug:x,utils:{buildNumericFormatter:Ui,buildCurrencyFormatter:$i}};Object.defineProperty(mo,"__version__",{value:nt});pr(fr,mo);})();