Current section

Files

Jump to
phoenix_live_view priv static phoenix_live_view.min.js
Raw

priv/static/phoenix_live_view.min.js

var LiveView=(()=>{var qe=Object.defineProperty;var gt=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var mt=(s,e,t)=>e in s?qe(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,se=(s,e)=>{for(var t in e||(e={}))Gt.call(e,t)&&mt(s,t,e[t]);if(gt)for(var t of gt(e))zt.call(e,t)&&mt(s,t,e[t]);return s};var Yt=s=>qe(s,"__esModule",{value:!0});var Qt=(s,e)=>{Yt(s);for(var t in e)qe(s,t,{get:e[t],enumerable:!0})};var vi={};Qt(vi,{LiveSocket:()=>Je});var ke="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",Te="data-phx-link",St="track-static",At="data-phx-link-state",R="data-phx-ref",J="data-phx-ref-src",Ie="track-uploads",N="data-phx-upload-ref",ne="data-phx-preflighted-refs",Pt="data-phx-done-refs",Ge="drop-target",ce="data-phx-active-refs",fe="phx:live-file:updated",pe="data-phx-skip",ze="data-phx-prune",Ye="page-loading",Qe="phx-connected",Re="phx-loading",Ze="phx-no-feedback",et="phx-error",j="data-phx-parent-id",oe="data-phx-main",K="data-phx-root-id",yt="trigger-action",ge="feedback-for",Le="phx-has-focused",wt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],De=["checkbox","radio"],Oe="phx-has-submitted",L="data-phx-session",B=`[${L}]`,tt="data-phx-sticky",Y="data-phx-static",He="data-phx-readonly",me="data-phx-disabled",ve="disable-with",be="data-phx-disable-with-restore",_e="hook",Ct="debounce",kt="throttle",Ee="update",xt="key",U="phxPrivate",it="auto-recover",Ne="phx:live-socket:debug",Ue="phx:live-socket:profiling",Fe="phx:live-socket:latency-sim",Tt="progress",It=1,Rt=200,Lt="phx-",Dt=3e4;var ae="debounce-trigger",Se="throttled",rt="debounce-prev-key",Ot={debounce:300,throttle:300},st="d",F="s",x="c",nt="e",ot="r",at="t",Ht="p";var Me=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=(s,e)=>console.error&&console.error(s,e),M=s=>{let e=typeof s;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(s)};function Nt(){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 Ut=(s,e,t,i)=>{s.liveSocket.isDebugEnabled()&&console.log(`${s.id} ${e}: ${t} - `,i)},Xe=s=>typeof s=="function"?s:function(){return s},le=s=>JSON.parse(JSON.stringify(s)),ee=(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(B)));return null},he=s=>s!==null&&typeof s=="object"&&!(s instanceof Array),Ft=(s,e)=>JSON.stringify(s)===JSON.stringify(e),lt=s=>{for(let e in s)return!1;return!0},D=(s,e)=>s&&e(s),Mt=function(s,e,t,i){s.forEach(r=>{new Me(r,t.config.chunk_size,i).upload()})};var Xt={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),a=n===null?i:r(n);return s.setItem(o,JSON.stringify(a)),a},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&&Xt.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}"]`)}},V=Xt;var X={byId(s){return document.getElementById(s)||w(`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(N)!==null},findUploadInputs(s){return this.all(s,`input[type="file"][${N}]`)},findComponentNodeList(s,e){return this.filterWithinSameLiveView(this.all(s,`[${C}="${e}"]`),s)},isPhxDestroyed(s){return!!(s.id&&X.private(s,"destroyed"))},markPhxChildDestroyed(s){this.isPhxChild(s)&&s.setAttribute(L,""),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},findPhxSticky(s){return this.all(s,`[${tt}]`)},findPhxChildren(s,e){return this.all(s,`${B}[${j}="${e}"]`)},findParentCIDs(s,e){let t=new Set(e);return e.reduce((i,r)=>{let n=`[${C}="${r}"] [${C}]`;return this.filterWithinSameLiveView(this.all(s,n),s).map(o=>parseInt(o.getAttribute(C))).forEach(o=>i.delete(o)),i},t)},filterWithinSameLiveView(s,e){return e.querySelector(B)?s.filter(t=>this.withinSameLiveView(t,e)):s},withinSameLiveView(s,e){for(;s=s.parentNode;){if(s.isSameNode(e))return!0;if(s.getAttribute(L)!==null)return!1}},private(s,e){return s[U]&&s[U][e]},deletePrivate(s,e){s[U]&&delete s[U][e]},putPrivate(s,e,t){s[U]||(s[U]={}),s[U][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[U]&&(s[U]=e[U])},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 a=s.getAttribute(t),d=s.getAttribute(r);a===""&&(a=i),d===""&&(d=n);let h=a||d;switch(h){case null:return o();case"blur":this.once(s,"debounce-blur")&&s.addEventListener("blur",()=>o());return;default:let f=parseInt(h),p=()=>d?this.deletePrivate(s,Se):o(),c=this.incCycle(s,ae,p);if(isNaN(f))return w(`invalid throttle/debounce value: ${h}`);if(d){let E=!1;if(e.type==="keydown"){let g=this.private(s,rt);this.putPrivate(s,rt,e.key),E=g!==e.key}if(!E&&this.private(s,Se))return!1;o(),this.putPrivate(s,Se,!0),setTimeout(()=>this.triggerCycle(s,ae),f)}else setTimeout(()=>this.triggerCycle(s,ae,c),f);let m=s.form;m&&this.once(m,"bind-debounce")&&m.addEventListener("submit",()=>{Array.from(new FormData(m).entries(),([E])=>{let g=m.querySelector(`[name="${E}"]`);this.incCycle(g,ae),this.deletePrivate(g,Se)})}),this.once(s,"bind-debounce")&&s.addEventListener("blur",()=>this.triggerCycle(s,ae))}},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,Oe)||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(j)},isPhxSticky(s){return s.getAttribute&&s.getAttribute(tt)!==null},firstPhxChild(s){return this.isPhxChild(s)?s:this.all(s,`[${j}]`)[0]},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 a=n.length-1;a>=0;a--){let d=n[a].name;i.indexOf(d)<0&&s.setAttribute(d,e.getAttribute(d))}let o=s.attributes;for(let a=o.length-1;a>=0;a--){let d=o[a].name;r?d.startsWith("data-")&&!e.hasAttribute(d)&&s.removeAttribute(d):e.hasAttribute(d)||s.removeAttribute(d)}},mergeFocusedInput(s,e){s instanceof HTMLSelectElement||X.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(!X.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 wt.indexOf(s.type)>=0},isNowTriggerFormExternal(s,e){return s.getAttribute&&s.getAttribute(e)!==null},syncPendingRef(s,e,t){let i=s.getAttribute(R);if(i===null)return!0;let r=s.getAttribute(J);return X.isFormInput(s)||s.getAttribute(t)!==null?(X.isUploadInput(s)&&X.mergeAttrs(s,e,{isIgnored:!0}),X.putPrivate(s,R,e),!1):(xe.forEach(n=>{s.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(R,i),e.setAttribute(J,r),!0)},cleanChildNodes(s,e){if(X.isPhxUpdate(s,e,["append","prepend"])){let t=[];s.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(s,e,t){let i=new Set(["id",L,Y,oe,K]);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=(X.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=X.private(s,"sticky");!e||e.forEach(([t,i,r])=>this.putSticky(s,t,i))}},l=X;var de=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(ce).split(",").indexOf(y.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(ne).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(fe,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(fe,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(ce).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:Mt}}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(n=>this.genFileRef(n)===t);i(URL.createObjectURL(r))}static hasUploadsInProgress(e){let t=0;return l.findUploadInputs(e).forEach(i=>{i.getAttribute(ne)!==i.getAttribute(Pt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(r=>{let n={path:e.name},o=e.getAttribute(N);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(N),l.putPrivate(e,"files",[])}static untrackFile(e,t){l.putPrivate(e,"files",l.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)));l.putPrivate(e,"files",this.activeFiles(e).concat(i)),e.value=null}else l.putPrivate(e,"files",t)}static activeFileInputs(e){let t=l.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(l.private(e,"files")||[]).filter(t=>de.isActive(e,t))}static inputsAwaitingPreflight(e){let t=l.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!de.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(y.filesAwaitingPreflight(e)||[]).map(r=>new de(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:a,callback:d}=o.uploader(i.uploaders);return n[a]=n[a]||{callback:d,entries:[]},n[a].entries.push(o),n},{});for(let n in r){let{callback:o,entries:a}=r[n];o(a,t,e,i)}}};var ei={LiveFileUpload:{activeRefs(){return this.el.getAttribute(ce)},preflightedRefs(){return this.el.getAttribute(ne)},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(fe))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(N)),y.getEntryDataURL(this.inputEl,this.ref,s=>{this.url=s,this.el.src=s})},destroyed(){URL.revokeObjectURL(this.url)}}},$t=ei;var $e=class{constructor(e,t,i){let r=new Set,n=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(r.add(a.id),n.has(a.id))){let d=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:d})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!r.has(a))}perform(){let e=l.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(s,e){var t=e.attributes,i,r,n,o,a;if(!(e.nodeType===Bt||s.nodeType===Bt)){for(var d=t.length-1;d>=0;d--)i=t[d],r=i.name,n=i.namespaceURI,o=i.value,n?(r=i.localName||r,a=s.getAttributeNS(n,r),a!==o&&(i.prefix==="xmlns"&&(r=i.name),s.setAttributeNS(n,r,o))):(a=s.getAttribute(r),a!==o&&s.setAttribute(r,o));for(var h=s.attributes,f=h.length-1;f>=0;f--)i=h[f],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 Be,ii="http://www.w3.org/1999/xhtml",T=typeof document=="undefined"?void 0:document,ri=!!T&&"content"in T.createElement("template"),si=!!T&&T.createRange&&"createContextualFragment"in T.createRange();function ni(s){var e=T.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function oi(s){Be||(Be=T.createRange(),Be.selectNode(T.body));var e=Be.createContextualFragment(s);return e.childNodes[0]}function ai(s){var e=T.createElement("body");return e.innerHTML=s,e.childNodes[0]}function li(s){return s=s.trim(),ri?ni(s):si?oi(s):ai(s)}function Ve(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 hi(s,e){return!e||e===ii?T.createElement(s):T.createElementNS(e,s)}function di(s,e){for(var t=s.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function ht(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var Vt={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)}ht(s,e,"selected")},INPUT:function(s,e){ht(s,e,"checked"),ht(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}}},Ae=1,ui=11,Jt=3,jt=8;function te(){}function ci(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function fi(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=T.createElement("html"),i.innerHTML=n}else i=li(i);var o=r.getNodeKey||ci,a=r.onBeforeNodeAdded||te,d=r.onNodeAdded||te,h=r.onBeforeElUpdated||te,f=r.onElUpdated||te,p=r.onBeforeNodeDiscarded||te,c=r.onNodeDiscarded||te,m=r.onBeforeElChildrenUpdated||te,E=r.childrenOnly===!0,g=Object.create(null),A=[];function I(_){A.push(_)}function $(_,b){if(_.nodeType===Ae)for(var v=_.firstChild;v;){var S=void 0;b&&(S=o(v))?I(S):(c(v),v.firstChild&&$(v,b)),v=v.nextSibling}}function W(_,b,v){p(_)!==!1&&(b&&b.removeChild(_),c(_),$(_,v))}function u(_){if(_.nodeType===Ae||_.nodeType===ui)for(var b=_.firstChild;b;){var v=o(b);v&&(g[v]=b),u(b),b=b.nextSibling}}u(t);function P(_){d(_);for(var b=_.firstChild;b;){var v=b.nextSibling,S=o(b);if(S){var H=g[S];H&&Ve(b,H)?(b.parentNode.replaceChild(H,b),Z(H,b)):P(b)}else P(b);b=v}}function ct(_,b,v){for(;b;){var S=b.nextSibling;(v=o(b))?I(v):W(b,_,!0),b=S}}function Z(_,b,v){var S=o(b);S&&delete g[S],!(!v&&(h(_,b)===!1||(s(_,b),f(_),m(_,b)===!1)))&&(_.nodeName!=="TEXTAREA"?Wt(_,b):Vt.TEXTAREA(_,b))}function Wt(_,b){var v=b.firstChild,S=_.firstChild,H,q,re,we,G;e:for(;v;){for(we=v.nextSibling,H=o(v);S;){if(re=S.nextSibling,v.isSameNode&&v.isSameNode(S)){v=we,S=re;continue e}q=o(S);var Ce=S.nodeType,z=void 0;if(Ce===v.nodeType&&(Ce===Ae?(H?H!==q&&((G=g[H])?re===G?z=!1:(_.insertBefore(G,S),q?I(q):W(S,_,!0),S=G):z=!1):q&&(z=!1),z=z!==!1&&Ve(S,v),z&&Z(S,v)):(Ce===Jt||Ce==jt)&&(z=!0,S.nodeValue!==v.nodeValue&&(S.nodeValue=v.nodeValue))),z){v=we,S=re;continue e}q?I(q):W(S,_,!0),S=re}if(H&&(G=g[H])&&Ve(G,v))_.appendChild(G),Z(G,v);else{var We=a(v);We!==!1&&(We&&(v=We),v.actualize&&(v=v.actualize(_.ownerDocument||T)),_.appendChild(v),P(v))}v=we,S=re}ct(_,S,q);var pt=Vt[_.nodeName];pt&&pt(_,b)}var k=t,ye=k.nodeType,ft=i.nodeType;if(!E){if(ye===Ae)ft===Ae?Ve(t,i)||(c(t),k=di(t,hi(i.nodeName,i.namespaceURI))):k=i;else if(ye===Jt||ye===jt){if(ft===ye)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 je=0,qt=A.length;je<qt;je++){var Ke=g[A[je]];Ke&&W(Ke,Ke.parentNode,!1)}}return!E&&k!==t&&t.parentNode&&(k.actualize&&(k=k.actualize(t.ownerDocument||T)),t.parentNode.replaceChild(k,t)),k}}var pi=fi(ti),dt=pi;var ie=class{static patchEl(e,t,i){dt(e,t,{childrenOnly:!1,onBeforeElUpdated:(r,n)=>{if(i&&i.isSameNode(r)&&l.isFormInput(r))return l.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=M(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(){l.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:a,selectionEnd:d}=o&&l.hasSelectionRange(o)?o:{},h=t.binding(Ee),f=t.binding(ge),p=t.binding(ve),c=t.binding(yt),m=t.binding("remove"),E=[],g=[],A=[],I=[],$=null,W=t.time("premorph container prep",()=>this.buildDiffHTML(i,r,h,n));return this.trackBefore("added",i),this.trackBefore("updated",i,i),t.time("morphdom",()=>{dt(n,W,{childrenOnly:n.getAttribute(C)===null,getNodeKey:u=>l.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(),l.isNowTriggerFormExternal(u,c)&&($=u),l.discardError(n,u,f),(l.isPhxChild(u)&&e.ownsElement(u)||l.isPhxSticky(u)&&e.ownsElement(u.parentNode))&&this.trackAfter("phxChildAdded",u),E.push(u)},onNodeDiscarded:u=>{(l.isPhxChild(u)||l.isPhxSticky(u))&&t.destroyViewByEl(u),this.trackAfter("discarded",u)},onBeforeNodeDiscarded:u=>u.getAttribute&&u.getAttribute(ze)!==null?!0:u.parentNode!==null&&l.isPhxUpdate(u.parentNode,h,["append","prepend"])&&u.id?!1:u.getAttribute&&u.getAttribute(m)?(I.push(u),!1):!this.skipCIDSibling(u),onElUpdated:u=>{l.isNowTriggerFormExternal(u,c)&&($=u),g.push(u)},onBeforeElUpdated:(u,P)=>{if(l.cleanChildNodes(P,h),this.skipCIDSibling(P)||l.isPhxSticky(u))return!1;if(l.isIgnored(u,h))return this.trackBefore("updated",u,P),l.mergeAttrs(u,P,{isIgnored:!0}),g.push(u),l.applyStickyOperations(u),!1;if(u.type==="number"&&u.validity&&u.validity.badInput)return!1;if(!l.syncPendingRef(u,P,p))return l.isUploadInput(u)&&(this.trackBefore("updated",u,P),g.push(u)),l.applyStickyOperations(u),!1;if(l.isPhxChild(P)){let Z=u.getAttribute(L);return l.mergeAttrs(u,P,{exclude:[Y]}),Z!==""&&u.setAttribute(L,Z),u.setAttribute(K,this.rootID),l.applyStickyOperations(u),!1}return l.copyPrivates(P,u),l.discardError(n,P,f),o&&u.isSameNode(o)&&l.isFormInput(u)?(this.trackBefore("updated",u,P),l.mergeFocusedInput(u,P),l.syncAttrsToProps(u),g.push(u),l.applyStickyOperations(u),!1):(l.isPhxUpdate(P,h,["append","prepend"])&&A.push(new $e(u,P,P.getAttribute(h))),l.syncAttrsToProps(P),l.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(()=>l.restoreFocus(o,a,d)),l.dispatchEvent(document,"phx:update"),E.forEach(u=>this.trackAfter("added",u)),g.forEach(u=>this.trackAfter("updated",u)),I.length>0&&(t.transitionRemoves(I),t.requestDOMUpdate(()=>{I.forEach(u=>{let P=l.firstPhxChild(u);P&&t.destroyViewByEl(P),u.remove()}),this.trackAfter("transitionsDiscarded",I)})),$&&(t.disconnect(),$.submit()),!0}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.getAttribute(pe)!==null}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=l.findComponentNodeList(this.container,this.targetCID);return i.length===0&&l.childNodeLength(e)===1?t:t&&t.parentNode}buildDiffHTML(e,t,i,r){let n=this.isCIDPatch(),o=n&&r.getAttribute(C)===this.targetCID.toString();if(!n||o)return t;{let a=null,d=document.createElement("template");a=l.cloneNode(r);let[h,...f]=l.findComponentNodeList(a,this.targetCID);return d.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(pe,""),p.innerHTML="")}),Array.from(d.content.childNodes).forEach(p=>a.insertBefore(p,h)),h.remove(),a.outerHTML}}};var Pe=class{static extract(e){let{[ot]:t,[nt]:i,[at]:r}=e;return delete e[ot],delete e[nt],delete e[at],{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 n in t)t[n]=this.cachedFindComponent(n,t[n],r,t,i);for(let n in t)r[n]=t[n];e[x]=t}}cachedFindComponent(e,t,i,r,n){if(n[e])return n[e];{let o,a,d=t[F];if(M(d)){let h;d>0?h=this.cachedFindComponent(d,r[d],i,r,n):h=i[-d],a=h[F],o=this.cloneMerge(h,t),o[F]=a}else o=t[F]!==void 0?t:this.cloneMerge(i[e]||{},t);return n[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],n=e[i];he(r)&&r[F]===void 0&&he(n)?this.doMutableMerge(n,r):e[i]=r}}cloneMerge(e,t){let i=se(se({},e),t);for(let r in i){let n=t[r],o=e[r];he(n)&&n[F]===void 0&&he(o)&&(i[r]=this.cloneMerge(o,n))}return i}componentToString(e){return this.recursiveCIDToString(this.rendered[x],e)}pruneCIDs(e){e.forEach(t=>delete this.rendered[x][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[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 n=1;n<r.length;n++)this.dynamicToBuffer(e[n-1],t,i),i.buffer+=r[n]}comprehensionToBuffer(e,t,i){let{[st]:r,[F]:n}=e;n=this.templateStatic(n,t);let o=t||e[Ht];for(let a=0;a<r.length;a++){let d=r[a];i.buffer+=n[0];for(let h=1;h<n.length;h++)this.dynamicToBuffer(d[h-1],o,i),i.buffer+=n[h]}}dynamicToBuffer(e,t,i){typeof e=="number"?i.buffer+=this.recursiveCIDToString(i.components,e,i.onlyCids):he(e)?this.toOutputBuffer(e,t,i):i.buffer+=e}recursiveCIDToString(e,t,i){let r=e[t]||w(`no component for CID ${t}`,e),n=document.createElement("template");n.innerHTML=this.recursiveToString(r,e,i);let o=n.content,a=i&&!i.has(t),[d,h]=Array.from(o.childNodes).reduce(([f,p],c,m)=>c.nodeType===Node.ELEMENT_NODE?c.getAttribute(C)?[f,!0]:(c.setAttribute(C,t),c.id||(c.id=`${this.parentViewId()}-${t}-${m}`),a&&(c.setAttribute(pe,""),c.innerHTML=""),[!0,p]):c.nodeValue.trim()!==""?(w(`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(),[f,p]),[!1,!1]);return!d&&!h?(w(`expected at least one HTML element tag inside a component, but the component is empty:
`,n.innerHTML.trim()),this.createSpan("",t).outerHTML):(!d&&h&&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.",n.innerHTML.trim()),n.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,(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 mi={exec(s,e,t,i,r){let[n,o]=r||[null,{}];(e.charAt(0)==="["?JSON.parse(e):[[n,o]]).forEach(([d,h])=>{d===n&&o.data&&(h.data=Object.assign(h.data||{},o.data)),this.filterToEls(i,h).forEach(f=>{this[`exec_${d}`](s,e,t,i,f,h)})})},isVisible(s){return!!(s.offsetWidth||s.offsetHeight||s.getClientRects().length>0)},exec_dispatch(s,e,t,i,r,{to:n,event:o,detail:a}){l.dispatchEvent(r,o,a)},exec_push(s,e,t,i,r,n){let{event:o,data:a,target:d,page_loading:h,loading:f,value:p}=n,c={loading:f,value:p,target:d,page_loading:!!h},m=s==="change"?i.form:i,E=d||m.getAttribute(t.binding("target"))||m;t.withinTargets(E,(g,A)=>{if(s==="change"){let{newCid:I,_target:$,callback:W}=n;$&&(c._target=$),g.pushInput(i,A,I,o||e,c,W)}else s==="submit"?g.submitForm(i,A,o||e,c):g.pushEvent(s,i,A,o||e,a,c)})},exec_add_class(s,e,t,i,r,{names:n,transition:o,time:a}){this.addOrRemoveClasses(r,n,[],o,a,t)},exec_remove_class(s,e,t,i,r,{names:n,transition:o,time:a}){this.addOrRemoveClasses(r,[],n,o,a,t)},exec_transition(s,e,t,i,r,{time:n,transition:o}){let[a,d,h]=o,f=()=>this.addOrRemoveClasses(r,a.concat(d),[]),p=()=>this.addOrRemoveClasses(r,h,a.concat(d));t.transition(n,f,p)},exec_toggle(s,e,t,i,r,{display:n,ins:o,outs:a,time:d}){this.toggle(s,t,r,n,o,a,d)},exec_show(s,e,t,i,r,{display:n,transition:o,time:a}){this.show(s,t,r,n,o,a)},exec_hide(s,e,t,i,r,{display:n,transition:o,time:a}){this.hide(s,t,r,n,o,a)},exec_set_attr(s,e,t,i,r,{attr:[n,o]}){this.setOrRemoveAttrs(r,[[n,o]],[])},exec_remove_attr(s,e,t,i,r,{attr:n}){this.setOrRemoveAttrs(r,[],[n])},show(s,e,t,i,r,n){this.isVisible(t)||this.toggle(s,e,t,i,r,null,n)},hide(s,e,t,i,r,n){this.isVisible(t)&&this.toggle(s,e,t,i,null,r,n)},toggle(s,e,t,i,r,n,o){let[a,d,h]=r||[[],[],[]],[f,p,c]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(t)){let m=()=>{this.addOrRemoveClasses(t,p,a.concat(d).concat(h)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,c,p))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,m,()=>{this.addOrRemoveClasses(t,[],f.concat(c)),l.putSticky(t,"toggle",E=>E.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(s==="remove")return;let m=()=>{this.addOrRemoveClasses(t,d,f.concat(p).concat(c)),l.putSticky(t,"toggle",E=>E.style.display=i||"block"),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,h,d))})};t.dispatchEvent(new Event("phx:show-start")),e.transition(o,m,()=>{this.addOrRemoveClasses(t,[],a.concat(h)),t.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),l.putSticky(t,"toggle",m=>m.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start")),l.putSticky(t,"toggle",m=>m.style.display=i||"block"),t.dispatchEvent(new Event("phx:show-end"))})},addOrRemoveClasses(s,e,t,i,r,n){let[o,a,d]=i||[[],[],[]];if(o.length>0){let h=()=>this.addOrRemoveClasses(s,a.concat(o),[]),f=()=>this.addOrRemoveClasses(s,e.concat(d),t.concat(o).concat(a));return n.transition(r,h,f)}window.requestAnimationFrame(()=>{let[h,f]=l.getSticky(s,"classes",[[],[]]),p=e.filter(g=>h.indexOf(g)<0&&!s.classList.contains(g)),c=t.filter(g=>f.indexOf(g)<0&&s.classList.contains(g)),m=h.filter(g=>t.indexOf(g)<0).concat(p),E=f.filter(g=>e.indexOf(g)<0).concat(c);l.putSticky(s,"classes",g=>(g.classList.remove(...E),g.classList.add(...m),[m,E]))})},setOrRemoveAttrs(s,e,t){let[i,r]=l.getSticky(s,"attrs",[[],[]]),n=e.filter(([h,f])=>!this.hasSet(i,h)&&!s.attributes.getNamedItem(h)),o=t.filter(h=>r.indexOf(h)<0&&s.attributes.getNamedItem(h)),a=i.filter(([h,f])=>t.indexOf(h)<0).concat(n),d=r.filter(h=>!this.hasSet(e,h)).concat(o);l.putSticky(s,"attrs",h=>(d.forEach(f=>h.removeAttribute(f)),a.forEach(([f,p])=>h.setAttribute(f,p)),[a,d]))},hasSet(s,e){return s.find(([t,i])=>t===e)},hasAllClasses(s,e){return e.every(t=>s.classList.contains(t))},isToggledOut(s,e){return!this.isVisible(s)||this.hasAllClasses(s,e)},filterToEls(s,{to:e}){return e?l.all(document,e):[s]}},O=mi;var ut=(s,e={})=>{let t=new FormData(s),i=[];t.forEach((n,o,a)=>{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()},ue=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.el.getAttribute(oe)!==null}connectParams(){let e=this.liveSocket.params(this.el),t=l.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])};l.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,Re,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(Re)}}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,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(M(e))l.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,n=>t(n,r)))}}applyDiff(e,t,i){this.log(e,()=>["",le(t)]);let{diff:r,reply:n,events:o,title:a}=Pe.extract(t);return a&&l.putTitle(a),i({diff:r,reply:n,events:o}),n}onJoin(e){let{rendered:t,container:i}=e;if(i){let[r,n]=i;this.el=l.replaceRootContainer(this.el,r,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,V.dropLocal(this.liveSocket.localStorage,window.location.pathname,ke),this.applyDiff("mount",t,({diff:r,events:n})=>{this.rendered=new Pe(this.id,r);let o=this.renderContainer(null,"join");this.dropPendingRefs();let a=this.formsForRecovery(o);this.joinCount++,a.length>0?a.forEach(([d,h,f],p)=>{this.pushFormRecovery(d,f,c=>{p===a.length-1&&this.onJoinComplete(c,o,n)})}):this.onJoinComplete(e,o,n)})}dropPendingRefs(){l.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);l.findPhxChildrenInFragment(t,this.id).filter(n=>{let o=n.id&&this.el.querySelector(`[id="${n.id}"]`),a=o&&o.getAttribute(Y);return a&&n.setAttribute(Y,a),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=l.byId(this.id),this.el.setAttribute(K,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(),l.all(this.el,`[${this.binding(_e)}], [data-phx-${_e}]`,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&&l.isIgnored(e,this.binding(Ee));if(i&&!e.isEqualNode(t)&&!(r&&Ft(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 a=this.addHook(o);a&&a.__mounted()}),e.after("phxChildAdded",o=>{l.isPhxSticky(o)?this.liveSocket.joinRootViews():r=!0}),e.before("updated",(o,a)=>{this.triggerBeforeUpdateHook(o,a)&&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=>{l.all(r,`[${C}]`).concat(r).forEach(o=>{let a=this.componentID(o);M(a)&&i.indexOf(a)===-1&&i.push(a);let d=this.getHook(o);d&&this.destroyHook(d)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){l.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(j)][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 ue(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",()=>{l.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 ie(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 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-${_e}`)||e.getAttribute(this.binding(_e));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,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.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()&&l.dispatchEvent(window,"phx:page-loading-start",{to:this.href,kind:"error"}),this.showLoader(),this.setContainerClasses(Re,et)}pushWithReply(e,t,i,r=function(){}){if(!this.isConnected())return;let[n,[o],a]=e?e():[null,[],{}],d=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(Ye))!==null)&&(d=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",h=>{n!==null&&this.undoRefs(n);let f=p=>{h.redirect&&this.onRedirect(h.redirect),h.live_patch&&this.onLivePatch(h.live_patch),h.live_redirect&&this.onLiveRedirect(h.live_redirect),d(),r(h,p)};h.diff?this.liveSocket.requestDOMUpdate(()=>{let p=this.applyDiff("update",h.diff,({diff:c,events:m})=>{this.update(c,m)});f(p)}):f(null)}))}undoRefs(e){l.all(document,`[${J}="${this.id}"][${R}="${e}"]`,t=>{let i=t.getAttribute(me);t.removeAttribute(R),t.removeAttribute(J),t.getAttribute(He)!==null&&(t.readOnly=!1,t.removeAttribute(He)),i!==null&&(t.disabled=i==="true",t.removeAttribute(me)),xe.forEach(o=>l.removeClass(t,o));let r=t.getAttribute(be);r!==null&&(t.innerText=r,t.removeAttribute(be));let n=l.private(t,R);if(n){let o=this.triggerBeforeUpdateHook(t,n);ie.patchEl(t,n,this.liveSocket.getActiveElement()),o&&o.__updated(),l.deletePrivate(t,R)}})}putRef(e,t,i={}){let r=this.ref++,n=this.binding(ve);return i.loading&&(e=e.concat(l.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(n);a!==null&&(o.getAttribute(be)||o.setAttribute(be,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(M(t))return t;let r=e.getAttribute(this.binding("target"));return M(r)?parseInt(r):t&&(r!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return M(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[n,o,a]=this.putRef([],"hook");return this.pushWithReply(()=>[n,o,a],"event",{type:"hook",event:t,value:i,cid:this.closestComponentID(e)},(d,h)=>r(h,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,o)})}pushFileProgress(e,t,i,r=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(Tt)),ref:e.getAttribute(N),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)},r)})}pushInput(e,t,i,r,n,o){let a,d=M(i)?i:this.targetComponentID(e.form,t),h=()=>this.putRef([e,e.form],"change",n),f=ut(e.form,{_target:n._target});l.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:d};this.pushWithReply(h,"event",p,c=>{if(l.showError(e,this.liveSocket.binding(ge)),l.isUploadInput(e)&&e.getAttribute("data-phx-auto-upload")!==null){if(y.filesAwaitingPreflight(e).length>0){let[m,E]=h();this.uploadFiles(e.form,t,m,d,g=>{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=>!(ee(c,`${this.binding(Ee)}=ignore`,c.form)||ee(c,"data-phx-update=ignore",c.form)),a=c=>c.hasAttribute(this.binding(ve)),d=c=>c.tagName=="BUTTON",h=c=>["INPUT","TEXTAREA","SELECT"].includes(c.tagName),f=()=>{let c=Array.from(e.elements),m=c.filter(a),E=c.filter(d).filter(o),g=c.filter(h).filter(o);return E.forEach(A=>{A.setAttribute(me,A.disabled),A.disabled=!0}),g.forEach(A=>{A.setAttribute(He,A.readOnly),A.readOnly=!0,A.files&&(A.setAttribute(me,A.disabled),A.disabled=!0)}),e.setAttribute(this.binding(Ye),""),this.putRef([e].concat(m).concat(E).concat(g),"submit",r)},p=this.targetComponentID(e,t);if(y.hasUploadsInProgress(e)){let[c,m]=f(),E=()=>this.pushFormSubmit(e,t,i,r,n);return this.scheduleSubmit(e,c,r,E)}else if(y.inputsAwaitingPreflight(e).length>0){let[c,m]=f(),E=()=>[c,m,r];this.uploadFiles(e,t,c,p,g=>{let A=ut(e,{});this.pushWithReply(E,"event",{type:"form",event:i,value:A,cid:p},n)})}else{let c=ut(e);this.pushWithReply(f,"event",{type:"form",event:i,value:c,cid:p},n)}}uploadFiles(e,t,i,r,n){let o=this.joinCount,a=y.activeFileInputs(e),d=a.length;a.forEach(h=>{let f=new y(h,this,()=>{d--,d===0&&n()});this.uploaders[h]=f;let p=f.entries().map(m=>m.toPreflightPayload()),c={ref:h.getAttribute(N),entries:p,cid:this.targetComponentID(h.form,t)};this.log("upload",()=>["sending preflight request",c]),this.pushWithReply(null,"allow_upload",c,m=>{if(this.log("upload",()=>["got preflight response",m]),m.error){this.undoRefs(i);let[E,g]=m.error;this.log("upload",()=>[`error for entry ${E}`,g])}else{let E=g=>{this.channel.onError(()=>{this.joinCount===o&&g()})};f.initAdapterUpload(m,E,this.liveSocket)}})})}dispatchUploads(e,t){let i=l.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}"`):l.dispatchEvent(i[0],Ie,{files:t})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(r,n)=>{let o=e.elements[0],a=e.getAttribute(this.binding(it))||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),n=t?()=>this.putRef([t],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=this.pushWithReply(n,"live_patch",{url:e},d=>{this.liveSocket.requestDOMUpdate(()=>{d.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,l.all(this.el,`form[${t}]`).filter(r=>r.id&&this.ownsElement(r)).filter(r=>r.elements.length>0).filter(r=>r.getAttribute(this.binding(it))!=="ignore").map(r=>{let n=i.content.querySelector(`form[id="${r.id}"][${t}="${r.getAttribute(t)}"]`);return n?[r,n,this.targetComponentID(n)]:[r,null,null]}).filter(([r,n,o])=>n)}maybePushComponentsDestroyed(e){let t=e.filter(i=>l.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=>l.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(j)===this.id||D(e.closest(B),t=>t.id)===this.id}submitForm(e,t,i,r={}){l.putPrivate(e,Oe,!0);let n=this.liveSocket.binding(ge),o=Array.from(e.elements);this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,r,()=>{o.forEach(a=>l.showError(a,n)),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(le(Ot),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.linkRef=1,this.clickRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=le(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||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(Ne)==="true"}enableDebug(){this.sessionStorage.setItem(Ne,"true")}enableProfiling(){this.sessionStorage.setItem(Ue,"true")}disableDebug(){this.sessionStorage.removeItem(Ne)}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(Fe,e)}disableLatencySim(){this.sessionStorage.removeItem(Fe)}getLatencySim(){let e=this.sessionStorage.getItem(Fe);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=>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,n]=i();this.viewLogger(e,t,r,n)}else if(this.isDebugEnabled()){let[r,n]=i();Ut(e,t,r,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,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(a,d){this.receives.push([a,d])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[d,h])=>a.receive(d,h),i())},r),o}reloadWithJitter(e,t){e.destroy(),this.disconnect();let i=this.reloadJitterMin,r=this.reloadJitterMax,n=Math.floor(Math.random()*(r-i+1))+i,o=V.updateLocal(this.localStorage,window.location.pathname,ke,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`]),n=this.failsafeJitter),setTimeout(()=>{this.hasPendingLink()?window.location=this.pendingLink:window.location.reload()},n)}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 l.all(document,`${B}:not([${j}])`,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)){let n=this.main.el,o=l.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((a,d)=>{a===1&&this.commitPendingLink(r)&&this.requestDOMUpdate(()=>{l.findPhxSticky(document).forEach(h=>o.appendChild(h)),n.replaceWith(o),i&&i(),d()})})}transitionRemoves(e){let t=this.binding("remove");e=e||l.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 ue(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(K);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(K));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let t=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",t),e.addEventListener("touchend",t)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents(){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.socket.onClose(e=>{e.code===1e3&&this.main&&this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",e=>{e.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),this.bindNav(),this.bindClicks(),this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(e,t,i,r,n,o)=>{let a=r.getAttribute(this.binding(xt)),d=e.key&&e.key.toLowerCase();if(a&&a.toLowerCase()!==d)return;let h=se({key:e.key},this.eventMeta(t,e,r));O.exec(t,n,i,r,["push",{data:h}])}),this.bind({blur:"focusout",focus:"focusin"},(e,t,i,r,n,o)=>{if(!o){let a=se({key:e.key},this.eventMeta(t,e,r));O.exec(t,n,i,r,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(e,t,i,r,n,o,a)=>{if(a==="window"){let d=this.eventMeta(t,e,r);O.exec(t,o,i,r,["push",{data:d}])}}),window.addEventListener("dragover",e=>e.preventDefault()),window.addEventListener("drop",e=>{e.preventDefault();let t=D(ee(e.target,this.binding(Ge)),n=>n.getAttribute(this.binding(Ge))),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(Ie,e=>{let t=e.target;if(!l.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,n=>{let o=this.binding(i),a=this.binding(`window-${i}`),d=n.target.getAttribute&&n.target.getAttribute(o);d?this.debounce(n.target,n,()=>{this.withinOwners(n.target,h=>{t(n,i,h,n.target,d,null)})}):l.all(document,`[${a}]`,h=>{let f=h.getAttribute(a);this.debounce(h,n,()=>{this.withinOwners(h,p=>{t(n,i,p,h,f,"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;this.clickRef++;let o=this.clickRef,a=null;i?a=n.target.matches(`[${r}]`)?n.target:n.target.querySelector(`[${r}]`):(a=ee(n.target,r),this.dispatchClickAway(n,o));let d=a&&a.getAttribute(r);!d||(a.getAttribute("href")==="#"&&n.preventDefault(),this.debounce(a,n,()=>{this.withinOwners(a,h=>{O.exec("click",d,h,a,["push",{data:this.eventMeta("click",n,a)}])})}))},i)}dispatchClickAway(e,t){let i=this.binding("click-away"),r=this.binding("click");l.all(document,`[${i}]`,n=>{n.isSameNode(e.target)||n.contains(e.target)||this.withinOwners(e.target,o=>{let a=n.getAttribute(i);if(O.isVisible(n)){let d=e.target.closest(`[${r}]`)||e.target;O.exec("click",a,o,n,["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:n,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,()=>{n&&this.replaceRootHistory(),typeof o=="number"&&setTimeout(()=>{window.scrollTo(0,o)},0)})})},!1),window.addEventListener("click",t=>{let i=ee(t.target,Te),r=i&&i.getAttribute(Te),n=t.metaKey||t.ctrlKey||t.button===1;if(!r||!this.isConnected()||!this.main||n)return;let o=i.href,a=i.getAttribute(At);t.preventDefault(),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 ${Te} to be "patch" or "redirect", got: ${r}`)})},!1)}dispatchEvent(e,t={}){l.dispatchEvent(window,`phx:${e}`,t)}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){l.dispatchEvent(window,"phx:page-loading-start",e);let i=()=>l.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)||(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"},n=>{this.replaceMain(e,i,()=>{V.pushState(t,{type:"redirect",id:this.main.id,scroll:r},e),this.registerNewLocation(window.location),n()})})}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=le(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=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:a,type:d}=l.private(r,"prev-iteration")||{};a===o-1&&t!==d||(l.putPrivate(r,"prev-iteration",{at:o,type:t}),this.debounce(r,i,()=>{this.withinOwners(r.form,h=>{l.putPrivate(r,Le,!0),l.isTextualInput(r)||this.setActiveElement(r),O.exec("change",n,h,r,["push",{_target:i.target.name}])})}))},!1)}debounce(e,t,i){let r=this.binding(Ct),n=this.binding(kt),o=this.defaults.debounce.toString(),a=this.defaults.throttle.toString();l.debounce(e,t,r,o,n,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;})();