You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

phoenix_live_view

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phoenix_live_view - npm Package Compare versions

Comparing version

to
0.8.1

159

assets/js/phoenix_live_view.js

@@ -36,3 +36,3 @@ /*

const PHX_HAS_FOCUSED = "phx-has-focused"
const FOCUSABLE_INPUTS = ["text", "textarea", "number", "email", "password", "search", "tel", "url"]
const FOCUSABLE_INPUTS = ["text", "textarea", "number", "email", "password", "search", "tel", "url", "date", "time"]
const CHECKABLE_INPUTS = ["checkbox", "radio"]

@@ -135,5 +135,16 @@ const PHX_HAS_SUBMITTED = "phx-has-submitted"

export let Rendered = {
build(rendered){
rendered[COMPONENTS] = rendered[COMPONENTS] || {}
return rendered
},
toString(rendered, components = rendered[COMPONENTS] || {}){
let output = {buffer: "", components: components}
this.toOutputBuffer(rendered, output)
return output.buffer
},
mergeDiff(source, diff){
if(!diff[COMPONENTS] && this.isNewFingerprint(diff)){
return diff
return this.build(diff)
} else {

@@ -145,37 +156,12 @@ recursiveMerge(source, diff)

isNewFingerprint(diff = {}){ return !!diff[STATIC] },
componentToString(rendered, cid){ return this.recursiveCIDToString(rendered[COMPONENTS], cid)},
componentToString(components, cid){
let component = components[cid] || logError(`no component for CID ${cid}`, components)
let template = document.createElement("template")
template.innerHTML = this.toString(component, components)
let container = template.content
Array.from(container.childNodes).forEach(child => {
if(child.nodeType === Node.ELEMENT_NODE){
child.setAttribute(PHX_COMPONENT, cid)
} else {
if(child.nodeValue.trim() !== ""){
logError(`only HTML element tags are allowed at the root of components.\n\n` +
`got: "${child.nodeValue.trim()}"\n\n` +
`within:\n`, template.innerHTML.trim())
let span = document.createElement("span")
span.innerText = child.nodeValue
span.setAttribute(PHX_COMPONENT, cid)
child.replaceWith(span)
} else {
child.remove()
}
}
})
return template.innerHTML
pruneCIDs(rendered, cids){
cids.forEach(cid => delete rendered[COMPONENTS][cid])
return rendered
},
// private
toString(rendered, components = rendered[COMPONENTS] || {}){
let output = {buffer: "", components: components}
this.toOutputBuffer(rendered, output)
return output.buffer
},
isNewFingerprint(diff = {}){ return !!diff[STATIC] },

@@ -208,3 +194,3 @@ toOutputBuffer(rendered, output){

if(typeof(rendered) === "number"){
output.buffer += this.componentToString(output.components, rendered)
output.buffer += this.recursiveCIDToString(output.components, rendered)
} else if(isObject(rendered)){

@@ -217,5 +203,27 @@ this.toOutputBuffer(rendered, output)

pruneCIDs(rendered, cids){
cids.forEach(cid => delete rendered[COMPONENTS][cid])
return rendered
recursiveCIDToString(components, cid){
let component = components[cid] || logError(`no component for CID ${cid}`, components)
let template = document.createElement("template")
template.innerHTML = this.toString(component, components)
let container = template.content
Array.from(container.childNodes).forEach(child => {
if(child.nodeType === Node.ELEMENT_NODE){
child.setAttribute(PHX_COMPONENT, cid)
} else {
if(child.nodeValue.trim() !== ""){
logError(`only HTML element tags are allowed at the root of components.\n\n` +
`got: "${child.nodeValue.trim()}"\n\n` +
`within:\n`, template.innerHTML.trim())
let span = document.createElement("span")
span.innerText = child.nodeValue
span.setAttribute(PHX_COMPONENT, cid)
child.replaceWith(span)
} else {
child.remove()
}
}
})
return template.innerHTML
}

@@ -423,2 +431,7 @@ }

redirect(to, flash){
this.unloaded = true
Browser.redirect(to, flash)
}
replaceMain(href, flash, callback = null, linkRef = this.setPendingLink(href)){

@@ -431,3 +444,3 @@ let mainEl = this.main.el

Browser.fetchPage(href, (status, html) => {
if(status !== 200){ return Browser.redirect(href) }
if(status !== 200){ return this.redirect(href) }

@@ -437,3 +450,3 @@ let template = document.createElement("template")

let el = template.content.childNodes[0]
if(!el || !this.isPhxView(el)){ return Browser.redirect(href) }
if(!el || !this.isPhxView(el)){ return this.redirect(href) }

@@ -681,3 +694,3 @@ this.joinView(el, null, href, flash, newMain => {

if(this.main.isConnected() && (type === "patch" && id === this.main.id)){
this.main.pushLinkPatch(href)
this.main.pushLinkPatch(href, null)
} else {

@@ -700,3 +713,3 @@ this.replaceMain(href, null, () => {

if(type === "patch"){
this.pushHistoryPatch(href, linkState)
this.pushHistoryPatch(href, linkState, target)
} else if(type === "redirect") {

@@ -716,5 +729,5 @@ this.historyRedirect(href, linkState)

pushHistoryPatch(href, linkState){
pushHistoryPatch(href, linkState, targetEl){
this.withPageLoading({to: href, kind: "patch"}, done => {
this.main.pushLinkPatch(href, () => {
this.main.pushLinkPatch(href, targetEl, () => {
this.historyPatch(href, linkState)

@@ -850,3 +863,3 @@ done()

if(to !== window.location.href){
history[kind + "State"](meta, "", to)
history[kind + "State"](meta, "", to || null) // IE will coerce undefined to string
let hashEl = this.getHashTargetEl(window.location.hash)

@@ -955,6 +968,2 @@

disableForm(form, prefix){
},
discardError(container, el){

@@ -1001,3 +1010,3 @@ let field = el.getAttribute && el.getAttribute(PHX_ERROR_FOR)

// skip selects because FF will reset highlighted index for any setAttribute
if(!(target instanceof HTMLSelectElement)){ DOM.mergeAttrs(target, source, ["value"]) }
if(!(target instanceof HTMLSelectElement && target.multiple !== true)){ DOM.mergeAttrs(target, source, ["value"]) }
if(source.readOnly){

@@ -1012,4 +1021,5 @@ target.setAttribute("readonly", true)

if(!DOM.isTextualInput(focused)){ return }
if(focused.readOnly){ focused.blur()}
focused.focus()
let wasFocused = focused.matches(":focus")
if(focused.readOnly){ focused.blur() }
if(!wasFocused){ focused.focus() }
if(focused.setSelectionRange && focused.type === "text" || focused.type === "textarea"){

@@ -1057,3 +1067,6 @@ focused.setSelectionRange(selectionStart, selectionEnd)

perform(){
let {view, container, id, html, targetCID} = this
let {view, container, html} = this
let targetContainer = this.isCIDPatch() ? this.targetCIDContainer() : container
if(this.isCIDPatch() && !targetContainer){ return }
let focused = view.liveSocket.getActiveElement()

@@ -1064,3 +1077,3 @@ let {selectionStart, selectionEnd} = focused && DOM.isTextualInput(focused) ? focused : {}

let updates = []
let [diffContainer, targetContainer] = this.buildDiffContainer(container, html, phxUpdate, targetCID)
let diffContainer = this.buildDiffContainer(container, html, phxUpdate, targetContainer)

@@ -1117,3 +1130,3 @@ this.trackBefore("added", container)

if(fromEl.isSameNode(focused) && DOM.isFormInput(fromEl)){
if(focused && fromEl.isSameNode(focused) && DOM.isFormInput(fromEl) && !(fromEl.multiple === true)){
this.trackBefore("updated", fromEl, toEl)

@@ -1142,2 +1155,9 @@ DOM.mergeFocusedInput(fromEl, toEl)

isCIDPatch(){ return typeof(this.targetCID) === "number" }
targetCIDContainer(){ if(!this.isCIDPatch()){ return }
let first = this.container.querySelector(`[${PHX_COMPONENT}="${this.targetCID}"]`)
return first && first.parentNode
}
// builds container for morphdom patch

@@ -1148,11 +1168,9 @@ // - precomputes append/prepend content in diff node to make it appear as if

// to allow existing nodes to be updated in place rather than reordered
buildDiffContainer(container, html, phxUpdate, targetCID){
let targetContainer = container
buildDiffContainer(container, html, phxUpdate, targetContainer){
let diffContainer = null
let elementsOnly = child => child.nodeType === Node.ELEMENT_NODE
let idsOnly = child => child.id || logError("append/prepend children require IDs, got: ", child)
if(typeof(targetCID) === "number"){
targetContainer = container.querySelector(`[${PHX_COMPONENT}="${targetCID}"]`).parentNode
if(this.isCIDPatch()){
diffContainer = DOM.cloneNode(targetContainer)
let componentNodes = DOM.findComponentNodeList(diffContainer, targetCID)
let componentNodes = DOM.findComponentNodeList(diffContainer, this.targetCID)
let prevSibling = componentNodes[0].previousSibling

@@ -1194,3 +1212,3 @@ componentNodes.forEach(c => c.remove())

return [diffContainer, targetContainer]
return diffContainer
}

@@ -1319,3 +1337,3 @@

Browser.dropLocal(this.name(), CONSECUTIVE_RELOADS)
this.rendered = rendered
this.rendered = Rendered.build(rendered)
let html = Rendered.toString(this.rendered)

@@ -1433,3 +1451,3 @@ this.dropPendingRefs()

let html = typeof(cid) === "number" ?
Rendered.componentToString(this.rendered[COMPONENTS], cid) :
Rendered.componentToString(this.rendered, cid) :
Rendered.toString(this.rendered)

@@ -1500,3 +1518,3 @@

onRedirect({to, flash}){ Browser.redirect(to, flash) }
onRedirect({to, flash}){ this.liveSocket.redirect(to, flash) }

@@ -1581,2 +1599,3 @@ hasGracefullyClosed(){ return this.gracefullyClosed }

let newRef = this.ref++
let disableWith = this.binding(PHX_DISABLE_WITH)

@@ -1586,2 +1605,4 @@ elements.forEach(el => {

el.setAttribute(PHX_REF, newRef)
let disableText = el.getAttribute(disableWith)
if(disableText !== null){ el.innerText = disableText }
})

@@ -1667,4 +1688,3 @@ return [newRef, elements]

let refGenerator = () => {
let disableWith = this.binding(PHX_DISABLE_WITH)
let disables = DOM.all(formEl, `[${disableWith}]`)
let disables = DOM.all(formEl, `[${this.binding(PHX_DISABLE_WITH)}]`)
let buttons = DOM.all(formEl, "button")

@@ -1680,3 +1700,2 @@ let inputs = DOM.all(formEl, "input")

})
disables.forEach(disableEl => disableEl.innerText = disableEl.getAttribute(disableWith))
formEl.setAttribute(this.binding(PHX_PAGE_LOADING), "")

@@ -1701,6 +1720,8 @@ return this.putRef([formEl].concat(disables).concat(buttons).concat(inputs), "submit")

pushLinkPatch(href, callback){
pushLinkPatch(href, targetEl, callback){
if(!this.isLoading()){ this.showLoader(this.liveSocket.loaderTimeout) }
let linkRef = this.liveSocket.setPendingLink(href)
this.pushWithReply(null, "link", {url: href}, resp => {
let refGen = targetEl ? () => this.putRef([targetEl], "click") : null
this.pushWithReply(refGen, "link", {url: href}, resp => {
if(resp.link_redirect){

@@ -1715,3 +1736,3 @@ this.liveSocket.replaceMain(href, null, callback, linkRef)

}
}).receive("timeout", () => Browser.redirect(window.location.href))
}).receive("timeout", () => this.liveSocket.redirect(window.location.href))
}

@@ -1718,0 +1739,0 @@

{
"name": "phoenix_live_view",
"version": "0.8.0",
"version": "0.8.1",
"description": "The Phoenix LiveView JavaScript client.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -0,1 +1,15 @@

## 0.8.1 (2020-02-27)
### Enhancements
- Support `phx-disable-with` on live redirect and live patch links
### Bug Fixes
- Fix focus issue on date and time inputs
- Fix LiveViews failing to mount when page restored from back/forward cache following a `redirect` on the server
- Fix IE coercing `undefined` to string when issuing pushState
- Fix IE error when focused element is null
- Fix client error when using components and live navigation where a dynamic template is rendered
- Fix latent component diff causing error when component removed from DOM before patch arrives
- Fix race condition where a component event received on the server for a component already removed by the server raised a match error
## 0.8.0 (2020-02-22)

@@ -2,0 +16,0 @@

{
"name": "phoenix_live_view",
"version": "0.8.0",
"version": "0.8.1",
"description": "The Phoenix LiveView JavaScript client.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phoenix_live_view=t():e.phoenix_live_view=t()}(this,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";var i;n.r(t);var r="http://www.w3.org/1999/xhtml",o="undefined"==typeof document?void 0:document,a=!!o&&"content"in o.createElement("template"),c=!!o&&o.createRange&&"createContextualFragment"in o.createRange();function u(e){return a?function(e){var t=o.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}(e):c?function(e){return i||(i=o.createRange()).selectNode(o.body),i.createContextualFragment(e).childNodes[0]}(e):function(e){var t=o.createElement("body");return t.innerHTML=e,t.childNodes[0]}(e)}function s(e,t){var n=e.nodeName,i=t.nodeName;return n===i||!!(t.actualize&&n.charCodeAt(0)<91&&i.charCodeAt(0)>90)&&n===i.toUpperCase()}function l(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var d={OPTION:function(e,t){var n=e.parentNode;if(n){var i=n.nodeName.toUpperCase();"OPTGROUP"===i&&(i=(n=n.parentNode)&&n.nodeName.toUpperCase()),"SELECT"!==i||n.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}l(e,t,"selected")},INPUT:function(e,t){l(e,t,"checked"),l(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var i=e.firstChild;if(i){var r=i.nodeValue;if(r==n||!n&&r==e.placeholder)return;i.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n,i,r=-1,o=0,a=e.firstChild;a;)if("OPTGROUP"===(i=a.nodeName&&a.nodeName.toUpperCase()))a=(n=a).firstChild;else{if("OPTION"===i){if(a.hasAttribute("selected")){r=o;break}o++}!(a=a.nextSibling)&&n&&(a=n.nextSibling,n=null)}e.selectedIndex=r}}},h=1,f=11,v=3,p=8;function y(){}function g(e){return e.id}var m=function(e){return function(t,n,i){if(i||(i={}),"string"==typeof n)if("#document"===t.nodeName||"HTML"===t.nodeName){var a=n;(n=o.createElement("html")).innerHTML=a}else n=u(n);var c,l=i.getNodeKey||g,m=i.onBeforeNodeAdded||y,k=i.onNodeAdded||y,b=i.onBeforeElUpdated||y,w=i.onElUpdated||y,E=i.onBeforeNodeDiscarded||y,x=i.onNodeDiscarded||y,A=i.onBeforeElChildrenUpdated||y,S=!0===i.childrenOnly,L={};function C(e){c?c.push(e):c=[e]}function P(e,t,n){!1!==E(e)&&(t&&t.removeChild(e),x(e),function e(t,n){if(t.nodeType===h)for(var i=t.firstChild;i;){var r=void 0;n&&(r=l(i))?C(r):(x(i),i.firstChild&&e(i,n)),i=i.nextSibling}}(e,n))}function T(e){k(e);for(var t=e.firstChild;t;){var n=t.nextSibling,i=l(t);if(i){var r=L[i];r&&s(t,r)&&(t.parentNode.replaceChild(r,t),N(r,t))}T(t),t=n}}function N(i,r,a){var c=l(r);if(c&&delete L[c],!n.isSameNode||!n.isSameNode(t)){if(!a){if(!1===b(i,r))return;if(e(i,r),w(i),!1===A(i,r))return}"TEXTAREA"!==i.nodeName?function(e,t){var n,i,r,a,c,u=t.firstChild,f=e.firstChild;e:for(;u;){for(a=u.nextSibling,n=l(u);f;){if(r=f.nextSibling,u.isSameNode&&u.isSameNode(f)){u=a,f=r;continue e}i=l(f);var y=f.nodeType,g=void 0;if(y===u.nodeType&&(y===h?(n?n!==i&&((c=L[n])?r===c?g=!1:(e.insertBefore(c,f),i?C(i):P(f,e,!0),f=c):g=!1):i&&(g=!1),(g=!1!==g&&s(f,u))&&N(f,u)):y!==v&&y!=p||(g=!0,f.nodeValue!==u.nodeValue&&(f.nodeValue=u.nodeValue))),g){u=a,f=r;continue e}i?C(i):P(f,e,!0),f=r}if(n&&(c=L[n])&&s(c,u))e.appendChild(c),N(c,u);else{var k=m(u);!1!==k&&(k&&(u=k),u.actualize&&(u=u.actualize(e.ownerDocument||o)),e.appendChild(u),T(u))}u=a,f=r}!function(e,t,n){for(;t;){var i=t.nextSibling;(n=l(t))?C(n):P(t,e,!0),t=i}}(e,f,i);var b=d[e.nodeName];b&&b(e,t)}(i,r):d.TEXTAREA(i,r)}}!function e(t){if(t.nodeType===h||t.nodeType===f)for(var n=t.firstChild;n;){var i=l(n);i&&(L[i]=n),e(n),n=n.nextSibling}}(t);var _=t,I=_.nodeType,R=n.nodeType;if(!S)if(I===h)R===h?s(t,n)||(x(t),_=function(e,t){for(var n=e.firstChild;n;){var i=n.nextSibling;t.appendChild(n),n=i}return t}(t,function(e,t){return t&&t!==r?o.createElementNS(t,e):o.createElement(e)}(n.nodeName,n.namespaceURI))):_=n;else if(I===v||I===p){if(R===I)return _.nodeValue!==n.nodeValue&&(_.nodeValue=n.nodeValue),_;_=n}if(_===n)x(t);else if(N(_,n,S),c)for(var H=0,D=c.length;H<D;H++){var V=L[c[H]];V&&P(V,V.parentNode,!1)}return!S&&_!==t&&t.parentNode&&(_.actualize&&(_=_.actualize(t.ownerDocument||o)),t.parentNode.replaceChild(_,t)),_}}(function(e,t){var n,i,r,o,a,c=t.attributes;for(n=c.length-1;n>=0;--n)r=(i=c[n]).name,o=i.namespaceURI,a=i.value,o?(r=i.localName||r,e.getAttributeNS(o,r)!==a&&e.setAttributeNS(o,r,a)):e.getAttribute(r)!==a&&e.setAttribute(r,a);for(n=(c=e.attributes).length-1;n>=0;--n)!1!==(i=c[n]).specified&&(r=i.name,(o=i.namespaceURI)?(r=i.localName||r,t.hasAttributeNS(o,r)||e.removeAttributeNS(o,r)):t.hasAttribute(r)||e.removeAttribute(r))});function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function w(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),e}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,c=e[Symbol.iterator]();!(i=(a=c.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{i||null==c.return||c.return()}finally{if(r)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function x(e){return(x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}n.d(t,"debug",function(){return D}),n.d(t,"Rendered",function(){return K}),n.d(t,"LiveSocket",function(){return U}),n.d(t,"Browser",function(){return q}),n.d(t,"DOM",function(){return W}),n.d(t,"View",function(){return X});var A=[1e3,3e3],S="data-phx-view",L=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],C="data-phx-component",P="data-phx-ref",T="[".concat(S,"]"),N=["text","textarea","number","email","password","search","tel","url"],_=["checkbox","radio"],I=1,R="phx-",H=function(e,t){return console.error&&console.error(e,t)};var D=function(e,t,n,i){e.liveSocket.isDebugEnabled()&&console.log("".concat(e.id," ").concat(t,": ").concat(n," - "),i)},V=function(e){return"function"==typeof e?e:function(){return e}},B=function(e){return JSON.parse(JSON.stringify(e))},O=function(e,t){do{if(e.matches("[".concat(t,"]")))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType&&!e.matches(T));return null},j=function(e){return null!==e&&"object"===x(e)&&!(e instanceof Array)},M=function(e,t){return e&&t(e)},F=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new FormData(e),i=new URLSearchParams,r=!0,o=!1,a=void 0;try{for(var c,u=n.entries()[Symbol.iterator]();!(r=(c=u.next()).done);r=!0){var s=E(c.value,2),l=s[0],d=s[1];i.append(l,d)}}catch(e){o=!0,a=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw a}}for(var h in t)i.append(h,t[h]);return i.toString()},K={mergeDiff:function(e,t){return!t.c&&this.isNewFingerprint(t)?t:(function e(t,n){for(var i in n){var r=n[i],o=t[i];j(r)&&j(o)?(o.d&&!r.d&&delete o.d,e(o,r)):t[i]=r}}(e,t),e)},isNewFingerprint:function(){return!!(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).s},componentToString:function(e,t){var n=e[t]||H("no component for CID ".concat(t),e),i=document.createElement("template");i.innerHTML=this.toString(n,e);var r=i.content;return Array.from(r.childNodes).forEach(function(e){if(e.nodeType===Node.ELEMENT_NODE)e.setAttribute(C,t);else if(""!==e.nodeValue.trim()){H("only HTML element tags are allowed at the root of components.\n\n"+'got: "'.concat(e.nodeValue.trim(),'"\n\n')+"within:\n",i.innerHTML.trim());var n=document.createElement("span");n.innerText=e.nodeValue,n.setAttribute(C,t),e.replaceWith(n)}else e.remove()}),i.innerHTML},toString:function(e){var t={buffer:"",components:arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.c||{}};return this.toOutputBuffer(e,t),t.buffer},toOutputBuffer:function(e,t){if(e.d)return this.comprehensionToBuffer(e,t);var n=e.s;t.buffer+=n[0];for(var i=1;i<n.length;i++)this.dynamicToBuffer(e[i-1],t),t.buffer+=n[i]},comprehensionToBuffer:function(e,t){for(var n=e.d,i=e.s,r=0;r<n.length;r++){var o=n[r];t.buffer+=i[0];for(var a=1;a<i.length;a++)this.dynamicToBuffer(o[a-1],t),t.buffer+=i[a]}},dynamicToBuffer:function(e,t){"number"==typeof e?t.buffer+=this.componentToString(t.components,e):j(e)?this.toOutputBuffer(e,t):t.buffer+=e},pruneCIDs:function(e,t){return t.forEach(function(t){return delete e.c[t]}),e}},U=function(){function e(t,n){var i=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(k(this,e),this.unloaded=!1,!n||"Object"===n.constructor.name)throw new Error('\n a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:\n\n import {Socket} from "phoenix"\n import {LiveSocket} from "phoenix_live_view"\n let liveSocket = new LiveSocket("/live", Socket, {...})\n ');this.socket=new n(t,r),this.bindingPrefix=r.bindingPrefix||R,this.opts=r,this.views={},this.params=V(r.params||{}),this.viewLogger=r.viewLogger,this.activeElement=null,this.prevActive=null,this.silenced=!1,this.root=null,this.main=null,this.linkRef=0,this.href=window.location.href,this.pendingLink=null,this.currentLocation=B(window.location),this.hooks=r.hooks||{},this.loaderTimeout=r.loaderTimeout||I,this.socket.onOpen(function(){i.isUnloaded()&&(i.destroyAllViews(),i.joinRootViews(),i.detectMainView()),i.unloaded=!1}),window.addEventListener("unload",function(e){i.unloaded=!0})}return w(e,[{key:"isDebugEnabled",value:function(){return"true"===sessionStorage.getItem("phx:live-socket:debug")}},{key:"enableDebug",value:function(){sessionStorage.setItem("phx:live-socket:debug","true")}},{key:"disableDebug",value:function(){sessionStorage.removeItem("phx:live-socket:debug")}},{key:"enableLatencySim",value:function(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),sessionStorage.setItem("phx:live-socket:latency-sim",e)}},{key:"disableLatencySim",value:function(){sessionStorage.removeItem("phx:live-socket:latency-sim")}},{key:"getLatencySim",value:function(){var e=sessionStorage.getItem("phx:live-socket:latency-sim");return e?parseInt(e):null}},{key:"getSocket",value:function(){return this.socket}},{key:"connect",value:function(){var e=this,t=function(){e.joinRootViews(),e.detectMainView(),e.root&&(e.bindTopLevelEvents(),e.socket.connect())};["complete","loaded","interactive"].indexOf(document.readyState)>=0?t():document.addEventListener("DOMContentLoaded",function(){return t()})}},{key:"disconnect",value:function(){this.socket.disconnect()}},{key:"log",value:function(e,t,n){if(this.viewLogger){var i=E(n(),2),r=i[0],o=i[1];this.viewLogger(e,t,r,o)}else if(this.isDebugEnabled()){var a=E(n(),2),c=a[0],u=a[1];D(e,t,c,u)}}},{key:"onChannel",value:function(e,t,n){var i=this;e.on(t,function(e){var t=i.getLatencySim();t?(console.log("simulating ".concat(t,"ms of latency from server to client")),setTimeout(function(){return n(e)},t)):n(e)})}},{key:"wrapPush",value:function(e){var t=this.getLatencySim();if(!t)return e();console.log("simulating ".concat(t,"ms of latency from client to server"));var n={receives:[],receive:function(e,t){this.receives.push([e,t])}};return setTimeout(function(){n.receives.reduce(function(e,t){var n=E(t,2),i=n[0],r=n[1];return e.receive(i,r)},e())},t),n}},{key:"reloadWithJitter",value:function(e){var t=this;this.disconnect();var n=A[0],i=A[1],r=Math.floor(Math.random()*(i-n+1))+n,o=q.updateLocal(e.name(),"consecutive-reloads",0,function(e){return e+1});this.log(e,"join",function(){return["ecountered ".concat(o," consecutive reloads")]}),o>10&&(this.log(e,"join",function(){return["exceeded ".concat(10," consecutive reloads. Entering failsafe mode")]}),r=3e4),setTimeout(function(){t.hasPendingLink()?window.location=t.pendingLink:window.location.reload()},r)}},{key:"getHookCallbacks",value:function(e){return this.hooks[e]}},{key:"isUnloaded",value:function(){return this.unloaded}},{key:"isConnected",value:function(){return this.socket.isConnected()}},{key:"getBindingPrefix",value:function(){return this.bindingPrefix}},{key:"binding",value:function(e){return"".concat(this.getBindingPrefix()).concat(e)}},{key:"channel",value:function(e,t){return this.socket.channel(e,t)}},{key:"joinRootViews",value:function(){var e=this;W.all(document,"".concat(T,":not([").concat("data-phx-parent-id","])"),function(t){var n=e.joinView(t,null,e.getHref());e.root=e.root||n})}},{key:"detectMainView",value:function(){var e=this;W.all(document,"".concat("[data-phx-main=true]"),function(t){var n=!!e.main,i=e.getViewByEl(t);i&&(e.main=i,n||e.replaceRootHistory())})}},{key:"replaceMain",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.setPendingLink(e),o=this.main.el,a=this.main.id;this.destroyAllViews(),this.main.showLoader(this.loaderTimeout),q.fetchPage(e,function(c,u){if(200!==c)return q.redirect(e);var s=document.createElement("template");s.innerHTML=u;var l=s.content.childNodes[0];if(!l||!n.isPhxView(l))return q.redirect(e);n.joinView(l,null,e,t,function(e){n.commitPendingLink(r)?(n.destroyViewById(a),o.replaceWith(e.el),n.main=e,n.main.showLoader(),i&&i()):e.destroy()})})}},{key:"isPhxView",value:function(e){return e.getAttribute&&null!==e.getAttribute(S)}},{key:"joinView",value:function(e,t,n,i,r){if(!this.getViewByEl(e)){var o=new X(e,this,t,n,i);return this.views[o.id]=o,o.join(r),o}}},{key:"owner",value:function(e,t){var n=this,i=M(e.closest(T),function(e){return n.getViewByEl(e)});i&&t(i)}},{key:"withinTargets",value:function(e,t){var n=this,i=Array.from(document.querySelectorAll(e));if(!(i.length>0))throw new Error("no phx-target's found matching selector \"".concat(e,'"'));i.forEach(function(e){n.owner(e,function(n){return t(n,e)})})}},{key:"withinOwners",value:function(e,t){var n=e.getAttribute(this.binding("target"));null===n?this.owner(e,function(n){return t(n,e)}):this.withinTargets(n,t)}},{key:"getViewByEl",value:function(e){return this.getViewById(e.id)}},{key:"getViewById",value:function(e){return this.views[e]}},{key:"onViewError",value:function(e){this.dropActiveElement(e)}},{key:"destroyAllViews",value:function(){for(var e in this.views)this.destroyViewById(e)}},{key:"destroyViewByEl",value:function(e){return this.destroyViewById(e.id)}},{key:"destroyViewById",value:function(e){var t=this.views[e];t&&(delete this.views[t.id],this.root&&t.id===this.root.id&&(this.root=null),t.destroy())}},{key:"setActiveElement",value:function(e){var t=this;if(this.activeElement!==e){this.activeElement=e;var n=function(){e===t.activeElement&&(t.activeElement=null),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t)};e.addEventListener("mouseup",n),e.addEventListener("touchend",n)}}},{key:"getActiveElement",value:function(){return document.activeElement===document.body&&this.activeElement||document.activeElement}},{key:"dropActiveElement",value:function(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}},{key:"restorePreviouslyActiveFocus",value:function(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}},{key:"blurActiveElement",value:function(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}},{key:"bindTopLevelEvents",value:function(){var e=this;this.bindClicks(),this.bindNav(),this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},function(t,n,i,r,o,a,c){var u=r.getAttribute(e.binding("key"));u&&u.toLowerCase()!==t.key.toLowerCase()||i.pushKey(r,o,n,a,{altGraphKey:t.altGraphKey,altKey:t.altKey,code:t.code,ctrlKey:t.ctrlKey,key:t.key,keyIdentifier:t.keyIdentifier,keyLocation:t.keyLocation,location:t.location,metaKey:t.metaKey,repeat:t.repeat,shiftKey:t.shiftKey})}),this.bind({blur:"focusout",focus:"focusin"},function(e,t,n,i,r,o,a){a||n.pushEvent(t,i,r,o,{type:t})}),this.bind({blur:"blur",focus:"focus"},function(e,t,n,i,r,o,a){a&&"window"!==!a&&n.pushEvent(t,i,r,o,{type:e.type})})}},{key:"setPendingLink",value:function(e){this.linkRef++;this.linkRef;return this.pendingLink=e,this.linkRef}},{key:"commitPendingLink",value:function(e){return this.linkRef===e&&(this.href=this.pendingLink,this.pendingLink=null,!0)}},{key:"getHref",value:function(){return this.href}},{key:"hasPendingLink",value:function(){return!!this.pendingLink}},{key:"bind",value:function(e,t){var n=this,i=function(i){var r=e[i];n.on(r,function(e){var r=n.binding(i),o=n.binding("window-".concat(i)),a=e.target.getAttribute&&e.target.getAttribute(r);a?n.debounce(e.target,e,function(){n.withinOwners(e.target,function(n,r){t(e,i,n,e.target,r,a,null)})}):W.all(document,"[".concat(o,"]"),function(r){var a=r.getAttribute(o);n.debounce(r,e,function(){n.withinOwners(r,function(n,o){t(e,i,n,r,o,a,"window")})})})})};for(var r in e)i(r)}},{key:"bindClicks",value:function(){var e=this;[!0,!1].forEach(function(t){var n=t?e.binding("capture-click"):e.binding("click");window.addEventListener("click",function(i){var r=null,o=(r=t?i.target.matches("[".concat(n,"]"))?i.target:i.target.querySelector("[".concat(n,"]")):O(i.target,n))&&r.getAttribute(n);if(o){"#"===r.getAttribute("href")&&i.preventDefault();var a={altKey:i.altKey,shiftKey:i.shiftKey,ctrlKey:i.ctrlKey,metaKey:i.metaKey,x:i.x||i.clientX,y:i.y||i.clientY,pageX:i.pageX,pageY:i.pageY,screenX:i.screenX,screenY:i.screenY,offsetX:i.offsetX,offsetY:i.offsetY};e.debounce(r,i,function(){e.withinOwners(r,function(e,t){e.pushEvent("click",r,t,o,a)})})}},t)})}},{key:"bindNav",value:function(){var e=this;q.canPushState()&&(window.onpopstate=function(t){if(e.registerNewLocation(window.location)){var n=t.state||{},i=n.type,r=n.id,o=n.root,a=window.location.href;e.main.isConnected()&&"patch"===i&&r===e.main.id?e.main.pushLinkPatch(a):e.replaceMain(a,null,function(){o&&e.replaceRootHistory()})}},window.addEventListener("click",function(t){var n=O(t.target,"data-phx-link"),i=n&&n.getAttribute("data-phx-link"),r=t.metaKey||t.ctrlKey||1===t.button;if(i&&e.isConnected()&&e.main&&!r){var o=n.href,a=n.getAttribute("data-phx-link-state");if(t.preventDefault(),e.pendingLink!==o)if("patch"===i)e.pushHistoryPatch(o,a);else{if("redirect"!==i)throw new Error("expected ".concat("data-phx-link",' to be "patch" or "redirect", got: ').concat(i));e.historyRedirect(o,a)}}},!1))}},{key:"withPageLoading",value:function(e,t){W.dispatchEvent(window,"phx:page-loading-start",e);var n=function(){return W.dispatchEvent(window,"phx:page-loading-stop",e)};return t?t(n):n}},{key:"pushHistoryPatch",value:function(e,t){var n=this;this.withPageLoading({to:e,kind:"patch"},function(i){n.main.pushLinkPatch(e,function(){n.historyPatch(e,t),i()})})}},{key:"historyPatch",value:function(e,t){q.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location)}},{key:"historyRedirect",value:function(e,t,n){var i=this;this.withPageLoading({to:e,kind:"redirect"},function(r){i.replaceMain(e,n,function(){q.pushState(t,{type:"redirect",id:i.main.id},e),i.registerNewLocation(window.location),r()})})}},{key:"replaceRootHistory",value:function(){q.pushState("replace",{root:!0,type:"patch",id:this.main.id})}},{key:"registerNewLocation",value:function(e){var t=this.currentLocation;return t.pathname+t.search!==e.pathname+e.search&&(this.currentLocation=B(e),!0)}},{key:"bindForms",value:function(){var e=this,t=0;this.on("submit",function(t){var n=t.target.getAttribute(e.binding("submit"));n&&(t.preventDefault(),t.target.disabled=!0,e.withinOwners(t.target,function(e,i){return e.submitForm(t.target,i,n)}))},!1);for(var n=["change","input"],i=function(){var i=n[r];e.on(i,function(n){var r=n.target,o=r.form&&r.form.getAttribute(e.binding("change"));if(o&&("number"!==r.type||!r.validity||!r.validity.badInput)){var a=t;t++;var c=W.private(r,"prev-iteration")||{},u=c.at,s=c.type;u===a-1&&i!==s||(W.putPrivate(r,"prev-iteration",{at:a,type:i}),e.debounce(r,n,function(){e.withinOwners(r.form,function(t,i){W.isTextualInput(r)?W.putPrivate(r,"phx-has-focused",!0):e.setActiveElement(r),t.pushInput(r,i,o,n.target)})}))}},!1)},r=0;r<n.length;r++)i()}},{key:"debounce",value:function(e,t,n){W.debounce(e,t,this.binding("debounce"),this.binding("throttle"),n)}},{key:"silenceEvents",value:function(e){this.silenced=!0,e(),this.silenced=!1}},{key:"on",value:function(e,t){var n=this;window.addEventListener(e,function(e){n.silenced||t(e)})}}]),e}(),q={canPushState:function(){return void 0!==history.pushState},dropLocal:function(e,t){return window.localStorage.removeItem(this.localKey(e,t))},updateLocal:function(e,t,n,i){var r=this.getLocal(e,t),o=this.localKey(e,t),a=null===r?n:i(r);return window.localStorage.setItem(o,JSON.stringify(a)),a},getLocal:function(e,t){return JSON.parse(window.localStorage.getItem(this.localKey(e,t)))},fetchPage:function(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.timeout=3e4,n.setRequestHeader("content-type","text/html"),n.setRequestHeader("cache-control","max-age=0, no-cache, no-store, must-revalidate, post-check=0, pre-check=0"),n.setRequestHeader("x-requested-with","live-link"),n.onerror=function(){return t(400)},n.ontimeout=function(){return t(504)},n.onreadystatechange=function(){if(4===n.readyState)return"live-link"!==n.getResponseHeader("x-requested-with")?t(400):200!==n.status?t(n.status):void t(200,n.responseText)},n.send()},pushState:function(e,t,n){if(this.canPushState()){if(n!==window.location.href){history[e+"State"](t,"",n);var i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():"redirect"===t.type&&window.scroll(0,0)}}else this.redirect(n)},setCookie:function(e,t){document.cookie="".concat(e,"=").concat(t)},getCookie:function(e){return document.cookie.replace(new RegExp("(?:(?:^|.*;s*)".concat(e,"s*=s*([^;]*).*$)|^.*$")),"$1")},redirect:function(e,t){t&&q.setCookie("__phoenix_flash__",t+"; max-age=60000; path=/"),window.location=e},localKey:function(e,t){return"".concat(e,"-").concat(t)},getHashTargetEl:function(e){if(""!==e.toString())return document.getElementById(e)||document.querySelector('a[name="'.concat(e.substring(1),'"]'))}},W={all:function(e,t,n){var i=Array.from(e.querySelectorAll(t));return n?i.forEach(n):i},findComponentNodeList:function(e,t){return this.all(e,"[".concat(C,'="').concat(t,'"]'))},private:function(e,t){return e.phxPrivate&&e.phxPrivate[t]},deletePrivate:function(e,t){e.phxPrivate&&delete e.phxPrivate[t]},putPrivate:function(e,t,n){e.phxPrivate||(e.phxPrivate={}),e.phxPrivate[t]=n},copyPrivates:function(e,t){t.phxPrivate&&(e.phxPrivate=B(t.phxPrivate))},putTitle:function(e){document.title=e},debounce:function(e,t,n,i,r){var o=this,a=e.getAttribute(n),c=e.getAttribute(i),u=a||c;switch(u){case null:return r();case"blur":if(this.private(e,"debounce-blur"))return;return e.addEventListener("blur",function(){return r()}),void this.putPrivate(e,"debounce-blur",u);default:var s=parseInt(u);if(isNaN(s))return H("invalid throttle/debounce value: ".concat(u));if(c&&"keydown"===t.type){var l=this.private(e,"debounce-prev-key");if(this.putPrivate(e,"debounce-prev-key",t.which),l!==t.which)return r()}if(this.private(e,"debounce-timer"))return;var d=function(t){c&&"phx-change"===t.type&&t.detail.triggeredBy.name===e.name||(clearTimeout(o.private(e,"debounce-timer")),o.deletePrivate(e,"debounce-timer"))};this.putPrivate(e,"debounce-timer",setTimeout(function(){e.form&&(e.form.removeEventListener("phx-change",d),e.form.removeEventListener("submit",d)),o.deletePrivate(e,"debounce-timer"),c||r()},s)),e.form&&(e.form.addEventListener("phx-change",d),e.form.addEventListener("submit",d)),c&&r()}},disableForm:function(e,t){},discardError:function(e,t){var n=t.getAttribute&&t.getAttribute("data-phx-error-for");if(n){var i=e.querySelector("#".concat(n));!n||this.private(i,"phx-has-focused")||this.private(i.form,"phx-has-submitted")||(t.style.display="none")}},isPhxChild:function(e){return e.getAttribute&&e.getAttribute("data-phx-parent-id")},dispatchEvent:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e.dispatchEvent(i)},cloneNode:function(e,t){var n=e.cloneNode();return n.innerHTML=void 0===t?e.innerHTML:t,n},mergeAttrs:function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=t.attributes,r=i.length-1;r>=0;r--){var o=i[r].name;n.indexOf(o)<0&&e.setAttribute(o,t.getAttribute(o))}for(var a=e.attributes,c=a.length-1;c>=0;c--){var u=a[c].name;t.hasAttribute(u)||e.removeAttribute(u)}},mergeFocusedInput:function(e,t){e instanceof HTMLSelectElement||W.mergeAttrs(e,t,["value"]),t.readOnly?e.setAttribute("readonly",!0):e.removeAttribute("readonly")},restoreFocus:function(e,t,n){W.isTextualInput(e)&&(e.readOnly&&e.blur(),e.focus(),(e.setSelectionRange&&"text"===e.type||"textarea"===e.type)&&e.setSelectionRange(t,n))},isFormInput:function(e){return/^(?:input|select|textarea)$/i.test(e.tagName)},syncAttrsToProps:function(e){e instanceof HTMLInputElement&&_.indexOf(e.type.toLocaleLowerCase())>=0&&(e.checked=null!==e.getAttribute("checked"))},isTextualInput:function(e){return N.indexOf(e.type)>=0}},J=function(){function e(t,n,i,r,o,a){k(this,e),this.view=t,this.container=n,this.id=i,this.html=r,this.targetCID=o,this.ref=a,this.callbacks={beforeadded:[],beforeupdated:[],beforediscarded:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[]}}return w(e,[{key:"before",value:function(e,t){this.callbacks["before".concat(e)].push(t)}},{key:"after",value:function(e,t){this.callbacks["after".concat(e)].push(t)}},{key:"trackBefore",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.callbacks["before".concat(e)].forEach(function(e){return e.apply(void 0,n)})}},{key:"trackAfter",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.callbacks["after".concat(e)].forEach(function(e){return e.apply(void 0,n)})}},{key:"perform",value:function(){var e=this,t=this.view,n=this.container,i=(this.id,this.html),r=this.targetCID,o=t.liveSocket.getActiveElement(),a=o&&W.isTextualInput(o)?o:{},c=a.selectionStart,u=a.selectionEnd,s=t.liveSocket.binding("update"),l=[],d=[],h=E(this.buildDiffContainer(n,i,s,r),2),f=h[0],v=h[1];return this.trackBefore("added",n),this.trackBefore("updated",n,n),m(v,f.outerHTML,{childrenOnly:!0,onBeforeNodeAdded:function(t){return W.discardError(v,t),e.trackBefore("added",t),t},onNodeAdded:function(n){W.isPhxChild(n)&&t.ownsElement(n)&&e.trackAfter("phxChildAdded",n),l.push(n)},onNodeDiscarded:function(t){e.trackAfter("discarded",t)},onBeforeNodeDiscarded:function(n){if(e.trackBefore("discarded",n),W.isPhxChild(n))return t.liveSocket.destroyViewByEl(n),!0},onElUpdated:function(e){d.push(e)},onBeforeElUpdated:function(t,n){if("ignore"===t.getAttribute(s))return e.trackBefore("updated",t,n),W.mergeAttrs(t,n),d.push(t),!1;if("number"===t.type&&t.validity&&t.validity.badInput)return!1;if(!e.syncPendingRef(t,n))return!1;if(W.isPhxChild(n)){var i=t.getAttribute("data-phx-static");return W.mergeAttrs(t,n),t.setAttribute("data-phx-static",i),!1}return W.copyPrivates(n,t),W.discardError(v,n),t.isSameNode(o)&&W.isFormInput(t)?(e.trackBefore("updated",t,n),W.mergeFocusedInput(t,n),W.syncAttrsToProps(t),d.push(t),!1):(W.syncAttrsToProps(n),e.trackBefore("updated",t,n),!0)}}),t.liveSocket.isDebugEnabled()&&function(){for(var e=new Set,t=document.querySelectorAll("*[id]"),n=0,i=t.length;n<i;n++)e.has(t[n].id)?console.error("Multiple IDs detected: ".concat(t[n].id,". Ensure unique element ids.")):e.add(t[n].id)}(),t.liveSocket.silenceEvents(function(){return W.restoreFocus(o,c,u)}),W.dispatchEvent(document,"phx:update"),l.forEach(function(t){return e.trackAfter("added",t)}),d.forEach(function(t){return e.trackAfter("updated",t)}),!0}},{key:"buildDiffContainer",value:function(e,t,n,i){var r=e,o=null,a=function(e){return e.nodeType===Node.ELEMENT_NODE},c=function(e){return e.id||H("append/prepend children require IDs, got: ",e)};if("number"==typeof i){r=e.querySelector("[".concat(C,'="').concat(i,'"]')).parentNode,o=W.cloneNode(r);var u=W.findComponentNodeList(o,i),s=u[0].previousSibling;u.forEach(function(e){return e.remove()});var l=s&&s.nextSibling;if(s&&l){var d=document.createElement("template");d.innerHTML=t,Array.from(d.content.childNodes).forEach(function(e){return o.insertBefore(e,l)})}else s?o.insertAdjacentHTML("beforeend",t):o.insertAdjacentHTML("afterbegin",t)}else o=W.cloneNode(e,t);return W.all(o,"[".concat(n,"=append],[").concat(n,"=prepend]"),function(t){var i=t.id||H("append/prepend requires an ID, got: ",t),r=e.querySelector("#".concat(i));if(r){var o=W.cloneNode(r),u=t.getAttribute(n),s=Array.from(t.childNodes).filter(a).map(c),l=Array.from(o.childNodes).filter(a).map(c);if(s.toString()!==l.toString())s.filter(function(e){return l.indexOf(e)>=0}).forEach(function(e){var n=t.querySelector("#".concat(e));o.querySelector("#".concat(e)).replaceWith(n)}),t.insertAdjacentHTML("append"===u?"afterbegin":"beforeend",o.innerHTML)}}),[o,r]}},{key:"syncPendingRef",value:function(e,t){var n=e.getAttribute&&e.getAttribute(P);if(null===n)return!0;var i=parseInt(n);return null!==this.ref&&this.ref>=i?(e.removeAttribute(P),L.forEach(function(t){return e.classList.remove(t)}),!0):(L.forEach(function(n){e.classList.contains(n)&&t.classList.add(n)}),t.setAttribute(P,e.getAttribute(P)),!W.isFormInput(e)&&!/submit/i.test(e.type))}}]),e}(),X=function(){function e(t,n,i,r,o){var a=this;k(this,e),this.liveSocket=n,this.flash=o,this.parent=i,this.gracefullyClosed=!1,this.el=t,this.id=this.el.id,this.view=this.el.getAttribute(S),this.ref=0,this.loaderTimer=null,this.pendingDiffs=[],this.href=r,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.viewHooks={},this.channel=this.liveSocket.channel("lv:".concat(this.id),function(){return{url:a.href,params:a.liveSocket.params(a.view),session:a.getSession(),static:a.getStatic(),flash:a.flash,joins:a.joinCount}}),this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel()}return w(e,[{key:"name",value:function(){return this.view}},{key:"isConnected",value:function(){return this.channel.canPush()}},{key:"getSession",value:function(){return this.el.getAttribute("data-phx-session")}},{key:"getStatic",value:function(){var e=this.el.getAttribute("data-phx-static");return""===e?null:e}},{key:"destroy",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};clearTimeout(this.loaderTimer);var n=function(){for(var n in t(),e.viewHooks)e.destroyHook(e.viewHooks[n])};this.hasGracefullyClosed()?(this.log("destroyed",function(){return["the server view has gracefully closed"]}),n()):(this.log("destroyed",function(){return["the child has been removed from the parent"]}),this.channel.leave().receive("ok",n).receive("error",n).receive("timeout",n))}},{key:"setContainerClasses",value:function(){var e;this.el.classList.remove("phx-connected","phx-disconnected","phx-error"),(e=this.el.classList).add.apply(e,arguments)}},{key:"isLoading",value:function(){return this.el.classList.contains("phx-disconnected")}},{key:"showLoader",value:function(e){var t=this;if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(function(){return t.showLoader()},e);else{for(var n in this.viewHooks)this.viewHooks[n].__trigger__("disconnected");this.setContainerClasses("phx-disconnected")}}},{key:"hideLoader",value:function(){clearTimeout(this.loaderTimer),this.setContainerClasses("phx-connected")}},{key:"triggerReconnected",value:function(){for(var e in this.viewHooks)this.viewHooks[e].__trigger__("reconnected")}},{key:"log",value:function(e,t){this.liveSocket.log(this,e,t)}},{key:"onJoin",value:function(e){var t=this,n=e.rendered;e.live_patch;this.log("join",function(){return["",n]}),n.title&&W.putTitle(n.title),q.dropLocal(this.name(),"consecutive-reloads"),this.rendered=n;var i=K.toString(this.rendered);this.dropPendingRefs();var r=this.formsForRecovery(i);this.joinCount>1&&r.length>0?r.forEach(function(e,n){t.pushFormRecovery(e,function(e){n===r.length-1&&t.onJoinComplete(e,i)})}):this.onJoinComplete(e,i)}},{key:"dropPendingRefs",value:function(){W.all(this.el,"[".concat(P,"]"),function(e){return e.removeAttribute(P)})}},{key:"formsForRecovery",value:function(e){var t=this,n=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,W.all(this.el,"form[".concat(n,"], form[").concat(this.binding("submit"),"]")).filter(function(e){return t.ownsElement(e)}).filter(function(e){return i.content.querySelector("form[".concat(n,'="').concat(e.getAttribute(n),'"]'))})}},{key:"onJoinComplete",value:function(e,t){var n=this,i=e.live_patch;this.joinPending=!1;var r=new J(this,this.el,this.id,t,null);if(this.performPatch(r),this.joinNewChildren(),W.all(this.el,"[".concat(this.binding("hook"),"]"),function(e){var t=n.addHook(e);t&&t.__trigger__("mounted")}),this.applyPendingUpdates(),i){var o=i.kind,a=i.to;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected()}},{key:"performPatch",value:function(e){var t=this,n=[],i=!1,r=new Set;e.after("added",function(e){var n=t.addHook(e);n&&n.__trigger__("mounted")}),e.after("phxChildAdded",function(e){return i=!0}),e.before("updated",function(e,n){var i=t.getHook(e);i&&!e.isEqualNode(n)&&(r.add(e.id),i.__trigger__("beforeUpdate"))}),e.after("updated",function(e){var n=t.getHook(e);n&&r.has(e.id)&&n.__trigger__("updated")}),e.before("discarded",function(e){var n=t.getHook(e);n&&n.__trigger__("beforeDestroy")}),e.after("discarded",function(e){var i=t.componentID(e);"number"==typeof i&&-1===n.indexOf(i)&&n.push(i);var r=t.getHook(e);r&&t.destroyHook(r)}),e.perform(),i&&this.joinNewChildren(),this.maybePushComponentsDestroyed(n)}},{key:"joinNewChildren",value:function(){var e=this;W.all(this.el,"".concat(T,"[").concat("data-phx-parent-id",'="').concat(this.id,'"]'),function(t){e.liveSocket.getViewByEl(t)||e.liveSocket.joinView(t,e)})}},{key:"update",value:function(e,t,n){if(!function(e){for(var t in e)return!1;return!0}(e)||null!==n){if(e.title&&W.putTitle(e.title),this.joinPending||this.liveSocket.hasPendingLink())return this.pendingDiffs.push({diff:e,cid:t,ref:n});this.log("update",function(){return["",e]}),this.rendered=K.mergeDiff(this.rendered,e);var i="number"==typeof t?K.componentToString(this.rendered.c,t):K.toString(this.rendered),r=new J(this,this.el,this.id,i,t,n);this.performPatch(r)}}},{key:"getHook",value:function(e){return this.viewHooks[Y.elementID(e)]}},{key:"addHook",value:function(e){if(!Y.elementID(e)&&e.getAttribute){var t=e.getAttribute(this.binding("hook"));if(!t||this.ownsElement(e)){var n=this.liveSocket.getHookCallbacks(t);if(n){var i=new Y(this,e,n);return this.viewHooks[Y.elementID(i.el)]=i,i}null!==t&&H('unknown hook found for "'.concat(t,'"'),e)}}}},{key:"destroyHook",value:function(e){e.__trigger__("destroyed"),delete this.viewHooks[Y.elementID(e.el)]}},{key:"applyPendingUpdates",value:function(){var e=this;this.pendingDiffs.forEach(function(t){var n=t.diff,i=t.cid,r=t.ref;return e.update(n,i,r)}),this.pendingDiffs=[]}},{key:"onChannel",value:function(e,t){this.liveSocket.onChannel(this.channel,e,t)}},{key:"bindChannel",value:function(){var e=this;this.onChannel("diff",function(t){return e.update(t)}),this.onChannel("redirect",function(t){var n=t.to,i=t.flash;return e.onRedirect({to:n,flash:i})}),this.onChannel("live_patch",function(t){return e.onLivePatch(t)}),this.onChannel("live_redirect",function(t){return e.onLiveRedirect(t)}),this.onChannel("session",function(t){var n=t.token;return e.el.setAttribute("data-phx-session",n)}),this.channel.onError(function(t){return e.onError(t)}),this.channel.onClose(function(){return e.onGracefulClose()})}},{key:"onGracefulClose",value:function(){this.gracefullyClosed=!0,this.liveSocket.destroyViewById(this.id)}},{key:"onLiveRedirect",value:function(e){var t=e.to,n=e.kind,i=e.flash,r=this.expandURL(t);this.liveSocket.historyRedirect(r,n,i)}},{key:"onLivePatch",value:function(e){var t=e.to,n=e.kind;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,n)}},{key:"expandURL",value:function(e){return e.startsWith("/")?"".concat(window.location.protocol,"//").concat(window.location.host).concat(e):e}},{key:"onRedirect",value:function(e){var t=e.to,n=e.flash;q.redirect(t,n)}},{key:"hasGracefullyClosed",value:function(){return this.gracefullyClosed}},{key:"join",value:function(e){var t=this,n=function(){};this.parent?(this.parent.channel.onClose(function(){return t.onGracefulClose()}),this.parent.channel.onError(function(){return t.liveSocket.destroyViewById(t.id)})):n=this.liveSocket.withPageLoading({to:this.href,kind:"initial"}),this.liveSocket.wrapPush(function(){return t.channel.join().receive("ok",function(i){0===t.joinCount&&e&&e(t),t.joinCount++,t.joinPending=!0,t.flash=null,t.parent||n(),t.onJoin(i)}).receive("error",function(e){return t.onJoinError(e)}).receive("timeout",function(){return t.onJoinError({reason:"timeout"})})})}},{key:"onJoinError",value:function(e){return"outdated"===e.reason?this.liveSocket.reloadWithJitter(this):"join crashed"===e.reason?this.liveSocket.reloadWithJitter(this):((e.redirect||e.live_redirect)&&this.channel.leave(),e.redirect?this.onRedirect(e.redirect):e.live_redirect?this.onLiveRedirect(e.live_redirect):(this.displayError(),void this.log("error",function(){return["unable to join",e]})))}},{key:"onError",value:function(e){if(this.joinPending)return this.liveSocket.reloadWithJitter(this);this.log("error",function(){return["view crashed",e]}),this.liveSocket.onViewError(this),document.activeElement.blur(),this.liveSocket.isUnloaded()?this.showLoader(200):this.displayError()}},{key:"displayError",value:function(){this.showLoader(),this.setContainerClasses("phx-disconnected","phx-error")}},{key:"pushWithReply",value:function(e,t,n){var i=this,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=E(e?e():[null,[]],2),a=o[0],c=E(o[1],1)[0],u=function(){};return c&&null!==c.getAttribute(this.binding("page-loading"))&&(u=this.liveSocket.withPageLoading({kind:"element",target:c})),"number"!=typeof n.cid&&delete n.cid,this.liveSocket.wrapPush(function(){return i.channel.push(t,n,3e4).receive("ok",function(e){(e.diff||null!==a)&&i.update(e.diff||{},n.cid,a),e.redirect&&i.onRedirect(e.redirect),e.live_patch&&i.onLivePatch(e.live_patch),e.live_redirect&&i.onLiveRedirect(e.live_redirect),u(),r(e)})})}},{key:"putRef",value:function(e,t){var n=this.ref++;return e.forEach(function(e){e.classList.add("phx-".concat(t,"-loading")),e.setAttribute(P,n)}),[n,e]}},{key:"componentID",value:function(e){var t=e.getAttribute&&e.getAttribute(C);return t?parseInt(t):null}},{key:"targetComponentID",value:function(e,t){return e.getAttribute(this.binding("target"))?this.closestComponentID(t):null}},{key:"closestComponentID",value:function(e){var t=this;return e?M(e.closest("[".concat(C,"]")),function(e){return t.ownsElement(e)&&t.componentID(e)}):null}},{key:"pushHookEvent",value:function(e,t,n){this.pushWithReply(null,"event",{type:"hook",event:t,value:n,cid:this.closestComponentID(e)})}},{key:"extractMeta",value:function(e,t){for(var n=this.binding("value-"),i=0;i<e.attributes.length;i++){var r=e.attributes[i].name;r.startsWith(n)&&(t[r.replace(n,"")]=e.getAttribute(r))}return void 0!==e.value&&(t.value=e.value,"INPUT"===e.tagName&&_.indexOf(e.type)>=0&&!e.checked&&delete t.value),t}},{key:"pushEvent",value:function(e,t,n,i,r){var o=this;this.pushWithReply(function(){return o.putRef([t],e)},"event",{type:e,event:i,value:this.extractMeta(t,r),cid:this.targetComponentID(t,n)})}},{key:"pushKey",value:function(e,t,n,i,r){var o=this;this.pushWithReply(function(){return o.putRef([e],n)},"event",{type:n,event:i,value:this.extractMeta(e,r),cid:this.targetComponentID(e,t)})}},{key:"pushInput",value:function(e,t,n,i,r){var o=this;W.dispatchEvent(e.form,"phx-change",{triggeredBy:e}),this.pushWithReply(function(){return o.putRef([e,e.form],"change")},"event",{type:"form",event:n,value:F(e.form,{_target:i.name}),cid:this.targetComponentID(e.form,t)},r)}},{key:"pushFormSubmit",value:function(e,t,n,i){var r=this;this.pushWithReply(function(){var t=r.binding("disable-with"),n=W.all(e,"[".concat(t,"]")),i=W.all(e,"button"),o=W.all(e,"input");return i.forEach(function(e){e.setAttribute("data-phx-disabled",e.disabled),e.disabled=!0}),o.forEach(function(e){e.setAttribute("data-phx-readonly",e.readOnly),e.readOnly=!0}),n.forEach(function(e){return e.innerText=e.getAttribute(t)}),e.setAttribute(r.binding("page-loading"),""),r.putRef([e].concat(n).concat(i).concat(o),"submit")},"event",{type:"form",event:n,value:F(e),cid:this.targetComponentID(e,t)},i)}},{key:"pushFormRecovery",value:function(e,t){var n=this;this.liveSocket.withinOwners(e,function(i,r){var o=e.elements[0],a=e.getAttribute(n.binding("auto-recover"))||e.getAttribute(n.binding("change"));i.pushInput(o,r,a,o,t)})}},{key:"pushLinkPatch",value:function(e,t){var n=this;this.isLoading()||this.showLoader(this.liveSocket.loaderTimeout);var i=this.liveSocket.setPendingLink(e);this.pushWithReply(null,"link",{url:e},function(r){r.link_redirect?n.liveSocket.replaceMain(e,null,t,i):n.liveSocket.commitPendingLink(i)&&(n.href=e,n.applyPendingUpdates(),n.hideLoader(),n.triggerReconnected(),t&&t())}).receive("timeout",function(){return q.redirect(window.location.href)})}},{key:"formsForRecovery",value:function(e){var t=this,n=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,W.all(this.el,"form[".concat(n,"]")).filter(function(e){return t.ownsElement(e)}).filter(function(e){return"ignore"!==e.getAttribute(t.binding("auto-recover"))}).filter(function(e){return i.content.querySelector("form[".concat(n,'="').concat(e.getAttribute(n),'"]'))})}},{key:"maybePushComponentsDestroyed",value:function(e){var t=this,n=e.filter(function(e){return 0===W.findComponentNodeList(t.el,e).length});n.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:n},function(){t.rendered=K.pruneCIDs(t.rendered,n)})}},{key:"ownsElement",value:function(e){return e.getAttribute("data-phx-parent-id")===this.id||M(e.closest(T),function(e){return e.id})===this.id}},{key:"submitForm",value:function(e,t,n){var i=this;W.putPrivate(e,"phx-has-submitted",!0),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,n,function(){i.liveSocket.restorePreviouslyActiveFocus()})}},{key:"binding",value:function(e){return this.liveSocket.binding(e)}}]),e}(),G=1,Y=function(){function e(t,n,i){for(var r in k(this,e),this.__view=t,this.__liveSocket=t.liveSocket,this.__callbacks=i,this.el=n,this.viewName=t.name(),this.el.phxHookId=this.constructor.makeID(),this.__callbacks)this[r]=this.__callbacks[r]}return w(e,null,[{key:"makeID",value:function(){return G++}},{key:"elementID",value:function(e){return e.phxHookId}}]),w(e,[{key:"pushEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__view.pushHookEvent(null,e,t)}},{key:"pushEventTo",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.__liveSocket.withinTargets(e,function(e,i){e.pushHookEvent(i,t,n)})}},{key:"__trigger__",value:function(e){var t=this.__callbacks[e];t&&t.call(this)}}]),e}();t.default=U},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){t.Phoenix||(t.Phoenix={}),e.exports=t.Phoenix.LiveView=n(0)}).call(this,n(1))}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phoenix_live_view=t():e.phoenix_live_view=t()}(this,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";var i;n.r(t);var r="http://www.w3.org/1999/xhtml",o="undefined"==typeof document?void 0:document,a=!!o&&"content"in o.createElement("template"),u=!!o&&o.createRange&&"createContextualFragment"in o.createRange();function c(e){return a?function(e){var t=o.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}(e):u?function(e){return i||(i=o.createRange()).selectNode(o.body),i.createContextualFragment(e).childNodes[0]}(e):function(e){var t=o.createElement("body");return t.innerHTML=e,t.childNodes[0]}(e)}function s(e,t){var n=e.nodeName,i=t.nodeName;return n===i||!!(t.actualize&&n.charCodeAt(0)<91&&i.charCodeAt(0)>90)&&n===i.toUpperCase()}function l(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var d={OPTION:function(e,t){var n=e.parentNode;if(n){var i=n.nodeName.toUpperCase();"OPTGROUP"===i&&(i=(n=n.parentNode)&&n.nodeName.toUpperCase()),"SELECT"!==i||n.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}l(e,t,"selected")},INPUT:function(e,t){l(e,t,"checked"),l(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var i=e.firstChild;if(i){var r=i.nodeValue;if(r==n||!n&&r==e.placeholder)return;i.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n,i,r=-1,o=0,a=e.firstChild;a;)if("OPTGROUP"===(i=a.nodeName&&a.nodeName.toUpperCase()))a=(n=a).firstChild;else{if("OPTION"===i){if(a.hasAttribute("selected")){r=o;break}o++}!(a=a.nextSibling)&&n&&(a=n.nextSibling,n=null)}e.selectedIndex=r}}},h=1,f=11,v=3,p=8;function g(){}function y(e){return e.id}var m=function(e){return function(t,n,i){if(i||(i={}),"string"==typeof n)if("#document"===t.nodeName||"HTML"===t.nodeName){var a=n;(n=o.createElement("html")).innerHTML=a}else n=c(n);var u,l=i.getNodeKey||y,m=i.onBeforeNodeAdded||g,k=i.onNodeAdded||g,b=i.onBeforeElUpdated||g,w=i.onElUpdated||g,x=i.onBeforeNodeDiscarded||g,E=i.onNodeDiscarded||g,S=i.onBeforeElChildrenUpdated||g,A=!0===i.childrenOnly,L={};function C(e){u?u.push(e):u=[e]}function P(e,t,n){!1!==x(e)&&(t&&t.removeChild(e),E(e),function e(t,n){if(t.nodeType===h)for(var i=t.firstChild;i;){var r=void 0;n&&(r=l(i))?C(r):(E(i),i.firstChild&&e(i,n)),i=i.nextSibling}}(e,n))}function T(e){k(e);for(var t=e.firstChild;t;){var n=t.nextSibling,i=l(t);if(i){var r=L[i];r&&s(t,r)&&(t.parentNode.replaceChild(r,t),I(r,t))}T(t),t=n}}function I(i,r,a){var u=l(r);if(u&&delete L[u],!n.isSameNode||!n.isSameNode(t)){if(!a){if(!1===b(i,r))return;if(e(i,r),w(i),!1===S(i,r))return}"TEXTAREA"!==i.nodeName?function(e,t){var n,i,r,a,u,c=t.firstChild,f=e.firstChild;e:for(;c;){for(a=c.nextSibling,n=l(c);f;){if(r=f.nextSibling,c.isSameNode&&c.isSameNode(f)){c=a,f=r;continue e}i=l(f);var g=f.nodeType,y=void 0;if(g===c.nodeType&&(g===h?(n?n!==i&&((u=L[n])?r===u?y=!1:(e.insertBefore(u,f),i?C(i):P(f,e,!0),f=u):y=!1):i&&(y=!1),(y=!1!==y&&s(f,c))&&I(f,c)):g!==v&&g!=p||(y=!0,f.nodeValue!==c.nodeValue&&(f.nodeValue=c.nodeValue))),y){c=a,f=r;continue e}i?C(i):P(f,e,!0),f=r}if(n&&(u=L[n])&&s(u,c))e.appendChild(u),I(u,c);else{var k=m(c);!1!==k&&(k&&(c=k),c.actualize&&(c=c.actualize(e.ownerDocument||o)),e.appendChild(c),T(c))}c=a,f=r}!function(e,t,n){for(;t;){var i=t.nextSibling;(n=l(t))?C(n):P(t,e,!0),t=i}}(e,f,i);var b=d[e.nodeName];b&&b(e,t)}(i,r):d.TEXTAREA(i,r)}}!function e(t){if(t.nodeType===h||t.nodeType===f)for(var n=t.firstChild;n;){var i=l(n);i&&(L[i]=n),e(n),n=n.nextSibling}}(t);var N=t,_=N.nodeType,R=n.nodeType;if(!A)if(_===h)R===h?s(t,n)||(E(t),N=function(e,t){for(var n=e.firstChild;n;){var i=n.nextSibling;t.appendChild(n),n=i}return t}(t,function(e,t){return t&&t!==r?o.createElementNS(t,e):o.createElement(e)}(n.nodeName,n.namespaceURI))):N=n;else if(_===v||_===p){if(R===_)return N.nodeValue!==n.nodeValue&&(N.nodeValue=n.nodeValue),N;N=n}if(N===n)E(t);else if(I(N,n,A),u)for(var D=0,H=u.length;D<H;D++){var V=L[u[D]];V&&P(V,V.parentNode,!1)}return!A&&N!==t&&t.parentNode&&(N.actualize&&(N=N.actualize(t.ownerDocument||o)),t.parentNode.replaceChild(N,t)),N}}(function(e,t){var n,i,r,o,a,u=t.attributes;for(n=u.length-1;n>=0;--n)r=(i=u[n]).name,o=i.namespaceURI,a=i.value,o?(r=i.localName||r,e.getAttributeNS(o,r)!==a&&e.setAttributeNS(o,r,a)):e.getAttribute(r)!==a&&e.setAttribute(r,a);for(n=(u=e.attributes).length-1;n>=0;--n)!1!==(i=u[n]).specified&&(r=i.name,(o=i.namespaceURI)?(r=i.localName||r,t.hasAttributeNS(o,r)||e.removeAttributeNS(o,r)):t.hasAttribute(r)||e.removeAttribute(r))});function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function w(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),e}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(i=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(r)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}n.d(t,"debug",function(){return H}),n.d(t,"Rendered",function(){return K}),n.d(t,"LiveSocket",function(){return U}),n.d(t,"Browser",function(){return q}),n.d(t,"DOM",function(){return W}),n.d(t,"View",function(){return X});var S=[1e3,3e3],A="data-phx-view",L=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],C="data-phx-component",P="data-phx-ref",T="[".concat(A,"]"),I=["text","textarea","number","email","password","search","tel","url","date","time"],N=["checkbox","radio"],_=1,R="phx-",D=function(e,t){return console.error&&console.error(e,t)};var H=function(e,t,n,i){e.liveSocket.isDebugEnabled()&&console.log("".concat(e.id," ").concat(t,": ").concat(n," - "),i)},V=function(e){return"function"==typeof e?e:function(){return e}},B=function(e){return JSON.parse(JSON.stringify(e))},O=function(e,t){do{if(e.matches("[".concat(t,"]")))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType&&!e.matches(T));return null},j=function(e){return null!==e&&"object"===E(e)&&!(e instanceof Array)},M=function(e,t){return e&&t(e)},F=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new FormData(e),i=new URLSearchParams,r=!0,o=!1,a=void 0;try{for(var u,c=n.entries()[Symbol.iterator]();!(r=(u=c.next()).done);r=!0){var s=x(u.value,2),l=s[0],d=s[1];i.append(l,d)}}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}for(var h in t)i.append(h,t[h]);return i.toString()},K={build:function(e){return e.c=e.c||{},e},toString:function(e){var t={buffer:"",components:arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.c||{}};return this.toOutputBuffer(e,t),t.buffer},mergeDiff:function(e,t){return!t.c&&this.isNewFingerprint(t)?this.build(t):(function e(t,n){for(var i in n){var r=n[i],o=t[i];j(r)&&j(o)?(o.d&&!r.d&&delete o.d,e(o,r)):t[i]=r}}(e,t),e)},componentToString:function(e,t){return this.recursiveCIDToString(e.c,t)},pruneCIDs:function(e,t){return t.forEach(function(t){return delete e.c[t]}),e},isNewFingerprint:function(){return!!(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).s},toOutputBuffer:function(e,t){if(e.d)return this.comprehensionToBuffer(e,t);var n=e.s;t.buffer+=n[0];for(var i=1;i<n.length;i++)this.dynamicToBuffer(e[i-1],t),t.buffer+=n[i]},comprehensionToBuffer:function(e,t){for(var n=e.d,i=e.s,r=0;r<n.length;r++){var o=n[r];t.buffer+=i[0];for(var a=1;a<i.length;a++)this.dynamicToBuffer(o[a-1],t),t.buffer+=i[a]}},dynamicToBuffer:function(e,t){"number"==typeof e?t.buffer+=this.recursiveCIDToString(t.components,e):j(e)?this.toOutputBuffer(e,t):t.buffer+=e},recursiveCIDToString:function(e,t){var n=e[t]||D("no component for CID ".concat(t),e),i=document.createElement("template");i.innerHTML=this.toString(n,e);var r=i.content;return Array.from(r.childNodes).forEach(function(e){if(e.nodeType===Node.ELEMENT_NODE)e.setAttribute(C,t);else if(""!==e.nodeValue.trim()){D("only HTML element tags are allowed at the root of components.\n\n"+'got: "'.concat(e.nodeValue.trim(),'"\n\n')+"within:\n",i.innerHTML.trim());var n=document.createElement("span");n.innerText=e.nodeValue,n.setAttribute(C,t),e.replaceWith(n)}else e.remove()}),i.innerHTML}},U=function(){function e(t,n){var i=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(k(this,e),this.unloaded=!1,!n||"Object"===n.constructor.name)throw new Error('\n a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:\n\n import {Socket} from "phoenix"\n import {LiveSocket} from "phoenix_live_view"\n let liveSocket = new LiveSocket("/live", Socket, {...})\n ');this.socket=new n(t,r),this.bindingPrefix=r.bindingPrefix||R,this.opts=r,this.views={},this.params=V(r.params||{}),this.viewLogger=r.viewLogger,this.activeElement=null,this.prevActive=null,this.silenced=!1,this.root=null,this.main=null,this.linkRef=0,this.href=window.location.href,this.pendingLink=null,this.currentLocation=B(window.location),this.hooks=r.hooks||{},this.loaderTimeout=r.loaderTimeout||_,this.socket.onOpen(function(){i.isUnloaded()&&(i.destroyAllViews(),i.joinRootViews(),i.detectMainView()),i.unloaded=!1}),window.addEventListener("unload",function(e){i.unloaded=!0})}return w(e,[{key:"isDebugEnabled",value:function(){return"true"===sessionStorage.getItem("phx:live-socket:debug")}},{key:"enableDebug",value:function(){sessionStorage.setItem("phx:live-socket:debug","true")}},{key:"disableDebug",value:function(){sessionStorage.removeItem("phx:live-socket:debug")}},{key:"enableLatencySim",value:function(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),sessionStorage.setItem("phx:live-socket:latency-sim",e)}},{key:"disableLatencySim",value:function(){sessionStorage.removeItem("phx:live-socket:latency-sim")}},{key:"getLatencySim",value:function(){var e=sessionStorage.getItem("phx:live-socket:latency-sim");return e?parseInt(e):null}},{key:"getSocket",value:function(){return this.socket}},{key:"connect",value:function(){var e=this,t=function(){e.joinRootViews(),e.detectMainView(),e.root&&(e.bindTopLevelEvents(),e.socket.connect())};["complete","loaded","interactive"].indexOf(document.readyState)>=0?t():document.addEventListener("DOMContentLoaded",function(){return t()})}},{key:"disconnect",value:function(){this.socket.disconnect()}},{key:"log",value:function(e,t,n){if(this.viewLogger){var i=x(n(),2),r=i[0],o=i[1];this.viewLogger(e,t,r,o)}else if(this.isDebugEnabled()){var a=x(n(),2),u=a[0],c=a[1];H(e,t,u,c)}}},{key:"onChannel",value:function(e,t,n){var i=this;e.on(t,function(e){var t=i.getLatencySim();t?(console.log("simulating ".concat(t,"ms of latency from server to client")),setTimeout(function(){return n(e)},t)):n(e)})}},{key:"wrapPush",value:function(e){var t=this.getLatencySim();if(!t)return e();console.log("simulating ".concat(t,"ms of latency from client to server"));var n={receives:[],receive:function(e,t){this.receives.push([e,t])}};return setTimeout(function(){n.receives.reduce(function(e,t){var n=x(t,2),i=n[0],r=n[1];return e.receive(i,r)},e())},t),n}},{key:"reloadWithJitter",value:function(e){var t=this;this.disconnect();var n=S[0],i=S[1],r=Math.floor(Math.random()*(i-n+1))+n,o=q.updateLocal(e.name(),"consecutive-reloads",0,function(e){return e+1});this.log(e,"join",function(){return["ecountered ".concat(o," consecutive reloads")]}),o>10&&(this.log(e,"join",function(){return["exceeded ".concat(10," consecutive reloads. Entering failsafe mode")]}),r=3e4),setTimeout(function(){t.hasPendingLink()?window.location=t.pendingLink:window.location.reload()},r)}},{key:"getHookCallbacks",value:function(e){return this.hooks[e]}},{key:"isUnloaded",value:function(){return this.unloaded}},{key:"isConnected",value:function(){return this.socket.isConnected()}},{key:"getBindingPrefix",value:function(){return this.bindingPrefix}},{key:"binding",value:function(e){return"".concat(this.getBindingPrefix()).concat(e)}},{key:"channel",value:function(e,t){return this.socket.channel(e,t)}},{key:"joinRootViews",value:function(){var e=this;W.all(document,"".concat(T,":not([").concat("data-phx-parent-id","])"),function(t){var n=e.joinView(t,null,e.getHref());e.root=e.root||n})}},{key:"detectMainView",value:function(){var e=this;W.all(document,"".concat("[data-phx-main=true]"),function(t){var n=!!e.main,i=e.getViewByEl(t);i&&(e.main=i,n||e.replaceRootHistory())})}},{key:"redirect",value:function(e,t){this.unloaded=!0,q.redirect(e,t)}},{key:"replaceMain",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.setPendingLink(e),o=this.main.el,a=this.main.id;this.destroyAllViews(),this.main.showLoader(this.loaderTimeout),q.fetchPage(e,function(u,c){if(200!==u)return n.redirect(e);var s=document.createElement("template");s.innerHTML=c;var l=s.content.childNodes[0];if(!l||!n.isPhxView(l))return n.redirect(e);n.joinView(l,null,e,t,function(e){n.commitPendingLink(r)?(n.destroyViewById(a),o.replaceWith(e.el),n.main=e,n.main.showLoader(),i&&i()):e.destroy()})})}},{key:"isPhxView",value:function(e){return e.getAttribute&&null!==e.getAttribute(A)}},{key:"joinView",value:function(e,t,n,i,r){if(!this.getViewByEl(e)){var o=new X(e,this,t,n,i);return this.views[o.id]=o,o.join(r),o}}},{key:"owner",value:function(e,t){var n=this,i=M(e.closest(T),function(e){return n.getViewByEl(e)});i&&t(i)}},{key:"withinTargets",value:function(e,t){var n=this,i=Array.from(document.querySelectorAll(e));if(!(i.length>0))throw new Error("no phx-target's found matching selector \"".concat(e,'"'));i.forEach(function(e){n.owner(e,function(n){return t(n,e)})})}},{key:"withinOwners",value:function(e,t){var n=e.getAttribute(this.binding("target"));null===n?this.owner(e,function(n){return t(n,e)}):this.withinTargets(n,t)}},{key:"getViewByEl",value:function(e){return this.getViewById(e.id)}},{key:"getViewById",value:function(e){return this.views[e]}},{key:"onViewError",value:function(e){this.dropActiveElement(e)}},{key:"destroyAllViews",value:function(){for(var e in this.views)this.destroyViewById(e)}},{key:"destroyViewByEl",value:function(e){return this.destroyViewById(e.id)}},{key:"destroyViewById",value:function(e){var t=this.views[e];t&&(delete this.views[t.id],this.root&&t.id===this.root.id&&(this.root=null),t.destroy())}},{key:"setActiveElement",value:function(e){var t=this;if(this.activeElement!==e){this.activeElement=e;var n=function(){e===t.activeElement&&(t.activeElement=null),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t)};e.addEventListener("mouseup",n),e.addEventListener("touchend",n)}}},{key:"getActiveElement",value:function(){return document.activeElement===document.body&&this.activeElement||document.activeElement}},{key:"dropActiveElement",value:function(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}},{key:"restorePreviouslyActiveFocus",value:function(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}},{key:"blurActiveElement",value:function(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}},{key:"bindTopLevelEvents",value:function(){var e=this;this.bindClicks(),this.bindNav(),this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},function(t,n,i,r,o,a,u){var c=r.getAttribute(e.binding("key"));c&&c.toLowerCase()!==t.key.toLowerCase()||i.pushKey(r,o,n,a,{altGraphKey:t.altGraphKey,altKey:t.altKey,code:t.code,ctrlKey:t.ctrlKey,key:t.key,keyIdentifier:t.keyIdentifier,keyLocation:t.keyLocation,location:t.location,metaKey:t.metaKey,repeat:t.repeat,shiftKey:t.shiftKey})}),this.bind({blur:"focusout",focus:"focusin"},function(e,t,n,i,r,o,a){a||n.pushEvent(t,i,r,o,{type:t})}),this.bind({blur:"blur",focus:"focus"},function(e,t,n,i,r,o,a){a&&"window"!==!a&&n.pushEvent(t,i,r,o,{type:e.type})})}},{key:"setPendingLink",value:function(e){this.linkRef++;this.linkRef;return this.pendingLink=e,this.linkRef}},{key:"commitPendingLink",value:function(e){return this.linkRef===e&&(this.href=this.pendingLink,this.pendingLink=null,!0)}},{key:"getHref",value:function(){return this.href}},{key:"hasPendingLink",value:function(){return!!this.pendingLink}},{key:"bind",value:function(e,t){var n=this,i=function(i){var r=e[i];n.on(r,function(e){var r=n.binding(i),o=n.binding("window-".concat(i)),a=e.target.getAttribute&&e.target.getAttribute(r);a?n.debounce(e.target,e,function(){n.withinOwners(e.target,function(n,r){t(e,i,n,e.target,r,a,null)})}):W.all(document,"[".concat(o,"]"),function(r){var a=r.getAttribute(o);n.debounce(r,e,function(){n.withinOwners(r,function(n,o){t(e,i,n,r,o,a,"window")})})})})};for(var r in e)i(r)}},{key:"bindClicks",value:function(){var e=this;[!0,!1].forEach(function(t){var n=t?e.binding("capture-click"):e.binding("click");window.addEventListener("click",function(i){var r=null,o=(r=t?i.target.matches("[".concat(n,"]"))?i.target:i.target.querySelector("[".concat(n,"]")):O(i.target,n))&&r.getAttribute(n);if(o){"#"===r.getAttribute("href")&&i.preventDefault();var a={altKey:i.altKey,shiftKey:i.shiftKey,ctrlKey:i.ctrlKey,metaKey:i.metaKey,x:i.x||i.clientX,y:i.y||i.clientY,pageX:i.pageX,pageY:i.pageY,screenX:i.screenX,screenY:i.screenY,offsetX:i.offsetX,offsetY:i.offsetY};e.debounce(r,i,function(){e.withinOwners(r,function(e,t){e.pushEvent("click",r,t,o,a)})})}},t)})}},{key:"bindNav",value:function(){var e=this;q.canPushState()&&(window.onpopstate=function(t){if(e.registerNewLocation(window.location)){var n=t.state||{},i=n.type,r=n.id,o=n.root,a=window.location.href;e.main.isConnected()&&"patch"===i&&r===e.main.id?e.main.pushLinkPatch(a,null):e.replaceMain(a,null,function(){o&&e.replaceRootHistory()})}},window.addEventListener("click",function(t){var n=O(t.target,"data-phx-link"),i=n&&n.getAttribute("data-phx-link"),r=t.metaKey||t.ctrlKey||1===t.button;if(i&&e.isConnected()&&e.main&&!r){var o=n.href,a=n.getAttribute("data-phx-link-state");if(t.preventDefault(),e.pendingLink!==o)if("patch"===i)e.pushHistoryPatch(o,a,n);else{if("redirect"!==i)throw new Error("expected ".concat("data-phx-link",' to be "patch" or "redirect", got: ').concat(i));e.historyRedirect(o,a)}}},!1))}},{key:"withPageLoading",value:function(e,t){W.dispatchEvent(window,"phx:page-loading-start",e);var n=function(){return W.dispatchEvent(window,"phx:page-loading-stop",e)};return t?t(n):n}},{key:"pushHistoryPatch",value:function(e,t,n){var i=this;this.withPageLoading({to:e,kind:"patch"},function(r){i.main.pushLinkPatch(e,n,function(){i.historyPatch(e,t),r()})})}},{key:"historyPatch",value:function(e,t){q.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location)}},{key:"historyRedirect",value:function(e,t,n){var i=this;this.withPageLoading({to:e,kind:"redirect"},function(r){i.replaceMain(e,n,function(){q.pushState(t,{type:"redirect",id:i.main.id},e),i.registerNewLocation(window.location),r()})})}},{key:"replaceRootHistory",value:function(){q.pushState("replace",{root:!0,type:"patch",id:this.main.id})}},{key:"registerNewLocation",value:function(e){var t=this.currentLocation;return t.pathname+t.search!==e.pathname+e.search&&(this.currentLocation=B(e),!0)}},{key:"bindForms",value:function(){var e=this,t=0;this.on("submit",function(t){var n=t.target.getAttribute(e.binding("submit"));n&&(t.preventDefault(),t.target.disabled=!0,e.withinOwners(t.target,function(e,i){return e.submitForm(t.target,i,n)}))},!1);for(var n=["change","input"],i=function(){var i=n[r];e.on(i,function(n){var r=n.target,o=r.form&&r.form.getAttribute(e.binding("change"));if(o&&("number"!==r.type||!r.validity||!r.validity.badInput)){var a=t;t++;var u=W.private(r,"prev-iteration")||{},c=u.at,s=u.type;c===a-1&&i!==s||(W.putPrivate(r,"prev-iteration",{at:a,type:i}),e.debounce(r,n,function(){e.withinOwners(r.form,function(t,i){W.isTextualInput(r)?W.putPrivate(r,"phx-has-focused",!0):e.setActiveElement(r),t.pushInput(r,i,o,n.target)})}))}},!1)},r=0;r<n.length;r++)i()}},{key:"debounce",value:function(e,t,n){W.debounce(e,t,this.binding("debounce"),this.binding("throttle"),n)}},{key:"silenceEvents",value:function(e){this.silenced=!0,e(),this.silenced=!1}},{key:"on",value:function(e,t){var n=this;window.addEventListener(e,function(e){n.silenced||t(e)})}}]),e}(),q={canPushState:function(){return void 0!==history.pushState},dropLocal:function(e,t){return window.localStorage.removeItem(this.localKey(e,t))},updateLocal:function(e,t,n,i){var r=this.getLocal(e,t),o=this.localKey(e,t),a=null===r?n:i(r);return window.localStorage.setItem(o,JSON.stringify(a)),a},getLocal:function(e,t){return JSON.parse(window.localStorage.getItem(this.localKey(e,t)))},fetchPage:function(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.timeout=3e4,n.setRequestHeader("content-type","text/html"),n.setRequestHeader("cache-control","max-age=0, no-cache, no-store, must-revalidate, post-check=0, pre-check=0"),n.setRequestHeader("x-requested-with","live-link"),n.onerror=function(){return t(400)},n.ontimeout=function(){return t(504)},n.onreadystatechange=function(){if(4===n.readyState)return"live-link"!==n.getResponseHeader("x-requested-with")?t(400):200!==n.status?t(n.status):void t(200,n.responseText)},n.send()},pushState:function(e,t,n){if(this.canPushState()){if(n!==window.location.href){history[e+"State"](t,"",n||null);var i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():"redirect"===t.type&&window.scroll(0,0)}}else this.redirect(n)},setCookie:function(e,t){document.cookie="".concat(e,"=").concat(t)},getCookie:function(e){return document.cookie.replace(new RegExp("(?:(?:^|.*;s*)".concat(e,"s*=s*([^;]*).*$)|^.*$")),"$1")},redirect:function(e,t){t&&q.setCookie("__phoenix_flash__",t+"; max-age=60000; path=/"),window.location=e},localKey:function(e,t){return"".concat(e,"-").concat(t)},getHashTargetEl:function(e){if(""!==e.toString())return document.getElementById(e)||document.querySelector('a[name="'.concat(e.substring(1),'"]'))}},W={all:function(e,t,n){var i=Array.from(e.querySelectorAll(t));return n?i.forEach(n):i},findComponentNodeList:function(e,t){return this.all(e,"[".concat(C,'="').concat(t,'"]'))},private:function(e,t){return e.phxPrivate&&e.phxPrivate[t]},deletePrivate:function(e,t){e.phxPrivate&&delete e.phxPrivate[t]},putPrivate:function(e,t,n){e.phxPrivate||(e.phxPrivate={}),e.phxPrivate[t]=n},copyPrivates:function(e,t){t.phxPrivate&&(e.phxPrivate=B(t.phxPrivate))},putTitle:function(e){document.title=e},debounce:function(e,t,n,i,r){var o=this,a=e.getAttribute(n),u=e.getAttribute(i),c=a||u;switch(c){case null:return r();case"blur":if(this.private(e,"debounce-blur"))return;return e.addEventListener("blur",function(){return r()}),void this.putPrivate(e,"debounce-blur",c);default:var s=parseInt(c);if(isNaN(s))return D("invalid throttle/debounce value: ".concat(c));if(u&&"keydown"===t.type){var l=this.private(e,"debounce-prev-key");if(this.putPrivate(e,"debounce-prev-key",t.which),l!==t.which)return r()}if(this.private(e,"debounce-timer"))return;var d=function(t){u&&"phx-change"===t.type&&t.detail.triggeredBy.name===e.name||(clearTimeout(o.private(e,"debounce-timer")),o.deletePrivate(e,"debounce-timer"))};this.putPrivate(e,"debounce-timer",setTimeout(function(){e.form&&(e.form.removeEventListener("phx-change",d),e.form.removeEventListener("submit",d)),o.deletePrivate(e,"debounce-timer"),u||r()},s)),e.form&&(e.form.addEventListener("phx-change",d),e.form.addEventListener("submit",d)),u&&r()}},discardError:function(e,t){var n=t.getAttribute&&t.getAttribute("data-phx-error-for");if(n){var i=e.querySelector("#".concat(n));!n||this.private(i,"phx-has-focused")||this.private(i.form,"phx-has-submitted")||(t.style.display="none")}},isPhxChild:function(e){return e.getAttribute&&e.getAttribute("data-phx-parent-id")},dispatchEvent:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e.dispatchEvent(i)},cloneNode:function(e,t){var n=e.cloneNode();return n.innerHTML=void 0===t?e.innerHTML:t,n},mergeAttrs:function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=t.attributes,r=i.length-1;r>=0;r--){var o=i[r].name;n.indexOf(o)<0&&e.setAttribute(o,t.getAttribute(o))}for(var a=e.attributes,u=a.length-1;u>=0;u--){var c=a[u].name;t.hasAttribute(c)||e.removeAttribute(c)}},mergeFocusedInput:function(e,t){e instanceof HTMLSelectElement&&!0!==e.multiple||W.mergeAttrs(e,t,["value"]),t.readOnly?e.setAttribute("readonly",!0):e.removeAttribute("readonly")},restoreFocus:function(e,t,n){if(W.isTextualInput(e)){var i=e.matches(":focus");e.readOnly&&e.blur(),i||e.focus(),(e.setSelectionRange&&"text"===e.type||"textarea"===e.type)&&e.setSelectionRange(t,n)}},isFormInput:function(e){return/^(?:input|select|textarea)$/i.test(e.tagName)},syncAttrsToProps:function(e){e instanceof HTMLInputElement&&N.indexOf(e.type.toLocaleLowerCase())>=0&&(e.checked=null!==e.getAttribute("checked"))},isTextualInput:function(e){return I.indexOf(e.type)>=0}},J=function(){function e(t,n,i,r,o,a){k(this,e),this.view=t,this.container=n,this.id=i,this.html=r,this.targetCID=o,this.ref=a,this.callbacks={beforeadded:[],beforeupdated:[],beforediscarded:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[]}}return w(e,[{key:"before",value:function(e,t){this.callbacks["before".concat(e)].push(t)}},{key:"after",value:function(e,t){this.callbacks["after".concat(e)].push(t)}},{key:"trackBefore",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.callbacks["before".concat(e)].forEach(function(e){return e.apply(void 0,n)})}},{key:"trackAfter",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.callbacks["after".concat(e)].forEach(function(e){return e.apply(void 0,n)})}},{key:"perform",value:function(){var e=this,t=this.view,n=this.container,i=this.html,r=this.isCIDPatch()?this.targetCIDContainer():n;if(!this.isCIDPatch()||r){var o=t.liveSocket.getActiveElement(),a=o&&W.isTextualInput(o)?o:{},u=a.selectionStart,c=a.selectionEnd,s=t.liveSocket.binding("update"),l=[],d=[],h=this.buildDiffContainer(n,i,s,r);return this.trackBefore("added",n),this.trackBefore("updated",n,n),m(r,h.outerHTML,{childrenOnly:!0,onBeforeNodeAdded:function(t){return W.discardError(r,t),e.trackBefore("added",t),t},onNodeAdded:function(n){W.isPhxChild(n)&&t.ownsElement(n)&&e.trackAfter("phxChildAdded",n),l.push(n)},onNodeDiscarded:function(t){e.trackAfter("discarded",t)},onBeforeNodeDiscarded:function(n){if(e.trackBefore("discarded",n),W.isPhxChild(n))return t.liveSocket.destroyViewByEl(n),!0},onElUpdated:function(e){d.push(e)},onBeforeElUpdated:function(t,n){if("ignore"===t.getAttribute(s))return e.trackBefore("updated",t,n),W.mergeAttrs(t,n),d.push(t),!1;if("number"===t.type&&t.validity&&t.validity.badInput)return!1;if(!e.syncPendingRef(t,n))return!1;if(W.isPhxChild(n)){var i=t.getAttribute("data-phx-static");return W.mergeAttrs(t,n),t.setAttribute("data-phx-static",i),!1}return W.copyPrivates(n,t),W.discardError(r,n),o&&t.isSameNode(o)&&W.isFormInput(t)&&!0!==t.multiple?(e.trackBefore("updated",t,n),W.mergeFocusedInput(t,n),W.syncAttrsToProps(t),d.push(t),!1):(W.syncAttrsToProps(n),e.trackBefore("updated",t,n),!0)}}),t.liveSocket.isDebugEnabled()&&function(){for(var e=new Set,t=document.querySelectorAll("*[id]"),n=0,i=t.length;n<i;n++)e.has(t[n].id)?console.error("Multiple IDs detected: ".concat(t[n].id,". Ensure unique element ids.")):e.add(t[n].id)}(),t.liveSocket.silenceEvents(function(){return W.restoreFocus(o,u,c)}),W.dispatchEvent(document,"phx:update"),l.forEach(function(t){return e.trackAfter("added",t)}),d.forEach(function(t){return e.trackAfter("updated",t)}),!0}}},{key:"isCIDPatch",value:function(){return"number"==typeof this.targetCID}},{key:"targetCIDContainer",value:function(){if(this.isCIDPatch()){var e=this.container.querySelector("[".concat(C,'="').concat(this.targetCID,'"]'));return e&&e.parentNode}}},{key:"buildDiffContainer",value:function(e,t,n,i){var r=null,o=function(e){return e.nodeType===Node.ELEMENT_NODE},a=function(e){return e.id||D("append/prepend children require IDs, got: ",e)};if(this.isCIDPatch()){r=W.cloneNode(i);var u=W.findComponentNodeList(r,this.targetCID),c=u[0].previousSibling;u.forEach(function(e){return e.remove()});var s=c&&c.nextSibling;if(c&&s){var l=document.createElement("template");l.innerHTML=t,Array.from(l.content.childNodes).forEach(function(e){return r.insertBefore(e,s)})}else c?r.insertAdjacentHTML("beforeend",t):r.insertAdjacentHTML("afterbegin",t)}else r=W.cloneNode(e,t);return W.all(r,"[".concat(n,"=append],[").concat(n,"=prepend]"),function(t){var i=t.id||D("append/prepend requires an ID, got: ",t),r=e.querySelector("#".concat(i));if(r){var u=W.cloneNode(r),c=t.getAttribute(n),s=Array.from(t.childNodes).filter(o).map(a),l=Array.from(u.childNodes).filter(o).map(a);if(s.toString()!==l.toString())s.filter(function(e){return l.indexOf(e)>=0}).forEach(function(e){var n=t.querySelector("#".concat(e));u.querySelector("#".concat(e)).replaceWith(n)}),t.insertAdjacentHTML("append"===c?"afterbegin":"beforeend",u.innerHTML)}}),r}},{key:"syncPendingRef",value:function(e,t){var n=e.getAttribute&&e.getAttribute(P);if(null===n)return!0;var i=parseInt(n);return null!==this.ref&&this.ref>=i?(e.removeAttribute(P),L.forEach(function(t){return e.classList.remove(t)}),!0):(L.forEach(function(n){e.classList.contains(n)&&t.classList.add(n)}),t.setAttribute(P,e.getAttribute(P)),!W.isFormInput(e)&&!/submit/i.test(e.type))}}]),e}(),X=function(){function e(t,n,i,r,o){var a=this;k(this,e),this.liveSocket=n,this.flash=o,this.parent=i,this.gracefullyClosed=!1,this.el=t,this.id=this.el.id,this.view=this.el.getAttribute(A),this.ref=0,this.loaderTimer=null,this.pendingDiffs=[],this.href=r,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.viewHooks={},this.channel=this.liveSocket.channel("lv:".concat(this.id),function(){return{url:a.href,params:a.liveSocket.params(a.view),session:a.getSession(),static:a.getStatic(),flash:a.flash,joins:a.joinCount}}),this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel()}return w(e,[{key:"name",value:function(){return this.view}},{key:"isConnected",value:function(){return this.channel.canPush()}},{key:"getSession",value:function(){return this.el.getAttribute("data-phx-session")}},{key:"getStatic",value:function(){var e=this.el.getAttribute("data-phx-static");return""===e?null:e}},{key:"destroy",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};clearTimeout(this.loaderTimer);var n=function(){for(var n in t(),e.viewHooks)e.destroyHook(e.viewHooks[n])};this.hasGracefullyClosed()?(this.log("destroyed",function(){return["the server view has gracefully closed"]}),n()):(this.log("destroyed",function(){return["the child has been removed from the parent"]}),this.channel.leave().receive("ok",n).receive("error",n).receive("timeout",n))}},{key:"setContainerClasses",value:function(){var e;this.el.classList.remove("phx-connected","phx-disconnected","phx-error"),(e=this.el.classList).add.apply(e,arguments)}},{key:"isLoading",value:function(){return this.el.classList.contains("phx-disconnected")}},{key:"showLoader",value:function(e){var t=this;if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(function(){return t.showLoader()},e);else{for(var n in this.viewHooks)this.viewHooks[n].__trigger__("disconnected");this.setContainerClasses("phx-disconnected")}}},{key:"hideLoader",value:function(){clearTimeout(this.loaderTimer),this.setContainerClasses("phx-connected")}},{key:"triggerReconnected",value:function(){for(var e in this.viewHooks)this.viewHooks[e].__trigger__("reconnected")}},{key:"log",value:function(e,t){this.liveSocket.log(this,e,t)}},{key:"onJoin",value:function(e){var t=this,n=e.rendered;e.live_patch;this.log("join",function(){return["",n]}),n.title&&W.putTitle(n.title),q.dropLocal(this.name(),"consecutive-reloads"),this.rendered=K.build(n);var i=K.toString(this.rendered);this.dropPendingRefs();var r=this.formsForRecovery(i);this.joinCount>1&&r.length>0?r.forEach(function(e,n){t.pushFormRecovery(e,function(e){n===r.length-1&&t.onJoinComplete(e,i)})}):this.onJoinComplete(e,i)}},{key:"dropPendingRefs",value:function(){W.all(this.el,"[".concat(P,"]"),function(e){return e.removeAttribute(P)})}},{key:"formsForRecovery",value:function(e){var t=this,n=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,W.all(this.el,"form[".concat(n,"], form[").concat(this.binding("submit"),"]")).filter(function(e){return t.ownsElement(e)}).filter(function(e){return i.content.querySelector("form[".concat(n,'="').concat(e.getAttribute(n),'"]'))})}},{key:"onJoinComplete",value:function(e,t){var n=this,i=e.live_patch;this.joinPending=!1;var r=new J(this,this.el,this.id,t,null);if(this.performPatch(r),this.joinNewChildren(),W.all(this.el,"[".concat(this.binding("hook"),"]"),function(e){var t=n.addHook(e);t&&t.__trigger__("mounted")}),this.applyPendingUpdates(),i){var o=i.kind,a=i.to;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected()}},{key:"performPatch",value:function(e){var t=this,n=[],i=!1,r=new Set;e.after("added",function(e){var n=t.addHook(e);n&&n.__trigger__("mounted")}),e.after("phxChildAdded",function(e){return i=!0}),e.before("updated",function(e,n){var i=t.getHook(e);i&&!e.isEqualNode(n)&&(r.add(e.id),i.__trigger__("beforeUpdate"))}),e.after("updated",function(e){var n=t.getHook(e);n&&r.has(e.id)&&n.__trigger__("updated")}),e.before("discarded",function(e){var n=t.getHook(e);n&&n.__trigger__("beforeDestroy")}),e.after("discarded",function(e){var i=t.componentID(e);"number"==typeof i&&-1===n.indexOf(i)&&n.push(i);var r=t.getHook(e);r&&t.destroyHook(r)}),e.perform(),i&&this.joinNewChildren(),this.maybePushComponentsDestroyed(n)}},{key:"joinNewChildren",value:function(){var e=this;W.all(this.el,"".concat(T,"[").concat("data-phx-parent-id",'="').concat(this.id,'"]'),function(t){e.liveSocket.getViewByEl(t)||e.liveSocket.joinView(t,e)})}},{key:"update",value:function(e,t,n){if(!function(e){for(var t in e)return!1;return!0}(e)||null!==n){if(e.title&&W.putTitle(e.title),this.joinPending||this.liveSocket.hasPendingLink())return this.pendingDiffs.push({diff:e,cid:t,ref:n});this.log("update",function(){return["",e]}),this.rendered=K.mergeDiff(this.rendered,e);var i="number"==typeof t?K.componentToString(this.rendered,t):K.toString(this.rendered),r=new J(this,this.el,this.id,i,t,n);this.performPatch(r)}}},{key:"getHook",value:function(e){return this.viewHooks[Y.elementID(e)]}},{key:"addHook",value:function(e){if(!Y.elementID(e)&&e.getAttribute){var t=e.getAttribute(this.binding("hook"));if(!t||this.ownsElement(e)){var n=this.liveSocket.getHookCallbacks(t);if(n){var i=new Y(this,e,n);return this.viewHooks[Y.elementID(i.el)]=i,i}null!==t&&D('unknown hook found for "'.concat(t,'"'),e)}}}},{key:"destroyHook",value:function(e){e.__trigger__("destroyed"),delete this.viewHooks[Y.elementID(e.el)]}},{key:"applyPendingUpdates",value:function(){var e=this;this.pendingDiffs.forEach(function(t){var n=t.diff,i=t.cid,r=t.ref;return e.update(n,i,r)}),this.pendingDiffs=[]}},{key:"onChannel",value:function(e,t){this.liveSocket.onChannel(this.channel,e,t)}},{key:"bindChannel",value:function(){var e=this;this.onChannel("diff",function(t){return e.update(t)}),this.onChannel("redirect",function(t){var n=t.to,i=t.flash;return e.onRedirect({to:n,flash:i})}),this.onChannel("live_patch",function(t){return e.onLivePatch(t)}),this.onChannel("live_redirect",function(t){return e.onLiveRedirect(t)}),this.onChannel("session",function(t){var n=t.token;return e.el.setAttribute("data-phx-session",n)}),this.channel.onError(function(t){return e.onError(t)}),this.channel.onClose(function(){return e.onGracefulClose()})}},{key:"onGracefulClose",value:function(){this.gracefullyClosed=!0,this.liveSocket.destroyViewById(this.id)}},{key:"onLiveRedirect",value:function(e){var t=e.to,n=e.kind,i=e.flash,r=this.expandURL(t);this.liveSocket.historyRedirect(r,n,i)}},{key:"onLivePatch",value:function(e){var t=e.to,n=e.kind;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,n)}},{key:"expandURL",value:function(e){return e.startsWith("/")?"".concat(window.location.protocol,"//").concat(window.location.host).concat(e):e}},{key:"onRedirect",value:function(e){var t=e.to,n=e.flash;this.liveSocket.redirect(t,n)}},{key:"hasGracefullyClosed",value:function(){return this.gracefullyClosed}},{key:"join",value:function(e){var t=this,n=function(){};this.parent?(this.parent.channel.onClose(function(){return t.onGracefulClose()}),this.parent.channel.onError(function(){return t.liveSocket.destroyViewById(t.id)})):n=this.liveSocket.withPageLoading({to:this.href,kind:"initial"}),this.liveSocket.wrapPush(function(){return t.channel.join().receive("ok",function(i){0===t.joinCount&&e&&e(t),t.joinCount++,t.joinPending=!0,t.flash=null,t.parent||n(),t.onJoin(i)}).receive("error",function(e){return t.onJoinError(e)}).receive("timeout",function(){return t.onJoinError({reason:"timeout"})})})}},{key:"onJoinError",value:function(e){return"outdated"===e.reason?this.liveSocket.reloadWithJitter(this):"join crashed"===e.reason?this.liveSocket.reloadWithJitter(this):((e.redirect||e.live_redirect)&&this.channel.leave(),e.redirect?this.onRedirect(e.redirect):e.live_redirect?this.onLiveRedirect(e.live_redirect):(this.displayError(),void this.log("error",function(){return["unable to join",e]})))}},{key:"onError",value:function(e){if(this.joinPending)return this.liveSocket.reloadWithJitter(this);this.log("error",function(){return["view crashed",e]}),this.liveSocket.onViewError(this),document.activeElement.blur(),this.liveSocket.isUnloaded()?this.showLoader(200):this.displayError()}},{key:"displayError",value:function(){this.showLoader(),this.setContainerClasses("phx-disconnected","phx-error")}},{key:"pushWithReply",value:function(e,t,n){var i=this,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=x(e?e():[null,[]],2),a=o[0],u=x(o[1],1)[0],c=function(){};return u&&null!==u.getAttribute(this.binding("page-loading"))&&(c=this.liveSocket.withPageLoading({kind:"element",target:u})),"number"!=typeof n.cid&&delete n.cid,this.liveSocket.wrapPush(function(){return i.channel.push(t,n,3e4).receive("ok",function(e){(e.diff||null!==a)&&i.update(e.diff||{},n.cid,a),e.redirect&&i.onRedirect(e.redirect),e.live_patch&&i.onLivePatch(e.live_patch),e.live_redirect&&i.onLiveRedirect(e.live_redirect),c(),r(e)})})}},{key:"putRef",value:function(e,t){var n=this.ref++,i=this.binding("disable-with");return e.forEach(function(e){e.classList.add("phx-".concat(t,"-loading")),e.setAttribute(P,n);var r=e.getAttribute(i);null!==r&&(e.innerText=r)}),[n,e]}},{key:"componentID",value:function(e){var t=e.getAttribute&&e.getAttribute(C);return t?parseInt(t):null}},{key:"targetComponentID",value:function(e,t){return e.getAttribute(this.binding("target"))?this.closestComponentID(t):null}},{key:"closestComponentID",value:function(e){var t=this;return e?M(e.closest("[".concat(C,"]")),function(e){return t.ownsElement(e)&&t.componentID(e)}):null}},{key:"pushHookEvent",value:function(e,t,n){this.pushWithReply(null,"event",{type:"hook",event:t,value:n,cid:this.closestComponentID(e)})}},{key:"extractMeta",value:function(e,t){for(var n=this.binding("value-"),i=0;i<e.attributes.length;i++){var r=e.attributes[i].name;r.startsWith(n)&&(t[r.replace(n,"")]=e.getAttribute(r))}return void 0!==e.value&&(t.value=e.value,"INPUT"===e.tagName&&N.indexOf(e.type)>=0&&!e.checked&&delete t.value),t}},{key:"pushEvent",value:function(e,t,n,i,r){var o=this;this.pushWithReply(function(){return o.putRef([t],e)},"event",{type:e,event:i,value:this.extractMeta(t,r),cid:this.targetComponentID(t,n)})}},{key:"pushKey",value:function(e,t,n,i,r){var o=this;this.pushWithReply(function(){return o.putRef([e],n)},"event",{type:n,event:i,value:this.extractMeta(e,r),cid:this.targetComponentID(e,t)})}},{key:"pushInput",value:function(e,t,n,i,r){var o=this;W.dispatchEvent(e.form,"phx-change",{triggeredBy:e}),this.pushWithReply(function(){return o.putRef([e,e.form],"change")},"event",{type:"form",event:n,value:F(e.form,{_target:i.name}),cid:this.targetComponentID(e.form,t)},r)}},{key:"pushFormSubmit",value:function(e,t,n,i){var r=this;this.pushWithReply(function(){var t=W.all(e,"[".concat(r.binding("disable-with"),"]")),n=W.all(e,"button"),i=W.all(e,"input");return n.forEach(function(e){e.setAttribute("data-phx-disabled",e.disabled),e.disabled=!0}),i.forEach(function(e){e.setAttribute("data-phx-readonly",e.readOnly),e.readOnly=!0}),e.setAttribute(r.binding("page-loading"),""),r.putRef([e].concat(t).concat(n).concat(i),"submit")},"event",{type:"form",event:n,value:F(e),cid:this.targetComponentID(e,t)},i)}},{key:"pushFormRecovery",value:function(e,t){var n=this;this.liveSocket.withinOwners(e,function(i,r){var o=e.elements[0],a=e.getAttribute(n.binding("auto-recover"))||e.getAttribute(n.binding("change"));i.pushInput(o,r,a,o,t)})}},{key:"pushLinkPatch",value:function(e,t,n){var i=this;this.isLoading()||this.showLoader(this.liveSocket.loaderTimeout);var r=this.liveSocket.setPendingLink(e),o=t?function(){return i.putRef([t],"click")}:null;this.pushWithReply(o,"link",{url:e},function(t){t.link_redirect?i.liveSocket.replaceMain(e,null,n,r):i.liveSocket.commitPendingLink(r)&&(i.href=e,i.applyPendingUpdates(),i.hideLoader(),i.triggerReconnected(),n&&n())}).receive("timeout",function(){return i.liveSocket.redirect(window.location.href)})}},{key:"formsForRecovery",value:function(e){var t=this,n=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,W.all(this.el,"form[".concat(n,"]")).filter(function(e){return t.ownsElement(e)}).filter(function(e){return"ignore"!==e.getAttribute(t.binding("auto-recover"))}).filter(function(e){return i.content.querySelector("form[".concat(n,'="').concat(e.getAttribute(n),'"]'))})}},{key:"maybePushComponentsDestroyed",value:function(e){var t=this,n=e.filter(function(e){return 0===W.findComponentNodeList(t.el,e).length});n.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:n},function(){t.rendered=K.pruneCIDs(t.rendered,n)})}},{key:"ownsElement",value:function(e){return e.getAttribute("data-phx-parent-id")===this.id||M(e.closest(T),function(e){return e.id})===this.id}},{key:"submitForm",value:function(e,t,n){var i=this;W.putPrivate(e,"phx-has-submitted",!0),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,n,function(){i.liveSocket.restorePreviouslyActiveFocus()})}},{key:"binding",value:function(e){return this.liveSocket.binding(e)}}]),e}(),G=1,Y=function(){function e(t,n,i){for(var r in k(this,e),this.__view=t,this.__liveSocket=t.liveSocket,this.__callbacks=i,this.el=n,this.viewName=t.name(),this.el.phxHookId=this.constructor.makeID(),this.__callbacks)this[r]=this.__callbacks[r]}return w(e,null,[{key:"makeID",value:function(){return G++}},{key:"elementID",value:function(e){return e.phxHookId}}]),w(e,[{key:"pushEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__view.pushHookEvent(null,e,t)}},{key:"pushEventTo",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.__liveSocket.withinTargets(e,function(e,i){e.pushHookEvent(i,t,n)})}},{key:"__trigger__",value:function(e){var t=this.__callbacks[e];t&&t.call(this)}}]),e}();t.default=U},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){t.Phoenix||(t.Phoenix={}),e.exports=t.Phoenix.LiveView=n(0)}).call(this,n(1))}])});

@@ -32,3 +32,3 @@ # Phoenix LiveView

```console
$ npm install --save --prefix assets mdn-polyfills url-search-params-polyfill formdata-polyfill child-replace-with-polyfill classlist-polyfill shim-keyboard-event-key
$ npm install --save --prefix assets mdn-polyfills url-search-params-polyfill formdata-polyfill child-replace-with-polyfill classlist-polyfill @webcomponents/template shim-keyboard-event-key
```

@@ -50,2 +50,3 @@

import "classlist-polyfill"
import "@webcomponents/template"
import "shim-keyboard-event-key"

@@ -52,0 +53,0 @@