@krate/runtime 0.5.0-rc.1 → 0.5.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-context.js +1 -1
- package/dist/actions.d.ts +7 -0
- package/dist/actions.js +34 -10
- package/dist/after.d.ts +28 -0
- package/dist/after.js +48 -0
- package/dist/assets-static.d.ts +10 -1
- package/dist/assets-static.js +10 -2
- package/dist/base-path.d.ts +7 -0
- package/dist/base-path.js +20 -0
- package/dist/boundary.js +1 -1
- package/dist/builtin-tags.d.ts +12 -0
- package/dist/builtin-tags.js +42 -0
- package/dist/cache-adapter.js +1 -1
- package/dist/cache-scope.d.ts +8 -0
- package/dist/cache-scope.js +14 -1
- package/dist/cloudflare-workers.d.ts +2 -0
- package/dist/cloudflare-workers.js +27 -0
- package/dist/context.d.ts +5 -0
- package/dist/context.js +28 -17
- package/dist/dev-overlay.d.ts +54 -3
- package/dist/dev-overlay.js +470 -77
- package/dist/dom.js +18 -3
- package/dist/effects.js +2 -2
- package/dist/flight-props.d.ts +7 -0
- package/dist/flight-props.js +105 -0
- package/dist/handler-html.js +4 -4
- package/dist/handler-routing.d.ts +2 -23
- package/dist/handler-routing.js +9 -190
- package/dist/handler-segments.d.ts +6 -0
- package/dist/handler-segments.js +18 -4
- package/dist/head-tags.d.ts +9 -0
- package/dist/head-tags.js +93 -6
- package/dist/highlight-bind.js +1 -1
- package/dist/highlight.d.ts +3 -2
- package/dist/highlight.js +17 -12
- package/dist/hints.d.ts +25 -2
- package/dist/hints.js +147 -74
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/island-swap.d.ts +47 -0
- package/dist/island-swap.js +635 -0
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-types.d.ts +99 -3
- package/dist/krate-core.js +1 -1
- package/dist/krate-dev.js +385 -66
- package/dist/krate-f-actions.js +1 -1
- package/dist/krate-f-classes.js +1 -1
- package/dist/krate-f-highlight.js +1 -1
- package/dist/krate-f-list.js +1 -1
- package/dist/krate-f-navigation.js +1 -1
- package/dist/krate-f-router-lite.js +1 -1
- package/dist/krate-f-router.js +1 -1
- package/dist/krate-features.json +454 -0
- package/dist/krate-hydrate-lite.js +5 -5
- package/dist/krate-hydrate.js +5 -5
- package/dist/krate-island-swap.js +1 -0
- package/dist/krate-runtime.js +5 -5
- package/dist/list.d.ts +14 -4
- package/dist/list.js +4 -5
- package/dist/metadata.js +5 -2
- package/dist/navigation-react.d.ts +13 -0
- package/dist/navigation-react.js +86 -0
- package/dist/navigation.d.ts +19 -0
- package/dist/navigation.js +35 -0
- package/dist/node-server.js +3 -3
- package/dist/og.js +1 -1
- package/dist/platform.d.ts +52 -0
- package/dist/platform.js +57 -0
- package/dist/react-compat.d.ts +39 -0
- package/dist/react-compat.js +359 -0
- package/dist/react-server.d.ts +63 -0
- package/dist/react-server.js +125 -0
- package/dist/region-wire.d.ts +10 -0
- package/dist/region-wire.js +154 -0
- package/dist/request-context.js +1 -1
- package/dist/request-extras.d.ts +4 -0
- package/dist/request-extras.js +51 -0
- package/dist/resp.js +1 -1
- package/dist/route-source.d.ts +39 -0
- package/dist/route-source.js +532 -0
- package/dist/router-lite.js +3 -9
- package/dist/router.d.ts +1 -1
- package/dist/router.js +628 -98
- package/dist/server-handler.d.ts +69 -1
- package/dist/server-handler.js +515 -96
- package/dist/server-renderer.js +16 -7
- package/dist/server.d.ts +73 -16
- package/dist/server.js +619 -102
- package/dist/sha256.js +9 -9
- package/dist/signal.js +0 -6
- package/dist/site-config.d.ts +15 -0
- package/dist/site-config.js +28 -0
- package/dist/slot.d.ts +12 -0
- package/dist/slot.js +23 -0
- package/dist/ssr-core.d.ts +2 -0
- package/dist/ssr-core.js +12 -4
- package/dist/testing.d.ts +62 -0
- package/dist/testing.js +90 -0
- package/dist/use-id.js +1 -1
- package/package.json +28 -3
- package/dist/action-context.test.d.ts +0 -1
- package/dist/action-context.test.js +0 -72
- package/dist/actions.test.d.ts +0 -1
- package/dist/actions.test.js +0 -477
- package/dist/cache-adapter.test.d.ts +0 -1
- package/dist/cache-adapter.test.js +0 -244
- package/dist/cache.test.d.ts +0 -1
- package/dist/cache.test.js +0 -233
- package/dist/class-component.test.d.ts +0 -1
- package/dist/class-component.test.js +0 -462
- package/dist/class-helpers.test.d.ts +0 -1
- package/dist/class-helpers.test.js +0 -169
- package/dist/context.test.d.ts +0 -1
- package/dist/context.test.js +0 -57
- package/dist/derived.test.d.ts +0 -1
- package/dist/derived.test.js +0 -140
- package/dist/dev-overlay.test.d.ts +0 -1
- package/dist/dev-overlay.test.js +0 -165
- package/dist/discrete.test.d.ts +0 -1
- package/dist/discrete.test.js +0 -100
- package/dist/dom.test.d.ts +0 -1
- package/dist/dom.test.js +0 -39
- package/dist/effect-errors.test.d.ts +0 -1
- package/dist/effect-errors.test.js +0 -199
- package/dist/effects.test.d.ts +0 -1
- package/dist/effects.test.js +0 -485
- package/dist/events.test.d.ts +0 -1
- package/dist/events.test.js +0 -447
- package/dist/handler-html.test.d.ts +0 -1
- package/dist/handler-html.test.js +0 -256
- package/dist/handler-routing.test.d.ts +0 -1
- package/dist/handler-routing.test.js +0 -99
- package/dist/handler-segments.test.d.ts +0 -1
- package/dist/handler-segments.test.js +0 -217
- package/dist/head-tags.test.d.ts +0 -1
- package/dist/head-tags.test.js +0 -131
- package/dist/highlight-bind.test.d.ts +0 -1
- package/dist/highlight-bind.test.js +0 -124
- package/dist/highlight.test.d.ts +0 -1
- package/dist/highlight.test.js +0 -56
- package/dist/lanes.test.d.ts +0 -1
- package/dist/lanes.test.js +0 -59
- package/dist/list.test.d.ts +0 -1
- package/dist/list.test.js +0 -435
- package/dist/metadata.test.d.ts +0 -1
- package/dist/metadata.test.js +0 -167
- package/dist/navigation.test.d.ts +0 -1
- package/dist/navigation.test.js +0 -130
- package/dist/node-server.test.d.ts +0 -1
- package/dist/node-server.test.js +0 -492
- package/dist/optimistic-lanes.test.d.ts +0 -1
- package/dist/optimistic-lanes.test.js +0 -45
- package/dist/patterns.test.d.ts +0 -1
- package/dist/patterns.test.js +0 -125
- package/dist/portal.test.d.ts +0 -1
- package/dist/portal.test.js +0 -99
- package/dist/react-effects.test.d.ts +0 -1
- package/dist/react-effects.test.js +0 -133
- package/dist/react-suspense.test.d.ts +0 -1
- package/dist/react-suspense.test.js +0 -194
- package/dist/react.test.d.ts +0 -1
- package/dist/react.test.js +0 -60
- package/dist/react19.test.d.ts +0 -1
- package/dist/react19.test.js +0 -176
- package/dist/reactivity-core.test.d.ts +0 -1
- package/dist/reactivity-core.test.js +0 -152
- package/dist/reconcile.test.d.ts +0 -1
- package/dist/reconcile.test.js +0 -110
- package/dist/refs.test.d.ts +0 -1
- package/dist/refs.test.js +0 -257
- package/dist/router-layout.test.d.ts +0 -1
- package/dist/router-layout.test.js +0 -249
- package/dist/router-nav.test.d.ts +0 -1
- package/dist/router-nav.test.js +0 -559
- package/dist/router-slots.test.d.ts +0 -1
- package/dist/router-slots.test.js +0 -144
- package/dist/router-speculation.test.d.ts +0 -1
- package/dist/router-speculation.test.js +0 -25
- package/dist/router-styles.test.d.ts +0 -1
- package/dist/router-styles.test.js +0 -98
- package/dist/router.test.d.ts +0 -1
- package/dist/router.test.js +0 -36
- package/dist/server-async.test.d.ts +0 -1
- package/dist/server-async.test.js +0 -216
- package/dist/server-handler.test.d.ts +0 -1
- package/dist/server-handler.test.js +0 -535
- package/dist/server-highlight.test.d.ts +0 -1
- package/dist/server-highlight.test.js +0 -32
- package/dist/server-renderer.test.d.ts +0 -1
- package/dist/server-renderer.test.js +0 -266
- package/dist/server.test.d.ts +0 -1
- package/dist/server.test.js +0 -88
- package/dist/sha256.test.d.ts +0 -1
- package/dist/sha256.test.js +0 -13
- package/dist/signal-lanes.test.d.ts +0 -1
- package/dist/signal-lanes.test.js +0 -32
- package/dist/signal.test.d.ts +0 -1
- package/dist/signal.test.js +0 -68
- package/dist/slots.test.d.ts +0 -1
- package/dist/slots.test.js +0 -187
- package/dist/snapshots.test.d.ts +0 -1
- package/dist/snapshots.test.js +0 -208
- package/dist/ssr-core-behavior.test.d.ts +0 -1
- package/dist/ssr-core-behavior.test.js +0 -620
- package/dist/ssr-core.test.d.ts +0 -1
- package/dist/ssr-core.test.js +0 -324
- package/dist/static-memory.test.d.ts +0 -1
- package/dist/static-memory.test.js +0 -26
- package/dist/storage.test.d.ts +0 -1
- package/dist/storage.test.js +0 -46
- package/dist/suspense-actions.test.d.ts +0 -1
- package/dist/suspense-actions.test.js +0 -72
- package/dist/suspense.test.d.ts +0 -1
- package/dist/suspense.test.js +0 -556
package/dist/krate-f-classes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __krate_exports=(()=>{var T=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var ge=(t,e)=>{for(var n in e)T(t,n,{get:e[n],enumerable:!0})},ve=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Oe(e))!xe.call(t,o)&&o!==n&&T(t,o,{get:()=>e[o],enumerable:!(r=ke(e,o))||r.enumerable});return t};var Se=t=>ve(T({},"__esModule",{value:!0}),t);var ze={};ge(ze,{__krateClass:()=>me,__krateClassError:()=>Ne,__krateCondPost:()=>Fe,__krateCondPre:()=>Ue,__krateOnError:()=>_e,__krateOwn:()=>Pe,__krateOwner:()=>Ie,componentStack:()=>de,createOwner:()=>be,getOwner:()=>I,handleError:()=>O,inCommitPhaseError:()=>V,krateScopeFailed:()=>je,mountClassElement:()=>Le,mountOwner:()=>z,onOwnerCleanup:()=>U,remountChildren:()=>_,runWithOwner:()=>j,setBoundary:()=>N,unmountChildren:()=>Q,unmountOwner:()=>F});var G=window.createEffect;var H=window.createSignal;var Y=window.krateCurrentScope;var Z=window.krateGetOwner;var $=window.krateOnDispose,ee=window.krateOnSettle;var te=window.krateRenderPhase,B=window.krateRequestFlush;var ne=window.krateScopeOfId,re=window.krateSetOwner;var oe=window.setOwnerHooks,h=window.untrack;var se=window.krateForgetOwner;var ie=window.krateOnHookError,ae=window.krateOnLayoutCommit;var x=null,ye=0,m=new Map,S=new Map,b=new Map,P=0,v=[];function ce(t,e,n,r,o,s,c){let a={id:t,name:e,parent:n,creator:r,children:[],order:ye++,state:"dormant",boundary:null,blocked:!1,inError:!1,cond:o,branch:s,setup:c,data:{},scope:Y(),cleanups:[]};return n&&n.children.push(a),a}function I(){return x}function be(t,e=x){let n=ce("",t,e||null,e||null,"","",null);return n.state=e&&e.state!=="mounted"?"dormant":"mounted",n}function j(t,e){if(!t)return e();let n=t;if(n.state!=="mounted")return;let r=x;x=n;try{return h(e)}catch(o){O(o,n);return}finally{x=r}}function U(t,e){let n=t;if(n.state!=="mounted"){Ee(e,n);return}n.cleanups.push(e)}function N(t,e){t.boundary=e}function de(t){let e="";for(let n=t;n;n=n.parent)e+=`
|
|
2
2
|
at `+n.name;return e}function O(t,e=x){if(!e)throw t;let n={componentStack:de(e)};for(let r=e.parent;r;r=r.parent){if(r.state!=="mounted"||!r.boundary)continue;let o=!1;try{o=r.boundary(t,n,e)}catch(s){O(s,r);return}if(o)return}Ce(t,n,e)}function Ce(t,e,n){let r=globalThis;try{let o=String(t?.stack||t?.message||t);Array.isArray(r.__krateErrs)&&r.__krateErrs.push(o)}catch{}typeof console<"u"&&(console.error(t),console.error("The above error occurred in the <"+n.name+"> component:"+e.componentStack+`
|
|
3
3
|
|
|
4
|
-
Add an error boundary (a class component with static getDerivedStateFromError) to recover from it.`)),n.blocked=!0,F(n)}function Ee(t,e){try{t()}catch(n){e&&e.parent?O(n,e):le(n)}}function le(t){typeof console<"u"&&console.error(t)}function F(t){g(t,"dormant")}function je(t){for(let e of m.values())if(e.scope===t&&e.inError)return!0;return!1}function z(t){let e=t;e.state==="dormant"&&(e.blocked=!1,C(e)&&E(e))}function Q(t){for(let e of t.children)g(e,"dormant")}function _(t){if(t.state==="mounted")for(let e of t.children.slice())e.blocked=!1,e.state==="dormant"&&C(e)&&E(e)}function g(t,e){if(t.state==="mounted"){t.state=e;let n=[];for(let r of t.cleanups.splice(0))try{r()}catch(o){n.push(o)}if(t.id)try{se(t.id)}catch(r){n.push(r)}for(let r of t.children)g(r,e);for(let r of n)t.parent?O(r,t):le(r);return}if(e==="disposed"&&t.state!=="disposed"){t.state="disposed";for(let n of t.children)g(n,e)}}function pe(t){if(!t.cond)return!0;let e=S.get(t.cond);return e===void 0||e===t.branch}function C(t){return t.blocked||!pe(t)?!1:!t.parent||t.parent.state==="mounted"}function E(t){if(t.state!=="dormant")return;t.state="mounted",P++;let e=Z();try{t.setup&&j(t,t.setup)}finally{re(e),P--}if(t.state==="mounted")for(let n of t.children.slice())n.state==="dormant"&&C(n)&&E(n);if(P===0&&v.length>0){let n=v.splice(0).sort((r,o)=>r.order-o.order);for(let r of n)r.state==="dormant"&&C(r)&&E(r)}}$(t=>{t===null?Re():De(t)});function Re(){let t=[];for(let e of m.values())e.parent||t.push(e);for(let e of t)g(e,"disposed");m.clear(),S.clear(),b.clear(),v.length=0}function De(t){let e=[];for(let n of m.values())t(n.scope)&&e.push(n);for(let n of e)n.state!=="disposed"&&g(n,"disposed");for(let n of e){m.delete(n.id);let r=n.parent;if(r&&!t(r.scope)){let o=r.children.indexOf(n);o
|
|
4
|
+
Add an error boundary (a class component with static getDerivedStateFromError) to recover from it.`)),n.blocked=!0,F(n)}function Ee(t,e){try{t()}catch(n){e&&e.parent?O(n,e):le(n)}}function le(t){typeof console<"u"&&console.error(t)}function F(t){g(t,"dormant")}function je(t){for(let e of m.values())if(e.scope===t&&e.inError)return!0;return!1}function z(t){let e=t;e.state==="dormant"&&(e.blocked=!1,C(e)&&E(e))}function Q(t){for(let e of t.children)g(e,"dormant")}function _(t){if(t.state==="mounted")for(let e of t.children.slice())e.blocked=!1,e.state==="dormant"&&C(e)&&E(e)}function g(t,e){if(t.state==="mounted"){t.state=e;let n=[];for(let r of t.cleanups.splice(0))try{r()}catch(o){n.push(o)}if(t.id)try{se(t.id)}catch(r){n.push(r)}for(let r of t.children)g(r,e);for(let r of n)t.parent?O(r,t):le(r);return}if(e==="disposed"&&t.state!=="disposed"){t.state="disposed";for(let n of t.children)g(n,e)}}function pe(t){if(!t.cond)return!0;let e=S.get(t.cond);return e===void 0||e===t.branch}function C(t){return t.blocked||!pe(t)?!1:!t.parent||t.parent.state==="mounted"}function E(t){if(t.state!=="dormant")return;t.state="mounted",P++;let e=Z();try{t.setup&&j(t,t.setup)}finally{re(e),P--}if(t.state==="mounted")for(let n of t.children.slice())n.state==="dormant"&&C(n)&&E(n);if(P===0&&v.length>0){let n=v.splice(0).sort((r,o)=>r.order-o.order);for(let r of n)r.state==="dormant"&&C(r)&&E(r)}}$(t=>{t===null?Re():De(t)});function Re(){let t=[];for(let e of m.values())e.parent||t.push(e);for(let e of t)g(e,"disposed");m.clear(),S.clear(),b.clear(),v.length=0}function De(t){let e=[];for(let n of m.values())t(n.scope)&&e.push(n);for(let n of e)n.state!=="disposed"&&g(n,"disposed");for(let n of e){m.delete(n.id);let r=n.parent;if(r&&!t(r.scope)){let o=r.children.indexOf(n);o!==-1&&r.children.splice(o,1)}}for(let n of Array.from(S.keys()))t(ne(n))&&(S.delete(n),b.delete(n));for(let n=v.length-1;n>=0;n--)v[n].state==="disposed"&&v.splice(n,1)}function Pe(t,e,n){let r=e||{},o=m.get(t);o&&g(o,"disposed");let s=r.p&&m.get(r.p)||null,c=r.k&&m.get(r.k)||null,a=ce(t,r.n||t,s,c,r.c||"",r.b||"",n);if(m.set(t,a),a.cond){let p=b.get(a.cond);p||(p=[],b.set(a.cond,p)),p.push(a)}s&&s.inError&&pe(a)&&(a.blocked=!0),C(a)&&E(a)}function Ie(t){return m.get(t)||null}function Ue(t,e){let n=S.get(t);if(n===void 0||n===(e?"c":"a"))return;let o=b.get(t);if(o)for(let s of o)s.branch===n&&s.state==="mounted"&&g(s,"dormant")}function Fe(t,e){let n=e?"c":"a",r=S.get(t);if(S.set(t,n),r===n)return;let o=b.get(t);if(o)for(let s of o)s.branch!==n||s.state!=="dormant"||!C(s)||(P>0?v.push(s):E(s))}function _e(t,e){return!x||e&&e.isConnected===!1?!1:(O(t,x),!0)}ie((t,e)=>{let n=e?m.get(e):void 0;if(!n)return!1;if(n.state==="mounted"){L++;try{O(t,n)}finally{L--}}return!0});var L=0;function V(){return L>0}oe({current:()=>x,run:(t,e)=>{j(t,e)},cleanup:(t,e)=>U(t,e),error:(t,e)=>{let n=t;return n.state==="mounted"&&O(e,n),!0}});var ue=window.krateSetRef;var Ae=0,fe=Symbol.for("krate.class.rawProps"),J=class{constructor(e,n,r,o){this.seq=Ae++;this.rawGetters=[];this.queue=[];this.forced=!1;this.parentRender=!1;this.mounted=!1;this.disposed=!1;this.catching=!1;this.detachRef=null;this.errorCommitPending=!1;this.spec=o||{},this.owner=I(),this.raw=e&&typeof e=="object"?e:{},this.getState=n,this.setStateSignal=r;let c=this.raw[fe];if(!c){c=[];for(let i of Object.keys(this.raw)){let u=Object.getOwnPropertyDescriptor(this.raw,i);if(u&&u.get){let k=u.get,q=this.raw;c.push([i,()=>k.call(q)])}}try{Object.defineProperty(this.raw,fe,{value:c,enumerable:!1,configurable:!0})}catch{}}this.rawGetters.push(...c),this.props=this.readProps(),this.key=this.readKey(),this.state=h(n)||{},this.context=this.readContext();let[a,p]=H(this.props);this.setRendered=p,this.gateProps(a);let d=this,f={get props(){return d.props},get state(){return d.state},set state(i){d.state=i},get context(){return d.context},setState(i,u){d.enqueue({partial:i,callback:u})},forceUpdate(i){d.forced=!0,d.enqueue({partial:null,callback:i})}};if(this.inst=f,this.owner&&(this.owner.data.classController=this,U(this.owner,()=>this.unmount()),(this.spec.getDerivedStateFromError||this.spec.componentDidCatch)&&N(this.owner,(i,u)=>this.catchError(i,u))),this.spec.setContext&&this.spec.setContext(this.context),this.rawGetters.length>0||this.spec.context){let i=!0;G(()=>{for(let[,u]of this.rawGetters)u();if(this.trackContext(),i){i=!1;return}this.disposed||(y.add(this),we())})}R(this,()=>{let i=this.spec.expose?h(this.spec.expose):null;if(i)for(let k of Object.keys(i))k in this.inst||(this.inst[k]=i[k]);this.mounted=!0,this.spec.componentDidMount&&this.spec.componentDidMount.call(this.inst);let u=h(()=>this.raw.ref);u&&(this.detachRef=ue(u,this.inst))});let w=this.spec.buildError;if(w&&this.spec.componentDidCatch){let i=new Error(w.message||"Error");w.name&&(i.name=w.name),this.owner&&(this.owner.inError=!0),R(this,()=>{this.spec.componentDidCatch.call(this.inst,i,{componentStack:`
|
|
5
5
|
at `+(this.spec.name||"Component")+" (build)"})})}else w&&this.owner&&(this.owner.inError=!0)}readProps(){let e={};h(()=>{for(let r of Object.keys(this.raw)){if(r.startsWith("__krate")||r==="ref"||r==="key")continue;let o=this.rawGetters.find(s=>s[0]===r);e[r]=o?o[1]():this.raw[r]}});let n=this.spec.defaultProps;if(n)for(let r of Object.keys(n))e[r]===void 0&&(e[r]=n[r]);return e}readContext(){return h(()=>this.trackContext())}trackContext(){let e=this.spec.context;if(!e)return;let n=e();if(typeof n=="function"){for(let r of Object.keys(this.raw))if(r.startsWith("__krate_ctx_")&&this.raw[r]===n)return n()}return n}gateProps(e){let n=new Set;for(let[o]of this.rawGetters)n.add(o);let r=this.spec.defaultProps;if(r)for(let o of Object.keys(r))this.raw[o]===void 0&&n.add(o);for(let o of n)if(!(o.startsWith("__krate")||o==="ref"||o==="key"))try{Object.defineProperty(this.raw,o,{get:()=>e()[o],enumerable:!0,configurable:!0})}catch{}}enqueue(e){this.disposed||(this.queue.push(e),y.add(this),we())}markParentRender(){this.disposed||!this.mounted||(this.parentRender=!0,y.add(this))}performUpdate(){if(!(this.disposed||this.owner&&this.owner.state!=="mounted"))if(this.owner)j(this.owner,()=>this.update());else try{this.update()}catch(e){console.error(e)}}readKey(){let e=this.rawGetters.find(n=>n[0]==="__krate_key");return h(()=>e?e[1]():this.raw.__krate_key)}update(){let e=this.spec,n=this.inst;if(!Object.is(this.readKey(),this.key)&&this.owner){let l=this.owner;F(l),l.inError=!1,z(l),_(l);return}let r=this.readProps(),o=this.readContext(),s=!K(r,this.props)||o!==this.context,c=this.queue;this.queue=[];let a=this.forced;this.forced=!1;let p=this.parentRender;if(this.parentRender=!1,c.length===0&&!a&&!s&&!p)return;let d=!e.getDerivedStateFromProps&&!e.getSnapshotBeforeUpdate;d&&(s||p)&&e.componentWillReceiveProps&&(e.componentWillReceiveProps.call(n,r,o),c.push(...this.queue),this.queue=[]);let f=this.props,w=this.state,i=w,u=[];for(let l of c){let M=typeof l.partial=="function"?l.partial.call(n,i,r):l.partial;M!=null&&typeof M=="object"&&(i={...i,...M}),typeof l.callback=="function"&&u.push(l.callback)}if(e.getDerivedStateFromProps){let l=e.getDerivedStateFromProps(r,i);l!=null&&(i={...i,...l})}let k=!0;if(a||(e.shouldComponentUpdate?k=!!e.shouldComponentUpdate.call(n,r,i,o):e.pure&&(k=!K(f,r)||!K(w,i))),k&&d&&e.componentWillUpdate&&e.componentWillUpdate.call(n,r,i,o),this.props=r,this.state=i,this.context=o,!k){for(let l of u)R(this,()=>l.call(n));return}let q=e.getSnapshotBeforeUpdate?e.getSnapshotBeforeUpdate.call(n,f,w):void 0;this.setRendered(r),e.setContext&&e.setContext(o),this.setStateSignal(a&&i===w?{...i}:i),a&&i===w&&(this.state=h(this.getState)),this.owner&&this.owner.inError&&!this.errorCommitPending&&this.owner&&(this.owner.inError=!1,D.add(this.owner)),R(this,()=>{e.componentDidUpdate&&e.componentDidUpdate.call(n,f,w,q)});for(let l of u)R(this,()=>l.call(n));this.cascade()}cascade(){let e=this.owner;if(!e)return;let n=o=>{for(let s=o?o.creator:null;s;s=s.creator){if(s===e)return!0;if(s.data.classController)return!1}return!1},r=o=>{for(let s of o.children){if(s.state!=="mounted")continue;let c=s.data.classController;c&&n(s)&&c.markParentRender(),r(s)}};r(e)}catchError(e,n){let r=this.spec,o=this.owner;if(this.disposed||!o||o.state!=="mounted")return!1;if(this.catching)return!0;if(o.inError)return!1;this.catching=!0;try{typeof console<"u"&&(console.error(e),console.error("The above error occurred in the <"+(n.componentStack.match(/at (\S+)/)?.[1]||"Unknown")+"> component:"+n.componentStack+`
|
|
6
6
|
|
|
7
7
|
React will try to recreate this component tree from scratch using the error boundary you provided, `+(r.name||"Component")+".")),o.inError=!0;let s=o.children.filter(f=>f.state==="mounted");Q(o);for(let f of s)f.blocked=!0;let c=this.state;if(r.getDerivedStateFromError){this.mounted&&!X&&!V()&&r.getDerivedStateFromError(e);let f=r.getDerivedStateFromError(e);f!=null&&(c={...c,...f})}else typeof console<"u"&&console.error((r.name||"Component")+": Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.");let a=this.props,p=this.state,d=this.mounted;this.state=c,this.errorCommitPending=!0,this.setStateSignal(c),R(this,()=>{this.errorCommitPending=!1,d&&c!==p&&r.componentDidUpdate&&r.componentDidUpdate.call(this.inst,a,p,void 0),r.componentDidCatch&&r.componentDidCatch.call(this.inst,e,n)})}finally{this.catching=!1}return!0}unmount(){if(this.disposed)return;this.disposed=!0,y.delete(this);let e=this.detachRef;this.detachRef=null,e&&e(),this.mounted&&this.spec.componentWillUnmount&&this.spec.componentWillUnmount.call(this.inst),this.mounted=!1}runLifecycle(e){if(!this.disposed)if(this.owner)j(this.owner,e);else try{e()}catch(n){console.error(n)}}};function K(t,e){if(t===e)return!0;if(!t||!e)return!1;let n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let o of n)if(!Object.prototype.hasOwnProperty.call(e,o)||!Object.is(t[o],e[o]))return!1;return!0}var y=new Set,D=new Set,A=[],We=0,W=!1;function we(){B()}function R(t,e){A.push({c:t,fn:e,n:We++}),W||(W=!0,B())}function qe(t,e){return t.owner&&e.owner?t.owner.order-e.owner.order:t.seq-e.seq}function he(t,e){for(let n=e.parent;n;n=n.parent)if(n===t)return!0;return!1}function Me(t,e){let n=t.c.owner,r=e.c.owner;return n&&r&&n!==r?he(n,r)?1:he(r,n)?-1:n.order-r.order:n===r?t.n-e.n:t.c.seq-e.c.seq||t.n-e.n}function Te(){for(let t=0;y.size>0&&t<1e3;t++){let e=Array.from(y).sort(qe);y.clear(),te(()=>{for(let n of e)n.performUpdate()})}}var X=!1;function Ge(){W=!1,X=!0;try{He()}finally{X=!1}}function He(){if(D.size>0){let t=Array.from(D).sort((e,n)=>e.order-n.order);D.clear();for(let e of t)_(e)}if(A.length>0){let t=A.splice(0).sort(Me);for(let e of t)e.c.runLifecycle(e.fn)}}ee(Te);ae(()=>{(W||A.length>0||D.size>0)&&Ge()});function me(t,e,n,r){return new J(t,e,n,r).inst}var Be=["shouldComponentUpdate","getSnapshotBeforeUpdate","componentDidMount","componentDidUpdate","componentWillUnmount","componentDidCatch","componentWillReceiveProps","componentWillUpdate"];function Le(t,e,n){let r=new t(e),[o,s]=H(r.state||{}),c={name:t.displayName||t.name,pure:!!t.prototype.isPureReactComponent,defaultProps:t.defaultProps||null,getDerivedStateFromProps:t.getDerivedStateFromProps,getDerivedStateFromError:t.getDerivedStateFromError};for(let d of Be){let f=r[d]??r["UNSAFE_"+d];typeof f=="function"&&(c[d]=(...w)=>f.apply(r,w))}let a=me(e,o,s,c);Object.defineProperty(r,"props",{get:()=>a.props,configurable:!0}),Object.defineProperty(r,"state",{get:()=>a.state,set:d=>{a.state=d},configurable:!0}),r.setState=a.setState,r.forceUpdate=a.forceUpdate;let p=document.createElement("div");return p.style.display="contents",G(()=>{o();let d=h(()=>n(r.render()));p.replaceChildren(d)}),p}function Ne(t){O(t,I())}return Se(ze);})();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __krate_exports=(()=>{var h=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var i in e)h(t,i,{get:e[i],enumerable:!0})},O=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of H(e))!L.call(t,r)&&r!==i&&h(t,r,{get:()=>e[r],enumerable:!(n=y(e,r))||n.enumerable});return t};var R=t=>O(h({},"__esModule",{value:!0}),t);var K={};A(K,{krateHighlight:()=>P,krateHighlightInit:()=>x});var b=new Map;function k(t){let e=b.get(t);if(e===void 0){let i=typeof window<"u"&&window.__KRATE_HL?window.__KRATE_HL[t]:void 0,n=window.__KRATE_HL_LOAD||(r=>import(r));e=i?n(i).then(r=>r,()=>null):Promise.resolve(null),b.set(t,e)}return e}function P(t,e,i){return k(e).then(n=>n?n.highlight(n.trimSpace(t),e,i):null)}var N=new WeakSet;function M(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType===8&&e.data.startsWith("k:")){let i="/"+e.data;for(let n=e.nextSibling;n;n=n.nextSibling)if(n.nodeType===8&&n.data===i)return[e,n]}return null}function w(t){if(N.has(t))return;N.add(t);let e=t.getAttribute("data-krate-hl")||"";if(!e)return;let i=null,n,r=0,c=!1,f=()=>{let o=M(t);return o?{start:o[0],end:o[1]}:{start:null,end:null}},a=o=>o.start?o.start.nextSibling:t.firstChild,S=o=>{let l="";for(let s=a(o);s&&s!==o.end;s=s.nextSibling)l+=s.textContent||"";return l},m=f(),p=a(m);p&&p.nodeType===1&&(i=S(m));let v=o=>{let l=f(),s=document.createElement("template");s.innerHTML=o,c=!0;for(let d=a(l);d&&d!==l.end;){let u=d.nextSibling;d.parentNode&&d.parentNode.removeChild(d),d=u}(l.end&&l.end.parentNode?l.end.parentNode:t).insertBefore(s.content,l.end),c=!1,g.takeRecords()},E=(o,l)=>{let s=++r;n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,k(e).then(d=>{if(!d||s!==r||!t.isConnected)return;let u=d.highlight(d.trimSpace(o),e);u!==null&&s===r&&v(u)})},l)},C=()=>{if(c)return;if(!t.isConnected){g.disconnect();return}let o=f(),l=a(o);if(!l||l.nodeType!==3)return;for(let u=l.nextSibling;u&&u!==o.end;){let T=u.nextSibling;u.parentNode
|
|
1
|
+
var __krate_exports=(()=>{var h=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var i in e)h(t,i,{get:e[i],enumerable:!0})},O=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of H(e))!L.call(t,r)&&r!==i&&h(t,r,{get:()=>e[r],enumerable:!(n=y(e,r))||n.enumerable});return t};var R=t=>O(h({},"__esModule",{value:!0}),t);var K={};A(K,{krateHighlight:()=>P,krateHighlightInit:()=>x});var b=new Map;function k(t){let e=b.get(t);if(e===void 0){let i=typeof window<"u"&&window.__KRATE_HL?window.__KRATE_HL[t]:void 0,n=window.__KRATE_HL_LOAD||(r=>import(r));e=i?n(i).then(r=>r,()=>null):Promise.resolve(null),b.set(t,e)}return e}function P(t,e,i){return k(e).then(n=>n?n.highlight(n.trimSpace(t),e,i):null)}var N=new WeakSet;function M(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType===8&&e.data.startsWith("k:")){let i="/"+e.data;for(let n=e.nextSibling;n;n=n.nextSibling)if(n.nodeType===8&&n.data===i)return[e,n]}return null}function w(t){if(N.has(t))return;N.add(t);let e=t.getAttribute("data-krate-hl")||"";if(!e)return;let i=null,n,r=0,c=!1,f=()=>{let o=M(t);return o?{start:o[0],end:o[1]}:{start:null,end:null}},a=o=>o.start?o.start.nextSibling:t.firstChild,S=o=>{let l="";for(let s=a(o);s&&s!==o.end;s=s.nextSibling)l+=s.textContent||"";return l},m=f(),p=a(m);p&&p.nodeType===1&&(i=S(m));let v=o=>{let l=f(),s=document.createElement("template");s.innerHTML=o,c=!0;for(let d=a(l);d&&d!==l.end;){let u=d.nextSibling;d.parentNode&&d.parentNode.removeChild(d),d=u}(l.end&&l.end.parentNode?l.end.parentNode:t).insertBefore(s.content,l.end),c=!1,g.takeRecords()},E=(o,l)=>{let s=++r;n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,k(e).then(d=>{if(!d||s!==r||!t.isConnected)return;let u=d.highlight(d.trimSpace(o),e);u!==null&&s===r&&v(u)})},l)},C=()=>{if(c)return;if(!t.isConnected){g.disconnect();return}let o=f(),l=a(o);if(!l||l.nodeType!==3)return;for(let u=l.nextSibling;u&&u!==o.end;){let T=u.nextSibling;u.parentNode?.removeChild(u),u=T}let s=l.textContent||"";if(s===i)return;let d=i===null;i=s,E(s,d?0:120)},g=new MutationObserver(C);g.observe(t,{childList:!0,characterData:!0,subtree:!0}),C()}var _=!1;function D(){_||typeof MutationObserver>"u"||(_=!0,new MutationObserver(t=>{for(let e of t)for(let i=0;i<e.addedNodes.length;i++){let n=e.addedNodes[i];if(n.nodeType!==1)continue;let r=n;r.matches("code[data-krate-hl]")?w(r):r.querySelector("code[data-krate-hl]")&&x(r)}}).observe(document.documentElement,{childList:!0,subtree:!0}))}function x(t){let i=(t||document).querySelectorAll("code[data-krate-hl]");for(let n=0;n<i.length;n++)w(i[n]);t||D()}return R(K);})();
|
|
2
2
|
for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
|
package/dist/krate-f-list.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __krate_exports=(()=>{var C=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var Q=(e,t)=>{for(var r in t)C(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of z(t))!J.call(e,i)&&i!==r&&C(e,i,{get:()=>t[i],enumerable:!(n=$(t,i))||n.enumerable});return e};var Y=e=>X(C({},"__esModule",{value:!0}),e);var le={};Q(le,{krateBindList:()=>de,krateList:()=>we,longestIncreasingSubsequence:()=>q});var I=window.createEffect;var A=window.createRoot,v=window.createSignal;var D=window.onCleanup;var
|
|
1
|
+
var __krate_exports=(()=>{var C=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var Q=(e,t)=>{for(var r in t)C(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of z(t))!J.call(e,i)&&i!==r&&C(e,i,{get:()=>t[i],enumerable:!(n=$(t,i))||n.enumerable});return e};var Y=e=>X(C({},"__esModule",{value:!0}),e);var le={};Q(le,{krateBindList:()=>de,krateList:()=>we,longestIncreasingSubsequence:()=>q});var I=window.createEffect;var A=window.createRoot,v=window.createSignal;var D=window.onCleanup;var L=window.untrack;var M=window.krateUnmount,V=window.krateWithOwner;var _=window.adoptValue,T=window.appendChild;var m=window.disposeNode;var K=window.insertAt;var H=window.removeRest,R=window.trackEffect,S=window.withDOM,B=window.withVNodes;var b=window.krateMuteEvents;var P=window.krateWithIdScope;function Z(e,t,r){if(!e)return String(r);let n=e(t,r);return n==null?String(r):"$"+String(n)}function ee(e){try{return decodeURIComponent(e)}catch{return e}}function te(e){let t=e.map(r=>r.charAt(0)==="$"?r.slice(1):r);console.error("Encountered two children with the same key, `"+t.join("`, `")+"`. Keys should be unique so that components maintain their identity across updates. Krate keeps the first occurrence on its existing row and renders each duplicate as its own row.")}function ne(){return[document.createComment(""),document.createComment("")]}function G(e,t,r,n,i){A(a=>{R(t.start,a);let s=(e.start.nodeValue||"").slice(2),{value:d,owner:l}=V(()=>P(s?s+":"+t.key:"",()=>{if(!e.accessor)return e.render(r,n);let[u,k]=v(r),[x,w]=v(n);return t.setItem=k,t.setIndex=w,e.render(u,x)}));D(()=>M(l)),i(d)})}function U(e,t,r,n){let[i,a]=ne(),s={key:t,item:r,index:n,start:i,end:a,setItem:null,setIndex:null,live:!0},d=document.createDocumentFragment();return d.appendChild(i),S(()=>G(e,s,r,n,l=>T(d,l))),d.appendChild(a),d.__row=s,d}function oe(e,t,r,n){t.item=r,t.index=n,t.live=!0;let i=t.start.parentNode;try{B(()=>G(e,t,r,n,a=>{let s={parent:i,next:t.start.nextSibling};S(()=>_(a,s)),H(s,t.end)}))}catch(a){console.error(a),W(t.start,t.end,!1),m(t.start);let s=U(e,t.key,r,n),d=s.__row;i.insertBefore(s,t.start),i.removeChild(t.start),i.removeChild(t.end),Object.assign(t,d)}}function W(e,t,r){let n=e.parentNode;if(!n)return;let i=e.nextSibling;for(;i&&i!==t;){let a=i.nextSibling;m(i),n.removeChild(i),i=a}r&&(m(e),n.removeChild(e),t.parentNode===n&&n.removeChild(t))}function j(e){W(e.start,e.end,!0)}function re(e,t){let r=t.parentNode;if(e.end.nextSibling===t)return;let n=e.start;for(;n;){let i=n===e.end?null:n.nextSibling;r.insertBefore(n,t),n=i}}function q(e){let t=e.length,r=new Int32Array(t),n=[];for(let s=0;s<t;s++){let d=e[s];if(d<0)continue;let l=0,u=n.length;for(;l<u;){let k=l+u>>1;e[n[k]]<d?l=k+1:u=k}r[s]=l>0?n[l-1]:-1,n[l]=s}let i=new Array(n.length),a=n.length?n[n.length-1]:-1;for(let s=n.length-1;s>=0;s--)i[s]=a,a=r[a];return i}function se(e){return e==null?[]:Array.isArray(e)?e:typeof e[Symbol.iterator]=="function"?Array.from(e):[]}function ie(e){if(typeof document>"u")return null;let t=document.activeElement;if(!t||t===document.body||!e||!e.contains(t))return null;let r=null;try{let n=t;typeof n.selectionStart=="number"&&(r=[n.selectionStart,n.selectionEnd,n.selectionDirection])}catch{r=null}return()=>{if(!(document.activeElement===t||!t.isConnected)&&(t.focus({preventScroll:!0}),r))try{t.setSelectionRange(r[0],r[1],r[2]||void 0)}catch{}}}function ae(e,t){let{end:r,keyFn:n}=e,i=r.parentNode,a=e.rows,s=t.length,d=new Array(s),l=new Map,u=null;for(let o=0;o<s;o++){let c=Z(n,t[o],o),p=l.get(c);p!==void 0?((u||(u=[])).push(c),l.set(c,p+1),c=c+"\0"+p):l.set(c,1),d[o]=c}u&&te(u);let k=new Map;for(let o=0;o<a.length;o++)k.set(a[o].key,o);for(let o=0;o<s&&o<a.length;o++){let c=a[o];!c.live&&!l.has(c.key)&&!k.has(d[o])&&(k.delete(c.key),c.key=d[o],k.set(c.key,o))}let x=ie(i),w=new Array(s),g=new Int32Array(s).fill(-1),E=new Uint8Array(a.length);for(let o=0;o<s;o++){let c=k.get(d[o]);if(c===void 0)continue;let p=a[c],h=t[o];p.live&&!e.accessor&&(p.item!==h||e.usesIndex&&p.index!==o)||(E[c]=1,g[o]=c,w[o]=p)}b(()=>{for(let o=0;o<a.length;o++)E[o]||j(a[o])});for(let o=0;o<s;o++){let c=w[o];if(!c)continue;let p=t[o];if(!c.live){oe(e,c,p,o);continue}c.item!==p&&(c.item=p,c.setItem&&c.setItem(()=>p)),c.index!==o&&(c.index=o,c.setIndex&&c.setIndex(o))}let y=new Array(s),f=null;for(let o=0;o<s;o++){if(w[o]){f=null;continue}let c=U(e,d[o],t[o],o);w[o]=c.__row,f?(f.appendChild(c),y[o-1]=null):f=c,y[o]=f}let N=new Uint8Array(s);for(let o of q(g))N[o]=1;b(()=>{let o=r;for(let c=s-1;c>=0;c--){let p=w[c],h=y[c];h?i.insertBefore(h,o):g[c]>=0&&!N[c]&&re(p,o),o=p.start}e.rows=w,x&&x()})}function ce(e){let{start:t,end:r}=e,n=t.parentNode,i=(t.nodeValue||"").slice(2),a="k:"+i+":",s=[],d=t.nextSibling;for(;d&&d!==r;){let u=d.nodeType===8&&d.nodeValue||"";if(i&&u.indexOf(a)===0){let x="/"+u,w=d.nextSibling;for(;w&&w!==r&&!(w.nodeType===8&&w.nodeValue===x);)w=w.nextSibling;if(w&&w!==r){s.push({key:ee(u.slice(a.length)),item:void 0,index:s.length,start:d,end:w,setItem:null,setIndex:null,live:!1}),d=w.nextSibling;continue}}let k=d.nextSibling;m(d),n.removeChild(d),d=k}let l=new Set;e.rows=s.filter(u=>l.has(u.key)?(j(u),!1):(l.add(u.key),!0))}function O(e,t,r){let n=!0,i=I(()=>{let a=se(t());L(()=>{n&&(n=!1,r&&ce(e)),ae(e,a)})});R(e.start,i)}function F(e,t,r,n,i){return{start:e,end:t,rows:[],keyFn:r,render:n,accessor:i===1,usesIndex:n.length>1}}function de(e,t,r,n,i){let a="/"+(e.nodeValue||""),s=e.nextSibling;for(;s&&!(s.nodeType===8&&s.nodeValue===a);)s=s.nextSibling;s||(s=document.createComment(a),e.parentNode.insertBefore(s,e.nextSibling)),O(F(e,s,r,n,i),t,!0)}function we(e,t,r,n){return{__ka:1,items:e,key:t,render:r,mode:n,mount(){let i=document.createDocumentFragment(),a=document.createComment(""),s=document.createComment("");return i.appendChild(a),i.appendChild(s),O(F(a,s,t,r,n),e,!1),i},adopt(i){let a=i.next;for(;a&&a.nodeType===8&&(a.nodeValue||"").indexOf("/k:")===0;)a=a.nextSibling;if(a&&a.nodeType===8&&(a.nodeValue||"").indexOf("k:")===0){let s="/"+a.nodeValue,d=a.nextSibling;for(;d&&!(d.nodeType===8&&d.nodeValue===s);)d=d.nextSibling;if(d){i.next=d.nextSibling,S(()=>O(F(a,d,t,r,n),e,!0));return}}K(i,S(()=>this.mount()))}}}return Y(le);})();
|
|
2
2
|
for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __krate_exports=(()=>{var
|
|
1
|
+
var __krate_exports=(()=>{var m=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},M=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of I(t))!B.call(e,o)&&o!==n&&m(e,o,{get:()=>t[o],enumerable:!(r=q(t,o))||r.enumerable});return e};var G=e=>M(m({},"__esModule",{value:!0}),e);var se={};U(se,{forbidden:()=>A,krateLayoutSegments:()=>z,krateMatchParams:()=>W,krateResetNavigation:()=>$,krateRouteStore:()=>j,notFound:()=>T,permanentRedirect:()=>oe,redirect:()=>F,unauthorized:()=>_,useParams:()=>Q,usePathname:()=>Z,useRouter:()=>te,useSearchParams:()=>Y,useSelectedLayoutSegment:()=>re,useSelectedLayoutSegments:()=>ne});var b=window.createSignal;var c=window.krateDerived;var X=Symbol.for("krate.request.store");function i(){let e=globalThis[X];return e&&typeof e.getStore=="function"?e.getStore():void 0}function T(){let e=new Error("NEXT_NOT_FOUND");throw e.__krateNotFound=!0,e.digest="NEXT_NOT_FOUND",e}function C(e){let t=new Error(e===403?"NEXT_FORBIDDEN":"NEXT_UNAUTHORIZED");throw t.__krateHTTPStatus=e,t.digest="NEXT_HTTP_ERROR_FALLBACK;"+e,t}function A(){return C(403)}function _(){return C(401)}function x(){let e=i();if(!e)return{path:"/",route:"",params:{}};let t=e.url.split("?")[0]||"/",n=e.params||{},r=[];for(let o of t.split("/").filter(Boolean)){let s=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(o);if(!s){r.push(o);continue}let u=n[s[3]];u!==void 0&&u!==""&&r.push(...u.split("/").filter(Boolean))}return{path:"/"+r.join("/"),route:t,params:n}}function w(e){try{return decodeURIComponent(e)}catch{return e}}function E(){return x().path}function O(){let e=i(),t=new URLSearchParams;for(let[n,r]of Object.entries(e&&e.searchParams||{}))t.append(n,String(r));return t}function N(){let{route:e,params:t}=x(),n={};for(let r of e.split("/").filter(Boolean)){let o=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(r);if(!o)continue;let s=t[o[3]];s===void 0||s===""||(n[o[3]]=o[2]?s.split("/").filter(Boolean).map(w):w(s))}return n}function d(e){return()=>{throw new Error(`useRouter().${e}() can only be called in the browser; use redirect() while rendering`)}}function P(){return{push:d("push"),replace:d("replace"),back:d("back"),forward:d("forward"),refresh:d("refresh"),prefetch:()=>{}}}function k(e,t){return x().path.split("/").filter(Boolean).map(w).slice(typeof t=="number"?t:0)}function D(e,t){let n=k(e,t);return n.length>0?n[0]:null}var H=window.getNavigationState,S=window.subscribeNavigation,a=window.krateRouter;function J(){let e=globalThis.__KRATE_ROUTE__;if(typeof e=="string")return e;if(typeof document>"u")return"";let t=document.getElementById("__krate_page");if(!t)return"";try{let n=JSON.parse(t.textContent||"{}");return typeof n.r=="string"?n.r:""}catch{return""}}function V(e){return e.length>1&&e.endsWith("/")?e.replace(/\/+$/,"")||"/":e}function y(){if(typeof location>"u")return{pathname:"/",search:"",route:""};let{pathname:e,search:t}=H();return{pathname:V(e),search:t,route:J()}}var p=null;function l(){if(p)return p;let[e,t]=b(y());if(p=e,typeof window<"u"){let n=()=>{let r=y(),o=e();(r.pathname!==o.pathname||r.search!==o.search||r.route!==o.route)&&t(r)};S(n),window.addEventListener("krate:navigate-end",n)}return e}function j(){let e=null;return{subscribe:r=>{let o=S(r);return typeof window<"u"&&window.addEventListener("krate:navigate-end",r),()=>{o(),typeof window<"u"&&window.removeEventListener("krate:navigate-end",r)}},getSnapshot:()=>{let r=y();return e&&e.pathname===r.pathname&&e.search===r.search&&e.route===r.route?e:(e=r,r)}}}function W(e,t){return L(e,t)}function z(e,t){return e.split("/").filter(Boolean).map(f).slice(typeof t=="number"?t:0)}function $(){p=null}function g(e,t){let n=e;return n.toString=t,n.toJSON=()=>e(),e}function Z(){if(i())return E();let e=l(),t=c(()=>e().pathname);return g(t,()=>t())}function Y(){if(i())return O();let e=l(),t=c(()=>new URLSearchParams(e().search));return g(t,()=>e().search)}function f(e){try{return decodeURIComponent(e)}catch{return e}}function L(e,t){let n={};if(!e)return n;let r=e.split("/").filter(Boolean),o=t.split("/").filter(Boolean);for(let s=0;s<r.length;s++){let u=r[s],h=/^\[(\[)?(\.\.\.)?([^\]]+)\]?\]$/.exec(u);if(!h)continue;let R=h[3];if(h[2]){let v=o.slice(s).map(f);return v.length>0&&(n[R]=v),n}s<o.length&&(n[R]=f(o[s]))}return n}function Q(){if(i())return N();let e=l(),t=c(()=>{let n=e();return L(n.route,n.pathname)});return g(t,()=>JSON.stringify(t()))}var ee={push:(e,t)=>{a.push(e,t)},replace:(e,t)=>{a.replace(e,t)},back:()=>a.back(),forward:()=>a.forward(),refresh:()=>{a.refresh()},prefetch:e=>{a.prefetch(e)}};function te(){return i()?P():ee}function ne(e,t){if(i())return k(e,t);let n=l(),r=typeof t=="number"?t:0,o=c(()=>n().pathname.split("/").filter(Boolean).map(f).slice(r));return g(o,()=>o().join("/"))}function re(e,t){if(i())return D(e,t);let n=l(),r=typeof t=="number"?t:0,o=c(()=>{let s=n().pathname.split("/").filter(Boolean).map(f);return s.length>r?s[r]:null});return g(o,()=>String(o()))}function F(e){typeof location<"u"&&a.push(e);let t=new Error("Server action redirect to "+e);throw t.__krateRedirect=e,t}function oe(e){return F(e)}return G(se);})();
|
|
2
2
|
for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __krate_exports=(()=>{var
|
|
1
|
+
var __krate_exports=(()=>{var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},_=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of h(t))!g.call(e,i)&&i!==n&&r(e,i,{get:()=>t[i],enumerable:!(o=p(t,i))||o.enumerable});return e};var m=e=>_(r({},"__esModule",{value:!0}),e);var R={};v(R,{destroyRouter:()=>C,getHistoryState:()=>b,getNavigationState:()=>f,initRouter:()=>w,invalidatePrefetchCache:()=>l,krateRouter:()=>P,navigate:()=>c,reinitRouter:()=>x,subscribeNavigation:()=>d});var y="__krate_cfg__";function u(){let e=globalThis;if(e.__KRATE_CFG__)return e.__KRATE_CFG__;let t=e.document,n=t&&typeof t.getElementById=="function"?t.getElementById(y):null;if(n)try{let o=JSON.parse(n.textContent||"{}");if(o&&typeof o=="object")return e.__KRATE_CFG__=o,o}catch{}return{}}function a(){let e=u(),t=e&&e.basePath||"";return!t||t==="/"?"":"/"+t.replace(/^\/+|\/+$/g,"")}function s(e){let t=a();return t&&e.charCodeAt(0)===47&&e.charCodeAt(1)!==47?t+e:e}function f(){if(typeof location>"u")return{url:"",pathname:"/",search:"",hash:"",status:"idle"};let e=a(),t=location.pathname;return e&&(t===e||t.startsWith(e+"/"))&&(t=t.slice(e.length)||"/"),{url:location.href,pathname:t,search:location.search,hash:location.hash,status:"idle"}}function d(e){if(typeof window>"u")return()=>{};let t=()=>e(f());return window.addEventListener("hashchange",t),()=>{window.removeEventListener("hashchange",t)}}function b(){return typeof history>"u"?null:history.state}function l(e){}function w(){}function x(){}function C(){}function c(e,t={}){return typeof location>"u"||(t.replace?location.replace(s(e)):location.assign(s(e))),!0}var P={push(e,t={}){return c(e,{...t,replace:!1}),Promise.resolve()},replace(e,t={}){return c(e,{...t,replace:!0}),Promise.resolve()},back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh(){return typeof location<"u"&&location.reload(),Promise.resolve()},prefetch(e){return Promise.resolve()},subscribe:d,getState:f,invalidate:l};typeof window<"u"&&window.addEventListener("krate:revalidate",()=>{typeof location<"u"&&location.reload()});return m(R);})();
|
|
2
2
|
for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
|
package/dist/krate-f-router.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __krate_exports=(()=>{var le=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var ht=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},pt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ft(t))!dt.call(e,o)&&o!==n&&le(e,o,{get:()=>t[o],enumerable:!(r=ut(t,o))||r.enumerable});return e};var mt=e=>pt(le({},"__esModule",{value:!0}),e);var Zt={};ht(Zt,{compareRouteSpecificity:()=>Ye,destroyRouter:()=>Qt,getHistoryState:()=>St,getNavigationState:()=>Ue,initRouter:()=>ct,invalidatePrefetchCache:()=>ve,krateRouter:()=>Yt,matchRoutePattern:()=>ze,navigate:()=>Xt,pageAssetURLs:()=>He,reinitRouter:()=>Gt,subscribeNavigation:()=>Ie});var me=/\/chunks\/runtime\.[^/]+\.js$/;function ne(){return globalThis.__KRATE_CFG__||{}}function ge(){let e=ne().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function I(e){let t=ge();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}function de(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function O(e){if(ne().dev)try{console.warn("[krate router] "+e)}catch{}}function Me(e,t){if(/^(https?:)?\/\//.test(e)||e.startsWith("/"))return new URL(e,t).href;let n=t;if(!n.endsWith("/")){let r=n.lastIndexOf("/");n=r>0?n.slice(0,r+1):"/"}return new URL(e,n).href}function He(e,t,n){let r=new DOMParser().parseFromString(e,"text/html"),o=[],i=new Set,s=c=>{if(!c)return;let a;try{a=Me(c,t)}catch{return}i.has(a)||n.has(a)||me.test(a)||(i.add(a),o.push(a))};return r.querySelectorAll("script[src]").forEach(c=>s(c.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(c=>s(c.getAttribute("href"))),o}var _=!1,T=0,k,Re=0,m="",A="",F="idle",W=new Set,S=new Map,R=new Map,gt=30,yt=3e4,L=new Map,vt=50,ue=new Set,kt=128,G=new Map,B=new Map,M=null,$=[],bt="_krate/i",wt=150,Et=200;function he(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function D(){return Re++,Date.now().toString(36)+"-"+Re.toString(36)}function re(e){try{let t=new URL(e,location.href);return t.hash="",t.href}catch{return e}}function x(e){let t=new URL(e,location.href);return de(t.pathname)+t.search}function j(e,t=!1){let n=globalThis.__krateHardNavigate;if(typeof n=="function"){n(e,t);return}t?location.replace(e):location.assign(e)}function J(e,t){return{__krate:e,state:t===void 0?null:t}}function Q(e){if(e&&typeof e=="object"&&typeof e.__krate=="string")return e.__krate}function St(){if(typeof history>"u")return null;let e=history.state;return Q(e)!==void 0?e.state:e}function De(){let e=new URL(location.href);return{url:e.href,pathname:I(e.pathname),search:e.search,hash:e.hash,status:F}}function Ue(){return typeof location>"u"?{url:"",pathname:"/",search:"",hash:"",status:"idle"}:De()}function oe(){if(W.size===0)return;let e=De();for(let t of Array.from(W))try{t(e)}catch(n){console.error(n)}}function H(e){F!==e&&(F=e,oe())}function Ie(e){return W.add(e),()=>{W.delete(e)}}function b(e,t,n=!1){try{let r=new CustomEvent(e,{detail:t,cancelable:n});return window.dispatchEvent(r),!r.defaultPrevented}catch{return!0}}function ye(e){try{let t=globalThis.__krate_onNavigation;typeof t=="function"&&t(e)}catch{}}function z(e){if(e){if(L.delete(e),L.size>=vt){let t=L.keys().next().value;t!==void 0&&L.delete(t)}L.set(e,window.scrollY||0)}}function Ke(){let e=ne().prefetchTTL;return typeof e=="number"&&e>=0?e:yt}function At(e,t){for(S.delete(e);S.size>=gt;){let n=S.keys().next().value;if(n===void 0)break;S.delete(n)}S.set(e,t)}function Lt(e){let t=S.get(e);if(t&&(S.delete(e),!(he()-t.at>Ke())))return t}function ve(e){if(e===void 0){S.clear(),R.clear();return}let t=re(e);S.delete(t),R.delete(t)}function ke(e){return/text\/html|application\/xhtml\+xml/i.test(e)}function V(e){return/^\s*(<!doctype html|<html|<head|<body)/i.test(e)}function Tt(e){if(ue.has(e)||ue.size>=kt)return;ue.add(e);let t=document.createElement("link");t.rel="prefetch",t.as="script",t.href=e,document.head.appendChild(t)}function be(e){let t=re(e),n=S.get(t);if(n&&he()-n.at<=Ke())return Promise.resolve();let r=R.get(t);if(r)return r;let o=fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async i=>{if(!i.ok)return;let s=i.headers.get("content-type")||"",c=i.url||t;if(new URL(c,location.href).origin!==location.origin)return;let a=await i.text();if(!(ke(s)||s===""&&V(a))||R.get(t)!==o)return;At(t,{html:a,url:c,status:i.status,at:he()});let u=new Set;document.querySelectorAll("script[src]").forEach(l=>u.add(l.src));for(let l of He(a,c,u))Tt(l)}).catch(()=>{}).finally(()=>{R.get(t)===o&&R.delete(t)});return R.set(t,o),o}function we(e){if(e.hasAttribute("data-krate-external")||e.hasAttribute("download"))return!1;let t=e.getAttribute("href");if(!t||t.startsWith("javascript:"))return!1;let n;try{n=new URL(t,location.href)}catch{return!1}if(n.origin!==location.origin)return!1;let r=e.getAttribute("target");return!(r&&r!=="_self")}function Ee(e){let t=e.getAttribute("data-prefetch");return e.hasAttribute("data-prefetch")&&t!=="false"&&t!=="0"}function Rt(e){let t=window.requestIdleCallback;typeof t=="function"?t(e,{timeout:1e3}):setTimeout(e,50)}function Z(e){let t=e.target;if(!t||typeof t.closest!="function")return;let n=t.closest("a[data-prefetch]");if(!n||!Ee(n)||!we(n))return;let r=n.getAttribute("href");if(!r)return;let o=new URL(r,location.href).href;if(x(o)===A)return;let i=B.get(n);i&&clearTimeout(i);let s=setTimeout(()=>{B.delete(n),be(o)},Et);B.set(n,s)}function Oe(){M&&document.querySelectorAll("a[data-prefetch]").forEach(e=>{Ee(e)&&M.observe(e)})}function _t(){document.addEventListener("mouseover",Z),document.addEventListener("focusin",Z),typeof IntersectionObserver<"u"&&(M=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let n=t.target,r=n.getAttribute("href");if(r&&we(n)&&Ee(n)){let o=new URL(r,location.href).href;x(o)!==A&&Rt(()=>{be(o)})}M.unobserve(t.target)}},{rootMargin:"200px"}),Oe())}function xt(){let e=typeof HTMLScriptElement<"u"?HTMLScriptElement.supports:void 0;if(!(typeof e!="function"||!e("speculationrules"))&&!document.querySelector('meta[http-equiv="Content-Security-Policy" i]'))try{let t=document.createElement("script");t.type="speculationrules",t.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(t)}catch{}}function Be(){if(typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{}return!1}function Fe(){return ne().viewTransitions===!1||Be()?!1:typeof document.startViewTransition=="function"}function w(e){return e.getElementById("root")||e.body}function Pt(){let e=document.querySelector("template[data-krate-loading]");if(e&&e.content&&$.length===0){let t=e.content.cloneNode(!0);$=Array.from(t.childNodes),document.body.appendChild(t)}if(!Fe()&&!Be()){let t=w(document);t.style.transition=`opacity ${wt}ms ease`,t.style.opacity="0"}}function Se(){for(let t of $)t.parentNode&&t.parentNode.removeChild(t);$=[];let e=w(document);e.style.opacity==="0"&&(e.style.opacity="")}function We(e){e.querySelectorAll("[data-view-transition]").forEach(t=>{let n=t.getAttribute("data-view-transition");n&&(t.style.viewTransitionName=n);let r=t.getAttribute("data-view-transition-class");r&&t.style.setProperty("view-transition-class",r)})}var Ct=3e3;function Nt(e,t){let n=[];e.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u.getAttribute("href");if(!l)return;let p=new URL(l,t).href;n.includes(p)||n.push(p)});let r=new Map,o=[];document.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u;l.href&&(n.includes(l.href)&&!r.has(l.href)?r.set(l.href,l):o.push(l))});let i=[],s=[],c=null;n.forEach((u,l)=>{let p=r.get(u)||null;if(!p){let h=document.createElement("link");if(h.rel="stylesheet",h.href=u,s.push(new Promise(g=>{let f=()=>{h.removeEventListener("load",f),h.removeEventListener("error",f),g()};h.addEventListener("load",f),h.addEventListener("error",f)})),i.push({link:h,media:h.getAttribute("media")}),h.media="not all",c)c.after(h);else{let g=n.slice(l+1).map(f=>r.get(f)).find(f=>!!f);g?g.before(h):document.head.appendChild(h)}p=h}c=p});let a=Promise.resolve();if(s.length>0){let u,l=new Promise(p=>{u=setTimeout(p,Ct)});a=Promise.race([Promise.all(s).then(()=>{}),l]).then(()=>clearTimeout(u))}return{ready:a,commit(){for(let{link:u,media:l}of i)l===null?u.removeAttribute("media"):u.setAttribute("media",l);o.forEach(u=>u.remove())},abort(){i.forEach(({link:u})=>u.remove())}}}var _e='meta[name="description"], meta[name="robots"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Mt(e){document.head.querySelectorAll(_e).forEach(t=>t.remove()),e.head.querySelectorAll(_e).forEach(t=>{document.head.appendChild(document.importNode(t,!0))})}function $e(e,t){let n=new Set;document.querySelectorAll("script[src]:not([data-krate-spa])").forEach(i=>n.add(i.src));let r=[],o=new Set;return e.querySelectorAll("script[src]").forEach(i=>{let s=i.getAttribute("src");if(!s)return;let c=(i.getAttribute("type")||"").toLowerCase();if(c&&c!=="module"&&c!=="text/javascript"&&c!=="application/javascript")return;let a=Me(s,t);!n.has(a)&&!o.has(a)&&(o.add(a),r.push({src:a,module:c==="module"}))}),r}function je(e){return new Promise(t=>{let n=document.createElement("script");n.src=e.src,e.module&&(n.type="module"),me.test(e.src)||n.setAttribute("data-krate-spa",""),n.onload=()=>t(!0),n.onerror=()=>t(!1),document.body.appendChild(n)})}var q=new Set;function Je(e){e.querySelectorAll("script[data-krate-boot]").forEach(t=>{let n=t.textContent||"";if(!n||q.has(n))return;q.add(n);let r=document.createElement("script");r.text=n,document.head.appendChild(r),r.remove()})}function Ht(e){if(!e||e==="#")return null;let t=e.slice(1);try{t=decodeURIComponent(t)}catch{}return document.getElementById(t)||document.getElementsByName(t)[0]||null}function Ae(e){let t=Ht(e);if(!t)return!1;try{t.scrollIntoView({block:"start"})}catch{}return!0}function Dt(e,t){if(t.kind==="pop"){let r=t.restoreKey?L.get(t.restoreKey):void 0;if(r!==void 0){window.scrollTo(0,r);return}}let n=new URL(e,location.href).hash;Ae(n)||t.scroll&&t.kind!=="refresh"&&window.scrollTo(0,0)}var X=null;function Ut(){let e=document.activeElement;if(e&&e!==document.body&&e.isConnected&&e!==X)return;let t=w(document);t.hasAttribute("tabindex")||(t.setAttribute("tabindex","-1"),X=t,t.addEventListener("blur",()=>{X===t&&(t.removeAttribute("tabindex"),X=null)},{once:!0}));try{t.focus({preventScroll:!0})}catch{}}var xe="__krate-route-announcer";function It(){let e=document.getElementById(xe);e||(e=document.createElement("div"),e.id=xe,e.setAttribute("aria-live","assertive"),e.setAttribute("aria-atomic","true"),e.setAttribute("role","status"),e.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0"),document.body.appendChild(e));let t=w(document).querySelector("h1"),n=document.title||(t&&t.textContent?t.textContent.trim():"")||I(location.pathname);e.textContent=n}function ie(){let e=de(I(location.pathname));document.querySelectorAll("a[data-krate-link]").forEach(t=>{let n=t.getAttribute("href"),r="";try{r=n?de(I(new URL(n,location.href).pathname)):""}catch{r=""}let o="";r&&r===e?o="exact":r&&r!=="/"&&e.startsWith(r+"/")&&(o="segment"),o==="exact"?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current"),o?t.setAttribute("data-krate-active",o):t.removeAttribute("data-krate-active")})}function Pe(e){let t=ge()+e;return G.has(t)?Promise.resolve(G.get(t)??null):fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async n=>{let r=n.ok?await n.text():null,o=r&&V(r)?r:null;return G.set(t,o),o}).catch(()=>null)}async function Kt(e,t){let n=re(e.url);if(!e.bypassCache){let p=R.get(n);if(p&&await p,t.aborted)return{ok:!1,aborted:!0};let h=Lt(n);if(h){let g=new URL(e.url,location.href).hash,f=g&&!new URL(h.url,location.href).hash?h.url+g:h.url;return{ok:!0,doc:{html:h.html,url:f,status:h.status}}}}let r;try{r=await fetch(n,{headers:{Accept:"text/html"},credentials:"same-origin",signal:t,cache:e.bypassCache?"no-cache":"default"})}catch(p){return p?.name==="AbortError"||t.aborted?{ok:!1,aborted:!0}:b("krate:navigate-error",{url:e.url,status:0,error:p},!0)?{ok:!1,hard:e.url}:{ok:!1,aborted:!0}}let o=r.url||n;if(new URL(o,location.href).origin!==location.origin)return{ok:!1,hard:o};let i=r.headers.get("content-type")||"",s="";try{s=await r.text()}catch(p){if(p?.name==="AbortError"||t.aborted)return{ok:!1,aborted:!0};s=""}if(t.aborted)return{ok:!1,aborted:!0};let c=ke(i)||i===""&&V(s),a=new URL(e.url,location.href).hash,u=a&&!new URL(o).hash?o+a:o;if(r.ok)return c?{ok:!0,doc:{html:s,url:u,status:r.status}}:{ok:!1,hard:u};if(b("krate:navigate-error",{url:e.url,status:r.status}),c&&V(s))return{ok:!0,doc:{html:s,url:u,status:r.status}};let l=null;return r.status===404||r.status===410?l=await Pe("/404.html"):r.status>=500&&(l=await Pe("/500.html")),t.aborted?{ok:!1,aborted:!0}:l?{ok:!0,doc:{html:l,url:u,status:r.status}}:{ok:!1,hard:u}}async function se(e){let t=location.href;if(e.kind!=="pop"){if(!b("krate:navigate-start",{url:e.url,from:t,kind:e.kind},!0))return}else b("krate:navigate-start",{url:e.url,from:t,kind:e.kind});let n=++T;k&&k.abort();let r=new AbortController;k=r,H("loading"),!e.bypassCache&&S.has(re(e.url))||Pt();let i;try{i=await Kt(e,r.signal)}finally{k===r&&(k=void 0)}if(n===T){if(!i.ok){Se(),H("idle"),"hard"in i&&j(i.hard,e.kind==="replace"||e.kind==="refresh");return}await Ot(i.doc,e,n)}}async function Ot(e,t,n){let r=new DOMParser().parseFromString(e.html,"text/html"),o=e.url,i=w(r),s=w(document);t.kind==="push"&&z(m);let c=Ve(r),a=$t(C,c,location.href,o,r),u=Nt(r,o);if(await u.ready,n!==T){u.abort();return}if(await Bt(()=>{let g=r.querySelector("title");g&&(document.title=g.textContent||"");let f=globalThis;if(a.keep.length>0&&typeof f.krateDisposeExcept=="function"?f.krateDisposeExcept(a.keep):typeof f.disposeAll=="function"&&f.disposeAll(),a.region){let{live:v,next:d}=a.region;ee(v[0],v[1]);let E=U(d[0],d[1]).map(y=>document.importNode(y,!0));for(let y of E)v[1].parentNode.insertBefore(y,v[1]);for(let y of a.slots){ee(y.live[0],y.live[1]);for(let K of U(y.next[0],y.next[1]))y.live[1].parentNode.insertBefore(document.importNode(K,!0),y.live[1])}Ft(s,i)}else{let v=Array.from(i.childNodes).map(d=>document.importNode(d,!0));s.replaceChildren(...v)}C=a.chain,Y.clear(),u.commit(),Mt(r),We(document)}),n!==T)return;Se(),t.kind==="push"?(m=D(),history.pushState(J(m,t.state),"",o)):t.kind==="replace"?(L.delete(m),m=D(),history.replaceState(J(m,t.state),"",o)):t.kind==="refresh"?o!==location.href&&history.replaceState(history.state,"",o):t.restoreKey&&(m=t.restoreKey),A=x(location.href),N=A,Ge(r),jt(r),Dt(o,t),t.kind!=="pop"&&t.kind!=="refresh"&&Ut(),t.kind!=="refresh"&&It(),ie(),b("krate:navigate",{url:location.href,status:e.status}),ye(location.href),H("idle"),document.querySelectorAll("script[data-krate-spa]").forEach(g=>g.remove()),Je(r);let p=$e(r,o);Ne(a.skip);let h=await Promise.all(p.map(je));if(Ne([]),n===T){if(h.some(g=>!g)){b("krate:navigate-error",{url:location.href,status:e.status,error:"script-load"}),j(location.href,!0);return}te(),b("krate:navigate-end",{url:location.href,status:e.status})}}function Bt(e){if(!Fe())return e(),Promise.resolve();let t=!1,n=()=>{t||(t=!0,e())};try{let r=document.startViewTransition(n);r&&r.finished&&typeof r.finished.catch=="function"&&r.finished.catch(()=>{});let o=r&&r.updateCallbackDone;if(o&&typeof o.then=="function")return o.then(()=>n(),()=>n())}catch{}return n(),Promise.resolve()}var C=[];function Ve(e){let t=e.getElementById("__krate_route");if(!t)return[];try{let n=JSON.parse(t.textContent||"{}");return Array.isArray(n.chain)?n.chain:[]}catch{return O("unreadable #__krate_route route info; layouts will be remounted"),[]}}function Ce(e,t){let n=I(new URL(e,location.href).pathname).split("/").filter(Boolean);return(t<0?n:n.slice(0,t)).join("/")}function P(e,t,n="kl:"){let o=(e.ownerDocument||e).createTreeWalker(e,128),i=n+t,s="/"+n+t;for(;o.nextNode();){let c=o.currentNode;if(c.nodeValue===i){for(let a=c.nextSibling;a;a=a.nextSibling)if(a.nodeType===8&&a.nodeValue===s)return[c,a];return null}}return null}function U(e,t){let n=[];for(let r=e.nextSibling;r&&r!==t;r=r.nextSibling)n.push(r);return n}function ee(e,t){let n=globalThis.disposeNode;for(let r of U(e,t))r.parentNode.removeChild(r),typeof n=="function"&&n(r)}function Ft(e,t){let n=":scope > template[data-krate-loading]";e.querySelectorAll(n).forEach(r=>r.remove()),t.querySelectorAll(n).forEach(r=>e.appendChild(document.importNode(r,!0)))}function Ne(e){let t=globalThis.krateKeepScopes;typeof t=="function"&&t(e)}function Wt(e){let t=globalThis.krateScopeFailed;return typeof t=="function"&&!!t(e)}function $t(e,t,n,r,o){let i={keep:[],skip:[],region:null,slots:[],chain:t},s=0;for(;s<e.length&&s<t.length;){let f=e[s],v=t[s];if(f.id!==v.id||f.k!==v.k||f.k!=="layout"&&f.k!=="error"||Ce(n,f.d)!==Ce(r,v.d)||f.k==="error"&&Wt(f.id))break;if(!f.p||!v.p){O(`layout ${v.f||v.id} is remounted on this navigation: ${v.why||f.why||"not persistable"}`);break}s++}if(s===0)return i;if(typeof globalThis.krateDisposeExcept!="function")return O("the runtime has no krateDisposeExcept; layouts are remounted"),i;let c=t[s-1].id,a=P(w(document),c),u=P(w(o),c);if(!a||!u)return O(`layout ${t[s-1].f||c} boundary markers are missing; the whole page is swapped`),i;let l=e.slice(0,s).map(f=>f.id),p=l.slice(),h=[],g=t.slice();for(let f=0;f<s;f++){let v=e[f].s||[],d=[];for(let E of t[f].s||[]){let y=v.find(lt=>lt.key===E.key),K=P(w(document),E.key,"ks:"),ce=P(w(o),E.key,"ks:");if(y&&K&&(E.src!=="page"||!ce)){l.push(y.scope),p.push(y.scope,E.scope),d.push({...E,scope:y.scope,src:y.src});continue}if(K&&ce){h.push({live:K,next:ce}),d.push(E);continue}return O(`slot @${E.n} markers are missing; the whole page is swapped`),i}g[f]={...t[f],s:d}}return{keep:l,skip:p,region:{live:a,next:u},slots:h,chain:g}}var Y=new Map,N="";function pe(e){let t=e.replace(/^\/+|\/+$/g,"");return t?t.split("/").map(n=>n.startsWith("[[...")&&n.endsWith("]]")?{kind:3,text:n.slice(5,-2)}:n.startsWith("[...")&&n.endsWith("]")?{kind:2,text:n.slice(4,-1)}:n.startsWith("[")&&n.endsWith("]")?{kind:1,text:n.slice(1,-1)}:{kind:0,text:n}):[]}function ze(e,t){let n=pe(t),r=e.replace(/^\/+|\/+$/g,""),o=r?r.split("/"):[],i={};for(let s=0;s<n.length;s++){let c=n[s];if(c.kind>=2){if(s!==n.length-1)return null;let a=o.slice(s);return c.kind===2&&a.length===0||a.some(u=>u==="")?null:(i[c.text]=a.map(fe).join("/"),i)}if(s>=o.length)return null;if(c.kind===1){if(!o[s])return null;i[c.text]=fe(o[s])}else if(fe(o[s])!==c.text)return null}return o.length===n.length?i:null}function fe(e){try{return decodeURIComponent(e)}catch{return e}}function Ye(e,t){let n=pe(e),r=pe(t);for(let o=0;o<n.length&&o<r.length;o++){if(n[o].kind!==r[o].kind)return n[o].kind-r[o].kind;if(n[o].kind===0&&n[o].text!==r[o].text)return n[o].text<r[o].text?-1:1}return n.length!==r.length?r.length-n.length:e<t?-1:e>t?1:0}function Le(e){let t=I(new URL(e,location.href).pathname).replace(/^\/+|\/+$/g,""),n=null;for(let r of C)for(let o of r.s||[])for(let i of o.i||[])ze(t,i)&&(!n||Ye(i,n.pattern)<0)&&(n={hit:{entry:r,slot:o,path:t},pattern:i});return n&&!P(w(document),n.hit.slot.key,"ks:")?null:n?n.hit:null}function Xe(e,t){C=C.map(n=>n.s&&n.s.some(r=>r.key===e)?{...n,s:n.s.map(r=>r.key===e?t:r)}:n)}function Ge(e){let t="",n=e.getElementById("__krate_page");if(n)try{let r=JSON.parse(n.textContent||"{}");typeof r.r=="string"&&(t=r.r)}catch{}globalThis.__KRATE_ROUTE__=t;for(let r of Array.from(e.querySelectorAll("script:not([src])"))){let o=/window\.__KRATE_PARAMS__\s*=\s*(\{[\s\S]*?\})\s*;?\s*$/.exec(r.textContent||"");if(o){try{globalThis.__KRATE_PARAMS__=JSON.parse(o[1])}catch{}return}}delete globalThis.__KRATE_PARAMS__}function jt(e){let t=e.getElementById("__krate_error"),n=document.getElementById("__krate_error");if(!t){n&&n.remove();return}let r=document.importNode(t,!0);n?n.replaceWith(r):document.head.appendChild(r)}function Qe(e){let t=globalThis.krateDisposeScopes;typeof t=="function"&&t(e)}async function Te(e,t){let n=location.href;if(e.kind!=="pop"&&!b("krate:navigate-start",{url:e.url,from:n,kind:e.kind,intercept:t.slot.n},!0))return;let r=++T;k&&k.abort();let o=new AbortController;k=o,H("loading");let i=location.origin+ge()+"/"+bt+"/"+t.slot.key+(t.path?"/"+t.path:""),s="",c=!1;try{let d=await fetch(i,{headers:{Accept:"text/html"},credentials:"same-origin",signal:o.signal,cache:e.bypassCache?"no-cache":"default"});s=await d.text(),c=d.ok&&(ke(d.headers.get("content-type")||"")||V(s)),c||b("krate:navigate-error",{url:e.url,status:d.status,intercept:t.slot.n})}catch(d){if(d?.name==="AbortError"||o.signal.aborted)return;b("krate:navigate-error",{url:e.url,status:0,error:d,intercept:t.slot.n})}finally{k===o&&(k=void 0)}if(r!==T)return;let a=c?new DOMParser().parseFromString(s,"text/html"):null,u=a?P(w(a),t.slot.key,"ks:"):null,l=P(w(document),t.slot.key,"ks:"),p=null;try{let d=a&&a.getElementById("__krate_route");p=d&&JSON.parse(d.textContent||"{}").frag||null}catch{p=null}if(!a||!u||!l||!p||p.key!==t.slot.key||!p.scope){try{console.warn(`[krate router] intercepting route for ${e.url} (slot @${t.slot.n}) could not be loaded; navigating to the page`)}catch{}return H("idle"),se({...e})}if(e.kind==="push"&&z(m),t.slot.src!=="intercept"){Y.set(m,{key:t.slot.key,nodes:U(l[0],l[1]),slot:t.slot,path:N});for(let d of U(l[0],l[1]))d.parentNode.removeChild(d)}else Qe([t.slot.scope]),ee(l[0],l[1]);for(let d of U(u[0],u[1]))l[1].parentNode.insertBefore(document.importNode(d,!0),l[1]);let h=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(d=>h.add(d.href)),a.querySelectorAll('link[rel="stylesheet"][href]').forEach(d=>{let E=new URL(d.getAttribute("href"),i).href;if(h.has(E))return;let y=document.createElement("link");y.rel="stylesheet",y.href=E,document.head.appendChild(y)}),Xe(t.slot.key,{...t.slot,scope:p.scope,src:"intercept"}),Je(a);let g={__krate:"",state:e.state===void 0?null:e.state,__kint:{key:t.slot.key,base:N}};e.kind==="push"?(m=D(),g.__krate=m,history.pushState(g,"",e.url)):e.kind==="replace"?(m=D(),g.__krate=m,history.replaceState(g,"",e.url)):e.kind==="pop"&&e.restoreKey&&(m=e.restoreKey),A=x(location.href),Ge(a),ie(),b("krate:navigate",{url:location.href,status:200,intercept:t.slot.n}),ye(location.href),H("idle");let f=$e(a,i),v=await Promise.all(f.map(je));if(r===T){if(v.some(d=>!d)){b("krate:navigate-error",{url:location.href,status:200,error:"script-load",intercept:t.slot.n}),j(location.href,!0);return}te(),b("krate:navigate-end",{url:location.href,status:200,intercept:t.slot.n})}}function Jt(e,t){let n=P(w(document),e.key,"ks:"),r=C.flatMap(i=>i.s||[]).find(i=>i.key===e.key);if(!n||!r||r.src!=="intercept")return!1;Qe([r.scope]),ee(n[0],n[1]);for(let i of e.nodes)n[1].parentNode.insertBefore(i,n[1]);Xe(e.key,e.slot),Y.delete(t),m=t,A=x(location.href);let o=L.get(t);return o!==void 0&&window.scrollTo(0,o),ie(),b("krate:navigate",{url:location.href,status:200}),ye(location.href),oe(),!0}function Vt(e){return x(e)===A}function Ze(){F==="loading"&&(T++,k&&k.abort(),k=void 0,Se(),H("idle"))}function zt(e,t){Ze(),z(m),(e!==location.href||t.state!==void 0)&&(t.kind==="replace"?history.replaceState(J(m||D(),t.state),"",e):(m=D(),history.pushState(J(m,t.state),"",e)));let n=new URL(e).hash;!Ae(n)&&t.scroll&&!n&&window.scrollTo(0,0),oe()}function ae(e){let t;try{t=new URL(e.url,location.href)}catch{return j(e.url),Promise.resolve()}if(t.origin!==location.origin)return j(t.href,e.kind==="replace"),Promise.resolve();if(e.url=t.href,(e.kind==="push"||e.kind==="replace")&&Vt(t.href)&&(t.hash||t.href===location.href))return zt(t.href,e),Promise.resolve();if(e.kind==="push"||e.kind==="replace"){let n=Le(t.href);if(n)return Te(e,n)}return se(e)}function qe(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target;if(!t||typeof t.closest!="function")return;let n=t.closest("a[data-krate-link]");if(!n||!we(n))return;let r=n.getAttribute("href");r&&(e.preventDefault(),ae({url:new URL(r,location.href).href,kind:n.hasAttribute("data-krate-replace")?"replace":"push",scroll:n.getAttribute("data-krate-scroll")!=="false"}))}function et(e){if(e.defaultPrevented)return;let t=e.target;if(!t||t.tagName!=="FORM"||t.hasAttribute("data-krate-reload"))return;let n=e.submitter||null;if((n&&n.getAttribute("formmethod")||t.getAttribute("method")||"get").toLowerCase()!=="get")return;let o=n&&n.getAttribute("formtarget")||t.getAttribute("target");if(o&&o!=="_self")return;let i=n&&n.getAttribute("formaction")||t.getAttribute("action")||"",s;try{s=new URL(i||location.href,location.href)}catch{return}if(s.origin!==location.origin||s.protocol.indexOf("http")!==0)return;let c;try{c=n?new FormData(t,n):new FormData(t)}catch{c=new FormData(t),n&&n.name&&c.append(n.name,n.value)}let a=new URLSearchParams;for(let[u,l]of c.entries()){if(typeof l!="string")return;a.append(u,l)}e.preventDefault(),s.search=a.toString(),s.hash="",ae({url:s.href,kind:"push",scroll:!0})}function tt(e){z(m);let t=Q(e.state),n=location.href;if(x(n)===A){Ze(),m=t||m;let i=t?L.get(t):void 0;i!==void 0?window.scrollTo(0,i):Ae(location.hash),oe();return}let r=t?Y.get(t):void 0;if(r&&t&&r.path===x(n)&&r.path===N&&Jt(r,t))return;let o=e.state&&typeof e.state=="object"?e.state.__kint:null;if(o&&o.base===N){let i=Le(n);if(i&&i.slot.key===o.key){Te({url:n,kind:"pop",scroll:!1,restoreKey:t},i);return}}se({url:n,kind:"pop",scroll:!0,restoreKey:t})}function nt(){ve(),it()}function rt(){z(m);try{history.scrollRestoration="auto"}catch{}}function ot(){try{history.scrollRestoration="manual"}catch{}}function te(){Oe(),ie(),We(document),document.querySelectorAll("script[src]").forEach(e=>{me.test(e.src)||e.setAttribute("data-krate-spa","")})}function it(){if(!_||typeof location>"u")return typeof location<"u"&&location.reload(),Promise.resolve();if(A!==N){let e=Le(location.href);if(e&&e.slot.src==="intercept")return Te({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0},e)}return se({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0})}function st(e,t={}){return _?ae({url:e,kind:"push",scroll:t.scroll!==!1,state:t.state}):(typeof location<"u"&&location.assign(e),Promise.resolve())}function at(e,t={}){return _?ae({url:e,kind:"replace",scroll:t.scroll!==!1,state:t.state}):(typeof location<"u"&&location.replace(e),Promise.resolve())}var Yt={push:st,replace:at,back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh:it,prefetch(e){if(!_||typeof location>"u")return Promise.resolve();let t;try{t=new URL(e,location.href)}catch{return Promise.resolve()}return t.origin!==location.origin?Promise.resolve():be(t.href)},subscribe:Ie,getState:Ue,invalidate:ve};function Xt(e,t={}){return _?(t.replace?at(e,t):st(e,t),!1):(typeof location<"u"&&(t.replace?location.replace(e):location.assign(e)),!0)}function ct(){if(!(typeof document>"u")){if(_){te();return}if(_=!0,document.querySelectorAll("script[data-krate-boot]").forEach(e=>q.add(e.textContent||"")),A=x(location.href),C=Ve(document),N=A,m=Q(history.state)||D(),Q(history.state)===void 0)try{history.replaceState(J(m,history.state),"",location.href)}catch{}try{history.scrollRestoration="manual"}catch{}document.addEventListener("click",qe),document.addEventListener("submit",et),window.addEventListener("popstate",tt),window.addEventListener("krate:revalidate",nt),window.addEventListener("pagehide",rt),window.addEventListener("pageshow",ot),_t(),xt(),te()}}function Gt(){ct()}function Qt(){if(_){_=!1,document.removeEventListener("click",qe),document.removeEventListener("submit",et),window.removeEventListener("popstate",tt),window.removeEventListener("krate:revalidate",nt),window.removeEventListener("pagehide",rt),window.removeEventListener("pageshow",ot),document.removeEventListener("mouseover",Z),document.removeEventListener("focusin",Z);for(let e of B.values())clearTimeout(e);B=new Map,M&&(M.disconnect(),M=null),k&&k.abort(),k=void 0,T++,S.clear(),R.clear(),L.clear(),G.clear(),q.clear(),W.clear(),F="idle",$=[],C=[],Y.clear(),N=""}}return mt(Zt);})();
|
|
1
|
+
var __krate_exports=(()=>{var Pe=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Zt=Object.prototype.hasOwnProperty;var qt=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},en=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qt(t))!Zt.call(e,o)&&o!==n&&Pe(e,o,{get:()=>t[o],enumerable:!(r=Yt(t,o))||r.enumerable});return e};var tn=e=>en(Pe({},"__esModule",{value:!0}),e);var qn={};qt(qn,{compareRouteSpecificity:()=>Ht,destroyRouter:()=>Zn,getHistoryState:()=>hn,getNavigationState:()=>dt,initRouter:()=>zt,invalidatePrefetchCache:()=>We,krateRouter:()=>le,matchRoutePattern:()=>Mt,navigate:()=>Yn,pageAssetURLs:()=>at,reinitRouter:()=>Qn,subscribeNavigation:()=>ht});var nn="__krate_cfg__";function fe(){let e=globalThis;if(e.__KRATE_CFG__)return e.__KRATE_CFG__;let t=e.document,n=t&&typeof t.getElementById=="function"?t.getElementById(nn):null;if(n)try{let r=JSON.parse(n.textContent||"{}");if(r&&typeof r=="object")return e.__KRATE_CFG__=r,r}catch{}return{}}function G(){let e=fe(),t=e&&e.basePath||"";return!t||t==="/"?"":"/"+t.replace(/^\/+|\/+$/g,"")}function M(e){let t=G();return t&&e.charCodeAt(0)===47&&e.charCodeAt(1)!==47?t+e:e}var rn=/\/chunks\/runtime\.[^/]+\.js$/,st=/\/chunks\/(?:runtime\.[^/]+|c\/[^/]+)\.js$/;function ke(){return fe()}function z(e){let t=G();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}function Me(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function te(e){if(ke().dev)try{console.warn("[krate router] "+e)}catch{}}function Fe(e,t){if(/^(https?:)?\/\//.test(e)||e.startsWith("/"))return new URL(e,t).href;let n=t;if(!n.endsWith("/")){let r=n.lastIndexOf("/");n=r>0?n.slice(0,r+1):"/"}return new URL(e,n).href}function at(e,t,n){let r=typeof e=="string"?new DOMParser().parseFromString(e,"text/html"):e,o=[],i=new Set,a=s=>{if(!s)return;let c;try{c=Fe(s,t)}catch{return}i.has(c)||n.has(c)||rn.test(c)||(i.add(c),o.push(c))};return r.querySelectorAll("script[src]").forEach(s=>a(s.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(s=>a(s.getAttribute("href"))),o}var R=!1,re=Symbol.for("krate.router");function V(){if(R)return null;let e=globalThis,t=e[re];if(!t&&typeof document<"u"&<()&&typeof e.initRouter=="function"){try{e.initRouter()}catch(n){console.error(n)}t=e[re]}return t&&t!==le?t:null}function ct(){let e=globalThis.navigate;return lt()&&typeof e=="function"?e:null}function lt(){let e=globalThis.krateRouter;return!!e&&e!==le}var L=0,v,Ye=0,f="",_="",X="idle",oe=new Set,A=new Map,C=new Map,on=30,sn=3e4,N=new Map,an=50,Ne=new Set,cn=128,he=new Map,b=new Map,ln=10,ne=0,J="",K=new Map,F=null,me=[],U,un="_krate/i",fn=200,dn=100,ut="data-krate-navigating";function He(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function j(){return Ye++,Date.now().toString(36)+"-"+Ye.toString(36)}function Y(e){try{let t=new URL(e,location.href);return t.hash="",t.href}catch{return e}}function E(e){let t=new URL(e,location.href);return Me(t.pathname)+t.search}function ie(e,t=!1){let n=globalThis.__krateHardNavigate;if(typeof n=="function"){n(e,t);return}t?location.replace(e):location.assign(e)}function se(e,t){return{__krate:e,state:t===void 0?null:t}}function pe(e){if(e&&typeof e=="object"&&typeof e.__krate=="string")return e.__krate}function hn(){if(typeof history>"u")return null;let e=history.state;return pe(e)!==void 0?e.state:e}function ft(){let e=new URL(location.href);return{url:e.href,pathname:z(e.pathname),search:e.search,hash:e.hash,status:X}}function dt(){let e=V();return e?e.getState():typeof location>"u"?{url:"",pathname:"/",search:"",hash:"",status:"idle"}:ft()}function be(){if(oe.size===0)return;let e=ft();for(let t of Array.from(oe))try{t(e)}catch(n){console.error(n)}}function B(e){if(X!==e){X=e;try{document.documentElement.toggleAttribute(ut,e==="loading")}catch{}be()}}function ht(e){let t=V();return t?t.subscribe(e):(oe.add(e),()=>{oe.delete(e)})}function k(e,t,n=!1){try{let r=new CustomEvent(e,{detail:t,cancelable:n});return window.dispatchEvent(r),!r.defaultPrevented}catch{return!0}}function Be(e){try{let t=globalThis.__krate_onNavigation;typeof t=="function"&&t(e)}catch{}}function ae(e){if(e){if(N.delete(e),N.size>=an){let t=N.keys().next().value;t!==void 0&&N.delete(t)}N.set(e,window.scrollY||0)}}function mt(){let e=ke().prefetchTTL;return typeof e=="number"&&e>=0?e:sn}function mn(e,t){for(A.delete(e);A.size>=on;){let n=A.keys().next().value;if(n===void 0)break;A.delete(n)}A.set(e,t)}function pn(e){let t=A.get(e);if(t&&(A.delete(e),!(He()-t.at>mt())))return t}function We(e){if(ne++,e===void 0){A.clear(),C.clear(),b.clear();return}let t=Y(e);A.delete(t),C.delete(t),b.forEach((n,r)=>{Y(n.url)===t&&b.delete(r)})}function je(e,t){if(e){for(b.delete(e);b.size>=ln;){let n=b.keys().next().value;if(n===void 0)break;b.delete(n)}b.set(e,t)}}function gn(e,t){if(ce())return;let n=ne;vt(()=>{b.has(e)||n!==ne||fetch(Y(t),{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async r=>{if(!r.ok||/no-store/i.test(r.headers.get("cache-control")||""))return;let o=r.url||Y(t);if(E(o)!==E(t))return;let i=r.headers.get("content-type")||"",a=await r.text();(Ee(i)||i===""&&Q(a))&&(n!==ne||b.has(e)||!R||je(e,{html:a,url:t,status:r.status}))}).catch(()=>{})})}function Ee(e){return/text\/html|application\/xhtml\+xml/i.test(e)}function Q(e){return/^\s*(<!doctype html|<html|<head|<body)/i.test(e)}function Qe(e,t="script"){if(Ne.has(e)||Ne.size>=cn)return;Ne.add(e);let n=document.createElement("link");n.rel="prefetch",n.as=t,n.href=e,document.head.appendChild(n)}function yn(e,t){let n=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(o=>n.add(o.href));let r=[];return e.querySelectorAll('link[rel="stylesheet"][href]').forEach(o=>{try{let i=new URL(o.getAttribute("href"),t).href;!n.has(i)&&!r.includes(i)&&r.push(i)}catch{}}),r}function pt(){let e=new Set;document.querySelectorAll("script[src]").forEach(t=>e.add(t.src));try{for(let t of performance.getEntriesByType("resource"))e.add(t.name)}catch{}return e}function we(e){let t=Y(e),n=A.get(t);if(n&&He()-n.at<=mt())return Promise.resolve();let r=C.get(t);if(r)return r;let o=fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async i=>{if(!i.ok)return;let a=i.headers.get("content-type")||"",s=i.url||t;if(new URL(s,location.href).origin!==location.origin)return;let c=await i.text();if(!(Ee(a)||a===""&&Q(c))||C.get(t)!==o)return;mn(t,{html:c,url:s,status:i.status,at:He()});let u=new DOMParser().parseFromString(c,"text/html");for(let l of yn(u,s))Qe(l,"style");for(let l of at(u,s,pt()))Qe(l)}).catch(()=>{}).finally(()=>{C.get(t)===o&&C.delete(t)});return C.set(t,o),o}function Ve(e){if(e.hasAttribute("data-krate-external")||e.hasAttribute("download"))return!1;let t=e.getAttribute("href");if(!t||t.startsWith("javascript:"))return!1;let n;try{n=new URL(t,location.href)}catch{return!1}if(n.origin!==location.origin)return!1;let r=e.getAttribute("target");return!(r&&r!=="_self")}function gt(e){let t=e.getAttribute("data-prefetch");return e.hasAttribute("data-prefetch")&&t!=="false"&&t!=="0"}var vn=5,De=0;function ce(){let e=navigator.connection;return e?e.saveData===!0||e.effectiveType==="slow-2g"||e.effectiveType==="2g":!1}function yt(e){if(!gt(e))return!1;let t=e.getAttribute("data-prefetch");return t==="viewport"||ke().prefetch==="viewport"&&t!=="intent"}function vt(e){let t=window.requestIdleCallback;typeof t=="function"?t(e,{timeout:1e3}):setTimeout(e,50)}function kt(e){let t=e.target;if(!t||typeof t.closest!="function")return null;let n=t.closest("a[data-prefetch]");if(!n||!gt(n)||!Ve(n)||ce())return null;let r=n.getAttribute("href");if(!r)return null;let o=new URL(r,location.href).href;return E(o)===_?null:{a:n,url:o}}function ge(e){let t=kt(e);if(!t)return;let{a:n,url:r}=t,o=K.get(n);o&&clearTimeout(o);let i=setTimeout(()=>{K.delete(n),we(r)},fn);K.set(n,i)}function bt(e){if(typeof e.button=="number"&&e.button!==0)return;let t=kt(e);if(!t)return;let n=K.get(t.a);n&&(clearTimeout(n),K.delete(t.a)),we(t.url)}var Et=["touchstart",typeof PointerEvent=="function"?"pointerdown":"mousedown"];function wt(){De=0,!(!F||ce())&&document.querySelectorAll("a[data-prefetch]").forEach(e=>{yt(e)&&F.observe(e)})}function kn(){document.addEventListener("mouseover",ge),document.addEventListener("focusin",ge);for(let e of Et)document.addEventListener(e,bt,{passive:!0});typeof IntersectionObserver<"u"&&(F=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let n=t.target,r=n.getAttribute("href");if(r&&Ve(n)&&yt(n)&&De<vn&&!ce()){let o=new URL(r,location.href).href;E(o)!==_&&(De++,vt(()=>{we(o)}))}F.unobserve(t.target)}},{rootMargin:"200px"}),wt())}function bn(){let e=typeof HTMLScriptElement<"u"?HTMLScriptElement.supports:void 0;if(!(typeof e!="function"||!e("speculationrules"))&&!document.querySelector('meta[http-equiv="Content-Security-Policy" i]')&&!ce())try{let t=document.createElement("script");t.type="speculationrules";let n=G();t.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:n+"/*"},{not:{href_matches:n+"/__krate/*"}},{not:{href_matches:n+"/api/*"}}]},eagerness:"moderate"}]});let r=o=>{o&&o.blockedURI==="inline"&&String(o.effectiveDirective||o.violatedDirective||"").startsWith("script-src")&&(t.remove(),document.removeEventListener("securitypolicyviolation",r))};document.addEventListener("securitypolicyviolation",r),document.head.appendChild(t)}catch{}}function En(){if(typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{}return!1}function wn(){return ke().viewTransitions===!1||En()?!1:typeof document.startViewTransition=="function"}function S(e){return e.getElementById("root")||e.body}function Sn(){U!==void 0&&clearTimeout(U),U=setTimeout(()=>{U=void 0;let e=document.querySelector("template[data-krate-loading]");if(X!=="loading"||!e||!e.content||me.length>0)return;let t=e.content.cloneNode(!0);me=Array.from(t.childNodes),document.body.appendChild(t)},dn)}function Se(){U!==void 0&&(clearTimeout(U),U=void 0);for(let e of me)e.parentNode&&e.parentNode.removeChild(e);me=[]}function St(e){e.querySelectorAll("[data-view-transition]").forEach(t=>{let n=t.getAttribute("data-view-transition");n&&(t.style.viewTransitionName=n);let r=t.getAttribute("data-view-transition-class");r&&t.style.setProperty("view-transition-class",r)})}var Tn=3e3;function Tt(e){return new Promise(t=>{let n=()=>{e.removeEventListener("load",n),e.removeEventListener("error",n),t()};e.addEventListener("load",n),e.addEventListener("error",n)})}function At(e){if(e.length===0)return Promise.resolve();let t,n=new Promise(r=>{t=setTimeout(r,Tn)});return Promise.race([Promise.all(e).then(()=>{}),n]).then(()=>clearTimeout(t))}function An(e,t){let n=[];e.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{let u=c.getAttribute("href");if(!u)return;let l=new URL(u,t).href;n.includes(l)||n.push(l)});let r=new Map,o=[];document.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{let u=c;u.href&&(n.includes(u.href)&&!r.has(u.href)?r.set(u.href,u):o.push(u))});let i=[],a=[],s=null;return n.forEach((c,u)=>{let l=r.get(c)||null;if(!l){let m=document.createElement("link");if(m.rel="stylesheet",m.href=c,a.push(Tt(m)),i.push({link:m,media:m.getAttribute("media")}),m.media="not all",s)s.after(m);else{let p=n.slice(u+1).map(g=>r.get(g)).find(g=>!!g);p?p.before(m):document.head.appendChild(m)}l=m}s=l}),{ready:At(a),commit(){for(let{link:c,media:u}of i)u===null?c.removeAttribute("media"):c.setAttribute("media",u);o.forEach(c=>c.remove())},abort(){i.forEach(({link:c})=>c.remove())}}}var Ze='meta[name="description"], meta[name="robots"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Ln(e){document.head.querySelectorAll(Ze).forEach(t=>t.remove()),e.head.querySelectorAll(Ze).forEach(t=>{document.head.appendChild(document.importNode(t,!0))})}var Ie=null;function qe(e){let t={};if(e)for(let n of Array.from(e.attributes))t[n.name]=n.value;return t}function Oe(e){return{html:qe(e.documentElement),body:qe(e.body)}}function Rn(e){let t=Ie??Oe(document),n=Oe(e),r=(o,i,a)=>{if(o)for(let s of new Set([...Object.keys(i),...Object.keys(a)]))i[s]!==a[s]&&(a[s]===void 0?o.removeAttribute(s):o.setAttribute(s,a[s]))};r(document.documentElement,t.html,n.html),r(document.body,t.body,n.body),Ie=n}function Ue(e,t){let n=new Set;document.querySelectorAll("script[src]:not([data-krate-spa])").forEach(i=>n.add(i.src));let r=[],o=new Set;return e.querySelectorAll("script[src]").forEach(i=>{let a=i.getAttribute("src");if(!a)return;let s=(i.getAttribute("type")||"").toLowerCase();if(s&&s!=="module"&&s!=="text/javascript"&&s!=="application/javascript")return;let c=Fe(a,t);!n.has(c)&&!o.has(c)&&(o.add(c),r.push({src:c,module:s==="module"}))}),r}function _n(e,t,n){let r=pt(),o=[],i=[],a=(s,c,u)=>{if(r.has(s))return;r.add(s);let l=document.createElement("link");c?l.rel="modulepreload":(l.rel="preload",l.as="script"),u!==null&&l.setAttribute("crossorigin",u),l.href=s,i.push(Tt(l)),o.push(l),document.head.appendChild(l)};for(let s of n)a(s.src,s.module,null);return e.querySelectorAll('link[rel="modulepreload"][href]').forEach(s=>{try{a(Fe(s.getAttribute("href"),t),!0,s.getAttribute("crossorigin"))}catch{}}),{ready:At(i),remove(){o.forEach(s=>s.remove())}}}function Lt(e){return new Promise(t=>{let n=document.createElement("script");n.src=e.src,e.module?n.type="module":n.async=!1,st.test(e.src)||n.setAttribute("data-krate-spa",""),n.onload=()=>t(!0),n.onerror=()=>t(!1),document.body.appendChild(n)})}var ye=new Set;function Rt(e){e.querySelectorAll("script[data-krate-boot]").forEach(t=>{let n=t.textContent||"";if(!n||ye.has(n))return;ye.add(n);let r=document.createElement("script");r.text=n,document.head.appendChild(r),r.remove()})}function Pn(e){if(!e||e==="#")return null;let t=e.slice(1);try{t=decodeURIComponent(t)}catch{}return document.getElementById(t)||document.getElementsByName(t)[0]||null}function $e(e){let t=Pn(e);if(!t)return!1;try{t.scrollIntoView({block:"start"})}catch{}return!0}function Nn(e,t){if(t.kind==="pop"){let r=t.restoreKey?N.get(t.restoreKey):void 0;if(r!==void 0){window.scrollTo(0,r);return}}let n=new URL(e,location.href).hash;$e(n)||t.scroll&&t.kind!=="refresh"&&window.scrollTo(0,0)}var de=null,Cn=["name","type","role","aria-label","placeholder","data-testid","data-slot","href"];function _t(e){let t=e.tagName;for(let n of Cn){let r=e.getAttribute(n);r!==null&&(t+="\0"+n+"="+r)}return t}function Pt(e,t,n){return Array.from(e.getElementsByTagName(n)).filter(r=>_t(r)===t)}function xn(e,t,n){if(!t.contains(e))return!1;if(!n.region)return!0;let r=o=>!!(o[0].compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)&&!!(o[1].compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING);return r(n.region.live)||n.slots.some(o=>r(o.live))}function Mn(e,t){let n=document.activeElement;if(!n||n===document.body||n===e||!xn(n,e,t))return null;let r=_t(n),o=n,i=null,a=null;try{i=typeof o.selectionStart=="number"?o.selectionStart:null,a=typeof o.selectionEnd=="number"?o.selectionEnd:null}catch{}return{id:n.id,sig:r,index:Pt(e,r,n.tagName).indexOf(n),start:i,end:a}}function et(e){let t=document.activeElement;return!!t&&t!==document.body&&t!==e&&e.contains(t)}function tt(e,t){let n=t.sig.split("\0")[0],r=t.id?document.getElementById(t.id):null;if((!r||!e.contains(r))&&(r=Pt(e,t.sig,n)[t.index]??null),!(!r||typeof r.focus!="function"))try{r.focus({preventScroll:!0});let o=r;if(t.start!==null&&t.end!==null&&document.activeElement===r&&typeof o.setSelectionRange=="function"){let i=o.value.length;o.setSelectionRange(Math.min(t.start,i),Math.min(t.end,i))}}catch{}}function Hn(){let e=document.activeElement;if(e&&e!==document.body&&e.isConnected&&e!==de)return;let t=S(document);t.hasAttribute("tabindex")||(t.setAttribute("tabindex","-1"),de=t,t.addEventListener("blur",()=>{de===t&&(t.removeAttribute("tabindex"),de=null)},{once:!0}));try{t.focus({preventScroll:!0})}catch{}}var nt="__krate-route-announcer";function Dn(){let e=document.getElementById(nt);e||(e=document.createElement("div"),e.id=nt,e.setAttribute("aria-live","assertive"),e.setAttribute("aria-atomic","true"),e.setAttribute("role","status"),e.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0"),document.body.appendChild(e));let t=S(document).querySelector("h1"),n=document.title||(t&&t.textContent?t.textContent.trim():"")||z(location.pathname);e.textContent=n}function Te(){let e=Me(z(location.pathname));document.querySelectorAll("a[data-krate-link]").forEach(t=>{let n=t.getAttribute("href"),r="";try{r=n?Me(z(new URL(n,location.href).pathname)):""}catch{r=""}let o="";r&&r===e?o="exact":r&&r!=="/"&&e.startsWith(r+"/")&&(o="segment"),o==="exact"?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current"),o?t.setAttribute("data-krate-active",o):t.removeAttribute("data-krate-active")})}function rt(e){let t=G()+e;return he.has(t)?Promise.resolve(he.get(t)??null):fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async n=>{let r=n.ok?await n.text():null,o=r&&Q(r)?r:null;return he.set(t,o),o}).catch(()=>null)}function In(e){if(e.kind!=="pop"||!e.restoreKey||e.bypassCache)return;let t=b.get(e.restoreKey);return t&&E(t.url)===E(e.url)?t:void 0}async function On(e,t){let n=Y(e.url),r=In(e);if(r)return{ok:!0,doc:{html:r.html,url:e.url,status:r.status}};if(!e.bypassCache){let p=C.get(n);if(p&&await p,t.aborted)return{ok:!1,aborted:!0};let g=pn(n);if(g){let h=new URL(e.url,location.href).hash,y=h&&!new URL(g.url,location.href).hash?g.url+h:g.url;return{ok:!0,doc:{html:g.html,url:y,status:g.status}}}}Sn();let o;try{o=await fetch(n,{headers:{Accept:"text/html"},credentials:"same-origin",signal:t,cache:e.bypassCache?"no-cache":"default"})}catch(p){return p?.name==="AbortError"||t.aborted?{ok:!1,aborted:!0}:k("krate:navigate-error",{url:e.url,status:0,error:p},!0)?{ok:!1,hard:e.url}:{ok:!1,aborted:!0}}let i=o.url||n;if(new URL(i,location.href).origin!==location.origin)return{ok:!1,hard:i};let a=o.headers.get("content-type")||"",s="";try{s=await o.text()}catch(p){if(p?.name==="AbortError"||t.aborted)return{ok:!1,aborted:!0};s=""}if(t.aborted)return{ok:!1,aborted:!0};let c=Ee(a)||a===""&&Q(s),u=new URL(e.url,location.href).hash,l=u&&!new URL(i).hash?i+u:i;if(o.ok)return c?{ok:!0,doc:{html:s,url:l,status:o.status}}:{ok:!1,hard:l};if(k("krate:navigate-error",{url:e.url,status:o.status}),c&&Q(s))return{ok:!0,doc:{html:s,url:l,status:o.status}};let m=null;return o.status===404||o.status===410?m=await rt("/404.html"):o.status>=500&&(m=await rt("/500.html")),t.aborted?{ok:!1,aborted:!0}:m?{ok:!0,doc:{html:m,url:l,status:o.status}}:{ok:!1,hard:l}}async function Ae(e){let t=location.href;if(e.kind!=="pop"){if(!k("krate:navigate-start",{url:e.url,from:t,kind:e.kind},!0))return}else k("krate:navigate-start",{url:e.url,from:t,kind:e.kind});let n=++L;v&&v.abort();let r=new AbortController;v=r,B("loading");let o;try{o=await On(e,r.signal)}finally{v===r&&(v=void 0)}if(n===L){if(!o.ok){Se(),B("idle"),"hard"in o&&ie(o.hard,e.kind==="replace"||e.kind==="refresh");return}await Un(o.doc,e,n)}}async function Un(e,t,n){let r=new DOMParser().parseFromString(e.html,"text/html"),o=e.url,i=S(r),a=S(document),s=An(r,o),c=_n(r,o,Ue(r,o));if(await Promise.all([s.ready,c.ready]),n!==L){s.abort(),c.remove();return}let u=f,l=location.href;t.kind==="push"&&ae(f);let m=xt(r),p=$n(D,m,location.href,o,r),g=E(o).split("?")[0]===x.split("?")[0],h=null,y=null,d=[];if(await Wn(()=>{g&&(h=Mn(a,p));let P=document.activeElement;y=P&&P!==document.body&&a.contains(P)?P:null;let Xt=y?Fn(y):null,Xe=r.querySelector("title");Xe&&(document.title=Xe.textContent||"");let ue=globalThis;p.keep.length>0&&typeof ue.krateDisposeExcept=="function"?ue.krateDisposeExcept(p.keep):typeof ue.disposeAll=="function"&&ue.disposeAll();let Re={sameProps:!g},_e=I=>{let ee=document.createDocumentFragment();for(let O of I)ee.appendChild(document.importNode(O,!0));return Array.from(ee.childNodes)};if(p.region){let{live:I,next:ee}=p.region;d=Ce(I[0].parentNode,I[0],I[1],_e(W(ee[0],ee[1])),Re);for(let O of p.slots)d.push(...Ce(O.live[0].parentNode,O.live[0],O.live[1],_e(W(O.next[0],O.next[1])),Re));jn(a,i)}else d=Ce(a,null,null,_e(Array.from(i.childNodes)),Re);D=p.chain,Z.forEach(I=>Ct(I.nodes)),Z.clear(),s.commit(),Ln(r),Rn(r),St(document),y&&y.isConnected?(document.activeElement!==y&&Bn(y,Xt),h=null):h&&tt(a,h)},t.kind!=="refresh"&&!g),n!==L){c.remove();return}Se(),t.kind==="push"?(f=j(),history.pushState(se(f,t.state),"",o)):t.kind==="replace"?(N.delete(f),b.delete(f),f=j(),history.replaceState(se(f,t.state),"",o)):t.kind==="refresh"?o!==location.href&&history.replaceState(history.state,"",o):t.restoreKey&&(f=t.restoreKey),e.status>=200&&e.status<300&&je(f,{html:e.html,url:location.href,status:e.status}),t.kind==="push"&&u&&u===J?(J="",gn(u,l)):t.kind==="replace"&&u===J&&(J=""),_=E(location.href),x=_,It(r),Gn(r),Nn(o,t),t.kind!=="pop"&&t.kind!=="refresh"&&Hn(),t.kind!=="refresh"&&Dn(),Te(),k("krate:navigate",{url:location.href,status:e.status}),Be(location.href),B("idle"),document.querySelectorAll("script[data-krate-spa]").forEach(P=>P.remove()),Rt(r);let T=Ue(r,o);it(p.skip);let q=await Promise.all(T.map(Lt));if(it([]),c.remove(),n!==L)return;if(q.some(P=>!P)){k("krate:navigate-error",{url:location.href,status:e.status,error:"script-load"}),ie(location.href,!0);return}ve(),k("krate:navigate-end",{url:location.href,status:e.status});let $=h;$&&!et(a)&&(await Kn(d),n===L&&!et(a)&&tt(a,$))}function Nt(){let e=globalThis.__krateIslandSwap;return e&&typeof e.swap=="function"&&typeof e.unmount=="function"?e:null}function Ce(e,t,n,r,o){let i=Nt();if(i)return i.swap(e,t,n,r,o);if(t&&n){Ge(t,n);for(let a of r)e.insertBefore(a,n)}else e.replaceChildren(...r);return[]}function Ct(e){let t=Nt();t&&t.unmount(e)}function Kn(e){let t=globalThis.__krateIslandsReady,n=Promise.all([...e,t&&typeof t.then=="function"?t:null]);return Promise.race([n,new Promise(r=>setTimeout(r,3e3))])}function Fn(e){let t=e;try{return typeof t.selectionStart=="number"&&typeof t.selectionEnd=="number"?[t.selectionStart,t.selectionEnd]:null}catch{return null}}function Bn(e,t){try{e.focus({preventScroll:!0}),t&&document.activeElement===e&&typeof e.setSelectionRange=="function"&&e.setSelectionRange(t[0],t[1])}catch{}}function Wn(e,t=!0){if(!t||!wn())return e(),Promise.resolve();let n=!1,r=()=>{n||(n=!0,e())};try{let o=document.startViewTransition(r);o&&o.finished&&typeof o.finished.catch=="function"&&o.finished.catch(()=>{}),o&&o.ready&&typeof o.ready.catch=="function"&&o.ready.catch(()=>{});let i=o&&o.updateCallbackDone;if(i&&typeof i.then=="function")return i.then(()=>r(),()=>r())}catch{}return r(),Promise.resolve()}var D=[];function xt(e){let t=e.getElementById("__krate_route");if(!t)return[];try{let n=JSON.parse(t.textContent||"{}");return Array.isArray(n.chain)?n.chain:[]}catch{return te("unreadable #__krate_route route info; layouts will be remounted"),[]}}function ot(e,t){let n=z(new URL(e,location.href).pathname).split("/").filter(Boolean);return(t<0?n:n.slice(0,t)).join("/")}function H(e,t,n="kl:"){let o=(e.ownerDocument||e).createTreeWalker(e,128),i=n+t,a="/"+n+t;for(;o.nextNode();){let s=o.currentNode;if(s.nodeValue===i){for(let c=s.nextSibling;c;c=c.nextSibling)if(c.nodeType===8&&c.nodeValue===a)return[s,c];return null}}return null}function W(e,t){let n=[];for(let r=e.nextSibling;r&&r!==t;r=r.nextSibling)n.push(r);return n}function Ge(e,t){let n=globalThis.disposeNode;Ct(W(e,t));for(let r of W(e,t))r.parentNode.removeChild(r),typeof n=="function"&&n(r)}function jn(e,t){let n=":scope > template[data-krate-loading]";e.querySelectorAll(n).forEach(r=>r.remove()),t.querySelectorAll(n).forEach(r=>e.appendChild(document.importNode(r,!0)))}function it(e){let t=globalThis.krateKeepScopes;typeof t=="function"&&t(e)}function Vn(e){let t=globalThis.krateScopeFailed;return typeof t=="function"&&!!t(e)}function $n(e,t,n,r,o){let i={keep:[],skip:[],region:null,slots:[],chain:t},a=0;for(;a<e.length&&a<t.length;){let h=e[a],y=t[a];if(h.id!==y.id||h.k!==y.k||h.k!=="layout"&&h.k!=="error"||ot(n,h.d)!==ot(r,y.d)||h.k==="error"&&Vn(h.id))break;if(!h.p||!y.p){te(`layout ${y.f||y.id} is remounted on this navigation: ${y.why||h.why||"not persistable"}`);break}a++}if(a===0)return i;if(typeof globalThis.krateDisposeExcept!="function")return te("the runtime has no krateDisposeExcept; layouts are remounted"),i;let s=t[a-1].id,c=H(S(document),s),u=H(S(o),s);if(!c||!u)return te(`layout ${t[a-1].f||s} boundary markers are missing; the whole page is swapped`),i;let l=e.slice(0,a).map(h=>h.id),m=l.slice(),p=[],g=t.slice();for(let h=0;h<a;h++){let y=e[h].s||[],d=[];for(let w of t[h].s||[]){let T=y.find(P=>P.key===w.key),q=H(S(document),w.key,"ks:"),$=H(S(o),w.key,"ks:");if(T&&q&&(w.src!=="page"||!$)){l.push(T.scope),m.push(T.scope,w.scope),d.push({...w,scope:T.scope,src:T.src});continue}if(q&&$){p.push({live:q,next:$}),d.push(w);continue}return te(`slot @${w.n} markers are missing; the whole page is swapped`),i}g[h]={...t[h],s:d}}return{keep:l,skip:m,region:{live:c,next:u},slots:p,chain:g}}var Z=new Map,x="";function Ke(e){let t=e.replace(/^\/+|\/+$/g,"");return t?t.split("/").map(n=>n.startsWith("[[...")&&n.endsWith("]]")?{kind:3,text:n.slice(5,-2)}:n.startsWith("[...")&&n.endsWith("]")?{kind:2,text:n.slice(4,-1)}:n.startsWith("[")&&n.endsWith("]")?{kind:1,text:n.slice(1,-1)}:{kind:0,text:n}):[]}function Mt(e,t){let n=Ke(t),r=e.replace(/^\/+|\/+$/g,""),o=r?r.split("/"):[],i={};for(let a=0;a<n.length;a++){let s=n[a];if(s.kind>=2){if(a!==n.length-1)return null;let c=o.slice(a);return s.kind===2&&c.length===0||c.some(u=>u==="")?null:(i[s.text]=c.map(xe).join("/"),i)}if(a>=o.length)return null;if(s.kind===1){if(!o[a])return null;i[s.text]=xe(o[a])}else if(xe(o[a])!==s.text)return null}return o.length===n.length?i:null}function xe(e){try{return decodeURIComponent(e)}catch{return e}}function Ht(e,t){let n=Ke(e),r=Ke(t);for(let o=0;o<n.length&&o<r.length;o++){if(n[o].kind!==r[o].kind)return n[o].kind-r[o].kind;if(n[o].kind===0&&n[o].text!==r[o].text)return n[o].text<r[o].text?-1:1}return n.length!==r.length?r.length-n.length:e<t?-1:e>t?1:0}function Je(e){let t=z(new URL(e,location.href).pathname).replace(/^\/+|\/+$/g,""),n=null;for(let r of D)for(let o of r.s||[])for(let i of o.i||[])Mt(t,i)&&(!n||Ht(i,n.pattern)<0)&&(n={hit:{entry:r,slot:o,path:t},pattern:i});return n&&!H(S(document),n.hit.slot.key,"ks:")?null:n?n.hit:null}function Dt(e,t){D=D.map(n=>n.s&&n.s.some(r=>r.key===e)?{...n,s:n.s.map(r=>r.key===e?t:r)}:n)}function It(e){let t="",n=e.getElementById("__krate_page");if(n)try{let r=JSON.parse(n.textContent||"{}");typeof r.r=="string"&&(t=r.r)}catch{}globalThis.__KRATE_ROUTE__=t;for(let r of Array.from(e.querySelectorAll("script:not([src])"))){let o=/window\.__KRATE_PARAMS__\s*=\s*(\{[\s\S]*?\})\s*;?\s*$/.exec(r.textContent||"");if(o){try{globalThis.__KRATE_PARAMS__=JSON.parse(o[1])}catch{}return}}delete globalThis.__KRATE_PARAMS__}function Gn(e){let t=e.getElementById("__krate_error"),n=document.getElementById("__krate_error");if(!t){n&&n.remove();return}let r=document.importNode(t,!0);n?n.replaceWith(r):document.head.appendChild(r)}function Ot(e){let t=globalThis.krateDisposeScopes;typeof t=="function"&&t(e)}async function ze(e,t){let n=location.href;if(e.kind!=="pop"&&!k("krate:navigate-start",{url:e.url,from:n,kind:e.kind,intercept:t.slot.n},!0))return;let r=++L;v&&v.abort();let o=new AbortController;v=o,B("loading");let i=location.origin+G()+"/"+un+"/"+t.slot.key+(t.path?"/"+t.path:""),a="",s=!1;try{let d=await fetch(i,{headers:{Accept:"text/html"},credentials:"same-origin",signal:o.signal,cache:e.bypassCache?"no-cache":"default"});a=await d.text(),s=d.ok&&(Ee(d.headers.get("content-type")||"")||Q(a)),s||k("krate:navigate-error",{url:e.url,status:d.status,intercept:t.slot.n})}catch(d){if(d?.name==="AbortError"||o.signal.aborted)return;k("krate:navigate-error",{url:e.url,status:0,error:d,intercept:t.slot.n})}finally{v===o&&(v=void 0)}if(r!==L)return;let c=s?new DOMParser().parseFromString(a,"text/html"):null,u=c?H(S(c),t.slot.key,"ks:"):null,l=H(S(document),t.slot.key,"ks:"),m=null;try{let d=c&&c.getElementById("__krate_route");m=d&&JSON.parse(d.textContent||"{}").frag||null}catch{m=null}if(!c||!u||!l||!m||m.key!==t.slot.key||!m.scope){try{console.warn(`[krate router] intercepting route for ${e.url} (slot @${t.slot.n}) could not be loaded; navigating to the page`)}catch{}return B("idle"),Ae({...e})}if(e.kind==="push"&&ae(f),t.slot.src!=="intercept"){Z.set(f,{key:t.slot.key,nodes:W(l[0],l[1]),slot:t.slot,path:x});for(let d of W(l[0],l[1]))d.parentNode.removeChild(d)}else Ot([t.slot.scope]),Ge(l[0],l[1]);for(let d of W(u[0],u[1]))l[1].parentNode.insertBefore(document.importNode(d,!0),l[1]);let p=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(d=>p.add(d.href)),c.querySelectorAll('link[rel="stylesheet"][href]').forEach(d=>{let w=new URL(d.getAttribute("href"),i).href;if(p.has(w))return;let T=document.createElement("link");T.rel="stylesheet",T.href=w,document.head.appendChild(T)}),Dt(t.slot.key,{...t.slot,scope:m.scope,src:"intercept"}),Rt(c);let g={__krate:"",state:e.state===void 0?null:e.state,__kint:{key:t.slot.key,base:x}};e.kind==="push"?(f=j(),g.__krate=f,history.pushState(g,"",e.url)):e.kind==="replace"?(f=j(),g.__krate=f,history.replaceState(g,"",e.url)):e.kind==="pop"&&e.restoreKey&&(f=e.restoreKey),_=E(location.href),It(c),Te(),k("krate:navigate",{url:location.href,status:200,intercept:t.slot.n}),Be(location.href),B("idle");let h=Ue(c,i),y=await Promise.all(h.map(Lt));if(r===L){if(y.some(d=>!d)){k("krate:navigate-error",{url:location.href,status:200,error:"script-load",intercept:t.slot.n}),ie(location.href,!0);return}ve(),k("krate:navigate-end",{url:location.href,status:200,intercept:t.slot.n})}}function Jn(e,t){let n=H(S(document),e.key,"ks:"),r=D.flatMap(i=>i.s||[]).find(i=>i.key===e.key);if(!n||!r||r.src!=="intercept")return!1;Ot([r.scope]),Ge(n[0],n[1]);for(let i of e.nodes)n[1].parentNode.insertBefore(i,n[1]);Dt(e.key,e.slot),Z.delete(t),f=t,_=E(location.href);let o=N.get(t);return o!==void 0&&window.scrollTo(0,o),Te(),k("krate:navigate",{url:location.href,status:200}),Be(location.href),be(),!0}function zn(e){return E(e)===_}function Ut(){X==="loading"&&(L++,v&&v.abort(),v=void 0,Se(),B("idle"))}function Xn(e,t){if(Ut(),ae(f),e!==location.href||t.state!==void 0)if(t.kind==="replace")history.replaceState(se(f||j(),t.state),"",e);else{let r=b.get(f);f=j(),history.pushState(se(f,t.state),"",e),r&&je(f,{...r,url:e})}let n=new URL(e).hash;!$e(n)&&t.scroll&&!n&&window.scrollTo(0,0),be()}function Le(e){let t;try{t=new URL(e.url,location.href)}catch{return ie(e.url),Promise.resolve()}if(t.origin!==location.origin)return ie(t.href,e.kind==="replace"),Promise.resolve();if(e.url=t.href,(e.kind==="push"||e.kind==="replace")&&zn(t.href)&&(t.hash||t.href===location.href))return Xn(t.href,e),Promise.resolve();if(e.kind==="push"||e.kind==="replace"){let n=Je(t.href);if(n)return ze(e,n)}return Ae(e)}function Kt(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target;if(!t||typeof t.closest!="function")return;let n=t.closest("a[data-krate-link]");if(!n||!Ve(n))return;let r=n.getAttribute("href");r&&(e.preventDefault(),Le({url:new URL(r,location.href).href,kind:n.hasAttribute("data-krate-replace")?"replace":"push",scroll:n.getAttribute("data-krate-scroll")!=="false"}))}function Ft(e){if(e.defaultPrevented)return;let t=e.target;if(!t||t.tagName!=="FORM"||t.hasAttribute("data-krate-reload"))return;let n=e.submitter||null;if((n&&n.getAttribute("formmethod")||t.getAttribute("method")||"get").toLowerCase()!=="get")return;let o=n&&n.getAttribute("formtarget")||t.getAttribute("target");if(o&&o!=="_self")return;let i=n&&n.getAttribute("formaction")||t.getAttribute("action")||"",a;try{a=new URL(i||location.href,location.href)}catch{return}if(a.origin!==location.origin||a.protocol.indexOf("http")!==0)return;let s;try{s=n?new FormData(t,n):new FormData(t)}catch{s=new FormData(t),n&&n.name&&s.append(n.name,n.value)}let c=new URLSearchParams;for(let[u,l]of s.entries()){if(typeof l!="string")return;c.append(u,l)}e.preventDefault(),a.search=c.toString(),a.hash="",Le({url:a.href,kind:"push",scroll:!0})}function Bt(e){ae(f);let t=pe(e.state),n=location.href;if(E(n)===_){Ut(),f=t||f;let i=t?N.get(t):void 0;i!==void 0?window.scrollTo(0,i):$e(location.hash),be();return}let r=t?Z.get(t):void 0;if(r&&t&&r.path===E(n)&&r.path===x&&Jn(r,t))return;let o=e.state&&typeof e.state=="object"?e.state.__kint:null;if(o&&o.base===x){let i=Je(n);if(i&&i.slot.key===o.key){ze({url:n,kind:"pop",scroll:!1,restoreKey:t},i);return}}Ae({url:n,kind:"pop",scroll:!0,restoreKey:t})}function Wt(){We(),$t()}function jt(){ae(f);try{history.scrollRestoration="auto"}catch{}}function Vt(){try{history.scrollRestoration="manual"}catch{}}function ve(){wt(),Te(),St(document),document.querySelectorAll("script[src]").forEach(e=>{st.test(e.src)||e.setAttribute("data-krate-spa","")})}function $t(){let e=V();if(e)return e.refresh();if(!R||typeof location>"u")return typeof location<"u"&&location.reload(),Promise.resolve();if(_!==x){let t=Je(location.href);if(t&&t.slot.src==="intercept")return ze({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0},t)}return Ae({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0})}function Gt(e,t={}){if(!R){let n=V();if(n)return n.push(e,t);let r=ct();return r?r(e,{...t,replace:!1}):typeof location<"u"&&location.assign(M(e)),Promise.resolve()}return Le({url:M(e),kind:"push",scroll:t.scroll!==!1,state:t.state})}function Jt(e,t={}){if(!R){let n=V();if(n)return n.replace(e,t);let r=ct();return r?r(e,{...t,replace:!0}):typeof location<"u"&&location.replace(M(e)),Promise.resolve()}return Le({url:M(e),kind:"replace",scroll:t.scroll!==!1,state:t.state})}var le={push:Gt,replace:Jt,back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh:$t,prefetch(e){let t=V();if(t)return t.prefetch(e);if(!R||typeof location>"u")return Promise.resolve();let n;try{n=new URL(M(e),location.href)}catch{return Promise.resolve()}return n.origin!==location.origin?Promise.resolve():we(n.href)},subscribe:ht,getState:dt,invalidate:We};function Yn(e,t={}){return R||V()?(t.replace?Jt(e,t):Gt(e,t),!1):(typeof location<"u"&&(t.replace?location.replace(M(e)):location.assign(M(e))),!0)}function zt(){if(!(typeof document>"u")){if(R){ve();return}if(R=!0,globalThis[re]=le,document.querySelectorAll("script[data-krate-boot]").forEach(e=>ye.add(e.textContent||"")),_=E(location.href),D=xt(document),Ie=Oe(document),x=_,f=pe(history.state)||j(),J=f,pe(history.state)===void 0)try{history.replaceState(se(f,history.state),"",location.href)}catch{}try{history.scrollRestoration="manual"}catch{}document.addEventListener("click",Kt),document.addEventListener("submit",Ft),window.addEventListener("popstate",Bt),window.addEventListener("krate:revalidate",Wt),window.addEventListener("pagehide",jt),window.addEventListener("pageshow",Vt),kn(),bn(),ve()}}function Qn(){zt()}function Zn(){if(R){R=!1,globalThis[re]===le&&delete globalThis[re],document.removeEventListener("click",Kt),document.removeEventListener("submit",Ft),window.removeEventListener("popstate",Bt),window.removeEventListener("krate:revalidate",Wt),window.removeEventListener("pagehide",jt),window.removeEventListener("pageshow",Vt),document.removeEventListener("mouseover",ge),document.removeEventListener("focusin",ge);for(let e of Et)document.removeEventListener(e,bt);for(let e of K.values())clearTimeout(e);K=new Map,F&&(F.disconnect(),F=null),v&&v.abort(),v=void 0,L++,A.clear(),C.clear(),b.clear(),J="",ne++,N.clear(),he.clear(),ye.clear(),oe.clear(),X="idle",document.documentElement.removeAttribute(ut),Se(),D=[],Z.clear(),x=""}}return tn(qn);})();
|
|
2
2
|
for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
|