From 509dbb6e1241ffc49db149421ae41f018d880719 Mon Sep 17 00:00:00 2001 From: Alexandr Chernyaev Date: Sun, 18 Aug 2024 03:24:24 +0300 Subject: [PATCH] refs #2877 Fixed validation issue with required attribute in SimpleMDE --- public/js/orchid.js | 2 +- public/js/orchid.js.map | 2 +- public/mix-manifest.json | 2 +- .../js/controllers/simplemde_controller.js | 51 ++++++++----------- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/public/js/orchid.js b/public/js/orchid.js index 863e55aff..f72bafa81 100644 --- a/public/js/orchid.js +++ b/public/js/orchid.js @@ -13,4 +13,4 @@ opacity ${pt.animationDuration/2}ms ${pt.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(t){this.value=t,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(t){this.progressElement.style.opacity="0",setTimeout(t,1.5*pt.animationDuration)}uninstallProgressElement(){this.progressElement.parentNode&&document.documentElement.removeChild(this.progressElement)}startTrickling(){this.trickleInterval||(this.trickleInterval=window.setInterval(this.trickle,pt.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 t=document.createElement("style");return t.type="text/css",t.textContent=pt.defaultCSS,this.cspNonce&&(t.nonce=this.cspNonce),t}createProgressElement(){const t=document.createElement("div");return t.className="turbo-progress-bar",t}get cspNonce(){return L("csp-nonce")}}class mt extends rt{detailsByOuterHTML=this.children.filter((t=>!function(t){const e=t.localName;return"noscript"==e}(t))).map((t=>function(t){t.hasAttribute("nonce")&&t.setAttribute("nonce","");return t}(t))).reduce(((t,e)=>{const{outerHTML:r}=e,n=r in t?t[r]:{type:yt(e),tracked:bt(e),elements:[]};return{...t,[r]:{...n,elements:[...n.elements,e]}}}),{});get trackedElementSignature(){return Object.keys(this.detailsByOuterHTML).filter((t=>this.detailsByOuterHTML[t].tracked)).join("")}getScriptElementsNotInSnapshot(t){return this.getElementsMatchingTypeNotInSnapshot("script",t)}getStylesheetElementsNotInSnapshot(t){return this.getElementsMatchingTypeNotInSnapshot("stylesheet",t)}getElementsMatchingTypeNotInSnapshot(t,e){return Object.keys(this.detailsByOuterHTML).filter((t=>!(t in e.detailsByOuterHTML))).map((t=>this.detailsByOuterHTML[t])).filter((({type:e})=>e==t)).map((({elements:[t]})=>t))}get provisionalElements(){return Object.keys(this.detailsByOuterHTML).reduce(((t,e)=>{const{type:r,tracked:n,elements:o}=this.detailsByOuterHTML[e];return null!=r||n?o.length>1?[...t,...o.slice(1)]:t:[...t,...o]}),[])}getMetaValue(t){const e=this.findMetaElementByName(t);return e?e.getAttribute("content"):null}findMetaElementByName(t){return Object.keys(this.detailsByOuterHTML).reduce(((e,r)=>{const{elements:[n]}=this.detailsByOuterHTML[r];return function(t,e){const r=t.localName;return"meta"==r&&t.getAttribute("name")==e}(n,t)?n:e}),0)}}function yt(t){return function(t){const e=t.localName;return"script"==e}(t)?"script":function(t){const e=t.localName;return"style"==e||"link"==e&&"stylesheet"==t.getAttribute("rel")}(t)?"stylesheet":void 0}function bt(t){return"reload"==t.getAttribute("data-turbo-track")}class gt extends rt{static fromHTMLString(t=""){return this.fromDocument(A(t))}static fromElement(t){return this.fromDocument(t.ownerDocument)}static fromDocument({documentElement:t,body:e,head:r}){return new this(t,e,new mt(r))}constructor(t,e,r){super(e),this.documentElement=t,this.headSnapshot=r}clone(){const t=this.element.cloneNode(!0),e=this.element.querySelectorAll("select"),r=t.querySelectorAll("select");for(const[t,n]of e.entries()){const e=r[t];for(const t of e.selectedOptions)t.selected=!1;for(const t of n.selectedOptions)e.options[t.index].selected=!0}for(const e of t.querySelectorAll('input[type="password"]'))e.value="";return new gt(this.documentElement,t,this.headSnapshot)}get lang(){return this.documentElement.getAttribute("lang")}get headElement(){return this.headSnapshot.element}get rootLocation(){return a(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"same-origin"===this.headSnapshot.getMetaValue("view-transition")}get shouldMorphPage(){return"morph"===this.getSetting("refresh-method")}get shouldPreserveScrollPosition(){return"preserve"===this.getSetting("refresh-scroll")}getSetting(t){return this.headSnapshot.getMetaValue(`turbo-${t}`)}}class vt{#c=!1;#u=Promise.resolve();renderChange(t,e){return t&&this.viewTransitionsAvailable&&!this.#c?(this.#c=!0,this.#u=this.#u.then((async()=>{await document.startViewTransition(e).finished}))):this.#u=this.#u.then(e),this.#u}get viewTransitionsAvailable(){return document.startViewTransition}}const wt={action:"advance",historyChanged:!1,visitCachedSnapshot:()=>{},willRender:!0,updateHistory:!0,shouldCacheSnapshot:!0,acceptsStreamResponse:!1},At="visitStart",Ot="requestStart",St="requestEnd",Et="visitEnd",jt="initialized",Pt="started",Tt="canceled",_t="failed",kt="completed",xt=0,Lt=-1,Rt=-2,Nt={advance:"forward",restore:"back",replace:"none"};class Ct{identifier=S();timingMetrics={};followedRedirect=!1;historyChanged=!1;scrolled=!1;shouldCacheSnapshot=!0;acceptsStreamResponse=!1;snapshotCached=!1;state=jt;viewTransitioner=new vt;constructor(t,e,r,n={}){this.delegate=t,this.location=e,this.restorationIdentifier=r||S();const{action:o,historyChanged:i,referrer:s,snapshot:a,snapshotHTML:c,response:u,visitCachedSnapshot:l,willRender:f,updateHistory:h,shouldCacheSnapshot:d,acceptsStreamResponse:p,direction:m}={...wt,...n};this.action=o,this.historyChanged=i,this.referrer=s,this.snapshot=a,this.snapshotHTML=c,this.response=u,this.isSamePage=this.delegate.locationWithActionIsSamePage(this.location,this.action),this.isPageRefresh=this.view.isPageRefresh(this),this.visitCachedSnapshot=l,this.willRender=f,this.updateHistory=h,this.scrolled=!f,this.shouldCacheSnapshot=d,this.acceptsStreamResponse=p,this.direction=m||Nt[o]}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==jt&&(this.recordTimingMetric(At),this.state=Pt,this.adapter.visitStarted(this),this.delegate.visitStarted(this))}cancel(){this.state==Pt&&(this.request&&this.request.cancel(),this.cancelRender(),this.state=Tt)}complete(){this.state==Pt&&(this.recordTimingMetric(Et),this.adapter.visitCompleted(this),this.state=kt,this.followRedirect(),this.followedRedirect||this.delegate.visitCompleted(this))}fail(){this.state==Pt&&(this.state=_t,this.adapter.visitFailed(this),this.delegate.visitCompleted(this))}changeHistory(){if(!this.historyChanged&&this.updateHistory){const t=_(this.location.href===this.referrer?.href?"replace":this.action);this.history.update(t,this.location,this.restorationIdentifier),this.historyChanged=!0}}issueRequest(){this.hasPreloadedResponse()?this.simulateRequest():this.shouldIssueRequest()&&!this.request&&(this.request=new $(this,H.get,this.location),this.request.perform())}simulateRequest(){this.response&&(this.startRequest(),this.recordResponse(),this.finishRequest())}startRequest(){this.recordTimingMetric(Ot),this.adapter.visitRequestStarted(this)}recordResponse(t=this.response){if(this.response=t,t){const{statusCode:e}=t;Mt(e)?this.adapter.visitRequestCompleted(this):this.adapter.visitRequestFailedWithStatusCode(this,e)}}finishRequest(){this.recordTimingMetric(St),this.adapter.visitRequestFinished(this)}loadResponse(){if(this.response){const{statusCode:t,responseHTML:e}=this.response;this.render((async()=>{if(this.shouldCacheSnapshot&&this.cacheSnapshot(),this.view.renderPromise&&await this.view.renderPromise,Mt(t)&&null!=e){const t=gt.fromHTMLString(e);await this.renderPageSnapshot(t,!1),this.adapter.visitRendered(this),this.complete()}else await this.view.renderError(gt.fromHTMLString(e),this),this.adapter.visitRendered(this),this.fail()}))}}getCachedSnapshot(){const t=this.view.getCachedSnapshotForLocation(this.location)||this.getPreloadedSnapshot();if(t&&(!c(this.location)||t.hasAnchor(c(this.location)))&&("restore"==this.action||t.isPreviewable))return t}getPreloadedSnapshot(){if(this.snapshotHTML)return gt.fromHTMLString(this.snapshotHTML)}hasCachedSnapshot(){return null!=this.getCachedSnapshot()}loadCachedSnapshot(){const t=this.getCachedSnapshot();if(t){const e=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(t,e),this.adapter.visitRendered(this),e||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(t){this.acceptsStreamResponse&&t.acceptResponseType(Z.contentType)}requestStarted(){this.startRequest()}requestPreventedHandlingResponse(t,e){}async requestSucceededWithResponse(t,e){const r=await e.responseHTML,{redirected:n,statusCode:o}=e;null==r?this.recordResponse({statusCode:Rt,redirected:n}):(this.redirectedToLocation=e.redirected?e.location:void 0,this.recordResponse({statusCode:o,responseHTML:r,redirected:n}))}async requestFailedWithResponse(t,e){const r=await e.responseHTML,{redirected:n,statusCode:o}=e;null==r?this.recordResponse({statusCode:Rt,redirected:n}):this.recordResponse({statusCode:o,responseHTML:r,redirected:n})}requestErrored(t,e){this.recordResponse({statusCode:xt,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:t}=this.restorationData;if(t)return this.view.scrollToPosition(t),!0}scrollToAnchor(){const t=c(this.location);if(null!=t)return this.view.scrollToAnchor(t),!0}recordTimingMetric(t){this.timingMetrics[t]=(new Date).getTime()}getTimingMetrics(){return{...this.timingMetrics}}getHistoryMethodForAction(t){switch(t){case"replace":return history.replaceState;case"advance":case"restore":return history.pushState}}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((t=>t&&this.visitCachedSnapshot(t))),this.snapshotCached=!0)}async render(t){this.cancelRender(),this.frame=await g(),await t(),delete this.frame}async renderPageSnapshot(t,e){await this.viewTransitioner.renderChange(this.view.shouldTransitionTo(t),(async()=>{await this.view.renderPage(t,e,this.willRender,this),this.performScroll()}))}cancelRender(){this.frame&&(cancelAnimationFrame(this.frame),delete this.frame)}}function Mt(t){return t>=200&&t<300}class Bt{progressBar=new pt;constructor(t){this.session=t}visitProposedToLocation(t,e){h(t,this.navigator.rootLocation)?this.navigator.startVisit(t,e?.restorationIdentifier||S(),e):window.location.href=t.toString()}visitStarted(t){this.location=t.location,t.loadCachedSnapshot(),t.issueRequest(),t.goToSamePageAnchor()}visitRequestStarted(t){this.progressBar.setValue(0),t.hasCachedSnapshot()||"restore"!=t.action?this.showVisitProgressBarAfterDelay():this.showProgressBar()}visitRequestCompleted(t){t.loadResponse()}visitRequestFailedWithStatusCode(t,e){switch(e){case xt:case Lt:case Rt:return this.reload({reason:"request_failed",context:{statusCode:e}});default:return t.loadResponse()}}visitRequestFinished(t){}visitCompleted(t){this.progressBar.setValue(1),this.hideVisitProgressBar()}pageInvalidated(t){this.reload(t)}visitFailed(t){this.progressBar.setValue(1),this.hideVisitProgressBar()}visitRendered(t){}formSubmissionStarted(t){this.progressBar.setValue(0),this.showFormProgressBarAfterDelay()}formSubmissionFinished(t){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(t){b("turbo:reload",{detail:t}),window.location.href=this.location?.toString()||window.location.href}get navigator(){return this.session.navigator}}class It{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=t=>{for(const t of this.temporaryElements)t.remove()};get temporaryElements(){return[...document.querySelectorAll(this.selector),...this.temporaryElementsWithDeprecation]}get temporaryElementsWithDeprecation(){const t=document.querySelectorAll(this.deprecatedSelector);return t.length,[...t]}}class Ft{constructor(t,e){this.session=t,this.element=e,this.linkInterceptor=new ct(this,e),this.formSubmitObserver=new it(this,e)}start(){this.linkInterceptor.start(),this.formSubmitObserver.start()}stop(){this.linkInterceptor.stop(),this.formSubmitObserver.stop()}shouldInterceptLinkClick(t,e,r){return this.#l(t)}linkClickIntercepted(t,e,r){const n=this.#f(t);n&&n.delegate.linkClickIntercepted(t,e,r)}willSubmitForm(t,e){return null==t.closest("turbo-frame")&&this.#h(t,e)&&this.#l(t,e)}formSubmitted(t,e){const r=this.#f(t,e);r&&r.delegate.formSubmitted(t,e)}#h(t,e){const r=u(t,e),n=this.element.ownerDocument.querySelector('meta[name="turbo-root"]'),o=a(n?.content??"/");return this.#l(t,e)&&h(r,o)}#l(t,e){if(t instanceof HTMLFormElement?this.session.submissionIsNavigatable(t,e):this.session.elementIsNavigatable(t)){const r=this.#f(t,e);return!!r&&r!=t.closest("turbo-frame")}return!1}#f(t,e){const r=e?.getAttribute("data-turbo-frame")||t.getAttribute("data-turbo-frame");if(r&&"_top"!=r){const t=this.element.querySelector(`#${r}:not([disabled])`);if(t instanceof s)return t}}}class Dt{location;restorationIdentifier=S();restorationData={};started=!1;pageLoaded=!1;currentIndex=0;constructor(t){this.delegate=t}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(t,e){this.update(history.pushState,t,e)}replace(t,e){this.update(history.replaceState,t,e)}update(t,e,r=S()){t===history.pushState&&++this.currentIndex;const n={turbo:{restorationIdentifier:r,restorationIndex:this.currentIndex}};t.call(history,n,"",e.href),this.location=e,this.restorationIdentifier=r}getRestorationDataForIdentifier(t){return this.restorationData[t]||{}}updateRestorationData(t){const{restorationIdentifier:e}=this,r=this.restorationData[e];this.restorationData[e]={...r,...t}}assumeControlOfScrollRestoration(){this.previousScrollRestoration||(this.previousScrollRestoration=history.scrollRestoration??"auto",history.scrollRestoration="manual")}relinquishControlOfScrollRestoration(){this.previousScrollRestoration&&(history.scrollRestoration=this.previousScrollRestoration,delete this.previousScrollRestoration)}onPopState=t=>{if(this.shouldHandlePopState()){const{turbo:e}=t.state||{};if(e){this.location=new URL(window.location.href);const{restorationIdentifier:t,restorationIndex:r}=e;this.restorationIdentifier=t;const n=r>this.currentIndex?"forward":"back";this.delegate.historyPoppedToLocationWithRestorationIdentifierAndDirection(this.location,t,n),this.currentIndex=r}}};onPageLoad=async t=>{await Promise.resolve(),this.pageLoaded=!0};shouldHandlePopState(){return this.pageIsLoaded()}pageIsLoaded(){return this.pageLoaded||"complete"==document.readyState}}class qt{started=!1;#d=null;constructor(t,e){this.delegate=t,this.eventTarget=e}start(){this.started||("loading"===this.eventTarget.readyState?this.eventTarget.addEventListener("DOMContentLoaded",this.#p,{once:!0}):this.#p())}stop(){this.started&&(this.eventTarget.removeEventListener("mouseenter",this.#m,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("mouseleave",this.#y,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("turbo:before-fetch-request",this.#b,!0),this.started=!1)}#p=()=>{this.eventTarget.addEventListener("mouseenter",this.#m,{capture:!0,passive:!0}),this.eventTarget.addEventListener("mouseleave",this.#y,{capture:!0,passive:!0}),this.eventTarget.addEventListener("turbo:before-fetch-request",this.#b,!0),this.started=!0};#m=t=>{if("false"===L("turbo-prefetch"))return;const e=t.target;if(e.matches&&e.matches("a[href]:not([target^=_]):not([download])")&&this.#g(e)){const t=e,r=I(t);if(this.delegate.canPrefetchRequestToLocation(t,r)){this.#d=t;const n=new $(this,H.get,r,new URLSearchParams,e);X.setLater(r.toString(),n,this.#v)}}};#y=t=>{t.target===this.#d&&this.#w()};#w=()=>{X.clear(),this.#d=null};#b=t=>{if("FORM"!==t.target.tagName&&"GET"===t.detail.fetchOptions.method){const e=X.get(t.detail.url.toString());e&&(t.detail.fetchRequest=e),X.clear()}};prepareRequest(t){const e=t.target;t.headers["X-Sec-Purpose"]="prefetch";const r=e.closest("turbo-frame"),n=e.getAttribute("data-turbo-frame")||r?.getAttribute("target")||r?.id;n&&"_top"!==n&&(t.headers["Turbo-Frame"]=n)}requestSucceededWithResponse(){}requestStarted(t){}requestErrored(t){}requestFinished(t){}requestPreventedHandlingResponse(t,e){}requestFailedWithResponse(t,e){}get#v(){return Number(L("turbo-prefetch-cache-time"))||1e4}#g(t){return!!t.getAttribute("href")&&(!Ut(t)&&(!Vt(t)&&(!Ht(t)&&(!Wt(t)&&!$t(t)))))}}const Ut=t=>t.origin!==document.location.origin||!["http:","https:"].includes(t.protocol)||t.hasAttribute("target"),Vt=t=>t.pathname+t.search===document.location.pathname+document.location.search||t.href.startsWith("#"),Ht=t=>{if("false"===t.getAttribute("data-turbo-prefetch"))return!0;if("false"===t.getAttribute("data-turbo"))return!0;const e=R(t,"[data-turbo-prefetch]");return!(!e||"false"!==e.getAttribute("data-turbo-prefetch"))},Wt=t=>{const e=t.getAttribute("data-turbo-method");return!(!e||"get"===e.toLowerCase())||(!!zt(t)||(!!t.hasAttribute("data-turbo-confirm")||!!t.hasAttribute("data-turbo-stream")))},zt=t=>t.hasAttribute("data-remote")||t.hasAttribute("data-behavior")||t.hasAttribute("data-confirm")||t.hasAttribute("data-method"),$t=t=>b("turbo:before-prefetch",{target:t,cancelable:!0}).defaultPrevented;class Kt{constructor(t){this.delegate=t}proposeVisit(t,e={}){this.delegate.allowsVisitingLocationWithAction(t,e.action)&&this.delegate.visitProposedToLocation(t,e)}startVisit(t,e,r={}){this.stop(),this.currentVisit=new Ct(this,a(t),e,{referrer:this.location,...r}),this.currentVisit.start()}submitForm(t,e){this.stop(),this.formSubmission=new et(this,t,e,!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(t){"function"==typeof this.adapter.formSubmissionStarted&&this.adapter.formSubmissionStarted(t)}async formSubmissionSucceededWithResponse(t,e){if(t==this.formSubmission){const r=await e.responseHTML;if(r){const n=t.isSafe;n||this.view.clearSnapshotCache();const{statusCode:o,redirected:i}=e,s={action:this.#A(t,e),shouldCacheSnapshot:n,response:{statusCode:o,responseHTML:r,redirected:i}};this.proposeVisit(e.location,s)}}}async formSubmissionFailedWithResponse(t,e){const r=await e.responseHTML;if(r){const t=gt.fromHTMLString(r);e.serverError?await this.view.renderError(t,this.currentVisit):await this.view.renderPage(t,!1,!0,this.currentVisit),t.shouldPreserveScrollPosition||this.view.scrollToTop(),this.view.clearSnapshotCache()}}formSubmissionErrored(t,e){}formSubmissionFinished(t){"function"==typeof this.adapter.formSubmissionFinished&&this.adapter.formSubmissionFinished(t)}visitStarted(t){this.delegate.visitStarted(t)}visitCompleted(t){this.delegate.visitCompleted(t),delete this.currentVisit}locationWithActionIsSamePage(t,e){const r=c(t),n=c(this.view.lastRenderedLocation),o="restore"===e&&void 0===r;return"replace"!==e&&d(t)===d(this.view.lastRenderedLocation)&&(o||null!=r&&r!==n)}visitScrolledToSamePageLocation(t,e){this.delegate.visitScrolledToSamePageLocation(t,e)}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}#A(t,e){const{submitter:r,formElement:n}=t;return k(r,n)||this.#O(e)}#O(t){return t.redirected&&t.location.href===this.location?.href?"replace":"advance"}}const Yt=0,Gt=1,Jt=2,Qt=3;class Zt{stage=Yt;started=!1;constructor(t){this.delegate=t}start(){this.started||(this.stage==Yt&&(this.stage=Gt),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:t}=this;"interactive"==t?this.pageIsInteractive():"complete"==t&&this.pageIsComplete()};pageIsInteractive(){this.stage==Gt&&(this.stage=Jt,this.delegate.pageBecameInteractive())}pageIsComplete(){this.pageIsInteractive(),this.stage==Jt&&(this.stage=Qt,this.delegate.pageLoaded())}pageWillUnload=()=>{this.delegate.pageWillUnload()};get readyState(){return document.readyState}}class Xt{started=!1;constructor(t){this.delegate=t}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(t){this.delegate.scrollPositionChanged(t)}}class te{render({fragment:t}){ft.preservingPermanentElements(this,function(t){const e=ot(document.documentElement),r={};for(const n of e){const{id:e}=n;for(const o of t.querySelectorAll("turbo-stream")){const t=nt(o.templateElement.content,e);t&&(r[e]=[n,t])}}return r}(t),(()=>{!async function(t,e){const r=`turbo-stream-autofocus-${S()}`,n=t.querySelectorAll("turbo-stream"),o=function(t){for(const e of t){const t=C(e.templateElement.content);if(t)return t}return null}(n);let i=null;o&&(i=o.id?o.id:r,o.id=i);e(),await g();if((null==document.activeElement||document.activeElement==document.body)&&i){const t=document.getElementById(i);N(t)&&t.focus(),t&&t.id==r&&t.removeAttribute("id")}}(t,(()=>{!async function(t){const[e,r]=await async function(t,e){const r=e();return t(),await v(),[r,e()]}(t,(()=>document.activeElement)),n=e&&e.id;if(n){const t=document.getElementById(n);N(t)&&t!=r&&t.focus()}}((()=>{document.documentElement.appendChild(t)}))}))}))}enteringBardo(t,e){e.replaceWith(t.cloneNode(!0))}leavingBardo(){}}class ee{sources=new Set;#S=!1;constructor(t){this.delegate=t}start(){this.#S||(this.#S=!0,addEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}stop(){this.#S&&(this.#S=!1,removeEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}connectStreamSource(t){this.streamSourceIsConnected(t)||(this.sources.add(t),t.addEventListener("message",this.receiveMessageEvent,!1))}disconnectStreamSource(t){this.streamSourceIsConnected(t)&&(this.sources.delete(t),t.removeEventListener("message",this.receiveMessageEvent,!1))}streamSourceIsConnected(t){return this.sources.has(t)}inspectFetchResponse=t=>{const e=function(t){const e=t.detail?.fetchResponse;if(e instanceof m)return e}(t);e&&function(t){const e=t.contentType??"";return e.startsWith(Z.contentType)}(e)&&(t.preventDefault(),this.receiveMessageResponse(e))};receiveMessageEvent=t=>{this.#S&&"string"==typeof t.data&&this.receiveMessageHTML(t.data)};async receiveMessageResponse(t){const e=await t.responseHTML;e&&this.receiveMessageHTML(e)}receiveMessageHTML(t){this.delegate.receivedMessageFromStream(Z.wrap(t))}}class re extends ht{static renderElement(t,e){const{documentElement:r,body:n}=document;r.replaceChild(e,n)}async render(){this.replaceHeadAndBody(),this.activateScriptElements()}replaceHeadAndBody(){const{documentElement:t,head:e}=document;t.replaceChild(this.newHead,e),this.renderElement(this.currentElement,this.newElement)}activateScriptElements(){for(const t of this.scriptElements){const e=t.parentNode;if(e){const r=y(t);e.replaceChild(r,t)}}}get newHead(){return this.newSnapshot.headSnapshot.element}get scriptElements(){return document.documentElement.querySelectorAll("script")}}var ne=function(){let t=new Set,e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:u,afterNodeAdded:u,beforeNodeMorphed:u,afterNodeMorphed:u,beforeNodeRemoved:u,afterNodeRemoved:u,beforeAttributeUpdated:u},head:{style:"merge",shouldPreserve:function(t){return"true"===t.getAttribute("im-preserve")},shouldReAppend:function(t){return"true"===t.getAttribute("im-re-append")},shouldRemove:u,afterHeadMorphed:u}};function r(t,e,n){if(n.head.block){let o=t.querySelector("head"),i=e.querySelector("head");if(o&&i){let s=c(i,o,n);return void Promise.all(s).then((function(){r(t,e,Object.assign(n,{head:{block:!1,ignore:!0}}))}))}}if("innerHTML"===n.morphStyle)return i(e,t,n),t.children;if("outerHTML"===n.morphStyle||null==n.morphStyle){let r=function(t,e,r){let n;n=t.firstChild;let o=n,i=0;for(;n;){let t=m(n,e,r);t>i&&(o=n,i=t),n=n.nextSibling}return o}(e,t,n),i=r?.previousSibling,s=r?.nextSibling,a=o(t,r,n);return r?function(t,e,r){let n=[],o=[];for(;null!=t;)n.push(t),t=t.previousSibling;for(;n.length>0;){let t=n.pop();o.push(t),e.parentElement.insertBefore(t,e)}o.push(e);for(;null!=r;)n.push(r),o.push(r),r=r.nextSibling;for(;n.length>0;)e.parentElement.insertBefore(n.pop(),e.nextSibling);return o}(i,a,s):[]}throw"Do not understand how to morph style "+n.morphStyle}function n(t,e){return e.ignoreActiveValue&&t===document.activeElement&&t!==document.body}function o(t,e,r){if(!r.ignoreActive||t!==document.activeElement)return null==e?!1===r.callbacks.beforeNodeRemoved(t)?t:(t.remove(),r.callbacks.afterNodeRemoved(t),null):f(t,e)?(!1===r.callbacks.beforeNodeMorphed(t,e)||(t instanceof HTMLHeadElement&&r.head.ignore||(t instanceof HTMLHeadElement&&"morph"!==r.head.style?c(e,t,r):(!function(t,e,r){let o=t.nodeType;if(1===o){const n=t.attributes,o=e.attributes;for(const t of n)s(t.name,e,"update",r)||e.getAttribute(t.name)!==t.value&&e.setAttribute(t.name,t.value);for(let n=o.length-1;0<=n;n--){const i=o[n];s(i.name,e,"remove",r)||(t.hasAttribute(i.name)||e.removeAttribute(i.name))}}8!==o&&3!==o||e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue);n(e,r)||function(t,e,r){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement&&"file"!==t.type){let n=t.value,o=e.value;a(t,e,"checked",r),a(t,e,"disabled",r),t.hasAttribute("value")?n!==o&&(s("value",e,"update",r)||(e.setAttribute("value",n),e.value=n)):s("value",e,"remove",r)||(e.value="",e.removeAttribute("value"))}else if(t instanceof HTMLOptionElement)a(t,e,"selected",r);else if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){let n=t.value,o=e.value;if(s("value",e,"update",r))return;n!==o&&(e.value=n),e.firstChild&&e.firstChild.nodeValue!==n&&(e.firstChild.nodeValue=n)}}(t,e,r)}(e,t,r),n(t,r)||i(e,t,r))),r.callbacks.afterNodeMorphed(t,e)),t):!1===r.callbacks.beforeNodeRemoved(t)||!1===r.callbacks.beforeNodeAdded(e)?t:(t.parentElement.replaceChild(e,t),r.callbacks.afterNodeAdded(e),r.callbacks.afterNodeRemoved(t),e)}function i(t,e,r){let n,i=t.firstChild,s=e.firstChild;for(;i;){if(n=i,i=n.nextSibling,null==s){if(!1===r.callbacks.beforeNodeAdded(n))return;e.appendChild(n),r.callbacks.afterNodeAdded(n),v(r,n);continue}if(l(n,s,r)){o(s,n,r),s=s.nextSibling,v(r,n);continue}let a=d(t,e,n,s,r);if(a){s=h(s,a,r),o(a,n,r),v(r,n);continue}let c=p(t,e,n,s,r);if(c)s=h(s,c,r),o(c,n,r),v(r,n);else{if(!1===r.callbacks.beforeNodeAdded(n))return;e.insertBefore(n,s),r.callbacks.afterNodeAdded(n),v(r,n)}}for(;null!==s;){let t=s;s=s.nextSibling,y(t,r)}}function s(t,e,r,n){return!("value"!==t||!n.ignoreActiveValue||e!==document.activeElement)||!1===n.callbacks.beforeAttributeUpdated(t,e,r)}function a(t,e,r,n){if(t[r]!==e[r]){let o=s(r,e,"update",n);o||(e[r]=t[r]),t[r]?o||e.setAttribute(r,t[r]):s(r,e,"remove",n)||e.removeAttribute(r)}}function c(t,e,r){let n=[],o=[],i=[],s=[],a=r.head.style,c=new Map;for(const e of t.children)c.set(e.outerHTML,e);for(const t of e.children){let e=c.has(t.outerHTML),n=r.head.shouldReAppend(t),u=r.head.shouldPreserve(t);e||u?n?o.push(t):(c.delete(t.outerHTML),i.push(t)):"append"===a?n&&(o.push(t),s.push(t)):!1!==r.head.shouldRemove(t)&&o.push(t)}s.push(...c.values());let u=[];for(const t of s){let o=document.createRange().createContextualFragment(t.outerHTML).firstChild;if(!1!==r.callbacks.beforeNodeAdded(o)){if(o.href||o.src){let t=null,e=new Promise((function(e){t=e}));o.addEventListener("load",(function(){t()})),u.push(e)}e.appendChild(o),r.callbacks.afterNodeAdded(o),n.push(o)}}for(const t of o)!1!==r.callbacks.beforeNodeRemoved(t)&&(e.removeChild(t),r.callbacks.afterNodeRemoved(t));return r.head.afterHeadMorphed(e,{added:n,kept:i,removed:o}),u}function u(){}function l(t,e,r){return null!=t&&null!=e&&(t.nodeType===e.nodeType&&t.tagName===e.tagName&&(""!==t.id&&t.id===e.id||w(r,t,e)>0))}function f(t,e){return null!=t&&null!=e&&(t.nodeType===e.nodeType&&t.tagName===e.tagName)}function h(t,e,r){for(;t!==e;){let e=t;t=t.nextSibling,y(e,r)}return v(r,e),e.nextSibling}function d(t,e,r,n,o){let i=w(o,r,e);if(i>0){let e=n,s=0;for(;null!=e;){if(l(r,e,o))return e;if(s+=w(o,e,t),s>i)return null;e=e.nextSibling}}return null}function p(t,e,r,n,o){let i=n,s=r.nextSibling,a=0;for(;null!=i;){if(w(o,i,t)>0)return null;if(f(r,i))return i;if(f(s,i)&&(a++,s=s.nextSibling,a>=2))return null;i=i.nextSibling}return i}function m(t,e,r){return f(t,e)?.5+w(r,t,e):0}function y(t,e){v(e,t),!1!==e.callbacks.beforeNodeRemoved(t)&&(t.remove(),e.callbacks.afterNodeRemoved(t))}function b(t,e){return!t.deadIds.has(e)}function g(e,r,n){return(e.idMap.get(n)||t).has(r)}function v(e,r){let n=e.idMap.get(r)||t;for(const t of n)e.deadIds.add(t)}function w(e,r,n){let o=e.idMap.get(r)||t,i=0;for(const t of o)b(e,t)&&g(e,t,n)&&++i;return i}function A(t,e){let r=t.parentElement,n=t.querySelectorAll("[id]");for(const t of n){let n=t;for(;n!==r&&null!=n;){let r=e.get(n);null==r&&(r=new Set,e.set(n,r)),r.add(t.id),n=n.parentElement}}}function O(t,e){let r=new Map;return A(t,r),A(e,r),r}return{morph:function(t,n,o={}){t instanceof Document&&(t=t.documentElement),"string"==typeof n&&(n=function(t){let e=new DOMParser,r=t.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"");if(r.match(/<\/html>/)||r.match(/<\/head>/)||r.match(/<\/body>/)){let n=e.parseFromString(t,"text/html");if(r.match(/<\/html>/))return n.generatedByIdiomorph=!0,n;{let t=n.firstChild;return t?(t.generatedByIdiomorph=!0,t):null}}{let r=e.parseFromString("","text/html").body.querySelector("template").content;return r.generatedByIdiomorph=!0,r}}(n));let i=function(t){if(null==t){return document.createElement("div")}if(t.generatedByIdiomorph)return t;if(t instanceof Node){const e=document.createElement("div");return e.append(t),e}{const e=document.createElement("div");for(const r of[...t])e.append(r);return e}}(n),s=function(t,r,n){return n=function(t){let r={};return Object.assign(r,e),Object.assign(r,t),r.callbacks={},Object.assign(r.callbacks,e.callbacks),Object.assign(r.callbacks,t.callbacks),r.head={},Object.assign(r.head,e.head),Object.assign(r.head,t.head),r}(n),{target:t,newContent:r,config:n,morphStyle:n.morphStyle,ignoreActive:n.ignoreActive,ignoreActiveValue:n.ignoreActiveValue,idMap:O(t,r),deadIds:new Set,callbacks:n.callbacks,head:n.head}}(t,i,o);return r(t,i,s)},defaults:e}}();function oe(t,e,{callbacks:r,...n}={}){ne.morph(t,e,{...n,callbacks:new se(r)})}function ie(t,e){oe(t,e.children,{morphStyle:"innerHTML"})}class se{#E;constructor({beforeNodeMorphed:t}={}){this.#E=t||(()=>!0)}beforeNodeAdded=t=>!(t.id&&t.hasAttribute("data-turbo-permanent")&&document.getElementById(t.id));beforeNodeMorphed=(t,e)=>{if(t instanceof Element){if(!t.hasAttribute("data-turbo-permanent")&&this.#E(t,e)){return!b("turbo:before-morph-element",{cancelable:!0,target:t,detail:{currentElement:t,newElement:e}}).defaultPrevented}return!1}};beforeAttributeUpdated=(t,e,r)=>!b("turbo:before-morph-attribute",{cancelable:!0,target:e,detail:{attributeName:t,mutationType:r}}).defaultPrevented;beforeNodeRemoved=t=>this.beforeNodeMorphed(t);afterNodeMorphed=(t,e)=>{t instanceof Element&&b("turbo:morph-element",{target:t,detail:{currentElement:t,newElement:e}})}}class ae extends dt{static renderElement(t,e){b("turbo:before-frame-morph",{target:t,detail:{currentElement:t,newElement:e}}),ie(t,e)}}class ce extends ht{static renderElement(t,e){document.body&&e instanceof HTMLBodyElement?document.body.replaceWith(e):document.documentElement.appendChild(e)}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.#j(),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}#j(){const{documentElement:t}=this.currentSnapshot,{lang:e}=this.newSnapshot;e?t.setAttribute("lang",e):t.removeAttribute("lang")}async mergeHead(){const t=this.mergeProvisionalElements(),e=this.copyNewHeadStylesheetElements();this.copyNewHeadScriptElements(),await t,await e,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 t=[];for(const e of this.newHeadStylesheetElements)t.push(T(e)),document.head.appendChild(e);await Promise.all(t)}copyNewHeadScriptElements(){for(const t of this.newHeadScriptElements)document.head.appendChild(y(t))}removeUnusedDynamicStylesheetElements(){for(const t of this.unusedDynamicStylesheetElements)document.head.removeChild(t)}async mergeProvisionalElements(){const t=[...this.newHeadProvisionalElements];for(const e of this.currentHeadProvisionalElements)this.isCurrentElementInElementList(e,t)||document.head.removeChild(e);for(const e of t)document.head.appendChild(e)}isCurrentElementInElementList(t,e){for(const[r,n]of e.entries()){if("TITLE"==t.tagName){if("TITLE"!=n.tagName)continue;if(t.innerHTML==n.innerHTML)return e.splice(r,1),!0}if(n.isEqualNode(t))return e.splice(r,1),!0}return!1}removeCurrentHeadProvisionalElements(){for(const t of this.currentHeadProvisionalElements)document.head.removeChild(t)}copyNewHeadProvisionalElements(){for(const t of this.newHeadProvisionalElements)document.head.appendChild(t)}activateNewBody(){document.adoptNode(this.newElement),this.activateNewBodyScriptElements()}activateNewBodyScriptElements(){for(const t of this.newBodyScriptElements){const e=y(t);t.replaceWith(e)}}async assignNewBody(){await this.renderElement(this.currentElement,this.newElement)}get unusedDynamicStylesheetElements(){return this.oldHeadStylesheetElements.filter((t=>"dynamic"===t.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 ue extends ce{static renderElement(t,e){oe(t,e,{callbacks:{beforeNodeMorphed:t=>!le(t)}});for(const e of t.querySelectorAll("turbo-frame"))le(e)&&fe(e);b("turbo:morph",{detail:{currentElement:t,newElement:e}})}async preservingPermanentElements(t){return await t()}get renderMethod(){return"morph"}get shouldAutofocus(){return!1}}function le(t){return t instanceof s&&t.src&&"morph"===t.refresh&&!t.closest("[data-turbo-permanent]")}function fe(t){t.addEventListener("turbo:before-frame-render",(({detail:t})=>{t.render=ae.renderElement}),{once:!0}),t.reload()}class he{keys=[];snapshots={};constructor(t){this.size=t}has(t){return p(t)in this.snapshots}get(t){if(this.has(t)){const e=this.read(t);return this.touch(t),e}}put(t,e){return this.write(t,e),this.touch(t),e}clear(){this.snapshots={}}read(t){return this.snapshots[p(t)]}write(t,e){this.snapshots[p(t)]=e}touch(t){const e=p(t),r=this.keys.indexOf(e);r>-1&&this.keys.splice(r,1),this.keys.unshift(e),this.trim()}trim(){for(const t of this.keys.splice(this.size))delete this.snapshots[t]}}class de extends st{snapshotCache=new he(10);lastRenderedLocation=new URL(location.href);forceReloaded=!1;shouldTransitionTo(t){return this.snapshot.prefersViewTransitions&&t.prefersViewTransitions}renderPage(t,e=!1,r=!0,n){const o=this.isPageRefresh(n)&&this.snapshot.shouldMorphPage?ue:ce,i=new o(this.snapshot,t,o.renderElement,e,r);return i.shouldRender?n?.changeHistory():this.forceReloaded=!0,this.render(i)}renderError(t,e){e?.changeHistory();const r=new re(this.snapshot,t,re.renderElement,!1);return this.render(r)}clearSnapshotCache(){this.snapshotCache.clear()}async cacheSnapshot(t=this.snapshot){if(t.isCacheable){this.delegate.viewWillCacheSnapshot();const{lastRenderedLocation:e}=this;await w();const r=t.clone();return this.snapshotCache.put(e,r),r}}getCachedSnapshotForLocation(t){return this.snapshotCache.get(t)}isPageRefresh(t){return!t||this.lastRenderedLocation.pathname===t.location.pathname&&"replace"===t.action}shouldPreserveScrollPosition(t){return this.isPageRefresh(t)&&this.snapshot.shouldPreserveScrollPosition}get snapshot(){return gt.fromElement(this.element)}}class pe{selector="a[data-turbo-preload]";constructor(t,e){this.delegate=t,this.snapshotCache=e}start(){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",this.#P):this.preloadOnLoadLinksForView(document.body)}stop(){document.removeEventListener("DOMContentLoaded",this.#P)}preloadOnLoadLinksForView(t){for(const e of t.querySelectorAll(this.selector))this.delegate.shouldPreloadLink(e)&&this.preloadURL(e)}async preloadURL(t){const e=new URL(t.href);if(this.snapshotCache.has(e))return;const r=new $(this,H.get,e,new URLSearchParams,t);await r.perform()}prepareRequest(t){t.headers["X-Sec-Purpose"]="prefetch"}async requestSucceededWithResponse(t,e){try{const r=await e.responseHTML,n=gt.fromHTMLString(r);this.snapshotCache.put(t.url,n)}catch(t){}}requestStarted(t){}requestErrored(t){}requestFinished(t){}requestPreventedHandlingResponse(t,e){}requestFailedWithResponse(t,e){}#P=()=>{this.preloadOnLoadLinksForView(document.body)}}class me{constructor(t){this.session=t}clear(){this.session.clearCache()}resetCacheControl(){this.#T("")}exemptPageFromCache(){this.#T("no-cache")}exemptPageFromPreview(){this.#T("no-preview")}#T(t){!function(t,e){let r=x(t);r||(r=document.createElement("meta"),r.setAttribute("name",t),document.head.appendChild(r)),r.setAttribute("content",e)}("turbo-cache-control",t)}}function ye(t){Object.defineProperties(t,be)}const be={absoluteURL:{get(){return this.toString()}}},ge=new class{navigator=new Kt(this);history=new Dt(this);view=new de(this,document.documentElement);adapter=new Bt(this);pageObserver=new Zt(this);cacheObserver=new It;linkPrefetchObserver=new qt(this,document);linkClickObserver=new ut(this,window);formSubmitObserver=new it(this,document);scrollObserver=new Xt(this);streamObserver=new ee(this);formLinkClickObserver=new lt(this,document.documentElement);frameRedirector=new Ft(this,document.documentElement);streamMessageRenderer=new te;cache=new me(this);drive=!0;enabled=!0;progressBarDelay=500;started=!1;formMode="on";#_=150;constructor(t){this.recentRequests=t,this.preloader=new pe(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(t){this.adapter=t}visit(t,e={}){const r=e.frame?document.getElementById(e.frame):null;if(r instanceof s){const n=e.action||k(r);r.delegate.proposeVisitIfNavigatedWithAction(r,n),r.src=t.toString()}else this.navigator.proposeVisit(a(t),e)}refresh(t,e){e&&this.recentRequests.has(e)||this.navigator.currentVisit||this.visit(t,{action:"replace",shouldCacheSnapshot:!1})}connectStreamSource(t){this.streamObserver.connectStreamSource(t)}disconnectStreamSource(t){this.streamObserver.disconnectStreamSource(t)}renderStreamMessage(t){this.streamMessageRenderer.render(Z.wrap(t))}clearCache(){this.view.clearSnapshotCache()}setProgressBarDelay(t){this.progressBarDelay=t}setFormMode(t){this.formMode=t}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}get pageRefreshDebouncePeriod(){return this.#_}set pageRefreshDebouncePeriod(t){this.refresh=function(t,e){let r=null;return(...n)=>{clearTimeout(r),r=setTimeout((()=>t.apply(this,n)),e)}}(this.debouncedRefresh.bind(this),t),this.#_=t}shouldPreloadLink(t){const e=t.hasAttribute("data-turbo-method"),r=t.hasAttribute("data-turbo-stream"),n=t.getAttribute("data-turbo-frame"),o="_top"==n?null:document.getElementById(n)||R(t,"turbo-frame:not([disabled])");if(e||r||o instanceof s)return!1;{const e=new URL(t.href);return this.elementIsNavigatable(t)&&h(e,this.snapshot.rootLocation)}}historyPoppedToLocationWithRestorationIdentifierAndDirection(t,e,r){this.enabled?this.navigator.startVisit(t,e,{action:"restore",historyChanged:!0,direction:r}):this.adapter.pageInvalidated({reason:"turbo_disabled"})}scrollPositionChanged(t){this.history.updateRestorationData({scrollPosition:t})}willSubmitFormLinkToLocation(t,e){return this.elementIsNavigatable(t)&&h(e,this.snapshot.rootLocation)}submittedFormLinkToLocation(){}canPrefetchRequestToLocation(t,e){return this.elementIsNavigatable(t)&&h(e,this.snapshot.rootLocation)}willFollowLinkToLocation(t,e,r){return this.elementIsNavigatable(t)&&h(e,this.snapshot.rootLocation)&&this.applicationAllowsFollowingLinkToLocation(t,e,r)}followedLinkToLocation(t,e){const r=this.getActionForLink(t),n=t.hasAttribute("data-turbo-stream");this.visit(e.href,{action:r,acceptsStreamResponse:n})}allowsVisitingLocationWithAction(t,e){return this.locationWithActionIsSamePage(t,e)||this.applicationAllowsVisitingLocation(t)}visitProposedToLocation(t,e){ye(t),this.adapter.visitProposedToLocation(t,e)}visitStarted(t){t.acceptsStreamResponse||(j(document.documentElement),this.view.markVisitDirection(t.direction)),ye(t.location),t.silent||this.notifyApplicationAfterVisitingLocation(t.location,t.action)}visitCompleted(t){this.view.unmarkVisitDirection(),P(document.documentElement),this.notifyApplicationAfterPageLoad(t.getTimingMetrics())}locationWithActionIsSamePage(t,e){return this.navigator.locationWithActionIsSamePage(t,e)}visitScrolledToSamePageLocation(t,e){this.notifyApplicationAfterVisitingSamePageLocation(t,e)}willSubmitForm(t,e){const r=u(t,e);return this.submissionIsNavigatable(t,e)&&h(a(r),this.snapshot.rootLocation)}formSubmitted(t,e){this.navigator.submitForm(t,e)}pageBecameInteractive(){this.view.lastRenderedLocation=this.location,this.notifyApplicationAfterPageLoad()}pageLoaded(){this.history.assumeControlOfScrollRestoration()}pageWillUnload(){this.history.relinquishControlOfScrollRestoration()}receivedMessageFromStream(t){this.renderStreamMessage(t)}viewWillCacheSnapshot(){this.navigator.currentVisit?.silent||this.notifyApplicationBeforeCachingSnapshot()}allowsImmediateRender({element:t},e){const r=this.notifyApplicationBeforeRender(t,e),{defaultPrevented:n,detail:{render:o}}=r;return this.view.renderer&&o&&(this.view.renderer.renderElement=o),!n}viewRenderedSnapshot(t,e,r){this.view.lastRenderedLocation=this.history.location,this.notifyApplicationAfterRender(r)}preloadOnLoadLinksForView(t){this.preloader.preloadOnLoadLinksForView(t)}viewInvalidated(t){this.adapter.pageInvalidated(t)}frameLoaded(t){this.notifyApplicationAfterFrameLoad(t)}frameRendered(t,e){this.notifyApplicationAfterFrameRender(t,e)}applicationAllowsFollowingLinkToLocation(t,e,r){return!this.notifyApplicationAfterClickingLinkToLocation(t,e,r).defaultPrevented}applicationAllowsVisitingLocation(t){return!this.notifyApplicationBeforeVisitingLocation(t).defaultPrevented}notifyApplicationAfterClickingLinkToLocation(t,e,r){return b("turbo:click",{target:t,detail:{url:e.href,originalEvent:r},cancelable:!0})}notifyApplicationBeforeVisitingLocation(t){return b("turbo:before-visit",{detail:{url:t.href},cancelable:!0})}notifyApplicationAfterVisitingLocation(t,e){return b("turbo:visit",{detail:{url:t.href,action:e}})}notifyApplicationBeforeCachingSnapshot(){return b("turbo:before-cache")}notifyApplicationBeforeRender(t,e){return b("turbo:before-render",{detail:{newBody:t,...e},cancelable:!0})}notifyApplicationAfterRender(t){return b("turbo:render",{detail:{renderMethod:t}})}notifyApplicationAfterPageLoad(t={}){return b("turbo:load",{detail:{url:this.location.href,timing:t}})}notifyApplicationAfterVisitingSamePageLocation(t,e){dispatchEvent(new HashChangeEvent("hashchange",{oldURL:t.toString(),newURL:e.toString()}))}notifyApplicationAfterFrameLoad(t){return b("turbo:frame-load",{target:t})}notifyApplicationAfterFrameRender(t,e){return b("turbo:frame-render",{detail:{fetchResponse:t},target:e,cancelable:!0})}submissionIsNavigatable(t,e){if("off"==this.formMode)return!1;{const r=!e||this.elementIsNavigatable(e);return"optin"==this.formMode?r&&null!=t.closest('[data-turbo="true"]'):r&&this.elementIsNavigatable(t)}}elementIsNavigatable(t){const e=R(t,"[data-turbo]"),r=R(t,"turbo-frame");return this.drive||r?!e||"false"!=e.getAttribute("data-turbo"):!!e&&"true"==e.getAttribute("data-turbo")}getActionForLink(t){return k(t)||"advance"}get snapshot(){return this.view.snapshot}}(D),{cache:ve,navigator:we}=ge;function Ae(){ge.start()}function Oe(t){ge.registerAdapter(t)}function Se(t,e){ge.visit(t,e)}function Ee(t){ge.connectStreamSource(t)}function je(t){ge.disconnectStreamSource(t)}function Pe(t){ge.renderStreamMessage(t)}function Te(){ge.clearCache()}function _e(t){ge.setProgressBarDelay(t)}function ke(t){et.confirmMethod=t}function xe(t){ge.setFormMode(t)}var Le=Object.freeze({__proto__:null,navigator:we,session:ge,cache:ve,PageRenderer:ce,PageSnapshot:gt,FrameRenderer:dt,fetch:U,start:Ae,registerAdapter:Oe,visit:Se,connectStreamSource:Ee,disconnectStreamSource:je,renderStreamMessage:Pe,clearCache:Te,setProgressBarDelay:_e,setConfirmMethod:ke,setFormMode:xe});class Re extends Error{}function Ne(t){if(null!=t){const e=document.getElementById(t);if(e instanceof s)return e}}function Ce(t,e){if(t){const n=t.getAttribute("src");if(null!=n&&null!=e&&(r=e,a(n).href==a(r).href))throw new Error(`Matching element has a source URL which references itself`);if(t.ownerDocument!==document&&(t=document.importNode(t,!0)),t instanceof s)return t.connectedCallback(),t.disconnectedCallback(),t}var r}const Me={after(){this.targetElements.forEach((t=>t.parentElement?.insertBefore(this.templateContent,t.nextSibling)))},append(){this.removeDuplicateTargetChildren(),this.targetElements.forEach((t=>t.append(this.templateContent)))},before(){this.targetElements.forEach((t=>t.parentElement?.insertBefore(this.templateContent,t)))},prepend(){this.removeDuplicateTargetChildren(),this.targetElements.forEach((t=>t.prepend(this.templateContent)))},remove(){this.targetElements.forEach((t=>t.remove()))},replace(){const t=this.getAttribute("method");this.targetElements.forEach((e=>{"morph"===t?oe(e,this.templateContent):e.replaceWith(this.templateContent)}))},update(){const t=this.getAttribute("method");this.targetElements.forEach((e=>{"morph"===t?ie(e,this.templateContent):(e.innerHTML="",e.append(this.templateContent))}))},refresh(){ge.refresh(this.baseURI,this.requestId)}};class Be extends HTMLElement{static async renderElement(t){await t.performAction()}async connectedCallback(){try{await this.render()}catch(t){}finally{this.disconnect()}}async render(){return this.renderPromise??=(async()=>{const t=this.beforeRenderEvent;this.dispatchEvent(t)&&(await g(),await t.detail.render(this))})()}disconnect(){try{this.remove()}catch{}}removeDuplicateTargetChildren(){this.duplicateChildren.forEach((t=>t.remove()))}get duplicateChildren(){const t=this.targetElements.flatMap((t=>[...t.children])).filter((t=>!!t.id)),e=[...this.templateContent?.children||[]].filter((t=>!!t.id)).map((t=>t.id));return t.filter((t=>e.includes(t.id)))}get performAction(){if(this.action){const t=Me[this.action];if(t)return t;this.#k("unknown action")}this.#k("action attribute is missing")}get targetElements(){return this.target?this.targetElementsById:this.targets?this.targetElementsByQuery:void this.#k("target or targets attribute is missing")}get templateContent(){return this.templateElement.content.cloneNode(!0)}get templateElement(){if(null===this.firstElementChild){const t=this.ownerDocument.createElement("template");return this.appendChild(t),t}if(this.firstElementChild instanceof HTMLTemplateElement)return this.firstElementChild;this.#k("first child element must be a