Packages
phoenix_live_view
1.0.9
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.2.0-rc.3
1.2.0-rc.2
1.2.0-rc.1
1.2.0-rc.0
1.1.32
1.1.31
1.1.30
1.1.29
1.1.28
1.1.27
1.1.26
1.1.25
1.1.24
1.1.23
1.1.22
1.1.21
1.1.20
1.1.19
1.1.18
1.1.17
1.1.16
1.1.15
1.1.14
1.1.13
1.1.12
1.1.11
1.1.10
1.1.9
1.1.8
1.1.7
1.1.6
retired
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.1.0-rc.4
1.1.0-rc.3
1.1.0-rc.2
1.1.0-rc.1
1.1.0-rc.0
1.0.18
1.0.17
1.0.16
1.0.15
1.0.14
1.0.13
1.0.12
1.0.11
1.0.10
1.0.9
1.0.8
retired
1.0.7
1.0.6
retired
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-rc.9
1.0.0-rc.8
1.0.0-rc.7
1.0.0-rc.6
1.0.0-rc.5
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
1.0.0-rc.0
0.20.17
0.20.16
0.20.15
0.20.14
0.20.13
0.20.12
0.20.11
0.20.10
0.20.9
0.20.8
0.20.7
0.20.6
0.20.5
0.20.4
0.20.3
0.20.2
0.20.1
0.20.0
0.19.5
0.19.4
0.19.3
0.19.2
0.19.1
0.19.0
0.18.18
0.18.17
0.18.16
0.18.15
0.18.14
0.18.13
0.18.12
0.18.11
0.18.10
0.18.9
0.18.8
0.18.7
0.18.6
0.18.5
0.18.4
0.18.3
0.18.2
0.18.1
0.18.0
0.17.14
0.17.13
0.17.12
0.17.11
0.17.10
0.17.9
0.17.8
0.17.7
0.17.6
0.17.5
0.17.4
0.17.3
0.17.2
0.17.1
0.17.0
0.16.4
0.16.3
0.16.2
0.16.1
0.16.0
0.15.7
0.15.6
0.15.5
0.15.4
0.15.3
0.15.2
0.15.1
0.15.0
0.14.8
0.14.7
0.14.6
0.14.5
0.14.4
0.14.3
0.14.2
0.14.1
0.14.0
0.13.3
0.13.2
0.13.1
0.13.0
0.12.1
0.12.0
0.11.1
0.11.0
0.10.0
0.9.0
0.8.1
0.8.0
0.7.1
0.7.0
0.6.0
0.6.0-dev
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.3.1
0.3.0
0.2.1
0.2.0
0.1.1
0.1.0
Rich, real-time user experiences with server-rendered HTML
Current section
Files
Jump to
Current section
Files
priv/static/phoenix_live_view.min.js
var LiveView=(()=>{var ze=Object.defineProperty,Ei=Object.defineProperties,yi=Object.getOwnPropertyDescriptor,Pi=Object.getOwnPropertyDescriptors,ki=Object.getOwnPropertyNames,Ft=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Ci=Object.prototype.propertyIsEnumerable;var Mt=(s,e,t)=>e in s?ze(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,N=(s,e)=>{for(var t in e||(e={}))Ut.call(e,t)&&Mt(s,t,e[t]);if(Ft)for(var t of Ft(e))Ci.call(e,t)&&Mt(s,t,e[t]);return s},Ne=(s,e)=>Ei(s,Pi(e));var Ti=(s,e)=>{for(var t in e)ze(s,t,{get:e[t],enumerable:!0})},Ri=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ki(e))!Ut.call(s,r)&&r!==t&&ze(s,r,{get:()=>e[r],enumerable:!(i=yi(e,r))||i.enumerable});return s};var xi=s=>Ri(ze({},"__esModule",{value:!0}),s);var ns={};Ti(ns,{LiveSocket:()=>qe,createHook:()=>rs,isUsedInput:()=>_i});var Ye="consecutive-reloads";var Qe=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],$="data-phx-component",Ze="data-phx-link",Xt="track-static",$t="data-phx-link-state",ae="data-phx-ref-loading",O="data-phx-ref-src",C="data-phx-ref-lock",et="track-uploads",B="data-phx-upload-ref",we="data-phx-preflighted-refs",Bt="data-phx-done-refs",pt="drop-target",Fe="data-phx-active-refs",Ee="phx:live-file:updated",tt="data-phx-skip",it="data-phx-id",mt="data-phx-prune",gt="phx-connected",he="phx-loading",fe="phx-error",vt="phx-client-error",ye="phx-server-error",ee="data-phx-parent-id",Pe="data-phx-main",W="data-phx-root-id",Me="viewport-top",Ue="viewport-bottom",Vt="trigger-action",pe="phx-has-focused",jt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],st=["checkbox","radio"],me="phx-has-submitted",M="data-phx-session",K=`[${M}]`,bt="data-phx-sticky",te="data-phx-static",Xe="data-phx-readonly",de="data-phx-disabled",At="disable-with",ke="data-phx-disable-with-restore",Ce="hook",Jt="debounce",Wt="throttle",Te="update",rt="stream",Re="data-phx-stream",qt="key",G="phxPrivate",St="auto-recover",$e="phx:live-socket:debug",nt="phx:live-socket:profiling",ot="phx:live-socket:latency-sim",Be="phx:nav-history-position",Kt="progress",_t="mounted",wt="__phoenix_reload_status__",Gt=1,Et=3,zt=200,Yt=500,Qt="phx-",Zt=3e4;var xe="debounce-trigger",Ie="throttled",yt="debounce-prev-key",ei={debounce:300,throttle:300},Pt=[ae,O,C],Ve="d",z="s",lt="r",L="c",kt="e",Ct="r",Tt="t",ti="p",Rt="stream";var je=class{constructor(e,t,i){let{chunk_size:r,chunk_timeout:n}=t;this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=r,this.chunkTimeout=n,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(e))}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return I("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 I=(s,e)=>console.error&&console.error(s,e),q=s=>{let e=typeof s;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(s)};function ii(){let s=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)s.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):s.add(e[t].id)}function si(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 ri=(s,e,t,i)=>{s.liveSocket.isDebugEnabled()&&console.log(`${s.id} ${e}: ${t} - `,i)},Oe=s=>typeof s=="function"?s:function(){return s},Le=s=>JSON.parse(JSON.stringify(s)),ge=(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(K)));return null},ve=s=>s!==null&&typeof s=="object"&&!(s instanceof Array),ni=(s,e)=>JSON.stringify(s)===JSON.stringify(e),xt=s=>{for(let e in s)return!1;return!0},Y=(s,e)=>s&&e(s),oi=function(s,e,t,i){s.forEach(r=>{new je(r,t.config,i).upload()})};var Ii={canPushState(){return typeof history.pushState!="undefined"},dropLocal(s,e,t){return s.removeItem(this.localKey(e,t))},updateLocal(s,e,t,i,r){let n=this.getLocal(s,e,t),o=this.localKey(e,t),l=n===null?i:r(n);return s.setItem(o,JSON.stringify(l)),l},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){e&&this.setCookie("__phoenix_flash__",e,60),window.location=s},localKey(s,e){return`${s}-${e}`},getHashTargetEl(s){let e=s.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},D=Ii;var be={byId(s){return document.getElementById(s)||I(`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(B)!==null},isAutoUpload(s){return s.hasAttribute("data-phx-auto-upload")},findUploadInputs(s){let e=s.id,t=this.all(document,`input[type="file"][${B}][form="${e}"]`);return this.all(s,`input[type="file"][${B}]`).concat(t)},findComponentNodeList(s,e){return this.filterWithinSameLiveView(this.all(s,`[${$}="${e}"]`),s)},isPhxDestroyed(s){return!!(s.id&&be.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",r=s.target.hasAttribute("target")&&!s.target.getAttribute("target").startsWith("_");return e||i||t||r},isUnloadableFormSubmit(s){return s.target&&s.target.getAttribute("method")==="dialog"||s.submitter&&s.submitter.getAttribute("formmethod")==="dialog"?!1:!s.defaultPrevented&&!this.wantsNewTab(s)},isNewPageClick(s,e){let t=s.target instanceof HTMLAnchorElement?s.target.getAttribute("href"):null,i;if(s.defaultPrevented||t===null||this.wantsNewTab(s)||t.startsWith("mailto:")||t.startsWith("tel:")||s.target.isContentEditable)return!1;try{i=new URL(t)}catch(r){try{i=new URL(t,e)}catch(n){return!0}}return i.host===e.host&&i.protocol===e.protocol&&i.pathname===e.pathname&&i.search===e.search?i.hash===""&&!i.href.endsWith("#"):i.protocol.startsWith("http")},markPhxChildDestroyed(s){this.isPhxChild(s)&&s.setAttribute(M,""),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,`[${bt}]`)},findPhxChildren(s,e){return this.all(s,`${K}[${ee}="${e}"]`)},findExistingParentCIDs(s,e){let t=new Set,i=new Set;return e.forEach(r=>{this.filterWithinSameLiveView(this.all(s,`[${$}="${r}"]`),s).forEach(n=>{t.add(r),this.filterWithinSameLiveView(this.all(n,`[${$}]`),n).map(o=>parseInt(o.getAttribute($))).forEach(o=>i.add(o))})}),i.forEach(r=>t.delete(r)),t},filterWithinSameLiveView(s,e){return e.querySelector(K)?s.filter(t=>this.withinSameLiveView(t,e)):s},withinSameLiveView(s,e){for(;s=s.parentNode;){if(s.isSameNode(e))return!0;if(s.getAttribute(M)!==null)return!1}},private(s,e){return s[G]&&s[G][e]},deletePrivate(s,e){s[G]&&delete s[G][e]},putPrivate(s,e,t){s[G]||(s[G]={}),s[G][e]=t},updatePrivate(s,e,t,i){let r=this.private(s,e);r===void 0?this.putPrivate(s,e,i(t)):this.putPrivate(s,e,i(r))},syncPendingAttrs(s,e){s.hasAttribute(O)&&(Qe.forEach(t=>{s.classList.contains(t)&&e.classList.add(t)}),Pt.filter(t=>s.hasAttribute(t)).forEach(t=>{e.setAttribute(t,s.getAttribute(t))}))},copyPrivates(s,e){e[G]&&(s[G]=e[G])},putTitle(s){let e=document.querySelector("title");if(e){let{prefix:t,suffix:i,default:r}=e.dataset,n=typeof s!="string"||s.trim()==="";if(n&&typeof r!="string")return;let o=n?r:s;document.title=`${t||""}${o||""}${i||""}`}else document.title=s},debounce(s,e,t,i,r,n,o,l){let a=s.getAttribute(t),d=s.getAttribute(r);a===""&&(a=i),d===""&&(d=n);let u=a||d;switch(u){case null:return l();case"blur":this.incCycle(s,"debounce-blur-cycle",()=>{o()&&l()}),this.once(s,"debounce-blur")&&s.addEventListener("blur",()=>this.triggerCycle(s,"debounce-blur-cycle"));return;default:let p=parseInt(u),m=()=>d?this.deletePrivate(s,Ie):l(),g=this.incCycle(s,xe,m);if(isNaN(p))return I(`invalid throttle/debounce value: ${u}`);if(d){let v=!1;if(e.type==="keydown"){let A=this.private(s,yt);this.putPrivate(s,yt,e.key),v=A!==e.key}if(!v&&this.private(s,Ie))return!1;{l();let A=setTimeout(()=>{o()&&this.triggerCycle(s,xe)},p);this.putPrivate(s,Ie,A)}}else setTimeout(()=>{o()&&this.triggerCycle(s,xe,g)},p);let c=s.form;c&&this.once(c,"bind-debounce")&&c.addEventListener("submit",()=>{Array.from(new FormData(c).entries(),([v])=>{let A=c.querySelector(`[name="${v}"]`);this.incCycle(A,xe),this.deletePrivate(A,Ie)})}),this.once(s,"bind-debounce")&&s.addEventListener("blur",()=>{clearTimeout(this.private(s,Ie)),this.triggerCycle(s,xe)})}},triggerCycle(s,e,t){let[i,r]=this.private(s,e);t||(t=i),t===i&&(this.incCycle(s,e),r())},once(s,e){return this.private(s,e)===!0?!1:(this.putPrivate(s,e,!0),!0)},incCycle(s,e,t=function(){}){let[i]=this.private(s,e)||[0,t];return i++,this.putPrivate(s,e,[i,t]),i},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(`
hook attached to non-connected DOM element
ensure you are calling createHook within your connectedCallback. ${s.outerHTML}
`),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,pe)||this.private(s,me))},resetForm(s){Array.from(s.elements).forEach(e=>{this.deletePrivate(e,pe),this.deletePrivate(e,me)})},isPhxChild(s){return s.getAttribute&&s.getAttribute(ee)},isPhxSticky(s){return s.getAttribute&&s.getAttribute(bt)!==null},isChildOfAny(s,e){return!!e.find(t=>t.contains(s))},firstPhxChild(s){return this.isPhxChild(s)?s:this.all(s,`[${ee}]`)[0]},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||{}},l=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);s.dispatchEvent(l)},cloneNode(s,e){if(typeof e=="undefined")return s.cloneNode(!0);{let t=s.cloneNode(!1);return t.innerHTML=e,t}},mergeAttrs(s,e,t={}){let i=new Set(t.exclude||[]),r=t.isIgnored,n=e.attributes;for(let l=n.length-1;l>=0;l--){let a=n[l].name;if(i.has(a))a==="value"&&s.value===e.value&&s.setAttribute("value",e.getAttribute(a));else{let d=e.getAttribute(a);s.getAttribute(a)!==d&&(!r||r&&a.startsWith("data-"))&&s.setAttribute(a,d)}}let o=s.attributes;for(let l=o.length-1;l>=0;l--){let a=o[l].name;r?a.startsWith("data-")&&!e.hasAttribute(a)&&!Pt.includes(a)&&s.removeAttribute(a):e.hasAttribute(a)||s.removeAttribute(a)}},mergeFocusedInput(s,e){s instanceof HTMLSelectElement||be.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(),!be.isTextualInput(s))return;s.matches(":focus")||s.focus(),this.hasSelectionRange(s)&&s.setSelectionRange(e,t)},isFormInput(s){return/^(?:input|select|textarea)$/i.test(s.tagName)&&s.type!=="button"},syncAttrsToProps(s){s instanceof HTMLInputElement&&st.indexOf(s.type.toLocaleLowerCase())>=0&&(s.checked=s.getAttribute("checked")!==null)},isTextualInput(s){return jt.indexOf(s.type)>=0},isNowTriggerFormExternal(s,e){return s.getAttribute&&s.getAttribute(e)!==null&&document.body.contains(s)},cleanChildNodes(s,e){if(be.isPhxUpdate(s,e,["append","prepend"])){let t=[];s.childNodes.forEach(i=>{i.id||(!(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()==="")&&i.nodeType!==Node.COMMENT_NODE&&I(`only HTML element tags with an id are allowed inside containers with phx-update.
removing illegal node: "${(i.outerHTML||i.nodeValue).trim()}"
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(s,e,t){let i=new Set(["id",M,te,Pe,W]);if(s.tagName.toLowerCase()===e.toLowerCase())return Array.from(s.attributes).filter(r=>!i.has(r.name.toLowerCase())).forEach(r=>s.removeAttribute(r.name)),Object.keys(t).filter(r=>!i.has(r.toLowerCase())).forEach(r=>s.setAttribute(r,t[r])),s;{let r=document.createElement(e);return Object.keys(t).forEach(n=>r.setAttribute(n,t[n])),i.forEach(n=>r.setAttribute(n,s.getAttribute(n))),r.innerHTML=s.innerHTML,s.replaceWith(r),r}},getSticky(s,e,t){let i=(be.private(s,"sticky")||[]).find(([r])=>e===r);if(i){let[r,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(s,e){this.updatePrivate(s,"sticky",[],t=>t.filter(([i,r])=>i!==e))},putSticky(s,e,t){let i=t(s);this.updatePrivate(s,"sticky",[],r=>{let n=r.findIndex(([o])=>e===o);return n>=0?r[n]=[e,t,i]:r.push([e,t,i]),r})},applyStickyOperations(s){let e=be.private(s,"sticky");e&&e.forEach(([t,i,r])=>this.putSticky(s,t,i))},isLocked(s){return s.hasAttribute&&s.hasAttribute(C)}},h=be;var re=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(Fe).split(",").indexOf(T.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(we).split(",").indexOf(T.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,r){this.ref=T.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(Ee,this._onElUpdated),this.autoUpload=r}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{T.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(Ee,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||T.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(Ee,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Fe).split(",").indexOf(this.ref)===-1&&(T.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||I(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:oi}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||I(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Oi=0,T=class s{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(Oi++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let r=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(r))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(we)!==i.getAttribute(Bt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(r=>{let n={path:e.name},o=e.getAttribute(B);i[o]=i[o]||[],n.ref=this.genFileRef(r),n.last_modified=r.lastModified,n.name=r.name||n.ref,n.relative_path=r.webkitRelativePath,n.type=r.type,n.size=r.size,typeof r.meta=="function"&&(n.meta=r.meta()),i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(B),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let r=t.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));h.updatePrivate(e,"files",[],n=>n.concat(r)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>re.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!re.isPreflighted(e,t)&&!re.isPreflightInProgress(t))}static markPreflightInProgress(e){e.forEach(t=>re.markPreflightInProgress(t.file))}constructor(e,t,i){this.autoUpload=h.isAutoUpload(e),this.view=t,this.onComplete=i,this._entries=Array.from(s.filesAwaitingPreflight(e)||[]).map(r=>new re(e,r,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(n=>(n.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),n));let r=this._entries.reduce((n,o)=>{if(!o.meta)return n;let{name:l,callback:a}=o.uploader(i.uploaders);return n[l]=n[l]||{callback:a,entries:[]},n[l].entries.push(o),n},{});for(let n in r){let{callback:o,entries:l}=r[n];o(l,t,e,i)}}};var Li={anyOf(s,e){return e.find(t=>s instanceof t)},isFocusable(s,e){return s instanceof HTMLAnchorElement&&s.rel!=="ignore"||s instanceof HTMLAreaElement&&s.href!==void 0||!s.disabled&&this.anyOf(s,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||s instanceof HTMLIFrameElement||s.tabIndex>0||!e&&s.getAttribute("tabindex")!==null&&s.getAttribute("aria-hidden")!=="true"},attemptFocus(s,e){if(this.isFocusable(s,e))try{s.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(s)},focusFirstInteractive(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(s){let e=s.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(s){let e=s.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},F=Li;var hi={LiveFileUpload:{activeRefs(){return this.el.getAttribute(Fe)},preflightedRefs(){return this.el.getAttribute(we)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let s=this.preflightedRefs();this.preflightedWas!==s&&(this.preflightedWas=s,s===""&&this.__view().cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(Ee))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(B)),T.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;F.attemptFocus(e)||F.focusFirst(e)}else F.focusLast(this.el)}),this.focusEnd.addEventListener("focus",s=>{if(!s.relatedTarget||!this.el.contains(s.relatedTarget)){let e=s.target.previousElementSibling;F.attemptFocus(e)||F.focusLast(e)}else F.focusFirst(this.el)}),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&F.focusFirst(this.el)}}},di=s=>["HTML","BODY"].indexOf(s.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(s).overflowY)>=0?s:di(s.parentElement),li=s=>s?s.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,It=s=>s?s.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,Ot=s=>s?s.getBoundingClientRect().top:0,Di=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Ot(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=It(e)},Hi=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.bottom)>=Ot(e)&&Math.ceil(t.left)>=0&&Math.floor(t.bottom)<=It(e)},ai=(s,e)=>{let t=s.getBoundingClientRect();return Math.ceil(t.top)>=Ot(e)&&Math.ceil(t.left)>=0&&Math.floor(t.top)<=It(e)};hi.InfiniteScroll={mounted(){this.scrollContainer=di(this.el);let s=li(this.scrollContainer),e=!1,t=500,i=null,r=this.throttle(t,(l,a)=>{i=()=>!0,this.liveSocket.execJSHookPush(this.el,l,{id:a.id,_overran:!0},()=>{i=null})}),n=this.throttle(t,(l,a)=>{i=()=>a.scrollIntoView({block:"start"}),this.liveSocket.execJSHookPush(this.el,l,{id:a.id},()=>{i=null,window.requestAnimationFrame(()=>{ai(a,this.scrollContainer)||a.scrollIntoView({block:"start"})})})}),o=this.throttle(t,(l,a)=>{i=()=>a.scrollIntoView({block:"end"}),this.liveSocket.execJSHookPush(this.el,l,{id:a.id},()=>{i=null,window.requestAnimationFrame(()=>{ai(a,this.scrollContainer)||a.scrollIntoView({block:"end"})})})});this.onScroll=l=>{let a=li(this.scrollContainer);if(i)return s=a,i();let d=this.el.getBoundingClientRect(),u=this.el.getAttribute(this.liveSocket.binding("viewport-top")),p=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),m=this.el.lastElementChild,g=this.el.firstElementChild,c=a<s,v=a>s;c&&u&&!e&&d.top>=0?(e=!0,r(u,g)):v&&e&&d.top<=0&&(e=!1),u&&c&&Di(g,this.scrollContainer)?n(u,g):p&&v&&Hi(m,this.scrollContainer)&&o(p,m),s=a},this.scrollContainer?this.scrollContainer.addEventListener("scroll",this.onScroll):window.addEventListener("scroll",this.onScroll)},destroyed(){this.scrollContainer?this.scrollContainer.removeEventListener("scroll",this.onScroll):window.removeEventListener("scroll",this.onScroll)},throttle(s,e){let t=0,i;return(...r)=>{let n=Date.now(),o=s-(n-t);o<=0||o>s?(i&&(clearTimeout(i),i=null),t=n,e(...r)):i||(i=setTimeout(()=>{t=Date.now(),i=null,e(...r)},o))}}};var ui=hi;var De=class{static onUnlock(e,t){if(!h.isLocked(e)&&!e.closest(`[${C}]`))return t();let i=e.closest(`[${C}]`),r=i.closest(`[${C}]`).getAttribute(C);i.addEventListener(`phx:undo-lock:${r}`,()=>{t()},{once:!0})}constructor(e){this.el=e,this.loadingRef=e.hasAttribute(ae)?parseInt(e.getAttribute(ae),10):null,this.lockRef=e.hasAttribute(C)?parseInt(e.getAttribute(C),10):null}maybeUndo(e,t,i){this.isWithin(e)&&(this.undoLocks(e,t,i),this.undoLoading(e,t),this.isFullyResolvedBy(e)&&this.el.removeAttribute(O))}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 r=h.private(this.el,C);r&&(i(r),h.deletePrivate(this.el,C)),this.el.removeAttribute(C);let n={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,n))}undoLoading(e,t){if(!this.isLoadingUndoneBy(e)){this.canUndoLoading(e)&&this.el.classList.contains("phx-submit-loading")&&this.el.classList.remove("phx-change-loading");return}if(this.canUndoLoading(e)){this.el.removeAttribute(ae);let i=this.el.getAttribute(de),r=this.el.getAttribute(Xe);r!==null&&(this.el.readOnly=r==="true",this.el.removeAttribute(Xe)),i!==null&&(this.el.disabled=i==="true",this.el.removeAttribute(de));let n=this.el.getAttribute(ke);n!==null&&(this.el.innerText=n,this.el.removeAttribute(ke));let o={detail:{ref:e,event:t},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,o))}Qe.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(e))&&h.removeClass(this.el,i)})}isLoadingUndoneBy(e){return this.loadingRef===null?!1:this.loadingRef<=e}isLockUndoneBy(e){return this.lockRef===null?!1:this.lockRef<=e}isFullyResolvedBy(e){return(this.loadingRef===null||this.loadingRef<=e)&&(this.lockRef===null||this.lockRef<=e)}canUndoLoading(e){return this.lockRef===null||this.lockRef<=e}};var Je=class{constructor(e,t,i){let r=new Set,n=new Set([...t.children].map(l=>l.id)),o=[];Array.from(e.children).forEach(l=>{if(l.id&&(r.add(l.id),n.has(l.id))){let a=l.previousElementSibling&&l.previousElementSibling.id;o.push({elementId:l.id,previousElementId:a})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(l=>!r.has(l))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?Y(document.getElementById(t.previousElementId),i=>{Y(document.getElementById(t.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",r)})}):Y(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{Y(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var ci=11;function Ni(s,e){var t=e.attributes,i,r,n,o,l;if(!(e.nodeType===ci||s.nodeType===ci)){for(var a=t.length-1;a>=0;a--)i=t[a],r=i.name,n=i.namespaceURI,o=i.value,n?(r=i.localName||r,l=s.getAttributeNS(n,r),l!==o&&(i.prefix==="xmlns"&&(r=i.name),s.setAttributeNS(n,r,o))):(l=s.getAttribute(r),l!==o&&s.setAttribute(r,o));for(var d=s.attributes,u=d.length-1;u>=0;u--)i=d[u],r=i.name,n=i.namespaceURI,n?(r=i.localName||r,e.hasAttributeNS(n,r)||s.removeAttributeNS(n,r)):e.hasAttribute(r)||s.removeAttribute(r)}}var at,Fi="http://www.w3.org/1999/xhtml",U=typeof document=="undefined"?void 0:document,Mi=!!U&&"content"in U.createElement("template"),Ui=!!U&&U.createRange&&"createContextualFragment"in U.createRange();function Xi(s){var e=U.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function $i(s){at||(at=U.createRange(),at.selectNode(U.body));var e=at.createContextualFragment(s);return e.childNodes[0]}function Bi(s){var e=U.createElement("body");return e.innerHTML=s,e.childNodes[0]}function Vi(s){return s=s.trim(),Mi?Xi(s):Ui?$i(s):Bi(s)}function ht(s,e){var t=s.nodeName,i=e.nodeName,r,n;return t===i?!0:(r=t.charCodeAt(0),n=i.charCodeAt(0),r<=90&&n>=97?t===i.toUpperCase():n<=90&&r>=97?i===t.toUpperCase():!1)}function ji(s,e){return!e||e===Fi?U.createElement(s):U.createElementNS(e,s)}function Ji(s,e){for(var t=s.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function Lt(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var fi={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)}Lt(s,e,"selected")},INPUT:function(s,e){Lt(s,e,"checked"),Lt(s,e,"disabled"),s.value!==e.value&&(s.value=e.value),e.hasAttribute("value")||s.removeAttribute("value")},TEXTAREA:function(s,e){var t=e.value;s.value!==t&&(s.value=t);var i=s.firstChild;if(i){var r=i.nodeValue;if(r==t||!t&&r==s.placeholder)return;i.nodeValue=t}},SELECT:function(s,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,r=s.firstChild,n,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")n=r,r=n.firstChild;else{if(o==="OPTION"){if(r.hasAttribute("selected")){t=i;break}i++}r=r.nextSibling,!r&&n&&(r=n.nextSibling,n=null)}s.selectedIndex=t}}},We=1,pi=11,mi=3,gi=8;function ue(){}function Wi(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function qi(s){return function(t,i,r){if(r||(r={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=U.createElement("html"),i.innerHTML=n}else i=Vi(i);else i.nodeType===pi&&(i=i.firstElementChild);var o=r.getNodeKey||Wi,l=r.onBeforeNodeAdded||ue,a=r.onNodeAdded||ue,d=r.onBeforeElUpdated||ue,u=r.onElUpdated||ue,p=r.onBeforeNodeDiscarded||ue,m=r.onNodeDiscarded||ue,g=r.onBeforeElChildrenUpdated||ue,c=r.skipFromChildren||ue,v=r.addChild||function(S,_){return S.appendChild(_)},A=r.childrenOnly===!0,x=Object.create(null),Z=[];function P(S){Z.push(S)}function V(S,_){if(S.nodeType===We)for(var R=S.firstChild;R;){var w=void 0;_&&(w=o(R))?P(w):(m(R),R.firstChild&&V(R,_)),R=R.nextSibling}}function j(S,_,R){p(S)!==!1&&(_&&_.removeChild(S),m(S),V(S,R))}function H(S){if(S.nodeType===We||S.nodeType===pi)for(var _=S.firstChild;_;){var R=o(_);R&&(x[R]=_),H(_),_=_.nextSibling}}H(t);function f(S){a(S);for(var _=S.firstChild;_;){var R=_.nextSibling,w=o(_);if(w){var k=x[w];k&&ht(_,k)?(_.parentNode.replaceChild(k,_),X(k,_)):f(_)}else f(_);_=R}}function b(S,_,R){for(;_;){var w=_.nextSibling;(R=o(_))?P(R):j(_,S,!0),_=w}}function X(S,_,R){var w=o(_);if(w&&delete x[w],!R){var k=d(S,_);if(k===!1||(k instanceof HTMLElement&&(S=k,H(S)),s(S,_),u(S),g(S,_)===!1))return}S.nodeName!=="TEXTAREA"?ie(S,_):fi.TEXTAREA(S,_)}function ie(S,_){var R=c(S,_),w=_.firstChild,k=S.firstChild,Se,se,_e,Ke,oe;e:for(;w;){for(Ke=w.nextSibling,Se=o(w);!R&&k;){if(_e=k.nextSibling,w.isSameNode&&w.isSameNode(k)){w=Ke,k=_e;continue e}se=o(k);var Ge=k.nodeType,le=void 0;if(Ge===w.nodeType&&(Ge===We?(Se?Se!==se&&((oe=x[Se])?_e===oe?le=!1:(S.insertBefore(oe,k),se?P(se):j(k,S,!0),k=oe,se=o(k)):le=!1):se&&(le=!1),le=le!==!1&&ht(k,w),le&&X(k,w)):(Ge===mi||Ge==gi)&&(le=!0,k.nodeValue!==w.nodeValue&&(k.nodeValue=w.nodeValue))),le){w=Ke,k=_e;continue e}se?P(se):j(k,S,!0),k=_e}if(Se&&(oe=x[Se])&&ht(oe,w))R||v(S,oe),X(oe,w);else{var ft=l(w);ft!==!1&&(ft&&(w=ft),w.actualize&&(w=w.actualize(S.ownerDocument||U)),v(S,w),f(w))}w=Ke,k=_e}b(S,k,se);var Nt=fi[S.nodeName];Nt&&Nt(S,_)}var E=t,J=E.nodeType,ne=i.nodeType;if(!A){if(J===We)ne===We?ht(t,i)||(m(t),E=Ji(t,ji(i.nodeName,i.namespaceURI))):E=i;else if(J===mi||J===gi){if(ne===J)return E.nodeValue!==i.nodeValue&&(E.nodeValue=i.nodeValue),E;E=i}}if(E===i)m(t);else{if(i.isSameNode&&i.isSameNode(E))return;if(X(E,i,A),Z)for(var ut=0,wi=Z.length;ut<wi;ut++){var ct=x[Z[ut]];ct&&j(ct,ct.parentNode,!1)}}return!A&&E!==t&&t.parentNode&&(E.actualize&&(E=E.actualize(t.ownerDocument||U)),t.parentNode.replaceChild(E,t)),E}}var Ki=qi(Ni),vi=Ki;var ce=class{constructor(e,t,i,r,n,o,l={}){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=r,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=o,this.cidPatch=q(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=this.isCIDPatch()?this.targetCIDContainer(r):t,this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]},this.withChildren=l.withChildren||l.undoRef||!1,this.undoRef=l.undoRef}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(Te);h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(mt,"")})}perform(e){let{view:t,liveSocket:i,html:r,container:n,targetContainer:o}=this;if(this.isCIDPatch()&&!o)return;let l=i.getActiveElement(),{selectionStart:a,selectionEnd:d}=l&&h.hasSelectionRange(l)?l:{},u=i.binding(Te),p=i.binding(Me),m=i.binding(Ue),g=i.binding(Vt),c=[],v=[],A=[],x=null;function Z(P,V,j=this.withChildren){let H={childrenOnly:P.getAttribute($)===null&&!j,getNodeKey:f=>h.isPhxDestroyed(f)?null:e?f.id:f.id||f.getAttribute&&f.getAttribute(it),skipFromChildren:f=>f.getAttribute(u)===rt,addChild:(f,b)=>{let{ref:X,streamAt:ie}=this.getStreamInsert(b);if(X===void 0)return f.appendChild(b);if(this.setStreamRef(b,X),ie===0)f.insertAdjacentElement("afterbegin",b);else if(ie===-1){let E=f.lastElementChild;if(E&&!E.hasAttribute(Re)){let J=Array.from(f.children).find(ne=>!ne.hasAttribute(Re));f.insertBefore(b,J)}else f.appendChild(b)}else if(ie>0){let E=Array.from(f.children)[ie];f.insertBefore(b,E)}},onBeforeNodeAdded:f=>{h.maintainPrivateHooks(f,f,p,m),this.trackBefore("added",f);let b=f;return this.streamComponentRestore[f.id]&&(b=this.streamComponentRestore[f.id],delete this.streamComponentRestore[f.id],Z.call(this,b,f,!0)),b},onNodeAdded:f=>{f.getAttribute&&this.maybeReOrderStream(f,!0),f instanceof HTMLImageElement&&f.srcset?f.srcset=f.srcset:f instanceof HTMLVideoElement&&f.autoplay&&f.play(),h.isNowTriggerFormExternal(f,g)&&(x=f),(h.isPhxChild(f)&&t.ownsElement(f)||h.isPhxSticky(f)&&t.ownsElement(f.parentNode))&&this.trackAfter("phxChildAdded",f),c.push(f)},onNodeDiscarded:f=>this.onNodeDiscarded(f),onBeforeNodeDiscarded:f=>f.getAttribute&&f.getAttribute(mt)!==null?!0:!(f.parentElement!==null&&f.id&&h.isPhxUpdate(f.parentElement,u,[rt,"append","prepend"])||this.maybePendingRemove(f)||this.skipCIDSibling(f)),onElUpdated:f=>{h.isNowTriggerFormExternal(f,g)&&(x=f),v.push(f),this.maybeReOrderStream(f,!1)},onBeforeElUpdated:(f,b)=>{if(f.id&&f.isSameNode(P)&&f.id!==b.id)return H.onNodeDiscarded(f),f.replaceWith(b),H.onNodeAdded(b);if(h.syncPendingAttrs(f,b),h.maintainPrivateHooks(f,b,p,m),h.cleanChildNodes(b,u),this.skipCIDSibling(b))return this.maybeReOrderStream(f),!1;if(h.isPhxSticky(f))return[M,te,W].map(E=>[E,f.getAttribute(E),b.getAttribute(E)]).forEach(([E,J,ne])=>{ne&&J!==ne&&f.setAttribute(E,ne)}),!1;if(h.isIgnored(f,u)||f.form&&f.form.isSameNode(x))return this.trackBefore("updated",f,b),h.mergeAttrs(f,b,{isIgnored:h.isIgnored(f,u)}),v.push(f),h.applyStickyOperations(f),!1;if(f.type==="number"&&f.validity&&f.validity.badInput)return!1;let X=l&&f.isSameNode(l)&&h.isFormInput(f),ie=X&&this.isChangedSelect(f,b);if(f.hasAttribute(O)&&f.getAttribute(C)!=this.undoRef){h.isUploadInput(f)&&(h.mergeAttrs(f,b,{isIgnored:!0}),this.trackBefore("updated",f,b),v.push(f)),h.applyStickyOperations(f);let J=f.hasAttribute(C)?h.private(f,C)||f.cloneNode(!0):null;J&&(h.putPrivate(f,C,J),X||(f=J))}if(h.isPhxChild(b)){let E=f.getAttribute(M);return h.mergeAttrs(f,b,{exclude:[te]}),E!==""&&f.setAttribute(M,E),f.setAttribute(W,this.rootID),h.applyStickyOperations(f),!1}return this.undoRef&&h.private(b,C)&&h.putPrivate(f,C,h.private(b,C)),h.copyPrivates(b,f),X&&f.type!=="hidden"&&!ie?(this.trackBefore("updated",f,b),h.mergeFocusedInput(f,b),h.syncAttrsToProps(f),v.push(f),h.applyStickyOperations(f),!1):(ie&&f.blur(),h.isPhxUpdate(b,u,["append","prepend"])&&A.push(new Je(f,b,b.getAttribute(u))),h.syncAttrsToProps(b),h.applyStickyOperations(b),this.trackBefore("updated",f,b),f)}};vi(P,V,H)}return this.trackBefore("added",n),this.trackBefore("updated",n,n),i.time("morphdom",()=>{this.streams.forEach(([P,V,j,H])=>{V.forEach(([f,b,X])=>{this.streamInserts[f]={ref:P,streamAt:b,limit:X,reset:H}}),H!==void 0&&h.all(n,`[${Re}="${P}"]`,f=>{this.removeStreamChildElement(f)}),j.forEach(f=>{let b=n.querySelector(`[id="${f}"]`);b&&this.removeStreamChildElement(b)})}),e&&h.all(this.container,`[${u}=${rt}]`).filter(P=>this.view.ownsElement(P)).forEach(P=>{Array.from(P.children).forEach(V=>{this.removeStreamChildElement(V,!0)})}),Z.call(this,o,r)}),i.isDebugEnabled()&&(ii(),si(this.streamInserts),Array.from(document.querySelectorAll("input[name=id]")).forEach(P=>{P.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
`,P)})),A.length>0&&i.time("post-morph append/prepend restoration",()=>{A.forEach(P=>P.perform())}),i.silenceEvents(()=>h.restoreFocus(l,a,d)),h.dispatchEvent(document,"phx:update"),c.forEach(P=>this.trackAfter("added",P)),v.forEach(P=>this.trackAfter("updated",P)),this.transitionPendingRemoves(),x&&(i.unload(),Object.getPrototypeOf(x).submit.call(x)),!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}removeStreamChildElement(e,t=!1){!t&&!this.view.ownsElement(e)||(this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e)))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,t){h.putSticky(e,Re,i=>i.setAttribute(Re,t))}maybeReOrderStream(e,t){let{ref:i,streamAt:r,reset:n}=this.getStreamInsert(e);if(r!==void 0&&(this.setStreamRef(e,i),!(!n&&!t)&&e.parentElement)){if(r===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(r>0){let o=Array.from(e.parentElement.children),l=o.indexOf(e);if(r>=o.length-1)e.parentElement.appendChild(e);else{let a=o[r];l>r?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:t}=this.getStreamInsert(e),i=t!==null&&Array.from(e.parentElement.children);t&&t<0&&i.length>t*-1?i.slice(0,i.length+t).forEach(r=>this.removeStreamChildElement(r)):t&&t>=0&&i.length>t&&i.slice(t).forEach(r=>this.removeStreamChildElement(r))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&t.transitionRemoves(e,()=>{e.forEach(i=>{let r=h.firstPhxChild(i);r&&t.destroyViewByEl(r),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(tt)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}indexOf(e,t){return Array.from(e.children).indexOf(t)}};var Gi=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),zi=new Set(["'",'"']),bi=(s,e,t)=>{let i=0,r=!1,n,o,l,a,d,u,p=s.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${s}`);for(i=p[0].length,n=p[1],l=p[2],a=i,i;i<s.length&&s.charAt(i)!==">";i++)if(s.charAt(i)==="="){let c=s.slice(i-3,i)===" id";i++;let v=s.charAt(i);if(zi.has(v)){let A=i;for(i++,i;i<s.length&&s.charAt(i)!==v;i++);if(c){d=s.slice(A+1,i);break}}}let m=s.length-1;for(r=!1;m>=n.length+l.length;){let c=s.charAt(m);if(r)c==="-"&&s.slice(m-3,m)==="<!-"?(r=!1,m-=4):m-=1;else if(c===">"&&s.slice(m-2,m)==="--")r=!0,m-=3;else{if(c===">")break;m-=1}}o=s.slice(m+1,s.length);let g=Object.keys(e).map(c=>e[c]===!0?c:`${c}="${e[c]}"`).join(" ");if(t){let c=d?` id="${d}"`:"";Gi.has(l)?u=`<${l}${c}${g===""?"":" "}${g}/>`:u=`<${l}${c}${g===""?"":" "}${g}></${l}>`}else{let c=s.slice(a,m+1);u=`<${l}${g===""?"":" "}${g}${c}`}return[u,n,o]},He=class{static extract(e){let{[Ct]:t,[kt]:i,[Tt]:r}=e;return delete e[Ct],delete e[kt],delete e[Tt],{diff:e,title:r,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[L],e,!0,{});return[t,i]}recursiveToString(e,t=e[L],i,r,n){i=i?new Set(i):null;let o={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,o,r,n),[o.buffer,o.streams]}componentCIDs(e){return Object.keys(e[L]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[L]?Object.keys(e).length===1:!1}getComponent(e,t){return e[L][t]}resetRender(e){this.rendered[L][e]&&(this.rendered[L][e].reset=!0)}mergeDiff(e){let t=e[L],i={};if(delete e[L],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[L]=this.rendered[L]||{},t){let r=this.rendered[L];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],r,t,i);for(let n in t)r[n]=t[n];e[L]=t}}cachedFindComponent(e,t,i,r,n){if(n[e])return n[e];{let o,l,a=t[z];if(q(a)){let d;a>0?d=this.cachedFindComponent(a,r[a],i,r,n):d=i[-a],l=d[z],o=this.cloneMerge(d,t,!0),o[z]=l}else o=t[z]!==void 0||i[e]===void 0?t:this.cloneMerge(i[e],t,!1);return n[e]=o,o}}mutableMerge(e,t){return t[z]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let r=t[i],n=e[i];ve(r)&&r[z]===void 0&&ve(n)?this.doMutableMerge(n,r):e[i]=r}e[lt]&&(e.newRender=!0)}cloneMerge(e,t,i){let r=N(N({},e),t);for(let n in r){let o=t[n],l=e[n];ve(o)&&o[z]===void 0&&ve(l)?r[n]=this.cloneMerge(l,o,i):o===void 0&&ve(l)&&(r[n]=this.cloneMerge(l,{},i))}return i?(delete r.magicId,delete r.newRender):e[lt]&&(r.newRender=!0),r}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[L],e,null),[r,n,o]=bi(t,{});return[r,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[L][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,r,n={}){if(e[Ve])return this.comprehensionToBuffer(e,t,i);let{[z]:o}=e;o=this.templateStatic(o,t);let l=e[lt],a=i.buffer;l&&(i.buffer=""),r&&l&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),i.buffer+=o[0];for(let d=1;d<o.length;d++)this.dynamicToBuffer(e[d-1],t,i,r),i.buffer+=o[d];if(l){let d=!1,u;r||e.magicId?(d=r&&!e.newRender,u=N({[it]:e.magicId},n)):u=n,d&&(u[tt]=!0);let[p,m,g]=bi(i.buffer,u,d);e.newRender=!1,i.buffer=a+m+p+g}}comprehensionToBuffer(e,t,i){let{[Ve]:r,[z]:n,[Rt]:o}=e,[l,a,d,u]=o||[null,{},[],null];n=this.templateStatic(n,t);let p=t||e[ti];for(let m=0;m<r.length;m++){let g=r[m];i.buffer+=n[0];for(let c=1;c<n.length;c++)this.dynamicToBuffer(g[c-1],p,i,!1),i.buffer+=n[c]}o!==void 0&&(e[Ve].length>0||d.length>0||u)&&(delete e[Rt],e[Ve]=[],i.streams.add(o))}dynamicToBuffer(e,t,i,r){if(typeof e=="number"){let[n,o]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=n,i.streams=new Set([...i.streams,...o])}else ve(e)?this.toOutputBuffer(e,t,i,r,{}):i.buffer+=e}recursiveCIDToString(e,t,i){let r=e[t]||I(`no component for CID ${t}`,e),n={[$]:t},o=i&&!i.has(t);r.newRender=!o,r.magicId=`c${t}-${this.parentViewId()}`;let l=!r.reset,[a,d]=this.recursiveToString(r,e,i,l,n);return delete r.reset,[a,d]}};var Ai=[],Si=200,Yi={exec(s,e,t,i,r,n){let[o,l]=n||[null,{callback:n&&n.callback}];(t.charAt(0)==="["?JSON.parse(t):[[o,l]]).forEach(([d,u])=>{d===o&&(u=N(N({},l),u),u.callback=u.callback||l.callback),this.filterToEls(i.liveSocket,r,u).forEach(p=>{this[`exec_${d}`](s,e,t,i,r,p,u)})})},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,r,n,{attr:o,to:l}){let a=n.getAttribute(o);if(!a)throw new Error(`expected ${o} to contain JS command on "${l}"`);i.liveSocket.execJS(n,a,e)},exec_dispatch(s,e,t,i,r,n,{event:o,detail:l,bubbles:a}){l=l||{},l.dispatcher=r,h.dispatchEvent(n,o,{detail:l,bubbles:a})},exec_push(s,e,t,i,r,n,o){let{event:l,data:a,target:d,page_loading:u,loading:p,value:m,dispatcher:g,callback:c}=o,v={loading:p,value:m,target:d,page_loading:!!u},A=e==="change"&&g?g:r,x=d||A.getAttribute(i.binding("target"))||A,Z=(P,V)=>{if(P.isConnected())if(e==="change"){let{newCid:j,_target:H}=o;H=H||(h.isFormInput(r)?r.name:void 0),H&&(v._target=H),P.pushInput(r,V,j,l||t,v,c)}else if(e==="submit"){let{submitter:j}=o;P.submitForm(r,V,l||t,j,v,c)}else P.pushEvent(e,r,V,l||t,a,v,c)};o.targetView&&o.targetCtx?Z(o.targetView,o.targetCtx):i.withinTargets(x,Z)},exec_navigate(s,e,t,i,r,n,{href:o,replace:l}){i.liveSocket.historyRedirect(s,o,l?"replace":"push",null,r)},exec_patch(s,e,t,i,r,n,{href:o,replace:l}){i.liveSocket.pushHistoryPatch(s,o,l?"replace":"push",r)},exec_focus(s,e,t,i,r,n){F.attemptFocus(n),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>F.attemptFocus(n))})},exec_focus_first(s,e,t,i,r,n){F.focusFirstInteractive(n)||F.focusFirst(n),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>F.focusFirstInteractive(n)||F.focusFirst(n))})},exec_push_focus(s,e,t,i,r,n){Ai.push(n||r)},exec_pop_focus(s,e,t,i,r,n){let o=Ai.pop();o&&(o.focus(),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o.focus())}))},exec_add_class(s,e,t,i,r,n,{names:o,transition:l,time:a,blocking:d}){this.addOrRemoveClasses(n,o,[],l,a,i,d)},exec_remove_class(s,e,t,i,r,n,{names:o,transition:l,time:a,blocking:d}){this.addOrRemoveClasses(n,[],o,l,a,i,d)},exec_toggle_class(s,e,t,i,r,n,{names:o,transition:l,time:a,blocking:d}){this.toggleClasses(n,o,l,a,i,d)},exec_toggle_attr(s,e,t,i,r,n,{attr:[o,l,a]}){this.toggleAttr(n,o,l,a)},exec_transition(s,e,t,i,r,n,{time:o,transition:l,blocking:a}){this.addOrRemoveClasses(n,[],[],l,o,i,a)},exec_toggle(s,e,t,i,r,n,{display:o,ins:l,outs:a,time:d,blocking:u}){this.toggle(e,i,n,o,l,a,d,u)},exec_show(s,e,t,i,r,n,{display:o,transition:l,time:a,blocking:d}){this.show(e,i,n,o,l,a,d)},exec_hide(s,e,t,i,r,n,{display:o,transition:l,time:a,blocking:d}){this.hide(e,i,n,o,l,a,d)},exec_set_attr(s,e,t,i,r,n,{attr:[o,l]}){this.setOrRemoveAttrs(n,[[o,l]],[])},exec_remove_attr(s,e,t,i,r,n,{attr:o}){this.setOrRemoveAttrs(n,[],[o])},show(s,e,t,i,r,n,o){this.isVisible(t)||this.toggle(s,e,t,i,r,null,n,o)},hide(s,e,t,i,r,n,o){this.isVisible(t)&&this.toggle(s,e,t,i,null,r,n,o)},toggle(s,e,t,i,r,n,o,l){o=o||Si;let[a,d,u]=r||[[],[],[]],[p,m,g]=n||[[],[],[]];if(a.length>0||p.length>0)if(this.isVisible(t)){let c=()=>{this.addOrRemoveClasses(t,m,a.concat(d).concat(u)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,g,m))})},v=()=>{this.addOrRemoveClasses(t,[],p.concat(g)),h.putSticky(t,"toggle",A=>A.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))};t.dispatchEvent(new Event("phx:hide-start")),l===!1?(c(),setTimeout(v,o)):e.transition(o,c,v)}else{if(s==="remove")return;let c=()=>{this.addOrRemoveClasses(t,d,p.concat(m).concat(g));let A=i||this.defaultDisplay(t);window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>{h.putSticky(t,"toggle",x=>x.style.display=A),this.addOrRemoveClasses(t,u,d)})})},v=()=>{this.addOrRemoveClasses(t,[],a.concat(u)),t.dispatchEvent(new Event("phx:show-end"))};t.dispatchEvent(new Event("phx:show-start")),l===!1?(c(),setTimeout(v,o)):e.transition(o,c,v)}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",c=>c.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let c=i||this.defaultDisplay(t);h.putSticky(t,"toggle",v=>v.style.display=c),t.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(s,e,t,i,r,n){window.requestAnimationFrame(()=>{let[o,l]=h.getSticky(s,"classes",[[],[]]),a=e.filter(u=>o.indexOf(u)<0&&!s.classList.contains(u)),d=e.filter(u=>l.indexOf(u)<0&&s.classList.contains(u));this.addOrRemoveClasses(s,a,d,t,i,r,n)})},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,r,n,o){r=r||Si;let[l,a,d]=i||[[],[],[]];if(l.length>0){let u=()=>{this.addOrRemoveClasses(s,a,[].concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(s,l,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(s,d,a))})},p=()=>this.addOrRemoveClasses(s,e.concat(d),t.concat(l).concat(a));o===!1?(u(),setTimeout(p,r)):n.transition(r,u,p);return}window.requestAnimationFrame(()=>{let[u,p]=h.getSticky(s,"classes",[[],[]]),m=e.filter(A=>u.indexOf(A)<0&&!s.classList.contains(A)),g=t.filter(A=>p.indexOf(A)<0&&s.classList.contains(A)),c=u.filter(A=>t.indexOf(A)<0).concat(m),v=p.filter(A=>e.indexOf(A)<0).concat(g);h.putSticky(s,"classes",A=>(A.classList.remove(...v),A.classList.add(...c),[c,v]))})},setOrRemoveAttrs(s,e,t){let[i,r]=h.getSticky(s,"attrs",[[],[]]),n=e.map(([a,d])=>a).concat(t),o=i.filter(([a,d])=>!n.includes(a)).concat(e),l=r.filter(a=>!n.includes(a)).concat(t);h.putSticky(s,"attrs",a=>(l.forEach(d=>a.removeAttribute(d)),o.forEach(([d,u])=>a.setAttribute(d,u)),[o,l]))},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 r=e.closest(t.closest);return r?[r]:[]}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]}},y=Yi;var Dt="hookId",Qi=1,Q=class{static makeID(){return Qi++}static elementID(e){return h.private(e,Dt)}constructor(e,t,i){this.el=t,this.__attachView(e),this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,h.putPrivate(this.el,Dt,this.constructor.makeID());for(let r in this.__callbacks)this[r]=this.__callbacks[r]}__attachView(e){e?(this.__view=()=>e,this.liveSocket=e.liveSocket):(this.__view=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)},this.liveSocket=null)}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed(),h.deletePrivate(this.el,Dt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}js(){let e=this;return{exec(t){e.__view().liveSocket.execJS(e.el,t,"hook")},show(t,i={}){let r=e.__view().liveSocket.owner(t);y.show("hook",r,t,i.display,i.transition,i.time,i.blocking)},hide(t,i={}){let r=e.__view().liveSocket.owner(t);y.hide("hook",r,t,null,i.transition,i.time,i.blocking)},toggle(t,i={}){let r=e.__view().liveSocket.owner(t);i.in=y.transitionClasses(i.in),i.out=y.transitionClasses(i.out),y.toggle("hook",r,t,i.display,i.in,i.out,i.time,i.blocking)},addClass(t,i,r={}){i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,i,[],r.transition,r.time,n,r.blocking)},removeClass(t,i,r={}){r.transition=y.transitionClasses(r.transition),i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,[],i,r.transition,r.time,n,r.blocking)},toggleClass(t,i,r={}){r.transition=y.transitionClasses(r.transition),i=Array.isArray(i)?i:i.split(" ");let n=e.__view().liveSocket.owner(t);y.toggleClasses(t,i,r.transition,r.time,n,r.blocking)},transition(t,i,r={}){let n=e.__view().liveSocket.owner(t);y.addOrRemoveClasses(t,[],[],y.transitionClasses(i),r.time,n,r.blocking)},setAttribute(t,i,r){y.setOrRemoveAttrs(t,[[i,r]],[])},removeAttribute(t,i){y.setOrRemoveAttrs(t,[],[i])},toggleAttribute(t,i,r,n){y.toggleAttr(t,i,r,n)}}}pushEvent(e,t={},i){return i===void 0?new Promise((r,n)=>{try{this.__view().pushHookEvent(this.el,null,e,t,(l,a)=>r(l))===!1&&n(new Error("unable to push hook event. LiveView not connected"))}catch(o){n(o)}}):this.__view().pushHookEvent(this.el,null,e,t,i)}pushEventTo(e,t,i={},r){return r===void 0?new Promise((n,o)=>{try{this.__view().withinTargets(e,(l,a)=>{l.pushHookEvent(this.el,a,t,i,(u,p)=>n(u))===!1&&o(new Error("unable to push hook event. LiveView not connected"))})}catch(l){o(l)}}):this.__view().withinTargets(e,(n,o)=>n.pushHookEvent(this.el,o,t,i,r))}handleEvent(e,t){let i=(r,n)=>n?e:t(r.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view().dispatchUploads(null,e,t)}uploadTo(e,t,i){return this.__view().withinTargets(e,(r,n)=>{r.dispatchUploads(n,t,i)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var Zi=(s,e)=>{let t=s.endsWith("[]"),i=t?s.slice(0,-2):s;return i=i.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),t&&(i+="[]"),i},dt=(s,e,t=[])=>{let{submitter:i}=e,r;if(i&&i.name){let u=document.createElement("input");u.type="hidden";let p=i.getAttribute("form");p&&u.setAttribute("form",p),u.name=i.name,u.value=i.value,i.parentElement.insertBefore(u,i),r=u}let n=new FormData(s),o=[];n.forEach((u,p,m)=>{u instanceof File&&o.push(p)}),o.forEach(u=>n.delete(u));let l=new URLSearchParams,{inputsUnused:a,onlyHiddenInputs:d}=Array.from(s.elements).reduce((u,p)=>{let{inputsUnused:m,onlyHiddenInputs:g}=u,c=p.name;if(!c)return u;m[c]===void 0&&(m[c]=!0),g[c]===void 0&&(g[c]=!0);let v=h.private(p,pe)||h.private(p,me),A=p.type==="hidden";return m[c]=m[c]&&!v,g[c]=g[c]&&A,u},{inputsUnused:{},onlyHiddenInputs:{}});for(let[u,p]of n.entries())if(t.length===0||t.indexOf(u)>=0){let m=a[u],g=d[u];m&&!(i&&i.name==u)&&!g&&l.append(Zi(u,"_unused_"),""),l.append(u,p)}return i&&r&&i.parentElement.removeChild(r),l.toString()},Ae=class s{static closestView(e){let t=e.closest(K);return t?h.private(t,"view"):null}constructor(e,t,i,r,n){this.isDead=!1,this.liveSocket=t,this.flash=r,this.parent=i,this.root=i?i.root:this,this.el=e,h.putPrivate(this.el,"view",this),this.id=this.el.id,this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.disconnectedTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let o=this.href&&this.expandURL(this.href);return{redirect:this.redirect?o:void 0,url:this.redirect?void 0:o||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}})}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(Pe)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(Xt)}]`).map(r=>r.src||r.href).filter(r=>typeof r=="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(M)}getStatic(){let e=this.el.getAttribute(te);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(gt,he,fe,vt,ye),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(he)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),clearTimeout(this.disconnectedTimer),this.setContainerClasses(gt),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,r){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,n=>t(n,e));if(q(e))h.findComponentNodeList(r||this.el,e).length===0?I(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let n=Array.from(i.querySelectorAll(e));n.length===0&&I(`nothing found matching the phx-target selector "${e}"`),n.forEach(o=>this.liveSocket.owner(o,l=>t(l,o)))}}applyDiff(e,t,i){this.log(e,()=>["",Le(t)]);let{diff:r,reply:n,events:o,title:l}=He.extract(t);i({diff:r,reply:n,events:o}),(typeof l=="string"||e=="mount")&&window.requestAnimationFrame(()=>h.putTitle(l))}onJoin(e){let{rendered:t,container:i,liveview_version:r}=e;if(i){let[n,o]=i;this.el=h.replaceRootContainer(this.el,n,o)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&D.pushState("replace",{type:"patch",id:this.id,position:this.liveSocket.currentHistoryPosition}),r!==this.liveSocket.version()&&console.error(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${r}. To avoid issues, please ensure that your assets use the same version as the server.`),D.dropLocal(this.liveSocket.localStorage,window.location.pathname,Ye),this.applyDiff("mount",t,({diff:n,events:o})=>{this.rendered=new He(this.id,n);let[l,a]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(l,()=>{this.onJoinComplete(e,l,a,o)})})}dropPendingRefs(){h.all(document,`[${O}="${this.refSrc()}"]`,e=>{e.removeAttribute(ae),e.removeAttribute(O),e.removeAttribute(C)})}onJoinComplete({live_patch:e},t,i,r){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,r);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let l=o.id&&this.el.querySelector(`[id="${o.id}"]`),a=l&&l.getAttribute(te);return a&&o.setAttribute(te,a),l&&l.setAttribute(W,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,r)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,r)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,r)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(W,this.root.id)}execNewMounted(e=this.el){let t=this.binding(Me),i=this.binding(Ue);h.all(e,`[${t}], [${i}]`,r=>{this.ownsElement(r)&&(h.maintainPrivateHooks(r,r,t,i),this.maybeAddNewHook(r))}),h.all(e,`[${this.binding(Ce)}], [data-phx-${Ce}]`,r=>{this.ownsElement(r)&&this.maybeAddNewHook(r)}),h.all(e,`[${this.binding(_t)}]`,r=>{this.ownsElement(r)&&this.maybeMounted(r)})}applyJoinPatch(e,t,i,r){this.attachTrueDocEl();let n=new ce(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(r),this.applyPendingUpdates(),e){let{kind:o,to:l}=e;this.liveSocket.historyPatch(l,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),r=i&&h.isIgnored(e,this.binding(Te));if(i&&!e.isEqualNode(t)&&!(r&&ni(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(_t)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){let t=this.addHook(e);t&&t.__mounted()}performPatch(e,t,i=!1){let r=[],n=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.after("added",l=>{this.liveSocket.triggerDOM("onNodeAdded",[l]);let a=this.binding(Me),d=this.binding(Ue);h.maintainPrivateHooks(l,l,a,d),this.maybeAddNewHook(l),l.getAttribute&&this.maybeMounted(l)}),e.after("phxChildAdded",l=>{h.isPhxSticky(l)?this.liveSocket.joinRootViews():n=!0}),e.before("updated",(l,a)=>{this.triggerBeforeUpdateHook(l,a)&&o.add(l.id)}),e.after("updated",l=>{o.has(l.id)&&this.getHook(l).__updated()}),e.after("discarded",l=>{l.nodeType===Node.ELEMENT_NODE&&r.push(l)}),e.after("transitionsDiscarded",l=>this.afterElementsRemoved(l,t)),e.perform(i),this.afterElementsRemoved(r,t),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),n}afterElementsRemoved(e,t){let i=[];e.forEach(r=>{let n=h.all(r,`[${$}]`),o=h.all(r,`[${this.binding(Ce)}], [data-phx-hook]`);n.concat(r).forEach(l=>{let a=this.componentID(l);q(a)&&i.indexOf(a)===-1&&i.push(a)}),o.concat(r).forEach(l=>{let a=this.getHook(l);a&&this.destroyHook(a)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,t){let i=this.binding("change"),r=this.root.formsForRecovery,n=document.createElement("template");n.innerHTML=e;let o=n.content.firstElementChild;o.id=this.id,o.setAttribute(W,this.root.id),o.setAttribute(M,this.getSession()),o.setAttribute(te,this.getStatic()),o.setAttribute(ee,this.parent?this.parent.id:null);let l=h.all(n.content,"form").filter(a=>a.id&&r[a.id]).filter(a=>!this.pendingForms.has(a.id)).filter(a=>r[a.id].getAttribute(i)===a.getAttribute(i)).map(a=>[r[a.id],a]);if(l.length===0)return t();l.forEach(([a,d],u)=>{this.pendingForms.add(d.id),this.pushFormRecovery(a,d,n.content.firstElementChild,()=>{this.pendingForms.delete(d.id),u===l.length-1&&t()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){var t;return e.id===this.id?this:(t=this.children[e.getAttribute(ee)])==null?void 0:t[e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new 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){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findExistingParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):xt(e)||this.liveSocket.time("full patch complete",()=>{let[r,n]=this.renderContainer(e,"update"),o=new ce(this,this.el,this.id,r,n,null);i=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,r=e?this.rendered.componentCIDs(e):null,[n,o]=this.rendered.toString(r);return[`<${i}>${n}</${i}>`,o]})}componentPatch(e,t){if(xt(e))return!1;let[i,r]=this.rendered.componentToString(t),n=new ce(this,this.el,this.id,i,r,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[Q.elementID(e)]}addHook(e){let t=Q.elementID(e);if(!(e.getAttribute&&!this.ownsElement(e)))if(t&&!this.viewHooks[t]){let i=h.getCustomElHook(e)||I(`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-${Ce}`)||e.getAttribute(this.binding(Ce)),r=this.liveSocket.getHookCallbacks(i);if(r){e.id||I(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);let n=new Q(this,e,r);return this.viewHooks[Q.elementID(n.el)]=n,n}else i!==null&&I(`unknown hook found for "${i}"`,e)}}}destroyHook(e){let t=Q.elementID(e.el);e.__destroyed(),e.__cleanup__(),delete this.viewHooks[t]}applyPendingUpdates(){this.liveSocket.hasPendingLink()&&this.root.isMain()||(this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates()))}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:t,kind:i,flash:r}=e,n=this.expandURL(t),o=new CustomEvent("phx:server-navigate",{detail:{to:t,kind:i,flash:r}});this.liveSocket.historyRedirect(o,n,i,r)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t,reloadToken:i}){this.liveSocket.redirect(e,t,i)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}joinPush(){return this.joinPush=this.joinPush||this.channel.join(),this.joinPush}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.wrapPush(()=>this.channel.join(),{ok:t=>this.liveSocket.requestDOMUpdate(()=>this.onJoin(t)),error:t=>this.onJoinError(t),timeout:()=>this.onJoinError({reason:"timeout"})})}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page reload`,e]),this.onRedirect({to:this.root.href,reloadToken:e.token});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.root.href});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([he,fe,ye]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=Et&&(this.root.displayError([he,fe,ye]),this.log("error",()=>[`giving up trying to mount after ${Et} tries`,e]),this.destroy());let t=h.byId(this.el.id);t?(h.mergeAttrs(t,this.el),this.displayError([he,fe,ye]),this.el=t):this.destroy()}}onClose(e){if(!this.isDestroyed()){if(this.isMain()&&this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(zt)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([he,fe,ye]):this.displayError([he,fe,vt]))}displayError(e){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.delayedDisconnected()}delayedDisconnected(){this.disconnectedTimer=setTimeout(()=>{this.execAll(this.binding("disconnected"))},this.liveSocket.disconnectedTimeout)}wrapPush(e,t){let i=this.liveSocket.getLatencySim(),r=i?n=>setTimeout(()=>!this.isDestroyed()&&n(),i):n=>!this.isDestroyed()&&n();r(()=>{e().receive("ok",n=>r(()=>t.ok&&t.ok(n))).receive("error",n=>r(()=>t.error&&t.error(n))).receive("timeout",()=>r(()=>t.timeout&&t.timeout()))})}pushWithReply(e,t,i){if(!this.isConnected())return Promise.reject({error:"noconnection"});let[r,[n],o]=e?e():[null,[],{}],l=this.joinCount,a=function(){};return o.page_loading&&(a=this.liveSocket.withPageLoading({kind:"element",target:n})),typeof i.cid!="number"&&delete i.cid,new Promise((d,u)=>{this.wrapPush(()=>this.channel.push(t,i,Zt),{ok:p=>{r!==null&&(this.lastAckRef=r);let m=g=>{p.redirect&&this.onRedirect(p.redirect),p.live_patch&&this.onLivePatch(p.live_patch),p.live_redirect&&this.onLiveRedirect(p.live_redirect),a(),d({resp:p,reply:g})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:g,reply:c,events:v})=>{r!==null&&this.undoRefs(r,i.event),this.update(g,v),m(c)})}):(r!==null&&this.undoRefs(r,i.event),m(null))},error:p=>u({error:p}),timeout:()=>{u({timeout:!0}),this.joinCount===l&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,t,i){if(!this.isConnected())return;let r=`[${O}="${this.refSrc()}"]`;i?(i=new Set(i),h.all(document,r,n=>{i&&!i.has(n)||(h.all(n,r,o=>this.undoElRef(o,e,t)),this.undoElRef(n,e,t))})):h.all(document,r,n=>this.undoElRef(n,e,t))}undoElRef(e,t,i){new De(e).maybeUndo(t,i,n=>{let o=new ce(this,e,this.id,n,[],null,{undoRef:t}),l=this.performPatch(o,!0);h.all(e,`[${O}="${this.refSrc()}"]`,a=>this.undoElRef(a,t,i)),l&&this.joinNewChildren()})}refSrc(){return this.el.id}putRef(e,t,i,r={}){let n=this.ref++,o=this.binding(At);if(r.loading){let l=h.all(document,r.loading).map(a=>({el:a,lock:!0,loading:!0}));e=e.concat(l)}for(let{el:l,lock:a,loading:d}of e){if(!a&&!d)throw new Error("putRef requires lock or loading");if(l.setAttribute(O,this.refSrc()),d&&l.setAttribute(ae,n),a&&l.setAttribute(C,n),!d||r.submitter&&!(l===r.submitter||l===r.form))continue;let u=new Promise(c=>{l.addEventListener(`phx:undo-lock:${n}`,()=>c(g),{once:!0})}),p=new Promise(c=>{l.addEventListener(`phx:undo-loading:${n}`,()=>c(g),{once:!0})});l.classList.add(`phx-${i}-loading`);let m=l.getAttribute(o);m!==null&&(l.getAttribute(ke)||l.setAttribute(ke,l.innerText),m!==""&&(l.innerText=m),l.setAttribute(de,l.getAttribute(de)||l.disabled),l.setAttribute("disabled",""));let g={event:t,eventType:i,ref:n,isLoading:d,isLocked:a,lockElements:e.filter(({lock:c})=>c).map(({el:c})=>c),loadingElements:e.filter(({loading:c})=>c).map(({el:c})=>c),unlock:c=>{c=Array.isArray(c)?c:[c],this.undoRefs(n,t,c)},lockComplete:u,loadingComplete:p,lock:c=>new Promise(v=>{if(this.isAcked(n))return v(g);c.setAttribute(C,n),c.setAttribute(O,this.refSrc()),c.addEventListener(`phx:lock-stop:${n}`,()=>v(g),{once:!0})})};l.dispatchEvent(new CustomEvent("phx:push",{detail:g,bubbles:!0,cancelable:!1})),t&&l.dispatchEvent(new CustomEvent(`phx:push:${t}`,{detail:g,bubbles:!0,cancelable:!1}))}return[n,e.map(({el:l})=>l),r]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){let t=e.getAttribute&&e.getAttribute($);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(q(t))return t;let r=i.target||e.getAttribute(this.binding("target"));return q(r)?parseInt(r):t&&(r!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return q(e)?e:e?Y(e.closest(`[${$}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,r,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",i,r]),!1;let[o,l,a]=this.putRef([{el:e,loading:!0,lock:!0}],i,"hook");return this.pushWithReply(()=>[o,l,a],"event",{type:"hook",event:i,value:r,cid:this.closestComponentID(t)}).then(({resp:d,reply:u})=>n(u,o)),o}extractMeta(e,t,i){let r=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(r)&&(t[o.replace(r,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&st.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,r,n,o={},l){this.pushWithReply(()=>this.putRef([{el:t,loading:!0,lock:!0}],r,e,o),"event",{type:e,event:r,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)}).then(({reply:a})=>l&&l(a))}pushFileProgress(e,t,i,r=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(Kt)),ref:e.getAttribute(B),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)}).then(({resp:l})=>r(l))})}pushInput(e,t,i,r,n,o){if(!e.form)throw new Error("form events require the input to be inside a form");let l,a=q(i)?i:this.targetComponentID(e.form,t,n),d=()=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],r,"change",n),u,p=this.extractMeta(e.form,{},n.value),m={};e instanceof HTMLButtonElement&&(m.submitter=e),e.getAttribute(this.binding("change"))?u=dt(e.form,m,[e.name]):u=dt(e.form,m),h.isUploadInput(e)&&e.files&&e.files.length>0&&T.trackFiles(e,Array.from(e.files)),l=T.serializeUploads(e);let g={type:"form",event:r,value:u,meta:N({_target:n._target||"undefined"},p),uploads:l,cid:a};this.pushWithReply(d,"event",g).then(({resp:c})=>{h.isUploadInput(e)&&h.isAutoUpload(e)?De.onUnlock(e,()=>{if(T.filesAwaitingPreflight(e).length>0){let[v,A]=d();this.undoRefs(v,r,[e.form]),this.uploadFiles(e.form,r,t,v,a,x=>{o&&o(c),this.triggerAwaitingSubmit(e.form,r),this.undoRefs(v,r)})}}):o&&o(c)})}triggerAwaitingSubmit(e,t){let i=this.getScheduledSubmit(e);if(i){let[r,n,o,l]=i;this.cancelSubmit(e,t),l()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,r,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,r){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,r])}cancelSubmit(e,t){this.formSubmits=this.formSubmits.filter(([i,r,n,o])=>i.isSameNode(e)?(this.undoRefs(r,t),!1):!0)}disableForm(e,t,i={}){let r=c=>!(ge(c,`${this.binding(Te)}=ignore`,c.form)||ge(c,"data-phx-update=ignore",c.form)),n=c=>c.hasAttribute(this.binding(At)),o=c=>c.tagName=="BUTTON",l=c=>["INPUT","TEXTAREA","SELECT"].includes(c.tagName),a=Array.from(e.elements),d=a.filter(n),u=a.filter(o).filter(r),p=a.filter(l).filter(r);u.forEach(c=>{c.setAttribute(de,c.disabled),c.disabled=!0}),p.forEach(c=>{c.setAttribute(Xe,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(de,c.disabled),c.disabled=!0)});let m=d.concat(u).concat(p).map(c=>({el:c,loading:!0,lock:!0})),g=[{el:e,loading:!0,lock:!1}].concat(m).reverse();return this.putRef(g,t,"submit",i)}pushFormSubmit(e,t,i,r,n,o){let l=()=>this.disableForm(e,i,Ne(N({},n),{form:e,submitter:r})),a=this.targetComponentID(e,t);if(T.hasUploadsInProgress(e)){let[d,u]=l(),p=()=>this.pushFormSubmit(e,t,i,r,n,o);return this.scheduleSubmit(e,d,n,p)}else if(T.inputsAwaitingPreflight(e).length>0){let[d,u]=l(),p=()=>[d,u,n];this.uploadFiles(e,i,t,d,a,m=>{if(T.inputsAwaitingPreflight(e).length>0)return this.undoRefs(d,i);let g=this.extractMeta(e,{},n.value),c=dt(e,{submitter:r});this.pushWithReply(p,"event",{type:"form",event:i,value:c,meta:g,cid:a}).then(({resp:v})=>o(v))})}else if(!(e.hasAttribute(O)&&e.classList.contains("phx-submit-loading"))){let d=this.extractMeta(e,{},n.value),u=dt(e,{submitter:r});this.pushWithReply(l,"event",{type:"form",event:i,value:u,meta:d,cid:a}).then(({resp:p})=>o(p))}}uploadFiles(e,t,i,r,n,o){let l=this.joinCount,a=T.activeFileInputs(e),d=a.length;a.forEach(u=>{let p=new T(u,this,()=>{d--,d===0&&o()}),m=p.entries().map(c=>c.toPreflightPayload());if(m.length===0){d--;return}let g={ref:u.getAttribute(B),entries:m,cid:this.targetComponentID(u.form,i)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g).then(({resp:c})=>{if(this.log("upload",()=>["got preflight response",c]),p.entries().forEach(v=>{c.entries&&!c.entries[v.ref]&&this.handleFailedEntryPreflight(v.ref,"failed preflight",p)}),c.error||Object.keys(c.entries).length===0)this.undoRefs(r,t),(c.error||[]).map(([A,x])=>{this.handleFailedEntryPreflight(A,x,p)});else{let v=A=>{this.channel.onError(()=>{this.joinCount===l&&A()})};p.initAdapterUpload(c,v,this.liveSocket)}})})}handleFailedEntryPreflight(e,t,i){if(i.isAutoUpload()){let r=i.entries().find(n=>n.ref===e.toString());r&&r.cancel()}else i.entries().map(r=>r.cancel());this.log("upload",()=>[`error for entry ${e}`,t])}dispatchUploads(e,t,i){let r=this.targetCtxElement(e)||this.el,n=h.findUploadInputs(r).filter(o=>o.name===t);n.length===0?I(`no live file inputs found matching the name "${t}"`):n.length>1?I(`duplicate live file inputs found matching the name "${t}"`):h.dispatchEvent(n[0],et,{detail:{files:i}})}targetCtxElement(e){if(q(e)){let[t]=h.findComponentNodeList(this.el,e);return t}else return e||null}pushFormRecovery(e,t,i,r){let n=this.binding("change"),o=t.getAttribute(this.binding("target"))||t,l=t.getAttribute(this.binding(St))||t.getAttribute(this.binding("change")),a=Array.from(e.elements).filter(p=>h.isFormInput(p)&&p.name&&!p.hasAttribute(n));if(a.length===0)return;a.forEach(p=>p.hasAttribute(B)&&T.clearFiles(p));let d=a.find(p=>p.type!=="hidden")||a[0],u=0;this.withinTargets(o,(p,m)=>{let g=this.targetComponentID(t,m);u++;let c=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});y.exec(c,"change",l,this,d,["push",{_target:d.name,targetView:p,targetCtx:m,newCid:g,callback:()=>{u--,u===0&&r()}}])},i,i)}pushLinkPatch(e,t,i,r){let n=this.liveSocket.setPendingLink(t),o=e.isTrusted&&e.type!=="popstate",l=i?()=>this.putRef([{el:i,loading:o,lock:!0}],null,"click"):null,a=()=>this.liveSocket.redirect(window.location.href),d=t.startsWith("/")?`${location.protocol}//${location.host}${t}`:t;this.pushWithReply(l,"live_patch",{url:d}).then(({resp:u})=>{this.liveSocket.requestDOMUpdate(()=>{u.link_redirect?this.liveSocket.replaceMain(t,null,r,n):(this.liveSocket.commitPendingLink(n)&&(this.href=t),this.applyPendingUpdates(),r&&r(n))})},({error:u,timeout:p})=>a())}getFormsForRecovery(){if(this.joinCount===0)return{};let e=this.binding("change");return h.all(this.el,`form[${e}]`).filter(t=>t.id).filter(t=>t.elements.length>0).filter(t=>t.getAttribute(this.binding(St))!=="ignore").map(t=>t.cloneNode(!0)).reduce((t,i)=>(t[i.id]=i,t),{})}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(t.forEach(i=>this.rendered.resetRender(i)),this.pushWithReply(null,"cids_will_destroy",{cids:t}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let i=t.filter(r=>h.findComponentNodeList(this.el,r).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)})})}))}ownsElement(e){let t=e.closest(K);return e.getAttribute(ee)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,r,n={}){h.putPrivate(e,me,!0),Array.from(e.elements).forEach(l=>h.putPrivate(l,me,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,r,n,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var _i=s=>h.isUsedInput(s),qe=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:
import {Socket} from "phoenix"
import {LiveSocket} from "phoenix_live_view"
let liveSocket = new LiveSocket("/live", Socket, {...})
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Qt,this.opts=i,this.params=Oe(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Le(ei),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=Le(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Gt,this.disconnectedTimeout=i.disconnectedTimeout||Yt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||10,this.reloadJitterMin=i.reloadJitterMin||5e3,this.reloadJitterMax=i.reloadJitterMax||1e4,this.failsafeJitter=i.failsafeJitter||3e4,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.boundEventNames=new Set,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:Oe(),onPatchEnd:Oe(),onNodeAdded:Oe(),onBeforeElUpdated:Oe()},i.dom||{}),this.transitions=new Ht,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(Be))||0,window.addEventListener("pagehide",r=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.0.9"}isProfileEnabled(){return this.sessionStorage.getItem(nt)==="true"}isDebugEnabled(){return this.sessionStorage.getItem($e)==="true"}isDebugDisabled(){return this.sessionStorage.getItem($e)==="false"}enableDebug(){this.sessionStorage.setItem($e,"true")}enableProfiling(){this.sessionStorage.setItem(nt,"true")}disableDebug(){this.sessionStorage.setItem($e,"false")}disableProfiling(){this.sessionStorage.removeItem(nt)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(ot,e)}disableLatencySim(){this.sessionStorage.removeItem(ot)}getLatencySim(){let e=this.sessionStorage.getItem(ot);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 r=new CustomEvent("phx:exec",{detail:{sourceElement:e}});this.owner(e,n=>y.exec(r,i,t,n,e))}execJSHookPush(e,t,i,r){this.withinOwners(e,n=>{let o=new CustomEvent("phx:exec",{detail:{sourceElement:e}});y.exec(o,"hook",t,n,e,["push",{data:i,callback:r}])})}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[r,n]=i();this.viewLogger(e,t,r,n)}else if(this.isDebugEnabled()){let[r,n]=i();ri(e,t,r,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,r=>{let n=this.getLatencySim();n?setTimeout(()=>i(r),n):i(r)})}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,r=this.reloadJitterMax,n=Math.floor(Math.random()*(r-i+1))+i,o=D.updateLocal(this.localStorage,window.location.pathname,Ye,0,l=>l+1);o>=this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>=this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?ui[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,t){return this.socket.channel(e,t)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>{var i;t.execNewMounted(),this.maybeScroll((i=history.state)==null?void 0:i.scroll)})}}joinRootViews(){let e=!1;return h.all(document,`${K}:not([${ee}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);h.isPhxSticky(t)||i.setHref(this.getHref()),i.join(),t.hasAttribute(Pe)&&(this.main=i)}e=!0}),e}redirect(e,t,i){i&&D.setCookie(wt,i,60),this.unload(),D.redirect(e,t)}replaceMain(e,t,i=null,r=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.findPhxSticky(document)||[],l=h.all(this.outgoingMainEl,`[${this.binding("remove")}]`).filter(d=>!h.isChildOfAny(d,o)),a=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(a,t,n),this.main.setRedirect(e),this.transitionRemoves(l),this.main.join((d,u)=>{d===1&&this.commitPendingLink(r)&&this.requestDOMUpdate(()=>{l.forEach(p=>p.remove()),o.forEach(p=>a.appendChild(p)),this.outgoingMainEl.replaceWith(a),this.outgoingMainEl=null,i&&i(r),u()})})}transitionRemoves(e,t){let i=this.binding("remove"),r=n=>{n.preventDefault(),n.stopImmediatePropagation()};e.forEach(n=>{for(let o of this.boundEventNames)n.addEventListener(o,r,!0);this.execJS(n,n.getAttribute(i),"remove")}),this.requestDOMUpdate(()=>{e.forEach(n=>{for(let o of this.boundEventNames)n.removeEventListener(o,r,!0)}),t&&t()})}isPhxView(e){return e.getAttribute&&e.getAttribute(M)!==null}newRootView(e,t,i){let r=new Ae(e,this,null,t,i);return this.roots[r.id]=r,r}owner(e,t){let i=Y(e.closest(K),r=>this.getViewByEl(r))||this.main;return i&&t?t(i):i}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(W);return Y(this.getRootById(t),i=>i.getDescendentByEl(e))}getRootById(e){return this.roots[e]}destroyAllViews(){for(let e in this.roots)this.roots[e].destroy(),delete this.roots[e];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(W));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}getActiveElement(){return document.activeElement}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.serverCloseRef=this.socket.onClose(t=>{if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,r,n,o,l)=>{let a=n.getAttribute(this.binding(qt)),d=t.key&&t.key.toLowerCase();if(a&&a.toLowerCase()!==d)return;let u=N({key:t.key},this.eventMeta(i,t,n));y.exec(t,i,o,r,n,["push",{data:u}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,r,n,o,l)=>{if(!l){let a=N({key:t.key},this.eventMeta(i,t,n));y.exec(t,i,o,r,n,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,r,n,o,l)=>{if(l==="window"){let a=this.eventMeta(i,t,n);y.exec(t,i,o,r,n,["push",{data:a}])}}),this.on("dragover",t=>t.preventDefault()),this.on("drop",t=>{t.preventDefault();let i=Y(ge(t.target,this.binding(pt)),o=>o.getAttribute(this.binding(pt))),r=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!r||r.disabled||n.length===0||!(r.files instanceof FileList)||(T.trackFiles(r,n,t.dataTransfer),r.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(et,t=>{let i=t.target;if(!h.isUploadInput(i))return;let r=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);T.trackFiles(i,r),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let r=this.metadataCallbacks[e];return r?r(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){D.deleteCookie(wt)}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let r=e[i];this.on(r,n=>{let o=this.binding(i),l=this.binding(`window-${i}`),a=n.target.getAttribute&&n.target.getAttribute(o);a?this.debounce(n.target,n,r,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,a,null)})}):h.all(document,`[${l}]`,d=>{let u=d.getAttribute(l);this.debounce(d,n,r,()=>{this.withinOwners(d,p=>{t(n,i,p,d,u,"window")})})})})}}bindClicks(){this.on("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click")}bindClick(e,t){let i=this.binding(t);window.addEventListener(e,r=>{let n=null;r.detail===0&&(this.clickStartedAtTarget=r.target);let o=this.clickStartedAtTarget||r.target;n=ge(r.target,i),this.dispatchClickAway(r,o),this.clickStartedAtTarget=null;let l=n&&n.getAttribute(i);if(!l){h.isNewPageClick(r,window.location)&&this.unload();return}n.getAttribute("href")==="#"&&r.preventDefault(),!n.hasAttribute(O)&&this.debounce(n,r,"click",()=>{this.withinOwners(n,a=>{y.exec(r,"click",l,a,n,["push",{data:this.eventMeta("click",r,n)}])})})},!1)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,r=>{r.isSameNode(t)||r.contains(t)||this.withinOwners(r,n=>{let o=r.getAttribute(i);y.isVisible(r)&&y.isInViewport(r)&&y.exec(e,"click",o,n,r,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!D.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{D.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,backType:r,id:n,scroll:o,position:l}=t.state||{},a=window.location.href,d=l>this.currentHistoryPosition;i=d?i:r||i,this.currentHistoryPosition=l||0,this.sessionStorage.setItem(Be,this.currentHistoryPosition.toString()),h.dispatchEvent(window,"phx:navigate",{detail:{href:a,patch:i==="patch",pop:!0,direction:d?"forward":"backward"}}),this.requestDOMUpdate(()=>{let u=()=>{this.maybeScroll(o)};this.main.isConnected()&&i==="patch"&&n===this.main.id?this.main.pushLinkPatch(t,a,null,u):this.replaceMain(a,null,u)})},!1),window.addEventListener("click",t=>{let i=ge(t.target,Ze),r=i&&i.getAttribute(Ze);if(!r||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let n=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,o=i.getAttribute($t);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(r==="patch")this.pushHistoryPatch(t,n,o,i);else if(r==="redirect")this.historyRedirect(t,n,o,null,i);else throw new Error(`expected ${Ze} to be "patch" or "redirect", got: ${r}`);let l=i.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(i,l,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i,r){if(!this.isConnected()||!this.main.isMain())return D.redirect(t);this.withPageLoading({to:t,kind:"patch"},n=>{this.main.pushLinkPatch(e,t,r,o=>{this.historyPatch(t,i,o),n()})})}historyPatch(e,t,i=this.setPendingLink(e)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Be,this.currentHistoryPosition.toString()),D.updateCurrentState(r=>Ne(N({},r),{backType:"patch"})),D.pushState(t,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},e),h.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:e,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(e,t,i,r,n){let o=n&&e.isTrusted&&e.type!=="popstate";if(o&&n.classList.add("phx-click-loading"),!this.isConnected()||!this.main.isMain())return D.redirect(t,r);if(/^\/$|^\/[^\/]+.*$/.test(t)){let{protocol:a,host:d}=window.location;t=`${a}//${d}${t}`}let l=window.scrollY;this.withPageLoading({to:t,kind:"redirect"},a=>{this.replaceMain(t,r,d=>{d===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(Be,this.currentHistoryPosition.toString()),D.updateCurrentState(u=>Ne(N({},u),{backType:"redirect"})),D.pushState(i,{type:"redirect",id:this.main.id,scroll:l,position:this.currentHistoryPosition},t),h.dispatchEvent(window,"phx:navigate",{detail:{href:t,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),o&&n.classList.remove("phx-click-loading"),a()})})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=Le(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let r=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!r&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{let r=i.target.getAttribute(this.binding("submit"));if(!r){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{y.exec(i,"submit",r,n,i.target,["push",{submitter:i.submitter}])})});for(let i of["change","input"])this.on(i,r=>{if(r instanceof CustomEvent&&r.target.form===void 0){if(r.detail&&r.detail.dispatcher)throw new Error(`dispatching a custom ${i} event is only supported on input elements inside a form`);return}let n=this.binding("change"),o=r.target;if(r.isComposing){let c=`composition-listener-${i}`;h.private(o,c)||(h.putPrivate(o,c,!0),o.addEventListener("compositionend",()=>{o.dispatchEvent(new Event(i,{bubbles:!0})),h.deletePrivate(o,c)},{once:!0}));return}let l=o.getAttribute(n),a=o.form&&o.form.getAttribute(n),d=l||a;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let u=l?o:o.form,p=e;e++;let{at:m,type:g}=h.private(o,"prev-iteration")||{};m===p-1&&i==="change"&&g==="input"||(h.putPrivate(o,"prev-iteration",{at:p,type:i}),this.debounce(o,r,i,()=>{this.withinOwners(u,c=>{h.putPrivate(o,pe,!0),y.exec(r,"change",d,c,o,["push",{_target:r.target.name,dispatcher:u}])})}))});this.on("reset",i=>{let r=i.target;h.resetForm(r);let n=Array.from(r.elements).find(o=>o.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,r){if(i==="blur"||i==="focusout")return r();let n=this.binding(Jt),o=this.binding(Wt),l=this.defaults.debounce.toString(),a=this.defaults.throttle.toString();this.withinOwners(e,d=>{let u=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,l,o,a,u,()=>{r()})})}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 r=this.domCallbacks.jsQuerySelectorAll;return r?r(e,t,i):i()}},Ht=class{constructor(){this.transitions=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let r=setTimeout(()=>{this.transitions.delete(r),i(),this.flushPendingOps()},e);this.transitions.add(r)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};var rs=(s,e={})=>{let t=h.getCustomElHook(s);if(t)return t;let i=new Q(Ae.closestView(s),s,e);return h.putCustomElHook(s,i),i};return xi(ns);})();