Packages

This mix task allows you to start a server anywhere on the file system and serve files.

Current section

Files

Jump to
ex_server priv static assets app.js
Raw

priv/static/assets/app.js

(()=>{var Ft=Object.create;var ve=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames,tt=Object.getOwnPropertySymbols,Vt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable;var st=(e,t,i)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ee=(e,t)=>{for(var i in t||(t={}))it.call(t,i)&&st(e,i,t[i]);if(tt)for(var i of tt(t))Xt.call(t,i)&&st(e,i,t[i]);return e};var Wt=e=>ve(e,"__esModule",{value:!0});var qt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var zt=(e,t,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Jt(t))!it.call(e,s)&&s!=="default"&&ve(e,s,{get:()=>t[s],enumerable:!(i=Bt(t,s))||i.enumerable});return e},Kt=e=>zt(Wt(ve(e!=null?Ft(Vt(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Ut=qt((Ht,Re)=>{(function(e,t){"use strict";(function(){for(var u=0,g=["ms","moz","webkit","o"],v=0;v<g.length&&!e.requestAnimationFrame;++v)e.requestAnimationFrame=e[g[v]+"RequestAnimationFrame"],e.cancelAnimationFrame=e[g[v]+"CancelAnimationFrame"]||e[g[v]+"CancelRequestAnimationFrame"];e.requestAnimationFrame||(e.requestAnimationFrame=function(m,_){var T=new Date().getTime(),D=Math.max(0,16-(T-u)),c=e.setTimeout(function(){m(T+D)},D);return u=T+D,c}),e.cancelAnimationFrame||(e.cancelAnimationFrame=function(m){clearTimeout(m)})})();var i,s,n,r,o,a=function(u,g,v){u.addEventListener?u.addEventListener(g,v,!1):u.attachEvent?u.attachEvent("on"+g,v):u["on"+g]=v},l={autoRun:!0,barThickness:3,barColors:{0:"rgba(26, 188, 156, .9)",".25":"rgba(52, 152, 219, .9)",".50":"rgba(241, 196, 15, .9)",".75":"rgba(230, 126, 34, .9)","1.0":"rgba(211, 84, 0, .9)"},shadowBlur:10,shadowColor:"rgba(0, 0, 0, .6)",className:null},d=function(){i.width=e.innerWidth,i.height=l.barThickness*5;var u=i.getContext("2d");u.shadowBlur=l.shadowBlur,u.shadowColor=l.shadowColor;var g=u.createLinearGradient(0,0,i.width,0);for(var v in l.barColors)g.addColorStop(v,l.barColors[v]);u.lineWidth=l.barThickness,u.beginPath(),u.moveTo(0,l.barThickness/2),u.lineTo(Math.ceil(r*i.width),l.barThickness/2),u.strokeStyle=g,u.stroke()},p=function(){i=t.createElement("canvas");var u=i.style;u.position="fixed",u.top=u.left=u.right=u.margin=u.padding=0,u.zIndex=100001,u.display="none",l.className&&i.classList.add(l.className),t.body.appendChild(i),a(e,"resize",d)},f={config:function(u){for(var g in u)l.hasOwnProperty(g)&&(l[g]=u[g])},show:function(){o||(o=!0,n!==null&&e.cancelAnimationFrame(n),i||p(),i.style.opacity=1,i.style.display="block",f.progress(0),l.autoRun&&function u(){s=e.requestAnimationFrame(u),f.progress("+"+.05*Math.pow(1-Math.sqrt(r),2))}())},progress:function(u){return typeof u=="undefined"||(typeof u=="string"&&(u=(u.indexOf("+")>=0||u.indexOf("-")>=0?r:0)+parseFloat(u)),r=u>1?1:u,d()),r},hide:function(){!o||(o=!1,s!=null&&(e.cancelAnimationFrame(s),s=null),function u(){if(f.progress("+.1")>=1&&(i.style.opacity-=.05,i.style.opacity<=.05)){i.style.display="none",n=null;return}n=e.requestAnimationFrame(u)}())}};typeof Re=="object"&&typeof Re.exports=="object"?Re.exports=f:typeof define=="function"&&define.amd?define(function(){return f}):this.topbar=f}).call(Ht,window,document)});"use strict";(function(){var e=t();function t(){if(typeof window.CustomEvent=="function")return window.CustomEvent;function n(r,o){o=o||{bubbles:!1,cancelable:!1,detail:void 0};var a=document.createEvent("CustomEvent");return a.initCustomEvent(r,o.bubbles,o.cancelable,o.detail),a}return n.prototype=window.Event.prototype,n}function i(n,r){var o=document.createElement("input");return o.type="hidden",o.name=n,o.value=r,o}function s(n,r){var o=n.getAttribute("data-to"),a=i("_method",n.getAttribute("data-method")),l=i("_csrf_token",n.getAttribute("data-csrf")),d=document.createElement("form"),p=n.getAttribute("target");d.method=n.getAttribute("data-method")==="get"?"get":"post",d.action=o,d.style.display="hidden",p?d.target=p:r&&(d.target="_blank"),d.appendChild(l),d.appendChild(a),document.body.appendChild(d),d.submit()}window.addEventListener("click",function(n){var r=n.target;if(!n.defaultPrevented)for(;r&&r.getAttribute;){var o=new e("phoenix.link.click",{bubbles:!0,cancelable:!0});if(!r.dispatchEvent(o))return n.preventDefault(),n.stopImmediatePropagation(),!1;if(r.getAttribute("data-method"))return s(r,n.metaKey||n.shiftKey),n.preventDefault(),!1;r=r.parentNode}},!1),window.addEventListener("phoenix.link.click",function(n){var r=n.target.getAttribute("data-confirm");r&&!window.confirm(r)&&n.preventDefault()},!1)})();var te=e=>typeof e=="function"?e:function(){return e},Gt=typeof self!="undefined"?self:null,ie=typeof window!="undefined"?window:null,be=Gt||ie||void 0,Yt="2.0.0",N={connecting:0,open:1,closing:2,closed:3},Qt=1e4,Zt=1e3,R={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},$={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},Oe={longpoll:"longpoll",websocket:"websocket"},ei={complete:4},ye=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})}},nt=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))}},ti=class{constructor(e,t,i){this.state=R.closed,this.topic=e,this.params=te(t||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new ye(this,$.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new nt(()=>{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=R.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=R.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=R.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=R.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 ye(this,$.leave,te({}),this.timeout).send(),this.state=R.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on($.reply,(s,n)=>{this.trigger(this.replyEventName(n),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($.close,e)}onError(e){return this.on($.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 ye(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=R.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger($.close,"leave")},i=new ye(this,$.leave,te({}),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=R.joining,this.joinPush.resend(e))}trigger(e,t,i,s){let n=this.onMessage(e,t,i,s);if(t&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(o=>o.event===e);for(let o=0;o<r.length;o++)r[o].callback(n,i,s||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===R.closed}isErrored(){return this.state===R.errored}isJoined(){return this.state===R.joined}isJoining(){return this.state===R.joining}isLeaving(){return this.state===R.leaving}},se=class{static request(e,t,i,s,n,r,o){if(be.XDomainRequest){let a=new be.XDomainRequest;this.xdomainRequest(a,e,t,s,n,r,o)}else{let a=new be.XMLHttpRequest;this.xhrRequest(a,e,t,i,s,n,r,o)}}static xdomainRequest(e,t,i,s,n,r,o){e.timeout=n,e.open(t,i),e.onload=()=>{let a=this.parseJSON(e.responseText);o&&o(a)},r&&(e.ontimeout=r),e.onprogress=()=>{},e.send(s)}static xhrRequest(e,t,i,s,n,r,o,a){e.open(t,i,!0),e.timeout=r,e.setRequestHeader("Content-Type",s),e.onerror=()=>{a&&a(null)},e.onreadystatechange=()=>{if(e.readyState===ei.complete&&a){let l=this.parseJSON(e.responseText);a(l)}},o&&(e.ontimeout=o),e.send(n)}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 n=t?`${t}[${s}]`:s,r=e[s];typeof r=="object"?i.push(this.serialize(r,n)):i.push(encodeURIComponent(n)+"="+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)}`}},rt=class{constructor(e){this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=N.connecting,this.poll()}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+Oe.websocket),"$1/"+Oe.longpoll)}endpointURL(){return se.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(){this.close(),this.readyState=N.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry()}poll(){(this.readyState===N.open||this.readyState===N.connecting)&&se.request("GET",this.endpointURL(),"application/json",null,this.timeout,this.ontimeout.bind(this),e=>{if(e){var{status:t,token:i,messages:s}=e;this.token=i}else t=0;switch(t){case 200:s.forEach(n=>{setTimeout(()=>{this.onmessage({data:n})},0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=N.open,this.onopen(),this.poll();break;case 403:this.onerror(),this.close();break;case 0:case 500:this.onerror(),this.closeAndRetry();break;default:throw new Error(`unhandled poll status ${t}`)}})}send(e){se.request("POST",this.endpointURL(),"application/json",e,this.timeout,this.onerror.bind(this,"timeout"),t=>{(!t||t.status!==200)&&(this.onerror(t&&t.status),this.closeAndRetry())})}close(e,t){this.readyState=N.closed,this.onclose()}};var Se={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(i))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[i,s,n,r,o]=JSON.parse(e);return t({join_ref:i,ref:s,topic:n,event:r,payload:o})}},binaryEncode(e){let{join_ref:t,ref:i,event:s,topic:n,payload:r}=e,o=this.META_LENGTH+t.length+i.length+n.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),d=0;l.setUint8(d++,this.KINDS.push),l.setUint8(d++,t.length),l.setUint8(d++,i.length),l.setUint8(d++,n.length),l.setUint8(d++,s.length),Array.from(t,f=>l.setUint8(d++,f.charCodeAt(0))),Array.from(i,f=>l.setUint8(d++,f.charCodeAt(0))),Array.from(n,f=>l.setUint8(d++,f.charCodeAt(0))),Array.from(s,f=>l.setUint8(d++,f.charCodeAt(0)));var p=new Uint8Array(a.byteLength+r.byteLength);return p.set(new Uint8Array(a),0),p.set(new Uint8Array(r),a.byteLength),p.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=i.decode(e.slice(o,o+s));o=o+s;let l=i.decode(e.slice(o,o+n));o=o+n;let d=i.decode(e.slice(o,o+r));o=o+r;let p=e.slice(o,e.byteLength);return{join_ref:a,ref:null,topic:l,event:d,payload:p}},decodeReply(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),o=t.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=i.decode(e.slice(a,a+s));a=a+s;let d=i.decode(e.slice(a,a+n));a=a+n;let p=i.decode(e.slice(a,a+r));a=a+r;let f=i.decode(e.slice(a,a+o));a=a+o;let u=e.slice(a,e.byteLength),g={status:f,response:u};return{join_ref:l,ref:d,topic:p,event:$.reply,payload:g}},decodeBroadcast(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=this.HEADER_LENGTH+2,o=i.decode(e.slice(r,r+s));r=r+s;let a=i.decode(e.slice(r,r+n));r=r+n;let l=e.slice(r,e.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},ot=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||Qt,this.transport=t.transport||be.WebSocket||rt,this.establishedConnections=0,this.defaultEncoder=Se.encode.bind(Se),this.defaultDecoder=Se.decode.bind(Se),this.closeWasClean=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==rt?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;ie&&ie.addEventListener&&(ie.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),ie.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.longpollerTimeout=t.longpollerTimeout||2e4,this.params=te(t.params||{}),this.endPoint=`${e}/${Oe.websocket}`,this.vsn=t.vsn||Yt,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new nt(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}replaceTransport(e){this.disconnect(),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=se.appendParams(se.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,this.reconnectTimer.reset(),this.teardown(e,t,i)}connect(e){this.connectClock++,e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=te(e)),!this.conn&&(this.closeWasClean=!1,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=t=>this.onConnError(t),this.conn.onmessage=t=>this.onConnMessage(t),this.conn.onclose=t=>this.onConnClose(t))}log(e,t,i){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}onConnOpen(){this.hasLogger()&&this.log("transport",`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.abnormalClose("heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,clearTimeout(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.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===N.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(),clearTimeout(this.heartbeatTimer),!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($.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case N.connecting:return"connecting";case N.open:return"open";case N.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t.joinRef()!==e.joinRef())}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 ti(e,t,this);return this.channels.push(i),i}push(e){if(this.hasLogger()){let{topic:t,event:i,payload:s,ref:n,join_ref:r}=e;this.log("push",`${t} ${i} (${r}, ${n})`,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.heartbeatTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}abnormalClose(e){this.closeWasClean=!1,this.isConnected()&&this.conn.close(Zt,e)}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:n,ref:r,join_ref:o}=t;r&&r===this.pendingHeartbeatRef&&(clearTimeout(this.heartbeatTimer),this.pendingHeartbeatRef=null,setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${n.status||""} ${i} ${s} ${r&&"("+r+")"||""}`,n);for(let a=0;a<this.channels.length;a++){let l=this.channels[a];!l.isMember(i,s,n,o)||l.trigger(s,n,r,o)}for(let a=0;a<this.stateChangeCallbacks.message.length;a++){let[,l]=this.stateChangeCallbacks.message[a];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())}};var at="consecutive-reloads",ii=10,si=1e3,ni=3e3,ri=3e4,lt=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],L="data-phx-component",Ne="data-phx-link",oi="track-static",ai="data-phx-link-state",H="data-phx-ref",z="data-phx-ref-src",ht="track-uploads",K="data-phx-upload-ref",He="data-phx-preflighted-refs",li="data-phx-done-refs",dt="drop-target",Ue="data-phx-active-refs",Me="phx:live-file:updated",je="data-phx-skip",ct="data-phx-prune",ut="page-loading",ft="phx-connected",$e="phx-loading",pt="phx-no-feedback",gt="phx-error",Q="data-phx-parent-id",Fe="data-phx-main",ne="data-phx-root-id",hi="trigger-action",Be="feedback-for",mt="phx-has-focused",di=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],vt=["checkbox","radio"],bt="phx-has-submitted",X="data-phx-session",Z=`[${X}]`,yt="data-phx-sticky",re="data-phx-static",Je="data-phx-readonly",ke="data-phx-disabled",Ve="disable-with",Ae="data-phx-disable-with-restore",we="hook",ci="debounce",ui="throttle",Xe="update",fi="key",U="phxPrivate",St="auto-recover",We="phx:live-socket:debug",qe="phx:live-socket:profiling",ze="phx:live-socket:latency-sim",pi="progress",gi=1,mi=200,vi="phx-",bi=3e4,oe="debounce-trigger",Ce="throttled",kt="debounce-prev-key",yi={debounce:300,throttle:300},At="d",M="s",x="c",wt="e",Ct="r",Et="t",Si="p",ki=class{constructor(e,t,i){this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=t,this.chunkTimer=null,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){clearTimeout(this.chunkTimer),this.uploadChannel.leave(),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 C("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))})}},C=(e,t)=>console.error&&console.error(e,t),W=e=>{let t=typeof e;return t==="number"||t==="string"&&/^(0|[1-9]\d*)$/.test(e)};function Ai(){let e=new Set,t=document.querySelectorAll("*[id]");for(let i=0,s=t.length;i<s;i++)e.has(t[i].id)?console.error(`Multiple IDs detected: ${t[i].id}. Ensure unique element ids.`):e.add(t[i].id)}var wi=(e,t,i,s)=>{e.liveSocket.isDebugEnabled()&&console.log(`${e.id} ${t}: ${i} - `,s)},Ke=e=>typeof e=="function"?e:function(){return e},Ee=e=>JSON.parse(JSON.stringify(e)),ae=(e,t,i)=>{do{if(e.matches(`[${t}]`))return e;e=e.parentElement||e.parentNode}while(e!==null&&e.nodeType===1&&!(i&&i.isSameNode(e)||e.matches(Z)));return null},le=e=>e!==null&&typeof e=="object"&&!(e instanceof Array),Ci=(e,t)=>JSON.stringify(e)===JSON.stringify(t),_t=e=>{for(let t in e)return!1;return!0},F=(e,t)=>e&&t(e),Ei=function(e,t,i,s){e.forEach(n=>{new ki(n,i.config.chunk_size,s).upload()})},Tt={canPushState(){return typeof history.pushState!="undefined"},dropLocal(e,t,i){return e.removeItem(this.localKey(t,i))},updateLocal(e,t,i,s,n){let r=this.getLocal(e,t,i),o=this.localKey(t,i),a=r===null?s:n(r);return e.setItem(o,JSON.stringify(a)),a},getLocal(e,t,i){return JSON.parse(e.getItem(this.localKey(t,i)))},updateCurrentState(e){!this.canPushState()||history.replaceState(e(history.state||{}),"",window.location.href)},pushState(e,t,i){if(this.canPushState()){if(i!==window.location.href){if(t.type=="redirect"&&t.scroll){let n=history.state||{};n.scroll=t.scroll,history.replaceState(n,"",window.location.href)}delete t.scroll,history[e+"State"](t,"",i||null);let s=this.getHashTargetEl(window.location.hash);s?s.scrollIntoView():t.type==="redirect"&&window.scroll(0,0)}}else this.redirect(i)},setCookie(e,t){document.cookie=`${e}=${t}`},getCookie(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${e}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(e,t){t&&Tt.setCookie("__phoenix_flash__",t+"; max-age=60000; path=/"),window.location=e},localKey(e,t){return`${e}-${t}`},getHashTargetEl(e){let t=e.toString().substring(1);if(t!=="")return document.getElementById(t)||document.querySelector(`a[name="${t}"]`)}},q=Tt,O={byId(e){return document.getElementById(e)||C(`no id found for ${e}`)},removeClass(e,t){e.classList.remove(t),e.classList.length===0&&e.removeAttribute("class")},all(e,t,i){if(!e)return[];let s=Array.from(e.querySelectorAll(t));return i?s.forEach(i):s},childNodeLength(e){let t=document.createElement("template");return t.innerHTML=e,t.content.childElementCount},isUploadInput(e){return e.type==="file"&&e.getAttribute(K)!==null},findUploadInputs(e){return this.all(e,`input[type="file"][${K}]`)},findComponentNodeList(e,t){return this.filterWithinSameLiveView(this.all(e,`[${L}="${t}"]`),e)},isPhxDestroyed(e){return!!(e.id&&O.private(e,"destroyed"))},markPhxChildDestroyed(e){this.isPhxChild(e)&&e.setAttribute(X,""),this.putPrivate(e,"destroyed",!0)},findPhxChildrenInFragment(e,t){let i=document.createElement("template");return i.innerHTML=e,this.findPhxChildren(i.content,t)},isIgnored(e,t){return(e.getAttribute(t)||e.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(e,t,i){return e.getAttribute&&i.indexOf(e.getAttribute(t))>=0},findPhxSticky(e){return this.all(e,`[${yt}]`)},findPhxChildren(e,t){return this.all(e,`${Z}[${Q}="${t}"]`)},findParentCIDs(e,t){let i=new Set(t);return t.reduce((s,n)=>{let r=`[${L}="${n}"] [${L}]`;return this.filterWithinSameLiveView(this.all(e,r),e).map(o=>parseInt(o.getAttribute(L))).forEach(o=>s.delete(o)),s},i)},filterWithinSameLiveView(e,t){return t.querySelector(Z)?e.filter(i=>this.withinSameLiveView(i,t)):e},withinSameLiveView(e,t){for(;e=e.parentNode;){if(e.isSameNode(t))return!0;if(e.getAttribute(X)!==null)return!1}},private(e,t){return e[U]&&e[U][t]},deletePrivate(e,t){e[U]&&delete e[U][t]},putPrivate(e,t,i){e[U]||(e[U]={}),e[U][t]=i},updatePrivate(e,t,i,s){let n=this.private(e,t);n===void 0?this.putPrivate(e,t,s(i)):this.putPrivate(e,t,s(n))},copyPrivates(e,t){t[U]&&(e[U]=t[U])},putTitle(e){let t=document.querySelector("title"),{prefix:i,suffix:s}=t.dataset;document.title=`${i||""}${e}${s||""}`},debounce(e,t,i,s,n,r,o){let a=e.getAttribute(i),l=e.getAttribute(n);a===""&&(a=s),l===""&&(l=r);let d=a||l;switch(d){case null:return o();case"blur":this.once(e,"debounce-blur")&&e.addEventListener("blur",()=>o());return;default:let p=parseInt(d),f=()=>l?this.deletePrivate(e,Ce):o(),u=this.incCycle(e,oe,f);if(isNaN(p))return C(`invalid throttle/debounce value: ${d}`);if(l){let v=!1;if(t.type==="keydown"){let m=this.private(e,kt);this.putPrivate(e,kt,t.key),v=m!==t.key}if(!v&&this.private(e,Ce))return!1;o(),this.putPrivate(e,Ce,!0),setTimeout(()=>this.triggerCycle(e,oe),p)}else setTimeout(()=>this.triggerCycle(e,oe,u),p);let g=e.form;g&&this.once(g,"bind-debounce")&&g.addEventListener("submit",()=>{Array.from(new FormData(g).entries(),([v])=>{let m=g.querySelector(`[name="${v}"]`);this.incCycle(m,oe),this.deletePrivate(m,Ce)})}),this.once(e,"bind-debounce")&&e.addEventListener("blur",()=>this.triggerCycle(e,oe))}},triggerCycle(e,t,i){let[s,n]=this.private(e,t);i||(i=s),i===s&&(this.incCycle(e,t),n())},once(e,t){return this.private(e,t)===!0?!1:(this.putPrivate(e,t,!0),!0)},incCycle(e,t,i=function(){}){let[s]=this.private(e,t)||[0,i];return s++,this.putPrivate(e,t,[s,i]),s},discardError(e,t,i){let s=t.getAttribute&&t.getAttribute(i),n=s&&e.querySelector(`[id="${s}"], [name="${s}"]`);!n||this.private(n,mt)||this.private(n.form,bt)||t.classList.add(pt)},showError(e,t){(e.id||e.name)&&this.all(e.form,`[${t}="${e.id}"], [${t}="${e.name}"]`,i=>{this.removeClass(i,pt)})},isPhxChild(e){return e.getAttribute&&e.getAttribute(Q)},isPhxSticky(e){return e.getAttribute&&e.getAttribute(yt)!==null},firstPhxChild(e){return this.isPhxChild(e)?e:this.all(e,`[${Q}]`)[0]},dispatchEvent(e,t,i={}){let s=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:i});e.dispatchEvent(s)},cloneNode(e,t){if(typeof t=="undefined")return e.cloneNode(!0);{let i=e.cloneNode(!1);return i.innerHTML=t,i}},mergeAttrs(e,t,i={}){let s=i.exclude||[],n=i.isIgnored,r=t.attributes;for(let a=r.length-1;a>=0;a--){let l=r[a].name;s.indexOf(l)<0&&e.setAttribute(l,t.getAttribute(l))}let o=e.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;n?l.startsWith("data-")&&!t.hasAttribute(l)&&e.removeAttribute(l):t.hasAttribute(l)||e.removeAttribute(l)}},mergeFocusedInput(e,t){e instanceof HTMLSelectElement||O.mergeAttrs(e,t,{except:["value"]}),t.readOnly?e.setAttribute("readonly",!0):e.removeAttribute("readonly")},hasSelectionRange(e){return e.setSelectionRange&&(e.type==="text"||e.type==="textarea")},restoreFocus(e,t,i){if(!O.isTextualInput(e))return;let s=e.matches(":focus");e.readOnly&&e.blur(),s||e.focus(),this.hasSelectionRange(e)&&e.setSelectionRange(t,i)},isFormInput(e){return/^(?:input|select|textarea)$/i.test(e.tagName)&&e.type!=="button"},syncAttrsToProps(e){e instanceof HTMLInputElement&&vt.indexOf(e.type.toLocaleLowerCase())>=0&&(e.checked=e.getAttribute("checked")!==null)},isTextualInput(e){return di.indexOf(e.type)>=0},isNowTriggerFormExternal(e,t){return e.getAttribute&&e.getAttribute(t)!==null},syncPendingRef(e,t,i){let s=e.getAttribute(H);if(s===null)return!0;let n=e.getAttribute(z);return O.isFormInput(e)||e.getAttribute(i)!==null?(O.isUploadInput(e)&&O.mergeAttrs(e,t,{isIgnored:!0}),O.putPrivate(e,H,t),!1):(lt.forEach(r=>{e.classList.contains(r)&&t.classList.add(r)}),t.setAttribute(H,s),t.setAttribute(z,n),!0)},cleanChildNodes(e,t){if(O.isPhxUpdate(e,t,["append","prepend"])){let i=[];e.childNodes.forEach(s=>{s.id||(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()===""||C(`only HTML element tags with an id are allowed inside containers with phx-update.
removing illegal node: "${(s.outerHTML||s.nodeValue).trim()}"
`),i.push(s))}),i.forEach(s=>s.remove())}},replaceRootContainer(e,t,i){let s=new Set(["id",X,re,Fe,ne]);if(e.tagName.toLowerCase()===t.toLowerCase())return Array.from(e.attributes).filter(n=>!s.has(n.name.toLowerCase())).forEach(n=>e.removeAttribute(n.name)),Object.keys(i).filter(n=>!s.has(n.toLowerCase())).forEach(n=>e.setAttribute(n,i[n])),e;{let n=document.createElement(t);return Object.keys(i).forEach(r=>n.setAttribute(r,i[r])),s.forEach(r=>n.setAttribute(r,e.getAttribute(r))),n.innerHTML=e.innerHTML,e.replaceWith(n),n}},getSticky(e,t,i){let s=(O.private(e,"sticky")||[]).find(([n])=>t===n);if(s){let[n,r,o]=s;return o}else return typeof i=="function"?i():i},deleteSticky(e,t){this.updatePrivate(e,"sticky",[],i=>i.filter(([s,n])=>s!==t))},putSticky(e,t,i){let s=i(e);this.updatePrivate(e,"sticky",[],n=>{let r=n.findIndex(([o])=>t===o);return r>=0?n[r]=[t,i,s]:n.push([t,i,s]),n})},applyStickyOperations(e){let t=O.private(e,"sticky");!t||t.forEach(([i,s,n])=>this.putSticky(e,i,s))}},h=O,Ge=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(Ue).split(",").indexOf(E.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(He).split(",").indexOf(E.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=E.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(Me,this._onElUpdated)}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{E.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}cancel(){this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),E.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Me,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Ue).split(",").indexOf(this.ref)===-1&&this.cancel()}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,size:this.file.size,type:this.file.type,ref:this.ref}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||C(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:Ei}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||C(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}},_i=0,E=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(_i++).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(He)!==i.getAttribute(li)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},r=e.getAttribute(K);i[r]=i[r]||[],n.ref=this.genFileRef(s),n.name=s.name||n.ref,n.type=s.type,n.size=s.size,i[r].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(K),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){if(e.getAttribute("multiple")!==null){let i=t.filter(s=>!this.activeFiles(e).find(n=>Object.is(n,s)));h.putPrivate(e,"files",this.activeFiles(e).concat(i)),e.value=null}else 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=>Ge.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=>!Ge.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(E.filesAwaitingPreflight(e)||[]).map(s=>new Ge(e,s,t)),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),n));let s=this._entries.reduce((n,r)=>{let{name:o,callback:a}=r.uploader(i.uploaders);return n[o]=n[o]||{callback:a,entries:[]},n[o].entries.push(r),n},{});for(let n in s){let{callback:r,entries:o}=s[n];r(o,t,e,i)}}},Ti={LiveFileUpload:{activeRefs(){return this.el.getAttribute(Ue)},preflightedRefs(){return this.el.getAttribute(He)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let e=this.preflightedRefs();this.preflightedWas!==e&&(this.preflightedWas=e,e===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(Me))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(K)),E.getEntryDataURL(this.inputEl,this.ref,e=>{this.url=e,this.el.src=e})},destroyed(){URL.revokeObjectURL(this.url)}}},Pi=Ti,Ri=class{constructor(e,t,i){let s=new Set,n=new Set([...t.children].map(o=>o.id)),r=[];Array.from(e.children).forEach(o=>{if(o.id&&(s.add(o.id),n.has(o.id))){let a=o.previousElementSibling&&o.previousElementSibling.id;r.push({elementId:o.id,previousElementId:a})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=r,this.elementIdsToAdd=[...n].filter(o=>!s.has(o))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?F(document.getElementById(t.previousElementId),i=>{F(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):F(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{F(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}},Pt=11;function Li(e,t){var i=t.attributes,s,n,r,o,a;if(!(t.nodeType===Pt||e.nodeType===Pt)){for(var l=i.length-1;l>=0;l--)s=i[l],n=s.name,r=s.namespaceURI,o=s.value,r?(n=s.localName||n,a=e.getAttributeNS(r,n),a!==o&&(s.prefix==="xmlns"&&(n=s.name),e.setAttributeNS(r,n,o))):(a=e.getAttribute(n),a!==o&&e.setAttribute(n,o));for(var d=e.attributes,p=d.length-1;p>=0;p--)s=d[p],n=s.name,r=s.namespaceURI,r?(n=s.localName||n,t.hasAttributeNS(r,n)||e.removeAttributeNS(r,n)):t.hasAttribute(n)||e.removeAttribute(n)}}var _e,xi="http://www.w3.org/1999/xhtml",P=typeof document=="undefined"?void 0:document,Di=!!P&&"content"in P.createElement("template"),Ii=!!P&&P.createRange&&"createContextualFragment"in P.createRange();function Oi(e){var t=P.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function Ni(e){_e||(_e=P.createRange(),_e.selectNode(P.body));var t=_e.createContextualFragment(e);return t.childNodes[0]}function Hi(e){var t=P.createElement("body");return t.innerHTML=e,t.childNodes[0]}function Ui(e){return e=e.trim(),Di?Oi(e):Ii?Ni(e):Hi(e)}function Te(e,t){var i=e.nodeName,s=t.nodeName,n,r;return i===s?!0:(n=i.charCodeAt(0),r=s.charCodeAt(0),n<=90&&r>=97?i===s.toUpperCase():r<=90&&n>=97?s===i.toUpperCase():!1)}function Mi(e,t){return!t||t===xi?P.createElement(e):P.createElementNS(t,e)}function ji(e,t){for(var i=e.firstChild;i;){var s=i.nextSibling;t.appendChild(i),i=s}return t}function Ye(e,t,i){e[i]!==t[i]&&(e[i]=t[i],e[i]?e.setAttribute(i,""):e.removeAttribute(i))}var Rt={OPTION:function(e,t){var i=e.parentNode;if(i){var s=i.nodeName.toUpperCase();s==="OPTGROUP"&&(i=i.parentNode,s=i&&i.nodeName.toUpperCase()),s==="SELECT"&&!i.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),i.selectedIndex=-1)}Ye(e,t,"selected")},INPUT:function(e,t){Ye(e,t,"checked"),Ye(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var i=t.value;e.value!==i&&(e.value=i);var s=e.firstChild;if(s){var n=s.nodeValue;if(n==i||!i&&n==e.placeholder)return;s.nodeValue=i}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var i=-1,s=0,n=e.firstChild,r,o;n;)if(o=n.nodeName&&n.nodeName.toUpperCase(),o==="OPTGROUP")r=n,n=r.firstChild;else{if(o==="OPTION"){if(n.hasAttribute("selected")){i=s;break}s++}n=n.nextSibling,!n&&r&&(n=r.nextSibling,r=null)}e.selectedIndex=i}}},he=1,$i=11,Lt=3,xt=8;function G(){}function Fi(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function Bi(e){return function(i,s,n){if(n||(n={}),typeof s=="string")if(i.nodeName==="#document"||i.nodeName==="HTML"||i.nodeName==="BODY"){var r=s;s=P.createElement("html"),s.innerHTML=r}else s=Ui(s);var o=n.getNodeKey||Fi,a=n.onBeforeNodeAdded||G,l=n.onNodeAdded||G,d=n.onBeforeElUpdated||G,p=n.onElUpdated||G,f=n.onBeforeNodeDiscarded||G,u=n.onNodeDiscarded||G,g=n.onBeforeElChildrenUpdated||G,v=n.childrenOnly===!0,m=Object.create(null),_=[];function T(S){_.push(S)}function D(S,y){if(S.nodeType===he)for(var b=S.firstChild;b;){var k=void 0;y&&(k=o(b))?T(k):(u(b),b.firstChild&&D(b,y)),b=b.nextSibling}}function c(S,y,b){f(S)!==!1&&(y&&y.removeChild(S),u(S),D(S,b))}function A(S){if(S.nodeType===he||S.nodeType===$i)for(var y=S.firstChild;y;){var b=o(y);b&&(m[b]=y),A(y),y=y.nextSibling}}A(i);function ce(S){l(S);for(var y=S.firstChild;y;){var b=y.nextSibling,k=o(y);if(k){var I=m[k];I&&Te(y,I)?(y.parentNode.replaceChild(I,y),fe(I,y)):ce(y)}else ce(y);y=b}}function ue(S,y,b){for(;y;){var k=y.nextSibling;(b=o(y))?T(b):c(y,S,!0),y=k}}function fe(S,y,b){var k=o(y);k&&delete m[k],!(!b&&(d(S,y)===!1||(e(S,y),p(S),g(S,y)===!1)))&&(S.nodeName!=="TEXTAREA"?jt(S,y):Rt.TEXTAREA(S,y))}function jt(S,y){var b=y.firstChild,k=S.firstChild,I,B,Y,ge,J;e:for(;b;){for(ge=b.nextSibling,I=o(b);k;){if(Y=k.nextSibling,b.isSameNode&&b.isSameNode(k)){b=ge,k=Y;continue e}B=o(k);var me=k.nodeType,V=void 0;if(me===b.nodeType&&(me===he?(I?I!==B&&((J=m[I])?Y===J?V=!1:(S.insertBefore(J,k),B?T(B):c(k,S,!0),k=J):V=!1):B&&(V=!1),V=V!==!1&&Te(k,b),V&&fe(k,b)):(me===Lt||me==xt)&&(V=!0,k.nodeValue!==b.nodeValue&&(k.nodeValue=b.nodeValue))),V){b=ge,k=Y;continue e}B?T(B):c(k,S,!0),k=Y}if(I&&(J=m[I])&&Te(J,b))S.appendChild(J),fe(J,b);else{var Ie=a(b);Ie!==!1&&(Ie&&(b=Ie),b.actualize&&(b=b.actualize(S.ownerDocument||P)),S.appendChild(b),ce(b))}b=ge,k=Y}ue(S,k,B);var et=Rt[S.nodeName];et&&et(S,y)}var w=i,pe=w.nodeType,Ze=s.nodeType;if(!v){if(pe===he)Ze===he?Te(i,s)||(u(i),w=ji(i,Mi(s.nodeName,s.namespaceURI))):w=s;else if(pe===Lt||pe===xt){if(Ze===pe)return w.nodeValue!==s.nodeValue&&(w.nodeValue=s.nodeValue),w;w=s}}if(w===s)u(i);else{if(s.isSameNode&&s.isSameNode(w))return;if(fe(w,s,v),_)for(var xe=0,$t=_.length;xe<$t;xe++){var De=m[_[xe]];De&&c(De,De.parentNode,!1)}}return!v&&w!==i&&i.parentNode&&(w.actualize&&(w=w.actualize(i.ownerDocument||P)),i.parentNode.replaceChild(w,i)),w}}var Ji=Bi(Li),Dt=Ji,Pe=class{static patchEl(e,t,i){Dt(e,t,{childrenOnly:!1,onBeforeElUpdated:(s,n)=>{if(i&&i.isSameNode(s)&&h.isFormInput(s))return h.mergeFocusedInput(s,n),!1}})}constructor(e,t,i,s,n){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.targetCID=n,this.cidPatch=W(this.targetCID),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(){h.all(this.container,"[phx-update=append] > *, [phx-update=prepend] > *",e=>{e.setAttribute(ct,"")})}perform(){let{view:e,liveSocket:t,container:i,html:s}=this,n=this.isCIDPatch()?this.targetCIDContainer(s):i;if(this.isCIDPatch()&&!n)return;let r=t.getActiveElement(),{selectionStart:o,selectionEnd:a}=r&&h.hasSelectionRange(r)?r:{},l=t.binding(Xe),d=t.binding(Be),p=t.binding(Ve),f=t.binding(hi),u=t.binding("remove"),g=[],v=[],m=[],_=[],T=null,D=t.time("premorph container prep",()=>this.buildDiffHTML(i,s,l,n));return this.trackBefore("added",i),this.trackBefore("updated",i,i),t.time("morphdom",()=>{Dt(n,D,{childrenOnly:n.getAttribute(L)===null,getNodeKey:c=>h.isPhxDestroyed(c)?null:c.id,onBeforeNodeAdded:c=>(this.trackBefore("added",c),c),onNodeAdded:c=>{c instanceof HTMLImageElement&&c.srcset?c.srcset=c.srcset:c instanceof HTMLVideoElement&&c.autoplay&&c.play(),h.isNowTriggerFormExternal(c,f)&&(T=c),h.discardError(n,c,d),(h.isPhxChild(c)&&e.ownsElement(c)||h.isPhxSticky(c)&&e.ownsElement(c.parentNode))&&this.trackAfter("phxChildAdded",c),g.push(c)},onNodeDiscarded:c=>{(h.isPhxChild(c)||h.isPhxSticky(c))&&t.destroyViewByEl(c),this.trackAfter("discarded",c)},onBeforeNodeDiscarded:c=>c.getAttribute&&c.getAttribute(ct)!==null?!0:c.parentNode!==null&&h.isPhxUpdate(c.parentNode,l,["append","prepend"])&&c.id?!1:c.getAttribute&&c.getAttribute(u)?(_.push(c),!1):!this.skipCIDSibling(c),onElUpdated:c=>{h.isNowTriggerFormExternal(c,f)&&(T=c),v.push(c)},onBeforeElUpdated:(c,A)=>{if(h.cleanChildNodes(A,l),this.skipCIDSibling(A)||h.isPhxSticky(c))return!1;if(h.isIgnored(c,l))return this.trackBefore("updated",c,A),h.mergeAttrs(c,A,{isIgnored:!0}),v.push(c),h.applyStickyOperations(c),!1;if(c.type==="number"&&c.validity&&c.validity.badInput)return!1;if(!h.syncPendingRef(c,A,p))return h.isUploadInput(c)&&(this.trackBefore("updated",c,A),v.push(c)),h.applyStickyOperations(c),!1;if(h.isPhxChild(A)){let ue=c.getAttribute(X);return h.mergeAttrs(c,A,{exclude:[re]}),ue!==""&&c.setAttribute(X,ue),c.setAttribute(ne,this.rootID),h.applyStickyOperations(c),!1}return h.copyPrivates(A,c),h.discardError(n,A,d),r&&c.isSameNode(r)&&h.isFormInput(c)?(this.trackBefore("updated",c,A),h.mergeFocusedInput(c,A),h.syncAttrsToProps(c),v.push(c),h.applyStickyOperations(c),!1):(h.isPhxUpdate(A,l,["append","prepend"])&&m.push(new Ri(c,A,A.getAttribute(l))),h.syncAttrsToProps(A),h.applyStickyOperations(A),this.trackBefore("updated",c,A),!0)}})}),t.isDebugEnabled()&&Ai(),m.length>0&&t.time("post-morph append/prepend restoration",()=>{m.forEach(c=>c.perform())}),t.silenceEvents(()=>h.restoreFocus(r,o,a)),h.dispatchEvent(document,"phx:update"),g.forEach(c=>this.trackAfter("added",c)),v.forEach(c=>this.trackAfter("updated",c)),_.length>0&&(t.transitionRemoves(_),t.requestDOMUpdate(()=>{_.forEach(c=>{let A=h.firstPhxChild(c);A&&t.destroyViewByEl(A),c.remove()}),this.trackAfter("transitionsDiscarded",_)})),T&&(t.disconnect(),T.submit()),!0}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.getAttribute(je)!==null}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}buildDiffHTML(e,t,i,s){let n=this.isCIDPatch(),r=n&&s.getAttribute(L)===this.targetCID.toString();if(!n||r)return t;{let o=null,a=document.createElement("template");o=h.cloneNode(s);let[l,...d]=h.findComponentNodeList(o,this.targetCID);return a.innerHTML=t,d.forEach(p=>p.remove()),Array.from(o.childNodes).forEach(p=>{p.id&&p.nodeType===Node.ELEMENT_NODE&&p.getAttribute(L)!==this.targetCID.toString()&&(p.setAttribute(je,""),p.innerHTML="")}),Array.from(a.content.childNodes).forEach(p=>o.insertBefore(p,l)),l.remove(),o.outerHTML}}},It=class{static extract(e){let{[Ct]:t,[wt]:i,[Et]:s}=e;return delete e[Ct],delete e[wt],delete e[Et],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){return this.recursiveToString(this.rendered,this.rendered[x],e)}recursiveToString(e,t=e[x],i){i=i?new Set(i):null;let s={buffer:"",components:t,onlyCids:i};return this.toOutputBuffer(e,null,s),s.buffer}componentCIDs(e){return Object.keys(e[x]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[x]?Object.keys(e).length===1:!1}getComponent(e,t){return e[x][t]}mergeDiff(e){let t=e[x],i={};if(delete e[x],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[x]=this.rendered[x]||{},t){let s=this.rendered[x];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[x]=t}}cachedFindComponent(e,t,i,s,n){if(n[e])return n[e];{let r,o,a=t[M];if(W(a)){let l;a>0?l=this.cachedFindComponent(a,s[a],i,s,n):l=i[-a],o=l[M],r=this.cloneMerge(l,t),r[M]=o}else r=t[M]!==void 0?t:this.cloneMerge(i[e]||{},t);return n[e]=r,r}}mutableMerge(e,t){return t[M]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let s=t[i],n=e[i];le(s)&&s[M]===void 0&&le(n)?this.doMutableMerge(n,s):e[i]=s}}cloneMerge(e,t){let i=ee(ee({},e),t);for(let s in i){let n=t[s],r=e[s];le(n)&&n[M]===void 0&&le(r)&&(i[s]=this.cloneMerge(r,n))}return i}componentToString(e){return this.recursiveCIDToString(this.rendered[x],e)}pruneCIDs(e){e.forEach(t=>delete this.rendered[x][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[M]}templateStatic(e,t){return typeof e=="number"?t[e]:e}toOutputBuffer(e,t,i){if(e[At])return this.comprehensionToBuffer(e,t,i);let{[M]:s}=e;s=this.templateStatic(s,t),i.buffer+=s[0];for(let n=1;n<s.length;n++)this.dynamicToBuffer(e[n-1],t,i),i.buffer+=s[n]}comprehensionToBuffer(e,t,i){let{[At]:s,[M]:n}=e;n=this.templateStatic(n,t);let r=t||e[Si];for(let o=0;o<s.length;o++){let a=s[o];i.buffer+=n[0];for(let l=1;l<n.length;l++)this.dynamicToBuffer(a[l-1],r,i),i.buffer+=n[l]}}dynamicToBuffer(e,t,i){typeof e=="number"?i.buffer+=this.recursiveCIDToString(i.components,e,i.onlyCids):le(e)?this.toOutputBuffer(e,t,i):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||C(`no component for CID ${t}`,e),n=document.createElement("template");n.innerHTML=this.recursiveToString(s,e,i);let r=n.content,o=i&&!i.has(t),[a,l]=Array.from(r.childNodes).reduce(([d,p],f,u)=>f.nodeType===Node.ELEMENT_NODE?f.getAttribute(L)?[d,!0]:(f.setAttribute(L,t),f.id||(f.id=`${this.parentViewId()}-${t}-${u}`),o&&(f.setAttribute(je,""),f.innerHTML=""),[!0,p]):f.nodeValue.trim()!==""?(C(`only HTML element tags are allowed at the root of components.
got: "${f.nodeValue.trim()}"
within:
`,n.innerHTML.trim()),f.replaceWith(this.createSpan(f.nodeValue,t)),[!0,p]):(f.remove(),[d,p]),[!1,!1]);return!a&&!l?(C(`expected at least one HTML element tag inside a component, but the component is empty:
`,n.innerHTML.trim()),this.createSpan("",t).outerHTML):(!a&&l&&C("expected at least one HTML element tag directly inside a component, but only subcomponents were found. A component must render at least one HTML tag directly inside itself.",n.innerHTML.trim()),n.innerHTML)}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(L,t),i}},Vi=1,de=class{static makeID(){return Vi++}static elementID(e){return e.phxHookId}constructor(e,t,i){this.__view=e,this.__liveSocket=e.liveSocket,this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,this.el=t,this.el.phxHookId=this.constructor.makeID();for(let s in this.__callbacks)this[s]=this.__callbacks[s]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,t={},i=function(){}){return this.__view.pushHookEvent(null,e,t,i)}pushEventTo(e,t,i={},s=function(){}){return this.__view.withinTargets(e,(n,r)=>n.pushHookEvent(r,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(e,t)}uploadTo(e,t,i){return this.__view.withinTargets(e,s=>s.dispatchUploads(t,i))}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}},Xi={exec(e,t,i,s,n){let[r,o]=n||[null,{}];(t.charAt(0)==="["?JSON.parse(t):[[r,o]]).forEach(([l,d])=>{l===r&&o.data&&(d.data=Object.assign(d.data||{},o.data)),this.filterToEls(s,d).forEach(p=>{this[`exec_${l}`](e,t,i,s,p,d)})})},isVisible(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length>0)},exec_dispatch(e,t,i,s,n,{to:r,event:o,detail:a}){h.dispatchEvent(n,o,a)},exec_push(e,t,i,s,n,r){let{event:o,data:a,target:l,page_loading:d,loading:p,value:f}=r,u={loading:p,value:f,target:l,page_loading:!!d},g=e==="change"?s.form:s,v=l||g.getAttribute(i.binding("target"))||g;i.withinTargets(v,(m,_)=>{if(e==="change"){let{newCid:T,_target:D,callback:c}=r;D&&(u._target=D),m.pushInput(s,_,T,o||t,u,c)}else e==="submit"?m.submitForm(s,_,o||t,u):m.pushEvent(e,s,_,o||t,a,u)})},exec_add_class(e,t,i,s,n,{names:r,transition:o,time:a}){this.addOrRemoveClasses(n,r,[],o,a,i)},exec_remove_class(e,t,i,s,n,{names:r,transition:o,time:a}){this.addOrRemoveClasses(n,[],r,o,a,i)},exec_transition(e,t,i,s,n,{time:r,transition:o}){let[a,l,d]=o,p=()=>this.addOrRemoveClasses(n,a.concat(l),[]),f=()=>this.addOrRemoveClasses(n,d,a.concat(l));i.transition(r,p,f)},exec_toggle(e,t,i,s,n,{display:r,ins:o,outs:a,time:l}){this.toggle(e,i,n,r,o,a,l)},exec_show(e,t,i,s,n,{display:r,transition:o,time:a}){this.show(e,i,n,r,o,a)},exec_hide(e,t,i,s,n,{display:r,transition:o,time:a}){this.hide(e,i,n,r,o,a)},exec_set_attr(e,t,i,s,n,{attr:[r,o]}){this.setOrRemoveAttrs(n,[[r,o]],[])},exec_remove_attr(e,t,i,s,n,{attr:r}){this.setOrRemoveAttrs(n,[],[r])},show(e,t,i,s,n,r){this.isVisible(i)||this.toggle(e,t,i,s,n,null,r)},hide(e,t,i,s,n,r){this.isVisible(i)&&this.toggle(e,t,i,s,null,n,r)},toggle(e,t,i,s,n,r,o){let[a,l,d]=n||[[],[],[]],[p,f,u]=r||[[],[],[]];if(a.length>0||p.length>0)if(this.isVisible(i)){let g=()=>{this.addOrRemoveClasses(i,f,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,u,f))})};i.dispatchEvent(new Event("phx:hide-start")),t.transition(o,g,()=>{this.addOrRemoveClasses(i,[],p.concat(u)),h.putSticky(i,"toggle",v=>v.style.display="none"),i.dispatchEvent(new Event("phx:hide-end"))})}else{if(e==="remove")return;let g=()=>{this.addOrRemoveClasses(i,l,p.concat(f).concat(u)),h.putSticky(i,"toggle",v=>v.style.display=s||"block"),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,d,l))})};i.dispatchEvent(new Event("phx:show-start")),t.transition(o,g,()=>{this.addOrRemoveClasses(i,[],a.concat(d)),i.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(i)?window.requestAnimationFrame(()=>{i.dispatchEvent(new Event("phx:hide-start")),h.putSticky(i,"toggle",g=>g.style.display="none"),i.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{i.dispatchEvent(new Event("phx:show-start")),h.putSticky(i,"toggle",g=>g.style.display=s||"block"),i.dispatchEvent(new Event("phx:show-end"))})},addOrRemoveClasses(e,t,i,s,n,r){let[o,a,l]=s||[[],[],[]];if(o.length>0){let d=()=>this.addOrRemoveClasses(e,a.concat(o),[]),p=()=>this.addOrRemoveClasses(e,t.concat(l),i.concat(o).concat(a));return r.transition(n,d,p)}window.requestAnimationFrame(()=>{let[d,p]=h.getSticky(e,"classes",[[],[]]),f=t.filter(m=>d.indexOf(m)<0&&!e.classList.contains(m)),u=i.filter(m=>p.indexOf(m)<0&&e.classList.contains(m)),g=d.filter(m=>i.indexOf(m)<0).concat(f),v=p.filter(m=>t.indexOf(m)<0).concat(u);h.putSticky(e,"classes",m=>(m.classList.remove(...v),m.classList.add(...g),[g,v]))})},setOrRemoveAttrs(e,t,i){let[s,n]=h.getSticky(e,"attrs",[[],[]]),r=t.filter(([d,p])=>!this.hasSet(s,d)&&!e.attributes.getNamedItem(d)),o=i.filter(d=>n.indexOf(d)<0&&e.attributes.getNamedItem(d)),a=s.filter(([d,p])=>i.indexOf(d)<0).concat(r),l=n.filter(d=>!this.hasSet(t,d)).concat(o);h.putSticky(e,"attrs",d=>(l.forEach(p=>d.removeAttribute(p)),a.forEach(([p,f])=>d.setAttribute(p,f)),[a,l]))},hasSet(e,t){return e.find(([i,s])=>i===t)},hasAllClasses(e,t){return t.every(i=>e.classList.contains(i))},isToggledOut(e,t){return!this.isVisible(e)||this.hasAllClasses(e,t)},filterToEls(e,{to:t}){return t?h.all(document,t):[e]}},j=Xi,Qe=(e,t={})=>{let i=new FormData(e),s=[];i.forEach((r,o,a)=>{r instanceof File&&s.push(o)}),s.forEach(r=>i.delete(r));let n=new URLSearchParams;for(let[r,o]of i.entries())n.append(r,o);for(let r in t)n.append(r,t[r]);return n.toString()},Ot=class{constructor(e,t,i,s){this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pruningCIDs=[],this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(n){n&&n()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.uploaders={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>({redirect:this.redirect?this.href:void 0,url:this.redirect?void 0:this.href||void 0,params:this.connectParams(),session:this.getSession(),static:this.getStatic(),flash:this.flash})),this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel()}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.getAttribute(Fe)!==null}connectParams(){let e=this.liveSocket.params(this.el),t=h.all(document,`[${this.binding(oi)}]`).map(i=>i.src||i.href).filter(i=>typeof i=="string");return t.length>0&&(e._track_static=t),e._mounts=this.joinCount,e}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(X)}getStatic(){let e=this.el.getAttribute(re);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(ft,$e,gt),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($e)}}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(ft)}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){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,i=>t(i,e));if(W(e))h.findComponentNodeList(this.el,e).length===0?C(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let i=Array.from(document.querySelectorAll(e));i.length===0&&C(`nothing found matching the phx-target selector "${e}"`),i.forEach(s=>this.liveSocket.owner(s,n=>t(n,s)))}}applyDiff(e,t,i){this.log(e,()=>["",Ee(t)]);let{diff:s,reply:n,events:r,title:o}=It.extract(t);return o&&h.putTitle(o),i({diff:s,reply:n,events:r}),n}onJoin(e){let{rendered:t,container:i}=e;if(i){let[s,n]=i;this.el=h.replaceRootContainer(this.el,s,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,q.dropLocal(this.liveSocket.localStorage,window.location.pathname,at),this.applyDiff("mount",t,({diff:s,events:n})=>{this.rendered=new It(this.id,s);let r=this.renderContainer(null,"join");this.dropPendingRefs();let o=this.formsForRecovery(r);this.joinCount++,o.length>0?o.forEach(([a,l,d],p)=>{this.pushFormRecovery(a,d,f=>{p===o.length-1&&this.onJoinComplete(f,r,n)})}):this.onJoinComplete(e,r,n)})}dropPendingRefs(){h.all(document,`[${z}="${this.id}"][${H}]`,e=>{e.removeAttribute(H),e.removeAttribute(z)})}onJoinComplete({live_patch:e},t,i){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i);h.findPhxChildrenInFragment(t,this.id).filter(n=>{let r=n.id&&this.el.querySelector(`[id="${n.id}"]`),o=r&&r.getAttribute(re);return o&&n.setAttribute(re,o),this.joinChild(n)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(ne,this.root.id)}applyJoinPatch(e,t,i){this.attachTrueDocEl();let s=new Pe(this,this.el,this.id,t,null);if(s.markPrunableContentForRemoval(),this.performPatch(s,!1),this.joinNewChildren(),h.all(this.el,`[${this.binding(we)}], [data-phx-${we}]`,n=>{let r=this.addHook(n);r&&r.__mounted()}),this.joinPending=!1,this.liveSocket.dispatchEvents(i),this.applyPendingUpdates(),e){let{kind:n,to:r}=e;this.liveSocket.historyPatch(r,n)}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(Xe));if(i&&!e.isEqualNode(t)&&!(s&&Ci(e.dataset,t.dataset)))return i.__beforeUpdate(),i}performPatch(e,t){let i=[],s=!1,n=new Set;return e.after("added",r=>{this.liveSocket.triggerDOM("onNodeAdded",[r]);let o=this.addHook(r);o&&o.__mounted()}),e.after("phxChildAdded",r=>{h.isPhxSticky(r)?this.liveSocket.joinRootViews():s=!0}),e.before("updated",(r,o)=>{this.triggerBeforeUpdateHook(r,o)&&n.add(r.id)}),e.after("updated",r=>{n.has(r.id)&&this.getHook(r).__updated()}),e.after("discarded",r=>{r.nodeType===Node.ELEMENT_NODE&&i.push(r)}),e.after("transitionsDiscarded",r=>this.afterElementsRemoved(r,t)),e.perform(),this.afterElementsRemoved(i,t),s}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{h.all(s,`[${L}]`).concat(s).forEach(r=>{let o=this.componentID(r);W(o)&&i.indexOf(o)===-1&&i.push(o);let a=this.getHook(r);a&&this.destroyHook(a)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(Q)][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 Ot(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.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink())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.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):_t(e)||this.liveSocket.time("full patch complete",()=>{let s=this.renderContainer(e,"update"),n=new Pe(this,this.el,this.id,s,null);i=this.performPatch(n,!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).concat(this.pruningCIDs):null,n=this.rendered.toString(s);return`<${i}>${n}</${i}>`})}componentPatch(e,t){if(_t(e))return!1;let i=this.rendered.componentToString(t),s=new Pe(this,this.el,this.id,i,t);return this.performPatch(s,!0)}getHook(e){return this.viewHooks[de.elementID(e)]}addHook(e){if(de.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${we}`)||e.getAttribute(this.binding(we));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||C(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let s=new de(this,e,i);return this.viewHooks[de.elementID(s.el)]=s,s}else t!==null&&C(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[de.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[]}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(){for(let e in this.root.children[this.id])this.getChildById(e).destroy()}onLiveRedirect(e){let{to:t,kind:i,flash:s}=e,n=this.expandURL(t);this.liveSocket.historyRedirect(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}){this.liveSocket.redirect(e,t)}isDestroyed(){return this.destroyed}join(e){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.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",t=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(t))}).receive("error",t=>!this.isDestroyed()&&this.onJoinError(t)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){return e.reason==="unauthorized"||e.reason==="stale"?(this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.href})):((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect?this.onRedirect(e.redirect):e.live_redirect?this.onLiveRedirect(e.live_redirect):(this.log("error",()=>["unable to join",e]),this.liveSocket.reloadWithJitter(this)))}onClose(e){if(!this.isDestroyed()){if(this.isJoinPending()&&document.visibilityState!=="hidden"||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(mi)}}onError(e){this.onClose(e),this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||this.displayError()}displayError(){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{to:this.href,kind:"error"}),this.showLoader(),this.setContainerClasses($e,gt)}pushWithReply(e,t,i,s=function(){}){if(!this.isConnected())return;let[n,[r],o]=e?e():[null,[],{}],a=function(){};return(o.page_loading||r&&r.getAttribute(this.binding(ut))!==null)&&(a=this.liveSocket.withPageLoading({kind:"element",target:r})),typeof i.cid!="number"&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(t,i,bi).receive("ok",l=>{n!==null&&this.undoRefs(n);let d=p=>{l.redirect&&this.onRedirect(l.redirect),l.live_patch&&this.onLivePatch(l.live_patch),l.live_redirect&&this.onLiveRedirect(l.live_redirect),a(),s(l,p)};l.diff?this.liveSocket.requestDOMUpdate(()=>{let p=this.applyDiff("update",l.diff,({diff:f,events:u})=>{this.update(f,u)});d(p)}):d(null)}))}undoRefs(e){h.all(document,`[${z}="${this.id}"][${H}="${e}"]`,t=>{let i=t.getAttribute(ke);t.removeAttribute(H),t.removeAttribute(z),t.getAttribute(Je)!==null&&(t.readOnly=!1,t.removeAttribute(Je)),i!==null&&(t.disabled=i==="true",t.removeAttribute(ke)),lt.forEach(r=>h.removeClass(t,r));let s=t.getAttribute(Ae);s!==null&&(t.innerText=s,t.removeAttribute(Ae));let n=h.private(t,H);if(n){let r=this.triggerBeforeUpdateHook(t,n);Pe.patchEl(t,n,this.liveSocket.getActiveElement()),r&&r.__updated(),h.deletePrivate(t,H)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(Ve);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(r=>{r.classList.add(`phx-${t}-loading`),r.setAttribute(H,s),r.setAttribute(z,this.el.id);let o=r.getAttribute(n);o!==null&&(r.getAttribute(Ae)||r.setAttribute(Ae,r.innerText),o!==""&&(r.innerText=o),r.setAttribute("disabled",""))}),[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(L);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(W(t))return t;let s=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?F(e.closest(`[${L}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",t,i]),!1;let[n,r,o]=this.putRef([],"hook");return this.pushWithReply(()=>[n,r,o],"event",{type:"hook",event:t,value:i,cid:this.closestComponentID(e)},(a,l)=>s(l,n)),n}extractMeta(e,t,i){let s=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let r=e.attributes[n].name;r.startsWith(s)&&(t[r.replace(s,"")]=e.getAttribute(r))}if(e.value!==void 0&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&vt.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,r={}){this.pushWithReply(()=>this.putRef([t],e,r),"event",{type:e,event:s,value:this.extractMeta(t,n,r.value),cid:this.targetComponentID(t,i,r)})}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(n,r)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(pi)),ref:e.getAttribute(K),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,r)},s)})}pushInput(e,t,i,s,n,r){let o,a=W(i)?i:this.targetComponentID(e.form,t),l=()=>this.putRef([e,e.form],"change",n),d=Qe(e.form,{_target:n._target});h.isUploadInput(e)&&e.files&&e.files.length>0&&E.trackFiles(e,Array.from(e.files)),o=E.serializeUploads(e);let p={type:"form",event:s,value:d,uploads:o,cid:a};this.pushWithReply(l,"event",p,f=>{if(h.showError(e,this.liveSocket.binding(Be)),h.isUploadInput(e)&&e.getAttribute("data-phx-auto-upload")!==null){if(E.filesAwaitingPreflight(e).length>0){let[u,g]=l();this.uploadFiles(e.form,t,u,a,v=>{r&&r(f),this.triggerAwaitingSubmit(e.form)})}}else r&&r(f)})}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,s,n,r]=t;this.cancelSubmit(e),r()}}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){this.formSubmits=this.formSubmits.filter(([t,i,s])=>t.isSameNode(e)?(this.undoRefs(i),!1):!0)}pushFormSubmit(e,t,i,s,n){let r=f=>!(ae(f,`${this.binding(Xe)}=ignore`,f.form)||ae(f,"data-phx-update=ignore",f.form)),o=f=>f.hasAttribute(this.binding(Ve)),a=f=>f.tagName=="BUTTON",l=f=>["INPUT","TEXTAREA","SELECT"].includes(f.tagName),d=()=>{let f=Array.from(e.elements),u=f.filter(o),g=f.filter(a).filter(r),v=f.filter(l).filter(r);return g.forEach(m=>{m.setAttribute(ke,m.disabled),m.disabled=!0}),v.forEach(m=>{m.setAttribute(Je,m.readOnly),m.readOnly=!0,m.files&&(m.setAttribute(ke,m.disabled),m.disabled=!0)}),e.setAttribute(this.binding(ut),""),this.putRef([e].concat(u).concat(g).concat(v),"submit",s)},p=this.targetComponentID(e,t);if(E.hasUploadsInProgress(e)){let[f,u]=d(),g=()=>this.pushFormSubmit(e,t,i,s,n);return this.scheduleSubmit(e,f,s,g)}else if(E.inputsAwaitingPreflight(e).length>0){let[f,u]=d(),g=()=>[f,u,s];this.uploadFiles(e,t,f,p,v=>{let m=Qe(e,{});this.pushWithReply(g,"event",{type:"form",event:i,value:m,cid:p},n)})}else{let f=Qe(e);this.pushWithReply(d,"event",{type:"form",event:i,value:f,cid:p},n)}}uploadFiles(e,t,i,s,n){let r=this.joinCount,o=E.activeFileInputs(e),a=o.length;o.forEach(l=>{let d=new E(l,this,()=>{a--,a===0&&n()});this.uploaders[l]=d;let p=d.entries().map(u=>u.toPreflightPayload()),f={ref:l.getAttribute(K),entries:p,cid:this.targetComponentID(l.form,t)};this.log("upload",()=>["sending preflight request",f]),this.pushWithReply(null,"allow_upload",f,u=>{if(this.log("upload",()=>["got preflight response",u]),u.error){this.undoRefs(i);let[g,v]=u.error;this.log("upload",()=>[`error for entry ${g}`,v])}else{let g=v=>{this.channel.onError(()=>{this.joinCount===r&&v()})};d.initAdapterUpload(u,g,this.liveSocket)}})})}dispatchUploads(e,t){let i=h.findUploadInputs(this.el).filter(s=>s.name===e);i.length===0?C(`no live file inputs found matching the name "${e}"`):i.length>1?C(`duplicate live file inputs found matching the name "${e}"`):h.dispatchEvent(i[0],ht,{files:t})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(s,n)=>{let r=e.elements[0],o=e.getAttribute(this.binding(St))||e.getAttribute(this.binding("change"));j.exec("change",o,s,r,["push",{_target:r.name,newCid:t,callback:i}])})}pushLinkPatch(e,t,i){let s=this.liveSocket.setPendingLink(e),n=t?()=>this.putRef([t],"click"):null,r=()=>this.liveSocket.redirect(window.location.href),o=this.pushWithReply(n,"live_patch",{url:e},a=>{this.liveSocket.requestDOMUpdate(()=>{a.link_redirect?this.liveSocket.replaceMain(e,null,i,s):(this.liveSocket.commitPendingLink(s)&&(this.href=e),this.applyPendingUpdates(),i&&i(s))})});o?o.receive("timeout",r):r()}formsForRecovery(e){if(this.joinCount===0)return[];let t=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,h.all(this.el,`form[${t}]`).filter(s=>s.id&&this.ownsElement(s)).filter(s=>s.elements.length>0).filter(s=>s.getAttribute(this.binding(St))!=="ignore").map(s=>{let n=i.content.querySelector(`form[id="${s.id}"][${t}="${s.getAttribute(t)}"]`);return n?[s,n,this.targetComponentID(n)]:[s,null,null]}).filter(([s,n,r])=>n)}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(this.pruningCIDs.push(...t),this.pushWithReply(null,"cids_will_destroy",{cids:t},()=>{this.pruningCIDs=this.pruningCIDs.filter(s=>t.indexOf(s)!==-1);let i=t.filter(s=>h.findComponentNodeList(this.el,s).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i},s=>{this.rendered.pruneCIDs(s.cids)})}))}ownsElement(e){return e.getAttribute(Q)===this.id||F(e.closest(Z),t=>t.id)===this.id}submitForm(e,t,i,s={}){h.putPrivate(e,bt,!0);let n=this.liveSocket.binding(Be),r=Array.from(e.elements);this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,()=>{r.forEach(o=>h.showError(o,n)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}},Nt=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||vi,this.opts=i,this.params=Ke(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Ee(yi),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.linkRef=1,this.clickRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=Ee(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||gi,this.maxReloads=i.maxReloads||ii,this.reloadJitterMin=i.reloadJitterMin||si,this.reloadJitterMax=i.reloadJitterMax||ni,this.failsafeJitter=i.failsafeJitter||ri,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:Ke(),onBeforeElUpdated:Ke()},i.dom||{}),this.transitions=new Wi,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(qe)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(We)==="true"}enableDebug(){this.sessionStorage.setItem(We,"true")}enableProfiling(){this.sessionStorage.setItem(qe,"true")}disableDebug(){this.sessionStorage.removeItem(We)}disableProfiling(){this.sessionStorage.removeItem(qe)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(ze,e)}disableLatencySim(){this.sessionStorage.removeItem(ze)}getLatencySim(){let e=this.sessionStorage.getItem(ze);return e?parseInt(e):null}getSocket(){return this.socket}connect(){let e=()=>{this.joinRootViews()&&(this.bindTopLevelEvents(),this.socket.connect())};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){this.socket.disconnect(e)}execJS(e,t,i=null){this.owner(e,s=>j.exec(i,t,s,e))}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();wi(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?(console.log(`simulating ${n}ms of latency from server to client`),setTimeout(()=>i(s),n)):i(s)})}wrapPush(e,t,i){let s=this.getLatencySim(),n=e.joinCount;if(!s)return t.timeout?i().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):i();console.log(`simulating ${s}ms of latency from client to server`);let r={receives:[],receive(o,a){this.receives.push([o,a])}};return setTimeout(()=>{e.isDestroyed()||r.receives.reduce((o,[a,l])=>o.receive(a,l),i())},s),r}reloadWithJitter(e,t){e.destroy(),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,r=q.updateLocal(this.localStorage,window.location.pathname,at,0,o=>o+1);t?t():this.log(e,"join",()=>[`encountered ${r} consecutive reloads`]),r>this.maxReloads&&(this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),n=this.failsafeJitter),setTimeout(()=>{this.hasPendingLink()?window.location=this.pendingLink:window.location.reload()},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?Pi[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)}joinRootViews(){let e=!1;return h.all(document,`${Z}:not([${Q}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.getAttribute(Fe)&&(this.main=i)}e=!0}),e}redirect(e,t){this.disconnect(),q.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let n=this.main.el,r=h.cloneNode(n,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(r,t),this.main.setRedirect(e),this.transitionRemoves(),this.main.join((o,a)=>{o===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{h.findPhxSticky(document).forEach(l=>r.appendChild(l)),n.replaceWith(r),i&&i(),a()})})}transitionRemoves(e){let t=this.binding("remove");e=e||h.all(document,`[${t}]`),e.forEach(i=>{document.body.contains(i)&&this.execJS(i,i.getAttribute(t),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(X)!==null}newRootView(e,t){let i=new Ot(e,this,null,t);return this.roots[i.id]=i,i}owner(e,t){let i=F(e.closest(Z),s=>this.getViewByEl(s))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(ne);return F(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]}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(ne));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let t=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",t),e.addEventListener("touchend",t)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents(){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.socket.onClose(e=>{e.code===1e3&&this.main&&this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",e=>{e.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),this.bindNav(),this.bindClicks(),this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(e,t,i,s,n,r)=>{let o=s.getAttribute(this.binding(fi)),a=e.key&&e.key.toLowerCase();if(o&&o.toLowerCase()!==a)return;let l=ee({key:e.key},this.eventMeta(t,e,s));j.exec(t,n,i,s,["push",{data:l}])}),this.bind({blur:"focusout",focus:"focusin"},(e,t,i,s,n,r)=>{if(!r){let o=ee({key:e.key},this.eventMeta(t,e,s));j.exec(t,n,i,s,["push",{data:o}])}}),this.bind({blur:"blur",focus:"focus"},(e,t,i,s,n,r,o)=>{if(o==="window"){let a=this.eventMeta(t,e,s);j.exec(t,r,i,s,["push",{data:a}])}}),window.addEventListener("dragover",e=>e.preventDefault()),window.addEventListener("drop",e=>{e.preventDefault();let t=F(ae(e.target,this.binding(dt)),n=>n.getAttribute(this.binding(dt))),i=t&&document.getElementById(t),s=Array.from(e.dataTransfer.files||[]);!i||i.disabled||s.length===0||!(i.files instanceof FileList)||(E.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(ht,e=>{let t=e.target;if(!h.isUploadInput(t))return;let i=Array.from(e.detail.files||[]).filter(s=>s instanceof File||s instanceof Blob);E.trackFiles(t,i),t.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.linkRef}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let s=e[i];this.on(s,n=>{let r=this.binding(i),o=this.binding(`window-${i}`),a=n.target.getAttribute&&n.target.getAttribute(r);a?this.debounce(n.target,n,()=>{this.withinOwners(n.target,l=>{t(n,i,l,n.target,a,null)})}):h.all(document,`[${o}]`,l=>{let d=l.getAttribute(o);this.debounce(l,n,()=>{this.withinOwners(l,p=>{t(n,i,p,l,d,"window")})})})})}}bindClicks(){this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let s=this.binding(t);window.addEventListener(e,n=>{if(!this.isConnected())return;this.clickRef++;let r=this.clickRef,o=null;i?o=n.target.matches(`[${s}]`)?n.target:n.target.querySelector(`[${s}]`):(o=ae(n.target,s),this.dispatchClickAway(n,r));let a=o&&o.getAttribute(s);!a||(o.getAttribute("href")==="#"&&n.preventDefault(),this.debounce(o,n,()=>{this.withinOwners(o,l=>{j.exec("click",a,l,o,["push",{data:this.eventMeta("click",n,o)}])})}))},i)}dispatchClickAway(e,t){let i=this.binding("click-away"),s=this.binding("click");h.all(document,`[${i}]`,n=>{n.isSameNode(e.target)||n.contains(e.target)||this.withinOwners(e.target,r=>{let o=n.getAttribute(i);if(j.isVisible(n)){let a=e.target.closest(`[${s}]`)||e.target;j.exec("click",o,r,n,["push",{data:this.eventMeta("click",e,e.target)}])}})})}bindNav(){if(!q.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{q.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,id:s,root:n,scroll:r}=t.state||{},o=window.location.href;this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&s===this.main.id?this.main.pushLinkPatch(o,null):this.replaceMain(o,null,()=>{n&&this.replaceRootHistory(),typeof r=="number"&&setTimeout(()=>{window.scrollTo(0,r)},0)})})},!1),window.addEventListener("click",t=>{let i=ae(t.target,Ne),s=i&&i.getAttribute(Ne),n=t.metaKey||t.ctrlKey||t.button===1;if(!s||!this.isConnected()||!this.main||n)return;let r=i.href,o=i.getAttribute(ai);t.preventDefault(),this.pendingLink!==r&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(r,o,i);else if(s==="redirect")this.historyRedirect(r,o);else throw new Error(`expected ${Ne} to be "patch" or "redirect", got: ${s}`)})},!1)}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,t)}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",e);let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",e);return t?t(i):i}pushHistoryPatch(e,t,i){this.withPageLoading({to:e,kind:"patch"},s=>{this.main.pushLinkPatch(e,i,n=>{this.historyPatch(e,t,n),s()})})}historyPatch(e,t,i=this.setPendingLink(e)){!this.commitPendingLink(i)||(q.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location))}historyRedirect(e,t,i){let s=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,i,()=>{q.pushState(t,{type:"redirect",id:this.main.id,scroll:s},e),this.registerNewLocation(window.location),n()})})}replaceRootHistory(){q.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=Ee(e),!0)}bindForms(){let e=0;this.on("submit",t=>{let i=t.target.getAttribute(this.binding("submit"));!i||(t.preventDefault(),t.target.disabled=!0,this.withinOwners(t.target,s=>{j.exec("submit",i,s,t.target,["push",{}])}))},!1);for(let t of["change","input"])this.on(t,i=>{let s=i.target,n=s.form&&s.form.getAttribute(this.binding("change"));if(!n||s.type==="number"&&s.validity&&s.validity.badInput)return;let r=e;e++;let{at:o,type:a}=h.private(s,"prev-iteration")||{};o===r-1&&t!==a||(h.putPrivate(s,"prev-iteration",{at:r,type:t}),this.debounce(s,i,()=>{this.withinOwners(s.form,l=>{h.putPrivate(s,mt,!0),h.isTextualInput(s)||this.setActiveElement(s),j.exec("change",n,l,s,["push",{_target:i.target.name}])})}))},!1)}debounce(e,t,i){let s=this.binding(ci),n=this.binding(ui),r=this.defaults.debounce.toString(),o=this.defaults.throttle.toString();h.debounce(e,t,s,r,n,o,i)}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,i=>{this.silenced||t(i)})}},Wi=class{constructor(){this.transitions=new Set,this.pendingOps=[],this.reset()}reset(){this.transitions.forEach(e=>{cancelTimeout(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.size()===0&&this.flushPendingOps()},e);this.transitions.add(s)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){this.pendingOps.forEach(e=>e()),this.pendingOps=[]}};var Le=Kt(Ut()),qi=document.querySelector("meta[name='csrf-token']").getAttribute("content"),Mt=new Nt("/live",ot,{params:{_csrf_token:qi}});document.documentElement.classList.remove("dark");Le.default.config({barColors:{0:"#29d"},shadowColor:"rgba(0, 0, 0, .3)"});window.addEventListener("phx:page-loading-start",e=>Le.default.show());window.addEventListener("phx:page-loading-stop",e=>Le.default.hide());window.addEventListener("server:toggle_theme",e=>{document.documentElement.classList.toggle("dark")});Mt.connect();window.liveSocket=Mt;})();
/**
* @license MIT
* topbar 1.0.0, 2021-01-06
* https://buunguyen.github.io/topbar
* Copyright (c) 2021 Buu Nguyen
*/