text: var LiveView=(()=>{var Ge=Object.defineProperty;var gt=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var mt=(n,e,t)=>e in n?Ge(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ne=(n,e)=>{for(var t in e||(e={}))Gt.call(e,t)&&mt(n,t,e[t]);if(gt)for(var t of gt(e))zt.call(e,t)&&mt(n,t,e[t]);return n};var Yt=n=>Ge(n,"__esModule",{value:!0});var Qt=(n,e)=>{Yt(n);for(var t in e)Ge(n,t,{get:e[t],enumerable:!0})};var vi={};Qt(vi,{LiveSocket:()=>je});var Te="consecutive-reloads",vt=10,bt=1e3,_t=3e3,Et=3e4,xe=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],C="data-phx-component",Ie="data-phx-link",St="track-static",At="data-phx-link-state",R="data-phx-ref",j="data-phx-ref-src",Re="track-uploads",U="data-phx-upload-ref",se="data-phx-preflighted-refs",Pt="data-phx-done-refs",ze="drop-target",fe="data-phx-active-refs",pe="phx:live-file:updated",ge="data-phx-skip",Ye="data-phx-prune",Qe="page-loading",Ze="phx-connected",Le="phx-loading",et="phx-no-feedback",tt="phx-error",K="data-phx-parent-id",oe="data-phx-main",W="data-phx-root-id",yt="trigger-action",me="feedback-for",De="phx-has-focused",wt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],Oe=["checkbox","radio"],He="phx-has-submitted",L="data-phx-session",B=`[${L}]`,it="data-phx-sticky",Y="data-phx-static",Ne="data-phx-readonly",ve="data-phx-disabled",be="disable-with",_e="data-phx-disable-with-restore",ae="hook",Ct="debounce",kt="throttle",Ee="update",Tt="key",M="phxPrivate",rt="auto-recover",Se="phx:live-socket:debug",Ue="phx:live-socket:profiling",Me="phx:live-socket:latency-sim",xt="progress",It=1,Rt=200,Lt="phx-",Dt=3e4;var le="debounce-trigger",Ae="throttled",nt="debounce-prev-key",Ot={debounce:300,throttle:300},st="d",F="s",x="c",ot="e",at="r",lt="t",Ht="p";var Fe=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 w("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))})}};var w=(n,e)=>console.error&&console.error(n,e),X=n=>{let e=typeof n;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(n)};function Nt(){let n=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)n.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):n.add(e[t].id)}var Ut=(n,e,t,i)=>{n.liveSocket.isDebugEnabled()&&console.log(`${n.id} ${e}: ${t} - `,i)},Xe=n=>typeof n=="function"?n:function(){return n},he=n=>JSON.parse(JSON.stringify(n)),ee=(n,e,t)=>{do{if(n.matches(`[${e}]`))return n;n=n.parentElement||n.parentNode}while(n!==null&&n.nodeType===1&&!(t&&t.isSameNode(n)||n.matches(B)));return null},de=n=>n!==null&&typeof n=="object"&&!(n instanceof Array),Mt=(n,e)=>JSON.stringify(n)===JSON.stringify(e),ht=n=>{for(let e in n)return!1;return!0},D=(n,e)=>n&&e(n),Ft=function(n,e,t,i){n.forEach(r=>{new Fe(r,t.config.chunk_size,i).upload()})};var Xt={canPushState(){return typeof history.pushState!="undefined"},dropLocal(n,e,t){return n.removeItem(this.localKey(e,t))},updateLocal(n,e,t,i,r){let s=this.getLocal(n,e,t),o=this.localKey(e,t),a=s===null?i:r(s);return n.setItem(o,JSON.stringify(a)),a},getLocal(n,e,t){return JSON.parse(n.getItem(this.localKey(e,t)))},updateCurrentState(n){!this.canPushState()||history.replaceState(n(history.state||{}),"",window.location.href)},pushState(n,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let r=history.state||{};r.scroll=e.scroll,history.replaceState(r,"",window.location.href)}delete e.scroll,history[n+"State"](e,"",t||null);let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)}}else this.redirect(t)},setCookie(n,e){document.cookie=`${n}=${e}`},getCookie(n){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${n}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(n,e){e&&Xt.setCookie("__phoenix_flash__",e+"; max-age=60000; path=/"),window.location=n},localKey(n,e){return`${n}-${e}`},getHashTargetEl(n){let e=n.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},V=Xt;var $={byId(n){return document.getElementById(n)||w(`no id found for ${n}`)},removeClass(n,e){n.classList.remove(e),n.classList.length===0&&n.removeAttribute("class")},all(n,e,t){if(!n)return[];let i=Array.from(n.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(n){let e=document.createElement("template");return e.innerHTML=n,e.content.childElementCount},isUploadInput(n){return n.type==="file"&&n.getAttribute(U)!==null},findUploadInputs(n){return this.all(n,`input[type="file"][${U}]`)},findComponentNodeList(n,e){return this.filterWithinSameLiveView(this.all(n,`[${C}="${e}"]`),n)},isPhxDestroyed(n){return!!(n.id&&$.private(n,"destroyed"))},markPhxChildDestroyed(n){this.isPhxChild(n)&&n.setAttribute(L,""),this.putPrivate(n,"destroyed",!0)},findPhxChildrenInFragment(n,e){let t=document.createElement("template");return t.innerHTML=n,this.findPhxChildren(t.content,e)},isIgnored(n,e){return(n.getAttribute(e)||n.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(n,e,t){return n.getAttribute&&t.indexOf(n.getAttribute(e))>=0},findPhxSticky(n){return this.all(n,`[${it}]`)},findPhxChildren(n,e){return this.all(n,`${B}[${K}="${e}"]`)},findParentCIDs(n,e){let t=new Set(e);return e.reduce((i,r)=>{let s=`[${C}="${r}"] [${C}]`;return this.filterWithinSameLiveView(this.all(n,s),n).map(o=>parseInt(o.getAttribute(C))).forEach(o=>i.delete(o)),i},t)},filterWithinSameLiveView(n,e){return e.querySelector(B)?n.filter(t=>this.withinSameLiveView(t,e)):n},withinSameLiveView(n,e){for(;n=n.parentNode;){if(n.isSameNode(e))return!0;if(n.getAttribute(L)!==null)return!1}},private(n,e){return n[M]&&n[M][e]},deletePrivate(n,e){n[M]&&delete n[M][e]},putPrivate(n,e,t){n[M]||(n[M]={}),n[M][e]=t},updatePrivate(n,e,t,i){let r=this.private(n,e);r===void 0?this.putPrivate(n,e,i(t)):this.putPrivate(n,e,i(r))},copyPrivates(n,e){e[M]&&(n[M]=e[M])},putTitle(n){let e=document.querySelector("title"),{prefix:t,suffix:i}=e.dataset;document.title=`${t||""}${n}${i||""}`},debounce(n,e,t,i,r,s,o){let a=n.getAttribute(t),l=n.getAttribute(r);a===""&&(a=i),l===""&&(l=s);let d=a||l;switch(d){case null:return o();case"blur":this.once(n,"debounce-blur")&&n.addEventListener("blur",()=>o());return;default:let f=parseInt(d),p=()=>l?this.deletePrivate(n,Ae):o(),c=this.incCycle(n,le,p);if(isNaN(f))return w(`invalid throttle/debounce value: ${d}`);if(l){let E=!1;if(e.type==="keydown"){let v=this.private(n,nt);this.putPrivate(n,nt,e.key),E=v!==e.key}if(!E&&this.private(n,Ae))return!1;o(),this.putPrivate(n,Ae,!0),setTimeout(()=>this.triggerCycle(n,le),f)}else setTimeout(()=>this.triggerCycle(n,le,c),f);let g=n.form;g&&this.once(g,"bind-debounce")&&g.addEventListener("submit",()=>{Array.from(new FormData(g).entries(),([E])=>{let v=g.querySelector(`[name="${E}"]`);this.incCycle(v,le),this.deletePrivate(v,Ae)})}),this.once(n,"bind-debounce")&&n.addEventListener("blur",()=>this.triggerCycle(n,le))}},triggerCycle(n,e,t){let[i,r]=this.private(n,e);t||(t=i),t===i&&(this.incCycle(n,e),r())},once(n,e){return this.private(n,e)===!0?!1:(this.putPrivate(n,e,!0),!0)},incCycle(n,e,t=function(){}){let[i]=this.private(n,e)||[0,t];return i++,this.putPrivate(n,e,[i,t]),i},discardError(n,e,t){let i=e.getAttribute&&e.getAttribute(t),r=i&&n.querySelector(`[id="${i}"], [name="${i}"]`);!r||this.private(r,De)||this.private(r.form,He)||e.classList.add(et)},showError(n,e){(n.id||n.name)&&this.all(n.form,`[${e}="${n.id}"], [${e}="${n.name}"]`,t=>{this.removeClass(t,et)})},isPhxChild(n){return n.getAttribute&&n.getAttribute(K)},isPhxSticky(n){return n.getAttribute&&n.getAttribute(it)!==null},firstPhxChild(n){return this.isPhxChild(n)?n:this.all(n,`[${K}]`)[0]},dispatchEvent(n,e,t={}){let r={bubbles:t.bubbles===void 0?!0:!!t.bubbles,cancelable:!0,detail:t.detail||{}},s=e==="click"?new MouseEvent("click",r):new CustomEvent(e,r);n.dispatchEvent(s)},cloneNode(n,e){if(typeof e=="undefined")return n.cloneNode(!0);{let t=n.cloneNode(!1);return t.innerHTML=e,t}},mergeAttrs(n,e,t={}){let i=t.exclude||[],r=t.isIgnored,s=e.attributes;for(let a=s.length-1;a>=0;a--){let l=s[a].name;i.indexOf(l)<0&&n.setAttribute(l,e.getAttribute(l))}let o=n.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;r?l.startsWith("data-")&&!e.hasAttribute(l)&&n.removeAttribute(l):e.hasAttribute(l)||n.removeAttribute(l)}},mergeFocusedInput(n,e){n instanceof HTMLSelectElement||$.mergeAttrs(n,e,{exclude:["value"]}),e.readOnly?n.setAttribute("readonly",!0):n.removeAttribute("readonly")},hasSelectionRange(n){return n.setSelectionRange&&(n.type==="text"||n.type==="textarea")},restoreFocus(n,e,t){if(!$.isTextualInput(n))return;let i=n.matches(":focus");n.readOnly&&n.blur(),i||n.focus(),this.hasSelectionRange(n)&&n.setSelectionRange(e,t)},isFormInput(n){return/^(?:input|select|textarea)$/i.test(n.tagName)&&n.type!=="button"},syncAttrsToProps(n){n instanceof HTMLInputElement&&Oe.indexOf(n.type.toLocaleLowerCase())>=0&&(n.checked=n.getAttribute("checked")!==null)},isTextualInput(n){return wt.indexOf(n.type)>=0},isNowTriggerFormExternal(n,e){return n.getAttribute&&n.getAttribute(e)!==null},syncPendingRef(n,e,t){let i=n.getAttribute(R);if(i===null)return!0;let r=n.getAttribute(j);return $.isFormInput(n)||n.getAttribute(t)!==null?($.isUploadInput(n)&&$.mergeAttrs(n,e,{isIgnored:!0}),$.putPrivate(n,R,e),!1):(xe.forEach(s=>{n.classList.contains(s)&&e.classList.add(s)}),e.setAttribute(R,i),e.setAttribute(j,r),!0)},cleanChildNodes(n,e){if($.isPhxUpdate(n,e,["append","prepend"])){let t=[];n.childNodes.forEach(i=>{i.id||(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()===""||w(`only HTML element tags with an id are allowed inside containers with phx-update.
  
  removing illegal node: "${(i.outerHTML||i.nodeValue).trim()}"
  
  `),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(n,e,t){let i=new Set(["id",L,Y,oe,W]);if(n.tagName.toLowerCase()===e.toLowerCase())return Array.from(n.attributes).filter(r=>!i.has(r.name.toLowerCase())).forEach(r=>n.removeAttribute(r.name)),Object.keys(t).filter(r=>!i.has(r.toLowerCase())).forEach(r=>n.setAttribute(r,t[r])),n;{let r=document.createElement(e);return Object.keys(t).forEach(s=>r.setAttribute(s,t[s])),i.forEach(s=>r.setAttribute(s,n.getAttribute(s))),r.innerHTML=n.innerHTML,n.replaceWith(r),r}},getSticky(n,e,t){let i=($.private(n,"sticky")||[]).find(([r])=>e===r);if(i){let[r,s,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(n,e){this.updatePrivate(n,"sticky",[],t=>t.filter(([i,r])=>i!==e))},putSticky(n,e,t){let i=t(n);this.updatePrivate(n,"sticky",[],r=>{let s=r.findIndex(([o])=>e===o);return s>=0?r[s]=[e,t,i]:r.push([e,t,i]),r})},applyStickyOperations(n){let e=$.private(n,"sticky");!e||e.forEach(([t,i,r])=>this.putSticky(n,t,i))}},h=$;var ue=class{static isActive(e,t){let i=t._phxRef===void 0,s=e.getAttribute(fe).split(",").indexOf(y.genFileRef(t))>=0;return t.size>0&&(i||s)}static isPreflighted(e,t){return e.getAttribute(se).split(",").indexOf(y.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=y.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(pe,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,()=>{y.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}),y.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(pe,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(fe).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]||w(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:Ft}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||w(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Zt=0,y=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(Zt++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let r=this.activeFiles(e).find(s=>this.genFileRef(s)===t);i(URL.createObjectURL(r))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(se)!==i.getAttribute(Pt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(r=>{let s={path:e.name},o=e.getAttribute(U);i[o]=i[o]||[],s.ref=this.genFileRef(r),s.name=r.name||s.ref,s.type=r.type,s.size=r.size,i[o].push(s)}),i}static clearFiles(e){e.value=null,e.removeAttribute(U),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(r=>!this.activeFiles(e).find(s=>Object.is(s,r)));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=>ue.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=>!ue.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(y.filesAwaitingPreflight(e)||[]).map(r=>new ue(e,r,t)),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(s=>(s.zipPostFlight(e),s.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),s));let r=this._entries.reduce((s,o)=>{let{name:a,callback:l}=o.uploader(i.uploaders);return s[a]=s[a]||{callback:l,entries:[]},s[a].entries.push(o),s},{});for(let s in r){let{callback:o,entries:a}=r[s];o(a,t,e,i)}}};var ei={LiveFileUpload:{activeRefs(){return this.el.getAttribute(fe)},preflightedRefs(){return this.el.getAttribute(se)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let n=this.preflightedRefs();this.preflightedWas!==n&&(this.preflightedWas=n,n===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(pe))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(U)),y.getEntryDataURL(this.inputEl,this.ref,n=>{this.url=n,this.el.src=n})},destroyed(){URL.revokeObjectURL(this.url)}}},$t=ei;var $e=class{constructor(e,t,i){let r=new Set,s=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(r.add(a.id),s.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...s].filter(a=>!r.has(a))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?D(document.getElementById(t.previousElementId),i=>{D(document.getElementById(t.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",r)})}):D(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{D(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var Bt=11;function ti(n,e){var t=e.attributes,i,r,s,o,a;if(!(e.nodeType===Bt||n.nodeType===Bt)){for(var l=t.length-1;l>=0;l--)i=t[l],r=i.name,s=i.namespaceURI,o=i.value,s?(r=i.localName||r,a=n.getAttributeNS(s,r),a!==o&&(i.prefix==="xmlns"&&(r=i.name),n.setAttributeNS(s,r,o))):(a=n.getAttribute(r),a!==o&&n.setAttribute(r,o));for(var d=n.attributes,f=d.length-1;f>=0;f--)i=d[f],r=i.name,s=i.namespaceURI,s?(r=i.localName||r,e.hasAttributeNS(s,r)||n.removeAttributeNS(s,r)):e.hasAttribute(r)||n.removeAttribute(r)}}var Be,ii="http://www.w3.org/1999/xhtml",I=typeof document=="undefined"?void 0:document,ri=!!I&&"content"in I.createElement("template"),ni=!!I&&I.createRange&&"createContextualFragment"in I.createRange();function si(n){var e=I.createElement("template");return e.innerHTML=n,e.content.childNodes[0]}function oi(n){Be||(Be=I.createRange(),Be.selectNode(I.body));var e=Be.createContextualFragment(n);return e.childNodes[0]}function ai(n){var e=I.createElement("body");return e.innerHTML=n,e.childNodes[0]}function li(n){return n=n.trim(),ri?si(n):ni?oi(n):ai(n)}function Ve(n,e){var t=n.nodeName,i=e.nodeName,r,s;return t===i?!0:(r=t.charCodeAt(0),s=i.charCodeAt(0),r<=90&&s>=97?t===i.toUpperCase():s<=90&&r>=97?i===t.toUpperCase():!1)}function hi(n,e){return!e||e===ii?I.createElement(n):I.createElementNS(e,n)}function di(n,e){for(var t=n.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function dt(n,e,t){n[t]!==e[t]&&(n[t]=e[t],n[t]?n.setAttribute(t,""):n.removeAttribute(t))}var Vt={OPTION:function(n,e){var t=n.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(n.hasAttribute("selected")&&!e.selected&&(n.setAttribute("selected","selected"),n.removeAttribute("selected")),t.selectedIndex=-1)}dt(n,e,"selected")},INPUT:function(n,e){dt(n,e,"checked"),dt(n,e,"disabled"),n.value!==e.value&&(n.value=e.value),e.hasAttribute("value")||n.removeAttribute("value")},TEXTAREA:function(n,e){var t=e.value;n.value!==t&&(n.value=t);var i=n.firstChild;if(i){var r=i.nodeValue;if(r==t||!t&&r==n.placeholder)return;i.nodeValue=t}},SELECT:function(n,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,r=n.firstChild,s,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")s=r,r=s.firstChild;else{if(o==="OPTION"){if(r.hasAttribute("selected")){t=i;break}i++}r=r.nextSibling,!r&&s&&(r=s.nextSibling,s=null)}n.selectedIndex=t}}},Pe=1,ui=11,Jt=3,jt=8;function te(){}function ci(n){if(n)return n.getAttribute&&n.getAttribute("id")||n.id}function fi(n){return function(t,i,r){if(r||(r={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var s=i;i=I.createElement("html"),i.innerHTML=s}else i=li(i);var o=r.getNodeKey||ci,a=r.onBeforeNodeAdded||te,l=r.onNodeAdded||te,d=r.onBeforeElUpdated||te,f=r.onElUpdated||te,p=r.onBeforeNodeDiscarded||te,c=r.onNodeDiscarded||te,g=r.onBeforeElChildrenUpdated||te,E=r.childrenOnly===!0,v=Object.create(null),A=[];function T(_){A.push(_)}function J(_,b){if(_.nodeType===Pe)for(var m=_.firstChild;m;){var S=void 0;b&&(S=o(m))?T(S):(c(m),m.firstChild&&J(m,b)),m=m.nextSibling}}function H(_,b,m){p(_)!==!1&&(b&&b.removeChild(_),c(_),J(_,m))}function u(_){if(_.nodeType===Pe||_.nodeType===ui)for(var b=_.firstChild;b;){var m=o(b);m&&(v[m]=b),u(b),b=b.nextSibling}}u(t);function P(_){l(_);for(var b=_.firstChild;b;){var m=b.nextSibling,S=o(b);if(S){var N=v[S];N&&Ve(b,N)?(b.parentNode.replaceChild(N,b),Z(N,b)):P(b)}else P(b);b=m}}function ct(_,b,m){for(;b;){var S=b.nextSibling;(m=o(b))?T(m):H(b,_,!0),b=S}}function Z(_,b,m){var S=o(b);S&&delete v[S],!(!m&&(d(_,b)===!1||(n(_,b),f(_),g(_,b)===!1)))&&(_.nodeName!=="TEXTAREA"?Wt(_,b):Vt.TEXTAREA(_,b))}function Wt(_,b){var m=b.firstChild,S=_.firstChild,N,q,re,Ce,G;e:for(;m;){for(Ce=m.nextSibling,N=o(m);S;){if(re=S.nextSibling,m.isSameNode&&m.isSameNode(S)){m=Ce,S=re;continue e}q=o(S);var ke=S.nodeType,z=void 0;if(ke===m.nodeType&&(ke===Pe?(N?N!==q&&((G=v[N])?re===G?z=!1:(_.insertBefore(G,S),q?T(q):H(S,_,!0),S=G):z=!1):q&&(z=!1),z=z!==!1&&Ve(S,m),z&&Z(S,m)):(ke===Jt||ke==jt)&&(z=!0,S.nodeValue!==m.nodeValue&&(S.nodeValue=m.nodeValue))),z){m=Ce,S=re;continue e}q?T(q):H(S,_,!0),S=re}if(N&&(G=v[N])&&Ve(G,m))_.appendChild(G),Z(G,m);else{var qe=a(m);qe!==!1&&(qe&&(m=qe),m.actualize&&(m=m.actualize(_.ownerDocument||I)),_.appendChild(m),P(m))}m=Ce,S=re}ct(_,S,q);var pt=Vt[_.nodeName];pt&&pt(_,b)}var k=t,we=k.nodeType,ft=i.nodeType;if(!E){if(we===Pe)ft===Pe?Ve(t,i)||(c(t),k=di(t,hi(i.nodeName,i.namespaceURI))):k=i;else if(we===Jt||we===jt){if(ft===we)return k.nodeValue!==i.nodeValue&&(k.nodeValue=i.nodeValue),k;k=i}}if(k===i)c(t);else{if(i.isSameNode&&i.isSameNode(k))return;if(Z(k,i,E),A)for(var Ke=0,qt=A.length;Ke<qt;Ke++){var We=v[A[Ke]];We&&H(We,We.parentNode,!1)}}return!E&&k!==t&&t.parentNode&&(k.actualize&&(k=k.actualize(t.ownerDocument||I)),t.parentNode.replaceChild(k,t)),k}}var pi=fi(ti),ut=pi;var ie=class{static patchEl(e,t,i){ut(e,t,{childrenOnly:!1,onBeforeElUpdated:(r,s)=>{if(i&&i.isSameNode(r)&&h.isFormInput(r))return h.mergeFocusedInput(r,s),!1}})}constructor(e,t,i,r,s){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=r,this.targetCID=s,this.cidPatch=X(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(Ye,"")})}perform(){let{view:e,liveSocket:t,container:i,html:r}=this,s=this.isCIDPatch()?this.targetCIDContainer(r):i;if(this.isCIDPatch()&&!s)return;let o=t.getActiveElement(),{selectionStart:a,selectionEnd:l}=o&&h.hasSelectionRange(o)?o:{},d=t.binding(Ee),f=t.binding(me),p=t.binding(be),c=t.binding(yt),g=t.binding("remove"),E=[],v=[],A=[],T=[],J=null,H=t.time("premorph container prep",()=>this.buildDiffHTML(i,r,d,s));return this.trackBefore("added",i),this.trackBefore("updated",i,i),t.time("morphdom",()=>{ut(s,H,{childrenOnly:s.getAttribute(C)===null,getNodeKey:u=>h.isPhxDestroyed(u)?null:u.id,onBeforeNodeAdded:u=>(this.trackBefore("added",u),u),onNodeAdded:u=>{u instanceof HTMLImageElement&&u.srcset?u.srcset=u.srcset:u instanceof HTMLVideoElement&&u.autoplay&&u.play(),h.isNowTriggerFormExternal(u,c)&&(J=u),h.discardError(s,u,f),(h.isPhxChild(u)&&e.ownsElement(u)||h.isPhxSticky(u)&&e.ownsElement(u.parentNode))&&this.trackAfter("phxChildAdded",u),E.push(u)},onNodeDiscarded:u=>{(h.isPhxChild(u)||h.isPhxSticky(u))&&t.destroyViewByEl(u),this.trackAfter("discarded",u)},onBeforeNodeDiscarded:u=>u.getAttribute&&u.getAttribute(Ye)!==null?!0:u.parentNode!==null&&h.isPhxUpdate(u.parentNode,d,["append","prepend"])&&u.id?!1:u.getAttribute&&u.getAttribute(g)?(T.push(u),!1):!this.skipCIDSibling(u),onElUpdated:u=>{h.isNowTriggerFormExternal(u,c)&&(J=u),v.push(u)},onBeforeElUpdated:(u,P)=>{if(h.cleanChildNodes(P,d),this.skipCIDSibling(P)||h.isPhxSticky(u))return!1;if(h.isIgnored(u,d))return this.trackBefore("updated",u,P),h.mergeAttrs(u,P,{isIgnored:!0}),v.push(u),h.applyStickyOperations(u),!1;if(u.type==="number"&&u.validity&&u.validity.badInput)return!1;if(!h.syncPendingRef(u,P,p))return h.isUploadInput(u)&&(this.trackBefore("updated",u,P),v.push(u)),h.applyStickyOperations(u),!1;if(h.isPhxChild(P)){let Z=u.getAttribute(L);return h.mergeAttrs(u,P,{exclude:[Y]}),Z!==""&&u.setAttribute(L,Z),u.setAttribute(W,this.rootID),h.applyStickyOperations(u),!1}return h.copyPrivates(P,u),h.discardError(s,P,f),o&&u.isSameNode(o)&&h.isFormInput(u)?(this.trackBefore("updated",u,P),h.mergeFocusedInput(u,P),h.syncAttrsToProps(u),v.push(u),h.applyStickyOperations(u),!1):(h.isPhxUpdate(P,d,["append","prepend"])&&A.push(new $e(u,P,P.getAttribute(d))),h.syncAttrsToProps(P),h.applyStickyOperations(P),this.trackBefore("updated",u,P),!0)}})}),t.isDebugEnabled()&&Nt(),A.length>0&&t.time("post-morph append/prepend restoration",()=>{A.forEach(u=>u.perform())}),t.silenceEvents(()=>h.restoreFocus(o,a,l)),h.dispatchEvent(document,"phx:update"),E.forEach(u=>this.trackAfter("added",u)),v.forEach(u=>this.trackAfter("updated",u)),T.length>0&&(t.transitionRemoves(T),t.requestDOMUpdate(()=>{T.forEach(u=>{let P=h.firstPhxChild(u);P&&t.destroyViewByEl(P),u.remove()}),this.trackAfter("transitionsDiscarded",T)})),J&&(t.disconnect(),J.submit()),!0}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.getAttribute(ge)!==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,r){let s=this.isCIDPatch(),o=s&&r.getAttribute(C)===this.targetCID.toString();if(!s||o)return t;{let a=null,l=document.createElement("template");a=h.cloneNode(r);let[d,...f]=h.findComponentNodeList(a,this.targetCID);return l.innerHTML=t,f.forEach(p=>p.remove()),Array.from(a.childNodes).forEach(p=>{p.id&&p.nodeType===Node.ELEMENT_NODE&&p.getAttribute(C)!==this.targetCID.toString()&&(p.setAttribute(ge,""),p.innerHTML="")}),Array.from(l.content.childNodes).forEach(p=>a.insertBefore(p,d)),d.remove(),a.outerHTML}}};var ye=class{static extract(e){let{[at]:t,[ot]:i,[lt]:r}=e;return delete e[at],delete e[ot],delete e[lt],{diff:e,title:r,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 r={buffer:"",components:t,onlyCids:i};return this.toOutputBuffer(e,null,r),r.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 r=this.rendered[x];for(let s in t)t[s]=this.cachedFindComponent(s,t[s],r,t,i);for(let s in t)r[s]=t[s];e[x]=t}}cachedFindComponent(e,t,i,r,s){if(s[e])return s[e];{let o,a,l=t[F];if(X(l)){let d;l>0?d=this.cachedFindComponent(l,r[l],i,r,s):d=i[-l],a=d[F],o=this.cloneMerge(d,t),o[F]=a}else o=t[F]!==void 0?t:this.cloneMerge(i[e]||{},t);return s[e]=o,o}}mutableMerge(e,t){return t[F]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let r=t[i],s=e[i];de(r)&&r[F]===void 0&&de(s)?this.doMutableMerge(s,r):e[i]=r}}cloneMerge(e,t){let i=ne(ne({},e),t);for(let r in i){let s=t[r],o=e[r];de(s)&&s[F]===void 0&&de(o)&&(i[r]=this.cloneMerge(o,s))}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[F]}templateStatic(e,t){return typeof e=="number"?t[e]:e}toOutputBuffer(e,t,i){if(e[st])return this.comprehensionToBuffer(e,t,i);let{[F]:r}=e;r=this.templateStatic(r,t),i.buffer+=r[0];for(let s=1;s<r.length;s++)this.dynamicToBuffer(e[s-1],t,i),i.buffer+=r[s]}comprehensionToBuffer(e,t,i){let{[st]:r,[F]:s}=e;s=this.templateStatic(s,t);let o=t||e[Ht];for(let a=0;a<r.length;a++){let l=r[a];i.buffer+=s[0];for(let d=1;d<s.length;d++)this.dynamicToBuffer(l[d-1],o,i),i.buffer+=s[d]}}dynamicToBuffer(e,t,i){typeof e=="number"?i.buffer+=this.recursiveCIDToString(i.components,e,i.onlyCids):de(e)?this.toOutputBuffer(e,t,i):i.buffer+=e}recursiveCIDToString(e,t,i){let r=e[t]||w(`no component for CID ${t}`,e),s=document.createElement("template");s.innerHTML=this.recursiveToString(r,e,i);let o=s.content,a=i&&!i.has(t),[l,d]=Array.from(o.childNodes).reduce(([f,p],c,g)=>c.nodeType===Node.ELEMENT_NODE?c.getAttribute(C)?[f,!0]:(c.setAttribute(C,t),c.id||(c.id=`${this.parentViewId()}-${t}-${g}`),a&&(c.setAttribute(ge,""),c.innerHTML=""),[!0,p]):c.nodeValue.trim()!==""?(w(`only HTML element tags are allowed at the root of components.
  
  got: "${c.nodeValue.trim()}"
  
  within:
  `,s.innerHTML.trim()),c.replaceWith(this.createSpan(c.nodeValue,t)),[!0,p]):(c.remove(),[f,p]),[!1,!1]);return!l&&!d?(w(`expected at least one HTML element tag inside a component, but the component is empty:
  `,s.innerHTML.trim()),this.createSpan("",t).outerHTML):(!l&&d&&w("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)}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(C,t),i}};var gi=1,Q=class{static makeID(){return gi++}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 r in this.__callbacks)this[r]=this.__callbacks[r]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,t={},i=function(){}){return this.__view.pushHookEvent(null,e,t,i)}pushEventTo(e,t,i={},r=function(){}){return this.__view.withinTargets(e,(s,o)=>s.pushHookEvent(o,t,i,r))}handleEvent(e,t){let i=(r,s)=>s?e:t(r.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,r=>r.dispatchUploads(t,i))}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var mi={exec(n,e,t,i,r){let[s,o]=r||[null,{}];(e.charAt(0)==="["?JSON.parse(e):[[s,o]]).forEach(([l,d])=>{l===s&&o.data&&(d.data=Object.assign(d.data||{},o.data)),this.filterToEls(i,d).forEach(f=>{this[`exec_${l}`](n,e,t,i,f,d)})})},isVisible(n){return!!(n.offsetWidth||n.offsetHeight||n.getClientRects().length>0)},exec_dispatch(n,e,t,i,r,{to:s,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=i,h.dispatchEvent(r,o,{detail:a,bubbles:l})},exec_push(n,e,t,i,r,s){if(!t.isConnected())return;let{event:o,data:a,target:l,page_loading:d,loading:f,value:p,dispatcher:c}=s,g={loading:f,value:p,target:l,page_loading:!!d},E=n==="change"&&c?c:i,v=l||E.getAttribute(t.binding("target"))||E;t.withinTargets(v,(A,T)=>{if(n==="change"){let{newCid:J,_target:H,callback:u}=s;H=H||(i instanceof HTMLInputElement?i.name:void 0),H&&(g._target=H),A.pushInput(i,T,J,o||e,g,u)}else n==="submit"?A.submitForm(i,T,o||e,g):A.pushEvent(n,i,T,o||e,a,g)})},exec_add_class(n,e,t,i,r,{names:s,transition:o,time:a}){this.addOrRemoveClasses(r,s,[],o,a,t)},exec_remove_class(n,e,t,i,r,{names:s,transition:o,time:a}){this.addOrRemoveClasses(r,[],s,o,a,t)},exec_transition(n,e,t,i,r,{time:s,transition:o}){let[a,l,d]=o,f=()=>this.addOrRemoveClasses(r,a.concat(l),[]),p=()=>this.addOrRemoveClasses(r,d,a.concat(l));t.transition(s,f,p)},exec_toggle(n,e,t,i,r,{display:s,ins:o,outs:a,time:l}){this.toggle(n,t,r,s,o,a,l)},exec_show(n,e,t,i,r,{display:s,transition:o,time:a}){this.show(n,t,r,s,o,a)},exec_hide(n,e,t,i,r,{display:s,transition:o,time:a}){this.hide(n,t,r,s,o,a)},exec_set_attr(n,e,t,i,r,{attr:[s,o]}){this.setOrRemoveAttrs(r,[[s,o]],[])},exec_remove_attr(n,e,t,i,r,{attr:s}){this.setOrRemoveAttrs(r,[],[s])},show(n,e,t,i,r,s){this.isVisible(t)||this.toggle(n,e,t,i,r,null,s)},hide(n,e,t,i,r,s){this.isVisible(t)&&this.toggle(n,e,t,i,null,r,s)},toggle(n,e,t,i,r,s,o){let[a,l,d]=r||[[],[],[]],[f,p,c]=s||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(t)){let g=()=>{this.addOrRemoveClasses(t,p,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,c,p))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,g,()=>{this.addOrRemoveClasses(t,[],f.concat(c)),h.putSticky(t,"toggle",E=>E.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(n==="remove")return;let g=()=>{this.addOrRemoveClasses(t,l,f.concat(p).concat(c)),h.putSticky(t,"toggle",E=>E.style.display=i||"block"),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,d,l))})};t.dispatchEvent(new Event("phx:show-start")),e.transition(o,g,()=>{this.addOrRemoveClasses(t,[],a.concat(d)),t.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",g=>g.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start")),h.putSticky(t,"toggle",g=>g.style.display=i||"block"),t.dispatchEvent(new Event("phx:show-end"))})},addOrRemoveClasses(n,e,t,i,r,s){let[o,a,l]=i||[[],[],[]];if(o.length>0){let d=()=>this.addOrRemoveClasses(n,a.concat(o),[]),f=()=>this.addOrRemoveClasses(n,e.concat(l),t.concat(o).concat(a));return s.transition(r,d,f)}window.requestAnimationFrame(()=>{let[d,f]=h.getSticky(n,"classes",[[],[]]),p=e.filter(v=>d.indexOf(v)<0&&!n.classList.contains(v)),c=t.filter(v=>f.indexOf(v)<0&&n.classList.contains(v)),g=d.filter(v=>t.indexOf(v)<0).concat(p),E=f.filter(v=>e.indexOf(v)<0).concat(c);h.putSticky(n,"classes",v=>(v.classList.remove(...E),v.classList.add(...g),[g,E]))})},setOrRemoveAttrs(n,e,t){let[i,r]=h.getSticky(n,"attrs",[[],[]]),s=e.map(([l,d])=>l).concat(t),o=i.filter(([l,d])=>!s.includes(l)).concat(e),a=r.filter(l=>!s.includes(l)).concat(t);h.putSticky(n,"attrs",l=>(a.forEach(d=>l.removeAttribute(d)),o.forEach(([d,f])=>l.setAttribute(d,f)),[o,a]))},hasAllClasses(n,e){return e.every(t=>n.classList.contains(t))},isToggledOut(n,e){return!this.isVisible(n)||this.hasAllClasses(n,e)},filterToEls(n,{to:e}){return e?h.all(document,e):[n]}},O=mi;var Je=(n,e,t=[])=>{let i=new FormData(n),r=[];i.forEach((o,a,l)=>{o instanceof File&&r.push(a)}),r.forEach(o=>i.delete(o));let s=new URLSearchParams;for(let[o,a]of i.entries())(t.length===0||t.indexOf(o)>=0)&&s.append(o,a);for(let o in e)s.append(o,e[o]);return s.toString()},ce=class{constructor(e,t,i,r){this.liveSocket=t,this.flash=r,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(s){s&&s()},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(oe)!==null}connectParams(){let e=this.liveSocket.params(this.el),t=h.all(document,`[${this.binding(St)}]`).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(L)}getStatic(){let e=this.el.getAttribute(Y);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(Ze,Le,tt),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(Le)}}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(Ze)}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(X(e))h.findComponentNodeList(this.el,e).length===0?w(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let i=Array.from(document.querySelectorAll(e));i.length===0&&w(`nothing found matching the phx-target selector "${e}"`),i.forEach(r=>this.liveSocket.owner(r,s=>t(s,r)))}}applyDiff(e,t,i){this.log(e,()=>["",he(t)]);let{diff:r,reply:s,events:o,title:a}=ye.extract(t);return a&&h.putTitle(a),i({diff:r,reply:s,events:o}),s}onJoin(e){let{rendered:t,container:i}=e;if(i){let[r,s]=i;this.el=h.replaceRootContainer(this.el,r,s)}this.childJoins=0,this.joinPending=!0,this.flash=null,V.dropLocal(this.liveSocket.localStorage,window.location.pathname,Te),this.applyDiff("mount",t,({diff:r,events:s})=>{this.rendered=new ye(this.id,r);let o=this.renderContainer(null,"join");this.dropPendingRefs();let a=this.formsForRecovery(o);this.joinCount++,a.length>0?a.forEach(([l,d,f],p)=>{this.pushFormRecovery(l,f,c=>{p===a.length-1&&this.onJoinComplete(c,o,s)})}):this.onJoinComplete(e,o,s)})}dropPendingRefs(){h.all(document,`[${j}="${this.id}"][${R}]`,e=>{e.removeAttribute(R),e.removeAttribute(j)})}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(s=>{let o=s.id&&this.el.querySelector(`[id="${s.id}"]`),a=o&&o.getAttribute(Y);return a&&s.setAttribute(Y,a),this.joinChild(s)}).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(W,this.root.id)}applyJoinPatch(e,t,i){this.attachTrueDocEl();let r=new ie(this,this.el,this.id,t,null);if(r.markPrunableContentForRemoval(),this.performPatch(r,!1),this.joinNewChildren(),h.all(this.el,`[${this.binding(ae)}], [data-phx-${ae}]`,s=>{let o=this.addHook(s);o&&o.__mounted()}),this.joinPending=!1,this.liveSocket.dispatchEvents(i),this.applyPendingUpdates(),e){let{kind:s,to:o}=e;this.liveSocket.historyPatch(o,s)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),r=i&&h.isIgnored(e,this.binding(Ee));if(i&&!e.isEqualNode(t)&&!(r&&Mt(e.dataset,t.dataset)))return i.__beforeUpdate(),i}performPatch(e,t){let i=[],r=!1,s=new Set;return e.after("added",o=>{this.liveSocket.triggerDOM("onNodeAdded",[o]);let a=this.addHook(o);a&&a.__mounted()}),e.after("phxChildAdded",o=>{h.isPhxSticky(o)?this.liveSocket.joinRootViews():r=!0}),e.before("updated",(o,a)=>{this.triggerBeforeUpdateHook(o,a)&&s.add(o.id)}),e.after("updated",o=>{s.has(o.id)&&this.getHook(o).__updated()}),e.after("discarded",o=>{o.nodeType===Node.ELEMENT_NODE&&i.push(o)}),e.after("transitionsDiscarded",o=>this.afterElementsRemoved(o,t)),e.perform(),this.afterElementsRemoved(i,t),r}afterElementsRemoved(e,t){let i=[];e.forEach(r=>{let s=h.all(r,`[${C}]`),o=h.all(r,`[${this.binding(ae)}]`);s.concat(r).forEach(a=>{let l=this.componentID(a);X(l)&&i.indexOf(l)===-1&&i.push(l)}),o.concat(r).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),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(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 i=new ce(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(s=>{this.componentPatch(this.rendered.getComponent(e,s),s)&&(i=!0)})}):ht(e)||this.liveSocket.time("full patch complete",()=>{let r=this.renderContainer(e,"update"),s=new ie(this,this.el,this.id,r,null);i=this.performPatch(s,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,r=e?this.rendered.componentCIDs(e).concat(this.pruningCIDs):null,s=this.rendered.toString(r);return`<${i}>${s}</${i}>`})}componentPatch(e,t){if(ht(e))return!1;let i=this.rendered.componentToString(t),r=new ie(this,this.el,this.id,i,t);return this.performPatch(r,!0)}getHook(e){return this.viewHooks[Q.elementID(e)]}addHook(e){if(Q.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${ae}`)||e.getAttribute(this.binding(ae));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||w(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let r=new Q(this,e,i);return this.viewHooks[Q.elementID(r.el)]=r,r}else t!==null&&w(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[Q.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:r}=e,s=this.expandURL(t);this.liveSocket.historyRedirect(s,i,r)}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(Rt)}}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",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(Le,tt)}pushWithReply(e,t,i,r=function(){}){if(!this.isConnected())return;let[s,[o],a]=e?e():[null,[],{}],l=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(Qe))!==null)&&(l=this.liveSocket.withPageLoading({kind:"element",target:o})),typeof i.cid!="number"&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(t,i,Dt).receive("ok",d=>{s!==null&&this.undoRefs(s);let f=p=>{d.redirect&&this.onRedirect(d.redirect),d.live_patch&&this.onLivePatch(d.live_patch),d.live_redirect&&this.onLiveRedirect(d.live_redirect),l(),r(d,p)};d.diff?this.liveSocket.requestDOMUpdate(()=>{let p=this.applyDiff("update",d.diff,({diff:c,events:g})=>{this.update(c,g)});f(p)}):f(null)}))}undoRefs(e){h.all(document,`[${j}="${this.id}"][${R}="${e}"]`,t=>{let i=t.getAttribute(ve);t.removeAttribute(R),t.removeAttribute(j),t.getAttribute(Ne)!==null&&(t.readOnly=!1,t.removeAttribute(Ne)),i!==null&&(t.disabled=i==="true",t.removeAttribute(ve)),xe.forEach(o=>h.removeClass(t,o));let r=t.getAttribute(_e);r!==null&&(t.innerText=r,t.removeAttribute(_e));let s=h.private(t,R);if(s){let o=this.triggerBeforeUpdateHook(t,s);ie.patchEl(t,s,this.liveSocket.getActiveElement()),o&&o.__updated(),h.deletePrivate(t,R)}})}putRef(e,t,i={}){let r=this.ref++,s=this.binding(be);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(o=>{o.classList.add(`phx-${t}-loading`),o.setAttribute(R,r),o.setAttribute(j,this.el.id);let a=o.getAttribute(s);a!==null&&(o.getAttribute(_e)||o.setAttribute(_e,o.innerText),a!==""&&(o.innerText=a),o.setAttribute("disabled",""))}),[r,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(C);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(X(t))return t;let r=e.getAttribute(this.binding("target"));return X(r)?parseInt(r):t&&(r!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return X(e)?e:e?D(e.closest(`[${C}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,r){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",t,i]),!1;let[s,o,a]=this.putRef([],"hook");return this.pushWithReply(()=>[s,o,a],"event",{type:"hook",event:t,value:i,cid:this.closestComponentID(e)},(l,d)=>r(d,s)),s}extractMeta(e,t,i){let r=this.binding("value-");for(let s=0;s<e.attributes.length;s++){t||(t={});let o=e.attributes[s].name;o.startsWith(r)&&(t[o.replace(r,"")]=e.getAttribute(o))}if(e.value!==void 0&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&Oe.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let s in i)t[s]=i[s]}return t}pushEvent(e,t,i,r,s,o={}){this.pushWithReply(()=>this.putRef([t],e,o),"event",{type:e,event:r,value:this.extractMeta(t,s,o.value),cid:this.targetComponentID(t,i,o)})}pushFileProgress(e,t,i,r=function(){}){this.liveSocket.withinOwners(e.form,(s,o)=>{s.pushWithReply(null,"progress",{event:e.getAttribute(s.binding(xt)),ref:e.getAttribute(U),entry_ref:t,progress:i,cid:s.targetComponentID(e.form,o)},r)})}pushInput(e,t,i,r,s,o){let a,l=X(i)?i:this.targetComponentID(e.form,t),d=()=>this.putRef([e,e.form],"change",s),f;e.getAttribute(this.binding("change"))?f=Je(e.form,{_target:s._target},[e.name]):f=Je(e.form,{_target:s._target}),h.isUploadInput(e)&&e.files&&e.files.length>0&&y.trackFiles(e,Array.from(e.files)),a=y.serializeUploads(e);let p={type:"form",event:r,value:f,uploads:a,cid:l};this.pushWithReply(d,"event",p,c=>{if(h.showError(e,this.liveSocket.binding(me)),h.isUploadInput(e)&&e.getAttribute("data-phx-auto-upload")!==null){if(y.filesAwaitingPreflight(e).length>0){let[g,E]=d();this.uploadFiles(e.form,t,g,l,v=>{o&&o(c),this.triggerAwaitingSubmit(e.form)})}}else o&&o(c)})}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,r,s,o]=t;this.cancelSubmit(e),o()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,r,s])=>t.isSameNode(e))}scheduleSubmit(e,t,i,r){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,r])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([t,i,r])=>t.isSameNode(e)?(this.undoRefs(i),!1):!0)}pushFormSubmit(e,t,i,r,s){let o=c=>!(ee(c,`${this.binding(Ee)}=ignore`,c.form)||ee(c,"data-phx-update=ignore",c.form)),a=c=>c.hasAttribute(this.binding(be)),l=c=>c.tagName=="BUTTON",d=c=>["INPUT","TEXTAREA","SELECT"].includes(c.tagName),f=()=>{let c=Array.from(e.elements),g=c.filter(a),E=c.filter(l).filter(o),v=c.filter(d).filter(o);return E.forEach(A=>{A.setAttribute(ve,A.disabled),A.disabled=!0}),v.forEach(A=>{A.setAttribute(Ne,A.readOnly),A.readOnly=!0,A.files&&(A.setAttribute(ve,A.disabled),A.disabled=!0)}),e.setAttribute(this.binding(Qe),""),this.putRef([e].concat(g).concat(E).concat(v),"submit",r)},p=this.targetComponentID(e,t);if(y.hasUploadsInProgress(e)){let[c,g]=f(),E=()=>this.pushFormSubmit(e,t,i,r,s);return this.scheduleSubmit(e,c,r,E)}else if(y.inputsAwaitingPreflight(e).length>0){let[c,g]=f(),E=()=>[c,g,r];this.uploadFiles(e,t,c,p,v=>{let A=Je(e,{});this.pushWithReply(E,"event",{type:"form",event:i,value:A,cid:p},s)})}else{let c=Je(e,{});this.pushWithReply(f,"event",{type:"form",event:i,value:c,cid:p},s)}}uploadFiles(e,t,i,r,s){let o=this.joinCount,a=y.activeFileInputs(e),l=a.length;a.forEach(d=>{let f=new y(d,this,()=>{l--,l===0&&s()});this.uploaders[d]=f;let p=f.entries().map(g=>g.toPreflightPayload()),c={ref:d.getAttribute(U),entries:p,cid:this.targetComponentID(d.form,t)};this.log("upload",()=>["sending preflight request",c]),this.pushWithReply(null,"allow_upload",c,g=>{if(this.log("upload",()=>["got preflight response",g]),g.error){this.undoRefs(i);let[E,v]=g.error;this.log("upload",()=>[`error for entry ${E}`,v])}else{let E=v=>{this.channel.onError(()=>{this.joinCount===o&&v()})};f.initAdapterUpload(g,E,this.liveSocket)}})})}dispatchUploads(e,t){let i=h.findUploadInputs(this.el).filter(r=>r.name===e);i.length===0?w(`no live file inputs found matching the name "${e}"`):i.length>1?w(`duplicate live file inputs found matching the name "${e}"`):h.dispatchEvent(i[0],Re,{detail:{files:t}})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(r,s)=>{let o=e.elements[0],a=e.getAttribute(this.binding(rt))||e.getAttribute(this.binding("change"));O.exec("change",a,r,o,["push",{_target:o.name,newCid:t,callback:i}])})}pushLinkPatch(e,t,i){let r=this.liveSocket.setPendingLink(e),s=t?()=>this.putRef([t],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=this.pushWithReply(s,"live_patch",{url:e},l=>{this.liveSocket.requestDOMUpdate(()=>{l.link_redirect?this.liveSocket.replaceMain(e,null,i,r):(this.liveSocket.commitPendingLink(r)&&(this.href=e),this.applyPendingUpdates(),i&&i(r))})});a?a.receive("timeout",o):o()}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(r=>r.id&&this.ownsElement(r)).filter(r=>r.elements.length>0).filter(r=>r.getAttribute(this.binding(rt))!=="ignore").map(r=>{let s=i.content.querySelector(`form[id="${r.id}"][${t}="${r.getAttribute(t)}"]`);return s?[r,s,this.targetComponentID(s)]:[r,null,null]}).filter(([r,s,o])=>s)}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(r=>t.indexOf(r)!==-1);let i=t.filter(r=>h.findComponentNodeList(this.el,r).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i},r=>{this.rendered.pruneCIDs(r.cids)})}))}ownsElement(e){return e.getAttribute(K)===this.id||D(e.closest(B),t=>t.id)===this.id}submitForm(e,t,i,r={}){h.putPrivate(e,He,!0);let s=this.liveSocket.binding(me),o=Array.from(e.elements);this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,r,()=>{o.forEach(a=>h.showError(a,s)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var je=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||Lt,this.opts=i,this.params=Xe(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(he(Ot),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=he(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||It,this.maxReloads=i.maxReloads||vt,this.reloadJitterMin=i.reloadJitterMin||bt,this.reloadJitterMax=i.reloadJitterMax||_t,this.failsafeJitter=i.failsafeJitter||Et,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:Xe(),onBeforeElUpdated:Xe()},i.dom||{}),this.transitions=new Kt,window.addEventListener("pagehide",r=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(Ue)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Se)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Se)==="false"}enableDebug(){this.sessionStorage.setItem(Se,"true")}enableProfiling(){this.sessionStorage.setItem(Ue,"true")}disableDebug(){this.sessionStorage.setItem(Se,"false")}disableProfiling(){this.sessionStorage.removeItem(Ue)}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(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();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,r=>O.exec(i,t,r,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[r,s]=i();this.viewLogger(e,t,r,s)}else if(this.isDebugEnabled()){let[r,s]=i();Ut(e,t,r,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,r=>{let s=this.getLatencySim();s?(console.log(`simulating ${s}ms of latency from server to client`),setTimeout(()=>i(r),s)):i(r)})}wrapPush(e,t,i){let r=this.getLatencySim(),s=e.joinCount;if(!r)return this.isConnected()&&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 ${r}ms of latency from client to server`);let o={receives:[],receive(a,l){this.receives.push([a,l])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[l,d])=>a.receive(l,d),i())},r),o}reloadWithJitter(e,t){e.destroy(),this.disconnect();let i=this.reloadJitterMin,r=this.reloadJitterMax,s=Math.floor(Math.random()*(r-i+1))+i,o=V.updateLocal(this.localStorage,window.location.pathname,Te,0,a=>a+1);t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>this.maxReloads&&(this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),s=this.failsafeJitter),setTimeout(()=>{this.hasPendingLink()?window.location=this.pendingLink:window.location.reload()},s)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?$t[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,`${B}:not([${K}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.getAttribute(oe)&&(this.main=i)}e=!0}),e}redirect(e,t){this.disconnect(),V.redirect(e,t)}replaceMain(e,t,i=null,r=this.setPendingLink(e)){this.outgoingMainEl=this.outgoingMainEl||this.main.el;let s=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(s,t),this.main.setRedirect(e),this.transitionRemoves(),this.main.join((o,a)=>{o===1&&this.commitPendingLink(r)&&this.requestDOMUpdate(()=>{h.findPhxSticky(document).forEach(l=>s.appendChild(l)),this.outgoingMainEl.replaceWith(s),this.outgoingMainEl=null,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(L)!==null}newRootView(e,t){let i=new ce(e,this,null,t);return this.roots[i.id]=i,i}owner(e,t){let i=D(e.closest(B),r=>this.getViewByEl(r))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(W);return D(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(W));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&&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,r,s,o)=>{let a=r.getAttribute(this.binding(Tt)),l=e.key&&e.key.toLowerCase();if(a&&a.toLowerCase()!==l)return;let d=ne({key:e.key},this.eventMeta(t,e,r));O.exec(t,s,i,r,["push",{data:d}])}),this.bind({blur:"focusout",focus:"focusin"},(e,t,i,r,s,o)=>{if(!o){let a=ne({key:e.key},this.eventMeta(t,e,r));O.exec(t,s,i,r,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(e,t,i,r,s,o,a)=>{if(a==="window"){let l=this.eventMeta(t,e,r);O.exec(t,o,i,r,["push",{data:l}])}}),window.addEventListener("dragover",e=>e.preventDefault()),window.addEventListener("drop",e=>{e.preventDefault();let t=D(ee(e.target,this.binding(ze)),s=>s.getAttribute(this.binding(ze))),i=t&&document.getElementById(t),r=Array.from(e.dataTransfer.files||[]);!i||i.disabled||r.length===0||!(i.files instanceof FileList)||(y.trackFiles(i,r),i.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(Re,e=>{let t=e.target;if(!h.isUploadInput(t))return;let i=Array.from(e.detail.files||[]).filter(r=>r instanceof File||r instanceof Blob);y.trackFiles(t,i),t.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let r=this.metadataCallbacks[e];return r?r(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 r=e[i];this.on(r,s=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=s.target.getAttribute&&s.target.getAttribute(o);l?this.debounce(s.target,s,()=>{this.withinOwners(s.target,d=>{t(s,i,d,s.target,l,null)})}):h.all(document,`[${a}]`,d=>{let f=d.getAttribute(a);this.debounce(d,s,()=>{this.withinOwners(d,p=>{t(s,i,p,d,f,"window")})})})})}}bindClicks(){window.addEventListener("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let r=this.binding(t);window.addEventListener(e,s=>{let o=null;if(i)o=s.target.matches(`[${r}]`)?s.target:s.target.querySelector(`[${r}]`);else{let l=this.clickStartedAtTarget||s.target;o=ee(l,r),this.dispatchClickAway(s,l),this.clickStartedAtTarget=null}let a=o&&o.getAttribute(r);!a||(o.getAttribute("href")==="#"&&s.preventDefault(),this.debounce(o,s,()=>{this.withinOwners(o,l=>{O.exec("click",a,l,o,["push",{data:this.eventMeta("click",s,o)}])})}))},i)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,r=>{r.isSameNode(t)||r.contains(t)||this.withinOwners(e.target,s=>{let o=r.getAttribute(i);O.isVisible(r)&&O.exec("click",o,s,r,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!V.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{V.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,id:r,root:s,scroll:o}=t.state||{},a=window.location.href;this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&r===this.main.id?this.main.pushLinkPatch(a,null):this.replaceMain(a,null,()=>{s&&this.replaceRootHistory(),typeof o=="number"&&setTimeout(()=>{window.scrollTo(0,o)},0)})})},!1),window.addEventListener("click",t=>{let i=ee(t.target,Ie),r=i&&i.getAttribute(Ie),s=t.metaKey||t.ctrlKey||t.button===1;if(!r||!this.isConnected()||!this.main||s)return;let o=i.href,a=i.getAttribute(At);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==o&&this.requestDOMUpdate(()=>{if(r==="patch")this.pushHistoryPatch(o,a,i);else if(r==="redirect")this.historyRedirect(o,a);else throw new Error(`expected ${Ie} to be "patch" or "redirect", got: ${r}`)})},!1)}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i){this.withPageLoading({to:e,kind:"patch"},r=>{this.main.pushLinkPatch(e,i,s=>{this.historyPatch(e,t,s),r()})})}historyPatch(e,t,i=this.setPendingLink(e)){!this.commitPendingLink(i)||(V.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location))}historyRedirect(e,t,i){let r=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},s=>{this.replaceMain(e,i,()=>{V.pushState(t,{type:"redirect",id:this.main.id,scroll:r},e),this.registerNewLocation(window.location),s()})})}replaceRootHistory(){V.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=he(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,r=>{O.exec("submit",i,r,t.target,["push",{}])}))},!1);for(let t of["change","input"])this.on(t,i=>{let r=this.binding("change"),s=i.target,o=s.getAttribute(r),a=s.form&&s.form.getAttribute(r),l=o||a;if(!l||s.type==="number"&&s.validity&&s.validity.badInput)return;let d=o?s:s.form,f=e;e++;let{at:p,type:c}=h.private(s,"prev-iteration")||{};p===f-1&&t!==c||(h.putPrivate(s,"prev-iteration",{at:f,type:t}),this.debounce(s,i,()=>{this.withinOwners(d,g=>{h.putPrivate(s,De,!0),h.isTextualInput(s)||this.setActiveElement(s),O.exec("change",l,g,s,["push",{_target:i.target.name,dispatcher:d}])})}))},!1)}debounce(e,t,i){let r=this.binding(Ct),s=this.binding(kt),o=this.defaults.debounce.toString(),a=this.defaults.throttle.toString();h.debounce(e,t,r,o,s,a,i)}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,i=>{this.silenced||t(i)})}},Kt=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 r=setTimeout(()=>{this.transitions.delete(r),i(),this.size()===0&&this.flushPendingOps()},e);this.transitions.add(r)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){this.pendingOps.forEach(e=>e()),this.pendingOps=[]}};return vi;})();
  