Skip to main content

priv/static/durable_dashboard/app.js

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./flow_graph-Cp6z_J_Q.js","./vendor-xyflow-uXvVV99t.js"])))=>i.map(i=>d[i]);
var Ne=t=>typeof t=="function"?t:function(){return t},Ci=typeof self<"u"?self:null,Ee=typeof window<"u"?window:null,z=Ci||Ee||globalThis,Ti="2.0.0",G={connecting:0,open:1,closing:2,closed:3},_i=1e4,Pi=1e3,j={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ee={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},mt={longpoll:"longpoll",websocket:"websocket"},Ri={complete:4},gt="base64url.bearer.phx.",Be=class{constructor(t,e,i,s){this.channel=t,this.event=e,this.payload=i||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:t,response:e,_ref:i}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},di=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},xi=class{constructor(t,e,i){this.state=j.closed,this.topic=t,this.params=Ne(e||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Be(this,ee.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new di(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=j.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=j.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=j.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=j.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new Be(this,ee.leave,Ne({}),this.timeout).send(),this.state=j.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(ee.reply,(s,n)=>{this.trigger(this.replyEventName(n),s)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(t){this.on(ee.close,t)}onError(t){return this.on(ee.error,e=>t(e))}on(t,e){let i=this.bindingRef++;return this.bindings.push({event:t,ref:i,callback:e}),i}off(t,e){this.bindings=this.bindings.filter(i=>!(i.event===t&&(typeof e>"u"||e===i.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,i=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new Be(this,t,function(){return e},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=j.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(ee.close,"leave")},i=new Be(this,ee.leave,Ne({}),t);return i.receive("ok",()=>e()).receive("timeout",()=>e()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(t,e,i){return e}isMember(t,e,i,s){return this.topic!==t?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:i,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=j.joining,this.joinPush.resend(t))}trigger(t,e,i,s){let n=this.onMessage(t,e,i,s);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(o=>o.event===t);for(let o=0;o<r.length;o++)r[o].callback(n,i,s||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===j.closed}isErrored(){return this.state===j.errored}isJoined(){return this.state===j.joined}isJoining(){return this.state===j.joining}isLeaving(){return this.state===j.leaving}},tt=class{static request(t,e,i,s,n,r,o){if(z.XDomainRequest){let a=new z.XDomainRequest;return this.xdomainRequest(a,t,e,s,n,r,o)}else if(z.XMLHttpRequest){let a=new z.XMLHttpRequest;return this.xhrRequest(a,t,e,i,s,n,r,o)}else{if(z.fetch&&z.AbortController)return this.fetchRequest(t,e,i,s,n,r,o);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,i,s,n,r,o){let a={method:t,headers:i,body:s},h=null;return n&&(h=new AbortController,setTimeout(()=>h.abort(),n),a.signal=h.signal),z.fetch(e,a).then(c=>c.text()).then(c=>this.parseJSON(c)).then(c=>o&&o(c)).catch(c=>{c.name==="AbortError"&&r?r():o&&o(null)}),h}static xdomainRequest(t,e,i,s,n,r,o){return t.timeout=n,t.open(e,i),t.onload=()=>{let a=this.parseJSON(t.responseText);o&&o(a)},r&&(t.ontimeout=r),t.onprogress=()=>{},t.send(s),t}static xhrRequest(t,e,i,s,n,r,o,a){t.open(e,i,!0),t.timeout=r;for(let[h,c]of Object.entries(s))t.setRequestHeader(h,c);return t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===Ri.complete&&a){let h=this.parseJSON(t.responseText);a(h)}},o&&(t.ontimeout=o),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let i=[];for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let n=e?`${e}[${s}]`:s,r=t[s];typeof r=="object"?i.push(this.serialize(r,n)):i.push(encodeURIComponent(n)+"="+encodeURIComponent(r))}return i.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let i=t.match(/\?/)?"&":"?";return`${t}${i}${this.serialize(e)}`}},Li=t=>{let e="",i=new Uint8Array(t),s=i.byteLength;for(let n=0;n<s;n++)e+=String.fromCharCode(i[n]);return btoa(e)},we=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(gt)&&(this.authToken=atob(e[1].slice(gt.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=G.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+mt.websocket),"$1/"+mt.longpoll)}endpointURL(){return tt.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,i){this.close(t,e,i),this.readyState=G.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===G.open||this.readyState===G.connecting}poll(){const t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:i,token:s,messages:n}=e;if(i===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=s}else i=0;switch(i){case 200:n.forEach(r=>{setTimeout(()=>this.onmessage({data:r}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=G.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${i}`)}})}send(t){typeof t!="string"&&(t=Li(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},t.join(`
`),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,!e||e.status!==200?(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(t,e,i){for(let n of this.reqs)n.abort();this.readyState=G.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(t,e,i,s,n){let r,o=()=>{this.reqs.delete(r),s()};r=tt.request(t,this.endpointURL(),e,i,this.timeout,o,a=>{this.reqs.delete(r),this.isActive()&&n(a)}),this.reqs.add(r)}},Ve={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let i=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(i))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[i,s,n,r,o]=JSON.parse(t);return e({join_ref:i,ref:s,topic:n,event:r,payload:o})}},binaryEncode(t){let{join_ref:e,ref:i,event:s,topic:n,payload:r}=t,o=this.META_LENGTH+e.length+i.length+n.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),h=new DataView(a),c=0;h.setUint8(c++,this.KINDS.push),h.setUint8(c++,e.length),h.setUint8(c++,i.length),h.setUint8(c++,n.length),h.setUint8(c++,s.length),Array.from(e,p=>h.setUint8(c++,p.charCodeAt(0))),Array.from(i,p=>h.setUint8(c++,p.charCodeAt(0))),Array.from(n,p=>h.setUint8(c++,p.charCodeAt(0))),Array.from(s,p=>h.setUint8(c++,p.charCodeAt(0)));var d=new Uint8Array(a.byteLength+r.byteLength);return d.set(new Uint8Array(a),0),d.set(new Uint8Array(r),a.byteLength),d.buffer},binaryDecode(t){let e=new DataView(t),i=e.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(t,e,s);case this.KINDS.reply:return this.decodeReply(t,e,s);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,s)}},decodePush(t,e,i){let s=e.getUint8(1),n=e.getUint8(2),r=e.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=i.decode(t.slice(o,o+s));o=o+s;let h=i.decode(t.slice(o,o+n));o=o+n;let c=i.decode(t.slice(o,o+r));o=o+r;let d=t.slice(o,t.byteLength);return{join_ref:a,ref:null,topic:h,event:c,payload:d}},decodeReply(t,e,i){let s=e.getUint8(1),n=e.getUint8(2),r=e.getUint8(3),o=e.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,h=i.decode(t.slice(a,a+s));a=a+s;let c=i.decode(t.slice(a,a+n));a=a+n;let d=i.decode(t.slice(a,a+r));a=a+r;let p=i.decode(t.slice(a,a+o));a=a+o;let m=t.slice(a,t.byteLength),g={status:p,response:m};return{join_ref:h,ref:c,topic:d,event:ee.reply,payload:g}},decodeBroadcast(t,e,i){let s=e.getUint8(1),n=e.getUint8(2),r=this.HEADER_LENGTH+2,o=i.decode(t.slice(r,r+s));r=r+s;let a=i.decode(t.slice(r,r+n));r=r+n;let h=t.slice(r,t.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:h}}},Ii=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||_i,this.transport=e.transport||z.WebSocket||we,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=e.sessionStorage||z&&z.sessionStorage,this.establishedConnections=0,this.defaultEncoder=Ve.encode.bind(Ve),this.defaultDecoder=Ve.decode.bind(Ve),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.transport!==we?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;Ee&&Ee.addEventListener&&(Ee.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),Ee.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect())}),Ee.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>e.rejoinAfterMs?e.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>e.reconnectAfterMs?e.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(s,n,r)=>{console.log(`${s}: ${n}`,r)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=Ne(e.params||{}),this.endPoint=`${t}/${mt.websocket}`,this.vsn=e.vsn||Ti,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new di(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(()=>this.connect())},this.reconnectAfterMs),this.authToken=e.authToken}getLongPollTransport(){return we}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=tt.appendParams(tt.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,i){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,i)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Ne(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==we?this.connectWithFallback(we,this.longPollFallbackMs):this.transportConnect())}log(t,e,i){this.logger&&this.logger(t,e,i)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let s=this.onMessage(n=>{n.ref===e&&(this.off([s]),t(Date.now()-i))});return!0}transportName(t){switch(t){case we:return"LongPoll";default:return t.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${gt}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let i=!1,s=!0,n,r,o=this.transportName(t),a=h=>{this.log("transport",`falling back to ${o}...`,h),this.off([n,r]),s=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${o}`))return a("memorized");this.fallbackTimer=setTimeout(a,e),r=this.onError(h=>{this.log("transport","error",h),s&&!i&&(clearTimeout(this.fallbackTimer),a(h))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(i=!0,!s){let h=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${h}`,"true"),this.log("transport",`established ${h} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(a,e),this.ping(h=>{this.log("transport","connected to primary after",h),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transportName(this.transport)} connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,t])=>t())}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Pi,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,i){if(!this.conn)return t&&t();const s=this.conn;this.waitForBufferDone(s,()=>{e?s.close(e,i||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e,i=1){if(i===5||!t.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(t,e,i+1)},150*i)}waitForSocketClosed(t,e,i=1){if(i===5||t.readyState===G.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(t,e,i+1)},150*i)}onConnClose(t){this.conn&&(this.conn.onclose=()=>{});let e=t&&t.code;this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&e!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(t))}onConnError(t){this.hasLogger()&&this.log("transport",t);let e=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(t,e,i)}),(e===this.transport||i>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(ee.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case G.connecting:return"connecting";case G.open:return"open";case G.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([i])=>t.indexOf(i)===-1)}channel(t,e={}){let i=new xi(t,e,this);return this.channels.push(i),i}push(t){if(this.hasLogger()){let{topic:e,event:i,payload:s,ref:n,join_ref:r}=t;this.log("push",`${e} ${i} (${r}, ${n})`,s)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:i,event:s,payload:n,ref:r,join_ref:o}=e;r&&r===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${n.status||""} ${i} ${s} ${r&&"("+r+")"||""}`,n);for(let a=0;a<this.channels.length;a++){const h=this.channels[a];h.isMember(i,s,n,o)&&h.trigger(s,n,r,o)}for(let a=0;a<this.stateChangeCallbacks.message.length;a++){let[,h]=this.stateChangeCallbacks.message[a];h(e)}})}leaveOpenTopic(t){let e=this.channels.find(i=>i.topic===t&&(i.isJoined()||i.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}},ui="consecutive-reloads",Oi=10,Di=5e3,Hi=1e4,Ni=3e4,fi=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],ht="phx-drop-target-active",Y="data-phx-component",Te="data-phx-view",lt="data-phx-link",$i="track-static",Mi="data-phx-link-state",_e="data-phx-ref-loading",J="data-phx-ref-src",O="data-phx-ref-lock",Dt="phx-pending-refs",pi="track-uploads",ie="data-phx-upload-ref",Tt="data-phx-preflighted-refs",Fi="data-phx-done-refs",Je="drop-target",vt="data-phx-active-refs",Ye="phx:live-file:updated",mi="data-phx-skip",gi="data-phx-id",Ht="data-phx-prune",Nt="phx-connected",le="phx-loading",ye="phx-error",$t="phx-client-error",Pe="phx-server-error",pe="data-phx-parent-id",_t="data-phx-main",ae="data-phx-root-id",bt="viewport-top",wt="viewport-bottom",Ui="viewport-overrun-target",ji="trigger-action",it="phx-has-focused",Bi=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],vi=["checkbox","radio"],$e="phx-has-submitted",Q="data-phx-session",Me=`[${Q}]`,yt="data-phx-sticky",fe="data-phx-static",kt="data-phx-readonly",Se="data-phx-disabled",Mt="disable-with",st="data-phx-disable-with-restore",Re="hook",Vi="debounce",Ji="throttle",nt="update",Qe="stream",xe="data-phx-stream",Pt="data-phx-portal",me="data-phx-teleported",he="data-phx-teleported-src",Ze="data-phx-runtime-hook",Xi="data-phx-pid",qi="key",W="phxPrivate",Ft="auto-recover",Xe="phx:live-socket:debug",ct="phx:live-socket:profiling",dt="phx:live-socket:latency-sim",qe="phx:nav-history-position",Wi="progress",Ut="mounted",jt="__phoenix_reload_status__",Ki=1,Bt=3,zi=200,Gi=500,Yi="phx-",Qi=3e4,Le="debounce-trigger",Ie="throttled",Vt="debounce-prev-key",Zi={debounce:300,throttle:300},Jt=[_e,J,O],V="s",ut="r",M="c",L="k",K="kc",Xt="e",qt="r",Wt="t",re="p",ke="stream",es=class{constructor(t,e,i){const{chunk_size:s,chunk_timeout:n}=e;this.liveSocket=i,this.entry=t,this.offset=0,this.chunkSize=s,this.chunkTimeout=n,this.chunkTimer=null,this.errored=!1,this.uploadChannel=i.channel(`lvu:${t.ref}`,{token:t.metadata()})}error(t){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(t))}upload(){this.uploadChannel.onError(t=>this.error(t)),this.uploadChannel.join().receive("ok",t=>this.readNextChunk()).receive("error",t=>this.error(t))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){const t=new window.FileReader,e=this.entry.file.slice(this.offset,this.chunkSize+this.offset);t.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return P("Read error: "+i.target.error)},t.readAsArrayBuffer(e)}pushChunk(t){this.uploadChannel.isJoined()&&this.uploadChannel.push("chunk",t,this.chunkTimeout).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))}).receive("error",({reason:e})=>this.error(e))}},P=(t,e)=>console.error&&console.error(t,e),te=t=>{const e=typeof t;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(t)};function ts(){const t=new Set,e=document.querySelectorAll("*[id]");for(let i=0,s=e.length;i<s;i++)t.has(e[i].id)?console.error(`Multiple IDs detected: ${e[i].id}. Ensure unique element ids.`):t.add(e[i].id)}function is(t){const e=new Set;Object.keys(t).forEach(i=>{const s=document.getElementById(i);s&&s.parentElement&&s.parentElement.getAttribute("phx-update")!=="stream"&&e.add(`The stream container with id "${s.parentElement.id}" is missing the phx-update="stream" attribute. Ensure it is set for streams to work properly.`)}),e.forEach(i=>console.error(i))}var ss=(t,e,i,s)=>{t.liveSocket.isDebugEnabled()&&console.log(`${t.id} ${e}: ${i} - `,s)},Oe=t=>typeof t=="function"?t:function(){return t},et=t=>JSON.parse(JSON.stringify(t)),ue=(t,e,i)=>{do{if(t.matches(`[${e}]`)&&!t.disabled)return t;t=t.parentElement||t.parentNode}while(t!==null&&t.nodeType===1&&!(i&&i.isSameNode(t)||t.matches(Me)));return null},Ae=t=>t!==null&&typeof t=="object"&&!(t instanceof Array),ns=(t,e)=>JSON.stringify(t)===JSON.stringify(e),Kt=t=>{for(const e in t)return!1;return!0},Ce=(t,e)=>t&&e(t),rs=function(t,e,i,s){t.forEach(n=>{new es(n,i.config,s).upload()})},os=t=>{if(t.dataTransfer.types){for(let e=0;e<t.dataTransfer.types.length;e++)if(t.dataTransfer.types[e]==="Files")return!0}return!1},as={canPushState(){return typeof history.pushState<"u"},dropLocal(t,e,i){return t.removeItem(this.localKey(e,i))},updateLocal(t,e,i,s,n){const r=this.getLocal(t,e,i),o=this.localKey(e,i),a=r===null?s:n(r);return t.setItem(o,JSON.stringify(a)),a},getLocal(t,e,i){return JSON.parse(t.getItem(this.localKey(e,i)))},updateCurrentState(t){this.canPushState()&&history.replaceState(t(history.state||{}),"",window.location.href)},pushState(t,e,i){if(this.canPushState()){if(i!==window.location.href){if(e.type=="redirect"&&e.scroll){const s=history.state||{};s.scroll=e.scroll,history.replaceState(s,"",window.location.href)}delete e.scroll,history[t+"State"](e,"",i||null),window.requestAnimationFrame(()=>{const s=this.getHashTargetEl(window.location.hash);s?s.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)})}}else this.redirect(i)},setCookie(t,e,i){const s=typeof i=="number"?` max-age=${i};`:"";document.cookie=`${t}=${e};${s} path=/`},getCookie(t){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${t}s*=s*([^;]*).*$)|^.*$`),"$1")},deleteCookie(t){document.cookie=`${t}=; max-age=-1; path=/`},redirect(t,e,i=s=>{window.location.href=s}){e&&this.setCookie("__phoenix_flash__",e,60),i(t)},localKey(t,e){return`${t}-${e}`},getHashTargetEl(t){const e=t.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},U=as,de={byId(t){return document.getElementById(t)||P(`no id found for ${t}`)},removeClass(t,e){t.classList.remove(e),t.classList.length===0&&t.removeAttribute("class")},all(t,e,i){if(!t)return[];const s=Array.from(t.querySelectorAll(e));return i&&s.forEach(i),s},childNodeLength(t){const e=document.createElement("template");return e.innerHTML=t,e.content.childElementCount},isUploadInput(t){return t.type==="file"&&t.getAttribute(ie)!==null},isAutoUpload(t){return t.hasAttribute("data-phx-auto-upload")},findUploadInputs(t){const e=t.id,i=this.all(document,`input[type="file"][${ie}][form="${e}"]`);return this.all(t,`input[type="file"][${ie}]`).concat(i)},findComponentNodeList(t,e,i=document){return this.all(i,`[${Te}="${t}"][${Y}="${e}"]`)},isPhxDestroyed(t){return!!(t.id&&de.private(t,"destroyed"))},wantsNewTab(t){const e=t.ctrlKey||t.shiftKey||t.metaKey||t.button&&t.button===1,i=t.target instanceof HTMLAnchorElement&&t.target.hasAttribute("download"),s=t.target.hasAttribute("target")&&t.target.getAttribute("target").toLowerCase()==="_blank",n=t.target.hasAttribute("target")&&!t.target.getAttribute("target").startsWith("_");return e||s||i||n},isUnloadableFormSubmit(t){return t.target&&t.target.getAttribute("method")==="dialog"||t.submitter&&t.submitter.getAttribute("formmethod")==="dialog"?!1:!t.defaultPrevented&&!this.wantsNewTab(t)},isNewPageClick(t,e){const i=t.target instanceof HTMLAnchorElement?t.target.getAttribute("href"):null;let s;if(t.defaultPrevented||i===null||this.wantsNewTab(t)||i.startsWith("mailto:")||i.startsWith("tel:")||t.target.isContentEditable)return!1;try{s=new URL(i)}catch{try{s=new URL(i,e)}catch{return!0}}return s.host===e.host&&s.protocol===e.protocol&&s.pathname===e.pathname&&s.search===e.search?s.hash===""&&!s.href.endsWith("#"):s.protocol.startsWith("http")},markPhxChildDestroyed(t){this.isPhxChild(t)&&t.setAttribute(Q,""),this.putPrivate(t,"destroyed",!0)},findPhxChildrenInFragment(t,e){const i=document.createElement("template");return i.innerHTML=t,this.findPhxChildren(i.content,e)},isIgnored(t,e){return(t.getAttribute(e)||t.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(t,e,i){return t.getAttribute&&i.indexOf(t.getAttribute(e))>=0},findPhxSticky(t){return this.all(t,`[${yt}]`)},findPhxChildren(t,e){return this.all(t,`${Me}[${pe}="${e}"]`)},findExistingParentCIDs(t,e){const i=new Set,s=new Set;return e.forEach(n=>{this.all(document,`[${Te}="${t}"][${Y}="${n}"]`).forEach(r=>{i.add(n),this.all(r,`[${Te}="${t}"][${Y}]`).map(o=>parseInt(o.getAttribute(Y))).forEach(o=>s.add(o))})}),s.forEach(n=>i.delete(n)),i},private(t,e){return t[W]&&t[W][e]},deletePrivate(t,e){t[W]&&delete t[W][e]},putPrivate(t,e,i){t[W]||(t[W]={}),t[W][e]=i},updatePrivate(t,e,i,s){const n=this.private(t,e);n===void 0?this.putPrivate(t,e,s(i)):this.putPrivate(t,e,s(n))},syncPendingAttrs(t,e){t.hasAttribute(J)&&(fi.forEach(i=>{t.classList.contains(i)&&e.classList.add(i)}),Jt.filter(i=>t.hasAttribute(i)).forEach(i=>{e.setAttribute(i,t.getAttribute(i))}))},copyPrivates(t,e){e[W]&&(t[W]=e[W])},putTitle(t){const e=document.querySelector("title");if(e){const{prefix:i,suffix:s,default:n}=e.dataset,r=typeof t!="string"||t.trim()==="";if(r&&typeof n!="string")return;const o=r?n:t;document.title=`${i||""}${o||""}${s||""}`}else document.title=t},debounce(t,e,i,s,n,r,o,a){let h=t.getAttribute(i),c=t.getAttribute(n);h===""&&(h=s),c===""&&(c=r);const d=h||c;switch(d){case null:return a();case"blur":this.incCycle(t,"debounce-blur-cycle",()=>{o()&&a()}),this.once(t,"debounce-blur")&&t.addEventListener("blur",()=>this.triggerCycle(t,"debounce-blur-cycle"));return;default:const p=parseInt(d),m=()=>c?this.deletePrivate(t,Ie):a(),g=this.incCycle(t,Le,m);if(isNaN(p))return P(`invalid throttle/debounce value: ${d}`);if(c){let v=!1;if(e.type==="keydown"){const w=this.private(t,Vt);this.putPrivate(t,Vt,e.key),v=w!==e.key}if(!v&&this.private(t,Ie))return!1;{a();const w=setTimeout(()=>{o()&&this.triggerCycle(t,Le)},p);this.putPrivate(t,Ie,w)}}else setTimeout(()=>{o()&&this.triggerCycle(t,Le,g)},p);const u=t.form;u&&this.once(u,"bind-debounce")&&u.addEventListener("submit",()=>{Array.from(new FormData(u).entries(),([v])=>{const w=u.elements.namedItem(v),D=w instanceof RadioNodeList?w[0]:w;D&&(this.incCycle(D,Le),this.deletePrivate(D,Ie))})}),this.once(t,"bind-debounce")&&t.addEventListener("blur",()=>{clearTimeout(this.private(t,Ie)),this.triggerCycle(t,Le)})}},triggerCycle(t,e,i){const[s,n]=this.private(t,e);i||(i=s),i===s&&(this.incCycle(t,e),n())},once(t,e){return this.private(t,e)===!0?!1:(this.putPrivate(t,e,!0),!0)},incCycle(t,e,i=function(){}){let[s]=this.private(t,e)||[0,i];return s++,this.putPrivate(t,e,[s,i]),s},maintainPrivateHooks(t,e,i,s){t.hasAttribute&&t.hasAttribute("data-phx-hook")&&!e.hasAttribute("data-phx-hook")&&e.setAttribute("data-phx-hook",t.getAttribute("data-phx-hook")),e.hasAttribute&&(e.hasAttribute(i)||e.hasAttribute(s))&&e.setAttribute("data-phx-hook","Phoenix.InfiniteScroll")},putCustomElHook(t,e){t.isConnected?t.setAttribute("data-phx-hook",""):console.error(`
        hook attached to non-connected DOM element
        ensure you are calling createHook within your connectedCallback. ${t.outerHTML}
      `),this.putPrivate(t,"custom-el-hook",e)},getCustomElHook(t){return this.private(t,"custom-el-hook")},isUsedInput(t){return t.nodeType===Node.ELEMENT_NODE&&(this.private(t,it)||this.private(t,$e))},resetForm(t){Array.from(t.elements).forEach(e=>{this.deletePrivate(e,it),this.deletePrivate(e,$e)})},isPhxChild(t){return t.getAttribute&&t.getAttribute(pe)},isPhxSticky(t){return t.getAttribute&&t.getAttribute(yt)!==null},isChildOfAny(t,e){return!!e.find(i=>i.contains(t))},firstPhxChild(t){return this.isPhxChild(t)?t:this.all(t,`[${pe}]`)[0]},isPortalTemplate(t){return t.tagName==="TEMPLATE"&&t.hasAttribute(Pt)},closestViewEl(t){const e=t.closest(`[${me}],${Me}`);return e?e.hasAttribute(me)?this.byId(e.getAttribute(me)):e.hasAttribute(Q)?e:null:null},dispatchEvent(t,e,i={}){let s=!0;t.nodeName==="INPUT"&&t.type==="file"&&e==="click"&&(s=!1);const o={bubbles:i.bubbles===void 0?s:!!i.bubbles,cancelable:!0,detail:i.detail||{}},a=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);t.dispatchEvent(a)},cloneNode(t,e){if(typeof e>"u")return t.cloneNode(!0);{const i=t.cloneNode(!1);return i.innerHTML=e,i}},mergeAttrs(t,e,i={}){const s=new Set(i.exclude||[]),n=i.isIgnored,r=e.attributes;for(let a=r.length-1;a>=0;a--){const h=r[a].name;if(s.has(h)){if(h==="value"){const c=e.value??e.getAttribute(h);t.value===c&&t.setAttribute("value",e.getAttribute(h))}}else{const c=e.getAttribute(h);t.getAttribute(h)!==c&&(!n||n&&h.startsWith("data-"))&&t.setAttribute(h,c)}}const o=t.attributes;for(let a=o.length-1;a>=0;a--){const h=o[a].name;n?h.startsWith("data-")&&!e.hasAttribute(h)&&!Jt.includes(h)&&t.removeAttribute(h):e.hasAttribute(h)||t.removeAttribute(h)}},mergeFocusedInput(t,e){t instanceof HTMLSelectElement||de.mergeAttrs(t,e,{exclude:["value"]}),e.readOnly?t.setAttribute("readonly",!0):t.removeAttribute("readonly")},hasSelectionRange(t){return t.setSelectionRange&&(t.type==="text"||t.type==="textarea")},restoreFocus(t,e,i){if(t instanceof HTMLSelectElement&&t.focus(),!de.isTextualInput(t))return;t.matches(":focus")||t.focus(),this.hasSelectionRange(t)&&t.setSelectionRange(e,i)},isFormInput(t){return t.localName&&customElements.get(t.localName)?customElements.get(t.localName).formAssociated:/^(?:input|select|textarea)$/i.test(t.tagName)&&t.type!=="button"},syncAttrsToProps(t){t instanceof HTMLInputElement&&vi.indexOf(t.type.toLocaleLowerCase())>=0&&(t.checked=t.getAttribute("checked")!==null)},isTextualInput(t){return Bi.indexOf(t.type)>=0},isNowTriggerFormExternal(t,e){return t.getAttribute&&t.getAttribute(e)!==null&&document.body.contains(t)},cleanChildNodes(t,e){if(de.isPhxUpdate(t,e,["append","prepend",Qe])){const i=[];t.childNodes.forEach(s=>{s.id||(!(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()==="")&&s.nodeType!==Node.COMMENT_NODE&&P(`only HTML element tags with an id are allowed inside containers with phx-update.

removing illegal node: "${(s.outerHTML||s.nodeValue).trim()}"

`),i.push(s))}),i.forEach(s=>s.remove())}},replaceRootContainer(t,e,i){const s=new Set(["id",Q,fe,_t,ae]);if(t.tagName.toLowerCase()===e.toLowerCase())return Array.from(t.attributes).filter(n=>!s.has(n.name.toLowerCase())).forEach(n=>t.removeAttribute(n.name)),Object.keys(i).filter(n=>!s.has(n.toLowerCase())).forEach(n=>t.setAttribute(n,i[n])),t;{const n=document.createElement(e);return Object.keys(i).forEach(r=>n.setAttribute(r,i[r])),s.forEach(r=>n.setAttribute(r,t.getAttribute(r))),n.innerHTML=t.innerHTML,t.replaceWith(n),n}},getSticky(t,e,i){const s=(de.private(t,"sticky")||[]).find(([n])=>e===n);if(s){const[n,r,o]=s;return o}else return typeof i=="function"?i():i},deleteSticky(t,e){this.updatePrivate(t,"sticky",[],i=>i.filter(([s,n])=>s!==e))},putSticky(t,e,i){const s=i(t);this.updatePrivate(t,"sticky",[],n=>{const r=n.findIndex(([o])=>e===o);return r>=0?n[r]=[e,i,s]:n.push([e,i,s]),n})},applyStickyOperations(t){const e=de.private(t,"sticky");e&&e.forEach(([i,s,n])=>this.putSticky(t,i,s))},isLocked(t){return t.hasAttribute&&t.hasAttribute(O)},attributeIgnored(t,e){return e.some(i=>t.name==i||i==="*"||i.includes("*")&&t.name.match(i)!=null)}},l=de,De=class{static isActive(t,e){const i=e._phxRef===void 0,n=t.getAttribute(vt).split(",").indexOf(N.genFileRef(e))>=0;return e.size>0&&(i||n)}static isPreflighted(t,e){return t.getAttribute(Tt).split(",").indexOf(N.genFileRef(e))>=0&&this.isActive(t,e)}static isPreflightInProgress(t){return t._preflightInProgress===!0}static markPreflightInProgress(t){t._preflightInProgress=!0}constructor(t,e,i,s){this.ref=N.genFileRef(e),this.fileEl=t,this.file=e,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(Ye,this._onElUpdated),this.autoUpload=s}metadata(){return this.meta}progress(t){this._progress=Math.floor(t),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{N.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(t="failed"){this.fileEl.removeEventListener(Ye,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:t}),this.isAutoUpload()||N.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(t){this._onDone=()=>{this.fileEl.removeEventListener(Ye,this._onElUpdated),t()}}onElUpdated(){this.fileEl.getAttribute(vt).split(",").indexOf(this.ref)===-1&&(N.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(t){if(this.meta.uploader){const e=t[this.meta.uploader]||P(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:e}}else return{name:"channel",callback:rs}}zipPostFlight(t){this.meta=t.entries[this.ref],this.meta||P(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:t})}},hs=0,N=class At{static genFileRef(e){const i=e._phxRef;return i!==void 0?i:(e._phxRef=(hs++).toString(),e._phxRef)}static getEntryDataURL(e,i,s){const n=this.activeFiles(e).find(r=>this.genFileRef(r)===i);s(URL.createObjectURL(n))}static hasUploadsInProgress(e){let i=0;return l.findUploadInputs(e).forEach(s=>{s.getAttribute(Tt)!==s.getAttribute(Fi)&&i++}),i>0}static serializeUploads(e){const i=this.activeFiles(e),s={};return i.forEach(n=>{const r={path:e.name},o=e.getAttribute(ie);s[o]=s[o]||[],r.ref=this.genFileRef(n),r.last_modified=n.lastModified,r.name=n.name||r.ref,r.relative_path=n.webkitRelativePath,r.type=n.type,r.size=n.size,typeof n.meta=="function"&&(r.meta=n.meta()),s[o].push(r)}),s}static clearFiles(e){e.value=null,e.removeAttribute(ie),l.putPrivate(e,"files",[])}static untrackFile(e,i){l.putPrivate(e,"files",l.private(e,"files").filter(s=>!Object.is(s,i)))}static trackFiles(e,i,s){if(e.getAttribute("multiple")!==null){const n=i.filter(r=>!this.activeFiles(e).find(o=>Object.is(o,r)));l.updatePrivate(e,"files",[],r=>r.concat(n)),e.value=null}else s&&s.files.length>0&&(e.files=s.files),l.putPrivate(e,"files",i)}static activeFileInputs(e){const i=l.findUploadInputs(e);return Array.from(i).filter(s=>s.files&&this.activeFiles(s).length>0)}static activeFiles(e){return(l.private(e,"files")||[]).filter(i=>De.isActive(e,i))}static inputsAwaitingPreflight(e){const i=l.findUploadInputs(e);return Array.from(i).filter(s=>this.filesAwaitingPreflight(s).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(i=>!De.isPreflighted(e,i)&&!De.isPreflightInProgress(i))}static markPreflightInProgress(e){e.forEach(i=>De.markPreflightInProgress(i.file))}constructor(e,i,s){this.autoUpload=l.isAutoUpload(e),this.view=i,this.onComplete=s,this._entries=Array.from(At.filesAwaitingPreflight(e)||[]).map(n=>new De(e,n,i,this.autoUpload)),At.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}isAutoUpload(){return this.autoUpload}entries(){return this._entries}initAdapterUpload(e,i,s){this._entries=this._entries.map(r=>(r.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(r.zipPostFlight(e),r.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),r));const n=this._entries.reduce((r,o)=>{if(!o.meta)return r;const{name:a,callback:h}=o.uploader(s.uploaders);return r[a]=r[a]||{callback:h,entries:[]},r[a].entries.push(o),r},{});for(const r in n){const{callback:o,entries:a}=n[r];o(a,i,e,s)}}},ls={anyOf(t,e){return e.find(i=>t instanceof i)},isFocusable(t,e){return t instanceof HTMLAnchorElement&&t.rel!=="ignore"||t instanceof HTMLAreaElement&&t.href!==void 0||!t.disabled&&this.anyOf(t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||t instanceof HTMLIFrameElement||t.tabIndex>=0&&t.getAttribute("aria-hidden")!=="true"||!e&&t.getAttribute("tabindex")!==null&&t.getAttribute("aria-hidden")!=="true"},attemptFocus(t,e){if(this.isFocusable(t,e))try{t.focus()}catch{}return!!document.activeElement&&document.activeElement.isSameNode(t)},focusFirstInteractive(t){let e=t.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e))return!0;e=e.nextElementSibling}},focusFirst(t){let e=t.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(t){let e=t.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},B=ls,bi={LiveFileUpload:{activeRefs(){return this.el.getAttribute(vt)},preflightedRefs(){return this.el.getAttribute(Tt)},mounted(){this.js().ignoreAttributes(this.el,["value"]),this.preflightedWas=this.preflightedRefs()},updated(){const t=this.preflightedRefs();this.preflightedWas!==t&&(this.preflightedWas=t,t===""&&this.__view().cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(Ye))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(ie)),N.getEntryDataURL(this.inputEl,this.ref,t=>{this.url=t,this.el.src=t})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",t=>{if(!t.relatedTarget||!this.el.contains(t.relatedTarget)){const e=t.target.nextElementSibling;B.attemptFocus(e)||B.focusFirst(e)}else B.focusLast(this.el)}),this.focusEnd.addEventListener("focus",t=>{if(!t.relatedTarget||!this.el.contains(t.relatedTarget)){const e=t.target.previousElementSibling;B.attemptFocus(e)||B.focusLast(e)}else B.focusFirst(this.el)}),this.el.contains(document.activeElement)||(this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&B.focusFirst(this.el))}}},wi=t=>["HTML","BODY"].indexOf(t.nodeName.toUpperCase())>=0?null:["scroll","auto"].indexOf(getComputedStyle(t).overflowY)>=0?t:wi(t.parentElement),zt=t=>t?t.scrollTop:document.documentElement.scrollTop||document.body.scrollTop,Rt=t=>t?t.getBoundingClientRect().bottom:window.innerHeight||document.documentElement.clientHeight,xt=t=>t?t.getBoundingClientRect().top:0,cs=(t,e)=>{const i=t.getBoundingClientRect();return Math.ceil(i.top)>=xt(e)&&Math.ceil(i.left)>=0&&Math.floor(i.top)<=Rt(e)},ds=(t,e)=>{const i=t.getBoundingClientRect();return Math.ceil(i.bottom)>=xt(e)&&Math.ceil(i.left)>=0&&Math.floor(i.bottom)<=Rt(e)},Gt=(t,e)=>{const i=t.getBoundingClientRect();return Math.ceil(i.top)>=xt(e)&&Math.ceil(i.left)>=0&&Math.floor(i.top)<=Rt(e)};bi.InfiniteScroll={mounted(){this.scrollContainer=wi(this.el);let t=zt(this.scrollContainer),e=!1;const i=500;let s=null;const n=this.throttle(i,(a,h)=>{s=()=>!0,this.liveSocket.js().push(this.el,a,{value:{id:h.id,_overran:!0},callback:()=>{s=null}})}),r=this.throttle(i,(a,h)=>{s=()=>h.scrollIntoView({block:"start"}),this.liveSocket.js().push(this.el,a,{value:{id:h.id},callback:()=>{s=null,window.requestAnimationFrame(()=>{Gt(h,this.scrollContainer)||h.scrollIntoView({block:"start"})})}})}),o=this.throttle(i,(a,h)=>{s=()=>h.scrollIntoView({block:"end"}),this.liveSocket.js().push(this.el,a,{value:{id:h.id},callback:()=>{s=null,window.requestAnimationFrame(()=>{Gt(h,this.scrollContainer)||h.scrollIntoView({block:"end"})})}})});this.onScroll=a=>{const h=zt(this.scrollContainer);if(s)return t=h,s();const c=this.findOverrunTarget(),d=this.el.getAttribute(this.liveSocket.binding("viewport-top")),p=this.el.getAttribute(this.liveSocket.binding("viewport-bottom")),m=this.el.lastElementChild,g=this.el.firstElementChild,u=h<t,v=h>t;u&&d&&!e&&c.top>=0?(e=!0,n(d,g)):v&&e&&c.top<=0&&(e=!1),d&&u&&cs(g,this.scrollContainer)?r(d,g):p&&v&&ds(m,this.scrollContainer)&&o(p,m),t=h},this.scrollContainer?this.scrollContainer.addEventListener("scroll",this.onScroll):window.addEventListener("scroll",this.onScroll)},destroyed(){this.scrollContainer?this.scrollContainer.removeEventListener("scroll",this.onScroll):window.removeEventListener("scroll",this.onScroll)},throttle(t,e){let i=0,s;return(...n)=>{const r=Date.now(),o=t-(r-i);o<=0||o>t?(s&&(clearTimeout(s),s=null),i=r,e(...n)):s||(s=setTimeout(()=>{i=Date.now(),s=null,e(...n)},o))}},findOverrunTarget(){let t;const e=this.el.getAttribute(this.liveSocket.binding(Ui));if(e){const i=document.getElementById(e);if(i)t=i.getBoundingClientRect();else throw new Error("did not find element with id "+e)}else t=this.el.getBoundingClientRect();return t}};var us=bi,Et=class{static onUnlock(t,e){if(!l.isLocked(t)&&!t.closest(`[${O}]`))return e();const i=t.closest(`[${O}]`),s=i.closest(`[${O}]`).getAttribute(O);i.addEventListener(`phx:undo-lock:${s}`,()=>{e()},{once:!0})}constructor(t){this.el=t,this.loadingRef=t.hasAttribute(_e)?parseInt(t.getAttribute(_e),10):null,this.lockRef=t.hasAttribute(O)?parseInt(t.getAttribute(O),10):null}maybeUndo(t,e,i){if(!this.isWithin(t)){l.updatePrivate(this.el,Dt,[],s=>(s.push(t),s));return}this.undoLocks(t,e,i),this.undoLoading(t,e),l.updatePrivate(this.el,Dt,[],s=>s.filter(n=>{let r={detail:{ref:n,event:e},bubbles:!0,cancelable:!1};return this.loadingRef&&this.loadingRef>n&&this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${n}`,r)),this.lockRef&&this.lockRef>n&&this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${n}`,r)),n>t})),this.isFullyResolvedBy(t)&&this.el.removeAttribute(J)}isWithin(t){return!(this.loadingRef!==null&&this.loadingRef>t&&this.lockRef!==null&&this.lockRef>t)}undoLocks(t,e,i){if(!this.isLockUndoneBy(t))return;const s=l.private(this.el,O);s&&(i(s),l.deletePrivate(this.el,O)),this.el.removeAttribute(O);const n={detail:{ref:t,event:e},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-lock:${this.lockRef}`,n))}undoLoading(t,e){if(!this.isLoadingUndoneBy(t)){this.canUndoLoading(t)&&this.el.classList.contains("phx-submit-loading")&&this.el.classList.remove("phx-change-loading");return}if(this.canUndoLoading(t)){this.el.removeAttribute(_e);const i=this.el.getAttribute(Se),s=this.el.getAttribute(kt);s!==null&&(this.el.readOnly=s==="true",this.el.removeAttribute(kt)),i!==null&&(this.el.disabled=i==="true",this.el.removeAttribute(Se));const n=this.el.getAttribute(st);n!==null&&(this.el.textContent=n,this.el.removeAttribute(st));const r={detail:{ref:t,event:e},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`phx:undo-loading:${this.loadingRef}`,r))}fi.forEach(i=>{(i!=="phx-submit-loading"||this.canUndoLoading(t))&&l.removeClass(this.el,i)})}isLoadingUndoneBy(t){return this.loadingRef===null?!1:this.loadingRef<=t}isLockUndoneBy(t){return this.lockRef===null?!1:this.lockRef<=t}isFullyResolvedBy(t){return(this.loadingRef===null||this.loadingRef<=t)&&(this.lockRef===null||this.lockRef<=t)}canUndoLoading(t){return this.lockRef===null||this.lockRef<=t}},fs=class{constructor(t,e,i){const s=new Set,n=new Set([...e.children].map(o=>o.id)),r=[];Array.from(t.children).forEach(o=>{if(o.id&&(s.add(o.id),n.has(o.id))){const a=o.previousElementSibling&&o.previousElementSibling.id;r.push({elementId:o.id,previousElementId:a})}}),this.containerId=e.id,this.updateType=i,this.elementsToModify=r,this.elementIdsToAdd=[...n].filter(o=>!s.has(o))}perform(){const t=l.byId(this.containerId);t&&(this.elementsToModify.forEach(e=>{e.previousElementId?Ce(document.getElementById(e.previousElementId),i=>{Ce(document.getElementById(e.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):Ce(document.getElementById(e.elementId),i=>{i.previousElementSibling==null||t.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(e=>{Ce(document.getElementById(e),i=>t.insertAdjacentElement("afterbegin",i))}))}},Yt=11;function ps(t,e){var i=e.attributes,s,n,r,o,a;if(!(e.nodeType===Yt||t.nodeType===Yt)){for(var h=i.length-1;h>=0;h--)s=i[h],n=s.name,r=s.namespaceURI,o=s.value,r?(n=s.localName||n,a=t.getAttributeNS(r,n),a!==o&&(s.prefix==="xmlns"&&(n=s.name),t.setAttributeNS(r,n,o))):(a=t.getAttribute(n),a!==o&&t.setAttribute(n,o));for(var c=t.attributes,d=c.length-1;d>=0;d--)s=c[d],n=s.name,r=s.namespaceURI,r?(n=s.localName||n,e.hasAttributeNS(r,n)||t.removeAttributeNS(r,n)):e.hasAttribute(n)||t.removeAttribute(n)}}var We,ms="http://www.w3.org/1999/xhtml",F=typeof document>"u"?void 0:document,gs=!!F&&"content"in F.createElement("template"),vs=!!F&&F.createRange&&"createContextualFragment"in F.createRange();function bs(t){var e=F.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function ws(t){We||(We=F.createRange(),We.selectNode(F.body));var e=We.createContextualFragment(t);return e.childNodes[0]}function ys(t){var e=F.createElement("body");return e.innerHTML=t,e.childNodes[0]}function ks(t){return t=t.trim(),gs?bs(t):vs?ws(t):ys(t)}function Ke(t,e){var i=t.nodeName,s=e.nodeName,n,r;return i===s?!0:(n=i.charCodeAt(0),r=s.charCodeAt(0),n<=90&&r>=97?i===s.toUpperCase():r<=90&&n>=97?s===i.toUpperCase():!1)}function As(t,e){return!e||e===ms?F.createElement(t):F.createElementNS(e,t)}function Es(t,e){for(var i=t.firstChild;i;){var s=i.nextSibling;e.appendChild(i),i=s}return e}function ft(t,e,i){t[i]!==e[i]&&(t[i]=e[i],t[i]?t.setAttribute(i,""):t.removeAttribute(i))}var Qt={OPTION:function(t,e){var i=t.parentNode;if(i){var s=i.nodeName.toUpperCase();s==="OPTGROUP"&&(i=i.parentNode,s=i&&i.nodeName.toUpperCase()),s==="SELECT"&&!i.hasAttribute("multiple")&&(t.hasAttribute("selected")&&!e.selected&&(t.setAttribute("selected","selected"),t.removeAttribute("selected")),i.selectedIndex=-1)}ft(t,e,"selected")},INPUT:function(t,e){ft(t,e,"checked"),ft(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),e.hasAttribute("value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var i=e.value;t.value!==i&&(t.value=i);var s=t.firstChild;if(s){var n=s.nodeValue;if(n==i||!i&&n==t.placeholder)return;s.nodeValue=i}},SELECT:function(t,e){if(!e.hasAttribute("multiple")){for(var i=-1,s=0,n=t.firstChild,r,o;n;)if(o=n.nodeName&&n.nodeName.toUpperCase(),o==="OPTGROUP")r=n,n=r.firstChild,n||(n=r.nextSibling,r=null);else{if(o==="OPTION"){if(n.hasAttribute("selected")){i=s;break}s++}n=n.nextSibling,!n&&r&&(n=r.nextSibling,r=null)}t.selectedIndex=i}}},He=1,Zt=11,ei=3,ti=8;function oe(){}function Ss(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}function Cs(t){return function(i,s,n){if(n||(n={}),typeof s=="string")if(i.nodeName==="#document"||i.nodeName==="HTML"){var r=s;s=F.createElement("html"),s.innerHTML=r}else if(i.nodeName==="BODY"){var o=s;s=F.createElement("html"),s.innerHTML=o;var a=s.querySelector("body");a&&(s=a)}else s=ks(s);else s.nodeType===Zt&&(s=s.firstElementChild);var h=n.getNodeKey||Ss,c=n.onBeforeNodeAdded||oe,d=n.onNodeAdded||oe,p=n.onBeforeElUpdated||oe,m=n.onElUpdated||oe,g=n.onBeforeNodeDiscarded||oe,u=n.onNodeDiscarded||oe,v=n.onBeforeElChildrenUpdated||oe,w=n.skipFromChildren||oe,D=n.addChild||function(y,k){return y.appendChild(k)},X=n.childrenOnly===!0,A=Object.create(null),C=[];function R(y){C.push(y)}function $(y,k){if(y.nodeType===He)for(var I=y.firstChild;I;){var E=void 0;k&&(E=h(I))?R(E):(u(I),I.firstChild&&$(I,k)),I=I.nextSibling}}function f(y,k,I){g(y)!==!1&&(k&&k.removeChild(y),u(y),$(y,I))}function b(y){if(y.nodeType===He||y.nodeType===Zt)for(var k=y.firstChild;k;){var I=h(k);I&&(A[I]=k),b(k),k=k.nextSibling}}b(i);function H(y){d(y);for(var k=y.firstChild;k;){var I=k.nextSibling,E=h(k);if(E){var T=A[E];T&&Ke(k,T)?(k.parentNode.replaceChild(T,k),x(T,k)):H(k)}else H(k);k=I}}function q(y,k,I){for(;k;){var E=k.nextSibling;(I=h(k))?R(I):f(k,y,!0),k=E}}function x(y,k,I){var E=h(k);if(E&&delete A[E],!I){var T=p(y,k);if(T===!1||(T instanceof HTMLElement&&(y=T,b(y)),t(y,k),m(y),v(y,k)===!1))return}y.nodeName!=="TEXTAREA"?ge(y,k):Qt.TEXTAREA(y,k)}function ge(y,k){var I=w(y,k),E=k.firstChild,T=y.firstChild,ve,Z,be,Ue,se;e:for(;E;){for(Ue=E.nextSibling,ve=h(E);!I&&T;){if(be=T.nextSibling,E.isSameNode&&E.isSameNode(T)){E=Ue,T=be;continue e}Z=h(T);var je=T.nodeType,ne=void 0;if(je===E.nodeType&&(je===He?(ve?ve!==Z&&((se=A[ve])?be===se?ne=!1:(y.insertBefore(se,T),Z?R(Z):f(T,y,!0),T=se,Z=h(T)):ne=!1):Z&&(ne=!1),ne=ne!==!1&&Ke(T,E),ne&&x(T,E)):(je===ei||je==ti)&&(ne=!0,T.nodeValue!==E.nodeValue&&(T.nodeValue=E.nodeValue))),ne){E=Ue,T=be;continue e}Z?R(Z):f(T,y,!0),T=be}if(ve&&(se=A[ve])&&Ke(se,E))I||D(y,se),x(se,E);else{var at=c(E);at!==!1&&(at&&(E=at),E.actualize&&(E=E.actualize(y.ownerDocument||F)),D(y,E),H(E))}E=Ue,T=be}q(y,T,Z);var Ot=Qt[y.nodeName];Ot&&Ot(y,k)}var _=i,Fe=_.nodeType,It=s.nodeType;if(!X){if(Fe===He)It===He?Ke(i,s)||(u(i),_=Es(i,As(s.nodeName,s.namespaceURI))):_=s;else if(Fe===ei||Fe===ti){if(It===Fe)return _.nodeValue!==s.nodeValue&&(_.nodeValue=s.nodeValue),_;_=s}}if(_===s)u(i);else{if(s.isSameNode&&s.isSameNode(_))return;if(x(_,s,X),C)for(var rt=0,Si=C.length;rt<Si;rt++){var ot=A[C[rt]];ot&&f(ot,ot.parentNode,!1)}}return!X&&_!==i&&i.parentNode&&(_.actualize&&(_=_.actualize(i.ownerDocument||F)),i.parentNode.replaceChild(_,i)),_}}var Ts=Cs(ps),St=Ts,ze=class{constructor(t,e,i,s,n,r,o={}){this.view=t,this.liveSocket=t.liveSocket,this.container=e,this.id=i,this.rootID=t.root.id,this.html=s,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=r,this.cidPatch=te(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=this.isCIDPatch()?this.targetCIDContainer(s):e,this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]},this.withChildren=o.withChildren||o.undoRef||!1,this.undoRef=o.undoRef}before(t,e){this.callbacks[`before${t}`].push(e)}after(t,e){this.callbacks[`after${t}`].push(e)}trackBefore(t,...e){this.callbacks[`before${t}`].forEach(i=>i(...e))}trackAfter(t,...e){this.callbacks[`after${t}`].forEach(i=>i(...e))}markPrunableContentForRemoval(){const t=this.liveSocket.binding(nt);l.all(this.container,`[${t}=append] > *, [${t}=prepend] > *`,e=>{e.setAttribute(Ht,"")})}perform(t){const{view:e,liveSocket:i,html:s,container:n}=this;let r=this.targetContainer;if(this.isCIDPatch()&&!this.targetContainer)return;if(this.isCIDPatch()){const A=r.closest(`[${O}]`);if(A&&!A.isSameNode(r)){const C=l.private(A,O);C&&(r=C.querySelector(`[data-phx-component="${this.targetCID}"]`))}}const o=i.getActiveElement(),{selectionStart:a,selectionEnd:h}=o&&l.hasSelectionRange(o)?o:{},c=i.binding(nt),d=i.binding(bt),p=i.binding(wt),m=i.binding(ji),g=[],u=[],v=[];let w=[],D=null;const X=(A,C,R=this.withChildren)=>{const $={childrenOnly:A.getAttribute(Y)===null&&!R,getNodeKey:f=>l.isPhxDestroyed(f)?null:t?f.id:f.id||f.getAttribute&&f.getAttribute(gi),skipFromChildren:f=>f.getAttribute(c)===Qe,addChild:(f,b)=>{const{ref:H,streamAt:q}=this.getStreamInsert(b);if(H===void 0)return f.appendChild(b);if(this.setStreamRef(b,H),q===0)f.insertAdjacentElement("afterbegin",b);else if(q===-1){const x=f.lastElementChild;if(x&&!x.hasAttribute(xe)){const ge=Array.from(f.children).find(_=>!_.hasAttribute(xe));f.insertBefore(b,ge)}else f.appendChild(b)}else if(q>0){const x=Array.from(f.children)[q];f.insertBefore(b,x)}},onBeforeNodeAdded:f=>{var H;if((H=this.getStreamInsert(f))!=null&&H.updateOnly&&!this.streamComponentRestore[f.id])return!1;l.maintainPrivateHooks(f,f,d,p),this.trackBefore("added",f);let b=f;return this.streamComponentRestore[f.id]&&(b=this.streamComponentRestore[f.id],delete this.streamComponentRestore[f.id],X(b,f,!0)),b},onNodeAdded:f=>{f.getAttribute&&this.maybeReOrderStream(f,!0),l.isPortalTemplate(f)&&w.push(()=>this.teleport(f,X)),f instanceof HTMLImageElement&&f.srcset?f.srcset=f.srcset:f instanceof HTMLVideoElement&&f.autoplay&&f.play(),l.isNowTriggerFormExternal(f,m)&&(D=f),(l.isPhxChild(f)&&e.ownsElement(f)||l.isPhxSticky(f)&&e.ownsElement(f.parentNode))&&this.trackAfter("phxChildAdded",f),f.nodeName==="SCRIPT"&&f.hasAttribute(Ze)&&this.handleRuntimeHook(f,C),g.push(f)},onNodeDiscarded:f=>this.onNodeDiscarded(f),onBeforeNodeDiscarded:f=>{if(f.getAttribute&&f.getAttribute(Ht)!==null)return!0;if(f.parentElement!==null&&f.id&&l.isPhxUpdate(f.parentElement,c,[Qe,"append","prepend"])||f.getAttribute&&f.getAttribute(me)||this.maybePendingRemove(f)||this.skipCIDSibling(f))return!1;if(l.isPortalTemplate(f)){const b=document.getElementById(f.content.firstElementChild.id);b&&(b.remove(),$.onNodeDiscarded(b),this.view.dropPortalElementId(b.id))}return!0},onElUpdated:f=>{l.isNowTriggerFormExternal(f,m)&&(D=f),u.push(f),this.maybeReOrderStream(f,!1)},onBeforeElUpdated:(f,b)=>{if(f.id&&f.isSameNode(A)&&f.id!==b.id)return $.onNodeDiscarded(f),f.replaceWith(b),$.onNodeAdded(b);if(l.syncPendingAttrs(f,b),l.maintainPrivateHooks(f,b,d,p),l.cleanChildNodes(b,c),this.skipCIDSibling(b))return this.maybeReOrderStream(f),!1;if(l.isPhxSticky(f))return[Q,fe,ae].map(x=>[x,f.getAttribute(x),b.getAttribute(x)]).forEach(([x,ge,_])=>{_&&ge!==_&&f.setAttribute(x,_)}),!1;if(l.isIgnored(f,c)||f.form&&f.form.isSameNode(D))return this.trackBefore("updated",f,b),l.mergeAttrs(f,b,{isIgnored:l.isIgnored(f,c)}),u.push(f),l.applyStickyOperations(f),!1;if(f.type==="number"&&f.validity&&f.validity.badInput)return!1;const H=o&&f.isSameNode(o)&&l.isFormInput(f),q=H&&this.isChangedSelect(f,b);if(f.hasAttribute(J)){const x=new Et(f);if(x.lockRef&&(!this.undoRef||!x.isLockUndoneBy(this.undoRef))){l.applyStickyOperations(f);const _=f.hasAttribute(O)?l.private(f,O)||f.cloneNode(!0):null;_&&(l.putPrivate(f,O,_),H||(f=_))}}if(l.isPhxChild(b)){const x=f.getAttribute(Q);return l.mergeAttrs(f,b,{exclude:[fe]}),x!==""&&f.setAttribute(Q,x),f.setAttribute(ae,this.rootID),l.applyStickyOperations(f),!1}return this.undoRef&&l.private(b,O)&&l.putPrivate(f,O,l.private(b,O)),l.copyPrivates(b,f),l.isPortalTemplate(b)?(w.push(()=>this.teleport(b,X)),f.content.replaceChildren(b.content.cloneNode(!0)),!1):H&&f.type!=="hidden"&&!q?(this.trackBefore("updated",f,b),l.mergeFocusedInput(f,b),l.syncAttrsToProps(f),u.push(f),l.applyStickyOperations(f),!1):(q&&f.blur(),l.isPhxUpdate(b,c,["append","prepend"])&&v.push(new fs(f,b,b.getAttribute(c))),l.syncAttrsToProps(b),l.applyStickyOperations(b),this.trackBefore("updated",f,b),f)}};St(A,C,$)};if(this.trackBefore("added",n),this.trackBefore("updated",n,n),i.time("morphdom",()=>{this.streams.forEach(([C,R,$,f])=>{R.forEach(([b,H,q,x])=>{this.streamInserts[b]={ref:C,streamAt:H,limit:q,reset:f,updateOnly:x}}),f!==void 0&&l.all(document,`[${xe}="${C}"]`,b=>{this.removeStreamChildElement(b)}),$.forEach(b=>{const H=document.getElementById(b);H&&this.removeStreamChildElement(H)})}),t&&l.all(this.container,`[${c}=${Qe}]`).filter(C=>this.view.ownsElement(C)).forEach(C=>{Array.from(C.children).forEach(R=>{this.removeStreamChildElement(R,!0)})}),X(r,s);let A=0;for(;w.length>0&&A<5;){const C=w.slice();w=[],C.forEach(R=>R()),A++}this.view.portalElementIds.forEach(C=>{const R=document.getElementById(C);R&&(document.getElementById(R.getAttribute(he))||(R.remove(),this.onNodeDiscarded(R),this.view.dropPortalElementId(C)))})}),i.isDebugEnabled()&&(ts(),is(this.streamInserts),Array.from(document.querySelectorAll("input[name=id]")).forEach(A=>{A instanceof HTMLInputElement&&A.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM.
`,A)})),v.length>0&&i.time("post-morph append/prepend restoration",()=>{v.forEach(A=>A.perform())}),i.silenceEvents(()=>l.restoreFocus(o,a,h)),l.dispatchEvent(document,"phx:update"),g.forEach(A=>this.trackAfter("added",A)),u.forEach(A=>this.trackAfter("updated",A)),this.transitionPendingRemoves(),D){i.unload();const A=l.private(D,"submitter");if(A&&A.name&&r.contains(A)){const C=document.createElement("input");C.type="hidden";const R=A.getAttribute("form");R&&C.setAttribute("form",R),C.name=A.name,C.value=A.value,A.parentElement.insertBefore(C,A)}Object.getPrototypeOf(D).submit.call(D)}return!0}onNodeDiscarded(t){(l.isPhxChild(t)||l.isPhxSticky(t))&&this.liveSocket.destroyViewByEl(t),this.trackAfter("discarded",t)}maybePendingRemove(t){return t.getAttribute&&t.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(t),!0):!1}removeStreamChildElement(t,e=!1){!e&&!this.view.ownsElement(t)||(this.streamInserts[t.id]?(this.streamComponentRestore[t.id]=t,t.remove()):this.maybePendingRemove(t)||(t.remove(),this.onNodeDiscarded(t)))}getStreamInsert(t){return(t.id?this.streamInserts[t.id]:{})||{}}setStreamRef(t,e){l.putSticky(t,xe,i=>i.setAttribute(xe,e))}maybeReOrderStream(t,e){const{ref:i,streamAt:s,reset:n}=this.getStreamInsert(t);if(s!==void 0&&(this.setStreamRef(t,i),!(!n&&!e)&&t.parentElement)){if(s===0)t.parentElement.insertBefore(t,t.parentElement.firstElementChild);else if(s>0){const r=Array.from(t.parentElement.children),o=r.indexOf(t);if(s>=r.length-1)t.parentElement.appendChild(t);else{const a=r[s];o>s?t.parentElement.insertBefore(t,a):t.parentElement.insertBefore(t,a.nextElementSibling)}}this.maybeLimitStream(t)}}maybeLimitStream(t){const{limit:e}=this.getStreamInsert(t),i=e!==null&&Array.from(t.parentElement.children);e&&e<0&&i.length>e*-1?i.slice(0,i.length+e).forEach(s=>this.removeStreamChildElement(s)):e&&e>=0&&i.length>e&&i.slice(e).forEach(s=>this.removeStreamChildElement(s))}transitionPendingRemoves(){const{pendingRemoves:t,liveSocket:e}=this;t.length>0&&e.transitionRemoves(t,()=>{t.forEach(i=>{const s=l.firstPhxChild(i);s&&e.destroyViewByEl(s),i.remove()}),this.trackAfter("transitionsDiscarded",t)})}isChangedSelect(t,e){return!(t instanceof HTMLSelectElement)||t.multiple?!1:t.options.length!==e.options.length?!0:(e.value=t.value,!t.isEqualNode(e))}isCIDPatch(){return this.cidPatch}skipCIDSibling(t){return t.nodeType===Node.ELEMENT_NODE&&t.hasAttribute(mi)}targetCIDContainer(t){if(!this.isCIDPatch())return;const[e,...i]=l.findComponentNodeList(this.view.id,this.targetCID);return i.length===0&&l.childNodeLength(t)===1?e:e&&e.parentNode}indexOf(t,e){return Array.from(t.children).indexOf(e)}teleport(t,e){const i=t.getAttribute(Pt),s=document.querySelector(i);if(!s)throw new Error("portal target with selector "+i+" not found");const n=t.content.firstElementChild;if(this.skipCIDSibling(n))return;if(!(n!=null&&n.id))throw new Error("phx-portal template must have a single root element with ID!");const r=document.getElementById(n.id);let o;r?(s.contains(r)||s.appendChild(r),o=r):(o=document.createElement(n.tagName),s.appendChild(o)),n.setAttribute(me,this.view.id),n.setAttribute(he,t.id),e(o,n,!0),n.removeAttribute(me),n.removeAttribute(he),this.view.pushPortalElementId(n.id)}handleRuntimeHook(t,e){const i=t.getAttribute(Ze);let s=t.hasAttribute("nonce")?t.getAttribute("nonce"):null;if(t.hasAttribute("nonce")){const r=document.createElement("template");r.innerHTML=e,s=r.content.querySelector(`script[${Ze}="${CSS.escape(i)}"]`).getAttribute("nonce")}const n=document.createElement("script");n.textContent=t.textContent,l.mergeAttrs(n,t,{isIgnored:!1}),s&&(n.nonce=s),t.replaceWith(n),t=n}},_s=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Ps=new Set(["'",'"']),ii=(t,e,i)=>{let s=0,n=!1,r,o,a,h,c,d;const p=t.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/);if(p===null)throw new Error(`malformed html ${t}`);for(s=p[0].length,r=p[1],a=p[2],h=s,s;s<t.length&&t.charAt(s)!==">";s++)if(t.charAt(s)==="="){const u=t.slice(s-3,s)===" id";s++;const v=t.charAt(s);if(Ps.has(v)){const w=s;for(s++,s;s<t.length&&t.charAt(s)!==v;s++);if(u){c=t.slice(w+1,s);break}}}let m=t.length-1;for(n=!1;m>=r.length+a.length;){const u=t.charAt(m);if(n)u==="-"&&t.slice(m-3,m)==="<!-"?(n=!1,m-=4):m-=1;else if(u===">"&&t.slice(m-2,m)==="--")n=!0,m-=3;else{if(u===">")break;m-=1}}o=t.slice(m+1,t.length);const g=Object.keys(e).map(u=>e[u]===!0?u:`${u}="${e[u]}"`).join(" ");if(i){const u=c?` id="${c}"`:"";_s.has(a)?d=`<${a}${u}${g===""?"":" "}${g}/>`:d=`<${a}${u}${g===""?"":" "}${g}></${a}>`}else{const u=t.slice(h,m+1);d=`<${a}${g===""?"":" "}${g}${u}`}return[d,r,o]},si=class{static extract(t){const{[qt]:e,[Xt]:i,[Wt]:s}=t;return delete t[qt],delete t[Xt],delete t[Wt],{diff:t,title:s,reply:e||null,events:i||[]}}constructor(t,e){this.viewId=t,this.rendered={},this.magicId=0,this.mergeDiff(e)}parentViewId(){return this.viewId}toString(t){const{buffer:e,streams:i}=this.recursiveToString(this.rendered,this.rendered[M],t,!0,{});return{buffer:e,streams:i}}recursiveToString(t,e=t[M],i,s,n){i=i?new Set(i):null;const r={buffer:"",components:e,onlyCids:i,streams:new Set};return this.toOutputBuffer(t,null,r,s,n),{buffer:r.buffer,streams:r.streams}}componentCIDs(t){return Object.keys(t[M]||{}).map(e=>parseInt(e))}isComponentOnlyDiff(t){return t[M]?Object.keys(t).length===1:!1}getComponent(t,e){return t[M][e]}resetRender(t){this.rendered[M][t]&&(this.rendered[M][t].reset=!0)}mergeDiff(t){const e=t[M],i={};if(delete t[M],this.rendered=this.mutableMerge(this.rendered,t),this.rendered[M]=this.rendered[M]||{},e){const s=this.rendered[M];for(const n in e)e[n]=this.cachedFindComponent(n,e[n],s,e,i);for(const n in e)s[n]=e[n];t[M]=e}}cachedFindComponent(t,e,i,s,n){if(n[t])return n[t];{let r,o,a=e[V];if(te(a)){let h;a>0?h=this.cachedFindComponent(a,s[a],i,s,n):h=i[-a],o=h[V],r=this.cloneMerge(h,e,!0),r[V]=o}else r=e[V]!==void 0||i[t]===void 0?e:this.cloneMerge(i[t],e,!1);return n[t]=r,r}}mutableMerge(t,e){return e[V]!==void 0?e:(this.doMutableMerge(t,e),t)}doMutableMerge(t,e){if(e[L])this.mergeKeyed(t,e);else for(const i in e){const s=e[i],n=t[i];Ae(s)&&s[V]===void 0&&Ae(n)?this.doMutableMerge(n,s):t[i]=s}t[ut]&&(t.newRender=!0)}clone(t){return"structuredClone"in window?structuredClone(t):JSON.parse(JSON.stringify(t))}mergeKeyed(t,e){const i=this.clone(t);if(Object.entries(e[L]).forEach(([s,n])=>{if(s!==K)if(Array.isArray(n)){const[r,o]=n;t[L][s]=i[L][r],this.doMutableMerge(t[L][s],o)}else if(typeof n=="number"){const r=n;t[L][s]=i[L][r]}else typeof n=="object"&&(t[L][s]||(t[L][s]={}),this.doMutableMerge(t[L][s],n))}),e[L][K]<t[L][K])for(let s=e[L][K];s<t[L][K];s++)delete t[L][s];t[L][K]=e[L][K],e[ke]&&(t[ke]=e[ke]),e[re]&&(t[re]=e[re])}cloneMerge(t,e,i){let s;if(e[L])s=this.clone(t),this.mergeKeyed(s,e);else{s={...t,...e};for(const n in s){const r=e[n],o=t[n];Ae(r)&&r[V]===void 0&&Ae(o)?s[n]=this.cloneMerge(o,r,i):r===void 0&&Ae(o)&&(s[n]=this.cloneMerge(o,{},i))}}return i?(delete s.magicId,delete s.newRender):t[ut]&&(s.newRender=!0),s}componentToString(t){const{buffer:e,streams:i}=this.recursiveCIDToString(this.rendered[M],t,null),[s]=ii(e,{});return{buffer:s,streams:i}}pruneCIDs(t){t.forEach(e=>delete this.rendered[M][e])}get(){return this.rendered}isNewFingerprint(t={}){return!!t[V]}templateStatic(t,e){return typeof t=="number"?e[t]:t}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(t,e,i,s,n={}){if(t[L])return this.comprehensionToBuffer(t,e,i,s);t[re]&&(e=t[re],delete t[re]);let{[V]:r}=t;r=this.templateStatic(r,e),t[V]=r;const o=t[ut],a=i.buffer;o&&(i.buffer=""),s&&o&&!t.magicId&&(t.newRender=!0,t.magicId=this.nextMagicID()),i.buffer+=r[0];for(let h=1;h<r.length;h++)this.dynamicToBuffer(t[h-1],e,i,s),i.buffer+=r[h];if(o){let h=!1,c;s||t.magicId?(h=s&&!t.newRender,c={[gi]:t.magicId,...n}):c=n,h&&(c[mi]=!0);const[d,p,m]=ii(i.buffer,c,h);t.newRender=!1,i.buffer=a+p+d+m}}comprehensionToBuffer(t,e,i,s){const n=e||t[re],r=this.templateStatic(t[V],e);t[V]=r,delete t[re];for(let o=0;o<t[L][K];o++){i.buffer+=r[0];for(let a=1;a<r.length;a++)this.dynamicToBuffer(t[L][o][a-1],n,i,s),i.buffer+=r[a]}if(t[ke]){const o=t[ke],[a,h,c,d]=o||[null,{},[],null];o!==void 0&&(t[L][K]>0||c.length>0||d)&&(delete t[ke],t[L]={[K]:0},i.streams.add(o))}}dynamicToBuffer(t,e,i,s){if(typeof t=="number"){const{buffer:n,streams:r}=this.recursiveCIDToString(i.components,t,i.onlyCids);i.buffer+=n,i.streams=new Set([...i.streams,...r])}else Ae(t)?this.toOutputBuffer(t,e,i,s,{}):i.buffer+=t}recursiveCIDToString(t,e,i){const s=t[e]||P(`no component for CID ${e}`,t),n={[Y]:e,[Te]:this.viewId},r=i&&!i.has(e);s.newRender=!r,s.magicId=`c${e}-${this.parentViewId()}`;const o=!s.reset,{buffer:a,streams:h}=this.recursiveToString(s,t,i,o,n);return delete s.reset,{buffer:a,streams:h}}},ni=[],ri=200,Rs={exec(t,e,i,s,n,r){const[o,a]=r||[null,{callback:r&&r.callback}];(i.charAt(0)==="["?JSON.parse(i):[[o,a]]).forEach(([c,d])=>{c===o&&(d={...a,...d},d.callback=d.callback||a.callback),this.filterToEls(s.liveSocket,n,d).forEach(p=>{this[`exec_${c}`](t,e,i,s,n,p,d)})})},isVisible(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length>0)},isInViewport(t){const e=t.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth;return e.right>0&&e.bottom>0&&e.left<s&&e.top<i},exec_exec(t,e,i,s,n,r,{attr:o,to:a}){const h=r.getAttribute(o);if(!h)throw new Error(`expected ${o} to contain JS command on "${a}"`);s.liveSocket.execJS(r,h,e)},exec_dispatch(t,e,i,s,n,r,{event:o,detail:a,bubbles:h,blocking:c}){if(a=a||{},a.dispatcher=n,c){const d=new Promise((p,m)=>{a.done=p});s.liveSocket.asyncTransition(d)}l.dispatchEvent(r,o,{detail:a,bubbles:h})},exec_push(t,e,i,s,n,r,o){const{event:a,data:h,target:c,page_loading:d,loading:p,value:m,dispatcher:g,callback:u}=o,v={loading:p,value:m,target:c,page_loading:!!d,originalEvent:t},w=e==="change"&&g?g:n,D=c||w.getAttribute(s.binding("target"))||w,X=(A,C)=>{if(A.isConnected())if(e==="change"){let{newCid:R,_target:$}=o;$=$||(l.isFormInput(n)?n.name:void 0),$&&(v._target=$),A.pushInput(n,C,R,a||i,v,u)}else if(e==="submit"){const{submitter:R}=o;A.submitForm(n,C,a||i,R,v,u)}else A.pushEvent(e,n,C,a||i,h,v,u)};o.targetView&&o.targetCtx?X(o.targetView,o.targetCtx):s.withinTargets(D,X)},exec_navigate(t,e,i,s,n,r,{href:o,replace:a}){s.liveSocket.historyRedirect(t,o,a?"replace":"push",null,n)},exec_patch(t,e,i,s,n,r,{href:o,replace:a}){s.liveSocket.pushHistoryPatch(t,o,a?"replace":"push",n)},exec_focus(t,e,i,s,n,r){B.attemptFocus(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>B.attemptFocus(r))})},exec_focus_first(t,e,i,s,n,r){B.focusFirstInteractive(r)||B.focusFirst(r),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>B.focusFirstInteractive(r)||B.focusFirst(r))})},exec_push_focus(t,e,i,s,n,r){ni.push(r||n)},exec_pop_focus(t,e,i,s,n,r){const o=ni.pop();o&&(o.focus(),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>o.focus())}))},exec_add_class(t,e,i,s,n,r,{names:o,transition:a,time:h,blocking:c}){this.addOrRemoveClasses(r,o,[],a,h,s,c)},exec_remove_class(t,e,i,s,n,r,{names:o,transition:a,time:h,blocking:c}){this.addOrRemoveClasses(r,[],o,a,h,s,c)},exec_toggle_class(t,e,i,s,n,r,{names:o,transition:a,time:h,blocking:c}){this.toggleClasses(r,o,a,h,s,c)},exec_toggle_attr(t,e,i,s,n,r,{attr:[o,a,h]}){this.toggleAttr(r,o,a,h)},exec_ignore_attrs(t,e,i,s,n,r,{attrs:o}){this.ignoreAttrs(r,o)},exec_transition(t,e,i,s,n,r,{time:o,transition:a,blocking:h}){this.addOrRemoveClasses(r,[],[],a,o,s,h)},exec_toggle(t,e,i,s,n,r,{display:o,ins:a,outs:h,time:c,blocking:d}){this.toggle(e,s,r,o,a,h,c,d)},exec_show(t,e,i,s,n,r,{display:o,transition:a,time:h,blocking:c}){this.show(e,s,r,o,a,h,c)},exec_hide(t,e,i,s,n,r,{display:o,transition:a,time:h,blocking:c}){this.hide(e,s,r,o,a,h,c)},exec_set_attr(t,e,i,s,n,r,{attr:[o,a]}){this.setOrRemoveAttrs(r,[[o,a]],[])},exec_remove_attr(t,e,i,s,n,r,{attr:o}){this.setOrRemoveAttrs(r,[],[o])},ignoreAttrs(t,e){l.putPrivate(t,"JS:ignore_attrs",{apply:(i,s)=>{let n=Array.from(i.attributes),r=n.map(o=>o.name);Array.from(s.attributes).filter(o=>!r.includes(o.name)).forEach(o=>{l.attributeIgnored(o,e)&&s.removeAttribute(o.name)}),n.forEach(o=>{l.attributeIgnored(o,e)&&s.setAttribute(o.name,o.value)})}})},onBeforeElUpdated(t,e){const i=l.private(t,"JS:ignore_attrs");i&&i.apply(t,e)},show(t,e,i,s,n,r,o){this.isVisible(i)||this.toggle(t,e,i,s,n,null,r,o)},hide(t,e,i,s,n,r,o){this.isVisible(i)&&this.toggle(t,e,i,s,null,n,r,o)},toggle(t,e,i,s,n,r,o,a){o=o||ri;const[h,c,d]=n||[[],[],[]],[p,m,g]=r||[[],[],[]];if(h.length>0||p.length>0)if(this.isVisible(i)){const u=()=>{this.addOrRemoveClasses(i,m,h.concat(c).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,p,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,g,m))})},v=()=>{this.addOrRemoveClasses(i,[],p.concat(g)),l.putSticky(i,"toggle",w=>w.style.display="none"),i.dispatchEvent(new Event("phx:hide-end"))};i.dispatchEvent(new Event("phx:hide-start")),a===!1?(u(),setTimeout(v,o)):e.transition(o,u,v)}else{if(t==="remove")return;const u=()=>{this.addOrRemoveClasses(i,c,p.concat(m).concat(g));const w=s||this.defaultDisplay(i);window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,h,[]),window.requestAnimationFrame(()=>{l.putSticky(i,"toggle",D=>D.style.display=w),this.addOrRemoveClasses(i,d,c)})})},v=()=>{this.addOrRemoveClasses(i,[],h.concat(d)),i.dispatchEvent(new Event("phx:show-end"))};i.dispatchEvent(new Event("phx:show-start")),a===!1?(u(),setTimeout(v,o)):e.transition(o,u,v)}else this.isVisible(i)?window.requestAnimationFrame(()=>{i.dispatchEvent(new Event("phx:hide-start")),l.putSticky(i,"toggle",u=>u.style.display="none"),i.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{i.dispatchEvent(new Event("phx:show-start"));const u=s||this.defaultDisplay(i);l.putSticky(i,"toggle",v=>v.style.display=u),i.dispatchEvent(new Event("phx:show-end"))})},toggleClasses(t,e,i,s,n,r){window.requestAnimationFrame(()=>{const[o,a]=l.getSticky(t,"classes",[[],[]]),h=e.filter(d=>o.indexOf(d)<0&&!t.classList.contains(d)),c=e.filter(d=>a.indexOf(d)<0&&t.classList.contains(d));this.addOrRemoveClasses(t,h,c,i,s,n,r)})},toggleAttr(t,e,i,s){t.hasAttribute(e)?s!==void 0?t.getAttribute(e)===i?this.setOrRemoveAttrs(t,[[e,s]],[]):this.setOrRemoveAttrs(t,[[e,i]],[]):this.setOrRemoveAttrs(t,[],[e]):this.setOrRemoveAttrs(t,[[e,i]],[])},addOrRemoveClasses(t,e,i,s,n,r,o){n=n||ri;const[a,h,c]=s||[[],[],[]];if(a.length>0){const d=()=>{this.addOrRemoveClasses(t,h,[].concat(a).concat(c)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,c,h))})},p=()=>this.addOrRemoveClasses(t,e.concat(c),i.concat(a).concat(h));o===!1?(d(),setTimeout(p,n)):r.transition(n,d,p);return}window.requestAnimationFrame(()=>{const[d,p]=l.getSticky(t,"classes",[[],[]]),m=e.filter(w=>d.indexOf(w)<0&&!t.classList.contains(w)),g=i.filter(w=>p.indexOf(w)<0&&t.classList.contains(w)),u=d.filter(w=>i.indexOf(w)<0).concat(m),v=p.filter(w=>e.indexOf(w)<0).concat(g);l.putSticky(t,"classes",w=>(w.classList.remove(...v),w.classList.add(...u),[u,v]))})},setOrRemoveAttrs(t,e,i){const[s,n]=l.getSticky(t,"attrs",[[],[]]),r=e.map(([h,c])=>h).concat(i),o=s.filter(([h,c])=>!r.includes(h)).concat(e),a=n.filter(h=>!r.includes(h)).concat(i);l.putSticky(t,"attrs",h=>(a.forEach(c=>h.removeAttribute(c)),o.forEach(([c,d])=>h.setAttribute(c,d)),[o,a]))},hasAllClasses(t,e){return e.every(i=>t.classList.contains(i))},isToggledOut(t,e){return!this.isVisible(t)||this.hasAllClasses(t,e)},filterToEls(t,e,{to:i}){const s=()=>{if(typeof i=="string")return document.querySelectorAll(i);if(i.closest){const n=e.closest(i.closest);return n?[n]:[]}else if(i.inner)return e.querySelectorAll(i.inner)};return i?t.jsQuerySelectorAll(e,i,s):[e]},defaultDisplay(t){return{tr:"table-row",td:"table-cell"}[t.tagName.toLowerCase()]||"block"},transitionClasses(t){if(!t)return null;let[e,i,s]=Array.isArray(t)?t:[t.split(" "),[],[]];return e=Array.isArray(e)?e:e.split(" "),i=Array.isArray(i)?i:i.split(" "),s=Array.isArray(s)?s:s.split(" "),[e,i,s]}},S=Rs,yi=(t,e)=>({exec(i,s){t.execJS(i,s,e)},show(i,s={}){const n=t.owner(i);S.show(e,n,i,s.display,S.transitionClasses(s.transition),s.time,s.blocking)},hide(i,s={}){const n=t.owner(i);S.hide(e,n,i,null,S.transitionClasses(s.transition),s.time,s.blocking)},toggle(i,s={}){const n=t.owner(i),r=S.transitionClasses(s.in),o=S.transitionClasses(s.out);S.toggle(e,n,i,s.display,r,o,s.time,s.blocking)},addClass(i,s,n={}){const r=Array.isArray(s)?s:s.split(" "),o=t.owner(i);S.addOrRemoveClasses(i,r,[],S.transitionClasses(n.transition),n.time,o,n.blocking)},removeClass(i,s,n={}){const r=Array.isArray(s)?s:s.split(" "),o=t.owner(i);S.addOrRemoveClasses(i,[],r,S.transitionClasses(n.transition),n.time,o,n.blocking)},toggleClass(i,s,n={}){const r=Array.isArray(s)?s:s.split(" "),o=t.owner(i);S.toggleClasses(i,r,S.transitionClasses(n.transition),n.time,o,n.blocking)},transition(i,s,n={}){const r=t.owner(i);S.addOrRemoveClasses(i,[],[],S.transitionClasses(s),n.time,r,n.blocking)},setAttribute(i,s,n){S.setOrRemoveAttrs(i,[[s,n]],[])},removeAttribute(i,s){S.setOrRemoveAttrs(i,[],[s])},toggleAttribute(i,s,n,r){S.toggleAttr(i,s,n,r)},push(i,s,n={}){t.withinOwners(i,r=>{const o=n.value||{};delete n.value;let a=new CustomEvent("phx:exec",{detail:{sourceElement:i}});S.exec(a,e,s,r,i,["push",{data:o,...n}])})},navigate(i,s={}){const n=new CustomEvent("phx:exec");t.historyRedirect(n,i,s.replace?"replace":"push",null,null)},patch(i,s={}){const n=new CustomEvent("phx:exec");t.pushHistoryPatch(n,i,s.replace?"replace":"push",null)},ignoreAttributes(i,s){S.ignoreAttrs(i,Array.isArray(s)?s:[s])}}),pt="hookId",oi="deadHook",xs=1,ce=class ki{get liveSocket(){return this.__liveSocket()}static makeID(){return xs++}static elementID(e){return l.private(e,pt)}static deadHook(e){return l.private(e,oi)===!0}constructor(e,i,s){if(this.el=i,this.__attachView(e),this.__listeners=new Set,this.__isDisconnected=!1,l.putPrivate(this.el,pt,ki.makeID()),e&&e.isDead&&l.putPrivate(this.el,oi,!0),s){const n=new Set(["el","liveSocket","__view","__listeners","__isDisconnected","constructor","js","pushEvent","pushEventTo","handleEvent","removeHandleEvent","upload","uploadTo","__mounted","__updated","__beforeUpdate","__destroyed","__reconnected","__disconnected","__cleanup__"]);for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&(this[o]=s[o],n.has(o)&&console.warn(`Hook object for element #${i.id} overwrites core property '${o}'!`));["mounted","beforeUpdate","updated","destroyed","disconnected","reconnected"].forEach(o=>{s[o]&&typeof s[o]=="function"&&(this[o]=s[o])})}}__attachView(e){e?(this.__view=()=>e,this.__liveSocket=()=>e.liveSocket):(this.__view=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)},this.__liveSocket=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)})}mounted(){}beforeUpdate(){}updated(){}destroyed(){}disconnected(){}reconnected(){}__mounted(){this.mounted()}__updated(){this.updated()}__beforeUpdate(){this.beforeUpdate()}__destroyed(){this.destroyed(),l.deletePrivate(this.el,pt)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected()}js(){return{...yi(this.__view().liveSocket,"hook"),exec:e=>{this.__view().liveSocket.execJS(this.el,e,"hook")}}}pushEvent(e,i,s){const n=this.__view().pushHookEvent(this.el,null,e,i||{});if(s===void 0)return n.then(({reply:r})=>r);n.then(({reply:r,ref:o})=>s(r,o)).catch(()=>{})}pushEventTo(e,i,s,n){if(n===void 0){const r=[];this.__view().withinTargets(e,(a,h)=>{r.push({view:a,targetCtx:h})});const o=r.map(({view:a,targetCtx:h})=>a.pushHookEvent(this.el,h,i,s||{}));return Promise.allSettled(o)}this.__view().withinTargets(e,(r,o)=>{r.pushHookEvent(this.el,o,i,s||{}).then(({reply:a,ref:h})=>n(a,h)).catch(()=>{})})}handleEvent(e,i){const s={event:e,callback:n=>i(n.detail)};return window.addEventListener(`phx:${e}`,s.callback),this.__listeners.add(s),s}removeHandleEvent(e){window.removeEventListener(`phx:${e.event}`,e.callback),this.__listeners.delete(e)}upload(e,i){return this.__view().dispatchUploads(null,e,i)}uploadTo(e,i,s){return this.__view().withinTargets(e,(n,r)=>{n.dispatchUploads(r,i,s)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}},Ls=(t,e)=>{const i=t.endsWith("[]");let s=i?t.slice(0,-2):t;return s=s.replace(/([^\[\]]+)(\]?$)/,`${e}$1$2`),i&&(s+="[]"),s},Ge=(t,e,i=[])=>{const{submitter:s}=e;let n;if(s&&s.name){const d=document.createElement("input");d.type="hidden";const p=s.getAttribute("form");p&&d.setAttribute("form",p),d.name=s.name,d.value=s.value,s.parentElement.insertBefore(d,s),n=d}const r=new FormData(t),o=[];r.forEach((d,p,m)=>{d instanceof File&&o.push(p)}),o.forEach(d=>r.delete(d));const a=new URLSearchParams,{inputsUnused:h,onlyHiddenInputs:c}=Array.from(t.elements).reduce((d,p)=>{const{inputsUnused:m,onlyHiddenInputs:g}=d,u=p.name;if(!u)return d;m[u]===void 0&&(m[u]=!0),g[u]===void 0&&(g[u]=!0);const v=l.private(p,it)||l.private(p,$e),w=p.type==="hidden";return m[u]=m[u]&&!v,g[u]=g[u]&&w,d},{inputsUnused:{},onlyHiddenInputs:{}});for(const[d,p]of r.entries())if(i.length===0||i.indexOf(d)>=0){const m=h[d],g=c[d];m&&!(s&&s.name==d)&&!g&&a.append(Ls(d,"_unused_"),""),typeof p=="string"&&a.append(d,p)}return s&&n&&s.parentElement.removeChild(n),a.toString()},Is=class Ai{static closestView(e){const i=e.closest(Me);return i?l.private(i,"view"):null}constructor(e,i,s,n,r){this.isDead=!1,this.liveSocket=i,this.flash=n,this.parent=s,this.root=s?s.root:this,this.el=e;const o=l.private(this.el,"view");if(o!==void 0&&o.isDead!==!0)throw P(`The DOM element for this view has already been bound to a view.

        An element can only ever be associated with a single view!
        Please ensure that you are not trying to initialize multiple LiveSockets on the same page.
        This could happen if you're accidentally trying to render your root layout more than once.
        Ensure that the template set on the LiveView is different than the root layout.
      `,{view:o}),new Error("Cannot bind multiple views to the same DOM element.");l.putPrivate(this.el,"view",this),this.id=this.el.id,this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.disconnectedTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(a){a&&a()},this.stopCallback=function(){},this.pendingJoinOps=[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{const a=this.href&&this.expandURL(this.href);return{redirect:this.redirect?a:void 0,url:this.redirect?void 0:a||void 0,params:this.connectParams(r),session:this.getSession(),static:this.getStatic(),flash:this.flash,sticky:this.el.hasAttribute(yt)}}),this.portalElementIds=new Set}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.hasAttribute(_t)}connectParams(e){const i=this.liveSocket.params(this.el),s=l.all(document,`[${this.binding($i)}]`).map(n=>n.src||n.href).filter(n=>typeof n=="string");return s.length>0&&(i._track_static=s),i._mounts=this.joinCount,i._mount_attempts=this.joinAttempts,i._live_referer=e,this.joinAttempts++,i}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(Q)}getStatic(){const e=this.el.getAttribute(fe);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyPortalElements(),this.destroyed=!0,l.deletePrivate(this.el,"view"),delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);const i=()=>{e();for(const s in this.viewHooks)this.destroyHook(this.viewHooks[s])};l.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",i).receive("error",i).receive("timeout",i)}setContainerClasses(...e){this.el.classList.remove(Nt,le,ye,$t,Pe),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(const i in this.viewHooks)this.viewHooks[i].__disconnected();this.setContainerClasses(le)}}execAll(e){l.all(this.el,`[${e}]`,i=>this.liveSocket.execJS(i,i.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),clearTimeout(this.disconnectedTimer),this.setContainerClasses(Nt),this.execAll(this.binding("connected"))}triggerReconnected(){for(const e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,i){this.liveSocket.log(this,e,i)}transition(e,i,s=function(){}){this.liveSocket.transition(e,i,s)}withinTargets(e,i,s=document){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,n=>i(n,e));if(te(e))l.findComponentNodeList(this.id,e,s).length===0?P(`no component found matching phx-target of ${e}`):i(this,parseInt(e));else{const n=Array.from(s.querySelectorAll(e));n.length===0&&P(`nothing found matching the phx-target selector "${e}"`),n.forEach(r=>this.liveSocket.owner(r,o=>i(o,r)))}}applyDiff(e,i,s){this.log(e,()=>["",et(i)]);const{diff:n,reply:r,events:o,title:a}=si.extract(i),h=o.reduce((d,p)=>(p.length===3&&p[2]==!0?d.pre.push(p.slice(0,-1)):d.post.push(p),d),{pre:[],post:[]});this.liveSocket.dispatchEvents(h.pre);const c=()=>{s({diff:n,reply:r,events:h.post}),(typeof a=="string"||e=="mount"&&this.isMain())&&window.requestAnimationFrame(()=>l.putTitle(a))};"onDocumentPatch"in this.liveSocket.domCallbacks?this.liveSocket.triggerDOM("onDocumentPatch",[c]):c()}onJoin(e){const{rendered:i,container:s,liveview_version:n,pid:r}=e;if(s){const[o,a]=s;this.el=l.replaceRootContainer(this.el,o,a)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&U.pushState("replace",{type:"patch",id:this.id,position:this.liveSocket.currentHistoryPosition}),n!==this.liveSocket.version()&&console.warn(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${n}. To avoid issues, please ensure that your assets use the same version as the server.`),r&&this.el.setAttribute(Xi,r),U.dropLocal(this.liveSocket.localStorage,window.location.pathname,ui),this.applyDiff("mount",i,({diff:o,events:a})=>{this.rendered=new si(this.id,o);const[h,c]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(h,()=>{this.onJoinComplete(e,h,c,a)})})}dropPendingRefs(){l.all(document,`[${J}="${this.refSrc()}"]`,e=>{e.removeAttribute(_e),e.removeAttribute(J),e.removeAttribute(O)})}onJoinComplete({live_patch:e},i,s,n){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,i,s,n);l.findPhxChildrenInFragment(i,this.id).filter(o=>{const a=o.id&&this.el.querySelector(`[id="${o.id}"]`),h=a&&a.getAttribute(fe);return h&&o.setAttribute(fe,h),a&&a.setAttribute(ae,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,i,s,n)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,i,s,n)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,i,s,n)])}attachTrueDocEl(){this.el=l.byId(this.id),this.el.setAttribute(ae,this.root.id)}execNewMounted(e=document){let i=this.binding(bt),s=this.binding(wt);this.all(e,`[${i}], [${s}]`,n=>{l.maintainPrivateHooks(n,n,i,s),this.maybeAddNewHook(n)}),this.all(e,`[${this.binding(Re)}], [data-phx-${Re}]`,n=>{this.maybeAddNewHook(n)}),this.all(e,`[${this.binding(Ut)}]`,n=>{this.maybeMounted(n)})}all(e,i,s){l.all(e,i,n=>{this.ownsElement(n)&&s(n)})}applyJoinPatch(e,i,s,n){this.joinCount>1&&this.pendingJoinOps.length&&(this.pendingJoinOps.forEach(o=>typeof o=="function"&&o()),this.pendingJoinOps=[]),this.attachTrueDocEl();const r=new ze(this,this.el,this.id,i,s,null);if(r.markPrunableContentForRemoval(),this.performPatch(r,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(n),this.applyPendingUpdates(),e){const{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,i){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,i]);const s=this.getHook(e),n=s&&l.isIgnored(e,this.binding(nt));if(s&&!e.isEqualNode(i)&&!(n&&ns(e.dataset,i.dataset)))return s.__beforeUpdate(),s}maybeMounted(e){const i=e.getAttribute(this.binding(Ut)),s=i&&l.private(e,"mounted");i&&!s&&(this.liveSocket.execJS(e,i),l.putPrivate(e,"mounted",!0))}maybeAddNewHook(e){const i=this.addHook(e);i&&i.__mounted()}performPatch(e,i,s=!1){const n=[];let r=!1;const o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[e.targetContainer]),e.after("added",a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]);const h=this.binding(bt),c=this.binding(wt);l.maintainPrivateHooks(a,a,h,c),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.after("phxChildAdded",a=>{l.isPhxSticky(a)?this.liveSocket.joinRootViews():r=!0}),e.before("updated",(a,h)=>{this.triggerBeforeUpdateHook(a,h)&&o.add(a.id),S.onBeforeElUpdated(a,h)}),e.after("updated",a=>{o.has(a.id)&&this.getHook(a).__updated()}),e.after("discarded",a=>{a.nodeType===Node.ELEMENT_NODE&&n.push(a)}),e.after("transitionsDiscarded",a=>this.afterElementsRemoved(a,i)),e.perform(s),this.afterElementsRemoved(n,i),this.liveSocket.triggerDOM("onPatchEnd",[e.targetContainer]),r}afterElementsRemoved(e,i){const s=[];e.forEach(n=>{const r=l.all(n,`[${Te}="${this.id}"][${Y}]`),o=l.all(n,`[${this.binding(Re)}], [data-phx-hook]`);r.concat(n).forEach(a=>{const h=this.componentID(a);te(h)&&s.indexOf(h)===-1&&a.getAttribute(Te)===this.id&&s.push(h)}),o.concat(n).forEach(a=>{const h=this.getHook(a);h&&this.destroyHook(h)})}),i&&this.maybePushComponentsDestroyed(s)}joinNewChildren(){l.findPhxChildren(document,this.id).forEach(e=>this.joinChild(e))}maybeRecoverForms(e,i){const s=this.binding("change"),n=this.root.formsForRecovery,r=document.createElement("template");r.innerHTML=e,l.all(r.content,`[${Pt}]`).forEach(h=>{r.content.firstElementChild.appendChild(h.content.firstElementChild)});const o=r.content.firstElementChild;o.id=this.id,o.setAttribute(ae,this.root.id),o.setAttribute(Q,this.getSession()),o.setAttribute(fe,this.getStatic()),o.setAttribute(pe,this.parent?this.parent.id:null);const a=l.all(r.content,"form").filter(h=>h.id&&n[h.id]).filter(h=>!this.pendingForms.has(h.id)).filter(h=>n[h.id].getAttribute(s)===h.getAttribute(s)).map(h=>[n[h.id],h]);if(a.length===0)return i();a.forEach(([h,c],d)=>{this.pendingForms.add(c.id),this.pushFormRecovery(h,c,r.content.firstElementChild,()=>{this.pendingForms.delete(c.id),d===a.length-1&&i()})})}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){var i;return e.id===this.id?this:(i=this.children[e.getAttribute(pe)])==null?void 0:i[e.id]}destroyDescendent(e){for(const i in this.root.children)for(const s in this.root.children[i])if(s===e)return this.root.children[i][s].destroy()}joinChild(e){if(!this.getChildById(e.id)){const s=new Ai(e,this.liveSocket,this);return this.root.children[this.id][s.id]=s,s.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.pendingForms.clear(),this.formsForRecovery={},this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,i])=>{e.isDestroyed()||i()}),this.pendingJoinOps=[]})}update(e,i,s=!1){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return s||this.pendingDiffs.push({diff:e,events:i}),!1;this.rendered.mergeDiff(e);let n=!1;return this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{l.findExistingParentCIDs(this.id,this.rendered.componentCIDs(e)).forEach(o=>{this.componentPatch(this.rendered.getComponent(e,o),o)&&(n=!0)})}):Kt(e)||this.liveSocket.time("full patch complete",()=>{const[r,o]=this.renderContainer(e,"update"),a=new ze(this,this.el,this.id,r,o,null);n=this.performPatch(a,!0)}),this.liveSocket.dispatchEvents(i),n&&this.joinNewChildren(),!0}renderContainer(e,i){return this.liveSocket.time(`toString diff (${i})`,()=>{const s=this.el.tagName,n=e?this.rendered.componentCIDs(e):null,{buffer:r,streams:o}=this.rendered.toString(n);return[`<${s}>${r}</${s}>`,o]})}componentPatch(e,i){if(Kt(e))return!1;const{buffer:s,streams:n}=this.rendered.componentToString(i),r=new ze(this,this.el,this.id,s,n,i);return this.performPatch(r,!0)}getHook(e){return this.viewHooks[ce.elementID(e)]}addHook(e){const i=ce.elementID(e);if(!(e.getAttribute&&!this.ownsElement(e)))if(i&&!this.viewHooks[i]){if(ce.deadHook(e))return;const s=l.getCustomElHook(e)||P(`no hook found for custom element: ${e.id}`);return this.viewHooks[i]=s,s.__attachView(this),s}else{if(i||!e.getAttribute)return;{const s=e.getAttribute(`data-phx-${Re}`)||e.getAttribute(this.binding(Re));if(!s)return;const n=this.liveSocket.getHookDefinition(s);if(n){if(!e.id){P(`no DOM ID for hook "${s}". Hooks require a unique ID on each element.`,e);return}let r;try{if(typeof n=="function"&&n.prototype instanceof ce)r=new n(this,e);else if(typeof n=="object"&&n!==null)r=new ce(this,e,n);else{P(`Invalid hook definition for "${s}". Expected a class extending ViewHook or an object definition.`,e);return}}catch(o){const a=o instanceof Error?o.message:String(o);P(`Failed to create hook "${s}": ${a}`,e);return}return this.viewHooks[ce.elementID(r.el)]=r,r}else s!==null&&P(`unknown hook found for "${s}"`,e)}}}destroyHook(e){const i=ce.elementID(e.el);e.__destroyed(),e.__cleanup__(),delete this.viewHooks[i]}applyPendingUpdates(){this.pendingDiffs=this.pendingDiffs.filter(({diff:e,events:i})=>!this.update(e,i,!0)),this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){const i=this.root.children[this.id]||{};for(const s in i)e(this.getChildById(s))}onChannel(e,i){this.liveSocket.onChannel(this.channel,e,s=>{this.isJoinPending()?this.joinCount>1?this.pendingJoinOps.push(()=>i(s)):this.root.pendingJoinOps.push([this,()=>i(s)]):this.liveSocket.requestDOMUpdate(()=>i(s))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:i,events:s})=>this.update(i,s))})}),this.onChannel("redirect",({to:e,flash:i})=>this.onRedirect({to:e,flash:i})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){this.eachChild(e=>e.destroy())}onLiveRedirect(e){const{to:i,kind:s,flash:n}=e,r=this.expandURL(i),o=new CustomEvent("phx:server-navigate",{detail:{to:i,kind:s,flash:n}});this.liveSocket.historyRedirect(o,r,s,n)}onLivePatch(e){const{to:i,kind:s}=e;this.href=this.expandURL(i),this.liveSocket.historyPatch(i,s)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:i,reloadToken:s}){this.liveSocket.redirect(e,i,s)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}joinPush(){return this.joinPush=this.joinPush||this.channel.join(),this.joinPush}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=i=>{i=i||function(){},e?e(this.joinCount,i):i()},this.wrapPush(()=>this.channel.join(),{ok:i=>this.liveSocket.requestDOMUpdate(()=>this.onJoin(i)),error:i=>this.onJoinError(i),timeout:()=>this.onJoinError({reason:"timeout"})})}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page reload`,e]),this.onRedirect({to:this.liveSocket.main.href,reloadToken:e.token});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.liveSocket.main.href,flash:this.flash});return}if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);if(this.log("error",()=>["unable to join",e]),this.isMain())this.displayError([le,ye,Pe],{unstructuredError:e,errorKind:"server"}),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=Bt&&(this.root.displayError([le,ye,Pe],{unstructuredError:e,errorKind:"server"}),this.log("error",()=>[`giving up trying to mount after ${Bt} tries`,e]),this.destroy());const i=l.byId(this.el.id);i?(l.mergeAttrs(i,this.el),this.displayError([le,ye,Pe],{unstructuredError:e,errorKind:"server"}),this.el=i):this.destroy()}}onClose(e){if(!this.isDestroyed()){if(this.isMain()&&this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),this.liveSocket.isUnloaded()&&this.showLoader(zi)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([le,ye,Pe],{unstructuredError:e,errorKind:"server"}):this.displayError([le,ye,$t],{unstructuredError:e,errorKind:"client"}))}displayError(e,i={}){this.isMain()&&l.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error",...i}}),this.showLoader(),this.setContainerClasses(...e),this.delayedDisconnected()}delayedDisconnected(){this.disconnectedTimer=setTimeout(()=>{this.execAll(this.binding("disconnected"))},this.liveSocket.disconnectedTimeout)}wrapPush(e,i){const s=this.liveSocket.getLatencySim(),n=s?r=>setTimeout(()=>!this.isDestroyed()&&r(),s):r=>!this.isDestroyed()&&r();n(()=>{e().receive("ok",r=>n(()=>i.ok&&i.ok(r))).receive("error",r=>n(()=>i.error&&i.error(r))).receive("timeout",()=>n(()=>i.timeout&&i.timeout()))})}pushWithReply(e,i,s){if(!this.isConnected())return Promise.reject(new Error("no connection"));const[n,[r],o]=e?e({payload:s}):[null,[],{}],a=this.joinCount;let h=function(){};return o.page_loading&&(h=this.liveSocket.withPageLoading({kind:"element",target:r})),typeof s.cid!="number"&&delete s.cid,new Promise((c,d)=>{this.wrapPush(()=>this.channel.push(i,s,Qi),{ok:p=>{n!==null&&(this.lastAckRef=n);const m=g=>{p.redirect&&this.onRedirect(p.redirect),p.live_patch&&this.onLivePatch(p.live_patch),p.live_redirect&&this.onLiveRedirect(p.live_redirect),h(),c({resp:p,reply:g,ref:n})};p.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",p.diff,({diff:g,reply:u,events:v})=>{n!==null&&this.undoRefs(n,s.event),this.update(g,v),m(u)})}):(n!==null&&this.undoRefs(n,s.event),m(null))},error:p=>d(new Error(`failed with reason: ${JSON.stringify(p)}`)),timeout:()=>{d(new Error("timeout")),this.joinCount===a&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(e,i,s){if(!this.isConnected())return;const n=`[${J}="${this.refSrc()}"]`;s?(s=new Set(s),l.all(document,n,r=>{s&&!s.has(r)||(l.all(r,n,o=>this.undoElRef(o,e,i)),this.undoElRef(r,e,i))})):l.all(document,n,r=>this.undoElRef(r,e,i))}undoElRef(e,i,s){new Et(e).maybeUndo(i,s,r=>{const o=new ze(this,e,this.id,r,[],null,{undoRef:i}),a=this.performPatch(o,!0);l.all(e,`[${J}="${this.refSrc()}"]`,h=>this.undoElRef(h,i,s)),a&&this.joinNewChildren()})}refSrc(){return this.el.id}putRef(e,i,s,n={}){const r=this.ref++,o=this.binding(Mt);if(n.loading){const a=l.all(document,n.loading).map(h=>({el:h,lock:!0,loading:!0}));e=e.concat(a)}for(const{el:a,lock:h,loading:c}of e){if(!h&&!c)throw new Error("putRef requires lock or loading");if(a.setAttribute(J,this.refSrc()),c&&a.setAttribute(_e,r),h&&a.setAttribute(O,r),!c||n.submitter&&!(a===n.submitter||a===n.form))continue;const d=new Promise(u=>{a.addEventListener(`phx:undo-lock:${r}`,()=>u(g),{once:!0})}),p=new Promise(u=>{a.addEventListener(`phx:undo-loading:${r}`,()=>u(g),{once:!0})});a.classList.add(`phx-${s}-loading`);const m=a.getAttribute(o);m!==null&&(a.getAttribute(st)||a.setAttribute(st,a.textContent),m!==""&&(a.textContent=m),a.setAttribute(Se,a.getAttribute(Se)||a.disabled),a.setAttribute("disabled",""));const g={event:i,eventType:s,ref:r,isLoading:c,isLocked:h,lockElements:e.filter(({lock:u})=>u).map(({el:u})=>u),loadingElements:e.filter(({loading:u})=>u).map(({el:u})=>u),unlock:u=>{u=Array.isArray(u)?u:[u],this.undoRefs(r,i,u)},lockComplete:d,loadingComplete:p,lock:u=>new Promise(v=>{if(this.isAcked(r))return v(g);u.setAttribute(O,r),u.setAttribute(J,this.refSrc()),u.addEventListener(`phx:lock-stop:${r}`,()=>v(g),{once:!0})})};n.payload&&(g.payload=n.payload),n.target&&(g.target=n.target),n.originalEvent&&(g.originalEvent=n.originalEvent),a.dispatchEvent(new CustomEvent("phx:push",{detail:g,bubbles:!0,cancelable:!1})),i&&a.dispatchEvent(new CustomEvent(`phx:push:${i}`,{detail:g,bubbles:!0,cancelable:!1}))}return[r,e.map(({el:a})=>a),n]}isAcked(e){return this.lastAckRef!==null&&this.lastAckRef>=e}componentID(e){const i=e.getAttribute&&e.getAttribute(Y);return i?parseInt(i):null}targetComponentID(e,i,s={}){if(te(i))return i;const n=s.target||e.getAttribute(this.binding("target"));return te(n)?parseInt(n):i&&(n!==null||s.target)?this.closestComponentID(i):null}closestComponentID(e){return te(e)?e:e?Ce(e.closest(`[${Y}],[${he}]`),i=>{if(i.hasAttribute(Y))return this.ownsElement(i)&&this.componentID(i);if(i.hasAttribute(he)){const s=l.byId(i.getAttribute(he));return this.closestComponentID(s)}}):null}pushHookEvent(e,i,s,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",s,n]),Promise.reject(new Error("unable to push hook event. LiveView not connected"));const r=()=>this.putRef([{el:e,loading:!0,lock:!0}],s,"hook",{payload:n,target:i});return this.pushWithReply(r,"event",{type:"hook",event:s,value:n,cid:this.closestComponentID(i)}).then(({resp:o,reply:a,ref:h})=>({reply:a,ref:h}))}extractMeta(e,i,s){const n=this.binding("value-");for(let r=0;r<e.attributes.length;r++){i||(i={});const o=e.attributes[r].name;o.startsWith(n)&&(i[o.replace(n,"")]=e.getAttribute(o))}if(e.value!==void 0&&!(e instanceof HTMLFormElement)&&(i||(i={}),i.value=e.value,e.tagName==="INPUT"&&vi.indexOf(e.type)>=0&&!e.checked&&delete i.value),s){i||(i={});for(const r in s)i[r]=s[r]}return i}pushEvent(e,i,s,n,r,o={},a){this.pushWithReply(h=>this.putRef([{el:i,loading:!0,lock:!0}],n,e,{...o,payload:h==null?void 0:h.payload}),"event",{type:e,event:n,value:this.extractMeta(i,r,o.value),cid:this.targetComponentID(i,s,o)}).then(({reply:h})=>a&&a(h)).catch(h=>P("Failed to push event",h))}pushFileProgress(e,i,s,n=function(){}){this.liveSocket.withinOwners(e.form,(r,o)=>{r.pushWithReply(null,"progress",{event:e.getAttribute(r.binding(Wi)),ref:e.getAttribute(ie),entry_ref:i,progress:s,cid:r.targetComponentID(e.form,o)}).then(()=>n()).catch(a=>P("Failed to push file progress",a))})}pushInput(e,i,s,n,r,o){if(!e.form)throw new Error("form events require the input to be inside a form");let a;const h=te(s)?s:this.targetComponentID(e.form,i,r),c=u=>this.putRef([{el:e,loading:!0,lock:!0},{el:e.form,loading:!0,lock:!0}],n,"change",{...r,payload:u==null?void 0:u.payload});let d;const p=this.extractMeta(e.form,{},r.value),m={};e instanceof HTMLButtonElement&&(m.submitter=e),e.getAttribute(this.binding("change"))?d=Ge(e.form,m,[e.name]):d=Ge(e.form,m),l.isUploadInput(e)&&e.files&&e.files.length>0&&N.trackFiles(e,Array.from(e.files)),a=N.serializeUploads(e);const g={type:"form",event:n,value:d,meta:{_target:r._target||"undefined",...p},uploads:a,cid:h};this.pushWithReply(c,"event",g).then(({resp:u})=>{l.isUploadInput(e)&&l.isAutoUpload(e)?Et.onUnlock(e,()=>{if(N.filesAwaitingPreflight(e).length>0){const[v,w]=c();this.undoRefs(v,n,[e.form]),this.uploadFiles(e.form,n,i,v,h,D=>{o&&o(u),this.triggerAwaitingSubmit(e.form,n),this.undoRefs(v,n)})}}):o&&o(u)}).catch(u=>P("Failed to push input event",u))}triggerAwaitingSubmit(e,i){const s=this.getScheduledSubmit(e);if(s){const[n,r,o,a]=s;this.cancelSubmit(e,i),a()}}getScheduledSubmit(e){return this.formSubmits.find(([i,s,n,r])=>i.isSameNode(e))}scheduleSubmit(e,i,s,n){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,i,s,n])}cancelSubmit(e,i){this.formSubmits=this.formSubmits.filter(([s,n,r,o])=>s.isSameNode(e)?(this.undoRefs(n,i),!1):!0)}disableForm(e,i,s={}){const n=u=>!(ue(u,`${this.binding(nt)}=ignore`,u.form)||ue(u,"data-phx-update=ignore",u.form)),r=u=>u.hasAttribute(this.binding(Mt)),o=u=>u.tagName=="BUTTON",a=u=>["INPUT","TEXTAREA","SELECT"].includes(u.tagName),h=Array.from(e.elements),c=h.filter(r),d=h.filter(o).filter(n),p=h.filter(a).filter(n);d.forEach(u=>{u.setAttribute(Se,u.disabled),u.disabled=!0}),p.forEach(u=>{u.setAttribute(kt,u.readOnly),u.readOnly=!0,u.files&&(u.setAttribute(Se,u.disabled),u.disabled=!0)});const m=c.concat(d).concat(p).map(u=>({el:u,loading:!0,lock:!0})),g=[{el:e,loading:!0,lock:!1}].concat(m).reverse();return this.putRef(g,i,"submit",s)}pushFormSubmit(e,i,s,n,r,o){const a=c=>this.disableForm(e,s,{...r,form:e,payload:c==null?void 0:c.payload,submitter:n});l.putPrivate(e,"submitter",n);const h=this.targetComponentID(e,i);if(N.hasUploadsInProgress(e)){const[c,d]=a(),p=()=>this.pushFormSubmit(e,i,s,n,r,o);return this.scheduleSubmit(e,c,r,p)}else if(N.inputsAwaitingPreflight(e).length>0){const[c,d]=a(),p=()=>[c,d,r];this.uploadFiles(e,s,i,c,h,m=>{if(N.inputsAwaitingPreflight(e).length>0)return this.undoRefs(c,s);const g=this.extractMeta(e,{},r.value),u=Ge(e,{submitter:n});this.pushWithReply(p,"event",{type:"form",event:s,value:u,meta:g,cid:h}).then(({resp:v})=>o(v)).catch(v=>P("Failed to push form submit",v))})}else if(!(e.hasAttribute(J)&&e.classList.contains("phx-submit-loading"))){const c=this.extractMeta(e,{},r.value),d=Ge(e,{submitter:n});this.pushWithReply(a,"event",{type:"form",event:s,value:d,meta:c,cid:h}).then(({resp:p})=>o(p)).catch(p=>P("Failed to push form submit",p))}}uploadFiles(e,i,s,n,r,o){const a=this.joinCount,h=N.activeFileInputs(e);let c=h.length;h.forEach(d=>{const p=new N(d,this,()=>{c--,c===0&&o()}),m=p.entries().map(u=>u.toPreflightPayload());if(m.length===0){c--;return}const g={ref:d.getAttribute(ie),entries:m,cid:this.targetComponentID(d.form,s)};this.log("upload",()=>["sending preflight request",g]),this.pushWithReply(null,"allow_upload",g).then(({resp:u})=>{if(this.log("upload",()=>["got preflight response",u]),p.entries().forEach(v=>{u.entries&&!u.entries[v.ref]&&this.handleFailedEntryPreflight(v.ref,"failed preflight",p)}),u.error||Object.keys(u.entries).length===0)this.undoRefs(n,i),(u.error||[]).map(([w,D])=>{this.handleFailedEntryPreflight(w,D,p)});else{const v=w=>{this.channel.onError(()=>{this.joinCount===a&&w()})};p.initAdapterUpload(u,v,this.liveSocket)}}).catch(u=>P("Failed to push upload",u))})}handleFailedEntryPreflight(e,i,s){if(s.isAutoUpload()){const n=s.entries().find(r=>r.ref===e.toString());n&&n.cancel()}else s.entries().map(n=>n.cancel());this.log("upload",()=>[`error for entry ${e}`,i])}dispatchUploads(e,i,s){const n=this.targetCtxElement(e)||this.el,r=l.findUploadInputs(n).filter(o=>o.name===i);r.length===0?P(`no live file inputs found matching the name "${i}"`):r.length>1?P(`duplicate live file inputs found matching the name "${i}"`):l.dispatchEvent(r[0],pi,{detail:{files:s}})}targetCtxElement(e){if(te(e)){const[i]=l.findComponentNodeList(this.id,e);return i}else return e||null}pushFormRecovery(e,i,s,n){const r=this.binding("change"),o=i.getAttribute(this.binding("target"))||i,a=i.getAttribute(this.binding(Ft))||i.getAttribute(this.binding("change")),h=Array.from(e.elements).filter(p=>l.isFormInput(p)&&p.name&&!p.hasAttribute(r));if(h.length===0){n();return}h.forEach(p=>p.hasAttribute(ie)&&N.clearFiles(p));const c=h.find(p=>p.type!=="hidden")||h[0];let d=0;this.withinTargets(o,(p,m)=>{const g=this.targetComponentID(i,m);d++;let u=new CustomEvent("phx:form-recovery",{detail:{sourceElement:e}});S.exec(u,"change",a,this,c,["push",{_target:c.name,targetView:p,targetCtx:m,newCid:g,callback:()=>{d--,d===0&&n()}}])},s)}pushLinkPatch(e,i,s,n){const r=this.liveSocket.setPendingLink(i),o=e.isTrusted&&e.type!=="popstate",a=s?()=>this.putRef([{el:s,loading:o,lock:!0}],null,"click"):null,h=()=>this.liveSocket.redirect(window.location.href),c=i.startsWith("/")?`${location.protocol}//${location.host}${i}`:i;this.pushWithReply(a,"live_patch",{url:c}).then(({resp:d})=>{this.liveSocket.requestDOMUpdate(()=>{if(d.link_redirect)this.liveSocket.replaceMain(i,null,n,r);else{if(d.redirect)return;this.liveSocket.commitPendingLink(r)&&(this.href=i),this.applyPendingUpdates(),n&&n(r)}})},({error:d,timeout:p})=>h())}getFormsForRecovery(){if(this.joinCount===0)return{};const e=this.binding("change");return l.all(document,`#${CSS.escape(this.id)} form[${e}], [${me}="${CSS.escape(this.id)}"] form[${e}]`).filter(i=>i.id).filter(i=>i.elements.length>0).filter(i=>i.getAttribute(this.binding(Ft))!=="ignore").map(i=>{const s=i.cloneNode(!0);St(s,i,{onBeforeElUpdated:(r,o)=>(l.copyPrivates(r,o),r.getAttribute("form")===i.id?(r.parentNode.removeChild(r),!1):!0)});const n=document.querySelectorAll(`[form="${CSS.escape(i.id)}"]`);return Array.from(n).forEach(r=>{const o=r.cloneNode(!0);St(o,r),l.copyPrivates(o,r),o.removeAttribute("form"),s.appendChild(o)}),s}).reduce((i,s)=>(i[s.id]=s,i),{})}maybePushComponentsDestroyed(e){let i=e.filter(n=>l.findComponentNodeList(this.id,n).length===0);const s=n=>{this.isDestroyed()||P("Failed to push components destroyed",n)};i.length>0&&(i.forEach(n=>this.rendered.resetRender(n)),this.pushWithReply(null,"cids_will_destroy",{cids:i}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let n=i.filter(r=>l.findComponentNodeList(this.id,r).length===0);n.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:n}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)}).catch(s)})}).catch(s))}ownsElement(e){let i=l.closestViewEl(e);return e.getAttribute(pe)===this.id||i&&i.id===this.id||!i&&this.isDead}submitForm(e,i,s,n,r={}){l.putPrivate(e,$e,!0),Array.from(e.elements).forEach(a=>l.putPrivate(a,$e,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,i,s,n,r,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}pushPortalElementId(e){this.portalElementIds.add(e)}dropPortalElementId(e){this.portalElementIds.delete(e)}destroyPortalElements(){this.liveSocket.unloaded||this.portalElementIds.forEach(e=>{const i=document.getElementById(e);i&&i.remove()})}},Os=class{constructor(t,e,i={}){if(this.unloaded=!1,!e||e.constructor.name==="Object")throw new Error(`
      a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:

          import {Socket} from "phoenix"
          import {LiveSocket} from "phoenix_live_view"
          let liveSocket = new LiveSocket("/live", Socket, {...})
      `);this.socket=new e(t,i),this.bindingPrefix=i.bindingPrefix||Yi,this.opts=i,this.params=Oe(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(et(Zi),i.defaults||{}),this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=et(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Ki,this.disconnectedTimeout=i.disconnectedTimeout||Gi,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||Oi,this.reloadJitterMin=i.reloadJitterMin||Di,this.reloadJitterMax=i.reloadJitterMax||Hi,this.failsafeJitter=i.failsafeJitter||Ni,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.boundEventNames=new Set,this.blockPhxChangeWhileComposing=i.blockPhxChangeWhileComposing||!1,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:Oe(),onPatchEnd:Oe(),onNodeAdded:Oe(),onBeforeElUpdated:Oe()},i.dom||{}),this.transitions=new Ds,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(qe))||0,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}version(){return"1.1.27"}isProfileEnabled(){return this.sessionStorage.getItem(ct)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Xe)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Xe)==="false"}enableDebug(){this.sessionStorage.setItem(Xe,"true")}enableProfiling(){this.sessionStorage.setItem(ct,"true")}disableDebug(){this.sessionStorage.setItem(Xe,"false")}disableProfiling(){this.sessionStorage.removeItem(ct)}enableLatencySim(t){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(dt,t)}disableLatencySim(){this.sessionStorage.removeItem(dt)}getLatencySim(){const t=this.sessionStorage.getItem(dt);return t?parseInt(t):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();const t=()=>{this.resetReloadStatus(),this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.bindTopLevelEvents({dead:!0}),this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?t():document.addEventListener("DOMContentLoaded",()=>t())}disconnect(t){clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off(this.serverCloseRef),this.serverCloseRef=null),this.socket.disconnect(t)}replaceTransport(t){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(t),this.connect()}execJS(t,e,i=null){const s=new CustomEvent("phx:exec",{detail:{sourceElement:t}});this.owner(t,n=>S.exec(s,i,e,n,t))}js(){return yi(this,"js")}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(t,e){this.domCallbacks[t](...e)}time(t,e){if(!this.isProfileEnabled()||!console.time)return e();console.time(t);const i=e();return console.timeEnd(t),i}log(t,e,i){if(this.viewLogger){const[s,n]=i();this.viewLogger(t,e,s,n)}else if(this.isDebugEnabled()){const[s,n]=i();ss(t,e,s,n)}}requestDOMUpdate(t){this.transitions.after(t)}asyncTransition(t){this.transitions.addAsyncTransition(t)}transition(t,e,i=function(){}){this.transitions.addTransition(t,e,i)}onChannel(t,e,i){t.on(e,s=>{const n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}reloadWithJitter(t,e){clearTimeout(this.reloadWithJitterTimer),this.disconnect();const i=this.reloadJitterMin,s=this.reloadJitterMax;let n=Math.floor(Math.random()*(s-i+1))+i;const r=U.updateLocal(this.localStorage,window.location.pathname,ui,0,o=>o+1);r>=this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{t.isDestroyed()||t.isConnected()||(t.destroy(),e?e():this.log(t,"join",()=>[`encountered ${r} consecutive reloads`]),r>=this.maxReloads&&this.log(t,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookDefinition(t){if(t)return this.maybeInternalHook(t)||this.hooks[t]||this.maybeRuntimeHook(t)}maybeInternalHook(t){return t&&t.startsWith("Phoenix.")&&us[t.split(".")[1]]}maybeRuntimeHook(t){const e=document.querySelector(`script[${Ze}="${CSS.escape(t)}"]`);if(!e)return;let i=window[`phx_hook_${t}`];if(!i||typeof i!="function"){P("a runtime hook must be a function",e);return}const s=i();if(s&&(typeof s=="object"||typeof s=="function"))return s;P("runtime hook must return an object with hook callbacks or an instance of ViewHook",e)}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(t){return`${this.getBindingPrefix()}${t}`}channel(t,e){return this.socket.channel(t,e)}joinDeadView(){const t=document.body;if(t&&!this.isPhxView(t)&&!this.isPhxView(document.firstElementChild)){const e=this.newRootView(t);e.setHref(this.getHref()),e.joinDead(),this.main||(this.main=e),window.requestAnimationFrame(()=>{var i;e.execNewMounted(),this.maybeScroll((i=history.state)==null?void 0:i.scroll)})}}joinRootViews(){let t=!1;return l.all(document,`${Me}:not([${pe}])`,e=>{if(!this.getRootById(e.id)){const i=this.newRootView(e);l.isPhxSticky(e)||i.setHref(this.getHref()),i.join(),e.hasAttribute(_t)&&(this.main=i)}t=!0}),t}redirect(t,e,i){i&&U.setCookie(jt,i,60),this.unload(),U.redirect(t,e)}replaceMain(t,e,i=null,s=this.setPendingLink(t)){const n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;const r=l.findPhxSticky(document)||[],o=l.all(this.outgoingMainEl,`[${this.binding("remove")}]`).filter(h=>!l.isChildOfAny(h,r)),a=l.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(a,e,n),this.main.setRedirect(t),this.transitionRemoves(o),this.main.join((h,c)=>{h===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{o.forEach(d=>d.remove()),r.forEach(d=>a.appendChild(d)),this.outgoingMainEl.replaceWith(a),this.outgoingMainEl=null,i&&i(s),c()})})}transitionRemoves(t,e){const i=this.binding("remove"),s=n=>{n.preventDefault(),n.stopImmediatePropagation()};t.forEach(n=>{for(const r of this.boundEventNames)n.addEventListener(r,s,!0);this.execJS(n,n.getAttribute(i),"remove")}),this.requestDOMUpdate(()=>{t.forEach(n=>{for(const r of this.boundEventNames)n.removeEventListener(r,s,!0)}),e&&e()})}isPhxView(t){return t.getAttribute&&t.getAttribute(Q)!==null}newRootView(t,e,i){const s=new Is(t,this,null,e,i);return this.roots[s.id]=s,s}owner(t,e){let i;const s=l.closestViewEl(t);if(s)i=this.getViewByEl(s);else{if(!t.isConnected)return null;i=this.main}return i&&e?e(i):i}withinOwners(t,e){this.owner(t,i=>e(i,t))}getViewByEl(t){const e=t.getAttribute(ae);return Ce(this.getRootById(e),i=>i.getDescendentByEl(t))}getRootById(t){return this.roots[t]}destroyAllViews(){for(const t in this.roots)this.roots[t].destroy(),delete this.roots[t];this.main=null}destroyViewByEl(t){const e=this.getRootById(t.getAttribute(ae));e&&e.id===t.id?(e.destroy(),delete this.roots[e.id]):e&&e.destroyDescendent(t.id)}getActiveElement(){return document.activeElement}dropActiveElement(t){this.prevActive&&t.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive instanceof HTMLElement&&this.prevActive.blur()}bindTopLevelEvents({dead:t}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.serverCloseRef=this.socket.onClose(e=>{if(e&&e.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",e=>{e.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),t||this.bindNav(),this.bindClicks(),t||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(e,i,s,n,r,o)=>{const a=n.getAttribute(this.binding(qi)),h=e.key&&e.key.toLowerCase();if(a&&a.toLowerCase()!==h)return;const c={key:e.key,...this.eventMeta(i,e,n)};S.exec(e,i,r,s,n,["push",{data:c}])}),this.bind({blur:"focusout",focus:"focusin"},(e,i,s,n,r,o)=>{if(!o){const a={key:e.key,...this.eventMeta(i,e,n)};S.exec(e,i,r,s,n,["push",{data:a}])}}),this.bind({blur:"blur",focus:"focus"},(e,i,s,n,r,o)=>{if(o==="window"){const a=this.eventMeta(i,e,n);S.exec(e,i,r,s,n,["push",{data:a}])}}),this.on("dragover",e=>e.preventDefault()),this.on("dragenter",e=>{const i=ue(e.target,this.binding(Je));!i||!(i instanceof HTMLElement)||os(e)&&this.js().addClass(i,ht)}),this.on("dragleave",e=>{const i=ue(e.target,this.binding(Je));if(!i||!(i instanceof HTMLElement))return;const s=i.getBoundingClientRect();(e.clientX<=s.left||e.clientX>=s.right||e.clientY<=s.top||e.clientY>=s.bottom)&&this.js().removeClass(i,ht)}),this.on("drop",e=>{e.preventDefault();const i=ue(e.target,this.binding(Je));if(!i||!(i instanceof HTMLElement))return;this.js().removeClass(i,ht);const s=i.getAttribute(this.binding(Je)),n=s&&document.getElementById(s),r=Array.from(e.dataTransfer.files||[]);!n||!(n instanceof HTMLInputElement)||n.disabled||r.length===0||!(n.files instanceof FileList)||(N.trackFiles(n,r,e.dataTransfer),n.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(pi,e=>{const i=e.target;if(!l.isUploadInput(i))return;const s=Array.from(e.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);N.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(t,e,i){const s=this.metadataCallbacks[t];return s?s(e,i):{}}setPendingLink(t){return this.linkRef++,this.pendingLink=t,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){U.deleteCookie(jt)}commitPendingLink(t){return this.linkRef!==t?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(t,e){for(const i in t){const s=t[i];this.on(s,n=>{const r=this.binding(i),o=this.binding(`window-${i}`),a=n.target.getAttribute&&n.target.getAttribute(r);a?this.debounce(n.target,n,s,()=>{this.withinOwners(n.target,h=>{e(n,i,h,n.target,a,null)})}):l.all(document,`[${o}]`,h=>{const c=h.getAttribute(o);this.debounce(h,n,s,()=>{this.withinOwners(h,d=>{e(n,i,d,h,c,"window")})})})})}}bindClicks(){this.on("mousedown",t=>this.clickStartedAtTarget=t.target),this.bindClick("click","click")}bindClick(t,e){const i=this.binding(e);window.addEventListener(t,s=>{let n=null;s.detail===0&&(this.clickStartedAtTarget=s.target);const r=this.clickStartedAtTarget||s.target;n=ue(s.target,i),this.dispatchClickAway(s,r),this.clickStartedAtTarget=null;const o=n&&n.getAttribute(i);if(!o){l.isNewPageClick(s,window.location)&&this.unload();return}n.getAttribute("href")==="#"&&s.preventDefault(),!n.hasAttribute(J)&&this.debounce(n,s,"click",()=>{this.withinOwners(n,a=>{S.exec(s,"click",o,a,n,["push",{data:this.eventMeta("click",s,n)}])})})},!1)}dispatchClickAway(t,e){const i=this.binding("click-away"),s=e.closest(`[${he}]`),n=s&&l.byId(s.getAttribute(he));l.all(document,`[${i}]`,r=>{let o=e;s&&!s.contains(r)&&(o=n),r.isSameNode(o)||r.contains(o)||!S.isVisible(e)||this.withinOwners(r,a=>{const h=r.getAttribute(i);S.isVisible(r)&&S.isInViewport(r)&&S.exec(t,"click",h,a,r,["push",{data:this.eventMeta("click",t,t.target)}])})})}bindNav(){if(!U.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let t=null;window.addEventListener("scroll",e=>{clearTimeout(t),t=setTimeout(()=>{U.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",e=>{if(!this.registerNewLocation(window.location))return;const{type:i,backType:s,id:n,scroll:r,position:o}=e.state||{},a=window.location.href,h=o>this.currentHistoryPosition,c=h?i:s||i;this.currentHistoryPosition=o||0,this.sessionStorage.setItem(qe,this.currentHistoryPosition.toString()),l.dispatchEvent(window,"phx:navigate",{detail:{href:a,patch:c==="patch",pop:!0,direction:h?"forward":"backward"}}),this.requestDOMUpdate(()=>{const d=()=>{this.maybeScroll(r)};this.main.isConnected()&&c==="patch"&&n===this.main.id?this.main.pushLinkPatch(e,a,null,d):this.replaceMain(a,null,d)})},!1),window.addEventListener("click",e=>{const i=ue(e.target,lt),s=i&&i.getAttribute(lt);if(!s||!this.isConnected()||!this.main||l.wantsNewTab(e))return;const n=i.href instanceof SVGAnimatedString?i.href.baseVal:i.href,r=i.getAttribute(Mi);e.preventDefault(),e.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(e,n,r,i);else if(s==="redirect")this.historyRedirect(e,n,r,null,i);else throw new Error(`expected ${lt} to be "patch" or "redirect", got: ${s}`);const o=i.getAttribute(this.binding("click"));o&&this.requestDOMUpdate(()=>this.execJS(i,o,"click"))})},!1)}maybeScroll(t){typeof t=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,t)})}dispatchEvent(t,e={}){l.dispatchEvent(window,`phx:${t}`,{detail:e})}dispatchEvents(t){t.forEach(([e,i])=>this.dispatchEvent(e,i))}withPageLoading(t,e){l.dispatchEvent(window,"phx:page-loading-start",{detail:t});const i=()=>l.dispatchEvent(window,"phx:page-loading-stop",{detail:t});return e?e(i):i}pushHistoryPatch(t,e,i,s){if(!this.isConnected()||!this.main.isMain())return U.redirect(e);this.withPageLoading({to:e,kind:"patch"},n=>{this.main.pushLinkPatch(t,e,s,r=>{this.historyPatch(e,i,r),n()})})}historyPatch(t,e,i=this.setPendingLink(t)){this.commitPendingLink(i)&&(this.currentHistoryPosition++,this.sessionStorage.setItem(qe,this.currentHistoryPosition.toString()),U.updateCurrentState(s=>({...s,backType:"patch"})),U.pushState(e,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},t),l.dispatchEvent(window,"phx:navigate",{detail:{patch:!0,href:t,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(t,e,i,s,n){const r=n&&t.isTrusted&&t.type!=="popstate";if(r&&n.classList.add("phx-click-loading"),!this.isConnected()||!this.main.isMain())return U.redirect(e,s);if(/^\/$|^\/[^\/]+.*$/.test(e)){const{protocol:a,host:h}=window.location;e=`${a}//${h}${e}`}const o=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},a=>{this.replaceMain(e,s,h=>{h===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(qe,this.currentHistoryPosition.toString()),U.updateCurrentState(c=>({...c,backType:"redirect"})),U.pushState(i,{type:"redirect",id:this.main.id,scroll:o,position:this.currentHistoryPosition},e),l.dispatchEvent(window,"phx:navigate",{detail:{href:e,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),r&&n.classList.remove("phx-click-loading"),a()})})}registerNewLocation(t){const{pathname:e,search:i}=this.currentLocation;return e+i===t.pathname+t.search?!1:(this.currentLocation=et(t),!0)}bindForms(){let t=0,e=!1;this.on("submit",i=>{const s=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!e&&n&&!s&&(e=!0,i.preventDefault(),this.withinOwners(i.target,r=>{r.disableForm(i.target),window.requestAnimationFrame(()=>{l.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))}),this.on("submit",i=>{const s=i.target.getAttribute(this.binding("submit"));if(!s){l.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{S.exec(i,"submit",s,n,i.target,["push",{submitter:i.submitter}])})});for(const i of["change","input"])this.on(i,s=>{if(s instanceof CustomEvent&&(s.target instanceof HTMLInputElement||s.target instanceof HTMLSelectElement||s.target instanceof HTMLTextAreaElement)&&s.target.form===void 0){if(s.detail&&s.detail.dispatcher)throw new Error(`dispatching a custom ${i} event is only supported on input elements inside a form`);return}const n=this.binding("change"),r=s.target;if(this.blockPhxChangeWhileComposing&&s.isComposing){const g=`composition-listener-${i}`;l.private(r,g)||(l.putPrivate(r,g,!0),r.addEventListener("compositionend",()=>{r.dispatchEvent(new Event(i,{bubbles:!0})),l.deletePrivate(r,g)},{once:!0}));return}const o=r.getAttribute(n),a=r.form&&r.form.getAttribute(n),h=o||a;if(!h||r.type==="number"&&r.validity&&r.validity.badInput)return;const c=o?r:r.form,d=t;t++;const{at:p,type:m}=l.private(r,"prev-iteration")||{};p===d-1&&i==="change"&&m==="input"||(l.putPrivate(r,"prev-iteration",{at:d,type:i}),this.debounce(r,s,i,()=>{this.withinOwners(c,g=>{l.putPrivate(r,it,!0),S.exec(s,"change",h,g,r,["push",{_target:s.target.name,dispatcher:c}])})}))});this.on("reset",i=>{const s=i.target;l.resetForm(s);const n=Array.from(s.elements).find(r=>r.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(t,e,i,s){if(i==="blur"||i==="focusout")return s();const n=this.binding(Vi),r=this.binding(Ji),o=this.defaults.debounce.toString(),a=this.defaults.throttle.toString();this.withinOwners(t,h=>{const c=()=>!h.isDestroyed()&&document.body.contains(t);l.debounce(t,e,n,o,r,a,c,()=>{s()})})}silenceEvents(t){this.silenced=!0,t(),this.silenced=!1}on(t,e){this.boundEventNames.add(t),window.addEventListener(t,i=>{this.silenced||e(i)})}jsQuerySelectorAll(t,e,i){const s=this.domCallbacks.jsQuerySelectorAll;return s?s(t,e,i):i()}},Ds=class{constructor(){this.transitions=new Set,this.promises=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(t=>{clearTimeout(t),this.transitions.delete(t)}),this.promises.clear(),this.flushPendingOps()}after(t){this.size()===0?t():this.pushPendingOp(t)}addTransition(t,e,i){e();const s=setTimeout(()=>{this.transitions.delete(s),i(),this.flushPendingOps()},t);this.transitions.add(s)}addAsyncTransition(t){this.promises.add(t),t.then(()=>{this.promises.delete(t),this.flushPendingOps()})}pushPendingOp(t){this.pendingOps.push(t)}size(){return this.transitions.size+this.promises.size}flushPendingOps(){if(this.size()>0)return;const t=this.pendingOps.shift();t&&(t(),this.flushPendingOps())}},Hs=Os;const Ns={mounted(){const t=i=>{const s=this.el.dataset.open==="true";if((i.metaKey||i.ctrlKey)&&(i.key==="k"||i.key==="K")){i.preventDefault(),this.pushEventTo(this.el,"palette:open",{});return}if(s)switch(i.key){case"Escape":i.preventDefault(),this.pushEventTo(this.el,"palette:close",{});break;case"ArrowDown":i.preventDefault(),this.pushEventTo(this.el,"palette:move",{dir:"down"});break;case"ArrowUp":i.preventDefault(),this.pushEventTo(this.el,"palette:move",{dir:"up"});break;case"Enter":i.preventDefault(),this.pushEventTo(this.el,"palette:activate",{});break}},e=()=>{this.pushEventTo(this.el,"palette:open",{})};document.addEventListener("keydown",t),document.documentElement.addEventListener("durable:open-palette",e),this._onKeyDown=t,this._onOpenEvent=e,this._focusObserver=new MutationObserver(()=>{if(this.el.dataset.open==="true"){const i=this.el.querySelector("[data-palette-input]");i&&document.activeElement!==i&&i.focus()}}),this._focusObserver.observe(this.el,{attributes:!0,attributeFilter:["data-open"]})},destroyed(){var t;this._onKeyDown&&document.removeEventListener("keydown",this._onKeyDown),this._onOpenEvent&&document.documentElement.removeEventListener("durable:open-palette",this._onOpenEvent),(t=this._focusObserver)==null||t.disconnect()}},$s=1400;async function Ms(t){try{await navigator.clipboard.writeText(t);return}catch{const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();try{document.execCommand("copy")}catch{}e.remove()}}function Fs(){document.addEventListener("click",t=>{const e=t.target,i=e==null?void 0:e.closest("[data-copy]");if(!i)return;Ms(i.dataset.copy??""),i.dataset.copied="true";const s=Number(i.dataset.copyTimer);s&&window.clearTimeout(s),i.dataset.copyTimer=String(window.setTimeout(()=>{delete i.dataset.copied,delete i.dataset.copyTimer},$s))})}const Us="modulepreload",js=function(t,e){return new URL(t,e).href},ai={},Bs=function(e,i,s){let n=Promise.resolve();if(i&&i.length>0){let o=function(d){return Promise.all(d.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const a=document.getElementsByTagName("link"),h=document.querySelector("meta[property=csp-nonce]"),c=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));n=o(i.map(d=>{if(d=js(d,s),d in ai)return;ai[d]=!0;const p=d.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(!!s)for(let v=a.length-1;v>=0;v--){const w=a[v];if(w.href===d&&(!p||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${m}`))return;const u=document.createElement("link");if(u.rel=p?"stylesheet":Us,p||(u.as="script"),u.crossOrigin="",u.href=d,c&&u.setAttribute("nonce",c),document.head.appendChild(u),p)return new Promise((v,w)=>{u.addEventListener("load",v),u.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${d}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})},Vs={async mounted(){const t=this.el.id||`flow-${Math.random().toString(36).slice(2,8)}`,e=`${t}:replace`,i=`${t}:patch-node`;this._eventNames={replace:e,patchNode:i};let s={nodes:[],edges:[]};try{const r=this.el.dataset.graph;r&&(s=JSON.parse(r))}catch(r){console.warn("[FlowGraph] failed to parse data-graph attribute:",r)}const{mountFlowIsland:n}=await Bs(async()=>{const{mountFlowIsland:r}=await import("./flow_graph-Cp6z_J_Q.js");return{mountFlowIsland:r}},__vite__mapDeps([0,1]),import.meta.url);this._island=n(this.el,s),this.handleEvent(e,r=>{var a;const{graph:o}=r;o&&((a=this._island)==null||a.setGraph(o))}),this.handleEvent(i,r=>{var h;const{id:o,patch:a}=r;o&&((h=this._island)==null||h.patchNode(o,a||{}))}),this._onStepClicked=r=>{var a;const o=r;(a=o.detail)!=null&&a.stepName&&this.pushEventTo(this.el,"step-clicked",{step_name:o.detail.stepName,step_execution_id:o.detail.stepExecutionId,child_workflow_id:o.detail.childWorkflowId})},this.el.addEventListener("durable:step-clicked",this._onStepClicked)},destroyed(){var t;(t=this._island)==null||t.destroy(),this._island=void 0,this._onStepClicked&&(this.el.removeEventListener("durable:step-clicked",this._onStepClicked),this._onStepClicked=void 0)}};function Ct(t){const e=t.dataset.ts;if(!e)return;const i=new Date(e);if(!Number.isNaN(i.getTime())){if(t.dataset.rel){t.setAttribute("title",hi(i,"datetime"));return}t.textContent=hi(i,t.dataset.format||"datetime"),t.setAttribute("title",i.toString())}}function Lt(t){t instanceof HTMLElement&&t.matches("time[data-ts]")&&Ct(t);for(const e of t.querySelectorAll("time[data-ts]"))Ct(e)}function hi(t,e){switch(e){case"time":return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,hour12:!1});case"date":return t.toLocaleDateString([],{year:"numeric",month:"short",day:"numeric"});default:return t.toLocaleString([],{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}}var li;const Js=(li=document.querySelector("meta[name='csrf-token']"))==null?void 0:li.getAttribute("content");var ci;const Xs=((ci=document.querySelector("meta[name='live-socket-path']"))==null?void 0:ci.getAttribute("content"))||"/live",Ei=new Hs(Xs,Ii,{hooks:{FlowGraph:Vs,CommandPalette:Ns},params:{_csrf_token:Js},dom:{onNodeAdded(t){t instanceof HTMLElement&&Lt(t)},onBeforeElUpdated(t,e){e instanceof HTMLElement&&e.matches("time[data-ts]")&&Ct(e)}}});Ei.connect();Fs();Lt(document);document.addEventListener("phx:page-loading-stop",()=>Lt(document));window.liveSocket=Ei;