var BeaconHooks=(()=>{var f=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var u=(t,e)=>{for(var d in e)f(t,d,{get:e[d],enumerable:!0})},x=(t,e,d,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of p(e))!r.call(t,a)&&a!==d&&f(t,a,{get:()=>e[a],enumerable:!(l=o(e,a))||l.enumerable});return t};var b=t=>x(f({},"__esModule",{value:!0}),t);var g={};u(g,{default:()=>c});var c={};return b(g);})();

var Phoenix=(()=>{var x=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var D=(a,e)=>{for(var t in e)x(a,t,{get:e[t],enumerable:!0})},U=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of M(e))!P.call(a,s)&&s!==t&&x(a,s,{get:()=>e[s],enumerable:!(i=$(e,s))||i.enumerable});return a};var J=a=>U(x({},"__esModule",{value:!0}),a);var F={};D(F,{Channel:()=>y,LongPoll:()=>m,Presence:()=>g,Serializer:()=>j,Socket:()=>w});var v=a=>typeof a=="function"?a:function(){return a};var z=typeof self!="undefined"?self:null,k=typeof window!="undefined"?window:null,T=z||k||T,H="2.0.0",d={connecting:0,open:1,closing:2,closed:3},N=1e4,O=1e3,u={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},p={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},A={longpoll:"longpoll",websocket:"websocket"},B={complete:4};var b=class{constructor(e,t,i,s){this.channel=e,this.event=t,this.payload=i||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(e){this.timeout=e,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(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:e,response:t,_ref:i}){this.recHooks.filter(s=>s.status===e).forEach(s=>s.callback(t))}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,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}};var R=class{constructor(e,t){this.callback=e,this.timerCalc=t,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))}};var y=class{constructor(e,t,i){this.state=u.closed,this.topic=e,this.params=v(t||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new b(this,p.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new R(()=>{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=u.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=u.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=u.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=u.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 b(this,p.leave,v({}),this.timeout).send(),this.state=u.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(p.reply,(s,o)=>{this.trigger(this.replyEventName(o),s)})}join(e=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=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(e){this.on(p.close,e)}onError(e){return this.on(p.error,t=>e(t))}on(e,t){let i=this.bindingRef++;return this.bindings.push({event:e,ref:i,callback:t}),i}off(e,t){this.bindings=this.bindings.filter(i=>!(i.event===e&&(typeof t=="undefined"||t===i.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,i=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new b(this,e,function(){return t},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=u.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(p.close,"leave")},i=new b(this,p.leave,v({}),e);return i.receive("ok",()=>t()).receive("timeout",()=>t()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(e,t,i){return t}isMember(e,t,i,s){return this.topic!==e?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:i,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=u.joining,this.joinPush.resend(e))}trigger(e,t,i,s){let o=this.onMessage(e,t,i,s);if(t&&!o)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(n=>n.event===e);for(let n=0;n<r.length;n++)r[n].callback(o,i,s||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===u.closed}isErrored(){return this.state===u.errored}isJoined(){return this.state===u.joined}isJoining(){return this.state===u.joining}isLeaving(){return this.state===u.leaving}};var C=class{static request(e,t,i,s,o,r,n){if(T.XDomainRequest){let h=new T.XDomainRequest;return this.xdomainRequest(h,e,t,s,o,r,n)}else{let h=new T.XMLHttpRequest;return this.xhrRequest(h,e,t,i,s,o,r,n)}}static xdomainRequest(e,t,i,s,o,r,n){return e.timeout=o,e.open(t,i),e.onload=()=>{let h=this.parseJSON(e.responseText);n&&n(h)},r&&(e.ontimeout=r),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,i,s,o,r,n,h){return e.open(t,i,!0),e.timeout=r,e.setRequestHeader("Content-Type",s),e.onerror=()=>h&&h(null),e.onreadystatechange=()=>{if(e.readyState===B.complete&&h){let l=this.parseJSON(e.responseText);h(l)}},n&&(e.ontimeout=n),e.send(o),e}static parseJSON(e){if(!e||e==="")return null;try{return JSON.parse(e)}catch(t){return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let i=[];for(var s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;let o=t?`${t}[${s}]`:s,r=e[s];typeof r=="object"?i.push(this.serialize(r,o)):i.push(encodeURIComponent(o)+"="+encodeURIComponent(r))}return i.join("&")}static appendParams(e,t){if(Object.keys(t).length===0)return e;let i=e.match(/\?/)?"&":"?";return`${e}${i}${this.serialize(t)}`}};var I=a=>{let e="",t=new Uint8Array(a),i=t.byteLength;for(let s=0;s<i;s++)e+=String.fromCharCode(t[s]);return btoa(e)},m=class{constructor(e){this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=d.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+A.websocket),"$1/"+A.longpoll)}endpointURL(){return C.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,i){this.close(e,t,i),this.readyState=d.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===d.open||this.readyState===d.connecting}poll(){this.ajax("GET","application/json",null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:i,messages:s}=e;this.token=i}else t=0;switch(t){case 200:s.forEach(o=>{setTimeout(()=>this.onmessage({data:o}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=d.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 ${t}`)}})}send(e){typeof e!="string"&&(e=I(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e){this.awaitingBatchAck=!0,this.ajax("POST","application/x-ndjson",e.join(`
`),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=!1,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(e,t,i){for(let o of this.reqs)o.abort();this.readyState=d.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent!="undefined"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(e,t,i,s,o){let r,n=()=>{this.reqs.delete(r),s()};r=C.request(e,this.endpointURL(),t,i,this.timeout,n,h=>{this.reqs.delete(r),this.isActive()&&o(h)}),this.reqs.add(r)}};var g=class{constructor(e,t={}){let i=t.events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=e,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(i.state,s=>{let{onJoin:o,onLeave:r,onSync:n}=this.caller;this.joinRef=this.channel.joinRef(),this.state=g.syncState(this.state,s,o,r),this.pendingDiffs.forEach(h=>{this.state=g.syncDiff(this.state,h,o,r)}),this.pendingDiffs=[],n()}),this.channel.on(i.diff,s=>{let{onJoin:o,onLeave:r,onSync:n}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=g.syncDiff(this.state,s,o,r),n())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(e){return g.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,t,i,s){let o=this.clone(e),r={},n={};return this.map(o,(h,l)=>{t[h]||(n[h]=l)}),this.map(t,(h,l)=>{let f=o[h];if(f){let c=l.metas.map(S=>S.phx_ref),E=f.metas.map(S=>S.phx_ref),L=l.metas.filter(S=>E.indexOf(S.phx_ref)<0),_=f.metas.filter(S=>c.indexOf(S.phx_ref)<0);L.length>0&&(r[h]=l,r[h].metas=L),_.length>0&&(n[h]=this.clone(f),n[h].metas=_)}else r[h]=l}),this.syncDiff(o,{joins:r,leaves:n},i,s)}static syncDiff(e,t,i,s){let{joins:o,leaves:r}=this.clone(t);return i||(i=function(){}),s||(s=function(){}),this.map(o,(n,h)=>{let l=e[n];if(e[n]=this.clone(h),l){let f=e[n].metas.map(E=>E.phx_ref),c=l.metas.filter(E=>f.indexOf(E.phx_ref)<0);e[n].metas.unshift(...c)}i(n,l,h)}),this.map(r,(n,h)=>{let l=e[n];if(!l)return;let f=h.metas.map(c=>c.phx_ref);l.metas=l.metas.filter(c=>f.indexOf(c.phx_ref)<0),s(n,l,h),l.metas.length===0&&delete e[n]}),e}static list(e,t){return t||(t=function(i,s){return s}),this.map(e,(i,s)=>t(i,s))}static map(e,t){return Object.getOwnPropertyNames(e).map(i=>t(i,e[i]))}static clone(e){return JSON.parse(JSON.stringify(e))}};var j={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(a,e){if(a.payload.constructor===ArrayBuffer)return e(this.binaryEncode(a));{let t=[a.join_ref,a.ref,a.topic,a.event,a.payload];return e(JSON.stringify(t))}},decode(a,e){if(a.constructor===ArrayBuffer)return e(this.binaryDecode(a));{let[t,i,s,o,r]=JSON.parse(a);return e({join_ref:t,ref:i,topic:s,event:o,payload:r})}},binaryEncode(a){let{join_ref:e,ref:t,event:i,topic:s,payload:o}=a,r=this.META_LENGTH+e.length+t.length+s.length+i.length,n=new ArrayBuffer(this.HEADER_LENGTH+r),h=new DataView(n),l=0;h.setUint8(l++,this.KINDS.push),h.setUint8(l++,e.length),h.setUint8(l++,t.length),h.setUint8(l++,s.length),h.setUint8(l++,i.length),Array.from(e,c=>h.setUint8(l++,c.charCodeAt(0))),Array.from(t,c=>h.setUint8(l++,c.charCodeAt(0))),Array.from(s,c=>h.setUint8(l++,c.charCodeAt(0))),Array.from(i,c=>h.setUint8(l++,c.charCodeAt(0)));var f=new Uint8Array(n.byteLength+o.byteLength);return f.set(new Uint8Array(n),0),f.set(new Uint8Array(o),n.byteLength),f.buffer},binaryDecode(a){let e=new DataView(a),t=e.getUint8(0),i=new TextDecoder;switch(t){case this.KINDS.push:return this.decodePush(a,e,i);case this.KINDS.reply:return this.decodeReply(a,e,i);case this.KINDS.broadcast:return this.decodeBroadcast(a,e,i)}},decodePush(a,e,t){let i=e.getUint8(1),s=e.getUint8(2),o=e.getUint8(3),r=this.HEADER_LENGTH+this.META_LENGTH-1,n=t.decode(a.slice(r,r+i));r=r+i;let h=t.decode(a.slice(r,r+s));r=r+s;let l=t.decode(a.slice(r,r+o));r=r+o;let f=a.slice(r,a.byteLength);return{join_ref:n,ref:null,topic:h,event:l,payload:f}},decodeReply(a,e,t){let i=e.getUint8(1),s=e.getUint8(2),o=e.getUint8(3),r=e.getUint8(4),n=this.HEADER_LENGTH+this.META_LENGTH,h=t.decode(a.slice(n,n+i));n=n+i;let l=t.decode(a.slice(n,n+s));n=n+s;let f=t.decode(a.slice(n,n+o));n=n+o;let c=t.decode(a.slice(n,n+r));n=n+r;let E=a.slice(n,a.byteLength),L={status:c,response:E};return{join_ref:h,ref:l,topic:f,event:p.reply,payload:L}},decodeBroadcast(a,e,t){let i=e.getUint8(1),s=e.getUint8(2),o=this.HEADER_LENGTH+2,r=t.decode(a.slice(o,o+i));o=o+i;let n=t.decode(a.slice(o,o+s));o=o+s;let h=a.slice(o,a.byteLength);return{join_ref:null,ref:null,topic:r,event:n,payload:h}}};var w=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||N,this.transport=t.transport||T.WebSocket||m,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||T&&T.sessionStorage,this.establishedConnections=0,this.defaultEncoder=j.encode.bind(j),this.defaultDecoder=j.decode.bind(j),this.closeWasClean=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==m?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;k&&k.addEventListener&&(k.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),k.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect())})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>t.rejoinAfterMs?t.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>t.reconnectAfterMs?t.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(s,o,r)=>{console.log(`${s}: ${o}`,r)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=v(t.params||{}),this.endPoint=`${e}/${A.websocket}`,this.vsn=t.vsn||H,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new R(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return m}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=C.appendParams(C.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)!=="/"?e:e.charAt(1)==="/"?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,i){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(e,t,i)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=v(e)),!this.conn&&(this.longPollFallbackMs&&this.transport!==m?this.connectWithFallback(m,this.longPollFallbackMs):this.transportConnect())}log(e,t,i){this.logger&&this.logger(e,t,i)}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(o=>{o.ref===t&&(this.off([s]),e(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=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let i=!1,s=!0,o,r,n=h=>{this.log("transport",`falling back to ${e.name}...`,h),this.off([o,r]),s=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${e.name}`))return n("memorized");this.fallbackTimer=setTimeout(n,t),r=this.onError(h=>{this.log("transport","error",h),s&&!i&&(clearTimeout(this.fallbackTimer),n(h))}),this.onOpen(()=>{if(i=!0,!s)return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${e.name}`,"true"),this.log("transport",`established ${e.name} fallback`);clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(n,t),this.ping(h=>{this.log("transport","connected to primary after",h),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transport.name} connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,e])=>e())}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(),O,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,i){if(!this.conn)return e&&e();this.waitForBufferDone(()=>{this.conn&&(t?this.conn.close(t,i||""):this.conn.close()),this.waitForSocketClosed(()=>{this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t=1){if(t===5||!this.conn||!this.conn.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(e,t+1)},150*t)}waitForSocketClosed(e,t=1){if(t===5||!this.conn||this.conn.readyState===d.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(e,t+1)},150*t)}onConnClose(e){let t=e&&e.code;this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&t!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(e))}onConnError(e){this.hasLogger()&&this.log("transport",e);let t=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(e,t,i)}),(t===this.transport||i>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(p.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case d.connecting:return"connecting";case d.open:return"open";case d.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([i])=>e.indexOf(i)===-1)}channel(e,t={}){let i=new y(e,t,this);return this.channels.push(i),i}push(e){if(this.hasLogger()){let{topic:t,event:i,payload:s,ref:o,join_ref:r}=e;this.log("push",`${t} ${i} (${r}, ${o})`,s)}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,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(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,t=>{let{topic:i,event:s,payload:o,ref:r,join_ref:n}=t;r&&r===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${o.status||""} ${i} ${s} ${r&&"("+r+")"||""}`,o);for(let h=0;h<this.channels.length;h++){let l=this.channels[h];l.isMember(i,s,o,n)&&l.trigger(s,o,r,n)}for(let h=0;h<this.stateChangeCallbacks.message.length;h++){let[,l]=this.stateChangeCallbacks.message[h];l(t)}})}leaveOpenTopic(e){let t=this.channels.find(i=>i.topic===e&&(i.isJoined()||i.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}};return J(F);})();
"use strict";

(function() {
  var PolyfillEvent = eventConstructor();

  function eventConstructor() {
    if (typeof window.CustomEvent === "function") return window.CustomEvent;
    // IE<=9 Support
    function CustomEvent(event, params) {
      params = params || {bubbles: false, cancelable: false, detail: undefined};
      var evt = document.createEvent('CustomEvent');
      evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
      return evt;
    }
    CustomEvent.prototype = window.Event.prototype;
    return CustomEvent;
  }

  function buildHiddenInput(name, value) {
    var input = document.createElement("input");
    input.type = "hidden";
    input.name = name;
    input.value = value;
    return input;
  }

  function handleClick(element, targetModifierKey) {
    var to = element.getAttribute("data-to"),
        method = buildHiddenInput("_method", element.getAttribute("data-method")),
        csrf = buildHiddenInput("_csrf_token", element.getAttribute("data-csrf")),
        form = document.createElement("form"),
        submit = document.createElement("input"),
        target = element.getAttribute("target");

    form.method = (element.getAttribute("data-method") === "get") ? "get" : "post";
    form.action = to;
    form.style.display = "none";

    if (target) form.target = target;
    else if (targetModifierKey) form.target = "_blank";

    form.appendChild(csrf);
    form.appendChild(method);
    document.body.appendChild(form);

    // Insert a button and click it instead of using `form.submit`
    // because the `submit` function does not emit a `submit` event.
    submit.type = "submit";
    form.appendChild(submit);
    submit.click();
  }

  window.addEventListener("click", function(e) {
    var element = e.target;
    if (e.defaultPrevented) return;

    while (element && element.getAttribute) {
      var phoenixLinkEvent = new PolyfillEvent('phoenix.link.click', {
        "bubbles": true, "cancelable": true
      });

      if (!element.dispatchEvent(phoenixLinkEvent)) {
        e.preventDefault();
        e.stopImmediatePropagation();
        return false;
      }

      if (element.getAttribute("data-method") && element.getAttribute("data-to")) {
        handleClick(element, e.metaKey || e.shiftKey);
        e.preventDefault();
        return false;
      } else {
        element = element.parentNode;
      }
    }
  }, false);

  window.addEventListener('phoenix.link.click', function (e) {
    var message = e.target.getAttribute("data-confirm");
    if(message && !window.confirm(message)) {
      e.preventDefault();
    }
  }, false);
})();
var LiveView=(()=>{var Ye=Object.defineProperty,Ei=Object.defineProperties,yi=Object.getOwnPropertyDescriptor,Pi=Object.getOwnPropertyDescriptors,ki=Object.getOwnPropertyNames,ze=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var $t=(r,e,t)=>e in r?Ye(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,I=(r,e)=>{for(var t in e||(e={}))mt.call(e,t)&&$t(r,t,e[t]);if(ze)for(var t of ze(e))Bt.call(e,t)&&$t(r,t,e[t]);return r},De=(r,e)=>Ei(r,Pi(e));var Vt=(r,e)=>{var t={};for(var i in r)mt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&ze)for(var i of ze(r))e.indexOf(i)<0&&Bt.call(r,i)&&(t[i]=r[i]);return t};var Ci=(r,e)=>{for(var t in e)Ye(r,t,{get:e[t],enumerable:!0})},Ri=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ki(e))!mt.call(r,s)&&s!==t&&Ye(r,s,{get:()=>e[s],enumerable:!(i=yi(e,s))||i.enumerable});return r};var Ti=r=>Ri(Ye({},"__esModule",{value:!0}),r);var rs={};Ci(rs,{LiveSocket:()=>qe,createHook:()=>ss,isUsedInput:()=>Si});var Qe="consecutive-reloads";var Ze=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],$="data-phx-component",et="data-phx-link",jt="track-static",Jt="data-phx-link-state",le="data-phx-ref-loading",O="data-phx-ref-src",L="data-phx-ref-lock",tt="track-uploads",B="data-phx-upload-ref",Ee="data-phx-preflighted-refs",Wt="data-phx-done-refs",gt="drop-target",Ne="data-phx-active-refs",ye="phx:live-file:updated",it="data-phx-skip",st="data-phx-id",vt="data-phx-prune",bt="phx-connected",ae="phx-loading",fe="phx-error",At="phx-client-error",Pe="phx-server-error",Z="data-phx-parent-id",ke="data-phx-main",J="data-phx-root-id",Fe="viewport-top",Me="viewport-bottom",_t="trigger-action",pe="phx-has-focused",qt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],rt=["checkbox","radio"],me="phx-has-submitted",M="data-phx-session",q=`[${M}]`,St="data-phx-sticky",ee="data-phx-static",Ue="data-phx-readonly",he="data-phx-disabled",wt="disable-with",Ce="data-phx-disable-with-restore",Re="hook",Kt="debounce",Gt="throttle",ge="update",nt="stream",Te="data-phx-stream",zt="key",K="phxPrivate",Et="auto-recover",Xe="phx:live-socket:debug",ot="phx:live-socket:profiling",lt="phx:live-socket:latency-sim",$e="phx:nav-history-position",Yt="progress",yt="mounted",Pt="__phoenix_reload_status__",Qt=1,kt=3,Zt=200,ei="phx-",ti=3e4;var xe="debounce-trigger",Ie="throttled",Ct="debounce-prev-key",ii={debounce:300,throttle:300},Rt=[le,O,L],Be="d",G="s",at="r",H="c",Tt="e",xt="r",It="t",si="p",Ot="stream";var Ve=class{constructor(e,t,i){let{chunk_size:s,chunk_timeout:n}=t;this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=s,this.chunkTimeout=n,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.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,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return x("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){this.uploadChannel.isJoined()&&this.uploadChannel.push("chunk",e,this.chunkTimeout).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:t})=>this.error(t))}};var x=(r,e)=>console.error&&console.error(r,e),W=r=>{let e=typeof r;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(r)};function ri(){let r=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)r.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):r.add(e[t].id)}var ni=(r,e,t,i)=>{r.liveSocket.isDebugEnabled()&&console.log(`${r.id} ${e}: ${t} - `,i)},Oe=r=>typeof r=="function"?r:function(){return r},Le=r=>JSON.parse(JSON.stringify(r)),ve=(r,e,t)=>{do{if(r.matches(`[${e}]`)&&!r.disabled)return r;r=r.parentElement||r.parentNode}while(r!==null&&r.nodeType===1&&!(t&&t.isSameNode(r)||r.matches(q)));return null},be=r=>r!==null&&typeof r=="object"&&!(r instanceof Array),oi=(r,e)=>JSON.stringify(r)===JSON.stringify(e),Lt=r=>{for(let e in r)return!1;return!0},z=(r,e)=>r&&e(r),li=function(r,e,t,i){r.forEach(s=>{new Ve(s,t.config,i).upload()})};var xi={canPushState(){return typeof history.pushState!="undefined"},dropLocal(r,e,t){return r.removeItem(this.localKey(e,t))},updateLocal(r,e,t,i,s){let n=this.getLocal(r,e,t),o=this.localKey(e,t),l=n===null?i:s(n);return r.setItem(o,JSON.stringify(l)),l},getLocal(r,e,t){return JSON.parse(r.getItem(this.localKey(e,t)))},updateCurrentState(r){this.canPushState()&&history.replaceState(r(history.state||{}),"",window.location.href)},pushState(r,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let i=history.state||{};i.scroll=e.scroll,history.replaceState(i,"",window.location.href)}delete e.scroll,history[r+"State"](e,"",t||null),window.requestAnimationFrame(()=>{let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)})}}else this.redirect(t)},setCookie(r,e,t){let i=typeof t=="number"?` max-age=${t};`:"";document.cookie=`${r}=${e};${i} path=/`},getCookie(r){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${r}s*=s*([^;]*).*$)|^.*$`),"$1")},deleteCookie(r){document.cookie=`${r}=; max-age=-1; path=/`},redirect(r,e){e&&this.setCookie("__phoenix_flash__",e,60),window.location=r},localKey(r,e){return`${r}-${e}`},getHashTargetEl(r){let e=r.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},D=xi;var Ae={byId(r){return document.getElementById(r)||x(`no id found for ${r}`)},removeClass(r,e){r.classList.remove(e),r.classList.length===0&&r.removeAttribute("class")},all(r,e,t){if(!r)return[];let i=Array.from(r.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(r){let e=document.createElement("template");return e.innerHTML=r,e.content.childElementCount},isUploadInput(r){return r.type==="file"&&r.getAttribute(B)!==null},isAutoUpload(r){return r.hasAttribute("data-phx-auto-upload")},findUploadInputs(r){let e=r.id,t=this.all(document,`input[type="file"][${B}][form="${e}"]`);return this.all(r,`input[type="file"][${B}]`).concat(t)},findComponentNodeList(r,e){return this.filterWithinSameLiveView(this.all(r,`[${$}="${e}"]`),r)},isPhxDestroyed(r){return!!(r.id&&Ae.private(r,"destroyed"))},wantsNewTab(r){let e=r.ctrlKey||r.shiftKey||r.metaKey||r.button&&r.button===1,t=r.target instanceof HTMLAnchorElement&&r.target.hasAttribute("download"),i=r.target.hasAttribute("target")&&r.target.getAttribute("target").toLowerCase()==="_blank",s=r.target.hasAttribute("target")&&!r.target.getAttribute("target").startsWith("_");return e||i||t||s},isUnloadableFormSubmit(r){return r.target&&r.target.getAttribute("method")==="dialog"||r.submitter&&r.submitter.getAttribute("formmethod")==="dialog"?!1:!r.defaultPrevented&&!this.wantsNewTab(r)},isNewPageClick(r,e){let t=r.target instanceof HTMLAnchorElement?r.target.getAttribute("href"):null,i;if(r.defaultPrevented||t===null||this.wantsNewTab(r)||t.startsWith("mailto:")||t.startsWith("tel:")||r.target.isContentEditable)return!1;try{i=new URL(t)}catch(s){try{i=new URL(t,e)}catch(n){return!0}}return i.host===e.host&&i.protocol===e.protocol&&i.pathname===e.pathname&&i.search===e.search?i.hash===""&&!i.href.endsWith("#"):i.protocol.startsWith("http")},markPhxChildDestroyed(r){this.isPhxChild(r)&&r.setAttribute(M,""),this.putPrivate(r,"destroyed",!0)},findPhxChildrenInFragment(r,e){let t=document.createElement("template");return t.innerHTML=r,this.findPhxChildren(t.content,e)},isIgnored(r,e){return(r.getAttribute(e)||r.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(r,e,t){return r.getAttribute&&t.indexOf(r.getAttribute(e))>=0},findPhxSticky(r){return this.all(r,`[${St}]`)},findPhxChildren(r,e){return this.all(r,`${q}[${Z}="${e}"]`)},findExistingParentCIDs(r,e){let t=new Set,i=new Set;return e.forEach(s=>{this.filterWithinSameLiveView(this.all(r,`[${$}="${s}"]`),r).forEach(n=>{t.add(s),this.all(n,`[${$}]`).map(o=>parseInt(o.getAttribute($))).forEach(o=>i.add(o))})}),i.forEach(s=>t.delete(s)),t},filterWithinSameLiveView(r,e){return e.querySelector(q)?r.filter(t=>this.withinSameLiveView(t,e)):r},withinSameLiveView(r,e){for(;r=r.parentNode;){if(r.isSameNode(e))return!0;if(r.getAttribute(M)!==null)return!1}},private(r,e){return r[K]&&r[K][e]},deletePrivate(r,e){r[K]&&delete r[K][e]},putPrivate(r,e,t){r[K]||(r[K]={}),r[K][e]=t},updatePrivate(r,e,t,i){let s=this.private(r,e);s===void 0?this.putPrivate(r,e,i(t)):this.putPrivate(r,e,i(s))},syncPendingAttrs(r,e){r.hasAttribute(O)&&(Ze.forEach(t=>{r.classList.contains(t)&&e.classList.add(t)}),Rt.filter(t=>r.hasAttribute(t)).forEach(t=>{e.setAttribute(t,r.getAttribute(t))}))},copyPrivates(r,e){e[K]&&(r[K]=e[K])},putTitle(r){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i,default:s}=e.dataset,n=typeof r!="string"||r.trim()==="";if(n&&typeof s!="string")return;let o=n?s:r;document.title=`${t||""}${o||""}${i||""}`}else document.title=r},debounce(r,e,t,i,s,n,o,l){let a=r.getAttribute(t),d=r.getAttribute(s);a===""&&(a=i),d===""&&(d=n);let c=a||d;switch(c){case null:return l();case"blur":this.once(r,"debounce-blur")&&r.addEventListener("blur",()=>{o()&&l()});return;default:let p=parseInt(c),m=()=>d?this.deletePrivate(r,Ie):l(),g=this.incCycle(r,xe,m);if(isNaN(p))return x(`invalid throttle/debounce value: ${c}`);if(d){let v=!1;if(e.type==="keydown"){let b=this.private(r,Ct);this.putPrivate(r,Ct,e.key),v=b!==e.key}if(!v&&this.private(r,Ie))return!1;{l();let b=setTimeout(()=>{o()&&this.triggerCycle(r,xe)},p);this.putPrivate(r,Ie,b)}}else setTimeout(()=>{o()&&this.triggerCycle(r,xe,g)},p);let u=r.form;u&&this.once(u,"bind-debounce")&&u.addEventListener("submit",()=>{Array.from(new FormData(u).entries(),([v])=>{let b=u.querySelector(`[name="${v}"]`);this.incCycle(b,xe),this.deletePrivate(b,Ie)})}),this.once(r,"bind-debounce")&&r.addEventListener("blur",()=>{clearTimeout(this.private(r,Ie)),this.triggerCycle(r,xe)})}},triggerCycle(r,e,t){let[i,s]=this.private(r,e);t||(t=i),t===i&&(this.incCycle(r,e),s())},once(r,e){return this.private(r,e)===!0?!1:(this.putPrivate(r,e,!0),!0)},incCycle(r,e,t=function(){}){let[i]=this.private(r,e)||[0,t];return i++,this.putPrivate(r,e,[i,t]),i},maintainPrivateHooks(r,e,t,i){r.hasAttribute&&r.hasAttribute("data-phx-hook")&&!e.hasAttribute("data-phx-hook")&&e.setAttribute("data-phx-hook",r.getAttribute("data-phx-hook")),e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute(i))&&e.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},putCustomElHook(r,e){r.isConnected?r.setAttribute("data-phx-hook",""):console.error(`
        hook attached to non-connected DOM element
        ensure you are calling createHook within your connectedCallback. ${r.outerHTML}
      `),this.putPrivate(r,"custom-el-hook",e)},getCustomElHook(r){return this.private(r,"custom-el-hook")},isUsedInput(r){return r.nodeType===Node.ELEMENT_NODE&&(this.private(r,pe)||this.private(r,me))},resetForm(r){Array.from(r.elements).forEach(e=>{this.deletePrivate(e,pe),this.deletePrivate(e,me)})},isPhxChild(r){return r.getAttribute&&r.getAttribute(Z)},isPhxSticky(r){return r.getAttribute&&r.getAttribute(St)!==null},isChildOfAny(r,e){return!!e.find(t=>t.contains(r))},firstPhxChild(r){return this.isPhxChild(r)?r:this.all(r,`[${Z}]`)[0]},dispatchEvent(r,e,t={}){let i=!0;r.nodeName==="INPUT"&&r.type==="file"&&e==="click"&&(i=!1);let o={bubbles:t.bubbles===void 0?i:!!t.bubbles,cancelable:!0,detail:t.detail||{}},l=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);r.dispatchEvent(l)},cloneNode(r,e){if(typeof e=="undefined")return r.cloneNode(!0);{let t=r.cloneNode(!1);return t.innerHTML=e,t}},mergeAttrs(r,e,t={}){let i=new Set(t.exclude||[]),s=t.isIgnored,n=e.attributes;for(let l=n.length-1;l>=0;l--){let a=n[l].name;if(i.has(a))a==="value"&&r.value===e.value&&r.setAttribute("value",e.getAttribute(a));else{let d=e.getAttribute(a);r.getAttribute(a)!==d&&(!s||s&&a.startsWith("data-"))&&r.setAttribute(a,d)}}let o=r.attributes;for(let l=o.length-1;l>=0;l--){let a=o[l].name;s?a.startsWith("data-")&&!e.hasAttribute(a)&&!Rt.includes(a)&&r.removeAttribute(a):e.hasAttribute(a)||r.removeAttribute(a)}},mergeFocusedInput(r,e){r instanceof HTMLSelectElement||Ae.mergeAttrs(r,e,{exclude:["value"]}),e.readOnly?r.setAttribute("readonly",!0):r.removeAttribute("readonly")},hasSelectionRange(r){return r.setSelectionRange&&(r.type==="text"||r.type==="textarea")},restoreFocus(r,e,t){if(r instanceof HTMLSelectElement&&r.focus(),!Ae.isTextualInput(r))return;r.matches(":focus")||r.focus(),this.hasSelectionRange(r)&&r.setSelectionRange(e,t)},isFormInput(r){return/^(?:input|select|textarea)$/i.test(r.tagName)&&r.type!=="button"},syncAttrsToProps(r){r instanceof HTMLInputElement&&rt.indexOf(r.type.toLocaleLowerCase())>=0&&(r.checked=r.getAttribute("checked")!==null)},isTextualInput(r){return qt.indexOf(r.type)>=0},isNowTriggerFormExternal(r,e){return r.getAttribute&&r.getAttribute(e)!==null&&document.body.contains(r)},cleanChildNodes(r,e){if(Ae.isPhxUpdate(r,e,["append","prepend"])){let t=[];r.childNodes.forEach(i=>{i.id||(!(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()==="")&&i.nodeType!==Node.COMMENT_NODE&&x(`only HTML element tags with an id are allowed inside containers with phx-update.

removing illegal node: "${(i.outerHTML||i.nodeValue).trim()}"

`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(r,e,t){let i=new Set(["id",M,ee,ke,J]);if(r.tagName.toLowerCase()===e.toLowerCase())return Array.from(r.attributes).filter(s=>!i.has(s.name.toLowerCase())).forEach(s=>r.removeAttribute(s.name)),Object.keys(t).filter(s=>!i.has(s.toLowerCase())).forEach(s=>r.setAttribute(s,t[s])),r;{let s=document.createElement(e);return Object.keys(t).forEach(n=>s.setAttribute(n,t[n])),i.forEach(n=>s.setAttribute(n,r.getAttribute(n))),s.innerHTML=r.innerHTML,r.replaceWith(s),s}},getSticky(r,e,t){let i=(Ae.private(r,"sticky")||[]).find(([s])=>e===s);if(i){let[s,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(r,e){this.updatePrivate(r,"sticky",[],t=>t.filter(([i,s])=>i!==e))},putSticky(r,e,t){let i=t(r);this.updatePrivate(r,"sticky",[],s=>{let n=s.findIndex(([o])=>e===o);return n>=0?s[n]=[e,t,i]:s.push([e,t,i]),s})},applyStickyOperations(r){let e=Ae.private(r,"sticky");e&&e.forEach(([t,i,s])=>this.putSticky(r,t,i))}},h=Ae;var se=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(Ne).split(",").indexOf(C.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(Ee).split(",").indexOf(C.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,s){this.ref=C.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,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(ye,this._onElUpdated),this.autoUpload=s}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,()=>{C.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(ye,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||C.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(ye,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Ne).split(",").indexOf(this.ref)===-1&&(C.untrackFile(this.fileEl,this.file),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 t=e[this.meta.uploader]||x(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:li}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||x(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Ii=0,C=class r{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(Ii++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(Ee)!==i.getAttribute(Wt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},o=e.getAttribute(B);i[o]=i[o]||[],n.ref=this.genFileRef(s),n.last_modified=s.lastModified,n.name=s.name||n.ref,n.relative_path=s.webkitRelativePath,n.type=s.type,n.size=s.size,typeof s.meta=="function"&&(n.meta=s.meta()),i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(B),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let s=t.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));h.updatePrivate(e,"files",[],n=>n.concat(s)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>se.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!se.isPreflighted(e,t)&&!se.isPreflightInProgress(t))}static markPreflightInProgress(e){e.forEach(t=>se.markPreflightInProgress(t.file))}constructor(e,t,i){this.autoUpload=h.isAutoUpload(e),this.view=t,this.onComplete=i,this._entries=Array.from(r.filesAwaitingPreflight(e)||[]).map(s=>new se(e,s,t,this.autoUpload)),r.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}isAutoUpload(){return this.autoUpload}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),n));let s=this._entries.reduce((n,o)=>{if(!o.meta)return n;let{name:l,callback:a}=o.uploader(i.uploaders);return n[l]=n[l]||{callback:a,entries:[]},n[l].entries.push(o),n},{});for(let n in s){let{callback:o,entries:l}=s[n];o(l,t,e,i)}}};var Oi={anyOf(r,e){return e.find(t=>r instanceof t)},isFocusable(r,e){return r instanceof HTMLAnchorElement&&r.rel!=="ignore"||r instanceof HTMLAreaElement&&r.href!==void 0||!r.disabled&&this.anyOf(r,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||r instanceof HTMLIFrameElement||r.tabIndex>0||!e&&r.getAttribute("tabindex")!==null&&r.getAttribute("aria-hidden")!=="true"},attemptFocus(r,e){if(this.isFocusable(r,e))try{r.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(r)},focusFirstInteractive(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(r){let e=r.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},de=Oi;var di={LiveFileUpload:{activeRefs(){return this.el.getAttribute(Ne)},preflightedRefs(){return this.el.getAttribute(Ee)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let r=this.preflightedRefs();this.preflightedWas!==r&&(this.preflightedWas=r,r===""&&this.__view().cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(ye))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(B)),C.getEntryDataURL(this.inputEl,this.ref,r=>{this.url=r,this.el.src=r})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>de.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>de.focusFirst(this.el)),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&de.focusFirst(this.el)}}},ui=r=>["HTML","BODY"].indexOf(r.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(r).overflowY)>=0?r:ui(r.parentElement),ai=r=>r?r.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,Ht=r=>r?r.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,Dt=r=>r?r.getBoundingClientRect().top:0,Li=(r,e)=>{let t=r.getBoundingClientRect();return Math.ceil(t.top)>=Dt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=Ht(e)},Hi=(r,e)=>{let t=r.getBoundingClientRect();return Math.ceil(t.bottom)>=Dt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.bottom)<=Ht(e)},hi=(r,e)=>{let t=r.getBoundingClientRect();return Math.ceil(t.top)>=Dt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=Ht(e)};di.InfiniteScroll={mounted(){this.scrollContainer=ui(this.el);let r=ai(this.scrollContainer),e=!1,t=500,i=null,s=this.throttle(t,(l,a)=>{i=()=>!0,this.liveSocket.execJSHookPush(this.el,l,{id:a.id,_overran:!0},()=>{i=null})}),n=this.throttle(t,(l,a)=>{i=()=>a.scrollIntoView({block:"start"}),this.liveSocket.execJSHookPush(this.el,l,{id:a.id},()=>{i=null,window.requestAnimationFrame(()=>{hi(a,this.scrollContainer)||a.scrollIntoView({block:"start"})})})}),o=this.throttle(t,(l,a)=>{i=()=>a.scrollIntoView({block:"end"}),this.liveSocket.execJSHookPush(this.el,l,{id:a.id},()=>{i=null,window.requestAnimationFrame(()=>{hi(a,this.scrollContainer)||a.scrollIntoView({block:"end"})})})});this.onScroll=l=>{let a=ai(this.scrollContainer);if(i)return r=a,i();let d=this.el.getBoundingClientRect(),c=this.el.getAttribute(this.liveSocket.binding("viewport-top")),p=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),m=this.el.lastElementChild,g=this.el.firstElementChild,u=a<r,v=a>r;u&&c&&!e&&d.top>=0?(e=!0,s(c,g)):v&&e&&d.top<=0&&(e=!1),c&&u&&Li(g,this.scrollContainer)?n(c,g):p&&v&&Hi(m,this.scrollContainer)&&o(p,m),r=a},this.scrollContainer?this.scrollContainer.addEventListener("scroll",this.onScroll):window.addEventListener("scroll",this.onScroll)},destroyed(){this.scrollContainer?this.scrollContainer.removeEventListener("scroll",this.onScroll):window.removeEventListener("scroll",this.onScroll)},throttle(r,e){let t=0,i;return(...s)=>{let n=Date.now(),o=r-(n-t);o<=0||o>r?(i&&(clearTimeout(i),i=null),t=n,e(...s)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...s)},o))}}};var ci=di;var je=class{constructor(e){this.el=e,this.loadingRef=e.hasAttribute(le)?parseInt(e.getAttribute(le),10):null,this.lockRef=e.hasAttribute(L)?parseInt(e.getAttribute(L),10):null}maybeUndo(e,t,i){this.isWithin(e)&&(this.undoLocks(e,t,i),this.undoLoading(e,t),this.isFullyResolvedBy(e)&&this.el.removeAttribute(O))}isWithin(e){return!(this.loadingRef!==null&&this.loadingRef>e&&this.lockRef!==null&&this.lockRef>e)}undoLocks(e,t,i){if(!this.isLockUndoneBy(e))return;let s=h.private(this.el,L);s&&(i(s),h.deletePrivate(this.el,L)),this.el.removeAttribute(L);let n={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,n))}undoLoading(e,t){if(!this.isLoadingUndoneBy(e)){this.canUndoLoading(e)&&this.el.classList.contains("phx-submit-loading")&&this.el.classList.remove("phx-change-loading");return}if(this.canUndoLoading(e)){this.el.removeAttribute(le);let i=this.el.getAttribute(he),s=this.el.getAttribute(Ue);s!==null&&(this.el.readOnly=s==="true",this.el.removeAttribute(Ue)),i!==null&&(this.el.disabled=i==="true",this.el.removeAttribute(he));let n=this.el.getAttribute(Ce);n!==null&&(this.el.innerText=n,this.el.removeAttribute(Ce));let o={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,o))}Ze.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(e))&&h.removeClass(this.el,i)})}isLoadingUndoneBy(e){return this.loadingRef===null?!1:this.loadingRef<=e}isLockUndoneBy(e){return this.lockRef===null?!1:this.lockRef<=e}isFullyResolvedBy(e){return(this.loadingRef===null||this.loadingRef<=e)&&(this.lockRef===null||this.lockRef<=e)}canUndoLoading(e){return this.lockRef===null||this.lockRef<=e}};var Je=class{constructor(e,t,i){let s=new Set,n=new Set([...t.children].map(l=>l.id)),o=[];Array.from(e.children).forEach(l=>{if(l.id&&(s.add(l.id),n.has(l.id))){let a=l.previousElementSibling&&l.previousElementSibling.id;o.push({elementId:l.id,previousElementId:a})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(l=>!s.has(l))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?z(document.getElementById(t.previousElementId),i=>{z(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):z(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{z(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var fi=11;function Di(r,e){var t=e.attributes,i,s,n,o,l;if(!(e.nodeType===fi||r.nodeType===fi)){for(var a=t.length-1;a>=0;a--)i=t[a],s=i.name,n=i.namespaceURI,o=i.value,n?(s=i.localName||s,l=r.getAttributeNS(n,s),l!==o&&(i.prefix==="xmlns"&&(s=i.name),r.setAttributeNS(n,s,o))):(l=r.getAttribute(s),l!==o&&r.setAttribute(s,o));for(var d=r.attributes,c=d.length-1;c>=0;c--)i=d[c],s=i.name,n=i.namespaceURI,n?(s=i.localName||s,e.hasAttributeNS(n,s)||r.removeAttributeNS(n,s)):e.hasAttribute(s)||r.removeAttribute(s)}}var ht,Ni="http://www.w3.org/1999/xhtml",U=typeof document=="undefined"?void 0:document,Fi=!!U&&"content"in U.createElement("template"),Mi=!!U&&U.createRange&&"createContextualFragment"in U.createRange();function Ui(r){var e=U.createElement("template");return e.innerHTML=r,e.content.childNodes[0]}function Xi(r){ht||(ht=U.createRange(),ht.selectNode(U.body));var e=ht.createContextualFragment(r);return e.childNodes[0]}function $i(r){var e=U.createElement("body");return e.innerHTML=r,e.childNodes[0]}function Bi(r){return r=r.trim(),Fi?Ui(r):Mi?Xi(r):$i(r)}function dt(r,e){var t=r.nodeName,i=e.nodeName,s,n;return t===i?!0:(s=t.charCodeAt(0),n=i.charCodeAt(0),s<=90&&n>=97?t===i.toUpperCase():n<=90&&s>=97?i===t.toUpperCase():!1)}function Vi(r,e){return!e||e===Ni?U.createElement(r):U.createElementNS(e,r)}function ji(r,e){for(var t=r.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Nt(r,e,t){r[t]!==e[t]&&(r[t]=e[t],r[t]?r.setAttribute(t,""):r.removeAttribute(t))}var pi={OPTION:function(r,e){var t=r.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(r.hasAttribute("selected")&&!e.selected&&(r.setAttribute("selected","selected"),r.removeAttribute("selected")),t.selectedIndex=-1)}Nt(r,e,"selected")},INPUT:function(r,e){Nt(r,e,"checked"),Nt(r,e,"disabled"),r.value!==e.value&&(r.value=e.value),e.hasAttribute("value")||r.removeAttribute("value")},TEXTAREA:function(r,e){var t=e.value;r.value!==t&&(r.value=t);var i=r.firstChild;if(i){var s=i.nodeValue;if(s==t||!t&&s==r.placeholder)return;i.nodeValue=t}},SELECT:function(r,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,s=r.firstChild,n,o;s;)if(o=s.nodeName&&s.nodeName.toUpperCase(),o==="OPTGROUP")n=s,s=n.firstChild;else{if(o==="OPTION"){if(s.hasAttribute("selected")){t=i;break}i++}s=s.nextSibling,!s&&n&&(s=n.nextSibling,n=null)}r.selectedIndex=t}}},We=1,mi=11,gi=3,vi=8;function ue(){}function Ji(r){if(r)return r.getAttribute&&r.getAttribute("id")||r.id}function Wi(r){return function(t,i,s){if(s||(s={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=U.createElement("html"),i.innerHTML=n}else i=Bi(i);else i.nodeType===mi&&(i=i.firstElementChild);var o=s.getNodeKey||Ji,l=s.onBeforeNodeAdded||ue,a=s.onNodeAdded||ue,d=s.onBeforeElUpdated||ue,c=s.onElUpdated||ue,p=s.onBeforeNodeDiscarded||ue,m=s.onNodeDiscarded||ue,g=s.onBeforeElChildrenUpdated||ue,u=s.skipFromChildren||ue,v=s.addChild||function(_,S){return _.appendChild(S)},b=s.childrenOnly===!0,T=Object.create(null),Q=[];function P(_){Q.push(_)}function V(_,S){if(_.nodeType===We)for(var R=_.firstChild;R;){var w=void 0;S&&(w=o(R))?P(w):(m(R),R.firstChild&&V(R,S)),R=R.nextSibling}}function F(_,S,R){p(_)!==!1&&(S&&S.removeChild(_),m(_),V(_,R))}function N(_){if(_.nodeType===We||_.nodeType===mi)for(var S=_.firstChild;S;){var R=o(S);R&&(T[R]=S),N(S),S=S.nextSibling}}N(t);function f(_){a(_);for(var S=_.firstChild;S;){var R=S.nextSibling,w=o(S);if(w){var k=T[w];k&&dt(S,k)?(S.parentNode.replaceChild(k,S),X(k,S)):f(S)}else f(S);S=R}}function A(_,S,R){for(;S;){var w=S.nextSibling;(R=o(S))?P(R):F(S,_,!0),S=w}}function X(_,S,R){var w=o(S);if(w&&delete T[w],!R){var k=d(_,S);if(k===!1||(k instanceof HTMLElement&&(_=k,N(_)),r(_,S),c(_),g(_,S)===!1))return}_.nodeName!=="TEXTAREA"?te(_,S):pi.TEXTAREA(_,S)}function te(_,S){var R=u(_,S),w=S.firstChild,k=_.firstChild,Se,ie,we,Ke,ne;e:for(;w;){for(Ke=w.nextSibling,Se=o(w);!R&&k;){if(we=k.nextSibling,w.isSameNode&&w.isSameNode(k)){w=Ke,k=we;continue e}ie=o(k);var Ge=k.nodeType,oe=void 0;if(Ge===w.nodeType&&(Ge===We?(Se?Se!==ie&&((ne=T[Se])?we===ne?oe=!1:(_.insertBefore(ne,k),ie?P(ie):F(k,_,!0),k=ne,ie=o(k)):oe=!1):ie&&(oe=!1),oe=oe!==!1&&dt(k,w),oe&&X(k,w)):(Ge===gi||Ge==vi)&&(oe=!0,k.nodeValue!==w.nodeValue&&(k.nodeValue=w.nodeValue))),oe){w=Ke,k=we;continue e}ie?P(ie):F(k,_,!0),k=we}if(Se&&(ne=T[Se])&&dt(ne,w))R||v(_,ne),X(ne,w);else{var pt=l(w);pt!==!1&&(pt&&(w=pt),w.actualize&&(w=w.actualize(_.ownerDocument||U)),v(_,w),f(w))}w=Ke,k=we}A(_,k,ie);var Xt=pi[_.nodeName];Xt&&Xt(_,S)}var E=t,j=E.nodeType,re=i.nodeType;if(!b){if(j===We)re===We?dt(t,i)||(m(t),E=ji(t,Vi(i.nodeName,i.namespaceURI))):E=i;else if(j===gi||j===vi){if(re===j)return E.nodeValue!==i.nodeValue&&(E.nodeValue=i.nodeValue),E;E=i}}if(E===i)m(t);else{if(i.isSameNode&&i.isSameNode(E))return;if(X(E,i,b),Q)for(var ct=0,wi=Q.length;ct<wi;ct++){var ft=T[Q[ct]];ft&&F(ft,ft.parentNode,!1)}}return!b&&E!==t&&t.parentNode&&(E.actualize&&(E=E.actualize(t.ownerDocument||U)),t.parentNode.replaceChild(E,t)),E}}var qi=Wi(Di),Ft=qi;var ce=class{static patchWithClonedTree(e,t,i){let s=i.getActiveElement(),{selectionStart:n,selectionEnd:o}=s&&h.hasSelectionRange(s)?s:{},l=i.binding(ge),a=null;Ft(e,t,{childrenOnly:!1,onBeforeElUpdated:(d,c)=>{if(h.syncPendingAttrs(d,c),!e.isSameNode(d)&&d.hasAttribute(L)||h.isIgnored(d,l))return!1;if(s&&s.isSameNode(d)&&h.isFormInput(d))return h.mergeFocusedInput(d,c),!1;h.isNowTriggerFormExternal(c,i.binding(_t))&&(a=c)}}),a&&(i.unload(),Object.getPrototypeOf(a).submit.call(a)),i.silenceEvents(()=>h.restoreFocus(s,n,o))}constructor(e,t,i,s,n,o){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=o,this.cidPatch=W(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=this.isCIDPatch()?this.targetCIDContainer(s):t,this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(ge);h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(vt,"")})}perform(e){let{view:t,liveSocket:i,html:s,container:n,targetContainer:o}=this;if(this.isCIDPatch()&&!o)return;let l=i.getActiveElement(),{selectionStart:a,selectionEnd:d}=l&&h.hasSelectionRange(l)?l:{},c=i.binding(ge),p=i.binding(Fe),m=i.binding(Me),g=i.binding(_t),u=[],v=[],b=[],T=null;function Q(P,V,F=!1){let N={childrenOnly:P.getAttribute($)===null&&!F,getNodeKey:f=>h.isPhxDestroyed(f)?null:e?f.id:f.id||f.getAttribute&&f.getAttribute(st),skipFromChildren:f=>f.getAttribute(c)===nt,addChild:(f,A)=>{let{ref:X,streamAt:te}=this.getStreamInsert(A);if(X===void 0)return f.appendChild(A);if(this.setStreamRef(A,X),te===0)f.insertAdjacentElement("afterbegin",A);else if(te===-1){let E=f.lastElementChild;if(E&&!E.hasAttribute(Te)){let j=Array.from(f.children).find(re=>!re.hasAttribute(Te));f.insertBefore(A,j)}else f.appendChild(A)}else if(te>0){let E=Array.from(f.children)[te];f.insertBefore(A,E)}},onBeforeNodeAdded:f=>{h.maintainPrivateHooks(f,f,p,m),this.trackBefore("added",f);let A=f;return this.streamComponentRestore[f.id]&&(A=this.streamComponentRestore[f.id],delete this.streamComponentRestore[f.id],Q.call(this,A,f,!0)),A},onNodeAdded:f=>{f.getAttribute&&this.maybeReOrderStream(f,!0),f instanceof HTMLImageElement&&f.srcset?f.srcset=f.srcset:f instanceof HTMLVideoElement&&f.autoplay&&f.play(),h.isNowTriggerFormExternal(f,g)&&(T=f),(h.isPhxChild(f)&&t.ownsElement(f)||h.isPhxSticky(f)&&t.ownsElement(f.parentNode))&&this.trackAfter("phxChildAdded",f),u.push(f)},onNodeDiscarded:f=>this.onNodeDiscarded(f),onBeforeNodeDiscarded:f=>f.getAttribute&&f.getAttribute(vt)!==null?!0:!(f.parentElement!==null&&f.id&&h.isPhxUpdate(f.parentElement,c,[nt,"append","prepend"])||this.maybePendingRemove(f)||this.skipCIDSibling(f)),onElUpdated:f=>{h.isNowTriggerFormExternal(f,g)&&(T=f),v.push(f),this.maybeReOrderStream(f,!1)},onBeforeElUpdated:(f,A)=>{if(f.id&&f.isSameNode(P)&&f.id!==A.id)return N.onNodeDiscarded(f),f.replaceWith(A),N.onNodeAdded(A);if(h.syncPendingAttrs(f,A),h.maintainPrivateHooks(f,A,p,m),h.cleanChildNodes(A,c),this.skipCIDSibling(A))return this.maybeReOrderStream(f),!1;if(h.isPhxSticky(f))return[M,ee,J].map(E=>[E,f.getAttribute(E),A.getAttribute(E)]).forEach(([E,j,re])=>{re&&j!==re&&f.setAttribute(E,re)}),!1;if(h.isIgnored(f,c)||f.form&&f.form.isSameNode(T))return this.trackBefore("updated",f,A),h.mergeAttrs(f,A,{isIgnored:h.isIgnored(f,c)}),v.push(f),h.applyStickyOperations(f),!1;if(f.type==="number"&&f.validity&&f.validity.badInput)return!1;let X=l&&f.isSameNode(l)&&h.isFormInput(f),te=X&&this.isChangedSelect(f,A);if(f.hasAttribute(O)){h.isUploadInput(f)&&(h.mergeAttrs(f,A,{isIgnored:!0}),this.trackBefore("updated",f,A),v.push(f)),h.applyStickyOperations(f);let j=f.hasAttribute(L)?h.private(f,L)||f.cloneNode(!0):null;j&&(h.putPrivate(f,L,j),X||(f=j))}if(h.isPhxChild(A)){let E=f.getAttribute(M);return h.mergeAttrs(f,A,{exclude:[ee]}),E!==""&&f.setAttribute(M,E),f.setAttribute(J,this.rootID),h.applyStickyOperations(f),!1}return h.copyPrivates(A,f),X&&f.type!=="hidden"&&!te?(this.trackBefore("updated",f,A),h.mergeFocusedInput(f,A),h.syncAttrsToProps(f),v.push(f),h.applyStickyOperations(f),!1):(te&&f.blur(),h.isPhxUpdate(A,c,["append","prepend"])&&b.push(new Je(f,A,A.getAttribute(c))),h.syncAttrsToProps(A),h.applyStickyOperations(A),this.trackBefore("updated",f,A),f)}};Ft(P,V,N)}return this.trackBefore("added",n),this.trackBefore("updated",n,n),i.time("morphdom",()=>{this.streams.forEach(([P,V,F,N])=>{V.forEach(([f,A,X])=>{this.streamInserts[f]={ref:P,streamAt:A,limit:X,reset:N}}),N!==void 0&&h.all(n,`[${Te}="${P}"]`,f=>{this.removeStreamChildElement(f)}),F.forEach(f=>{let A=n.querySelector(`[id="${f}"]`);A&&this.removeStreamChildElement(A)})}),e&&h.all(this.container,`[${c}=${nt}]`,P=>{this.liveSocket.owner(P,V=>{V===this.view&&Array.from(P.children).forEach(F=>{this.removeStreamChildElement(F)})})}),Q.call(this,o,s)}),i.isDebugEnabled()&&(ri(),Array.from(document.querySelectorAll("input[name=id]")).forEach(P=>{P.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
`,P)})),b.length>0&&i.time("post-morph append/prepend restoration",()=>{b.forEach(P=>P.perform())}),i.silenceEvents(()=>h.restoreFocus(l,a,d)),h.dispatchEvent(document,"phx:update"),u.forEach(P=>this.trackAfter("added",P)),v.forEach(P=>this.trackAfter("updated",P)),this.transitionPendingRemoves(),T&&(i.unload(),Object.getPrototypeOf(T).submit.call(T)),!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.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,t){h.putSticky(e,Te,i=>i.setAttribute(Te,t))}maybeReOrderStream(e,t){let{ref:i,streamAt:s,reset:n}=this.getStreamInsert(e);if(s!==void 0&&(this.setStreamRef(e,i),!(!n&&!t)&&e.parentElement)){if(s===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(s>0){let o=Array.from(e.parentElement.children),l=o.indexOf(e);if(s>=o.length-1)e.parentElement.appendChild(e);else{let a=o[s];l>s?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:t}=this.getStreamInsert(e),i=t!==null&&Array.from(e.parentElement.children);t&&t<0&&i.length>t*-1?i.slice(0,i.length+t).forEach(s=>this.removeStreamChildElement(s)):t&&t>=0&&i.length>t&&i.slice(t).forEach(s=>this.removeStreamChildElement(s))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&t.transitionRemoves(e,!1,()=>{e.forEach(i=>{let s=h.firstPhxChild(i);s&&t.destroyViewByEl(s),i.remove()}),this.trackAfter("transitionsDiscarded",e)})}isChangedSelect(e,t){return!(e instanceof HTMLSelectElement)||e.multiple?!1:e.options.length!==t.options.length?!0:(t.value=e.value,!e.isEqualNode(t))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(it)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}indexOf(e,t){return Array.from(e.children).indexOf(t)}};var Ki=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Gi=new Set(["'",'"']),bi=(r,e,t)=>{let i=0,s=!1,n,o,l,a,d,c,p=r.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${r}`);for(i=p[0].length,n=p[1],l=p[2],a=i,i;i<r.length&&r.charAt(i)!==">";i++)if(r.charAt(i)==="="){let u=r.slice(i-3,i)===" id";i++;let v=r.charAt(i);if(Gi.has(v)){let b=i;for(i++,i;i<r.length&&r.charAt(i)!==v;i++);if(u){d=r.slice(b+1,i);break}}}let m=r.length-1;for(s=!1;m>=n.length+l.length;){let u=r.charAt(m);if(s)u==="-"&&r.slice(m-3,m)==="<!-"?(s=!1,m-=4):m-=1;else if(u===">"&&r.slice(m-2,m)==="--")s=!0,m-=3;else{if(u===">")break;m-=1}}o=r.slice(m+1,r.length);let g=Object.keys(e).map(u=>e[u]===!0?u:`${u}="${e[u]}"`).join(" ");if(t){let u=d?` id="${d}"`:"";Ki.has(l)?c=`<${l}${u}${g===""?"":" "}${g}/>`:c=`<${l}${u}${g===""?"":" "}${g}></${l}>`}else{let u=r.slice(a,m+1);c=`<${l}${g===""?"":" "}${g}${u}`}return[c,n,o]},He=class{static extract(e){let{[xt]:t,[Tt]:i,[It]:s}=e;return delete e[xt],delete e[Tt],delete e[It],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[H],e,!0,{});return[t,i]}recursiveToString(e,t=e[H],i,s,n){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,s,n),[o.buffer,o.streams]}componentCIDs(e){return Object.keys(e[H]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[H]?Object.keys(e).length===1:!1}getComponent(e,t){return e[H][t]}resetRender(e){this.rendered[H][e]&&(this.rendered[H][e].reset=!0)}mergeDiff(e){let t=e[H],i={};if(delete e[H],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[H]=this.rendered[H]||{},t){let s=this.rendered[H];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],s,t,i);for(let n in t)s[n]=t[n];e[H]=t}}cachedFindComponent(e,t,i,s,n){if(n[e])return n[e];{let o,l,a=t[G];if(W(a)){let d;a>0?d=this.cachedFindComponent(a,s[a],i,s,n):d=i[-a],l=d[G],o=this.cloneMerge(d,t,!0),o[G]=l}else o=t[G]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return n[e]=o,o}}mutableMerge(e,t){return t[G]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let s=t[i],n=e[i];be(s)&&s[G]===void 0&&be(n)?this.doMutableMerge(n,s):e[i]=s}e[at]&&(e.newRender=!0)}cloneMerge(e,t,i){let s=I(I({},e),t);for(let n in s){let o=t[n],l=e[n];be(o)&&o[G]===void 0&&be(l)?s[n]=this.cloneMerge(l,o,i):o===void 0&&be(l)&&(s[n]=this.cloneMerge(l,{},i))}return i?(delete s.magicId,delete s.newRender):e[at]&&(s.newRender=!0),s}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[H],e,null),[s,n,o]=bi(t,{});return[s,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[H][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[G]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,t,i,s,n={}){if(e[Be])return this.comprehensionToBuffer(e,t,i);let{[G]:o}=e;o=this.templateStatic(o,t);let l=e[at],a=i.buffer;l&&(i.buffer=""),s&&l&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let d=1;d<o.length;d++)this.dynamicToBuffer(e[d-1],t,i,s),i.buffer+=o[d];if(l){let d=!1,c;s||e.magicId?(d=s&&!e.newRender,c=I({[st]:e.magicId},n)):c=n,d&&(c[it]=!0);let[p,m,g]=bi(i.buffer,c,d);e.newRender=!1,i.buffer=a+m+p+g}}comprehensionToBuffer(e,t,i){let{[Be]:s,[G]:n,[Ot]:o}=e,[l,a,d,c]=o||[null,{},[],null];n=this.templateStatic(n,t);let p=t||e[si];for(let m=0;m<s.length;m++){let g=s[m];i.buffer+=n[0];for(let u=1;u<n.length;u++)this.dynamicToBuffer(g[u-1],p,i,!1),i.buffer+=n[u]}o!==void 0&&(e[Be].length>0||d.length>0||c)&&(delete e[Ot],e[Be]=[],i.streams.add(o))}dynamicToBuffer(e,t,i,s){if(typeof e=="number"){let[n,o]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=n,i.streams=new Set([...i.streams,...o])}else be(e)?this.toOutputBuffer(e,t,i,s,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||x(`no component for CID ${t}`,e),n={[$]:t},o=i&&!i.has(t);s.newRender=!o,s.magicId=`c${t}-${this.parentViewId()}`;let l=!s.reset,[a,d]=this.recursiveToString(s,e,i,l,n);return delete s.reset,[a,d]}};var Ai=[],_i=200,zi={exec(r,e,t,i,s,n){let[o,l]=n||[null,{callback:n&&n.callback}];(t.charAt(0)==="["?JSON.parse(t):[[o,l]]).forEach(([d,c])=>{d===o&&(c=I(I({},l),c),c.callback=c.callback||l.callback),this.filterToEls(i.liveSocket,s,c).forEach(p=>{this[`exec_${d}`](r,e,t,i,s,p,c)})})},isVisible(r){return!!(r.offsetWidth||r.offsetHeight||r.getClientRects().length>0)},isInViewport(r){let e=r.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth;return e.right>0&&e.bottom>0&&e.left<i&&e.top<t},exec_exec(r,e,t,i,s,n,{attr:o,to:l}){(l?h.all(document,l):[s]).forEach(d=>{let c=d.getAttribute(o);if(!c)throw new Error(`expected ${o} to contain JS command on "${l}"`);i.liveSocket.execJS(d,c,e)})},exec_dispatch(r,e,t,i,s,n,{event:o,detail:l,bubbles:a}){l=l||{},l.dispatcher=s,h.dispatchEvent(n,o,{detail:l,bubbles:a})},exec_push(r,e,t,i,s,n,o){let{event:l,data:a,target:d,page_loading:c,loading:p,value:m,dispatcher:g,callback:u}=o,v={loading:p,value:m,target:d,page_loading:!!c},b=e==="change"&&g?g:s,T=d||b.getAttribute(i.binding("target"))||b,Q=(P,V)=>{if(P.isConnected())if(e==="change"){let{newCid:F,_target:N}=o;N=N||(h.isFormInput(s)?s.name:void 0),N&&(v._target=N),P.pushInput(s,V,F,l||t,v,u)}else if(e==="submit"){let{submitter:F}=o;P.submitForm(s,V,l||t,F,v,u)}else P.pushEvent(e,s,V,l||t,a,v,u)};o.targetView&&o.targetCtx?Q(o.targetView,o.targetCtx):i.withinTargets(T,Q)},exec_navigate(r,e,t,i,s,n,{href:o,replace:l}){i.liveSocket.historyRedirect(r,o,l?"replace":"push",null,s)},exec_patch(r,e,t,i,s,n,{href:o,replace:l}){i.liveSocket.pushHistoryPatch(r,o,l?"replace":"push",s)},exec_focus(r,e,t,i,s,n){window.requestAnimationFrame(()=>de.attemptFocus(n))},exec_focus_first(r,e,t,i,s,n){window.requestAnimationFrame(()=>de.focusFirstInteractive(n)||de.focusFirst(n))},exec_push_focus(r,e,t,i,s,n){window.requestAnimationFrame(()=>Ai.push(n||s))},exec_pop_focus(r,e,t,i,s,n){window.requestAnimationFrame(()=>{let o=Ai.pop();o&&o.focus()})},exec_add_class(r,e,t,i,s,n,{names:o,transition:l,time:a,blocking:d}){this.addOrRemoveClasses(n,o,[],l,a,i,d)},exec_remove_class(r,e,t,i,s,n,{names:o,transition:l,time:a,blocking:d}){this.addOrRemoveClasses(n,[],o,l,a,i,d)},exec_toggle_class(r,e,t,i,s,n,{names:o,transition:l,time:a,blocking:d}){this.toggleClasses(n,o,l,a,i,d)},exec_toggle_attr(r,e,t,i,s,n,{attr:[o,l,a]}){this.toggleAttr(n,o,l,a)},exec_transition(r,e,t,i,s,n,{time:o,transition:l,blocking:a}){this.addOrRemoveClasses(n,[],[],l,o,i,a)},exec_toggle(r,e,t,i,s,n,{display:o,ins:l,outs:a,time:d,blocking:c}){this.toggle(e,i,n,o,l,a,d,c)},exec_show(r,e,t,i,s,n,{display:o,transition:l,time:a,blocking:d}){this.show(e,i,n,o,l,a,d)},exec_hide(r,e,t,i,s,n,{display:o,transition:l,time:a,blocking:d}){this.hide(e,i,n,o,l,a,d)},exec_set_attr(r,e,t,i,s,n,{attr:[o,l]}){this.setOrRemoveAttrs(n,[[o,l]],[])},exec_remove_attr(r,e,t,i,s,n,{attr:o}){this.setOrRemoveAttrs(n,[],[o])},show(r,e,t,i,s,n,o){this.isVisible(t)||this.toggle(r,e,t,i,s,null,n,o)},hide(r,e,t,i,s,n,o){this.isVisible(t)&&this.toggle(r,e,t,i,null,s,n,o)},toggle(r,e,t,i,s,n,o,l){o=o||_i;let[a,d,c]=s||[[],[],[]],[p,m,g]=n||[[],[],[]];if(a.length>0||p.length>0)if(this.isVisible(t)){let u=()=>{this.addOrRemoveClasses(t,m,a.concat(d).concat(c)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,g,m))})},v=()=>{this.addOrRemoveClasses(t,[],p.concat(g)),h.putSticky(t,"toggle",b=>b.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))};t.dispatchEvent(new Event("phx:hide-start")),l===!1?(u(),setTimeout(v,o)):e.transition(o,u,v)}else{if(r==="remove")return;let u=()=>{this.addOrRemoveClasses(t,d,p.concat(m).concat(g));let b=i||this.defaultDisplay(t);h.putSticky(t,"toggle",T=>T.style.display=b),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,c,d))})},v=()=>{this.addOrRemoveClasses(t,[],a.concat(c)),t.dispatchEvent(new Event("phx:show-end"))};t.dispatchEvent(new Event("phx:show-start")),l===!1?(u(),setTimeout(v,o)):e.transition(o,u,v)}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",u=>u.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let u=i||this.defaultDisplay(t);h.putSticky(t,"toggle",v=>v.style.display=u),t.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(r,e,t,i,s,n){window.requestAnimationFrame(()=>{let[o,l]=h.getSticky(r,"classes",[[],[]]),a=e.filter(c=>o.indexOf(c)<0&&!r.classList.contains(c)),d=e.filter(c=>l.indexOf(c)<0&&r.classList.contains(c));this.addOrRemoveClasses(r,a,d,t,i,s,n)})},toggleAttr(r,e,t,i){r.hasAttribute(e)?i!==void 0?r.getAttribute(e)===t?this.setOrRemoveAttrs(r,[[e,i]],[]):this.setOrRemoveAttrs(r,[[e,t]],[]):this.setOrRemoveAttrs(r,[],[e]):this.setOrRemoveAttrs(r,[[e,t]],[])},addOrRemoveClasses(r,e,t,i,s,n,o){s=s||_i;let[l,a,d]=i||[[],[],[]];if(l.length>0){let c=()=>{this.addOrRemoveClasses(r,a,[].concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(r,l,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(r,d,a))})},p=()=>this.addOrRemoveClasses(r,e.concat(d),t.concat(l).concat(a));o===!1?(c(),setTimeout(p,s)):n.transition(s,c,p);return}window.requestAnimationFrame(()=>{let[c,p]=h.getSticky(r,"classes",[[],[]]),m=e.filter(b=>c.indexOf(b)<0&&!r.classList.contains(b)),g=t.filter(b=>p.indexOf(b)<0&&r.classList.contains(b)),u=c.filter(b=>t.indexOf(b)<0).concat(m),v=p.filter(b=>e.indexOf(b)<0).concat(g);h.putSticky(r,"classes",b=>(b.classList.remove(...v),b.classList.add(...u),[u,v]))})},setOrRemoveAttrs(r,e,t){let[i,s]=h.getSticky(r,"attrs",[[],[]]),n=e.map(([a,d])=>a).concat(t),o=i.filter(([a,d])=>!n.includes(a)).concat(e),l=s.filter(a=>!n.includes(a)).concat(t);h.putSticky(r,"attrs",a=>(l.forEach(d=>a.removeAttribute(d)),o.forEach(([d,c])=>a.setAttribute(d,c)),[o,l]))},hasAllClasses(r,e){return e.every(t=>r.classList.contains(t))},isToggledOut(r,e){return!this.isVisible(r)||this.hasAllClasses(r,e)},filterToEls(r,e,{to:t}){let i=()=>{if(typeof t=="string")return document.querySelectorAll(t);if(t.closest){let s=e.closest(t.closest);return s?[s]:[]}else if(t.inner)return e.querySelectorAll(t.inner)};return t?r.jsQuerySelectorAll(e,t,i):[e]},defaultDisplay(r){return{tr:"table-row",td:"table-cell"}[r.tagName.toLowerCase()]||"block"},transitionClasses(r){if(!r)return null;let[e,t,i]=Array.isArray(r)?r:[r.split(" "),[],[]];return e=Array.isArray(e)?e:e.split(" "),t=Array.isArray(t)?t:t.split(" "),i=Array.isArray(i)?i:i.split(" "),[e,t,i]}},y=zi;var Mt="hookId",Yi=1,Y=class{static makeID(){return Yi++}static elementID(e){return h.private(e,Mt)}constructor(e,t,i){this.el=t,this.__attachView(e),this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,h.putPrivate(this.el,Mt,this.constructor.makeID());for(let s in this.__callbacks)this[s]=this.__callbacks[s]}__attachView(e){e?(this.__view=()=>e,this.liveSocket=e.liveSocket):(this.__view=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)},this.liveSocket=null)}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed(),h.deletePrivate(this.el,Mt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}js(){let e=this;return{exec(t){e.__view().liveSocket.execJS(e.el,t,"hook")},show(t,i={}){let s=e.__view().liveSocket.owner(t);y.show("hook",s,t,i.display,i.transition,i.time,i.blocking)},hide(t,i={}){let s=e.__view().liveSocket.owner(t);y.hide("hook",s,t,null,i.transition,i.time,i.blocking)},toggle(t,i={}){let s=e.__view().liveSocket.owner(t);i.in=y.transitionClasses(i.in),i.out=y.transitionClasses(i.out),y.toggle("hook",s,t,i.display,i.in,i.out,i.time,i.blocking)},addClass(t,i,s={}){i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,i,[],s.transition,s.time,n,s.blocking)},removeClass(t,i,s={}){s.transition=y.transitionClasses(s.transition),i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,[],i,s.transition,s.time,n,s.blocking)},toggleClass(t,i,s={}){s.transition=y.transitionClasses(s.transition),i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.toggleClasses(t,i,s.transition,s.time,n,s.blocking)},transition(t,i,s={}){let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,[],[],y.transitionClasses(i),s.time,n,s.blocking)},setAttribute(t,i,s){y.setOrRemoveAttrs(t,[[i,s]],[])},removeAttribute(t,i){y.setOrRemoveAttrs(t,[],[i])},toggleAttribute(t,i,s,n){y.toggleAttr(t,i,s,n)}}}pushEvent(e,t={},i){return i===void 0?new Promise((s,n)=>{try{this.__view().pushHookEvent(this.el,null,e,t,(l,a)=>s(l))===!1&&n(new Error("unable to push hook event. LiveView not connected"))}catch(o){n(o)}}):this.__view().pushHookEvent(this.el,null,e,t,i)}pushEventTo(e,t,i={},s){return s===void 0?new Promise((n,o)=>{try{this.__view().withinTargets(e,(l,a)=>{l.pushHookEvent(this.el,a,t,i,(c,p)=>n(c))===!1&&o(new Error("unable to push hook event. LiveView not connected"))})}catch(l){o(l)}}):this.__view().withinTargets(e,(n,o)=>n.pushHookEvent(this.el,o,t,i,s))}handleEvent(e,t){let i=(s,n)=>n?e:t(s.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view().dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view().withinTargets(e,(s,n)=>{s.dispatchUploads(n,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var Qi=(r,e)=>{let t=r.endsWith("[]"),i=t?r.slice(0,-2):r;return i=i.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),t&&(i+="[]"),i},ut=(r,e,t=[])=>{let c=e,{submitter:i}=c,s=Vt(c,["submitter"]),n;if(i&&i.name){let p=document.createElement("input");p.type="hidden";let m=i.getAttribute("form");m&&p.setAttribute("form",m),p.name=i.name,p.value=i.value,i.parentElement.insertBefore(p,i),n=p}let o=new FormData(r),l=[];o.forEach((p,m,g)=>{p instanceof File&&l.push(m)}),l.forEach(p=>o.delete(p));let a=new URLSearchParams,d=Array.from(r.elements);for(let[p,m]of o.entries())if(t.length===0||t.indexOf(p)>=0){let g=d.filter(b=>b.name===p),u=!g.some(b=>h.private(b,pe)||h.private(b,me)),v=g.every(b=>b.type==="hidden");u&&!(i&&i.name==p)&&!v&&a.append(Qi(p,"_unused_"),""),a.append(p,m)}i&&n&&i.parentElement.removeChild(n);for(let p in s)a.append(p,s[p]);return a.toString()},_e=class r{static closestView(e){let t=e.closest(q);return t?h.private(t,"view"):null}constructor(e,t,i,s,n){this.isDead=!1,this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e,h.putPrivate(this.el,"view",this),this.id=this.el.id,this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=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.formsForRecovery={},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(ke)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(jt)}]`).map(s=>s.src||s.href).filter(s=>typeof s=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._mount_attempts=this.joinAttempts,t._live_referer=e,this.joinAttempts++,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(M)}getStatic(){let e=this.el.getAttribute(ee);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 t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(bt,ae,fe,At,Pe),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(ae)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(bt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t,i=document,s){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,n=>t(n,e));if(W(e))h.findComponentNodeList(s||this.el,e).length===0?x(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let n=Array.from(i.querySelectorAll(e));n.length===0&&x(`nothing found matching the phx-target selector "${e}"`),n.forEach(o=>this.liveSocket.owner(o,l=>t(l,o)))}}applyDiff(e,t,i){this.log(e,()=>["",Le(t)]);let{diff:s,reply:n,events:o,title:l}=He.extract(t);i({diff:s,reply:n,events:o}),(typeof l=="string"||e=="mount")&&window.requestAnimationFrame(()=>h.putTitle(l))}onJoin(e){let{rendered:t,container:i,liveview_version:s}=e;if(i){let[n,o]=i;this.el=h.replaceRootContainer(this.el,n,o)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&this.liveSocket.replaceRootHistory(),s!==this.liveSocket.version()&&console.error(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${s}. To avoid issues, please ensure that your assets use the same version as the server.`),D.dropLocal(this.liveSocket.localStorage,window.location.pathname,Qe),this.applyDiff("mount",t,({diff:n,events:o})=>{this.rendered=new He(this.id,n);let[l,a]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(l,()=>{this.onJoinComplete(e,l,a,o)})})}dropPendingRefs(){h.all(document,`[${O}="${this.refSrc()}"]`,e=>{e.removeAttribute(le),e.removeAttribute(O),e.removeAttribute(L)})}onJoinComplete({live_patch:e},t,i,s){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,s);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let l=o.id&&this.el.querySelector(`[id="${o.id}"]`),a=l&&l.getAttribute(ee);return a&&o.setAttribute(ee,a),l&&l.setAttribute(J,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,s)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(J,this.root.id)}execNewMounted(e=this.el){let t=this.binding(Fe),i=this.binding(Me);h.all(e,`[${t}], [${i}]`,s=>{this.ownsElement(s)&&(h.maintainPrivateHooks(s,s,t,i),this.maybeAddNewHook(s))}),h.all(e,`[${this.binding(Re)}], [data-phx-${Re}]`,s=>{this.ownsElement(s)&&this.maybeAddNewHook(s)}),h.all(e,`[${this.binding(yt)}]`,s=>{this.ownsElement(s)&&this.maybeMounted(s)})}applyJoinPatch(e,t,i,s){this.attachTrueDocEl();let n=new ce(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(s),this.applyPendingUpdates(),e){let{kind:o,to:l}=e;this.liveSocket.historyPatch(l,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),s=i&&h.isIgnored(e,this.binding(ge));if(i&&!e.isEqualNode(t)&&!(s&&oi(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(yt)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){let t=this.addHook(e);t&&t.__mounted()}performPatch(e,t,i=!1){let s=[],n=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.after("added",l=>{this.liveSocket.triggerDOM("onNodeAdded",[l]);let a=this.binding(Fe),d=this.binding(Me);h.maintainPrivateHooks(l,l,a,d),this.maybeAddNewHook(l),l.getAttribute&&this.maybeMounted(l)}),e.after("phxChildAdded",l=>{h.isPhxSticky(l)?this.liveSocket.joinRootViews():n=!0}),e.before("updated",(l,a)=>{this.triggerBeforeUpdateHook(l,a)&&o.add(l.id)}),e.after("updated",l=>{o.has(l.id)&&this.getHook(l).__updated()}),e.after("discarded",l=>{l.nodeType===Node.ELEMENT_NODE&&s.push(l)}),e.after("transitionsDiscarded",l=>this.afterElementsRemoved(l,t)),e.perform(i),this.afterElementsRemoved(s,t),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),n}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let n=h.all(s,`[${$}]`),o=h.all(s,`[${this.binding(Re)}], [data-phx-hook]`);n.concat(s).forEach(l=>{let a=this.componentID(l);W(a)&&i.indexOf(a)===-1&&i.push(a)}),o.concat(s).forEach(l=>{let a=this.getHook(l);a&&this.destroyHook(a)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,t){let i=this.binding("change"),s=this.root.formsForRecovery,n=document.createElement("template");n.innerHTML=e;let o=n.content.firstElementChild;o.id=this.id,o.setAttribute(J,this.root.id),o.setAttribute(M,this.getSession()),o.setAttribute(ee,this.getStatic()),o.setAttribute(Z,this.parent?this.parent.id:null);let l=h.all(n.content,"form").filter(a=>a.id&&s[a.id]).filter(a=>!this.pendingForms.has(a.id)).filter(a=>s[a.id].getAttribute(i)===a.getAttribute(i)).map(a=>[s[a.id],a]);if(l.length===0)return t();l.forEach(([a,d],c)=>{this.pendingForms.add(d.id),this.pushFormRecovery(a,d,n.content.firstElementChild,()=>{this.pendingForms.delete(d.id),c===l.length-1&&t()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){var t;return e.id===this.id?this:(t=this.children[e.getAttribute(Z)])==null?void 0:t[e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new r(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.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.pendingForms.clear(),this.formsForRecovery={},this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findExistingParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):Lt(e)||this.liveSocket.time("full patch complete",()=>{let[s,n]=this.renderContainer(e,"update"),o=new ce(this,this.el,this.id,s,n,null);i=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,s=e?this.rendered.componentCIDs(e):null,[n,o]=this.rendered.toString(s);return[`<${i}>${n}</${i}>`,o]})}componentPatch(e,t){if(Lt(e))return!1;let[i,s]=this.rendered.componentToString(t),n=new ce(this,this.el,this.id,i,s,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[Y.elementID(e)]}addHook(e){let t=Y.elementID(e);if(t&&!this.viewHooks[t]){let i=h.getCustomElHook(e)||x(`no hook found for custom element: ${e.id}`);return this.viewHooks[t]=i,i.__attachView(this),i}else{if(t||!e.getAttribute)return;{let i=e.getAttribute(`data-phx-${Re}`)||e.getAttribute(this.binding(Re));if(i&&!this.ownsElement(e))return;let s=this.liveSocket.getHookCallbacks(i);if(s){e.id||x(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);let n=new Y(this,e,s);return this.viewHooks[Y.elementID(n.el)]=n,n}else i!==null&&x(`unknown hook found for "${i}"`,e)}}}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[Y.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),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:t,kind:i,flash:s}=e,n=this.expandURL(t),o=new CustomEvent("phx:server-navigate",{detail:{to:t,kind:i,flash:s}});this.liveSocket.historyRedirect(o,n,i,s)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t,reloadToken:i}){this.liveSocket.redirect(e,t,i)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}joinPush(){return this.joinPush=this.joinPush||this.channel.join(),this.joinPush}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.wrapPush(()=>this.channel.join(),{ok:t=>this.liveSocket.requestDOMUpdate(()=>this.onJoin(t)),error:t=>this.onJoinError(t),timeout:()=>this.onJoinError({reason:"timeout"})})}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page reload`,e]),this.onRedirect({to:this.root.href,reloadToken:e.token});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.root.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);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([ae,fe,Pe]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=kt&&(this.root.displayError([ae,fe,Pe]),this.log("error",()=>[`giving up trying to mount after ${kt} tries`,e]),this.destroy());let t=h.byId(this.el.id);t?(h.mergeAttrs(t,this.el),this.displayError([ae,fe,Pe]),this.el=t):this.destroy()}}onClose(e){if(!this.isDestroyed()){if(this.isMain()&&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(Zt)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([ae,fe,Pe]):this.displayError([ae,fe,At]))}displayError(e){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.execAll(this.binding("disconnected"))}wrapPush(e,t){let i=this.liveSocket.getLatencySim(),s=i?n=>setTimeout(()=>!this.isDestroyed()&&n(),i):n=>!this.isDestroyed()&&n();s(()=>{e().receive("ok",n=>s(()=>t.ok&&t.ok(n))).receive("error",n=>s(()=>t.error&&t.error(n))).receive("timeout",()=>s(()=>t.timeout&&t.timeout()))})}pushWithReply(e,t,i){if(!this.isConnected())return Promise.reject({error:"noconnection"});let[s,[n],o]=e?e():[null,[],{}],l=this.joinCount,a=function(){};return o.page_loading&&(a=this.liveSocket.withPageLoading({kind:"element",target:n})),typeof i.cid!="number"&&delete i.cid,new Promise((d,c)=>{this.wrapPush(()=>this.channel.push(t,i,ti),{ok:p=>{s!==null&&(this.lastAckRef=s);let m=g=>{p.redirect&&this.onRedirect(p.redirect),p.live_patch&&this.onLivePatch(p.live_patch),p.live_redirect&&this.onLiveRedirect(p.live_redirect),a(),d({resp:p,reply:g})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:g,reply:u,events:v})=>{s!==null&&this.undoRefs(s,i.event),this.update(g,v),m(u)})}):(s!==null&&this.undoRefs(s,i.event),m(null))},error:p=>c({error:p}),timeout:()=>{c({timeout:!0}),this.joinCount===l&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,t,i){if(!this.isConnected())return;let s=`[${O}="${this.refSrc()}"]`;i?(i=new Set(i),h.all(document,s,n=>{i&&!i.has(n)||(h.all(n,s,o=>this.undoElRef(o,e,t)),this.undoElRef(n,e,t))})):h.all(document,s,n=>this.undoElRef(n,e,t))}undoElRef(e,t,i){new je(e).maybeUndo(t,i,n=>{let o=this.triggerBeforeUpdateHook(e,n);ce.patchWithClonedTree(e,n,this.liveSocket),h.all(e,`[${O}="${this.refSrc()}"]`,l=>this.undoElRef(l,t,i)),this.execNewMounted(e),o&&o.__updated()})}refSrc(){return this.el.id}putRef(e,t,i,s={}){let n=this.ref++,o=this.binding(wt);if(s.loading){let l=h.all(document,s.loading).map(a=>({el:a,lock:!0,loading:!0}));e=e.concat(l)}for(let{el:l,lock:a,loading:d}of e){if(!a&&!d)throw new Error("putRef requires lock or loading");if(l.setAttribute(O,this.refSrc()),d&&l.setAttribute(le,n),a&&l.setAttribute(L,n),!d||s.submitter&&!(l===s.submitter||l===s.form))continue;let c=new Promise(u=>{l.addEventListener(`phx:undo-lock:${n}`,()=>u(g),{once:!0})}),p=new Promise(u=>{l.addEventListener(`phx:undo-loading:${n}`,()=>u(g),{once:!0})});l.classList.add(`phx-${i}-loading`);let m=l.getAttribute(o);m!==null&&(l.getAttribute(Ce)||l.setAttribute(Ce,l.innerText),m!==""&&(l.innerText=m),l.setAttribute(he,l.getAttribute(he)||l.disabled),l.setAttribute("disabled",""));let g={event:t,eventType:i,ref:n,isLoading:d,isLocked:a,lockElements:e.filter(({lock:u})=>u).map(({el:u})=>u),loadingElements:e.filter(({loading:u})=>u).map(({el:u})=>u),unlock:u=>{u=Array.isArray(u)?u:[u],this.undoRefs(n,t,u)},lockComplete:c,loadingComplete:p,lock:u=>new Promise(v=>{if(this.isAcked(n))return v(g);u.setAttribute(L,n),u.setAttribute(O,this.refSrc()),u.addEventListener(`phx:lock-stop:${n}`,()=>v(g),{once:!0})})};l.dispatchEvent(new CustomEvent("phx:push",{detail:g,bubbles:!0,cancelable:!1})),t&&l.dispatchEvent(new CustomEvent(`phx:push:${t}`,{detail:g,bubbles:!0,cancelable:!1}))}return[n,e.map(({el:l})=>l),s]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){let t=e.getAttribute&&e.getAttribute($);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(W(t))return t;let s=i.target||e.getAttribute(this.binding("target"));return W(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return W(e)?e:e?z(e.closest(`[${$}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,s]),!1;let[o,l,a]=this.putRef([{el:e,loading:!0,lock:!0}],i,"hook");return this.pushWithReply(()=>[o,l,a],"event",{type:"hook",event:i,value:s,cid:this.closestComponentID(t)}).then(({resp:d,reply:c})=>n(c,o)),o}extractMeta(e,t,i){let s=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(s)&&(t[o.replace(s,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&rt.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,s,n,o={},l){this.pushWithReply(()=>this.putRef([{el:t,loading:!0,lock:!0}],s,e,o),"event",{type:e,event:s,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)}).then(({reply:a})=>l&&l(a))}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(Yt)),ref:e.getAttribute(B),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)}).then(({resp:l})=>s(l))})}pushInput(e,t,i,s,n,o){if(!e.form)throw new Error("form events require the input to be inside a form");let l,a=W(i)?i:this.targetComponentID(e.form,t,n),d=()=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],s,"change",n),c,p=this.extractMeta(e.form);e instanceof HTMLButtonElement&&(p.submitter=e),e.getAttribute(this.binding("change"))?c=ut(e.form,I({_target:n._target},p),[e.name]):c=ut(e.form,I({_target:n._target},p)),h.isUploadInput(e)&&e.files&&e.files.length>0&&C.trackFiles(e,Array.from(e.files)),l=C.serializeUploads(e);let m={type:"form",event:s,value:c,uploads:l,cid:a};this.pushWithReply(d,"event",m).then(({resp:g})=>{if(h.isUploadInput(e)&&h.isAutoUpload(e)){if(C.filesAwaitingPreflight(e).length>0){let[u,v]=d();this.undoRefs(u,s,[e.form]),this.uploadFiles(e.form,s,t,u,a,b=>{o&&o(g),this.triggerAwaitingSubmit(e.form,s),this.undoRefs(u,s)})}}else o&&o(g)})}triggerAwaitingSubmit(e,t){let i=this.getScheduledSubmit(e);if(i){let[s,n,o,l]=i;this.cancelSubmit(e,t),l()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,s,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,s){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,s])}cancelSubmit(e,t){this.formSubmits=this.formSubmits.filter(([i,s,n,o])=>i.isSameNode(e)?(this.undoRefs(s,t),!1):!0)}disableForm(e,t,i={}){let s=u=>!(ve(u,`${this.binding(ge)}=ignore`,u.form)||ve(u,"data-phx-update=ignore",u.form)),n=u=>u.hasAttribute(this.binding(wt)),o=u=>u.tagName=="BUTTON",l=u=>["INPUT","TEXTAREA","SELECT"].includes(u.tagName),a=Array.from(e.elements),d=a.filter(n),c=a.filter(o).filter(s),p=a.filter(l).filter(s);c.forEach(u=>{u.setAttribute(he,u.disabled),u.disabled=!0}),p.forEach(u=>{u.setAttribute(Ue,u.readOnly),u.readOnly=!0,u.files&&(u.setAttribute(he,u.disabled),u.disabled=!0)});let m=d.concat(c).concat(p).map(u=>({el:u,loading:!0,lock:!0})),g=[{el:e,loading:!0,lock:!1}].concat(m).reverse();return this.putRef(g,t,"submit",i)}pushFormSubmit(e,t,i,s,n,o){let l=()=>this.disableForm(e,i,De(I({},n),{form:e,submitter:s})),a=this.targetComponentID(e,t);if(C.hasUploadsInProgress(e)){let[d,c]=l(),p=()=>this.pushFormSubmit(e,t,i,s,n,o);return this.scheduleSubmit(e,d,n,p)}else if(C.inputsAwaitingPreflight(e).length>0){let[d,c]=l(),p=()=>[d,c,n];this.uploadFiles(e,i,t,d,a,m=>{if(C.inputsAwaitingPreflight(e).length>0)return this.undoRefs(d,i);let g=this.extractMeta(e),u=ut(e,I({submitter:s},g));this.pushWithReply(p,"event",{type:"form",event:i,value:u,cid:a}).then(({resp:v})=>o(v))})}else if(!(e.hasAttribute(O)&&e.classList.contains("phx-submit-loading"))){let d=this.extractMeta(e),c=ut(e,I({submitter:s},d));this.pushWithReply(l,"event",{type:"form",event:i,value:c,cid:a}).then(({resp:p})=>o(p))}}uploadFiles(e,t,i,s,n,o){let l=this.joinCount,a=C.activeFileInputs(e),d=a.length;a.forEach(c=>{let p=new C(c,this,()=>{d--,d===0&&o()}),m=p.entries().map(u=>u.toPreflightPayload());if(m.length===0){d--;return}let g={ref:c.getAttribute(B),entries:m,cid:this.targetComponentID(c.form,i)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g).then(({resp:u})=>{if(this.log("upload",()=>["got preflight response",u]),p.entries().forEach(v=>{u.entries&&!u.entries[v.ref]&&this.handleFailedEntryPreflight(v.ref,"failed preflight",p)}),u.error||Object.keys(u.entries).length===0)this.undoRefs(s,t),(u.error||[]).map(([b,T])=>{this.handleFailedEntryPreflight(b,T,p)});else{let v=b=>{this.channel.onError(()=>{this.joinCount===l&&b()})};p.initAdapterUpload(u,v,this.liveSocket)}})})}handleFailedEntryPreflight(e,t,i){if(i.isAutoUpload()){let s=i.entries().find(n=>n.ref===e.toString());s&&s.cancel()}else i.entries().map(s=>s.cancel());this.log("upload",()=>[`error for entry ${e}`,t])}dispatchUploads(e,t,i){let s=this.targetCtxElement(e)||this.el,n=h.findUploadInputs(s).filter(o=>o.name===t);n.length===0?x(`no live file inputs found matching the name "${t}"`):n.length>1?x(`duplicate live file inputs found matching the name "${t}"`):h.dispatchEvent(n[0],tt,{detail:{files:i}})}targetCtxElement(e){if(W(e)){let[t]=h.findComponentNodeList(this.el,e);return t}else return e||null}pushFormRecovery(e,t,i,s){let n=this.binding("change"),o=t.getAttribute(this.binding("target"))||t,l=t.getAttribute(this.binding(Et))||t.getAttribute(this.binding("change")),a=Array.from(e.elements).filter(p=>h.isFormInput(p)&&p.name&&!p.hasAttribute(n));if(a.length===0)return;a.forEach(p=>p.hasAttribute(B)&&C.clearFiles(p));let d=a.find(p=>p.type!=="hidden")||a[0],c=0;this.withinTargets(o,(p,m)=>{let g=this.targetComponentID(t,m);c++;let u=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});y.exec(u,"change",l,this,d,["push",{_target:d.name,targetView:p,targetCtx:m,newCid:g,callback:()=>{c--,c===0&&s()}}])},i,i)}pushLinkPatch(e,t,i,s){let n=this.liveSocket.setPendingLink(t),o=e.isTrusted&&e.type!=="popstate",l=i?()=>this.putRef([{el:i,loading:o,lock:!0}],null,"click"):null,a=()=>this.liveSocket.redirect(window.location.href),d=t.startsWith("/")?`${location.protocol}//${location.host}${t}`:t;this.pushWithReply(l,"live_patch",{url:d}).then(({resp:c})=>{this.liveSocket.requestDOMUpdate(()=>{c.link_redirect?this.liveSocket.replaceMain(t,null,s,n):(this.liveSocket.commitPendingLink(n)&&(this.href=t),this.applyPendingUpdates(),s&&s(n))})},({error:c,timeout:p})=>a())}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return h.all(this.el,`form[${e}]`).filter(t=>t.id).filter(t=>t.elements.length>0).filter(t=>t.getAttribute(this.binding(Et))!=="ignore").map(t=>t.cloneNode(!0)).reduce((t,i)=>(t[i.id]=i,t),{})}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(t.forEach(i=>this.rendered.resetRender(i)),this.pushWithReply(null,"cids_will_destroy",{cids:t}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let i=t.filter(s=>h.findComponentNodeList(this.el,s).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i}).then(({resp:s})=>{this.rendered.pruneCIDs(s.cids)})})}))}ownsElement(e){let t=e.closest(q);return e.getAttribute(Z)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,s,n={}){h.putPrivate(e,me,!0),Array.from(e.elements).forEach(l=>h.putPrivate(l,me,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,n,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var Si=r=>h.isUsedInput(r),qe=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.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 t(e,i),this.bindingPrefix=i.bindingPrefix||ei,this.opts=i,this.params=Oe(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Le(ii),i.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=Le(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Qt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||10,this.reloadJitterMin=i.reloadJitterMin||5e3,this.reloadJitterMax=i.reloadJitterMax||1e4,this.failsafeJitter=i.failsafeJitter||3e4,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.boundEventNames=new Set,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:Oe(),onPatchEnd:Oe(),onNodeAdded:Oe(),onBeforeElUpdated:Oe()},i.dom||{}),this.transitions=new Ut,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem($e))||0,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.0.2"}isProfileEnabled(){return this.sessionStorage.getItem(ot)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Xe)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Xe)==="false"}enableDebug(){this.sessionStorage.setItem(Xe,"true")}enableProfiling(){this.sessionStorage.setItem(ot,"true")}disableDebug(){this.sessionStorage.setItem(Xe,"false")}disableProfiling(){this.sessionStorage.removeItem(ot)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(lt,e)}disableLatencySim(){this.sessionStorage.removeItem(lt)}getLatencySim(){let e=this.sessionStorage.getItem(lt);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.resetReloadStatus(),this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.bindTopLevelEvents({dead:!0}),this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off(this.serverCloseRef),this.serverCloseRef=null),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){let s=new CustomEvent("phx:exec",{detail:{sourceElement:e}});this.owner(e,n=>y.exec(s,i,t,n,e))}execJSHookPush(e,t,i,s){this.withinOwners(e,n=>{let o=new CustomEvent("phx:exec",{detail:{sourceElement:e}});y.exec(o,"hook",t,n,e,["push",{data:i,callback:s}])})}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,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[s,n]=i();this.viewLogger(e,t,s,n)}else if(this.isDebugEnabled()){let[s,n]=i();ni(e,t,s,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,o=D.updateLocal(this.localStorage,window.location.pathname,Qe,0,l=>l+1);o>=this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>=this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?ci[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,t){return this.socket.channel(e,t)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>{var i;t.execNewMounted(),this.maybeScroll((i=history.state)==null?void 0:i.scroll)})}}joinRootViews(){let e=!1;return h.all(document,`${q}:not([${Z}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.hasAttribute(ke)&&(this.main=i)}e=!0}),e}redirect(e,t,i){i&&D.setCookie(Pt,i,60),this.unload(),D.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.all(this.outgoingMainEl,`[${this.binding("remove")}]`),l=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(l,t,n),this.main.setRedirect(e),this.transitionRemoves(o,!0),this.main.join((a,d)=>{a===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{o.forEach(c=>c.remove()),h.findPhxSticky(document).forEach(c=>l.appendChild(c)),this.outgoingMainEl.replaceWith(l),this.outgoingMainEl=null,i&&i(s),d()})})}transitionRemoves(e,t,i){let s=this.binding("remove");if(t){let o=h.findPhxSticky(document)||[];e=e.filter(l=>!h.isChildOfAny(l,o))}let n=o=>{o.preventDefault(),o.stopImmediatePropagation()};e.forEach(o=>{for(let l of this.boundEventNames)o.addEventListener(l,n,!0);this.execJS(o,o.getAttribute(s),"remove")}),this.requestDOMUpdate(()=>{e.forEach(o=>{for(let l of this.boundEventNames)o.removeEventListener(l,n,!0)}),i&&i()})}isPhxView(e){return e.getAttribute&&e.getAttribute(M)!==null}newRootView(e,t,i){let s=new _e(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=z(e.closest(q),s=>this.getViewByEl(s))||this.main;return i&&t?t(i):i}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(J);return z(this.getRootById(t),i=>i.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 t=this.getRootById(e.getAttribute(J));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}getActiveElement(){return document.activeElement}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.serverCloseRef=this.socket.onClose(t=>{if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,s,n,o,l)=>{let a=n.getAttribute(this.binding(zt)),d=t.key&&t.key.toLowerCase();if(a&&a.toLowerCase()!==d)return;let c=I({key:t.key},this.eventMeta(i,t,n));y.exec(t,i,o,s,n,["push",{data:c}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,n,o,l)=>{if(!l){let a=I({key:t.key},this.eventMeta(i,t,n));y.exec(t,i,o,s,n,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,n,o,l)=>{if(l==="window"){let a=this.eventMeta(i,t,n);y.exec(t,i,o,s,n,["push",{data:a}])}}),this.on("dragover",t=>t.preventDefault()),this.on("drop",t=>{t.preventDefault();let i=z(ve(t.target,this.binding(gt)),o=>o.getAttribute(this.binding(gt))),s=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!s||s.disabled||n.length===0||!(s.files instanceof FileList)||(C.trackFiles(s,n,t.dataTransfer),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(tt,t=>{let i=t.target;if(!h.isUploadInput(i))return;let s=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);C.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let s=this.metadataCallbacks[e];return s?s(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){D.deleteCookie(Pt)}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,t){for(let i in e){let s=e[i];this.on(s,n=>{let o=this.binding(i),l=this.binding(`window-${i}`),a=n.target.getAttribute&&n.target.getAttribute(o);a?this.debounce(n.target,n,s,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,a,null)})}):h.all(document,`[${l}]`,d=>{let c=d.getAttribute(l);this.debounce(d,n,s,()=>{this.withinOwners(d,p=>{t(n,i,p,d,c,"window")})})})})}}bindClicks(){this.on("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click")}bindClick(e,t){let i=this.binding(t);window.addEventListener(e,s=>{let n=null;s.detail===0&&(this.clickStartedAtTarget=s.target);let o=this.clickStartedAtTarget||s.target;n=ve(s.target,i),this.dispatchClickAway(s,o),this.clickStartedAtTarget=null;let l=n&&n.getAttribute(i);if(!l){h.isNewPageClick(s,window.location)&&this.unload();return}n.getAttribute("href")==="#"&&s.preventDefault(),!n.hasAttribute(O)&&this.debounce(n,s,"click",()=>{this.withinOwners(n,a=>{y.exec(s,"click",l,a,n,["push",{data:this.eventMeta("click",s,n)}])})})},!1)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(s,n=>{let o=s.getAttribute(i);y.isVisible(s)&&y.isInViewport(s)&&y.exec(e,"click",o,n,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!D.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{D.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,backType:s,id:n,root:o,scroll:l,position:a}=t.state||{},d=window.location.href,c=a>this.currentHistoryPosition;i=c?i:s||i,this.currentHistoryPosition=a||0,this.sessionStorage.setItem($e,this.currentHistoryPosition.toString()),h.dispatchEvent(window,"phx:navigate",{detail:{href:d,patch:i==="patch",pop:!0,direction:c?"forward":"backward"}}),this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&n===this.main.id?this.main.pushLinkPatch(t,d,null,()=>{this.maybeScroll(l)}):this.replaceMain(d,null,()=>{o&&this.replaceRootHistory(),this.maybeScroll(l)})})},!1),window.addEventListener("click",t=>{let i=ve(t.target,et),s=i&&i.getAttribute(et);if(!s||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let n=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,o=i.getAttribute(Jt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(t,n,o,i);else if(s==="redirect")this.historyRedirect(t,n,o,null,i);else throw new Error(`expected ${et} to be "patch" or "redirect", got: ${s}`);let l=i.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(i,l,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i,s){if(!this.isConnected()||!this.main.isMain())return D.redirect(t);this.withPageLoading({to:t,kind:"patch"},n=>{this.main.pushLinkPatch(e,t,s,o=>{this.historyPatch(t,i,o),n()})})}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem($e,this.currentHistoryPosition.toString()),D.updateCurrentState(s=>De(I({},s),{backType:"patch"})),D.pushState(t,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},e),h.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i,s,n){if(n&&e.isTrusted&&e.type!=="popstate"&&n.classList.add("phx-click-loading"),!this.isConnected()||!this.main.isMain())return D.redirect(t,s);if(/^\/$|^\/[^\/]+.*$/.test(t)){let{protocol:l,host:a}=window.location;t=`${l}//${a}${t}`}let o=window.scrollY;this.withPageLoading({to:t,kind:"redirect"},l=>{this.replaceMain(t,s,a=>{a===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem($e,this.currentHistoryPosition.toString()),D.updateCurrentState(d=>De(I({},d),{backType:"redirect"})),D.pushState(i,{type:"redirect",id:this.main.id,scroll:o,position:this.currentHistoryPosition},t),h.dispatchEvent(window,"phx:navigate",{detail:{href:t,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),l()})})}replaceRootHistory(){D.pushState("replace",{root:!0,type:"patch",id:this.main.id,position:this.currentHistoryPosition})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=Le(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!s&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));if(!s){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{y.exec(i,"submit",s,n,i.target,["push",{submitter:i.submitter}])})});for(let i of["change","input"])this.on(i,s=>{if(s instanceof CustomEvent&&s.target.form===void 0){if(s.detail&&s.detail.dispatcher)throw new Error(`dispatching a custom ${i} event is only supported on input elements inside a form`);return}let n=this.binding("change"),o=s.target;if(s.isComposing){let u=`composition-listener-${i}`;h.private(o,u)||(h.putPrivate(o,u,!0),o.addEventListener("compositionend",()=>{o.dispatchEvent(new Event(i,{bubbles:!0})),h.deletePrivate(o,u)},{once:!0}));return}let l=o.getAttribute(n),a=o.form&&o.form.getAttribute(n),d=l||a;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let c=l?o:o.form,p=e;e++;let{at:m,type:g}=h.private(o,"prev-iteration")||{};m===p-1&&i==="change"&&g==="input"||(h.putPrivate(o,"prev-iteration",{at:p,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(c,u=>{h.putPrivate(o,pe,!0),y.exec(s,"change",d,u,o,["push",{_target:s.target.name,dispatcher:c}])})}))});this.on("reset",i=>{let s=i.target;h.resetForm(s);let n=Array.from(s.elements).find(o=>o.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let n=this.binding(Kt),o=this.binding(Gt),l=this.defaults.debounce.toString(),a=this.defaults.throttle.toString();this.withinOwners(e,d=>{let c=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,l,o,a,c,()=>{s()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){this.boundEventNames.add(e),window.addEventListener(e,i=>{this.silenced||t(i)})}jsQuerySelectorAll(e,t,i){let s=this.domCallbacks.jsQuerySelectorAll;return s?s(e,t,i):i()}},Ut=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,t,i){t();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.flushPendingOps()},e);this.transitions.add(s)}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 ss=(r,e={})=>{let t=h.getCustomElHook(r);if(t)return t;let i=new Y(_e.closestView(r),r,e);return h.putCustomElHook(r,i),i};return Ti(rs);})();
var Beacon=(()=>{window.addEventListener("phx:beacon:page-updated",e=>{e.detail.hasOwnProperty("runtime_css_path")&&(document.getElementById("beacon-runtime-stylesheet").href=e.detail.runtime_css_path),e.detail.hasOwnProperty("meta_tags")&&(document.querySelectorAll("meta:not([name='csrf-token'])").forEach(t=>t.remove()),e.detail.meta_tags.forEach(t=>{let o=document.createElement("meta");Object.keys(t).forEach(n=>{o.setAttribute(n,t[n])}),document.getElementsByTagName("head")[0].appendChild(o)}))});var i=document.querySelector("html").getAttribute("phx-socket")||"/live",l=document.querySelector("meta[name='csrf-token']").getAttribute("content"),a,c,r=new LiveView.LiveSocket(i,Phoenix.Socket,{params:{_csrf_token:l},hooks:(c=(a=window.BeaconHooks)==null?void 0:a.default)!=null?c:{}});r.connect();window.liveSocket=r;})();
