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