phoenix_live_view 1.1.2 → 1.1.3

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,21 +1,21 @@
1
- var LiveView=(()=>{var rt=Object.defineProperty,Li=Object.defineProperties,Oi=Object.getOwnPropertyDescriptor,Hi=Object.getOwnPropertyDescriptors,Di=Object.getOwnPropertyNames,qt=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,Ni=Object.prototype.propertyIsEnumerable;var Kt=(n,e,t)=>e in n?rt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,H=(n,e)=>{for(var t in e||(e={}))Gt.call(e,t)&&Kt(n,t,e[t]);if(qt)for(var t of qt(e))Ni.call(e,t)&&Kt(n,t,e[t]);return n},ae=(n,e)=>Li(n,Hi(e));var Mi=(n,e)=>{for(var t in e)rt(n,t,{get:e[t],enumerable:!0})},Fi=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Di(e))!Gt.call(n,s)&&s!==t&&rt(n,s,{get:()=>e[s],enumerable:!(i=Oi(e,s))||i.enumerable});return n};var Ui=n=>Fi(rt({},"__esModule",{value:!0}),n);var ms={};Mi(ms,{LiveSocket:()=>fs,ViewHook:()=>Q,createHook:()=>ps,isUsedInput:()=>Ri});var ot="consecutive-reloads";var at=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],q="data-phx-component",Re="data-phx-view",lt="data-phx-link",zt="track-static",Yt="data-phx-link-state",ue="data-phx-ref-loading",N="data-phx-ref-src",R="data-phx-ref-lock",kt="phx-pending-refs",ht="track-uploads",K="data-phx-upload-ref",Ie="data-phx-preflighted-refs",Qt="data-phx-done-refs",Pt="drop-target",We="data-phx-active-refs",Le="phx:live-file:updated",ct="data-phx-skip",dt="data-phx-id",Tt="data-phx-prune",Ct="phx-connected",fe="phx-loading",Ae="phx-error",xt="phx-client-error",Oe="phx-server-error",ie="data-phx-parent-id",He="data-phx-main",z="data-phx-root-id",qe="viewport-top",Ke="viewport-bottom",Zt="trigger-action",ye="phx-has-focused",ei=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],ut=["checkbox","radio"],Se="phx-has-submitted",V="data-phx-session",se=`[${V}]`,Ge="data-phx-sticky",ne="data-phx-static",ze="data-phx-readonly",pe="data-phx-disabled",Rt="disable-with",De="data-phx-disable-with-restore",Ne="hook",ti="debounce",ii="throttle",Me="update",Fe="stream",Ue="data-phx-stream",ft="data-phx-portal",me="data-phx-teleported",pt="data-phx-teleported-src",Xe="data-phx-runtime-hook",si="data-phx-pid",ni="key",ee="phxPrivate",It="auto-recover",Ye="phx:live-socket:debug",mt="phx:live-socket:profiling",gt="phx:live-socket:latency-sim",Qe="phx:nav-history-position",ri="progress",Lt="mounted",Ot="__phoenix_reload_status__",oi=1,Ht=3,ai=200,li=500,hi="phx-",ci=3e4;var $e="debounce-trigger",Be="throttled",Dt="debounce-prev-key",di={debounce:300,throttle:300},Nt=[ue,N,R],G="s",vt="r",F="c",I="k",te="kc",Mt="e",Ft="r",Ut="t",le="p",_e="stream";var Ze=class{constructor(e,t,i){let{chunk_size:s,chunk_timeout:r}=t;this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=s,this.chunkTimeout=r,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),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 k("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){this.uploadChannel.isJoined()&&this.uploadChannel.push("chunk",e,this.chunkTimeout).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))}).receive("error",({reason:t})=>this.error(t))}};var k=(n,e)=>console.error&&console.error(n,e),Y=n=>{let e=typeof n;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(n)};function ui(){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)}function fi(n){let e=new Set;Object.keys(n).forEach(t=>{let i=document.getElementById(t);i&&i.parentElement&&i.parentElement.getAttribute("phx-update")!=="stream"&&e.add(`The stream container with id "${i.parentElement.id}" is missing the phx-update="stream" attribute. Ensure it is set for streams to work properly.`)}),e.forEach(t=>console.error(t))}var pi=(n,e,t,i)=>{n.liveSocket.isDebugEnabled()&&console.log(`${n.id} ${e}: ${t} - `,i)},Ve=n=>typeof n=="function"?n:function(){return n},je=n=>JSON.parse(JSON.stringify(n)),we=(n,e,t)=>{do{if(n.matches(`[${e}]`)&&!n.disabled)return n;n=n.parentElement||n.parentNode}while(n!==null&&n.nodeType===1&&!(t&&t.isSameNode(n)||n.matches(se)));return null},ke=n=>n!==null&&typeof n=="object"&&!(n instanceof Array),mi=(n,e)=>JSON.stringify(n)===JSON.stringify(e),Xt=n=>{for(let e in n)return!1;return!0},re=(n,e)=>n&&e(n),gi=function(n,e,t,i){n.forEach(s=>{new Ze(s,t.config,i).upload()})};var Xi={canPushState(){return typeof history.pushState!="undefined"},dropLocal(n,e,t){return n.removeItem(this.localKey(e,t))},updateLocal(n,e,t,i,s){let r=this.getLocal(n,e,t),o=this.localKey(e,t),a=r===null?i:s(r);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 i=history.state||{};i.scroll=e.scroll,history.replaceState(i,"",window.location.href)}delete e.scroll,history[n+"State"](e,"",t||null),window.requestAnimationFrame(()=>{let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)})}}else this.redirect(t)},setCookie(n,e,t){let i=typeof t=="number"?` max-age=${t};`:"";document.cookie=`${n}=${e};${i} path=/`},getCookie(n){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${n}s*=s*([^;]*).*$)|^.*$`),"$1")},deleteCookie(n){document.cookie=`${n}=; max-age=-1; path=/`},redirect(n,e,t=i=>{window.location.href=i}){e&&this.setCookie("__phoenix_flash__",e,60),t(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=Xi;var Pe={byId(n){return document.getElementById(n)||k(`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(K)!==null},isAutoUpload(n){return n.hasAttribute("data-phx-auto-upload")},findUploadInputs(n){let e=n.id,t=this.all(document,`input[type="file"][${K}][form="${e}"]`);return this.all(n,`input[type="file"][${K}]`).concat(t)},findComponentNodeList(n,e,t=document){return this.all(t,`[${Re}="${n}"][${q}="${e}"]`)},isPhxDestroyed(n){return!!(n.id&&Pe.private(n,"destroyed"))},wantsNewTab(n){let e=n.ctrlKey||n.shiftKey||n.metaKey||n.button&&n.button===1,t=n.target instanceof HTMLAnchorElement&&n.target.hasAttribute("download"),i=n.target.hasAttribute("target")&&n.target.getAttribute("target").toLowerCase()==="_blank",s=n.target.hasAttribute("target")&&!n.target.getAttribute("target").startsWith("_");return e||i||t||s},isUnloadableFormSubmit(n){return n.target&&n.target.getAttribute("method")==="dialog"||n.submitter&&n.submitter.getAttribute("formmethod")==="dialog"?!1:!n.defaultPrevented&&!this.wantsNewTab(n)},isNewPageClick(n,e){let t=n.target instanceof HTMLAnchorElement?n.target.getAttribute("href"):null,i;if(n.defaultPrevented||t===null||this.wantsNewTab(n)||t.startsWith("mailto:")||t.startsWith("tel:")||n.target.isContentEditable)return!1;try{i=new URL(t)}catch(s){try{i=new URL(t,e)}catch(r){return!0}}return i.host===e.host&&i.protocol===e.protocol&&i.pathname===e.pathname&&i.search===e.search?i.hash===""&&!i.href.endsWith("#"):i.protocol.startsWith("http")},markPhxChildDestroyed(n){this.isPhxChild(n)&&n.setAttribute(V,""),this.putPrivate(n,"destroyed",!0)},findPhxChildrenInFragment(n,e){let t=document.createElement("template");return t.innerHTML=n,this.findPhxChildren(t.content,e)},isIgnored(n,e){return(n.getAttribute(e)||n.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(n,e,t){return n.getAttribute&&t.indexOf(n.getAttribute(e))>=0},findPhxSticky(n){return this.all(n,`[${Ge}]`)},findPhxChildren(n,e){return this.all(n,`${se}[${ie}="${e}"]`)},findExistingParentCIDs(n,e){let t=new Set,i=new Set;return e.forEach(s=>{this.all(document,`[${Re}="${n}"][${q}="${s}"]`).forEach(r=>{t.add(s),this.all(r,`[${Re}="${n}"][${q}]`).map(o=>parseInt(o.getAttribute(q))).forEach(o=>i.add(o))})}),i.forEach(s=>t.delete(s)),t},private(n,e){return n[ee]&&n[ee][e]},deletePrivate(n,e){n[ee]&&delete n[ee][e]},putPrivate(n,e,t){n[ee]||(n[ee]={}),n[ee][e]=t},updatePrivate(n,e,t,i){let s=this.private(n,e);s===void 0?this.putPrivate(n,e,i(t)):this.putPrivate(n,e,i(s))},syncPendingAttrs(n,e){n.hasAttribute(N)&&(at.forEach(t=>{n.classList.contains(t)&&e.classList.add(t)}),Nt.filter(t=>n.hasAttribute(t)).forEach(t=>{e.setAttribute(t,n.getAttribute(t))}))},copyPrivates(n,e){e[ee]&&(n[ee]=e[ee])},putTitle(n){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i,default:s}=e.dataset,r=typeof n!="string"||n.trim()==="";if(r&&typeof s!="string")return;let o=r?s:n;document.title=`${t||""}${o||""}${i||""}`}else document.title=n},debounce(n,e,t,i,s,r,o,a){let l=n.getAttribute(t),c=n.getAttribute(s);l===""&&(l=i),c===""&&(c=r);let u=l||c;switch(u){case null:return a();case"blur":this.incCycle(n,"debounce-blur-cycle",()=>{o()&&a()}),this.once(n,"debounce-blur")&&n.addEventListener("blur",()=>this.triggerCycle(n,"debounce-blur-cycle"));return;default:let p=parseInt(u),m=()=>c?this.deletePrivate(n,Be):a(),g=this.incCycle(n,$e,m);if(isNaN(p))return k(`invalid throttle/debounce value: ${u}`);if(c){let v=!1;if(e.type==="keydown"){let E=this.private(n,Dt);this.putPrivate(n,Dt,e.key),v=E!==e.key}if(!v&&this.private(n,Be))return!1;{a();let E=setTimeout(()=>{o()&&this.triggerCycle(n,$e)},p);this.putPrivate(n,Be,E)}}else setTimeout(()=>{o()&&this.triggerCycle(n,$e,g)},p);let d=n.form;d&&this.once(d,"bind-debounce")&&d.addEventListener("submit",()=>{Array.from(new FormData(d).entries(),([v])=>{let E=d.querySelector(`[name="${v}"]`);this.incCycle(E,$e),this.deletePrivate(E,Be)})}),this.once(n,"bind-debounce")&&n.addEventListener("blur",()=>{clearTimeout(this.private(n,Be)),this.triggerCycle(n,$e)})}},triggerCycle(n,e,t){let[i,s]=this.private(n,e);t||(t=i),t===i&&(this.incCycle(n,e),s())},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},maintainPrivateHooks(n,e,t,i){n.hasAttribute&&n.hasAttribute("data-phx-hook")&&!e.hasAttribute("data-phx-hook")&&e.setAttribute("data-phx-hook",n.getAttribute("data-phx-hook")),e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute(i))&&e.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},putCustomElHook(n,e){n.isConnected?n.setAttribute("data-phx-hook",""):console.error(`
1
+ var LiveView=(()=>{var ot=Object.defineProperty,Li=Object.defineProperties,Oi=Object.getOwnPropertyDescriptor,Hi=Object.getOwnPropertyDescriptors,Di=Object.getOwnPropertyNames,qt=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,Ni=Object.prototype.propertyIsEnumerable;var Kt=(n,e,t)=>e in n?ot(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,H=(n,e)=>{for(var t in e||(e={}))Gt.call(e,t)&&Kt(n,t,e[t]);if(qt)for(var t of qt(e))Ni.call(e,t)&&Kt(n,t,e[t]);return n},ae=(n,e)=>Li(n,Hi(e));var Mi=(n,e)=>{for(var t in e)ot(n,t,{get:e[t],enumerable:!0})},Fi=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Di(e))!Gt.call(n,s)&&s!==t&&ot(n,s,{get:()=>e[s],enumerable:!(i=Oi(e,s))||i.enumerable});return n};var Ui=n=>Fi(ot({},"__esModule",{value:!0}),n);var ms={};Mi(ms,{LiveSocket:()=>fs,ViewHook:()=>Q,createHook:()=>ps,isUsedInput:()=>Ri});var at="consecutive-reloads";var lt=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],q="data-phx-component",Re="data-phx-view",ht="data-phx-link",zt="track-static",Yt="data-phx-link-state",ue="data-phx-ref-loading",N="data-phx-ref-src",R="data-phx-ref-lock",kt="phx-pending-refs",ct="track-uploads",K="data-phx-upload-ref",Ie="data-phx-preflighted-refs",Qt="data-phx-done-refs",Pt="drop-target",We="data-phx-active-refs",Le="phx:live-file:updated",dt="data-phx-skip",ut="data-phx-id",Tt="data-phx-prune",Ct="phx-connected",fe="phx-loading",Ae="phx-error",xt="phx-client-error",Oe="phx-server-error",ie="data-phx-parent-id",He="data-phx-main",z="data-phx-root-id",qe="viewport-top",Ke="viewport-bottom",Zt="trigger-action",ye="phx-has-focused",ei=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],ft=["checkbox","radio"],Se="phx-has-submitted",V="data-phx-session",se=`[${V}]`,Ge="data-phx-sticky",ne="data-phx-static",ze="data-phx-readonly",pe="data-phx-disabled",Rt="disable-with",De="data-phx-disable-with-restore",Ne="hook",ti="debounce",ii="throttle",Me="update",Fe="stream",Ue="data-phx-stream",pt="data-phx-portal",me="data-phx-teleported",mt="data-phx-teleported-src",Xe="data-phx-runtime-hook",si="data-phx-pid",ni="key",ee="phxPrivate",It="auto-recover",Ye="phx:live-socket:debug",gt="phx:live-socket:profiling",vt="phx:live-socket:latency-sim",Qe="phx:nav-history-position",ri="progress",Lt="mounted",Ot="__phoenix_reload_status__",oi=1,Ht=3,ai=200,li=500,hi="phx-",ci=3e4;var $e="debounce-trigger",Be="throttled",Dt="debounce-prev-key",di={debounce:300,throttle:300},Nt=[ue,N,R],G="s",bt="r",F="c",I="k",te="kc",Mt="e",Ft="r",Ut="t",le="p",_e="stream";var Ze=class{constructor(e,t,i){let{chunk_size:s,chunk_timeout:r}=t;this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=s,this.chunkTimeout=r,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),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 k("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){this.uploadChannel.isJoined()&&this.uploadChannel.push("chunk",e,this.chunkTimeout).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))}).receive("error",({reason:t})=>this.error(t))}};var k=(n,e)=>console.error&&console.error(n,e),Y=n=>{let e=typeof n;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(n)};function ui(){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)}function fi(n){let e=new Set;Object.keys(n).forEach(t=>{let i=document.getElementById(t);i&&i.parentElement&&i.parentElement.getAttribute("phx-update")!=="stream"&&e.add(`The stream container with id "${i.parentElement.id}" is missing the phx-update="stream" attribute. Ensure it is set for streams to work properly.`)}),e.forEach(t=>console.error(t))}var pi=(n,e,t,i)=>{n.liveSocket.isDebugEnabled()&&console.log(`${n.id} ${e}: ${t} - `,i)},Ve=n=>typeof n=="function"?n:function(){return n},je=n=>JSON.parse(JSON.stringify(n)),we=(n,e,t)=>{do{if(n.matches(`[${e}]`)&&!n.disabled)return n;n=n.parentElement||n.parentNode}while(n!==null&&n.nodeType===1&&!(t&&t.isSameNode(n)||n.matches(se)));return null},ke=n=>n!==null&&typeof n=="object"&&!(n instanceof Array),mi=(n,e)=>JSON.stringify(n)===JSON.stringify(e),Xt=n=>{for(let e in n)return!1;return!0},re=(n,e)=>n&&e(n),gi=function(n,e,t,i){n.forEach(s=>{new Ze(s,t.config,i).upload()})};var Xi={canPushState(){return typeof history.pushState!="undefined"},dropLocal(n,e,t){return n.removeItem(this.localKey(e,t))},updateLocal(n,e,t,i,s){let r=this.getLocal(n,e,t),o=this.localKey(e,t),a=r===null?i:s(r);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 i=history.state||{};i.scroll=e.scroll,history.replaceState(i,"",window.location.href)}delete e.scroll,history[n+"State"](e,"",t||null),window.requestAnimationFrame(()=>{let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)})}}else this.redirect(t)},setCookie(n,e,t){let i=typeof t=="number"?` max-age=${t};`:"";document.cookie=`${n}=${e};${i} path=/`},getCookie(n){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${n}s*=s*([^;]*).*$)|^.*$`),"$1")},deleteCookie(n){document.cookie=`${n}=; max-age=-1; path=/`},redirect(n,e,t=i=>{window.location.href=i}){e&&this.setCookie("__phoenix_flash__",e,60),t(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=Xi;var Pe={byId(n){return document.getElementById(n)||k(`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(K)!==null},isAutoUpload(n){return n.hasAttribute("data-phx-auto-upload")},findUploadInputs(n){let e=n.id,t=this.all(document,`input[type="file"][${K}][form="${e}"]`);return this.all(n,`input[type="file"][${K}]`).concat(t)},findComponentNodeList(n,e,t=document){return this.all(t,`[${Re}="${n}"][${q}="${e}"]`)},isPhxDestroyed(n){return!!(n.id&&Pe.private(n,"destroyed"))},wantsNewTab(n){let e=n.ctrlKey||n.shiftKey||n.metaKey||n.button&&n.button===1,t=n.target instanceof HTMLAnchorElement&&n.target.hasAttribute("download"),i=n.target.hasAttribute("target")&&n.target.getAttribute("target").toLowerCase()==="_blank",s=n.target.hasAttribute("target")&&!n.target.getAttribute("target").startsWith("_");return e||i||t||s},isUnloadableFormSubmit(n){return n.target&&n.target.getAttribute("method")==="dialog"||n.submitter&&n.submitter.getAttribute("formmethod")==="dialog"?!1:!n.defaultPrevented&&!this.wantsNewTab(n)},isNewPageClick(n,e){let t=n.target instanceof HTMLAnchorElement?n.target.getAttribute("href"):null,i;if(n.defaultPrevented||t===null||this.wantsNewTab(n)||t.startsWith("mailto:")||t.startsWith("tel:")||n.target.isContentEditable)return!1;try{i=new URL(t)}catch(s){try{i=new URL(t,e)}catch(r){return!0}}return i.host===e.host&&i.protocol===e.protocol&&i.pathname===e.pathname&&i.search===e.search?i.hash===""&&!i.href.endsWith("#"):i.protocol.startsWith("http")},markPhxChildDestroyed(n){this.isPhxChild(n)&&n.setAttribute(V,""),this.putPrivate(n,"destroyed",!0)},findPhxChildrenInFragment(n,e){let t=document.createElement("template");return t.innerHTML=n,this.findPhxChildren(t.content,e)},isIgnored(n,e){return(n.getAttribute(e)||n.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(n,e,t){return n.getAttribute&&t.indexOf(n.getAttribute(e))>=0},findPhxSticky(n){return this.all(n,`[${Ge}]`)},findPhxChildren(n,e){return this.all(n,`${se}[${ie}="${e}"]`)},findExistingParentCIDs(n,e){let t=new Set,i=new Set;return e.forEach(s=>{this.all(document,`[${Re}="${n}"][${q}="${s}"]`).forEach(r=>{t.add(s),this.all(r,`[${Re}="${n}"][${q}]`).map(o=>parseInt(o.getAttribute(q))).forEach(o=>i.add(o))})}),i.forEach(s=>t.delete(s)),t},private(n,e){return n[ee]&&n[ee][e]},deletePrivate(n,e){n[ee]&&delete n[ee][e]},putPrivate(n,e,t){n[ee]||(n[ee]={}),n[ee][e]=t},updatePrivate(n,e,t,i){let s=this.private(n,e);s===void 0?this.putPrivate(n,e,i(t)):this.putPrivate(n,e,i(s))},syncPendingAttrs(n,e){n.hasAttribute(N)&&(lt.forEach(t=>{n.classList.contains(t)&&e.classList.add(t)}),Nt.filter(t=>n.hasAttribute(t)).forEach(t=>{e.setAttribute(t,n.getAttribute(t))}))},copyPrivates(n,e){e[ee]&&(n[ee]=e[ee])},putTitle(n){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i,default:s}=e.dataset,r=typeof n!="string"||n.trim()==="";if(r&&typeof s!="string")return;let o=r?s:n;document.title=`${t||""}${o||""}${i||""}`}else document.title=n},debounce(n,e,t,i,s,r,o,a){let l=n.getAttribute(t),c=n.getAttribute(s);l===""&&(l=i),c===""&&(c=r);let u=l||c;switch(u){case null:return a();case"blur":this.incCycle(n,"debounce-blur-cycle",()=>{o()&&a()}),this.once(n,"debounce-blur")&&n.addEventListener("blur",()=>this.triggerCycle(n,"debounce-blur-cycle"));return;default:let p=parseInt(u),m=()=>c?this.deletePrivate(n,Be):a(),g=this.incCycle(n,$e,m);if(isNaN(p))return k(`invalid throttle/debounce value: ${u}`);if(c){let v=!1;if(e.type==="keydown"){let E=this.private(n,Dt);this.putPrivate(n,Dt,e.key),v=E!==e.key}if(!v&&this.private(n,Be))return!1;{a();let E=setTimeout(()=>{o()&&this.triggerCycle(n,$e)},p);this.putPrivate(n,Be,E)}}else setTimeout(()=>{o()&&this.triggerCycle(n,$e,g)},p);let d=n.form;d&&this.once(d,"bind-debounce")&&d.addEventListener("submit",()=>{Array.from(new FormData(d).entries(),([v])=>{let E=d.querySelector(`[name="${v}"]`);this.incCycle(E,$e),this.deletePrivate(E,Be)})}),this.once(n,"bind-debounce")&&n.addEventListener("blur",()=>{clearTimeout(this.private(n,Be)),this.triggerCycle(n,$e)})}},triggerCycle(n,e,t){let[i,s]=this.private(n,e);t||(t=i),t===i&&(this.incCycle(n,e),s())},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},maintainPrivateHooks(n,e,t,i){n.hasAttribute&&n.hasAttribute("data-phx-hook")&&!e.hasAttribute("data-phx-hook")&&e.setAttribute("data-phx-hook",n.getAttribute("data-phx-hook")),e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute(i))&&e.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},putCustomElHook(n,e){n.isConnected?n.setAttribute("data-phx-hook",""):console.error(`
2
2
  hook attached to non-connected DOM element
3
3
  ensure you are calling createHook within your connectedCallback. ${n.outerHTML}
4
- `),this.putPrivate(n,"custom-el-hook",e)},getCustomElHook(n){return this.private(n,"custom-el-hook")},isUsedInput(n){return n.nodeType===Node.ELEMENT_NODE&&(this.private(n,ye)||this.private(n,Se))},resetForm(n){Array.from(n.elements).forEach(e=>{this.deletePrivate(e,ye),this.deletePrivate(e,Se)})},isPhxChild(n){return n.getAttribute&&n.getAttribute(ie)},isPhxSticky(n){return n.getAttribute&&n.getAttribute(Ge)!==null},isChildOfAny(n,e){return!!e.find(t=>t.contains(n))},firstPhxChild(n){return this.isPhxChild(n)?n:this.all(n,`[${ie}]`)[0]},isPortalTemplate(n){return n.tagName==="TEMPLATE"&&n.hasAttribute(ft)},closestViewEl(n){let e=n.closest(`[${me}],${se}`);return e?e.hasAttribute(me)?this.byId(e.getAttribute(me)):e.hasAttribute(V)?e:null:null},dispatchEvent(n,e,t={}){let i=!0;n.nodeName==="INPUT"&&n.type==="file"&&e==="click"&&(i=!1);let o={bubbles:t.bubbles===void 0?i:!!t.bubbles,cancelable:!0,detail:t.detail||{}},a=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);n.dispatchEvent(a)},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=new Set(t.exclude||[]),s=t.isIgnored,r=e.attributes;for(let a=r.length-1;a>=0;a--){let l=r[a].name;if(i.has(l))l==="value"&&n.value===e.value&&n.setAttribute("value",e.getAttribute(l));else{let c=e.getAttribute(l);n.getAttribute(l)!==c&&(!s||s&&l.startsWith("data-"))&&n.setAttribute(l,c)}}let o=n.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;s?l.startsWith("data-")&&!e.hasAttribute(l)&&!Nt.includes(l)&&n.removeAttribute(l):e.hasAttribute(l)||n.removeAttribute(l)}},mergeFocusedInput(n,e){n instanceof HTMLSelectElement||Pe.mergeAttrs(n,e,{exclude:["value"]}),e.readOnly?n.setAttribute("readonly",!0):n.removeAttribute("readonly")},hasSelectionRange(n){return n.setSelectionRange&&(n.type==="text"||n.type==="textarea")},restoreFocus(n,e,t){if(n instanceof HTMLSelectElement&&n.focus(),!Pe.isTextualInput(n))return;n.matches(":focus")||n.focus(),this.hasSelectionRange(n)&&n.setSelectionRange(e,t)},isFormInput(n){return n.localName&&customElements.get(n.localName)?customElements.get(n.localName).formAssociated:/^(?:input|select|textarea)$/i.test(n.tagName)&&n.type!=="button"},syncAttrsToProps(n){n instanceof HTMLInputElement&&ut.indexOf(n.type.toLocaleLowerCase())>=0&&(n.checked=n.getAttribute("checked")!==null)},isTextualInput(n){return ei.indexOf(n.type)>=0},isNowTriggerFormExternal(n,e){return n.getAttribute&&n.getAttribute(e)!==null&&document.body.contains(n)},cleanChildNodes(n,e){if(Pe.isPhxUpdate(n,e,["append","prepend",Fe])){let t=[];n.childNodes.forEach(i=>{i.id||(!(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()==="")&&i.nodeType!==Node.COMMENT_NODE&&k(`only HTML element tags with an id are allowed inside containers with phx-update.
4
+ `),this.putPrivate(n,"custom-el-hook",e)},getCustomElHook(n){return this.private(n,"custom-el-hook")},isUsedInput(n){return n.nodeType===Node.ELEMENT_NODE&&(this.private(n,ye)||this.private(n,Se))},resetForm(n){Array.from(n.elements).forEach(e=>{this.deletePrivate(e,ye),this.deletePrivate(e,Se)})},isPhxChild(n){return n.getAttribute&&n.getAttribute(ie)},isPhxSticky(n){return n.getAttribute&&n.getAttribute(Ge)!==null},isChildOfAny(n,e){return!!e.find(t=>t.contains(n))},firstPhxChild(n){return this.isPhxChild(n)?n:this.all(n,`[${ie}]`)[0]},isPortalTemplate(n){return n.tagName==="TEMPLATE"&&n.hasAttribute(pt)},closestViewEl(n){let e=n.closest(`[${me}],${se}`);return e?e.hasAttribute(me)?this.byId(e.getAttribute(me)):e.hasAttribute(V)?e:null:null},dispatchEvent(n,e,t={}){let i=!0;n.nodeName==="INPUT"&&n.type==="file"&&e==="click"&&(i=!1);let o={bubbles:t.bubbles===void 0?i:!!t.bubbles,cancelable:!0,detail:t.detail||{}},a=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);n.dispatchEvent(a)},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=new Set(t.exclude||[]),s=t.isIgnored,r=e.attributes;for(let a=r.length-1;a>=0;a--){let l=r[a].name;if(i.has(l))l==="value"&&n.value===e.value&&n.setAttribute("value",e.getAttribute(l));else{let c=e.getAttribute(l);n.getAttribute(l)!==c&&(!s||s&&l.startsWith("data-"))&&n.setAttribute(l,c)}}let o=n.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;s?l.startsWith("data-")&&!e.hasAttribute(l)&&!Nt.includes(l)&&n.removeAttribute(l):e.hasAttribute(l)||n.removeAttribute(l)}},mergeFocusedInput(n,e){n instanceof HTMLSelectElement||Pe.mergeAttrs(n,e,{exclude:["value"]}),e.readOnly?n.setAttribute("readonly",!0):n.removeAttribute("readonly")},hasSelectionRange(n){return n.setSelectionRange&&(n.type==="text"||n.type==="textarea")},restoreFocus(n,e,t){if(n instanceof HTMLSelectElement&&n.focus(),!Pe.isTextualInput(n))return;n.matches(":focus")||n.focus(),this.hasSelectionRange(n)&&n.setSelectionRange(e,t)},isFormInput(n){return n.localName&&customElements.get(n.localName)?customElements.get(n.localName).formAssociated:/^(?:input|select|textarea)$/i.test(n.tagName)&&n.type!=="button"},syncAttrsToProps(n){n instanceof HTMLInputElement&&ft.indexOf(n.type.toLocaleLowerCase())>=0&&(n.checked=n.getAttribute("checked")!==null)},isTextualInput(n){return ei.indexOf(n.type)>=0},isNowTriggerFormExternal(n,e){return n.getAttribute&&n.getAttribute(e)!==null&&document.body.contains(n)},cleanChildNodes(n,e){if(Pe.isPhxUpdate(n,e,["append","prepend",Fe])){let t=[];n.childNodes.forEach(i=>{i.id||(!(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()==="")&&i.nodeType!==Node.COMMENT_NODE&&k(`only HTML element tags with an id are allowed inside containers with phx-update.
5
5
 
6
6
  removing illegal node: "${(i.outerHTML||i.nodeValue).trim()}"
7
7
 
8
- `),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(n,e,t){let i=new Set(["id",V,ne,He,z]);if(n.tagName.toLowerCase()===e.toLowerCase())return Array.from(n.attributes).filter(s=>!i.has(s.name.toLowerCase())).forEach(s=>n.removeAttribute(s.name)),Object.keys(t).filter(s=>!i.has(s.toLowerCase())).forEach(s=>n.setAttribute(s,t[s])),n;{let s=document.createElement(e);return Object.keys(t).forEach(r=>s.setAttribute(r,t[r])),i.forEach(r=>s.setAttribute(r,n.getAttribute(r))),s.innerHTML=n.innerHTML,n.replaceWith(s),s}},getSticky(n,e,t){let i=(Pe.private(n,"sticky")||[]).find(([s])=>e===s);if(i){let[s,r,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(n,e){this.updatePrivate(n,"sticky",[],t=>t.filter(([i,s])=>i!==e))},putSticky(n,e,t){let i=t(n);this.updatePrivate(n,"sticky",[],s=>{let r=s.findIndex(([o])=>e===o);return r>=0?s[r]=[e,t,i]:s.push([e,t,i]),s})},applyStickyOperations(n){let e=Pe.private(n,"sticky");e&&e.forEach(([t,i,s])=>this.putSticky(n,t,i))},isLocked(n){return n.hasAttribute&&n.hasAttribute(R)}},h=Pe;var he=class{static isActive(e,t){let i=t._phxRef===void 0,r=e.getAttribute(We).split(",").indexOf(x.genFileRef(t))>=0;return t.size>0&&(i||r)}static isPreflighted(e,t){return e.getAttribute(Ie).split(",").indexOf(x.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,s){this.ref=x.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(Le,this._onElUpdated),this.autoUpload=s}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,()=>{x.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(Le,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||x.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Le,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(We).split(",").indexOf(this.ref)===-1&&(x.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||k(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:gi}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||k(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var $i=0,x=class n{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=($i++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(r=>this.genFileRef(r)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(Ie)!==i.getAttribute(Qt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let r={path:e.name},o=e.getAttribute(K);i[o]=i[o]||[],r.ref=this.genFileRef(s),r.last_modified=s.lastModified,r.name=s.name||r.ref,r.relative_path=s.webkitRelativePath,r.type=s.type,r.size=s.size,typeof s.meta=="function"&&(r.meta=s.meta()),i[o].push(r)}),i}static clearFiles(e){e.value=null,e.removeAttribute(K),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let s=t.filter(r=>!this.activeFiles(e).find(o=>Object.is(o,r)));h.updatePrivate(e,"files",[],r=>r.concat(s)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>he.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!he.isPreflighted(e,t)&&!he.isPreflightInProgress(t))}static markPreflightInProgress(e){e.forEach(t=>he.markPreflightInProgress(t.file))}constructor(e,t,i){this.autoUpload=h.isAutoUpload(e),this.view=t,this.onComplete=i,this._entries=Array.from(n.filesAwaitingPreflight(e)||[]).map(s=>new he(e,s,t,this.autoUpload)),n.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}isAutoUpload(){return this.autoUpload}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(r=>(r.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(r.zipPostFlight(e),r.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),r));let s=this._entries.reduce((r,o)=>{if(!o.meta)return r;let{name:a,callback:l}=o.uploader(i.uploaders);return r[a]=r[a]||{callback:l,entries:[]},r[a].entries.push(o),r},{});for(let r in s){let{callback:o,entries:a}=s[r];o(a,t,e,i)}}};var Bi={anyOf(n,e){return e.find(t=>n instanceof t)},isFocusable(n,e){return n instanceof HTMLAnchorElement&&n.rel!=="ignore"||n instanceof HTMLAreaElement&&n.href!==void 0||!n.disabled&&this.anyOf(n,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||n instanceof HTMLIFrameElement||n.tabIndex>=0&&n.getAttribute("aria-hidden")!=="true"||!e&&n.getAttribute("tabindex")!==null&&n.getAttribute("aria-hidden")!=="true"},attemptFocus(n,e){if(this.isFocusable(n,e))try{n.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(n)},focusFirstInteractive(n){let e=n.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e))return!0;e=e.nextElementSibling}},focusFirst(n){let e=n.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(n){let e=n.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},$=Bi;var Ei={LiveFileUpload:{activeRefs(){return this.el.getAttribute(We)},preflightedRefs(){return this.el.getAttribute(Ie)},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(Le))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(K)),x.getEntryDataURL(this.inputEl,this.ref,n=>{this.url=n,this.el.src=n})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",n=>{if(!n.relatedTarget||!this.el.contains(n.relatedTarget)){let e=n.target.nextElementSibling;$.attemptFocus(e)||$.focusFirst(e)}else $.focusLast(this.el)}),this.focusEnd.addEventListener("focus",n=>{if(!n.relatedTarget||!this.el.contains(n.relatedTarget)){let e=n.target.previousElementSibling;$.attemptFocus(e)||$.focusLast(e)}else $.focusFirst(this.el)}),this.el.contains(document.activeElement)||(this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&$.focusFirst(this.el))}}},Ai=n=>["HTML","BODY"].indexOf(n.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(n).overflowY)>=0?n:Ai(n.parentElement),vi=n=>n?n.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,$t=n=>n?n.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,Bt=n=>n?n.getBoundingClientRect().top:0,Vi=(n,e)=>{let t=n.getBoundingClientRect();return Math.ceil(t.top)>=Bt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=$t(e)},ji=(n,e)=>{let t=n.getBoundingClientRect();return Math.ceil(t.bottom)>=Bt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.bottom)<=$t(e)},bi=(n,e)=>{let t=n.getBoundingClientRect();return Math.ceil(t.top)>=Bt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=$t(e)};Ei.InfiniteScroll={mounted(){this.scrollContainer=Ai(this.el);let n=vi(this.scrollContainer),e=!1,t=500,i=null,s=this.throttle(t,(a,l)=>{i=()=>!0,this.liveSocket.js().push(this.el,a,{value:{id:l.id,_overran:!0},callback:()=>{i=null}})}),r=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"start"}),this.liveSocket.js().push(this.el,a,{value:{id:l.id},callback:()=>{i=null,window.requestAnimationFrame(()=>{bi(l,this.scrollContainer)||l.scrollIntoView({block:"start"})})}})}),o=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"end"}),this.liveSocket.js().push(this.el,a,{value:{id:l.id},callback:()=>{i=null,window.requestAnimationFrame(()=>{bi(l,this.scrollContainer)||l.scrollIntoView({block:"end"})})}})});this.onScroll=a=>{let l=vi(this.scrollContainer);if(i)return n=l,i();let c=this.el.getBoundingClientRect(),u=this.el.getAttribute(this.liveSocket.binding("viewport-top")),p=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),m=this.el.lastElementChild,g=this.el.firstElementChild,d=l<n,v=l>n;d&&u&&!e&&c.top>=0?(e=!0,s(u,g)):v&&e&&c.top<=0&&(e=!1),u&&d&&Vi(g,this.scrollContainer)?r(u,g):p&&v&&ji(m,this.scrollContainer)&&o(p,m),n=l},this.scrollContainer?this.scrollContainer.addEventListener("scroll",this.onScroll):window.addEventListener("scroll",this.onScroll)},destroyed(){this.scrollContainer?this.scrollContainer.removeEventListener("scroll",this.onScroll):window.removeEventListener("scroll",this.onScroll)},throttle(n,e){let t=0,i;return(...s)=>{let r=Date.now(),o=n-(r-t);o<=0||o>n?(i&&(clearTimeout(i),i=null),t=r,e(...s)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...s)},o))}}};var yi=Ei;var ge=class{static onUnlock(e,t){if(!h.isLocked(e)&&!e.closest(`[${R}]`))return t();let i=e.closest(`[${R}]`),s=i.closest(`[${R}]`).getAttribute(R);i.addEventListener(`phx:undo-lock:${s}`,()=>{t()},{once:!0})}constructor(e){this.el=e,this.loadingRef=e.hasAttribute(ue)?parseInt(e.getAttribute(ue),10):null,this.lockRef=e.hasAttribute(R)?parseInt(e.getAttribute(R),10):null}maybeUndo(e,t,i){if(!this.isWithin(e)){h.updatePrivate(this.el,kt,[],s=>(s.push(e),s));return}this.undoLocks(e,t,i),this.undoLoading(e,t),h.updatePrivate(this.el,kt,[],s=>s.filter(r=>{let o={detail:{ref:r,event:t},bubbles:!0,cancelable:!1};return this.loadingRef&&this.loadingRef>r&&this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${r}`,o)),this.lockRef&&this.lockRef>r&&this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${r}`,o)),r>e})),this.isFullyResolvedBy(e)&&this.el.removeAttribute(N)}isWithin(e){return!(this.loadingRef!==null&&this.loadingRef>e&&this.lockRef!==null&&this.lockRef>e)}undoLocks(e,t,i){if(!this.isLockUndoneBy(e))return;let s=h.private(this.el,R);s&&(i(s),h.deletePrivate(this.el,R)),this.el.removeAttribute(R);let r={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,r))}undoLoading(e,t){if(!this.isLoadingUndoneBy(e)){this.canUndoLoading(e)&&this.el.classList.contains("phx-submit-loading")&&this.el.classList.remove("phx-change-loading");return}if(this.canUndoLoading(e)){this.el.removeAttribute(ue);let i=this.el.getAttribute(pe),s=this.el.getAttribute(ze);s!==null&&(this.el.readOnly=s==="true",this.el.removeAttribute(ze)),i!==null&&(this.el.disabled=i==="true",this.el.removeAttribute(pe));let r=this.el.getAttribute(De);r!==null&&(this.el.innerText=r,this.el.removeAttribute(De));let o={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,o))}at.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(e))&&h.removeClass(this.el,i)})}isLoadingUndoneBy(e){return this.loadingRef===null?!1:this.loadingRef<=e}isLockUndoneBy(e){return this.lockRef===null?!1:this.lockRef<=e}isFullyResolvedBy(e){return(this.loadingRef===null||this.loadingRef<=e)&&(this.lockRef===null||this.lockRef<=e)}canUndoLoading(e){return this.lockRef===null||this.lockRef<=e}};var et=class{constructor(e,t,i){let s=new Set,r=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(s.add(a.id),r.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...r].filter(a=>!s.has(a))}perform(){let e=h.byId(this.containerId);e&&(this.elementsToModify.forEach(t=>{t.previousElementId?re(document.getElementById(t.previousElementId),i=>{re(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):re(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{re(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))}))}};var Si=11;function Ji(n,e){var t=e.attributes,i,s,r,o,a;if(!(e.nodeType===Si||n.nodeType===Si)){for(var l=t.length-1;l>=0;l--)i=t[l],s=i.name,r=i.namespaceURI,o=i.value,r?(s=i.localName||s,a=n.getAttributeNS(r,s),a!==o&&(i.prefix==="xmlns"&&(s=i.name),n.setAttributeNS(r,s,o))):(a=n.getAttribute(s),a!==o&&n.setAttribute(s,o));for(var c=n.attributes,u=c.length-1;u>=0;u--)i=c[u],s=i.name,r=i.namespaceURI,r?(s=i.localName||s,e.hasAttributeNS(r,s)||n.removeAttributeNS(r,s)):e.hasAttribute(s)||n.removeAttribute(s)}}var bt,Wi="http://www.w3.org/1999/xhtml",j=typeof document=="undefined"?void 0:document,qi=!!j&&"content"in j.createElement("template"),Ki=!!j&&j.createRange&&"createContextualFragment"in j.createRange();function Gi(n){var e=j.createElement("template");return e.innerHTML=n,e.content.childNodes[0]}function zi(n){bt||(bt=j.createRange(),bt.selectNode(j.body));var e=bt.createContextualFragment(n);return e.childNodes[0]}function Yi(n){var e=j.createElement("body");return e.innerHTML=n,e.childNodes[0]}function Qi(n){return n=n.trim(),qi?Gi(n):Ki?zi(n):Yi(n)}function Et(n,e){var t=n.nodeName,i=e.nodeName,s,r;return t===i?!0:(s=t.charCodeAt(0),r=i.charCodeAt(0),s<=90&&r>=97?t===i.toUpperCase():r<=90&&s>=97?i===t.toUpperCase():!1)}function Zi(n,e){return!e||e===Wi?j.createElement(n):j.createElementNS(e,n)}function es(n,e){for(var t=n.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Vt(n,e,t){n[t]!==e[t]&&(n[t]=e[t],n[t]?n.setAttribute(t,""):n.removeAttribute(t))}var _i={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)}Vt(n,e,"selected")},INPUT:function(n,e){Vt(n,e,"checked"),Vt(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 s=i.nodeValue;if(s==t||!t&&s==n.placeholder)return;i.nodeValue=t}},SELECT:function(n,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,s=n.firstChild,r,o;s;)if(o=s.nodeName&&s.nodeName.toUpperCase(),o==="OPTGROUP")r=s,s=r.firstChild,s||(s=r.nextSibling,r=null);else{if(o==="OPTION"){if(s.hasAttribute("selected")){t=i;break}i++}s=s.nextSibling,!s&&r&&(s=r.nextSibling,r=null)}n.selectedIndex=t}}},tt=1,wi=11,ki=3,Pi=8;function ve(){}function ts(n){if(n)return n.getAttribute&&n.getAttribute("id")||n.id}function is(n){return function(t,i,s){if(s||(s={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var r=i;i=j.createElement("html"),i.innerHTML=r}else i=Qi(i);else i.nodeType===wi&&(i=i.firstElementChild);var o=s.getNodeKey||ts,a=s.onBeforeNodeAdded||ve,l=s.onNodeAdded||ve,c=s.onBeforeElUpdated||ve,u=s.onElUpdated||ve,p=s.onBeforeNodeDiscarded||ve,m=s.onNodeDiscarded||ve,g=s.onBeforeElChildrenUpdated||ve,d=s.skipFromChildren||ve,v=s.addChild||function(A,y){return A.appendChild(y)},E=s.childrenOnly===!0,D=Object.create(null),X=[];function B(A){X.push(A)}function S(A,y){if(A.nodeType===tt)for(var L=A.firstChild;L;){var w=void 0;y&&(w=o(L))?B(w):(m(L),L.firstChild&&S(L,y)),L=L.nextSibling}}function T(A,y,L){p(A)!==!1&&(y&&y.removeChild(A),m(A),S(A,L))}function M(A){if(A.nodeType===tt||A.nodeType===wi)for(var y=A.firstChild;y;){var L=o(y);L&&(D[L]=y),M(y),y=y.nextSibling}}M(t);function Z(A){l(A);for(var y=A.firstChild;y;){var L=y.nextSibling,w=o(y);if(w){var P=D[w];P&&Et(y,P)?(y.parentNode.replaceChild(P,y),b(P,y)):Z(y)}else Z(y);y=L}}function f(A,y,L){for(;y;){var w=y.nextSibling;(L=o(y))?B(L):T(y,A,!0),y=w}}function b(A,y,L){var w=o(y);if(w&&delete D[w],!L){var P=c(A,y);if(P===!1||(P instanceof HTMLElement&&(A=P,M(A)),n(A,y),u(A),g(A,y)===!1))return}A.nodeName!=="TEXTAREA"?J(A,y):_i.TEXTAREA(A,y)}function J(A,y){var L=d(A,y),w=y.firstChild,P=A.firstChild,Ce,oe,xe,st,ce;e:for(;w;){for(st=w.nextSibling,Ce=o(w);!L&&P;){if(xe=P.nextSibling,w.isSameNode&&w.isSameNode(P)){w=st,P=xe;continue e}oe=o(P);var nt=P.nodeType,de=void 0;if(nt===w.nodeType&&(nt===tt?(Ce?Ce!==oe&&((ce=D[Ce])?xe===ce?de=!1:(A.insertBefore(ce,P),oe?B(oe):T(P,A,!0),P=ce,oe=o(P)):de=!1):oe&&(de=!1),de=de!==!1&&Et(P,w),de&&b(P,w)):(nt===ki||nt==Pi)&&(de=!0,P.nodeValue!==w.nodeValue&&(P.nodeValue=w.nodeValue))),de){w=st,P=xe;continue e}oe?B(oe):T(P,A,!0),P=xe}if(Ce&&(ce=D[Ce])&&Et(ce,w))L||v(A,ce),b(ce,w);else{var wt=a(w);wt!==!1&&(wt&&(w=wt),w.actualize&&(w=w.actualize(A.ownerDocument||j)),v(A,w),Z(w))}w=st,P=xe}f(A,P,oe);var Wt=_i[A.nodeName];Wt&&Wt(A,y)}var C=t,O=C.nodeType,Ee=i.nodeType;if(!E){if(O===tt)Ee===tt?Et(t,i)||(m(t),C=es(t,Zi(i.nodeName,i.namespaceURI))):C=i;else if(O===ki||O===Pi){if(Ee===O)return C.nodeValue!==i.nodeValue&&(C.nodeValue=i.nodeValue),C;C=i}}if(C===i)m(t);else{if(i.isSameNode&&i.isSameNode(C))return;if(b(C,i,E),X)for(var W=0,Ii=X.length;W<Ii;W++){var _t=D[X[W]];_t&&T(_t,_t.parentNode,!1)}}return!E&&C!==t&&t.parentNode&&(C.actualize&&(C=C.actualize(t.ownerDocument||j)),t.parentNode.replaceChild(C,t)),C}}var ss=is(Ji),At=ss;var be=class{constructor(e,t,i,s,r,o,a={}){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.streams=r,this.streamInserts={},this.streamComponentRestore={},this.targetCID=o,this.cidPatch=Y(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=this.isCIDPatch()?this.targetCIDContainer(s):t,this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]},this.withChildren=a.withChildren||a.undoRef||!1,this.undoRef=a.undoRef}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(){let e=this.liveSocket.binding(Me);h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(Tt,"")})}perform(e){let{view:t,liveSocket:i,html:s,container:r,targetContainer:o}=this;if(this.isCIDPatch()&&!o)return;let a=i.getActiveElement(),{selectionStart:l,selectionEnd:c}=a&&h.hasSelectionRange(a)?a:{},u=i.binding(Me),p=i.binding(qe),m=i.binding(Ke),g=i.binding(Zt),d=[],v=[],E=[],D=[],X=null,B=(S,T,M=this.withChildren)=>{let Z={childrenOnly:S.getAttribute(q)===null&&!M,getNodeKey:f=>h.isPhxDestroyed(f)?null:e?f.id:f.id||f.getAttribute&&f.getAttribute(dt),skipFromChildren:f=>f.getAttribute(u)===Fe,addChild:(f,b)=>{let{ref:J,streamAt:C}=this.getStreamInsert(b);if(J===void 0)return f.appendChild(b);if(this.setStreamRef(b,J),C===0)f.insertAdjacentElement("afterbegin",b);else if(C===-1){let O=f.lastElementChild;if(O&&!O.hasAttribute(Ue)){let Ee=Array.from(f.children).find(W=>!W.hasAttribute(Ue));f.insertBefore(b,Ee)}else f.appendChild(b)}else if(C>0){let O=Array.from(f.children)[C];f.insertBefore(b,O)}},onBeforeNodeAdded:f=>{var J;if((J=this.getStreamInsert(f))!=null&&J.updateOnly&&!this.streamComponentRestore[f.id])return!1;h.maintainPrivateHooks(f,f,p,m),this.trackBefore("added",f);let b=f;return this.streamComponentRestore[f.id]&&(b=this.streamComponentRestore[f.id],delete this.streamComponentRestore[f.id],B(b,f,!0)),b},onNodeAdded:f=>{f.getAttribute&&this.maybeReOrderStream(f,!0),h.isPortalTemplate(f)&&D.push(()=>this.teleport(f,B)),f instanceof HTMLImageElement&&f.srcset?f.srcset=f.srcset:f instanceof HTMLVideoElement&&f.autoplay&&f.play(),h.isNowTriggerFormExternal(f,g)&&(X=f),(h.isPhxChild(f)&&t.ownsElement(f)||h.isPhxSticky(f)&&t.ownsElement(f.parentNode))&&this.trackAfter("phxChildAdded",f),f.nodeName==="SCRIPT"&&f.hasAttribute(Xe)&&this.handleRuntimeHook(f,T),d.push(f)},onNodeDiscarded:f=>this.onNodeDiscarded(f),onBeforeNodeDiscarded:f=>{if(f.getAttribute&&f.getAttribute(Tt)!==null)return!0;if(f.parentElement!==null&&f.id&&h.isPhxUpdate(f.parentElement,u,[Fe,"append","prepend"])||f.getAttribute&&f.getAttribute(me)||this.maybePendingRemove(f)||this.skipCIDSibling(f))return!1;if(h.isPortalTemplate(f)){let b=document.getElementById(f.content.firstElementChild.id);b&&(b.remove(),Z.onNodeDiscarded(b),this.view.dropPortalElementId(b.id))}return!0},onElUpdated:f=>{h.isNowTriggerFormExternal(f,g)&&(X=f),v.push(f),this.maybeReOrderStream(f,!1)},onBeforeElUpdated:(f,b)=>{if(f.id&&f.isSameNode(S)&&f.id!==b.id)return Z.onNodeDiscarded(f),f.replaceWith(b),Z.onNodeAdded(b);if(h.syncPendingAttrs(f,b),h.maintainPrivateHooks(f,b,p,m),h.cleanChildNodes(b,u),this.skipCIDSibling(b))return this.maybeReOrderStream(f),!1;if(h.isPhxSticky(f))return[V,ne,z].map(O=>[O,f.getAttribute(O),b.getAttribute(O)]).forEach(([O,Ee,W])=>{W&&Ee!==W&&f.setAttribute(O,W)}),!1;if(h.isIgnored(f,u)||f.form&&f.form.isSameNode(X))return this.trackBefore("updated",f,b),h.mergeAttrs(f,b,{isIgnored:h.isIgnored(f,u)}),v.push(f),h.applyStickyOperations(f),!1;if(f.type==="number"&&f.validity&&f.validity.badInput)return!1;let J=a&&f.isSameNode(a)&&h.isFormInput(f),C=J&&this.isChangedSelect(f,b);if(f.hasAttribute(N)){let O=new ge(f);if(O.lockRef&&(!this.undoRef||!O.isLockUndoneBy(this.undoRef))){h.isUploadInput(f)&&(h.mergeAttrs(f,b,{isIgnored:!0}),this.trackBefore("updated",f,b),v.push(f)),h.applyStickyOperations(f);let W=f.hasAttribute(R)?h.private(f,R)||f.cloneNode(!0):null;W&&(h.putPrivate(f,R,W),J||(f=W))}}if(h.isPhxChild(b)){let O=f.getAttribute(V);return h.mergeAttrs(f,b,{exclude:[ne]}),O!==""&&f.setAttribute(V,O),f.setAttribute(z,this.rootID),h.applyStickyOperations(f),!1}return this.undoRef&&h.private(b,R)&&h.putPrivate(f,R,h.private(b,R)),h.copyPrivates(b,f),h.isPortalTemplate(b)?(D.push(()=>this.teleport(b,B)),!1):J&&f.type!=="hidden"&&!C?(this.trackBefore("updated",f,b),h.mergeFocusedInput(f,b),h.syncAttrsToProps(f),v.push(f),h.applyStickyOperations(f),!1):(C&&f.blur(),h.isPhxUpdate(b,u,["append","prepend"])&&E.push(new et(f,b,b.getAttribute(u))),h.syncAttrsToProps(b),h.applyStickyOperations(b),this.trackBefore("updated",f,b),f)}};At(S,T,Z)};if(this.trackBefore("added",r),this.trackBefore("updated",r,r),i.time("morphdom",()=>{this.streams.forEach(([S,T,M,Z])=>{T.forEach(([f,b,J,C])=>{this.streamInserts[f]={ref:S,streamAt:b,limit:J,reset:Z,updateOnly:C}}),Z!==void 0&&h.all(r,`[${Ue}="${S}"]`,f=>{this.removeStreamChildElement(f)}),M.forEach(f=>{let b=r.querySelector(`[id="${f}"]`);b&&this.removeStreamChildElement(b)})}),e&&h.all(this.container,`[${u}=${Fe}]`).filter(S=>this.view.ownsElement(S)).forEach(S=>{Array.from(S.children).forEach(T=>{this.removeStreamChildElement(T,!0)})}),B(o,s),D.forEach(S=>S()),this.view.portalElementIds.forEach(S=>{let T=document.getElementById(S);T&&(document.getElementById(T.getAttribute(pt))||(T.remove(),this.onNodeDiscarded(T),this.view.dropPortalElementId(S)))})}),i.isDebugEnabled()&&(ui(),fi(this.streamInserts),Array.from(document.querySelectorAll("input[name=id]")).forEach(S=>{S instanceof HTMLInputElement&&S.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
9
- `,S)})),E.length>0&&i.time("post-morph append/prepend restoration",()=>{E.forEach(S=>S.perform())}),i.silenceEvents(()=>h.restoreFocus(a,l,c)),h.dispatchEvent(document,"phx:update"),d.forEach(S=>this.trackAfter("added",S)),v.forEach(S=>this.trackAfter("updated",S)),this.transitionPendingRemoves(),X){i.unload();let S=h.private(X,"submitter");if(S&&S.name&&o.contains(S)){let T=document.createElement("input");T.type="hidden";let M=S.getAttribute("form");M&&T.setAttribute("form",M),T.name=S.name,T.value=S.value,S.parentElement.insertBefore(T,S)}Object.getPrototypeOf(X).submit.call(X)}return!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e,t=!1){!t&&!this.view.ownsElement(e)||(this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e)))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,t){h.putSticky(e,Ue,i=>i.setAttribute(Ue,t))}maybeReOrderStream(e,t){let{ref:i,streamAt:s,reset:r}=this.getStreamInsert(e);if(s!==void 0&&(this.setStreamRef(e,i),!(!r&&!t)&&e.parentElement)){if(s===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(s>0){let o=Array.from(e.parentElement.children),a=o.indexOf(e);if(s>=o.length-1)e.parentElement.appendChild(e);else{let l=o[s];a>s?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:t}=this.getStreamInsert(e),i=t!==null&&Array.from(e.parentElement.children);t&&t<0&&i.length>t*-1?i.slice(0,i.length+t).forEach(s=>this.removeStreamChildElement(s)):t&&t>=0&&i.length>t&&i.slice(t).forEach(s=>this.removeStreamChildElement(s))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&t.transitionRemoves(e,()=>{e.forEach(i=>{let s=h.firstPhxChild(i);s&&t.destroyViewByEl(s),i.remove()}),this.trackAfter("transitionsDiscarded",e)})}isChangedSelect(e,t){return!(e instanceof HTMLSelectElement)||e.multiple?!1:e.options.length!==t.options.length?!0:(t.value=e.value,!e.isEqualNode(t))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(ct)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.view.id,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}indexOf(e,t){return Array.from(e.children).indexOf(t)}teleport(e,t){let i=e.getAttribute(ft),s=document.querySelector(i);if(!s)throw new Error("portal target with selector "+i+" not found");let r=e.content.firstElementChild;if(this.skipCIDSibling(r))return;if(!(r!=null&&r.id))throw new Error("phx-portal template must have a single root element with ID!");let o=document.getElementById(r.id),a;o?(s.contains(o)||s.appendChild(o),a=o):(a=document.createElement(r.tagName),s.appendChild(a)),r.setAttribute(me,this.view.id),r.setAttribute(pt,e.id),t(a,r,!0),r.removeAttribute(me),r.removeAttribute(pt),this.view.pushPortalElementId(r.id)}handleRuntimeHook(e,t){let i=e.getAttribute(Xe),s=e.hasAttribute("nonce")?e.getAttribute("nonce"):null;if(e.hasAttribute("nonce")){let o=document.createElement("template");o.innerHTML=t,s=o.content.querySelector(`script[${Xe}="${CSS.escape(i)}"]`).getAttribute("nonce")}let r=document.createElement("script");r.textContent=e.textContent,h.mergeAttrs(r,e,{isIgnored:!1}),s&&(r.nonce=s),e.replaceWith(r),e=r}};var ns=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),rs=new Set(["'",'"']),Ti=(n,e,t)=>{let i=0,s=!1,r,o,a,l,c,u,p=n.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${n}`);for(i=p[0].length,r=p[1],a=p[2],l=i,i;i<n.length&&n.charAt(i)!==">";i++)if(n.charAt(i)==="="){let d=n.slice(i-3,i)===" id";i++;let v=n.charAt(i);if(rs.has(v)){let E=i;for(i++,i;i<n.length&&n.charAt(i)!==v;i++);if(d){c=n.slice(E+1,i);break}}}let m=n.length-1;for(s=!1;m>=r.length+a.length;){let d=n.charAt(m);if(s)d==="-"&&n.slice(m-3,m)==="<!-"?(s=!1,m-=4):m-=1;else if(d===">"&&n.slice(m-2,m)==="--")s=!0,m-=3;else{if(d===">")break;m-=1}}o=n.slice(m+1,n.length);let g=Object.keys(e).map(d=>e[d]===!0?d:`${d}="${e[d]}"`).join(" ");if(t){let d=c?` id="${c}"`:"";ns.has(a)?u=`<${a}${d}${g===""?"":" "}${g}/>`:u=`<${a}${d}${g===""?"":" "}${g}></${a}>`}else{let d=n.slice(l,m+1);u=`<${a}${g===""?"":" "}${g}${d}`}return[u,r,o]},Je=class{static extract(e){let{[Ft]:t,[Mt]:i,[Ut]:s}=e;return delete e[Ft],delete e[Mt],delete e[Ut],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let{buffer:t,streams:i}=this.recursiveToString(this.rendered,this.rendered[F],e,!0,{});return{buffer:t,streams:i}}recursiveToString(e,t=e[F],i,s,r){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,s,r),{buffer:o.buffer,streams:o.streams}}componentCIDs(e){return Object.keys(e[F]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[F]?Object.keys(e).length===1:!1}getComponent(e,t){return e[F][t]}resetRender(e){this.rendered[F][e]&&(this.rendered[F][e].reset=!0)}mergeDiff(e){let t=e[F],i={};if(delete e[F],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[F]=this.rendered[F]||{},t){let s=this.rendered[F];for(let r in t)t[r]=this.cachedFindComponent(r,t[r],s,t,i);for(let r in t)s[r]=t[r];e[F]=t}}cachedFindComponent(e,t,i,s,r){if(r[e])return r[e];{let o,a,l=t[G];if(Y(l)){let c;l>0?c=this.cachedFindComponent(l,s[l],i,s,r):c=i[-l],a=c[G],o=this.cloneMerge(c,t,!0),o[G]=a}else o=t[G]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return r[e]=o,o}}mutableMerge(e,t){return t[G]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){if(t[I])this.mergeKeyed(e,t);else for(let i in t){let s=t[i],r=e[i];ke(s)&&s[G]===void 0&&ke(r)?this.doMutableMerge(r,s):e[i]=s}e[vt]&&(e.newRender=!0)}clone(e){return"structuredClone"in window?structuredClone(e):JSON.parse(JSON.stringify(e))}mergeKeyed(e,t){let i=this.clone(e);if(Object.entries(t[I]).forEach(([s,r])=>{if(s!==te)if(Array.isArray(r)){let[o,a]=r;e[I][s]=i[I][o],this.doMutableMerge(e[I][s],a)}else if(typeof r=="number"){let o=r;e[I][s]=i[I][o]}else typeof r=="object"&&(e[I][s]||(e[I][s]={}),this.doMutableMerge(e[I][s],r))}),t[I][te]<e[I][te])for(let s=t[I][te];s<e[I][te];s++)delete e[I][s];e[I][te]=t[I][te],t[_e]&&(e[_e]=t[_e]),t[le]&&(e[le]=t[le])}cloneMerge(e,t,i){let s=H(H({},e),t);for(let r in s){let o=t[r],a=e[r];ke(o)&&o[G]===void 0&&ke(a)?s[r]=this.cloneMerge(a,o,i):o===void 0&&ke(a)&&(s[r]=this.cloneMerge(a,{},i))}return i?(delete s.magicId,delete s.newRender):e[vt]&&(s.newRender=!0),s}componentToString(e){let{buffer:t,streams:i}=this.recursiveCIDToString(this.rendered[F],e,null),[s,r,o]=Ti(t,{});return{buffer:s,streams:i}}pruneCIDs(e){e.forEach(t=>delete this.rendered[F][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[G]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,t,i,s,r={}){if(e[I])return this.comprehensionToBuffer(e,t,i,s);e[le]&&(t=e[le],delete e[le]);let{[G]:o}=e;o=this.templateStatic(o,t),e[G]=o;let a=e[vt],l=i.buffer;a&&(i.buffer=""),s&&a&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let c=1;c<o.length;c++)this.dynamicToBuffer(e[c-1],t,i,s),i.buffer+=o[c];if(a){let c=!1,u;s||e.magicId?(c=s&&!e.newRender,u=H({[dt]:e.magicId},r)):u=r,c&&(u[ct]=!0);let[p,m,g]=Ti(i.buffer,u,c);e.newRender=!1,i.buffer=l+m+p+g}}comprehensionToBuffer(e,t,i,s){let r=t||e[le],o=this.templateStatic(e[G],t);e[G]=o,delete e[le];for(let a=0;a<e[I][te];a++){i.buffer+=o[0];for(let l=1;l<o.length;l++)this.dynamicToBuffer(e[I][a][l-1],r,i,s),i.buffer+=o[l]}if(e[_e]){let a=e[_e],[l,c,u,p]=a||[null,{},[],null];a!==void 0&&(e[I][te]>0||u.length>0||p)&&(delete e[_e],e[I]={[te]:0},i.streams.add(a))}}dynamicToBuffer(e,t,i,s){if(typeof e=="number"){let{buffer:r,streams:o}=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=r,i.streams=new Set([...i.streams,...o])}else ke(e)?this.toOutputBuffer(e,t,i,s,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||k(`no component for CID ${t}`,e),r={[q]:t,[Re]:this.viewId},o=i&&!i.has(t);s.newRender=!o,s.magicId=`c${t}-${this.parentViewId()}`;let a=!s.reset,{buffer:l,streams:c}=this.recursiveToString(s,e,i,a,r);return delete s.reset,{buffer:l,streams:c}}};var Ci=[],xi=200,os={exec(n,e,t,i,s,r){let[o,a]=r||[null,{callback:r&&r.callback}];(t.charAt(0)==="["?JSON.parse(t):[[o,a]]).forEach(([c,u])=>{c===o&&(u=H(H({},a),u),u.callback=u.callback||a.callback),this.filterToEls(i.liveSocket,s,u).forEach(p=>{this[`exec_${c}`](n,e,t,i,s,p,u)})})},isVisible(n){return!!(n.offsetWidth||n.offsetHeight||n.getClientRects().length>0)},isInViewport(n){let e=n.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth;return e.right>0&&e.bottom>0&&e.left<i&&e.top<t},exec_exec(n,e,t,i,s,r,{attr:o,to:a}){let l=r.getAttribute(o);if(!l)throw new Error(`expected ${o} to contain JS command on "${a}"`);i.liveSocket.execJS(r,l,e)},exec_dispatch(n,e,t,i,s,r,{event:o,detail:a,bubbles:l,blocking:c}){if(a=a||{},a.dispatcher=s,c){let u=new Promise((p,m)=>{a.done=p});i.liveSocket.asyncTransition(u)}h.dispatchEvent(r,o,{detail:a,bubbles:l})},exec_push(n,e,t,i,s,r,o){let{event:a,data:l,target:c,page_loading:u,loading:p,value:m,dispatcher:g,callback:d}=o,v={loading:p,value:m,target:c,page_loading:!!u,originalEvent:n},E=e==="change"&&g?g:s,D=c||E.getAttribute(i.binding("target"))||E,X=(B,S)=>{if(B.isConnected())if(e==="change"){let{newCid:T,_target:M}=o;M=M||(h.isFormInput(s)?s.name:void 0),M&&(v._target=M),B.pushInput(s,S,T,a||t,v,d)}else if(e==="submit"){let{submitter:T}=o;B.submitForm(s,S,a||t,T,v,d)}else B.pushEvent(e,s,S,a||t,l,v,d)};o.targetView&&o.targetCtx?X(o.targetView,o.targetCtx):i.withinTargets(D,X)},exec_navigate(n,e,t,i,s,r,{href:o,replace:a}){i.liveSocket.historyRedirect(n,o,a?"replace":"push",null,s)},exec_patch(n,e,t,i,s,r,{href:o,replace:a}){i.liveSocket.pushHistoryPatch(n,o,a?"replace":"push",s)},exec_focus(n,e,t,i,s,r){$.attemptFocus(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>$.attemptFocus(r))})},exec_focus_first(n,e,t,i,s,r){$.focusFirstInteractive(r)||$.focusFirst(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>$.focusFirstInteractive(r)||$.focusFirst(r))})},exec_push_focus(n,e,t,i,s,r){Ci.push(r||s)},exec_pop_focus(n,e,t,i,s,r){let o=Ci.pop();o&&(o.focus(),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o.focus())}))},exec_add_class(n,e,t,i,s,r,{names:o,transition:a,time:l,blocking:c}){this.addOrRemoveClasses(r,o,[],a,l,i,c)},exec_remove_class(n,e,t,i,s,r,{names:o,transition:a,time:l,blocking:c}){this.addOrRemoveClasses(r,[],o,a,l,i,c)},exec_toggle_class(n,e,t,i,s,r,{names:o,transition:a,time:l,blocking:c}){this.toggleClasses(r,o,a,l,i,c)},exec_toggle_attr(n,e,t,i,s,r,{attr:[o,a,l]}){this.toggleAttr(r,o,a,l)},exec_ignore_attrs(n,e,t,i,s,r,{attrs:o}){this.ignoreAttrs(r,o)},exec_transition(n,e,t,i,s,r,{time:o,transition:a,blocking:l}){this.addOrRemoveClasses(r,[],[],a,o,i,l)},exec_toggle(n,e,t,i,s,r,{display:o,ins:a,outs:l,time:c,blocking:u}){this.toggle(e,i,r,o,a,l,c,u)},exec_show(n,e,t,i,s,r,{display:o,transition:a,time:l,blocking:c}){this.show(e,i,r,o,a,l,c)},exec_hide(n,e,t,i,s,r,{display:o,transition:a,time:l,blocking:c}){this.hide(e,i,r,o,a,l,c)},exec_set_attr(n,e,t,i,s,r,{attr:[o,a]}){this.setOrRemoveAttrs(r,[[o,a]],[])},exec_remove_attr(n,e,t,i,s,r,{attr:o}){this.setOrRemoveAttrs(r,[],[o])},ignoreAttrs(n,e){h.putPrivate(n,"JS:ignore_attrs",{apply:(t,i)=>{Array.from(t.attributes).forEach(s=>{e.some(r=>s.name==r||r.includes("*")&&s.name.match(r)!=null)&&i.setAttribute(s.name,s.value)})}})},onBeforeElUpdated(n,e){let t=h.private(n,"JS:ignore_attrs");t&&t.apply(n,e)},show(n,e,t,i,s,r,o){this.isVisible(t)||this.toggle(n,e,t,i,s,null,r,o)},hide(n,e,t,i,s,r,o){this.isVisible(t)&&this.toggle(n,e,t,i,null,s,r,o)},toggle(n,e,t,i,s,r,o,a){o=o||xi;let[l,c,u]=s||[[],[],[]],[p,m,g]=r||[[],[],[]];if(l.length>0||p.length>0)if(this.isVisible(t)){let d=()=>{this.addOrRemoveClasses(t,m,l.concat(c).concat(u)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,g,m))})},v=()=>{this.addOrRemoveClasses(t,[],p.concat(g)),h.putSticky(t,"toggle",E=>E.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))};t.dispatchEvent(new Event("phx:hide-start")),a===!1?(d(),setTimeout(v,o)):e.transition(o,d,v)}else{if(n==="remove")return;let d=()=>{this.addOrRemoveClasses(t,c,p.concat(m).concat(g));let E=i||this.defaultDisplay(t);window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,l,[]),window.requestAnimationFrame(()=>{h.putSticky(t,"toggle",D=>D.style.display=E),this.addOrRemoveClasses(t,u,c)})})},v=()=>{this.addOrRemoveClasses(t,[],l.concat(u)),t.dispatchEvent(new Event("phx:show-end"))};t.dispatchEvent(new Event("phx:show-start")),a===!1?(d(),setTimeout(v,o)):e.transition(o,d,v)}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",d=>d.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let d=i||this.defaultDisplay(t);h.putSticky(t,"toggle",v=>v.style.display=d),t.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(n,e,t,i,s,r){window.requestAnimationFrame(()=>{let[o,a]=h.getSticky(n,"classes",[[],[]]),l=e.filter(u=>o.indexOf(u)<0&&!n.classList.contains(u)),c=e.filter(u=>a.indexOf(u)<0&&n.classList.contains(u));this.addOrRemoveClasses(n,l,c,t,i,s,r)})},toggleAttr(n,e,t,i){n.hasAttribute(e)?i!==void 0?n.getAttribute(e)===t?this.setOrRemoveAttrs(n,[[e,i]],[]):this.setOrRemoveAttrs(n,[[e,t]],[]):this.setOrRemoveAttrs(n,[],[e]):this.setOrRemoveAttrs(n,[[e,t]],[])},addOrRemoveClasses(n,e,t,i,s,r,o){s=s||xi;let[a,l,c]=i||[[],[],[]];if(a.length>0){let u=()=>{this.addOrRemoveClasses(n,l,[].concat(a).concat(c)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(n,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(n,c,l))})},p=()=>this.addOrRemoveClasses(n,e.concat(c),t.concat(a).concat(l));o===!1?(u(),setTimeout(p,s)):r.transition(s,u,p);return}window.requestAnimationFrame(()=>{let[u,p]=h.getSticky(n,"classes",[[],[]]),m=e.filter(E=>u.indexOf(E)<0&&!n.classList.contains(E)),g=t.filter(E=>p.indexOf(E)<0&&n.classList.contains(E)),d=u.filter(E=>t.indexOf(E)<0).concat(m),v=p.filter(E=>e.indexOf(E)<0).concat(g);h.putSticky(n,"classes",E=>(E.classList.remove(...v),E.classList.add(...d),[d,v]))})},setOrRemoveAttrs(n,e,t){let[i,s]=h.getSticky(n,"attrs",[[],[]]),r=e.map(([l,c])=>l).concat(t),o=i.filter(([l,c])=>!r.includes(l)).concat(e),a=s.filter(l=>!r.includes(l)).concat(t);h.putSticky(n,"attrs",l=>(a.forEach(c=>l.removeAttribute(c)),o.forEach(([c,u])=>l.setAttribute(c,u)),[o,a]))},hasAllClasses(n,e){return e.every(t=>n.classList.contains(t))},isToggledOut(n,e){return!this.isVisible(n)||this.hasAllClasses(n,e)},filterToEls(n,e,{to:t}){let i=()=>{if(typeof t=="string")return document.querySelectorAll(t);if(t.closest){let s=e.closest(t.closest);return s?[s]:[]}else if(t.inner)return e.querySelectorAll(t.inner)};return t?n.jsQuerySelectorAll(e,t,i):[e]},defaultDisplay(n){return{tr:"table-row",td:"table-cell"}[n.tagName.toLowerCase()]||"block"},transitionClasses(n){if(!n)return null;let[e,t,i]=Array.isArray(n)?n:[n.split(" "),[],[]];return e=Array.isArray(e)?e:e.split(" "),t=Array.isArray(t)?t:t.split(" "),i=Array.isArray(i)?i:i.split(" "),[e,t,i]}},_=os;var yt=(n,e)=>({exec(t,i){n.execJS(t,i,e)},show(t,i={}){let s=n.owner(t);_.show(e,s,t,i.display,_.transitionClasses(i.transition),i.time,i.blocking)},hide(t,i={}){let s=n.owner(t);_.hide(e,s,t,null,_.transitionClasses(i.transition),i.time,i.blocking)},toggle(t,i={}){let s=n.owner(t),r=_.transitionClasses(i.in),o=_.transitionClasses(i.out);_.toggle(e,s,t,i.display,r,o,i.time,i.blocking)},addClass(t,i,s={}){let r=Array.isArray(i)?i:i.split(" "),o=n.owner(t);_.addOrRemoveClasses(t,r,[],_.transitionClasses(s.transition),s.time,o,s.blocking)},removeClass(t,i,s={}){let r=Array.isArray(i)?i:i.split(" "),o=n.owner(t);_.addOrRemoveClasses(t,[],r,_.transitionClasses(s.transition),s.time,o,s.blocking)},toggleClass(t,i,s={}){let r=Array.isArray(i)?i:i.split(" "),o=n.owner(t);_.toggleClasses(t,r,_.transitionClasses(s.transition),s.time,o,s.blocking)},transition(t,i,s={}){let r=n.owner(t);_.addOrRemoveClasses(t,[],[],_.transitionClasses(i),s.time,r,s.blocking)},setAttribute(t,i,s){_.setOrRemoveAttrs(t,[[i,s]],[])},removeAttribute(t,i){_.setOrRemoveAttrs(t,[],[i])},toggleAttribute(t,i,s,r){_.toggleAttr(t,i,s,r)},push(t,i,s={}){n.withinOwners(t,r=>{let o=s.value||{};delete s.value;let a=new CustomEvent("phx:exec",{detail:{sourceElement:t}});_.exec(a,e,i,r,t,["push",H({data:o},s)])})},navigate(t,i={}){let s=new CustomEvent("phx:exec");n.historyRedirect(s,t,i.replace?"replace":"push",null,null)},patch(t,i={}){let s=new CustomEvent("phx:exec");n.pushHistoryPatch(s,t,i.replace?"replace":"push",null)},ignoreAttributes(t,i){_.ignoreAttrs(t,Array.isArray(i)?i:[i])}});var jt="hookId",as=1,Q=class n{static makeID(){return as++}static elementID(e){return h.private(e,jt)}constructor(e,t,i){if(this.el=t,this.__attachView(e),this.__listeners=new Set,this.__isDisconnected=!1,h.putPrivate(this.el,jt,n.makeID()),i){let s=new Set(["el","liveSocket","__view","__listeners","__isDisconnected","constructor","js","pushEvent","pushEventTo","handleEvent","removeHandleEvent","upload","uploadTo","__mounted","__updated","__beforeUpdate","__destroyed","__reconnected","__disconnected","__cleanup__"]);for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&(this[o]=i[o],s.has(o)&&console.warn(`Hook object for element #${t.id} overwrites core property '${o}'!`));["mounted","beforeUpdate","updated","destroyed","disconnected","reconnected"].forEach(o=>{i[o]&&typeof i[o]=="function"&&(this[o]=i[o])})}}__attachView(e){e?(this.__view=()=>e,this.liveSocket=e.liveSocket):(this.__view=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)},this.liveSocket=null)}mounted(){}beforeUpdate(){}updated(){}destroyed(){}disconnected(){}reconnected(){}__mounted(){this.mounted()}__updated(){this.updated()}__beforeUpdate(){this.beforeUpdate()}__destroyed(){this.destroyed(),h.deletePrivate(this.el,jt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected()}js(){return ae(H({},yt(this.__view().liveSocket,"hook")),{exec:e=>{this.__view().liveSocket.execJS(this.el,e,"hook")}})}pushEvent(e,t,i){let s=this.__view().pushHookEvent(this.el,null,e,t||{});if(i===void 0)return s.then(({reply:r})=>r);s.then(({reply:r,ref:o})=>i(r,o)).catch(()=>{})}pushEventTo(e,t,i,s){if(s===void 0){let r=[];this.__view().withinTargets(e,(a,l)=>{r.push({view:a,targetCtx:l})});let o=r.map(({view:a,targetCtx:l})=>a.pushHookEvent(this.el,l,t,i||{}));return Promise.allSettled(o)}this.__view().withinTargets(e,(r,o)=>{r.pushHookEvent(this.el,o,t,i||{}).then(({reply:a,ref:l})=>s(a,l)).catch(()=>{})})}handleEvent(e,t){let i={event:e,callback:s=>t(s.detail)};return window.addEventListener(`phx:${e}`,i.callback),this.__listeners.add(i),i}removeHandleEvent(e){window.removeEventListener(`phx:${e.event}`,e.callback),this.__listeners.delete(e)}upload(e,t){return this.__view().dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view().withinTargets(e,(s,r)=>{s.dispatchUploads(r,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var ls=(n,e)=>{let t=n.endsWith("[]"),i=t?n.slice(0,-2):n;return i=i.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),t&&(i+="[]"),i},St=(n,e,t=[])=>{let{submitter:i}=e,s;if(i&&i.name){let u=document.createElement("input");u.type="hidden";let p=i.getAttribute("form");p&&u.setAttribute("form",p),u.name=i.name,u.value=i.value,i.parentElement.insertBefore(u,i),s=u}let r=new FormData(n),o=[];r.forEach((u,p,m)=>{u instanceof File&&o.push(p)}),o.forEach(u=>r.delete(u));let a=new URLSearchParams,{inputsUnused:l,onlyHiddenInputs:c}=Array.from(n.elements).reduce((u,p)=>{let{inputsUnused:m,onlyHiddenInputs:g}=u,d=p.name;if(!d)return u;m[d]===void 0&&(m[d]=!0),g[d]===void 0&&(g[d]=!0);let v=h.private(p,ye)||h.private(p,Se),E=p.type==="hidden";return m[d]=m[d]&&!v,g[d]=g[d]&&E,u},{inputsUnused:{},onlyHiddenInputs:{}});for(let[u,p]of r.entries())if(t.length===0||t.indexOf(u)>=0){let m=l[u],g=c[u];m&&!(i&&i.name==u)&&!g&&a.append(ls(u,"_unused_"),""),typeof p=="string"&&a.append(u,p)}return i&&s&&i.parentElement.removeChild(s),a.toString()},Te=class n{static closestView(e){let t=e.closest(se);return t?h.private(t,"view"):null}constructor(e,t,i,s,r){this.isDead=!1,this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e;let o=h.private(this.el,"view");if(o!==void 0&&o.isDead!==!0)throw k(`The DOM element for this view has already been bound to a view.
8
+ `),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(n,e,t){let i=new Set(["id",V,ne,He,z]);if(n.tagName.toLowerCase()===e.toLowerCase())return Array.from(n.attributes).filter(s=>!i.has(s.name.toLowerCase())).forEach(s=>n.removeAttribute(s.name)),Object.keys(t).filter(s=>!i.has(s.toLowerCase())).forEach(s=>n.setAttribute(s,t[s])),n;{let s=document.createElement(e);return Object.keys(t).forEach(r=>s.setAttribute(r,t[r])),i.forEach(r=>s.setAttribute(r,n.getAttribute(r))),s.innerHTML=n.innerHTML,n.replaceWith(s),s}},getSticky(n,e,t){let i=(Pe.private(n,"sticky")||[]).find(([s])=>e===s);if(i){let[s,r,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(n,e){this.updatePrivate(n,"sticky",[],t=>t.filter(([i,s])=>i!==e))},putSticky(n,e,t){let i=t(n);this.updatePrivate(n,"sticky",[],s=>{let r=s.findIndex(([o])=>e===o);return r>=0?s[r]=[e,t,i]:s.push([e,t,i]),s})},applyStickyOperations(n){let e=Pe.private(n,"sticky");e&&e.forEach(([t,i,s])=>this.putSticky(n,t,i))},isLocked(n){return n.hasAttribute&&n.hasAttribute(R)}},h=Pe;var he=class{static isActive(e,t){let i=t._phxRef===void 0,r=e.getAttribute(We).split(",").indexOf(x.genFileRef(t))>=0;return t.size>0&&(i||r)}static isPreflighted(e,t){return e.getAttribute(Ie).split(",").indexOf(x.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,s){this.ref=x.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(Le,this._onElUpdated),this.autoUpload=s}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,()=>{x.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(Le,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||x.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Le,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(We).split(",").indexOf(this.ref)===-1&&(x.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||k(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:gi}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||k(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var $i=0,x=class n{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=($i++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(r=>this.genFileRef(r)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(Ie)!==i.getAttribute(Qt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let r={path:e.name},o=e.getAttribute(K);i[o]=i[o]||[],r.ref=this.genFileRef(s),r.last_modified=s.lastModified,r.name=s.name||r.ref,r.relative_path=s.webkitRelativePath,r.type=s.type,r.size=s.size,typeof s.meta=="function"&&(r.meta=s.meta()),i[o].push(r)}),i}static clearFiles(e){e.value=null,e.removeAttribute(K),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let s=t.filter(r=>!this.activeFiles(e).find(o=>Object.is(o,r)));h.updatePrivate(e,"files",[],r=>r.concat(s)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>he.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!he.isPreflighted(e,t)&&!he.isPreflightInProgress(t))}static markPreflightInProgress(e){e.forEach(t=>he.markPreflightInProgress(t.file))}constructor(e,t,i){this.autoUpload=h.isAutoUpload(e),this.view=t,this.onComplete=i,this._entries=Array.from(n.filesAwaitingPreflight(e)||[]).map(s=>new he(e,s,t,this.autoUpload)),n.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}isAutoUpload(){return this.autoUpload}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(r=>(r.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(r.zipPostFlight(e),r.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),r));let s=this._entries.reduce((r,o)=>{if(!o.meta)return r;let{name:a,callback:l}=o.uploader(i.uploaders);return r[a]=r[a]||{callback:l,entries:[]},r[a].entries.push(o),r},{});for(let r in s){let{callback:o,entries:a}=s[r];o(a,t,e,i)}}};var Bi={anyOf(n,e){return e.find(t=>n instanceof t)},isFocusable(n,e){return n instanceof HTMLAnchorElement&&n.rel!=="ignore"||n instanceof HTMLAreaElement&&n.href!==void 0||!n.disabled&&this.anyOf(n,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||n instanceof HTMLIFrameElement||n.tabIndex>=0&&n.getAttribute("aria-hidden")!=="true"||!e&&n.getAttribute("tabindex")!==null&&n.getAttribute("aria-hidden")!=="true"},attemptFocus(n,e){if(this.isFocusable(n,e))try{n.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(n)},focusFirstInteractive(n){let e=n.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e))return!0;e=e.nextElementSibling}},focusFirst(n){let e=n.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(n){let e=n.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},$=Bi;var Ei={LiveFileUpload:{activeRefs(){return this.el.getAttribute(We)},preflightedRefs(){return this.el.getAttribute(Ie)},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(Le))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(K)),x.getEntryDataURL(this.inputEl,this.ref,n=>{this.url=n,this.el.src=n})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",n=>{if(!n.relatedTarget||!this.el.contains(n.relatedTarget)){let e=n.target.nextElementSibling;$.attemptFocus(e)||$.focusFirst(e)}else $.focusLast(this.el)}),this.focusEnd.addEventListener("focus",n=>{if(!n.relatedTarget||!this.el.contains(n.relatedTarget)){let e=n.target.previousElementSibling;$.attemptFocus(e)||$.focusLast(e)}else $.focusFirst(this.el)}),this.el.contains(document.activeElement)||(this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&$.focusFirst(this.el))}}},Ai=n=>["HTML","BODY"].indexOf(n.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(n).overflowY)>=0?n:Ai(n.parentElement),vi=n=>n?n.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,$t=n=>n?n.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,Bt=n=>n?n.getBoundingClientRect().top:0,Vi=(n,e)=>{let t=n.getBoundingClientRect();return Math.ceil(t.top)>=Bt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=$t(e)},ji=(n,e)=>{let t=n.getBoundingClientRect();return Math.ceil(t.bottom)>=Bt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.bottom)<=$t(e)},bi=(n,e)=>{let t=n.getBoundingClientRect();return Math.ceil(t.top)>=Bt(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=$t(e)};Ei.InfiniteScroll={mounted(){this.scrollContainer=Ai(this.el);let n=vi(this.scrollContainer),e=!1,t=500,i=null,s=this.throttle(t,(a,l)=>{i=()=>!0,this.liveSocket.js().push(this.el,a,{value:{id:l.id,_overran:!0},callback:()=>{i=null}})}),r=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"start"}),this.liveSocket.js().push(this.el,a,{value:{id:l.id},callback:()=>{i=null,window.requestAnimationFrame(()=>{bi(l,this.scrollContainer)||l.scrollIntoView({block:"start"})})}})}),o=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"end"}),this.liveSocket.js().push(this.el,a,{value:{id:l.id},callback:()=>{i=null,window.requestAnimationFrame(()=>{bi(l,this.scrollContainer)||l.scrollIntoView({block:"end"})})}})});this.onScroll=a=>{let l=vi(this.scrollContainer);if(i)return n=l,i();let c=this.el.getBoundingClientRect(),u=this.el.getAttribute(this.liveSocket.binding("viewport-top")),p=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),m=this.el.lastElementChild,g=this.el.firstElementChild,d=l<n,v=l>n;d&&u&&!e&&c.top>=0?(e=!0,s(u,g)):v&&e&&c.top<=0&&(e=!1),u&&d&&Vi(g,this.scrollContainer)?r(u,g):p&&v&&ji(m,this.scrollContainer)&&o(p,m),n=l},this.scrollContainer?this.scrollContainer.addEventListener("scroll",this.onScroll):window.addEventListener("scroll",this.onScroll)},destroyed(){this.scrollContainer?this.scrollContainer.removeEventListener("scroll",this.onScroll):window.removeEventListener("scroll",this.onScroll)},throttle(n,e){let t=0,i;return(...s)=>{let r=Date.now(),o=n-(r-t);o<=0||o>n?(i&&(clearTimeout(i),i=null),t=r,e(...s)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...s)},o))}}};var yi=Ei;var ge=class{static onUnlock(e,t){if(!h.isLocked(e)&&!e.closest(`[${R}]`))return t();let i=e.closest(`[${R}]`),s=i.closest(`[${R}]`).getAttribute(R);i.addEventListener(`phx:undo-lock:${s}`,()=>{t()},{once:!0})}constructor(e){this.el=e,this.loadingRef=e.hasAttribute(ue)?parseInt(e.getAttribute(ue),10):null,this.lockRef=e.hasAttribute(R)?parseInt(e.getAttribute(R),10):null}maybeUndo(e,t,i){if(!this.isWithin(e)){h.updatePrivate(this.el,kt,[],s=>(s.push(e),s));return}this.undoLocks(e,t,i),this.undoLoading(e,t),h.updatePrivate(this.el,kt,[],s=>s.filter(r=>{let o={detail:{ref:r,event:t},bubbles:!0,cancelable:!1};return this.loadingRef&&this.loadingRef>r&&this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${r}`,o)),this.lockRef&&this.lockRef>r&&this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${r}`,o)),r>e})),this.isFullyResolvedBy(e)&&this.el.removeAttribute(N)}isWithin(e){return!(this.loadingRef!==null&&this.loadingRef>e&&this.lockRef!==null&&this.lockRef>e)}undoLocks(e,t,i){if(!this.isLockUndoneBy(e))return;let s=h.private(this.el,R);s&&(i(s),h.deletePrivate(this.el,R)),this.el.removeAttribute(R);let r={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,r))}undoLoading(e,t){if(!this.isLoadingUndoneBy(e)){this.canUndoLoading(e)&&this.el.classList.contains("phx-submit-loading")&&this.el.classList.remove("phx-change-loading");return}if(this.canUndoLoading(e)){this.el.removeAttribute(ue);let i=this.el.getAttribute(pe),s=this.el.getAttribute(ze);s!==null&&(this.el.readOnly=s==="true",this.el.removeAttribute(ze)),i!==null&&(this.el.disabled=i==="true",this.el.removeAttribute(pe));let r=this.el.getAttribute(De);r!==null&&(this.el.innerText=r,this.el.removeAttribute(De));let o={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,o))}lt.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(e))&&h.removeClass(this.el,i)})}isLoadingUndoneBy(e){return this.loadingRef===null?!1:this.loadingRef<=e}isLockUndoneBy(e){return this.lockRef===null?!1:this.lockRef<=e}isFullyResolvedBy(e){return(this.loadingRef===null||this.loadingRef<=e)&&(this.lockRef===null||this.lockRef<=e)}canUndoLoading(e){return this.lockRef===null||this.lockRef<=e}};var et=class{constructor(e,t,i){let s=new Set,r=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(s.add(a.id),r.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...r].filter(a=>!s.has(a))}perform(){let e=h.byId(this.containerId);e&&(this.elementsToModify.forEach(t=>{t.previousElementId?re(document.getElementById(t.previousElementId),i=>{re(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):re(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{re(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))}))}};var Si=11;function Ji(n,e){var t=e.attributes,i,s,r,o,a;if(!(e.nodeType===Si||n.nodeType===Si)){for(var l=t.length-1;l>=0;l--)i=t[l],s=i.name,r=i.namespaceURI,o=i.value,r?(s=i.localName||s,a=n.getAttributeNS(r,s),a!==o&&(i.prefix==="xmlns"&&(s=i.name),n.setAttributeNS(r,s,o))):(a=n.getAttribute(s),a!==o&&n.setAttribute(s,o));for(var c=n.attributes,u=c.length-1;u>=0;u--)i=c[u],s=i.name,r=i.namespaceURI,r?(s=i.localName||s,e.hasAttributeNS(r,s)||n.removeAttributeNS(r,s)):e.hasAttribute(s)||n.removeAttribute(s)}}var Et,Wi="http://www.w3.org/1999/xhtml",j=typeof document=="undefined"?void 0:document,qi=!!j&&"content"in j.createElement("template"),Ki=!!j&&j.createRange&&"createContextualFragment"in j.createRange();function Gi(n){var e=j.createElement("template");return e.innerHTML=n,e.content.childNodes[0]}function zi(n){Et||(Et=j.createRange(),Et.selectNode(j.body));var e=Et.createContextualFragment(n);return e.childNodes[0]}function Yi(n){var e=j.createElement("body");return e.innerHTML=n,e.childNodes[0]}function Qi(n){return n=n.trim(),qi?Gi(n):Ki?zi(n):Yi(n)}function At(n,e){var t=n.nodeName,i=e.nodeName,s,r;return t===i?!0:(s=t.charCodeAt(0),r=i.charCodeAt(0),s<=90&&r>=97?t===i.toUpperCase():r<=90&&s>=97?i===t.toUpperCase():!1)}function Zi(n,e){return!e||e===Wi?j.createElement(n):j.createElementNS(e,n)}function es(n,e){for(var t=n.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Vt(n,e,t){n[t]!==e[t]&&(n[t]=e[t],n[t]?n.setAttribute(t,""):n.removeAttribute(t))}var _i={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)}Vt(n,e,"selected")},INPUT:function(n,e){Vt(n,e,"checked"),Vt(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 s=i.nodeValue;if(s==t||!t&&s==n.placeholder)return;i.nodeValue=t}},SELECT:function(n,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,s=n.firstChild,r,o;s;)if(o=s.nodeName&&s.nodeName.toUpperCase(),o==="OPTGROUP")r=s,s=r.firstChild,s||(s=r.nextSibling,r=null);else{if(o==="OPTION"){if(s.hasAttribute("selected")){t=i;break}i++}s=s.nextSibling,!s&&r&&(s=r.nextSibling,r=null)}n.selectedIndex=t}}},tt=1,wi=11,ki=3,Pi=8;function ve(){}function ts(n){if(n)return n.getAttribute&&n.getAttribute("id")||n.id}function is(n){return function(t,i,s){if(s||(s={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var r=i;i=j.createElement("html"),i.innerHTML=r}else i=Qi(i);else i.nodeType===wi&&(i=i.firstElementChild);var o=s.getNodeKey||ts,a=s.onBeforeNodeAdded||ve,l=s.onNodeAdded||ve,c=s.onBeforeElUpdated||ve,u=s.onElUpdated||ve,p=s.onBeforeNodeDiscarded||ve,m=s.onNodeDiscarded||ve,g=s.onBeforeElChildrenUpdated||ve,d=s.skipFromChildren||ve,v=s.addChild||function(A,y){return A.appendChild(y)},E=s.childrenOnly===!0,D=Object.create(null),X=[];function B(A){X.push(A)}function S(A,y){if(A.nodeType===tt)for(var L=A.firstChild;L;){var w=void 0;y&&(w=o(L))?B(w):(m(L),L.firstChild&&S(L,y)),L=L.nextSibling}}function T(A,y,L){p(A)!==!1&&(y&&y.removeChild(A),m(A),S(A,L))}function M(A){if(A.nodeType===tt||A.nodeType===wi)for(var y=A.firstChild;y;){var L=o(y);L&&(D[L]=y),M(y),y=y.nextSibling}}M(t);function Z(A){l(A);for(var y=A.firstChild;y;){var L=y.nextSibling,w=o(y);if(w){var P=D[w];P&&At(y,P)?(y.parentNode.replaceChild(P,y),b(P,y)):Z(y)}else Z(y);y=L}}function f(A,y,L){for(;y;){var w=y.nextSibling;(L=o(y))?B(L):T(y,A,!0),y=w}}function b(A,y,L){var w=o(y);if(w&&delete D[w],!L){var P=c(A,y);if(P===!1||(P instanceof HTMLElement&&(A=P,M(A)),n(A,y),u(A),g(A,y)===!1))return}A.nodeName!=="TEXTAREA"?J(A,y):_i.TEXTAREA(A,y)}function J(A,y){var L=d(A,y),w=y.firstChild,P=A.firstChild,Ce,oe,xe,nt,ce;e:for(;w;){for(nt=w.nextSibling,Ce=o(w);!L&&P;){if(xe=P.nextSibling,w.isSameNode&&w.isSameNode(P)){w=nt,P=xe;continue e}oe=o(P);var rt=P.nodeType,de=void 0;if(rt===w.nodeType&&(rt===tt?(Ce?Ce!==oe&&((ce=D[Ce])?xe===ce?de=!1:(A.insertBefore(ce,P),oe?B(oe):T(P,A,!0),P=ce,oe=o(P)):de=!1):oe&&(de=!1),de=de!==!1&&At(P,w),de&&b(P,w)):(rt===ki||rt==Pi)&&(de=!0,P.nodeValue!==w.nodeValue&&(P.nodeValue=w.nodeValue))),de){w=nt,P=xe;continue e}oe?B(oe):T(P,A,!0),P=xe}if(Ce&&(ce=D[Ce])&&At(ce,w))L||v(A,ce),b(ce,w);else{var wt=a(w);wt!==!1&&(wt&&(w=wt),w.actualize&&(w=w.actualize(A.ownerDocument||j)),v(A,w),Z(w))}w=nt,P=xe}f(A,P,oe);var Wt=_i[A.nodeName];Wt&&Wt(A,y)}var C=t,O=C.nodeType,Ee=i.nodeType;if(!E){if(O===tt)Ee===tt?At(t,i)||(m(t),C=es(t,Zi(i.nodeName,i.namespaceURI))):C=i;else if(O===ki||O===Pi){if(Ee===O)return C.nodeValue!==i.nodeValue&&(C.nodeValue=i.nodeValue),C;C=i}}if(C===i)m(t);else{if(i.isSameNode&&i.isSameNode(C))return;if(b(C,i,E),X)for(var W=0,Ii=X.length;W<Ii;W++){var _t=D[X[W]];_t&&T(_t,_t.parentNode,!1)}}return!E&&C!==t&&t.parentNode&&(C.actualize&&(C=C.actualize(t.ownerDocument||j)),t.parentNode.replaceChild(C,t)),C}}var ss=is(Ji),it=ss;var be=class{constructor(e,t,i,s,r,o,a={}){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.streams=r,this.streamInserts={},this.streamComponentRestore={},this.targetCID=o,this.cidPatch=Y(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=this.isCIDPatch()?this.targetCIDContainer(s):t,this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]},this.withChildren=a.withChildren||a.undoRef||!1,this.undoRef=a.undoRef}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(){let e=this.liveSocket.binding(Me);h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(Tt,"")})}perform(e){let{view:t,liveSocket:i,html:s,container:r,targetContainer:o}=this;if(this.isCIDPatch()&&!o)return;let a=i.getActiveElement(),{selectionStart:l,selectionEnd:c}=a&&h.hasSelectionRange(a)?a:{},u=i.binding(Me),p=i.binding(qe),m=i.binding(Ke),g=i.binding(Zt),d=[],v=[],E=[],D=[],X=null,B=(S,T,M=this.withChildren)=>{let Z={childrenOnly:S.getAttribute(q)===null&&!M,getNodeKey:f=>h.isPhxDestroyed(f)?null:e?f.id:f.id||f.getAttribute&&f.getAttribute(ut),skipFromChildren:f=>f.getAttribute(u)===Fe,addChild:(f,b)=>{let{ref:J,streamAt:C}=this.getStreamInsert(b);if(J===void 0)return f.appendChild(b);if(this.setStreamRef(b,J),C===0)f.insertAdjacentElement("afterbegin",b);else if(C===-1){let O=f.lastElementChild;if(O&&!O.hasAttribute(Ue)){let Ee=Array.from(f.children).find(W=>!W.hasAttribute(Ue));f.insertBefore(b,Ee)}else f.appendChild(b)}else if(C>0){let O=Array.from(f.children)[C];f.insertBefore(b,O)}},onBeforeNodeAdded:f=>{var J;if((J=this.getStreamInsert(f))!=null&&J.updateOnly&&!this.streamComponentRestore[f.id])return!1;h.maintainPrivateHooks(f,f,p,m),this.trackBefore("added",f);let b=f;return this.streamComponentRestore[f.id]&&(b=this.streamComponentRestore[f.id],delete this.streamComponentRestore[f.id],B(b,f,!0)),b},onNodeAdded:f=>{f.getAttribute&&this.maybeReOrderStream(f,!0),h.isPortalTemplate(f)&&D.push(()=>this.teleport(f,B)),f instanceof HTMLImageElement&&f.srcset?f.srcset=f.srcset:f instanceof HTMLVideoElement&&f.autoplay&&f.play(),h.isNowTriggerFormExternal(f,g)&&(X=f),(h.isPhxChild(f)&&t.ownsElement(f)||h.isPhxSticky(f)&&t.ownsElement(f.parentNode))&&this.trackAfter("phxChildAdded",f),f.nodeName==="SCRIPT"&&f.hasAttribute(Xe)&&this.handleRuntimeHook(f,T),d.push(f)},onNodeDiscarded:f=>this.onNodeDiscarded(f),onBeforeNodeDiscarded:f=>{if(f.getAttribute&&f.getAttribute(Tt)!==null)return!0;if(f.parentElement!==null&&f.id&&h.isPhxUpdate(f.parentElement,u,[Fe,"append","prepend"])||f.getAttribute&&f.getAttribute(me)||this.maybePendingRemove(f)||this.skipCIDSibling(f))return!1;if(h.isPortalTemplate(f)){let b=document.getElementById(f.content.firstElementChild.id);b&&(b.remove(),Z.onNodeDiscarded(b),this.view.dropPortalElementId(b.id))}return!0},onElUpdated:f=>{h.isNowTriggerFormExternal(f,g)&&(X=f),v.push(f),this.maybeReOrderStream(f,!1)},onBeforeElUpdated:(f,b)=>{if(f.id&&f.isSameNode(S)&&f.id!==b.id)return Z.onNodeDiscarded(f),f.replaceWith(b),Z.onNodeAdded(b);if(h.syncPendingAttrs(f,b),h.maintainPrivateHooks(f,b,p,m),h.cleanChildNodes(b,u),this.skipCIDSibling(b))return this.maybeReOrderStream(f),!1;if(h.isPhxSticky(f))return[V,ne,z].map(O=>[O,f.getAttribute(O),b.getAttribute(O)]).forEach(([O,Ee,W])=>{W&&Ee!==W&&f.setAttribute(O,W)}),!1;if(h.isIgnored(f,u)||f.form&&f.form.isSameNode(X))return this.trackBefore("updated",f,b),h.mergeAttrs(f,b,{isIgnored:h.isIgnored(f,u)}),v.push(f),h.applyStickyOperations(f),!1;if(f.type==="number"&&f.validity&&f.validity.badInput)return!1;let J=a&&f.isSameNode(a)&&h.isFormInput(f),C=J&&this.isChangedSelect(f,b);if(f.hasAttribute(N)){let O=new ge(f);if(O.lockRef&&(!this.undoRef||!O.isLockUndoneBy(this.undoRef))){h.isUploadInput(f)&&(h.mergeAttrs(f,b,{isIgnored:!0}),this.trackBefore("updated",f,b),v.push(f)),h.applyStickyOperations(f);let W=f.hasAttribute(R)?h.private(f,R)||f.cloneNode(!0):null;W&&(h.putPrivate(f,R,W),J||(f=W))}}if(h.isPhxChild(b)){let O=f.getAttribute(V);return h.mergeAttrs(f,b,{exclude:[ne]}),O!==""&&f.setAttribute(V,O),f.setAttribute(z,this.rootID),h.applyStickyOperations(f),!1}return this.undoRef&&h.private(b,R)&&h.putPrivate(f,R,h.private(b,R)),h.copyPrivates(b,f),h.isPortalTemplate(b)?(D.push(()=>this.teleport(b,B)),!1):J&&f.type!=="hidden"&&!C?(this.trackBefore("updated",f,b),h.mergeFocusedInput(f,b),h.syncAttrsToProps(f),v.push(f),h.applyStickyOperations(f),!1):(C&&f.blur(),h.isPhxUpdate(b,u,["append","prepend"])&&E.push(new et(f,b,b.getAttribute(u))),h.syncAttrsToProps(b),h.applyStickyOperations(b),this.trackBefore("updated",f,b),f)}};it(S,T,Z)};if(this.trackBefore("added",r),this.trackBefore("updated",r,r),i.time("morphdom",()=>{this.streams.forEach(([S,T,M,Z])=>{T.forEach(([f,b,J,C])=>{this.streamInserts[f]={ref:S,streamAt:b,limit:J,reset:Z,updateOnly:C}}),Z!==void 0&&h.all(r,`[${Ue}="${S}"]`,f=>{this.removeStreamChildElement(f)}),M.forEach(f=>{let b=r.querySelector(`[id="${f}"]`);b&&this.removeStreamChildElement(b)})}),e&&h.all(this.container,`[${u}=${Fe}]`).filter(S=>this.view.ownsElement(S)).forEach(S=>{Array.from(S.children).forEach(T=>{this.removeStreamChildElement(T,!0)})}),B(o,s),D.forEach(S=>S()),this.view.portalElementIds.forEach(S=>{let T=document.getElementById(S);T&&(document.getElementById(T.getAttribute(mt))||(T.remove(),this.onNodeDiscarded(T),this.view.dropPortalElementId(S)))})}),i.isDebugEnabled()&&(ui(),fi(this.streamInserts),Array.from(document.querySelectorAll("input[name=id]")).forEach(S=>{S instanceof HTMLInputElement&&S.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
9
+ `,S)})),E.length>0&&i.time("post-morph append/prepend restoration",()=>{E.forEach(S=>S.perform())}),i.silenceEvents(()=>h.restoreFocus(a,l,c)),h.dispatchEvent(document,"phx:update"),d.forEach(S=>this.trackAfter("added",S)),v.forEach(S=>this.trackAfter("updated",S)),this.transitionPendingRemoves(),X){i.unload();let S=h.private(X,"submitter");if(S&&S.name&&o.contains(S)){let T=document.createElement("input");T.type="hidden";let M=S.getAttribute("form");M&&T.setAttribute("form",M),T.name=S.name,T.value=S.value,S.parentElement.insertBefore(T,S)}Object.getPrototypeOf(X).submit.call(X)}return!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e,t=!1){!t&&!this.view.ownsElement(e)||(this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e)))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,t){h.putSticky(e,Ue,i=>i.setAttribute(Ue,t))}maybeReOrderStream(e,t){let{ref:i,streamAt:s,reset:r}=this.getStreamInsert(e);if(s!==void 0&&(this.setStreamRef(e,i),!(!r&&!t)&&e.parentElement)){if(s===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(s>0){let o=Array.from(e.parentElement.children),a=o.indexOf(e);if(s>=o.length-1)e.parentElement.appendChild(e);else{let l=o[s];a>s?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:t}=this.getStreamInsert(e),i=t!==null&&Array.from(e.parentElement.children);t&&t<0&&i.length>t*-1?i.slice(0,i.length+t).forEach(s=>this.removeStreamChildElement(s)):t&&t>=0&&i.length>t&&i.slice(t).forEach(s=>this.removeStreamChildElement(s))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&t.transitionRemoves(e,()=>{e.forEach(i=>{let s=h.firstPhxChild(i);s&&t.destroyViewByEl(s),i.remove()}),this.trackAfter("transitionsDiscarded",e)})}isChangedSelect(e,t){return!(e instanceof HTMLSelectElement)||e.multiple?!1:e.options.length!==t.options.length?!0:(t.value=e.value,!e.isEqualNode(t))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(dt)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.view.id,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}indexOf(e,t){return Array.from(e.children).indexOf(t)}teleport(e,t){let i=e.getAttribute(pt),s=document.querySelector(i);if(!s)throw new Error("portal target with selector "+i+" not found");let r=e.content.firstElementChild;if(this.skipCIDSibling(r))return;if(!(r!=null&&r.id))throw new Error("phx-portal template must have a single root element with ID!");let o=document.getElementById(r.id),a;o?(s.contains(o)||s.appendChild(o),a=o):(a=document.createElement(r.tagName),s.appendChild(a)),r.setAttribute(me,this.view.id),r.setAttribute(mt,e.id),t(a,r,!0),r.removeAttribute(me),r.removeAttribute(mt),this.view.pushPortalElementId(r.id)}handleRuntimeHook(e,t){let i=e.getAttribute(Xe),s=e.hasAttribute("nonce")?e.getAttribute("nonce"):null;if(e.hasAttribute("nonce")){let o=document.createElement("template");o.innerHTML=t,s=o.content.querySelector(`script[${Xe}="${CSS.escape(i)}"]`).getAttribute("nonce")}let r=document.createElement("script");r.textContent=e.textContent,h.mergeAttrs(r,e,{isIgnored:!1}),s&&(r.nonce=s),e.replaceWith(r),e=r}};var ns=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),rs=new Set(["'",'"']),Ti=(n,e,t)=>{let i=0,s=!1,r,o,a,l,c,u,p=n.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${n}`);for(i=p[0].length,r=p[1],a=p[2],l=i,i;i<n.length&&n.charAt(i)!==">";i++)if(n.charAt(i)==="="){let d=n.slice(i-3,i)===" id";i++;let v=n.charAt(i);if(rs.has(v)){let E=i;for(i++,i;i<n.length&&n.charAt(i)!==v;i++);if(d){c=n.slice(E+1,i);break}}}let m=n.length-1;for(s=!1;m>=r.length+a.length;){let d=n.charAt(m);if(s)d==="-"&&n.slice(m-3,m)==="<!-"?(s=!1,m-=4):m-=1;else if(d===">"&&n.slice(m-2,m)==="--")s=!0,m-=3;else{if(d===">")break;m-=1}}o=n.slice(m+1,n.length);let g=Object.keys(e).map(d=>e[d]===!0?d:`${d}="${e[d]}"`).join(" ");if(t){let d=c?` id="${c}"`:"";ns.has(a)?u=`<${a}${d}${g===""?"":" "}${g}/>`:u=`<${a}${d}${g===""?"":" "}${g}></${a}>`}else{let d=n.slice(l,m+1);u=`<${a}${g===""?"":" "}${g}${d}`}return[u,r,o]},Je=class{static extract(e){let{[Ft]:t,[Mt]:i,[Ut]:s}=e;return delete e[Ft],delete e[Mt],delete e[Ut],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let{buffer:t,streams:i}=this.recursiveToString(this.rendered,this.rendered[F],e,!0,{});return{buffer:t,streams:i}}recursiveToString(e,t=e[F],i,s,r){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,s,r),{buffer:o.buffer,streams:o.streams}}componentCIDs(e){return Object.keys(e[F]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[F]?Object.keys(e).length===1:!1}getComponent(e,t){return e[F][t]}resetRender(e){this.rendered[F][e]&&(this.rendered[F][e].reset=!0)}mergeDiff(e){let t=e[F],i={};if(delete e[F],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[F]=this.rendered[F]||{},t){let s=this.rendered[F];for(let r in t)t[r]=this.cachedFindComponent(r,t[r],s,t,i);for(let r in t)s[r]=t[r];e[F]=t}}cachedFindComponent(e,t,i,s,r){if(r[e])return r[e];{let o,a,l=t[G];if(Y(l)){let c;l>0?c=this.cachedFindComponent(l,s[l],i,s,r):c=i[-l],a=c[G],o=this.cloneMerge(c,t,!0),o[G]=a}else o=t[G]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return r[e]=o,o}}mutableMerge(e,t){return t[G]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){if(t[I])this.mergeKeyed(e,t);else for(let i in t){let s=t[i],r=e[i];ke(s)&&s[G]===void 0&&ke(r)?this.doMutableMerge(r,s):e[i]=s}e[bt]&&(e.newRender=!0)}clone(e){return"structuredClone"in window?structuredClone(e):JSON.parse(JSON.stringify(e))}mergeKeyed(e,t){let i=this.clone(e);if(Object.entries(t[I]).forEach(([s,r])=>{if(s!==te)if(Array.isArray(r)){let[o,a]=r;e[I][s]=i[I][o],this.doMutableMerge(e[I][s],a)}else if(typeof r=="number"){let o=r;e[I][s]=i[I][o]}else typeof r=="object"&&(e[I][s]||(e[I][s]={}),this.doMutableMerge(e[I][s],r))}),t[I][te]<e[I][te])for(let s=t[I][te];s<e[I][te];s++)delete e[I][s];e[I][te]=t[I][te],t[_e]&&(e[_e]=t[_e]),t[le]&&(e[le]=t[le])}cloneMerge(e,t,i){let s=H(H({},e),t);for(let r in s){let o=t[r],a=e[r];ke(o)&&o[G]===void 0&&ke(a)?s[r]=this.cloneMerge(a,o,i):o===void 0&&ke(a)&&(s[r]=this.cloneMerge(a,{},i))}return i?(delete s.magicId,delete s.newRender):e[bt]&&(s.newRender=!0),s}componentToString(e){let{buffer:t,streams:i}=this.recursiveCIDToString(this.rendered[F],e,null),[s,r,o]=Ti(t,{});return{buffer:s,streams:i}}pruneCIDs(e){e.forEach(t=>delete this.rendered[F][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[G]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,t,i,s,r={}){if(e[I])return this.comprehensionToBuffer(e,t,i,s);e[le]&&(t=e[le],delete e[le]);let{[G]:o}=e;o=this.templateStatic(o,t),e[G]=o;let a=e[bt],l=i.buffer;a&&(i.buffer=""),s&&a&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let c=1;c<o.length;c++)this.dynamicToBuffer(e[c-1],t,i,s),i.buffer+=o[c];if(a){let c=!1,u;s||e.magicId?(c=s&&!e.newRender,u=H({[ut]:e.magicId},r)):u=r,c&&(u[dt]=!0);let[p,m,g]=Ti(i.buffer,u,c);e.newRender=!1,i.buffer=l+m+p+g}}comprehensionToBuffer(e,t,i,s){let r=t||e[le],o=this.templateStatic(e[G],t);e[G]=o,delete e[le];for(let a=0;a<e[I][te];a++){i.buffer+=o[0];for(let l=1;l<o.length;l++)this.dynamicToBuffer(e[I][a][l-1],r,i,s),i.buffer+=o[l]}if(e[_e]){let a=e[_e],[l,c,u,p]=a||[null,{},[],null];a!==void 0&&(e[I][te]>0||u.length>0||p)&&(delete e[_e],e[I]={[te]:0},i.streams.add(a))}}dynamicToBuffer(e,t,i,s){if(typeof e=="number"){let{buffer:r,streams:o}=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=r,i.streams=new Set([...i.streams,...o])}else ke(e)?this.toOutputBuffer(e,t,i,s,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||k(`no component for CID ${t}`,e),r={[q]:t,[Re]:this.viewId},o=i&&!i.has(t);s.newRender=!o,s.magicId=`c${t}-${this.parentViewId()}`;let a=!s.reset,{buffer:l,streams:c}=this.recursiveToString(s,e,i,a,r);return delete s.reset,{buffer:l,streams:c}}};var Ci=[],xi=200,os={exec(n,e,t,i,s,r){let[o,a]=r||[null,{callback:r&&r.callback}];(t.charAt(0)==="["?JSON.parse(t):[[o,a]]).forEach(([c,u])=>{c===o&&(u=H(H({},a),u),u.callback=u.callback||a.callback),this.filterToEls(i.liveSocket,s,u).forEach(p=>{this[`exec_${c}`](n,e,t,i,s,p,u)})})},isVisible(n){return!!(n.offsetWidth||n.offsetHeight||n.getClientRects().length>0)},isInViewport(n){let e=n.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth;return e.right>0&&e.bottom>0&&e.left<i&&e.top<t},exec_exec(n,e,t,i,s,r,{attr:o,to:a}){let l=r.getAttribute(o);if(!l)throw new Error(`expected ${o} to contain JS command on "${a}"`);i.liveSocket.execJS(r,l,e)},exec_dispatch(n,e,t,i,s,r,{event:o,detail:a,bubbles:l,blocking:c}){if(a=a||{},a.dispatcher=s,c){let u=new Promise((p,m)=>{a.done=p});i.liveSocket.asyncTransition(u)}h.dispatchEvent(r,o,{detail:a,bubbles:l})},exec_push(n,e,t,i,s,r,o){let{event:a,data:l,target:c,page_loading:u,loading:p,value:m,dispatcher:g,callback:d}=o,v={loading:p,value:m,target:c,page_loading:!!u,originalEvent:n},E=e==="change"&&g?g:s,D=c||E.getAttribute(i.binding("target"))||E,X=(B,S)=>{if(B.isConnected())if(e==="change"){let{newCid:T,_target:M}=o;M=M||(h.isFormInput(s)?s.name:void 0),M&&(v._target=M),B.pushInput(s,S,T,a||t,v,d)}else if(e==="submit"){let{submitter:T}=o;B.submitForm(s,S,a||t,T,v,d)}else B.pushEvent(e,s,S,a||t,l,v,d)};o.targetView&&o.targetCtx?X(o.targetView,o.targetCtx):i.withinTargets(D,X)},exec_navigate(n,e,t,i,s,r,{href:o,replace:a}){i.liveSocket.historyRedirect(n,o,a?"replace":"push",null,s)},exec_patch(n,e,t,i,s,r,{href:o,replace:a}){i.liveSocket.pushHistoryPatch(n,o,a?"replace":"push",s)},exec_focus(n,e,t,i,s,r){$.attemptFocus(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>$.attemptFocus(r))})},exec_focus_first(n,e,t,i,s,r){$.focusFirstInteractive(r)||$.focusFirst(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>$.focusFirstInteractive(r)||$.focusFirst(r))})},exec_push_focus(n,e,t,i,s,r){Ci.push(r||s)},exec_pop_focus(n,e,t,i,s,r){let o=Ci.pop();o&&(o.focus(),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o.focus())}))},exec_add_class(n,e,t,i,s,r,{names:o,transition:a,time:l,blocking:c}){this.addOrRemoveClasses(r,o,[],a,l,i,c)},exec_remove_class(n,e,t,i,s,r,{names:o,transition:a,time:l,blocking:c}){this.addOrRemoveClasses(r,[],o,a,l,i,c)},exec_toggle_class(n,e,t,i,s,r,{names:o,transition:a,time:l,blocking:c}){this.toggleClasses(r,o,a,l,i,c)},exec_toggle_attr(n,e,t,i,s,r,{attr:[o,a,l]}){this.toggleAttr(r,o,a,l)},exec_ignore_attrs(n,e,t,i,s,r,{attrs:o}){this.ignoreAttrs(r,o)},exec_transition(n,e,t,i,s,r,{time:o,transition:a,blocking:l}){this.addOrRemoveClasses(r,[],[],a,o,i,l)},exec_toggle(n,e,t,i,s,r,{display:o,ins:a,outs:l,time:c,blocking:u}){this.toggle(e,i,r,o,a,l,c,u)},exec_show(n,e,t,i,s,r,{display:o,transition:a,time:l,blocking:c}){this.show(e,i,r,o,a,l,c)},exec_hide(n,e,t,i,s,r,{display:o,transition:a,time:l,blocking:c}){this.hide(e,i,r,o,a,l,c)},exec_set_attr(n,e,t,i,s,r,{attr:[o,a]}){this.setOrRemoveAttrs(r,[[o,a]],[])},exec_remove_attr(n,e,t,i,s,r,{attr:o}){this.setOrRemoveAttrs(r,[],[o])},ignoreAttrs(n,e){h.putPrivate(n,"JS:ignore_attrs",{apply:(t,i)=>{Array.from(t.attributes).forEach(s=>{e.some(r=>s.name==r||r.includes("*")&&s.name.match(r)!=null)&&i.setAttribute(s.name,s.value)})}})},onBeforeElUpdated(n,e){let t=h.private(n,"JS:ignore_attrs");t&&t.apply(n,e)},show(n,e,t,i,s,r,o){this.isVisible(t)||this.toggle(n,e,t,i,s,null,r,o)},hide(n,e,t,i,s,r,o){this.isVisible(t)&&this.toggle(n,e,t,i,null,s,r,o)},toggle(n,e,t,i,s,r,o,a){o=o||xi;let[l,c,u]=s||[[],[],[]],[p,m,g]=r||[[],[],[]];if(l.length>0||p.length>0)if(this.isVisible(t)){let d=()=>{this.addOrRemoveClasses(t,m,l.concat(c).concat(u)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,g,m))})},v=()=>{this.addOrRemoveClasses(t,[],p.concat(g)),h.putSticky(t,"toggle",E=>E.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))};t.dispatchEvent(new Event("phx:hide-start")),a===!1?(d(),setTimeout(v,o)):e.transition(o,d,v)}else{if(n==="remove")return;let d=()=>{this.addOrRemoveClasses(t,c,p.concat(m).concat(g));let E=i||this.defaultDisplay(t);window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,l,[]),window.requestAnimationFrame(()=>{h.putSticky(t,"toggle",D=>D.style.display=E),this.addOrRemoveClasses(t,u,c)})})},v=()=>{this.addOrRemoveClasses(t,[],l.concat(u)),t.dispatchEvent(new Event("phx:show-end"))};t.dispatchEvent(new Event("phx:show-start")),a===!1?(d(),setTimeout(v,o)):e.transition(o,d,v)}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",d=>d.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let d=i||this.defaultDisplay(t);h.putSticky(t,"toggle",v=>v.style.display=d),t.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(n,e,t,i,s,r){window.requestAnimationFrame(()=>{let[o,a]=h.getSticky(n,"classes",[[],[]]),l=e.filter(u=>o.indexOf(u)<0&&!n.classList.contains(u)),c=e.filter(u=>a.indexOf(u)<0&&n.classList.contains(u));this.addOrRemoveClasses(n,l,c,t,i,s,r)})},toggleAttr(n,e,t,i){n.hasAttribute(e)?i!==void 0?n.getAttribute(e)===t?this.setOrRemoveAttrs(n,[[e,i]],[]):this.setOrRemoveAttrs(n,[[e,t]],[]):this.setOrRemoveAttrs(n,[],[e]):this.setOrRemoveAttrs(n,[[e,t]],[])},addOrRemoveClasses(n,e,t,i,s,r,o){s=s||xi;let[a,l,c]=i||[[],[],[]];if(a.length>0){let u=()=>{this.addOrRemoveClasses(n,l,[].concat(a).concat(c)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(n,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(n,c,l))})},p=()=>this.addOrRemoveClasses(n,e.concat(c),t.concat(a).concat(l));o===!1?(u(),setTimeout(p,s)):r.transition(s,u,p);return}window.requestAnimationFrame(()=>{let[u,p]=h.getSticky(n,"classes",[[],[]]),m=e.filter(E=>u.indexOf(E)<0&&!n.classList.contains(E)),g=t.filter(E=>p.indexOf(E)<0&&n.classList.contains(E)),d=u.filter(E=>t.indexOf(E)<0).concat(m),v=p.filter(E=>e.indexOf(E)<0).concat(g);h.putSticky(n,"classes",E=>(E.classList.remove(...v),E.classList.add(...d),[d,v]))})},setOrRemoveAttrs(n,e,t){let[i,s]=h.getSticky(n,"attrs",[[],[]]),r=e.map(([l,c])=>l).concat(t),o=i.filter(([l,c])=>!r.includes(l)).concat(e),a=s.filter(l=>!r.includes(l)).concat(t);h.putSticky(n,"attrs",l=>(a.forEach(c=>l.removeAttribute(c)),o.forEach(([c,u])=>l.setAttribute(c,u)),[o,a]))},hasAllClasses(n,e){return e.every(t=>n.classList.contains(t))},isToggledOut(n,e){return!this.isVisible(n)||this.hasAllClasses(n,e)},filterToEls(n,e,{to:t}){let i=()=>{if(typeof t=="string")return document.querySelectorAll(t);if(t.closest){let s=e.closest(t.closest);return s?[s]:[]}else if(t.inner)return e.querySelectorAll(t.inner)};return t?n.jsQuerySelectorAll(e,t,i):[e]},defaultDisplay(n){return{tr:"table-row",td:"table-cell"}[n.tagName.toLowerCase()]||"block"},transitionClasses(n){if(!n)return null;let[e,t,i]=Array.isArray(n)?n:[n.split(" "),[],[]];return e=Array.isArray(e)?e:e.split(" "),t=Array.isArray(t)?t:t.split(" "),i=Array.isArray(i)?i:i.split(" "),[e,t,i]}},_=os;var yt=(n,e)=>({exec(t,i){n.execJS(t,i,e)},show(t,i={}){let s=n.owner(t);_.show(e,s,t,i.display,_.transitionClasses(i.transition),i.time,i.blocking)},hide(t,i={}){let s=n.owner(t);_.hide(e,s,t,null,_.transitionClasses(i.transition),i.time,i.blocking)},toggle(t,i={}){let s=n.owner(t),r=_.transitionClasses(i.in),o=_.transitionClasses(i.out);_.toggle(e,s,t,i.display,r,o,i.time,i.blocking)},addClass(t,i,s={}){let r=Array.isArray(i)?i:i.split(" "),o=n.owner(t);_.addOrRemoveClasses(t,r,[],_.transitionClasses(s.transition),s.time,o,s.blocking)},removeClass(t,i,s={}){let r=Array.isArray(i)?i:i.split(" "),o=n.owner(t);_.addOrRemoveClasses(t,[],r,_.transitionClasses(s.transition),s.time,o,s.blocking)},toggleClass(t,i,s={}){let r=Array.isArray(i)?i:i.split(" "),o=n.owner(t);_.toggleClasses(t,r,_.transitionClasses(s.transition),s.time,o,s.blocking)},transition(t,i,s={}){let r=n.owner(t);_.addOrRemoveClasses(t,[],[],_.transitionClasses(i),s.time,r,s.blocking)},setAttribute(t,i,s){_.setOrRemoveAttrs(t,[[i,s]],[])},removeAttribute(t,i){_.setOrRemoveAttrs(t,[],[i])},toggleAttribute(t,i,s,r){_.toggleAttr(t,i,s,r)},push(t,i,s={}){n.withinOwners(t,r=>{let o=s.value||{};delete s.value;let a=new CustomEvent("phx:exec",{detail:{sourceElement:t}});_.exec(a,e,i,r,t,["push",H({data:o},s)])})},navigate(t,i={}){let s=new CustomEvent("phx:exec");n.historyRedirect(s,t,i.replace?"replace":"push",null,null)},patch(t,i={}){let s=new CustomEvent("phx:exec");n.pushHistoryPatch(s,t,i.replace?"replace":"push",null)},ignoreAttributes(t,i){_.ignoreAttrs(t,Array.isArray(i)?i:[i])}});var jt="hookId",as=1,Q=class n{static makeID(){return as++}static elementID(e){return h.private(e,jt)}constructor(e,t,i){if(this.el=t,this.__attachView(e),this.__listeners=new Set,this.__isDisconnected=!1,h.putPrivate(this.el,jt,n.makeID()),i){let s=new Set(["el","liveSocket","__view","__listeners","__isDisconnected","constructor","js","pushEvent","pushEventTo","handleEvent","removeHandleEvent","upload","uploadTo","__mounted","__updated","__beforeUpdate","__destroyed","__reconnected","__disconnected","__cleanup__"]);for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&(this[o]=i[o],s.has(o)&&console.warn(`Hook object for element #${t.id} overwrites core property '${o}'!`));["mounted","beforeUpdate","updated","destroyed","disconnected","reconnected"].forEach(o=>{i[o]&&typeof i[o]=="function"&&(this[o]=i[o])})}}__attachView(e){e?(this.__view=()=>e,this.liveSocket=e.liveSocket):(this.__view=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)},this.liveSocket=null)}mounted(){}beforeUpdate(){}updated(){}destroyed(){}disconnected(){}reconnected(){}__mounted(){this.mounted()}__updated(){this.updated()}__beforeUpdate(){this.beforeUpdate()}__destroyed(){this.destroyed(),h.deletePrivate(this.el,jt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected()}js(){return ae(H({},yt(this.__view().liveSocket,"hook")),{exec:e=>{this.__view().liveSocket.execJS(this.el,e,"hook")}})}pushEvent(e,t,i){let s=this.__view().pushHookEvent(this.el,null,e,t||{});if(i===void 0)return s.then(({reply:r})=>r);s.then(({reply:r,ref:o})=>i(r,o)).catch(()=>{})}pushEventTo(e,t,i,s){if(s===void 0){let r=[];this.__view().withinTargets(e,(a,l)=>{r.push({view:a,targetCtx:l})});let o=r.map(({view:a,targetCtx:l})=>a.pushHookEvent(this.el,l,t,i||{}));return Promise.allSettled(o)}this.__view().withinTargets(e,(r,o)=>{r.pushHookEvent(this.el,o,t,i||{}).then(({reply:a,ref:l})=>s(a,l)).catch(()=>{})})}handleEvent(e,t){let i={event:e,callback:s=>t(s.detail)};return window.addEventListener(`phx:${e}`,i.callback),this.__listeners.add(i),i}removeHandleEvent(e){window.removeEventListener(`phx:${e.event}`,e.callback),this.__listeners.delete(e)}upload(e,t){return this.__view().dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view().withinTargets(e,(s,r)=>{s.dispatchUploads(r,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var ls=(n,e)=>{let t=n.endsWith("[]"),i=t?n.slice(0,-2):n;return i=i.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),t&&(i+="[]"),i},St=(n,e,t=[])=>{let{submitter:i}=e,s;if(i&&i.name){let u=document.createElement("input");u.type="hidden";let p=i.getAttribute("form");p&&u.setAttribute("form",p),u.name=i.name,u.value=i.value,i.parentElement.insertBefore(u,i),s=u}let r=new FormData(n),o=[];r.forEach((u,p,m)=>{u instanceof File&&o.push(p)}),o.forEach(u=>r.delete(u));let a=new URLSearchParams,{inputsUnused:l,onlyHiddenInputs:c}=Array.from(n.elements).reduce((u,p)=>{let{inputsUnused:m,onlyHiddenInputs:g}=u,d=p.name;if(!d)return u;m[d]===void 0&&(m[d]=!0),g[d]===void 0&&(g[d]=!0);let v=h.private(p,ye)||h.private(p,Se),E=p.type==="hidden";return m[d]=m[d]&&!v,g[d]=g[d]&&E,u},{inputsUnused:{},onlyHiddenInputs:{}});for(let[u,p]of r.entries())if(t.length===0||t.indexOf(u)>=0){let m=l[u],g=c[u];m&&!(i&&i.name==u)&&!g&&a.append(ls(u,"_unused_"),""),typeof p=="string"&&a.append(u,p)}return i&&s&&i.parentElement.removeChild(s),a.toString()},Te=class n{static closestView(e){let t=e.closest(se);return t?h.private(t,"view"):null}constructor(e,t,i,s,r){this.isDead=!1,this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e;let o=h.private(this.el,"view");if(o!==void 0&&o.isDead!==!0)throw k(`The DOM element for this view has already been bound to a view.
10
10
 
11
11
  An element can only ever be associated with a single view!
12
12
  Please ensure that you are not trying to initialize multiple LiveSockets on the same page.
13
13
  This could happen if you're accidentally trying to render your root layout more than once.
14
14
  Ensure that the template set on the LiveView is different than the root layout.
15
- `,{view:o}),new Error("Cannot bind multiple views to the same DOM element.");h.putPrivate(this.el,"view",this),this.id=this.el.id,this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.disconnectedTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(a){a&&a()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let a=this.href&&this.expandURL(this.href);return{redirect:this.redirect?a:void 0,url:this.redirect?void 0:a||void 0,params:this.connectParams(r),session:this.getSession(),static:this.getStatic(),flash:this.flash,sticky:this.el.hasAttribute(Ge)}}),this.portalElementIds=new Set}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(He)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(zt)}]`).map(s=>s.src||s.href).filter(s=>typeof s=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._mount_attempts=this.joinAttempts,t._live_referer=e,this.joinAttempts++,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(V)}getStatic(){let e=this.el.getAttribute(ne);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyPortalElements(),this.destroyed=!0,h.deletePrivate(this.el,"view"),delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(Ct,fe,Ae,xt,Oe),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(fe)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),clearTimeout(this.disconnectedTimer),this.setContainerClasses(Ct),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t,i=document){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,s=>t(s,e));if(Y(e))h.findComponentNodeList(this.id,e,i).length===0?k(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let s=Array.from(i.querySelectorAll(e));s.length===0&&k(`nothing found matching the phx-target selector "${e}"`),s.forEach(r=>this.liveSocket.owner(r,o=>t(o,r)))}}applyDiff(e,t,i){this.log(e,()=>["",je(t)]);let{diff:s,reply:r,events:o,title:a}=Je.extract(t);i({diff:s,reply:r,events:o}),(typeof a=="string"||e=="mount")&&window.requestAnimationFrame(()=>h.putTitle(a))}onJoin(e){let{rendered:t,container:i,liveview_version:s,pid:r}=e;if(i){let[o,a]=i;this.el=h.replaceRootContainer(this.el,o,a)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&U.pushState("replace",{type:"patch",id:this.id,position:this.liveSocket.currentHistoryPosition}),s!==this.liveSocket.version()&&console.error(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${s}. To avoid issues, please ensure that your assets use the same version as the server.`),r&&this.el.setAttribute(si,r),U.dropLocal(this.liveSocket.localStorage,window.location.pathname,ot),this.applyDiff("mount",t,({diff:o,events:a})=>{this.rendered=new Je(this.id,o);let[l,c]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(l,()=>{this.onJoinComplete(e,l,c,a)})})}dropPendingRefs(){h.all(document,`[${N}="${this.refSrc()}"]`,e=>{e.removeAttribute(ue),e.removeAttribute(N),e.removeAttribute(R)})}onJoinComplete({live_patch:e},t,i,s){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,s);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(ne);return l&&o.setAttribute(ne,l),a&&a.setAttribute(z,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,s)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(z,this.root.id)}execNewMounted(e=document){let t=this.binding(qe),i=this.binding(Ke);this.all(e,`[${t}], [${i}]`,s=>{h.maintainPrivateHooks(s,s,t,i),this.maybeAddNewHook(s)}),this.all(e,`[${this.binding(Ne)}], [data-phx-${Ne}]`,s=>{this.maybeAddNewHook(s)}),this.all(e,`[${this.binding(Lt)}]`,s=>{this.maybeMounted(s)})}all(e,t,i){h.all(e,t,s=>{this.ownsElement(s)&&i(s)})}applyJoinPatch(e,t,i,s){this.attachTrueDocEl();let r=new be(this,this.el,this.id,t,i,null);if(r.markPrunableContentForRemoval(),this.performPatch(r,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(s),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),s=i&&h.isIgnored(e,this.binding(Me));if(i&&!e.isEqualNode(t)&&!(s&&mi(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(Lt)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){let t=this.addHook(e);t&&t.__mounted()}performPatch(e,t,i=!1){let s=[],r=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.after("added",a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]);let l=this.binding(qe),c=this.binding(Ke);h.maintainPrivateHooks(a,a,l,c),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.after("phxChildAdded",a=>{h.isPhxSticky(a)?this.liveSocket.joinRootViews():r=!0}),e.before("updated",(a,l)=>{this.triggerBeforeUpdateHook(a,l)&&o.add(a.id),_.onBeforeElUpdated(a,l)}),e.after("updated",a=>{o.has(a.id)&&this.getHook(a).__updated()}),e.after("discarded",a=>{a.nodeType===Node.ELEMENT_NODE&&s.push(a)}),e.after("transitionsDiscarded",a=>this.afterElementsRemoved(a,t)),e.perform(i),this.afterElementsRemoved(s,t),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),r}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let r=h.all(s,`[${q}]`),o=h.all(s,`[${this.binding(Ne)}], [data-phx-hook]`);r.concat(s).forEach(a=>{let l=this.componentID(a);Y(l)&&i.indexOf(l)===-1&&i.push(l)}),o.concat(s).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(document,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,t){let i=this.binding("change"),s=this.root.formsForRecovery,r=document.createElement("template");r.innerHTML=e;let o=r.content.firstElementChild;o.id=this.id,o.setAttribute(z,this.root.id),o.setAttribute(V,this.getSession()),o.setAttribute(ne,this.getStatic()),o.setAttribute(ie,this.parent?this.parent.id:null);let a=h.all(r.content,"form").filter(l=>l.id&&s[l.id]).filter(l=>!this.pendingForms.has(l.id)).filter(l=>s[l.id].getAttribute(i)===l.getAttribute(i)).map(l=>[s[l.id],l]);if(a.length===0)return t();a.forEach(([l,c],u)=>{this.pendingForms.add(c.id),this.pushFormRecovery(l,c,r.content.firstElementChild,()=>{this.pendingForms.delete(c.id),u===a.length-1&&t()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){var t;return e.id===this.id?this:(t=this.children[e.getAttribute(ie)])==null?void 0:t[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 n(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.pendingForms.clear(),this.formsForRecovery={},this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findExistingParentCIDs(this.id,this.rendered.componentCIDs(e)).forEach(r=>{this.componentPatch(this.rendered.getComponent(e,r),r)&&(i=!0)})}):Xt(e)||this.liveSocket.time("full patch complete",()=>{let[s,r]=this.renderContainer(e,"update"),o=new be(this,this.el,this.id,s,r,null);i=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,s=e?this.rendered.componentCIDs(e):null,{buffer:r,streams:o}=this.rendered.toString(s);return[`<${i}>${r}</${i}>`,o]})}componentPatch(e,t){if(Xt(e))return!1;let{buffer:i,streams:s}=this.rendered.componentToString(t),r=new be(this,this.el,this.id,i,s,t);return this.performPatch(r,!0)}getHook(e){return this.viewHooks[Q.elementID(e)]}addHook(e){let t=Q.elementID(e);if(!(e.getAttribute&&!this.ownsElement(e)))if(t&&!this.viewHooks[t]){let i=h.getCustomElHook(e)||k(`no hook found for custom element: ${e.id}`);return this.viewHooks[t]=i,i.__attachView(this),i}else{if(t||!e.getAttribute)return;{let i=e.getAttribute(`data-phx-${Ne}`)||e.getAttribute(this.binding(Ne));if(!i)return;let s=this.liveSocket.getHookDefinition(i);if(s){if(!e.id){k(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);return}let r;try{if(typeof s=="function"&&s.prototype instanceof Q)r=new s(this,e);else if(typeof s=="object"&&s!==null)r=new Q(this,e,s);else{k(`Invalid hook definition for "${i}". Expected a class extending ViewHook or an object definition.`,e);return}}catch(o){let a=o instanceof Error?o.message:String(o);k(`Failed to create hook "${i}": ${a}`,e);return}return this.viewHooks[Q.elementID(r.el)]=r,r}else i!==null&&k(`unknown hook found for "${i}"`,e)}}}destroyHook(e){let t=Q.elementID(e.el);e.__destroyed(),e.__cleanup__(),delete this.viewHooks[t]}applyPendingUpdates(){this.liveSocket.hasPendingLink()&&this.root.isMain()||(this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates()))}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}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(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:t,kind:i,flash:s}=e,r=this.expandURL(t),o=new CustomEvent("phx:server-navigate",{detail:{to:t,kind:i,flash:s}});this.liveSocket.historyRedirect(o,r,i,s)}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,reloadToken:i}){this.liveSocket.redirect(e,t,i)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}joinPush(){return this.joinPush=this.joinPush||this.channel.join(),this.joinPush}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.wrapPush(()=>this.channel.join(),{ok:t=>this.liveSocket.requestDOMUpdate(()=>this.onJoin(t)),error:t=>this.onJoinError(t),timeout:()=>this.onJoinError({reason:"timeout"})})}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page reload`,e]),this.onRedirect({to:this.root.href,reloadToken:e.token});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.root.href,flash:this.flash});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([fe,Ae,Oe]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=Ht&&(this.root.displayError([fe,Ae,Oe]),this.log("error",()=>[`giving up trying to mount after ${Ht} tries`,e]),this.destroy());let t=h.byId(this.el.id);t?(h.mergeAttrs(t,this.el),this.displayError([fe,Ae,Oe]),this.el=t):this.destroy()}}onClose(e){if(!this.isDestroyed()){if(this.isMain()&&this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),this.liveSocket.isUnloaded()&&this.showLoader(ai)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([fe,Ae,Oe]):this.displayError([fe,Ae,xt]))}displayError(e){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.delayedDisconnected()}delayedDisconnected(){this.disconnectedTimer=setTimeout(()=>{this.execAll(this.binding("disconnected"))},this.liveSocket.disconnectedTimeout)}wrapPush(e,t){let i=this.liveSocket.getLatencySim(),s=i?r=>setTimeout(()=>!this.isDestroyed()&&r(),i):r=>!this.isDestroyed()&&r();s(()=>{e().receive("ok",r=>s(()=>t.ok&&t.ok(r))).receive("error",r=>s(()=>t.error&&t.error(r))).receive("timeout",()=>s(()=>t.timeout&&t.timeout()))})}pushWithReply(e,t,i){if(!this.isConnected())return Promise.reject(new Error("no connection"));let[s,[r],o]=e?e({payload:i}):[null,[],{}],a=this.joinCount,l=function(){};return o.page_loading&&(l=this.liveSocket.withPageLoading({kind:"element",target:r})),typeof i.cid!="number"&&delete i.cid,new Promise((c,u)=>{this.wrapPush(()=>this.channel.push(t,i,ci),{ok:p=>{s!==null&&(this.lastAckRef=s);let m=g=>{p.redirect&&this.onRedirect(p.redirect),p.live_patch&&this.onLivePatch(p.live_patch),p.live_redirect&&this.onLiveRedirect(p.live_redirect),l(),c({resp:p,reply:g,ref:s})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:g,reply:d,events:v})=>{s!==null&&this.undoRefs(s,i.event),this.update(g,v),m(d)})}):(s!==null&&this.undoRefs(s,i.event),m(null))},error:p=>u(new Error(`failed with reason: ${p}`)),timeout:()=>{u(new Error("timeout")),this.joinCount===a&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,t,i){if(!this.isConnected())return;let s=`[${N}="${this.refSrc()}"]`;i?(i=new Set(i),h.all(document,s,r=>{i&&!i.has(r)||(h.all(r,s,o=>this.undoElRef(o,e,t)),this.undoElRef(r,e,t))})):h.all(document,s,r=>this.undoElRef(r,e,t))}undoElRef(e,t,i){new ge(e).maybeUndo(t,i,r=>{let o=new be(this,e,this.id,r,[],null,{undoRef:t}),a=this.performPatch(o,!0);h.all(e,`[${N}="${this.refSrc()}"]`,l=>this.undoElRef(l,t,i)),a&&this.joinNewChildren()})}refSrc(){return this.el.id}putRef(e,t,i,s={}){let r=this.ref++,o=this.binding(Rt);if(s.loading){let a=h.all(document,s.loading).map(l=>({el:l,lock:!0,loading:!0}));e=e.concat(a)}for(let{el:a,lock:l,loading:c}of e){if(!l&&!c)throw new Error("putRef requires lock or loading");if(a.setAttribute(N,this.refSrc()),c&&a.setAttribute(ue,r),l&&a.setAttribute(R,r),!c||s.submitter&&!(a===s.submitter||a===s.form))continue;let u=new Promise(d=>{a.addEventListener(`phx:undo-lock:${r}`,()=>d(g),{once:!0})}),p=new Promise(d=>{a.addEventListener(`phx:undo-loading:${r}`,()=>d(g),{once:!0})});a.classList.add(`phx-${i}-loading`);let m=a.getAttribute(o);m!==null&&(a.getAttribute(De)||a.setAttribute(De,a.innerText),m!==""&&(a.innerText=m),a.setAttribute(pe,a.getAttribute(pe)||a.disabled),a.setAttribute("disabled",""));let g={event:t,eventType:i,ref:r,isLoading:c,isLocked:l,lockElements:e.filter(({lock:d})=>d).map(({el:d})=>d),loadingElements:e.filter(({loading:d})=>d).map(({el:d})=>d),unlock:d=>{d=Array.isArray(d)?d:[d],this.undoRefs(r,t,d)},lockComplete:u,loadingComplete:p,lock:d=>new Promise(v=>{if(this.isAcked(r))return v(g);d.setAttribute(R,r),d.setAttribute(N,this.refSrc()),d.addEventListener(`phx:lock-stop:${r}`,()=>v(g),{once:!0})})};s.payload&&(g.payload=s.payload),s.target&&(g.target=s.target),s.originalEvent&&(g.originalEvent=s.originalEvent),a.dispatchEvent(new CustomEvent("phx:push",{detail:g,bubbles:!0,cancelable:!1})),t&&a.dispatchEvent(new CustomEvent(`phx:push:${t}`,{detail:g,bubbles:!0,cancelable:!1}))}return[r,e.map(({el:a})=>a),s]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){let t=e.getAttribute&&e.getAttribute(q);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(Y(t))return t;let s=i.target||e.getAttribute(this.binding("target"));return Y(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return Y(e)?e:e?re(e.closest(`[${q}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,s]),Promise.reject(new Error("unable to push hook event. LiveView not connected"));let r=()=>this.putRef([{el:e,loading:!0,lock:!0}],i,"hook",{payload:s,target:t});return this.pushWithReply(r,"event",{type:"hook",event:i,value:s,cid:this.closestComponentID(t)}).then(({resp:o,reply:a,ref:l})=>({reply:a,ref:l}))}extractMeta(e,t,i){let s=this.binding("value-");for(let r=0;r<e.attributes.length;r++){t||(t={});let o=e.attributes[r].name;o.startsWith(s)&&(t[o.replace(s,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&ut.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let r in i)t[r]=i[r]}return t}pushEvent(e,t,i,s,r,o={},a){this.pushWithReply(l=>this.putRef([{el:t,loading:!0,lock:!0}],s,e,ae(H({},o),{payload:l==null?void 0:l.payload})),"event",{type:e,event:s,value:this.extractMeta(t,r,o.value),cid:this.targetComponentID(t,i,o)}).then(({reply:l})=>a&&a(l)).catch(l=>k("Failed to push event",l))}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(r,o)=>{r.pushWithReply(null,"progress",{event:e.getAttribute(r.binding(ri)),ref:e.getAttribute(K),entry_ref:t,progress:i,cid:r.targetComponentID(e.form,o)}).then(()=>s()).catch(a=>k("Failed to push file progress",a))})}pushInput(e,t,i,s,r,o){if(!e.form)throw new Error("form events require the input to be inside a form");let a,l=Y(i)?i:this.targetComponentID(e.form,t,r),c=d=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],s,"change",ae(H({},r),{payload:d==null?void 0:d.payload})),u,p=this.extractMeta(e.form,{},r.value),m={};e instanceof HTMLButtonElement&&(m.submitter=e),e.getAttribute(this.binding("change"))?u=St(e.form,m,[e.name]):u=St(e.form,m),h.isUploadInput(e)&&e.files&&e.files.length>0&&x.trackFiles(e,Array.from(e.files)),a=x.serializeUploads(e);let g={type:"form",event:s,value:u,meta:H({_target:r._target||"undefined"},p),uploads:a,cid:l};this.pushWithReply(c,"event",g).then(({resp:d})=>{h.isUploadInput(e)&&h.isAutoUpload(e)?ge.onUnlock(e,()=>{if(x.filesAwaitingPreflight(e).length>0){let[v,E]=c();this.undoRefs(v,s,[e.form]),this.uploadFiles(e.form,s,t,v,l,D=>{o&&o(d),this.triggerAwaitingSubmit(e.form,s),this.undoRefs(v,s)})}}):o&&o(d)}).catch(d=>k("Failed to push input event",d))}triggerAwaitingSubmit(e,t){let i=this.getScheduledSubmit(e);if(i){let[s,r,o,a]=i;this.cancelSubmit(e,t),a()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,s,r])=>t.isSameNode(e))}scheduleSubmit(e,t,i,s){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,s])}cancelSubmit(e,t){this.formSubmits=this.formSubmits.filter(([i,s,r,o])=>i.isSameNode(e)?(this.undoRefs(s,t),!1):!0)}disableForm(e,t,i={}){let s=d=>!(we(d,`${this.binding(Me)}=ignore`,d.form)||we(d,"data-phx-update=ignore",d.form)),r=d=>d.hasAttribute(this.binding(Rt)),o=d=>d.tagName=="BUTTON",a=d=>["INPUT","TEXTAREA","SELECT"].includes(d.tagName),l=Array.from(e.elements),c=l.filter(r),u=l.filter(o).filter(s),p=l.filter(a).filter(s);u.forEach(d=>{d.setAttribute(pe,d.disabled),d.disabled=!0}),p.forEach(d=>{d.setAttribute(ze,d.readOnly),d.readOnly=!0,d.files&&(d.setAttribute(pe,d.disabled),d.disabled=!0)});let m=c.concat(u).concat(p).map(d=>({el:d,loading:!0,lock:!0})),g=[{el:e,loading:!0,lock:!1}].concat(m).reverse();return this.putRef(g,t,"submit",i)}pushFormSubmit(e,t,i,s,r,o){let a=c=>this.disableForm(e,i,ae(H({},r),{form:e,payload:c==null?void 0:c.payload,submitter:s}));h.putPrivate(e,"submitter",s);let l=this.targetComponentID(e,t);if(x.hasUploadsInProgress(e)){let[c,u]=a(),p=()=>this.pushFormSubmit(e,t,i,s,r,o);return this.scheduleSubmit(e,c,r,p)}else if(x.inputsAwaitingPreflight(e).length>0){let[c,u]=a(),p=()=>[c,u,r];this.uploadFiles(e,i,t,c,l,m=>{if(x.inputsAwaitingPreflight(e).length>0)return this.undoRefs(c,i);let g=this.extractMeta(e,{},r.value),d=St(e,{submitter:s});this.pushWithReply(p,"event",{type:"form",event:i,value:d,meta:g,cid:l}).then(({resp:v})=>o(v)).catch(v=>k("Failed to push form submit",v))})}else if(!(e.hasAttribute(N)&&e.classList.contains("phx-submit-loading"))){let c=this.extractMeta(e,{},r.value),u=St(e,{submitter:s});this.pushWithReply(a,"event",{type:"form",event:i,value:u,meta:c,cid:l}).then(({resp:p})=>o(p)).catch(p=>k("Failed to push form submit",p))}}uploadFiles(e,t,i,s,r,o){let a=this.joinCount,l=x.activeFileInputs(e),c=l.length;l.forEach(u=>{let p=new x(u,this,()=>{c--,c===0&&o()}),m=p.entries().map(d=>d.toPreflightPayload());if(m.length===0){c--;return}let g={ref:u.getAttribute(K),entries:m,cid:this.targetComponentID(u.form,i)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g).then(({resp:d})=>{if(this.log("upload",()=>["got preflight response",d]),p.entries().forEach(v=>{d.entries&&!d.entries[v.ref]&&this.handleFailedEntryPreflight(v.ref,"failed preflight",p)}),d.error||Object.keys(d.entries).length===0)this.undoRefs(s,t),(d.error||[]).map(([E,D])=>{this.handleFailedEntryPreflight(E,D,p)});else{let v=E=>{this.channel.onError(()=>{this.joinCount===a&&E()})};p.initAdapterUpload(d,v,this.liveSocket)}}).catch(d=>k("Failed to push upload",d))})}handleFailedEntryPreflight(e,t,i){if(i.isAutoUpload()){let s=i.entries().find(r=>r.ref===e.toString());s&&s.cancel()}else i.entries().map(s=>s.cancel());this.log("upload",()=>[`error for entry ${e}`,t])}dispatchUploads(e,t,i){let s=this.targetCtxElement(e)||this.el,r=h.findUploadInputs(s).filter(o=>o.name===t);r.length===0?k(`no live file inputs found matching the name "${t}"`):r.length>1?k(`duplicate live file inputs found matching the name "${t}"`):h.dispatchEvent(r[0],ht,{detail:{files:i}})}targetCtxElement(e){if(Y(e)){let[t]=h.findComponentNodeList(this.id,e);return t}else return e||null}pushFormRecovery(e,t,i,s){let r=this.binding("change"),o=t.getAttribute(this.binding("target"))||t,a=t.getAttribute(this.binding(It))||t.getAttribute(this.binding("change")),l=Array.from(e.elements).filter(p=>h.isFormInput(p)&&p.name&&!p.hasAttribute(r));if(l.length===0){s();return}l.forEach(p=>p.hasAttribute(K)&&x.clearFiles(p));let c=l.find(p=>p.type!=="hidden")||l[0],u=0;this.withinTargets(o,(p,m)=>{let g=this.targetComponentID(t,m);u++;let d=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});_.exec(d,"change",a,this,c,["push",{_target:c.name,targetView:p,targetCtx:m,newCid:g,callback:()=>{u--,u===0&&s()}}])},i)}pushLinkPatch(e,t,i,s){let r=this.liveSocket.setPendingLink(t),o=e.isTrusted&&e.type!=="popstate",a=i?()=>this.putRef([{el:i,loading:o,lock:!0}],null,"click"):null,l=()=>this.liveSocket.redirect(window.location.href),c=t.startsWith("/")?`${location.protocol}//${location.host}${t}`:t;this.pushWithReply(a,"live_patch",{url:c}).then(({resp:u})=>{this.liveSocket.requestDOMUpdate(()=>{u.link_redirect?this.liveSocket.replaceMain(t,null,s,r):(this.liveSocket.commitPendingLink(r)&&(this.href=t),this.applyPendingUpdates(),s&&s(r))})},({error:u,timeout:p})=>l())}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return h.all(this.el,`form[${e}]`).filter(t=>t.id).filter(t=>t.elements.length>0).filter(t=>t.getAttribute(this.binding(It))!=="ignore").map(t=>{let i=t.cloneNode(!1);return h.copyPrivates(i,t),Array.from(t.elements).forEach(s=>{let r=s.cloneNode(!0);At(r,s),h.copyPrivates(r,s),i.appendChild(r)}),i}).reduce((t,i)=>(t[i.id]=i,t),{})}maybePushComponentsDestroyed(e){let t=e.filter(s=>h.findComponentNodeList(this.el,s).length===0),i=s=>{this.isDestroyed()||k("Failed to push components destroyed",s)};t.length>0&&(t.forEach(s=>this.rendered.resetRender(s)),this.pushWithReply(null,"cids_will_destroy",{cids:t}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let s=t.filter(r=>h.findComponentNodeList(this.el,r).length===0);s.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:s}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)}).catch(i)})}).catch(i))}ownsElement(e){let t=e.closest(se);return e.getAttribute(ie)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,s,r={}){h.putPrivate(e,Se,!0),Array.from(e.elements).forEach(a=>h.putPrivate(a,Se,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,r,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}pushPortalElementId(e){this.portalElementIds.add(e)}dropPortalElementId(e){this.portalElementIds.delete(e)}destroyPortalElements(){this.portalElementIds.forEach(e=>{let t=document.getElementById(e);t&&t.remove()})}};var Ri=n=>h.isUsedInput(n),it=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
15
+ `,{view:o}),new Error("Cannot bind multiple views to the same DOM element.");h.putPrivate(this.el,"view",this),this.id=this.el.id,this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.disconnectedTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(a){a&&a()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let a=this.href&&this.expandURL(this.href);return{redirect:this.redirect?a:void 0,url:this.redirect?void 0:a||void 0,params:this.connectParams(r),session:this.getSession(),static:this.getStatic(),flash:this.flash,sticky:this.el.hasAttribute(Ge)}}),this.portalElementIds=new Set}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(He)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(zt)}]`).map(s=>s.src||s.href).filter(s=>typeof s=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._mount_attempts=this.joinAttempts,t._live_referer=e,this.joinAttempts++,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(V)}getStatic(){let e=this.el.getAttribute(ne);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyPortalElements(),this.destroyed=!0,h.deletePrivate(this.el,"view"),delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(Ct,fe,Ae,xt,Oe),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(fe)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),clearTimeout(this.disconnectedTimer),this.setContainerClasses(Ct),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t,i=document){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,s=>t(s,e));if(Y(e))h.findComponentNodeList(this.id,e,i).length===0?k(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let s=Array.from(i.querySelectorAll(e));s.length===0&&k(`nothing found matching the phx-target selector "${e}"`),s.forEach(r=>this.liveSocket.owner(r,o=>t(o,r)))}}applyDiff(e,t,i){this.log(e,()=>["",je(t)]);let{diff:s,reply:r,events:o,title:a}=Je.extract(t);i({diff:s,reply:r,events:o}),(typeof a=="string"||e=="mount")&&window.requestAnimationFrame(()=>h.putTitle(a))}onJoin(e){let{rendered:t,container:i,liveview_version:s,pid:r}=e;if(i){let[o,a]=i;this.el=h.replaceRootContainer(this.el,o,a)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&U.pushState("replace",{type:"patch",id:this.id,position:this.liveSocket.currentHistoryPosition}),s!==this.liveSocket.version()&&console.error(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${s}. To avoid issues, please ensure that your assets use the same version as the server.`),r&&this.el.setAttribute(si,r),U.dropLocal(this.liveSocket.localStorage,window.location.pathname,at),this.applyDiff("mount",t,({diff:o,events:a})=>{this.rendered=new Je(this.id,o);let[l,c]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(l,()=>{this.onJoinComplete(e,l,c,a)})})}dropPendingRefs(){h.all(document,`[${N}="${this.refSrc()}"]`,e=>{e.removeAttribute(ue),e.removeAttribute(N),e.removeAttribute(R)})}onJoinComplete({live_patch:e},t,i,s){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,s);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(ne);return l&&o.setAttribute(ne,l),a&&a.setAttribute(z,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,s)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(z,this.root.id)}execNewMounted(e=document){let t=this.binding(qe),i=this.binding(Ke);this.all(e,`[${t}], [${i}]`,s=>{h.maintainPrivateHooks(s,s,t,i),this.maybeAddNewHook(s)}),this.all(e,`[${this.binding(Ne)}], [data-phx-${Ne}]`,s=>{this.maybeAddNewHook(s)}),this.all(e,`[${this.binding(Lt)}]`,s=>{this.maybeMounted(s)})}all(e,t,i){h.all(e,t,s=>{this.ownsElement(s)&&i(s)})}applyJoinPatch(e,t,i,s){this.attachTrueDocEl();let r=new be(this,this.el,this.id,t,i,null);if(r.markPrunableContentForRemoval(),this.performPatch(r,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(s),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),s=i&&h.isIgnored(e,this.binding(Me));if(i&&!e.isEqualNode(t)&&!(s&&mi(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(Lt)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){let t=this.addHook(e);t&&t.__mounted()}performPatch(e,t,i=!1){let s=[],r=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.after("added",a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]);let l=this.binding(qe),c=this.binding(Ke);h.maintainPrivateHooks(a,a,l,c),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.after("phxChildAdded",a=>{h.isPhxSticky(a)?this.liveSocket.joinRootViews():r=!0}),e.before("updated",(a,l)=>{this.triggerBeforeUpdateHook(a,l)&&o.add(a.id),_.onBeforeElUpdated(a,l)}),e.after("updated",a=>{o.has(a.id)&&this.getHook(a).__updated()}),e.after("discarded",a=>{a.nodeType===Node.ELEMENT_NODE&&s.push(a)}),e.after("transitionsDiscarded",a=>this.afterElementsRemoved(a,t)),e.perform(i),this.afterElementsRemoved(s,t),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),r}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let r=h.all(s,`[${q}]`),o=h.all(s,`[${this.binding(Ne)}], [data-phx-hook]`);r.concat(s).forEach(a=>{let l=this.componentID(a);Y(l)&&i.indexOf(l)===-1&&i.push(l)}),o.concat(s).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(document,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,t){let i=this.binding("change"),s=this.root.formsForRecovery,r=document.createElement("template");r.innerHTML=e;let o=r.content.firstElementChild;o.id=this.id,o.setAttribute(z,this.root.id),o.setAttribute(V,this.getSession()),o.setAttribute(ne,this.getStatic()),o.setAttribute(ie,this.parent?this.parent.id:null);let a=h.all(r.content,"form").filter(l=>l.id&&s[l.id]).filter(l=>!this.pendingForms.has(l.id)).filter(l=>s[l.id].getAttribute(i)===l.getAttribute(i)).map(l=>[s[l.id],l]);if(a.length===0)return t();a.forEach(([l,c],u)=>{this.pendingForms.add(c.id),this.pushFormRecovery(l,c,r.content.firstElementChild,()=>{this.pendingForms.delete(c.id),u===a.length-1&&t()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){var t;return e.id===this.id?this:(t=this.children[e.getAttribute(ie)])==null?void 0:t[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 n(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.pendingForms.clear(),this.formsForRecovery={},this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findExistingParentCIDs(this.id,this.rendered.componentCIDs(e)).forEach(r=>{this.componentPatch(this.rendered.getComponent(e,r),r)&&(i=!0)})}):Xt(e)||this.liveSocket.time("full patch complete",()=>{let[s,r]=this.renderContainer(e,"update"),o=new be(this,this.el,this.id,s,r,null);i=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,s=e?this.rendered.componentCIDs(e):null,{buffer:r,streams:o}=this.rendered.toString(s);return[`<${i}>${r}</${i}>`,o]})}componentPatch(e,t){if(Xt(e))return!1;let{buffer:i,streams:s}=this.rendered.componentToString(t),r=new be(this,this.el,this.id,i,s,t);return this.performPatch(r,!0)}getHook(e){return this.viewHooks[Q.elementID(e)]}addHook(e){let t=Q.elementID(e);if(!(e.getAttribute&&!this.ownsElement(e)))if(t&&!this.viewHooks[t]){let i=h.getCustomElHook(e)||k(`no hook found for custom element: ${e.id}`);return this.viewHooks[t]=i,i.__attachView(this),i}else{if(t||!e.getAttribute)return;{let i=e.getAttribute(`data-phx-${Ne}`)||e.getAttribute(this.binding(Ne));if(!i)return;let s=this.liveSocket.getHookDefinition(i);if(s){if(!e.id){k(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);return}let r;try{if(typeof s=="function"&&s.prototype instanceof Q)r=new s(this,e);else if(typeof s=="object"&&s!==null)r=new Q(this,e,s);else{k(`Invalid hook definition for "${i}". Expected a class extending ViewHook or an object definition.`,e);return}}catch(o){let a=o instanceof Error?o.message:String(o);k(`Failed to create hook "${i}": ${a}`,e);return}return this.viewHooks[Q.elementID(r.el)]=r,r}else i!==null&&k(`unknown hook found for "${i}"`,e)}}}destroyHook(e){let t=Q.elementID(e.el);e.__destroyed(),e.__cleanup__(),delete this.viewHooks[t]}applyPendingUpdates(){this.liveSocket.hasPendingLink()&&this.root.isMain()||(this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates()))}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}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(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:t,kind:i,flash:s}=e,r=this.expandURL(t),o=new CustomEvent("phx:server-navigate",{detail:{to:t,kind:i,flash:s}});this.liveSocket.historyRedirect(o,r,i,s)}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,reloadToken:i}){this.liveSocket.redirect(e,t,i)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}joinPush(){return this.joinPush=this.joinPush||this.channel.join(),this.joinPush}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.wrapPush(()=>this.channel.join(),{ok:t=>this.liveSocket.requestDOMUpdate(()=>this.onJoin(t)),error:t=>this.onJoinError(t),timeout:()=>this.onJoinError({reason:"timeout"})})}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page reload`,e]),this.onRedirect({to:this.root.href,reloadToken:e.token});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.root.href,flash:this.flash});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([fe,Ae,Oe]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=Ht&&(this.root.displayError([fe,Ae,Oe]),this.log("error",()=>[`giving up trying to mount after ${Ht} tries`,e]),this.destroy());let t=h.byId(this.el.id);t?(h.mergeAttrs(t,this.el),this.displayError([fe,Ae,Oe]),this.el=t):this.destroy()}}onClose(e){if(!this.isDestroyed()){if(this.isMain()&&this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),this.liveSocket.isUnloaded()&&this.showLoader(ai)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([fe,Ae,Oe]):this.displayError([fe,Ae,xt]))}displayError(e){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.delayedDisconnected()}delayedDisconnected(){this.disconnectedTimer=setTimeout(()=>{this.execAll(this.binding("disconnected"))},this.liveSocket.disconnectedTimeout)}wrapPush(e,t){let i=this.liveSocket.getLatencySim(),s=i?r=>setTimeout(()=>!this.isDestroyed()&&r(),i):r=>!this.isDestroyed()&&r();s(()=>{e().receive("ok",r=>s(()=>t.ok&&t.ok(r))).receive("error",r=>s(()=>t.error&&t.error(r))).receive("timeout",()=>s(()=>t.timeout&&t.timeout()))})}pushWithReply(e,t,i){if(!this.isConnected())return Promise.reject(new Error("no connection"));let[s,[r],o]=e?e({payload:i}):[null,[],{}],a=this.joinCount,l=function(){};return o.page_loading&&(l=this.liveSocket.withPageLoading({kind:"element",target:r})),typeof i.cid!="number"&&delete i.cid,new Promise((c,u)=>{this.wrapPush(()=>this.channel.push(t,i,ci),{ok:p=>{s!==null&&(this.lastAckRef=s);let m=g=>{p.redirect&&this.onRedirect(p.redirect),p.live_patch&&this.onLivePatch(p.live_patch),p.live_redirect&&this.onLiveRedirect(p.live_redirect),l(),c({resp:p,reply:g,ref:s})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:g,reply:d,events:v})=>{s!==null&&this.undoRefs(s,i.event),this.update(g,v),m(d)})}):(s!==null&&this.undoRefs(s,i.event),m(null))},error:p=>u(new Error(`failed with reason: ${p}`)),timeout:()=>{u(new Error("timeout")),this.joinCount===a&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,t,i){if(!this.isConnected())return;let s=`[${N}="${this.refSrc()}"]`;i?(i=new Set(i),h.all(document,s,r=>{i&&!i.has(r)||(h.all(r,s,o=>this.undoElRef(o,e,t)),this.undoElRef(r,e,t))})):h.all(document,s,r=>this.undoElRef(r,e,t))}undoElRef(e,t,i){new ge(e).maybeUndo(t,i,r=>{let o=new be(this,e,this.id,r,[],null,{undoRef:t}),a=this.performPatch(o,!0);h.all(e,`[${N}="${this.refSrc()}"]`,l=>this.undoElRef(l,t,i)),a&&this.joinNewChildren()})}refSrc(){return this.el.id}putRef(e,t,i,s={}){let r=this.ref++,o=this.binding(Rt);if(s.loading){let a=h.all(document,s.loading).map(l=>({el:l,lock:!0,loading:!0}));e=e.concat(a)}for(let{el:a,lock:l,loading:c}of e){if(!l&&!c)throw new Error("putRef requires lock or loading");if(a.setAttribute(N,this.refSrc()),c&&a.setAttribute(ue,r),l&&a.setAttribute(R,r),!c||s.submitter&&!(a===s.submitter||a===s.form))continue;let u=new Promise(d=>{a.addEventListener(`phx:undo-lock:${r}`,()=>d(g),{once:!0})}),p=new Promise(d=>{a.addEventListener(`phx:undo-loading:${r}`,()=>d(g),{once:!0})});a.classList.add(`phx-${i}-loading`);let m=a.getAttribute(o);m!==null&&(a.getAttribute(De)||a.setAttribute(De,a.innerText),m!==""&&(a.innerText=m),a.setAttribute(pe,a.getAttribute(pe)||a.disabled),a.setAttribute("disabled",""));let g={event:t,eventType:i,ref:r,isLoading:c,isLocked:l,lockElements:e.filter(({lock:d})=>d).map(({el:d})=>d),loadingElements:e.filter(({loading:d})=>d).map(({el:d})=>d),unlock:d=>{d=Array.isArray(d)?d:[d],this.undoRefs(r,t,d)},lockComplete:u,loadingComplete:p,lock:d=>new Promise(v=>{if(this.isAcked(r))return v(g);d.setAttribute(R,r),d.setAttribute(N,this.refSrc()),d.addEventListener(`phx:lock-stop:${r}`,()=>v(g),{once:!0})})};s.payload&&(g.payload=s.payload),s.target&&(g.target=s.target),s.originalEvent&&(g.originalEvent=s.originalEvent),a.dispatchEvent(new CustomEvent("phx:push",{detail:g,bubbles:!0,cancelable:!1})),t&&a.dispatchEvent(new CustomEvent(`phx:push:${t}`,{detail:g,bubbles:!0,cancelable:!1}))}return[r,e.map(({el:a})=>a),s]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){let t=e.getAttribute&&e.getAttribute(q);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(Y(t))return t;let s=i.target||e.getAttribute(this.binding("target"));return Y(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return Y(e)?e:e?re(e.closest(`[${q}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,s]),Promise.reject(new Error("unable to push hook event. LiveView not connected"));let r=()=>this.putRef([{el:e,loading:!0,lock:!0}],i,"hook",{payload:s,target:t});return this.pushWithReply(r,"event",{type:"hook",event:i,value:s,cid:this.closestComponentID(t)}).then(({resp:o,reply:a,ref:l})=>({reply:a,ref:l}))}extractMeta(e,t,i){let s=this.binding("value-");for(let r=0;r<e.attributes.length;r++){t||(t={});let o=e.attributes[r].name;o.startsWith(s)&&(t[o.replace(s,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&ft.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let r in i)t[r]=i[r]}return t}pushEvent(e,t,i,s,r,o={},a){this.pushWithReply(l=>this.putRef([{el:t,loading:!0,lock:!0}],s,e,ae(H({},o),{payload:l==null?void 0:l.payload})),"event",{type:e,event:s,value:this.extractMeta(t,r,o.value),cid:this.targetComponentID(t,i,o)}).then(({reply:l})=>a&&a(l)).catch(l=>k("Failed to push event",l))}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(r,o)=>{r.pushWithReply(null,"progress",{event:e.getAttribute(r.binding(ri)),ref:e.getAttribute(K),entry_ref:t,progress:i,cid:r.targetComponentID(e.form,o)}).then(()=>s()).catch(a=>k("Failed to push file progress",a))})}pushInput(e,t,i,s,r,o){if(!e.form)throw new Error("form events require the input to be inside a form");let a,l=Y(i)?i:this.targetComponentID(e.form,t,r),c=d=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],s,"change",ae(H({},r),{payload:d==null?void 0:d.payload})),u,p=this.extractMeta(e.form,{},r.value),m={};e instanceof HTMLButtonElement&&(m.submitter=e),e.getAttribute(this.binding("change"))?u=St(e.form,m,[e.name]):u=St(e.form,m),h.isUploadInput(e)&&e.files&&e.files.length>0&&x.trackFiles(e,Array.from(e.files)),a=x.serializeUploads(e);let g={type:"form",event:s,value:u,meta:H({_target:r._target||"undefined"},p),uploads:a,cid:l};this.pushWithReply(c,"event",g).then(({resp:d})=>{h.isUploadInput(e)&&h.isAutoUpload(e)?ge.onUnlock(e,()=>{if(x.filesAwaitingPreflight(e).length>0){let[v,E]=c();this.undoRefs(v,s,[e.form]),this.uploadFiles(e.form,s,t,v,l,D=>{o&&o(d),this.triggerAwaitingSubmit(e.form,s),this.undoRefs(v,s)})}}):o&&o(d)}).catch(d=>k("Failed to push input event",d))}triggerAwaitingSubmit(e,t){let i=this.getScheduledSubmit(e);if(i){let[s,r,o,a]=i;this.cancelSubmit(e,t),a()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,s,r])=>t.isSameNode(e))}scheduleSubmit(e,t,i,s){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,s])}cancelSubmit(e,t){this.formSubmits=this.formSubmits.filter(([i,s,r,o])=>i.isSameNode(e)?(this.undoRefs(s,t),!1):!0)}disableForm(e,t,i={}){let s=d=>!(we(d,`${this.binding(Me)}=ignore`,d.form)||we(d,"data-phx-update=ignore",d.form)),r=d=>d.hasAttribute(this.binding(Rt)),o=d=>d.tagName=="BUTTON",a=d=>["INPUT","TEXTAREA","SELECT"].includes(d.tagName),l=Array.from(e.elements),c=l.filter(r),u=l.filter(o).filter(s),p=l.filter(a).filter(s);u.forEach(d=>{d.setAttribute(pe,d.disabled),d.disabled=!0}),p.forEach(d=>{d.setAttribute(ze,d.readOnly),d.readOnly=!0,d.files&&(d.setAttribute(pe,d.disabled),d.disabled=!0)});let m=c.concat(u).concat(p).map(d=>({el:d,loading:!0,lock:!0})),g=[{el:e,loading:!0,lock:!1}].concat(m).reverse();return this.putRef(g,t,"submit",i)}pushFormSubmit(e,t,i,s,r,o){let a=c=>this.disableForm(e,i,ae(H({},r),{form:e,payload:c==null?void 0:c.payload,submitter:s}));h.putPrivate(e,"submitter",s);let l=this.targetComponentID(e,t);if(x.hasUploadsInProgress(e)){let[c,u]=a(),p=()=>this.pushFormSubmit(e,t,i,s,r,o);return this.scheduleSubmit(e,c,r,p)}else if(x.inputsAwaitingPreflight(e).length>0){let[c,u]=a(),p=()=>[c,u,r];this.uploadFiles(e,i,t,c,l,m=>{if(x.inputsAwaitingPreflight(e).length>0)return this.undoRefs(c,i);let g=this.extractMeta(e,{},r.value),d=St(e,{submitter:s});this.pushWithReply(p,"event",{type:"form",event:i,value:d,meta:g,cid:l}).then(({resp:v})=>o(v)).catch(v=>k("Failed to push form submit",v))})}else if(!(e.hasAttribute(N)&&e.classList.contains("phx-submit-loading"))){let c=this.extractMeta(e,{},r.value),u=St(e,{submitter:s});this.pushWithReply(a,"event",{type:"form",event:i,value:u,meta:c,cid:l}).then(({resp:p})=>o(p)).catch(p=>k("Failed to push form submit",p))}}uploadFiles(e,t,i,s,r,o){let a=this.joinCount,l=x.activeFileInputs(e),c=l.length;l.forEach(u=>{let p=new x(u,this,()=>{c--,c===0&&o()}),m=p.entries().map(d=>d.toPreflightPayload());if(m.length===0){c--;return}let g={ref:u.getAttribute(K),entries:m,cid:this.targetComponentID(u.form,i)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g).then(({resp:d})=>{if(this.log("upload",()=>["got preflight response",d]),p.entries().forEach(v=>{d.entries&&!d.entries[v.ref]&&this.handleFailedEntryPreflight(v.ref,"failed preflight",p)}),d.error||Object.keys(d.entries).length===0)this.undoRefs(s,t),(d.error||[]).map(([E,D])=>{this.handleFailedEntryPreflight(E,D,p)});else{let v=E=>{this.channel.onError(()=>{this.joinCount===a&&E()})};p.initAdapterUpload(d,v,this.liveSocket)}}).catch(d=>k("Failed to push upload",d))})}handleFailedEntryPreflight(e,t,i){if(i.isAutoUpload()){let s=i.entries().find(r=>r.ref===e.toString());s&&s.cancel()}else i.entries().map(s=>s.cancel());this.log("upload",()=>[`error for entry ${e}`,t])}dispatchUploads(e,t,i){let s=this.targetCtxElement(e)||this.el,r=h.findUploadInputs(s).filter(o=>o.name===t);r.length===0?k(`no live file inputs found matching the name "${t}"`):r.length>1?k(`duplicate live file inputs found matching the name "${t}"`):h.dispatchEvent(r[0],ct,{detail:{files:i}})}targetCtxElement(e){if(Y(e)){let[t]=h.findComponentNodeList(this.id,e);return t}else return e||null}pushFormRecovery(e,t,i,s){let r=this.binding("change"),o=t.getAttribute(this.binding("target"))||t,a=t.getAttribute(this.binding(It))||t.getAttribute(this.binding("change")),l=Array.from(e.elements).filter(p=>h.isFormInput(p)&&p.name&&!p.hasAttribute(r));if(l.length===0){s();return}l.forEach(p=>p.hasAttribute(K)&&x.clearFiles(p));let c=l.find(p=>p.type!=="hidden")||l[0],u=0;this.withinTargets(o,(p,m)=>{let g=this.targetComponentID(t,m);u++;let d=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});_.exec(d,"change",a,this,c,["push",{_target:c.name,targetView:p,targetCtx:m,newCid:g,callback:()=>{u--,u===0&&s()}}])},i)}pushLinkPatch(e,t,i,s){let r=this.liveSocket.setPendingLink(t),o=e.isTrusted&&e.type!=="popstate",a=i?()=>this.putRef([{el:i,loading:o,lock:!0}],null,"click"):null,l=()=>this.liveSocket.redirect(window.location.href),c=t.startsWith("/")?`${location.protocol}//${location.host}${t}`:t;this.pushWithReply(a,"live_patch",{url:c}).then(({resp:u})=>{this.liveSocket.requestDOMUpdate(()=>{u.link_redirect?this.liveSocket.replaceMain(t,null,s,r):(this.liveSocket.commitPendingLink(r)&&(this.href=t),this.applyPendingUpdates(),s&&s(r))})},({error:u,timeout:p})=>l())}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return h.all(this.el,`form[${e}]`).filter(t=>t.id).filter(t=>t.elements.length>0).filter(t=>t.getAttribute(this.binding(It))!=="ignore").map(t=>{let i=t.cloneNode(!0);it(i,t,{onBeforeElUpdated:(r,o)=>(h.copyPrivates(r,o),!0)});let s=document.querySelectorAll(`[form="${t.id}"]`);return Array.from(s).forEach(r=>{if(t.contains(r))return;let o=r.cloneNode(!0);it(o,r),h.copyPrivates(o,r),i.appendChild(o)}),i}).reduce((t,i)=>(t[i.id]=i,t),{})}maybePushComponentsDestroyed(e){let t=e.filter(s=>h.findComponentNodeList(this.el,s).length===0),i=s=>{this.isDestroyed()||k("Failed to push components destroyed",s)};t.length>0&&(t.forEach(s=>this.rendered.resetRender(s)),this.pushWithReply(null,"cids_will_destroy",{cids:t}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let s=t.filter(r=>h.findComponentNodeList(this.el,r).length===0);s.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:s}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)}).catch(i)})}).catch(i))}ownsElement(e){let t=e.closest(se);return e.getAttribute(ie)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,s,r={}){h.putPrivate(e,Se,!0),Array.from(e.elements).forEach(a=>h.putPrivate(a,Se,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,r,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}pushPortalElementId(e){this.portalElementIds.add(e)}dropPortalElementId(e){this.portalElementIds.delete(e)}destroyPortalElements(){this.portalElementIds.forEach(e=>{let t=document.getElementById(e);t&&t.remove()})}};var Ri=n=>h.isUsedInput(n),st=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
16
16
  a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:
17
17
 
18
18
  import {Socket} from "phoenix"
19
19
  import {LiveSocket} from "phoenix_live_view"
20
20
  let liveSocket = new LiveSocket("/live", Socket, {...})
21
- `);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||hi,this.opts=i,this.params=Ve(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(je(di),i.defaults||{}),this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=je(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||oi,this.disconnectedTimeout=i.disconnectedTimeout||li,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||10,this.reloadJitterMin=i.reloadJitterMin||5e3,this.reloadJitterMax=i.reloadJitterMax||1e4,this.failsafeJitter=i.failsafeJitter||3e4,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.boundEventNames=new Set,this.blockPhxChangeWhileComposing=i.blockPhxChangeWhileComposing||!1,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:Ve(),onPatchEnd:Ve(),onNodeAdded:Ve(),onBeforeElUpdated:Ve()},i.dom||{}),this.transitions=new Jt,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(Qe))||0,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.1.2"}isProfileEnabled(){return this.sessionStorage.getItem(mt)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Ye)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Ye)==="false"}enableDebug(){this.sessionStorage.setItem(Ye,"true")}enableProfiling(){this.sessionStorage.setItem(mt,"true")}disableDebug(){this.sessionStorage.setItem(Ye,"false")}disableProfiling(){this.sessionStorage.removeItem(mt)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(gt,e)}disableLatencySim(){this.sessionStorage.removeItem(gt)}getLatencySim(){let e=this.sessionStorage.getItem(gt);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.resetReloadStatus(),this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.bindTopLevelEvents({dead:!0}),this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off(this.serverCloseRef),this.serverCloseRef=null),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){let s=new CustomEvent("phx:exec",{detail:{sourceElement:e}});this.owner(e,r=>_.exec(s,i,t,r,e))}js(){return yt(this,"js")}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}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[s,r]=i();this.viewLogger(e,t,s,r)}else if(this.isDebugEnabled()){let[s,r]=i();pi(e,t,s,r)}}requestDOMUpdate(e){this.transitions.after(e)}asyncTransition(e){this.transitions.addAsyncTransition(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let r=this.getLatencySim();r?setTimeout(()=>i(s),r):i(s)})}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,r=Math.floor(Math.random()*(s-i+1))+i,o=U.updateLocal(this.localStorage,window.location.pathname,ot,0,a=>a+1);o>=this.maxReloads&&(r=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>=this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},r)}getHookDefinition(e){if(e)return this.maybeInternalHook(e)||this.hooks[e]||this.maybeRuntimeHook(e)}maybeInternalHook(e){return e&&e.startsWith("Phoenix.")&&yi[e.split(".")[1]]}maybeRuntimeHook(e){let t=document.querySelector(`script[${Xe}="${CSS.escape(e)}"]`);if(!t)return;let i=window[`phx_hook_${e}`];if(!i||typeof i!="function"){k("a runtime hook must be a function",t);return}let s=i();if(s&&(typeof s=="object"||typeof s=="function"))return s;k("runtime hook must return an object with hook callbacks or an instance of ViewHook",t)}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)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>{var i;t.execNewMounted(),this.maybeScroll((i=history.state)==null?void 0:i.scroll)})}}joinRootViews(){let e=!1;return h.all(document,`${se}:not([${ie}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);h.isPhxSticky(t)||i.setHref(this.getHref()),i.join(),t.hasAttribute(He)&&(this.main=i)}e=!0}),e}redirect(e,t,i){i&&U.setCookie(Ot,i,60),this.unload(),U.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let r=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.findPhxSticky(document)||[],a=h.all(this.outgoingMainEl,`[${this.binding("remove")}]`).filter(c=>!h.isChildOfAny(c,o)),l=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(l,t,r),this.main.setRedirect(e),this.transitionRemoves(a),this.main.join((c,u)=>{c===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{a.forEach(p=>p.remove()),o.forEach(p=>l.appendChild(p)),this.outgoingMainEl.replaceWith(l),this.outgoingMainEl=null,i&&i(s),u()})})}transitionRemoves(e,t){let i=this.binding("remove"),s=r=>{r.preventDefault(),r.stopImmediatePropagation()};e.forEach(r=>{for(let o of this.boundEventNames)r.addEventListener(o,s,!0);this.execJS(r,r.getAttribute(i),"remove")}),this.requestDOMUpdate(()=>{e.forEach(r=>{for(let o of this.boundEventNames)r.removeEventListener(o,s,!0)}),t&&t()})}isPhxView(e){return e.getAttribute&&e.getAttribute(V)!==null}newRootView(e,t,i){let s=new Te(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i,s=h.closestViewEl(e);return s?i=this.getViewByEl(s):i=this.main,i&&t?t(i):i}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(z);return re(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];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(z));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}getActiveElement(){return document.activeElement}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.serverCloseRef=this.socket.onClose(t=>{if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,s,r,o,a)=>{let l=r.getAttribute(this.binding(ni)),c=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==c)return;let u=H({key:t.key},this.eventMeta(i,t,r));_.exec(t,i,o,s,r,["push",{data:u}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,r,o,a)=>{if(!a){let l=H({key:t.key},this.eventMeta(i,t,r));_.exec(t,i,o,s,r,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,r,o,a)=>{if(a==="window"){let l=this.eventMeta(i,t,r);_.exec(t,i,o,s,r,["push",{data:l}])}}),this.on("dragover",t=>t.preventDefault()),this.on("drop",t=>{t.preventDefault();let i=re(we(t.target,this.binding(Pt)),o=>o.getAttribute(this.binding(Pt))),s=i&&document.getElementById(i),r=Array.from(t.dataTransfer.files||[]);!s||!(s instanceof HTMLInputElement)||s.disabled||r.length===0||!(s.files instanceof FileList)||(x.trackFiles(s,r,t.dataTransfer),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(ht,t=>{let i=t.target;if(!h.isUploadInput(i))return;let s=Array.from(t.detail.files||[]).filter(r=>r instanceof File||r instanceof Blob);x.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let s=this.metadataCallbacks[e];return s?s(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){U.deleteCookie(Ot)}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 s=e[i];this.on(s,r=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=r.target.getAttribute&&r.target.getAttribute(o);l?this.debounce(r.target,r,s,()=>{this.withinOwners(r.target,c=>{t(r,i,c,r.target,l,null)})}):h.all(document,`[${a}]`,c=>{let u=c.getAttribute(a);this.debounce(c,r,s,()=>{this.withinOwners(c,p=>{t(r,i,p,c,u,"window")})})})})}}bindClicks(){this.on("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click")}bindClick(e,t){let i=this.binding(t);window.addEventListener(e,s=>{let r=null;s.detail===0&&(this.clickStartedAtTarget=s.target);let o=this.clickStartedAtTarget||s.target;r=we(s.target,i),this.dispatchClickAway(s,o),this.clickStartedAtTarget=null;let a=r&&r.getAttribute(i);if(!a){h.isNewPageClick(s,window.location)&&this.unload();return}r.getAttribute("href")==="#"&&s.preventDefault(),!r.hasAttribute(N)&&this.debounce(r,s,"click",()=>{this.withinOwners(r,l=>{_.exec(s,"click",a,l,r,["push",{data:this.eventMeta("click",s,r)}])})})},!1)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(s,r=>{let o=s.getAttribute(i);_.isVisible(s)&&_.isInViewport(s)&&_.exec(e,"click",o,r,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}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,backType:s,id:r,scroll:o,position:a}=t.state||{},l=window.location.href,c=a>this.currentHistoryPosition,u=c?i:s||i;this.currentHistoryPosition=a||0,this.sessionStorage.setItem(Qe,this.currentHistoryPosition.toString()),h.dispatchEvent(window,"phx:navigate",{detail:{href:l,patch:u==="patch",pop:!0,direction:c?"forward":"backward"}}),this.requestDOMUpdate(()=>{let p=()=>{this.maybeScroll(o)};this.main.isConnected()&&u==="patch"&&r===this.main.id?this.main.pushLinkPatch(t,l,null,p):this.replaceMain(l,null,p)})},!1),window.addEventListener("click",t=>{let i=we(t.target,lt),s=i&&i.getAttribute(lt);if(!s||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let r=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,o=i.getAttribute(Yt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==r&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(t,r,o,i);else if(s==="redirect")this.historyRedirect(t,r,o,null,i);else throw new Error(`expected ${lt} to be "patch" or "redirect", got: ${s}`);let a=i.getAttribute(this.binding("click"));a&&this.requestDOMUpdate(()=>this.execJS(i,a,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i,s){if(!this.isConnected()||!this.main.isMain())return U.redirect(t);this.withPageLoading({to:t,kind:"patch"},r=>{this.main.pushLinkPatch(e,t,s,o=>{this.historyPatch(t,i,o),r()})})}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Qe,this.currentHistoryPosition.toString()),U.updateCurrentState(s=>ae(H({},s),{backType:"patch"})),U.pushState(t,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},e),h.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i,s,r){let o=r&&e.isTrusted&&e.type!=="popstate";if(o&&r.classList.add("phx-click-loading"),!this.isConnected()||!this.main.isMain())return U.redirect(t,s);if(/^\/$|^\/[^\/]+.*$/.test(t)){let{protocol:l,host:c}=window.location;t=`${l}//${c}${t}`}let a=window.scrollY;this.withPageLoading({to:t,kind:"redirect"},l=>{this.replaceMain(t,s,c=>{c===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Qe,this.currentHistoryPosition.toString()),U.updateCurrentState(u=>ae(H({},u),{backType:"redirect"})),U.pushState(i,{type:"redirect",id:this.main.id,scroll:a,position:this.currentHistoryPosition},t),h.dispatchEvent(window,"phx:navigate",{detail:{href:t,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),o&&r.classList.remove("phx-click-loading"),l()})})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=je(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),r=i.target.getAttribute(this.binding("change"));!t&&r&&!s&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));if(!s){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,r=>{_.exec(i,"submit",s,r,i.target,["push",{submitter:i.submitter}])})});for(let i of["change","input"])this.on(i,s=>{if(s instanceof CustomEvent&&(s.target instanceof HTMLInputElement||s.target instanceof HTMLSelectElement||s.target instanceof HTMLTextAreaElement)&&s.target.form===void 0){if(s.detail&&s.detail.dispatcher)throw new Error(`dispatching a custom ${i} event is only supported on input elements inside a form`);return}let r=this.binding("change"),o=s.target;if(this.blockPhxChangeWhileComposing&&s.isComposing){let d=`composition-listener-${i}`;h.private(o,d)||(h.putPrivate(o,d,!0),o.addEventListener("compositionend",()=>{o.dispatchEvent(new Event(i,{bubbles:!0})),h.deletePrivate(o,d)},{once:!0}));return}let a=o.getAttribute(r),l=o.form&&o.form.getAttribute(r),c=a||l;if(!c||o.type==="number"&&o.validity&&o.validity.badInput)return;let u=a?o:o.form,p=e;e++;let{at:m,type:g}=h.private(o,"prev-iteration")||{};m===p-1&&i==="change"&&g==="input"||(h.putPrivate(o,"prev-iteration",{at:p,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(u,d=>{h.putPrivate(o,ye,!0),_.exec(s,"change",c,d,o,["push",{_target:s.target.name,dispatcher:u}])})}))});this.on("reset",i=>{let s=i.target;h.resetForm(s);let r=Array.from(s.elements).find(o=>o.type==="reset");r&&window.requestAnimationFrame(()=>{r.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let r=this.binding(ti),o=this.binding(ii),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,c=>{let u=()=>!c.isDestroyed()&&document.body.contains(e);h.debounce(e,t,r,a,o,l,u,()=>{s()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){this.boundEventNames.add(e),window.addEventListener(e,i=>{this.silenced||t(i)})}jsQuerySelectorAll(e,t,i){let s=this.domCallbacks.jsQuerySelectorAll;return s?s(e,t,i):i()}},Jt=class{constructor(){this.transitions=new Set,this.promises=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.promises.clear(),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.flushPendingOps()},e);this.transitions.add(s)}addAsyncTransition(e){this.promises.add(e),e.then(()=>{this.promises.delete(e),this.flushPendingOps()})}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size+this.promises.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};var fs=it;function ps(n,e){let t=h.getCustomElHook(n);if(t)return t;let i=new Q(Te.closestView(n),n,e);return h.putCustomElHook(n,i),i}return Ui(ms);})();
21
+ `);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||hi,this.opts=i,this.params=Ve(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(je(di),i.defaults||{}),this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=je(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||oi,this.disconnectedTimeout=i.disconnectedTimeout||li,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||10,this.reloadJitterMin=i.reloadJitterMin||5e3,this.reloadJitterMax=i.reloadJitterMax||1e4,this.failsafeJitter=i.failsafeJitter||3e4,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.boundEventNames=new Set,this.blockPhxChangeWhileComposing=i.blockPhxChangeWhileComposing||!1,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:Ve(),onPatchEnd:Ve(),onNodeAdded:Ve(),onBeforeElUpdated:Ve()},i.dom||{}),this.transitions=new Jt,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(Qe))||0,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.1.3"}isProfileEnabled(){return this.sessionStorage.getItem(gt)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Ye)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Ye)==="false"}enableDebug(){this.sessionStorage.setItem(Ye,"true")}enableProfiling(){this.sessionStorage.setItem(gt,"true")}disableDebug(){this.sessionStorage.setItem(Ye,"false")}disableProfiling(){this.sessionStorage.removeItem(gt)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(vt,e)}disableLatencySim(){this.sessionStorage.removeItem(vt)}getLatencySim(){let e=this.sessionStorage.getItem(vt);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.resetReloadStatus(),this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.bindTopLevelEvents({dead:!0}),this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off(this.serverCloseRef),this.serverCloseRef=null),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){let s=new CustomEvent("phx:exec",{detail:{sourceElement:e}});this.owner(e,r=>_.exec(s,i,t,r,e))}js(){return yt(this,"js")}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}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[s,r]=i();this.viewLogger(e,t,s,r)}else if(this.isDebugEnabled()){let[s,r]=i();pi(e,t,s,r)}}requestDOMUpdate(e){this.transitions.after(e)}asyncTransition(e){this.transitions.addAsyncTransition(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let r=this.getLatencySim();r?setTimeout(()=>i(s),r):i(s)})}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,r=Math.floor(Math.random()*(s-i+1))+i,o=U.updateLocal(this.localStorage,window.location.pathname,at,0,a=>a+1);o>=this.maxReloads&&(r=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>=this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},r)}getHookDefinition(e){if(e)return this.maybeInternalHook(e)||this.hooks[e]||this.maybeRuntimeHook(e)}maybeInternalHook(e){return e&&e.startsWith("Phoenix.")&&yi[e.split(".")[1]]}maybeRuntimeHook(e){let t=document.querySelector(`script[${Xe}="${CSS.escape(e)}"]`);if(!t)return;let i=window[`phx_hook_${e}`];if(!i||typeof i!="function"){k("a runtime hook must be a function",t);return}let s=i();if(s&&(typeof s=="object"||typeof s=="function"))return s;k("runtime hook must return an object with hook callbacks or an instance of ViewHook",t)}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)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>{var i;t.execNewMounted(),this.maybeScroll((i=history.state)==null?void 0:i.scroll)})}}joinRootViews(){let e=!1;return h.all(document,`${se}:not([${ie}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);h.isPhxSticky(t)||i.setHref(this.getHref()),i.join(),t.hasAttribute(He)&&(this.main=i)}e=!0}),e}redirect(e,t,i){i&&U.setCookie(Ot,i,60),this.unload(),U.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let r=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.findPhxSticky(document)||[],a=h.all(this.outgoingMainEl,`[${this.binding("remove")}]`).filter(c=>!h.isChildOfAny(c,o)),l=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(l,t,r),this.main.setRedirect(e),this.transitionRemoves(a),this.main.join((c,u)=>{c===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{a.forEach(p=>p.remove()),o.forEach(p=>l.appendChild(p)),this.outgoingMainEl.replaceWith(l),this.outgoingMainEl=null,i&&i(s),u()})})}transitionRemoves(e,t){let i=this.binding("remove"),s=r=>{r.preventDefault(),r.stopImmediatePropagation()};e.forEach(r=>{for(let o of this.boundEventNames)r.addEventListener(o,s,!0);this.execJS(r,r.getAttribute(i),"remove")}),this.requestDOMUpdate(()=>{e.forEach(r=>{for(let o of this.boundEventNames)r.removeEventListener(o,s,!0)}),t&&t()})}isPhxView(e){return e.getAttribute&&e.getAttribute(V)!==null}newRootView(e,t,i){let s=new Te(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i,s=h.closestViewEl(e);return s?i=this.getViewByEl(s):i=this.main,i&&t?t(i):i}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(z);return re(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];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(z));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}getActiveElement(){return document.activeElement}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.serverCloseRef=this.socket.onClose(t=>{if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,s,r,o,a)=>{let l=r.getAttribute(this.binding(ni)),c=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==c)return;let u=H({key:t.key},this.eventMeta(i,t,r));_.exec(t,i,o,s,r,["push",{data:u}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,r,o,a)=>{if(!a){let l=H({key:t.key},this.eventMeta(i,t,r));_.exec(t,i,o,s,r,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,r,o,a)=>{if(a==="window"){let l=this.eventMeta(i,t,r);_.exec(t,i,o,s,r,["push",{data:l}])}}),this.on("dragover",t=>t.preventDefault()),this.on("drop",t=>{t.preventDefault();let i=re(we(t.target,this.binding(Pt)),o=>o.getAttribute(this.binding(Pt))),s=i&&document.getElementById(i),r=Array.from(t.dataTransfer.files||[]);!s||!(s instanceof HTMLInputElement)||s.disabled||r.length===0||!(s.files instanceof FileList)||(x.trackFiles(s,r,t.dataTransfer),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(ct,t=>{let i=t.target;if(!h.isUploadInput(i))return;let s=Array.from(t.detail.files||[]).filter(r=>r instanceof File||r instanceof Blob);x.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let s=this.metadataCallbacks[e];return s?s(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){U.deleteCookie(Ot)}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 s=e[i];this.on(s,r=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=r.target.getAttribute&&r.target.getAttribute(o);l?this.debounce(r.target,r,s,()=>{this.withinOwners(r.target,c=>{t(r,i,c,r.target,l,null)})}):h.all(document,`[${a}]`,c=>{let u=c.getAttribute(a);this.debounce(c,r,s,()=>{this.withinOwners(c,p=>{t(r,i,p,c,u,"window")})})})})}}bindClicks(){this.on("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click")}bindClick(e,t){let i=this.binding(t);window.addEventListener(e,s=>{let r=null;s.detail===0&&(this.clickStartedAtTarget=s.target);let o=this.clickStartedAtTarget||s.target;r=we(s.target,i),this.dispatchClickAway(s,o),this.clickStartedAtTarget=null;let a=r&&r.getAttribute(i);if(!a){h.isNewPageClick(s,window.location)&&this.unload();return}r.getAttribute("href")==="#"&&s.preventDefault(),!r.hasAttribute(N)&&this.debounce(r,s,"click",()=>{this.withinOwners(r,l=>{_.exec(s,"click",a,l,r,["push",{data:this.eventMeta("click",s,r)}])})})},!1)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(s,r=>{let o=s.getAttribute(i);_.isVisible(s)&&_.isInViewport(s)&&_.exec(e,"click",o,r,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}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,backType:s,id:r,scroll:o,position:a}=t.state||{},l=window.location.href,c=a>this.currentHistoryPosition,u=c?i:s||i;this.currentHistoryPosition=a||0,this.sessionStorage.setItem(Qe,this.currentHistoryPosition.toString()),h.dispatchEvent(window,"phx:navigate",{detail:{href:l,patch:u==="patch",pop:!0,direction:c?"forward":"backward"}}),this.requestDOMUpdate(()=>{let p=()=>{this.maybeScroll(o)};this.main.isConnected()&&u==="patch"&&r===this.main.id?this.main.pushLinkPatch(t,l,null,p):this.replaceMain(l,null,p)})},!1),window.addEventListener("click",t=>{let i=we(t.target,ht),s=i&&i.getAttribute(ht);if(!s||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let r=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,o=i.getAttribute(Yt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==r&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(t,r,o,i);else if(s==="redirect")this.historyRedirect(t,r,o,null,i);else throw new Error(`expected ${ht} to be "patch" or "redirect", got: ${s}`);let a=i.getAttribute(this.binding("click"));a&&this.requestDOMUpdate(()=>this.execJS(i,a,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i,s){if(!this.isConnected()||!this.main.isMain())return U.redirect(t);this.withPageLoading({to:t,kind:"patch"},r=>{this.main.pushLinkPatch(e,t,s,o=>{this.historyPatch(t,i,o),r()})})}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Qe,this.currentHistoryPosition.toString()),U.updateCurrentState(s=>ae(H({},s),{backType:"patch"})),U.pushState(t,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},e),h.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i,s,r){let o=r&&e.isTrusted&&e.type!=="popstate";if(o&&r.classList.add("phx-click-loading"),!this.isConnected()||!this.main.isMain())return U.redirect(t,s);if(/^\/$|^\/[^\/]+.*$/.test(t)){let{protocol:l,host:c}=window.location;t=`${l}//${c}${t}`}let a=window.scrollY;this.withPageLoading({to:t,kind:"redirect"},l=>{this.replaceMain(t,s,c=>{c===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Qe,this.currentHistoryPosition.toString()),U.updateCurrentState(u=>ae(H({},u),{backType:"redirect"})),U.pushState(i,{type:"redirect",id:this.main.id,scroll:a,position:this.currentHistoryPosition},t),h.dispatchEvent(window,"phx:navigate",{detail:{href:t,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),o&&r.classList.remove("phx-click-loading"),l()})})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=je(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),r=i.target.getAttribute(this.binding("change"));!t&&r&&!s&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));if(!s){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,r=>{_.exec(i,"submit",s,r,i.target,["push",{submitter:i.submitter}])})});for(let i of["change","input"])this.on(i,s=>{if(s instanceof CustomEvent&&(s.target instanceof HTMLInputElement||s.target instanceof HTMLSelectElement||s.target instanceof HTMLTextAreaElement)&&s.target.form===void 0){if(s.detail&&s.detail.dispatcher)throw new Error(`dispatching a custom ${i} event is only supported on input elements inside a form`);return}let r=this.binding("change"),o=s.target;if(this.blockPhxChangeWhileComposing&&s.isComposing){let d=`composition-listener-${i}`;h.private(o,d)||(h.putPrivate(o,d,!0),o.addEventListener("compositionend",()=>{o.dispatchEvent(new Event(i,{bubbles:!0})),h.deletePrivate(o,d)},{once:!0}));return}let a=o.getAttribute(r),l=o.form&&o.form.getAttribute(r),c=a||l;if(!c||o.type==="number"&&o.validity&&o.validity.badInput)return;let u=a?o:o.form,p=e;e++;let{at:m,type:g}=h.private(o,"prev-iteration")||{};m===p-1&&i==="change"&&g==="input"||(h.putPrivate(o,"prev-iteration",{at:p,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(u,d=>{h.putPrivate(o,ye,!0),_.exec(s,"change",c,d,o,["push",{_target:s.target.name,dispatcher:u}])})}))});this.on("reset",i=>{let s=i.target;h.resetForm(s);let r=Array.from(s.elements).find(o=>o.type==="reset");r&&window.requestAnimationFrame(()=>{r.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let r=this.binding(ti),o=this.binding(ii),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,c=>{let u=()=>!c.isDestroyed()&&document.body.contains(e);h.debounce(e,t,r,a,o,l,u,()=>{s()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){this.boundEventNames.add(e),window.addEventListener(e,i=>{this.silenced||t(i)})}jsQuerySelectorAll(e,t,i){let s=this.domCallbacks.jsQuerySelectorAll;return s?s(e,t,i):i()}},Jt=class{constructor(){this.transitions=new Set,this.promises=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.promises.clear(),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.flushPendingOps()},e);this.transitions.add(s)}addAsyncTransition(e){this.promises.add(e),e.then(()=>{this.promises.delete(e),this.flushPendingOps()})}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size+this.promises.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};var fs=st;function ps(n,e){let t=h.getCustomElHook(n);if(t)return t;let i=new Q(Te.closestView(n),n,e);return h.putCustomElHook(n,i),i}return Ui(ms);})();