phoenix_live_view 0.16.3 → 0.17.2

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