diff --git a/public/js/orchid.js b/public/js/orchid.js index a2a02913d5..3c4fff1685 100644 --- a/public/js/orchid.js +++ b/public/js/orchid.js @@ -13,4 +13,4 @@ opacity ${H.animationDuration/2}ms ${H.animationDuration/2}ms ease-in; transform: translate3d(0, 0, 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*H.animationDuration)}uninstallProgressElement(){this.progressElement.parentNode&&document.documentElement.removeChild(this.progressElement)}startTrickling(){this.trickleInterval||(this.trickleInterval=window.setInterval(this.trickle,H.animationDuration))}stopTrickling(){window.clearInterval(this.trickleInterval),delete this.trickleInterval}refresh(){requestAnimationFrame((()=>{this.progressElement.style.width=10+90*this.value+"%"}))}createStylesheetElement(){const t=document.createElement("style");return t.type="text/css",t.textContent=H.defaultCSS,t}createProgressElement(){const t=document.createElement("div");return t.className="turbo-progress-bar",t}}H.animationDuration=300;class Z extends M{constructor(){super(...arguments),this.detailsByOuterHTML=this.children.filter((t=>!function(t){return"noscript"==t.tagName.toLowerCase()}(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:U(e),tracked:V(e),elements:[]};return Object.assign(Object.assign({},t),{[r]:Object.assign(Object.assign({},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){return"meta"==t.tagName.toLowerCase()&&t.getAttribute("name")==e}(n,t)?n:e}),void 0)}}function U(t){return function(t){return"script"==t.tagName.toLowerCase()}(t)?"script":function(t){const e=t.tagName.toLowerCase();return"style"==e||"link"==e&&"stylesheet"==t.getAttribute("rel")}(t)?"stylesheet":void 0}function V(t){return"reload"==t.getAttribute("data-turbo-track")}class W extends M{constructor(t,e){super(t),this.headSnapshot=e}static fromHTMLString(t=""){return this.fromDocument(S(t))}static fromElement(t){return this.fromDocument(t.ownerDocument)}static fromDocument({head:t,body:e}){return new this(e,new Z(t))}clone(){return new W(this.element.cloneNode(!0),this.headSnapshot)}get headElement(){return this.headSnapshot.element}get rootLocation(){var t;return h(null!==(t=this.getSetting("root"))&&void 0!==t?t:"/")}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")}getSetting(t){return this.headSnapshot.getMetaValue(`turbo-${t}`)}}!function(t){t.visitStart="visitStart",t.requestStart="requestStart",t.requestEnd="requestEnd",t.visitEnd="visitEnd"}(u||(u={})),function(t){t.initialized="initialized",t.started="started",t.canceled="canceled",t.failed="failed",t.completed="completed"}(l||(l={}));const Y={action:"advance",historyChanged:!1,visitCachedSnapshot:()=>{},willRender:!0};var z,K;!function(t){t[t.networkFailure=0]="networkFailure",t[t.timeoutFailure=-1]="timeoutFailure",t[t.contentTypeMismatch=-2]="contentTypeMismatch"}(z||(z={}));class ${constructor(t,e,r,n={}){this.identifier=A(),this.timingMetrics={},this.followedRedirect=!1,this.historyChanged=!1,this.scrolled=!1,this.snapshotCached=!1,this.state=l.initialized,this.delegate=t,this.location=e,this.restorationIdentifier=r||A();const{action:o,historyChanged:i,referrer:s,snapshotHTML:a,response:c,visitCachedSnapshot:u,willRender:f}=Object.assign(Object.assign({},Y),n);this.action=o,this.historyChanged=i,this.referrer=s,this.snapshotHTML=a,this.response=c,this.isSamePage=this.delegate.locationWithActionIsSamePage(this.location,this.action),this.visitCachedSnapshot=u,this.willRender=f,this.scrolled=!f}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==l.initialized&&(this.recordTimingMetric(u.visitStart),this.state=l.started,this.adapter.visitStarted(this),this.delegate.visitStarted(this))}cancel(){this.state==l.started&&(this.request&&this.request.cancel(),this.cancelRender(),this.state=l.canceled)}complete(){this.state==l.started&&(this.recordTimingMetric(u.visitEnd),this.state=l.completed,this.adapter.visitCompleted(this),this.delegate.visitCompleted(this),this.followRedirect())}fail(){this.state==l.started&&(this.state=l.failed,this.adapter.visitFailed(this))}changeHistory(){var t;if(!this.historyChanged){const e=this.location.href===(null===(t=this.referrer)||void 0===t?void 0:t.href)?"replace":this.action,r=this.getHistoryMethodForAction(e);this.history.update(r,this.location,this.restorationIdentifier),this.historyChanged=!0}}issueRequest(){this.hasPreloadedResponse()?this.simulateRequest():this.shouldIssueRequest()&&!this.request&&(this.request=new T(this,s.get,this.location),this.request.perform())}simulateRequest(){this.response&&(this.startRequest(),this.recordResponse(),this.finishRequest())}startRequest(){this.recordTimingMetric(u.requestStart),this.adapter.visitRequestStarted(this)}recordResponse(t=this.response){if(this.response=t,t){const{statusCode:e}=t;J(e)?this.adapter.visitRequestCompleted(this):this.adapter.visitRequestFailedWithStatusCode(this,e)}}finishRequest(){this.recordTimingMetric(u.requestEnd),this.adapter.visitRequestFinished(this)}loadResponse(){if(this.response){const{statusCode:t,responseHTML:e}=this.response;this.render((async()=>{this.cacheSnapshot(),this.view.renderPromise&&await this.view.renderPromise,J(t)&&null!=e?(await this.view.renderPage(W.fromHTMLString(e),!1,this.willRender),this.adapter.visitRendered(this),this.complete()):(await this.view.renderError(W.fromHTMLString(e)),this.adapter.visitRendered(this),this.fail())}))}}getCachedSnapshot(){const t=this.view.getCachedSnapshotForLocation(this.location)||this.getPreloadedSnapshot();if(t&&(!d(this.location)||t.hasAnchor(d(this.location)))&&("restore"==this.action||t.isPreviewable))return t}getPreloadedSnapshot(){if(this.snapshotHTML)return W.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.adapter.visitRendered(this):(this.view.renderPromise&&await this.view.renderPromise,await this.view.renderPage(t,e,this.willRender),this.adapter.visitRendered(this),e||this.complete())}))}}followRedirect(){var t;this.redirectedToLocation&&!this.followedRedirect&&(null===(t=this.response)||void 0===t?void 0:t.redirected)&&(this.adapter.visitProposedToLocation(this.redirectedToLocation,{action:"replace",response:this.response}),this.followedRedirect=!0)}goToSamePageAnchor(){this.isSamePage&&this.render((async()=>{this.cacheSnapshot(),this.adapter.visitRendered(this)}))}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:z.contentTypeMismatch,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:z.contentTypeMismatch,redirected:n}):this.recordResponse({statusCode:o,responseHTML:r,redirected:n})}requestErrored(t,e){this.recordResponse({statusCode:z.networkFailure,redirected:!1})}requestFinished(){this.finishRequest()}performScroll(){this.scrolled||("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=d(this.location);if(null!=t)return this.view.scrollToAnchor(t),!0}recordTimingMetric(t){this.timingMetrics[t]=(new Date).getTime()}getTimingMetrics(){return Object.assign({},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().then((t=>t&&this.visitCachedSnapshot(t))),this.snapshotCached=!0)}async render(t){this.cancelRender(),await new Promise((t=>{this.frame=requestAnimationFrame((()=>t()))})),await t(),delete this.frame,this.performScroll()}cancelRender(){this.frame&&(cancelAnimationFrame(this.frame),delete this.frame)}}function J(t){return t>=200&&t<300}class Q{constructor(t){this.progressBar=new H,this.showProgressBar=()=>{this.progressBar.show()},this.session=t}visitProposedToLocation(t,e){this.navigator.startVisit(t,A(),e)}visitStarted(t){t.loadCachedSnapshot(),t.issueRequest(),t.changeHistory(),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 z.networkFailure:case z.timeoutFailure:case z.contentTypeMismatch:return this.reload();default:return t.loadResponse()}}visitRequestFinished(t){this.progressBar.setValue(1),this.hideVisitProgressBar()}visitCompleted(t){}pageInvalidated(){this.reload()}visitFailed(t){}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)}reload(){window.location.reload()}get navigator(){return this.session.navigator}}class X{constructor(){this.started=!1}start(){this.started||(this.started=!0,addEventListener("turbo:before-cache",this.removeStaleElements,!1))}stop(){this.started&&(this.started=!1,removeEventListener("turbo:before-cache",this.removeStaleElements,!1))}removeStaleElements(){const t=[...document.querySelectorAll('[data-turbo-cache="false"]')];for(const e of t)e.remove()}}class G{constructor(t){this.started=!1,this.submitCaptured=()=>{removeEventListener("submit",this.submitBubbled,!1),addEventListener("submit",this.submitBubbled,!1)},this.submitBubbled=t=>{if(!t.defaultPrevented){const e=t.target instanceof HTMLFormElement?t.target:void 0,r=t.submitter||void 0;if(e){"dialog"!=((null==r?void 0:r.getAttribute("formmethod"))||e.getAttribute("method"))&&this.delegate.willSubmitForm(e,r)&&(t.preventDefault(),this.delegate.formSubmitted(e,r))}}},this.delegate=t}start(){this.started||(addEventListener("submit",this.submitCaptured,!0),this.started=!0)}stop(){this.started&&(removeEventListener("submit",this.submitCaptured,!0),this.started=!1)}}class tt{constructor(t){this.element=t,this.linkInterceptor=new D(this,t),this.formInterceptor=new B(this,t)}start(){this.linkInterceptor.start(),this.formInterceptor.start()}stop(){this.linkInterceptor.stop(),this.formInterceptor.stop()}shouldInterceptLinkClick(t,e){return this.shouldRedirect(t)}linkClickIntercepted(t,e){const r=this.findFrameElement(t);r&&r.delegate.linkClickIntercepted(t,e)}shouldInterceptFormSubmission(t,e){return this.shouldSubmit(t,e)}formSubmissionIntercepted(t,e){const r=this.findFrameElement(t,e);r&&(r.removeAttribute("reloadable"),r.delegate.formSubmissionIntercepted(t,e))}shouldSubmit(t,e){var r;const n=p(t,e),o=this.element.ownerDocument.querySelector('meta[name="turbo-root"]'),i=h(null!==(r=null==o?void 0:o.content)&&void 0!==r?r:"/");return this.shouldRedirect(t,e)&&g(n,i)}shouldRedirect(t,e){const r=this.findFrameElement(t,e);return!!r&&r!=t.closest("turbo-frame")}findFrameElement(t,e){const r=(null==e?void 0: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 f)return t}}}class et{constructor(t){this.restorationIdentifier=A(),this.restorationData={},this.started=!1,this.pageLoaded=!1,this.onPopState=t=>{if(this.shouldHandlePopState()){const{turbo:e}=t.state||{};if(e){this.location=new URL(window.location.href);const{restorationIdentifier:t}=e;this.restorationIdentifier=t,this.delegate.historyPoppedToLocationWithRestorationIdentifier(this.location,t)}}},this.onPageLoad=async t=>{await Promise.resolve(),this.pageLoaded=!0},this.delegate=t}start(){this.started||(addEventListener("popstate",this.onPopState,!1),addEventListener("load",this.onPageLoad,!1),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=A()){const n={turbo:{restorationIdentifier:r}};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]=Object.assign(Object.assign({},r),t)}assumeControlOfScrollRestoration(){var t;this.previousScrollRestoration||(this.previousScrollRestoration=null!==(t=history.scrollRestoration)&&void 0!==t?t:"auto",history.scrollRestoration="manual")}relinquishControlOfScrollRestoration(){this.previousScrollRestoration&&(history.scrollRestoration=this.previousScrollRestoration,delete this.previousScrollRestoration)}shouldHandlePopState(){return this.pageIsLoaded()}pageIsLoaded(){return this.pageLoaded||"complete"==document.readyState}}class rt{constructor(t){this.started=!1,this.clickCaptured=()=>{removeEventListener("click",this.clickBubbled,!1),addEventListener("click",this.clickBubbled,!1)},this.clickBubbled=t=>{if(this.clickEventIsSignificant(t)){const e=t.composedPath&&t.composedPath()[0]||t.target,r=this.findLinkFromClickTarget(e);if(r){const e=this.getLocationForLink(r);this.delegate.willFollowLinkToLocation(r,e)&&(t.preventDefault(),this.delegate.followedLinkToLocation(r,e))}}},this.delegate=t}start(){this.started||(addEventListener("click",this.clickCaptured,!0),this.started=!0)}stop(){this.started&&(removeEventListener("click",this.clickCaptured,!0),this.started=!1)}clickEventIsSignificant(t){return!(t.target&&t.target.isContentEditable||t.defaultPrevented||t.which>1||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)}findLinkFromClickTarget(t){if(t instanceof Element)return t.closest("a[href]:not([target^=_]):not([download])")}getLocationForLink(t){return h(t.getAttribute("href")||"")}}function nt(t){return"advance"==t||"replace"==t||"restore"==t}class ot{constructor(t){this.delegate=t}proposeVisit(t,e={}){this.delegate.allowsVisitingLocationWithAction(t,e.action)&&(g(t,this.view.snapshot.rootLocation)?this.delegate.visitProposedToLocation(t,e):window.location.href=t.toString())}startVisit(t,e,r={}){this.stop(),this.currentVisit=new $(this,h(t),e,Object.assign({referrer:this.location},r)),this.currentVisit.start()}submitForm(t,e){this.stop(),this.formSubmission=new x(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 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){t.method!=s.get&&this.view.clearSnapshotCache();const{statusCode:n,redirected:o}=e,i={action:this.getActionForFormSubmission(t),response:{statusCode:n,responseHTML:r,redirected:o}};this.proposeVisit(e.location,i)}}}async formSubmissionFailedWithResponse(t,e){const r=await e.responseHTML;if(r){const t=W.fromHTMLString(r);e.serverError?await this.view.renderError(t):await this.view.renderPage(t),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)}locationWithActionIsSamePage(t,e){const r=d(t),n=d(this.view.lastRenderedLocation),o="restore"===e&&void 0===r;return"replace"!==e&&b(t)===b(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}getActionForFormSubmission(t){const{formElement:e,submitter:r}=t,n=R("data-turbo-action",r,e);return nt(n)?n:"advance"}}!function(t){t[t.initial=0]="initial",t[t.loading=1]="loading",t[t.interactive=2]="interactive",t[t.complete=3]="complete"}(K||(K={}));class it{constructor(t){this.stage=K.initial,this.started=!1,this.interpretReadyState=()=>{const{readyState:t}=this;"interactive"==t?this.pageIsInteractive():"complete"==t&&this.pageIsComplete()},this.pageWillUnload=()=>{this.delegate.pageWillUnload()},this.delegate=t}start(){this.started||(this.stage==K.initial&&(this.stage=K.loading),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)}pageIsInteractive(){this.stage==K.loading&&(this.stage=K.interactive,this.delegate.pageBecameInteractive())}pageIsComplete(){this.pageIsInteractive(),this.stage==K.interactive&&(this.stage=K.complete,this.delegate.pageLoaded())}get readyState(){return document.readyState}}class st{constructor(t){this.started=!1,this.onScroll=()=>{this.updatePosition({x:window.pageXOffset,y:window.pageYOffset})},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)}updatePosition(t){this.delegate.scrollPositionChanged(t)}}class at{constructor(t){this.sources=new Set,this.started=!1,this.inspectFetchResponse=t=>{const e=function(t){var e;const r=null===(e=t.detail)||void 0===e?void 0:e.fetchResponse;if(r instanceof w)return r}(t);e&&function(t){var e;return(null!==(e=t.contentType)&&void 0!==e?e:"").startsWith(C.contentType)}(e)&&(t.preventDefault(),this.receiveMessageResponse(e))},this.receiveMessageEvent=t=>{this.started&&"string"==typeof t.data&&this.receiveMessageHTML(t.data)},this.delegate=t}start(){this.started||(this.started=!0,addEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}stop(){this.started&&(this.started=!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)}async receiveMessageResponse(t){const e=await t.responseHTML;e&&this.receiveMessageHTML(e)}receiveMessageHTML(t){this.delegate.receivedMessageFromStream(new C(t))}}class ct extends q{async render(){this.replaceHeadAndBody(),this.activateScriptElements()}replaceHeadAndBody(){const{documentElement:t,head:e,body:r}=document;t.replaceChild(this.newHead,e),t.replaceChild(this.newElement,r)}activateScriptElements(){for(const t of this.scriptElements){const e=t.parentNode;if(e){const r=this.createScriptElement(t);e.replaceChild(r,t)}}}get newHead(){return this.newSnapshot.headSnapshot.element}get scriptElements(){return[...document.documentElement.querySelectorAll("script")]}}class ut extends q{get shouldRender(){return this.newSnapshot.isVisitable&&this.trackedElementsAreIdentical}prepareToRender(){this.mergeHead()}async render(){this.willRender&&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}mergeHead(){this.copyNewHeadStylesheetElements(),this.copyNewHeadScriptElements(),this.removeCurrentHeadProvisionalElements(),this.copyNewHeadProvisionalElements()}replaceBody(){this.preservingPermanentElements((()=>{this.activateNewBody(),this.assignNewBody()}))}get trackedElementsAreIdentical(){return this.currentHeadSnapshot.trackedElementSignature==this.newHeadSnapshot.trackedElementSignature}copyNewHeadStylesheetElements(){for(const t of this.newHeadStylesheetElements)document.head.appendChild(t)}copyNewHeadScriptElements(){for(const t of this.newHeadScriptElements)document.head.appendChild(this.createScriptElement(t))}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=this.createScriptElement(t);t.replaceWith(e)}}assignNewBody(){document.body&&this.newElement instanceof HTMLBodyElement?document.body.replaceWith(this.newElement):document.documentElement.appendChild(this.newElement)}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 lt{constructor(t){this.keys=[],this.snapshots={},this.size=t}has(t){return v(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[v(t)]}write(t,e){this.snapshots[v(t)]=e}touch(t){const e=v(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 ft extends F{constructor(){super(...arguments),this.snapshotCache=new lt(10),this.lastRenderedLocation=new URL(location.href)}renderPage(t,e=!1,r=!0){const n=new ut(this.snapshot,t,e,r);return this.render(n)}renderError(t){const e=new ct(this.snapshot,t,!1);return this.render(e)}clearSnapshotCache(){this.snapshotCache.clear()}async cacheSnapshot(){if(this.shouldCacheSnapshot){this.delegate.viewWillCacheSnapshot();const{snapshot:t,lastRenderedLocation:e}=this;await new Promise((t=>setTimeout((()=>t()),0)));const r=t.clone();return this.snapshotCache.put(e,r),r}}getCachedSnapshotForLocation(t){return this.snapshotCache.get(t)}get snapshot(){return W.fromElement(this.element)}get shouldCacheSnapshot(){return this.snapshot.isCacheable}}function ht(t){Object.defineProperties(t,dt)}const dt={absoluteURL:{get(){return this.toString()}}},pt=new class{constructor(){this.navigator=new ot(this),this.history=new et(this),this.view=new ft(this,document.documentElement),this.adapter=new Q(this),this.pageObserver=new it(this),this.cacheObserver=new X,this.linkClickObserver=new rt(this),this.formSubmitObserver=new G(this),this.scrollObserver=new st(this),this.streamObserver=new at(this),this.frameRedirector=new tt(document.documentElement),this.drive=!0,this.enabled=!0,this.progressBarDelay=500,this.started=!1}start(){this.started||(this.pageObserver.start(),this.cacheObserver.start(),this.linkClickObserver.start(),this.formSubmitObserver.start(),this.scrollObserver.start(),this.streamObserver.start(),this.frameRedirector.start(),this.history.start(),this.started=!0,this.enabled=!0)}disable(){this.enabled=!1}stop(){this.started&&(this.pageObserver.stop(),this.cacheObserver.stop(),this.linkClickObserver.stop(),this.formSubmitObserver.stop(),this.scrollObserver.stop(),this.streamObserver.stop(),this.frameRedirector.stop(),this.history.stop(),this.started=!1)}registerAdapter(t){this.adapter=t}visit(t,e={}){this.navigator.proposeVisit(h(t),e)}connectStreamSource(t){this.streamObserver.connectStreamSource(t)}disconnectStreamSource(t){this.streamObserver.disconnectStreamSource(t)}renderStreamMessage(t){document.documentElement.appendChild(C.wrap(t).fragment)}clearCache(){this.view.clearSnapshotCache()}setProgressBarDelay(t){this.progressBarDelay=t}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}historyPoppedToLocationWithRestorationIdentifier(t,e){this.enabled?this.navigator.startVisit(t,e,{action:"restore",historyChanged:!0}):this.adapter.pageInvalidated()}scrollPositionChanged(t){this.history.updateRestorationData({scrollPosition:t})}willFollowLinkToLocation(t,e){return this.elementDriveEnabled(t)&&g(e,this.snapshot.rootLocation)&&this.applicationAllowsFollowingLinkToLocation(t,e)}followedLinkToLocation(t,e){const r=this.getActionForLink(t);this.convertLinkWithMethodClickToFormSubmission(t)||this.visit(e.href,{action:r})}convertLinkWithMethodClickToFormSubmission(t){const e=t.getAttribute("data-turbo-method");if(e){const r=document.createElement("form");r.method=e,r.action=t.getAttribute("href")||"undefined",r.hidden=!0,t.hasAttribute("data-turbo-confirm")&&r.setAttribute("data-turbo-confirm",t.getAttribute("data-turbo-confirm"));const n=this.getTargetFrameForLink(t);return n?(r.setAttribute("data-turbo-frame",n),r.addEventListener("turbo:submit-start",(()=>r.remove()))):r.addEventListener("submit",(()=>r.remove())),document.body.appendChild(r),O("submit",{cancelable:!0,target:r})}return!1}allowsVisitingLocationWithAction(t,e){return this.locationWithActionIsSamePage(t,e)||this.applicationAllowsVisitingLocation(t)}visitProposedToLocation(t,e){ht(t),this.adapter.visitProposedToLocation(t,e)}visitStarted(t){ht(t.location),t.silent||this.notifyApplicationAfterVisitingLocation(t.location,t.action)}visitCompleted(t){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=p(t,e);return this.elementDriveEnabled(t)&&(!e||this.elementDriveEnabled(e))&&g(h(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(){var t;(null===(t=this.navigator.currentVisit)||void 0===t?void 0:t.silent)||this.notifyApplicationBeforeCachingSnapshot()}allowsImmediateRender({element:t},e){return!this.notifyApplicationBeforeRender(t,e).defaultPrevented}viewRenderedSnapshot(t,e){this.view.lastRenderedLocation=this.history.location,this.notifyApplicationAfterRender()}viewInvalidated(){this.adapter.pageInvalidated()}frameLoaded(t){this.notifyApplicationAfterFrameLoad(t)}frameRendered(t,e){this.notifyApplicationAfterFrameRender(t,e)}applicationAllowsFollowingLinkToLocation(t,e){return!this.notifyApplicationAfterClickingLinkToLocation(t,e).defaultPrevented}applicationAllowsVisitingLocation(t){return!this.notifyApplicationBeforeVisitingLocation(t).defaultPrevented}notifyApplicationAfterClickingLinkToLocation(t,e){return O("turbo:click",{target:t,detail:{url:e.href},cancelable:!0})}notifyApplicationBeforeVisitingLocation(t){return O("turbo:before-visit",{detail:{url:t.href},cancelable:!0})}notifyApplicationAfterVisitingLocation(t,e){return j(document.documentElement),O("turbo:visit",{detail:{url:t.href,action:e}})}notifyApplicationBeforeCachingSnapshot(){return O("turbo:before-cache")}notifyApplicationBeforeRender(t,e){return O("turbo:before-render",{detail:{newBody:t,resume:e},cancelable:!0})}notifyApplicationAfterRender(){return O("turbo:render")}notifyApplicationAfterPageLoad(t={}){return k(document.documentElement),O("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 O("turbo:frame-load",{target:t})}notifyApplicationAfterFrameRender(t,e){return O("turbo:frame-render",{detail:{fetchResponse:t},target:e,cancelable:!0})}elementDriveEnabled(t){const e=null==t?void 0:t.closest("[data-turbo]");return this.drive?!e||"false"!=e.getAttribute("data-turbo"):!!e&&"true"==e.getAttribute("data-turbo")}getActionForLink(t){const e=t.getAttribute("data-turbo-action");return nt(e)?e:"advance"}getTargetFrameForLink(t){const e=t.getAttribute("data-turbo-frame");if(e)return e;{const e=t.closest("turbo-frame");if(e)return e.id}}get snapshot(){return this.view.snapshot}},{navigator:mt}=pt;function yt(){pt.start()}function gt(t,e){pt.visit(t,e)}function bt(){pt.clearCache()}var vt=Object.freeze({__proto__:null,navigator:mt,session:pt,PageRenderer:ut,PageSnapshot:W,start:yt,registerAdapter:function(t){pt.registerAdapter(t)},visit:gt,connectStreamSource:function(t){pt.connectStreamSource(t)},disconnectStreamSource:function(t){pt.disconnectStreamSource(t)},renderStreamMessage:function(t){pt.renderStreamMessage(t)},clearCache:bt,setProgressBarDelay:function(t){pt.setProgressBarDelay(t)},setConfirmMethod:function(t){x.confirmMethod=t}});class wt{constructor(t){this.visitCachedSnapshot=({element:t})=>{var e;const{id:r,clone:n}=this;null===(e=t.querySelector("#"+r))||void 0===e||e.replaceWith(n)},this.clone=t.cloneNode(!0),this.id=t.id}}function Ot(t){if(null!=t){const e=document.getElementById(t);if(e instanceof f)return e}}function Et(t,e){if(t){const n=t.getAttribute("src");if(null!=n&&null!=e&&(r=e,h(n).href==h(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 f)return t.connectedCallback(),t.disconnectedCallback(),t}var r}const St={after(){this.targetElements.forEach((t=>{var e;return null===(e=t.parentElement)||void 0===e?void 0:e.insertBefore(this.templateContent,t.nextSibling)}))},append(){this.removeDuplicateTargetChildren(),this.targetElements.forEach((t=>t.append(this.templateContent)))},before(){this.targetElements.forEach((t=>{var e;return null===(e=t.parentElement)||void 0===e?void 0:e.insertBefore(this.templateContent,t)}))},prepend(){this.removeDuplicateTargetChildren(),this.targetElements.forEach((t=>t.prepend(this.templateContent)))},remove(){this.targetElements.forEach((t=>t.remove()))},replace(){this.targetElements.forEach((t=>t.replaceWith(this.templateContent)))},update(){this.targetElements.forEach((t=>{t.innerHTML="",t.append(this.templateContent)}))}};class Pt extends HTMLElement{async connectedCallback(){try{await this.render()}catch(t){}finally{this.disconnect()}}async render(){var t;return null!==(t=this.renderPromise)&&void 0!==t?t:this.renderPromise=(async()=>{this.dispatchEvent(this.beforeRenderEvent)&&(await E(),this.performAction())})()}disconnect(){try{this.remove()}catch(t){}}removeDuplicateTargetChildren(){this.duplicateChildren.forEach((t=>t.remove()))}get duplicateChildren(){var t;const e=this.targetElements.flatMap((t=>[...t.children])).filter((t=>!!t.id)),r=[...null===(t=this.templateContent)||void 0===t?void 0:t.children].filter((t=>!!t.id)).map((t=>t.id));return e.filter((t=>r.includes(t.id)))}get performAction(){if(this.action){const t=St[this.action];if(t)return t;this.raise("unknown action")}this.raise("action attribute is missing")}get targetElements(){return this.target?this.targetElementsById:this.targets?this.targetElementsByQuery:void this.raise("target or targets attribute is missing")}get templateContent(){return this.templateElement.content.cloneNode(!0)}get templateElement(){if(this.firstElementChild instanceof HTMLTemplateElement)return this.firstElementChild;this.raise("first child element must be a