diff --git a/pkg/connectors/icinga2/connector.go b/pkg/connectors/icinga2/connector.go index 7f1902a9..fe989d78 100644 --- a/pkg/connectors/icinga2/connector.go +++ b/pkg/connectors/icinga2/connector.go @@ -200,6 +200,7 @@ func (c *Connector) get(endpoint string, ctx context.Context) (io.ReadCloser, er if res.StatusCode >= 200 && res.StatusCode < 300 { return res.Body, nil } + defer res.Body.Close() if ct := res.Header.Get("Content-Type"); ct == "application/json" { e := struct { diff --git a/pkg/web/common/server.go b/pkg/web/common/server.go index c5d200b6..aac4ebb3 100644 --- a/pkg/web/common/server.go +++ b/pkg/web/common/server.go @@ -34,7 +34,7 @@ func Serve(ctx context.Context, addr string, handler http.Handler) { close(idleConnectionsClosed) }() - slog.InfoContext(ctx, "Starting http server", slog.String("addr", addr)) + slog.InfoContext(ctx, "Starting http server", slog.String("addr", "http://"+addr)) if err := srv.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) { // Still try to start, application might still do useful work diff --git a/pkg/web/static/js/index.js b/pkg/web/static/js/index.js index 95447ee1..a95e3356 100644 --- a/pkg/web/static/js/index.js +++ b/pkg/web/static/js/index.js @@ -2,8 +2,6 @@ import * as Turbo from '@hotwired/turbo'; import ReconnectingWebSocket from 'reconnecting-websocket'; import { toggleFilteredStatus } from "./toggle-filtered"; -toggleFilteredStatus(); - class SSEConn { constructor(socketUrl) { this.socketUrl = socketUrl; @@ -70,7 +68,12 @@ class FallbackConn { let conn = this; this.timerId = setTimeout(function reload() { if (conn.active) { - let lastRefresh = Date.parse(document.querySelector("#last_refresh").dateTime); + let lastRefreshNode = document.querySelector("#last_refresh"); + let lastRefresh = Date.now(); + if (lastRefreshNode) { + lastRefresh = Date.parse(lastRefreshNode.dateTime); + } + if (Date.now() - lastRefresh > 90000) { console.log("Force reloading, last refresh too old: " + (Date.now() - lastRefresh)) location.reload(); @@ -127,6 +130,8 @@ fallback.connect(); conn.connect(); document.addEventListener("DOMContentLoaded", function () { + toggleFilteredStatus(); + console.log('Adding handler for manual disconnect.'); const csEl = document.getElementById('connection-state'); csEl.addEventListener("change", function () { diff --git a/pkg/web/static/js/index.min.js b/pkg/web/static/js/index.min.js index 66f69530..cd6277f0 100644 --- a/pkg/web/static/js/index.min.js +++ b/pkg/web/static/js/index.min.js @@ -1,8 +1,8 @@ /*! -Turbo 8.0.19 +Turbo 8.0.17 Copyright © 2025 37signals LLC */ -!function(e){function t(e,t,r){throw new e("Failed to execute 'requestSubmit' on 'HTMLFormElement': "+t+".",r)}"function"!=typeof e.requestSubmit&&(e.requestSubmit=function(e){e?(!function(e,r){e instanceof HTMLElement||t(TypeError,"parameter 1 is not of type 'HTMLElement'"),"submit"==e.type||t(TypeError,"The specified element is not a submit button"),e.form==r||t(DOMException,"The specified element is not owned by this form element","NotFoundError")}(e,this),e.click()):((e=document.createElement("input")).type="submit",e.hidden=!0,this.appendChild(e),e.click(),this.removeChild(e))})}(HTMLFormElement.prototype);const e=new WeakMap;function t(t){const r=function(e){const t=e instanceof Element?e:e instanceof Node?e.parentElement:null,r=t?t.closest("input, button"):null;return"submit"==r?.type?r:null}(t.target);r&&r.form&&e.set(r.form,r)}!function(){if("submitter"in Event.prototype)return;let r=window.Event.prototype;if("SubmitEvent"in window){const e=window.SubmitEvent.prototype;if(!/Apple Computer/.test(navigator.vendor)||"submitter"in e)return;r=e}addEventListener("click",t,!0),Object.defineProperty(r,"submitter",{get(){if("submit"==this.type&&this.target instanceof HTMLFormElement)return e.get(this.target)}})}();const r="eager",s="lazy";class i extends HTMLElement{static delegateConstructor=void 0;loaded=Promise.resolve();static get observedAttributes(){return["disabled","loading","src"]}constructor(){super(),this.delegate=new i.delegateConstructor(this)}connectedCallback(){this.delegate.connect()}disconnectedCallback(){this.delegate.disconnect()}reload(){return this.delegate.sourceURLReloaded()}attributeChangedCallback(e){"loading"==e?this.delegate.loadingStyleChanged():"src"==e?this.delegate.sourceURLChanged():"disabled"==e&&this.delegate.disabledChanged()}get src(){return this.getAttribute("src")}set src(e){e?this.setAttribute("src",e):this.removeAttribute("src")}get refresh(){return this.getAttribute("refresh")}set refresh(e){e?this.setAttribute("refresh",e):this.removeAttribute("refresh")}get shouldReloadWithMorph(){return this.src&&"morph"===this.refresh}get loading(){return function(e){if("lazy"===e.toLowerCase())return s;return r}(this.getAttribute("loading")||"")}set loading(e){e?this.setAttribute("loading",e):this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get autoscroll(){return this.hasAttribute("autoscroll")}set autoscroll(e){e?this.setAttribute("autoscroll",""):this.removeAttribute("autoscroll")}get complete(){return!this.delegate.isLoading}get isActive(){return this.ownerDocument===document&&!this.isPreview}get isPreview(){return this.ownerDocument?.documentElement?.hasAttribute("data-turbo-preview")}}const n={enabled:!0,progressBarDelay:500,unvisitableExtensions:new Set([".7z",".aac",".apk",".avi",".bmp",".bz2",".css",".csv",".deb",".dmg",".doc",".docx",".exe",".gif",".gz",".heic",".heif",".ico",".iso",".jpeg",".jpg",".js",".json",".m4a",".mkv",".mov",".mp3",".mp4",".mpeg",".mpg",".msi",".ogg",".ogv",".pdf",".pkg",".png",".ppt",".pptx",".rar",".rtf",".svg",".tar",".tif",".tiff",".txt",".wav",".webm",".webp",".wma",".wmv",".xls",".xlsx",".xml",".zip"])};function o(e){if("false"==e.getAttribute("data-turbo-eval"))return e;{const t=document.createElement("script"),r=L();return r&&(t.nonce=r),t.textContent=e.textContent,t.async=!1,function(e,t){for(const{name:r,value:s}of t.attributes)e.setAttribute(r,s)}(t,e),t}}function a(e,{target:t,cancelable:r,detail:s}={}){const i=new CustomEvent(e,{cancelable:r,bubbles:!0,composed:!0,detail:s});return t&&t.isConnected?t.dispatchEvent(i):document.documentElement.dispatchEvent(i),i}function c(e){e.preventDefault(),e.stopImmediatePropagation()}function l(){return"hidden"===document.visibilityState?d():h()}function h(){return new Promise(e=>requestAnimationFrame(()=>e()))}function d(){return new Promise(e=>setTimeout(()=>e(),0))}function u(e=""){return(new DOMParser).parseFromString(e,"text/html")}function m(e,...t){const r=function(e,t){return e.reduce((e,r,s)=>e+r+(null==t[s]?"":t[s]),"")}(e,t).replace(/^\n/,"").split("\n"),s=r[0].match(/^\s+/),i=s?s[0].length:0;return r.map(e=>e.slice(i)).join("\n")}function p(){return Array.from({length:36}).map((e,t)=>8==t||13==t||18==t||23==t?"-":14==t?"4":19==t?(Math.floor(4*Math.random())+8).toString(16):Math.floor(15*Math.random()).toString(16)).join("")}function f(e,...t){for(const r of t.map(t=>t?.getAttribute(e)))if("string"==typeof r)return r;return null}function g(...e){for(const t of e)"turbo-frame"==t.localName&&t.setAttribute("busy",""),t.setAttribute("aria-busy","true")}function b(...e){for(const t of e)"turbo-frame"==t.localName&&t.removeAttribute("busy"),t.removeAttribute("aria-busy")}function v(e,t=2e3){return new Promise(r=>{const s=()=>{e.removeEventListener("error",s),e.removeEventListener("load",s),r()};e.addEventListener("load",s,{once:!0}),e.addEventListener("error",s,{once:!0}),setTimeout(r,t)})}function w(e){switch(e){case"replace":return history.replaceState;case"advance":case"restore":return history.pushState}}function y(...e){const t=f("data-turbo-action",...e);return function(e){return"advance"==e||"replace"==e||"restore"==e}(t)?t:null}function S(e){return document.querySelector(`meta[name="${e}"]`)}function E(e){const t=S(e);return t&&t.content}function L(){const e=S("csp-nonce");if(e){const{nonce:t,content:r}=e;return""==t?r:t}}function T(e,t){if(e instanceof Element)return e.closest(t)||T(e.assignedSlot||e.getRootNode()?.host,t)}function R(e){return!!e&&null==e.closest("[inert], :disabled, [hidden], details:not([open]), dialog:not([open])")&&"function"==typeof e.focus}function A(e){return Array.from(e.querySelectorAll("[autofocus]")).find(R)}function C(e){if("_blank"===e)return!1;if(e){for(const t of document.getElementsByName(e))if(t instanceof HTMLIFrameElement)return!1;return!0}return!0}function P(e){const t=T(e,"a[href], a[xlink\\:href]");return t?t.hasAttribute("download")||t.hasAttribute("target")&&"_self"!==t.target?null:t:null}function k(e){return F(e.getAttribute("href")||"")}const M={"aria-disabled":{beforeSubmit:e=>{e.setAttribute("aria-disabled","true"),e.addEventListener("click",c)},afterSubmit:e=>{e.removeAttribute("aria-disabled"),e.removeEventListener("click",c)}},disabled:{beforeSubmit:e=>e.disabled=!0,afterSubmit:e=>e.disabled=!1}};const I=new class{#e=null;constructor(e){Object.assign(this,e)}get submitter(){return this.#e}set submitter(e){this.#e=M[e]||e}}({mode:"on",submitter:"disabled"}),_={drive:n,forms:I};function F(e){return new URL(e.toString(),document.baseURI)}function q(e){let t;return e.hash?e.hash.slice(1):(t=e.href.match(/#(.*)$/))?t[1]:void 0}function O(e,t){return F(t?.getAttribute("formaction")||e.getAttribute("action")||e.action)}function H(e){return(function(e){return function(e){return e.pathname.split("/").slice(1)}(e).slice(-1)[0]}(e).match(/\.[^.]*$/)||[])[0]||""}function N(e,t){return function(e,t){const r=V(t.origin+t.pathname);return V(e.href)===r||e.href.startsWith(r)}(e,t)&&!_.drive.unvisitableExtensions.has(H(e))}function B(e){const t=q(e);return null!=t?e.href.slice(0,-(t.length+1)):e.href}function x(e){return B(e)}function D(e,t){return F(e).href==F(t).href}function V(e){return e.endsWith("/")?e:e+"/"}class W{constructor(e){this.response=e}get succeeded(){return this.response.ok}get failed(){return!this.succeeded}get clientError(){return this.statusCode>=400&&this.statusCode<=499}get serverError(){return this.statusCode>=500&&this.statusCode<=599}get redirected(){return this.response.redirected}get location(){return F(this.response.url)}get isHTML(){return this.contentType&&this.contentType.match(/^(?:text\/([^\s;,]+\b)?html|application\/xhtml\+xml)\b/)}get statusCode(){return this.response.status}get contentType(){return this.header("Content-Type")}get responseText(){return this.response.clone().text()}get responseHTML(){return this.isHTML?this.response.clone().text():Promise.resolve(void 0)}header(e){return this.response.headers.get(e)}}class U extends Set{constructor(e){super(),this.maxSize=e}add(e){if(this.size>=this.maxSize){const e=this.values().next().value;this.delete(e)}super.add(e)}}const j=new U(20);function $(e,t={}){const r=new Headers(t.headers||{}),s=p();return j.add(s),r.append("X-Turbo-Request-Id",s),window.fetch(e,{...t,headers:r})}function z(e){switch(e.toLowerCase()){case"get":return G.get;case"post":return G.post;case"put":return G.put;case"patch":return G.patch;case"delete":return G.delete}}const G={get:"get",post:"post",put:"put",patch:"patch",delete:"delete"};const Q={urlEncoded:"application/x-www-form-urlencoded",multipart:"multipart/form-data",plain:"text/plain"};class X{abortController=new AbortController;#t=e=>{};constructor(e,t,r,s=new URLSearchParams,i=null,n=Q.urlEncoded){const[o,a]=Y(F(r),t,s,n);this.delegate=e,this.url=o,this.target=i,this.fetchOptions={credentials:"same-origin",redirect:"follow",method:t.toUpperCase(),headers:{...this.defaultHeaders},body:a,signal:this.abortSignal,referrer:this.delegate.referrer?.href},this.enctype=n}get method(){return this.fetchOptions.method}set method(e){const t=this.isSafe?this.url.searchParams:this.fetchOptions.body||new FormData,r=z(e)||G.get;this.url.search="";const[s,i]=Y(this.url,r,t,this.enctype);this.url=s,this.fetchOptions.body=i,this.fetchOptions.method=r.toUpperCase()}get headers(){return this.fetchOptions.headers}set headers(e){this.fetchOptions.headers=e}get body(){return this.isSafe?this.url.searchParams:this.fetchOptions.body}set body(e){this.fetchOptions.body=e}get location(){return this.url}get params(){return this.url.searchParams}get entries(){return this.body?Array.from(this.body.entries()):[]}cancel(){this.abortController.abort()}async perform(){const{fetchOptions:e}=this;this.delegate.prepareRequest(this);const t=await this.#r(e);try{this.delegate.requestStarted(this),t.detail.fetchRequest?this.response=t.detail.fetchRequest.response:this.response=$(this.url.href,e);const r=await this.response;return await this.receive(r)}catch(e){if("AbortError"!==e.name)throw this.#s(e)&&this.delegate.requestErrored(this,e),e}finally{this.delegate.requestFinished(this)}}async receive(e){const t=new W(e);return a("turbo:before-fetch-response",{cancelable:!0,detail:{fetchResponse:t},target:this.target}).defaultPrevented?this.delegate.requestPreventedHandlingResponse(this,t):t.succeeded?this.delegate.requestSucceededWithResponse(this,t):this.delegate.requestFailedWithResponse(this,t),t}get defaultHeaders(){return{Accept:"text/html, application/xhtml+xml"}}get isSafe(){return K(this.method)}get abortSignal(){return this.abortController.signal}acceptResponseType(e){this.headers.Accept=[e,this.headers.Accept].join(", ")}async#r(e){const t=new Promise(e=>this.#t=e),r=a("turbo:before-fetch-request",{cancelable:!0,detail:{fetchOptions:e,url:this.url,resume:this.#t},target:this.target});return this.url=r.detail.url,r.defaultPrevented&&await t,r}#s(e){return!a("turbo:fetch-request-error",{target:this.target,cancelable:!0,detail:{request:this,error:e}}).defaultPrevented}}function K(e){return z(e)==G.get}function Y(e,t,r,s){const i=Array.from(r).length>0?new URLSearchParams(J(r)):e.searchParams;return K(t)?[Z(e,i),null]:s==Q.urlEncoded?[e,i]:[e,r]}function J(e){const t=[];for(const[r,s]of e)s instanceof File||t.push([r,s]);return t}function Z(e,t){const r=new URLSearchParams(J(t));return e.search=r.toString(),e}class ee{started=!1;constructor(e,t){this.delegate=e,this.element=t,this.intersectionObserver=new IntersectionObserver(this.intersect)}start(){this.started||(this.started=!0,this.intersectionObserver.observe(this.element))}stop(){this.started&&(this.started=!1,this.intersectionObserver.unobserve(this.element))}intersect=e=>{const t=e.slice(-1)[0];t?.isIntersecting&&this.delegate.elementAppearedInViewport(this.element)}}class te{static contentType="text/vnd.turbo-stream.html";static wrap(e){return"string"==typeof e?new this(function(e){const t=document.createElement("template");return t.innerHTML=e,t.content}(e)):e}constructor(e){this.fragment=function(e){for(const t of e.querySelectorAll("turbo-stream")){const e=document.importNode(t,!0);for(const t of e.templateElement.content.querySelectorAll("script"))t.replaceWith(o(t));t.replaceWith(e)}return e}(e)}}const re=new class{#i=null;#n=null;get(e){if(this.#n&&this.#n.url===e&&this.#n.expire>Date.now())return this.#n.request}setLater(e,t,r){this.clear(),this.#i=setTimeout(()=>{t.perform(),this.set(e,t,r),this.#i=null},100)}set(e,t,r){this.#n={url:e,request:t,expire:new Date((new Date).getTime()+r)}}clear(){this.#i&&clearTimeout(this.#i),this.#n=null}},se={initialized:"initialized",requesting:"requesting",waiting:"waiting",receiving:"receiving",stopping:"stopping",stopped:"stopped"};class ie{state=se.initialized;static confirmMethod(e){return Promise.resolve(confirm(e))}constructor(e,t,r,s=!1){const i=function(e,t){const r=t?.getAttribute("formmethod")||e.getAttribute("method")||"";return z(r.toLowerCase())||G.get}(t,r),n=function(e,t){const r=F(e);K(t)&&(r.search="");return r}(function(e,t){const r="string"==typeof e.action?e.action:null;return t?.hasAttribute("formaction")?t.getAttribute("formaction")||"":e.getAttribute("action")||r||""}(t,r),i),o=function(e,t){const r=new FormData(e),s=t?.getAttribute("name"),i=t?.getAttribute("value");s&&r.append(s,i||"");return r}(t,r),a=function(e,t){return function(e){switch(e.toLowerCase()){case Q.multipart:return Q.multipart;case Q.plain:return Q.plain;default:return Q.urlEncoded}}(t?.getAttribute("formenctype")||e.enctype)}(t,r);this.delegate=e,this.formElement=t,this.submitter=r,this.fetchRequest=new X(this,i,n,o,t,a),this.mustRedirect=s}get method(){return this.fetchRequest.method}set method(e){this.fetchRequest.method=e}get action(){return this.fetchRequest.url.toString()}set action(e){this.fetchRequest.url=F(e)}get body(){return this.fetchRequest.body}get enctype(){return this.fetchRequest.enctype}get isSafe(){return this.fetchRequest.isSafe}get location(){return this.fetchRequest.url}async start(){const{initialized:e,requesting:t}=se,r=f("data-turbo-confirm",this.submitter,this.formElement);if("string"==typeof r){const e="function"==typeof _.forms.confirm?_.forms.confirm:ie.confirmMethod;if(!await e(r,this.formElement,this.submitter))return}if(this.state==e)return this.state=t,this.fetchRequest.perform()}stop(){const{stopping:e,stopped:t}=se;if(this.state!=e&&this.state!=t)return this.state=e,this.fetchRequest.cancel(),!0}prepareRequest(e){if(!e.isSafe){const t=function(e){if(null!=e){const t=(document.cookie?document.cookie.split("; "):[]).find(t=>t.startsWith(e));if(t){const e=t.split("=").slice(1).join("=");return e?decodeURIComponent(e):void 0}}}(E("csrf-param"))||E("csrf-token");t&&(e.headers["X-CSRF-Token"]=t)}this.requestAcceptsTurboStreamResponse(e)&&e.acceptResponseType(te.contentType)}requestStarted(e){this.state=se.waiting,this.submitter&&_.forms.submitter.beforeSubmit(this.submitter),this.setSubmitsWith(),g(this.formElement),a("turbo:submit-start",{target:this.formElement,detail:{formSubmission:this}}),this.delegate.formSubmissionStarted(this)}requestPreventedHandlingResponse(e,t){re.clear(),this.result={success:t.succeeded,fetchResponse:t}}requestSucceededWithResponse(e,t){if(t.clientError||t.serverError)this.delegate.formSubmissionFailedWithResponse(this,t);else if(re.clear(),this.requestMustRedirect(e)&&function(e){return 200==e.statusCode&&!e.redirected}(t)){const e=new Error("Form responses must redirect to another location");this.delegate.formSubmissionErrored(this,e)}else this.state=se.receiving,this.result={success:!0,fetchResponse:t},this.delegate.formSubmissionSucceededWithResponse(this,t)}requestFailedWithResponse(e,t){this.result={success:!1,fetchResponse:t},this.delegate.formSubmissionFailedWithResponse(this,t)}requestErrored(e,t){this.result={success:!1,error:t},this.delegate.formSubmissionErrored(this,t)}requestFinished(e){this.state=se.stopped,this.submitter&&_.forms.submitter.afterSubmit(this.submitter),this.resetSubmitterText(),b(this.formElement),a("turbo:submit-end",{target:this.formElement,detail:{formSubmission:this,...this.result}}),this.delegate.formSubmissionFinished(this)}setSubmitsWith(){if(this.submitter&&this.submitsWith)if(this.submitter.matches("button"))this.originalSubmitText=this.submitter.innerHTML,this.submitter.innerHTML=this.submitsWith;else if(this.submitter.matches("input")){const e=this.submitter;this.originalSubmitText=e.value,e.value=this.submitsWith}}resetSubmitterText(){if(this.submitter&&this.originalSubmitText)if(this.submitter.matches("button"))this.submitter.innerHTML=this.originalSubmitText;else if(this.submitter.matches("input")){this.submitter.value=this.originalSubmitText}}requestMustRedirect(e){return!e.isSafe&&this.mustRedirect}requestAcceptsTurboStreamResponse(e){return!e.isSafe||function(e,...t){return t.some(t=>t&&t.hasAttribute(e))}("data-turbo-stream",this.submitter,this.formElement)}get submitsWith(){return this.submitter?.getAttribute("data-turbo-submits-with")}}class ne{constructor(e){this.element=e}get activeElement(){return this.element.ownerDocument.activeElement}get children(){return[...this.element.children]}hasAnchor(e){return null!=this.getElementForAnchor(e)}getElementForAnchor(e){return e?this.element.querySelector(`[id='${e}'], a[name='${e}']`):null}get isConnected(){return this.element.isConnected}get firstAutofocusableElement(){return A(this.element)}get permanentElements(){return ae(this.element)}getPermanentElementById(e){return oe(this.element,e)}getPermanentElementMapForSnapshot(e){const t={};for(const r of this.permanentElements){const{id:s}=r,i=e.getPermanentElementById(s);i&&(t[s]=[r,i])}return t}}function oe(e,t){return e.querySelector(`#${t}[data-turbo-permanent]`)}function ae(e){return e.querySelectorAll("[id][data-turbo-permanent]")}class ce{started=!1;constructor(e,t){this.delegate=e,this.eventTarget=t}start(){this.started||(this.eventTarget.addEventListener("submit",this.submitCaptured,!0),this.started=!0)}stop(){this.started&&(this.eventTarget.removeEventListener("submit",this.submitCaptured,!0),this.started=!1)}submitCaptured=()=>{this.eventTarget.removeEventListener("submit",this.submitBubbled,!1),this.eventTarget.addEventListener("submit",this.submitBubbled,!1)};submitBubbled=e=>{if(!e.defaultPrevented){const t=e.target instanceof HTMLFormElement?e.target:void 0,r=e.submitter||void 0;t&&function(e,t){const r=t?.getAttribute("formmethod")||e.getAttribute("method");return"dialog"!=r}(t,r)&&function(e,t){const r=t?.getAttribute("formtarget")||e.getAttribute("target");return C(r)}(t,r)&&this.delegate.willSubmitForm(t,r)&&(e.preventDefault(),e.stopImmediatePropagation(),this.delegate.formSubmitted(t,r))}}}class le{#o=e=>{};#a=e=>{};constructor(e,t){this.delegate=e,this.element=t}scrollToAnchor(e){const t=this.snapshot.getElementForAnchor(e);t?(this.focusElement(t),this.scrollToElement(t)):this.scrollToPosition({x:0,y:0})}scrollToAnchorFromLocation(e){this.scrollToAnchor(q(e))}scrollToElement(e){e.scrollIntoView()}focusElement(e){e instanceof HTMLElement&&(e.hasAttribute("tabindex")?e.focus():(e.setAttribute("tabindex","-1"),e.focus(),e.removeAttribute("tabindex")))}scrollToPosition({x:e,y:t}){this.scrollRoot.scrollTo(e,t)}scrollToTop(){this.scrollToPosition({x:0,y:0})}get scrollRoot(){return window}async render(e){const{isPreview:t,shouldRender:r,willRender:s,newSnapshot:i}=e,n=s;if(r)try{this.renderPromise=new Promise(e=>this.#o=e),this.renderer=e,await this.prepareToRenderSnapshot(e);const r=new Promise(e=>this.#a=e),s={resume:this.#a,render:this.renderer.renderElement,renderMethod:this.renderer.renderMethod};this.delegate.allowsImmediateRender(i,s)||await r,await this.renderSnapshot(e),this.delegate.viewRenderedSnapshot(i,t,this.renderer.renderMethod),this.delegate.preloadOnLoadLinksForView(this.element),this.finishRenderingSnapshot(e)}finally{delete this.renderer,this.#o(void 0),delete this.renderPromise}else n&&this.invalidate(e.reloadReason)}invalidate(e){this.delegate.viewInvalidated(e)}async prepareToRenderSnapshot(e){this.markAsPreview(e.isPreview),await e.prepareToRender()}markAsPreview(e){e?this.element.setAttribute("data-turbo-preview",""):this.element.removeAttribute("data-turbo-preview")}markVisitDirection(e){this.element.setAttribute("data-turbo-visit-direction",e)}unmarkVisitDirection(){this.element.removeAttribute("data-turbo-visit-direction")}async renderSnapshot(e){await e.render()}finishRenderingSnapshot(e){e.finishRendering()}}class he extends le{missing(){this.element.innerHTML='Content missing'}get snapshot(){return new ne(this.element)}}class de{constructor(e,t){this.delegate=e,this.element=t}start(){this.element.addEventListener("click",this.clickBubbled),document.addEventListener("turbo:click",this.linkClicked),document.addEventListener("turbo:before-visit",this.willVisit)}stop(){this.element.removeEventListener("click",this.clickBubbled),document.removeEventListener("turbo:click",this.linkClicked),document.removeEventListener("turbo:before-visit",this.willVisit)}clickBubbled=e=>{this.clickEventIsSignificant(e)?this.clickEvent=e:delete this.clickEvent};linkClicked=e=>{this.clickEvent&&this.clickEventIsSignificant(e)&&this.delegate.shouldInterceptLinkClick(e.target,e.detail.url,e.detail.originalEvent)&&(this.clickEvent.preventDefault(),e.preventDefault(),this.delegate.linkClickIntercepted(e.target,e.detail.url,e.detail.originalEvent)),delete this.clickEvent};willVisit=e=>{delete this.clickEvent};clickEventIsSignificant(e){const t=e.composed?e.target?.parentElement:e.target,r=P(t)||t;return r instanceof Element&&r.closest("turbo-frame, html")==this.element}}class ue{started=!1;constructor(e,t){this.delegate=e,this.eventTarget=t}start(){this.started||(this.eventTarget.addEventListener("click",this.clickCaptured,!0),this.started=!0)}stop(){this.started&&(this.eventTarget.removeEventListener("click",this.clickCaptured,!0),this.started=!1)}clickCaptured=()=>{this.eventTarget.removeEventListener("click",this.clickBubbled,!1),this.eventTarget.addEventListener("click",this.clickBubbled,!1)};clickBubbled=e=>{if(e instanceof MouseEvent&&this.clickEventIsSignificant(e)){const t=P(e.composedPath&&e.composedPath()[0]||e.target);if(t&&C(t.target)){const r=k(t);this.delegate.willFollowLinkToLocation(t,r,e)&&(e.preventDefault(),this.delegate.followedLinkToLocation(t,r))}}};clickEventIsSignificant(e){return!(e.target&&e.target.isContentEditable||e.defaultPrevented||e.which>1||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)}}class me{constructor(e,t){this.delegate=e,this.linkInterceptor=new ue(this,t)}start(){this.linkInterceptor.start()}stop(){this.linkInterceptor.stop()}canPrefetchRequestToLocation(e,t){return!1}prefetchAndCacheRequestToLocation(e,t){}willFollowLinkToLocation(e,t,r){return this.delegate.willSubmitFormLinkToLocation(e,t,r)&&(e.hasAttribute("data-turbo-method")||e.hasAttribute("data-turbo-stream"))}followedLinkToLocation(e,t){const r=document.createElement("form");for(const[e,s]of t.searchParams)r.append(Object.assign(document.createElement("input"),{type:"hidden",name:e,value:s}));const s=Object.assign(t,{search:""});r.setAttribute("data-turbo","true"),r.setAttribute("action",s.href),r.setAttribute("hidden","");const i=e.getAttribute("data-turbo-method");i&&r.setAttribute("method",i);const n=e.getAttribute("data-turbo-frame");n&&r.setAttribute("data-turbo-frame",n);const o=y(e);o&&r.setAttribute("data-turbo-action",o);const a=e.getAttribute("data-turbo-confirm");a&&r.setAttribute("data-turbo-confirm",a);e.hasAttribute("data-turbo-stream")&&r.setAttribute("data-turbo-stream",""),this.delegate.submittedFormLinkToLocation(e,t,r),document.body.appendChild(r),r.addEventListener("turbo:submit-end",()=>r.remove(),{once:!0}),requestAnimationFrame(()=>r.requestSubmit())}}class pe{static async preservingPermanentElements(e,t,r){const s=new this(e,t);s.enter(),await r(),s.leave()}constructor(e,t){this.delegate=e,this.permanentElementMap=t}enter(){for(const e in this.permanentElementMap){const[t,r]=this.permanentElementMap[e];this.delegate.enteringBardo(t,r),this.replaceNewPermanentElementWithPlaceholder(r)}}leave(){for(const e in this.permanentElementMap){const[t]=this.permanentElementMap[e];this.replaceCurrentPermanentElementWithClone(t),this.replacePlaceholderWithPermanentElement(t),this.delegate.leavingBardo(t)}}replaceNewPermanentElementWithPlaceholder(e){const t=function(e){const t=document.createElement("meta");return t.setAttribute("name","turbo-permanent-placeholder"),t.setAttribute("content",e.id),t}(e);e.replaceWith(t)}replaceCurrentPermanentElementWithClone(e){const t=e.cloneNode(!0);e.replaceWith(t)}replacePlaceholderWithPermanentElement(e){const t=this.getPlaceholderById(e.id);t?.replaceWith(e)}getPlaceholderById(e){return this.placeholders.find(t=>t.content==e)}get placeholders(){return[...document.querySelectorAll("meta[name=turbo-permanent-placeholder][content]")]}}class fe{#c=null;static renderElement(e,t){}constructor(e,t,r,s=!0){this.currentSnapshot=e,this.newSnapshot=t,this.isPreview=r,this.willRender=s,this.renderElement=this.constructor.renderElement,this.promise=new Promise((e,t)=>this.resolvingFunctions={resolve:e,reject:t})}get shouldRender(){return!0}get shouldAutofocus(){return!0}get reloadReason(){}prepareToRender(){}render(){}finishRendering(){this.resolvingFunctions&&(this.resolvingFunctions.resolve(),delete this.resolvingFunctions)}async preservingPermanentElements(e){await pe.preservingPermanentElements(this,this.permanentElementMap,e)}focusFirstAutofocusableElement(){if(this.shouldAutofocus){const e=this.connectedSnapshot.firstAutofocusableElement;e&&e.focus()}}enteringBardo(e){this.#c||e.contains(this.currentSnapshot.activeElement)&&(this.#c=this.currentSnapshot.activeElement)}leavingBardo(e){e.contains(this.#c)&&this.#c instanceof HTMLElement&&(this.#c.focus(),this.#c=null)}get connectedSnapshot(){return this.newSnapshot.isConnected?this.newSnapshot:this.currentSnapshot}get currentElement(){return this.currentSnapshot.element}get newElement(){return this.newSnapshot.element}get permanentElementMap(){return this.currentSnapshot.getPermanentElementMapForSnapshot(this.newSnapshot)}get renderMethod(){return"replace"}}class ge extends fe{static renderElement(e,t){const r=document.createRange();r.selectNodeContents(e),r.deleteContents();const s=t,i=s.ownerDocument?.createRange();i&&(i.selectNodeContents(s),e.appendChild(i.extractContents()))}constructor(e,t,r,s,i,n=!0){super(t,r,s,i,n),this.delegate=e}get shouldRender(){return!0}async render(){await l(),this.preservingPermanentElements(()=>{this.loadFrameElement()}),this.scrollFrameIntoView(),await l(),this.focusFirstAutofocusableElement(),await l(),this.activateScriptElements()}loadFrameElement(){this.delegate.willRenderFrame(this.currentElement,this.newElement),this.renderElement(this.currentElement,this.newElement)}scrollFrameIntoView(){if(this.currentElement.autoscroll||this.newElement.autoscroll){const r=this.currentElement.firstElementChild,s=(e=this.currentElement.getAttribute("data-autoscroll-block"),t="end","end"==e||"start"==e||"center"==e||"nearest"==e?e:t),i=function(e,t){return"auto"==e||"smooth"==e?e:t}(this.currentElement.getAttribute("data-autoscroll-behavior"),"auto");if(r)return r.scrollIntoView({block:s,behavior:i}),!0}var e,t;return!1}activateScriptElements(){for(const e of this.newScriptElements){const t=o(e);e.replaceWith(t)}}get newScriptElements(){return this.currentElement.querySelectorAll("script")}}var be=function(){const e=()=>{},t={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:e=>"true"===e.getAttribute("im-preserve"),shouldReAppend:e=>"true"===e.getAttribute("im-re-append"),shouldRemove:e,afterHeadMorphed:e},restoreFocus:!0};const r=function(){function e(e,t,r,i){if(!1===i.callbacks.beforeNodeAdded(t))return null;if(i.idMap.has(t)){const n=document.createElement(t.tagName);return e.insertBefore(n,r),s(n,t,i),i.callbacks.afterNodeAdded(n),n}{const s=document.importNode(t,!0);return e.insertBefore(s,r),i.callbacks.afterNodeAdded(s),s}}const t=function(){function e(e,t,r){let s=e.idMap.get(t),i=e.idMap.get(r);if(!i||!s)return!1;for(const e of s)if(i.has(e))return!0;return!1}function t(e,t){const r=e,s=t;return r.nodeType===s.nodeType&&r.tagName===s.tagName&&(!r.getAttribute?.("id")||r.getAttribute?.("id")===s.getAttribute?.("id"))}return function(r,s,i,n){let o=null,a=s.nextSibling,c=0,l=i;for(;l&&l!=n;){if(t(l,s)){if(e(r,l,s))return l;null===o&&(r.idMap.has(l)||(o=l))}if(null===o&&a&&t(l,a)&&(c++,a=a.nextSibling,c>=2&&(o=void 0)),r.activeElementAndParents.includes(l))break;l=l.nextSibling}return o||null}}();function r(e,t){if(e.idMap.has(t))o(e.pantry,t,null);else{if(!1===e.callbacks.beforeNodeRemoved(t))return;t.parentNode?.removeChild(t),e.callbacks.afterNodeRemoved(t)}}function i(e,t,s){let i=t;for(;i&&i!==s;){let t=i;i=i.nextSibling,r(e,t)}return i}function n(e,t,r,s){const i=s.target.getAttribute?.("id")===t&&s.target||s.target.querySelector(`[id="${t}"]`)||s.pantry.querySelector(`[id="${t}"]`);return function(e,t){const r=e.getAttribute("id");for(;e=e.parentNode;){let s=t.idMap.get(e);s&&(s.delete(r),s.size||t.idMap.delete(e))}}(i,s),o(e,i,r),i}function o(e,t,r){if(e.moveBefore)try{e.moveBefore(t,r)}catch(s){e.insertBefore(t,r)}else e.insertBefore(t,r)}return function(o,a,c,l=null,h=null){a instanceof HTMLTemplateElement&&c instanceof HTMLTemplateElement&&(a=a.content,c=c.content),l||=a.firstChild;for(const r of c.childNodes){if(l&&l!=h){const e=t(o,r,l,h);if(e){e!==l&&i(o,l,e),s(e,r,o),l=e.nextSibling;continue}}if(r instanceof Element){const e=r.getAttribute("id");if(o.persistentIds.has(e)){const t=n(a,e,l,o);s(t,r,o),l=t.nextSibling;continue}}const c=e(a,r,l,o);c&&(l=c.nextSibling)}for(;l&&l!=h;){const e=l;l=l.nextSibling,r(o,e)}}}(),s=function(){function e(e,r,s,i){const n=r[s];if(n!==e[s]){const o=t(s,e,"update",i);o||(e[s]=r[s]),n?o||e.setAttribute(s,""):t(s,e,"remove",i)||e.removeAttribute(s)}}function t(e,t,r,s){return!("value"!==e||!s.ignoreActiveValue||t!==document.activeElement)||!1===s.callbacks.beforeAttributeUpdated(e,t,r)}function s(e,t){return!!t.ignoreActiveValue&&e===document.activeElement&&e!==document.body}return function(n,o,a){return a.ignoreActive&&n===document.activeElement?null:(!1===a.callbacks.beforeNodeMorphed(n,o)||(n instanceof HTMLHeadElement&&a.head.ignore||(n instanceof HTMLHeadElement&&"morph"!==a.head.style?i(n,o,a):(!function(r,i,n){let o=i.nodeType;if(1===o){const o=r,a=i,c=o.attributes,l=a.attributes;for(const e of l)t(e.name,o,"update",n)||o.getAttribute(e.name)!==e.value&&o.setAttribute(e.name,e.value);for(let e=c.length-1;0<=e;e--){const r=c[e];if(r&&!a.hasAttribute(r.name)){if(t(r.name,o,"remove",n))continue;o.removeAttribute(r.name)}}s(o,n)||function(r,s,i){if(r instanceof HTMLInputElement&&s instanceof HTMLInputElement&&"file"!==s.type){let n=s.value,o=r.value;e(r,s,"checked",i),e(r,s,"disabled",i),s.hasAttribute("value")?o!==n&&(t("value",r,"update",i)||(r.setAttribute("value",n),r.value=n)):t("value",r,"remove",i)||(r.value="",r.removeAttribute("value"))}else if(r instanceof HTMLOptionElement&&s instanceof HTMLOptionElement)e(r,s,"selected",i);else if(r instanceof HTMLTextAreaElement&&s instanceof HTMLTextAreaElement){let e=s.value,n=r.value;if(t("value",r,"update",i))return;e!==n&&(r.value=e),r.firstChild&&r.firstChild.nodeValue!==e&&(r.firstChild.nodeValue=e)}}(o,a,n)}8!==o&&3!==o||r.nodeValue!==i.nodeValue&&(r.nodeValue=i.nodeValue)}(n,o,a),s(n,a)||r(a,n,o))),a.callbacks.afterNodeMorphed(n,o)),n)}}();function i(e,t,r){let s=[],i=[],n=[],o=[],a=new Map;for(const e of t.children)a.set(e.outerHTML,e);for(const t of e.children){let e=a.has(t.outerHTML),s=r.head.shouldReAppend(t),c=r.head.shouldPreserve(t);e||c?s?i.push(t):(a.delete(t.outerHTML),n.push(t)):"append"===r.head.style?s&&(i.push(t),o.push(t)):!1!==r.head.shouldRemove(t)&&i.push(t)}o.push(...a.values());let c=[];for(const t of o){let i=document.createRange().createContextualFragment(t.outerHTML).firstChild;if(!1!==r.callbacks.beforeNodeAdded(i)){if("href"in i&&i.href||"src"in i&&i.src){let e,t=new Promise(function(t){e=t});i.addEventListener("load",function(){e()}),c.push(t)}e.appendChild(i),r.callbacks.afterNodeAdded(i),s.push(i)}}for(const t of i)!1!==r.callbacks.beforeNodeRemoved(t)&&(e.removeChild(t),r.callbacks.afterNodeRemoved(t));return r.head.afterHeadMorphed(e,{added:s,kept:n,removed:i}),c}const n=function(){function e(){const e=document.createElement("div");return e.hidden=!0,document.body.insertAdjacentElement("afterend",e),e}function r(e){let t=[],r=document.activeElement;if("BODY"!==r?.tagName&&e.contains(r))for(;r&&(t.push(r),r!==e);)r=r.parentElement;return t}function s(e){let t=Array.from(e.querySelectorAll("[id]"));return e.getAttribute?.("id")&&t.push(e),t}function i(e,t,r,s){for(const i of s){const s=i.getAttribute("id");if(t.has(s)){let t=i;for(;t;){let i=e.get(t);if(null==i&&(i=new Set,e.set(t,i)),i.add(s),t===r)break;t=t.parentElement}}}}return function(n,o,a){const{persistentIds:c,idMap:l}=function(e,t){const r=s(e),n=s(t),o=function(e,t){let r=new Set,s=new Map;for(const{id:t,tagName:i}of e)s.has(t)?r.add(t):s.set(t,i);let i=new Set;for(const{id:e,tagName:n}of t)i.has(e)?r.add(e):s.get(e)===n&&i.add(e);for(const e of r)i.delete(e);return i}(r,n);let a=new Map;i(a,o,e,r);const c=t.__idiomorphRoot||t;return i(a,o,c,n),{persistentIds:o,idMap:a}}(n,o),h=function(e){let r=Object.assign({},t);return Object.assign(r,e),r.callbacks=Object.assign({},t.callbacks,e.callbacks),r.head=Object.assign({},t.head,e.head),r}(a),d=h.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(d))throw`Do not understand how to morph style ${d}`;return{target:n,newContent:o,config:h,morphStyle:d,ignoreActive:h.ignoreActive,ignoreActiveValue:h.ignoreActiveValue,restoreFocus:h.restoreFocus,idMap:l,persistentIds:c,pantry:e(),activeElementAndParents:r(n),callbacks:h.callbacks,head:h.head}}}(),{normalizeElement:o,normalizeParent:a}=function(){const e=new WeakSet;class t{constructor(e){this.originalNode=e,this.realParentNode=e.parentNode,this.previousSibling=e.previousSibling,this.nextSibling=e.nextSibling}get childNodes(){const e=[];let t=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;t&&t!=this.nextSibling;)e.push(t),t=t.nextSibling;return e}querySelectorAll(e){return this.childNodes.reduce((t,r)=>{if(r instanceof Element){r.matches(e)&&t.push(r);const s=r.querySelectorAll(e);for(let e=0;e]*>|>)([\s\S]*?)<\/svg>/gim,"");if(s.match(/<\/html>/)||s.match(/<\/head>/)||s.match(/<\/body>/)){let i=r.parseFromString(t,"text/html");if(s.match(/<\/html>/))return e.add(i),i;{let t=i.firstChild;return t&&e.add(t),t}}{let s=r.parseFromString("","text/html").body.querySelector("template").content;return e.add(s),s}}(s));if(e.has(s))return s;if(s instanceof Node){if(s.parentNode)return new t(s);{const e=document.createElement("div");return e.append(s),e}}{const e=document.createElement("div");for(const t of[...s])e.append(t);return e}}}}();return{morph:function(e,t,s={}){e=o(e);const c=a(t),l=n(e,c,s),h=function(e,t){if(!e.config.restoreFocus)return t();let r=document.activeElement;if(!(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement))return t();const{id:s,selectionStart:i,selectionEnd:n}=r,o=t();s&&s!==document.activeElement?.getAttribute("id")&&(r=e.target.querySelector(`[id="${s}"]`),r?.focus());r&&!r.selectionEnd&&n&&r.setSelectionRange(i,n);return o}(l,()=>function(e,t,r,s){if(e.head.block){const n=t.querySelector("head"),o=r.querySelector("head");if(n&&o){const t=i(n,o,e);return Promise.all(t).then(()=>{const t=Object.assign(e,{head:{block:!1,ignore:!0}});return s(t)})}}return s(e)}(l,e,c,t=>"innerHTML"===t.morphStyle?(r(t,e,c),Array.from(e.childNodes)):function(e,t,s){const i=a(t);return r(e,i,s,t,t.nextSibling),Array.from(i.childNodes)}(t,e,c)));return l.pantry.remove(),h},defaults:t}}();function ve(e,t,{callbacks:r,...s}={}){be.morph(e,t,{...s,callbacks:new Ee(r)})}function we(e,t,r={}){ve(e,t.childNodes,{...r,morphStyle:"innerHTML"})}function ye(e,t){return e instanceof i&&e.shouldReloadWithMorph&&(!t||function(e,t){return t instanceof Element&&"TURBO-FRAME"===t.nodeName&&e.id===t.id&&(!t.getAttribute("src")||D(e.src,t.getAttribute("src")))}(e,t))&&!e.closest("[data-turbo-permanent]")}function Se(e){return e.parentElement.closest("turbo-frame[src][refresh=morph]")}class Ee{#l;constructor({beforeNodeMorphed:e}={}){this.#l=e||(()=>!0)}beforeNodeAdded=e=>!(e.id&&e.hasAttribute("data-turbo-permanent")&&document.getElementById(e.id));beforeNodeMorphed=(e,t)=>{if(e instanceof Element){if(!e.hasAttribute("data-turbo-permanent")&&this.#l(e,t)){return!a("turbo:before-morph-element",{cancelable:!0,target:e,detail:{currentElement:e,newElement:t}}).defaultPrevented}return!1}};beforeAttributeUpdated=(e,t,r)=>!a("turbo:before-morph-attribute",{cancelable:!0,target:t,detail:{attributeName:e,mutationType:r}}).defaultPrevented;beforeNodeRemoved=e=>this.beforeNodeMorphed(e);afterNodeMorphed=(e,t)=>{e instanceof Element&&a("turbo:morph-element",{target:e,detail:{currentElement:e,newElement:t}})}}class Le extends ge{static renderElement(e,t){a("turbo:before-frame-morph",{target:e,detail:{currentElement:e,newElement:t}}),we(e,t,{callbacks:{beforeNodeMorphed:(t,r)=>!ye(t,r)||Se(t)!==e||(t.reload(),!1)}})}async preservingPermanentElements(e){return await e()}}class Te{static animationDuration=300;static get defaultCSS(){return m` +!function(e){function t(e,t,r){throw new e("Failed to execute 'requestSubmit' on 'HTMLFormElement': "+t+".",r)}"function"!=typeof e.requestSubmit&&(e.requestSubmit=function(e){e?(!function(e,r){e instanceof HTMLElement||t(TypeError,"parameter 1 is not of type 'HTMLElement'"),"submit"==e.type||t(TypeError,"The specified element is not a submit button"),e.form==r||t(DOMException,"The specified element is not owned by this form element","NotFoundError")}(e,this),e.click()):((e=document.createElement("input")).type="submit",e.hidden=!0,this.appendChild(e),e.click(),this.removeChild(e))})}(HTMLFormElement.prototype);const e=new WeakMap;function t(t){const r=function(e){const t=e instanceof Element?e:e instanceof Node?e.parentElement:null,r=t?t.closest("input, button"):null;return"submit"==r?.type?r:null}(t.target);r&&r.form&&e.set(r.form,r)}!function(){if("submitter"in Event.prototype)return;let r=window.Event.prototype;if("SubmitEvent"in window){const e=window.SubmitEvent.prototype;if(!/Apple Computer/.test(navigator.vendor)||"submitter"in e)return;r=e}addEventListener("click",t,!0),Object.defineProperty(r,"submitter",{get(){if("submit"==this.type&&this.target instanceof HTMLFormElement)return e.get(this.target)}})}();const r="eager",s="lazy";class n extends HTMLElement{static delegateConstructor=void 0;loaded=Promise.resolve();static get observedAttributes(){return["disabled","loading","src"]}constructor(){super(),this.delegate=new n.delegateConstructor(this)}connectedCallback(){this.delegate.connect()}disconnectedCallback(){this.delegate.disconnect()}reload(){return this.delegate.sourceURLReloaded()}attributeChangedCallback(e){"loading"==e?this.delegate.loadingStyleChanged():"src"==e?this.delegate.sourceURLChanged():"disabled"==e&&this.delegate.disabledChanged()}get src(){return this.getAttribute("src")}set src(e){e?this.setAttribute("src",e):this.removeAttribute("src")}get refresh(){return this.getAttribute("refresh")}set refresh(e){e?this.setAttribute("refresh",e):this.removeAttribute("refresh")}get shouldReloadWithMorph(){return this.src&&"morph"===this.refresh}get loading(){return function(e){if("lazy"===e.toLowerCase())return s;return r}(this.getAttribute("loading")||"")}set loading(e){e?this.setAttribute("loading",e):this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get autoscroll(){return this.hasAttribute("autoscroll")}set autoscroll(e){e?this.setAttribute("autoscroll",""):this.removeAttribute("autoscroll")}get complete(){return!this.delegate.isLoading}get isActive(){return this.ownerDocument===document&&!this.isPreview}get isPreview(){return this.ownerDocument?.documentElement?.hasAttribute("data-turbo-preview")}}const i={enabled:!0,progressBarDelay:500,unvisitableExtensions:new Set([".7z",".aac",".apk",".avi",".bmp",".bz2",".css",".csv",".deb",".dmg",".doc",".docx",".exe",".gif",".gz",".heic",".heif",".ico",".iso",".jpeg",".jpg",".js",".json",".m4a",".mkv",".mov",".mp3",".mp4",".mpeg",".mpg",".msi",".ogg",".ogv",".pdf",".pkg",".png",".ppt",".pptx",".rar",".rtf",".svg",".tar",".tif",".tiff",".txt",".wav",".webm",".webp",".wma",".wmv",".xls",".xlsx",".xml",".zip"])};function o(e){if("false"==e.getAttribute("data-turbo-eval"))return e;{const t=document.createElement("script"),r=L();return r&&(t.nonce=r),t.textContent=e.textContent,t.async=!1,function(e,t){for(const{name:r,value:s}of t.attributes)e.setAttribute(r,s)}(t,e),t}}function a(e,{target:t,cancelable:r,detail:s}={}){const n=new CustomEvent(e,{cancelable:r,bubbles:!0,composed:!0,detail:s});return t&&t.isConnected?t.dispatchEvent(n):document.documentElement.dispatchEvent(n),n}function c(e){e.preventDefault(),e.stopImmediatePropagation()}function l(){return"hidden"===document.visibilityState?d():h()}function h(){return new Promise(e=>requestAnimationFrame(()=>e()))}function d(){return new Promise(e=>setTimeout(()=>e(),0))}function u(e=""){return(new DOMParser).parseFromString(e,"text/html")}function m(e,...t){const r=function(e,t){return e.reduce((e,r,s)=>e+r+(null==t[s]?"":t[s]),"")}(e,t).replace(/^\n/,"").split("\n"),s=r[0].match(/^\s+/),n=s?s[0].length:0;return r.map(e=>e.slice(n)).join("\n")}function p(){return Array.from({length:36}).map((e,t)=>8==t||13==t||18==t||23==t?"-":14==t?"4":19==t?(Math.floor(4*Math.random())+8).toString(16):Math.floor(15*Math.random()).toString(16)).join("")}function f(e,...t){for(const r of t.map(t=>t?.getAttribute(e)))if("string"==typeof r)return r;return null}function g(...e){for(const t of e)"turbo-frame"==t.localName&&t.setAttribute("busy",""),t.setAttribute("aria-busy","true")}function b(...e){for(const t of e)"turbo-frame"==t.localName&&t.removeAttribute("busy"),t.removeAttribute("aria-busy")}function v(e,t=2e3){return new Promise(r=>{const s=()=>{e.removeEventListener("error",s),e.removeEventListener("load",s),r()};e.addEventListener("load",s,{once:!0}),e.addEventListener("error",s,{once:!0}),setTimeout(r,t)})}function w(e){switch(e){case"replace":return history.replaceState;case"advance":case"restore":return history.pushState}}function y(...e){const t=f("data-turbo-action",...e);return function(e){return"advance"==e||"replace"==e||"restore"==e}(t)?t:null}function S(e){return document.querySelector(`meta[name="${e}"]`)}function E(e){const t=S(e);return t&&t.content}function L(){const e=S("csp-nonce");if(e){const{nonce:t,content:r}=e;return""==t?r:t}}function T(e,t){if(e instanceof Element)return e.closest(t)||T(e.assignedSlot||e.getRootNode()?.host,t)}function R(e){return!!e&&null==e.closest("[inert], :disabled, [hidden], details:not([open]), dialog:not([open])")&&"function"==typeof e.focus}function A(e){return Array.from(e.querySelectorAll("[autofocus]")).find(R)}function C(e){if("_blank"===e)return!1;if(e){for(const t of document.getElementsByName(e))if(t instanceof HTMLIFrameElement)return!1;return!0}return!0}function P(e){const t=T(e,"a[href], a[xlink\\:href]");return t?t.hasAttribute("download")||t.hasAttribute("target")&&"_self"!==t.target?null:t:null}function k(e){return F(e.getAttribute("href")||"")}const M={"aria-disabled":{beforeSubmit:e=>{e.setAttribute("aria-disabled","true"),e.addEventListener("click",c)},afterSubmit:e=>{e.removeAttribute("aria-disabled"),e.removeEventListener("click",c)}},disabled:{beforeSubmit:e=>e.disabled=!0,afterSubmit:e=>e.disabled=!1}};const I=new class{#e=null;constructor(e){Object.assign(this,e)}get submitter(){return this.#e}set submitter(e){this.#e=M[e]||e}}({mode:"on",submitter:"disabled"}),_={drive:i,forms:I};function F(e){return new URL(e.toString(),document.baseURI)}function q(e){let t;return e.hash?e.hash.slice(1):(t=e.href.match(/#(.*)$/))?t[1]:void 0}function O(e,t){return F(t?.getAttribute("formaction")||e.getAttribute("action")||e.action)}function H(e){return(function(e){return function(e){return e.pathname.split("/").slice(1)}(e).slice(-1)[0]}(e).match(/\.[^.]*$/)||[])[0]||""}function N(e,t){return function(e,t){const r=V(t.origin+t.pathname);return V(e.href)===r||e.href.startsWith(r)}(e,t)&&!_.drive.unvisitableExtensions.has(H(e))}function B(e){const t=q(e);return null!=t?e.href.slice(0,-(t.length+1)):e.href}function x(e){return B(e)}function D(e,t){return F(e).href==F(t).href}function V(e){return e.endsWith("/")?e:e+"/"}class W{constructor(e){this.response=e}get succeeded(){return this.response.ok}get failed(){return!this.succeeded}get clientError(){return this.statusCode>=400&&this.statusCode<=499}get serverError(){return this.statusCode>=500&&this.statusCode<=599}get redirected(){return this.response.redirected}get location(){return F(this.response.url)}get isHTML(){return this.contentType&&this.contentType.match(/^(?:text\/([^\s;,]+\b)?html|application\/xhtml\+xml)\b/)}get statusCode(){return this.response.status}get contentType(){return this.header("Content-Type")}get responseText(){return this.response.clone().text()}get responseHTML(){return this.isHTML?this.response.clone().text():Promise.resolve(void 0)}header(e){return this.response.headers.get(e)}}class U extends Set{constructor(e){super(),this.maxSize=e}add(e){if(this.size>=this.maxSize){const e=this.values().next().value;this.delete(e)}super.add(e)}}const j=new U(20);function $(e,t={}){const r=new Headers(t.headers||{}),s=p();return j.add(s),r.append("X-Turbo-Request-Id",s),window.fetch(e,{...t,headers:r})}function z(e){switch(e.toLowerCase()){case"get":return G.get;case"post":return G.post;case"put":return G.put;case"patch":return G.patch;case"delete":return G.delete}}const G={get:"get",post:"post",put:"put",patch:"patch",delete:"delete"};const Q={urlEncoded:"application/x-www-form-urlencoded",multipart:"multipart/form-data",plain:"text/plain"};class X{abortController=new AbortController;#t=e=>{};constructor(e,t,r,s=new URLSearchParams,n=null,i=Q.urlEncoded){const[o,a]=Y(F(r),t,s,i);this.delegate=e,this.url=o,this.target=n,this.fetchOptions={credentials:"same-origin",redirect:"follow",method:t.toUpperCase(),headers:{...this.defaultHeaders},body:a,signal:this.abortSignal,referrer:this.delegate.referrer?.href},this.enctype=i}get method(){return this.fetchOptions.method}set method(e){const t=this.isSafe?this.url.searchParams:this.fetchOptions.body||new FormData,r=z(e)||G.get;this.url.search="";const[s,n]=Y(this.url,r,t,this.enctype);this.url=s,this.fetchOptions.body=n,this.fetchOptions.method=r.toUpperCase()}get headers(){return this.fetchOptions.headers}set headers(e){this.fetchOptions.headers=e}get body(){return this.isSafe?this.url.searchParams:this.fetchOptions.body}set body(e){this.fetchOptions.body=e}get location(){return this.url}get params(){return this.url.searchParams}get entries(){return this.body?Array.from(this.body.entries()):[]}cancel(){this.abortController.abort()}async perform(){const{fetchOptions:e}=this;this.delegate.prepareRequest(this);const t=await this.#r(e);try{this.delegate.requestStarted(this),t.detail.fetchRequest?this.response=t.detail.fetchRequest.response:this.response=$(this.url.href,e);const r=await this.response;return await this.receive(r)}catch(e){if("AbortError"!==e.name)throw this.#s(e)&&this.delegate.requestErrored(this,e),e}finally{this.delegate.requestFinished(this)}}async receive(e){const t=new W(e);return a("turbo:before-fetch-response",{cancelable:!0,detail:{fetchResponse:t},target:this.target}).defaultPrevented?this.delegate.requestPreventedHandlingResponse(this,t):t.succeeded?this.delegate.requestSucceededWithResponse(this,t):this.delegate.requestFailedWithResponse(this,t),t}get defaultHeaders(){return{Accept:"text/html, application/xhtml+xml"}}get isSafe(){return K(this.method)}get abortSignal(){return this.abortController.signal}acceptResponseType(e){this.headers.Accept=[e,this.headers.Accept].join(", ")}async#r(e){const t=new Promise(e=>this.#t=e),r=a("turbo:before-fetch-request",{cancelable:!0,detail:{fetchOptions:e,url:this.url,resume:this.#t},target:this.target});return this.url=r.detail.url,r.defaultPrevented&&await t,r}#s(e){return!a("turbo:fetch-request-error",{target:this.target,cancelable:!0,detail:{request:this,error:e}}).defaultPrevented}}function K(e){return z(e)==G.get}function Y(e,t,r,s){const n=Array.from(r).length>0?new URLSearchParams(J(r)):e.searchParams;return K(t)?[Z(e,n),null]:s==Q.urlEncoded?[e,n]:[e,r]}function J(e){const t=[];for(const[r,s]of e)s instanceof File||t.push([r,s]);return t}function Z(e,t){const r=new URLSearchParams(J(t));return e.search=r.toString(),e}class ee{started=!1;constructor(e,t){this.delegate=e,this.element=t,this.intersectionObserver=new IntersectionObserver(this.intersect)}start(){this.started||(this.started=!0,this.intersectionObserver.observe(this.element))}stop(){this.started&&(this.started=!1,this.intersectionObserver.unobserve(this.element))}intersect=e=>{const t=e.slice(-1)[0];t?.isIntersecting&&this.delegate.elementAppearedInViewport(this.element)}}class te{static contentType="text/vnd.turbo-stream.html";static wrap(e){return"string"==typeof e?new this(function(e){const t=document.createElement("template");return t.innerHTML=e,t.content}(e)):e}constructor(e){this.fragment=function(e){for(const t of e.querySelectorAll("turbo-stream")){const e=document.importNode(t,!0);for(const t of e.templateElement.content.querySelectorAll("script"))t.replaceWith(o(t));t.replaceWith(e)}return e}(e)}}const re=new class{#n=null;#i=null;get(e){if(this.#i&&this.#i.url===e&&this.#i.expire>Date.now())return this.#i.request}setLater(e,t,r){this.clear(),this.#n=setTimeout(()=>{t.perform(),this.set(e,t,r),this.#n=null},100)}set(e,t,r){this.#i={url:e,request:t,expire:new Date((new Date).getTime()+r)}}clear(){this.#n&&clearTimeout(this.#n),this.#i=null}},se={initialized:"initialized",requesting:"requesting",waiting:"waiting",receiving:"receiving",stopping:"stopping",stopped:"stopped"};class ne{state=se.initialized;static confirmMethod(e){return Promise.resolve(confirm(e))}constructor(e,t,r,s=!1){const n=function(e,t){const r=t?.getAttribute("formmethod")||e.getAttribute("method")||"";return z(r.toLowerCase())||G.get}(t,r),i=function(e,t){const r=F(e);K(t)&&(r.search="");return r}(function(e,t){const r="string"==typeof e.action?e.action:null;return t?.hasAttribute("formaction")?t.getAttribute("formaction")||"":e.getAttribute("action")||r||""}(t,r),n),o=function(e,t){const r=new FormData(e),s=t?.getAttribute("name"),n=t?.getAttribute("value");s&&r.append(s,n||"");return r}(t,r),a=function(e,t){return function(e){switch(e.toLowerCase()){case Q.multipart:return Q.multipart;case Q.plain:return Q.plain;default:return Q.urlEncoded}}(t?.getAttribute("formenctype")||e.enctype)}(t,r);this.delegate=e,this.formElement=t,this.submitter=r,this.fetchRequest=new X(this,n,i,o,t,a),this.mustRedirect=s}get method(){return this.fetchRequest.method}set method(e){this.fetchRequest.method=e}get action(){return this.fetchRequest.url.toString()}set action(e){this.fetchRequest.url=F(e)}get body(){return this.fetchRequest.body}get enctype(){return this.fetchRequest.enctype}get isSafe(){return this.fetchRequest.isSafe}get location(){return this.fetchRequest.url}async start(){const{initialized:e,requesting:t}=se,r=f("data-turbo-confirm",this.submitter,this.formElement);if("string"==typeof r){const e="function"==typeof _.forms.confirm?_.forms.confirm:ne.confirmMethod;if(!await e(r,this.formElement,this.submitter))return}if(this.state==e)return this.state=t,this.fetchRequest.perform()}stop(){const{stopping:e,stopped:t}=se;if(this.state!=e&&this.state!=t)return this.state=e,this.fetchRequest.cancel(),!0}prepareRequest(e){if(!e.isSafe){const t=function(e){if(null!=e){const t=(document.cookie?document.cookie.split("; "):[]).find(t=>t.startsWith(e));if(t){const e=t.split("=").slice(1).join("=");return e?decodeURIComponent(e):void 0}}}(E("csrf-param"))||E("csrf-token");t&&(e.headers["X-CSRF-Token"]=t)}this.requestAcceptsTurboStreamResponse(e)&&e.acceptResponseType(te.contentType)}requestStarted(e){this.state=se.waiting,this.submitter&&_.forms.submitter.beforeSubmit(this.submitter),this.setSubmitsWith(),g(this.formElement),a("turbo:submit-start",{target:this.formElement,detail:{formSubmission:this}}),this.delegate.formSubmissionStarted(this)}requestPreventedHandlingResponse(e,t){re.clear(),this.result={success:t.succeeded,fetchResponse:t}}requestSucceededWithResponse(e,t){if(t.clientError||t.serverError)this.delegate.formSubmissionFailedWithResponse(this,t);else if(re.clear(),this.requestMustRedirect(e)&&function(e){return 200==e.statusCode&&!e.redirected}(t)){const e=new Error("Form responses must redirect to another location");this.delegate.formSubmissionErrored(this,e)}else this.state=se.receiving,this.result={success:!0,fetchResponse:t},this.delegate.formSubmissionSucceededWithResponse(this,t)}requestFailedWithResponse(e,t){this.result={success:!1,fetchResponse:t},this.delegate.formSubmissionFailedWithResponse(this,t)}requestErrored(e,t){this.result={success:!1,error:t},this.delegate.formSubmissionErrored(this,t)}requestFinished(e){this.state=se.stopped,this.submitter&&_.forms.submitter.afterSubmit(this.submitter),this.resetSubmitterText(),b(this.formElement),a("turbo:submit-end",{target:this.formElement,detail:{formSubmission:this,...this.result}}),this.delegate.formSubmissionFinished(this)}setSubmitsWith(){if(this.submitter&&this.submitsWith)if(this.submitter.matches("button"))this.originalSubmitText=this.submitter.innerHTML,this.submitter.innerHTML=this.submitsWith;else if(this.submitter.matches("input")){const e=this.submitter;this.originalSubmitText=e.value,e.value=this.submitsWith}}resetSubmitterText(){if(this.submitter&&this.originalSubmitText)if(this.submitter.matches("button"))this.submitter.innerHTML=this.originalSubmitText;else if(this.submitter.matches("input")){this.submitter.value=this.originalSubmitText}}requestMustRedirect(e){return!e.isSafe&&this.mustRedirect}requestAcceptsTurboStreamResponse(e){return!e.isSafe||function(e,...t){return t.some(t=>t&&t.hasAttribute(e))}("data-turbo-stream",this.submitter,this.formElement)}get submitsWith(){return this.submitter?.getAttribute("data-turbo-submits-with")}}class ie{constructor(e){this.element=e}get activeElement(){return this.element.ownerDocument.activeElement}get children(){return[...this.element.children]}hasAnchor(e){return null!=this.getElementForAnchor(e)}getElementForAnchor(e){return e?this.element.querySelector(`[id='${e}'], a[name='${e}']`):null}get isConnected(){return this.element.isConnected}get firstAutofocusableElement(){return A(this.element)}get permanentElements(){return ae(this.element)}getPermanentElementById(e){return oe(this.element,e)}getPermanentElementMapForSnapshot(e){const t={};for(const r of this.permanentElements){const{id:s}=r,n=e.getPermanentElementById(s);n&&(t[s]=[r,n])}return t}}function oe(e,t){return e.querySelector(`#${t}[data-turbo-permanent]`)}function ae(e){return e.querySelectorAll("[id][data-turbo-permanent]")}class ce{started=!1;constructor(e,t){this.delegate=e,this.eventTarget=t}start(){this.started||(this.eventTarget.addEventListener("submit",this.submitCaptured,!0),this.started=!0)}stop(){this.started&&(this.eventTarget.removeEventListener("submit",this.submitCaptured,!0),this.started=!1)}submitCaptured=()=>{this.eventTarget.removeEventListener("submit",this.submitBubbled,!1),this.eventTarget.addEventListener("submit",this.submitBubbled,!1)};submitBubbled=e=>{if(!e.defaultPrevented){const t=e.target instanceof HTMLFormElement?e.target:void 0,r=e.submitter||void 0;t&&function(e,t){const r=t?.getAttribute("formmethod")||e.getAttribute("method");return"dialog"!=r}(t,r)&&function(e,t){const r=t?.getAttribute("formtarget")||e.getAttribute("target");return C(r)}(t,r)&&this.delegate.willSubmitForm(t,r)&&(e.preventDefault(),e.stopImmediatePropagation(),this.delegate.formSubmitted(t,r))}}}class le{#o=e=>{};#a=e=>{};constructor(e,t){this.delegate=e,this.element=t}scrollToAnchor(e){const t=this.snapshot.getElementForAnchor(e);t?(this.focusElement(t),this.scrollToElement(t)):this.scrollToPosition({x:0,y:0})}scrollToAnchorFromLocation(e){this.scrollToAnchor(q(e))}scrollToElement(e){e.scrollIntoView()}focusElement(e){e instanceof HTMLElement&&(e.hasAttribute("tabindex")?e.focus():(e.setAttribute("tabindex","-1"),e.focus(),e.removeAttribute("tabindex")))}scrollToPosition({x:e,y:t}){this.scrollRoot.scrollTo(e,t)}scrollToTop(){this.scrollToPosition({x:0,y:0})}get scrollRoot(){return window}async render(e){const{isPreview:t,shouldRender:r,willRender:s,newSnapshot:n}=e,i=s;if(r)try{this.renderPromise=new Promise(e=>this.#o=e),this.renderer=e,await this.prepareToRenderSnapshot(e);const r=new Promise(e=>this.#a=e),s={resume:this.#a,render:this.renderer.renderElement,renderMethod:this.renderer.renderMethod};this.delegate.allowsImmediateRender(n,s)||await r,await this.renderSnapshot(e),this.delegate.viewRenderedSnapshot(n,t,this.renderer.renderMethod),this.delegate.preloadOnLoadLinksForView(this.element),this.finishRenderingSnapshot(e)}finally{delete this.renderer,this.#o(void 0),delete this.renderPromise}else i&&this.invalidate(e.reloadReason)}invalidate(e){this.delegate.viewInvalidated(e)}async prepareToRenderSnapshot(e){this.markAsPreview(e.isPreview),await e.prepareToRender()}markAsPreview(e){e?this.element.setAttribute("data-turbo-preview",""):this.element.removeAttribute("data-turbo-preview")}markVisitDirection(e){this.element.setAttribute("data-turbo-visit-direction",e)}unmarkVisitDirection(){this.element.removeAttribute("data-turbo-visit-direction")}async renderSnapshot(e){await e.render()}finishRenderingSnapshot(e){e.finishRendering()}}class he extends le{missing(){this.element.innerHTML='Content missing'}get snapshot(){return new ie(this.element)}}class de{constructor(e,t){this.delegate=e,this.element=t}start(){this.element.addEventListener("click",this.clickBubbled),document.addEventListener("turbo:click",this.linkClicked),document.addEventListener("turbo:before-visit",this.willVisit)}stop(){this.element.removeEventListener("click",this.clickBubbled),document.removeEventListener("turbo:click",this.linkClicked),document.removeEventListener("turbo:before-visit",this.willVisit)}clickBubbled=e=>{this.clickEventIsSignificant(e)?this.clickEvent=e:delete this.clickEvent};linkClicked=e=>{this.clickEvent&&this.clickEventIsSignificant(e)&&this.delegate.shouldInterceptLinkClick(e.target,e.detail.url,e.detail.originalEvent)&&(this.clickEvent.preventDefault(),e.preventDefault(),this.delegate.linkClickIntercepted(e.target,e.detail.url,e.detail.originalEvent)),delete this.clickEvent};willVisit=e=>{delete this.clickEvent};clickEventIsSignificant(e){const t=e.composed?e.target?.parentElement:e.target,r=P(t)||t;return r instanceof Element&&r.closest("turbo-frame, html")==this.element}}class ue{started=!1;constructor(e,t){this.delegate=e,this.eventTarget=t}start(){this.started||(this.eventTarget.addEventListener("click",this.clickCaptured,!0),this.started=!0)}stop(){this.started&&(this.eventTarget.removeEventListener("click",this.clickCaptured,!0),this.started=!1)}clickCaptured=()=>{this.eventTarget.removeEventListener("click",this.clickBubbled,!1),this.eventTarget.addEventListener("click",this.clickBubbled,!1)};clickBubbled=e=>{if(e instanceof MouseEvent&&this.clickEventIsSignificant(e)){const t=P(e.composedPath&&e.composedPath()[0]||e.target);if(t&&C(t.target)){const r=k(t);this.delegate.willFollowLinkToLocation(t,r,e)&&(e.preventDefault(),this.delegate.followedLinkToLocation(t,r))}}};clickEventIsSignificant(e){return!(e.target&&e.target.isContentEditable||e.defaultPrevented||e.which>1||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)}}class me{constructor(e,t){this.delegate=e,this.linkInterceptor=new ue(this,t)}start(){this.linkInterceptor.start()}stop(){this.linkInterceptor.stop()}canPrefetchRequestToLocation(e,t){return!1}prefetchAndCacheRequestToLocation(e,t){}willFollowLinkToLocation(e,t,r){return this.delegate.willSubmitFormLinkToLocation(e,t,r)&&(e.hasAttribute("data-turbo-method")||e.hasAttribute("data-turbo-stream"))}followedLinkToLocation(e,t){const r=document.createElement("form");for(const[e,s]of t.searchParams)r.append(Object.assign(document.createElement("input"),{type:"hidden",name:e,value:s}));const s=Object.assign(t,{search:""});r.setAttribute("data-turbo","true"),r.setAttribute("action",s.href),r.setAttribute("hidden","");const n=e.getAttribute("data-turbo-method");n&&r.setAttribute("method",n);const i=e.getAttribute("data-turbo-frame");i&&r.setAttribute("data-turbo-frame",i);const o=y(e);o&&r.setAttribute("data-turbo-action",o);const a=e.getAttribute("data-turbo-confirm");a&&r.setAttribute("data-turbo-confirm",a);e.hasAttribute("data-turbo-stream")&&r.setAttribute("data-turbo-stream",""),this.delegate.submittedFormLinkToLocation(e,t,r),document.body.appendChild(r),r.addEventListener("turbo:submit-end",()=>r.remove(),{once:!0}),requestAnimationFrame(()=>r.requestSubmit())}}class pe{static async preservingPermanentElements(e,t,r){const s=new this(e,t);s.enter(),await r(),s.leave()}constructor(e,t){this.delegate=e,this.permanentElementMap=t}enter(){for(const e in this.permanentElementMap){const[t,r]=this.permanentElementMap[e];this.delegate.enteringBardo(t,r),this.replaceNewPermanentElementWithPlaceholder(r)}}leave(){for(const e in this.permanentElementMap){const[t]=this.permanentElementMap[e];this.replaceCurrentPermanentElementWithClone(t),this.replacePlaceholderWithPermanentElement(t),this.delegate.leavingBardo(t)}}replaceNewPermanentElementWithPlaceholder(e){const t=function(e){const t=document.createElement("meta");return t.setAttribute("name","turbo-permanent-placeholder"),t.setAttribute("content",e.id),t}(e);e.replaceWith(t)}replaceCurrentPermanentElementWithClone(e){const t=e.cloneNode(!0);e.replaceWith(t)}replacePlaceholderWithPermanentElement(e){const t=this.getPlaceholderById(e.id);t?.replaceWith(e)}getPlaceholderById(e){return this.placeholders.find(t=>t.content==e)}get placeholders(){return[...document.querySelectorAll("meta[name=turbo-permanent-placeholder][content]")]}}class fe{#c=null;static renderElement(e,t){}constructor(e,t,r,s=!0){this.currentSnapshot=e,this.newSnapshot=t,this.isPreview=r,this.willRender=s,this.renderElement=this.constructor.renderElement,this.promise=new Promise((e,t)=>this.resolvingFunctions={resolve:e,reject:t})}get shouldRender(){return!0}get shouldAutofocus(){return!0}get reloadReason(){}prepareToRender(){}render(){}finishRendering(){this.resolvingFunctions&&(this.resolvingFunctions.resolve(),delete this.resolvingFunctions)}async preservingPermanentElements(e){await pe.preservingPermanentElements(this,this.permanentElementMap,e)}focusFirstAutofocusableElement(){if(this.shouldAutofocus){const e=this.connectedSnapshot.firstAutofocusableElement;e&&e.focus()}}enteringBardo(e){this.#c||e.contains(this.currentSnapshot.activeElement)&&(this.#c=this.currentSnapshot.activeElement)}leavingBardo(e){e.contains(this.#c)&&this.#c instanceof HTMLElement&&(this.#c.focus(),this.#c=null)}get connectedSnapshot(){return this.newSnapshot.isConnected?this.newSnapshot:this.currentSnapshot}get currentElement(){return this.currentSnapshot.element}get newElement(){return this.newSnapshot.element}get permanentElementMap(){return this.currentSnapshot.getPermanentElementMapForSnapshot(this.newSnapshot)}get renderMethod(){return"replace"}}class ge extends fe{static renderElement(e,t){const r=document.createRange();r.selectNodeContents(e),r.deleteContents();const s=t,n=s.ownerDocument?.createRange();n&&(n.selectNodeContents(s),e.appendChild(n.extractContents()))}constructor(e,t,r,s,n,i=!0){super(t,r,s,n,i),this.delegate=e}get shouldRender(){return!0}async render(){await l(),this.preservingPermanentElements(()=>{this.loadFrameElement()}),this.scrollFrameIntoView(),await l(),this.focusFirstAutofocusableElement(),await l(),this.activateScriptElements()}loadFrameElement(){this.delegate.willRenderFrame(this.currentElement,this.newElement),this.renderElement(this.currentElement,this.newElement)}scrollFrameIntoView(){if(this.currentElement.autoscroll||this.newElement.autoscroll){const r=this.currentElement.firstElementChild,s=(e=this.currentElement.getAttribute("data-autoscroll-block"),t="end","end"==e||"start"==e||"center"==e||"nearest"==e?e:t),n=function(e,t){return"auto"==e||"smooth"==e?e:t}(this.currentElement.getAttribute("data-autoscroll-behavior"),"auto");if(r)return r.scrollIntoView({block:s,behavior:n}),!0}var e,t;return!1}activateScriptElements(){for(const e of this.newScriptElements){const t=o(e);e.replaceWith(t)}}get newScriptElements(){return this.currentElement.querySelectorAll("script")}}var be=function(){const e=()=>{},t={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:e=>"true"===e.getAttribute("im-preserve"),shouldReAppend:e=>"true"===e.getAttribute("im-re-append"),shouldRemove:e,afterHeadMorphed:e},restoreFocus:!0};const r=function(){function e(e,t,r,n){if(!1===n.callbacks.beforeNodeAdded(t))return null;if(n.idMap.has(t)){const i=document.createElement(t.tagName);return e.insertBefore(i,r),s(i,t,n),n.callbacks.afterNodeAdded(i),i}{const s=document.importNode(t,!0);return e.insertBefore(s,r),n.callbacks.afterNodeAdded(s),s}}const t=function(){function e(e,t,r){let s=e.idMap.get(t),n=e.idMap.get(r);if(!n||!s)return!1;for(const e of s)if(n.has(e))return!0;return!1}function t(e,t){const r=e,s=t;return r.nodeType===s.nodeType&&r.tagName===s.tagName&&(!r.id||r.id===s.id)}return function(r,s,n,i){let o=null,a=s.nextSibling,c=0,l=n;for(;l&&l!=i;){if(t(l,s)){if(e(r,l,s))return l;null===o&&(r.idMap.has(l)||(o=l))}if(null===o&&a&&t(l,a)&&(c++,a=a.nextSibling,c>=2&&(o=void 0)),l.contains(document.activeElement))break;l=l.nextSibling}return o||null}}();function r(e,t){if(e.idMap.has(t))o(e.pantry,t,null);else{if(!1===e.callbacks.beforeNodeRemoved(t))return;t.parentNode?.removeChild(t),e.callbacks.afterNodeRemoved(t)}}function n(e,t,s){let n=t;for(;n&&n!==s;){let t=n;n=n.nextSibling,r(e,t)}return n}function i(e,t,r,s){const n=s.target.querySelector(`#${t}`)||s.pantry.querySelector(`#${t}`);return function(e,t){const r=e.id;for(;e=e.parentNode;){let s=t.idMap.get(e);s&&(s.delete(r),s.size||t.idMap.delete(e))}}(n,s),o(e,n,r),n}function o(e,t,r){if(e.moveBefore)try{e.moveBefore(t,r)}catch(s){e.insertBefore(t,r)}else e.insertBefore(t,r)}return function(o,a,c,l=null,h=null){a instanceof HTMLTemplateElement&&c instanceof HTMLTemplateElement&&(a=a.content,c=c.content),l||=a.firstChild;for(const r of c.childNodes){if(l&&l!=h){const e=t(o,r,l,h);if(e){e!==l&&n(o,l,e),s(e,r,o),l=e.nextSibling;continue}}if(r instanceof Element&&o.persistentIds.has(r.id)){const e=i(a,r.id,l,o);s(e,r,o),l=e.nextSibling;continue}const c=e(a,r,l,o);c&&(l=c.nextSibling)}for(;l&&l!=h;){const e=l;l=l.nextSibling,r(o,e)}}}(),s=function(){function e(e,r,s,n){const i=r[s];if(i!==e[s]){const o=t(s,e,"update",n);o||(e[s]=r[s]),i?o||e.setAttribute(s,""):t(s,e,"remove",n)||e.removeAttribute(s)}}function t(e,t,r,s){return!("value"!==e||!s.ignoreActiveValue||t!==document.activeElement)||!1===s.callbacks.beforeAttributeUpdated(e,t,r)}function s(e,t){return!!t.ignoreActiveValue&&e===document.activeElement&&e!==document.body}return function(i,o,a){return a.ignoreActive&&i===document.activeElement?null:(!1===a.callbacks.beforeNodeMorphed(i,o)||(i instanceof HTMLHeadElement&&a.head.ignore||(i instanceof HTMLHeadElement&&"morph"!==a.head.style?n(i,o,a):(!function(r,n,i){let o=n.nodeType;if(1===o){const o=r,a=n,c=o.attributes,l=a.attributes;for(const e of l)t(e.name,o,"update",i)||o.getAttribute(e.name)!==e.value&&o.setAttribute(e.name,e.value);for(let e=c.length-1;0<=e;e--){const r=c[e];if(r&&!a.hasAttribute(r.name)){if(t(r.name,o,"remove",i))continue;o.removeAttribute(r.name)}}s(o,i)||function(r,s,n){if(r instanceof HTMLInputElement&&s instanceof HTMLInputElement&&"file"!==s.type){let i=s.value,o=r.value;e(r,s,"checked",n),e(r,s,"disabled",n),s.hasAttribute("value")?o!==i&&(t("value",r,"update",n)||(r.setAttribute("value",i),r.value=i)):t("value",r,"remove",n)||(r.value="",r.removeAttribute("value"))}else if(r instanceof HTMLOptionElement&&s instanceof HTMLOptionElement)e(r,s,"selected",n);else if(r instanceof HTMLTextAreaElement&&s instanceof HTMLTextAreaElement){let e=s.value,i=r.value;if(t("value",r,"update",n))return;e!==i&&(r.value=e),r.firstChild&&r.firstChild.nodeValue!==e&&(r.firstChild.nodeValue=e)}}(o,a,i)}8!==o&&3!==o||r.nodeValue!==n.nodeValue&&(r.nodeValue=n.nodeValue)}(i,o,a),s(i,a)||r(a,i,o))),a.callbacks.afterNodeMorphed(i,o)),i)}}();function n(e,t,r){let s=[],n=[],i=[],o=[],a=new Map;for(const e of t.children)a.set(e.outerHTML,e);for(const t of e.children){let e=a.has(t.outerHTML),s=r.head.shouldReAppend(t),c=r.head.shouldPreserve(t);e||c?s?n.push(t):(a.delete(t.outerHTML),i.push(t)):"append"===r.head.style?s&&(n.push(t),o.push(t)):!1!==r.head.shouldRemove(t)&&n.push(t)}o.push(...a.values());let c=[];for(const t of o){let n=document.createRange().createContextualFragment(t.outerHTML).firstChild;if(!1!==r.callbacks.beforeNodeAdded(n)){if("href"in n&&n.href||"src"in n&&n.src){let e,t=new Promise(function(t){e=t});n.addEventListener("load",function(){e()}),c.push(t)}e.appendChild(n),r.callbacks.afterNodeAdded(n),s.push(n)}}for(const t of n)!1!==r.callbacks.beforeNodeRemoved(t)&&(e.removeChild(t),r.callbacks.afterNodeRemoved(t));return r.head.afterHeadMorphed(e,{added:s,kept:i,removed:n}),c}const i=function(){function e(){const e=document.createElement("div");return e.hidden=!0,document.body.insertAdjacentElement("afterend",e),e}function r(e){let t=Array.from(e.querySelectorAll("[id]"));return e.id&&t.push(e),t}function s(e,t,r,s){for(const n of s)if(t.has(n.id)){let t=n;for(;t;){let s=e.get(t);if(null==s&&(s=new Set,e.set(t,s)),s.add(n.id),t===r)break;t=t.parentElement}}}return function(n,i,o){const{persistentIds:a,idMap:c}=function(e,t){const n=r(e),i=r(t),o=function(e,t){let r=new Set,s=new Map;for(const{id:t,tagName:n}of e)s.has(t)?r.add(t):s.set(t,n);let n=new Set;for(const{id:e,tagName:i}of t)n.has(e)?r.add(e):s.get(e)===i&&n.add(e);for(const e of r)n.delete(e);return n}(n,i);let a=new Map;s(a,o,e,n);const c=t.__idiomorphRoot||t;return s(a,o,c,i),{persistentIds:o,idMap:a}}(n,i),l=function(e){let r=Object.assign({},t);return Object.assign(r,e),r.callbacks=Object.assign({},t.callbacks,e.callbacks),r.head=Object.assign({},t.head,e.head),r}(o),h=l.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(h))throw`Do not understand how to morph style ${h}`;return{target:n,newContent:i,config:l,morphStyle:h,ignoreActive:l.ignoreActive,ignoreActiveValue:l.ignoreActiveValue,restoreFocus:l.restoreFocus,idMap:c,persistentIds:a,pantry:e(),callbacks:l.callbacks,head:l.head}}}(),{normalizeElement:o,normalizeParent:a}=function(){const e=new WeakSet;return{normalizeElement:function(e){return e instanceof Document?e.documentElement:e},normalizeParent:function t(r){if(null==r)return document.createElement("div");if("string"==typeof r)return t(function(t){let r=new DOMParser,s=t.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"");if(s.match(/<\/html>/)||s.match(/<\/head>/)||s.match(/<\/body>/)){let n=r.parseFromString(t,"text/html");if(s.match(/<\/html>/))return e.add(n),n;{let t=n.firstChild;return t&&e.add(t),t}}{let s=r.parseFromString("","text/html").body.querySelector("template").content;return e.add(s),s}}(r));if(e.has(r))return r;if(r instanceof Node){if(r.parentNode)return function(e){return{childNodes:[e],querySelectorAll:t=>{const r=e.querySelectorAll(t);return e.matches(t)?[e,...r]:r},insertBefore:(t,r)=>e.parentNode.insertBefore(t,r),moveBefore:(t,r)=>e.parentNode.moveBefore(t,r),get __idiomorphRoot(){return e}}}(r);{const e=document.createElement("div");return e.append(r),e}}{const e=document.createElement("div");for(const t of[...r])e.append(t);return e}}}}();return{morph:function(e,t,s={}){e=o(e);const c=a(t),l=i(e,c,s),h=function(e,t){if(!e.config.restoreFocus)return t();let r=document.activeElement;if(!(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement))return t();const{id:s,selectionStart:n,selectionEnd:i}=r,o=t();s&&s!==document.activeElement?.id&&(r=e.target.querySelector(`#${s}`),r?.focus());r&&!r.selectionEnd&&i&&r.setSelectionRange(n,i);return o}(l,()=>function(e,t,r,s){if(e.head.block){const i=t.querySelector("head"),o=r.querySelector("head");if(i&&o){const t=n(i,o,e);return Promise.all(t).then(()=>{const t=Object.assign(e,{head:{block:!1,ignore:!0}});return s(t)})}}return s(e)}(l,e,c,t=>"innerHTML"===t.morphStyle?(r(t,e,c),Array.from(e.childNodes)):function(e,t,s){const n=a(t);let i=Array.from(n.childNodes);const o=i.indexOf(t),c=i.length-(o+1);return r(e,n,s,t,t.nextSibling),i=Array.from(n.childNodes),i.slice(o,i.length-c)}(t,e,c)));return l.pantry.remove(),h},defaults:t}}();function ve(e,t,{callbacks:r,...s}={}){be.morph(e,t,{...s,callbacks:new Ee(r)})}function we(e,t,r={}){ve(e,t.childNodes,{...r,morphStyle:"innerHTML"})}function ye(e,t){return e instanceof n&&t instanceof Element&&"TURBO-FRAME"===t.nodeName&&e.shouldReloadWithMorph&&e.id===t.id&&(!t.getAttribute("src")||D(e.src,t.getAttribute("src")))&&!e.closest("[data-turbo-permanent]")}function Se(e){return e.parentElement.closest("turbo-frame[src][refresh=morph]")}class Ee{#l;constructor({beforeNodeMorphed:e}={}){this.#l=e||(()=>!0)}beforeNodeAdded=e=>!(e.id&&e.hasAttribute("data-turbo-permanent")&&document.getElementById(e.id));beforeNodeMorphed=(e,t)=>{if(e instanceof Element){if(!e.hasAttribute("data-turbo-permanent")&&this.#l(e,t)){return!a("turbo:before-morph-element",{cancelable:!0,target:e,detail:{currentElement:e,newElement:t}}).defaultPrevented}return!1}};beforeAttributeUpdated=(e,t,r)=>!a("turbo:before-morph-attribute",{cancelable:!0,target:t,detail:{attributeName:e,mutationType:r}}).defaultPrevented;beforeNodeRemoved=e=>this.beforeNodeMorphed(e);afterNodeMorphed=(e,t)=>{e instanceof Element&&a("turbo:morph-element",{target:e,detail:{currentElement:e,newElement:t}})}}class Le extends ge{static renderElement(e,t){a("turbo:before-frame-morph",{target:e,detail:{currentElement:e,newElement:t}}),we(e,t,{callbacks:{beforeNodeMorphed:(t,r)=>!ye(t,r)||Se(t)!==e||(t.reload(),!1)}})}async preservingPermanentElements(e){return await e()}}class Te{static animationDuration=300;static get defaultCSS(){return m` .turbo-progress-bar { position: fixed; display: block; @@ -16,7 +16,7 @@ Copyright © 2025 37signals LLC opacity ${Te.animationDuration/2}ms ${Te.animationDuration/2}ms ease-in; transform: translate3d(0, 0, 0); } - `}hiding=!1;value=0;visible=!1;constructor(){this.stylesheetElement=this.createStylesheetElement(),this.progressElement=this.createProgressElement(),this.installStylesheetElement(),this.setValue(0)}show(){this.visible||(this.visible=!0,this.installProgressElement(),this.startTrickling())}hide(){this.visible&&!this.hiding&&(this.hiding=!0,this.fadeProgressElement(()=>{this.uninstallProgressElement(),this.stopTrickling(),this.visible=!1,this.hiding=!1}))}setValue(e){this.value=e,this.refresh()}installStylesheetElement(){document.head.insertBefore(this.stylesheetElement,document.head.firstChild)}installProgressElement(){this.progressElement.style.width="0",this.progressElement.style.opacity="1",document.documentElement.insertBefore(this.progressElement,document.body),this.refresh()}fadeProgressElement(e){this.progressElement.style.opacity="0",setTimeout(e,1.5*Te.animationDuration)}uninstallProgressElement(){this.progressElement.parentNode&&document.documentElement.removeChild(this.progressElement)}startTrickling(){this.trickleInterval||(this.trickleInterval=window.setInterval(this.trickle,Te.animationDuration))}stopTrickling(){window.clearInterval(this.trickleInterval),delete this.trickleInterval}trickle=()=>{this.setValue(this.value+Math.random()/100)};refresh(){requestAnimationFrame(()=>{this.progressElement.style.width=10+90*this.value+"%"})}createStylesheetElement(){const e=document.createElement("style");e.type="text/css",e.textContent=Te.defaultCSS;const t=L();return t&&(e.nonce=t),e}createProgressElement(){const e=document.createElement("div");return e.className="turbo-progress-bar",e}}class Re extends ne{detailsByOuterHTML=this.children.filter(e=>!function(e){const t=e.localName;return"noscript"==t}(e)).map(e=>function(e){e.hasAttribute("nonce")&&e.setAttribute("nonce","");return e}(e)).reduce((e,t)=>{const{outerHTML:r}=t,s=r in e?e[r]:{type:Ae(t),tracked:Ce(t),elements:[]};return{...e,[r]:{...s,elements:[...s.elements,t]}}},{});get trackedElementSignature(){return Object.keys(this.detailsByOuterHTML).filter(e=>this.detailsByOuterHTML[e].tracked).join("")}getScriptElementsNotInSnapshot(e){return this.getElementsMatchingTypeNotInSnapshot("script",e)}getStylesheetElementsNotInSnapshot(e){return this.getElementsMatchingTypeNotInSnapshot("stylesheet",e)}getElementsMatchingTypeNotInSnapshot(e,t){return Object.keys(this.detailsByOuterHTML).filter(e=>!(e in t.detailsByOuterHTML)).map(e=>this.detailsByOuterHTML[e]).filter(({type:t})=>t==e).map(({elements:[e]})=>e)}get provisionalElements(){return Object.keys(this.detailsByOuterHTML).reduce((e,t)=>{const{type:r,tracked:s,elements:i}=this.detailsByOuterHTML[t];return null!=r||s?i.length>1?[...e,...i.slice(1)]:e:[...e,...i]},[])}getMetaValue(e){const t=this.findMetaElementByName(e);return t?t.getAttribute("content"):null}findMetaElementByName(e){return Object.keys(this.detailsByOuterHTML).reduce((t,r)=>{const{elements:[s]}=this.detailsByOuterHTML[r];return function(e,t){const r=e.localName;return"meta"==r&&e.getAttribute("name")==t}(s,e)?s:t},0)}}function Ae(e){return function(e){const t=e.localName;return"script"==t}(e)?"script":function(e){const t=e.localName;return"style"==t||"link"==t&&"stylesheet"==e.getAttribute("rel")}(e)?"stylesheet":void 0}function Ce(e){return"reload"==e.getAttribute("data-turbo-track")}class Pe extends ne{static fromHTMLString(e=""){return this.fromDocument(u(e))}static fromElement(e){return this.fromDocument(e.ownerDocument)}static fromDocument({documentElement:e,body:t,head:r}){return new this(e,t,new Re(r))}constructor(e,t,r){super(t),this.documentElement=e,this.headSnapshot=r}clone(){const e=this.element.cloneNode(!0),t=this.element.querySelectorAll("select"),r=e.querySelectorAll("select");for(const[e,s]of t.entries()){const t=r[e];for(const e of t.selectedOptions)e.selected=!1;for(const e of s.selectedOptions)t.options[e.index].selected=!0}for(const t of e.querySelectorAll('input[type="password"]'))t.value="";return new Pe(this.documentElement,e,this.headSnapshot)}get lang(){return this.documentElement.getAttribute("lang")}get headElement(){return this.headSnapshot.element}get rootLocation(){return F(this.getSetting("root")??"/")}get cacheControlValue(){return this.getSetting("cache-control")}get isPreviewable(){return"no-preview"!=this.cacheControlValue}get isCacheable(){return"no-cache"!=this.cacheControlValue}get isVisitable(){return"reload"!=this.getSetting("visit-control")}get prefersViewTransitions(){return("true"===this.getSetting("view-transition")||"same-origin"===this.headSnapshot.getMetaValue("view-transition"))&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches}get shouldMorphPage(){return"morph"===this.getSetting("refresh-method")}get shouldPreserveScrollPosition(){return"preserve"===this.getSetting("refresh-scroll")}getSetting(e){return this.headSnapshot.getMetaValue(`turbo-${e}`)}}class ke{#h=!1;#d=Promise.resolve();renderChange(e,t){return e&&this.viewTransitionsAvailable&&!this.#h?(this.#h=!0,this.#d=this.#d.then(async()=>{await document.startViewTransition(t).finished})):this.#d=this.#d.then(t),this.#d}get viewTransitionsAvailable(){return document.startViewTransition}}const Me={action:"advance",historyChanged:!1,visitCachedSnapshot:()=>{},willRender:!0,updateHistory:!0,shouldCacheSnapshot:!0,acceptsStreamResponse:!1},Ie="visitStart",_e="requestStart",Fe="requestEnd",qe="visitEnd",Oe="initialized",He="started",Ne="canceled",Be="failed",xe="completed",De=0,Ve=-1,We=-2,Ue={advance:"forward",restore:"back",replace:"none"};class je{identifier=p();timingMetrics={};followedRedirect=!1;historyChanged=!1;scrolled=!1;shouldCacheSnapshot=!0;acceptsStreamResponse=!1;snapshotCached=!1;state=Oe;viewTransitioner=new ke;constructor(e,t,r,s={}){this.delegate=e,this.location=t,this.restorationIdentifier=r||p();const{action:i,historyChanged:n,referrer:o,snapshot:a,snapshotHTML:c,response:l,visitCachedSnapshot:h,willRender:d,updateHistory:u,shouldCacheSnapshot:m,acceptsStreamResponse:f,direction:g}={...Me,...s};this.action=i,this.historyChanged=n,this.referrer=o,this.snapshot=a,this.snapshotHTML=c,this.response=l,this.isSamePage=this.delegate.locationWithActionIsSamePage(this.location,this.action),this.isPageRefresh=this.view.isPageRefresh(this),this.visitCachedSnapshot=h,this.willRender=d,this.updateHistory=u,this.scrolled=!d,this.shouldCacheSnapshot=m,this.acceptsStreamResponse=f,this.direction=g||Ue[i]}get adapter(){return this.delegate.adapter}get view(){return this.delegate.view}get history(){return this.delegate.history}get restorationData(){return this.history.getRestorationDataForIdentifier(this.restorationIdentifier)}get silent(){return this.isSamePage}start(){this.state==Oe&&(this.recordTimingMetric(Ie),this.state=He,this.adapter.visitStarted(this),this.delegate.visitStarted(this))}cancel(){this.state==He&&(this.request&&this.request.cancel(),this.cancelRender(),this.state=Ne)}complete(){this.state==He&&(this.recordTimingMetric(qe),this.adapter.visitCompleted(this),this.state=xe,this.followRedirect(),this.followedRedirect||this.delegate.visitCompleted(this))}fail(){this.state==He&&(this.state=Be,this.adapter.visitFailed(this),this.delegate.visitCompleted(this))}changeHistory(){if(!this.historyChanged&&this.updateHistory){const e=w(this.location.href===this.referrer?.href?"replace":this.action);this.history.update(e,this.location,this.restorationIdentifier),this.historyChanged=!0}}issueRequest(){this.hasPreloadedResponse()?this.simulateRequest():this.shouldIssueRequest()&&!this.request&&(this.request=new X(this,G.get,this.location),this.request.perform())}simulateRequest(){this.response&&(this.startRequest(),this.recordResponse(),this.finishRequest())}startRequest(){this.recordTimingMetric(_e),this.adapter.visitRequestStarted(this)}recordResponse(e=this.response){if(this.response=e,e){const{statusCode:t}=e;$e(t)?this.adapter.visitRequestCompleted(this):this.adapter.visitRequestFailedWithStatusCode(this,t)}}finishRequest(){this.recordTimingMetric(Fe),this.adapter.visitRequestFinished(this)}loadResponse(){if(this.response){const{statusCode:e,responseHTML:t}=this.response;this.render(async()=>{if(this.shouldCacheSnapshot&&this.cacheSnapshot(),this.view.renderPromise&&await this.view.renderPromise,$e(e)&&null!=t){const e=Pe.fromHTMLString(t);await this.renderPageSnapshot(e,!1),this.adapter.visitRendered(this),this.complete()}else await this.view.renderError(Pe.fromHTMLString(t),this),this.adapter.visitRendered(this),this.fail()})}}getCachedSnapshot(){const e=this.view.getCachedSnapshotForLocation(this.location)||this.getPreloadedSnapshot();if(e&&(!q(this.location)||e.hasAnchor(q(this.location)))&&("restore"==this.action||e.isPreviewable))return e}getPreloadedSnapshot(){if(this.snapshotHTML)return Pe.fromHTMLString(this.snapshotHTML)}hasCachedSnapshot(){return null!=this.getCachedSnapshot()}loadCachedSnapshot(){const e=this.getCachedSnapshot();if(e){const t=this.shouldIssueRequest();this.render(async()=>{this.cacheSnapshot(),this.isSamePage||this.isPageRefresh?this.adapter.visitRendered(this):(this.view.renderPromise&&await this.view.renderPromise,await this.renderPageSnapshot(e,t),this.adapter.visitRendered(this),t||this.complete())})}}followRedirect(){this.redirectedToLocation&&!this.followedRedirect&&this.response?.redirected&&(this.adapter.visitProposedToLocation(this.redirectedToLocation,{action:"replace",response:this.response,shouldCacheSnapshot:!1,willRender:!1}),this.followedRedirect=!0)}goToSamePageAnchor(){this.isSamePage&&this.render(async()=>{this.cacheSnapshot(),this.performScroll(),this.changeHistory(),this.adapter.visitRendered(this)})}prepareRequest(e){this.acceptsStreamResponse&&e.acceptResponseType(te.contentType)}requestStarted(){this.startRequest()}requestPreventedHandlingResponse(e,t){}async requestSucceededWithResponse(e,t){const r=await t.responseHTML,{redirected:s,statusCode:i}=t;null==r?this.recordResponse({statusCode:We,redirected:s}):(this.redirectedToLocation=t.redirected?t.location:void 0,this.recordResponse({statusCode:i,responseHTML:r,redirected:s}))}async requestFailedWithResponse(e,t){const r=await t.responseHTML,{redirected:s,statusCode:i}=t;null==r?this.recordResponse({statusCode:We,redirected:s}):this.recordResponse({statusCode:i,responseHTML:r,redirected:s})}requestErrored(e,t){this.recordResponse({statusCode:De,redirected:!1})}requestFinished(){this.finishRequest()}performScroll(){this.scrolled||this.view.forceReloaded||this.view.shouldPreserveScrollPosition(this)||("restore"==this.action?this.scrollToRestoredPosition()||this.scrollToAnchor()||this.view.scrollToTop():this.scrollToAnchor()||this.view.scrollToTop(),this.isSamePage&&this.delegate.visitScrolledToSamePageLocation(this.view.lastRenderedLocation,this.location),this.scrolled=!0)}scrollToRestoredPosition(){const{scrollPosition:e}=this.restorationData;if(e)return this.view.scrollToPosition(e),!0}scrollToAnchor(){const e=q(this.location);if(null!=e)return this.view.scrollToAnchor(e),!0}recordTimingMetric(e){this.timingMetrics[e]=(new Date).getTime()}getTimingMetrics(){return{...this.timingMetrics}}hasPreloadedResponse(){return"object"==typeof this.response}shouldIssueRequest(){return!this.isSamePage&&("restore"==this.action?!this.hasCachedSnapshot():this.willRender)}cacheSnapshot(){this.snapshotCached||(this.view.cacheSnapshot(this.snapshot).then(e=>e&&this.visitCachedSnapshot(e)),this.snapshotCached=!0)}async render(e){this.cancelRender(),await new Promise(e=>{this.frame="hidden"===document.visibilityState?setTimeout(()=>e(),0):requestAnimationFrame(()=>e())}),await e(),delete this.frame}async renderPageSnapshot(e,t){await this.viewTransitioner.renderChange(this.view.shouldTransitionTo(e),async()=>{await this.view.renderPage(e,t,this.willRender,this),this.performScroll()})}cancelRender(){this.frame&&(cancelAnimationFrame(this.frame),delete this.frame)}}function $e(e){return e>=200&&e<300}class ze{progressBar=new Te;constructor(e){this.session=e}visitProposedToLocation(e,t){N(e,this.navigator.rootLocation)?this.navigator.startVisit(e,t?.restorationIdentifier||p(),t):window.location.href=e.toString()}visitStarted(e){this.location=e.location,this.redirectedToLocation=null,e.loadCachedSnapshot(),e.issueRequest(),e.goToSamePageAnchor()}visitRequestStarted(e){this.progressBar.setValue(0),e.hasCachedSnapshot()||"restore"!=e.action?this.showVisitProgressBarAfterDelay():this.showProgressBar()}visitRequestCompleted(e){e.loadResponse(),e.response.redirected&&(this.redirectedToLocation=e.redirectedToLocation)}visitRequestFailedWithStatusCode(e,t){switch(t){case De:case Ve:case We:return this.reload({reason:"request_failed",context:{statusCode:t}});default:return e.loadResponse()}}visitRequestFinished(e){}visitCompleted(e){this.progressBar.setValue(1),this.hideVisitProgressBar()}pageInvalidated(e){this.reload(e)}visitFailed(e){this.progressBar.setValue(1),this.hideVisitProgressBar()}visitRendered(e){}linkPrefetchingIsEnabledForLocation(e){return!0}formSubmissionStarted(e){this.progressBar.setValue(0),this.showFormProgressBarAfterDelay()}formSubmissionFinished(e){this.progressBar.setValue(1),this.hideFormProgressBar()}showVisitProgressBarAfterDelay(){this.visitProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay)}hideVisitProgressBar(){this.progressBar.hide(),null!=this.visitProgressBarTimeout&&(window.clearTimeout(this.visitProgressBarTimeout),delete this.visitProgressBarTimeout)}showFormProgressBarAfterDelay(){null==this.formProgressBarTimeout&&(this.formProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay))}hideFormProgressBar(){this.progressBar.hide(),null!=this.formProgressBarTimeout&&(window.clearTimeout(this.formProgressBarTimeout),delete this.formProgressBarTimeout)}showProgressBar=()=>{this.progressBar.show()};reload(e){a("turbo:reload",{detail:e}),window.location.href=(this.redirectedToLocation||this.location)?.toString()||window.location.href}get navigator(){return this.session.navigator}}class Ge{selector="[data-turbo-temporary]";deprecatedSelector="[data-turbo-cache=false]";started=!1;start(){this.started||(this.started=!0,addEventListener("turbo:before-cache",this.removeTemporaryElements,!1))}stop(){this.started&&(this.started=!1,removeEventListener("turbo:before-cache",this.removeTemporaryElements,!1))}removeTemporaryElements=e=>{for(const e of this.temporaryElements)e.remove()};get temporaryElements(){return[...document.querySelectorAll(this.selector),...this.temporaryElementsWithDeprecation]}get temporaryElementsWithDeprecation(){const e=document.querySelectorAll(this.deprecatedSelector);return e.length&&console.warn(`The ${this.deprecatedSelector} selector is deprecated and will be removed in a future version. Use ${this.selector} instead.`),[...e]}}class Qe{constructor(e,t){this.session=e,this.element=t,this.linkInterceptor=new de(this,t),this.formSubmitObserver=new ce(this,t)}start(){this.linkInterceptor.start(),this.formSubmitObserver.start()}stop(){this.linkInterceptor.stop(),this.formSubmitObserver.stop()}shouldInterceptLinkClick(e,t,r){return this.#u(e)}linkClickIntercepted(e,t,r){const s=this.#m(e);s&&s.delegate.linkClickIntercepted(e,t,r)}willSubmitForm(e,t){return null==e.closest("turbo-frame")&&this.#p(e,t)&&this.#u(e,t)}formSubmitted(e,t){const r=this.#m(e,t);r&&r.delegate.formSubmitted(e,t)}#p(e,t){const r=O(e,t),s=this.element.ownerDocument.querySelector('meta[name="turbo-root"]'),i=F(s?.content??"/");return this.#u(e,t)&&N(r,i)}#u(e,t){if(e instanceof HTMLFormElement?this.session.submissionIsNavigatable(e,t):this.session.elementIsNavigatable(e)){const r=this.#m(e,t);return!!r&&r!=e.closest("turbo-frame")}return!1}#m(e,t){const r=t?.getAttribute("data-turbo-frame")||e.getAttribute("data-turbo-frame");if(r&&"_top"!=r){const e=this.element.querySelector(`#${r}:not([disabled])`);if(e instanceof i)return e}}}class Xe{location;restorationIdentifier=p();restorationData={};started=!1;pageLoaded=!1;currentIndex=0;constructor(e){this.delegate=e}start(){this.started||(addEventListener("popstate",this.onPopState,!1),addEventListener("load",this.onPageLoad,!1),this.currentIndex=history.state?.turbo?.restorationIndex||0,this.started=!0,this.replace(new URL(window.location.href)))}stop(){this.started&&(removeEventListener("popstate",this.onPopState,!1),removeEventListener("load",this.onPageLoad,!1),this.started=!1)}push(e,t){this.update(history.pushState,e,t)}replace(e,t){this.update(history.replaceState,e,t)}update(e,t,r=p()){e===history.pushState&&++this.currentIndex;const s={turbo:{restorationIdentifier:r,restorationIndex:this.currentIndex}};e.call(history,s,"",t.href),this.location=t,this.restorationIdentifier=r}getRestorationDataForIdentifier(e){return this.restorationData[e]||{}}updateRestorationData(e){const{restorationIdentifier:t}=this,r=this.restorationData[t];this.restorationData[t]={...r,...e}}assumeControlOfScrollRestoration(){this.previousScrollRestoration||(this.previousScrollRestoration=history.scrollRestoration??"auto",history.scrollRestoration="manual")}relinquishControlOfScrollRestoration(){this.previousScrollRestoration&&(history.scrollRestoration=this.previousScrollRestoration,delete this.previousScrollRestoration)}onPopState=e=>{if(this.shouldHandlePopState()){const{turbo:t}=e.state||{};if(t){this.location=new URL(window.location.href);const{restorationIdentifier:e,restorationIndex:r}=t;this.restorationIdentifier=e;const s=r>this.currentIndex?"forward":"back";this.delegate.historyPoppedToLocationWithRestorationIdentifierAndDirection(this.location,e,s),this.currentIndex=r}}};onPageLoad=async e=>{await Promise.resolve(),this.pageLoaded=!0};shouldHandlePopState(){return this.pageIsLoaded()}pageIsLoaded(){return this.pageLoaded||"complete"==document.readyState}}class Ke{started=!1;#f=null;constructor(e,t){this.delegate=e,this.eventTarget=t}start(){this.started||("loading"===this.eventTarget.readyState?this.eventTarget.addEventListener("DOMContentLoaded",this.#g,{once:!0}):this.#g())}stop(){this.started&&(this.eventTarget.removeEventListener("mouseenter",this.#b,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("mouseleave",this.#v,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("turbo:before-fetch-request",this.#w,!0),this.started=!1)}#g=()=>{this.eventTarget.addEventListener("mouseenter",this.#b,{capture:!0,passive:!0}),this.eventTarget.addEventListener("mouseleave",this.#v,{capture:!0,passive:!0}),this.eventTarget.addEventListener("turbo:before-fetch-request",this.#w,!0),this.started=!0};#b=e=>{if("false"===E("turbo-prefetch"))return;const t=e.target;if(t.matches&&t.matches("a[href]:not([target^=_]):not([download])")&&this.#y(t)){const e=t,r=k(e);if(this.delegate.canPrefetchRequestToLocation(e,r)){this.#f=e;const s=new X(this,G.get,r,new URLSearchParams,t);s.fetchOptions.priority="low",re.setLater(r.toString(),s,this.#S)}}};#v=e=>{e.target===this.#f&&this.#E()};#E=()=>{re.clear(),this.#f=null};#w=e=>{if("FORM"!==e.target.tagName&&"GET"===e.detail.fetchOptions.method){const t=re.get(e.detail.url.toString());t&&(e.detail.fetchRequest=t),re.clear()}};prepareRequest(e){const t=e.target;e.headers["X-Sec-Purpose"]="prefetch";const r=t.closest("turbo-frame"),s=t.getAttribute("data-turbo-frame")||r?.getAttribute("target")||r?.id;s&&"_top"!==s&&(e.headers["Turbo-Frame"]=s)}requestSucceededWithResponse(){}requestStarted(e){}requestErrored(e){}requestFinished(e){}requestPreventedHandlingResponse(e,t){}requestFailedWithResponse(e,t){}get#S(){return Number(E("turbo-prefetch-cache-time"))||1e4}#y(e){return!!e.getAttribute("href")&&(!Ye(e)&&(!Je(e)&&(!Ze(e)&&(!et(e)&&!rt(e)))))}}const Ye=e=>e.origin!==document.location.origin||!["http:","https:"].includes(e.protocol)||e.hasAttribute("target"),Je=e=>e.pathname+e.search===document.location.pathname+document.location.search||e.href.startsWith("#"),Ze=e=>{if("false"===e.getAttribute("data-turbo-prefetch"))return!0;if("false"===e.getAttribute("data-turbo"))return!0;const t=T(e,"[data-turbo-prefetch]");return!(!t||"false"!==t.getAttribute("data-turbo-prefetch"))},et=e=>{const t=e.getAttribute("data-turbo-method");return!(!t||"get"===t.toLowerCase())||(!!tt(e)||(!!e.hasAttribute("data-turbo-confirm")||!!e.hasAttribute("data-turbo-stream")))},tt=e=>e.hasAttribute("data-remote")||e.hasAttribute("data-behavior")||e.hasAttribute("data-confirm")||e.hasAttribute("data-method"),rt=e=>a("turbo:before-prefetch",{target:e,cancelable:!0}).defaultPrevented;class st{constructor(e){this.delegate=e}proposeVisit(e,t={}){this.delegate.allowsVisitingLocationWithAction(e,t.action)&&this.delegate.visitProposedToLocation(e,t)}startVisit(e,t,r={}){this.stop(),this.currentVisit=new je(this,F(e),t,{referrer:this.location,...r}),this.currentVisit.start()}submitForm(e,t){this.stop(),this.formSubmission=new ie(this,e,t,!0),this.formSubmission.start()}stop(){this.formSubmission&&(this.formSubmission.stop(),delete this.formSubmission),this.currentVisit&&(this.currentVisit.cancel(),delete this.currentVisit)}get adapter(){return this.delegate.adapter}get view(){return this.delegate.view}get rootLocation(){return this.view.snapshot.rootLocation}get history(){return this.delegate.history}formSubmissionStarted(e){"function"==typeof this.adapter.formSubmissionStarted&&this.adapter.formSubmissionStarted(e)}async formSubmissionSucceededWithResponse(e,t){if(e==this.formSubmission){const r=await t.responseHTML;if(r){const s=e.isSafe;s||this.view.clearSnapshotCache();const{statusCode:i,redirected:n}=t,o={action:this.#L(e,t),shouldCacheSnapshot:s,response:{statusCode:i,responseHTML:r,redirected:n}};this.proposeVisit(t.location,o)}}}async formSubmissionFailedWithResponse(e,t){const r=await t.responseHTML;if(r){const e=Pe.fromHTMLString(r);t.serverError?await this.view.renderError(e,this.currentVisit):await this.view.renderPage(e,!1,!0,this.currentVisit),e.shouldPreserveScrollPosition||this.view.scrollToTop(),this.view.clearSnapshotCache()}}formSubmissionErrored(e,t){console.error(t)}formSubmissionFinished(e){"function"==typeof this.adapter.formSubmissionFinished&&this.adapter.formSubmissionFinished(e)}linkPrefetchingIsEnabledForLocation(e){return"function"!=typeof this.adapter.linkPrefetchingIsEnabledForLocation||this.adapter.linkPrefetchingIsEnabledForLocation(e)}visitStarted(e){this.delegate.visitStarted(e)}visitCompleted(e){this.delegate.visitCompleted(e),delete this.currentVisit}locationWithActionIsSamePage(e,t){const r=q(e),s=q(this.view.lastRenderedLocation),i="restore"===t&&void 0===r;return"replace"!==t&&B(e)===B(this.view.lastRenderedLocation)&&(i||null!=r&&r!==s)}visitScrolledToSamePageLocation(e,t){this.delegate.visitScrolledToSamePageLocation(e,t)}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}#L(e,t){const{submitter:r,formElement:s}=e;return y(r,s)||this.#T(t)}#T(e){return e.redirected&&e.location.href===this.location?.href?"replace":"advance"}}const it=0,nt=1,ot=2,at=3;class ct{stage=it;started=!1;constructor(e){this.delegate=e}start(){this.started||(this.stage==it&&(this.stage=nt),document.addEventListener("readystatechange",this.interpretReadyState,!1),addEventListener("pagehide",this.pageWillUnload,!1),this.started=!0)}stop(){this.started&&(document.removeEventListener("readystatechange",this.interpretReadyState,!1),removeEventListener("pagehide",this.pageWillUnload,!1),this.started=!1)}interpretReadyState=()=>{const{readyState:e}=this;"interactive"==e?this.pageIsInteractive():"complete"==e&&this.pageIsComplete()};pageIsInteractive(){this.stage==nt&&(this.stage=ot,this.delegate.pageBecameInteractive())}pageIsComplete(){this.pageIsInteractive(),this.stage==ot&&(this.stage=at,this.delegate.pageLoaded())}pageWillUnload=()=>{this.delegate.pageWillUnload()};get readyState(){return document.readyState}}class lt{started=!1;constructor(e){this.delegate=e}start(){this.started||(addEventListener("scroll",this.onScroll,!1),this.onScroll(),this.started=!0)}stop(){this.started&&(removeEventListener("scroll",this.onScroll,!1),this.started=!1)}onScroll=()=>{this.updatePosition({x:window.pageXOffset,y:window.pageYOffset})};updatePosition(e){this.delegate.scrollPositionChanged(e)}}class ht{render({fragment:e}){pe.preservingPermanentElements(this,function(e){const t=ae(document.documentElement),r={};for(const s of t){const{id:t}=s;for(const i of e.querySelectorAll("turbo-stream")){const e=oe(i.templateElement.content,t);e&&(r[t]=[s,e])}}return r}(e),()=>{!async function(e,t){const r=`turbo-stream-autofocus-${p()}`,s=e.querySelectorAll("turbo-stream"),i=function(e){for(const t of e){const e=A(t.templateElement.content);if(e)return e}return null}(s);let n=null;i&&(n=i.id?i.id:r,i.id=n);t(),await l();if((null==document.activeElement||document.activeElement==document.body)&&n){const e=document.getElementById(n);R(e)&&e.focus(),e&&e.id==r&&e.removeAttribute("id")}}(e,()=>{!async function(e){const[t,r]=await async function(e,t){const r=t();return e(),await h(),[r,t()]}(e,()=>document.activeElement),s=t&&t.id;if(s){const e=document.getElementById(s);R(e)&&e!=r&&e.focus()}}(()=>{document.documentElement.appendChild(e)})})})}enteringBardo(e,t){t.replaceWith(e.cloneNode(!0))}leavingBardo(){}}class dt{sources=new Set;#R=!1;constructor(e){this.delegate=e}start(){this.#R||(this.#R=!0,addEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}stop(){this.#R&&(this.#R=!1,removeEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}connectStreamSource(e){this.streamSourceIsConnected(e)||(this.sources.add(e),e.addEventListener("message",this.receiveMessageEvent,!1))}disconnectStreamSource(e){this.streamSourceIsConnected(e)&&(this.sources.delete(e),e.removeEventListener("message",this.receiveMessageEvent,!1))}streamSourceIsConnected(e){return this.sources.has(e)}inspectFetchResponse=e=>{const t=function(e){const t=e.detail?.fetchResponse;if(t instanceof W)return t}(e);t&&function(e){const t=e.contentType??"";return t.startsWith(te.contentType)}(t)&&(e.preventDefault(),this.receiveMessageResponse(t))};receiveMessageEvent=e=>{this.#R&&"string"==typeof e.data&&this.receiveMessageHTML(e.data)};async receiveMessageResponse(e){const t=await e.responseHTML;t&&this.receiveMessageHTML(t)}receiveMessageHTML(e){this.delegate.receivedMessageFromStream(te.wrap(e))}}class ut extends fe{static renderElement(e,t){const{documentElement:r,body:s}=document;r.replaceChild(t,s)}async render(){this.replaceHeadAndBody(),this.activateScriptElements()}replaceHeadAndBody(){const{documentElement:e,head:t}=document;e.replaceChild(this.newHead,t),this.renderElement(this.currentElement,this.newElement)}activateScriptElements(){for(const e of this.scriptElements){const t=e.parentNode;if(t){const r=o(e);t.replaceChild(r,e)}}}get newHead(){return this.newSnapshot.headSnapshot.element}get scriptElements(){return document.documentElement.querySelectorAll("script")}}class mt extends fe{static renderElement(e,t){document.body&&t instanceof HTMLBodyElement?document.body.replaceWith(t):document.documentElement.appendChild(t)}get shouldRender(){return this.newSnapshot.isVisitable&&this.trackedElementsAreIdentical}get reloadReason(){return this.newSnapshot.isVisitable?this.trackedElementsAreIdentical?void 0:{reason:"tracked_element_mismatch"}:{reason:"turbo_visit_control_is_reload"}}async prepareToRender(){this.#A(),await this.mergeHead()}async render(){this.willRender&&await this.replaceBody()}finishRendering(){super.finishRendering(),this.isPreview||this.focusFirstAutofocusableElement()}get currentHeadSnapshot(){return this.currentSnapshot.headSnapshot}get newHeadSnapshot(){return this.newSnapshot.headSnapshot}get newElement(){return this.newSnapshot.element}#A(){const{documentElement:e}=this.currentSnapshot,{lang:t}=this.newSnapshot;t?e.setAttribute("lang",t):e.removeAttribute("lang")}async mergeHead(){const e=this.mergeProvisionalElements(),t=this.copyNewHeadStylesheetElements();this.copyNewHeadScriptElements(),await e,await t,this.willRender&&this.removeUnusedDynamicStylesheetElements()}async replaceBody(){await this.preservingPermanentElements(async()=>{this.activateNewBody(),await this.assignNewBody()})}get trackedElementsAreIdentical(){return this.currentHeadSnapshot.trackedElementSignature==this.newHeadSnapshot.trackedElementSignature}async copyNewHeadStylesheetElements(){const e=[];for(const t of this.newHeadStylesheetElements)e.push(v(t)),document.head.appendChild(t);await Promise.all(e)}copyNewHeadScriptElements(){for(const e of this.newHeadScriptElements)document.head.appendChild(o(e))}removeUnusedDynamicStylesheetElements(){for(const e of this.unusedDynamicStylesheetElements)document.head.removeChild(e)}async mergeProvisionalElements(){const e=[...this.newHeadProvisionalElements];for(const t of this.currentHeadProvisionalElements)this.isCurrentElementInElementList(t,e)||document.head.removeChild(t);for(const t of e)document.head.appendChild(t)}isCurrentElementInElementList(e,t){for(const[r,s]of t.entries()){if("TITLE"==e.tagName){if("TITLE"!=s.tagName)continue;if(e.innerHTML==s.innerHTML)return t.splice(r,1),!0}if(s.isEqualNode(e))return t.splice(r,1),!0}return!1}removeCurrentHeadProvisionalElements(){for(const e of this.currentHeadProvisionalElements)document.head.removeChild(e)}copyNewHeadProvisionalElements(){for(const e of this.newHeadProvisionalElements)document.head.appendChild(e)}activateNewBody(){document.adoptNode(this.newElement),this.activateNewBodyScriptElements()}activateNewBodyScriptElements(){for(const e of this.newBodyScriptElements){const t=o(e);e.replaceWith(t)}}async assignNewBody(){await this.renderElement(this.currentElement,this.newElement)}get unusedDynamicStylesheetElements(){return this.oldHeadStylesheetElements.filter(e=>"dynamic"===e.getAttribute("data-turbo-track"))}get oldHeadStylesheetElements(){return this.currentHeadSnapshot.getStylesheetElementsNotInSnapshot(this.newHeadSnapshot)}get newHeadStylesheetElements(){return this.newHeadSnapshot.getStylesheetElementsNotInSnapshot(this.currentHeadSnapshot)}get newHeadScriptElements(){return this.newHeadSnapshot.getScriptElementsNotInSnapshot(this.currentHeadSnapshot)}get currentHeadProvisionalElements(){return this.currentHeadSnapshot.provisionalElements}get newHeadProvisionalElements(){return this.newHeadSnapshot.provisionalElements}get newBodyScriptElements(){return this.newElement.querySelectorAll("script")}}class pt extends mt{static renderElement(e,t){ve(e,t,{callbacks:{beforeNodeMorphed:(e,t)=>!(ye(e,t)&&!Se(e))||(e.reload(),!1)}}),a("turbo:morph",{detail:{currentElement:e,newElement:t}})}async preservingPermanentElements(e){return await e()}get renderMethod(){return"morph"}get shouldAutofocus(){return!1}}class ft{keys=[];snapshots={};constructor(e){this.size=e}has(e){return x(e)in this.snapshots}get(e){if(this.has(e)){const t=this.read(e);return this.touch(e),t}}put(e,t){return this.write(e,t),this.touch(e),t}clear(){this.snapshots={}}read(e){return this.snapshots[x(e)]}write(e,t){this.snapshots[x(e)]=t}touch(e){const t=x(e),r=this.keys.indexOf(t);r>-1&&this.keys.splice(r,1),this.keys.unshift(t),this.trim()}trim(){for(const e of this.keys.splice(this.size))delete this.snapshots[e]}}class gt extends le{snapshotCache=new ft(10);lastRenderedLocation=new URL(location.href);forceReloaded=!1;shouldTransitionTo(e){return this.snapshot.prefersViewTransitions&&e.prefersViewTransitions}renderPage(e,t=!1,r=!0,s){const i=new(this.isPageRefresh(s)&&this.snapshot.shouldMorphPage?pt:mt)(this.snapshot,e,t,r);return i.shouldRender?s?.changeHistory():this.forceReloaded=!0,this.render(i)}renderError(e,t){t?.changeHistory();const r=new ut(this.snapshot,e,!1);return this.render(r)}clearSnapshotCache(){this.snapshotCache.clear()}async cacheSnapshot(e=this.snapshot){if(e.isCacheable){this.delegate.viewWillCacheSnapshot();const{lastRenderedLocation:t}=this;await d();const r=e.clone();return this.snapshotCache.put(t,r),r}}getCachedSnapshotForLocation(e){return this.snapshotCache.get(e)}isPageRefresh(e){return!e||this.lastRenderedLocation.pathname===e.location.pathname&&"replace"===e.action}shouldPreserveScrollPosition(e){return this.isPageRefresh(e)&&this.snapshot.shouldPreserveScrollPosition}get snapshot(){return Pe.fromElement(this.element)}}class bt{selector="a[data-turbo-preload]";constructor(e,t){this.delegate=e,this.snapshotCache=t}start(){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",this.#C):this.preloadOnLoadLinksForView(document.body)}stop(){document.removeEventListener("DOMContentLoaded",this.#C)}preloadOnLoadLinksForView(e){for(const t of e.querySelectorAll(this.selector))this.delegate.shouldPreloadLink(t)&&this.preloadURL(t)}async preloadURL(e){const t=new URL(e.href);if(this.snapshotCache.has(t))return;const r=new X(this,G.get,t,new URLSearchParams,e);await r.perform()}prepareRequest(e){e.headers["X-Sec-Purpose"]="prefetch"}async requestSucceededWithResponse(e,t){try{const r=await t.responseHTML,s=Pe.fromHTMLString(r);this.snapshotCache.put(e.url,s)}catch(e){}}requestStarted(e){}requestErrored(e){}requestFinished(e){}requestPreventedHandlingResponse(e,t){}requestFailedWithResponse(e,t){}#C=()=>{this.preloadOnLoadLinksForView(document.body)}}class vt{constructor(e){this.session=e}clear(){this.session.clearCache()}resetCacheControl(){this.#P("")}exemptPageFromCache(){this.#P("no-cache")}exemptPageFromPreview(){this.#P("no-preview")}#P(e){!function(e,t){let r=S(e);r||(r=document.createElement("meta"),r.setAttribute("name",e),document.head.appendChild(r)),r.setAttribute("content",t)}("turbo-cache-control",e)}}function wt(e){Object.defineProperties(e,yt)}const yt={absoluteURL:{get(){return this.toString()}}},St=new class{navigator=new st(this);history=new Xe(this);view=new gt(this,document.documentElement);adapter=new ze(this);pageObserver=new ct(this);cacheObserver=new Ge;linkPrefetchObserver=new Ke(this,document);linkClickObserver=new ue(this,window);formSubmitObserver=new ce(this,document);scrollObserver=new lt(this);streamObserver=new dt(this);formLinkClickObserver=new me(this,document.documentElement);frameRedirector=new Qe(this,document.documentElement);streamMessageRenderer=new ht;cache=new vt(this);enabled=!0;started=!1;#k=150;constructor(e){this.recentRequests=e,this.preloader=new bt(this,this.view.snapshotCache),this.debouncedRefresh=this.refresh,this.pageRefreshDebouncePeriod=this.pageRefreshDebouncePeriod}start(){this.started||(this.pageObserver.start(),this.cacheObserver.start(),this.linkPrefetchObserver.start(),this.formLinkClickObserver.start(),this.linkClickObserver.start(),this.formSubmitObserver.start(),this.scrollObserver.start(),this.streamObserver.start(),this.frameRedirector.start(),this.history.start(),this.preloader.start(),this.started=!0,this.enabled=!0)}disable(){this.enabled=!1}stop(){this.started&&(this.pageObserver.stop(),this.cacheObserver.stop(),this.linkPrefetchObserver.stop(),this.formLinkClickObserver.stop(),this.linkClickObserver.stop(),this.formSubmitObserver.stop(),this.scrollObserver.stop(),this.streamObserver.stop(),this.frameRedirector.stop(),this.history.stop(),this.preloader.stop(),this.started=!1)}registerAdapter(e){this.adapter=e}visit(e,t={}){const r=t.frame?document.getElementById(t.frame):null;if(r instanceof i){const s=t.action||y(r);r.delegate.proposeVisitIfNavigatedWithAction(r,s),r.src=e.toString()}else this.navigator.proposeVisit(F(e),t)}refresh(e,t){const r=t&&this.recentRequests.has(t),s=e===document.baseURI;r||this.navigator.currentVisit||!s||this.visit(e,{action:"replace",shouldCacheSnapshot:!1})}connectStreamSource(e){this.streamObserver.connectStreamSource(e)}disconnectStreamSource(e){this.streamObserver.disconnectStreamSource(e)}renderStreamMessage(e){this.streamMessageRenderer.render(te.wrap(e))}clearCache(){this.view.clearSnapshotCache()}setProgressBarDelay(e){console.warn("Please replace `session.setProgressBarDelay(delay)` with `session.progressBarDelay = delay`. The function is deprecated and will be removed in a future version of Turbo.`"),this.progressBarDelay=e}set progressBarDelay(e){_.drive.progressBarDelay=e}get progressBarDelay(){return _.drive.progressBarDelay}set drive(e){_.drive.enabled=e}get drive(){return _.drive.enabled}set formMode(e){_.forms.mode=e}get formMode(){return _.forms.mode}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}get pageRefreshDebouncePeriod(){return this.#k}set pageRefreshDebouncePeriod(e){this.refresh=function(e,t){let r=null;return(...s)=>{clearTimeout(r),r=setTimeout(()=>e.apply(this,s),t)}}(this.debouncedRefresh.bind(this),e),this.#k=e}shouldPreloadLink(e){const t=e.hasAttribute("data-turbo-method"),r=e.hasAttribute("data-turbo-stream"),s=e.getAttribute("data-turbo-frame"),n="_top"==s?null:document.getElementById(s)||T(e,"turbo-frame:not([disabled])");if(t||r||n instanceof i)return!1;{const t=new URL(e.href);return this.elementIsNavigatable(e)&&N(t,this.snapshot.rootLocation)}}historyPoppedToLocationWithRestorationIdentifierAndDirection(e,t,r){this.enabled?this.navigator.startVisit(e,t,{action:"restore",historyChanged:!0,direction:r}):this.adapter.pageInvalidated({reason:"turbo_disabled"})}scrollPositionChanged(e){this.history.updateRestorationData({scrollPosition:e})}willSubmitFormLinkToLocation(e,t){return this.elementIsNavigatable(e)&&N(t,this.snapshot.rootLocation)}submittedFormLinkToLocation(){}canPrefetchRequestToLocation(e,t){return this.elementIsNavigatable(e)&&N(t,this.snapshot.rootLocation)&&this.navigator.linkPrefetchingIsEnabledForLocation(t)}willFollowLinkToLocation(e,t,r){return this.elementIsNavigatable(e)&&N(t,this.snapshot.rootLocation)&&this.applicationAllowsFollowingLinkToLocation(e,t,r)}followedLinkToLocation(e,t){const r=this.getActionForLink(e),s=e.hasAttribute("data-turbo-stream");this.visit(t.href,{action:r,acceptsStreamResponse:s})}allowsVisitingLocationWithAction(e,t){return this.locationWithActionIsSamePage(e,t)||this.applicationAllowsVisitingLocation(e)}visitProposedToLocation(e,t){wt(e),this.adapter.visitProposedToLocation(e,t)}visitStarted(e){e.acceptsStreamResponse||(g(document.documentElement),this.view.markVisitDirection(e.direction)),wt(e.location),e.silent||this.notifyApplicationAfterVisitingLocation(e.location,e.action)}visitCompleted(e){this.view.unmarkVisitDirection(),b(document.documentElement),this.notifyApplicationAfterPageLoad(e.getTimingMetrics())}locationWithActionIsSamePage(e,t){return this.navigator.locationWithActionIsSamePage(e,t)}visitScrolledToSamePageLocation(e,t){this.notifyApplicationAfterVisitingSamePageLocation(e,t)}willSubmitForm(e,t){const r=O(e,t);return this.submissionIsNavigatable(e,t)&&N(F(r),this.snapshot.rootLocation)}formSubmitted(e,t){this.navigator.submitForm(e,t)}pageBecameInteractive(){this.view.lastRenderedLocation=this.location,this.notifyApplicationAfterPageLoad()}pageLoaded(){this.history.assumeControlOfScrollRestoration()}pageWillUnload(){this.history.relinquishControlOfScrollRestoration()}receivedMessageFromStream(e){this.renderStreamMessage(e)}viewWillCacheSnapshot(){this.navigator.currentVisit?.silent||this.notifyApplicationBeforeCachingSnapshot()}allowsImmediateRender({element:e},t){const r=this.notifyApplicationBeforeRender(e,t),{defaultPrevented:s,detail:{render:i}}=r;return this.view.renderer&&i&&(this.view.renderer.renderElement=i),!s}viewRenderedSnapshot(e,t,r){this.view.lastRenderedLocation=this.history.location,this.notifyApplicationAfterRender(r)}preloadOnLoadLinksForView(e){this.preloader.preloadOnLoadLinksForView(e)}viewInvalidated(e){this.adapter.pageInvalidated(e)}frameLoaded(e){this.notifyApplicationAfterFrameLoad(e)}frameRendered(e,t){this.notifyApplicationAfterFrameRender(e,t)}applicationAllowsFollowingLinkToLocation(e,t,r){return!this.notifyApplicationAfterClickingLinkToLocation(e,t,r).defaultPrevented}applicationAllowsVisitingLocation(e){return!this.notifyApplicationBeforeVisitingLocation(e).defaultPrevented}notifyApplicationAfterClickingLinkToLocation(e,t,r){return a("turbo:click",{target:e,detail:{url:t.href,originalEvent:r},cancelable:!0})}notifyApplicationBeforeVisitingLocation(e){return a("turbo:before-visit",{detail:{url:e.href},cancelable:!0})}notifyApplicationAfterVisitingLocation(e,t){return a("turbo:visit",{detail:{url:e.href,action:t}})}notifyApplicationBeforeCachingSnapshot(){return a("turbo:before-cache")}notifyApplicationBeforeRender(e,t){return a("turbo:before-render",{detail:{newBody:e,...t},cancelable:!0})}notifyApplicationAfterRender(e){return a("turbo:render",{detail:{renderMethod:e}})}notifyApplicationAfterPageLoad(e={}){return a("turbo:load",{detail:{url:this.location.href,timing:e}})}notifyApplicationAfterVisitingSamePageLocation(e,t){dispatchEvent(new HashChangeEvent("hashchange",{oldURL:e.toString(),newURL:t.toString()}))}notifyApplicationAfterFrameLoad(e){return a("turbo:frame-load",{target:e})}notifyApplicationAfterFrameRender(e,t){return a("turbo:frame-render",{detail:{fetchResponse:e},target:t,cancelable:!0})}submissionIsNavigatable(e,t){if("off"==_.forms.mode)return!1;{const r=!t||this.elementIsNavigatable(t);return"optin"==_.forms.mode?r&&null!=e.closest('[data-turbo="true"]'):r&&this.elementIsNavigatable(e)}}elementIsNavigatable(e){const t=T(e,"[data-turbo]"),r=T(e,"turbo-frame");return _.drive.enabled||r?!t||"false"!=t.getAttribute("data-turbo"):!!t&&"true"==t.getAttribute("data-turbo")}getActionForLink(e){return y(e)||"advance"}get snapshot(){return this.view.snapshot}}(j),{cache:Et,navigator:Lt}=St;function Tt(){St.start()}function Rt(e){St.connectStreamSource(e)}function At(e){St.disconnectStreamSource(e)}var Ct=Object.freeze({__proto__:null,navigator:Lt,session:St,cache:Et,PageRenderer:mt,PageSnapshot:Pe,FrameRenderer:ge,fetch:$,config:_,start:Tt,registerAdapter:function(e){St.registerAdapter(e)},visit:function(e,t){St.visit(e,t)},connectStreamSource:Rt,disconnectStreamSource:At,renderStreamMessage:function(e){St.renderStreamMessage(e)},clearCache:function(){console.warn("Please replace `Turbo.clearCache()` with `Turbo.cache.clear()`. The top-level function is deprecated and will be removed in a future version of Turbo.`"),St.clearCache()},setProgressBarDelay:function(e){console.warn("Please replace `Turbo.setProgressBarDelay(delay)` with `Turbo.config.drive.progressBarDelay = delay`. The top-level function is deprecated and will be removed in a future version of Turbo.`"),_.drive.progressBarDelay=e},setConfirmMethod:function(e){console.warn("Please replace `Turbo.setConfirmMethod(confirmMethod)` with `Turbo.config.forms.confirm = confirmMethod`. The top-level function is deprecated and will be removed in a future version of Turbo.`"),_.forms.confirm=e},setFormMode:function(e){console.warn("Please replace `Turbo.setFormMode(mode)` with `Turbo.config.forms.mode = mode`. The top-level function is deprecated and will be removed in a future version of Turbo.`"),_.forms.mode=e},morphBodyElements:function(e,t){pt.renderElement(e,t)},morphTurboFrameElements:function(e,t){Le.renderElement(e,t)},morphChildren:we,morphElements:ve});class Pt extends Error{}function kt(e){if(null!=e){const t=document.getElementById(e);if(t instanceof i)return t}}function Mt(e,t){if(e){const r=e.getAttribute("src");if(null!=r&&null!=t&&D(r,t))throw new Error(`Matching element has a source URL which references itself`);if(e.ownerDocument!==document&&(e=document.importNode(e,!0)),e instanceof i)return e.connectedCallback(),e.disconnectedCallback(),e}}const It={after(){this.targetElements.forEach(e=>e.parentElement?.insertBefore(this.templateContent,e.nextSibling))},append(){this.removeDuplicateTargetChildren(),this.targetElements.forEach(e=>e.append(this.templateContent))},before(){this.targetElements.forEach(e=>e.parentElement?.insertBefore(this.templateContent,e))},prepend(){this.removeDuplicateTargetChildren(),this.targetElements.forEach(e=>e.prepend(this.templateContent))},remove(){this.targetElements.forEach(e=>e.remove())},replace(){const e=this.getAttribute("method");this.targetElements.forEach(t=>{"morph"===e?ve(t,this.templateContent):t.replaceWith(this.templateContent)})},update(){const e=this.getAttribute("method");this.targetElements.forEach(t=>{"morph"===e?we(t,this.templateContent):(t.innerHTML="",t.append(this.templateContent))})},refresh(){St.refresh(this.baseURI,this.requestId)}};class _t extends HTMLElement{static async renderElement(e){await e.performAction()}async connectedCallback(){try{await this.render()}catch(e){console.error(e)}finally{this.disconnect()}}async render(){return this.renderPromise??=(async()=>{const e=this.beforeRenderEvent;this.dispatchEvent(e)&&(await l(),await e.detail.render(this))})()}disconnect(){try{this.remove()}catch{}}removeDuplicateTargetChildren(){this.duplicateChildren.forEach(e=>e.remove())}get duplicateChildren(){const e=this.targetElements.flatMap(e=>[...e.children]).filter(e=>!!e.getAttribute("id")),t=[...this.templateContent?.children||[]].filter(e=>!!e.getAttribute("id")).map(e=>e.getAttribute("id"));return e.filter(e=>t.includes(e.getAttribute("id")))}get performAction(){if(this.action){const e=It[this.action];if(e)return e;this.#M("unknown action")}this.#M("action attribute is missing")}get targetElements(){return this.target?this.targetElementsById:this.targets?this.targetElementsByQuery:void this.#M("target or targets attribute is missing")}get templateContent(){return this.templateElement.content.cloneNode(!0)}get templateElement(){if(null===this.firstElementChild){const e=this.ownerDocument.createElement("template");return this.appendChild(e),e}if(this.firstElementChild instanceof HTMLTemplateElement)return this.firstElementChild;this.#M("first child element must be a