phoenix_live_view 1.0.13 → 1.0.14

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