/*! For license information please see app.js.LICENSE.txt */ (()=>{var e={865:function(e,t,i){var n,s;n=function(){var e,t,i={version:"0.2.0"},n=i.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'
'};function s(e,t,i){return ei?i:e}function r(e){return 100*(-1+e)}function o(e,t,i){var s;return(s="translate3d"===n.positionUsing?{transform:"translate3d("+r(e)+"%,0,0)"}:"translate"===n.positionUsing?{transform:"translate("+r(e)+"%,0)"}:{"margin-left":r(e)+"%"}).transition="all "+t+"ms "+i,s}i.configure=function(e){var t,i;for(t in e)void 0!==(i=e[t])&&e.hasOwnProperty(t)&&(n[t]=i);return this},i.status=null,i.set=function(e){var t=i.isStarted();e=s(e,n.minimum,1),i.status=1===e?null:e;var r=i.render(!t),l=r.querySelector(n.barSelector),d=n.speed,c=n.easing;return r.offsetWidth,a((function(t){""===n.positionUsing&&(n.positionUsing=i.getPositioningCSS()),h(l,o(e,d,c)),1===e?(h(r,{transition:"none",opacity:1}),r.offsetWidth,setTimeout((function(){h(r,{transition:"all "+d+"ms linear",opacity:0}),setTimeout((function(){i.remove(),t()}),d)}),d)):setTimeout(t,d)})),this},i.isStarted=function(){return"number"==typeof i.status},i.start=function(){i.status||i.set(0);var e=function(){setTimeout((function(){i.status&&(i.trickle(),e())}),n.trickleSpeed)};return n.trickle&&e(),this},i.done=function(e){return e||i.status?i.inc(.3+.5*Math.random()).set(1):this},i.inc=function(e){var t=i.status;return t?("number"!=typeof e&&(e=(1-t)*s(Math.random()*t,.1,.95)),t=s(t+e,0,.994),i.set(t)):i.start()},i.trickle=function(){return i.inc(Math.random()*n.trickleRate)},e=0,t=0,i.promise=function(n){return n&&"resolved"!==n.state()?(0===t&&i.start(),e++,t++,n.always((function(){0==--t?(e=0,i.done()):i.set((e-t)/e)})),this):this},i.render=function(e){if(i.isRendered())return document.getElementById("nprogress");d(document.documentElement,"nprogress-busy");var t=document.createElement("div");t.id="nprogress",t.innerHTML=n.template;var s,o=t.querySelector(n.barSelector),a=e?"-100":r(i.status||0),l=document.querySelector(n.parent);return h(o,{transition:"all 0 linear",transform:"translate3d("+a+"%,0,0)"}),n.showSpinner||(s=t.querySelector(n.spinnerSelector))&&p(s),l!=document.body&&d(l,"nprogress-custom-parent"),l.appendChild(t),t},i.remove=function(){c(document.documentElement,"nprogress-busy"),c(document.querySelector(n.parent),"nprogress-custom-parent");var e=document.getElementById("nprogress");e&&p(e)},i.isRendered=function(){return!!document.getElementById("nprogress")},i.getPositioningCSS=function(){var e=document.body.style,t="WebkitTransform"in e?"Webkit":"MozTransform"in e?"Moz":"msTransform"in e?"ms":"OTransform"in e?"O":"";return t+"Perspective"in e?"translate3d":t+"Transform"in e?"translate":"margin"};var a=function(){var e=[];function t(){var i=e.shift();i&&i(t)}return function(i){e.push(i),1==e.length&&t()}}(),h=function(){var e=["Webkit","O","Moz","ms"],t={};function i(e){return e.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(e,t){return t.toUpperCase()}))}function n(t){var i=document.body.style;if(t in i)return t;for(var n,s=e.length,r=t.charAt(0).toUpperCase()+t.slice(1);s--;)if((n=e[s]+r)in i)return n;return t}function s(e){return e=i(e),t[e]||(t[e]=n(e))}function r(e,t,i){t=s(t),e.style[t]=i}return function(e,t){var i,n,s=arguments;if(2==s.length)for(i in t)void 0!==(n=t[i])&&t.hasOwnProperty(i)&&r(e,i,n);else r(e,s[1],s[2])}}();function l(e,t){return("string"==typeof e?e:u(e)).indexOf(" "+t+" ")>=0}function d(e,t){var i=u(e),n=i+t;l(i,t)||(e.className=n.substring(1))}function c(e,t){var i,n=u(e);l(e,t)&&(i=n.replace(" "+t+" "," "),e.className=i.substring(1,i.length-1))}function u(e){return(" "+(e.className||"")+" ").replace(/\s+/gi," ")}function p(e){e&&e.parentNode&&e.parentNode.removeChild(e)}return i},void 0===(s="function"==typeof n?n.call(t,i,t,e):n)||(e.exports=s)},827:()=>{"use strict";!function(){var e=function(){if("function"==typeof window.CustomEvent)return window.CustomEvent;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i}return e.prototype=window.Event.prototype,e}();function t(e,t){var i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,i}function i(e,i){var n=e.getAttribute("data-to"),s=t("_method",e.getAttribute("data-method")),r=t("_csrf_token",e.getAttribute("data-csrf")),o=document.createElement("form"),a=e.getAttribute("target");o.method="get"===e.getAttribute("data-method")?"get":"post",o.action=n,o.style.display="hidden",a?o.target=a:i&&(o.target="_blank"),o.appendChild(r),o.appendChild(s),document.body.appendChild(o),o.submit()}window.addEventListener("click",(function(t){var n=t.target;if(!t.defaultPrevented)for(;n&&n.getAttribute;){var s=new e("phoenix.link.click",{bubbles:!0,cancelable:!0});if(!n.dispatchEvent(s))return t.preventDefault(),t.stopImmediatePropagation(),!1;if(n.getAttribute("data-method"))return i(n,t.metaKey||t.shiftKey),t.preventDefault(),!1;n=n.parentNode}}),!1),window.addEventListener("phoenix.link.click",(function(e){var t=e.target.getAttribute("data-confirm");t&&!window.confirm(t)&&e.preventDefault()}),!1)}()}},t={};function i(n){var s=t[n];if(void 0!==s)return s.exports;var r=t[n]={exports:{}};return e[n].call(r.exports,r,r.exports,i),r.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";i(827);var e=e=>{if("function"==typeof e)return e;return function(){return e}},t="undefined"!=typeof self?self:null,n="undefined"!=typeof window?window:null,s=t||n||void 0,r=0,o=1,a=2,h=3,l="closed",d="errored",c="joined",u="joining",p="leaving",f="phx_close",m="phx_error",g="phx_join",v="phx_reply",b="phx_leave",y="longpoll",k="websocket",E=4,w=class{constructor(e,t,i,n){this.channel=e,this.event=t,this.payload=i||function(){return{}},this.receivedResp=null,this.timeout=n,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((t=>t.status===e)).forEach((e=>e.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})}},C=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))}},S=class{static request(e,t,i,n,r,o,a){if(s.XDomainRequest){let i=new s.XDomainRequest;this.xdomainRequest(i,e,t,n,r,o,a)}else{let h=new s.XMLHttpRequest;this.xhrRequest(h,e,t,i,n,r,o,a)}}static xdomainRequest(e,t,i,n,s,r,o){e.timeout=s,e.open(t,i),e.onload=()=>{let t=this.parseJSON(e.responseText);o&&o(t)},r&&(e.ontimeout=r),e.onprogress=()=>{},e.send(n)}static xhrRequest(e,t,i,n,s,r,o,a){e.open(t,i,!0),e.timeout=r,e.setRequestHeader("Content-Type",n),e.onerror=()=>{a&&a(null)},e.onreadystatechange=()=>{if(e.readyState===E&&a){let t=this.parseJSON(e.responseText);a(t)}},o&&(e.ontimeout=o),e.send(s)}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 n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let s=t?`${t}[${n}]`:n,r=e[n];"object"==typeof r?i.push(this.serialize(r,s)):i.push(encodeURIComponent(s)+"="+encodeURIComponent(r))}return i.join("&")}static appendParams(e,t){if(0===Object.keys(t).length)return e;let i=e.match(/\?/)?"&":"?";return`${e}${i}${this.serialize(t)}`}},A=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=r,this.poll()}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+k),"$1/"+y)}endpointURL(){return S.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(){this.close(),this.readyState=r}ontimeout(){this.onerror("timeout"),this.closeAndRetry()}poll(){this.readyState!==o&&this.readyState!==r||S.request("GET",this.endpointURL(),"application/json",null,this.timeout,this.ontimeout.bind(this),(e=>{if(e){var{status:t,token:i,messages:n}=e;this.token=i}else t=0;switch(t){case 200:n.forEach((e=>{setTimeout((()=>{this.onmessage({data:e})}),0)})),this.poll();break;case 204:this.poll();break;case 410:this.readyState=o,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){S.request("POST",this.endpointURL(),"application/json",e,this.timeout,this.onerror.bind(this,"timeout"),(e=>{e&&200===e.status||(this.onerror(e&&e.status),this.closeAndRetry())}))}close(e,t){this.readyState=h,this.onclose()}},x={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,n,s,r,o]=JSON.parse(e);return t({join_ref:i,ref:n,topic:s,event:r,payload:o})}},binaryEncode(e){let{join_ref:t,ref:i,event:n,topic:s,payload:r}=e,o=this.META_LENGTH+t.length+i.length+s.length+n.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),h=new DataView(a),l=0;h.setUint8(l++,this.KINDS.push),h.setUint8(l++,t.length),h.setUint8(l++,i.length),h.setUint8(l++,s.length),h.setUint8(l++,n.length),Array.from(t,(e=>h.setUint8(l++,e.charCodeAt(0)))),Array.from(i,(e=>h.setUint8(l++,e.charCodeAt(0)))),Array.from(s,(e=>h.setUint8(l++,e.charCodeAt(0)))),Array.from(n,(e=>h.setUint8(l++,e.charCodeAt(0))));var d=new Uint8Array(a.byteLength+r.byteLength);return d.set(new Uint8Array(a),0),d.set(new Uint8Array(r),a.byteLength),d.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),n=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(e,t,n);case this.KINDS.reply:return this.decodeReply(e,t,n);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,n)}},decodePush(e,t,i){let n=t.getUint8(1),s=t.getUint8(2),r=t.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=i.decode(e.slice(o,o+n));o+=n;let h=i.decode(e.slice(o,o+s));o+=s;let l=i.decode(e.slice(o,o+r));return o+=r,{join_ref:a,ref:null,topic:h,event:l,payload:e.slice(o,e.byteLength)}},decodeReply(e,t,i){let n=t.getUint8(1),s=t.getUint8(2),r=t.getUint8(3),o=t.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,h=i.decode(e.slice(a,a+n));a+=n;let l=i.decode(e.slice(a,a+s));a+=s;let d=i.decode(e.slice(a,a+r));a+=r;let c=i.decode(e.slice(a,a+o));a+=o;let u=e.slice(a,e.byteLength);return{join_ref:h,ref:l,topic:d,event:v,payload:{status:c,response:u}}},decodeBroadcast(e,t,i){let n=t.getUint8(1),s=t.getUint8(2),r=this.HEADER_LENGTH+2,o=i.decode(e.slice(r,r+n));r+=n;let a=i.decode(e.slice(r,r+s));return r+=s,{join_ref:null,ref:null,topic:o,event:a,payload:e.slice(r,e.byteLength)}}},T=i(865),P=i.n(T),L="consecutive-reloads",_=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],R="data-phx-component",I="data-phx-link",D="data-phx-ref",O="data-phx-ref-src",N="track-uploads",$="data-phx-upload-ref",M="data-phx-preflighted-refs",j="drop-target",U="data-phx-active-refs",H="phx:live-file:updated",F="data-phx-skip",B="data-phx-prune",J="page-loading",q="phx-connected",V="phx-loading",W="phx-no-feedback",z="phx-error",K="data-phx-parent-id",G="data-phx-main",X="data-phx-root-id",Y="feedback-for",Q="phx-has-focused",Z=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],ee=["checkbox","radio"],te="phx-has-submitted",ie="data-phx-session",ne=`[${ie}]`,se="data-phx-sticky",re="data-phx-static",oe="data-phx-readonly",ae="data-phx-disabled",he="disable-with",le="data-phx-disable-with-restore",de="hook",ce="update",ue="auto-recover",pe="phx:live-socket:debug",fe="phx:live-socket:profiling",me="phx:live-socket:latency-sim",ge="debounce-trigger",ve="throttled",be="debounce-prev-key",ye={debounce:300,throttle:300},ke="d",Ee="s",we="e",Ce="r",Se="t",Ae=(e,t)=>console.error&&console.error(e,t),xe=e=>{let t=typeof e;return"number"===t||"string"===t&&/^(0|[1-9]\d*)$/.test(e)};var Te,Pe=e=>"function"==typeof e?e:function(){return e},Le=e=>JSON.parse(JSON.stringify(e)),_e=(e,t,i)=>{do{if(e.matches(`[${t}]`))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType&&!(i&&i.isSameNode(e)||e.matches(ne)));return null},Re=e=>null!==e&&"object"==typeof e&&!(e instanceof Array),Ie=e=>{for(let t in e)return!1;return!0},De=(e,t)=>e&&t(e),Oe=function(e,t,i,n){e.forEach((e=>{let t=new 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=e=>{if(null!==e.target.error)return Ae("Read error: "+e.target.error);this.offset+=e.target.result.byteLength,this.pushChunk(e.target.result)},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))}))}}(e,i.config.chunk_size,n);t.upload()}))},Ne={canPushState:()=>void 0!==history.pushState,dropLocal(e,t,i){return e.removeItem(this.localKey(t,i))},updateLocal(e,t,i,n,s){let r=this.getLocal(e,t,i),o=this.localKey(t,i),a=null===r?n:s(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("redirect"==t.type&&t.scroll){let e=history.state||{};e.scroll=t.scroll,history.replaceState(e,"",window.location.href)}delete t.scroll,history[e+"State"](t,"",i||null);let n=this.getHashTargetEl(window.location.hash);n?n.scrollIntoView():"redirect"===t.type&&window.scroll(0,0)}}else this.redirect(i)},setCookie(e,t){document.cookie=`${e}=${t}`},getCookie:e=>document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${e}s*=s*([^;]*).*$)|^.*$`),"$1"),redirect(e,t){t&&Ne.setCookie("__phoenix_flash__",t+"; max-age=60000; path=/"),window.location=e},localKey:(e,t)=>`${e}-${t}`,getHashTargetEl(e){let t=e.toString().substring(1);if(""!==t)return document.getElementById(t)||document.querySelector(`a[name="${t}"]`)}},$e=Ne,Me={byId:e=>document.getElementById(e)||Ae(`no id found for ${e}`),removeClass(e,t){e.classList.remove(t),0===e.classList.length&&e.removeAttribute("class")},all(e,t,i){if(!e)return[];let n=Array.from(e.querySelectorAll(t));return i?n.forEach(i):n},childNodeLength(e){let t=document.createElement("template");return t.innerHTML=e,t.content.childElementCount},isUploadInput:e=>"file"===e.type&&null!==e.getAttribute($),findUploadInputs(e){return this.all(e,`input[type="file"][${$}]`)},findComponentNodeList(e,t){return this.filterWithinSameLiveView(this.all(e,`[${R}="${t}"]`),e)},isPhxDestroyed:e=>!(!e.id||!Me.private(e,"destroyed")),markPhxChildDestroyed(e){this.isPhxChild(e)&&e.setAttribute(ie,""),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)=>"ignore"===(e.getAttribute(t)||e.getAttribute("data-phx-update")),isPhxUpdate:(e,t,i)=>e.getAttribute&&i.indexOf(e.getAttribute(t))>=0,findPhxSticky(e){return this.all(e,`[${se}]`)},findPhxChildren(e,t){return this.all(e,`${ne}[${K}="${t}"]`)},findParentCIDs(e,t){let i=new Set(t);return t.reduce(((t,i)=>{let n=`[${R}="${i}"] [${R}]`;return this.filterWithinSameLiveView(this.all(e,n),e).map((e=>parseInt(e.getAttribute(R)))).forEach((e=>t.delete(e))),t}),i)},filterWithinSameLiveView(e,t){return t.querySelector(ne)?e.filter((e=>this.withinSameLiveView(e,t))):e},withinSameLiveView(e,t){for(;e=e.parentNode;){if(e.isSameNode(t))return!0;if(null!==e.getAttribute(ie))return!1}},private:(e,t)=>e.phxPrivate&&e.phxPrivate[t],deletePrivate(e,t){e.phxPrivate&&delete e.phxPrivate[t]},putPrivate(e,t,i){e.phxPrivate||(e.phxPrivate={}),e.phxPrivate[t]=i},updatePrivate(e,t,i,n){let s=this.private(e,t);void 0===s?this.putPrivate(e,t,n(i)):this.putPrivate(e,t,n(s))},copyPrivates(e,t){t.phxPrivate&&(e.phxPrivate=t.phxPrivate)},putTitle(e){let t=document.querySelector("title"),{prefix:i,suffix:n}=t.dataset;document.title=`${i||""}${e}${n||""}`},debounce(e,t,i,n,s,r,o){let a=e.getAttribute(i),h=e.getAttribute(s);""===a&&(a=n),""===h&&(h=r);let l=a||h;switch(l){case null:return o();case"blur":return void(this.once(e,"debounce-blur")&&e.addEventListener("blur",(()=>o())));default:let i=parseInt(l),n=()=>h?this.deletePrivate(e,ve):o(),s=this.incCycle(e,ge,n);if(isNaN(i))return Ae(`invalid throttle/debounce value: ${l}`);if(h){let n=!1;if("keydown"===t.type){let i=this.private(e,be);this.putPrivate(e,be,t.key),n=i!==t.key}if(!n&&this.private(e,ve))return!1;o(),this.putPrivate(e,ve,!0),setTimeout((()=>this.triggerCycle(e,ge)),i)}else setTimeout((()=>this.triggerCycle(e,ge,s)),i);let r=e.form;r&&this.once(r,"bind-debounce")&&r.addEventListener("submit",(()=>{Array.from(new FormData(r).entries(),(([e])=>{let t=r.querySelector(`[name="${e}"]`);this.incCycle(t,ge),this.deletePrivate(t,ve)}))})),this.once(e,"bind-debounce")&&e.addEventListener("blur",(()=>this.triggerCycle(e,ge)))}},triggerCycle(e,t,i){let[n,s]=this.private(e,t);i||(i=n),i===n&&(this.incCycle(e,t),s())},once(e,t){return!0!==this.private(e,t)&&(this.putPrivate(e,t,!0),!0)},incCycle(e,t,i=function(){}){let[n]=this.private(e,t)||[0,i];return n++,this.putPrivate(e,t,[n,i]),n},discardError(e,t,i){let n=t.getAttribute&&t.getAttribute(i),s=n&&e.querySelector(`[id="${n}"], [name="${n}"]`);s&&(this.private(s,Q)||this.private(s.form,te)||t.classList.add(W))},showError(e,t){(e.id||e.name)&&this.all(e.form,`[${t}="${e.id}"], [${t}="${e.name}"]`,(e=>{this.removeClass(e,W)}))},isPhxChild:e=>e.getAttribute&&e.getAttribute(K),isPhxSticky:e=>e.getAttribute&&null!==e.getAttribute(se),firstPhxChild(e){return this.isPhxChild(e)?e:this.all(e,`[${K}]`)[0]},dispatchEvent(e,t,i={}){let n=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:i});e.dispatchEvent(n)},cloneNode(e,t){if(void 0===t)return e.cloneNode(!0);{let i=e.cloneNode(!1);return i.innerHTML=t,i}},mergeAttrs(e,t,i={}){let n=i.exclude||[],s=i.isIgnored,r=t.attributes;for(let i=r.length-1;i>=0;i--){let s=r[i].name;n.indexOf(s)<0&&e.setAttribute(s,t.getAttribute(s))}let o=e.attributes;for(let i=o.length-1;i>=0;i--){let n=o[i].name;s?n.startsWith("data-")&&!t.hasAttribute(n)&&e.removeAttribute(n):t.hasAttribute(n)||e.removeAttribute(n)}},mergeFocusedInput(e,t){e instanceof HTMLSelectElement||Me.mergeAttrs(e,t,{except:["value"]}),t.readOnly?e.setAttribute("readonly",!0):e.removeAttribute("readonly")},hasSelectionRange:e=>e.setSelectionRange&&("text"===e.type||"textarea"===e.type),restoreFocus(e,t,i){if(!Me.isTextualInput(e))return;let n=e.matches(":focus");e.readOnly&&e.blur(),n||e.focus(),this.hasSelectionRange(e)&&e.setSelectionRange(t,i)},isFormInput:e=>/^(?:input|select|textarea)$/i.test(e.tagName)&&"button"!==e.type,syncAttrsToProps(e){e instanceof HTMLInputElement&&ee.indexOf(e.type.toLocaleLowerCase())>=0&&(e.checked=null!==e.getAttribute("checked"))},isTextualInput:e=>Z.indexOf(e.type)>=0,isNowTriggerFormExternal:(e,t)=>e.getAttribute&&null!==e.getAttribute(t),syncPendingRef(e,t,i){let n=e.getAttribute(D);if(null===n)return!0;let s=e.getAttribute(O);return Me.isFormInput(e)||null!==e.getAttribute(i)?(Me.isUploadInput(e)&&Me.mergeAttrs(e,t,{isIgnored:!0}),Me.putPrivate(e,D,t),!1):(_.forEach((i=>{e.classList.contains(i)&&t.classList.add(i)})),t.setAttribute(D,n),t.setAttribute(O,s),!0)},cleanChildNodes(e,t){if(Me.isPhxUpdate(e,t,["append","prepend"])){let t=[];e.childNodes.forEach((e=>{if(!e.id){e.nodeType===Node.TEXT_NODE&&""===e.nodeValue.trim()||Ae(`only HTML element tags with an id are allowed inside containers with phx-update.\n\nremoving illegal node: "${(e.outerHTML||e.nodeValue).trim()}"\n\n`),t.push(e)}})),t.forEach((e=>e.remove()))}},replaceRootContainer(e,t,i){let n=new Set(["id",ie,re,G,X]);if(e.tagName.toLowerCase()===t.toLowerCase())return Array.from(e.attributes).filter((e=>!n.has(e.name.toLowerCase()))).forEach((t=>e.removeAttribute(t.name))),Object.keys(i).filter((e=>!n.has(e.toLowerCase()))).forEach((t=>e.setAttribute(t,i[t]))),e;{let s=document.createElement(t);return Object.keys(i).forEach((e=>s.setAttribute(e,i[e]))),n.forEach((t=>s.setAttribute(t,e.getAttribute(t)))),s.innerHTML=e.innerHTML,e.replaceWith(s),s}},getSticky(e,t,i){let n=(Me.private(e,"sticky")||[]).find((([e])=>t===e));if(n){let[e,t,i]=n;return i}return"function"==typeof i?i():i},deleteSticky(e,t){this.updatePrivate(e,"sticky",[],(e=>e.filter((([e,i])=>e!==t))))},putSticky(e,t,i){let n=i(e);this.updatePrivate(e,"sticky",[],(e=>{let s=e.findIndex((([e])=>t===e));return s>=0?e[s]=[t,i,n]:e.push([t,i,n]),e}))},applyStickyOperations(e){let t=Me.private(e,"sticky");t&&t.forEach((([t,i,n])=>this.putSticky(e,t,i)))}},je=Me,Ue=class{static isActive(e,t){let i=void 0===t._phxRef,n=e.getAttribute(U).split(",").indexOf(Fe.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(M).split(",").indexOf(Fe.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=Fe.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(H,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,(()=>{Fe.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}),Fe.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(H,this._onElUpdated),e()}}onElUpdated(){-1===this.fileEl.getAttribute(U).split(",").indexOf(this.ref)&&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]||Ae(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}return{name:"channel",callback:Oe}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||Ae(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}},He=0,Fe=class{static genFileRef(e){let t=e._phxRef;return void 0!==t?t:(e._phxRef=(He++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let n=this.activeFiles(e).find((e=>this.genFileRef(e)===t));i(URL.createObjectURL(n))}static hasUploadsInProgress(e){let t=0;return je.findUploadInputs(e).forEach((e=>{e.getAttribute(M)!==e.getAttribute("data-phx-done-refs")&&t++})),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach((t=>{let n={path:e.name},s=e.getAttribute($);i[s]=i[s]||[],n.ref=this.genFileRef(t),n.name=t.name||n.ref,n.type=t.type,n.size=t.size,i[s].push(n)})),i}static clearFiles(e){e.value=null,e.removeAttribute($),je.putPrivate(e,"files",[])}static untrackFile(e,t){je.putPrivate(e,"files",je.private(e,"files").filter((e=>!Object.is(e,t))))}static trackFiles(e,t){if(null!==e.getAttribute("multiple")){let i=t.filter((t=>!this.activeFiles(e).find((e=>Object.is(e,t)))));je.putPrivate(e,"files",this.activeFiles(e).concat(i)),e.value=null}else je.putPrivate(e,"files",t)}static activeFileInputs(e){let t=je.findUploadInputs(e);return Array.from(t).filter((e=>e.files&&this.activeFiles(e).length>0))}static activeFiles(e){return(je.private(e,"files")||[]).filter((t=>Ue.isActive(e,t)))}static inputsAwaitingPreflight(e){let t=je.findUploadInputs(e);return Array.from(t).filter((e=>this.filesAwaitingPreflight(e).length>0))}static filesAwaitingPreflight(e){return this.activeFiles(e).filter((t=>!Ue.isPreflighted(e,t)))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(Fe.filesAwaitingPreflight(e)||[]).map((i=>new Ue(e,i,t))),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map((t=>(t.zipPostFlight(e),t.onDone((()=>{this.numEntriesInProgress--,0===this.numEntriesInProgress&&this.onComplete()})),t)));let n=this._entries.reduce(((e,t)=>{let{name:n,callback:s}=t.uploader(i.uploaders);return e[n]=e[n]||{callback:s,entries:[]},e[n].entries.push(t),e}),{});for(let s in n){let{callback:r,entries:o}=n[s];r(o,t,e,i)}}},Be={LiveFileUpload:{activeRefs(){return this.el.getAttribute(U)},preflightedRefs(){return this.el.getAttribute(M)},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(H))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute($)),Fe.getEntryDataURL(this.inputEl,this.ref,(e=>{this.url=e,this.el.src=e}))},destroyed(){URL.revokeObjectURL(this.url)}}};var Je="undefined"==typeof document?void 0:document,qe=!!Je&&"content"in Je.createElement("template"),Ve=!!Je&&Je.createRange&&"createContextualFragment"in Je.createRange();function We(e){return e=e.trim(),qe?function(e){var t=Je.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}(e):Ve?function(e){return Te||(Te=Je.createRange()).selectNode(Je.body),Te.createContextualFragment(e).childNodes[0]}(e):function(e){var t=Je.createElement("body");return t.innerHTML=e,t.childNodes[0]}(e)}function ze(e,t){var i,n,s=e.nodeName,r=t.nodeName;return s===r||(i=s.charCodeAt(0),n=r.charCodeAt(0),i<=90&&n>=97?s===r.toUpperCase():n<=90&&i>=97&&r===s.toUpperCase())}function Ke(e,t,i){e[i]!==t[i]&&(e[i]=t[i],e[i]?e.setAttribute(i,""):e.removeAttribute(i))}var Ge={OPTION:function(e,t){var i=e.parentNode;if(i){var n=i.nodeName.toUpperCase();"OPTGROUP"===n&&(n=(i=i.parentNode)&&i.nodeName.toUpperCase()),"SELECT"!==n||i.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),i.selectedIndex=-1)}Ke(e,t,"selected")},INPUT:function(e,t){Ke(e,t,"checked"),Ke(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 n=e.firstChild;if(n){var s=n.nodeValue;if(s==i||!i&&s==e.placeholder)return;n.nodeValue=i}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var i,n,s=-1,r=0,o=e.firstChild;o;)if("OPTGROUP"===(n=o.nodeName&&o.nodeName.toUpperCase()))o=(i=o).firstChild;else{if("OPTION"===n){if(o.hasAttribute("selected")){s=r;break}r++}!(o=o.nextSibling)&&i&&(o=i.nextSibling,i=null)}e.selectedIndex=s}}};function Xe(){}function Ye(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}var Qe,Ze=(Qe=function(e,t){var i,n,s,r,o=t.attributes;if(11!==t.nodeType&&11!==e.nodeType){for(var a=o.length-1;a>=0;a--)n=(i=o[a]).name,s=i.namespaceURI,r=i.value,s?(n=i.localName||n,e.getAttributeNS(s,n)!==r&&("xmlns"===i.prefix&&(n=i.name),e.setAttributeNS(s,n,r))):e.getAttribute(n)!==r&&e.setAttribute(n,r);for(var h=e.attributes,l=h.length-1;l>=0;l--)n=(i=h[l]).name,(s=i.namespaceURI)?(n=i.localName||n,t.hasAttributeNS(s,n)||e.removeAttributeNS(s,n)):t.hasAttribute(n)||e.removeAttribute(n)}},function(e,t,i){if(i||(i={}),"string"==typeof t)if("#document"===e.nodeName||"HTML"===e.nodeName||"BODY"===e.nodeName){var n=t;(t=Je.createElement("html")).innerHTML=n}else t=We(t);var s=i.getNodeKey||Ye,r=i.onBeforeNodeAdded||Xe,o=i.onNodeAdded||Xe,a=i.onBeforeElUpdated||Xe,h=i.onElUpdated||Xe,l=i.onBeforeNodeDiscarded||Xe,d=i.onNodeDiscarded||Xe,c=i.onBeforeElChildrenUpdated||Xe,u=!0===i.childrenOnly,p=Object.create(null),f=[];function m(e){f.push(e)}function g(e,t){if(1===e.nodeType)for(var i=e.firstChild;i;){var n=void 0;t&&(n=s(i))?m(n):(d(i),i.firstChild&&g(i,t)),i=i.nextSibling}}function v(e,t,i){!1!==l(e)&&(t&&t.removeChild(e),d(e),g(e,i))}function b(e){o(e);for(var t=e.firstChild;t;){var i=t.nextSibling,n=s(t);if(n){var r=p[n];r&&ze(t,r)?(t.parentNode.replaceChild(r,t),y(r,t)):b(t)}else b(t);t=i}}function y(e,t,i){var n=s(t);if(n&&delete p[n],!i){if(!1===a(e,t))return;if(Qe(e,t),h(e),!1===c(e,t))return}"TEXTAREA"!==e.nodeName?function(e,t){var i,n,o,a,h,l=t.firstChild,d=e.firstChild;e:for(;l;){for(a=l.nextSibling,i=s(l);d;){if(o=d.nextSibling,l.isSameNode&&l.isSameNode(d)){l=a,d=o;continue e}n=s(d);var c=d.nodeType,u=void 0;if(c===l.nodeType&&(1===c?(i?i!==n&&((h=p[i])?o===h?u=!1:(e.insertBefore(h,d),n?m(n):v(d,e,!0),d=h):u=!1):n&&(u=!1),(u=!1!==u&&ze(d,l))&&y(d,l)):3!==c&&8!=c||(u=!0,d.nodeValue!==l.nodeValue&&(d.nodeValue=l.nodeValue))),u){l=a,d=o;continue e}n?m(n):v(d,e,!0),d=o}if(i&&(h=p[i])&&ze(h,l))e.appendChild(h),y(h,l);else{var f=r(l);!1!==f&&(f&&(l=f),l.actualize&&(l=l.actualize(e.ownerDocument||Je)),e.appendChild(l),b(l))}l=a,d=o}!function(e,t,i){for(;t;){var n=t.nextSibling;(i=s(t))?m(i):v(t,e,!0),t=n}}(e,d,n);var g=Ge[e.nodeName];g&&g(e,t)}(e,t):Ge.TEXTAREA(e,t)}!function e(t){if(1===t.nodeType||11===t.nodeType)for(var i=t.firstChild;i;){var n=s(i);n&&(p[n]=i),e(i),i=i.nextSibling}}(e);var k,E,w=e,C=w.nodeType,S=t.nodeType;if(!u)if(1===C)1===S?ze(e,t)||(d(e),w=function(e,t){for(var i=e.firstChild;i;){var n=i.nextSibling;t.appendChild(i),i=n}return t}(e,(k=t.nodeName,(E=t.namespaceURI)&&"http://www.w3.org/1999/xhtml"!==E?Je.createElementNS(E,k):Je.createElement(k)))):w=t;else if(3===C||8===C){if(S===C)return w.nodeValue!==t.nodeValue&&(w.nodeValue=t.nodeValue),w;w=t}if(w===t)d(e);else{if(t.isSameNode&&t.isSameNode(w))return;if(y(w,t,u),f)for(var A=0,x=f.length;A{if(i&&i.isSameNode(e)&&je.isFormInput(e))return je.mergeFocusedInput(e,t),!1}})}constructor(e,t,i,n,s){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=n,this.targetCID=s,this.cidPatch=xe(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((e=>e(...t)))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach((e=>e(...t)))}markPrunableContentForRemoval(){je.all(this.container,"[phx-update=append] > *, [phx-update=prepend] > *",(e=>{e.setAttribute(B,"")}))}perform(){let{view:e,liveSocket:t,container:i,html:n}=this,s=this.isCIDPatch()?this.targetCIDContainer(n):i;if(this.isCIDPatch()&&!s)return;let r=t.getActiveElement(),{selectionStart:o,selectionEnd:a}=r&&je.hasSelectionRange(r)?r:{},h=t.binding(ce),l=t.binding(Y),d=t.binding(he),c=t.binding("trigger-action"),u=t.binding("remove"),p=[],f=[],m=[],g=[],v=null,b=t.time("premorph container prep",(()=>this.buildDiffHTML(i,n,h,s)));return this.trackBefore("added",i),this.trackBefore("updated",i,i),t.time("morphdom",(()=>{Ze(s,b,{childrenOnly:null===s.getAttribute(R),getNodeKey:e=>je.isPhxDestroyed(e)?null:e.id,onBeforeNodeAdded:e=>(this.trackBefore("added",e),e),onNodeAdded:t=>{t instanceof HTMLImageElement&&t.srcset?t.srcset=t.srcset:t instanceof HTMLVideoElement&&t.autoplay&&t.play(),je.isNowTriggerFormExternal(t,c)&&(v=t),je.discardError(s,t,l),(je.isPhxChild(t)&&e.ownsElement(t)||je.isPhxSticky(t)&&e.ownsElement(t.parentNode))&&this.trackAfter("phxChildAdded",t),p.push(t)},onNodeDiscarded:e=>{(je.isPhxChild(e)||je.isPhxSticky(e))&&t.destroyViewByEl(e),this.trackAfter("discarded",e)},onBeforeNodeDiscarded:e=>!(!e.getAttribute||null===e.getAttribute(B))||(null===e.parentNode||!je.isPhxUpdate(e.parentNode,h,["append","prepend"])||!e.id)&&(e.getAttribute&&e.getAttribute(u)?(g.push(e),!1):!this.skipCIDSibling(e)),onElUpdated:e=>{je.isNowTriggerFormExternal(e,c)&&(v=e),f.push(e)},onBeforeElUpdated:(e,t)=>{if(je.cleanChildNodes(t,h),this.skipCIDSibling(t))return!1;if(je.isPhxSticky(e))return!1;if(je.isIgnored(e,h))return this.trackBefore("updated",e,t),je.mergeAttrs(e,t,{isIgnored:!0}),f.push(e),je.applyStickyOperations(e),!1;if("number"===e.type&&e.validity&&e.validity.badInput)return!1;if(!je.syncPendingRef(e,t,d))return je.isUploadInput(e)&&(this.trackBefore("updated",e,t),f.push(e)),je.applyStickyOperations(e),!1;if(je.isPhxChild(t)){let i=e.getAttribute(ie);return je.mergeAttrs(e,t,{exclude:[re]}),""!==i&&e.setAttribute(ie,i),e.setAttribute(X,this.rootID),je.applyStickyOperations(e),!1}return je.copyPrivates(t,e),je.discardError(s,t,l),r&&e.isSameNode(r)&&je.isFormInput(e)?(this.trackBefore("updated",e,t),je.mergeFocusedInput(e,t),je.syncAttrsToProps(e),f.push(e),je.applyStickyOperations(e),!1):(je.isPhxUpdate(t,h,["append","prepend"])&&m.push(new class{constructor(e,t,i){let n=new Set,s=new Set([...t.children].map((e=>e.id))),r=[];Array.from(e.children).forEach((e=>{if(e.id&&(n.add(e.id),s.has(e.id))){let t=e.previousElementSibling&&e.previousElementSibling.id;r.push({elementId:e.id,previousElementId:t})}})),this.containerId=t.id,this.updateType=i,this.elementsToModify=r,this.elementIdsToAdd=[...s].filter((e=>!n.has(e)))}perform(){let e=je.byId(this.containerId);this.elementsToModify.forEach((t=>{t.previousElementId?De(document.getElementById(t.previousElementId),(e=>{De(document.getElementById(t.elementId),(t=>{t.previousElementSibling&&t.previousElementSibling.id==e.id||e.insertAdjacentElement("afterend",t)}))})):De(document.getElementById(t.elementId),(t=>{null==t.previousElementSibling||e.insertAdjacentElement("afterbegin",t)}))})),"prepend"==this.updateType&&this.elementIdsToAdd.reverse().forEach((t=>{De(document.getElementById(t),(t=>e.insertAdjacentElement("afterbegin",t)))}))}}(e,t,t.getAttribute(h))),je.syncAttrsToProps(t),je.applyStickyOperations(t),this.trackBefore("updated",e,t),!0)}})})),t.isDebugEnabled()&&function(){let e=new Set,t=document.querySelectorAll("*[id]");for(let i=0,n=t.length;i0&&t.time("post-morph append/prepend restoration",(()=>{m.forEach((e=>e.perform()))})),t.silenceEvents((()=>je.restoreFocus(r,o,a))),je.dispatchEvent(document,"phx:update"),p.forEach((e=>this.trackAfter("added",e))),f.forEach((e=>this.trackAfter("updated",e))),g.length>0&&(t.transitionRemoves(g),t.requestDOMUpdate((()=>{g.forEach((e=>{let i=je.firstPhxChild(e);i&&t.destroyViewByEl(i),e.remove()})),this.trackAfter("transitionsDiscarded",g)}))),v&&(t.disconnect(),v.submit()),!0}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&null!==e.getAttribute(F)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=je.findComponentNodeList(this.container,this.targetCID);return 0===i.length&&1===je.childNodeLength(e)?t:t&&t.parentNode}buildDiffHTML(e,t,i,n){let s=this.isCIDPatch(),r=s&&n.getAttribute(R)===this.targetCID.toString();if(!s||r)return t;{let e=null,i=document.createElement("template");e=je.cloneNode(n);let[s,...r]=je.findComponentNodeList(e,this.targetCID);return i.innerHTML=t,r.forEach((e=>e.remove())),Array.from(e.childNodes).forEach((e=>{e.id&&e.nodeType===Node.ELEMENT_NODE&&e.getAttribute(R)!==this.targetCID.toString()&&(e.setAttribute(F,""),e.innerHTML="")})),Array.from(i.content.childNodes).forEach((t=>e.insertBefore(t,s))),s.remove(),e.outerHTML}}},tt=class{static extract(e){let{[Ce]:t,[we]:i,[Se]:n}=e;return delete e[Ce],delete e[we],delete e[Se],{diff:e,title:n,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.c,e)}recursiveToString(e,t=e.c,i){let n={buffer:"",components:t,onlyCids:i=i?new Set(i):null};return this.toOutputBuffer(e,null,n),n.buffer}componentCIDs(e){return Object.keys(e.c||{}).map((e=>parseInt(e)))}isComponentOnlyDiff(e){return!!e.c&&1===Object.keys(e).length}getComponent(e,t){return e.c[t]}mergeDiff(e){let t=e.c,i={};if(delete e.c,this.rendered=this.mutableMerge(this.rendered,e),this.rendered.c=this.rendered.c||{},t){let n=this.rendered.c;for(let e in t)t[e]=this.cachedFindComponent(e,t[e],n,t,i);for(let e in t)n[e]=t[e];e.c=t}}cachedFindComponent(e,t,i,n,s){if(s[e])return s[e];{let r,o,a=t[Ee];if(xe(a)){let e;e=a>0?this.cachedFindComponent(a,n[a],i,n,s):i[-a],o=e[Ee],r=this.cloneMerge(e,t),r[Ee]=o}else r=void 0!==t[Ee]?t:this.cloneMerge(i[e]||{},t);return s[e]=r,r}}mutableMerge(e,t){return void 0!==t[Ee]?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let n=t[i],s=e[i];Re(n)&&void 0===n[Ee]&&Re(s)?this.doMutableMerge(s,n):e[i]=n}}cloneMerge(e,t){let i={...e,...t};for(let n in i){let s=t[n],r=e[n];Re(s)&&void 0===s[Ee]&&Re(r)&&(i[n]=this.cloneMerge(r,s))}return i}componentToString(e){return this.recursiveCIDToString(this.rendered.c,e)}pruneCIDs(e){e.forEach((e=>delete this.rendered.c[e]))}get(){return this.rendered}isNewFingerprint(e={}){return!!e[Ee]}templateStatic(e,t){return"number"==typeof e?t[e]:e}toOutputBuffer(e,t,i){if(e[ke])return this.comprehensionToBuffer(e,t,i);let{[Ee]:n}=e;n=this.templateStatic(n,t),i.buffer+=n[0];for(let s=1;sn.nodeType===Node.ELEMENT_NODE?n.getAttribute(R)?[e,!0]:(n.setAttribute(R,t),n.id||(n.id=`${this.parentViewId()}-${t}-${r}`),o&&(n.setAttribute(F,""),n.innerHTML=""),[!0,i]):""!==n.nodeValue.trim()?(Ae(`only HTML element tags are allowed at the root of components.\n\ngot: "${n.nodeValue.trim()}"\n\nwithin:\n`,s.innerHTML.trim()),n.replaceWith(this.createSpan(n.nodeValue,t)),[!0,i]):(n.remove(),[e,i])),[!1,!1]);return a||h?!a&&h?(Ae("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.",s.innerHTML.trim()),s.innerHTML):s.innerHTML:(Ae("expected at least one HTML element tag inside a component, but the component is empty:\n",s.innerHTML.trim()),this.createSpan("",t).outerHTML)}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(R,t),i}},it=1,nt=class{static makeID(){return it++}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 e in this.__callbacks)this[e]=this.__callbacks[e]}__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={},n=function(){}){return this.__view.withinTargets(e,((e,s)=>e.pushHookEvent(s,t,i,n)))}handleEvent(e,t){let i=(i,n)=>n?e:t(i.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,(e=>e.dispatchUploads(t,i)))}__cleanup__(){this.__listeners.forEach((e=>this.removeHandleEvent(e)))}},st={exec(e,t,i,n,s){let[r,o]=s||[null,{}];("["===t.charAt(0)?JSON.parse(t):[[r,o]]).forEach((([s,a])=>{s===r&&o.data&&(a.data=Object.assign(a.data||{},o.data)),this.filterToEls(n,a).forEach((r=>{this[`exec_${s}`](e,t,i,n,r,a)}))}))},isVisible:e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length>0),exec_dispatch(e,t,i,n,s,{to:r,event:o,detail:a}){je.dispatchEvent(s,o,a)},exec_push(e,t,i,n,s,r){let{event:o,data:a,target:h,page_loading:l,loading:d,value:c}=r,u={loading:d,value:c,target:h,page_loading:!!l},p="change"===e?n.form:n,f=h||p.getAttribute(i.binding("target"))||p;i.withinTargets(f,((i,s)=>{if("change"===e){let{newCid:e,_target:a,callback:h}=r;a&&(u._target=a),i.pushInput(n,s,e,o||t,u,h)}else"submit"===e?i.submitForm(n,s,o||t,u):i.pushEvent(e,n,s,o||t,a,u)}))},exec_add_class(e,t,i,n,s,{names:r,transition:o,time:a}){this.addOrRemoveClasses(s,r,[],o,a,i)},exec_remove_class(e,t,i,n,s,{names:r,transition:o,time:a}){this.addOrRemoveClasses(s,[],r,o,a,i)},exec_transition(e,t,i,n,s,{time:r,transition:o}){let[a,h,l]=o;i.transition(r,(()=>this.addOrRemoveClasses(s,a.concat(h),[])),(()=>this.addOrRemoveClasses(s,l,a.concat(h))))},exec_toggle(e,t,i,n,s,{display:r,ins:o,outs:a,time:h}){this.toggle(e,i,s,r,o,a,h)},exec_show(e,t,i,n,s,{display:r,transition:o,time:a}){this.show(e,i,s,r,o,a)},exec_hide(e,t,i,n,s,{display:r,transition:o,time:a}){this.hide(e,i,s,r,o,a)},exec_set_attr(e,t,i,n,s,{attr:[r,o]}){this.setOrRemoveAttrs(s,[[r,o]],[])},exec_remove_attr(e,t,i,n,s,{attr:r}){this.setOrRemoveAttrs(s,[],[r])},show(e,t,i,n,s,r){this.isVisible(i)||this.toggle(e,t,i,n,s,null,r)},hide(e,t,i,n,s,r){this.isVisible(i)&&this.toggle(e,t,i,n,null,s,r)},toggle(e,t,i,n,s,r,o){let[a,h,l]=s||[[],[],[]],[d,c,u]=r||[[],[],[]];if(a.length>0||d.length>0)if(this.isVisible(i)){let e=()=>{this.addOrRemoveClasses(i,c,a.concat(h).concat(l)),window.requestAnimationFrame((()=>{this.addOrRemoveClasses(i,d,[]),window.requestAnimationFrame((()=>this.addOrRemoveClasses(i,u,c)))}))};i.dispatchEvent(new Event("phx:hide-start")),t.transition(o,e,(()=>{this.addOrRemoveClasses(i,[],d.concat(u)),je.putSticky(i,"toggle",(e=>e.style.display="none")),i.dispatchEvent(new Event("phx:hide-end"))}))}else{if("remove"===e)return;let s=()=>{this.addOrRemoveClasses(i,h,d.concat(c).concat(u)),je.putSticky(i,"toggle",(e=>e.style.display=n||"block")),window.requestAnimationFrame((()=>{this.addOrRemoveClasses(i,a,[]),window.requestAnimationFrame((()=>this.addOrRemoveClasses(i,l,h)))}))};i.dispatchEvent(new Event("phx:show-start")),t.transition(o,s,(()=>{this.addOrRemoveClasses(i,[],a.concat(l)),i.dispatchEvent(new Event("phx:show-end"))}))}else this.isVisible(i)?window.requestAnimationFrame((()=>{i.dispatchEvent(new Event("phx:hide-start")),je.putSticky(i,"toggle",(e=>e.style.display="none")),i.dispatchEvent(new Event("phx:hide-end"))})):window.requestAnimationFrame((()=>{i.dispatchEvent(new Event("phx:show-start")),je.putSticky(i,"toggle",(e=>e.style.display=n||"block")),i.dispatchEvent(new Event("phx:show-end"))}))},addOrRemoveClasses(e,t,i,n,s,r){let[o,a,h]=n||[[],[],[]];if(o.length>0){let n=()=>this.addOrRemoveClasses(e,a.concat(o),[]),l=()=>this.addOrRemoveClasses(e,t.concat(h),i.concat(o).concat(a));return r.transition(s,n,l)}window.requestAnimationFrame((()=>{let[n,s]=je.getSticky(e,"classes",[[],[]]),r=t.filter((t=>n.indexOf(t)<0&&!e.classList.contains(t))),o=i.filter((t=>s.indexOf(t)<0&&e.classList.contains(t))),a=n.filter((e=>i.indexOf(e)<0)).concat(r),h=s.filter((e=>t.indexOf(e)<0)).concat(o);je.putSticky(e,"classes",(e=>(e.classList.remove(...h),e.classList.add(...a),[a,h])))}))},setOrRemoveAttrs(e,t,i){let[n,s]=je.getSticky(e,"attrs",[[],[]]),r=t.filter((([t,i])=>!this.hasSet(n,t)&&!e.attributes.getNamedItem(t))),o=i.filter((t=>s.indexOf(t)<0&&e.attributes.getNamedItem(t))),a=n.filter((([e,t])=>i.indexOf(e)<0)).concat(r),h=s.filter((e=>!this.hasSet(t,e))).concat(o);je.putSticky(e,"attrs",(e=>(h.forEach((t=>e.removeAttribute(t))),a.forEach((([t,i])=>e.setAttribute(t,i))),[a,h])))},hasSet:(e,t)=>e.find((([e,i])=>e===t)),hasAllClasses:(e,t)=>t.every((t=>e.classList.contains(t))),isToggledOut(e,t){return!this.isVisible(e)||this.hasAllClasses(e,t)},filterToEls:(e,{to:t})=>t?je.all(document,t):[e]},rt=(e,t={})=>{let i=new FormData(e),n=[];i.forEach(((e,t,i)=>{e instanceof File&&n.push(t)})),n.forEach((e=>i.delete(e)));let s=new URLSearchParams;for(let[e,t]of i.entries())s.append(e,t);for(let e in t)s.append(e,t[e]);return s.toString()},ot=class{constructor(e,t,i,n){this.liveSocket=t,this.flash=n,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(e){e&&e()},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 null!==this.el.getAttribute(G)}connectParams(){let e=this.liveSocket.params(this.el),t=je.all(document,`[${this.binding("track-static")}]`).map((e=>e.src||e.href)).filter((e=>"string"==typeof e));return t.length>0&&(e._track_static=t),e._mounts=this.joinCount,e}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(ie)}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 e in this.viewHooks)this.destroyHook(this.viewHooks[e])};je.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(q,V,z),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout((()=>this.showLoader()),e);else{for(let e in this.viewHooks)this.viewHooks[e].__disconnected();this.setContainerClasses(V)}}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(q)}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(xe(e)){0===je.findComponentNodeList(this.el,e).length?Ae(`no component found matching phx-target of ${e}`):t(this,parseInt(e))}else{let i=Array.from(document.querySelectorAll(e));0===i.length&&Ae(`nothing found matching the phx-target selector "${e}"`),i.forEach((e=>this.liveSocket.owner(e,(i=>t(i,e)))))}}applyDiff(e,t,i){this.log(e,(()=>["",Le(t)]));let{diff:n,reply:s,events:r,title:o}=tt.extract(t);return o&&je.putTitle(o),i({diff:n,reply:s,events:r}),s}onJoin(e){let{rendered:t,container:i}=e;if(i){let[e,t]=i;this.el=je.replaceRootContainer(this.el,e,t)}this.childJoins=0,this.joinPending=!0,this.flash=null,$e.dropLocal(this.liveSocket.localStorage,window.location.pathname,L),this.applyDiff("mount",t,(({diff:t,events:i})=>{this.rendered=new tt(this.id,t);let n=this.renderContainer(null,"join");this.dropPendingRefs();let s=this.formsForRecovery(n);this.joinCount++,s.length>0?s.forEach((([e,t,r],o)=>{this.pushFormRecovery(e,r,(e=>{o===s.length-1&&this.onJoinComplete(e,n,i)}))})):this.onJoinComplete(e,n,i)}))}dropPendingRefs(){je.all(document,`[${O}="${this.id}"][${D}]`,(e=>{e.removeAttribute(D),e.removeAttribute(O)}))}onJoinComplete({live_patch:e},t,i){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i);0===je.findPhxChildrenInFragment(t,this.id).filter((e=>{let t=e.id&&this.el.querySelector(`[id="${e.id}"]`),i=t&&t.getAttribute(re);return i&&e.setAttribute(re,i),this.joinChild(e)})).length?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=je.byId(this.id),this.el.setAttribute(X,this.root.id)}applyJoinPatch(e,t,i){this.attachTrueDocEl();let n=new et(this,this.el,this.id,t,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1),this.joinNewChildren(),je.all(this.el,`[${this.binding(de)}], [data-phx-hook]`,(e=>{let t=this.addHook(e);t&&t.__mounted()})),this.joinPending=!1,this.liveSocket.dispatchEvents(i),this.applyPendingUpdates(),e){let{kind:t,to:i}=e;this.liveSocket.historyPatch(i,t)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),n=i&&je.isIgnored(e,this.binding(ce));if(i&&!e.isEqualNode(t)&&(!n||(s=e.dataset,r=t.dataset,JSON.stringify(s)!==JSON.stringify(r))))return i.__beforeUpdate(),i;var s,r}performPatch(e,t){let i=[],n=!1,s=new Set;return e.after("added",(e=>{this.liveSocket.triggerDOM("onNodeAdded",[e]);let t=this.addHook(e);t&&t.__mounted()})),e.after("phxChildAdded",(e=>{je.isPhxSticky(e)?this.liveSocket.joinRootViews():n=!0})),e.before("updated",((e,t)=>{this.triggerBeforeUpdateHook(e,t)&&s.add(e.id)})),e.after("updated",(e=>{s.has(e.id)&&this.getHook(e).__updated()})),e.after("discarded",(e=>{e.nodeType===Node.ELEMENT_NODE&&i.push(e)})),e.after("transitionsDiscarded",(e=>this.afterElementsRemoved(e,t))),e.perform(),this.afterElementsRemoved(i,t),n}afterElementsRemoved(e,t){let i=[];e.forEach((e=>{je.all(e,`[${R}]`).concat(e).forEach((e=>{let t=this.componentID(e);xe(t)&&-1===i.indexOf(t)&&i.push(t);let n=this.getHook(e);n&&this.destroyHook(n)}))})),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){je.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(K)][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 t=new ot(e,this.liveSocket,this);return this.root.children[this.id][t.id]=t,t.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,0===this.childJoins&&(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",(()=>{je.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach((t=>{this.componentPatch(this.rendered.getComponent(e,t),t)&&(i=!0)}))})):Ie(e)||this.liveSocket.time("full patch complete",(()=>{let t=this.renderContainer(e,"update"),n=new et(this,this.el,this.id,t,null);i=this.performPatch(n,!0)})),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,(()=>{let t=this.el.tagName,i=e?this.rendered.componentCIDs(e).concat(this.pruningCIDs):null;return`<${t}>${this.rendered.toString(i)}`}))}componentPatch(e,t){if(Ie(e))return!1;let i=this.rendered.componentToString(t),n=new et(this,this.el,this.id,i,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[nt.elementID(e)]}addHook(e){if(nt.elementID(e)||!e.getAttribute)return;let t=e.getAttribute("data-phx-hook")||e.getAttribute(this.binding(de));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||Ae(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let n=new nt(this,e,i);return this.viewHooks[nt.elementID(n.el)]=n,n}null!==t&&Ae(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[nt.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,(e=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(e)]):this.liveSocket.requestDOMUpdate((()=>t(e)))}))}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",(e=>{this.liveSocket.requestDOMUpdate((()=>{this.applyDiff("update",e,(({diff:e,events:t})=>this.update(e,t)))}))})),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:n}=e,s=this.expandURL(t);this.liveSocket.historyRedirect(s,i,n)}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",(e=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate((()=>this.onJoin(e)))})).receive("error",(e=>!this.isDestroyed()&&this.onJoinError(e))).receive("timeout",(()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))))}onJoinError(e){return"unauthorized"===e.reason||"stale"===e.reason?(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()&&"hidden"!==document.visibilityState||this.liveSocket.hasPendingLink()&&"leave"!==e)return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(200)}}onError(e){this.onClose(e),this.log("error",(()=>["view crashed",e])),this.liveSocket.isUnloaded()||this.displayError()}displayError(){this.isMain()&&je.dispatchEvent(window,"phx:page-loading-start",{to:this.href,kind:"error"}),this.showLoader(),this.setContainerClasses(V,z)}pushWithReply(e,t,i,n=function(){}){if(!this.isConnected())return;let[s,[r],o]=e?e():[null,[],{}],a=function(){};return(o.page_loading||r&&null!==r.getAttribute(this.binding(J)))&&(a=this.liveSocket.withPageLoading({kind:"element",target:r})),"number"!=typeof i.cid&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},(()=>this.channel.push(t,i,3e4).receive("ok",(e=>{null!==s&&this.undoRefs(s);let t=t=>{e.redirect&&this.onRedirect(e.redirect),e.live_patch&&this.onLivePatch(e.live_patch),e.live_redirect&&this.onLiveRedirect(e.live_redirect),a(),n(e,t)};e.diff?this.liveSocket.requestDOMUpdate((()=>{let i=this.applyDiff("update",e.diff,(({diff:e,events:t})=>{this.update(e,t)}));t(i)})):t(null)}))))}undoRefs(e){je.all(document,`[${O}="${this.id}"][${D}="${e}"]`,(e=>{let t=e.getAttribute(ae);e.removeAttribute(D),e.removeAttribute(O),null!==e.getAttribute(oe)&&(e.readOnly=!1,e.removeAttribute(oe)),null!==t&&(e.disabled="true"===t,e.removeAttribute(ae)),_.forEach((t=>je.removeClass(e,t)));let i=e.getAttribute(le);null!==i&&(e.innerText=i,e.removeAttribute(le));let n=je.private(e,D);if(n){let t=this.triggerBeforeUpdateHook(e,n);et.patchEl(e,n,this.liveSocket.getActiveElement()),t&&t.__updated(),je.deletePrivate(e,D)}}))}putRef(e,t,i={}){let n=this.ref++,s=this.binding(he);return i.loading&&(e=e.concat(je.all(document,i.loading))),e.forEach((e=>{e.classList.add(`phx-${t}-loading`),e.setAttribute(D,n),e.setAttribute(O,this.el.id);let i=e.getAttribute(s);null!==i&&(e.getAttribute(le)||e.setAttribute(le,e.innerText),""!==i&&(e.innerText=i),e.setAttribute("disabled",""))})),[n,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(R);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(xe(t))return t;let n=e.getAttribute(this.binding("target"));return xe(n)?parseInt(n):t&&(null!==n||i.target)?this.closestComponentID(t):null}closestComponentID(e){return xe(e)?e:e?De(e.closest(`[${R}]`),(e=>this.ownsElement(e)&&this.componentID(e))):null}pushHookEvent(e,t,i,n){if(!this.isConnected())return this.log("hook",(()=>["unable to push hook event. LiveView not connected",t,i])),!1;let[s,r,o]=this.putRef([],"hook");return this.pushWithReply((()=>[s,r,o]),"event",{type:"hook",event:t,value:i,cid:this.closestComponentID(e)},((e,t)=>n(t,s))),s}extractMeta(e,t,i){let n=this.binding("value-");for(let i=0;i=0&&!e.checked&&delete t.value),i){t||(t={});for(let e in i)t[e]=i[e]}return t}pushEvent(e,t,i,n,s,r={}){this.pushWithReply((()=>this.putRef([t],e,r)),"event",{type:e,event:n,value:this.extractMeta(t,s,r.value),cid:this.targetComponentID(t,i,r)})}pushFileProgress(e,t,i,n=function(){}){this.liveSocket.withinOwners(e.form,((s,r)=>{s.pushWithReply(null,"progress",{event:e.getAttribute(s.binding("progress")),ref:e.getAttribute($),entry_ref:t,progress:i,cid:s.targetComponentID(e.form,r)},n)}))}pushInput(e,t,i,n,s,r){let o,a=xe(i)?i:this.targetComponentID(e.form,t),h=()=>this.putRef([e,e.form],"change",s),l=rt(e.form,{_target:s._target});je.isUploadInput(e)&&e.files&&e.files.length>0&&Fe.trackFiles(e,Array.from(e.files)),o=Fe.serializeUploads(e);let d={type:"form",event:n,value:l,uploads:o,cid:a};this.pushWithReply(h,"event",d,(i=>{if(je.showError(e,this.liveSocket.binding(Y)),je.isUploadInput(e)&&null!==e.getAttribute("data-phx-auto-upload")){if(Fe.filesAwaitingPreflight(e).length>0){let[n,s]=h();this.uploadFiles(e.form,t,n,a,(t=>{r&&r(i),this.triggerAwaitingSubmit(e.form)}))}}else r&&r(i)}))}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,n,s,r]=t;this.cancelSubmit(e),r()}}getScheduledSubmit(e){return this.formSubmits.find((([t,i,n,s])=>t.isSameNode(e)))}scheduleSubmit(e,t,i,n){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,n])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter((([t,i,n])=>!t.isSameNode(e)||(this.undoRefs(i),!1)))}pushFormSubmit(e,t,i,n,s){let r=e=>!(_e(e,`${this.binding(ce)}=ignore`,e.form)||_e(e,"data-phx-update=ignore",e.form)),o=e=>e.hasAttribute(this.binding(he)),a=e=>"BUTTON"==e.tagName,h=e=>["INPUT","TEXTAREA","SELECT"].includes(e.tagName),l=()=>{let t=Array.from(e.elements),i=t.filter(o),s=t.filter(a).filter(r),l=t.filter(h).filter(r);return s.forEach((e=>{e.setAttribute(ae,e.disabled),e.disabled=!0})),l.forEach((e=>{e.setAttribute(oe,e.readOnly),e.readOnly=!0,e.files&&(e.setAttribute(ae,e.disabled),e.disabled=!0)})),e.setAttribute(this.binding(J),""),this.putRef([e].concat(i).concat(s).concat(l),"submit",n)},d=this.targetComponentID(e,t);if(Fe.hasUploadsInProgress(e)){let[r,o]=l(),a=()=>this.pushFormSubmit(e,t,i,n,s);return this.scheduleSubmit(e,r,n,a)}if(Fe.inputsAwaitingPreflight(e).length>0){let[r,o]=l(),a=()=>[r,o,n];this.uploadFiles(e,t,r,d,(t=>{let n=rt(e,{});this.pushWithReply(a,"event",{type:"form",event:i,value:n,cid:d},s)}))}else{let t=rt(e);this.pushWithReply(l,"event",{type:"form",event:i,value:t,cid:d},s)}}uploadFiles(e,t,i,n,s){let r=this.joinCount,o=Fe.activeFileInputs(e),a=o.length;o.forEach((e=>{let n=new Fe(e,this,(()=>{a--,0===a&&s()}));this.uploaders[e]=n;let o=n.entries().map((e=>e.toPreflightPayload())),h={ref:e.getAttribute($),entries:o,cid:this.targetComponentID(e.form,t)};this.log("upload",(()=>["sending preflight request",h])),this.pushWithReply(null,"allow_upload",h,(e=>{if(this.log("upload",(()=>["got preflight response",e])),e.error){this.undoRefs(i);let[t,n]=e.error;this.log("upload",(()=>[`error for entry ${t}`,n]))}else{let t=e=>{this.channel.onError((()=>{this.joinCount===r&&e()}))};n.initAdapterUpload(e,t,this.liveSocket)}}))}))}dispatchUploads(e,t){let i=je.findUploadInputs(this.el).filter((t=>t.name===e));0===i.length?Ae(`no live file inputs found matching the name "${e}"`):i.length>1?Ae(`duplicate live file inputs found matching the name "${e}"`):je.dispatchEvent(i[0],N,{files:t})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,((n,s)=>{let r=e.elements[0],o=e.getAttribute(this.binding(ue))||e.getAttribute(this.binding("change"));st.exec("change",o,n,r,["push",{_target:r.name,newCid:t,callback:i}])}))}pushLinkPatch(e,t,i){let n=this.liveSocket.setPendingLink(e),s=t?()=>this.putRef([t],"click"):null,r=()=>this.liveSocket.redirect(window.location.href),o=this.pushWithReply(s,"live_patch",{url:e},(t=>{this.liveSocket.requestDOMUpdate((()=>{t.link_redirect?this.liveSocket.replaceMain(e,null,i,n):(this.liveSocket.commitPendingLink(n)&&(this.href=e),this.applyPendingUpdates(),i&&i(n))}))}));o?o.receive("timeout",r):r()}formsForRecovery(e){if(0===this.joinCount)return[];let t=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,je.all(this.el,`form[${t}]`).filter((e=>e.id&&this.ownsElement(e))).filter((e=>e.elements.length>0)).filter((e=>"ignore"!==e.getAttribute(this.binding(ue)))).map((e=>{let n=i.content.querySelector(`form[id="${e.id}"][${t}="${e.getAttribute(t)}"]`);return n?[e,n,this.targetComponentID(n)]:[e,null,null]})).filter((([e,t,i])=>t))}maybePushComponentsDestroyed(e){let t=e.filter((e=>0===je.findComponentNodeList(this.el,e).length));t.length>0&&(this.pruningCIDs.push(...t),this.pushWithReply(null,"cids_will_destroy",{cids:t},(()=>{this.pruningCIDs=this.pruningCIDs.filter((e=>-1!==t.indexOf(e)));let e=t.filter((e=>0===je.findComponentNodeList(this.el,e).length));e.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:e},(e=>{this.rendered.pruneCIDs(e.cids)}))})))}ownsElement(e){return e.getAttribute(K)===this.id||De(e.closest(ne),(e=>e.id))===this.id}submitForm(e,t,i,n={}){je.putPrivate(e,te,!0);let s=this.liveSocket.binding(Y),r=Array.from(e.elements);this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,n,(()=>{r.forEach((e=>je.showError(e,s))),this.liveSocket.restorePreviouslyActiveFocus()}))}binding(e){return this.liveSocket.binding(e)}},at=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){0===this.size()?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let n=setTimeout((()=>{this.transitions.delete(n),i(),0===this.size()&&this.flushPendingOps()}),e);this.transitions.add(n)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){this.pendingOps.forEach((e=>e())),this.pendingOps=[]}};let ht=document.querySelector("html").getAttribute("phx-socket")||"/live",lt=document.querySelector("meta[name='csrf-token']").getAttribute("content"),dt={};const ct={};dt.JsonEditor={mounted(){const e=this.el.getAttribute("data-input-id"),t=this;this.editor=new JSONEditor(this.el,{onChangeText:t=>{const i=document.getElementById(e);try{JSON.parse(t),i.value=t,i.dispatchEvent(new Event("change",{bubbles:!0}))}catch(e){}},onChange:()=>{try{const i=document.getElementById(e);json=t.editor.get(),i.value=JSON.stringify(json),i.dispatchEvent(new Event("change",{bubbles:!0}))}catch(e){}},onModeChange:e=>{t.mode=e},modes:["text","tree"]},JSON.parse(document.getElementById(e).value)),ct[this.el.id]=this.editor}},dt.JsonEditorSource={updated(){try{let e=ct[this.el.getAttribute("data-editor-id")];"tree"===e.getMode()?e.update(JSON.parse(this.el.value)):e.get()!==JSON.parse(this.el.value)&&e.setText(this.el.value)}catch(e){}}},dt.JsonView={updated(){const e=JSON.parse(this.el.getAttribute("data-json"));this.editor=new JSONEditor(this.el,{mode:"preview"},e)},mounted(){const e=JSON.parse(this.el.getAttribute("data-json"));this.editor=new JSONEditor(this.el,{mode:"preview"},e)}};dt.MarkdownEditor={mounted(){const e=this.el.getAttribute("data-target-id"),t=document.getElementById(e);new EasyMDE({element:t,forceSync:!0})}},dt.Actor={mounted(){this.handleEvent("set_actor",(e=>{document.cookie="actor_resource="+e.resource+";path=/",document.cookie="actor_primary_key="+e.primary_key+";path=/",document.cookie="actor_action="+e.action+";path=/",document.cookie="actor_api="+e.api+";path=/"})),this.handleEvent("clear_actor",(()=>{document.cookie="actor_resource=;path=/",document.cookie="actor_primary_key=;path=/",document.cookie="actor_action;path=/",document.cookie="actor_api=;path=/",document.cookie="actor_authorizing=false;path=/",document.cookie="actor_paused=true;path=/"})),this.handleEvent("toggle_authorizing",(e=>{document.cookie="actor_authorizing="+e.authorizing+";path=/"})),this.handleEvent("toggle_actor_paused",(e=>{document.cookie="actor_paused="+e.actor_paused+";path=/"}))}},dt.Tenant={mounted(){this.handleEvent("set_tenant",(e=>{document.cookie="tenant="+e.tenant+";path=/"})),this.handleEvent("clear_tenant",(()=>{document.cookie="tenant=;path=/"}))}},dt.MaintainAttrs={attrs(){return this.el.getAttribute("data-attrs").split(", ")},beforeUpdate(){this.prevAttrs=this.attrs().map((e=>[e,this.el.getAttribute(e)]))},updated(){this.prevAttrs.forEach((([e,t])=>this.el.setAttribute(e,t)))}};let ut=new class{constructor(e,t,i={}){if(this.unloaded=!1,!t||"Object"===t.constructor.name)throw new Error('\n a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:\n\n import {Socket} from "phoenix"\n import {LiveSocket} from "phoenix_live_view"\n let liveSocket = new LiveSocket("/live", Socket, {...})\n ');this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||"phx-",this.opts=i,this.params=Pe(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Le(ye),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=Le(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||1,this.maxReloads=i.maxReloads||10,this.reloadJitterMin=i.reloadJitterMin||1e3,this.reloadJitterMax=i.reloadJitterMax||3e3,this.failsafeJitter=i.failsafeJitter||3e4,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:Pe(),onBeforeElUpdated:Pe()},i.dom||{}),this.transitions=new at,window.addEventListener("pagehide",(e=>{this.unloaded=!0})),this.socket.onOpen((()=>{this.isUnloaded()&&window.location.reload()}))}isProfileEnabled(){return"true"===this.sessionStorage.getItem(fe)}isDebugEnabled(){return"true"===this.sessionStorage.getItem(pe)}enableDebug(){this.sessionStorage.setItem(pe,"true")}enableProfiling(){this.sessionStorage.setItem(fe,"true")}disableDebug(){this.sessionStorage.removeItem(pe)}disableProfiling(){this.sessionStorage.removeItem(fe)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(me,e)}disableLatencySim(){this.sessionStorage.removeItem(me)}getLatencySim(){let e=this.sessionStorage.getItem(me);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,(n=>st.exec(i,t,n,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[n,s]=i();this.viewLogger(e,t,n,s)}else if(this.isDebugEnabled()){let[n,s]=i();((e,t,i,n)=>{e.liveSocket.isDebugEnabled()&&console.log(`${e.id} ${t}: ${i} - `,n)})(e,t,n,s)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,(e=>{let t=this.getLatencySim();t?(console.log(`simulating ${t}ms of latency from server to client`),setTimeout((()=>i(e)),t)):i(e)}))}wrapPush(e,t,i){let n=this.getLatencySim(),s=e.joinCount;if(!n)return t.timeout?i().receive("timeout",(()=>{e.joinCount!==s||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 ${n}ms of latency from client to server`);let r={receives:[],receive(e,t){this.receives.push([e,t])}};return setTimeout((()=>{e.isDestroyed()||r.receives.reduce(((e,[t,i])=>e.receive(t,i)),i())}),n),r}reloadWithJitter(e,t){e.destroy(),this.disconnect();let i=this.reloadJitterMin,n=this.reloadJitterMax,s=Math.floor(Math.random()*(n-i+1))+i,r=$e.updateLocal(this.localStorage,window.location.pathname,L,0,(e=>e+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`])),s=this.failsafeJitter),setTimeout((()=>{this.hasPendingLink()?window.location=this.pendingLink:window.location.reload()}),s)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?Be[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 je.all(document,`${ne}:not([${K}])`,(t=>{if(!this.getRootById(t.id)){let e=this.newRootView(t);e.setHref(this.getHref()),e.join(),t.getAttribute(G)&&(this.main=e)}e=!0})),e}redirect(e,t){this.disconnect(),$e.redirect(e,t)}replaceMain(e,t,i=null,n=this.setPendingLink(e)){let s=this.main.el,r=je.cloneNode(s,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(r,t),this.main.setRedirect(e),this.transitionRemoves(),this.main.join(((e,t)=>{1===e&&this.commitPendingLink(n)&&this.requestDOMUpdate((()=>{je.findPhxSticky(document).forEach((e=>r.appendChild(e))),s.replaceWith(r),i&&i(),t()}))}))}transitionRemoves(e){let t=this.binding("remove");(e=e||je.all(document,`[${t}]`)).forEach((e=>{document.body.contains(e)&&this.execJS(e,e.getAttribute(t),"remove")}))}isPhxView(e){return e.getAttribute&&null!==e.getAttribute(ie)}newRootView(e,t){let i=new ot(e,this,null,t);return this.roots[i.id]=i,i}owner(e,t){let i=De(e.closest(ne),(e=>this.getViewByEl(e)))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,(i=>t(i,e)))}getViewByEl(e){let t=e.getAttribute(X);return De(this.getRootById(t),(t=>t.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(X));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=>{1e3===e.code&&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,n,s,r)=>{let o=n.getAttribute(this.binding("key")),a=e.key&&e.key.toLowerCase();if(o&&o.toLowerCase()!==a)return;let h={key:e.key,...this.eventMeta(t,e,n)};st.exec(t,s,i,n,["push",{data:h}])})),this.bind({blur:"focusout",focus:"focusin"},((e,t,i,n,s,r)=>{if(!r){let r={key:e.key,...this.eventMeta(t,e,n)};st.exec(t,s,i,n,["push",{data:r}])}})),this.bind({blur:"blur",focus:"focus"},((e,t,i,n,s,r,o)=>{if("window"===o){let s=this.eventMeta(t,e,n);st.exec(t,r,i,n,["push",{data:s}])}})),window.addEventListener("dragover",(e=>e.preventDefault())),window.addEventListener("drop",(e=>{e.preventDefault();let t=De(_e(e.target,this.binding(j)),(e=>e.getAttribute(this.binding(j)))),i=t&&document.getElementById(t),n=Array.from(e.dataTransfer.files||[]);i&&!i.disabled&&0!==n.length&&i.files instanceof FileList&&(Fe.trackFiles(i,n),i.dispatchEvent(new Event("input",{bubbles:!0})))})),this.on(N,(e=>{let t=e.target;if(!je.isUploadInput(t))return;let i=Array.from(e.detail.files||[]).filter((e=>e instanceof File||e instanceof Blob));Fe.trackFiles(t,i),t.dispatchEvent(new Event("input",{bubbles:!0}))})))}eventMeta(e,t,i){let n=this.metadataCallbacks[e];return n?n(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.linkRef}commitPendingLink(e){return this.linkRef===e&&(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 n=e[i];this.on(n,(e=>{let n=this.binding(i),s=this.binding(`window-${i}`),r=e.target.getAttribute&&e.target.getAttribute(n);r?this.debounce(e.target,e,(()=>{this.withinOwners(e.target,(n=>{t(e,i,n,e.target,r,null)}))})):je.all(document,`[${s}]`,(n=>{let r=n.getAttribute(s);this.debounce(n,e,(()=>{this.withinOwners(n,(s=>{t(e,i,s,n,r,"window")}))}))}))}))}}bindClicks(){this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let n=this.binding(t);window.addEventListener(e,(e=>{if(!this.isConnected())return;this.clickRef++;let t=this.clickRef,s=null;i?s=e.target.matches(`[${n}]`)?e.target:e.target.querySelector(`[${n}]`):(s=_e(e.target,n),this.dispatchClickAway(e,t));let r=s&&s.getAttribute(n);r&&("#"===s.getAttribute("href")&&e.preventDefault(),this.debounce(s,e,(()=>{this.withinOwners(s,(t=>{st.exec("click",r,t,s,["push",{data:this.eventMeta("click",e,s)}])}))})))}),i)}dispatchClickAway(e,t){let i=this.binding("click-away"),n=this.binding("click");je.all(document,`[${i}]`,(t=>{t.isSameNode(e.target)||t.contains(e.target)||this.withinOwners(e.target,(s=>{let r=t.getAttribute(i);if(st.isVisible(t)){e.target.closest(`[${n}]`)||e.target;st.exec("click",r,s,t,["push",{data:this.eventMeta("click",e,e.target)}])}}))}))}bindNav(){if(!$e.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",(t=>{clearTimeout(e),e=setTimeout((()=>{$e.updateCurrentState((e=>Object.assign(e,{scroll:window.scrollY})))}),100)})),window.addEventListener("popstate",(e=>{if(!this.registerNewLocation(window.location))return;let{type:t,id:i,root:n,scroll:s}=e.state||{},r=window.location.href;this.requestDOMUpdate((()=>{this.main.isConnected()&&"patch"===t&&i===this.main.id?this.main.pushLinkPatch(r,null):this.replaceMain(r,null,(()=>{n&&this.replaceRootHistory(),"number"==typeof s&&setTimeout((()=>{window.scrollTo(0,s)}),0)}))}))}),!1),window.addEventListener("click",(e=>{let t=_e(e.target,I),i=t&&t.getAttribute(I),n=e.metaKey||e.ctrlKey||1===e.button;if(!i||!this.isConnected()||!this.main||n)return;let s=t.href,r=t.getAttribute("data-phx-link-state");e.preventDefault(),this.pendingLink!==s&&this.requestDOMUpdate((()=>{if("patch"===i)this.pushHistoryPatch(s,r,t);else{if("redirect"!==i)throw new Error(`expected data-phx-link to be "patch" or "redirect", got: ${i}`);this.historyRedirect(s,r)}}))}),!1)}dispatchEvent(e,t={}){je.dispatchEvent(window,`phx:${e}`,t)}dispatchEvents(e){e.forEach((([e,t])=>this.dispatchEvent(e,t)))}withPageLoading(e,t){je.dispatchEvent(window,"phx:page-loading-start",e);let i=()=>je.dispatchEvent(window,"phx:page-loading-stop",e);return t?t(i):i}pushHistoryPatch(e,t,i){this.withPageLoading({to:e,kind:"patch"},(n=>{this.main.pushLinkPatch(e,i,(i=>{this.historyPatch(e,t,i),n()}))}))}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&($e.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location))}historyRedirect(e,t,i){let n=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},(s=>{this.replaceMain(e,i,(()=>{$e.pushState(t,{type:"redirect",id:this.main.id,scroll:n},e),this.registerNewLocation(window.location),s()}))}))}replaceRootHistory(){$e.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&&(this.currentLocation=Le(e),!0)}bindForms(){let e=0;this.on("submit",(e=>{let t=e.target.getAttribute(this.binding("submit"));t&&(e.preventDefault(),e.target.disabled=!0,this.withinOwners(e.target,(i=>{st.exec("submit",t,i,e.target,["push",{}])})))}),!1);for(let t of["change","input"])this.on(t,(i=>{let n=i.target,s=n.form&&n.form.getAttribute(this.binding("change"));if(!s)return;if("number"===n.type&&n.validity&&n.validity.badInput)return;let r=e;e++;let{at:o,type:a}=je.private(n,"prev-iteration")||{};o===r-1&&t!==a||(je.putPrivate(n,"prev-iteration",{at:r,type:t}),this.debounce(n,i,(()=>{this.withinOwners(n.form,(e=>{je.putPrivate(n,Q,!0),je.isTextualInput(n)||this.setActiveElement(n),st.exec("change",s,e,n,["push",{_target:i.target.name}])}))})))}),!1)}debounce(e,t,i){let n=this.binding("debounce"),s=this.binding("throttle"),r=this.defaults.debounce.toString(),o=this.defaults.throttle.toString();je.debounce(e,t,n,r,s,o,i)}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,(e=>{this.silenced||t(e)}))}}(ht,class{constructor(t,i={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=i.timeout||1e4,this.transport=i.transport||s.WebSocket||A,this.establishedConnections=0,this.defaultEncoder=x.encode.bind(x),this.defaultDecoder=x.decode.bind(x),this.closeWasClean=!1,this.binaryType=i.binaryType||"arraybuffer",this.connectClock=1,this.transport!==A?(this.encode=i.encode||this.defaultEncoder,this.decode=i.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let r=null;n&&n.addEventListener&&(n.addEventListener("pagehide",(e=>{this.conn&&(this.disconnect(),r=this.connectClock)})),n.addEventListener("pageshow",(e=>{r===this.connectClock&&(r=null,this.connect())}))),this.heartbeatIntervalMs=i.heartbeatIntervalMs||3e4,this.rejoinAfterMs=e=>i.rejoinAfterMs?i.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>i.reconnectAfterMs?i.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=i.logger||null,this.longpollerTimeout=i.longpollerTimeout||2e4,this.params=e(i.params||{}),this.endPoint=`${t}/${k}`,this.vsn=i.vsn||"2.0.0",this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new C((()=>{this.teardown((()=>this.connect()))}),this.reconnectAfterMs)}replaceTransport(e){this.disconnect(),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=S.appendParams(S.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(t){this.connectClock++,t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=e(t)),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=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e))}log(e,t,i){this.logger(e,t,i)}hasLogger(){return null!==this.logger}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){5!==t&&this.conn&&this.conn.bufferedAmount?setTimeout((()=>{this.waitForBufferDone(e,t+1)}),150*t):e()}waitForSocketClosed(e,t=1){5!==t&&this.conn&&this.conn.readyState!==h?setTimeout((()=>{this.waitForSocketClosed(e,t+1)}),150*t):e()}onConnClose(e){let t=e&&e.code;this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),clearTimeout(this.heartbeatTimer),this.closeWasClean||1e3===t||this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach((([,t])=>t(e)))}onConnError(e){this.hasLogger()&&this.log("transport",e);let t=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach((([,n])=>{n(e,t,i)})),(t===this.transport||i>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach((e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(m)}))}connectionState(){switch(this.conn&&this.conn.readyState){case r:return"connecting";case o:return"open";case a:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}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((([t])=>-1===e.indexOf(t)))}channel(t,i={}){let n=new class{constructor(t,i,n){this.state=l,this.topic=t,this.params=e(i||{}),this.socket=n,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new w(this,g,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new C((()=>{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=c,this.rejoinTimer.reset(),this.pushBuffer.forEach((e=>e.send())),this.pushBuffer=[]})),this.joinPush.receive("error",(()=>{this.state=d,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=l,this.socket.remove(this)})),this.onError((e=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=d,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 w(this,b,e({}),this.timeout).send(),this.state=d,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()})),this.on(v,((e,t)=>{this.trigger(this.replyEventName(t),e)}))}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(f,e)}onError(e){return this.on(m,(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&&(void 0===t||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 n=new w(this,e,(function(){return t}),i);return this.canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=p;let i=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(f,"leave")},n=new w(this,b,e({}),t);return n.receive("ok",(()=>i())).receive("timeout",(()=>i())),n.send(),this.canPush()||n.trigger("ok",{}),n}onMessage(e,t,i){return t}isMember(e,t,i,n){return!(this.topic!==e||n&&n!==this.joinRef()&&(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:i,joinRef:n}),1))}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=u,this.joinPush.resend(e))}trigger(e,t,i,n){let s=this.onMessage(e,t,i,n);if(t&&!s)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter((t=>t.event===e));for(let e=0;ethis.conn.send(e))):this.sendBuffer.push((()=>this.encode(e,(e=>this.conn.send(e)))))}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(1e3,e)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach((e=>e())),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,(e=>{let{topic:t,event:i,payload:n,ref:s,join_ref:r}=e;s&&s===this.pendingHeartbeatRef&&(clearTimeout(this.heartbeatTimer),this.pendingHeartbeatRef=null,setTimeout((()=>this.sendHeartbeat()),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${n.status||""} ${t} ${i} ${s&&"("+s+")"||""}`,n);for(let e=0;et.topic===e&&(t.isJoined()||t.isJoining())));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}},{params:{_csrf_token:lt},hooks:dt,dom:{onBeforeElUpdated(e,t){e._x_dataStack&&window.Alpine.clone(e,t)}}});window.addEventListener("phx:page-loading-start",(e=>P().start())),window.addEventListener("phx:page-loading-stop",(e=>P().done())),ut.connect(),ut.enableDebug(),window.liveSocket=ut})()})();