unpoly
Version:
Progressive enhancement for HTML
1 lines • 177 kB
JavaScript
(()=>{var t={5941:()=>{},7433:()=>{},7921:()=>{},7298:()=>{},2903:()=>{},573:()=>{},2811:()=>{up.browser={submitForm:function(t){t.submit()},canPushState:function(){return"GET"===up.protocol.initialRequestMethod()},canJQuery:function(){return!!window.jQuery},assertConfirmed:function(t){if(t.confirm&&!window.confirm(t.confirm))throw new up.Aborted("User canceled action");return!0},popCookie:function(t){var e;let n=null===(e=document.cookie.match(new RegExp(t+"=(\\w+)")))||void 0===e?void 0:e[1];if(n)return document.cookie=t+"=;Max-Age=0;Path=/",n}}},6346:()=>{const t=up.element,e=up.util;up.BodyShifter=class BodyShifter{constructor(){this.t=new Set,this.i=0,this.o=e.cleaner()}lowerStack(){0==--this.i&&this.o.clean()}raiseStack(){1==++this.i&&this.u()}onAnchoredElementInserted(t){return this.t.add(t),this.h(t,"right"),()=>this.t.delete(t)}l(){return this.p&&this.i>0}u(){this.p=up.viewport.rootScrollbarWidth(),this.o(t.setStyleTemp(t.root,{"--up-scrollbar-width":this.p+"px"})),this.h(document.body,"padding-right");for(let t of this.t)this.h(t,"right")}h(e,n){if(!this.l())return;let i=t.style(e,n);this.o(t.setStyleTemp(e,{["--up-original-"+n]:i}),t.addClassTemp(e,"up-scrollbar-away"))}}},7948:()=>{const t=up.util,e=up.element;up.Change.Addition=class Addition extends up.Change{constructor(t){super(t),this.m=t.acceptLayer,this.v=t.dismissLayer,this._=t.eventPlans||[],this.O=t.response}handleLayerChangeRequests(){this.layer.isOverlay()&&(this.k(),this.abortWhenLayerClosed(),this.layer.tryAcceptForLocation(this.S()),this.abortWhenLayerClosed(),this.j(),this.abortWhenLayerClosed(),this.layer.tryDismissForLocation(this.S()),this.abortWhenLayerClosed()),this.layer.asCurrent((()=>{for(let t of this._)up.emit(Object.assign(Object.assign({},t),this.S())),this.abortWhenLayerClosed()}))}k(){t.isDefined(this.m)&&this.layer.isOverlay()&&this.layer.accept(this.m,this.S())}j(){t.isDefined(this.v)&&this.layer.isOverlay()&&this.layer.dismiss(this.v,this.S())}abortWhenLayerClosed(t=this.layer){if(t.isClosed())throw new up.Aborted("Layer was closed")}C({oldElement:t,newElement:n,source:i}){"keep"===i&&(i=t&&up.fragment.source(t)),i&&e.setMissingAttr(n,"up-source",up.fragment.normalizeSource(i))}F({newElement:t,time:n}){e.setMissingAttr(t,"up-time",!!n&&n.toUTCString())}T({newElement:t,etag:n}){e.setMissingAttr(t,"up-etag",n||!1)}setReloadAttrs(t){this.C(t),this.F(t),this.T(t)}S(){return{response:this.O}}executeSteps(t,e,n){return new up.Change.UpdateSteps({steps:t,noneOptions:n}).execute(e)}}},3030:()=>{const t=up.util;up.Change=class Change{constructor(t){this.options=t}execute(){throw new up.NotImplemented}improveHistoryValue(e,n){return!1===e||t.isString(e)?e:n}deriveFailOptions(){return up.RenderOptions.deriveFailOptions(this.options)}}},7422:()=>{const t=up.util;up.Change.CloseLayer=class CloseLayer extends up.Change{constructor(t){var e,n;super(t),this.P=t.verb,this.R=up.layer.get(t),this.L=t.origin,this.A=t.value,this.$=null===(e=t.preventable)||void 0===e||e,this.O=t.response,this.D=null===(n=t.history)||void 0===n||n}execute(){if(!this.R.isOpen())return;if(up.browser.assertConfirmed(this.options),this.M().defaultPrevented&&this.$)throw new up.Aborted("Close event was prevented");this.N(),up.fragment.abort({reason:"Layer is closing",layer:this.R});const{parent:t}=this.R;this.R.peel(),this.R.stack.remove(this.R),this.D&&t.restoreHistory(),this.H(t),this.R.teardownHandlers(),this.R.destroyElements(this.options),this.q(t)}M(){let e=this.R.emit(this.B(`up:layer:${this.P}`),{callback:this.R.callback(`on${t.upperCaseFirst(this.P)}`),log:[`Will ${this.P} ${this.R} with value %o`,this.A]});return this.A=e.value,e}N(){let t=this.B(`up:layer:${this.P}ing`);this.R.emit(t,{log:!1})}q(e){const n=`${this.P}ed`,i=t.upperCaseFirst(n);return this.R.emit(this.B(`up:layer:${n}`),{baseLayer:e,callback:this.R.callback(`on${i}`),ensureBubbles:!0,log:[`${i} ${this.R} with value %o`,this.A]})}B(t){return up.event.build(t,{layer:this.R,value:this.A,origin:this.L,response:this.O})}H(t){var e;let n=this.R.hasFocus();if(this.R.overlayFocus.teardown(),null===(e=t.overlayFocus)||void 0===e||e.moveToFront(),n){let e=this.R.origin||t.element;up.focus(e,{preventScroll:!0})}}}},8228:function(){var t=this&&this.U||function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{a(i.next(t))}catch(t){s(t)}}function u(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((i=i.apply(t,e||[])).next())}))};up.Change.DestroyFragment=class DestroyFragment extends up.Change{constructor(t){super(t),this.R=up.layer.get(t)||up.layer.current,this.I=this.options.element,this.V=this.options.animation,this.K=this.options.log,this.X=this.options.onFinished}execute(){this.W=this.I.parentNode,up.fragment.markAsDestroying(this.I),up.motion.willAnimate(this.I,this.V,this.options)?this.G():this.J()}G(){var e;return t(this,void 0,void 0,(function*(){this.Y(),yield this.Z(),this.tt(),null===(e=this.X)||void 0===e||e.call(this)}))}J(){var t;this.tt(),this.Y(),null===(t=this.X)||void 0===t||t.call(this)}Z(){return up.motion.animate(this.I,this.V,this.options)}tt(){this.R.asCurrent((()=>{up.fragment.abort(this.I),up.script.clean(this.I,{layer:this.R}),up.element.cleanJQuery(this.I),this.I.remove()}))}Y(){up.fragment.emitDestroyed(this.I,{parent:this.W,log:this.K})}}},9005:()=>{var t;const e=up.util;up.Change.FromContent=(t=class FromContent extends up.Change{constructor(t){super(t),this.L=t.origin,this.et=t.preflight,this.nt=up.layer.getAll(t)}it(){let t=[];return this.rt(),this.st(),this.ot(t,this.nt,this.options.target),this.ot(t,this.nt,this.options.fallback),t}ut(t){return"new"===t||t.isOpen()}rt(){this.nt=e.filter(this.nt,this.ut)}ot(t,e,n){for(let i of e)for(let e of this.ct(n,i)){const n=Object.assign(Object.assign({},this.options),{target:e,layer:i,defaultPlacement:this.ht()}),r="new"===i?new up.Change.OpenLayer(n):new up.Change.UpdateLayer(n);t.push(r)}}ct(t,e){return up.fragment.expandTargets(t,{layer:e,mode:this.options.mode,origin:this.L})}execute(){return this.options.preload?Promise.resolve():this.lt(this.ft.bind(this))||this.dt()}ft(t){let e=t.execute(this.gt(),this.vt.bind(this,t));return e.options=this.options,e}bt(t){return!(t instanceof up.CannotMatch)}vt(t){var e,n;let i=this.it()[0];t!==i&&up.puts("up.render()",'Could not match primary target "%s". Updating a fallback target "%s".',i.target,t.target);let{assets:r}=this.gt();r&&up.script.assertAssetsOK(r,t.options),null===(n=(e=this.options).handleAbort)||void 0===n||n.call(e,null)}gt(){var t,n;if(this.et)return;const i=e.pick(this.options,["target","content","fragment","document","html","cspNonces","origin","data"]);return null===(n=(t=up.migrate).handleResponseDocOptions)||void 0===n||n.call(t,i),"content"===this.ht()&&(i.target=this.yt(i.target)),new up.ResponseDoc(i)}st(){var t;if(this.et)return;let e=this.gt();this.options.fragment&&((t=this.options).target||(t.target=e.rootSelector())),this.options.title=this.improveHistoryValue(this.options.title,e.title),this.options.metaTags=this.improveHistoryValue(this.options.metaTags,e.metaTags),this.options.lang=this.improveHistoryValue(this.options.lang,e.lang)}ht(){if(!this.options.document&&!this.options.fragment)return"content"}yt(t){let e=this.nt[0]||up.layer.root;return this.ct(t||":main",e)[0]}getPreflightProps(t={}){return this.lt((t=>t.getPreflightProps()))||t.optional||this.wt()}wt(){this._t("Could not find target in current page")}dt(){this._t("Could not find common target in current page and response")}_t(t){if(this.it().length){const n=e.uniq(e.map(this.it(),"target")),i=up.layer.optionToString(this.options.layer);throw new up.CannotMatch([t+" (tried selectors %o in %s)",n,i])}if(0!==this.nt.length)throw this.options.failPrefixForced?new up.CannotMatch("No target selector given for failed responses (https://unpoly.com/failed-responses)"):new up.CannotMatch("No target selector given");this.Ot()}Ot(){throw new up.CannotMatch("Could not find a layer to render in. You may have passed an unmatchable layer reference, or a detached element.")}lt(t){for(let e of this.it())try{return t(e)}catch(t){if(this.bt(t))throw t}}},e.memoizeMethod(t.prototype,{it:!0,gt:!0,getPreflightProps:!0}),t)},278:function(){var t,e=this&&this.U||function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{a(i.next(t))}catch(t){s(t)}}function u(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((i=i.apply(t,e||[])).next())}))};const n=up.util;up.Change.FromResponse=(t=class FromResponse extends up.Change{constructor(t){super(t),this.O=t.response,this.kt=this.O.request}execute(){var t;if(up.fragment.config.skipResponse(this.St())?this.xt():this.kt.assertEmitted("up:fragment:loaded",Object.assign(Object.assign({},this.St()),{callback:this.options.onLoaded,log:["Loaded fragment from %s",this.O.description],skip:()=>this.xt()})),null!==(t=n.evalOption(this.options.fail,this.O))&&void 0!==t?t:!this.O.ok)throw this.Et(this.deriveFailOptions());return this.Et(this.options)}xt(){up.puts("up.render()","Skipping "+this.O.description),this.options.target=":none",this.options.failTarget=":none"}Et(t){t.failPrefixForced&&up.puts("up.render()","Rendering failed response using fail-prefixed options (https://unpoly.com/failed-responses)"),this.jt(t),t.meta=this.Ct();let e=new up.Change.FromContent(t).execute();return e.finished=this.finish(e,t),e}finish(t,n){return e(this,void 0,void 0,(function*(){return t=yield t.finished,up.fragment.shouldRevalidate(this.kt,this.O,n)&&(t=yield this.Ft(t,n)),t}))}Ft(t,n){return e(this,void 0,void 0,(function*(){let e=n.target,i=t.target;if(/:(before|after)/.test(e))up.warn("up.render()","Cannot revalidate cache when prepending/appending (target %s)",e);else{up.puts("up.render()",'Revalidating cached response for target "%s"',i);let e=yield up.reload(i,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n),up.RenderOptions.NO_MOTION),up.RenderOptions.NO_INPUT_INTERFERENCE),up.RenderOptions.NO_PREVIEWS),{preferOldElements:t.fragments,layer:t.layer,onFinished:null,expiredResponse:this.O,preview:this.Tt(n),abort:!1,cache:!1,background:!0}));e.none||(t=e)}return t}))}Tt({preview:t,revalidatePreview:e}){return!0===e?t:e}St(){const{expiredResponse:t}=this.options;return{request:this.kt,response:this.O,renderOptions:this.options,revalidating:!!t,expiredResponse:t}}Ct(){var t,e;let n={revalidating:!!this.options.expiredResponse};return null===(e=(t=up.migrate).processCompilerPassMeta)||void 0===e||e.call(t,n,this.O),n}jt(t){var e,i;const r=this.O.url;let s=r,o=this.kt.hash;o&&(t.hash=o,s+=o),"GET"===this.O.method?t.source=this.improveHistoryValue(t.source,r):(t.source=this.improveHistoryValue(t.source,"keep"),t.history=!!t.location),t.location=this.improveHistoryValue(t.location,s),t.title=this.improveHistoryValue(t.title,this.O.title),t.eventPlans=this.O.eventPlans;let u=this.O.target;u&&(t.target=u),t.acceptLayer=this.O.acceptLayer,t.dismissLayer=this.O.dismissLayer,t.document=this.O.text,this.O.none&&(t.target=":none"),t.context=n.merge(t.context,this.O.context),t.cspNonces=this.O.cspNonces,null!==(e=t.time)&&void 0!==e||(t.time=this.O.lastModified),null!==(i=t.etag)&&void 0!==i||(t.etag=this.O.etag)}},n.memoizeMethod(t.prototype,{St:!0}),t)},2200:function(){var t,e=this&&this.U||function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{a(i.next(t))}catch(t){s(t)}}function u(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((i=i.apply(t,e||[])).next())}))};const n=up.util;up.Change.FromURL=(t=class FromURL extends up.Change{execute(){var t,i,r,s;return e(this,void 0,void 0,(function*(){let e=this.Pt();if(e)return up.puts("up.render()",e),up.network.loadPage(this.options),n.unresolvablePromise();let o=this.request=up.request(this.Rt());return null===(i=(t=this.options).onRequestKnown)||void 0===i||i.call(t,o),this.options.preload?o:(null===(s=(r=this.options).handleAbort)||void 0===s||s.call(r,o),o.runPreviews(this.options),yield n.always(o,(t=>this.Lt(t))))}))}Pt(){return n.isCrossOrigin(this.options.url)?"Loading cross-origin content in new page":this.options.history&&!up.browser.canPushState()?"Loading content in new page to restore history support":void 0}Rt(){const t=this.At(this.options),e=this.At(this.deriveFailOptions(),{optional:!0});return Object.assign(Object.assign(Object.assign({},this.options),t),n.withRenamedKeys(e,up.fragment.failKey))}getPreflightProps(){return this.Rt()}At(t,e){return new up.Change.FromContent(Object.assign(Object.assign({},t),{preflight:!0})).getPreflightProps(e)}Lt(t){return t instanceof up.Response?this.$t(t):this.Dt(t)}$t(t){return new up.Change.FromResponse(Object.assign(Object.assign({},this.options),{response:t})).execute()}Dt(t){throw t instanceof up.Offline&&this.request.emit("up:fragment:offline",{callback:this.options.onOffline,renderOptions:this.options,retry:t=>up.render(Object.assign(Object.assign({},this.options),t)),log:["Cannot load fragment from %s: %s",this.request.description,t.reason]}),t}},n.memoizeMethod(t.prototype,{Rt:!0}),t)},7050:function(){var t=this&&this.U||function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{a(i.next(t))}catch(t){s(t)}}function u(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((i=i.apply(t,e||[])).next())}))};let e=up.util;up.Change.OpenLayer=class OpenLayer extends up.Change.Addition{constructor(t){super(t),this.target=t.target,this.L=t.origin,this.Mt=t.baseLayer}getPreflightProps(){return{mode:this.options.mode,context:this.Nt().context,origin:this.options.origin,target:this.target,bindLayer:this.Mt,layer:"new",bindFragments:e.compact([up.fragment.get(":main",{layer:this.Mt})]),fragments:[]}}execute(t,e){this.responseDoc=t,this.Ht(),e(),this.qt();let n=this.layer.on("up:layer:accepting up:layer:dimissing",this.Bt.bind(this));try{return this.Ut(),this.Bt(),up.RenderResult.both(this.It,this.zt)}finally{n()}}Ht(){if(":none"===this.target?this.Vt=document.createElement("up-none"):this.Vt=this.responseDoc.select(this.target),!this.Vt||this.Mt.isClosed())throw new up.CannotMatch}qt(){up.puts("up.render()",`Opening element "${this.target}" in new overlay`),this.Kt(),this.layer=this.Nt(),this.Mt.peel({history:!this.layer.history}),up.layer.stack.push(this.layer),this.layer.createElements(),this.layer.setupHandlers()}Ut(){this.Xt(),this.handleLayerChangeRequests(),this.responseDoc.commitElement(this.Vt),this.layer.setContent(this.Vt),this.setReloadAttrs({newElement:this.Vt,source:this.options.source}),this.responseDoc.finalizeElement(this.Vt),this.It=new up.RenderResult({layer:this.layer,fragments:[this.Vt],target:this.target}),up.hello(this.layer.element,Object.assign(Object.assign({},this.options),{layer:this.layer,dataRoot:this.Vt})),this.Wt(),this.It.finished=this.Gt(),this.layer.opening=!1,this.Jt(),this.abortWhenLayerClosed()}Bt(){if(this.zt)return;let t=this.Qt().other;this.zt=this.executeSteps(t,this.responseDoc)}Gt(){return t(this,void 0,void 0,(function*(){return yield this.layer.startOpenAnimation(),this.abortWhenLayerClosed(),this.H(),this.It}))}Nt(){const t=Object.assign(Object.assign({},this.options),{opening:!0});return up.layer.build(t,(t=>this.options=up.RenderOptions.finalize(t)))}Xt(){var t;"auto"===this.layer.history&&(this.layer.history=up.fragment.hasAutoHistory([this.Vt],this.layer));let{parent:e}=this.layer;(t=this.layer).history&&(t.history=e.history),e.saveHistory(),this.layer.updateHistory(this.options)}H(){var t;null===(t=this.Mt.overlayFocus)||void 0===t||t.moveToBack(),this.layer.overlayFocus.moveToFront(),new up.FragmentFocus({fragment:this.Vt,layer:this.layer,autoMeans:["autofocus","layer"],inputDevice:this.options.inputDevice}).process(this.options.focus)}Wt(){const t=Object.assign(Object.assign({},this.options),{fragment:this.Vt,layer:this.layer,autoMeans:["hash","layer"]});new up.FragmentScrolling(t).process(this.options.scroll)}Kt(){up.event.assertEmitted("up:layer:open",{origin:this.L,baseLayer:this.Mt,layerOptions:this.options,log:"Opening new overlay"})}Jt(){this.layer.emit("up:layer:opened",{origin:this.L,callback:this.layer.callback("onOpened"),log:`Opened new ${this.layer}`})}Qt(){return up.radio.hungrySteps(this.Yt())}Yt(){return Object.assign(Object.assign({},this.options),{layer:this.layer,history:this.layer.history})}}},9441:()=>{var t;const e=up.util;up.Change.UpdateLayer=(t=class UpdateLayer extends up.Change.Addition{constructor(t){super(t=up.RenderOptions.finalize(t)),this.layer=t.layer,this.target=t.target,this.Zt=t.context,this.te=up.fragment.parseTargetSteps(this.target,this.options)}getPreflightProps(){this.ee();let t=this.ne();return{layer:this.layer,bindLayer:this.layer,mode:this.layer.mode,context:e.merge(this.layer.context,this.Zt),origin:this.options.origin,target:this.ie(),fragments:t,bindFragments:t}}ie(){return this.ee(),up.fragment.targetForSteps(this.te)}ne(){return this.ee(),e.map(this.te,"oldElement")}execute(t,e){this.responseDoc=t,this.Ht(),e();let n=this.layer.on("up:layer:accepting up:layer:dimissing",this.Bt.bind(this));try{return this.re(),this.Bt(),up.RenderResult.both(this.se,this.zt)}finally{n()}}re(){this.te.length&&up.puts("up.render()",`Updating "${this.ie()}" in ${this.layer}`),this.oe(),this.options.saveScroll&&up.viewport.saveScroll({layer:this.layer}),this.options.saveFocus&&up.viewport.saveFocus({layer:this.layer}),this.options.peel&&this.layer.peel({history:!this.ue()}),!1!==this.options.abort&&up.fragment.abort(this.ne(),{reason:"Fragment is being replaced"}),Object.assign(this.layer.context,this.Zt),this.ue()&&this.layer.updateHistory(this.options),this.handleLayerChangeRequests(),this.se=this.executeSteps(this.te,this.responseDoc,this.options)}Bt(){if(this.zt)return;let t=this.Qt().other;this.zt=this.executeSteps(t,this.responseDoc)}ee(){this.ae(),this.ce()}Ht(){this.ae(),this.he(),this.ce(),this.le()}he(){this.te.push(...this.Qt().current)}ae(){this.te=this.te.filter((t=>{const n=new up.FragmentFinder(e.pick(t,["selector","origin","layer","match","preferOldElements"]));if(t.oldElement||(t.oldElement=n.find()),t.oldElement)return!0;if(!t.maybe)throw new up.CannotMatch}))}le(){this.te=this.responseDoc.selectSteps(this.te)}ce(){this.te=up.fragment.compressNestedSteps(this.te)}Qt(){return up.radio.hungrySteps(this.Yt())}oe(){let t=up.FocusCapsule.preserve(this.layer);this.te.forEach(((e,n)=>{e.focusCapsule=t,n>0&&(e.scroll=!1,e.focus=!1)}))}ue(){return e.evalAutoOption(this.options.history,this.pe.bind(this))}pe(){const t=e.map(this.te,"oldElement");return up.fragment.hasAutoHistory(t,this.layer)}Yt(){return Object.assign(Object.assign({},this.options),{layer:this.layer,history:this.ue()})}},e.memoizeMethod(t.prototype,{ee:!0,ae:!0,ue:!0,Qt:!0}),t)},9489:function(){var t=this&&this.U||function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{a(i.next(t))}catch(t){s(t)}}function u(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((i=i.apply(t,e||[])).next())}))};const e=up.util,n=up.element;up.Change.UpdateSteps=class UpdateSteps extends up.Change.Addition{constructor(t){super(t),this.fe=t.noneOptions||{},this.te=e.copy(t.steps)}execute(t){var e;if(this.responseDoc=t,this.te=t.selectSteps(this.te),this.te=t.commitSteps(this.te),!this.te.length)return this.de();this.renderResult=new up.RenderResult({layer:null===(e=this.te[0])||void 0===e?void 0:e.layer,target:up.fragment.targetForSteps(this.te)}),this.te.reverse();const n=this.te.map((t=>this.me(t)));return this.renderResult.finished=this.Gt(n),this.renderResult}de(){return this.H(null,this.fe),this.Wt(null,this.fe),up.RenderResult.buildNone()}Gt(e){return t(this,void 0,void 0,(function*(){yield Promise.all(e);for(let t of this.te)this.abortWhenLayerClosed(t.layer);return this.renderResult}))}ge(t){let e=t.matches("up-wrapper")?t.children:[t];this.renderResult.fragments.unshift(...e)}me(t){switch(this.setReloadAttrs(t),t.placement){case"swap":if(this.ve(t))return this.H(t.oldElement,t),this.Wt(t.oldElement,t),Promise.resolve();{this.be(t);const e=t.oldElement.parentNode,i=Object.assign(Object.assign({},t),{beforeStart(){up.fragment.markAsDestroying(t.oldElement)},afterInsert:()=>{this.ye(t),this.responseDoc.finalizeElement(t.newElement),this.we(t),up.hello(t.newElement,t),this.ge(t.newElement)},beforeDetach:()=>{up.script.clean(t.oldElement,{layer:t.layer})},afterDetach(){n.cleanJQuery(),up.fragment.emitDestroyed(t.oldElement,{parent:e,log:!1})},scrollNew:()=>{this.H(t.newElement,t),this.Wt(t.newElement,t)}});return up.morph(t.oldElement,t.newElement,t.transition,i)}case"content":{let e=n.wrapChildren(t.oldElement),i=n.wrapChildren(t.newElement),r=Object.assign(Object.assign({},t),{placement:"swap",oldElement:e,newElement:i,focus:!1});return this.me(r).then((()=>{n.unwrap(i),this.H(t.oldElement,t)}))}case"before":case"after":{let e=n.wrapChildren(t.newElement),i="before"===t.placement?"afterbegin":"beforeend";return t.oldElement.insertAdjacentElement(i,e),this.responseDoc.finalizeElement(e),up.hello(e,t),this.ge(e),this.H(e,t),this.Wt(e,t),up.animate(e,t.transition,t).then((()=>n.unwrap(e)))}default:up.fail("Unknown placement: %o",t.placement)}}ve(t){if(!t.keep)return;const{oldElement:e,newElement:i}=t;let r;if(!n.booleanAttr(e,"up-keep"))return;let s=up.fragment.toTarget(e);const o={layer:t.layer};if(r=t.descendantsOnly?up.fragment.get(i,s,o):n.subtreeFirst(i,s,o),r&&!1!==n.booleanAttr(r,"up-keep")){const n={oldElement:e,newElement:r,newData:up.script.data(r),renderOptions:t};if(!up.fragment.emitKeep(n).defaultPrevented)return n}}be(t){const e=[];if(t.keep)for(let n of t.oldElement.querySelectorAll("[up-keep]")){let i=this.ve(Object.assign(Object.assign({},t),{oldElement:n,descendantsOnly:!0}));if(i){const t=n.cloneNode(!0);n.insertAdjacentElement("beforebegin",t),n.classList.add("up-keeping"),up.script.disableSubtree(i.newElement);let r=up.viewport.subtree(i.oldElement);i.revivers=r.map((function(t){let e=up.viewport.copyCursorProps(t);return()=>up.viewport.copyCursorProps(e,t)})),this._e(document.body)?i.newElement.replaceWith(n):document.body.append(n),e.push(i)}}t.keepPlans=e}ye(t){for(let e of t.keepPlans){e.newElement.replaceWith(e.oldElement);for(let t of e.revivers)t()}}we(t){for(let e of t.keepPlans)e.oldElement.classList.remove("up-keeping")}_e(t){return e.some(this.te,(e=>e.oldElement.contains(t)))}H(t,e){return new up.FragmentFocus(Object.assign(Object.assign({},e),{fragment:t,autoMeans:up.fragment.config.autoFocus})).process(e.focus)}Wt(t,e){return new up.FragmentScrolling(Object.assign(Object.assign({},e),{fragment:t,autoMeans:up.fragment.config.autoScroll})).process(e.scroll)}}},1569:()=>{const t=up.util;up.CompilerPass=class CompilerPass{constructor(t,e,{layer:n,data:i,dataRoot:r,dataMap:s,meta:o}){n||(n=up.layer.get(t)||up.layer.current),this.Oe=t,this.ke=e,this.R=n,this.Se=i,this.xe=r||t,this.Ee=s,o||(o={}),o.layer=n,this.je=o}run(){this.R.asCurrent((()=>{this.setCompileData();for(let t of this.ke)this.Ce(t)}))}setCompileData(){if(this.Se&&(this.xe.upCompileData=this.Se),this.Ee)for(let t in this.Ee)for(let e of this.Fe(t))e.upCompileData=this.Ee[t]}Ce(t){var e,n;const i=this.Te(t);if(i.length){if(t.isDefault||up.puts("up.hello()",'Compiling %d× "%s" on %s',i.length,t.selector,this.R),t.batch)this.Pe(t,i);else for(let e of i)this.Re(t,e);return null===(n=(e=up.migrate).postCompile)||void 0===n?void 0:n.call(e,i,t)}}Re(t,e){const n=[e];if(1!==t.length){const t=up.script.data(e);n.push(t,this.je)}const i=this.Le(t,e,n);up.destructor(e,i)}Pe(e,n){const i=[n];if(1!==e.length){const e=t.map(n,up.script.data);i.push(e,this.je)}this.Le(e,n,i)&&up.fail("Compilers with { batch: true } cannot return destructors")}Le(t,e,n){return up.error.guard((()=>t.apply(e,n)))}Fe(e){return up.fragment.subtree(this.Oe,t.evalOption(e),{layer:this.R})}Te(e){let n=this.Fe(e.selector);return t.filter(n,(t=>{let n=t.upAppliedCompilers||(t.upAppliedCompilers=new Set);if(!n.has(e))return n.add(e),!0}))}}},3742:()=>{const t=up.util,e=up.element;up.Config=class Config{constructor(t=(()=>({}))){this.Ae=t,this.reset(),document.addEventListener("up:framework:reset",(()=>this.reset()))}reset(){Object.assign(this,this.Ae())}matches(t,e){return t.matches(this.selector(e))}selector(n){let i=this[n],r=this["no"+t.upperCaseFirst(n)];return e.unionSelector(i,r)}selectorFn(t){return()=>this.selector(t)}}},2737:()=>{const t=up.util,e=up.element;up.CSSTransition=class CSSTransition{constructor(t,e,n){this.I=t,this.$e=e,this.De=Object.keys(this.$e),this.Me=n.finishEvent,this.Ne=n.duration,this.He=n.easing,this.qe=!1}start(){return 0===this.De.length?(this.qe=!0,Promise.resolve()):(this.Be=t.newDeferred(),this.Ue(),this.Ie=new Date,this.ze(),this.Ve(),this.Ke(),this.Xe(),this.Be)}Ve(){this.Me&&(this.We=up.on(this.I,this.Me,this.Ge.bind(this)))}Ge(t){t.stopPropagation(),this.Gt()}ze(){this.Je=t.timer(this.Ne+100,(()=>this.Gt()))}Qe(){clearTimeout(this.Je)}Ke(){this.Ye=up.on(this.I,"transitionend",this.Ze.bind(this))}Ze(e){if(e.target!==this.I)return;if(new Date-this.Ie<=.25*this.Ne)return;const n=e.propertyName;t.contains(this.De,n)&&this.Gt()}Gt(){var t,n;this.qe||(this.qe=!0,this.Qe(),null===(t=this.We)||void 0===t||t.call(this),null===(n=this.Ye)||void 0===n||n.call(this),e.concludeCSSTransition(this.I),this.tn(),this.Be.resolve())}Ue(){const t=e.style(this.I,["transition-property","transition-duration","transition-delay","transition-timing-function"]);if(e.hasCSSTransition(t)){if("all"!==t["transition-property"]){const n=t["transition-property"].split(/\s*,\s*/),i=e.style(this.I,n);this.en=e.setStyleTemp(this.I,i)}this.nn=e.concludeCSSTransition(this.I)}}tn(){var t,e;null===(t=this.en)||void 0===t||t.call(this),null===(e=this.nn)||void 0===e||e.call(this)}Xe(){e.setStyle(this.I,{"transition-property":this.De.join(),"transition-duration":`${this.Ne}ms`,"transition-timing-function":this.He}),e.setStyle(this.I,this.$e)}}},3635:()=>{const t=up.util;up.DestructorPass=class DestructorPass{constructor(t,e){this.rn=t,this.sn=e}run(){for(let e of this.un()){let n=t.pluckKey(e,"upDestructors");null==n||n.clean(e)}}un(){const t=Object.assign(Object.assign({},this.sn),{destroying:!0});return up.fragment.subtree(this.rn,".up-can-clean",t)}}},1906:()=>{const t=up.util,e=up.element;up.EventEmitter=class EventEmitter extends up.Record{keys(){return["target","event","baseLayer","callback","log","ensureBubbles"]}emit(){return this.an(),this.baseLayer?this.baseLayer.asCurrent((()=>this.cn())):this.cn(),this.event}cn(){this.target.dispatchEvent(this.event),this.ensureBubbles&&!this.target.isConnected&&document.dispatchEvent(this.event),up.error.guard((()=>{var t;return null===(t=this.callback)||void 0===t?void 0:t.call(this,this.event)}))}assertEmitted(){const t=this.emit();if(t.defaultPrevented)throw new up.Aborted(`Event ${t.type} was prevented`)}an(){if(!up.log.config.enabled)return;let e,n=this.log;t.isArray(n)?[n,...e]=n:e=[];const{type:i}=this.event;t.isString(n)?up.puts(i,n,...e):!1!==n&&up.puts(i,`Event ${i}`)}static fromEmitArgs(n,i={}){var r,s;let o,u=t.extractOptions(n);return u=t.merge(i,u),t.isElementLike(n[0])?u.target=e.get(n.shift()):n[0]instanceof up.Layer&&(u.layer=n.shift()),t.isGiven(u.layer)&&(o=up.layer.get(u.layer),u.target||(u.target=o.element),u.baseLayer||(u.baseLayer=o)),u.baseLayer&&(u.baseLayer=up.layer.get(u.baseLayer)),t.isString(u.target)?u.target=up.fragment.get(u.target,{layer:u.layer}):u.target||(u.target=document),(null===(r=n[0])||void 0===r?void 0:r.preventDefault)?(u.event=n[0],null!==(s=u.log)&&void 0!==s||(u.log=n[0].log)):t.isString(n[0])?u.event=up.event.build(n[0],u):u.event=up.event.build(u),new this(u)}}},4158:()=>{const t=up.util;up.EventListener=class EventListener extends up.Record{keys(){return["element","eventType","selector","callback","guard","baseLayer","passive","once","capture","beforeBoot"]}constructor(t){var e;super(t),this.hn=this.constructor.ln(t),this.isDefault=up.framework.evaling,null!==(e=this.beforeBoot)&&void 0!==e||(this.beforeBoot=0===this.eventType.indexOf("up:framework:")),this.nativeCallback=this.nativeCallback.bind(this)}bind(){var t;const e=(t=this.element).upEventListeners||(t.upEventListeners={});e[this.hn]&&up.fail("up.on(): The %o callback %o cannot be registered more than once",this.eventType,this.callback),e[this.hn]=this,this.element.addEventListener(...this.pn())}pn(){let e=t.compactObject(t.pick(this,["once","passive","capture"]));return[this.eventType,this.nativeCallback,e]}unbind(){let t=this.element.upEventListeners;t&&delete t[this.hn],this.element.removeEventListener(...this.pn())}nativeCallback(e){if(up.framework.beforeBoot&&!this.beforeBoot)return;let n=e.target;if(this.selector&&(n=n.closest(t.evalOption(this.selector))),(!this.guard||this.guard(e))&&n){const t=[e,n],i=this.callback.length;if(1!==i&&2!==i){const e=up.script.data(n);t.push(e)}if("click"===this.eventType&&n.disabled)return;const r=this.callback.bind(n,...t);this.baseLayer?this.baseLayer.asCurrent(r):r()}}static fromElement(t){let e=t.element.upEventListeners;if(e)return e[this.ln(t)]}static ln(e){var n;return(n=e.callback).upUid||(n.upUid=t.uid()),[e.eventType,e.selector,e.callback.upUid].join("|")}static allNonDefault(e){let n=e.upEventListeners;if(n){const e=Object.values(n);return t.reject(e,"isDefault")}return[]}}},3139:()=>{const t=up.util;up.EventListenerGroup=class EventListenerGroup extends up.Record{keys(){return["elements","eventTypes","selector","callback","guard","baseLayer","passive","once","capture","beforeBoot"]}bind(){const e=t.cleaner();return this.fn((function(t){const n=new up.EventListener(t);return n.bind(),e(n.unbind.bind(n))})),e.clean}fn(t){for(let e of this.elements)for(let n of this.eventTypes)t(this.dn(e,n))}dn(t,e){return Object.assign(Object.assign({},this.attributes()),{element:t,eventType:e})}unbind(){this.fn((function(t){let e=up.EventListener.fromElement(t);e&&e.unbind()}))}static fromBindArgs(e,n){const i=(e=t.copy(e)).pop();let r;r=e[0].addEventListener?[e.shift()]:t.isJQuery(e[0])||t.isList(e[0])&&e[0][0].addEventListener?e.shift():[document];let s=t.getSimpleTokens(e.shift()),o=up.migrate.fixEventTypes;o&&(s=o(s));const u=t.extractOptions(e),a=e[0];return new this(Object.assign(Object.assign({elements:r,eventTypes:s,selector:a,callback:i},u),n))}}},2214:function(){var t=this&&this.U||function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{a(i.next(t))}catch(t){s(t)}}function u(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((i=i.apply(t,e||[])).next())}))};const e=up.util;up.FieldWatcher=class FieldWatcher{constructor(t,e,n){this.sn=e,this.Oe=t,this.mn=up.form.getScope(t),this.gn=n,this.vn=e.batch}start(){this.bn=null,this.yn=this.wn(),this._n=null,this.On=!1,this.o=e.cleaner(),this.kn(this.Oe),this.Oe.addEventListener("up:fragment:inserted",(({target:t})=>{t!==this.Oe&&this.kn(t)})),this.o(up.fragment.onAborted(this.mn,(()=>this.Sn()))),this.o(up.on(this.mn,"reset",(()=>this.xn())))}stop(){this.Sn(),this.o.clean()}En(t){let n=e.copy(this.sn);return up.form.watchOptions(t,n,{defaults:{event:"input"}})}kn(t){for(let e of up.form.fields(t))this.jn(e)}jn(t){let e=this.En(t);this.o(up.on(t,e.event,(()=>this.Cn(e))))}Sn(){this.bn=null}Fn(t,n){this.bn=t,this.Tn=n;let i=n.delay||0;clearTimeout(this._n),this._n=e.timer(i,(()=>{this._n=null,this.Pn()}))}Rn(t){return!e.isEqual(t,this.yn)&&!e.isEqual(this.bn,t)}Pn(){return t(this,void 0,void 0,(function*(){if(!this.bn)return;if(this.On)return;if(this._n)return;if(!this.mn.isConnected)return;let t=e.omit(this.Tn,["event","delay"]);const n=this.Ln(this.yn,this.bn);this.yn=this.bn,this.bn=null,this.On=!0,this.Tn=null;const i=[];if(this.vn)i.push(this.An(n,t));else for(let e in n){const r=n[e];i.push(this.An(r,e,t))}if(e.some(i,e.isPromise)){let t=Promise.allSettled(i);yield t}this.On=!1,this.Pn()}))}An(...t){return up.error.guard(this.gn,...t)}Ln(t,n){const i={};let r=Object.keys(t);r=r.concat(Object.keys(n)),r=e.uniq(r);for(let s of r){const r=t[s],o=n[s];e.isEqual(r,o)||(i[s]=o)}return i}wn(){return up.Params.fromContainer(this.Oe).toObject()}Cn(t={}){const e=this.wn();this.Rn(e)&&this.Fn(e,t)}xn(){e.task((()=>this.Cn()))}}},5949:()=>{const t=up.util;up.FIFOCache=class FIFOCache{constructor({capacity:e=10,normalizeKey:n=t.identity}={}){this.$n=new Map,this.Dn=e,this.Mn=n}get(t){return t=this.Mn(t),this.$n.get(t)}set(t,e){if(this.$n.size===this.Dn){let t=this.$n.keys().next().value;this.$n.delete(t)}t=this.Mn(t),this.$n.set(t,e)}clear(){this.$n.clear()}}},665:()=>{up.FocusCapsule=class FocusCapsule{constructor(t,e){this.I=t,this.Nn=e,this.Hn=up.viewport.copyCursorProps(this.I)}wasLost(){return document.activeElement!==this.I&&!this.qn}autoVoid(){up.on("focusin",{once:!0},(()=>this.qn=!0))}restore(t,e){if(!this.wasLost())return!1;let n=up.fragment.get(this.Nn,{layer:t});return n?(up.viewport.copyCursorProps(this.Hn,n),up.focus(n,e),!0):void 0}static preserve(t){let e=up.viewport.focusedElementWithin(t.element);if(!e)return;let n=up.fragment.tryToTarget(e);return n?new this(e,n):void 0}}},5240:function(){var t=this&&this.U||function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{a(i.next(t))}catch(t){s(t)}}function u(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((i=i.apply(t,e||[])).next())}))},e=this&&this.Bn||function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n};const n=up.util,i=up.element;up.FormValidator=class FormValidator{constructor(t){this.Un=t,this.In=[],this.zn=null,this.Vn=!1,this.Kn(),this.Xn()}Xn(){up.fragment.onAborted(this.Un,(t=>this.Wn(t)))}Wn(t){this.In.length&&(this.In=[],this.Gn.reject(new up.Aborted(t.reason)),this.Kn())}Kn(){this.Gn=n.newDeferred()}watchContainer(t){let{event:e}=this.Jn(t);up.on(t,e,{guard:()=>up.fragment.isAlive(t)},(()=>up.error.muteUncriticalRejection(this.validate({origin:t}))))}validate(t={}){let e=this.Qn(t);return this.In.push(...e),this.Yn(),this.Gn}Qn(t){let e=this.Zn(t)||this.ti(t)||this.ei(t.origin);for(let n of e)n.renderOptions=this.Jn(n.origin,t),n.target=up.fragment.resolveOrigin(n.target,n);return e}ti(t){var{origin:n}=t,i=e(t,["origin"]);if(up.form.isField(n))return this.ni(n)||this.ii(n,i)}ii(t,{formGroup:e=!0}){if(!e)return;let n=up.form.groupSolution(t);return n?(up.puts("up.validate()","Validating form group of field %o",t),[n]):void 0}Zn({target:t,origin:e}){if(n.isString(t)){up.puts("up.validate()",'Validating target "%s"',t);let i=up.fragment.splitTarget(t);return n.compact(i.map((function(t){let n=up.fragment.get(t,{origin:e});if(n)return{element:n,target:t,origin:e};up.fail('Validation target "%s" does not match an element',t)})))}}ei(t){return up.puts("up.validate()","Validating element %o",t),[{element:t,target:up.fragment.toTarget(t),origin:t}]}ni(t){let e=t.closest("[up-validate]");if(e){let n=i.booleanOrStringAttr(e,"up-validate");return this.Zn({target:n,origin:t})}}Jn(t,e){return up.form.watchOptions(t,e,{defaults:{event:"change"}})}Yn(){let t=this.In.map((t=>t.renderOptions.delay)),e=Math.min(...t)||0;clearTimeout(this.zn),this.zn=n.timer(e,(()=>{this.zn=null,this.ri()}))}ri(){up.error.muteUncriticalRejection(this.si())}si(){return t(this,void 0,void 0,(function*(){if(!this.In.length)return;if(this.Vn)return;if(this.zn)return;let t=this.oi(this.In);this.In=[],this.Vn=!0;let e=this.Gn;this.Kn();try{e.resolve(up.render(t)),yield e}finally{this.Vn=!1,this.ri()}}))}oi(t){var e;let i=n.map(t,"origin"),r=n.flatMap(i,up.form.fields),s=n.uniq(n.map(r,"name")),o=n.map(t,"renderOptions"),u=n.mergeDefined(...o,up.form.destinationOptions(this.Un));return u.target=n.map(t,"target").join(", "),u.origin=this.Un,null!==(e=u.focus)&&void 0!==e||(u.focus="keep"),u.failOptions=!1,u.defaultMaybe=!0,u.params=up.Params.merge(u.params,...n.map(o,"params")),u.headers=n.merge(u.headers,...n.map(o,"headers")),this.ui(u.headers,s),u.feedback=n.some(o,"feedback"),u.data=void 0,u.dataMap=n.mapObject(t,(({target:t,element:e,renderOptions:{data:n,keepData:i}})=>[t,i?up.data(e):n])),u.preview=void 0,u.previewMap=n.mapObject(t,(({target:t,renderOptions:{preview:e}})=>[t,e])),u.placeholder=void 0,u.placeholderMap=n.mapObject(t,(({target:t,renderOptions:{placeholder:e}})=>[t,e])),u.disable=t.map((t=>up.fragment.resolveOrigin(t.renderOptions.disable,t))),u.guardEvent=up.event.build("up:form:validate",{fields:r,log:"Validating form",params:u.params,form:this.Un}),u}ui(t,e){let n=up.protocol.headerize("validate"),i=e.join(" ");(!i||i.length>up.protocol.config.maxHeaderSize)&&(i=":unknown"),t[n]=i}static forElement(t){let e=up.form.get(t);return e.upFormValidator||(e.upFormValidator=new this(e))}}},2587:()=>{const t=up.util,e=/^([^ >+(]+) (.+)$/;up.FragmentFinder=class FragmentFinder{constructor(t){var e;this.sn=t,this.L=t.origin,this.ai=t.selector,this.ci=t.document||window.document,this.hi=null!==(e=t.match)&&void 0!==e?e:up.fragment.config.match,this.li=t.preferOldElements}find(){return this.pi()||this.fi()||this.di()}pi(){if(this.li)return this.li.find((t=>this.ci.contains(t)&&up.fragment.matches(t,this.ai)))}fi(){var t;if("region"===this.hi&&!up.fragment.containsMainPseudo(this.ai)&&(null===(t=this.L)||void 0===t?void 0:t.isConnected))return this.mi()||this.gi()}mi(){return up.fragment.closest(this.L,this.ai,this.sn)}gi(){let n=up.fragment.splitTarget(this.ai);return t.findResult(n,(t=>{let n=t.match(e);if(n){let t=up.fragment.closest(this.L,n[1],this.sn);if(t)return up.fragment.getFirstDescendant(t,n[2])}}))}di(){return up.fragment.getFirstDescendant(this.ci,this.ai,this.sn)}}},7031:()=>{const t=up.util,e=up.element,n={preventScroll:!0};up.FragmentFocus=class FragmentFocus extends up.FragmentProcessor{keys(){return super.keys().concat(["hash","focusCapsule","inputDevice"])}processPrimitive(e){switch(e){case"keep":return this.vi();case"restore":return this.bi();case"target":case!0:return this.yi(this.fragment);case"layer":return this.yi(this.layer.getFocusElement());case"main":return this.wi(":main");case"hash":return this._i();case"autofocus":return this.Oi();default:if(t.isString(e))return this.wi(e)}}processElement(t){return this.yi(t)}resolveCondition(t){return"lost"===t?this.ki():super.resolveCondition(t)}wi(t){let e=this.findSelector(t);return this.yi(e)}vi(){var t;return null===(t=this.focusCapsule)||void 0===t?void 0:t.restore(this.layer,n)}bi(){return up.viewport.restoreFocus({layer:this.layer})}Oi(){let t=this.fragment&&e.subtreeFirst(this.fragment,"[autofocus]");if(t)return this.yi(t)}yi(t){if(t)return up.focus(t,Object.assign(Object.assign({force:!0},n),{inputDevice:this.inputDevice})),!0}_i(){let t=up.viewport.firstHashTarget(this.hash,{layer:this.layer});if(t)return this.yi(t)}ki(){var t;return null===(t=this.focusCapsule)||void 0===t?void 0:t.wasLost()}}},8057:()=>{const t=up.element;up.FragmentPolling=class FragmentPolling{constructor(t){this.sn=up.radio.pollOptions(t),this.rn=t,up.destructor(t,this.Si.bind(this)),up.fragment.onAborted(t,this.xi.bind(this)),this.Ei="initialized",this.ji=!0,this.Ci=!1,this.Fi()}static forFragment(t){return t.upPolling||(t.upPolling=new this(t))}onPollAttributeObserved(){this.Ti()}Si(){this.Pi()}Ti(t){if(Object.assign(this.sn,t),"started"!==this.Ei){if(!up.fragment.isTargetable(this.rn))return void up.warn("[up-poll]","Cannot poll untargetable fragment %o",this.rn);this.Ei="started",this.Ri(),this.Li()}}Pi(){var t;"started"===this.Ei&&(this.Ai(),this.Ei="stopped",null===(t=this.unbindEvents)||void 0===t||t.call(this))}forceStart(t){Object.assign(this.sn,t),this.forceStarted=!0,this.Ti()}forceStop(){this.Pi(),this.forceStarted=!1}Ri(){this.unbindEvents||(this.unbindEvents=up.on("visibilitychange up:layer:opened up:layer:dismissed up:layer:accepted",this.$i.bind(this)))}$i(){this.Di()&&this.Li()}Di(){return!document.hidden&&("any"===this.sn.ifLayer||this.Mi())}Ai(){clearTimeout(this.Ni),this.Ni=null}Li(){this.Ni||this.Ci||(this.Ai(),this.Ni=setTimeout(this.Hi.bind(this),this.qi()))}Hi(){this.Ni=null,this.Bi()}Bi(){"started"===this.Ei&&(this.Di()?this.Ui():up.puts("[up-poll]","Will not poll hidden fragment"))}Ii(){var e,n;return null!==(n=null!==(e=this.sn.interval)&&void 0!==e?e:t.numberAttr(this.rn,"up-interval"))&&void 0!==n?n:up.radio.config.pollInterval}qi(){return Math.max(this.Ii()-this.zi(),0)}zi(){return new Date-this.Vi}Mi(){var t,e;return this.layer||(this.layer=up.layer.get(this.rn)),null===(e=null===(t=this.layer)||void 0===t?void 0:t.isFront)||void 0===e?void 0:e.call(t)}Ui(){this.Ai();let t=this.ji;try{this.ji=!1,this.Ci=!0,up.reload(this.rn,this.Ki()).then(this.Xi.bind(this),this.Wi.bind(this))}finally{this.ji=t}}Ki(){let t=up.event.build("up:fragment:poll",{log:["Polling fragment",this.rn]});return Object.assign(Object.assign({},this.sn),{guardEvent:t})}xi({newLayer:t}){this.ji&&!t&&this.Pi()}Xi({fragment:t}){this.Ci=!1,this.Fi(),t?this.Gi(t):this.Li()}Gi(t){this.Pi(),this.forceStarted&&up.fragment.matches(this.rn,t)&&this.constructor.forFragment(t).forceStart(this.sn)}Wi(t){this.Ci=!1,this.Fi(),this.Li(),up.error.throwCritical(t)}Fi(){this.Vi=new Date}}},2828:()=>{const t=up.util;up.FragmentProcessor=class FragmentProcessor extends up.Record{keys(){return["fragment","autoMeans","origin","layer"]}process(t){let e=this.preprocess(t);return this.tryProcess(e)}preprocess(e){return t.getComplexTokens(e)}tryProcess(e){if(t.isArray(e))return this.processArray(e);if(t.isFunction(e)){let t=up.error.guard(e,this.fragment,this.attributes());return this.tryProcess(t)}if(t.isElement(e))return this.processElement(e);if(t.isString(e)){if("auto"===e)return this.tryProcess(this.autoMeans);let t=e.match(/^(.+?)-if-(.+?)$/);if(t)return this.resolveCondition(t[2])&&this.process(t[1])}return this.processPrimitive(e)}processArray(e){return t.find(e,(t=>this.tryProcess(t)))}resolveCondition(t){if("main"===t)return this.fragment&&up.fragment.contains(this.fragment,":main")}findSelector(t){const e={layer:this.layer,origin:this.origin};let n=this.fragment&&up.fragment.get(this.fragment,t,e)||up.fragment.get(t,e);if(n)return n;up.warn("up.render()",'Could not find an element matching "%s"',t)}}},4850:()=>{const t=up.util;up.FragmentScrolling=class FragmentScrolling extends up.FragmentProcessor{keys(){return super.keys().concat(["hash","mode","revealTop","revealMax","revealSnap","scrollBehavior"])}processPrimitive(e){switch(e){case"reset":return this.Ji();case"layer":return this.Qi();case"main":return this.Yi(":main");case"restore":return this.Zi();case"hash":return this.hash&&up.viewport.revealHash(this.hash,this.attributes());case"target":case"reveal":case!0:return this.tr(this.fragment);default:if(t.isString(e))return this.Yi(e)}}processElement(t){return this.tr(t)}tr(t){if(t)return up.reveal(t,this.attributes()),!0}Yi(t){let e=this.findSelector(t);return this.tr(e)}Qi(){return this.tr(this.layer.getBoxElement())}Ji(){return up.viewport.resetScroll(Object.assign(Object.assign({},this.attributes()),{around:this.fragment})),!0}Zi(){return up.viewport.restoreScroll(Object.assign(Object.assign({},this.attributes()),{around:this.fragment}))}}},7956:()=>{const t=up.element,e=up.util;up.Layer=class Layer extends up.Record{keys(){return["element","stack","history","mode","context","lastScrollTops","lastFocusCapsules"]}defaults(){return{context:{},lastScrollTops:up.viewport.newStateCache(),lastFocusCapsules:up.viewport.newStateCache()}}constructor(t={}){if(super(t),!this.mode)throw"missing { mode } option"}setupHandlers(){up.link.convertClicks(this)}teardownHandlers(){}mainTargets(){return up.layer.mainTargets(this.mode)}sync(){}accept(){throw new up.NotImplemented}dismiss(){throw new up.NotImplemented}peel(t){this.stack.peel(this,t)}evalOption(t){return e.evalOption(t,this)}isCurrent(){return this.stack.isCurrent(this)}isFront(){return this.stack.isFront(this)}isRoot(){return this.stack.isRoot(this)}isOverlay(){return this.stack.isOverlay(this)}isOpen(){return this.stack.isOpen(this)}isClosed(){return this.stack.isClosed(this)}get parent(){return this.stack.parentOf(this)}get child(){return this.stack.childOf(this)}get ancestors(){return this.stack.ancestorsOf(this)}get descendants(){return this.stack.descendantsOf(this)}get subtree(){return[this,...this.descendants]}get index(){var t;return null!==(t=this.er)&&void 0!==t?t:this.er=this.stack.indexOf(this)}getContentElement(){return this.contentElement||this.element}getBoxElement(){return this.boxElement||this.element}getFocusElement(){return this.getBoxElement()}getFirstSwappableElement(){throw new up.NotImplemented}contains(t){return t.closest(up.layer.anySelector())===this.element}on(...t){return this.nr(t).bind()}off(...t){return this.nr(t).unbind()}nr(t){return up.EventListenerGroup.fromBindArgs(t,{guard:t=>this.ir(t),elements:[this.element],baseLayer:this})}ir(t){return this.contains(t.target)}wasHitByMouseEvent({clientX:t,clientY:e}){const n=document.elementFromPoint(t,e);return!n||this.contains(n)}rr(t){return up.EventEmitter.fromEmitArgs(t,{layer:this})}emit(...t){return this.rr(t).emit()}isDetached(){return!this.element.isConnected}saveHistory(){this.history&&(this.savedTitle=document.title,this.savedMetaTags=up.history.findMetaTags(),this.savedLocation=up.history.location,this.savedLang=up.history.getLang())}restoreHistory(){this.showsLiveHistory()&&(this.savedLocation&&up.history.push(this.savedLocation),this.savedTitle&&(document.title=this.savedTitle),this.savedMetaTags&&up.history.updateMetaTags(this.savedMetaTags),e.isString(this.savedLang)&&up.history.updateLang(this.savedLang))}asCurrent(t){return this.stack.asCurrent(this,t)}updateHistory(t){var n,i;e.isString(t.location)&&(this.location=t.location),up.history.config.updateMetaTags&&e.isList(t.metaTags)&&(null===(i=null===(n=up.migrate)||void 0===n?void 0:n.warnOfHungryMetaTags)||void 0===i||i.call(n,t.metaTags),this.metaTags=t.metaTags),e.isString(t.title)&&(this.title=t.title),e.isString(t.lang)&&(this.lang=t.lang)}showsLiveHistory(){return this.history&&this.isFront()}get title(){return this.showsLiveHistory()?document.title:this.savedTitle}set title(t){this.savedTitle=t,this.showsLiveHistory()&&(document.title=t)}get metaTags(){return this.showsLiveHistory()?up.history.findMetaTags():this.savedMetaTags}set metaTags(t){this.savedMetaTags=t,this.showsLiveHistory()&&up.history.updateMetaTags(t)}get lang(){return this.showsLiveHistory()?up.history.getLang():this.savedLang}set lang(t){this.savedLang=t,this.showsLiveHistory()&&up.history.updateLang(t)}get location(){return this.showsLiveHistory()?up.history.location:this.savedLocation}set location(t){(this.location!==(t=e.normalizeURL(t))||this.opening)&&(this.savedLocation=t,this.showsLiveHistory()&&up.history.push(t),this.opening||this.emit("up:layer:location:changed",{location:t}))}selector(t){return this.constructor.selector(t)}static selector(t){throw new up.NotImplemented}toString(){throw new up.NotImplemented}affix(...e){return t.affix(this.getFirstSwappableElement(),...e)}[e.isEqual.key](t){return this.constructor===t.constructor&&this.element===t.element}hasFocus(){let t=document.activeElement;return t!==document.body&&this.element.contains(t)}reset(){Object.assign(this,this.defaults())}}},7101:()=>{var t;up.Layer.Cover=((t=class Cover extends up.Layer.OverlayWithViewport{}).mode="cover",t)},5580:()=>{var t;up.Layer.Drawer=((t=class Drawer extends up.Layer.OverlayWithViewport{}).mode="drawer",t)},86:()=>{var t;up.Layer.Modal=((t=class Modal extends up.Layer.OverlayWithViewport{}).mode="modal",t)},7403:function(){var t,e=this&&this.U||function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{a(i.next(t))}catch(t){s(t)}}function u(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((i=i.apply(t,e||[])).next())}))};const n=up.element,i=up.util;up.Layer.Overlay=((t=class Overlay extends up.Layer{keys(){return[...super.keys(),...this.constructor.VISUAL_KEYS,"onOpened","onAccept","onAccepted","onDismiss","onDismissed","acceptEvent","dismissEvent","acceptLocation","dismissLocation","opening"]}constructor(t){super(t),!0===this.dismissable?this.dismissable=["button","key","outside"]:!1===this.dismissable?this.dismissable=[]:this.dismissable=i.getSimpleTokens(this.dismissable),this.acceptLocation&&(this.acceptLocation=new up.URLPattern(this.acceptLocation)),this.dismissLocation&&(this.dismissLocation=new up.URLPattern(this.dismissLocation))}callback(t){let e=this[t];if(e)return e.bind(this)}createElement(t){this.nesting||(this.nesting=this.sr());const e=i.compactObject(i.pick(this,["align","position","size","class","nesting"]));this.element=this.affixPart(t,null,e)}createBackdropElement(t){this.backdropElement=this.affixPart(t,"backdrop")}createViewportElement(t){this.viewportElement=this.affixPart(t,"viewport",{"up-viewport":""})}createBoxElement(t){this.boxElement=this.affixPart(t,"box")}createContentElement(t){this.contentElement=this.affixPart(t,"content")}setContent(t){this.contentElement.append(t),this.onContentSet()}onContentSet(){}createDismissElement(t){return this.dismissElement=this.affixPart(t,"dismiss",{"up-dismiss":'":button"',"aria-label":this.dismissARIALabel}),n.affix(this.dismissE