phoenix_live_view 0.18.2 → 0.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/js/phoenix_live_view/dom.js +1 -1
- package/assets/js/phoenix_live_view/dom_patch.js +2 -2
- package/assets/js/phoenix_live_view/js.js +1 -1
- package/assets/js/phoenix_live_view/live_socket.js +30 -14
- package/assets/js/phoenix_live_view/view.js +14 -10
- package/assets/package.json +24 -0
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +52 -22
- package/priv/static/phoenix_live_view.cjs.js.map +2 -2
- package/priv/static/phoenix_live_view.esm.js +52 -22
- package/priv/static/phoenix_live_view.esm.js.map +2 -2
- package/priv/static/phoenix_live_view.js +52 -22
- package/priv/static/phoenix_live_view.min.js +4 -4
|
@@ -493,7 +493,7 @@ var LiveView = (() => {
|
|
|
493
493
|
if (!input) {
|
|
494
494
|
return;
|
|
495
495
|
}
|
|
496
|
-
if (!(this.private(input, PHX_HAS_FOCUSED) || this.private(input
|
|
496
|
+
if (!(this.private(input, PHX_HAS_FOCUSED) || this.private(input, PHX_HAS_SUBMITTED))) {
|
|
497
497
|
el.classList.add(PHX_NO_FEEDBACK_CLASS);
|
|
498
498
|
}
|
|
499
499
|
},
|
|
@@ -1686,7 +1686,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
1686
1686
|
dom_default.copyPrivates(toEl, fromEl);
|
|
1687
1687
|
dom_default.discardError(targetContainer, toEl, phxFeedbackFor);
|
|
1688
1688
|
let isFocusedFormEl = focused && fromEl.isSameNode(focused) && dom_default.isFormInput(fromEl);
|
|
1689
|
-
if (isFocusedFormEl) {
|
|
1689
|
+
if (isFocusedFormEl && fromEl.type !== "hidden") {
|
|
1690
1690
|
this.trackBefore("updated", fromEl, toEl);
|
|
1691
1691
|
dom_default.mergeFocusedInput(fromEl, toEl);
|
|
1692
1692
|
dom_default.syncAttrsToProps(fromEl);
|
|
@@ -1731,7 +1731,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
|
|
|
1731
1731
|
});
|
|
1732
1732
|
}
|
|
1733
1733
|
if (externalFormTriggered) {
|
|
1734
|
-
liveSocket.
|
|
1734
|
+
liveSocket.unload();
|
|
1735
1735
|
externalFormTriggered.submit();
|
|
1736
1736
|
}
|
|
1737
1737
|
return true;
|
|
@@ -2101,7 +2101,7 @@ within:
|
|
|
2101
2101
|
view.withinTargets(phxTarget, (targetView, targetCtx) => {
|
|
2102
2102
|
if (eventType === "change") {
|
|
2103
2103
|
let { newCid, _target, callback } = args;
|
|
2104
|
-
_target = _target || (sourceEl
|
|
2104
|
+
_target = _target || (dom_default.isFormInput(sourceEl) ? sourceEl.name : void 0);
|
|
2105
2105
|
if (_target) {
|
|
2106
2106
|
pushOpts._target = _target;
|
|
2107
2107
|
}
|
|
@@ -2338,7 +2338,7 @@ within:
|
|
|
2338
2338
|
this.href = href;
|
|
2339
2339
|
}
|
|
2340
2340
|
isMain() {
|
|
2341
|
-
return this.el.
|
|
2341
|
+
return this.el.hasAttribute(PHX_MAIN);
|
|
2342
2342
|
}
|
|
2343
2343
|
connectParams(liveReferer) {
|
|
2344
2344
|
let params = this.liveSocket.params(this.el);
|
|
@@ -2436,10 +2436,10 @@ within:
|
|
|
2436
2436
|
applyDiff(type, rawDiff, callback) {
|
|
2437
2437
|
this.log(type, () => ["", clone(rawDiff)]);
|
|
2438
2438
|
let { diff, reply, events, title } = Rendered.extract(rawDiff);
|
|
2439
|
+
callback({ diff, reply, events });
|
|
2439
2440
|
if (title) {
|
|
2440
|
-
dom_default.putTitle(title);
|
|
2441
|
+
window.requestAnimationFrame(() => dom_default.putTitle(title));
|
|
2441
2442
|
}
|
|
2442
|
-
callback({ diff, reply, events });
|
|
2443
2443
|
}
|
|
2444
2444
|
onJoin(resp) {
|
|
2445
2445
|
let { rendered, container } = resp;
|
|
@@ -2741,6 +2741,13 @@ within:
|
|
|
2741
2741
|
applyPendingUpdates() {
|
|
2742
2742
|
this.pendingDiffs.forEach(({ diff, events }) => this.update(diff, events));
|
|
2743
2743
|
this.pendingDiffs = [];
|
|
2744
|
+
this.eachChild((child) => child.applyPendingUpdates());
|
|
2745
|
+
}
|
|
2746
|
+
eachChild(callback) {
|
|
2747
|
+
let children = this.root.children[this.id] || {};
|
|
2748
|
+
for (let id in children) {
|
|
2749
|
+
callback(this.getChildById(id));
|
|
2750
|
+
}
|
|
2744
2751
|
}
|
|
2745
2752
|
onChannel(event, cb) {
|
|
2746
2753
|
this.liveSocket.onChannel(this.channel, event, (resp) => {
|
|
@@ -2764,9 +2771,7 @@ within:
|
|
|
2764
2771
|
this.channel.onClose((reason) => this.onClose(reason));
|
|
2765
2772
|
}
|
|
2766
2773
|
destroyAllChildren() {
|
|
2767
|
-
|
|
2768
|
-
this.getChildById(id).destroy();
|
|
2769
|
-
}
|
|
2774
|
+
this.eachChild((child) => child.destroy());
|
|
2770
2775
|
}
|
|
2771
2776
|
onLiveRedirect(redir) {
|
|
2772
2777
|
let { to, kind, flash } = redir;
|
|
@@ -3288,12 +3293,14 @@ within:
|
|
|
3288
3293
|
}
|
|
3289
3294
|
}
|
|
3290
3295
|
ownsElement(el) {
|
|
3291
|
-
|
|
3296
|
+
let parentViewEl = el.closest(PHX_VIEW_SELECTOR);
|
|
3297
|
+
return el.getAttribute(PHX_PARENT_ID) === this.id || parentViewEl && parentViewEl.id === this.id || !parentViewEl && this.isDead;
|
|
3292
3298
|
}
|
|
3293
3299
|
submitForm(form, targetCtx, phxEvent, opts = {}) {
|
|
3294
3300
|
dom_default.putPrivate(form, PHX_HAS_SUBMITTED, true);
|
|
3295
3301
|
let phxFeedback = this.liveSocket.binding(PHX_FEEDBACK_FOR);
|
|
3296
3302
|
let inputs = Array.from(form.elements);
|
|
3303
|
+
inputs.forEach((input) => dom_default.putPrivate(input, PHX_HAS_SUBMITTED, true));
|
|
3297
3304
|
this.liveSocket.blurActiveElement(this);
|
|
3298
3305
|
this.pushFormSubmit(form, targetCtx, phxEvent, opts, () => {
|
|
3299
3306
|
inputs.forEach((input) => dom_default.showError(input, phxFeedback));
|
|
@@ -3405,8 +3412,9 @@ within:
|
|
|
3405
3412
|
} else if (this.main) {
|
|
3406
3413
|
this.socket.connect();
|
|
3407
3414
|
} else {
|
|
3408
|
-
this.
|
|
3415
|
+
this.bindTopLevelEvents({ dead: true });
|
|
3409
3416
|
}
|
|
3417
|
+
this.joinDeadView();
|
|
3410
3418
|
};
|
|
3411
3419
|
if (["complete", "loaded", "interactive"].indexOf(document.readyState) >= 0) {
|
|
3412
3420
|
doConnect();
|
|
@@ -3426,6 +3434,17 @@ within:
|
|
|
3426
3434
|
execJS(el, encodedJS, eventType = null) {
|
|
3427
3435
|
this.owner(el, (view) => js_default.exec(eventType, encodedJS, view, el));
|
|
3428
3436
|
}
|
|
3437
|
+
unload() {
|
|
3438
|
+
if (this.unloaded) {
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3441
|
+
if (this.main && this.isConnected()) {
|
|
3442
|
+
this.log(this.main, "socket", () => ["disconnect for page nav"]);
|
|
3443
|
+
}
|
|
3444
|
+
this.unloaded = true;
|
|
3445
|
+
this.destroyAllViews();
|
|
3446
|
+
this.disconnect();
|
|
3447
|
+
}
|
|
3429
3448
|
triggerDOM(kind, args) {
|
|
3430
3449
|
this.domCallbacks[kind](...args);
|
|
3431
3450
|
}
|
|
@@ -3539,12 +3558,16 @@ within:
|
|
|
3539
3558
|
return this.socket.channel(topic, params);
|
|
3540
3559
|
}
|
|
3541
3560
|
joinDeadView() {
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3561
|
+
let body = document.body;
|
|
3562
|
+
if (body && !this.isPhxView(body) && !this.isPhxView(document.firstElementChild)) {
|
|
3563
|
+
let view = this.newRootView(body);
|
|
3564
|
+
view.setHref(this.getHref());
|
|
3565
|
+
view.joinDead();
|
|
3566
|
+
if (!this.main) {
|
|
3567
|
+
this.main = view;
|
|
3568
|
+
}
|
|
3569
|
+
window.requestAnimationFrame(() => view.execNewMounted());
|
|
3570
|
+
}
|
|
3548
3571
|
}
|
|
3549
3572
|
joinRootViews() {
|
|
3550
3573
|
let rootsFound = false;
|
|
@@ -3553,7 +3576,7 @@ within:
|
|
|
3553
3576
|
let view = this.newRootView(rootEl);
|
|
3554
3577
|
view.setHref(this.getHref());
|
|
3555
3578
|
view.join();
|
|
3556
|
-
if (rootEl.
|
|
3579
|
+
if (rootEl.hasAttribute(PHX_MAIN)) {
|
|
3557
3580
|
this.main = view;
|
|
3558
3581
|
}
|
|
3559
3582
|
}
|
|
@@ -3679,8 +3702,11 @@ within:
|
|
|
3679
3702
|
}
|
|
3680
3703
|
this.boundTopLevelEvents = true;
|
|
3681
3704
|
this.socket.onClose((event) => {
|
|
3705
|
+
if (event && event.code === 1001) {
|
|
3706
|
+
return this.unload();
|
|
3707
|
+
}
|
|
3682
3708
|
if (event && event.code === 1e3 && this.main) {
|
|
3683
|
-
this.reloadWithJitter(this.main);
|
|
3709
|
+
return this.reloadWithJitter(this.main);
|
|
3684
3710
|
}
|
|
3685
3711
|
});
|
|
3686
3712
|
document.body.addEventListener("click", function() {
|
|
@@ -3813,6 +3839,9 @@ within:
|
|
|
3813
3839
|
}
|
|
3814
3840
|
let phxEvent = target && target.getAttribute(click);
|
|
3815
3841
|
if (!phxEvent) {
|
|
3842
|
+
if (!capture && e.target.href !== void 0) {
|
|
3843
|
+
this.unload();
|
|
3844
|
+
}
|
|
3816
3845
|
return;
|
|
3817
3846
|
}
|
|
3818
3847
|
if (target.getAttribute("href") === "#") {
|
|
@@ -3937,7 +3966,7 @@ within:
|
|
|
3937
3966
|
if (!this.isConnected()) {
|
|
3938
3967
|
return browser_default.redirect(href, flash);
|
|
3939
3968
|
}
|
|
3940
|
-
if (
|
|
3969
|
+
if (/^\/$|^\/[^\/]+.*$/.test(href)) {
|
|
3941
3970
|
let { protocol, host } = window.location;
|
|
3942
3971
|
href = `${protocol}//${host}${href}`;
|
|
3943
3972
|
}
|
|
@@ -3971,6 +4000,7 @@ within:
|
|
|
3971
4000
|
if (!externalFormSubmitted && phxChange && !phxSubmit) {
|
|
3972
4001
|
externalFormSubmitted = true;
|
|
3973
4002
|
e.preventDefault();
|
|
4003
|
+
this.unload();
|
|
3974
4004
|
this.withinOwners(e.target, (view) => {
|
|
3975
4005
|
view.disableForm(e.target);
|
|
3976
4006
|
window.requestAnimationFrame(() => e.target.submit());
|
|
@@ -3980,7 +4010,7 @@ within:
|
|
|
3980
4010
|
this.on("submit", (e) => {
|
|
3981
4011
|
let phxEvent = e.target.getAttribute(this.binding("submit"));
|
|
3982
4012
|
if (!phxEvent) {
|
|
3983
|
-
return;
|
|
4013
|
+
return this.unload();
|
|
3984
4014
|
}
|
|
3985
4015
|
e.preventDefault();
|
|
3986
4016
|
e.target.disabled = true;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var LiveView=(()=>{var Ye=Object.defineProperty;var bt=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable;var Et=(r,e,t)=>e in r?Ye(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ne=(r,e)=>{for(var t in e||(e={}))Qt.call(e,t)&&Et(r,t,e[t]);if(bt)for(var t of bt(e))Zt.call(e,t)&&Et(r,t,e[t]);return r};var ei=r=>Ye(r,"__esModule",{value:!0});var ti=(r,e)=>{ei(r);for(var t in e)Ye(r,t,{get:e[t],enumerable:!0})};var Si={};ti(Si,{LiveSocket:()=>Ke});var ke="consecutive-reloads",_t=10,St=5e3,At=1e4,yt=3e4,Ie=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],x="data-phx-component",Le="data-phx-link",Pt="track-static",wt="data-phx-link-state",L="data-phx-ref",j="data-phx-ref-src",De="track-uploads",M="data-phx-upload-ref",oe="data-phx-preflighted-refs",xt="data-phx-done-refs",Qe="drop-target",me="data-phx-active-refs",ae="phx:live-file:updated",ge="data-phx-skip",Ze="data-phx-prune",et="page-loading",tt="phx-connected",Re="phx-loading",it="phx-no-feedback",rt="phx-error",W="data-phx-parent-id",le="data-phx-main",K="data-phx-root-id",Tt="trigger-action",ve="feedback-for",Oe="phx-has-focused",Ct=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],He=["checkbox","radio"],Ne="phx-has-submitted",D="data-phx-session",J=`[${D}]`,st="data-phx-sticky",Y="data-phx-static",Fe="data-phx-readonly",be="data-phx-disabled",Ee="disable-with",_e="data-phx-disable-with-restore",he="hook",kt="debounce",It="throttle",Se="update",Lt="key",U="phxPrivate",nt="auto-recover",Ae="phx:live-socket:debug",Me="phx:live-socket:profiling",Ue="phx:live-socket:latency-sim",Dt="progress",ot="mounted",Rt=1,Ot=200,Ht="phx-",Nt=3e4;var de="debounce-trigger",ye="throttled",at="debounce-prev-key",Ft={debounce:300,throttle:300},lt="d",X="s",k="c",ht="e",dt="r",ut="t",Mt="p";var Xe=class{constructor(e,t,i){this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=t,this.chunkTimer=null,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){clearTimeout(this.chunkTimer),this.uploadChannel.leave(),this.entry.error(e)}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return P("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))})}};var P=(r,e)=>console.error&&console.error(r,e),$=r=>{let e=typeof r;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(r)};function Ut(){let r=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)r.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):r.add(e[t].id)}var Xt=(r,e,t,i)=>{r.liveSocket.isDebugEnabled()&&console.log(`${r.id} ${e}: ${t} - `,i)},$e=r=>typeof r=="function"?r:function(){return r},ue=r=>JSON.parse(JSON.stringify(r)),te=(r,e,t)=>{do{if(r.matches(`[${e}]`)&&!r.disabled)return r;r=r.parentElement||r.parentNode}while(r!==null&&r.nodeType===1&&!(t&&t.isSameNode(r)||r.matches(J)));return null},ce=r=>r!==null&&typeof r=="object"&&!(r instanceof Array),$t=(r,e)=>JSON.stringify(r)===JSON.stringify(e),ct=r=>{for(let e in r)return!1;return!0},R=(r,e)=>r&&e(r),Bt=function(r,e,t,i){r.forEach(s=>{new Xe(s,t.config.chunk_size,i).upload()})};var Vt={canPushState(){return typeof history.pushState!="undefined"},dropLocal(r,e,t){return r.removeItem(this.localKey(e,t))},updateLocal(r,e,t,i,s){let n=this.getLocal(r,e,t),o=this.localKey(e,t),a=n===null?i:s(n);return r.setItem(o,JSON.stringify(a)),a},getLocal(r,e,t){return JSON.parse(r.getItem(this.localKey(e,t)))},updateCurrentState(r){!this.canPushState()||history.replaceState(r(history.state||{}),"",window.location.href)},pushState(r,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let s=history.state||{};s.scroll=e.scroll,history.replaceState(s,"",window.location.href)}delete e.scroll,history[r+"State"](e,"",t||null);let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)}}else this.redirect(t)},setCookie(r,e){document.cookie=`${r}=${e}`},getCookie(r){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${r}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(r,e){e&&Vt.setCookie("__phoenix_flash__",e+"; max-age=60000; path=/"),window.location=r},localKey(r,e){return`${r}-${e}`},getHashTargetEl(r){let e=r.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},O=Vt;var B={byId(r){return document.getElementById(r)||P(`no id found for ${r}`)},removeClass(r,e){r.classList.remove(e),r.classList.length===0&&r.removeAttribute("class")},all(r,e,t){if(!r)return[];let i=Array.from(r.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(r){let e=document.createElement("template");return e.innerHTML=r,e.content.childElementCount},isUploadInput(r){return r.type==="file"&&r.getAttribute(M)!==null},findUploadInputs(r){return this.all(r,`input[type="file"][${M}]`)},findComponentNodeList(r,e){return this.filterWithinSameLiveView(this.all(r,`[${x}="${e}"]`),r)},isPhxDestroyed(r){return!!(r.id&&B.private(r,"destroyed"))},markPhxChildDestroyed(r){this.isPhxChild(r)&&r.setAttribute(D,""),this.putPrivate(r,"destroyed",!0)},findPhxChildrenInFragment(r,e){let t=document.createElement("template");return t.innerHTML=r,this.findPhxChildren(t.content,e)},isIgnored(r,e){return(r.getAttribute(e)||r.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(r,e,t){return r.getAttribute&&t.indexOf(r.getAttribute(e))>=0},findPhxSticky(r){return this.all(r,`[${st}]`)},findPhxChildren(r,e){return this.all(r,`${J}[${W}="${e}"]`)},findParentCIDs(r,e){let t=new Set(e),i=e.reduce((s,n)=>{let o=`[${x}="${n}"] [${x}]`;return this.filterWithinSameLiveView(this.all(r,o),r).map(a=>parseInt(a.getAttribute(x))).forEach(a=>s.delete(a)),s},t);return i.size===0?new Set(e):i},filterWithinSameLiveView(r,e){return e.querySelector(J)?r.filter(t=>this.withinSameLiveView(t,e)):r},withinSameLiveView(r,e){for(;r=r.parentNode;){if(r.isSameNode(e))return!0;if(r.getAttribute(D)!==null)return!1}},private(r,e){return r[U]&&r[U][e]},deletePrivate(r,e){r[U]&&delete r[U][e]},putPrivate(r,e,t){r[U]||(r[U]={}),r[U][e]=t},updatePrivate(r,e,t,i){let s=this.private(r,e);s===void 0?this.putPrivate(r,e,i(t)):this.putPrivate(r,e,i(s))},copyPrivates(r,e){e[U]&&(r[U]=e[U])},putTitle(r){let e=document.querySelector("title"),{prefix:t,suffix:i}=e.dataset;document.title=`${t||""}${r}${i||""}`},debounce(r,e,t,i,s,n,o,a){let l=r.getAttribute(t),d=r.getAttribute(s);l===""&&(l=i),d===""&&(d=n);let f=l||d;switch(f){case null:return a();case"blur":this.once(r,"debounce-blur")&&r.addEventListener("blur",()=>a());return;default:let c=parseInt(f),p=()=>d?this.deletePrivate(r,ye):a(),E=this.incCycle(r,de,p);if(isNaN(c))return P(`invalid throttle/debounce value: ${f}`);if(d){let v=!1;if(e.type==="keydown"){let w=this.private(r,at);this.putPrivate(r,at,e.key),v=w!==e.key}if(!v&&this.private(r,ye))return!1;a(),this.putPrivate(r,ye,!0),setTimeout(()=>{o()&&this.triggerCycle(r,de)},c)}else setTimeout(()=>{o()&&this.triggerCycle(r,de,E)},c);let _=r.form;_&&this.once(_,"bind-debounce")&&_.addEventListener("submit",()=>{Array.from(new FormData(_).entries(),([v])=>{let w=_.querySelector(`[name="${v}"]`);this.incCycle(w,de),this.deletePrivate(w,ye)})}),this.once(r,"bind-debounce")&&r.addEventListener("blur",()=>this.triggerCycle(r,de))}},triggerCycle(r,e,t){let[i,s]=this.private(r,e);t||(t=i),t===i&&(this.incCycle(r,e),s())},once(r,e){return this.private(r,e)===!0?!1:(this.putPrivate(r,e,!0),!0)},incCycle(r,e,t=function(){}){let[i]=this.private(r,e)||[0,t];return i++,this.putPrivate(r,e,[i,t]),i},discardError(r,e,t){let i=e.getAttribute&&e.getAttribute(t),s=i&&r.querySelector(`[id="${i}"], [name="${i}"], [name="${i}[]"]`);!s||this.private(s,Oe)||this.private(s.form,Ne)||e.classList.add(it)},showError(r,e){(r.id||r.name)&&this.all(r.form,`[${e}="${r.id}"], [${e}="${r.name}"]`,t=>{this.removeClass(t,it)})},isPhxChild(r){return r.getAttribute&&r.getAttribute(W)},isPhxSticky(r){return r.getAttribute&&r.getAttribute(st)!==null},firstPhxChild(r){return this.isPhxChild(r)?r:this.all(r,`[${W}]`)[0]},dispatchEvent(r,e,t={}){let s={bubbles:t.bubbles===void 0?!0:!!t.bubbles,cancelable:!0,detail:t.detail||{}},n=e==="click"?new MouseEvent("click",s):new CustomEvent(e,s);r.dispatchEvent(n)},cloneNode(r,e){if(typeof e=="undefined")return r.cloneNode(!0);{let t=r.cloneNode(!1);return t.innerHTML=e,t}},mergeAttrs(r,e,t={}){let i=t.exclude||[],s=t.isIgnored,n=e.attributes;for(let a=n.length-1;a>=0;a--){let l=n[a].name;i.indexOf(l)<0&&r.setAttribute(l,e.getAttribute(l))}let o=r.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;s?l.startsWith("data-")&&!e.hasAttribute(l)&&r.removeAttribute(l):e.hasAttribute(l)||r.removeAttribute(l)}},mergeFocusedInput(r,e){r instanceof HTMLSelectElement||B.mergeAttrs(r,e,{exclude:["value"]}),e.readOnly?r.setAttribute("readonly",!0):r.removeAttribute("readonly")},hasSelectionRange(r){return r.setSelectionRange&&(r.type==="text"||r.type==="textarea")},restoreFocus(r,e,t){if(!B.isTextualInput(r))return;let i=r.matches(":focus");r.readOnly&&r.blur(),i||r.focus(),this.hasSelectionRange(r)&&r.setSelectionRange(e,t)},isFormInput(r){return/^(?:input|select|textarea)$/i.test(r.tagName)&&r.type!=="button"},syncAttrsToProps(r){r instanceof HTMLInputElement&&He.indexOf(r.type.toLocaleLowerCase())>=0&&(r.checked=r.getAttribute("checked")!==null)},isTextualInput(r){return Ct.indexOf(r.type)>=0},isNowTriggerFormExternal(r,e){return r.getAttribute&&r.getAttribute(e)!==null},syncPendingRef(r,e,t){let i=r.getAttribute(L);if(i===null)return!0;let s=r.getAttribute(j);return B.isFormInput(r)||r.getAttribute(t)!==null?(B.isUploadInput(r)&&B.mergeAttrs(r,e,{isIgnored:!0}),B.putPrivate(r,L,e),!1):(Ie.forEach(n=>{r.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(L,i),e.setAttribute(j,s),!0)},cleanChildNodes(r,e){if(B.isPhxUpdate(r,e,["append","prepend"])){let t=[];r.childNodes.forEach(i=>{i.id||(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()===""||P(`only HTML element tags with an id are allowed inside containers with phx-update.
|
|
1
|
+
var LiveView=(()=>{var Ye=Object.defineProperty;var bt=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable;var Et=(r,e,t)=>e in r?Ye(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ne=(r,e)=>{for(var t in e||(e={}))Qt.call(e,t)&&Et(r,t,e[t]);if(bt)for(var t of bt(e))Zt.call(e,t)&&Et(r,t,e[t]);return r};var ei=r=>Ye(r,"__esModule",{value:!0});var ti=(r,e)=>{ei(r);for(var t in e)Ye(r,t,{get:e[t],enumerable:!0})};var Ai={};ti(Ai,{LiveSocket:()=>qe});var Ie="consecutive-reloads",_t=10,At=5e3,St=1e4,yt=3e4,Le=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],x="data-phx-component",De="data-phx-link",Pt="track-static",wt="data-phx-link-state",L="data-phx-ref",j="data-phx-ref-src",Re="track-uploads",F="data-phx-upload-ref",oe="data-phx-preflighted-refs",xt="data-phx-done-refs",Qe="drop-target",me="data-phx-active-refs",ae="phx:live-file:updated",ge="data-phx-skip",Ze="data-phx-prune",et="page-loading",tt="phx-connected",Oe="phx-loading",it="phx-no-feedback",rt="phx-error",W="data-phx-parent-id",le="data-phx-main",q="data-phx-root-id",Ct="trigger-action",ve="feedback-for",He="phx-has-focused",Tt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],Ne=["checkbox","radio"],be="phx-has-submitted",D="data-phx-session",J=`[${D}]`,st="data-phx-sticky",Y="data-phx-static",Fe="data-phx-readonly",Ee="data-phx-disabled",_e="disable-with",Ae="data-phx-disable-with-restore",he="hook",kt="debounce",It="throttle",Se="update",Lt="key",M="phxPrivate",nt="auto-recover",ye="phx:live-socket:debug",Me="phx:live-socket:profiling",Ue="phx:live-socket:latency-sim",Dt="progress",ot="mounted",Rt=1,Ot=200,Ht="phx-",Nt=3e4;var de="debounce-trigger",Pe="throttled",at="debounce-prev-key",Ft={debounce:300,throttle:300},lt="d",U="s",k="c",ht="e",dt="r",ut="t",Mt="p";var Xe=class{constructor(e,t,i){this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=t,this.chunkTimer=null,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){clearTimeout(this.chunkTimer),this.uploadChannel.leave(),this.entry.error(e)}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return P("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))})}};var P=(r,e)=>console.error&&console.error(r,e),X=r=>{let e=typeof r;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(r)};function Ut(){let r=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)r.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):r.add(e[t].id)}var Xt=(r,e,t,i)=>{r.liveSocket.isDebugEnabled()&&console.log(`${r.id} ${e}: ${t} - `,i)},$e=r=>typeof r=="function"?r:function(){return r},ue=r=>JSON.parse(JSON.stringify(r)),te=(r,e,t)=>{do{if(r.matches(`[${e}]`)&&!r.disabled)return r;r=r.parentElement||r.parentNode}while(r!==null&&r.nodeType===1&&!(t&&t.isSameNode(r)||r.matches(J)));return null},ce=r=>r!==null&&typeof r=="object"&&!(r instanceof Array),$t=(r,e)=>JSON.stringify(r)===JSON.stringify(e),ct=r=>{for(let e in r)return!1;return!0},$=(r,e)=>r&&e(r),Bt=function(r,e,t,i){r.forEach(s=>{new Xe(s,t.config.chunk_size,i).upload()})};var Vt={canPushState(){return typeof history.pushState!="undefined"},dropLocal(r,e,t){return r.removeItem(this.localKey(e,t))},updateLocal(r,e,t,i,s){let n=this.getLocal(r,e,t),o=this.localKey(e,t),a=n===null?i:s(n);return r.setItem(o,JSON.stringify(a)),a},getLocal(r,e,t){return JSON.parse(r.getItem(this.localKey(e,t)))},updateCurrentState(r){!this.canPushState()||history.replaceState(r(history.state||{}),"",window.location.href)},pushState(r,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let s=history.state||{};s.scroll=e.scroll,history.replaceState(s,"",window.location.href)}delete e.scroll,history[r+"State"](e,"",t||null);let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)}}else this.redirect(t)},setCookie(r,e){document.cookie=`${r}=${e}`},getCookie(r){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${r}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(r,e){e&&Vt.setCookie("__phoenix_flash__",e+"; max-age=60000; path=/"),window.location=r},localKey(r,e){return`${r}-${e}`},getHashTargetEl(r){let e=r.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},R=Vt;var B={byId(r){return document.getElementById(r)||P(`no id found for ${r}`)},removeClass(r,e){r.classList.remove(e),r.classList.length===0&&r.removeAttribute("class")},all(r,e,t){if(!r)return[];let i=Array.from(r.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(r){let e=document.createElement("template");return e.innerHTML=r,e.content.childElementCount},isUploadInput(r){return r.type==="file"&&r.getAttribute(F)!==null},findUploadInputs(r){return this.all(r,`input[type="file"][${F}]`)},findComponentNodeList(r,e){return this.filterWithinSameLiveView(this.all(r,`[${x}="${e}"]`),r)},isPhxDestroyed(r){return!!(r.id&&B.private(r,"destroyed"))},markPhxChildDestroyed(r){this.isPhxChild(r)&&r.setAttribute(D,""),this.putPrivate(r,"destroyed",!0)},findPhxChildrenInFragment(r,e){let t=document.createElement("template");return t.innerHTML=r,this.findPhxChildren(t.content,e)},isIgnored(r,e){return(r.getAttribute(e)||r.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(r,e,t){return r.getAttribute&&t.indexOf(r.getAttribute(e))>=0},findPhxSticky(r){return this.all(r,`[${st}]`)},findPhxChildren(r,e){return this.all(r,`${J}[${W}="${e}"]`)},findParentCIDs(r,e){let t=new Set(e),i=e.reduce((s,n)=>{let o=`[${x}="${n}"] [${x}]`;return this.filterWithinSameLiveView(this.all(r,o),r).map(a=>parseInt(a.getAttribute(x))).forEach(a=>s.delete(a)),s},t);return i.size===0?new Set(e):i},filterWithinSameLiveView(r,e){return e.querySelector(J)?r.filter(t=>this.withinSameLiveView(t,e)):r},withinSameLiveView(r,e){for(;r=r.parentNode;){if(r.isSameNode(e))return!0;if(r.getAttribute(D)!==null)return!1}},private(r,e){return r[M]&&r[M][e]},deletePrivate(r,e){r[M]&&delete r[M][e]},putPrivate(r,e,t){r[M]||(r[M]={}),r[M][e]=t},updatePrivate(r,e,t,i){let s=this.private(r,e);s===void 0?this.putPrivate(r,e,i(t)):this.putPrivate(r,e,i(s))},copyPrivates(r,e){e[M]&&(r[M]=e[M])},putTitle(r){let e=document.querySelector("title"),{prefix:t,suffix:i}=e.dataset;document.title=`${t||""}${r}${i||""}`},debounce(r,e,t,i,s,n,o,a){let l=r.getAttribute(t),d=r.getAttribute(s);l===""&&(l=i),d===""&&(d=n);let f=l||d;switch(f){case null:return a();case"blur":this.once(r,"debounce-blur")&&r.addEventListener("blur",()=>a());return;default:let c=parseInt(f),p=()=>d?this.deletePrivate(r,Pe):a(),E=this.incCycle(r,de,p);if(isNaN(c))return P(`invalid throttle/debounce value: ${f}`);if(d){let v=!1;if(e.type==="keydown"){let w=this.private(r,at);this.putPrivate(r,at,e.key),v=w!==e.key}if(!v&&this.private(r,Pe))return!1;a(),this.putPrivate(r,Pe,!0),setTimeout(()=>{o()&&this.triggerCycle(r,de)},c)}else setTimeout(()=>{o()&&this.triggerCycle(r,de,E)},c);let _=r.form;_&&this.once(_,"bind-debounce")&&_.addEventListener("submit",()=>{Array.from(new FormData(_).entries(),([v])=>{let w=_.querySelector(`[name="${v}"]`);this.incCycle(w,de),this.deletePrivate(w,Pe)})}),this.once(r,"bind-debounce")&&r.addEventListener("blur",()=>this.triggerCycle(r,de))}},triggerCycle(r,e,t){let[i,s]=this.private(r,e);t||(t=i),t===i&&(this.incCycle(r,e),s())},once(r,e){return this.private(r,e)===!0?!1:(this.putPrivate(r,e,!0),!0)},incCycle(r,e,t=function(){}){let[i]=this.private(r,e)||[0,t];return i++,this.putPrivate(r,e,[i,t]),i},discardError(r,e,t){let i=e.getAttribute&&e.getAttribute(t),s=i&&r.querySelector(`[id="${i}"], [name="${i}"], [name="${i}[]"]`);!s||this.private(s,He)||this.private(s,be)||e.classList.add(it)},showError(r,e){(r.id||r.name)&&this.all(r.form,`[${e}="${r.id}"], [${e}="${r.name}"]`,t=>{this.removeClass(t,it)})},isPhxChild(r){return r.getAttribute&&r.getAttribute(W)},isPhxSticky(r){return r.getAttribute&&r.getAttribute(st)!==null},firstPhxChild(r){return this.isPhxChild(r)?r:this.all(r,`[${W}]`)[0]},dispatchEvent(r,e,t={}){let s={bubbles:t.bubbles===void 0?!0:!!t.bubbles,cancelable:!0,detail:t.detail||{}},n=e==="click"?new MouseEvent("click",s):new CustomEvent(e,s);r.dispatchEvent(n)},cloneNode(r,e){if(typeof e=="undefined")return r.cloneNode(!0);{let t=r.cloneNode(!1);return t.innerHTML=e,t}},mergeAttrs(r,e,t={}){let i=t.exclude||[],s=t.isIgnored,n=e.attributes;for(let a=n.length-1;a>=0;a--){let l=n[a].name;i.indexOf(l)<0&&r.setAttribute(l,e.getAttribute(l))}let o=r.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;s?l.startsWith("data-")&&!e.hasAttribute(l)&&r.removeAttribute(l):e.hasAttribute(l)||r.removeAttribute(l)}},mergeFocusedInput(r,e){r instanceof HTMLSelectElement||B.mergeAttrs(r,e,{exclude:["value"]}),e.readOnly?r.setAttribute("readonly",!0):r.removeAttribute("readonly")},hasSelectionRange(r){return r.setSelectionRange&&(r.type==="text"||r.type==="textarea")},restoreFocus(r,e,t){if(!B.isTextualInput(r))return;let i=r.matches(":focus");r.readOnly&&r.blur(),i||r.focus(),this.hasSelectionRange(r)&&r.setSelectionRange(e,t)},isFormInput(r){return/^(?:input|select|textarea)$/i.test(r.tagName)&&r.type!=="button"},syncAttrsToProps(r){r instanceof HTMLInputElement&&Ne.indexOf(r.type.toLocaleLowerCase())>=0&&(r.checked=r.getAttribute("checked")!==null)},isTextualInput(r){return Tt.indexOf(r.type)>=0},isNowTriggerFormExternal(r,e){return r.getAttribute&&r.getAttribute(e)!==null},syncPendingRef(r,e,t){let i=r.getAttribute(L);if(i===null)return!0;let s=r.getAttribute(j);return B.isFormInput(r)||r.getAttribute(t)!==null?(B.isUploadInput(r)&&B.mergeAttrs(r,e,{isIgnored:!0}),B.putPrivate(r,L,e),!1):(Le.forEach(n=>{r.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(L,i),e.setAttribute(j,s),!0)},cleanChildNodes(r,e){if(B.isPhxUpdate(r,e,["append","prepend"])){let t=[];r.childNodes.forEach(i=>{i.id||(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()===""||P(`only HTML element tags with an id are allowed inside containers with phx-update.
|
|
2
2
|
|
|
3
3
|
removing illegal node: "${(i.outerHTML||i.nodeValue).trim()}"
|
|
4
4
|
|
|
5
|
-
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(r,e,t){let i=new Set(["id",D,Y,le,K]);if(r.tagName.toLowerCase()===e.toLowerCase())return Array.from(r.attributes).filter(s=>!i.has(s.name.toLowerCase())).forEach(s=>r.removeAttribute(s.name)),Object.keys(t).filter(s=>!i.has(s.toLowerCase())).forEach(s=>r.setAttribute(s,t[s])),r;{let s=document.createElement(e);return Object.keys(t).forEach(n=>s.setAttribute(n,t[n])),i.forEach(n=>s.setAttribute(n,r.getAttribute(n))),s.innerHTML=r.innerHTML,r.replaceWith(s),s}},getSticky(r,e,t){let i=(B.private(r,"sticky")||[]).find(([s])=>e===s);if(i){let[s,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(r,e){this.updatePrivate(r,"sticky",[],t=>t.filter(([i,s])=>i!==e))},putSticky(r,e,t){let i=t(r);this.updatePrivate(r,"sticky",[],s=>{let n=s.findIndex(([o])=>e===o);return n>=0?s[n]=[e,t,i]:s.push([e,t,i]),s})},applyStickyOperations(r){let e=B.private(r,"sticky");!e||e.forEach(([t,i,s])=>this.putSticky(r,t,i))}},h=B;var fe=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(me).split(",").indexOf(y.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(oe).split(",").indexOf(y.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=y.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(ae,this._onElUpdated)}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{y.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}cancel(){this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(ae,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),y.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(ae,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(me).split(",").indexOf(this.ref)===-1&&this.cancel()}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||P(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:Bt}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||P(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var ii=0,y=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(ii++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(oe)!==i.getAttribute(xt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},o=e.getAttribute(M);i[o]=i[o]||[],n.ref=this.genFileRef(s),n.last_modified=s.lastModified,n.name=s.name||n.ref,n.relative_path=s.webkitRelativePath,n.type=s.type,n.size=s.size,i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(M),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){if(e.getAttribute("multiple")!==null){let i=t.filter(s=>!this.activeFiles(e).find(n=>Object.is(n,s)));h.putPrivate(e,"files",this.activeFiles(e).concat(i)),e.value=null}else 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=>fe.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=>!fe.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(y.filesAwaitingPreflight(e)||[]).map(s=>new fe(e,s,t)),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),n));let s=this._entries.reduce((n,o)=>{let{name:a,callback:l}=o.uploader(i.uploaders);return n[a]=n[a]||{callback:l,entries:[]},n[a].entries.push(o),n},{});for(let n in s){let{callback:o,entries:a}=s[n];o(a,t,e,i)}}};var ri={focusMain(){let r=document.querySelector("main h1, main, h1");if(r){let e=r.tabIndex;r.tabIndex=-1,r.focus(),r.tabIndex=e}},anyOf(r,e){return e.find(t=>r instanceof t)},isFocusable(r,e){return r instanceof HTMLAnchorElement&&r.rel!=="ignore"||r instanceof HTMLAreaElement&&r.href!==void 0||!r.disabled&&this.anyOf(r,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||r instanceof HTMLIFrameElement||r.tabIndex>0||!e&&r.tabIndex===0&&r.getAttribute("tabindex")!==null&&r.getAttribute("aria-hidden")!=="true"},attemptFocus(r,e){if(this.isFocusable(r,e))try{r.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(r)},focusFirstInteractive(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(r){let e=r.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},Q=ri;var si={LiveFileUpload:{activeRefs(){return this.el.getAttribute(me)},preflightedRefs(){return this.el.getAttribute(oe)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let r=this.preflightedRefs();this.preflightedWas!==r&&(this.preflightedWas=r,r===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(ae))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(M)),y.getEntryDataURL(this.inputEl,this.ref,r=>{this.url=r,this.el.src=r})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>Q.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>Q.focusFirst(this.el)),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&Q.focusFirst(this.el)}}},Jt=si;var Be=class{constructor(e,t,i){let s=new Set,n=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(s.add(a.id),n.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!s.has(a))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?R(document.getElementById(t.previousElementId),i=>{R(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):R(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{R(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var jt=11;function ni(r,e){var t=e.attributes,i,s,n,o,a;if(!(e.nodeType===jt||r.nodeType===jt)){for(var l=t.length-1;l>=0;l--)i=t[l],s=i.name,n=i.namespaceURI,o=i.value,n?(s=i.localName||s,a=r.getAttributeNS(n,s),a!==o&&(i.prefix==="xmlns"&&(s=i.name),r.setAttributeNS(n,s,o))):(a=r.getAttribute(s),a!==o&&r.setAttribute(s,o));for(var d=r.attributes,f=d.length-1;f>=0;f--)i=d[f],s=i.name,n=i.namespaceURI,n?(s=i.localName||s,e.hasAttributeNS(n,s)||r.removeAttributeNS(n,s)):e.hasAttribute(s)||r.removeAttribute(s)}}var Ve,oi="http://www.w3.org/1999/xhtml",I=typeof document=="undefined"?void 0:document,ai=!!I&&"content"in I.createElement("template"),li=!!I&&I.createRange&&"createContextualFragment"in I.createRange();function hi(r){var e=I.createElement("template");return e.innerHTML=r,e.content.childNodes[0]}function di(r){Ve||(Ve=I.createRange(),Ve.selectNode(I.body));var e=Ve.createContextualFragment(r);return e.childNodes[0]}function ui(r){var e=I.createElement("body");return e.innerHTML=r,e.childNodes[0]}function ci(r){return r=r.trim(),ai?hi(r):li?di(r):ui(r)}function Je(r,e){var t=r.nodeName,i=e.nodeName,s,n;return t===i?!0:(s=t.charCodeAt(0),n=i.charCodeAt(0),s<=90&&n>=97?t===i.toUpperCase():n<=90&&s>=97?i===t.toUpperCase():!1)}function fi(r,e){return!e||e===oi?I.createElement(r):I.createElementNS(e,r)}function pi(r,e){for(var t=r.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function ft(r,e,t){r[t]!==e[t]&&(r[t]=e[t],r[t]?r.setAttribute(t,""):r.removeAttribute(t))}var Wt={OPTION:function(r,e){var t=r.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(r.hasAttribute("selected")&&!e.selected&&(r.setAttribute("selected","selected"),r.removeAttribute("selected")),t.selectedIndex=-1)}ft(r,e,"selected")},INPUT:function(r,e){ft(r,e,"checked"),ft(r,e,"disabled"),r.value!==e.value&&(r.value=e.value),e.hasAttribute("value")||r.removeAttribute("value")},TEXTAREA:function(r,e){var t=e.value;r.value!==t&&(r.value=t);var i=r.firstChild;if(i){var s=i.nodeValue;if(s==t||!t&&s==r.placeholder)return;i.nodeValue=t}},SELECT:function(r,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,s=r.firstChild,n,o;s;)if(o=s.nodeName&&s.nodeName.toUpperCase(),o==="OPTGROUP")n=s,s=n.firstChild;else{if(o==="OPTION"){if(s.hasAttribute("selected")){t=i;break}i++}s=s.nextSibling,!s&&n&&(s=n.nextSibling,n=null)}r.selectedIndex=t}}},Pe=1,mi=11,Kt=3,qt=8;function ie(){}function gi(r){if(r)return r.getAttribute&&r.getAttribute("id")||r.id}function vi(r){return function(t,i,s){if(s||(s={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=I.createElement("html"),i.innerHTML=n}else i=ci(i);var o=s.getNodeKey||gi,a=s.onBeforeNodeAdded||ie,l=s.onNodeAdded||ie,d=s.onBeforeElUpdated||ie,f=s.onElUpdated||ie,c=s.onBeforeNodeDiscarded||ie,p=s.onNodeDiscarded||ie,E=s.onBeforeElChildrenUpdated||ie,_=s.childrenOnly===!0,v=Object.create(null),w=[];function C(b){w.push(b)}function V(b,g){if(b.nodeType===Pe)for(var m=b.firstChild;m;){var S=void 0;g&&(S=o(m))?C(S):(p(m),m.firstChild&&V(m,g)),m=m.nextSibling}}function N(b,g,m){c(b)!==!1&&(g&&g.removeChild(b),p(b),V(b,m))}function u(b){if(b.nodeType===Pe||b.nodeType===mi)for(var g=b.firstChild;g;){var m=o(g);m&&(v[m]=g),u(g),g=g.nextSibling}}u(t);function A(b){l(b);for(var g=b.firstChild;g;){var m=g.nextSibling,S=o(g);if(S){var F=v[S];F&&Je(g,F)?(g.parentNode.replaceChild(F,g),ee(F,g)):A(g)}else A(g);g=m}}function mt(b,g,m){for(;g;){var S=g.nextSibling;(m=o(g))?C(m):N(g,b,!0),g=S}}function ee(b,g,m){var S=o(g);S&&delete v[S],!(!m&&(d(b,g)===!1||(r(b,g),f(b),E(b,g)===!1)))&&(b.nodeName!=="TEXTAREA"?zt(b,g):Wt.TEXTAREA(b,g))}function zt(b,g){var m=g.firstChild,S=b.firstChild,F,q,se,Te,G;e:for(;m;){for(Te=m.nextSibling,F=o(m);S;){if(se=S.nextSibling,m.isSameNode&&m.isSameNode(S)){m=Te,S=se;continue e}q=o(S);var Ce=S.nodeType,z=void 0;if(Ce===m.nodeType&&(Ce===Pe?(F?F!==q&&((G=v[F])?se===G?z=!1:(b.insertBefore(G,S),q?C(q):N(S,b,!0),S=G):z=!1):q&&(z=!1),z=z!==!1&&Je(S,m),z&&ee(S,m)):(Ce===Kt||Ce==qt)&&(z=!0,S.nodeValue!==m.nodeValue&&(S.nodeValue=m.nodeValue))),z){m=Te,S=se;continue e}q?C(q):N(S,b,!0),S=se}if(F&&(G=v[F])&&Je(G,m))b.appendChild(G),ee(G,m);else{var ze=a(m);ze!==!1&&(ze&&(m=ze),m.actualize&&(m=m.actualize(b.ownerDocument||I)),b.appendChild(m),A(m))}m=Te,S=se}mt(b,S,q);var vt=Wt[b.nodeName];vt&&vt(b,g)}var T=t,xe=T.nodeType,gt=i.nodeType;if(!_){if(xe===Pe)gt===Pe?Je(t,i)||(p(t),T=pi(t,fi(i.nodeName,i.namespaceURI))):T=i;else if(xe===Kt||xe===qt){if(gt===xe)return T.nodeValue!==i.nodeValue&&(T.nodeValue=i.nodeValue),T;T=i}}if(T===i)p(t);else{if(i.isSameNode&&i.isSameNode(T))return;if(ee(T,i,_),w)for(var qe=0,Yt=w.length;qe<Yt;qe++){var Ge=v[w[qe]];Ge&&N(Ge,Ge.parentNode,!1)}}return!_&&T!==t&&t.parentNode&&(T.actualize&&(T=T.actualize(t.ownerDocument||I)),t.parentNode.replaceChild(T,t)),T}}var bi=vi(ni),pt=bi;var re=class{static patchEl(e,t,i){pt(e,t,{childrenOnly:!1,onBeforeElUpdated:(s,n)=>{if(i&&i.isSameNode(s)&&h.isFormInput(s))return h.mergeFocusedInput(s,n),!1}})}constructor(e,t,i,s,n){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.targetCID=n,this.cidPatch=$(this.targetCID),this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){h.all(this.container,"[phx-update=append] > *, [phx-update=prepend] > *",e=>{e.setAttribute(Ze,"")})}perform(){let{view:e,liveSocket:t,container:i,html:s}=this,n=this.isCIDPatch()?this.targetCIDContainer(s):i;if(this.isCIDPatch()&&!n)return;let o=t.getActiveElement(),{selectionStart:a,selectionEnd:l}=o&&h.hasSelectionRange(o)?o:{},d=t.binding(Se),f=t.binding(ve),c=t.binding(Ee),p=t.binding(Tt),E=t.binding("remove"),_=[],v=[],w=[],C=[],V=null,N=t.time("premorph container prep",()=>this.buildDiffHTML(i,s,d,n));return this.trackBefore("added",i),this.trackBefore("updated",i,i),t.time("morphdom",()=>{pt(n,N,{childrenOnly:n.getAttribute(x)===null,getNodeKey:u=>h.isPhxDestroyed(u)?null:u.id,onBeforeNodeAdded:u=>(this.trackBefore("added",u),u),onNodeAdded:u=>{u instanceof HTMLImageElement&&u.srcset?u.srcset=u.srcset:u instanceof HTMLVideoElement&&u.autoplay&&u.play(),h.isNowTriggerFormExternal(u,p)&&(V=u),h.discardError(n,u,f),(h.isPhxChild(u)&&e.ownsElement(u)||h.isPhxSticky(u)&&e.ownsElement(u.parentNode))&&this.trackAfter("phxChildAdded",u),_.push(u)},onNodeDiscarded:u=>{(h.isPhxChild(u)||h.isPhxSticky(u))&&t.destroyViewByEl(u),this.trackAfter("discarded",u)},onBeforeNodeDiscarded:u=>u.getAttribute&&u.getAttribute(Ze)!==null?!0:u.parentNode!==null&&h.isPhxUpdate(u.parentNode,d,["append","prepend"])&&u.id?!1:u.getAttribute&&u.getAttribute(E)?(C.push(u),!1):!this.skipCIDSibling(u),onElUpdated:u=>{h.isNowTriggerFormExternal(u,p)&&(V=u),v.push(u)},onBeforeElUpdated:(u,A)=>{if(h.cleanChildNodes(A,d),this.skipCIDSibling(A)||h.isPhxSticky(u))return!1;if(h.isIgnored(u,d)||u.form&&u.form.isSameNode(V))return this.trackBefore("updated",u,A),h.mergeAttrs(u,A,{isIgnored:!0}),v.push(u),h.applyStickyOperations(u),!1;if(u.type==="number"&&u.validity&&u.validity.badInput)return!1;if(!h.syncPendingRef(u,A,c))return h.isUploadInput(u)&&(this.trackBefore("updated",u,A),v.push(u)),h.applyStickyOperations(u),!1;if(h.isPhxChild(A)){let ee=u.getAttribute(D);return h.mergeAttrs(u,A,{exclude:[Y]}),ee!==""&&u.setAttribute(D,ee),u.setAttribute(K,this.rootID),h.applyStickyOperations(u),!1}return h.copyPrivates(A,u),h.discardError(n,A,f),o&&u.isSameNode(o)&&h.isFormInput(u)?(this.trackBefore("updated",u,A),h.mergeFocusedInput(u,A),h.syncAttrsToProps(u),v.push(u),h.applyStickyOperations(u),!1):(h.isPhxUpdate(A,d,["append","prepend"])&&w.push(new Be(u,A,A.getAttribute(d))),h.syncAttrsToProps(A),h.applyStickyOperations(A),this.trackBefore("updated",u,A),!0)}})}),t.isDebugEnabled()&&Ut(),w.length>0&&t.time("post-morph append/prepend restoration",()=>{w.forEach(u=>u.perform())}),t.silenceEvents(()=>h.restoreFocus(o,a,l)),h.dispatchEvent(document,"phx:update"),_.forEach(u=>this.trackAfter("added",u)),v.forEach(u=>this.trackAfter("updated",u)),C.length>0&&(t.transitionRemoves(C),t.requestDOMUpdate(()=>{C.forEach(u=>{let A=h.firstPhxChild(u);A&&t.destroyViewByEl(A),u.remove()}),this.trackAfter("transitionsDiscarded",C)})),V&&(t.disconnect(),V.submit()),!0}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.getAttribute(ge)!==null}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}buildDiffHTML(e,t,i,s){let n=this.isCIDPatch(),o=n&&s.getAttribute(x)===this.targetCID.toString();if(!n||o)return t;{let a=null,l=document.createElement("template");a=h.cloneNode(s);let[d,...f]=h.findComponentNodeList(a,this.targetCID);return l.innerHTML=t,f.forEach(c=>c.remove()),Array.from(a.childNodes).forEach(c=>{c.id&&c.nodeType===Node.ELEMENT_NODE&&c.getAttribute(x)!==this.targetCID.toString()&&(c.setAttribute(ge,""),c.innerHTML="")}),Array.from(l.content.childNodes).forEach(c=>a.insertBefore(c,d)),d.remove(),a.outerHTML}}};var we=class{static extract(e){let{[dt]:t,[ht]:i,[ut]:s}=e;return delete e[dt],delete e[ht],delete e[ut],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){return this.recursiveToString(this.rendered,this.rendered[k],e)}recursiveToString(e,t=e[k],i){i=i?new Set(i):null;let s={buffer:"",components:t,onlyCids:i};return this.toOutputBuffer(e,null,s),s.buffer}componentCIDs(e){return Object.keys(e[k]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[k]?Object.keys(e).length===1:!1}getComponent(e,t){return e[k][t]}mergeDiff(e){let t=e[k],i={};if(delete e[k],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[k]=this.rendered[k]||{},t){let s=this.rendered[k];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],s,t,i);for(let n in t)s[n]=t[n];e[k]=t}}cachedFindComponent(e,t,i,s,n){if(n[e])return n[e];{let o,a,l=t[X];if($(l)){let d;l>0?d=this.cachedFindComponent(l,s[l],i,s,n):d=i[-l],a=d[X],o=this.cloneMerge(d,t),o[X]=a}else o=t[X]!==void 0?t:this.cloneMerge(i[e]||{},t);return n[e]=o,o}}mutableMerge(e,t){return t[X]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let s=t[i],n=e[i];ce(s)&&s[X]===void 0&&ce(n)?this.doMutableMerge(n,s):e[i]=s}}cloneMerge(e,t){let i=ne(ne({},e),t);for(let s in i){let n=t[s],o=e[s];ce(n)&&n[X]===void 0&&ce(o)&&(i[s]=this.cloneMerge(o,n))}return i}componentToString(e){return this.recursiveCIDToString(this.rendered[k],e)}pruneCIDs(e){e.forEach(t=>delete this.rendered[k][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[X]}templateStatic(e,t){return typeof e=="number"?t[e]:e}toOutputBuffer(e,t,i){if(e[lt])return this.comprehensionToBuffer(e,t,i);let{[X]:s}=e;s=this.templateStatic(s,t),i.buffer+=s[0];for(let n=1;n<s.length;n++)this.dynamicToBuffer(e[n-1],t,i),i.buffer+=s[n]}comprehensionToBuffer(e,t,i){let{[lt]:s,[X]:n}=e;n=this.templateStatic(n,t);let o=t||e[Mt];for(let a=0;a<s.length;a++){let l=s[a];i.buffer+=n[0];for(let d=1;d<n.length;d++)this.dynamicToBuffer(l[d-1],o,i),i.buffer+=n[d]}}dynamicToBuffer(e,t,i){typeof e=="number"?i.buffer+=this.recursiveCIDToString(i.components,e,i.onlyCids):ce(e)?this.toOutputBuffer(e,t,i):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||P(`no component for CID ${t}`,e),n=document.createElement("template");n.innerHTML=this.recursiveToString(s,e,i);let o=n.content,a=i&&!i.has(t),[l,d]=Array.from(o.childNodes).reduce(([f,c],p,E)=>p.nodeType===Node.ELEMENT_NODE?p.getAttribute(x)?[f,!0]:(p.setAttribute(x,t),p.id||(p.id=`${this.parentViewId()}-${t}-${E}`),a&&(p.setAttribute(ge,""),p.innerHTML=""),[!0,c]):p.nodeValue.trim()!==""?(P(`only HTML element tags are allowed at the root of components.
|
|
5
|
+
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(r,e,t){let i=new Set(["id",D,Y,le,q]);if(r.tagName.toLowerCase()===e.toLowerCase())return Array.from(r.attributes).filter(s=>!i.has(s.name.toLowerCase())).forEach(s=>r.removeAttribute(s.name)),Object.keys(t).filter(s=>!i.has(s.toLowerCase())).forEach(s=>r.setAttribute(s,t[s])),r;{let s=document.createElement(e);return Object.keys(t).forEach(n=>s.setAttribute(n,t[n])),i.forEach(n=>s.setAttribute(n,r.getAttribute(n))),s.innerHTML=r.innerHTML,r.replaceWith(s),s}},getSticky(r,e,t){let i=(B.private(r,"sticky")||[]).find(([s])=>e===s);if(i){let[s,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(r,e){this.updatePrivate(r,"sticky",[],t=>t.filter(([i,s])=>i!==e))},putSticky(r,e,t){let i=t(r);this.updatePrivate(r,"sticky",[],s=>{let n=s.findIndex(([o])=>e===o);return n>=0?s[n]=[e,t,i]:s.push([e,t,i]),s})},applyStickyOperations(r){let e=B.private(r,"sticky");!e||e.forEach(([t,i,s])=>this.putSticky(r,t,i))}},h=B;var fe=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(me).split(",").indexOf(y.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(oe).split(",").indexOf(y.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=y.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(ae,this._onElUpdated)}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{y.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}cancel(){this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(ae,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),y.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(ae,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(me).split(",").indexOf(this.ref)===-1&&this.cancel()}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||P(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:Bt}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||P(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var ii=0,y=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(ii++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(oe)!==i.getAttribute(xt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},o=e.getAttribute(F);i[o]=i[o]||[],n.ref=this.genFileRef(s),n.last_modified=s.lastModified,n.name=s.name||n.ref,n.relative_path=s.webkitRelativePath,n.type=s.type,n.size=s.size,i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(F),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){if(e.getAttribute("multiple")!==null){let i=t.filter(s=>!this.activeFiles(e).find(n=>Object.is(n,s)));h.putPrivate(e,"files",this.activeFiles(e).concat(i)),e.value=null}else 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=>fe.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=>!fe.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(y.filesAwaitingPreflight(e)||[]).map(s=>new fe(e,s,t)),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),n));let s=this._entries.reduce((n,o)=>{let{name:a,callback:l}=o.uploader(i.uploaders);return n[a]=n[a]||{callback:l,entries:[]},n[a].entries.push(o),n},{});for(let n in s){let{callback:o,entries:a}=s[n];o(a,t,e,i)}}};var ri={focusMain(){let r=document.querySelector("main h1, main, h1");if(r){let e=r.tabIndex;r.tabIndex=-1,r.focus(),r.tabIndex=e}},anyOf(r,e){return e.find(t=>r instanceof t)},isFocusable(r,e){return r instanceof HTMLAnchorElement&&r.rel!=="ignore"||r instanceof HTMLAreaElement&&r.href!==void 0||!r.disabled&&this.anyOf(r,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||r instanceof HTMLIFrameElement||r.tabIndex>0||!e&&r.tabIndex===0&&r.getAttribute("tabindex")!==null&&r.getAttribute("aria-hidden")!=="true"},attemptFocus(r,e){if(this.isFocusable(r,e))try{r.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(r)},focusFirstInteractive(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(r){let e=r.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},Q=ri;var si={LiveFileUpload:{activeRefs(){return this.el.getAttribute(me)},preflightedRefs(){return this.el.getAttribute(oe)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let r=this.preflightedRefs();this.preflightedWas!==r&&(this.preflightedWas=r,r===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(ae))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(F)),y.getEntryDataURL(this.inputEl,this.ref,r=>{this.url=r,this.el.src=r})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>Q.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>Q.focusFirst(this.el)),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&Q.focusFirst(this.el)}}},Jt=si;var Be=class{constructor(e,t,i){let s=new Set,n=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(s.add(a.id),n.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!s.has(a))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?$(document.getElementById(t.previousElementId),i=>{$(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):$(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{$(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var jt=11;function ni(r,e){var t=e.attributes,i,s,n,o,a;if(!(e.nodeType===jt||r.nodeType===jt)){for(var l=t.length-1;l>=0;l--)i=t[l],s=i.name,n=i.namespaceURI,o=i.value,n?(s=i.localName||s,a=r.getAttributeNS(n,s),a!==o&&(i.prefix==="xmlns"&&(s=i.name),r.setAttributeNS(n,s,o))):(a=r.getAttribute(s),a!==o&&r.setAttribute(s,o));for(var d=r.attributes,f=d.length-1;f>=0;f--)i=d[f],s=i.name,n=i.namespaceURI,n?(s=i.localName||s,e.hasAttributeNS(n,s)||r.removeAttributeNS(n,s)):e.hasAttribute(s)||r.removeAttribute(s)}}var Ve,oi="http://www.w3.org/1999/xhtml",I=typeof document=="undefined"?void 0:document,ai=!!I&&"content"in I.createElement("template"),li=!!I&&I.createRange&&"createContextualFragment"in I.createRange();function hi(r){var e=I.createElement("template");return e.innerHTML=r,e.content.childNodes[0]}function di(r){Ve||(Ve=I.createRange(),Ve.selectNode(I.body));var e=Ve.createContextualFragment(r);return e.childNodes[0]}function ui(r){var e=I.createElement("body");return e.innerHTML=r,e.childNodes[0]}function ci(r){return r=r.trim(),ai?hi(r):li?di(r):ui(r)}function Je(r,e){var t=r.nodeName,i=e.nodeName,s,n;return t===i?!0:(s=t.charCodeAt(0),n=i.charCodeAt(0),s<=90&&n>=97?t===i.toUpperCase():n<=90&&s>=97?i===t.toUpperCase():!1)}function fi(r,e){return!e||e===oi?I.createElement(r):I.createElementNS(e,r)}function pi(r,e){for(var t=r.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function ft(r,e,t){r[t]!==e[t]&&(r[t]=e[t],r[t]?r.setAttribute(t,""):r.removeAttribute(t))}var Wt={OPTION:function(r,e){var t=r.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(r.hasAttribute("selected")&&!e.selected&&(r.setAttribute("selected","selected"),r.removeAttribute("selected")),t.selectedIndex=-1)}ft(r,e,"selected")},INPUT:function(r,e){ft(r,e,"checked"),ft(r,e,"disabled"),r.value!==e.value&&(r.value=e.value),e.hasAttribute("value")||r.removeAttribute("value")},TEXTAREA:function(r,e){var t=e.value;r.value!==t&&(r.value=t);var i=r.firstChild;if(i){var s=i.nodeValue;if(s==t||!t&&s==r.placeholder)return;i.nodeValue=t}},SELECT:function(r,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,s=r.firstChild,n,o;s;)if(o=s.nodeName&&s.nodeName.toUpperCase(),o==="OPTGROUP")n=s,s=n.firstChild;else{if(o==="OPTION"){if(s.hasAttribute("selected")){t=i;break}i++}s=s.nextSibling,!s&&n&&(s=n.nextSibling,n=null)}r.selectedIndex=t}}},we=1,mi=11,qt=3,Kt=8;function ie(){}function gi(r){if(r)return r.getAttribute&&r.getAttribute("id")||r.id}function vi(r){return function(t,i,s){if(s||(s={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=I.createElement("html"),i.innerHTML=n}else i=ci(i);var o=s.getNodeKey||gi,a=s.onBeforeNodeAdded||ie,l=s.onNodeAdded||ie,d=s.onBeforeElUpdated||ie,f=s.onElUpdated||ie,c=s.onBeforeNodeDiscarded||ie,p=s.onNodeDiscarded||ie,E=s.onBeforeElChildrenUpdated||ie,_=s.childrenOnly===!0,v=Object.create(null),w=[];function T(b){w.push(b)}function V(b,g){if(b.nodeType===we)for(var m=b.firstChild;m;){var A=void 0;g&&(A=o(m))?T(A):(p(m),m.firstChild&&V(m,g)),m=m.nextSibling}}function H(b,g,m){c(b)!==!1&&(g&&g.removeChild(b),p(b),V(b,m))}function u(b){if(b.nodeType===we||b.nodeType===mi)for(var g=b.firstChild;g;){var m=o(g);m&&(v[m]=g),u(g),g=g.nextSibling}}u(t);function S(b){l(b);for(var g=b.firstChild;g;){var m=g.nextSibling,A=o(g);if(A){var N=v[A];N&&Je(g,N)?(g.parentNode.replaceChild(N,g),ee(N,g)):S(g)}else S(g);g=m}}function mt(b,g,m){for(;g;){var A=g.nextSibling;(m=o(g))?T(m):H(g,b,!0),g=A}}function ee(b,g,m){var A=o(g);A&&delete v[A],!(!m&&(d(b,g)===!1||(r(b,g),f(b),E(b,g)===!1)))&&(b.nodeName!=="TEXTAREA"?zt(b,g):Wt.TEXTAREA(b,g))}function zt(b,g){var m=g.firstChild,A=b.firstChild,N,K,se,Te,G;e:for(;m;){for(Te=m.nextSibling,N=o(m);A;){if(se=A.nextSibling,m.isSameNode&&m.isSameNode(A)){m=Te,A=se;continue e}K=o(A);var ke=A.nodeType,z=void 0;if(ke===m.nodeType&&(ke===we?(N?N!==K&&((G=v[N])?se===G?z=!1:(b.insertBefore(G,A),K?T(K):H(A,b,!0),A=G):z=!1):K&&(z=!1),z=z!==!1&&Je(A,m),z&&ee(A,m)):(ke===qt||ke==Kt)&&(z=!0,A.nodeValue!==m.nodeValue&&(A.nodeValue=m.nodeValue))),z){m=Te,A=se;continue e}K?T(K):H(A,b,!0),A=se}if(N&&(G=v[N])&&Je(G,m))b.appendChild(G),ee(G,m);else{var ze=a(m);ze!==!1&&(ze&&(m=ze),m.actualize&&(m=m.actualize(b.ownerDocument||I)),b.appendChild(m),S(m))}m=Te,A=se}mt(b,A,K);var vt=Wt[b.nodeName];vt&&vt(b,g)}var C=t,Ce=C.nodeType,gt=i.nodeType;if(!_){if(Ce===we)gt===we?Je(t,i)||(p(t),C=pi(t,fi(i.nodeName,i.namespaceURI))):C=i;else if(Ce===qt||Ce===Kt){if(gt===Ce)return C.nodeValue!==i.nodeValue&&(C.nodeValue=i.nodeValue),C;C=i}}if(C===i)p(t);else{if(i.isSameNode&&i.isSameNode(C))return;if(ee(C,i,_),w)for(var Ke=0,Yt=w.length;Ke<Yt;Ke++){var Ge=v[w[Ke]];Ge&&H(Ge,Ge.parentNode,!1)}}return!_&&C!==t&&t.parentNode&&(C.actualize&&(C=C.actualize(t.ownerDocument||I)),t.parentNode.replaceChild(C,t)),C}}var bi=vi(ni),pt=bi;var re=class{static patchEl(e,t,i){pt(e,t,{childrenOnly:!1,onBeforeElUpdated:(s,n)=>{if(i&&i.isSameNode(s)&&h.isFormInput(s))return h.mergeFocusedInput(s,n),!1}})}constructor(e,t,i,s,n){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.targetCID=n,this.cidPatch=X(this.targetCID),this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){h.all(this.container,"[phx-update=append] > *, [phx-update=prepend] > *",e=>{e.setAttribute(Ze,"")})}perform(){let{view:e,liveSocket:t,container:i,html:s}=this,n=this.isCIDPatch()?this.targetCIDContainer(s):i;if(this.isCIDPatch()&&!n)return;let o=t.getActiveElement(),{selectionStart:a,selectionEnd:l}=o&&h.hasSelectionRange(o)?o:{},d=t.binding(Se),f=t.binding(ve),c=t.binding(_e),p=t.binding(Ct),E=t.binding("remove"),_=[],v=[],w=[],T=[],V=null,H=t.time("premorph container prep",()=>this.buildDiffHTML(i,s,d,n));return this.trackBefore("added",i),this.trackBefore("updated",i,i),t.time("morphdom",()=>{pt(n,H,{childrenOnly:n.getAttribute(x)===null,getNodeKey:u=>h.isPhxDestroyed(u)?null:u.id,onBeforeNodeAdded:u=>(this.trackBefore("added",u),u),onNodeAdded:u=>{u instanceof HTMLImageElement&&u.srcset?u.srcset=u.srcset:u instanceof HTMLVideoElement&&u.autoplay&&u.play(),h.isNowTriggerFormExternal(u,p)&&(V=u),h.discardError(n,u,f),(h.isPhxChild(u)&&e.ownsElement(u)||h.isPhxSticky(u)&&e.ownsElement(u.parentNode))&&this.trackAfter("phxChildAdded",u),_.push(u)},onNodeDiscarded:u=>{(h.isPhxChild(u)||h.isPhxSticky(u))&&t.destroyViewByEl(u),this.trackAfter("discarded",u)},onBeforeNodeDiscarded:u=>u.getAttribute&&u.getAttribute(Ze)!==null?!0:u.parentNode!==null&&h.isPhxUpdate(u.parentNode,d,["append","prepend"])&&u.id?!1:u.getAttribute&&u.getAttribute(E)?(T.push(u),!1):!this.skipCIDSibling(u),onElUpdated:u=>{h.isNowTriggerFormExternal(u,p)&&(V=u),v.push(u)},onBeforeElUpdated:(u,S)=>{if(h.cleanChildNodes(S,d),this.skipCIDSibling(S)||h.isPhxSticky(u))return!1;if(h.isIgnored(u,d)||u.form&&u.form.isSameNode(V))return this.trackBefore("updated",u,S),h.mergeAttrs(u,S,{isIgnored:!0}),v.push(u),h.applyStickyOperations(u),!1;if(u.type==="number"&&u.validity&&u.validity.badInput)return!1;if(!h.syncPendingRef(u,S,c))return h.isUploadInput(u)&&(this.trackBefore("updated",u,S),v.push(u)),h.applyStickyOperations(u),!1;if(h.isPhxChild(S)){let ee=u.getAttribute(D);return h.mergeAttrs(u,S,{exclude:[Y]}),ee!==""&&u.setAttribute(D,ee),u.setAttribute(q,this.rootID),h.applyStickyOperations(u),!1}return h.copyPrivates(S,u),h.discardError(n,S,f),o&&u.isSameNode(o)&&h.isFormInput(u)&&u.type!=="hidden"?(this.trackBefore("updated",u,S),h.mergeFocusedInput(u,S),h.syncAttrsToProps(u),v.push(u),h.applyStickyOperations(u),!1):(h.isPhxUpdate(S,d,["append","prepend"])&&w.push(new Be(u,S,S.getAttribute(d))),h.syncAttrsToProps(S),h.applyStickyOperations(S),this.trackBefore("updated",u,S),!0)}})}),t.isDebugEnabled()&&Ut(),w.length>0&&t.time("post-morph append/prepend restoration",()=>{w.forEach(u=>u.perform())}),t.silenceEvents(()=>h.restoreFocus(o,a,l)),h.dispatchEvent(document,"phx:update"),_.forEach(u=>this.trackAfter("added",u)),v.forEach(u=>this.trackAfter("updated",u)),T.length>0&&(t.transitionRemoves(T),t.requestDOMUpdate(()=>{T.forEach(u=>{let S=h.firstPhxChild(u);S&&t.destroyViewByEl(S),u.remove()}),this.trackAfter("transitionsDiscarded",T)})),V&&(t.unload(),V.submit()),!0}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.getAttribute(ge)!==null}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}buildDiffHTML(e,t,i,s){let n=this.isCIDPatch(),o=n&&s.getAttribute(x)===this.targetCID.toString();if(!n||o)return t;{let a=null,l=document.createElement("template");a=h.cloneNode(s);let[d,...f]=h.findComponentNodeList(a,this.targetCID);return l.innerHTML=t,f.forEach(c=>c.remove()),Array.from(a.childNodes).forEach(c=>{c.id&&c.nodeType===Node.ELEMENT_NODE&&c.getAttribute(x)!==this.targetCID.toString()&&(c.setAttribute(ge,""),c.innerHTML="")}),Array.from(l.content.childNodes).forEach(c=>a.insertBefore(c,d)),d.remove(),a.outerHTML}}};var xe=class{static extract(e){let{[dt]:t,[ht]:i,[ut]:s}=e;return delete e[dt],delete e[ht],delete e[ut],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){return this.recursiveToString(this.rendered,this.rendered[k],e)}recursiveToString(e,t=e[k],i){i=i?new Set(i):null;let s={buffer:"",components:t,onlyCids:i};return this.toOutputBuffer(e,null,s),s.buffer}componentCIDs(e){return Object.keys(e[k]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[k]?Object.keys(e).length===1:!1}getComponent(e,t){return e[k][t]}mergeDiff(e){let t=e[k],i={};if(delete e[k],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[k]=this.rendered[k]||{},t){let s=this.rendered[k];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],s,t,i);for(let n in t)s[n]=t[n];e[k]=t}}cachedFindComponent(e,t,i,s,n){if(n[e])return n[e];{let o,a,l=t[U];if(X(l)){let d;l>0?d=this.cachedFindComponent(l,s[l],i,s,n):d=i[-l],a=d[U],o=this.cloneMerge(d,t),o[U]=a}else o=t[U]!==void 0?t:this.cloneMerge(i[e]||{},t);return n[e]=o,o}}mutableMerge(e,t){return t[U]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let s=t[i],n=e[i];ce(s)&&s[U]===void 0&&ce(n)?this.doMutableMerge(n,s):e[i]=s}}cloneMerge(e,t){let i=ne(ne({},e),t);for(let s in i){let n=t[s],o=e[s];ce(n)&&n[U]===void 0&&ce(o)&&(i[s]=this.cloneMerge(o,n))}return i}componentToString(e){return this.recursiveCIDToString(this.rendered[k],e)}pruneCIDs(e){e.forEach(t=>delete this.rendered[k][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[U]}templateStatic(e,t){return typeof e=="number"?t[e]:e}toOutputBuffer(e,t,i){if(e[lt])return this.comprehensionToBuffer(e,t,i);let{[U]:s}=e;s=this.templateStatic(s,t),i.buffer+=s[0];for(let n=1;n<s.length;n++)this.dynamicToBuffer(e[n-1],t,i),i.buffer+=s[n]}comprehensionToBuffer(e,t,i){let{[lt]:s,[U]:n}=e;n=this.templateStatic(n,t);let o=t||e[Mt];for(let a=0;a<s.length;a++){let l=s[a];i.buffer+=n[0];for(let d=1;d<n.length;d++)this.dynamicToBuffer(l[d-1],o,i),i.buffer+=n[d]}}dynamicToBuffer(e,t,i){typeof e=="number"?i.buffer+=this.recursiveCIDToString(i.components,e,i.onlyCids):ce(e)?this.toOutputBuffer(e,t,i):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||P(`no component for CID ${t}`,e),n=document.createElement("template");n.innerHTML=this.recursiveToString(s,e,i);let o=n.content,a=i&&!i.has(t),[l,d]=Array.from(o.childNodes).reduce(([f,c],p,E)=>p.nodeType===Node.ELEMENT_NODE?p.getAttribute(x)?[f,!0]:(p.setAttribute(x,t),p.id||(p.id=`${this.parentViewId()}-${t}-${E}`),a&&(p.setAttribute(ge,""),p.innerHTML=""),[!0,c]):p.nodeValue.trim()!==""?(P(`only HTML element tags are allowed at the root of components.
|
|
6
6
|
|
|
7
7
|
got: "${p.nodeValue.trim()}"
|
|
8
8
|
|
|
9
9
|
within:
|
|
10
10
|
`,n.innerHTML.trim()),p.replaceWith(this.createSpan(p.nodeValue,t)),[!0,c]):(p.remove(),[f,c]),[!1,!1]);return!l&&!d?(P(`expected at least one HTML element tag inside a component, but the component is empty:
|
|
11
|
-
`,n.innerHTML.trim()),this.createSpan("",t).outerHTML):(!l&&d&&P("expected at least one HTML element tag directly inside a component, but only subcomponents were found. A component must render at least one HTML tag directly inside itself.",n.innerHTML.trim()),n.innerHTML)}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(x,t),i}};var Ei=1,Z=class{static makeID(){return Ei++}static elementID(e){return e.phxHookId}constructor(e,t,i){this.__view=e,this.liveSocket=e.liveSocket,this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,this.el=t,this.el.phxHookId=this.constructor.makeID();for(let s in this.__callbacks)this[s]=this.__callbacks[s]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,t={},i=function(){}){return this.__view.pushHookEvent(null,e,t,i)}pushEventTo(e,t,i={},s=function(){}){return this.__view.withinTargets(e,(n,o)=>n.pushHookEvent(o,t,i,s))}handleEvent(e,t){let i=(s,n)=>n?e:t(s.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view.dispatchUploads(e,t)}uploadTo(e,t,i){return this.__view.withinTargets(e,s=>s.dispatchUploads(t,i))}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var je=null,_i={exec(r,e,t,i,s){let[n,o]=s||[null,{}];(e.charAt(0)==="["?JSON.parse(e):[[n,o]]).forEach(([l,d])=>{l===n&&o.data&&(d.data=Object.assign(d.data||{},o.data)),this.filterToEls(i,d).forEach(f=>{this[`exec_${l}`](r,e,t,i,f,d)})})},isVisible(r){return!!(r.offsetWidth||r.offsetHeight||r.getClientRects().length>0)},exec_dispatch(r,e,t,i,s,{to:n,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=i,h.dispatchEvent(s,o,{detail:a,bubbles:l})},exec_push(r,e,t,i,s,n){if(!t.isConnected())return;let{event:o,data:a,target:l,page_loading:d,loading:f,value:c,dispatcher:p}=n,E={loading:f,value:c,target:l,page_loading:!!d},_=r==="change"&&p?p:i,v=l||_.getAttribute(t.binding("target"))||_;t.withinTargets(v,(w,C)=>{if(r==="change"){let{newCid:V,_target:N,callback:u}=n;N=N||(i instanceof HTMLInputElement?i.name:void 0),N&&(E._target=N),w.pushInput(i,C,V,o||e,E,u)}else r==="submit"?w.submitForm(i,C,o||e,E):w.pushEvent(r,i,C,o||e,a,E)})},exec_navigate(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.historyRedirect(n,o?"replace":"push")},exec_patch(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.pushHistoryPatch(n,o?"replace":"push",i)},exec_focus(r,e,t,i,s){window.requestAnimationFrame(()=>Q.attemptFocus(s))},exec_focus_first(r,e,t,i,s){window.requestAnimationFrame(()=>Q.focusFirstInteractive(s)||Q.focusFirst(s))},exec_push_focus(r,e,t,i,s){window.requestAnimationFrame(()=>je=s||i)},exec_pop_focus(r,e,t,i,s){window.requestAnimationFrame(()=>{je&&je.focus(),je=null})},exec_add_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,n,[],o,a,t)},exec_remove_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,[],n,o,a,t)},exec_transition(r,e,t,i,s,{time:n,transition:o}){let[a,l,d]=o,f=()=>this.addOrRemoveClasses(s,a.concat(l),[]),c=()=>this.addOrRemoveClasses(s,d,a.concat(l));t.transition(n,f,c)},exec_toggle(r,e,t,i,s,{display:n,ins:o,outs:a,time:l}){this.toggle(r,t,s,n,o,a,l)},exec_show(r,e,t,i,s,{display:n,transition:o,time:a}){this.show(r,t,s,n,o,a)},exec_hide(r,e,t,i,s,{display:n,transition:o,time:a}){this.hide(r,t,s,n,o,a)},exec_set_attr(r,e,t,i,s,{attr:[n,o]}){this.setOrRemoveAttrs(s,[[n,o]],[])},exec_remove_attr(r,e,t,i,s,{attr:n}){this.setOrRemoveAttrs(s,[],[n])},show(r,e,t,i,s,n){this.isVisible(t)||this.toggle(r,e,t,i,s,null,n)},hide(r,e,t,i,s,n){this.isVisible(t)&&this.toggle(r,e,t,i,null,s,n)},toggle(r,e,t,i,s,n,o){let[a,l,d]=s||[[],[],[]],[f,c,p]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(t)){let E=()=>{this.addOrRemoveClasses(t,c,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,p,c))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,E,()=>{this.addOrRemoveClasses(t,[],f.concat(p)),h.putSticky(t,"toggle",_=>_.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(r==="remove")return;let E=()=>{this.addOrRemoveClasses(t,l,f.concat(c).concat(p)),h.putSticky(t,"toggle",_=>_.style.display=i||"block"),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,d,l))})};t.dispatchEvent(new Event("phx:show-start")),e.transition(o,E,()=>{this.addOrRemoveClasses(t,[],a.concat(d)),t.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",E=>E.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start")),h.putSticky(t,"toggle",E=>E.style.display=i||"block"),t.dispatchEvent(new Event("phx:show-end"))})},addOrRemoveClasses(r,e,t,i,s,n){let[o,a,l]=i||[[],[],[]];if(o.length>0){let d=()=>this.addOrRemoveClasses(r,a.concat(o),[]),f=()=>this.addOrRemoveClasses(r,e.concat(l),t.concat(o).concat(a));return n.transition(s,d,f)}window.requestAnimationFrame(()=>{let[d,f]=h.getSticky(r,"classes",[[],[]]),c=e.filter(v=>d.indexOf(v)<0&&!r.classList.contains(v)),p=t.filter(v=>f.indexOf(v)<0&&r.classList.contains(v)),E=d.filter(v=>t.indexOf(v)<0).concat(c),_=f.filter(v=>e.indexOf(v)<0).concat(p);h.putSticky(r,"classes",v=>(v.classList.remove(..._),v.classList.add(...E),[E,_]))})},setOrRemoveAttrs(r,e,t){let[i,s]=h.getSticky(r,"attrs",[[],[]]),n=e.map(([l,d])=>l).concat(t),o=i.filter(([l,d])=>!n.includes(l)).concat(e),a=s.filter(l=>!n.includes(l)).concat(t);h.putSticky(r,"attrs",l=>(a.forEach(d=>l.removeAttribute(d)),o.forEach(([d,f])=>l.setAttribute(d,f)),[o,a]))},hasAllClasses(r,e){return e.every(t=>r.classList.contains(t))},isToggledOut(r,e){return!this.isVisible(r)||this.hasAllClasses(r,e)},filterToEls(r,{to:e}){return e?h.all(document,e):[r]}},H=_i;var We=(r,e,t=[])=>{let i=new FormData(r),s=[];i.forEach((o,a,l)=>{o instanceof File&&s.push(a)}),s.forEach(o=>i.delete(o));let n=new URLSearchParams;for(let[o,a]of i.entries())(t.length===0||t.indexOf(o)>=0)&&n.append(o,a);for(let o in e)n.append(o,e[o]);return n.toString()},pe=class{constructor(e,t,i,s,n){this.isDead=!1,this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pruningCIDs=[],this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.uploaders={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>({redirect:this.redirect?this.href:void 0,url:this.redirect?void 0:this.href||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}))}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.getAttribute(le)!==null}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(Pt)}]`).map(s=>s.src||s.href).filter(s=>typeof s=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._live_referer=e,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(D)}getStatic(){let e=this.el.getAttribute(Y);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(tt,Re,rt),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(Re)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(tt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,i=>t(i,e));if($(e))h.findComponentNodeList(this.el,e).length===0?P(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let i=Array.from(document.querySelectorAll(e));i.length===0&&P(`nothing found matching the phx-target selector "${e}"`),i.forEach(s=>this.liveSocket.owner(s,n=>t(n,s)))}}applyDiff(e,t,i){this.log(e,()=>["",ue(t)]);let{diff:s,reply:n,events:o,title:a}=we.extract(t);a&&h.putTitle(a),i({diff:s,reply:n,events:o})}onJoin(e){let{rendered:t,container:i}=e;if(i){let[s,n]=i;this.el=h.replaceRootContainer(this.el,s,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,O.dropLocal(this.liveSocket.localStorage,window.location.pathname,ke),this.applyDiff("mount",t,({diff:s,events:n})=>{this.rendered=new we(this.id,s);let o=this.renderContainer(null,"join");this.dropPendingRefs();let a=this.formsForRecovery(o);this.joinCount++,a.length>0?a.forEach(([l,d,f],c)=>{this.pushFormRecovery(l,f,p=>{c===a.length-1&&this.onJoinComplete(p,o,n)})}):this.onJoinComplete(e,o,n)})}dropPendingRefs(){h.all(document,`[${j}="${this.id}"][${L}]`,e=>{e.removeAttribute(L),e.removeAttribute(j)})}onJoinComplete({live_patch:e},t,i){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i);h.findPhxChildrenInFragment(t,this.id).filter(n=>{let o=n.id&&this.el.querySelector(`[id="${n.id}"]`),a=o&&o.getAttribute(Y);return a&&n.setAttribute(Y,a),this.joinChild(n)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(K,this.root.id)}execNewMounted(){h.all(this.el,`[${this.binding(he)}], [data-phx-${he}]`,e=>{this.maybeAddNewHook(e)}),h.all(this.el,`[${this.binding(ot)}]`,e=>this.maybeMounted(e))}applyJoinPatch(e,t,i){this.attachTrueDocEl();let s=new re(this,this.el,this.id,t,null);if(s.markPrunableContentForRemoval(),this.performPatch(s,!1),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(i),this.applyPendingUpdates(),e){let{kind:n,to:o}=e;this.liveSocket.historyPatch(o,n)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),s=i&&h.isIgnored(e,this.binding(Se));if(i&&!e.isEqualNode(t)&&!(s&&$t(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(ot)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e,t){let i=this.addHook(e);i&&i.__mounted()}performPatch(e,t){let i=[],s=!1,n=new Set;return e.after("added",o=>{this.liveSocket.triggerDOM("onNodeAdded",[o]),this.maybeAddNewHook(o),o.getAttribute&&this.maybeMounted(o)}),e.after("phxChildAdded",o=>{h.isPhxSticky(o)?this.liveSocket.joinRootViews():s=!0}),e.before("updated",(o,a)=>{this.triggerBeforeUpdateHook(o,a)&&n.add(o.id)}),e.after("updated",o=>{n.has(o.id)&&this.getHook(o).__updated()}),e.after("discarded",o=>{o.nodeType===Node.ELEMENT_NODE&&i.push(o)}),e.after("transitionsDiscarded",o=>this.afterElementsRemoved(o,t)),e.perform(),this.afterElementsRemoved(i,t),s}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let n=h.all(s,`[${x}]`),o=h.all(s,`[${this.binding(he)}]`);n.concat(s).forEach(a=>{let l=this.componentID(a);$(l)&&i.indexOf(l)===-1&&i.push(l)}),o.concat(s).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(W)][e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new pe(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):ct(e)||this.liveSocket.time("full patch complete",()=>{let s=this.renderContainer(e,"update"),n=new re(this,this.el,this.id,s,null);i=this.performPatch(n,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,s=e?this.rendered.componentCIDs(e).concat(this.pruningCIDs):null,n=this.rendered.toString(s);return`<${i}>${n}</${i}>`})}componentPatch(e,t){if(ct(e))return!1;let i=this.rendered.componentToString(t),s=new re(this,this.el,this.id,i,t);return this.performPatch(s,!0)}getHook(e){return this.viewHooks[Z.elementID(e)]}addHook(e){if(Z.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${he}`)||e.getAttribute(this.binding(he));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||P(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let s=new Z(this,e,i);return this.viewHooks[Z.elementID(s.el)]=s,s}else t!==null&&P(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[Z.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[]}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(){for(let e in this.root.children[this.id])this.getChildById(e).destroy()}onLiveRedirect(e){let{to:t,kind:i,flash:s}=e,n=this.expandURL(t);this.liveSocket.historyRedirect(n,i,s)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t}){this.liveSocket.redirect(e,t)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",t=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(t))}).receive("error",t=>!this.isDestroyed()&&this.onJoinError(t)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){if(e.reason==="unauthorized"||e.reason==="stale")return this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.href});if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);this.log("error",()=>["unable to join",e]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this)}onClose(e){if(!this.isDestroyed()){if(this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(Ot)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||this.displayError()}displayError(){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(Re,rt),this.execAll(this.binding("disconnected"))}pushWithReply(e,t,i,s=function(){}){if(!this.isConnected())return;let[n,[o],a]=e?e():[null,[],{}],l=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(et))!==null)&&(l=this.liveSocket.withPageLoading({kind:"element",target:o})),typeof i.cid!="number"&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(t,i,Nt).receive("ok",d=>{let f=c=>{d.redirect&&this.onRedirect(d.redirect),d.live_patch&&this.onLivePatch(d.live_patch),d.live_redirect&&this.onLiveRedirect(d.live_redirect),n!==null&&this.undoRefs(n),l(),s(d,c)};d.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",d.diff,({diff:c,reply:p,events:E})=>{this.update(c,E),f(p)})}):f(null)}))}undoRefs(e){!this.isConnected()||h.all(document,`[${j}="${this.id}"][${L}="${e}"]`,t=>{let i=t.getAttribute(be);t.removeAttribute(L),t.removeAttribute(j),t.getAttribute(Fe)!==null&&(t.readOnly=!1,t.removeAttribute(Fe)),i!==null&&(t.disabled=i==="true",t.removeAttribute(be)),Ie.forEach(o=>h.removeClass(t,o));let s=t.getAttribute(_e);s!==null&&(t.innerText=s,t.removeAttribute(_e));let n=h.private(t,L);if(n){let o=this.triggerBeforeUpdateHook(t,n);re.patchEl(t,n,this.liveSocket.getActiveElement()),o&&o.__updated(),h.deletePrivate(t,L)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(Ee);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(o=>{o.classList.add(`phx-${t}-loading`),o.setAttribute(L,s),o.setAttribute(j,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(_e)||o.setAttribute(_e,o.innerText),a!==""&&(o.innerText=a),o.setAttribute("disabled",""))}),[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(x);return t?parseInt(t):null}targetComponentID(e,t,i={}){if($(t))return t;let s=e.getAttribute(this.binding("target"));return $(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return $(e)?e:e?R(e.closest(`[${x}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",t,i]),!1;let[n,o,a]=this.putRef([],"hook");return this.pushWithReply(()=>[n,o,a],"event",{type:"hook",event:t,value:i,cid:this.closestComponentID(e)},(l,d)=>s(d,n)),n}extractMeta(e,t,i){let s=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(s)&&(t[o.replace(s,"")]=e.getAttribute(o))}if(e.value!==void 0&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&He.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,s,n,o={}){this.pushWithReply(()=>this.putRef([t],e,o),"event",{type:e,event:s,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)})}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(Dt)),ref:e.getAttribute(M),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)},s)})}pushInput(e,t,i,s,n,o){let a,l=$(i)?i:this.targetComponentID(e.form,t),d=()=>this.putRef([e,e.form],"change",n),f;e.getAttribute(this.binding("change"))?f=We(e.form,{_target:n._target},[e.name]):f=We(e.form,{_target:n._target}),h.isUploadInput(e)&&e.files&&e.files.length>0&&y.trackFiles(e,Array.from(e.files)),a=y.serializeUploads(e);let c={type:"form",event:s,value:f,uploads:a,cid:l};this.pushWithReply(d,"event",c,p=>{if(h.showError(e,this.liveSocket.binding(ve)),h.isUploadInput(e)&&e.getAttribute("data-phx-auto-upload")!==null){if(y.filesAwaitingPreflight(e).length>0){let[E,_]=d();this.uploadFiles(e.form,t,E,l,v=>{o&&o(p),this.triggerAwaitingSubmit(e.form)})}}else o&&o(p)})}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,s,n,o]=t;this.cancelSubmit(e),o()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,s,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,s){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,s])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([t,i,s])=>t.isSameNode(e)?(this.undoRefs(i),!1):!0)}disableForm(e,t={}){let i=c=>!(te(c,`${this.binding(Se)}=ignore`,c.form)||te(c,"data-phx-update=ignore",c.form)),s=c=>c.hasAttribute(this.binding(Ee)),n=c=>c.tagName=="BUTTON",o=c=>["INPUT","TEXTAREA","SELECT"].includes(c.tagName),a=Array.from(e.elements),l=a.filter(s),d=a.filter(n).filter(i),f=a.filter(o).filter(i);return d.forEach(c=>{c.setAttribute(be,c.disabled),c.disabled=!0}),f.forEach(c=>{c.setAttribute(Fe,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(be,c.disabled),c.disabled=!0)}),e.setAttribute(this.binding(et),""),this.putRef([e].concat(l).concat(d).concat(f),"submit",t)}pushFormSubmit(e,t,i,s,n){let o=()=>this.disableForm(e,s),a=this.targetComponentID(e,t);if(y.hasUploadsInProgress(e)){let[l,d]=o(),f=()=>this.pushFormSubmit(e,t,i,s,n);return this.scheduleSubmit(e,l,s,f)}else if(y.inputsAwaitingPreflight(e).length>0){let[l,d]=o(),f=()=>[l,d,s];this.uploadFiles(e,t,l,a,c=>{let p=We(e,{});this.pushWithReply(f,"event",{type:"form",event:i,value:p,cid:a},n)})}else{let l=We(e,{});this.pushWithReply(o,"event",{type:"form",event:i,value:l,cid:a},n)}}uploadFiles(e,t,i,s,n){let o=this.joinCount,a=y.activeFileInputs(e),l=a.length;a.forEach(d=>{let f=new y(d,this,()=>{l--,l===0&&n()});this.uploaders[d]=f;let c=f.entries().map(E=>E.toPreflightPayload()),p={ref:d.getAttribute(M),entries:c,cid:this.targetComponentID(d.form,t)};this.log("upload",()=>["sending preflight request",p]),this.pushWithReply(null,"allow_upload",p,E=>{if(this.log("upload",()=>["got preflight response",E]),E.error){this.undoRefs(i);let[_,v]=E.error;this.log("upload",()=>[`error for entry ${_}`,v])}else{let _=v=>{this.channel.onError(()=>{this.joinCount===o&&v()})};f.initAdapterUpload(E,_,this.liveSocket)}})})}dispatchUploads(e,t){let i=h.findUploadInputs(this.el).filter(s=>s.name===e);i.length===0?P(`no live file inputs found matching the name "${e}"`):i.length>1?P(`duplicate live file inputs found matching the name "${e}"`):h.dispatchEvent(i[0],De,{detail:{files:t}})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(s,n)=>{let o=e.elements[0],a=e.getAttribute(this.binding(nt))||e.getAttribute(this.binding("change"));H.exec("change",a,s,o,["push",{_target:o.name,newCid:t,callback:i}])})}pushLinkPatch(e,t,i){let s=this.liveSocket.setPendingLink(e),n=t?()=>this.putRef([t],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=this.pushWithReply(n,"live_patch",{url:e},l=>{this.liveSocket.requestDOMUpdate(()=>{l.link_redirect?this.liveSocket.replaceMain(e,null,i,s):(this.liveSocket.commitPendingLink(s)&&(this.href=e),this.applyPendingUpdates(),i&&i(s))})});a?a.receive("timeout",o):o()}formsForRecovery(e){if(this.joinCount===0)return[];let t=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,h.all(this.el,`form[${t}]`).filter(s=>s.id&&this.ownsElement(s)).filter(s=>s.elements.length>0).filter(s=>s.getAttribute(this.binding(nt))!=="ignore").map(s=>{let n=i.content.querySelector(`form[id="${s.id}"][${t}="${s.getAttribute(t)}"]`);return n?[s,n,this.targetComponentID(n)]:[s,null,null]}).filter(([s,n,o])=>n)}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(this.pruningCIDs.push(...t),this.pushWithReply(null,"cids_will_destroy",{cids:t},()=>{this.pruningCIDs=this.pruningCIDs.filter(s=>t.indexOf(s)!==-1);let i=t.filter(s=>h.findComponentNodeList(this.el,s).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i},s=>{this.rendered.pruneCIDs(s.cids)})}))}ownsElement(e){return this.isDead||e.getAttribute(W)===this.id||R(e.closest(J),t=>t.id)===this.id}submitForm(e,t,i,s={}){h.putPrivate(e,Ne,!0);let n=this.liveSocket.binding(ve),o=Array.from(e.elements);this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,()=>{o.forEach(a=>h.showError(a,n)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var Ke=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
|
|
11
|
+
`,n.innerHTML.trim()),this.createSpan("",t).outerHTML):(!l&&d&&P("expected at least one HTML element tag directly inside a component, but only subcomponents were found. A component must render at least one HTML tag directly inside itself.",n.innerHTML.trim()),n.innerHTML)}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(x,t),i}};var Ei=1,Z=class{static makeID(){return Ei++}static elementID(e){return e.phxHookId}constructor(e,t,i){this.__view=e,this.liveSocket=e.liveSocket,this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,this.el=t,this.el.phxHookId=this.constructor.makeID();for(let s in this.__callbacks)this[s]=this.__callbacks[s]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,t={},i=function(){}){return this.__view.pushHookEvent(null,e,t,i)}pushEventTo(e,t,i={},s=function(){}){return this.__view.withinTargets(e,(n,o)=>n.pushHookEvent(o,t,i,s))}handleEvent(e,t){let i=(s,n)=>n?e:t(s.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view.dispatchUploads(e,t)}uploadTo(e,t,i){return this.__view.withinTargets(e,s=>s.dispatchUploads(t,i))}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var je=null,_i={exec(r,e,t,i,s){let[n,o]=s||[null,{}];(e.charAt(0)==="["?JSON.parse(e):[[n,o]]).forEach(([l,d])=>{l===n&&o.data&&(d.data=Object.assign(d.data||{},o.data)),this.filterToEls(i,d).forEach(f=>{this[`exec_${l}`](r,e,t,i,f,d)})})},isVisible(r){return!!(r.offsetWidth||r.offsetHeight||r.getClientRects().length>0)},exec_dispatch(r,e,t,i,s,{to:n,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=i,h.dispatchEvent(s,o,{detail:a,bubbles:l})},exec_push(r,e,t,i,s,n){if(!t.isConnected())return;let{event:o,data:a,target:l,page_loading:d,loading:f,value:c,dispatcher:p}=n,E={loading:f,value:c,target:l,page_loading:!!d},_=r==="change"&&p?p:i,v=l||_.getAttribute(t.binding("target"))||_;t.withinTargets(v,(w,T)=>{if(r==="change"){let{newCid:V,_target:H,callback:u}=n;H=H||(h.isFormInput(i)?i.name:void 0),H&&(E._target=H),w.pushInput(i,T,V,o||e,E,u)}else r==="submit"?w.submitForm(i,T,o||e,E):w.pushEvent(r,i,T,o||e,a,E)})},exec_navigate(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.historyRedirect(n,o?"replace":"push")},exec_patch(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.pushHistoryPatch(n,o?"replace":"push",i)},exec_focus(r,e,t,i,s){window.requestAnimationFrame(()=>Q.attemptFocus(s))},exec_focus_first(r,e,t,i,s){window.requestAnimationFrame(()=>Q.focusFirstInteractive(s)||Q.focusFirst(s))},exec_push_focus(r,e,t,i,s){window.requestAnimationFrame(()=>je=s||i)},exec_pop_focus(r,e,t,i,s){window.requestAnimationFrame(()=>{je&&je.focus(),je=null})},exec_add_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,n,[],o,a,t)},exec_remove_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,[],n,o,a,t)},exec_transition(r,e,t,i,s,{time:n,transition:o}){let[a,l,d]=o,f=()=>this.addOrRemoveClasses(s,a.concat(l),[]),c=()=>this.addOrRemoveClasses(s,d,a.concat(l));t.transition(n,f,c)},exec_toggle(r,e,t,i,s,{display:n,ins:o,outs:a,time:l}){this.toggle(r,t,s,n,o,a,l)},exec_show(r,e,t,i,s,{display:n,transition:o,time:a}){this.show(r,t,s,n,o,a)},exec_hide(r,e,t,i,s,{display:n,transition:o,time:a}){this.hide(r,t,s,n,o,a)},exec_set_attr(r,e,t,i,s,{attr:[n,o]}){this.setOrRemoveAttrs(s,[[n,o]],[])},exec_remove_attr(r,e,t,i,s,{attr:n}){this.setOrRemoveAttrs(s,[],[n])},show(r,e,t,i,s,n){this.isVisible(t)||this.toggle(r,e,t,i,s,null,n)},hide(r,e,t,i,s,n){this.isVisible(t)&&this.toggle(r,e,t,i,null,s,n)},toggle(r,e,t,i,s,n,o){let[a,l,d]=s||[[],[],[]],[f,c,p]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(t)){let E=()=>{this.addOrRemoveClasses(t,c,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,p,c))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,E,()=>{this.addOrRemoveClasses(t,[],f.concat(p)),h.putSticky(t,"toggle",_=>_.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(r==="remove")return;let E=()=>{this.addOrRemoveClasses(t,l,f.concat(c).concat(p)),h.putSticky(t,"toggle",_=>_.style.display=i||"block"),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,d,l))})};t.dispatchEvent(new Event("phx:show-start")),e.transition(o,E,()=>{this.addOrRemoveClasses(t,[],a.concat(d)),t.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",E=>E.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start")),h.putSticky(t,"toggle",E=>E.style.display=i||"block"),t.dispatchEvent(new Event("phx:show-end"))})},addOrRemoveClasses(r,e,t,i,s,n){let[o,a,l]=i||[[],[],[]];if(o.length>0){let d=()=>this.addOrRemoveClasses(r,a.concat(o),[]),f=()=>this.addOrRemoveClasses(r,e.concat(l),t.concat(o).concat(a));return n.transition(s,d,f)}window.requestAnimationFrame(()=>{let[d,f]=h.getSticky(r,"classes",[[],[]]),c=e.filter(v=>d.indexOf(v)<0&&!r.classList.contains(v)),p=t.filter(v=>f.indexOf(v)<0&&r.classList.contains(v)),E=d.filter(v=>t.indexOf(v)<0).concat(c),_=f.filter(v=>e.indexOf(v)<0).concat(p);h.putSticky(r,"classes",v=>(v.classList.remove(..._),v.classList.add(...E),[E,_]))})},setOrRemoveAttrs(r,e,t){let[i,s]=h.getSticky(r,"attrs",[[],[]]),n=e.map(([l,d])=>l).concat(t),o=i.filter(([l,d])=>!n.includes(l)).concat(e),a=s.filter(l=>!n.includes(l)).concat(t);h.putSticky(r,"attrs",l=>(a.forEach(d=>l.removeAttribute(d)),o.forEach(([d,f])=>l.setAttribute(d,f)),[o,a]))},hasAllClasses(r,e){return e.every(t=>r.classList.contains(t))},isToggledOut(r,e){return!this.isVisible(r)||this.hasAllClasses(r,e)},filterToEls(r,{to:e}){return e?h.all(document,e):[r]}},O=_i;var We=(r,e,t=[])=>{let i=new FormData(r),s=[];i.forEach((o,a,l)=>{o instanceof File&&s.push(a)}),s.forEach(o=>i.delete(o));let n=new URLSearchParams;for(let[o,a]of i.entries())(t.length===0||t.indexOf(o)>=0)&&n.append(o,a);for(let o in e)n.append(o,e[o]);return n.toString()},pe=class{constructor(e,t,i,s,n){this.isDead=!1,this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pruningCIDs=[],this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.uploaders={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>({redirect:this.redirect?this.href:void 0,url:this.redirect?void 0:this.href||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}))}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(le)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(Pt)}]`).map(s=>s.src||s.href).filter(s=>typeof s=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._live_referer=e,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(D)}getStatic(){let e=this.el.getAttribute(Y);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(tt,Oe,rt),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(Oe)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(tt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,i=>t(i,e));if(X(e))h.findComponentNodeList(this.el,e).length===0?P(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let i=Array.from(document.querySelectorAll(e));i.length===0&&P(`nothing found matching the phx-target selector "${e}"`),i.forEach(s=>this.liveSocket.owner(s,n=>t(n,s)))}}applyDiff(e,t,i){this.log(e,()=>["",ue(t)]);let{diff:s,reply:n,events:o,title:a}=xe.extract(t);i({diff:s,reply:n,events:o}),a&&window.requestAnimationFrame(()=>h.putTitle(a))}onJoin(e){let{rendered:t,container:i}=e;if(i){let[s,n]=i;this.el=h.replaceRootContainer(this.el,s,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,R.dropLocal(this.liveSocket.localStorage,window.location.pathname,Ie),this.applyDiff("mount",t,({diff:s,events:n})=>{this.rendered=new xe(this.id,s);let o=this.renderContainer(null,"join");this.dropPendingRefs();let a=this.formsForRecovery(o);this.joinCount++,a.length>0?a.forEach(([l,d,f],c)=>{this.pushFormRecovery(l,f,p=>{c===a.length-1&&this.onJoinComplete(p,o,n)})}):this.onJoinComplete(e,o,n)})}dropPendingRefs(){h.all(document,`[${j}="${this.id}"][${L}]`,e=>{e.removeAttribute(L),e.removeAttribute(j)})}onJoinComplete({live_patch:e},t,i){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i);h.findPhxChildrenInFragment(t,this.id).filter(n=>{let o=n.id&&this.el.querySelector(`[id="${n.id}"]`),a=o&&o.getAttribute(Y);return a&&n.setAttribute(Y,a),this.joinChild(n)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(q,this.root.id)}execNewMounted(){h.all(this.el,`[${this.binding(he)}], [data-phx-${he}]`,e=>{this.maybeAddNewHook(e)}),h.all(this.el,`[${this.binding(ot)}]`,e=>this.maybeMounted(e))}applyJoinPatch(e,t,i){this.attachTrueDocEl();let s=new re(this,this.el,this.id,t,null);if(s.markPrunableContentForRemoval(),this.performPatch(s,!1),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(i),this.applyPendingUpdates(),e){let{kind:n,to:o}=e;this.liveSocket.historyPatch(o,n)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),s=i&&h.isIgnored(e,this.binding(Se));if(i&&!e.isEqualNode(t)&&!(s&&$t(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(ot)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e,t){let i=this.addHook(e);i&&i.__mounted()}performPatch(e,t){let i=[],s=!1,n=new Set;return e.after("added",o=>{this.liveSocket.triggerDOM("onNodeAdded",[o]),this.maybeAddNewHook(o),o.getAttribute&&this.maybeMounted(o)}),e.after("phxChildAdded",o=>{h.isPhxSticky(o)?this.liveSocket.joinRootViews():s=!0}),e.before("updated",(o,a)=>{this.triggerBeforeUpdateHook(o,a)&&n.add(o.id)}),e.after("updated",o=>{n.has(o.id)&&this.getHook(o).__updated()}),e.after("discarded",o=>{o.nodeType===Node.ELEMENT_NODE&&i.push(o)}),e.after("transitionsDiscarded",o=>this.afterElementsRemoved(o,t)),e.perform(),this.afterElementsRemoved(i,t),s}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let n=h.all(s,`[${x}]`),o=h.all(s,`[${this.binding(he)}]`);n.concat(s).forEach(a=>{let l=this.componentID(a);X(l)&&i.indexOf(l)===-1&&i.push(l)}),o.concat(s).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(W)][e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new pe(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):ct(e)||this.liveSocket.time("full patch complete",()=>{let s=this.renderContainer(e,"update"),n=new re(this,this.el,this.id,s,null);i=this.performPatch(n,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,s=e?this.rendered.componentCIDs(e).concat(this.pruningCIDs):null,n=this.rendered.toString(s);return`<${i}>${n}</${i}>`})}componentPatch(e,t){if(ct(e))return!1;let i=this.rendered.componentToString(t),s=new re(this,this.el,this.id,i,t);return this.performPatch(s,!0)}getHook(e){return this.viewHooks[Z.elementID(e)]}addHook(e){if(Z.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${he}`)||e.getAttribute(this.binding(he));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||P(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let s=new Z(this,e,i);return this.viewHooks[Z.elementID(s.el)]=s,s}else t!==null&&P(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[Z.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){let{to:t,kind:i,flash:s}=e,n=this.expandURL(t);this.liveSocket.historyRedirect(n,i,s)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t}){this.liveSocket.redirect(e,t)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",t=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(t))}).receive("error",t=>!this.isDestroyed()&&this.onJoinError(t)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){if(e.reason==="unauthorized"||e.reason==="stale")return this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.href});if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);this.log("error",()=>["unable to join",e]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this)}onClose(e){if(!this.isDestroyed()){if(this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(Ot)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||this.displayError()}displayError(){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(Oe,rt),this.execAll(this.binding("disconnected"))}pushWithReply(e,t,i,s=function(){}){if(!this.isConnected())return;let[n,[o],a]=e?e():[null,[],{}],l=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(et))!==null)&&(l=this.liveSocket.withPageLoading({kind:"element",target:o})),typeof i.cid!="number"&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(t,i,Nt).receive("ok",d=>{let f=c=>{d.redirect&&this.onRedirect(d.redirect),d.live_patch&&this.onLivePatch(d.live_patch),d.live_redirect&&this.onLiveRedirect(d.live_redirect),n!==null&&this.undoRefs(n),l(),s(d,c)};d.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",d.diff,({diff:c,reply:p,events:E})=>{this.update(c,E),f(p)})}):f(null)}))}undoRefs(e){!this.isConnected()||h.all(document,`[${j}="${this.id}"][${L}="${e}"]`,t=>{let i=t.getAttribute(Ee);t.removeAttribute(L),t.removeAttribute(j),t.getAttribute(Fe)!==null&&(t.readOnly=!1,t.removeAttribute(Fe)),i!==null&&(t.disabled=i==="true",t.removeAttribute(Ee)),Le.forEach(o=>h.removeClass(t,o));let s=t.getAttribute(Ae);s!==null&&(t.innerText=s,t.removeAttribute(Ae));let n=h.private(t,L);if(n){let o=this.triggerBeforeUpdateHook(t,n);re.patchEl(t,n,this.liveSocket.getActiveElement()),o&&o.__updated(),h.deletePrivate(t,L)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(_e);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(o=>{o.classList.add(`phx-${t}-loading`),o.setAttribute(L,s),o.setAttribute(j,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(Ae)||o.setAttribute(Ae,o.innerText),a!==""&&(o.innerText=a),o.setAttribute("disabled",""))}),[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(x);return t?parseInt(t):null}targetComponentID(e,t,i={}){if(X(t))return t;let s=e.getAttribute(this.binding("target"));return X(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return X(e)?e:e?$(e.closest(`[${x}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",t,i]),!1;let[n,o,a]=this.putRef([],"hook");return this.pushWithReply(()=>[n,o,a],"event",{type:"hook",event:t,value:i,cid:this.closestComponentID(e)},(l,d)=>s(d,n)),n}extractMeta(e,t,i){let s=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(s)&&(t[o.replace(s,"")]=e.getAttribute(o))}if(e.value!==void 0&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&Ne.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,s,n,o={}){this.pushWithReply(()=>this.putRef([t],e,o),"event",{type:e,event:s,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)})}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(Dt)),ref:e.getAttribute(F),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)},s)})}pushInput(e,t,i,s,n,o){let a,l=X(i)?i:this.targetComponentID(e.form,t),d=()=>this.putRef([e,e.form],"change",n),f;e.getAttribute(this.binding("change"))?f=We(e.form,{_target:n._target},[e.name]):f=We(e.form,{_target:n._target}),h.isUploadInput(e)&&e.files&&e.files.length>0&&y.trackFiles(e,Array.from(e.files)),a=y.serializeUploads(e);let c={type:"form",event:s,value:f,uploads:a,cid:l};this.pushWithReply(d,"event",c,p=>{if(h.showError(e,this.liveSocket.binding(ve)),h.isUploadInput(e)&&e.getAttribute("data-phx-auto-upload")!==null){if(y.filesAwaitingPreflight(e).length>0){let[E,_]=d();this.uploadFiles(e.form,t,E,l,v=>{o&&o(p),this.triggerAwaitingSubmit(e.form)})}}else o&&o(p)})}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,s,n,o]=t;this.cancelSubmit(e),o()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,s,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,s){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,s])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([t,i,s])=>t.isSameNode(e)?(this.undoRefs(i),!1):!0)}disableForm(e,t={}){let i=c=>!(te(c,`${this.binding(Se)}=ignore`,c.form)||te(c,"data-phx-update=ignore",c.form)),s=c=>c.hasAttribute(this.binding(_e)),n=c=>c.tagName=="BUTTON",o=c=>["INPUT","TEXTAREA","SELECT"].includes(c.tagName),a=Array.from(e.elements),l=a.filter(s),d=a.filter(n).filter(i),f=a.filter(o).filter(i);return d.forEach(c=>{c.setAttribute(Ee,c.disabled),c.disabled=!0}),f.forEach(c=>{c.setAttribute(Fe,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(Ee,c.disabled),c.disabled=!0)}),e.setAttribute(this.binding(et),""),this.putRef([e].concat(l).concat(d).concat(f),"submit",t)}pushFormSubmit(e,t,i,s,n){let o=()=>this.disableForm(e,s),a=this.targetComponentID(e,t);if(y.hasUploadsInProgress(e)){let[l,d]=o(),f=()=>this.pushFormSubmit(e,t,i,s,n);return this.scheduleSubmit(e,l,s,f)}else if(y.inputsAwaitingPreflight(e).length>0){let[l,d]=o(),f=()=>[l,d,s];this.uploadFiles(e,t,l,a,c=>{let p=We(e,{});this.pushWithReply(f,"event",{type:"form",event:i,value:p,cid:a},n)})}else{let l=We(e,{});this.pushWithReply(o,"event",{type:"form",event:i,value:l,cid:a},n)}}uploadFiles(e,t,i,s,n){let o=this.joinCount,a=y.activeFileInputs(e),l=a.length;a.forEach(d=>{let f=new y(d,this,()=>{l--,l===0&&n()});this.uploaders[d]=f;let c=f.entries().map(E=>E.toPreflightPayload()),p={ref:d.getAttribute(F),entries:c,cid:this.targetComponentID(d.form,t)};this.log("upload",()=>["sending preflight request",p]),this.pushWithReply(null,"allow_upload",p,E=>{if(this.log("upload",()=>["got preflight response",E]),E.error){this.undoRefs(i);let[_,v]=E.error;this.log("upload",()=>[`error for entry ${_}`,v])}else{let _=v=>{this.channel.onError(()=>{this.joinCount===o&&v()})};f.initAdapterUpload(E,_,this.liveSocket)}})})}dispatchUploads(e,t){let i=h.findUploadInputs(this.el).filter(s=>s.name===e);i.length===0?P(`no live file inputs found matching the name "${e}"`):i.length>1?P(`duplicate live file inputs found matching the name "${e}"`):h.dispatchEvent(i[0],Re,{detail:{files:t}})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(s,n)=>{let o=e.elements[0],a=e.getAttribute(this.binding(nt))||e.getAttribute(this.binding("change"));O.exec("change",a,s,o,["push",{_target:o.name,newCid:t,callback:i}])})}pushLinkPatch(e,t,i){let s=this.liveSocket.setPendingLink(e),n=t?()=>this.putRef([t],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=this.pushWithReply(n,"live_patch",{url:e},l=>{this.liveSocket.requestDOMUpdate(()=>{l.link_redirect?this.liveSocket.replaceMain(e,null,i,s):(this.liveSocket.commitPendingLink(s)&&(this.href=e),this.applyPendingUpdates(),i&&i(s))})});a?a.receive("timeout",o):o()}formsForRecovery(e){if(this.joinCount===0)return[];let t=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,h.all(this.el,`form[${t}]`).filter(s=>s.id&&this.ownsElement(s)).filter(s=>s.elements.length>0).filter(s=>s.getAttribute(this.binding(nt))!=="ignore").map(s=>{let n=i.content.querySelector(`form[id="${s.id}"][${t}="${s.getAttribute(t)}"]`);return n?[s,n,this.targetComponentID(n)]:[s,null,null]}).filter(([s,n,o])=>n)}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(this.pruningCIDs.push(...t),this.pushWithReply(null,"cids_will_destroy",{cids:t},()=>{this.pruningCIDs=this.pruningCIDs.filter(s=>t.indexOf(s)!==-1);let i=t.filter(s=>h.findComponentNodeList(this.el,s).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i},s=>{this.rendered.pruneCIDs(s.cids)})}))}ownsElement(e){let t=e.closest(J);return e.getAttribute(W)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,s={}){h.putPrivate(e,be,!0);let n=this.liveSocket.binding(ve),o=Array.from(e.elements);o.forEach(a=>h.putPrivate(a,be,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,()=>{o.forEach(a=>h.showError(a,n)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var qe=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
|
|
12
12
|
a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:
|
|
13
13
|
|
|
14
14
|
import {Socket} from "phoenix"
|
|
15
15
|
import {LiveSocket} from "phoenix_live_view"
|
|
16
16
|
let liveSocket = new LiveSocket("/live", Socket, {...})
|
|
17
|
-
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Ht,this.opts=i,this.params=$e(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(ue(Ft),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=ue(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Rt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||_t,this.reloadJitterMin=i.reloadJitterMin||St,this.reloadJitterMax=i.reloadJitterMax||At,this.failsafeJitter=i.failsafeJitter||yt,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:$e(),onBeforeElUpdated:$e()},i.dom||{}),this.transitions=new Gt,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(Me)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Ae)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Ae)==="false"}enableDebug(){this.sessionStorage.setItem(Ae,"true")}enableProfiling(){this.sessionStorage.setItem(Me,"true")}disableDebug(){this.sessionStorage.setItem(Ae,"false")}disableProfiling(){this.sessionStorage.removeItem(Me)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(Ue,e)}disableLatencySim(){this.sessionStorage.removeItem(Ue)}getLatencySim(){let e=this.sessionStorage.getItem(Ue);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){this.owner(e,s=>H.exec(i,t,s,e))}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[s,n]=i();this.viewLogger(e,t,s,n)}else if(this.isDebugEnabled()){let[s,n]=i();Xt(e,t,s,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}wrapPush(e,t,i){let s=this.getLatencySim(),n=e.joinCount;if(!s)return this.isConnected()&&t.timeout?i().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):i();let o={receives:[],receive(a,l){this.receives.push([a,l])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[l,d])=>a.receive(l,d),i())},s),o}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,o=O.updateLocal(this.localStorage,window.location.pathname,ke,0,a=>a+1);o>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?Jt[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(){this.bindTopLevelEvents({dead:!0});let e=this.newRootView(document.body);e.setHref(this.getHref()),e.joinDead(),this.main=e,window.requestAnimationFrame(()=>e.execNewMounted())}joinRootViews(){let e=!1;return h.all(document,`${J}:not([${W}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.getAttribute(le)&&(this.main=i)}e=!0}),e}redirect(e,t){this.disconnect(),O.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(o,t,n),this.main.setRedirect(e),this.transitionRemoves(),this.main.join((a,l)=>{a===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{h.findPhxSticky(document).forEach(d=>o.appendChild(d)),this.outgoingMainEl.replaceWith(o),this.outgoingMainEl=null,i&&requestAnimationFrame(i),l()})})}transitionRemoves(e){let t=this.binding("remove");e=e||h.all(document,`[${t}]`),e.forEach(i=>{document.body.contains(i)&&this.execJS(i,i.getAttribute(t),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(D)!==null}newRootView(e,t,i){let s=new pe(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=R(e.closest(J),s=>this.getViewByEl(s))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(K);return R(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(K));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let t=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",t),e.addEventListener("touchend",t)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.socket.onClose(t=>{t&&t.code===1e3&&this.main&&this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,s,n,o,a)=>{let l=n.getAttribute(this.binding(Lt)),d=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==d)return;let f=ne({key:t.key},this.eventMeta(i,t,n));H.exec(i,o,s,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,n,o,a)=>{if(!a){let l=ne({key:t.key},this.eventMeta(i,t,n));H.exec(i,o,s,n,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,n,o,a,l)=>{if(l==="window"){let d=this.eventMeta(i,t,n);H.exec(i,a,s,n,["push",{data:d}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=R(te(t.target,this.binding(Qe)),o=>o.getAttribute(this.binding(Qe))),s=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!s||s.disabled||n.length===0||!(s.files instanceof FileList)||(y.trackFiles(s,n),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(De,t=>{let i=t.target;if(!h.isUploadInput(i))return;let s=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);y.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let s=this.metadataCallbacks[e];return s?s(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.linkRef}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let s=e[i];this.on(s,n=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=n.target.getAttribute&&n.target.getAttribute(o);l?this.debounce(n.target,n,s,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,l,null)})}):h.all(document,`[${a}]`,d=>{let f=d.getAttribute(a);this.debounce(d,n,s,()=>{this.withinOwners(d,c=>{t(n,i,c,d,f,"window")})})})})}}bindClicks(){window.addEventListener("click",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let s=this.binding(t);window.addEventListener(e,n=>{let o=null;if(i)o=n.target.matches(`[${s}]`)?n.target:n.target.querySelector(`[${s}]`);else{let l=this.clickStartedAtTarget||n.target;o=te(l,s),this.dispatchClickAway(n,l),this.clickStartedAtTarget=null}let a=o&&o.getAttribute(s);!a||(o.getAttribute("href")==="#"&&n.preventDefault(),this.debounce(o,n,"click",()=>{this.withinOwners(o,l=>{H.exec("click",a,l,o,["push",{data:this.eventMeta("click",n,o)}])})}))},i)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(e.target,n=>{let o=s.getAttribute(i);H.isVisible(s)&&H.exec("click",o,n,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!O.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{O.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,id:s,root:n,scroll:o}=t.state||{},a=window.location.href;this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&s===this.main.id?this.main.pushLinkPatch(a,null):this.replaceMain(a,null,()=>{n&&this.replaceRootHistory(),typeof o=="number"&&setTimeout(()=>{window.scrollTo(0,o)},0)})})},!1),window.addEventListener("click",t=>{let i=te(t.target,Le),s=i&&i.getAttribute(Le),n=t.metaKey||t.ctrlKey||t.button===1;if(!s||!this.isConnected()||!this.main||n)return;let o=i.href,a=i.getAttribute(wt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==o&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(o,a,i);else if(s==="redirect")this.historyRedirect(o,a);else throw new Error(`expected ${Le} to be "patch" or "redirect", got: ${s}`);let l=i.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(i,l,"click"))})},!1)}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i){if(!this.isConnected())return O.redirect(e);this.withPageLoading({to:e,kind:"patch"},s=>{this.main.pushLinkPatch(e,i,n=>{this.historyPatch(e,t,n),s()})})}historyPatch(e,t,i=this.setPendingLink(e)){!this.commitPendingLink(i)||(O.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location))}historyRedirect(e,t,i){if(!this.isConnected())return O.redirect(e,i);if(/^\/[^\/]+.*$/.test(e)){let{protocol:n,host:o}=window.location;e=`${n}//${o}${e}`}let s=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,i,()=>{O.pushState(t,{type:"redirect",id:this.main.id,scroll:s},e),this.registerNewLocation(window.location),n()})})}replaceRootHistory(){O.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=ue(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!s&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>i.target.submit())}))},!0),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));!s||(i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{H.exec("submit",s,n,i.target,["push",{}])}))},!1);for(let i of["change","input"])this.on(i,s=>{let n=this.binding("change"),o=s.target,a=o.getAttribute(n),l=o.form&&o.form.getAttribute(n),d=a||l;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let f=a?o:o.form,c=e;e++;let{at:p,type:E}=h.private(o,"prev-iteration")||{};p===c-1&&i!==E||(h.putPrivate(o,"prev-iteration",{at:c,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(f,_=>{h.putPrivate(o,Oe,!0),h.isTextualInput(o)||this.setActiveElement(o),H.exec("change",d,_,o,["push",{_target:s.target.name,dispatcher:f}])})}))},!1)}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let n=this.binding(kt),o=this.binding(It),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,d=>{let f=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,a,o,l,f,()=>{s()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,i=>{this.silenced||t(i)})}},Gt=class{constructor(){this.transitions=new Set,this.pendingOps=[],this.reset()}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.size()===0&&this.flushPendingOps()},e);this.transitions.add(s)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){this.pendingOps.forEach(e=>e()),this.pendingOps=[]}};return Si;})();
|
|
17
|
+
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Ht,this.opts=i,this.params=$e(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(ue(Ft),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=ue(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Rt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||_t,this.reloadJitterMin=i.reloadJitterMin||At,this.reloadJitterMax=i.reloadJitterMax||St,this.failsafeJitter=i.failsafeJitter||yt,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:$e(),onBeforeElUpdated:$e()},i.dom||{}),this.transitions=new Gt,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(Me)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(ye)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(ye)==="false"}enableDebug(){this.sessionStorage.setItem(ye,"true")}enableProfiling(){this.sessionStorage.setItem(Me,"true")}disableDebug(){this.sessionStorage.setItem(ye,"false")}disableProfiling(){this.sessionStorage.removeItem(Me)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(Ue,e)}disableLatencySim(){this.sessionStorage.removeItem(Ue)}getLatencySim(){let e=this.sessionStorage.getItem(Ue);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.bindTopLevelEvents({dead:!0}),this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){this.owner(e,s=>O.exec(i,t,s,e))}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[s,n]=i();this.viewLogger(e,t,s,n)}else if(this.isDebugEnabled()){let[s,n]=i();Xt(e,t,s,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}wrapPush(e,t,i){let s=this.getLatencySim(),n=e.joinCount;if(!s)return this.isConnected()&&t.timeout?i().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):i();let o={receives:[],receive(a,l){this.receives.push([a,l])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[l,d])=>a.receive(l,d),i())},s),o}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,o=R.updateLocal(this.localStorage,window.location.pathname,Ie,0,a=>a+1);o>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?Jt[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,t){return this.socket.channel(e,t)}joinDeadView(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>t.execNewMounted())}}joinRootViews(){let e=!1;return h.all(document,`${J}:not([${W}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.hasAttribute(le)&&(this.main=i)}e=!0}),e}redirect(e,t){this.disconnect(),R.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(o,t,n),this.main.setRedirect(e),this.transitionRemoves(),this.main.join((a,l)=>{a===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{h.findPhxSticky(document).forEach(d=>o.appendChild(d)),this.outgoingMainEl.replaceWith(o),this.outgoingMainEl=null,i&&requestAnimationFrame(i),l()})})}transitionRemoves(e){let t=this.binding("remove");e=e||h.all(document,`[${t}]`),e.forEach(i=>{document.body.contains(i)&&this.execJS(i,i.getAttribute(t),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(D)!==null}newRootView(e,t,i){let s=new pe(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=$(e.closest(J),s=>this.getViewByEl(s))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(q);return $(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(q));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let t=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",t),e.addEventListener("touchend",t)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.socket.onClose(t=>{if(t&&t.code===1001)return this.unload();if(t&&t.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,s,n,o,a)=>{let l=n.getAttribute(this.binding(Lt)),d=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==d)return;let f=ne({key:t.key},this.eventMeta(i,t,n));O.exec(i,o,s,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,n,o,a)=>{if(!a){let l=ne({key:t.key},this.eventMeta(i,t,n));O.exec(i,o,s,n,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,n,o,a,l)=>{if(l==="window"){let d=this.eventMeta(i,t,n);O.exec(i,a,s,n,["push",{data:d}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=$(te(t.target,this.binding(Qe)),o=>o.getAttribute(this.binding(Qe))),s=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!s||s.disabled||n.length===0||!(s.files instanceof FileList)||(y.trackFiles(s,n),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(Re,t=>{let i=t.target;if(!h.isUploadInput(i))return;let s=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);y.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let s=this.metadataCallbacks[e];return s?s(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.linkRef}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let s=e[i];this.on(s,n=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=n.target.getAttribute&&n.target.getAttribute(o);l?this.debounce(n.target,n,s,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,l,null)})}):h.all(document,`[${a}]`,d=>{let f=d.getAttribute(a);this.debounce(d,n,s,()=>{this.withinOwners(d,c=>{t(n,i,c,d,f,"window")})})})})}}bindClicks(){window.addEventListener("click",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let s=this.binding(t);window.addEventListener(e,n=>{let o=null;if(i)o=n.target.matches(`[${s}]`)?n.target:n.target.querySelector(`[${s}]`);else{let l=this.clickStartedAtTarget||n.target;o=te(l,s),this.dispatchClickAway(n,l),this.clickStartedAtTarget=null}let a=o&&o.getAttribute(s);if(!a){!i&&n.target.href!==void 0&&this.unload();return}o.getAttribute("href")==="#"&&n.preventDefault(),this.debounce(o,n,"click",()=>{this.withinOwners(o,l=>{O.exec("click",a,l,o,["push",{data:this.eventMeta("click",n,o)}])})})},i)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(e.target,n=>{let o=s.getAttribute(i);O.isVisible(s)&&O.exec("click",o,n,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!R.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{R.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,id:s,root:n,scroll:o}=t.state||{},a=window.location.href;this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&s===this.main.id?this.main.pushLinkPatch(a,null):this.replaceMain(a,null,()=>{n&&this.replaceRootHistory(),typeof o=="number"&&setTimeout(()=>{window.scrollTo(0,o)},0)})})},!1),window.addEventListener("click",t=>{let i=te(t.target,De),s=i&&i.getAttribute(De),n=t.metaKey||t.ctrlKey||t.button===1;if(!s||!this.isConnected()||!this.main||n)return;let o=i.href,a=i.getAttribute(wt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==o&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(o,a,i);else if(s==="redirect")this.historyRedirect(o,a);else throw new Error(`expected ${De} to be "patch" or "redirect", got: ${s}`);let l=i.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(i,l,"click"))})},!1)}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i){if(!this.isConnected())return R.redirect(e);this.withPageLoading({to:e,kind:"patch"},s=>{this.main.pushLinkPatch(e,i,n=>{this.historyPatch(e,t,n),s()})})}historyPatch(e,t,i=this.setPendingLink(e)){!this.commitPendingLink(i)||(R.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location))}historyRedirect(e,t,i){if(!this.isConnected())return R.redirect(e,i);if(/^\/$|^\/[^\/]+.*$/.test(e)){let{protocol:n,host:o}=window.location;e=`${n}//${o}${e}`}let s=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,i,()=>{R.pushState(t,{type:"redirect",id:this.main.id,scroll:s},e),this.registerNewLocation(window.location),n()})})}replaceRootHistory(){R.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=ue(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!s&&(t=!0,i.preventDefault(),this.unload(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>i.target.submit())}))},!0),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));if(!s)return this.unload();i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{O.exec("submit",s,n,i.target,["push",{}])})},!1);for(let i of["change","input"])this.on(i,s=>{let n=this.binding("change"),o=s.target,a=o.getAttribute(n),l=o.form&&o.form.getAttribute(n),d=a||l;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let f=a?o:o.form,c=e;e++;let{at:p,type:E}=h.private(o,"prev-iteration")||{};p===c-1&&i!==E||(h.putPrivate(o,"prev-iteration",{at:c,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(f,_=>{h.putPrivate(o,He,!0),h.isTextualInput(o)||this.setActiveElement(o),O.exec("change",d,_,o,["push",{_target:s.target.name,dispatcher:f}])})}))},!1)}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let n=this.binding(kt),o=this.binding(It),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,d=>{let f=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,a,o,l,f,()=>{s()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,i=>{this.silenced||t(i)})}},Gt=class{constructor(){this.transitions=new Set,this.pendingOps=[],this.reset()}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.size()===0&&this.flushPendingOps()},e);this.transitions.add(s)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){this.pendingOps.forEach(e=>e()),this.pendingOps=[]}};return Ai;})();
|