phoenix_live_view 0.19.0 → 0.19.2

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