phoenix_live_view 1.1.13 → 1.1.14

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