UNPKG

unpoly

Version:

Progressive enhancement for HTML

1 lines 165 kB
(()=>{var t={1860:(t,e,n)=>{"use strict";n.r(e)},8711:(t,e,n)=>{"use strict";n.r(e)},4432:(t,e,n)=>{"use strict";n.r(e)},2065:(t,e,n)=>{"use strict";n.r(e)},35:(t,e,n)=>{"use strict";n.r(e)},5074:(t,e,n)=>{"use strict";n.r(e)},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){let e=document.cookie.match(new RegExp(t+"=(\\w+)"))?.[1];if(e)return document.cookie=t+"=;Max-Age=0;Path=/",e}}},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.k=t.response}handleLayerChangeRequests(){this.layer.isOverlay()&&(this.S(),this.abortWhenLayerClosed(),this.layer.tryAcceptForLocation(this.O()),this.abortWhenLayerClosed(),this.C(),this.abortWhenLayerClosed(),this.layer.tryDismissForLocation(this.O()),this.abortWhenLayerClosed()),this.layer.asCurrent((()=>{for(let t of this._)up.emit({...t,...this.O()}),this.abortWhenLayerClosed()}))}S(){t.isDefined(this.m)&&this.layer.isOverlay()&&this.layer.accept(this.m,this.O())}C(){t.isDefined(this.v)&&this.layer.isOverlay()&&this.layer.dismiss(this.v,this.O())}abortWhenLayerClosed(t=this.layer){if(t.isClosed())throw new up.Aborted("Layer was closed")}F({oldElement:t,newElement:n,source:i}){"keep"===i&&(i=t&&up.fragment.source(t)),i&&e.setMissingAttr(n,"up-source",up.fragment.normalizeSource(i))}T({newElement:t,time:n}){e.setMissingAttr(t,"up-time",!!n&&n.toUTCString())}R({newElement:t,etag:n}){e.setMissingAttr(t,"up-etag",n||!1)}setReloadAttrs(t){this.F(t),this.T(t),this.R(t)}O(){return{response:this.k}}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){super(t),this.P=t.verb,this.L=up.layer.get(t),this.A=t.origin,this.$=t.value,this.D=t.preventable??!0,this.k=t.response,this.M=t.history??!0}execute(){if(!this.L.isOpen())return;if(up.browser.assertConfirmed(this.options),this.N().defaultPrevented&&this.D)throw new up.Aborted("Close event was prevented");this.H(),up.fragment.abort({reason:"Layer is closing",layer:this.L});const{parent:t}=this.L;this.L.peel(),this.L.stack.remove(this.L),this.M&&t.restoreHistory(),this.j(t),this.L.teardownHandlers(),this.L.destroyElements(this.options),this.q(t)}N(){let e=this.L.emit(this.B(`up:layer:${this.P}`),{callback:this.L.callback(`on${t.upperCaseFirst(this.P)}`),log:[`Will ${this.P} ${this.L} with value %o`,this.$]});return this.$=e.value,e}H(){let t=this.B(`up:layer:${this.P}ing`);this.L.emit(t,{log:!1})}q(e){const n=`${this.P}ed`,i=t.upperCaseFirst(n);return this.L.emit(this.B(`up:layer:${n}`),{baseLayer:e,callback:this.L.callback(`on${i}`),ensureBubbles:!0,log:[`${i} ${this.L} with value %o`,this.$]})}B(t){return up.event.build(t,{layer:this.L,value:this.$,origin:this.A,response:this.k})}j(t){let e=this.L.hasFocus();if(this.L.overlayFocus.teardown(),t.overlayFocus?.moveToFront(),e){let e=this.L.origin||t.element;up.focus(e,{preventScroll:!0})}}}},8228:()=>{up.Change.DestroyFragment=class DestroyFragment extends up.Change{constructor(t){super(t),this.L=up.layer.get(t)||up.layer.current,this.U=this.options.element,this.I=this.options.animation,this.V=this.options.log,this.K=this.options.onFinished}execute(){this.X=this.U.parentNode,up.fragment.markAsDestroying(this.U),up.motion.willAnimate(this.U,this.I,this.options)?this.W():this.G()}async W(){this.J(),await this.Y(),this.Z(),this.K?.()}G(){this.Z(),this.J(),this.K?.()}Y(){return up.motion.animate(this.U,this.I,this.options)}Z(){this.L.asCurrent((()=>{up.fragment.abort(this.U),up.script.clean(this.U,{layer:this.L}),up.element.cleanJQuery(this.U),this.U.remove()}))}J(){up.fragment.emitDestroyed(this.U,{parent:this.X,log:this.V})}}},9005:()=>{var t;const e=up.util;up.Change.FromContent=(t=class FromContent extends up.Change{constructor(t){super(t),this.A=t.origin,this.tt=t.preflight,this.et=up.layer.getAll(t)}nt(){let t=[];return this.it(),this.st(),this.rt(t,this.et,this.options.target),this.rt(t,this.et,this.options.fallback),t}ot(t){return"new"===t||t.isOpen()}it(){this.et=e.filter(this.et,this.ot)}rt(t,e,n){for(let i of e)for(let e of this.ut(n,i)){const n={...this.options,target:e,layer:i,defaultPlacement:this.ht()},s="new"===i?new up.Change.OpenLayer(n):new up.Change.UpdateLayer(n);t.push(s)}}ut(t,e){return up.fragment.expandTargets(t,{layer:e,mode:this.options.mode,origin:this.A})}execute(){return this.options.preload?Promise.resolve():this.ct(this.lt.bind(this))||this.ft()}lt(t){let e=t.execute(this.dt(),this.gt.bind(this,t));return e.options=this.options,e}yt(t){return!(t instanceof up.CannotMatch)}gt(t){let e=this.nt()[0];t!==e&&up.puts("up.render()",'Could not match primary target "%s". Updating a fallback target "%s".',e.target,t.target);let{assets:n}=this.dt();n&&up.script.assertAssetsOK(n,t.options),this.options.handleAbort?.(null)}dt(){if(this.tt)return;const t=e.pick(this.options,["target","content","fragment","document","html","cspNonces","origin","data"]);return up.migrate.handleResponseDocOptions?.(t),"content"===this.ht()&&(t.target=this.wt(t.target)),new up.ResponseDoc(t)}st(){if(this.tt)return;let t=this.dt();this.options.fragment&&(this.options.target||=t.rootSelector()),this.options.title=this.improveHistoryValue(this.options.title,t.title),this.options.metaTags=this.improveHistoryValue(this.options.metaTags,t.metaTags),this.options.lang=this.improveHistoryValue(this.options.lang,t.lang)}ht(){if(!this.options.document&&!this.options.fragment)return"content"}wt(t){let e=this.et[0]||up.layer.root;return this.ut(t||":main",e)[0]}getPreflightProps(t={}){return this.ct((t=>t.getPreflightProps()))||t.optional||this.bt()}bt(){this.vt("Could not find target in current page")}ft(){this.vt("Could not find common target in current page and response")}vt(t){if(this.nt().length){const n=e.uniq(e.map(this.nt(),"target")),i=up.layer.optionToString(this.options.layer);throw new up.CannotMatch([t+" (tried selectors %o in %s)",n,i])}if(0!==this.et.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._t()}_t(){throw new up.CannotMatch("Could not find a layer to render in. You may have passed an unmatchable layer reference, or a detached element.")}ct(t){for(let e of this.nt())try{return t(e)}catch(t){if(this.yt(t))throw t}}},e.memoizeMethod(t.prototype,{nt:!0,dt:!0,getPreflightProps:!0}),t)},278:()=>{var t;const e=up.util;up.Change.FromResponse=(t=class FromResponse extends up.Change{constructor(t){super(t),this.k=t.response,this.kt=this.k.request}execute(){if(up.fragment.config.skipResponse(this.St())?this.xt():this.kt.assertEmitted("up:fragment:loaded",{...this.St(),callback:this.options.onLoaded,log:["Loaded fragment from %s",this.k.description],skip:()=>this.xt()}),e.evalOption(this.options.fail,this.k)??!this.k.ok)throw this.Et(this.deriveFailOptions());return this.Et(this.options)}xt(){up.puts("up.render()","Skipping "+this.k.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.Ot(t),t.meta=this.Ct();let e=new up.Change.FromContent(t).execute();return e.finished=this.finish(e,t),e}async finish(t,e){return t=await t.finished,up.fragment.shouldRevalidate(this.kt,this.k,e)&&(t=await this.Ft(t,e)),t}async Ft(t,e){let n=e.target,i=t.target;if(/:(before|after)/.test(n))up.warn("up.render()","Cannot revalidate cache when prepending/appending (target %s)",n);else{up.puts("up.render()",'Revalidating cached response for target "%s"',i);let n=await up.reload(i,{...e,...up.RenderOptions.NO_MOTION,...up.RenderOptions.NO_INPUT_INTERFERENCE,...up.RenderOptions.NO_PREVIEWS,preferOldElements:t.fragments,layer:t.layer,onFinished:null,expiredResponse:this.k,preview:this.Tt(e),abort:!1,cache:!1,background:!0});n.none||(t=n)}return t}Tt({preview:t,revalidatePreview:e}){return!0===e?t:e}St(){const{expiredResponse:t}=this.options;return{request:this.kt,response:this.k,renderOptions:this.options,revalidating:!!t,expiredResponse:t}}Ct(){let t={revalidating:!!this.options.expiredResponse};return up.migrate.processCompilerPassMeta?.(t,this.k),t}Ot(t){const n=this.k.url;let i=n,s=this.kt.hash;s&&(t.hash=s,i+=s),"GET"===this.k.method?t.source=this.improveHistoryValue(t.source,n):(t.source=this.improveHistoryValue(t.source,"keep"),t.history=!!t.location),t.location=this.improveHistoryValue(t.location,i),t.title=this.improveHistoryValue(t.title,this.k.title),t.eventPlans=this.k.eventPlans;let r=this.k.target;r&&(t.target=r),t.acceptLayer=this.k.acceptLayer,t.dismissLayer=this.k.dismissLayer,t.document=this.k.text,this.k.none&&(t.target=":none"),t.context=e.merge(t.context,this.k.context),t.cspNonces=this.k.cspNonces,t.time??=this.k.lastModified,t.etag??=this.k.etag}},e.memoizeMethod(t.prototype,{St:!0}),t)},2200:()=>{var t;const e=up.util;up.Change.FromURL=(t=class FromURL extends up.Change{async execute(){let t=this.Rt();if(t)return up.puts("up.render()",t),up.network.loadPage(this.options),e.unresolvablePromise();let n=this.request=up.request(this.Pt());return this.options.onRequestKnown?.(n),this.options.preload?n:(this.options.handleAbort?.(n),n.runPreviews(this.options),await e.always(n,(t=>this.Lt(t))))}Rt(){return e.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}Pt(){const t=this.At(this.options),n=this.At(this.deriveFailOptions(),{optional:!0});return{...this.options,...t,...e.withRenamedKeys(n,up.fragment.failKey)}}getPreflightProps(){return this.Pt()}At(t,e){return new up.Change.FromContent({...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({...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({...this.options,...t}),log:["Cannot load fragment from %s: %s",this.request.description,t.reason]}),t}},e.memoizeMethod(t.prototype,{Pt:!0}),t)},7050:()=>{let t=up.util;up.Change.OpenLayer=class OpenLayer extends up.Change.Addition{constructor(t){super(t),this.target=t.target,this.A=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:t.compact([up.fragment.get(":main",{layer:this.Mt})]),fragments:[]}}execute(t,e){this.responseDoc=t,this.Ht(),e(),this.jt();let n=this.layer.on("up:layer:accepting up:layer:dimissing",this.qt.bind(this));try{return this.Bt(),this.qt(),up.RenderResult.both(this.Ut,this.It)}finally{n()}}Ht(){if(":none"===this.target?this.zt=document.createElement("up-none"):this.zt=this.responseDoc.select(this.target),!this.zt||this.Mt.isClosed())throw new up.CannotMatch}jt(){up.puts("up.render()",`Opening element "${this.target}" in new overlay`),this.Vt(),this.layer=this.Nt(),this.Mt.peel({history:!this.layer.history}),up.layer.stack.push(this.layer),this.layer.createElements(),this.layer.setupHandlers()}Bt(){this.Kt(),this.handleLayerChangeRequests(),this.responseDoc.commitElement(this.zt),this.layer.setContent(this.zt),this.setReloadAttrs({newElement:this.zt,source:this.options.source}),this.responseDoc.finalizeElement(this.zt),this.Ut=new up.RenderResult({layer:this.layer,fragments:[this.zt],target:this.target}),up.hello(this.layer.element,{...this.options,layer:this.layer,dataRoot:this.zt}),this.Xt(),this.Ut.finished=this.Wt(),this.layer.opening=!1,this.Gt(),this.abortWhenLayerClosed()}qt(){if(this.It)return;let t=this.Jt().other;this.It=this.executeSteps(t,this.responseDoc)}async Wt(){return await this.layer.startOpenAnimation(),this.abortWhenLayerClosed(),this.j(),this.Ut}Nt(){const t={...this.options,opening:!0};return up.layer.build(t,(t=>this.options=up.RenderOptions.finalize(t)))}Kt(){"auto"===this.layer.history&&(this.layer.history=up.fragment.hasAutoHistory([this.zt],this.layer));let{parent:t}=this.layer;this.layer.history&&=t.history,t.saveHistory(),this.layer.updateHistory(this.options)}j(){this.Mt.overlayFocus?.moveToBack(),this.layer.overlayFocus.moveToFront(),new up.FragmentFocus({fragment:this.zt,layer:this.layer,autoMeans:["autofocus","layer"],inputDevice:this.options.inputDevice}).process(this.options.focus)}Xt(){const t={...this.options,fragment:this.zt,layer:this.layer,autoMeans:["hash","layer"]};new up.FragmentScrolling(t).process(this.options.scroll)}Vt(){up.event.assertEmitted("up:layer:open",{origin:this.A,baseLayer:this.Mt,layerOptions:this.options,log:"Opening new overlay"})}Gt(){this.layer.emit("up:layer:opened",{origin:this.A,callback:this.layer.callback("onOpened"),log:`Opened new ${this.layer}`})}Jt(){return up.radio.hungrySteps(this.Qt())}Qt(){return{...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.Yt=t.context,this.Zt=up.fragment.parseTargetSteps(this.target,this.options)}getPreflightProps(){this.te();let t=this.ee();return{layer:this.layer,bindLayer:this.layer,mode:this.layer.mode,context:e.merge(this.layer.context,this.Yt),origin:this.options.origin,target:this.ne(),fragments:t,bindFragments:t}}ne(){return this.te(),up.fragment.targetForSteps(this.Zt)}ee(){return this.te(),e.map(this.Zt,"oldElement")}execute(t,e){this.responseDoc=t,this.Ht(),e();let n=this.layer.on("up:layer:accepting up:layer:dimissing",this.qt.bind(this));try{return this.ie(),this.qt(),up.RenderResult.both(this.se,this.It)}finally{n()}}ie(){this.Zt.length&&up.puts("up.render()",`Updating "${this.ne()}" in ${this.layer}`),this.re(),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.oe()}),!1!==this.options.abort&&up.fragment.abort(this.ee(),{reason:"Fragment is being replaced"}),Object.assign(this.layer.context,this.Yt),this.oe()&&this.layer.updateHistory(this.options),this.handleLayerChangeRequests(),this.se=this.executeSteps(this.Zt,this.responseDoc,this.options)}qt(){if(this.It)return;let t=this.Jt().other;this.It=this.executeSteps(t,this.responseDoc)}te(){this.ue(),this.ae()}Ht(){this.ue(),this.he(),this.ae(),this.ce()}he(){this.Zt.push(...this.Jt().current)}ue(){this.Zt=this.Zt.filter((t=>{const n=new up.FragmentFinder(e.pick(t,["selector","origin","layer","match","preferOldElements"]));if(t.oldElement||=n.find(),t.oldElement)return!0;if(!t.maybe)throw new up.CannotMatch}))}ce(){this.Zt=this.responseDoc.selectSteps(this.Zt)}ae(){this.Zt=up.fragment.compressNestedSteps(this.Zt)}Jt(){return up.radio.hungrySteps(this.Qt())}re(){let t=up.FocusCapsule.preserve(this.layer);this.Zt.forEach(((e,n)=>{e.focusCapsule=t,n>0&&(e.scroll=!1,e.focus=!1)}))}oe(){return e.evalAutoOption(this.options.history,this.le.bind(this))}le(){const t=e.map(this.Zt,"oldElement");return up.fragment.hasAutoHistory(t,this.layer)}Qt(){return{...this.options,layer:this.layer,history:this.oe()}}},e.memoizeMethod(t.prototype,{te:!0,ue:!0,oe:!0,Jt:!0}),t)},9489:()=>{const t=up.util,e=up.element;up.Change.UpdateSteps=class UpdateSteps extends up.Change.Addition{constructor(e){super(e),this.pe=e.noneOptions||{},this.Zt=t.copy(e.steps)}execute(t){if(this.responseDoc=t,this.Zt=t.selectSteps(this.Zt),this.Zt=t.commitSteps(this.Zt),!this.Zt.length)return this.fe();this.renderResult=new up.RenderResult({layer:this.Zt[0]?.layer,target:up.fragment.targetForSteps(this.Zt)}),this.Zt.reverse();const e=this.Zt.map((t=>this.de(t)));return this.renderResult.finished=this.Wt(e),this.renderResult}fe(){return this.j(null,this.pe),this.Xt(null,this.pe),up.RenderResult.buildNone()}async Wt(t){await Promise.all(t);for(let t of this.Zt)this.abortWhenLayerClosed(t.layer);return this.renderResult}me(t){let e=t.matches("up-wrapper")?t.children:[t];this.renderResult.fragments.unshift(...e)}de(t){switch(this.setReloadAttrs(t),t.placement){case"swap":if(this.ge(t))return this.j(t.oldElement,t),this.Xt(t.oldElement,t),Promise.resolve();{this.ye(t);const n=t.oldElement.parentNode,i={...t,beforeStart(){up.fragment.markAsDestroying(t.oldElement)},afterInsert:()=>{this.we(t),this.responseDoc.finalizeElement(t.newElement),this.be(t),up.hello(t.newElement,t),this.me(t.newElement)},beforeDetach:()=>{up.script.clean(t.oldElement,{layer:t.layer})},afterDetach(){e.cleanJQuery(),up.fragment.emitDestroyed(t.oldElement,{parent:n,log:!1})},scrollNew:()=>{this.j(t.newElement,t),this.Xt(t.newElement,t)}};return up.morph(t.oldElement,t.newElement,t.transition,i)}case"content":{let n=e.wrapChildren(t.oldElement),i=e.wrapChildren(t.newElement),s={...t,placement:"swap",oldElement:n,newElement:i,focus:!1};return this.de(s).then((()=>{e.unwrap(i),this.j(t.oldElement,t)}))}case"before":case"after":{let n=e.wrapChildren(t.newElement),i="before"===t.placement?"afterbegin":"beforeend";return t.oldElement.insertAdjacentElement(i,n),this.responseDoc.finalizeElement(n),up.hello(n,t),this.me(n),this.j(n,t),this.Xt(n,t),up.animate(n,t.transition,t).then((()=>e.unwrap(n)))}default:up.fail("Unknown placement: %o",t.placement)}}ge(t){if(!t.keep)return;const{oldElement:n,newElement:i}=t;let s;if(!e.booleanAttr(n,"up-keep"))return;let r=up.fragment.toTarget(n);const o={layer:t.layer};if(s=t.descendantsOnly?up.fragment.get(i,r,o):e.subtreeFirst(i,r,o),s&&!1!==e.booleanAttr(s,"up-keep")){const e={oldElement:n,newElement:s,newData:up.script.data(s),renderOptions:t};if(!up.fragment.emitKeep(e).defaultPrevented)return e}}ye(t){const e=[];if(t.keep)for(let n of t.oldElement.querySelectorAll("[up-keep]")){let i=this.ge({...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 s=up.viewport.subtree(i.oldElement);i.revivers=s.map((function(t){let e=up.viewport.copyCursorProps(t);return()=>up.viewport.copyCursorProps(e,t)})),this.ve(document.body)?i.newElement.replaceWith(n):document.body.append(n),e.push(i)}}t.keepPlans=e}we(t){for(let e of t.keepPlans){e.newElement.replaceWith(e.oldElement);for(let t of e.revivers)t()}}be(t){for(let e of t.keepPlans)e.oldElement.classList.remove("up-keeping")}ve(e){return t.some(this.Zt,(t=>t.oldElement.contains(e)))}j(t,e){return new up.FragmentFocus({...e,fragment:t,autoMeans:up.fragment.config.autoFocus}).process(e.focus)}Xt(t,e){return new up.FragmentScrolling({...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:s,dataMap:r,meta:o}){n||=up.layer.get(t)||up.layer.current,this._e=t,this.ke=e,this.L=n,this.Se=i,this.xe=s||t,this.Ee=r,o||={},o.layer=n,this.Oe=o}run(){this.L.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){const e=this.Te(t);if(e.length){if(t.isDefault||up.puts("up.hello()",'Compiling %d× "%s" on %s',e.length,t.selector,this.L),t.batch)this.Re(t,e);else for(let n of e)this.Pe(t,n);return up.migrate.postCompile?.(e,t)}}Pe(t,e){const n=[e];if(1!==t.length){const t=up.script.data(e);n.push(t,this.Oe)}const i=this.Le(t,e,n);up.destructor(e,i)}Re(e,n){const i=[n];if(1!==e.length){const e=t.map(n,up.script.data);i.push(e,this.Oe)}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._e,t.evalOption(e),{layer:this.L})}Te(e){let n=this.Fe(e.selector);return t.filter(n,(t=>{let n=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],s=this["no"+t.upperCaseFirst(n)];return e.unionSelector(i,s)}selectorFn(t){return()=>this.selector(t)}}},2737:()=>{const t=up.util,e=up.element;up.CSSTransition=class CSSTransition{constructor(t,e,n){this.U=t,this.$e=e,this.De=Object.keys(this.$e),this.Me=n.finishEvent,this.Ne=n.duration,this.He=n.easing,this.je=!1}start(){return 0===this.De.length?(this.je=!0,Promise.resolve()):(this.qe=t.newDeferred(),this.Be(),this.Ue=new Date,this.Ie(),this.ze(),this.Ve(),this.Ke(),this.qe)}ze(){this.Me&&(this.Xe=up.on(this.U,this.Me,this.We.bind(this)))}We(t){t.stopPropagation(),this.Wt()}Ie(){this.Ge=t.timer(this.Ne+100,(()=>this.Wt()))}Je(){clearTimeout(this.Ge)}Ve(){this.Qe=up.on(this.U,"transitionend",this.Ye.bind(this))}Ye(e){if(e.target!==this.U)return;if(new Date-this.Ue<=.25*this.Ne)return;const n=e.propertyName;t.contains(this.De,n)&&this.Wt()}Wt(){this.je||(this.je=!0,this.Je(),this.Xe?.(),this.Qe?.(),e.concludeCSSTransition(this.U),this.Ze(),this.qe.resolve())}Be(){const t=e.style(this.U,["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.U,n);this.tn=e.setStyleTemp(this.U,i)}this.en=e.concludeCSSTransition(this.U)}}Ze(){this.tn?.(),this.en?.()}Ke(){e.setStyle(this.U,{"transition-property":this.De.join(),"transition-duration":`${this.Ne}ms`,"transition-timing-function":this.He}),e.setStyle(this.U,this.$e)}}},3635:()=>{const t=up.util;up.DestructorPass=class DestructorPass{constructor(t,e){this.nn=t,this.sn=e}run(){for(let e of this.rn()){let n=t.pluckKey(e,"upDestructors");n?.clean(e)}}rn(){const t={...this.sn,destroying:!0};return up.fragment.subtree(this.nn,".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.un(),this.baseLayer?this.baseLayer.asCurrent((()=>this.an())):this.an(),this.event}an(){this.target.dispatchEvent(this.event),this.ensureBubbles&&!this.target.isConnected&&document.dispatchEvent(this.event),up.error.guard((()=>this.callback?.(this.event)))}assertEmitted(){const t=this.emit();if(t.defaultPrevented)throw new up.Aborted(`Event ${t.type} was prevented`)}un(){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={}){let s,r=t.extractOptions(n);return r=t.merge(i,r),t.isElementLike(n[0])?r.target=e.get(n.shift()):n[0]instanceof up.Layer&&(r.layer=n.shift()),t.isGiven(r.layer)&&(s=up.layer.get(r.layer),r.target||=s.element,r.baseLayer||=s),r.baseLayer&&(r.baseLayer=up.layer.get(r.baseLayer)),t.isString(r.target)?r.target=up.fragment.get(r.target,{layer:r.layer}):r.target||(r.target=document),n[0]?.preventDefault?(r.event=n[0],r.log??=n[0].log):t.isString(n[0])?r.event=up.event.build(n[0],r):r.event=up.event.build(r),new this(r)}}},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){super(t),this.hn=this.constructor.cn(t),this.isDefault=up.framework.evaling,this.beforeBoot??=0===this.eventType.indexOf("up:framework:"),this.nativeCallback=this.nativeCallback.bind(this)}bind(){const t=this.element.upEventListeners||={};t[this.hn]&&up.fail("up.on(): The %o callback %o cannot be registered more than once",this.eventType,this.callback),t[this.hn]=this,this.element.addEventListener(...this.ln())}ln(){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.ln())}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 s=this.callback.bind(n,...t);this.baseLayer?this.baseLayer.asCurrent(s):s()}}static fromElement(t){let e=t.element.upEventListeners;if(e)return e[this.cn(t)]}static cn(e){return e.callback.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.pn((function(t){const n=new up.EventListener(t);return n.bind(),e(n.unbind.bind(n))})),e.clean}pn(t){for(let e of this.elements)for(let n of this.eventTypes)t(this.fn(e,n))}fn(t,e){return{...this.attributes(),element:t,eventType:e}}unbind(){this.pn((function(t){let e=up.EventListener.fromElement(t);e&&e.unbind()}))}static fromBindArgs(e,n){const i=(e=t.copy(e)).pop();let s;s=e[0].addEventListener?[e.shift()]:t.isJQuery(e[0])||t.isList(e[0])&&e[0][0].addEventListener?e.shift():[document];let r=t.getSimpleTokens(e.shift()),o=up.migrate.fixEventTypes;o&&(r=o(r));const u=t.extractOptions(e);return new this({elements:s,eventTypes:r,selector:e[0],callback:i,...u,...n})}}},2214:()=>{const t=up.util;up.FieldWatcher=class FieldWatcher{constructor(t,e,n){this.sn=e,this._e=t,this.dn=up.form.getScope(t),this.mn=n,this.gn=e.batch}start(){this.yn=null,this.wn=this.bn(),this.vn=null,this._n=!1,this.o=t.cleaner(),this.kn(this._e),this._e.addEventListener("up:fragment:inserted",(({target:t})=>{t!==this._e&&this.kn(t)})),this.o(up.fragment.onAborted(this.dn,(()=>this.Sn()))),this.o(up.on(this.dn,"reset",(()=>this.xn())))}stop(){this.Sn(),this.o.clean()}En(e){let n=t.copy(this.sn);return up.form.watchOptions(e,n,{defaults:{event:"input"}})}kn(t){for(let e of up.form.fields(t))this.On(e)}On(t){let e=this.En(t);this.o(up.on(t,e.event,(()=>this.Cn(e))))}Sn(){this.yn=null}Fn(e,n){this.yn=e,this.Tn=n;let i=n.delay||0;clearTimeout(this.vn),this.vn=t.timer(i,(()=>{this.vn=null,this.Rn()}))}Pn(e){return!t.isEqual(e,this.wn)&&!t.isEqual(this.yn,e)}async Rn(){if(!this.yn)return;if(this._n)return;if(this.vn)return;if(!this.dn.isConnected)return;let e=t.omit(this.Tn,["event","delay"]);const n=this.Ln(this.wn,this.yn);this.wn=this.yn,this.yn=null,this._n=!0,this.Tn=null;const i=[];if(this.gn)i.push(this.An(n,e));else for(let t in n){const s=n[t];i.push(this.An(s,t,e))}if(t.some(i,t.isPromise)){let t=Promise.allSettled(i);await t}this._n=!1,this.Rn()}An(...t){return up.error.guard(this.mn,...t)}Ln(e,n){const i={};let s=Object.keys(e);s=s.concat(Object.keys(n)),s=t.uniq(s);for(let r of s){const s=e[r],o=n[r];t.isEqual(s,o)||(i[r]=o)}return i}bn(){return up.Params.fromContainer(this._e).toObject()}Cn(t={}){const e=this.bn();this.Pn(e)&&this.Fn(e,t)}xn(){t.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.U=t,this.Nn=e,this.Hn=up.viewport.copyCursorProps(this.U)}wasLost(){return document.activeElement!==this.U&&!this.jn}autoVoid(){up.on("focusin",{once:!0},(()=>this.jn=!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:()=>{const t=up.util,e=up.element;up.FormValidator=class FormValidator{constructor(t){this.qn=t,this.Bn=[],this.Un=null,this.In=!1,this.zn(),this.Vn()}Vn(){up.fragment.onAborted(this.qn,(t=>this.Kn(t)))}Kn(t){this.Bn.length&&(this.Bn=[],this.Xn.reject(new up.Aborted(t.reason)),this.zn())}zn(){this.Xn=t.newDeferred()}watchContainer(t){let{event:e}=this.Wn(t);up.on(t,e,{guard:()=>up.fragment.isAlive(t)},(()=>up.error.muteUncriticalRejection(this.validate({origin:t}))))}validate(t={}){let e=this.Gn(t);return this.Bn.push(...e),this.Jn(),this.Xn}Gn(t){let e=this.Qn(t)||this.Yn(t)||this.Zn(t.origin);for(let n of e)n.renderOptions=this.Wn(n.origin,t),n.target=up.fragment.resolveOrigin(n.target,n);return e}Yn({origin:t,...e}){if(up.form.isField(t))return this.ti(t)||this.ei(t,e)}ei(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}Qn({target:e,origin:n}){if(t.isString(e)){up.puts("up.validate()",'Validating target "%s"',e);let i=up.fragment.splitTarget(e);return t.compact(i.map((function(t){let e=up.fragment.get(t,{origin:n});if(e)return{element:e,target:t,origin:n};up.fail('Validation target "%s" does not match an element',t)})))}}Zn(t){return up.puts("up.validate()","Validating element %o",t),[{element:t,target:up.fragment.toTarget(t),origin:t}]}ti(t){let n=t.closest("[up-validate]");if(n){let i=e.booleanOrStringAttr(n,"up-validate");return this.Qn({target:i,origin:t})}}Wn(t,e){return up.form.watchOptions(t,e,{defaults:{event:"change"}})}Jn(){let e=this.Bn.map((t=>t.renderOptions.delay)),n=Math.min(...e)||0;clearTimeout(this.Un),this.Un=t.timer(n,(()=>{this.Un=null,this.ni()}))}ni(){up.error.muteUncriticalRejection(this.ii())}async ii(){if(!this.Bn.length)return;if(this.In)return;if(this.Un)return;let t=this.si(this.Bn);this.Bn=[],this.In=!0;let e=this.Xn;this.zn();try{e.resolve(up.render(t)),await e}finally{this.In=!1,this.ni()}}si(e){let n=t.map(e,"origin"),i=t.flatMap(n,up.form.fields),s=t.uniq(t.map(i,"name")),r=t.map(e,"renderOptions"),o=t.mergeDefined(...r,up.form.destinationOptions(this.qn));return o.target=t.map(e,"target").join(", "),o.origin=this.qn,o.focus??="keep",o.failOptions=!1,o.defaultMaybe=!0,o.params=up.Params.merge(o.params,...t.map(r,"params")),o.headers=t.merge(o.headers,...t.map(r,"headers")),this.ri(o.headers,s),o.feedback=t.some(r,"feedback"),o.data=void 0,o.dataMap=t.mapObject(e,(({target:t,element:e,renderOptions:{data:n,keepData:i}})=>[t,i?up.data(e):n])),o.preview=void 0,o.previewMap=t.mapObject(e,(({target:t,renderOptions:{preview:e}})=>[t,e])),o.placeholder=void 0,o.placeholderMap=t.mapObject(e,(({target:t,renderOptions:{placeholder:e}})=>[t,e])),o.disable=e.map((t=>up.fragment.resolveOrigin(t.renderOptions.disable,t))),o.guardEvent=up.event.build("up:form:validate",{fields:i,log:"Validating form",params:o.params,form:this.qn}),o}ri(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||=new this(e)}}},2587:()=>{const t=up.util,e=/^([^ >+(]+) (.+)$/;up.FragmentFinder=class FragmentFinder{constructor(t){this.sn=t,this.A=t.origin,this.oi=t.selector,this.ui=t.document||window.document,this.ai=t.match??up.fragment.config.match,this.hi=t.preferOldElements}find(){return this.ci()||this.li()||this.pi()}ci(){if(this.hi)return this.hi.find((t=>this.ui.contains(t)&&up.fragment.matches(t,this.oi)))}li(){if("region"===this.ai&&!up.fragment.containsMainPseudo(this.oi)&&this.A?.isConnected)return this.fi()||this.di()}fi(){return up.fragment.closest(this.A,this.oi,this.sn)}di(){let n=up.fragment.splitTarget(this.oi);return t.findResult(n,(t=>{let n=t.match(e);if(n){let t=up.fragment.closest(this.A,n[1],this.sn);if(t)return up.fragment.getFirstDescendant(t,n[2])}}))}pi(){return up.fragment.getFirstDescendant(this.ui,this.oi,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.mi();case"restore":return this.gi();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.bi();case"autofocus":return this.vi();default:if(t.isString(e))return this.wi(e)}}processElement(t){return this.yi(t)}resolveCondition(t){return"lost"===t?this._i():super.resolveCondition(t)}wi(t){let e=this.findSelector(t);return this.yi(e)}mi(){return this.focusCapsule?.restore(this.layer,n)}gi(){return up.viewport.restoreFocus({layer:this.layer})}vi(){let t=this.fragment&&e.subtreeFirst(this.fragment,"[autofocus]");if(t)return this.yi(t)}yi(t){if(t)return up.focus(t,{force:!0,...n,inputDevice:this.inputDevice}),!0}bi(){let t=up.viewport.firstHashTarget(this.hash,{layer:this.layer});if(t)return this.yi(t)}_i(){return this.focusCapsule?.wasLost()}}},8057:()=>{const t=up.element;up.FragmentPolling=class FragmentPolling{constructor(t){this.sn=up.radio.pollOptions(t),this.nn=t,up.destructor(t,this.ki.bind(this)),up.fragment.onAborted(t,this.Si.bind(this)),this.xi="initialized",this.Ei=!0,this.Oi=!1,this.Ci()}static forFragment(t){return t.upPolling||=new this(t)}onPollAttributeObserved(){this.Fi()}ki(){this.Ti()}Fi(t){if(Object.assign(this.sn,t),"started"!==this.xi){if(!up.fragment.isTargetable(this.nn))return void up.warn("[up-poll]","Cannot poll untargetable fragment %o",this.nn);this.xi="started",this.Ri(),this.Pi()}}Ti(){"started"===this.xi&&(this.Li(),this.xi="stopped",this.unbindEvents?.())}forceStart(t){Object.assign(this.sn,t),this.forceStarted=!0,this.Fi()}forceStop(){this.Ti(),this.forceStarted=!1}Ri(){this.unbindEvents||(this.unbindEvents=up.on("visibilitychange up:layer:opened up:layer:dismissed up:layer:accepted",this.Ai.bind(this)))}Ai(){this.$i()&&this.Pi()}$i(){return!document.hidden&&("any"===this.sn.ifLayer||this.Di())}Li(){clearTimeout(this.Mi),this.Mi=null}Pi(){this.Mi||this.Oi||(this.Li(),this.Mi=setTimeout(this.Ni.bind(this),this.Hi()))}Ni(){this.Mi=null,this.ji()}ji(){"started"===this.xi&&(this.$i()?this.qi():up.puts("[up-poll]","Will not poll hidden fragment"))}Bi(){return this.sn.interval??t.numberAttr(this.nn,"up-interval")??up.radio.config.pollInterval}Hi(){return Math.max(this.Bi()-this.Ui(),0)}Ui(){return new Date-this.Ii}Di(){return this.layer||=up.layer.get(this.nn),this.layer?.isFront?.()}qi(){this.Li();let t=this.Ei;try{this.Ei=!1,this.Oi=!0,up.reload(this.nn,this.zi()).then(this.Vi.bind(this),this.Ki.bind(this))}finally{this.Ei=t}}zi(){let t=up.event.build("up:fragment:poll",{log:["Polling fragment",this.nn]});return{...this.sn,guardEvent:t}}Si({newLayer:t}){this.Ei&&!t&&this.Ti()}Vi({fragment:t}){this.Oi=!1,this.Ci(),t?this.Xi(t):this.Pi()}Xi(t){this.Ti(),this.forceStarted&&up.fragment.matches(this.nn,t)&&this.constructor.forFragment(t).forceStart(this.sn)}Ki(t){this.Oi=!1,this.Ci(),this.Pi(),up.error.throwCritical(t)}Ci(){this.Ii=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.Wi();case"layer":return this.Gi();case"main":return this.Ji(":main");case"restore":return this.Qi();case"hash":return this.hash&&up.viewport.revealHash(this.hash,this.attributes());case"target":case"reveal":case!0:return this.Yi(this.fragment);default:if(t.isString(e))return this.Ji(e)}}processElement(t){return this.Yi(t)}Yi(t){if(t)return up.reveal(t,this.attributes()),!0}Ji(t){let e=this.findSelector(t);return this.Yi(e)}Gi(){return this.Yi(this.layer.getBoxElement())}Wi(){return up.viewport.resetScroll({...this.attributes(),around:this.fragment}),!0}Qi(){return up.viewport.restoreScroll({...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(){return this.Zi??=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.ts(t).bind()}off(...t){return this.ts(t).unbind()}ts(t){return up.EventListenerGroup.fromBindArgs(t,{guard:t=>this.es(t),elements:[this.element],baseLayer:this})}es(t){return this.contains(t.target)}wasHitByMouseEvent({clientX:t,clientY:e}){const n=document.elementFromPoint(t,e);return!n||this.contains(n)}ns(t){return up.EventEmitter.fromEmitArgs(t,{layer:this})}emit(...t){return this.ns(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){e.isString(t.location)&&(this.location=t.location),up.history.config.updateMetaTags&&e.isList(t.metaTags)&&(up.migrate?.warnOfHungryMetaTags?.(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:()=>{var t;const e=up.element,n=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=n.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.ss();const e=n.compactObject(n.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}),e.affix(this.dismissElement,'span[aria-hidden="true"]',{text:this.dismissLabel})}affixPart(t,n,i={}){return e.affix(t,this.selector(n),i)}static selector(t){return n.compact(["up",this.mode,t]).join("-")}ss(){const{parent:t}=this;return this.mode===t.mode?1+t.ss():0}setupHandlers(){super.setupHandlers(),this.overlayFocus=new up.OverlayFocus(this),this.rs("button")&&this.createDismissElement(this.getBoxElement()),this.rs("outside")&&(this.viewportElement?up.on(this.viewportElement,"up:click",(t=>{t.target===this.viewportElement&&this.os(t,!0)})):this.unbindParentClicked=this.parent.on("up:click",((t,e)=>{if(!up.layer.isWithinForeignOverlay(e)){const n=this.origin&&this.origin.contains(e);this.os(t,n)}}))),this.rs("key")&&(this.unbindEscapePressed=up.event.onEscape((t=>this.onEscapePressed(t)))),this.registerClickCloser("up-accept",((t,e)=>{this.accept(t,e)})),this.registerClickCloser("up-dismiss",((t,e)=>{this.dismiss(t,e)})),up.migrate.registerLayerCloser?.(this),this.us(this.acceptEvent,this.accept),this.us(this.dismissEvent,this.dismiss),this.on("up:click","label[for]",((t,e)=>this.hs(t,e)))}hs(t,n){let i=n.getAttribute("for"),s=up.form.fieldSelector(e.idSelector(i)),r=up.fragment.all(s,{layer:"any"}),o=up.fragment.all(s,{layer:this});if(r.length>1&&o[0]!==r[0]){t.preventDefault();const e=o[0];e.focus(),e.matches("input[type=checkbox], input[type=radio]")&&e.click()}}os(t,e){up.log.putsEvent(t),e&&up.event.halt(t),up.error.muteUncriticalSync((()=>this.dismiss(":outside",{origin:t.target})))}onEscapePressed(t){if(this.isFront()){let e=up.form.focusedField();e?e.blur():this.rs("key")&&(up.event.halt(t,{log:!0}),up.error.muteUncriticalSync((()=>this.dismiss(":key"))))}}registerClickCloser(t,n){let i=`[${t}]`;this.on("up:click",i,(function(s){up.event.halt(s,{log:!0});const r=s.target.closest(i),o=e.jsonAttr(r,t),u={origin:r},a=new up.OptionsParser(r,u);a.booleanOrString("animation"),a.string("easing"),a.number("duration"),a.string("confirm"),up.error.muteUncriticalSync((()=>n(o,u)))}))}us(t,e){if(t)return this.on(t,(t=>{t.preventDefault(),up.error.muteUncriticalSync((()=>e.call(this,t,{response:t.response})))}))}tryAcceptForLocation(t){this.cs(this.acceptLocation,this.accept,t)}tryDismissForLocation(t){this.cs(this.dismissLocation,this.dismiss,t)}cs(t,e,n){let i,s;if(t&&(i=this.location)&&(s=t.recognize(i))){const t={...s,location:i};up.error.muteUncriticalSync((()=>e.call(this,t,n)))}}teardownHandlers(){super.teardownHandlers(),this.unbindParentClicked?.(),this.unbindEscapePressed?.(),this.overlayFocus.teardown()}destroyElements(t){const e={...t,animation:()=>this.startCloseAnimation(t),onFinished:()=>{this.onElementsRemoved(),t.onFinished?.()},log:!1};up.destroy(this.element,e)}onElementsRemoved(){}ls(t={}){const e=up.animate(this.getBoxElement(),t.boxAnimation,t);let n;return this.backdrop&&!up.motion.isNone(t.boxAnimation)&&(n=up.animate(this.backdropElement,t.backdropAnimation,t)),Promise.all([e,n])}async startOpenAnimation(t={}){let e=t.animation??this.evalOption(this.openAnimation);await this.ls({boxAnimation:e,backdropAnimation:"fade-in",easing:t.easing||this.openEasing,duration:t.duration||this.openDuration}),this.wasEverVisible=!0}startCloseAnimation(t={}){let e=this.wasEverVisible&&(t.animation??this.evalOption(this.closeAnimation));return this.ls({boxAnimation:e,backdropAnimation:"fade-out",easing:t.easing||this.closeEasing,duration:t.duration||this.closeDuration})}accept(t=null,e={}){return this.ps("accept",t,e)}dismiss(t=null,e={}){return this.ps("dismiss",t,e)}rs(t){return n.contains(this.dismissable,t)}ps(t,e,n){return n={...n,verb:t,value:e,layer:this},new up.Change.CloseLayer(n).execute()}getFirstSwappableElement(){return this.getContentElement().children[0]}toString(){return`${this.mode} overlay`}}).VISUAL_KEYS=["mode","position","align","size","origin","class","backdrop","dismissable","dismissLabel","dismissARIALabel","openAnimation","closeAnimation","openDuration","closeDuration","openEasing","closeEasing","trapFocus"],t)},6412:()=>{up.Layer.OverlayWithTether=class OverlayWithTether extends up.Layer.Overlay{createElements(){this.origin||up.fail("Missing { origin } option"),this.fs=new up.Tether({anchor:this.origin,align:this.align,position:this.position}),this.createElement(this.fs.parent),this.createContentElement(this.element)}onContentSet(){this.fs.start(this.element)}onElementsRemoved(){this.fs.stop()}sync(){this.isOpen()&&(this.isDetached()||this.fs.isDetached()?this.dismiss(":detached",{animation:!1,preventable:!1}):this.fs.sync())}}},7965:()=>{up.Layer.OverlayWithViewport=class OverlayWithViewport extends up.Layer.Overlay{static getParentElement(){return document.body}createElements(){up.viewport.bodyShifter.raiseStack(),this.createElement(this.constructor.getParentElement()),this.backdrop&&this.createBackdropElement(this.element),this.createViewportElement(this.element),this.createBoxElement(this.viewportElement),this.createContentElement(this.boxElement)}onElementsRemoved(){up.viewport.bodyShifter.lowerStack()}sync(){this.isDetached()&&this.isOpen()&&this.constructor.getParentElement().appendChild(this.element)}}},4552:()=>{var t;up.Layer.Popup=((t=class Popup extends up.Layer.OverlayWithTether{}).mode="popup",t)},7771:()=>{var t;const e=up.element;up.Layer.Root=((t=class Root extends up.Layer{get element(){return e.root}constructor(t){super(t),this.setupHandlers()}getFirstSwappableElement(){return document.body}static selector(){return"html"}setupHandlers(){th