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