phoenix_live_view 0.20.2 → 0.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/js/phoenix_live_view/dom.js +3 -3
- package/assets/js/phoenix_live_view/dom_patch.js +7 -15
- package/assets/js/phoenix_live_view/js.js +14 -4
- package/assets/js/phoenix_live_view/rendered.js +24 -43
- package/assets/js/phoenix_live_view/view.js +5 -1
- package/assets/package.json +1 -1
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +51 -70
- package/priv/static/phoenix_live_view.cjs.js.map +2 -2
- package/priv/static/phoenix_live_view.esm.js +51 -70
- package/priv/static/phoenix_live_view.esm.js.map +2 -2
- package/priv/static/phoenix_live_view.js +51 -70
- package/priv/static/phoenix_live_view.min.js +4 -5
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
var LiveView=(()=>{var ft=Object.defineProperty;var Xe=Object.getOwnPropertySymbols;var Dt=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable;var Ht=(r,e,t)=>e in r?ft(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,$=(r,e)=>{for(var t in e||(e={}))Dt.call(e,t)&&Ht(r,t,e[t]);if(Xe)for(var t of Xe(e))Lt.call(e,t)&&Ht(r,t,e[t]);return r};var Ei=r=>ft(r,"__esModule",{value:!0});var Nt=(r,e)=>{var t={};for(var i in r)Dt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&Xe)for(var i of Xe(r))e.indexOf(i)<0&&Lt.call(r,i)&&(t[i]=r[i]);return t};var Ai=(r,e)=>{Ei(r);for(var t in e)ft(r,t,{get:e[t],enumerable:!0})};var Vi={};Ai(Vi,{LiveSocket:()=>ht});var $e="consecutive-reloads",Ft=10,Mt=5e3,Ut=1e4,Xt=3e4,Be=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],M="data-phx-component",Ve="data-phx-link",$t="track-static",Bt="data-phx-link-state",O="data-phx-ref",Q="data-phx-ref-src",Je="track-uploads",B="data-phx-upload-ref",fe="data-phx-preflighted-refs",Vt="data-phx-done-refs",pt="drop-target",xe="data-phx-active-refs",pe="phx:live-file:updated",je="data-phx-skip",We="data-phx-id",mt="data-phx-prune",gt="page-loading",vt="phx-connected",me="phx-loading",qe="phx-no-feedback",ke="phx-error",bt="phx-client-error",Ke="phx-server-error",Z="data-phx-parent-id",ge="data-phx-main",ee="data-phx-root-id",Ge="viewport-top",ze="viewport-bottom",Jt="trigger-action",le="feedback-for",Ce="phx-has-focused",jt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],Ye=["checkbox","radio"],ve="phx-has-submitted",V="data-phx-session",Y=`[${V}]`,Et="data-phx-sticky",se="data-phx-static",Qe="data-phx-readonly",Te="data-phx-disabled",Ie="disable-with",Re="data-phx-disable-with-restore",be="hook",Wt="debounce",qt="throttle",Ee="update",Oe="stream",Ae="data-phx-stream",Kt="key",K="phxPrivate",At="auto-recover",De="phx:live-socket:debug",Ze="phx:live-socket:profiling",et="phx:live-socket:latency-sim",Gt="progress",_t="mounted",zt=1,Yt=200,Qt="phx-",Zt=3e4;var _e="debounce-trigger",Le="throttled",St="debounce-prev-key",ei={debounce:300,throttle:300},He="d",G="s",tt="r",H="c",wt="e",Pt="r",yt="t",ti="p",xt="stream";var it=class{constructor(e,t,i){this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=t,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(e))}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return C("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))}).receive("error",({reason:t})=>this.error(t))}};var C=(r,e)=>console.error&&console.error(r,e),J=r=>{let e=typeof r;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(r)};function ii(){let r=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)r.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):r.add(e[t].id)}var ri=(r,e,t,i)=>{r.liveSocket.isDebugEnabled()&&console.log(`${r.id} ${e}: ${t} - `,i)},rt=r=>typeof r=="function"?r:function(){return r},Se=r=>JSON.parse(JSON.stringify(r)),he=(r,e,t)=>{do{if(r.matches(`[${e}]`)&&!r.disabled)return r;r=r.parentElement||r.parentNode}while(r!==null&&r.nodeType===1&&!(t&&t.isSameNode(r)||r.matches(Y)));return null},we=r=>r!==null&&typeof r=="object"&&!(r instanceof Array),si=(r,e)=>JSON.stringify(r)===JSON.stringify(e),kt=r=>{for(let e in r)return!1;return!0},z=(r,e)=>r&&e(r),ni=function(r,e,t,i){r.forEach(s=>{new it(s,t.config.chunk_size,i).upload()})};var oi={canPushState(){return typeof history.pushState!="undefined"},dropLocal(r,e,t){return r.removeItem(this.localKey(e,t))},updateLocal(r,e,t,i,s){let n=this.getLocal(r,e,t),o=this.localKey(e,t),a=n===null?i:s(n);return r.setItem(o,JSON.stringify(a)),a},getLocal(r,e,t){return JSON.parse(r.getItem(this.localKey(e,t)))},updateCurrentState(r){!this.canPushState()||history.replaceState(r(history.state||{}),"",window.location.href)},pushState(r,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let s=history.state||{};s.scroll=e.scroll,history.replaceState(s,"",window.location.href)}delete e.scroll,history[r+"State"](e,"",t||null);let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)}}else this.redirect(t)},setCookie(r,e){document.cookie=`${r}=${e}`},getCookie(r){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${r}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(r,e){e&&oi.setCookie("__phoenix_flash__",e+"; max-age=60000; path=/"),window.location=r},localKey(r,e){return`${r}-${e}`},getHashTargetEl(r){let e=r.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},j=oi;var W={byId(r){return document.getElementById(r)||C(`no id found for ${r}`)},removeClass(r,e){r.classList.remove(e),r.classList.length===0&&r.removeAttribute("class")},all(r,e,t){if(!r)return[];let i=Array.from(r.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(r){let e=document.createElement("template");return e.innerHTML=r,e.content.childElementCount},isUploadInput(r){return r.type==="file"&&r.getAttribute(B)!==null},isAutoUpload(r){return r.hasAttribute("data-phx-auto-upload")},findUploadInputs(r){return this.all(r,`input[type="file"][${B}]`)},findComponentNodeList(r,e){return this.filterWithinSameLiveView(this.all(r,`[${M}="${e}"]`),r)},isPhxDestroyed(r){return!!(r.id&&W.private(r,"destroyed"))},wantsNewTab(r){let e=r.ctrlKey||r.shiftKey||r.metaKey||r.button&&r.button===1,t=r.target instanceof HTMLAnchorElement&&r.target.hasAttribute("download"),i=r.target.hasAttribute("target")&&r.target.getAttribute("target").toLowerCase()==="_blank";return e||i||t},isUnloadableFormSubmit(r){return r.target&&r.target.getAttribute("method")==="dialog"||r.submitter&&r.submitter.getAttribute("formmethod")==="dialog"?!1:!r.defaultPrevented&&!this.wantsNewTab(r)},isNewPageClick(r,e){let t=r.target instanceof HTMLAnchorElement?r.target.getAttribute("href"):null,i;if(r.defaultPrevented||t===null||this.wantsNewTab(r)||t.startsWith("mailto:")||t.startsWith("tel:")||r.target.isContentEditable)return!1;try{i=new URL(t)}catch(s){try{i=new URL(t,e)}catch(n){return!0}}return i.host===e.host&&i.protocol===e.protocol&&i.pathname===e.pathname&&i.search===e.search?i.hash===""&&!i.href.endsWith("#"):i.protocol.startsWith("http")},markPhxChildDestroyed(r){this.isPhxChild(r)&&r.setAttribute(V,""),this.putPrivate(r,"destroyed",!0)},findPhxChildrenInFragment(r,e){let t=document.createElement("template");return t.innerHTML=r,this.findPhxChildren(t.content,e)},isIgnored(r,e){return(r.getAttribute(e)||r.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(r,e,t){return r.getAttribute&&t.indexOf(r.getAttribute(e))>=0},findPhxSticky(r){return this.all(r,`[${Et}]`)},findPhxChildren(r,e){return this.all(r,`${Y}[${Z}="${e}"]`)},findParentCIDs(r,e){let t=new Set(e),i=e.reduce((s,n)=>{let o=`[${M}="${n}"] [${M}]`;return this.filterWithinSameLiveView(this.all(r,o),r).map(a=>parseInt(a.getAttribute(M))).forEach(a=>s.delete(a)),s},t);return i.size===0?new Set(e):i},filterWithinSameLiveView(r,e){return e.querySelector(Y)?r.filter(t=>this.withinSameLiveView(t,e)):r},withinSameLiveView(r,e){for(;r=r.parentNode;){if(r.isSameNode(e))return!0;if(r.getAttribute(V)!==null)return!1}},private(r,e){return r[K]&&r[K][e]},deletePrivate(r,e){r[K]&&delete r[K][e]},putPrivate(r,e,t){r[K]||(r[K]={}),r[K][e]=t},updatePrivate(r,e,t,i){let s=this.private(r,e);s===void 0?this.putPrivate(r,e,i(t)):this.putPrivate(r,e,i(s))},copyPrivates(r,e){e[K]&&(r[K]=e[K])},putTitle(r){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i}=e.dataset;document.title=`${t||""}${r}${i||""}`}else document.title=r},debounce(r,e,t,i,s,n,o,a){let l=r.getAttribute(t),d=r.getAttribute(s);l===""&&(l=i),d===""&&(d=n);let u=l||d;switch(u){case null:return a();case"blur":this.once(r,"debounce-blur")&&r.addEventListener("blur",()=>a());return;default:let f=parseInt(u),m=()=>d?this.deletePrivate(r,Le):a(),p=this.incCycle(r,_e,m);if(isNaN(f))return C(`invalid throttle/debounce value: ${u}`);if(d){let b=!1;if(e.type==="keydown"){let T=this.private(r,St);this.putPrivate(r,St,e.key),b=T!==e.key}if(!b&&this.private(r,Le))return!1;a(),this.putPrivate(r,Le,!0),setTimeout(()=>{o()&&this.triggerCycle(r,_e)},f)}else setTimeout(()=>{o()&&this.triggerCycle(r,_e,p)},f);let g=r.form;g&&this.once(g,"bind-debounce")&&g.addEventListener("submit",()=>{Array.from(new FormData(g).entries(),([b])=>{let T=g.querySelector(`[name="${b}"]`);this.incCycle(T,_e),this.deletePrivate(T,Le)})}),this.once(r,"bind-debounce")&&r.addEventListener("blur",()=>this.triggerCycle(r,_e))}},triggerCycle(r,e,t){let[i,s]=this.private(r,e);t||(t=i),t===i&&(this.incCycle(r,e),s())},once(r,e){return this.private(r,e)===!0?!1:(this.putPrivate(r,e,!0),!0)},incCycle(r,e,t=function(){}){let[i]=this.private(r,e)||[0,t];return i++,this.putPrivate(r,e,[i,t]),i},maybeAddPrivateHooks(r,e,t){r.hasAttribute&&(r.hasAttribute(e)||r.hasAttribute(t))&&r.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},maybeHideFeedback(r,e,t){let i=[];if(e.forEach(s=>{this.private(s,Ce)||this.private(s,ve)||(i.push(s.name),s.name.endsWith("[]")&&i.push(s.name.slice(0,-2)))}),i.length>0){let s=i.map(n=>`[${t}="${n}"]`).join(", ");W.all(r,s,n=>n.classList.add(qe))}},resetForm(r,e){Array.from(r.elements).forEach(t=>{let i=`[${e}="${t.id}"],
|
|
1
|
+
var LiveView=(()=>{var ft=Object.defineProperty;var Be=Object.getOwnPropertySymbols;var Dt=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable;var Ht=(s,e,t)=>e in s?ft(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,X=(s,e)=>{for(var t in e||(e={}))Dt.call(e,t)&&Ht(s,t,e[t]);if(Be)for(var t of Be(e))Lt.call(e,t)&&Ht(s,t,e[t]);return s};var Ei=s=>ft(s,"__esModule",{value:!0});var Nt=(s,e)=>{var t={};for(var i in s)Dt.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&Be)for(var i of Be(s))e.indexOf(i)<0&&Lt.call(s,i)&&(t[i]=s[i]);return t};var Ai=(s,e)=>{Ei(s);for(var t in e)ft(s,t,{get:e[t],enumerable:!0})};var Bi={};Ai(Bi,{LiveSocket:()=>ht});var Ve="consecutive-reloads",Ft=10,Mt=5e3,Ut=1e4,Xt=3e4,Je=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],F="data-phx-component",je="data-phx-link",$t="track-static",Bt="data-phx-link-state",R="data-phx-ref",Y="data-phx-ref-src",We="track-uploads",$="data-phx-upload-ref",fe="data-phx-preflighted-refs",Vt="data-phx-done-refs",pt="drop-target",xe="data-phx-active-refs",pe="phx:live-file:updated",qe="data-phx-skip",Ke="data-phx-id",mt="data-phx-prune",gt="page-loading",vt="phx-connected",me="phx-loading",Ge="phx-no-feedback",ke="phx-error",bt="phx-client-error",ze="phx-server-error",Z="data-phx-parent-id",ge="data-phx-main",ee="data-phx-root-id",Ce="viewport-top",Te="viewport-bottom",Jt="trigger-action",le="feedback-for",Ie="phx-has-focused",jt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],Ye=["checkbox","radio"],ve="phx-has-submitted",B="data-phx-session",Q=`[${B}]`,Et="data-phx-sticky",re="data-phx-static",Qe="data-phx-readonly",Re="data-phx-disabled",Oe="disable-with",De="data-phx-disable-with-restore",be="hook",Wt="debounce",qt="throttle",Ee="update",Le="stream",Ae="data-phx-stream",Kt="key",K="phxPrivate",At="auto-recover",He="phx:live-socket:debug",Ze="phx:live-socket:profiling",et="phx:live-socket:latency-sim",Gt="progress",_t="mounted",zt=1,Yt=200,Qt="phx-",Zt=3e4;var _e="debounce-trigger",Ne="throttled",St="debounce-prev-key",ei={debounce:300,throttle:300},Fe="d",G="s",tt="r",L="c",wt="e",yt="r",Pt="t",ti="p",xt="stream";var it=class{constructor(e,t,i){this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=t,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(e))}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return C("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))}).receive("error",({reason:t})=>this.error(t))}};var C=(s,e)=>console.error&&console.error(s,e),V=s=>{let e=typeof s;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(s)};function ii(){let s=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)s.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):s.add(e[t].id)}var si=(s,e,t,i)=>{s.liveSocket.isDebugEnabled()&&console.log(`${s.id} ${e}: ${t} - `,i)},st=s=>typeof s=="function"?s:function(){return s},Se=s=>JSON.parse(JSON.stringify(s)),he=(s,e,t)=>{do{if(s.matches(`[${e}]`)&&!s.disabled)return s;s=s.parentElement||s.parentNode}while(s!==null&&s.nodeType===1&&!(t&&t.isSameNode(s)||s.matches(Q)));return null},we=s=>s!==null&&typeof s=="object"&&!(s instanceof Array),ri=(s,e)=>JSON.stringify(s)===JSON.stringify(e),kt=s=>{for(let e in s)return!1;return!0},z=(s,e)=>s&&e(s),ni=function(s,e,t,i){s.forEach(r=>{new it(r,t.config.chunk_size,i).upload()})};var oi={canPushState(){return typeof history.pushState!="undefined"},dropLocal(s,e,t){return s.removeItem(this.localKey(e,t))},updateLocal(s,e,t,i,r){let n=this.getLocal(s,e,t),o=this.localKey(e,t),a=n===null?i:r(n);return s.setItem(o,JSON.stringify(a)),a},getLocal(s,e,t){return JSON.parse(s.getItem(this.localKey(e,t)))},updateCurrentState(s){!this.canPushState()||history.replaceState(s(history.state||{}),"",window.location.href)},pushState(s,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let r=history.state||{};r.scroll=e.scroll,history.replaceState(r,"",window.location.href)}delete e.scroll,history[s+"State"](e,"",t||null);let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)}}else this.redirect(t)},setCookie(s,e){document.cookie=`${s}=${e}`},getCookie(s){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${s}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(s,e){e&&oi.setCookie("__phoenix_flash__",e+"; max-age=60000; path=/"),window.location=s},localKey(s,e){return`${s}-${e}`},getHashTargetEl(s){let e=s.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},J=oi;var j={byId(s){return document.getElementById(s)||C(`no id found for ${s}`)},removeClass(s,e){s.classList.remove(e),s.classList.length===0&&s.removeAttribute("class")},all(s,e,t){if(!s)return[];let i=Array.from(s.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(s){let e=document.createElement("template");return e.innerHTML=s,e.content.childElementCount},isUploadInput(s){return s.type==="file"&&s.getAttribute($)!==null},isAutoUpload(s){return s.hasAttribute("data-phx-auto-upload")},findUploadInputs(s){return this.all(s,`input[type="file"][${$}]`)},findComponentNodeList(s,e){return this.filterWithinSameLiveView(this.all(s,`[${F}="${e}"]`),s)},isPhxDestroyed(s){return!!(s.id&&j.private(s,"destroyed"))},wantsNewTab(s){let e=s.ctrlKey||s.shiftKey||s.metaKey||s.button&&s.button===1,t=s.target instanceof HTMLAnchorElement&&s.target.hasAttribute("download"),i=s.target.hasAttribute("target")&&s.target.getAttribute("target").toLowerCase()==="_blank";return e||i||t},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,e){let t=s.target instanceof HTMLAnchorElement?s.target.getAttribute("href"):null,i;if(s.defaultPrevented||t===null||this.wantsNewTab(s)||t.startsWith("mailto:")||t.startsWith("tel:")||s.target.isContentEditable)return!1;try{i=new URL(t)}catch(r){try{i=new URL(t,e)}catch(n){return!0}}return i.host===e.host&&i.protocol===e.protocol&&i.pathname===e.pathname&&i.search===e.search?i.hash===""&&!i.href.endsWith("#"):i.protocol.startsWith("http")},markPhxChildDestroyed(s){this.isPhxChild(s)&&s.setAttribute(B,""),this.putPrivate(s,"destroyed",!0)},findPhxChildrenInFragment(s,e){let t=document.createElement("template");return t.innerHTML=s,this.findPhxChildren(t.content,e)},isIgnored(s,e){return(s.getAttribute(e)||s.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(s,e,t){return s.getAttribute&&t.indexOf(s.getAttribute(e))>=0},findPhxSticky(s){return this.all(s,`[${Et}]`)},findPhxChildren(s,e){return this.all(s,`${Q}[${Z}="${e}"]`)},findParentCIDs(s,e){let t=new Set(e),i=e.reduce((r,n)=>{let o=`[${F}="${n}"] [${F}]`;return this.filterWithinSameLiveView(this.all(s,o),s).map(a=>parseInt(a.getAttribute(F))).forEach(a=>r.delete(a)),r},t);return i.size===0?new Set(e):i},filterWithinSameLiveView(s,e){return e.querySelector(Q)?s.filter(t=>this.withinSameLiveView(t,e)):s},withinSameLiveView(s,e){for(;s=s.parentNode;){if(s.isSameNode(e))return!0;if(s.getAttribute(B)!==null)return!1}},private(s,e){return s[K]&&s[K][e]},deletePrivate(s,e){s[K]&&delete s[K][e]},putPrivate(s,e,t){s[K]||(s[K]={}),s[K][e]=t},updatePrivate(s,e,t,i){let r=this.private(s,e);r===void 0?this.putPrivate(s,e,i(t)):this.putPrivate(s,e,i(r))},copyPrivates(s,e){e[K]&&(s[K]=e[K])},putTitle(s){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i}=e.dataset;document.title=`${t||""}${s}${i||""}`}else document.title=s},debounce(s,e,t,i,r,n,o,a){let l=s.getAttribute(t),d=s.getAttribute(r);l===""&&(l=i),d===""&&(d=n);let u=l||d;switch(u){case null:return a();case"blur":this.once(s,"debounce-blur")&&s.addEventListener("blur",()=>a());return;default:let f=parseInt(u),g=()=>d?this.deletePrivate(s,Ne):a(),m=this.incCycle(s,_e,g);if(isNaN(f))return C(`invalid throttle/debounce value: ${u}`);if(d){let b=!1;if(e.type==="keydown"){let T=this.private(s,St);this.putPrivate(s,St,e.key),b=T!==e.key}if(!b&&this.private(s,Ne))return!1;a(),this.putPrivate(s,Ne,!0),setTimeout(()=>{o()&&this.triggerCycle(s,_e)},f)}else setTimeout(()=>{o()&&this.triggerCycle(s,_e,m)},f);let p=s.form;p&&this.once(p,"bind-debounce")&&p.addEventListener("submit",()=>{Array.from(new FormData(p).entries(),([b])=>{let T=p.querySelector(`[name="${b}"]`);this.incCycle(T,_e),this.deletePrivate(T,Ne)})}),this.once(s,"bind-debounce")&&s.addEventListener("blur",()=>this.triggerCycle(s,_e))}},triggerCycle(s,e,t){let[i,r]=this.private(s,e);t||(t=i),t===i&&(this.incCycle(s,e),r())},once(s,e){return this.private(s,e)===!0?!1:(this.putPrivate(s,e,!0),!0)},incCycle(s,e,t=function(){}){let[i]=this.private(s,e)||[0,t];return i++,this.putPrivate(s,e,[i,t]),i},maybeAddPrivateHooks(s,e,t){s.hasAttribute&&(s.hasAttribute(e)||s.hasAttribute(t))&&s.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},maybeHideFeedback(s,e,t){let i=[];if(e.forEach(r=>{this.private(r,Ie)||this.private(r,ve)||(i.push(r.name),r.name.endsWith("[]")&&i.push(r.name.slice(0,-2)))}),i.length>0){let r=i.map(n=>`[${t}="${n}"]`).join(", ");j.all(s,r,n=>n.classList.add(Ge))}},resetForm(s,e){Array.from(s.elements).forEach(t=>{let i=`[${e}="${t.id}"],
|
|
2
2
|
[${e}="${t.name}"],
|
|
3
|
-
[${e}="${t.name.replace(/\[\]$/,"")}"]`;this.deletePrivate(t,
|
|
3
|
+
[${e}="${t.name.replace(/\[\]$/,"")}"]`;this.deletePrivate(t,Ie),this.deletePrivate(t,ve),this.all(document,i,r=>{r.classList.add(Ge)})})},showError(s,e){(s.id||s.name)&&this.all(s.form,`[${e}="${s.id}"], [${e}="${s.name}"]`,t=>{this.removeClass(t,Ge)})},isPhxChild(s){return s.getAttribute&&s.getAttribute(Z)},isPhxSticky(s){return s.getAttribute&&s.getAttribute(Et)!==null},firstPhxChild(s){return this.isPhxChild(s)?s:this.all(s,`[${Z}]`)[0]},dispatchEvent(s,e,t={}){let r={bubbles:t.bubbles===void 0?!0:!!t.bubbles,cancelable:!0,detail:t.detail||{}},n=e==="click"?new MouseEvent("click",r):new CustomEvent(e,r);s.dispatchEvent(n)},cloneNode(s,e){if(typeof e=="undefined")return s.cloneNode(!0);{let t=s.cloneNode(!1);return t.innerHTML=e,t}},mergeAttrs(s,e,t={}){let i=t.exclude||[],r=t.isIgnored,n=e.attributes;for(let a=n.length-1;a>=0;a--){let l=n[a].name;i.indexOf(l)<0&&s.setAttribute(l,e.getAttribute(l))}let o=s.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;r?l.startsWith("data-")&&!e.hasAttribute(l)&&![R,Y].includes(l)&&s.removeAttribute(l):e.hasAttribute(l)||s.removeAttribute(l)}},mergeFocusedInput(s,e){j.mergeAttrs(s,e,{exclude:["value"]}),e.readOnly?s.setAttribute("readonly",!0):s.removeAttribute("readonly")},hasSelectionRange(s){return s.setSelectionRange&&(s.type==="text"||s.type==="textarea")},restoreFocus(s,e,t){if(!j.isTextualInput(s))return;let i=s.matches(":focus");s.readOnly&&s.blur(),i||s.focus(),this.hasSelectionRange(s)&&s.setSelectionRange(e,t)},isFormInput(s){return/^(?:input|select|textarea)$/i.test(s.tagName)&&s.type!=="button"},syncAttrsToProps(s){s instanceof HTMLInputElement&&Ye.indexOf(s.type.toLocaleLowerCase())>=0&&(s.checked=s.getAttribute("checked")!==null)},isTextualInput(s){return jt.indexOf(s.type)>=0},isNowTriggerFormExternal(s,e){return s.getAttribute&&s.getAttribute(e)!==null},syncPendingRef(s,e,t){let i=s.getAttribute(R);if(i===null)return!0;let r=s.getAttribute(Y);return j.isFormInput(s)||s.getAttribute(t)!==null?(j.isUploadInput(s)&&j.mergeAttrs(s,e,{isIgnored:!0}),j.putPrivate(s,R,e),!1):(Je.forEach(n=>{s.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(R,i),e.setAttribute(Y,r),!0)},cleanChildNodes(s,e){if(j.isPhxUpdate(s,e,["append","prepend"])){let t=[];s.childNodes.forEach(i=>{i.id||(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()===""||C(`only HTML element tags with an id are allowed inside containers with phx-update.
|
|
4
4
|
|
|
5
5
|
removing illegal node: "${(i.outerHTML||i.nodeValue).trim()}"
|
|
6
6
|
|
|
7
|
-
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(r,e,t){let i=new Set(["id",V,se,ge,ee]);if(r.tagName.toLowerCase()===e.toLowerCase())return Array.from(r.attributes).filter(s=>!i.has(s.name.toLowerCase())).forEach(s=>r.removeAttribute(s.name)),Object.keys(t).filter(s=>!i.has(s.toLowerCase())).forEach(s=>r.setAttribute(s,t[s])),r;{let s=document.createElement(e);return Object.keys(t).forEach(n=>s.setAttribute(n,t[n])),i.forEach(n=>s.setAttribute(n,r.getAttribute(n))),s.innerHTML=r.innerHTML,r.replaceWith(s),s}},getSticky(r,e,t){let i=(W.private(r,"sticky")||[]).find(([s])=>e===s);if(i){let[s,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(r,e){this.updatePrivate(r,"sticky",[],t=>t.filter(([i,s])=>i!==e))},putSticky(r,e,t){let i=t(r);this.updatePrivate(r,"sticky",[],s=>{let n=s.findIndex(([o])=>e===o);return n>=0?s[n]=[e,t,i]:s.push([e,t,i]),s})},applyStickyOperations(r){let e=W.private(r,"sticky");!e||e.forEach(([t,i,s])=>this.putSticky(r,t,i))}},h=W;var Pe=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(xe).split(",").indexOf(P.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(fe).split(",").indexOf(P.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=P.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(pe,this._onElUpdated)}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{P.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}cancel(){this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(pe,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),h.isAutoUpload(this.fileEl)||P.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(pe,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(xe).split(",").indexOf(this.ref)===-1&&this.cancel()}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||C(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:ni}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||C(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var _i=0,P=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(_i++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(fe)!==i.getAttribute(Vt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},o=e.getAttribute(B);i[o]=i[o]||[],n.ref=this.genFileRef(s),n.last_modified=s.lastModified,n.name=s.name||n.ref,n.relative_path=s.webkitRelativePath,n.type=s.type,n.size=s.size,typeof s.meta=="function"&&(n.meta=s.meta()),i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(B),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let s=t.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));h.putPrivate(e,"files",this.activeFiles(e).concat(s)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>Pe.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!Pe.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(P.filesAwaitingPreflight(e)||[]).map(s=>new Pe(e,s,t)),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),n));let s=this._entries.reduce((n,o)=>{if(!o.meta)return n;let{name:a,callback:l}=o.uploader(i.uploaders);return n[a]=n[a]||{callback:l,entries:[]},n[a].entries.push(o),n},{});for(let n in s){let{callback:o,entries:a}=s[n];o(a,t,e,i)}}};var Si={focusMain(){let r=document.querySelector("main h1, main, h1");if(r){let e=r.tabIndex;r.tabIndex=-1,r.focus(),r.tabIndex=e}},anyOf(r,e){return e.find(t=>r instanceof t)},isFocusable(r,e){return r instanceof HTMLAnchorElement&&r.rel!=="ignore"||r instanceof HTMLAreaElement&&r.href!==void 0||!r.disabled&&this.anyOf(r,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||r instanceof HTMLIFrameElement||r.tabIndex>0||!e&&r.getAttribute("tabindex")!==null&&r.getAttribute("aria-hidden")!=="true"},attemptFocus(r,e){if(this.isFocusable(r,e))try{r.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(r)},focusFirstInteractive(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(r){let e=r.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},ne=Si;var ai={LiveFileUpload:{activeRefs(){return this.el.getAttribute(xe)},preflightedRefs(){return this.el.getAttribute(fe)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let r=this.preflightedRefs();this.preflightedWas!==r&&(this.preflightedWas=r,r===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(pe))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(B)),P.getEntryDataURL(this.inputEl,this.ref,r=>{this.url=r,this.el.src=r})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>ne.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>ne.focusFirst(this.el)),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&ne.focusFirst(this.el)}}},li=()=>document.documentElement.scrollTop||document.body.scrollTop,Ct=()=>window.innerHeight||document.documentElement.clientHeight,wi=r=>{let e=r.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.top<=Ct()},Pi=r=>{let e=r.getBoundingClientRect();return e.right>=0&&e.left>=0&&e.bottom<=Ct()},hi=r=>{let e=r.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.top<=Ct()};ai.InfiniteScroll={mounted(){let r=li(),e=!1,t=500,i=null,s=this.throttle(t,(a,l)=>{i=()=>!0,this.liveSocket.execJSHookPush(this.el,a,{id:l.id,_overran:!0},()=>{i=null})}),n=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"start"}),this.liveSocket.execJSHookPush(this.el,a,{id:l.id},()=>{i=null,hi(l)||l.scrollIntoView({block:"start"})})}),o=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"end"}),this.liveSocket.execJSHookPush(this.el,a,{id:l.id},()=>{i=null,hi(l)||l.scrollIntoView({block:"end"})})});this.onScroll=a=>{let l=li();if(i)return r=l,i();let d=this.el.getBoundingClientRect(),u=this.el.getAttribute(this.liveSocket.binding("viewport-top")),f=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),m=this.el.lastElementChild,p=this.el.firstElementChild,g=l<r,b=l>r;g&&u&&!e&&d.top>=0?(e=!0,s(u,p)):b&&e&&d.top<=0&&(e=!1),u&&g&&wi(p)?n(u,p):f&&b&&Pi(m)&&o(f,m),r=l},window.addEventListener("scroll",this.onScroll)},destroyed(){window.removeEventListener("scroll",this.onScroll)},throttle(r,e){let t=0,i;return(...s)=>{let n=Date.now(),o=r-(n-t);o<=0||o>r?(i&&(clearTimeout(i),i=null),t=n,e(...s)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...s)},o))}}};var di=ai;var st=class{constructor(e,t,i){let s=new Set,n=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(s.add(a.id),n.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!s.has(a))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?z(document.getElementById(t.previousElementId),i=>{z(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):z(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{z(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var ci=11;function yi(r,e){var t=e.attributes,i,s,n,o,a;if(!(e.nodeType===ci||r.nodeType===ci)){for(var l=t.length-1;l>=0;l--)i=t[l],s=i.name,n=i.namespaceURI,o=i.value,n?(s=i.localName||s,a=r.getAttributeNS(n,s),a!==o&&(i.prefix==="xmlns"&&(s=i.name),r.setAttributeNS(n,s,o))):(a=r.getAttribute(s),a!==o&&r.setAttribute(s,o));for(var d=r.attributes,u=d.length-1;u>=0;u--)i=d[u],s=i.name,n=i.namespaceURI,n?(s=i.localName||s,e.hasAttributeNS(n,s)||r.removeAttributeNS(n,s)):e.hasAttribute(s)||r.removeAttribute(s)}}var nt,xi="http://www.w3.org/1999/xhtml",N=typeof document=="undefined"?void 0:document,ki=!!N&&"content"in N.createElement("template"),Ci=!!N&&N.createRange&&"createContextualFragment"in N.createRange();function Ti(r){var e=N.createElement("template");return e.innerHTML=r,e.content.childNodes[0]}function Ii(r){nt||(nt=N.createRange(),nt.selectNode(N.body));var e=nt.createContextualFragment(r);return e.childNodes[0]}function Ri(r){var e=N.createElement("body");return e.innerHTML=r,e.childNodes[0]}function Oi(r){return r=r.trim(),ki?Ti(r):Ci?Ii(r):Ri(r)}function ot(r,e){var t=r.nodeName,i=e.nodeName,s,n;return t===i?!0:(s=t.charCodeAt(0),n=i.charCodeAt(0),s<=90&&n>=97?t===i.toUpperCase():n<=90&&s>=97?i===t.toUpperCase():!1)}function Di(r,e){return!e||e===xi?N.createElement(r):N.createElementNS(e,r)}function Li(r,e){for(var t=r.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Tt(r,e,t){r[t]!==e[t]&&(r[t]=e[t],r[t]?r.setAttribute(t,""):r.removeAttribute(t))}var ui={OPTION:function(r,e){var t=r.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(r.hasAttribute("selected")&&!e.selected&&(r.setAttribute("selected","selected"),r.removeAttribute("selected")),t.selectedIndex=-1)}Tt(r,e,"selected")},INPUT:function(r,e){Tt(r,e,"checked"),Tt(r,e,"disabled"),r.value!==e.value&&(r.value=e.value),e.hasAttribute("value")||r.removeAttribute("value")},TEXTAREA:function(r,e){var t=e.value;r.value!==t&&(r.value=t);var i=r.firstChild;if(i){var s=i.nodeValue;if(s==t||!t&&s==r.placeholder)return;i.nodeValue=t}},SELECT:function(r,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,s=r.firstChild,n,o;s;)if(o=s.nodeName&&s.nodeName.toUpperCase(),o==="OPTGROUP")n=s,s=n.firstChild;else{if(o==="OPTION"){if(s.hasAttribute("selected")){t=i;break}i++}s=s.nextSibling,!s&&n&&(s=n.nextSibling,n=null)}r.selectedIndex=t}}},Ne=1,fi=11,pi=3,mi=8;function oe(){}function Hi(r){if(r)return r.getAttribute&&r.getAttribute("id")||r.id}function Ni(r){return function(t,i,s){if(s||(s={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=N.createElement("html"),i.innerHTML=n}else i=Oi(i);else i.nodeType===fi&&(i=i.firstElementChild);var o=s.getNodeKey||Hi,a=s.onBeforeNodeAdded||oe,l=s.onNodeAdded||oe,d=s.onBeforeElUpdated||oe,u=s.onElUpdated||oe,f=s.onBeforeNodeDiscarded||oe,m=s.onNodeDiscarded||oe,p=s.onBeforeElChildrenUpdated||oe,g=s.skipFromChildren||oe,b=s.addChild||function(E,v){return E.appendChild(v)},T=s.childrenOnly===!0,I=Object.create(null),D=[];function U(E){D.push(E)}function L(E,v){if(E.nodeType===Ne)for(var x=E.firstChild;x;){var _=void 0;v&&(_=o(x))?U(_):(m(x),x.firstChild&&L(x,v)),x=x.nextSibling}}function c(E,v,x){f(E)!==!1&&(v&&v.removeChild(E),m(E),L(E,x))}function A(E){if(E.nodeType===Ne||E.nodeType===fi)for(var v=E.firstChild;v;){var x=o(v);x&&(I[x]=v),A(v),v=v.nextSibling}}A(t);function X(E){l(E);for(var v=E.firstChild;v;){var x=v.nextSibling,_=o(v);if(_){var y=I[_];y&&ot(v,y)?(v.parentNode.replaceChild(y,v),S(y,v)):X(v)}else X(v);v=x}}function k(E,v,x){for(;v;){var _=v.nextSibling;(x=o(v))?U(x):c(v,E,!0),v=_}}function S(E,v,x){var _=o(v);_&&delete I[_],!(!x&&(d(E,v)===!1||(r(E,v),u(E),p(E,v)===!1)))&&(E.nodeName!=="TEXTAREA"?R(E,v):ui.TEXTAREA(E,v))}function R(E,v){var x=g(E,v),_=v.firstChild,y=E.firstChild,ce,te,ue,Me,ie;e:for(;_;){for(Me=_.nextSibling,ce=o(_);!x&&y;){if(ue=y.nextSibling,_.isSameNode&&_.isSameNode(y)){_=Me,y=ue;continue e}te=o(y);var Ue=y.nodeType,re=void 0;if(Ue===_.nodeType&&(Ue===Ne?(ce?ce!==te&&((ie=I[ce])?ue===ie?re=!1:(E.insertBefore(ie,y),te?U(te):c(y,E,!0),y=ie):re=!1):te&&(re=!1),re=re!==!1&&ot(y,_),re&&S(y,_)):(Ue===pi||Ue==mi)&&(re=!0,y.nodeValue!==_.nodeValue&&(y.nodeValue=_.nodeValue))),re){_=Me,y=ue;continue e}te?U(te):c(y,E,!0),y=ue}if(ce&&(ie=I[ce])&&ot(ie,_))x||b(E,ie),S(ie,_);else{var ut=a(_);ut!==!1&&(ut&&(_=ut),_.actualize&&(_=_.actualize(E.ownerDocument||N)),b(E,_),X(_))}_=Me,y=ue}k(E,y,te);var Ot=ui[E.nodeName];Ot&&Ot(E,v)}var w=t,q=w.nodeType,Rt=i.nodeType;if(!T){if(q===Ne)Rt===Ne?ot(t,i)||(m(t),w=Li(t,Di(i.nodeName,i.namespaceURI))):w=i;else if(q===pi||q===mi){if(Rt===q)return w.nodeValue!==i.nodeValue&&(w.nodeValue=i.nodeValue),w;w=i}}if(w===i)m(t);else{if(i.isSameNode&&i.isSameNode(w))return;if(S(w,i,T),D)for(var dt=0,bi=D.length;dt<bi;dt++){var ct=I[D[dt]];ct&&c(ct,ct.parentNode,!1)}}return!T&&w!==t&&t.parentNode&&(w.actualize&&(w=w.actualize(t.ownerDocument||N)),t.parentNode.replaceChild(w,t)),w}}var Fi=Ni(yi),It=Fi;var de=class{static patchEl(e,t,i){It(e,t,{childrenOnly:!1,onBeforeElUpdated:(s,n)=>{if(i&&i.isSameNode(s)&&h.isFormInput(s))return h.mergeFocusedInput(s,n),!1}})}constructor(e,t,i,s,n,o){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.streams=n,this.streamInserts={},this.targetCID=o,this.cidPatch=J(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(Ee);h.all(this.container,`[${e}=${Oe}]`,t=>t.innerHTML=""),h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(mt,"")})}perform(e){let{view:t,liveSocket:i,container:s,html:n}=this,o=this.isCIDPatch()?this.targetCIDContainer(n):s;if(this.isCIDPatch()&&!o)return;let a=i.getActiveElement(),{selectionStart:l,selectionEnd:d}=a&&h.hasSelectionRange(a)?a:{},u=i.binding(Ee),f=i.binding(le),m=i.binding(Ie),p=i.binding(Ge),g=i.binding(ze),b=i.binding(Jt),T=[],I=[],D=[],U=[],L=null;return this.trackBefore("added",s),this.trackBefore("updated",s,s),i.time("morphdom",()=>{this.streams.forEach(([c,A,X,k])=>{Object.entries(A).forEach(([S,[R,w]])=>{this.streamInserts[S]={ref:c,streamAt:R,limit:w,resetKept:!1}}),k!==void 0&&h.all(s,`[${Ae}="${c}"]`,S=>{A[S.id]?this.streamInserts[S.id].resetKept=!0:this.removeStreamChildElement(S)}),X.forEach(S=>{let R=s.querySelector(`[id="${S}"]`);R&&this.removeStreamChildElement(R)})}),It(o,n,{childrenOnly:o.getAttribute(M)===null,getNodeKey:c=>h.isPhxDestroyed(c)?null:e?c.id:c.id||c.getAttribute&&c.getAttribute(We),skipFromChildren:c=>c.getAttribute(u)===Oe,addChild:(c,A)=>{let{ref:X,streamAt:k,limit:S}=this.getStreamInsert(A);if(X===void 0)return c.appendChild(A);if(h.putSticky(A,Ae,q=>q.setAttribute(Ae,X)),k===0)c.insertAdjacentElement("afterbegin",A);else if(k===-1)c.appendChild(A);else if(k>0){let q=Array.from(c.children)[k];c.insertBefore(A,q)}let R=S!==null&&Array.from(c.children),w=[];S&&S<0&&R.length>S*-1?w=R.slice(0,R.length+S):S&&S>=0&&R.length>S&&(w=R.slice(S)),w.forEach(q=>{this.streamInserts[q.id]||this.removeStreamChildElement(q)})},onBeforeNodeAdded:c=>(h.maybeAddPrivateHooks(c,p,g),this.trackBefore("added",c),c),onNodeAdded:c=>{c.getAttribute&&this.maybeReOrderStream(c),c instanceof HTMLImageElement&&c.srcset?c.srcset=c.srcset:c instanceof HTMLVideoElement&&c.autoplay&&c.play(),h.isNowTriggerFormExternal(c,b)&&(L=c),c.getAttribute&&c.getAttribute("name")&&h.isFormInput(c)&&I.push(c),(h.isPhxChild(c)&&t.ownsElement(c)||h.isPhxSticky(c)&&t.ownsElement(c.parentNode))&&this.trackAfter("phxChildAdded",c),T.push(c)},onBeforeElChildrenUpdated:(c,A)=>{if(c.getAttribute(u)===Oe){let X=Array.from(A.children).map(k=>k.id);Array.from(c.children).filter(k=>{let{resetKept:S}=this.getStreamInsert(k);return S}).sort((k,S)=>{let R=X.indexOf(k.id),w=X.indexOf(S.id);return R===w?0:R<w?-1:1}).forEach(k=>c.appendChild(k))}},onNodeDiscarded:c=>this.onNodeDiscarded(c),onBeforeNodeDiscarded:c=>c.getAttribute&&c.getAttribute(mt)!==null?!0:!(c.parentElement!==null&&c.id&&h.isPhxUpdate(c.parentElement,u,[Oe,"append","prepend"])||this.maybePendingRemove(c)||this.skipCIDSibling(c)),onElUpdated:c=>{h.isNowTriggerFormExternal(c,b)&&(L=c),D.push(c),this.maybeReOrderStream(c)},onBeforeElUpdated:(c,A)=>{if(h.maybeAddPrivateHooks(A,p,g),h.cleanChildNodes(A,u),this.skipCIDSibling(A)||h.isPhxSticky(c))return!1;if(h.isIgnored(c,u)||c.form&&c.form.isSameNode(L))return this.trackBefore("updated",c,A),h.mergeAttrs(c,A,{isIgnored:!0}),D.push(c),h.applyStickyOperations(c),!1;if(c.type==="number"&&c.validity&&c.validity.badInput)return!1;if(!h.syncPendingRef(c,A,m))return h.isUploadInput(c)&&(this.trackBefore("updated",c,A),D.push(c)),h.applyStickyOperations(c),!1;if(h.isPhxChild(A)){let k=c.getAttribute(V);return h.mergeAttrs(c,A,{exclude:[se]}),k!==""&&c.setAttribute(V,k),c.setAttribute(ee,this.rootID),h.applyStickyOperations(c),!1}return h.copyPrivates(A,c),a&&c.isSameNode(a)&&h.isFormInput(c)&&c.type!=="hidden"?(this.trackBefore("updated",c,A),h.mergeFocusedInput(c,A),h.syncAttrsToProps(c),D.push(c),h.applyStickyOperations(c),I.push(c),!1):(h.isPhxUpdate(A,u,["append","prepend"])&&U.push(new st(c,A,A.getAttribute(u))),h.syncAttrsToProps(A),h.applyStickyOperations(A),A.getAttribute("name")&&h.isFormInput(A)&&I.push(A),this.trackBefore("updated",c,A),!0)}})}),i.isDebugEnabled()&&ii(),U.length>0&&i.time("post-morph append/prepend restoration",()=>{U.forEach(c=>c.perform())}),h.maybeHideFeedback(o,I,f),i.silenceEvents(()=>h.restoreFocus(a,l,d)),h.dispatchEvent(document,"phx:update"),T.forEach(c=>this.trackAfter("added",c)),D.forEach(c=>this.trackAfter("updated",c)),this.transitionPendingRemoves(),L&&(i.unload(),Object.getPrototypeOf(L).submit.call(L)),!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e){this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}maybeReOrderStream(e){let{ref:t,streamAt:i,limit:s}=this.getStreamInsert(e);if(i!==void 0){if(h.putSticky(e,Ae,n=>n.setAttribute(Ae,t)),i===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(i>0){let n=Array.from(e.parentElement.children),o=n.indexOf(e);if(i>=n.length-1)e.parentElement.appendChild(e);else{let a=n[i];o>i?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextElementSibling)}}}}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&(t.transitionRemoves(e),t.requestDOMUpdate(()=>{e.forEach(i=>{let s=h.firstPhxChild(i);s&&t.destroyViewByEl(s),i.remove()}),this.trackAfter("transitionsDiscarded",e)}))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(je)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}indexOf(e,t){return Array.from(e.children).indexOf(t)}};var Mi=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Ui=new Set([">","/"," ",`
|
|
8
|
-
`," ","\r"]),Xi=new Set(["'",'"']),gi=(r,e,t)=>{let i=0,s=!1,n,o,a,l,d,u;for(;i<r.length;){let p=r.charAt(i);if(s)p==="-"&&r.slice(i,i+3)==="-->"?(s=!1,i+=3):i++;else if(p==="<"&&r.slice(i,i+4)==="<!--")s=!0,i+=4;else if(p==="<"){n=r.slice(0,i);let g=i;for(i++,i;i<r.length&&!Ui.has(r.charAt(i));i++);for(l=i,a=r.slice(g+1,l),i;i<r.length&&r.charAt(i)!==">";i++)if(r.charAt(i)==="="){let b=r.slice(i-3,i)===" id";i++;let T=r.charAt(i);if(Xi.has(T)){let I=i;for(i++,i;i<r.length&&r.charAt(i)!==T;i++);if(b){d=r.slice(I+1,i);break}}}break}else i++}if(!a)throw new Error(`malformed html ${r}`);let f=r.length-1;for(s=!1;f>=n.length+a.length;){let p=r.charAt(f);if(s)p==="-"&&r.slice(f-3,f)==="<!-"?(s=!1,f-=4):f-=1;else if(p===">"&&r.slice(f-2,f)==="--")s=!0,f-=3;else{if(p===">")break;f-=1}}o=r.slice(f+1,r.length);let m=Object.keys(e).map(p=>e[p]===!0?p:`${p}="${e[p]}"`).join(" ");if(t){let p=d?` id="${d}"`:"";Mi.has(a)?u=`<${a}${p}${m===""?"":" "}${m}/>`:u=`<${a}${p}${m===""?"":" "}${m}></${a}>`}else{let p=r.slice(l,f+1);u=`<${a}${m===""?"":" "}${m}${p}`}return[u,n,o]},Fe=class{static extract(e){let{[Pt]:t,[wt]:i,[yt]:s}=e;return delete e[Pt],delete e[wt],delete e[yt],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[H],e,!0,{});return[t,i]}recursiveToString(e,t=e[H],i,s,n){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,s,n),[o.buffer,o.streams]}componentCIDs(e){return Object.keys(e[H]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[H]?Object.keys(e).length===1:!1}getComponent(e,t){return e[H][t]}mergeDiff(e){let t=e[H],i={};if(delete e[H],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[H]=this.rendered[H]||{},t){let s=this.rendered[H];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],s,t,i);for(let n in t)s[n]=t[n];e[H]=t}}cachedFindComponent(e,t,i,s,n){if(n[e])return n[e];{let o,a,l=t[G];if(J(l)){let d;l>0?d=this.cachedFindComponent(l,s[l],i,s,n):d=i[-l],a=d[G],o=this.cloneMerge(d,t,!0),o[G]=a}else o=t[G]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return n[e]=o,o}}mutableMerge(e,t){return t[G]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let s=t[i],n=e[i];we(s)&&s[G]===void 0&&we(n)?this.doMutableMerge(n,s):e[i]=s}e[tt]&&(e.newRender=!0)}cloneMerge(e,t,i){let s=$($({},e),t);for(let n in s){let o=t[n],a=e[n];we(o)&&o[G]===void 0&&we(a)&&(s[n]=this.cloneMerge(a,o,i))}return i?(delete s.magicId,delete s.newRender):e[tt]&&(s.newRender=!0),s}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[H],e,null),[s,n,o]=gi(t,{});return[s,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[H][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[G]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`${this.parentViewId()}-${this.magicId}`}toOutputBuffer(e,t,i,s,n={}){if(e[He])return this.comprehensionToBuffer(e,t,i);let{[G]:o}=e;o=this.templateStatic(o,t);let a=e[tt],l=i.buffer;a&&(i.buffer=""),s&&a&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let d=1;d<o.length;d++)this.dynamicToBuffer(e[d-1],t,i,s),i.buffer+=o[d];if(a){let d=!1,u;s||Object.keys(n).length>0?(d=!e.newRender,u=$({[We]:e.magicId},n)):u=n,d&&(u[je]=!0);let[f,m,p]=gi(i.buffer,u,d);e.newRender=!1,i.buffer=l+m+f+p}}comprehensionToBuffer(e,t,i){let{[He]:s,[G]:n,[xt]:o}=e,[a,l,d,u]=o||[null,{},[],null];n=this.templateStatic(n,t);let f=t||e[ti];for(let m=0;m<s.length;m++){let p=s[m];i.buffer+=n[0];for(let g=1;g<n.length;g++){let b=!1;this.dynamicToBuffer(p[g-1],f,i,b),i.buffer+=n[g]}}o!==void 0&&(e[He].length>0||d.length>0||u)&&(delete e[xt],e[He]=[],i.streams.add(o))}dynamicToBuffer(e,t,i,s){if(typeof e=="number"){let[n,o]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=n,i.streams=new Set([...i.streams,...o])}else we(e)?this.toOutputBuffer(e,t,i,s,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||C(`no component for CID ${t}`,e),n={[M]:t},o=i&&!i.has(t);s.newRender=!o,s.magicId=`${this.parentViewId()}-c-${t}`;let a=!0,[l,d]=this.recursiveToString(s,e,i,a,n);return[l,d]}};var $i=1,ae=class{static makeID(){return $i++}static elementID(e){return e.phxHookId}constructor(e,t,i){this.__view=e,this.liveSocket=e.liveSocket,this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,this.el=t,this.el.phxHookId=this.constructor.makeID();for(let s in this.__callbacks)this[s]=this.__callbacks[s]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,t={},i=function(){}){return this.__view.pushHookEvent(this.el,null,e,t,i)}pushEventTo(e,t,i={},s=function(){}){return this.__view.withinTargets(e,(n,o)=>n.pushHookEvent(this.el,o,t,i,s))}handleEvent(e,t){let i=(s,n)=>n?e:t(s.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view.dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view.withinTargets(e,(s,n)=>{s.dispatchUploads(n,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var at=null,Bi={exec(r,e,t,i,s){let[n,o]=s||[null,{callback:s&&s.callback}];(e.charAt(0)==="["?JSON.parse(e):[[n,o]]).forEach(([l,d])=>{l===n&&o.data&&(d.data=Object.assign(d.data||{},o.data),d.callback=d.callback||o.callback),this.filterToEls(i,d).forEach(u=>{this[`exec_${l}`](r,e,t,i,u,d)})})},isVisible(r){return!!(r.offsetWidth||r.offsetHeight||r.getClientRects().length>0)},isInViewport(r){let e=r.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)},exec_exec(r,e,t,i,s,[n,o]){(o?h.all(document,o):[i]).forEach(l=>{let d=l.getAttribute(n);if(!d)throw new Error(`expected ${n} to contain JS command on "${o}"`);t.liveSocket.execJS(l,d,r)})},exec_dispatch(r,e,t,i,s,{to:n,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=i,h.dispatchEvent(s,o,{detail:a,bubbles:l})},exec_push(r,e,t,i,s,n){if(!t.isConnected())return;let{event:o,data:a,target:l,page_loading:d,loading:u,value:f,dispatcher:m,callback:p}=n,g={loading:u,value:f,target:l,page_loading:!!d},b=r==="change"&&m?m:i,T=l||b.getAttribute(t.binding("target"))||b;t.withinTargets(T,(I,D)=>{if(r==="change"){let{newCid:U,_target:L}=n;L=L||(h.isFormInput(i)?i.name:void 0),L&&(g._target=L),I.pushInput(i,D,U,o||e,g,p)}else if(r==="submit"){let{submitter:U}=n;I.submitForm(i,D,o||e,U,g,p)}else I.pushEvent(r,i,D,o||e,a,g,p)})},exec_navigate(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.historyRedirect(n,o?"replace":"push")},exec_patch(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.pushHistoryPatch(n,o?"replace":"push",i)},exec_focus(r,e,t,i,s){window.requestAnimationFrame(()=>ne.attemptFocus(s))},exec_focus_first(r,e,t,i,s){window.requestAnimationFrame(()=>ne.focusFirstInteractive(s)||ne.focusFirst(s))},exec_push_focus(r,e,t,i,s){window.requestAnimationFrame(()=>at=s||i)},exec_pop_focus(r,e,t,i,s){window.requestAnimationFrame(()=>{at&&at.focus(),at=null})},exec_add_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,n,[],o,a,t)},exec_remove_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,[],n,o,a,t)},exec_transition(r,e,t,i,s,{time:n,transition:o}){this.addOrRemoveClasses(s,[],[],o,n,t)},exec_toggle(r,e,t,i,s,{display:n,ins:o,outs:a,time:l}){this.toggle(r,t,s,n,o,a,l)},exec_show(r,e,t,i,s,{display:n,transition:o,time:a}){this.show(r,t,s,n,o,a)},exec_hide(r,e,t,i,s,{display:n,transition:o,time:a}){this.hide(r,t,s,n,o,a)},exec_set_attr(r,e,t,i,s,{attr:[n,o]}){this.setOrRemoveAttrs(s,[[n,o]],[])},exec_remove_attr(r,e,t,i,s,{attr:n}){this.setOrRemoveAttrs(s,[],[n])},show(r,e,t,i,s,n){this.isVisible(t)||this.toggle(r,e,t,i,s,null,n)},hide(r,e,t,i,s,n){this.isVisible(t)&&this.toggle(r,e,t,i,null,s,n)},toggle(r,e,t,i,s,n,o){let[a,l,d]=s||[[],[],[]],[u,f,m]=n||[[],[],[]];if(a.length>0||u.length>0)if(this.isVisible(t)){let p=()=>{this.addOrRemoveClasses(t,f,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,u,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,m,f))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,p,()=>{this.addOrRemoveClasses(t,[],u.concat(m)),h.putSticky(t,"toggle",g=>g.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(r==="remove")return;let p=()=>{this.addOrRemoveClasses(t,l,u.concat(f).concat(m));let g=i||this.defaultDisplay(t);h.putSticky(t,"toggle",b=>b.style.display=g),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,d,l))})};t.dispatchEvent(new Event("phx:show-start")),e.transition(o,p,()=>{this.addOrRemoveClasses(t,[],a.concat(d)),t.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",p=>p.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let p=i||this.defaultDisplay(t);h.putSticky(t,"toggle",g=>g.style.display=p),t.dispatchEvent(new Event("phx:show-end"))})},addOrRemoveClasses(r,e,t,i,s,n){let[o,a,l]=i||[[],[],[]];if(o.length>0){let d=()=>{this.addOrRemoveClasses(r,a,[].concat(o).concat(l)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(r,o,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(r,l,a))})},u=()=>this.addOrRemoveClasses(r,e.concat(l),t.concat(o).concat(a));return n.transition(s,d,u)}window.requestAnimationFrame(()=>{let[d,u]=h.getSticky(r,"classes",[[],[]]),f=e.filter(b=>d.indexOf(b)<0&&!r.classList.contains(b)),m=t.filter(b=>u.indexOf(b)<0&&r.classList.contains(b)),p=d.filter(b=>t.indexOf(b)<0).concat(f),g=u.filter(b=>e.indexOf(b)<0).concat(m);h.putSticky(r,"classes",b=>(b.classList.remove(...g),b.classList.add(...p),[p,g]))})},setOrRemoveAttrs(r,e,t){let[i,s]=h.getSticky(r,"attrs",[[],[]]),n=e.map(([l,d])=>l).concat(t),o=i.filter(([l,d])=>!n.includes(l)).concat(e),a=s.filter(l=>!n.includes(l)).concat(t);h.putSticky(r,"attrs",l=>(a.forEach(d=>l.removeAttribute(d)),o.forEach(([d,u])=>l.setAttribute(d,u)),[o,a]))},hasAllClasses(r,e){return e.every(t=>r.classList.contains(t))},isToggledOut(r,e){return!this.isVisible(r)||this.hasAllClasses(r,e)},filterToEls(r,{to:e}){return e?h.all(document,e):[r]},defaultDisplay(r){return{tr:"table-row",td:"table-cell"}[r.tagName.toLowerCase()]||"block"}},F=Bi;var lt=(r,e,t=[])=>{let l=e,{submitter:i}=l,s=Nt(l,["submitter"]),n=new FormData(r);i&&i.hasAttribute("name")&&i.form&&i.form===r&&n.append(i.name,i.value);let o=[];n.forEach((d,u,f)=>{d instanceof File&&o.push(u)}),o.forEach(d=>n.delete(d));let a=new URLSearchParams;for(let[d,u]of n.entries())(t.length===0||t.indexOf(d)>=0)&&a.append(d,u);for(let d in s)a.append(d,s[d]);return a.toString()},ye=class{constructor(e,t,i,s,n){this.isDead=!1,this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pruningCIDs=[],this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.uploaders={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let o=this.href&&this.expandURL(this.href);return{redirect:this.redirect?o:void 0,url:this.redirect?void 0:o||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}})}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(ge)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding($t)}]`).map(s=>s.src||s.href).filter(s=>typeof s=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._live_referer=e,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(V)}getStatic(){let e=this.el.getAttribute(se);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(vt,me,ke,bt,Ke),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(me)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(vt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,i=>t(i,e));if(J(e))h.findComponentNodeList(this.el,e).length===0?C(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let i=Array.from(document.querySelectorAll(e));i.length===0&&C(`nothing found matching the phx-target selector "${e}"`),i.forEach(s=>this.liveSocket.owner(s,n=>t(n,s)))}}applyDiff(e,t,i){this.log(e,()=>["",Se(t)]);let{diff:s,reply:n,events:o,title:a}=Fe.extract(t);i({diff:s,reply:n,events:o}),a&&window.requestAnimationFrame(()=>h.putTitle(a))}onJoin(e){let{rendered:t,container:i}=e;if(i){let[s,n]=i;this.el=h.replaceRootContainer(this.el,s,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,j.dropLocal(this.liveSocket.localStorage,window.location.pathname,$e),this.applyDiff("mount",t,({diff:s,events:n})=>{this.rendered=new Fe(this.id,s);let[o,a]=this.renderContainer(null,"join");this.dropPendingRefs();let l=this.formsForRecovery(o);this.joinCount++,l.length>0?l.forEach(([d,u,f],m)=>{this.pushFormRecovery(d,f,p=>{m===l.length-1&&this.onJoinComplete(p,o,a,n)})}):this.onJoinComplete(e,o,a,n)})}dropPendingRefs(){h.all(document,`[${Q}="${this.id}"][${O}]`,e=>{e.removeAttribute(O),e.removeAttribute(Q)})}onJoinComplete({live_patch:e},t,i,s){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,s);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(se);return l&&o.setAttribute(se,l),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,s)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(ee,this.root.id)}execNewMounted(){let e=this.binding(Ge),t=this.binding(ze);h.all(this.el,`[${e}], [${t}]`,i=>{h.maybeAddPrivateHooks(i,e,t),this.maybeAddNewHook(i)}),h.all(this.el,`[${this.binding(be)}], [data-phx-${be}]`,i=>{this.maybeAddNewHook(i)}),h.all(this.el,`[${this.binding(_t)}]`,i=>this.maybeMounted(i))}applyJoinPatch(e,t,i,s){this.attachTrueDocEl();let n=new de(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(s),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),s=i&&h.isIgnored(e,this.binding(Ee));if(i&&!e.isEqualNode(t)&&!(s&&si(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(_t)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e,t){let i=this.addHook(e);i&&i.__mounted()}performPatch(e,t,i=!1){let s=[],n=!1,o=new Set;return e.after("added",a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.after("phxChildAdded",a=>{h.isPhxSticky(a)?this.liveSocket.joinRootViews():n=!0}),e.before("updated",(a,l)=>{this.triggerBeforeUpdateHook(a,l)&&o.add(a.id)}),e.after("updated",a=>{o.has(a.id)&&this.getHook(a).__updated()}),e.after("discarded",a=>{a.nodeType===Node.ELEMENT_NODE&&s.push(a)}),e.after("transitionsDiscarded",a=>this.afterElementsRemoved(a,t)),e.perform(i),this.afterElementsRemoved(s,t),n}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let n=h.all(s,`[${M}]`),o=h.all(s,`[${this.binding(be)}]`);n.concat(s).forEach(a=>{let l=this.componentID(a);J(l)&&i.indexOf(l)===-1&&i.push(l)}),o.concat(s).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(Z)][e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new ye(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):kt(e)||this.liveSocket.time("full patch complete",()=>{let[s,n]=this.renderContainer(e,"update"),o=new de(this,this.el,this.id,s,n,null);i=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,s=e?this.rendered.componentCIDs(e).concat(this.pruningCIDs):null,[n,o]=this.rendered.toString(s);return[`<${i}>${n}</${i}>`,o]})}componentPatch(e,t){if(kt(e))return!1;let[i,s]=this.rendered.componentToString(t),n=new de(this,this.el,this.id,i,s,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[ae.elementID(e)]}addHook(e){if(ae.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${be}`)||e.getAttribute(this.binding(be));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||C(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let s=new ae(this,e,i);return this.viewHooks[ae.elementID(s.el)]=s,s}else t!==null&&C(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[ae.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:t,kind:i,flash:s}=e,n=this.expandURL(t);this.liveSocket.historyRedirect(n,i,s)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t}){this.liveSocket.redirect(e,t)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",t=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(t))}).receive("error",t=>!this.isDestroyed()&&this.onJoinError(t)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page request`,e]),this.isMain()&&this.onRedirect({to:this.href});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.isMain()&&this.onRedirect({to:this.href});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);this.displayError([me,ke,Ke]),this.log("error",()=>["unable to join",e]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this)}onClose(e){if(!this.isDestroyed()){if(this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(Yt)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([me,ke,Ke]):this.displayError([me,ke,bt]))}displayError(e){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.execAll(this.binding("disconnected"))}pushWithReply(e,t,i,s=function(){}){if(!this.isConnected())return;let[n,[o],a]=e?e():[null,[],{}],l=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(gt))!==null)&&(l=this.liveSocket.withPageLoading({kind:"element",target:o})),typeof i.cid!="number"&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(t,i,Zt).receive("ok",d=>{let u=f=>{d.redirect&&this.onRedirect(d.redirect),d.live_patch&&this.onLivePatch(d.live_patch),d.live_redirect&&this.onLiveRedirect(d.live_redirect),l(),s(d,f)};d.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",d.diff,({diff:f,reply:m,events:p})=>{n!==null&&this.undoRefs(n),this.update(f,p),u(m)})}):(n!==null&&this.undoRefs(n),u(null))}))}undoRefs(e){!this.isConnected()||h.all(document,`[${Q}="${this.id}"][${O}="${e}"]`,t=>{let i=t.getAttribute(Te);t.removeAttribute(O),t.removeAttribute(Q),t.getAttribute(Qe)!==null&&(t.readOnly=!1,t.removeAttribute(Qe)),i!==null&&(t.disabled=i==="true",t.removeAttribute(Te)),Be.forEach(o=>h.removeClass(t,o));let s=t.getAttribute(Re);s!==null&&(t.innerText=s,t.removeAttribute(Re));let n=h.private(t,O);if(n){let o=this.triggerBeforeUpdateHook(t,n);de.patchEl(t,n,this.liveSocket.getActiveElement()),o&&o.__updated(),h.deletePrivate(t,O)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(Ie);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(o=>{o.classList.add(`phx-${t}-loading`),o.setAttribute(O,s),o.setAttribute(Q,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(Re)||o.setAttribute(Re,o.innerText),a!==""&&(o.innerText=a),o.setAttribute("disabled",""))}),[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(M);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(J(t))return t;let s=i.target||e.getAttribute(this.binding("target"));return J(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return J(e)?e:e?z(e.closest(`[${M}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,s]),!1;let[o,a,l]=this.putRef([e],"hook");return this.pushWithReply(()=>[o,a,l],"event",{type:"hook",event:i,value:s,cid:this.closestComponentID(t)},(d,u)=>n(u,o)),o}extractMeta(e,t,i){let s=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(s)&&(t[o.replace(s,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&Ye.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,s,n,o={},a){this.pushWithReply(()=>this.putRef([t],e,o),"event",{type:e,event:s,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)},(l,d)=>a&&a(d))}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(Gt)),ref:e.getAttribute(B),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)},s)})}pushInput(e,t,i,s,n,o){let a,l=J(i)?i:this.targetComponentID(e.form,t,n),d=()=>this.putRef([e,e.form],"change",n),u,f=this.extractMeta(e.form);e.getAttribute(this.binding("change"))?u=lt(e.form,$({_target:n._target},f),[e.name]):u=lt(e.form,$({_target:n._target},f)),h.isUploadInput(e)&&e.files&&e.files.length>0&&P.trackFiles(e,Array.from(e.files)),a=P.serializeUploads(e);let m={type:"form",event:s,value:u,uploads:a,cid:l};this.pushWithReply(d,"event",m,p=>{if(h.showError(e,this.liveSocket.binding(le)),h.isUploadInput(e)&&h.isAutoUpload(e)){if(P.filesAwaitingPreflight(e).length>0){let[g,b]=d();this.uploadFiles(e.form,t,g,l,T=>{o&&o(p),this.triggerAwaitingSubmit(e.form)})}}else o&&o(p)})}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,s,n,o]=t;this.cancelSubmit(e),o()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,s,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,s){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,s])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([t,i,s])=>t.isSameNode(e)?(this.undoRefs(i),!1):!0)}disableForm(e,t={}){let i=f=>!(he(f,`${this.binding(Ee)}=ignore`,f.form)||he(f,"data-phx-update=ignore",f.form)),s=f=>f.hasAttribute(this.binding(Ie)),n=f=>f.tagName=="BUTTON",o=f=>["INPUT","TEXTAREA","SELECT"].includes(f.tagName),a=Array.from(e.elements),l=a.filter(s),d=a.filter(n).filter(i),u=a.filter(o).filter(i);return d.forEach(f=>{f.setAttribute(Te,f.disabled),f.disabled=!0}),u.forEach(f=>{f.setAttribute(Qe,f.readOnly),f.readOnly=!0,f.files&&(f.setAttribute(Te,f.disabled),f.disabled=!0)}),e.setAttribute(this.binding(gt),""),this.putRef([e].concat(l).concat(d).concat(u),"submit",t)}pushFormSubmit(e,t,i,s,n,o){let a=()=>this.disableForm(e,n),l=this.targetComponentID(e,t);if(P.hasUploadsInProgress(e)){let[d,u]=a(),f=()=>this.pushFormSubmit(e,t,i,s,n,o);return this.scheduleSubmit(e,d,n,f)}else if(P.inputsAwaitingPreflight(e).length>0){let[d,u]=a(),f=()=>[d,u,n];this.uploadFiles(e,t,d,l,m=>{let p=this.extractMeta(e),g=lt(e,$({submitter:s},p));this.pushWithReply(f,"event",{type:"form",event:i,value:g,cid:l},o)})}else if(!(e.hasAttribute(O)&&e.classList.contains("phx-submit-loading"))){let d=this.extractMeta(e),u=lt(e,$({submitter:s},d));this.pushWithReply(a,"event",{type:"form",event:i,value:u,cid:l},o)}}uploadFiles(e,t,i,s,n){let o=this.joinCount,a=P.activeFileInputs(e),l=a.length;a.forEach(d=>{let u=new P(d,this,()=>{l--,l===0&&n()});this.uploaders[d]=u;let f=u.entries().map(p=>p.toPreflightPayload()),m={ref:d.getAttribute(B),entries:f,cid:this.targetComponentID(d.form,t)};this.log("upload",()=>["sending preflight request",m]),this.pushWithReply(null,"allow_upload",m,p=>{if(this.log("upload",()=>["got preflight response",p]),p.error){this.undoRefs(i);let[g,b]=p.error;this.log("upload",()=>[`error for entry ${g}`,b])}else{let g=b=>{this.channel.onError(()=>{this.joinCount===o&&b()})};u.initAdapterUpload(p,g,this.liveSocket)}})})}dispatchUploads(e,t,i){let s=this.targetCtxElement(e)||this.el,n=h.findUploadInputs(s).filter(o=>o.name===t);n.length===0?C(`no live file inputs found matching the name "${t}"`):n.length>1?C(`duplicate live file inputs found matching the name "${t}"`):h.dispatchEvent(n[0],Je,{detail:{files:i}})}targetCtxElement(e){if(J(e)){let[t]=h.findComponentNodeList(this.el,e);return t}else return e||null}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(s,n)=>{let o=this.binding("change"),a=Array.from(e.elements).filter(u=>h.isFormInput(u)&&u.name&&!u.hasAttribute(o));if(a.length===0)return;a.forEach(u=>u.hasAttribute(B)&&P.clearFiles(u));let l=a.find(u=>u.type!=="hidden")||a[0],d=e.getAttribute(this.binding(At))||e.getAttribute(this.binding("change"));F.exec("change",d,s,l,["push",{_target:l.name,newCid:t,callback:i}])})}pushLinkPatch(e,t,i){let s=this.liveSocket.setPendingLink(e),n=t?()=>this.putRef([t],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=e.startsWith("/")?`${location.protocol}//${location.host}${e}`:e,l=this.pushWithReply(n,"live_patch",{url:a},d=>{this.liveSocket.requestDOMUpdate(()=>{d.link_redirect?this.liveSocket.replaceMain(e,null,i,s):(this.liveSocket.commitPendingLink(s)&&(this.href=e),this.applyPendingUpdates(),i&&i(s))})});l?l.receive("timeout",o):o()}formsForRecovery(e){if(this.joinCount===0)return[];let t=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,h.all(this.el,`form[${t}]`).filter(s=>s.id&&this.ownsElement(s)).filter(s=>s.elements.length>0).filter(s=>s.getAttribute(this.binding(At))!=="ignore").map(s=>{let n=s.getAttribute(t).replaceAll(/([\[\]"])/g,"\\$1"),o=i.content.querySelector(`form[id="${s.id}"][${t}="${n}"]`);return o?[s,o,this.targetComponentID(o)]:[s,s,this.targetComponentID(s)]}).filter(([s,n,o])=>n)}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(this.pruningCIDs.push(...t),this.pushWithReply(null,"cids_will_destroy",{cids:t},()=>{this.pruningCIDs=this.pruningCIDs.filter(s=>t.indexOf(s)!==-1);let i=t.filter(s=>h.findComponentNodeList(this.el,s).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i},s=>{this.rendered.pruneCIDs(s.cids)})}))}ownsElement(e){let t=e.closest(Y);return e.getAttribute(Z)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,s,n={}){h.putPrivate(e,ve,!0);let o=this.liveSocket.binding(le),a=Array.from(e.elements);a.forEach(l=>h.putPrivate(l,ve,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,n,()=>{a.forEach(l=>h.showError(l,o)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var ht=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
|
|
7
|
+
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(s,e,t){let i=new Set(["id",B,re,ge,ee]);if(s.tagName.toLowerCase()===e.toLowerCase())return Array.from(s.attributes).filter(r=>!i.has(r.name.toLowerCase())).forEach(r=>s.removeAttribute(r.name)),Object.keys(t).filter(r=>!i.has(r.toLowerCase())).forEach(r=>s.setAttribute(r,t[r])),s;{let r=document.createElement(e);return Object.keys(t).forEach(n=>r.setAttribute(n,t[n])),i.forEach(n=>r.setAttribute(n,s.getAttribute(n))),r.innerHTML=s.innerHTML,s.replaceWith(r),r}},getSticky(s,e,t){let i=(j.private(s,"sticky")||[]).find(([r])=>e===r);if(i){let[r,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(s,e){this.updatePrivate(s,"sticky",[],t=>t.filter(([i,r])=>i!==e))},putSticky(s,e,t){let i=t(s);this.updatePrivate(s,"sticky",[],r=>{let n=r.findIndex(([o])=>e===o);return n>=0?r[n]=[e,t,i]:r.push([e,t,i]),r})},applyStickyOperations(s){let e=j.private(s,"sticky");!e||e.forEach(([t,i,r])=>this.putSticky(s,t,i))}},h=j;var ye=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(xe).split(",").indexOf(w.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(fe).split(",").indexOf(w.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=w.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(pe,this._onElUpdated)}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{w.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}cancel(){this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(pe,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),h.isAutoUpload(this.fileEl)||w.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(pe,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(xe).split(",").indexOf(this.ref)===-1&&this.cancel()}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||C(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:ni}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||C(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var _i=0,w=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(_i++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let r=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(r))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(fe)!==i.getAttribute(Vt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(r=>{let n={path:e.name},o=e.getAttribute($);i[o]=i[o]||[],n.ref=this.genFileRef(r),n.last_modified=r.lastModified,n.name=r.name||n.ref,n.relative_path=r.webkitRelativePath,n.type=r.type,n.size=r.size,typeof r.meta=="function"&&(n.meta=r.meta()),i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute($),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let r=t.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));h.putPrivate(e,"files",this.activeFiles(e).concat(r)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>ye.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!ye.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(w.filesAwaitingPreflight(e)||[]).map(r=>new ye(e,r,t)),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),n));let r=this._entries.reduce((n,o)=>{if(!o.meta)return n;let{name:a,callback:l}=o.uploader(i.uploaders);return n[a]=n[a]||{callback:l,entries:[]},n[a].entries.push(o),n},{});for(let n in r){let{callback:o,entries:a}=r[n];o(a,t,e,i)}}};var Si={focusMain(){let s=document.querySelector("main h1, main, h1");if(s){let e=s.tabIndex;s.tabIndex=-1,s.focus(),s.tabIndex=e}},anyOf(s,e){return e.find(t=>s instanceof t)},isFocusable(s,e){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||!e&&s.getAttribute("tabindex")!==null&&s.getAttribute("aria-hidden")!=="true"},attemptFocus(s,e){if(this.isFocusable(s,e))try{s.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(s)},focusFirstInteractive(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(s){let e=s.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},ne=Si;var ai={LiveFileUpload:{activeRefs(){return this.el.getAttribute(xe)},preflightedRefs(){return this.el.getAttribute(fe)},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(pe))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute($)),w.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",()=>ne.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>ne.focusFirst(this.el)),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&ne.focusFirst(this.el)}}},li=()=>document.documentElement.scrollTop||document.body.scrollTop,Ct=()=>window.innerHeight||document.documentElement.clientHeight,wi=s=>{let e=s.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.top<=Ct()},yi=s=>{let e=s.getBoundingClientRect();return e.right>=0&&e.left>=0&&e.bottom<=Ct()},hi=s=>{let e=s.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.top<=Ct()};ai.InfiniteScroll={mounted(){let s=li(),e=!1,t=500,i=null,r=this.throttle(t,(a,l)=>{i=()=>!0,this.liveSocket.execJSHookPush(this.el,a,{id:l.id,_overran:!0},()=>{i=null})}),n=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"start"}),this.liveSocket.execJSHookPush(this.el,a,{id:l.id},()=>{i=null,hi(l)||l.scrollIntoView({block:"start"})})}),o=this.throttle(t,(a,l)=>{i=()=>l.scrollIntoView({block:"end"}),this.liveSocket.execJSHookPush(this.el,a,{id:l.id},()=>{i=null,hi(l)||l.scrollIntoView({block:"end"})})});this.onScroll=a=>{let l=li();if(i)return s=l,i();let d=this.el.getBoundingClientRect(),u=this.el.getAttribute(this.liveSocket.binding("viewport-top")),f=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),g=this.el.lastElementChild,m=this.el.firstElementChild,p=l<s,b=l>s;p&&u&&!e&&d.top>=0?(e=!0,r(u,m)):b&&e&&d.top<=0&&(e=!1),u&&p&&wi(m)?n(u,m):f&&b&&yi(g)&&o(f,g),s=l},window.addEventListener("scroll",this.onScroll)},destroyed(){window.removeEventListener("scroll",this.onScroll)},throttle(s,e){let t=0,i;return(...r)=>{let n=Date.now(),o=s-(n-t);o<=0||o>s?(i&&(clearTimeout(i),i=null),t=n,e(...r)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...r)},o))}}};var di=ai;var rt=class{constructor(e,t,i){let r=new Set,n=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(r.add(a.id),n.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!r.has(a))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?z(document.getElementById(t.previousElementId),i=>{z(document.getElementById(t.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",r)})}):z(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{z(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var ci=11;function Pi(s,e){var t=e.attributes,i,r,n,o,a;if(!(e.nodeType===ci||s.nodeType===ci)){for(var l=t.length-1;l>=0;l--)i=t[l],r=i.name,n=i.namespaceURI,o=i.value,n?(r=i.localName||r,a=s.getAttributeNS(n,r),a!==o&&(i.prefix==="xmlns"&&(r=i.name),s.setAttributeNS(n,r,o))):(a=s.getAttribute(r),a!==o&&s.setAttribute(r,o));for(var d=s.attributes,u=d.length-1;u>=0;u--)i=d[u],r=i.name,n=i.namespaceURI,n?(r=i.localName||r,e.hasAttributeNS(n,r)||s.removeAttributeNS(n,r)):e.hasAttribute(r)||s.removeAttribute(r)}}var nt,xi="http://www.w3.org/1999/xhtml",H=typeof document=="undefined"?void 0:document,ki=!!H&&"content"in H.createElement("template"),Ci=!!H&&H.createRange&&"createContextualFragment"in H.createRange();function Ti(s){var e=H.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function Ii(s){nt||(nt=H.createRange(),nt.selectNode(H.body));var e=nt.createContextualFragment(s);return e.childNodes[0]}function Ri(s){var e=H.createElement("body");return e.innerHTML=s,e.childNodes[0]}function Oi(s){return s=s.trim(),ki?Ti(s):Ci?Ii(s):Ri(s)}function ot(s,e){var t=s.nodeName,i=e.nodeName,r,n;return t===i?!0:(r=t.charCodeAt(0),n=i.charCodeAt(0),r<=90&&n>=97?t===i.toUpperCase():n<=90&&r>=97?i===t.toUpperCase():!1)}function Di(s,e){return!e||e===xi?H.createElement(s):H.createElementNS(e,s)}function Li(s,e){for(var t=s.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Tt(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var ui={OPTION:function(s,e){var t=s.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(s.hasAttribute("selected")&&!e.selected&&(s.setAttribute("selected","selected"),s.removeAttribute("selected")),t.selectedIndex=-1)}Tt(s,e,"selected")},INPUT:function(s,e){Tt(s,e,"checked"),Tt(s,e,"disabled"),s.value!==e.value&&(s.value=e.value),e.hasAttribute("value")||s.removeAttribute("value")},TEXTAREA:function(s,e){var t=e.value;s.value!==t&&(s.value=t);var i=s.firstChild;if(i){var r=i.nodeValue;if(r==t||!t&&r==s.placeholder)return;i.nodeValue=t}},SELECT:function(s,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,r=s.firstChild,n,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")n=r,r=n.firstChild;else{if(o==="OPTION"){if(r.hasAttribute("selected")){t=i;break}i++}r=r.nextSibling,!r&&n&&(r=n.nextSibling,n=null)}s.selectedIndex=t}}},Me=1,fi=11,pi=3,mi=8;function oe(){}function Hi(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function Ni(s){return function(t,i,r){if(r||(r={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=H.createElement("html"),i.innerHTML=n}else i=Oi(i);else i.nodeType===fi&&(i=i.firstElementChild);var o=r.getNodeKey||Hi,a=r.onBeforeNodeAdded||oe,l=r.onNodeAdded||oe,d=r.onBeforeElUpdated||oe,u=r.onElUpdated||oe,f=r.onBeforeNodeDiscarded||oe,g=r.onNodeDiscarded||oe,m=r.onBeforeElChildrenUpdated||oe,p=r.skipFromChildren||oe,b=r.addChild||function(E,v){return E.appendChild(v)},T=r.childrenOnly===!0,I=Object.create(null),O=[];function M(E){O.push(E)}function D(E,v){if(E.nodeType===Me)for(var x=E.firstChild;x;){var _=void 0;v&&(_=o(x))?M(_):(g(x),x.firstChild&&D(x,v)),x=x.nextSibling}}function c(E,v,x){f(E)!==!1&&(v&&v.removeChild(E),g(E),D(E,x))}function A(E){if(E.nodeType===Me||E.nodeType===fi)for(var v=E.firstChild;v;){var x=o(v);x&&(I[x]=v),A(v),v=v.nextSibling}}A(t);function W(E){l(E);for(var v=E.firstChild;v;){var x=v.nextSibling,_=o(v);if(_){var y=I[_];y&&ot(v,y)?(v.parentNode.replaceChild(y,v),S(y,v)):W(v)}else W(v);v=x}}function k(E,v,x){for(;v;){var _=v.nextSibling;(x=o(v))?M(x):c(v,E,!0),v=_}}function S(E,v,x){var _=o(v);_&&delete I[_],!(!x&&(d(E,v)===!1||(s(E,v),u(E),m(E,v)===!1)))&&(E.nodeName!=="TEXTAREA"?U(E,v):ui.TEXTAREA(E,v))}function U(E,v){var x=p(E,v),_=v.firstChild,y=E.firstChild,ce,te,ue,Xe,ie;e:for(;_;){for(Xe=_.nextSibling,ce=o(_);!x&&y;){if(ue=y.nextSibling,_.isSameNode&&_.isSameNode(y)){_=Xe,y=ue;continue e}te=o(y);var $e=y.nodeType,se=void 0;if($e===_.nodeType&&($e===Me?(ce?ce!==te&&((ie=I[ce])?ue===ie?se=!1:(E.insertBefore(ie,y),te?M(te):c(y,E,!0),y=ie):se=!1):te&&(se=!1),se=se!==!1&&ot(y,_),se&&S(y,_)):($e===pi||$e==mi)&&(se=!0,y.nodeValue!==_.nodeValue&&(y.nodeValue=_.nodeValue))),se){_=Xe,y=ue;continue e}te?M(te):c(y,E,!0),y=ue}if(ce&&(ie=I[ce])&&ot(ie,_))x||b(E,ie),S(ie,_);else{var ut=a(_);ut!==!1&&(ut&&(_=ut),_.actualize&&(_=_.actualize(E.ownerDocument||H)),b(E,_),W(_))}_=Xe,y=ue}k(E,y,te);var Ot=ui[E.nodeName];Ot&&Ot(E,v)}var P=t,q=P.nodeType,Rt=i.nodeType;if(!T){if(q===Me)Rt===Me?ot(t,i)||(g(t),P=Li(t,Di(i.nodeName,i.namespaceURI))):P=i;else if(q===pi||q===mi){if(Rt===q)return P.nodeValue!==i.nodeValue&&(P.nodeValue=i.nodeValue),P;P=i}}if(P===i)g(t);else{if(i.isSameNode&&i.isSameNode(P))return;if(S(P,i,T),O)for(var dt=0,bi=O.length;dt<bi;dt++){var ct=I[O[dt]];ct&&c(ct,ct.parentNode,!1)}}return!T&&P!==t&&t.parentNode&&(P.actualize&&(P=P.actualize(t.ownerDocument||H)),t.parentNode.replaceChild(P,t)),P}}var Fi=Ni(Pi),It=Fi;var de=class{static patchEl(e,t,i){It(e,t,{childrenOnly:!1,onBeforeElUpdated:(r,n)=>{if(i&&i.isSameNode(r)&&h.isFormInput(r))return h.mergeFocusedInput(r,n),!1}})}constructor(e,t,i,r,n,o){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=r,this.streams=n,this.streamInserts={},this.targetCID=o,this.cidPatch=V(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(Ee);h.all(this.container,`[${e}=${Le}]`,t=>t.innerHTML=""),h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(mt,"")})}perform(e){let{view:t,liveSocket:i,container:r,html:n}=this,o=this.isCIDPatch()?this.targetCIDContainer(n):r;if(this.isCIDPatch()&&!o)return;let a=i.getActiveElement(),{selectionStart:l,selectionEnd:d}=a&&h.hasSelectionRange(a)?a:{},u=i.binding(Ee),f=i.binding(le),g=i.binding(Oe),m=i.binding(Ce),p=i.binding(Te),b=i.binding(Jt),T=[],I=[],O=[],M=[],D=null;return this.trackBefore("added",r),this.trackBefore("updated",r,r),i.time("morphdom",()=>{this.streams.forEach(([c,A,W,k])=>{Object.entries(A).forEach(([S,[U,P]])=>{this.streamInserts[S]={ref:c,streamAt:U,limit:P,resetKept:!1}}),k!==void 0&&h.all(r,`[${Ae}="${c}"]`,S=>{A[S.id]?this.streamInserts[S.id].resetKept=!0:this.removeStreamChildElement(S)}),W.forEach(S=>{let U=r.querySelector(`[id="${S}"]`);U&&this.removeStreamChildElement(U)})}),It(o,n,{childrenOnly:o.getAttribute(F)===null,getNodeKey:c=>h.isPhxDestroyed(c)?null:e?c.id:c.id||c.getAttribute&&c.getAttribute(Ke),skipFromChildren:c=>c.getAttribute(u)===Le,addChild:(c,A)=>{let{ref:W,streamAt:k,limit:S}=this.getStreamInsert(A);if(W===void 0)return c.appendChild(A);if(h.putSticky(A,Ae,q=>q.setAttribute(Ae,W)),k===0)c.insertAdjacentElement("afterbegin",A);else if(k===-1)c.appendChild(A);else if(k>0){let q=Array.from(c.children)[k];c.insertBefore(A,q)}let U=S!==null&&Array.from(c.children),P=[];S&&S<0&&U.length>S*-1?P=U.slice(0,U.length+S):S&&S>=0&&U.length>S&&(P=U.slice(S)),P.forEach(q=>{this.streamInserts[q.id]||this.removeStreamChildElement(q)})},onBeforeNodeAdded:c=>(h.maybeAddPrivateHooks(c,m,p),this.trackBefore("added",c),c),onNodeAdded:c=>{c.getAttribute&&this.maybeReOrderStream(c,!0),c instanceof HTMLImageElement&&c.srcset?c.srcset=c.srcset:c instanceof HTMLVideoElement&&c.autoplay&&c.play(),h.isNowTriggerFormExternal(c,b)&&(D=c),c.getAttribute&&c.getAttribute("name")&&h.isFormInput(c)&&I.push(c),(h.isPhxChild(c)&&t.ownsElement(c)||h.isPhxSticky(c)&&t.ownsElement(c.parentNode))&&this.trackAfter("phxChildAdded",c),T.push(c)},onBeforeElChildrenUpdated:(c,A)=>{if(c.getAttribute(u)===Le){let W=Array.from(A.children).map(k=>k.id);Array.from(c.children).filter(k=>{let{resetKept:S}=this.getStreamInsert(k);return S}).forEach(k=>{this.streamInserts[k.id].streamAt=W.indexOf(k.id)})}},onNodeDiscarded:c=>this.onNodeDiscarded(c),onBeforeNodeDiscarded:c=>c.getAttribute&&c.getAttribute(mt)!==null?!0:!(c.parentElement!==null&&c.id&&h.isPhxUpdate(c.parentElement,u,[Le,"append","prepend"])||this.maybePendingRemove(c)||this.skipCIDSibling(c)),onElUpdated:c=>{h.isNowTriggerFormExternal(c,b)&&(D=c),O.push(c),this.maybeReOrderStream(c,!1)},onBeforeElUpdated:(c,A)=>{if(h.maybeAddPrivateHooks(A,m,p),h.cleanChildNodes(A,u),this.skipCIDSibling(A)||h.isPhxSticky(c))return!1;if(h.isIgnored(c,u)||c.form&&c.form.isSameNode(D))return this.trackBefore("updated",c,A),h.mergeAttrs(c,A,{isIgnored:!0}),O.push(c),h.applyStickyOperations(c),!1;if(c.type==="number"&&c.validity&&c.validity.badInput)return!1;if(!h.syncPendingRef(c,A,g))return h.isUploadInput(c)&&(this.trackBefore("updated",c,A),O.push(c)),h.applyStickyOperations(c),!1;if(h.isPhxChild(A)){let k=c.getAttribute(B);return h.mergeAttrs(c,A,{exclude:[re]}),k!==""&&c.setAttribute(B,k),c.setAttribute(ee,this.rootID),h.applyStickyOperations(c),!1}return h.copyPrivates(A,c),a&&c.isSameNode(a)&&h.isFormInput(c)&&c.type!=="hidden"?(this.trackBefore("updated",c,A),h.mergeFocusedInput(c,A),h.syncAttrsToProps(c),O.push(c),h.applyStickyOperations(c),I.push(c),!1):(h.isPhxUpdate(A,u,["append","prepend"])&&M.push(new rt(c,A,A.getAttribute(u))),h.syncAttrsToProps(A),h.applyStickyOperations(A),A.getAttribute("name")&&h.isFormInput(A)&&I.push(A),this.trackBefore("updated",c,A),!0)}})}),i.isDebugEnabled()&&ii(),M.length>0&&i.time("post-morph append/prepend restoration",()=>{M.forEach(c=>c.perform())}),h.maybeHideFeedback(o,I,f),i.silenceEvents(()=>h.restoreFocus(a,l,d)),h.dispatchEvent(document,"phx:update"),T.forEach(c=>this.trackAfter("added",c)),O.forEach(c=>this.trackAfter("updated",c)),this.transitionPendingRemoves(),D&&(i.unload(),Object.getPrototypeOf(D).submit.call(D)),!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e){this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}maybeReOrderStream(e,t){let{ref:i,streamAt:r,limit:n}=this.getStreamInsert(e);if(!(r===void 0||r===0&&!t)){if(h.putSticky(e,Ae,o=>o.setAttribute(Ae,i)),r===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(r>0){let o=Array.from(e.parentElement.children),a=o.indexOf(e);if(r>=o.length-1)e.parentElement.appendChild(e);else{let l=o[r];a>r?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextElementSibling)}}}}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&(t.transitionRemoves(e),t.requestDOMUpdate(()=>{e.forEach(i=>{let r=h.firstPhxChild(i);r&&t.destroyViewByEl(r),i.remove()}),this.trackAfter("transitionsDiscarded",e)}))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(qe)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}indexOf(e,t){return Array.from(e.children).indexOf(t)}};var Mi=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Ui=new Set(["'",'"']),gi=(s,e,t)=>{let i=0,r=!1,n,o,a,l,d,u,f=s.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(f===null)throw new Error(`malformed html ${s}`);for(i=f[0].length,n=f[1],a=f[2],l=i,i;i<s.length&&s.charAt(i)!==">";i++)if(s.charAt(i)==="="){let p=s.slice(i-3,i)===" id";i++;let b=s.charAt(i);if(Ui.has(b)){let T=i;for(i++,i;i<s.length&&s.charAt(i)!==b;i++);if(p){d=s.slice(T+1,i);break}}}let g=s.length-1;for(r=!1;g>=n.length+a.length;){let p=s.charAt(g);if(r)p==="-"&&s.slice(g-3,g)==="<!-"?(r=!1,g-=4):g-=1;else if(p===">"&&s.slice(g-2,g)==="--")r=!0,g-=3;else{if(p===">")break;g-=1}}o=s.slice(g+1,s.length);let m=Object.keys(e).map(p=>e[p]===!0?p:`${p}="${e[p]}"`).join(" ");if(t){let p=d?` id="${d}"`:"";Mi.has(a)?u=`<${a}${p}${m===""?"":" "}${m}/>`:u=`<${a}${p}${m===""?"":" "}${m}></${a}>`}else{let p=s.slice(l,g+1);u=`<${a}${m===""?"":" "}${m}${p}`}return[u,n,o]},Ue=class{static extract(e){let{[yt]:t,[wt]:i,[Pt]:r}=e;return delete e[yt],delete e[wt],delete e[Pt],{diff:e,title:r,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[L],e,!0,{});return[t,i]}recursiveToString(e,t=e[L],i,r,n){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,r,n),[o.buffer,o.streams]}componentCIDs(e){return Object.keys(e[L]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[L]?Object.keys(e).length===1:!1}getComponent(e,t){return e[L][t]}mergeDiff(e){let t=e[L],i={};if(delete e[L],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[L]=this.rendered[L]||{},t){let r=this.rendered[L];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],r,t,i);for(let n in t)r[n]=t[n];e[L]=t}}cachedFindComponent(e,t,i,r,n){if(n[e])return n[e];{let o,a,l=t[G];if(V(l)){let d;l>0?d=this.cachedFindComponent(l,r[l],i,r,n):d=i[-l],a=d[G],o=this.cloneMerge(d,t,!0),o[G]=a}else o=t[G]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return n[e]=o,o}}mutableMerge(e,t){return t[G]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let r=t[i],n=e[i];we(r)&&r[G]===void 0&&we(n)?this.doMutableMerge(n,r):e[i]=r}e[tt]&&(e.newRender=!0)}cloneMerge(e,t,i){let r=X(X({},e),t);for(let n in r){let o=t[n],a=e[n];we(o)&&o[G]===void 0&&we(a)&&(r[n]=this.cloneMerge(a,o,i))}return i?(delete r.magicId,delete r.newRender):e[tt]&&(r.newRender=!0),r}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[L],e,null),[r,n,o]=gi(t,{});return[r,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[L][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[G]}templateStatic(e,t){return typeof e=="number"?t[e]:e}nextMagicID(){return this.magicId++,`${this.parentViewId()}-${this.magicId}`}toOutputBuffer(e,t,i,r,n={}){if(e[Fe])return this.comprehensionToBuffer(e,t,i);let{[G]:o}=e;o=this.templateStatic(o,t);let a=e[tt],l=i.buffer;a&&(i.buffer=""),r&&a&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let d=1;d<o.length;d++)this.dynamicToBuffer(e[d-1],t,i,r),i.buffer+=o[d];if(a){let d=!1,u;r||Object.keys(n).length>0?(d=!e.newRender,u=X({[Ke]:e.magicId},n)):u=n,d&&(u[qe]=!0);let[f,g,m]=gi(i.buffer,u,d);e.newRender=!1,i.buffer=l+g+f+m}}comprehensionToBuffer(e,t,i){let{[Fe]:r,[G]:n,[xt]:o}=e,[a,l,d,u]=o||[null,{},[],null];n=this.templateStatic(n,t);let f=t||e[ti];for(let g=0;g<r.length;g++){let m=r[g];i.buffer+=n[0];for(let p=1;p<n.length;p++){let b=!1;this.dynamicToBuffer(m[p-1],f,i,b),i.buffer+=n[p]}}o!==void 0&&(e[Fe].length>0||d.length>0||u)&&(delete e[xt],e[Fe]=[],i.streams.add(o))}dynamicToBuffer(e,t,i,r){if(typeof e=="number"){let[n,o]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=n,i.streams=new Set([...i.streams,...o])}else we(e)?this.toOutputBuffer(e,t,i,r,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let r=e[t]||C(`no component for CID ${t}`,e),n={[F]:t},o=i&&!i.has(t);r.newRender=!o,r.magicId=`${this.parentViewId()}-c-${t}`;let a=!0,[l,d]=this.recursiveToString(r,e,i,a,n);return[l,d]}};var Xi=1,ae=class{static makeID(){return Xi++}static elementID(e){return e.phxHookId}constructor(e,t,i){this.__view=e,this.liveSocket=e.liveSocket,this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,this.el=t,this.el.phxHookId=this.constructor.makeID();for(let r in this.__callbacks)this[r]=this.__callbacks[r]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,t={},i=function(){}){return this.__view.pushHookEvent(this.el,null,e,t,i)}pushEventTo(e,t,i={},r=function(){}){return this.__view.withinTargets(e,(n,o)=>n.pushHookEvent(this.el,o,t,i,r))}handleEvent(e,t){let i=(r,n)=>n?e:t(r.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view.dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view.withinTargets(e,(r,n)=>{r.dispatchUploads(n,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var at=null,$i={exec(s,e,t,i,r){let[n,o]=r||[null,{callback:r&&r.callback}];(e.charAt(0)==="["?JSON.parse(e):[[n,o]]).forEach(([l,d])=>{l===n&&o.data&&(d.data=Object.assign(d.data||{},o.data),d.callback=d.callback||o.callback),this.filterToEls(i,d).forEach(u=>{this[`exec_${l}`](s,e,t,i,u,d)})})},isVisible(s){return!!(s.offsetWidth||s.offsetHeight||s.getClientRects().length>0)},isInViewport(s){let e=s.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)},exec_exec(s,e,t,i,r,[n,o]){(o?h.all(document,o):[i]).forEach(l=>{let d=l.getAttribute(n);if(!d)throw new Error(`expected ${n} to contain JS command on "${o}"`);t.liveSocket.execJS(l,d,s)})},exec_dispatch(s,e,t,i,r,{to:n,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=i,h.dispatchEvent(r,o,{detail:a,bubbles:l})},exec_push(s,e,t,i,r,n){let{event:o,data:a,target:l,page_loading:d,loading:u,value:f,dispatcher:g,callback:m}=n,p={loading:u,value:f,target:l,page_loading:!!d},b=s==="change"&&g?g:i,T=l||b.getAttribute(t.binding("target"))||b;t.withinTargets(T,(I,O)=>{if(!!I.isConnected())if(s==="change"){let{newCid:M,_target:D}=n;D=D||(h.isFormInput(i)?i.name:void 0),D&&(p._target=D),I.pushInput(i,O,M,o||e,p,m)}else if(s==="submit"){let{submitter:M}=n;I.submitForm(i,O,o||e,M,p,m)}else I.pushEvent(s,i,O,o||e,a,p,m)})},exec_navigate(s,e,t,i,r,{href:n,replace:o}){t.liveSocket.historyRedirect(n,o?"replace":"push")},exec_patch(s,e,t,i,r,{href:n,replace:o}){t.liveSocket.pushHistoryPatch(n,o?"replace":"push",i)},exec_focus(s,e,t,i,r){window.requestAnimationFrame(()=>ne.attemptFocus(r))},exec_focus_first(s,e,t,i,r){window.requestAnimationFrame(()=>ne.focusFirstInteractive(r)||ne.focusFirst(r))},exec_push_focus(s,e,t,i,r){window.requestAnimationFrame(()=>at=r||i)},exec_pop_focus(s,e,t,i,r){window.requestAnimationFrame(()=>{at&&at.focus(),at=null})},exec_add_class(s,e,t,i,r,{names:n,transition:o,time:a}){this.addOrRemoveClasses(r,n,[],o,a,t)},exec_remove_class(s,e,t,i,r,{names:n,transition:o,time:a}){this.addOrRemoveClasses(r,[],n,o,a,t)},exec_toggle_class(s,e,t,i,r,{to:n,names:o,transition:a,time:l}){this.toggleClasses(r,o,a,t)},exec_transition(s,e,t,i,r,{time:n,transition:o}){this.addOrRemoveClasses(r,[],[],o,n,t)},exec_toggle(s,e,t,i,r,{display:n,ins:o,outs:a,time:l}){this.toggle(s,t,r,n,o,a,l)},exec_show(s,e,t,i,r,{display:n,transition:o,time:a}){this.show(s,t,r,n,o,a)},exec_hide(s,e,t,i,r,{display:n,transition:o,time:a}){this.hide(s,t,r,n,o,a)},exec_set_attr(s,e,t,i,r,{attr:[n,o]}){this.setOrRemoveAttrs(r,[[n,o]],[])},exec_remove_attr(s,e,t,i,r,{attr:n}){this.setOrRemoveAttrs(r,[],[n])},show(s,e,t,i,r,n){this.isVisible(t)||this.toggle(s,e,t,i,r,null,n)},hide(s,e,t,i,r,n){this.isVisible(t)&&this.toggle(s,e,t,i,null,r,n)},toggle(s,e,t,i,r,n,o){let[a,l,d]=r||[[],[],[]],[u,f,g]=n||[[],[],[]];if(a.length>0||u.length>0)if(this.isVisible(t)){let m=()=>{this.addOrRemoveClasses(t,f,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,u,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,g,f))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,m,()=>{this.addOrRemoveClasses(t,[],u.concat(g)),h.putSticky(t,"toggle",p=>p.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(s==="remove")return;let m=()=>{this.addOrRemoveClasses(t,l,u.concat(f).concat(g));let p=i||this.defaultDisplay(t);h.putSticky(t,"toggle",b=>b.style.display=p),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,d,l))})};t.dispatchEvent(new Event("phx:show-start")),e.transition(o,m,()=>{this.addOrRemoveClasses(t,[],a.concat(d)),t.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",m=>m.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let m=i||this.defaultDisplay(t);h.putSticky(t,"toggle",p=>p.style.display=m),t.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(s,e,t,i,r){window.requestAnimationFrame(()=>{let[n,o]=h.getSticky(s,"classes",[[],[]]),a=e.filter(d=>n.indexOf(d)<0&&!s.classList.contains(d)),l=e.filter(d=>o.indexOf(d)<0&&s.classList.contains(d));this.addOrRemoveClasses(s,a,l,t,i,r)})},addOrRemoveClasses(s,e,t,i,r,n){let[o,a,l]=i||[[],[],[]];if(o.length>0){let d=()=>{this.addOrRemoveClasses(s,a,[].concat(o).concat(l)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(s,o,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(s,l,a))})},u=()=>this.addOrRemoveClasses(s,e.concat(l),t.concat(o).concat(a));return n.transition(r,d,u)}window.requestAnimationFrame(()=>{let[d,u]=h.getSticky(s,"classes",[[],[]]),f=e.filter(b=>d.indexOf(b)<0&&!s.classList.contains(b)),g=t.filter(b=>u.indexOf(b)<0&&s.classList.contains(b)),m=d.filter(b=>t.indexOf(b)<0).concat(f),p=u.filter(b=>e.indexOf(b)<0).concat(g);h.putSticky(s,"classes",b=>(b.classList.remove(...p),b.classList.add(...m),[m,p]))})},setOrRemoveAttrs(s,e,t){let[i,r]=h.getSticky(s,"attrs",[[],[]]),n=e.map(([l,d])=>l).concat(t),o=i.filter(([l,d])=>!n.includes(l)).concat(e),a=r.filter(l=>!n.includes(l)).concat(t);h.putSticky(s,"attrs",l=>(a.forEach(d=>l.removeAttribute(d)),o.forEach(([d,u])=>l.setAttribute(d,u)),[o,a]))},hasAllClasses(s,e){return e.every(t=>s.classList.contains(t))},isToggledOut(s,e){return!this.isVisible(s)||this.hasAllClasses(s,e)},filterToEls(s,{to:e}){return e?h.all(document,e):[s]},defaultDisplay(s){return{tr:"table-row",td:"table-cell"}[s.tagName.toLowerCase()]||"block"}},N=$i;var lt=(s,e,t=[])=>{let l=e,{submitter:i}=l,r=Nt(l,["submitter"]),n=new FormData(s);i&&i.hasAttribute("name")&&i.form&&i.form===s&&n.append(i.name,i.value);let o=[];n.forEach((d,u,f)=>{d instanceof File&&o.push(u)}),o.forEach(d=>n.delete(d));let a=new URLSearchParams;for(let[d,u]of n.entries())(t.length===0||t.indexOf(d)>=0)&&a.append(d,u);for(let d in r)a.append(d,r[d]);return a.toString()},Pe=class{constructor(e,t,i,r,n){this.isDead=!1,this.liveSocket=t,this.flash=r,this.parent=i,this.root=i?i.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pruningCIDs=[],this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.uploaders={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let o=this.href&&this.expandURL(this.href);return{redirect:this.redirect?o:void 0,url:this.redirect?void 0:o||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}})}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(ge)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding($t)}]`).map(r=>r.src||r.href).filter(r=>typeof r=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._live_referer=e,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(B)}getStatic(){let e=this.el.getAttribute(re);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(vt,me,ke,bt,ze),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(me)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(vt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,i=>t(i,e));if(V(e))h.findComponentNodeList(this.el,e).length===0?C(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let i=Array.from(document.querySelectorAll(e));i.length===0&&C(`nothing found matching the phx-target selector "${e}"`),i.forEach(r=>this.liveSocket.owner(r,n=>t(n,r)))}}applyDiff(e,t,i){this.log(e,()=>["",Se(t)]);let{diff:r,reply:n,events:o,title:a}=Ue.extract(t);i({diff:r,reply:n,events:o}),a&&window.requestAnimationFrame(()=>h.putTitle(a))}onJoin(e){let{rendered:t,container:i}=e;if(i){let[r,n]=i;this.el=h.replaceRootContainer(this.el,r,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,J.dropLocal(this.liveSocket.localStorage,window.location.pathname,Ve),this.applyDiff("mount",t,({diff:r,events:n})=>{this.rendered=new Ue(this.id,r);let[o,a]=this.renderContainer(null,"join");this.dropPendingRefs();let l=this.formsForRecovery(o);this.joinCount++,l.length>0?l.forEach(([d,u,f],g)=>{this.pushFormRecovery(d,f,m=>{g===l.length-1&&this.onJoinComplete(m,o,a,n)})}):this.onJoinComplete(e,o,a,n)})}dropPendingRefs(){h.all(document,`[${Y}="${this.id}"][${R}]`,e=>{e.removeAttribute(R),e.removeAttribute(Y)})}onJoinComplete({live_patch:e},t,i,r){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,r);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(re);return l&&o.setAttribute(re,l),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,r)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,r)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,r)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(ee,this.root.id)}execNewMounted(){let e=this.binding(Ce),t=this.binding(Te);h.all(this.el,`[${e}], [${t}]`,i=>{h.maybeAddPrivateHooks(i,e,t),this.maybeAddNewHook(i)}),h.all(this.el,`[${this.binding(be)}], [data-phx-${be}]`,i=>{this.maybeAddNewHook(i)}),h.all(this.el,`[${this.binding(_t)}]`,i=>this.maybeMounted(i))}applyJoinPatch(e,t,i,r){this.attachTrueDocEl();let n=new de(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(r),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),r=i&&h.isIgnored(e,this.binding(Ee));if(i&&!e.isEqualNode(t)&&!(r&&ri(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(_t)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e,t){let i=this.addHook(e);i&&i.__mounted()}performPatch(e,t,i=!1){let r=[],n=!1,o=new Set;return e.after("added",a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]);let l=this.binding(Ce),d=this.binding(Te);h.maybeAddPrivateHooks(a,l,d),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.after("phxChildAdded",a=>{h.isPhxSticky(a)?this.liveSocket.joinRootViews():n=!0}),e.before("updated",(a,l)=>{this.triggerBeforeUpdateHook(a,l)&&o.add(a.id)}),e.after("updated",a=>{o.has(a.id)&&this.getHook(a).__updated()}),e.after("discarded",a=>{a.nodeType===Node.ELEMENT_NODE&&r.push(a)}),e.after("transitionsDiscarded",a=>this.afterElementsRemoved(a,t)),e.perform(i),this.afterElementsRemoved(r,t),n}afterElementsRemoved(e,t){let i=[];e.forEach(r=>{let n=h.all(r,`[${F}]`),o=h.all(r,`[${this.binding(be)}]`);n.concat(r).forEach(a=>{let l=this.componentID(a);V(l)&&i.indexOf(l)===-1&&i.push(l)}),o.concat(r).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(Z)][e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new Pe(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):kt(e)||this.liveSocket.time("full patch complete",()=>{let[r,n]=this.renderContainer(e,"update"),o=new de(this,this.el,this.id,r,n,null);i=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,r=e?this.rendered.componentCIDs(e).concat(this.pruningCIDs):null,[n,o]=this.rendered.toString(r);return[`<${i}>${n}</${i}>`,o]})}componentPatch(e,t){if(kt(e))return!1;let[i,r]=this.rendered.componentToString(t),n=new de(this,this.el,this.id,i,r,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[ae.elementID(e)]}addHook(e){if(ae.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${be}`)||e.getAttribute(this.binding(be));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||C(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let r=new ae(this,e,i);return this.viewHooks[ae.elementID(r.el)]=r,r}else t!==null&&C(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[ae.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:t,kind:i,flash:r}=e,n=this.expandURL(t);this.liveSocket.historyRedirect(n,i,r)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t}){this.liveSocket.redirect(e,t)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",t=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(t))}).receive("error",t=>!this.isDestroyed()&&this.onJoinError(t)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page request`,e]),this.isMain()&&this.onRedirect({to:this.href});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.isMain()&&this.onRedirect({to:this.href});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);this.displayError([me,ke,ze]),this.log("error",()=>["unable to join",e]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this)}onClose(e){if(!this.isDestroyed()){if(this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(Yt)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([me,ke,ze]):this.displayError([me,ke,bt]))}displayError(e){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.execAll(this.binding("disconnected"))}pushWithReply(e,t,i,r=function(){}){if(!this.isConnected())return;let[n,[o],a]=e?e():[null,[],{}],l=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(gt))!==null)&&(l=this.liveSocket.withPageLoading({kind:"element",target:o})),typeof i.cid!="number"&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(t,i,Zt).receive("ok",d=>{let u=f=>{d.redirect&&this.onRedirect(d.redirect),d.live_patch&&this.onLivePatch(d.live_patch),d.live_redirect&&this.onLiveRedirect(d.live_redirect),l(),r(d,f)};d.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",d.diff,({diff:f,reply:g,events:m})=>{n!==null&&this.undoRefs(n),this.update(f,m),u(g)})}):(n!==null&&this.undoRefs(n),u(null))}))}undoRefs(e){!this.isConnected()||h.all(document,`[${Y}="${this.id}"][${R}="${e}"]`,t=>{let i=t.getAttribute(Re);t.removeAttribute(R),t.removeAttribute(Y),t.getAttribute(Qe)!==null&&(t.readOnly=!1,t.removeAttribute(Qe)),i!==null&&(t.disabled=i==="true",t.removeAttribute(Re)),Je.forEach(o=>h.removeClass(t,o));let r=t.getAttribute(De);r!==null&&(t.innerText=r,t.removeAttribute(De));let n=h.private(t,R);if(n){let o=this.triggerBeforeUpdateHook(t,n);de.patchEl(t,n,this.liveSocket.getActiveElement()),o&&o.__updated(),h.deletePrivate(t,R)}})}putRef(e,t,i={}){let r=this.ref++,n=this.binding(Oe);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(o=>{o.classList.add(`phx-${t}-loading`),o.setAttribute(R,r),o.setAttribute(Y,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(De)||o.setAttribute(De,o.innerText),a!==""&&(o.innerText=a),o.setAttribute("disabled",""))}),[r,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(F);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(V(t))return t;let r=i.target||e.getAttribute(this.binding("target"));return V(r)?parseInt(r):t&&(r!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return V(e)?e:e?z(e.closest(`[${F}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,r,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,r]),!1;let[o,a,l]=this.putRef([e],"hook");return this.pushWithReply(()=>[o,a,l],"event",{type:"hook",event:i,value:r,cid:this.closestComponentID(t)},(d,u)=>n(u,o)),o}extractMeta(e,t,i){let r=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(r)&&(t[o.replace(r,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&Ye.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,r,n,o={},a){this.pushWithReply(()=>this.putRef([t],e,o),"event",{type:e,event:r,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)},(l,d)=>a&&a(d))}pushFileProgress(e,t,i,r=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(Gt)),ref:e.getAttribute($),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)},r)})}pushInput(e,t,i,r,n,o){let a,l=V(i)?i:this.targetComponentID(e.form,t,n),d=()=>this.putRef([e,e.form],"change",n),u,f=this.extractMeta(e.form);e.getAttribute(this.binding("change"))?u=lt(e.form,X({_target:n._target},f),[e.name]):u=lt(e.form,X({_target:n._target},f)),h.isUploadInput(e)&&e.files&&e.files.length>0&&w.trackFiles(e,Array.from(e.files)),a=w.serializeUploads(e);let g={type:"form",event:r,value:u,uploads:a,cid:l};this.pushWithReply(d,"event",g,m=>{if(h.showError(e,this.liveSocket.binding(le)),h.isUploadInput(e)&&h.isAutoUpload(e)){if(w.filesAwaitingPreflight(e).length>0){let[p,b]=d();this.uploadFiles(e.form,t,p,l,T=>{o&&o(m),this.triggerAwaitingSubmit(e.form),this.undoRefs(p)})}}else o&&o(m)})}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,r,n,o]=t;this.cancelSubmit(e),o()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,r,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,r){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,r])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([t,i,r])=>t.isSameNode(e)?(this.undoRefs(i),!1):!0)}disableForm(e,t={}){let i=f=>!(he(f,`${this.binding(Ee)}=ignore`,f.form)||he(f,"data-phx-update=ignore",f.form)),r=f=>f.hasAttribute(this.binding(Oe)),n=f=>f.tagName=="BUTTON",o=f=>["INPUT","TEXTAREA","SELECT"].includes(f.tagName),a=Array.from(e.elements),l=a.filter(r),d=a.filter(n).filter(i),u=a.filter(o).filter(i);return d.forEach(f=>{f.setAttribute(Re,f.disabled),f.disabled=!0}),u.forEach(f=>{f.setAttribute(Qe,f.readOnly),f.readOnly=!0,f.files&&(f.setAttribute(Re,f.disabled),f.disabled=!0)}),e.setAttribute(this.binding(gt),""),this.putRef([e].concat(l).concat(d).concat(u),"submit",t)}pushFormSubmit(e,t,i,r,n,o){let a=()=>this.disableForm(e,n),l=this.targetComponentID(e,t);if(w.hasUploadsInProgress(e)){let[d,u]=a(),f=()=>this.pushFormSubmit(e,t,i,r,n,o);return this.scheduleSubmit(e,d,n,f)}else if(w.inputsAwaitingPreflight(e).length>0){let[d,u]=a(),f=()=>[d,u,n];this.uploadFiles(e,t,d,l,g=>{let m=this.extractMeta(e),p=lt(e,X({submitter:r},m));this.pushWithReply(f,"event",{type:"form",event:i,value:p,cid:l},o)})}else if(!(e.hasAttribute(R)&&e.classList.contains("phx-submit-loading"))){let d=this.extractMeta(e),u=lt(e,X({submitter:r},d));this.pushWithReply(a,"event",{type:"form",event:i,value:u,cid:l},o)}}uploadFiles(e,t,i,r,n){let o=this.joinCount,a=w.activeFileInputs(e),l=a.length;a.forEach(d=>{let u=new w(d,this,()=>{l--,l===0&&n()});this.uploaders[d]=u;let f=u.entries().map(m=>m.toPreflightPayload()),g={ref:d.getAttribute($),entries:f,cid:this.targetComponentID(d.form,t)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g,m=>{if(this.log("upload",()=>["got preflight response",m]),m.error){this.undoRefs(i);let[p,b]=m.error;this.log("upload",()=>[`error for entry ${p}`,b])}else{let p=b=>{this.channel.onError(()=>{this.joinCount===o&&b()})};u.initAdapterUpload(m,p,this.liveSocket)}})})}dispatchUploads(e,t,i){let r=this.targetCtxElement(e)||this.el,n=h.findUploadInputs(r).filter(o=>o.name===t);n.length===0?C(`no live file inputs found matching the name "${t}"`):n.length>1?C(`duplicate live file inputs found matching the name "${t}"`):h.dispatchEvent(n[0],We,{detail:{files:i}})}targetCtxElement(e){if(V(e)){let[t]=h.findComponentNodeList(this.el,e);return t}else return e||null}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(r,n)=>{let o=this.binding("change"),a=Array.from(e.elements).filter(u=>h.isFormInput(u)&&u.name&&!u.hasAttribute(o));if(a.length===0)return;a.forEach(u=>u.hasAttribute($)&&w.clearFiles(u));let l=a.find(u=>u.type!=="hidden")||a[0],d=e.getAttribute(this.binding(At))||e.getAttribute(this.binding("change"));N.exec("change",d,r,l,["push",{_target:l.name,newCid:t,callback:i}])})}pushLinkPatch(e,t,i){let r=this.liveSocket.setPendingLink(e),n=t?()=>this.putRef([t],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=e.startsWith("/")?`${location.protocol}//${location.host}${e}`:e,l=this.pushWithReply(n,"live_patch",{url:a},d=>{this.liveSocket.requestDOMUpdate(()=>{d.link_redirect?this.liveSocket.replaceMain(e,null,i,r):(this.liveSocket.commitPendingLink(r)&&(this.href=e),this.applyPendingUpdates(),i&&i(r))})});l?l.receive("timeout",o):o()}formsForRecovery(e){if(this.joinCount===0)return[];let t=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,h.all(this.el,`form[${t}]`).filter(r=>r.id&&this.ownsElement(r)).filter(r=>r.elements.length>0).filter(r=>r.getAttribute(this.binding(At))!=="ignore").map(r=>{let n=r.getAttribute(t).replaceAll(/([\[\]"])/g,"\\$1"),o=i.content.querySelector(`form[id="${r.id}"][${t}="${n}"]`);return o?[r,o,this.targetComponentID(o)]:[r,r,this.targetComponentID(r)]}).filter(([r,n,o])=>n)}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(this.pruningCIDs.push(...t),this.pushWithReply(null,"cids_will_destroy",{cids:t},()=>{this.pruningCIDs=this.pruningCIDs.filter(r=>t.indexOf(r)!==-1);let i=t.filter(r=>h.findComponentNodeList(this.el,r).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i},r=>{this.rendered.pruneCIDs(r.cids)})}))}ownsElement(e){let t=e.closest(Q);return e.getAttribute(Z)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,r,n={}){h.putPrivate(e,ve,!0);let o=this.liveSocket.binding(le),a=Array.from(e.elements);a.forEach(l=>h.putPrivate(l,ve,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,r,n,()=>{a.forEach(l=>h.showError(l,o)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var ht=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
|
|
9
8
|
a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:
|
|
10
9
|
|
|
11
10
|
import {Socket} from "phoenix"
|
|
12
11
|
import {LiveSocket} from "phoenix_live_view"
|
|
13
12
|
let liveSocket = new LiveSocket("/live", Socket, {...})
|
|
14
|
-
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Qt,this.opts=i,this.params=rt(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Se(ei),i.defaults||{}),this.activeElement=null,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=Se(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||zt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||Ft,this.reloadJitterMin=i.reloadJitterMin||Mt,this.reloadJitterMax=i.reloadJitterMax||Ut,this.failsafeJitter=i.failsafeJitter||Xt,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:rt(),onBeforeElUpdated:rt()},i.dom||{}),this.transitions=new vi,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(Ze)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(De)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(De)==="false"}enableDebug(){this.sessionStorage.setItem(De,"true")}enableProfiling(){this.sessionStorage.setItem(Ze,"true")}disableDebug(){this.sessionStorage.setItem(De,"false")}disableProfiling(){this.sessionStorage.removeItem(Ze)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(et,e)}disableLatencySim(){this.sessionStorage.removeItem(et)}getLatencySim(){let e=this.sessionStorage.getItem(et);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.bindTopLevelEvents({dead:!0}),this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){this.owner(e,s=>F.exec(i,t,s,e))}execJSHookPush(e,t,i,s){this.withinOwners(e,n=>{F.exec("hook",t,n,e,["push",{data:i,callback:s}])})}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[s,n]=i();this.viewLogger(e,t,s,n)}else if(this.isDebugEnabled()){let[s,n]=i();ri(e,t,s,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}wrapPush(e,t,i){let s=this.getLatencySim(),n=e.joinCount;if(!s)return this.isConnected()&&t.timeout?i().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):i();let o={receives:[],receive(a,l){this.receives.push([a,l])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[l,d])=>a.receive(l,d),i())},s),o}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,o=j.updateLocal(this.localStorage,window.location.pathname,$e,0,a=>a+1);o>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?di[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,t){return this.socket.channel(e,t)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>t.execNewMounted())}}joinRootViews(){let e=!1;return h.all(document,`${Y}:not([${Z}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.hasAttribute(ge)&&(this.main=i)}e=!0}),e}redirect(e,t){this.unload(),j.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(o,t,n),this.main.setRedirect(e),this.transitionRemoves(),this.main.join((a,l)=>{a===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{h.findPhxSticky(document).forEach(d=>o.appendChild(d)),this.outgoingMainEl.replaceWith(o),this.outgoingMainEl=null,i&&requestAnimationFrame(()=>i(s)),l()})})}transitionRemoves(e){let t=this.binding("remove");e=e||h.all(document,`[${t}]`),e.forEach(i=>{this.execJS(i,i.getAttribute(t),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(V)!==null}newRootView(e,t,i){let s=new ye(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=z(e.closest(Y),s=>this.getViewByEl(s))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(ee);return z(this.getRootById(t),i=>i.getDescendentByEl(e))}getRootById(e){return this.roots[e]}destroyAllViews(){for(let e in this.roots)this.roots[e].destroy(),delete this.roots[e];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(ee));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let t=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",t),e.addEventListener("touchend",t)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.socket.onClose(t=>{if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,s,n,o,a)=>{let l=n.getAttribute(this.binding(Kt)),d=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==d)return;let u=$({key:t.key},this.eventMeta(i,t,n));F.exec(i,o,s,n,["push",{data:u}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,n,o,a)=>{if(!a){let l=$({key:t.key},this.eventMeta(i,t,n));F.exec(i,o,s,n,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,n,o,a)=>{if(a==="window"){let l=this.eventMeta(i,t,n);F.exec(i,o,s,n,["push",{data:l}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=z(he(t.target,this.binding(pt)),o=>o.getAttribute(this.binding(pt))),s=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!s||s.disabled||n.length===0||!(s.files instanceof FileList)||(P.trackFiles(s,n,t.dataTransfer),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(Je,t=>{let i=t.target;if(!h.isUploadInput(i))return;let s=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);P.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let s=this.metadataCallbacks[e];return s?s(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.linkRef}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let s=e[i];this.on(s,n=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=n.target.getAttribute&&n.target.getAttribute(o);l?this.debounce(n.target,n,s,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,l,null)})}):h.all(document,`[${a}]`,d=>{let u=d.getAttribute(a);this.debounce(d,n,s,()=>{this.withinOwners(d,f=>{t(n,i,f,d,u,"window")})})})})}}bindClicks(){window.addEventListener("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let s=this.binding(t);window.addEventListener(e,n=>{let o=null;if(i)o=n.target.matches(`[${s}]`)?n.target:n.target.querySelector(`[${s}]`);else{let l=this.clickStartedAtTarget||n.target;o=he(l,s),this.dispatchClickAway(n,l),this.clickStartedAtTarget=null}let a=o&&o.getAttribute(s);if(!a){!i&&h.isNewPageClick(n,window.location)&&this.unload();return}o.getAttribute("href")==="#"&&n.preventDefault(),!o.hasAttribute(O)&&this.debounce(o,n,"click",()=>{this.withinOwners(o,l=>{F.exec("click",a,l,o,["push",{data:this.eventMeta("click",n,o)}])})})},i)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(e.target,n=>{let o=s.getAttribute(i);F.isVisible(s)&&F.isInViewport(s)&&F.exec("click",o,n,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!j.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{j.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,id:s,root:n,scroll:o}=t.state||{},a=window.location.href;h.dispatchEvent(window,"phx:navigate",{detail:{href:a,patch:i==="patch",pop:!0}}),this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&s===this.main.id?this.main.pushLinkPatch(a,null,()=>{this.maybeScroll(o)}):this.replaceMain(a,null,()=>{n&&this.replaceRootHistory(),this.maybeScroll(o)})})},!1),window.addEventListener("click",t=>{let i=he(t.target,Ve),s=i&&i.getAttribute(Ve);if(!s||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let n=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,o=i.getAttribute(Bt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(n,o,i);else if(s==="redirect")this.historyRedirect(n,o);else throw new Error(`expected ${Ve} to be "patch" or "redirect", got: ${s}`);let a=i.getAttribute(this.binding("click"));a&&this.requestDOMUpdate(()=>this.execJS(i,a,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i){if(!this.isConnected())return j.redirect(e);this.withPageLoading({to:e,kind:"patch"},s=>{this.main.pushLinkPatch(e,i,n=>{this.historyPatch(e,t,n),s()})})}historyPatch(e,t,i=this.setPendingLink(e)){!this.commitPendingLink(i)||(j.pushState(t,{type:"patch",id:this.main.id},e),h.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i){if(!this.isConnected())return j.redirect(e,i);if(/^\/$|^\/[^\/]+.*$/.test(e)){let{protocol:n,host:o}=window.location;e=`${n}//${o}${e}`}let s=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,i,o=>{o===this.linkRef&&(j.pushState(t,{type:"redirect",id:this.main.id,scroll:s},e),h.dispatchEvent(window,"phx:navigate",{detail:{href:e,patch:!1,pop:!1}}),this.registerNewLocation(window.location)),n()})})}replaceRootHistory(){j.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=Se(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!s&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))},!0),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));if(!s){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{F.exec("submit",s,n,i.target,["push",{submitter:i.submitter}])})},!1);for(let i of["change","input"])this.on(i,s=>{let n=this.binding("change"),o=s.target,a=o.getAttribute(n),l=o.form&&o.form.getAttribute(n),d=a||l;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let u=a?o:o.form,f=e;e++;let{at:m,type:p}=h.private(o,"prev-iteration")||{};m===f-1&&i==="change"&&p==="input"||(h.putPrivate(o,"prev-iteration",{at:f,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(u,g=>{h.putPrivate(o,Ce,!0),h.isTextualInput(o)||this.setActiveElement(o),F.exec("change",d,g,o,["push",{_target:s.target.name,dispatcher:u}])})}))},!1);this.on("reset",i=>{let s=i.target;h.resetForm(s,this.binding(le));let n=Array.from(s.elements).find(o=>o.type==="reset");window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let n=this.binding(Wt),o=this.binding(qt),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,d=>{let u=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,a,o,l,u,()=>{s()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,i=>{this.silenced||t(i)})}},vi=class{constructor(){this.transitions=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.flushPendingOps()},e);this.transitions.add(s)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};return Vi;})();
|
|
13
|
+
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Qt,this.opts=i,this.params=st(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Se(ei),i.defaults||{}),this.activeElement=null,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=Se(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||zt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||Ft,this.reloadJitterMin=i.reloadJitterMin||Mt,this.reloadJitterMax=i.reloadJitterMax||Ut,this.failsafeJitter=i.failsafeJitter||Xt,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:st(),onBeforeElUpdated:st()},i.dom||{}),this.transitions=new vi,window.addEventListener("pagehide",r=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(Ze)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(He)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(He)==="false"}enableDebug(){this.sessionStorage.setItem(He,"true")}enableProfiling(){this.sessionStorage.setItem(Ze,"true")}disableDebug(){this.sessionStorage.setItem(He,"false")}disableProfiling(){this.sessionStorage.removeItem(Ze)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(et,e)}disableLatencySim(){this.sessionStorage.removeItem(et)}getLatencySim(){let e=this.sessionStorage.getItem(et);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.bindTopLevelEvents({dead:!0}),this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){this.owner(e,r=>N.exec(i,t,r,e))}execJSHookPush(e,t,i,r){this.withinOwners(e,n=>{N.exec("hook",t,n,e,["push",{data:i,callback:r}])})}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[r,n]=i();this.viewLogger(e,t,r,n)}else if(this.isDebugEnabled()){let[r,n]=i();si(e,t,r,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,r=>{let n=this.getLatencySim();n?setTimeout(()=>i(r),n):i(r)})}wrapPush(e,t,i){let r=this.getLatencySim(),n=e.joinCount;if(!r)return this.isConnected()&&t.timeout?i().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):i();let o={receives:[],receive(a,l){this.receives.push([a,l])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[l,d])=>a.receive(l,d),i())},r),o}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,r=this.reloadJitterMax,n=Math.floor(Math.random()*(r-i+1))+i,o=J.updateLocal(this.localStorage,window.location.pathname,Ve,0,a=>a+1);o>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?di[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,t){return this.socket.channel(e,t)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>t.execNewMounted())}}joinRootViews(){let e=!1;return h.all(document,`${Q}:not([${Z}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.hasAttribute(ge)&&(this.main=i)}e=!0}),e}redirect(e,t){this.unload(),J.redirect(e,t)}replaceMain(e,t,i=null,r=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(o,t,n),this.main.setRedirect(e),this.transitionRemoves(),this.main.join((a,l)=>{a===1&&this.commitPendingLink(r)&&this.requestDOMUpdate(()=>{h.findPhxSticky(document).forEach(d=>o.appendChild(d)),this.outgoingMainEl.replaceWith(o),this.outgoingMainEl=null,i&&requestAnimationFrame(()=>i(r)),l()})})}transitionRemoves(e){let t=this.binding("remove");e=e||h.all(document,`[${t}]`),e.forEach(i=>{this.execJS(i,i.getAttribute(t),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(B)!==null}newRootView(e,t,i){let r=new Pe(e,this,null,t,i);return this.roots[r.id]=r,r}owner(e,t){let i=z(e.closest(Q),r=>this.getViewByEl(r))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(ee);return z(this.getRootById(t),i=>i.getDescendentByEl(e))}getRootById(e){return this.roots[e]}destroyAllViews(){for(let e in this.roots)this.roots[e].destroy(),delete this.roots[e];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(ee));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let t=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",t),e.addEventListener("touchend",t)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.socket.onClose(t=>{if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,r,n,o,a)=>{let l=n.getAttribute(this.binding(Kt)),d=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==d)return;let u=X({key:t.key},this.eventMeta(i,t,n));N.exec(i,o,r,n,["push",{data:u}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,r,n,o,a)=>{if(!a){let l=X({key:t.key},this.eventMeta(i,t,n));N.exec(i,o,r,n,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,r,n,o,a)=>{if(a==="window"){let l=this.eventMeta(i,t,n);N.exec(i,o,r,n,["push",{data:l}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=z(he(t.target,this.binding(pt)),o=>o.getAttribute(this.binding(pt))),r=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!r||r.disabled||n.length===0||!(r.files instanceof FileList)||(w.trackFiles(r,n,t.dataTransfer),r.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(We,t=>{let i=t.target;if(!h.isUploadInput(i))return;let r=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);w.trackFiles(i,r),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let r=this.metadataCallbacks[e];return r?r(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.linkRef}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let r=e[i];this.on(r,n=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=n.target.getAttribute&&n.target.getAttribute(o);l?this.debounce(n.target,n,r,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,l,null)})}):h.all(document,`[${a}]`,d=>{let u=d.getAttribute(a);this.debounce(d,n,r,()=>{this.withinOwners(d,f=>{t(n,i,f,d,u,"window")})})})})}}bindClicks(){window.addEventListener("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let r=this.binding(t);window.addEventListener(e,n=>{let o=null;if(i)o=n.target.matches(`[${r}]`)?n.target:n.target.querySelector(`[${r}]`);else{let l=this.clickStartedAtTarget||n.target;o=he(l,r),this.dispatchClickAway(n,l),this.clickStartedAtTarget=null}let a=o&&o.getAttribute(r);if(!a){!i&&h.isNewPageClick(n,window.location)&&this.unload();return}o.getAttribute("href")==="#"&&n.preventDefault(),!o.hasAttribute(R)&&this.debounce(o,n,"click",()=>{this.withinOwners(o,l=>{N.exec("click",a,l,o,["push",{data:this.eventMeta("click",n,o)}])})})},i)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,r=>{r.isSameNode(t)||r.contains(t)||this.withinOwners(e.target,n=>{let o=r.getAttribute(i);N.isVisible(r)&&N.isInViewport(r)&&N.exec("click",o,n,r,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!J.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{J.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,id:r,root:n,scroll:o}=t.state||{},a=window.location.href;h.dispatchEvent(window,"phx:navigate",{detail:{href:a,patch:i==="patch",pop:!0}}),this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&r===this.main.id?this.main.pushLinkPatch(a,null,()=>{this.maybeScroll(o)}):this.replaceMain(a,null,()=>{n&&this.replaceRootHistory(),this.maybeScroll(o)})})},!1),window.addEventListener("click",t=>{let i=he(t.target,je),r=i&&i.getAttribute(je);if(!r||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let n=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,o=i.getAttribute(Bt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(r==="patch")this.pushHistoryPatch(n,o,i);else if(r==="redirect")this.historyRedirect(n,o);else throw new Error(`expected ${je} to be "patch" or "redirect", got: ${r}`);let a=i.getAttribute(this.binding("click"));a&&this.requestDOMUpdate(()=>this.execJS(i,a,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i){if(!this.isConnected())return J.redirect(e);this.withPageLoading({to:e,kind:"patch"},r=>{this.main.pushLinkPatch(e,i,n=>{this.historyPatch(e,t,n),r()})})}historyPatch(e,t,i=this.setPendingLink(e)){!this.commitPendingLink(i)||(J.pushState(t,{type:"patch",id:this.main.id},e),h.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i){if(!this.isConnected())return J.redirect(e,i);if(/^\/$|^\/[^\/]+.*$/.test(e)){let{protocol:n,host:o}=window.location;e=`${n}//${o}${e}`}let r=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,i,o=>{o===this.linkRef&&(J.pushState(t,{type:"redirect",id:this.main.id,scroll:r},e),h.dispatchEvent(window,"phx:navigate",{detail:{href:e,patch:!1,pop:!1}}),this.registerNewLocation(window.location)),n()})})}replaceRootHistory(){J.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=Se(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let r=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!r&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))},!0),this.on("submit",i=>{let r=i.target.getAttribute(this.binding("submit"));if(!r){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{N.exec("submit",r,n,i.target,["push",{submitter:i.submitter}])})},!1);for(let i of["change","input"])this.on(i,r=>{let n=this.binding("change"),o=r.target,a=o.getAttribute(n),l=o.form&&o.form.getAttribute(n),d=a||l;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let u=a?o:o.form,f=e;e++;let{at:g,type:m}=h.private(o,"prev-iteration")||{};g===f-1&&i==="change"&&m==="input"||(h.putPrivate(o,"prev-iteration",{at:f,type:i}),this.debounce(o,r,i,()=>{this.withinOwners(u,p=>{h.putPrivate(o,Ie,!0),h.isTextualInput(o)||this.setActiveElement(o),N.exec("change",d,p,o,["push",{_target:r.target.name,dispatcher:u}])})}))},!1);this.on("reset",i=>{let r=i.target;h.resetForm(r,this.binding(le));let n=Array.from(r.elements).find(o=>o.type==="reset");window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,r){if(i==="blur"||i==="focusout")return r();let n=this.binding(Wt),o=this.binding(qt),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,d=>{let u=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,a,o,l,u,()=>{r()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,i=>{this.silenced||t(i)})}},vi=class{constructor(){this.transitions=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let r=setTimeout(()=>{this.transitions.delete(r),i(),this.flushPendingOps()},e);this.transitions.add(r)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};return Bi;})();
|