@krate/runtime 0.4.0 → 0.5.0-alpha.1

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.
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var G=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var ft=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},dt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of lt(t))!ut.call(e,i)&&i!==n&&G(e,i,{get:()=>t[i],enumerable:!(r=at(t,i))||r.enumerable});return e};var pt=e=>dt(G({},"__esModule",{value:!0}),e);var rn={};ft(rn,{Slot:()=>en,clearNodes:()=>Ie,clearPersisted:()=>St,cloneElement:()=>nn,clsx:()=>ye,cn:()=>Gt,conditional:()=>zt,createCSSChoice:()=>bt,createCSSFlags:()=>Et,createCSSGroup:()=>wt,createCSSRange:()=>kt,createCSSStack:()=>Ct,createCSSToggle:()=>xt,createContext:()=>Z,createEffect:()=>N,createMemo:()=>Pt,createReducer:()=>Mt,createResource:()=>Dt,createScope:()=>ht,createScopeFlags:()=>mt,createSignal:()=>b,cva:()=>Qt,disposeAll:()=>vt,disposeNode:()=>k,forwardRef:()=>Ot,h:()=>Vt,hydrate:()=>jt,initRouter:()=>We,insert:()=>It,mount:()=>qt,navigate:()=>Yt,onCleanup:()=>U,onMount:()=>Rt,readDurableState:()=>re,readPersisted:()=>oe,reconcile:()=>Ft,reconcileTrees:()=>Ut,reinitRouter:()=>Jt,resetContexts:()=>Q,resolvePersist:()=>ne,subscribePersist:()=>se,twMerge:()=>Se,useRef:()=>_t,writePersisted:()=>ie});var gt=0,_=new Map;function Q(){for(let[e,t]of _)if(t.length>0){let n=t[0];_.set(e,[n])}}function ht(){return Z({})}function mt(){return Z({})}function Z(e){let t=gt++;_.set(t,[e]);let n=()=>{let r=_.get(t);return r&&r.length>0?r[r.length-1]:e};return{id:t,defaultValue:e,Provider:r=>{let i=_.get(t)||[e];i.push(r.value),_.set(t,i);let c=document.createElement("div");if(c.style.display="contents",r.children)for(let a of r.children)a instanceof Node?c.appendChild(a):a!=null&&c.appendChild(document.createTextNode(String(a)));return i.pop(),i.length===0&&i.push(e),c},useContext:n,use:n}}function yt(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var ee=yt();function Me(){return typeof window<"u"}function te(e){if(e&&typeof e=="object")return e;if(!Me())return ee;try{return e==="session"?window.sessionStorage:e==="memory"?ee:window.localStorage}catch{return ee}}function ne(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function re(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let i=r[e];if(typeof i=="string")try{return{found:!0,value:t(i)}}catch{return{found:!0,value:i}}return{found:!0,value:i}}function oe(e){let t=te(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function ie(e,t){let n=te(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function St(e){let t=te(e.store);try{t.removeItem(e.key)}catch{}}var j=new Map,Pe=!1;function Tt(){Pe||!Me()||(Pe=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=j.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function se(e,t){if(!e.sync)return()=>{};let n=j.get(e.key)??new Set;return n.add(t),j.set(e.key,n),Tt(),()=>{n.delete(t),n.size===0&&j.delete(e.key)}}var L=[],_e=[],ce=!1,O=new Set,ae=[],le=[],D=!1;function Oe(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function ue(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function vt(){for(let e of O)ue(e);O.clear();for(let e of ae)try{e()}catch{}ae.length=0,le.length=0,D=!1,Q()}function bt(e,t){return z(b(e))}function xt(e,t){return z(b(e))}function Et(e,t){let n={};for(let c of e){let[a]=b(!1);n[c]=a}let i=[n,(c,a)=>{}];return i.trigger=c=>({"data-krate-scope":"trigger",value:c}),i.panel=c=>({"data-krate-scope":"panel",value:c}),i.close=()=>({"data-krate-scope":"close"}),i}function wt(e,t){return z(b(e))}function kt(e,t){return z(b(e))}function z(e){let t=e;return t.trigger=n=>({"data-krate-scope":"trigger",value:n}),t.panel=n=>({"data-krate-scope":"panel",value:n}),t.close=()=>({"data-krate-scope":"close"}),t.current=()=>e[0](),t}function Ct(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function b(e,t){let n=e,r=null;if(t?.persist){r=ne(t.persist);let f=re(r.key,r.deserialize);if(f.found)n=f.value;else{let l=oe(r);l.found&&(n=l.value)}}let i=new Set,c=()=>{let f=L[L.length-1];return f&&!f.disposed&&(i.add(f),f.sources.add(i)),n},a=()=>{let f=Array.from(i);for(let l of f){if(l.disposed){i.delete(l);continue}if(l.running){l.rerun=!0;continue}l.queued||(l.queued=!0,le.push(l))}Nt()},S=f=>{let l=typeof f=="function"?f(n):f;l!==n&&(n=l,r&&ie(r,n),a())};if(r&&r.sync){let f=r,l=se(f,h=>{if(h!==null)try{let g=f.deserialize(h);g!==n&&(n=g,a())}catch{}});U(l)}return[c,S]}function Nt(){D||(D=!0,queueMicrotask(At))}function At(){D=!1;let e=le.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,F(t),t.rerun&&!t.disposed&&(t.rerun=!1,F(t)))}function F(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,L.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{L.pop(),e.running=!1}}function N(e){let t=Oe(e);return O.add(t),F(t),()=>{ue(t),O.delete(t)}}function U(e){let t=L[L.length-1];t?t.cleanups.push(e):ae.push(e)}function Rt(e){_e.push(e),ce||(ce=!0,queueMicrotask(Lt))}function Lt(){ce=!1;let e=_e.splice(0);for(let t of e)t()}function Pt(e){let[t,n]=b(void 0),r=Oe(()=>{let c=e();n(c)});O.add(r),F(r);let i=L[L.length-1];return i&&i.cleanups.push(()=>{r.disposed||(ue(r),O.delete(r))}),t}function Mt(e,t){let[n,r]=b(t);return[n,c=>r(a=>e(a,c))]}function _t(e){return{current:e}}function Ot(e){return t=>e(t,t.ref||(()=>{}))}var Ht={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},fe=new WeakMap;function Ke(e,t){let n=fe.get(e);n||(n=[],fe.set(e,n)),n.push(t)}function k(e){let t=fe.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)k(e.childNodes[n])}function Kt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Ie(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let i=r.nextSibling;k(r),n.removeChild(r),r=i}}function It(e,t,n){let r=Kt(n);r?(Ie(n,r),de(e,t,r)):de(e,t,null)}function de(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)de(e,r,n)}}function He(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),i=Ht[r]||r,c=`__krate_${i}`,a=e[c];a&&e.removeEventListener(i,a),e.addEventListener(i,n),e[c]=n}else t==="value"||t==="checked"||t==="selected"?t==="value"?e.value=n==null||n===!1?"":n:e[t]=!!n:t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function Ve(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Ve(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Ke(n,N(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function Vt(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[i,c]of Object.entries(t))typeof c=="function"&&!i.startsWith("on")?Ke(r,N(()=>He(r,i,c()))):He(r,i,c);for(let i of n)Ve(r,i);return r}function qe(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function qt(e,t){let n=qe(t),r=!1;N(()=>{r||(r=!0,n.appendChild(e()))})}function jt(e,t){let n=qe(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&k(r)}function Dt(e,t){let[n,r]=b(void 0),[i,c]=b(!0),[a,S]=b(void 0),[f,l]=b("unresolved"),[h,g]=b(0),p,v=()=>typeof e=="function"?e():e,T=async()=>{p&&p.abort(),p=new AbortController;let C=p,V=v();l(h()>0?"refreshing":"loading"),c(!0),S(void 0);try{let A=await t(V,{signal:C.signal});C.signal.aborted||(r(()=>A),l("ready"))}catch(A){A?.name!=="AbortError"&&!C.signal.aborted&&(S(A),l("error"))}finally{C.signal.aborted||c(!1)}};N(()=>{typeof e=="function"&&e.length===0&&e(),h(),T(),U(()=>{p&&(p.abort(),p=void 0)})});let x=function(){return n()};return Object.defineProperties(x,{loading:{get:()=>i()},error:{get:()=>a()},state:{get:()=>f()}}),[x,{mutate:C=>{r(C)},refetch:()=>{g(C=>C+1)}}]}function Ft(e,t,n,r,i,c){let a=[],S=t.nextSibling;for(;S&&S!==n;)a.push(S),S=S.nextSibling;if(c){let f=new Map;for(let h of a){let g=h.__k;g!=null&&!f.has(g)&&f.set(g,h)}let l=[];for(let h=0;h<r.length;h++){let g=c(r[h]),p=f.get(g);p?f.delete(g):(p=i(r[h],h),p.__k=g),l.push(p)}for(let h of f.values())h.parentNode===e&&(k(h),e.removeChild(h));for(let h=0;h<l.length;h++){let g=h===0?t:l[h-1];l[h]!==g.nextSibling&&e.insertBefore(l[h],g.nextSibling)}}else{let f=Math.max(a.length,r.length);for(let l=0;l<f;l++)if(l<r.length){let h=i(r[l],l);l<a.length?a[l]!==h&&(k(a[l]),e.replaceChild(h,a[l])):e.insertBefore(h,n)}else l<a.length&&a[l].parentNode===e&&(k(a[l]),e.removeChild(a[l]))}}function zt(e,t,n,r,i,c){let a=null;N(()=>{let f=r()?i():c?c():null;a?f?(k(a),e.replaceChild(f,a)):(k(a),e.removeChild(a)):f&&e.insertBefore(f,n),a=f})}function H(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function je(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let i=t.attributes[r].name,c=t.attributes[r].value;n.add(i),e.getAttribute(i)!==c&&e.setAttribute(i,c)}for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r].name;n.has(i)||e.removeAttribute(i)}}function pe(e,t){let n=document.importNode(t,!0);return e.parentNode&&(k(e),e.parentNode.replaceChild(n,e)),n}function De(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function ge(e,t){if(!De(e,t))return pe(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?pe(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return H(n)!==H(r)?pe(n,r):(je(n,r),Fe(n,r),n)}function Fe(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let g=!0;for(let p=0;p<r.length;p++)if(H(n[p])!==H(r[p])){g=!1;break}if(g){for(let p=0;p<r.length;p++)ge(n[p],r[p]);return}}let i=new Map,c=[];n.forEach((g,p)=>{let v=H(g);v!=null?i.has(v)||i.set(v,p):c.push(p)});let a=new Set,S=0,f=null,l=0,h=()=>{for(;l<c.length&&a.has(c[l]);)l++;return l<c.length?c[l]:-1};for(let g of r){let p=H(g),v;if(p!=null&&i.has(p)){let T=i.get(p);i.delete(p),a.add(T);let x=n[T];T<S?e.insertBefore(x,f):S=T,v=ge(x,g)}else if(p==null){let T=h();if(T>=0&&De(n[T],g)){a.add(T);let x=n[T];x.parentNode===e&&x.nextSibling!==f&&e.insertBefore(x,f),v=ge(x,g)}else v=document.importNode(g,!0),e.insertBefore(v,f)}else v=document.importNode(g,!0),e.insertBefore(v,f);f=v.nextSibling}n.forEach((g,p)=>{!a.has(p)&&g.parentNode===e&&(k(g),e.removeChild(g))})}function Ut(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let i=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(i,n);return}je(n,r),Fe(n,r)}var he=!1,K,W=null,B=0,P=new Map,Bt=30,I=new Map,Wt=50,ze=/\/chunks\/runtime\.[^/]+\.js$/;function Be(){return globalThis.__KRATE_CFG__||{}}function $t(){let e=Be().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function Ue(e){let t=$t();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var $=null;function Yt(e,t={}){return $?($(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function We(){if(typeof document>"u"||he)return;he=!0;let e="#root, main, .docs-content",t=150,n=200,r=null,i=null,c=new Map,a=null;function S(o){for(let s of e.split(", ")){let u=o.querySelector(s.trim());if(u)return u}return o.body}function f(o){if(o.hasAttribute("data-krate-external"))return!1;let s=o.getAttribute("href");return!(!s||s.startsWith("#")||s.startsWith("javascript:")||o.origin!==location.origin||o.target==="_blank")}function l(o){P.has(o)||fetch(o,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(s){if(P.size>=Bt){let u=P.keys().next().value;u!==void 0&&P.delete(u)}P.set(o,s)}}).catch(()=>{})}function h(){document.addEventListener("mouseover",v),document.addEventListener("focusin",v),typeof IntersectionObserver<"u"&&(a=new IntersectionObserver(o=>{for(let s of o)if(s.isIntersecting){let u=s.target,d=u.getAttribute("href");if(d&&f(u)){let m=new URL(d,location.origin).href;l(m)}a.unobserve(s.target)}},{rootMargin:"200px"}),g())}function g(){a&&document.querySelectorAll("a[data-prefetch]").forEach(o=>{a.observe(o)})}function p(){document.removeEventListener("mouseover",v),document.removeEventListener("focusin",v);for(let o of c.values())clearTimeout(o);c.clear(),a&&(a.disconnect(),a=null)}function v(o){let s=o.target.closest("a[data-prefetch]");if(!s||!f(s))return;let u=s.getAttribute("href");if(!u)return;let d=new URL(u,location.origin).href;if(P.has(d))return;let m=c.get(s);m&&clearTimeout(m);let y=setTimeout(()=>{c.delete(s),l(d)},n);c.set(s,y)}let T=null;function x(){if(A())return;let o=S(document),s=document.querySelector("template[data-krate-loading]");s&&s.content&&o&&(T=s.content.cloneNode(!0),document.body.appendChild(T)),o&&(o.style.transition=`opacity ${t}ms ease`,o.style.opacity="0")}function Y(){if(A())return;T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let o=S(document);o&&(o.style.opacity="1")}function C(o){try{let s=globalThis.__krate_onNavigation;typeof s=="function"&&s(o)}catch{}}function V(o,s){try{window.dispatchEvent(new CustomEvent(o,{detail:{url:s}}))}catch{}}function A(){if(Be().viewTransitions===!1)return!1;if(typeof window<"u"&&window.matchMedia)try{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return typeof document.startViewTransition=="function"}function Je(o){let s=o.querySelectorAll('link[rel="stylesheet"]'),u=new Set;s.forEach(m=>{let y=m.getAttribute("href");y&&u.add(new URL(y,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>{let y=m.href;y&&!u.has(y)&&m.remove()});let d=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>d.add(m.href)),s.forEach(m=>{let y=m.getAttribute("href");if(!y)return;let E=new URL(y,location.origin).href;if(!d.has(E)){let R=document.createElement("link");R.rel="stylesheet",R.href=E,document.head.appendChild(R)}})}function Te(o){o.querySelectorAll("[data-view-transition]").forEach(s=>{let u=s.getAttribute("data-view-transition");u&&(s.style.viewTransitionName=u)})}function Xe(){let o=S(document);if(o){o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1");try{o.focus({preventScroll:!0})}catch{try{o.focus()}catch{}}}}function Ge(){let o=HTMLScriptElement.supports;if(!(typeof o!="function"||!o("speculationrules")))try{let s=document.createElement("script");s.type="speculationrules",s.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(s)}catch{}}function ve(o){return o.getElementById("root")||o.body}let be='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Qe(o){document.head.querySelectorAll(be).forEach(s=>s.remove()),o.head.querySelectorAll(be).forEach(s=>{document.head.appendChild(document.importNode(s,!0))})}function xe(o,s,u,d={}){let{replace:m=!1,scroll:y=!0,restoreScroll:E=!1}=d,M=new DOMParser().parseFromString(o,"text/html"),Re=ve(M),Le=ve(document);if(!Re||!Le){location.href=s;return}V("krate:navigate-start",s);let X=()=>{let w=M.querySelector("title");w&&(document.title=w.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let q=Array.from(Re.childNodes).map(ct=>document.importNode(ct,!0));Le.replaceChildren(...q),Je(M),Qe(M),Te(document)};if(A())try{let w=document.startViewTransition(X);w&&w.finished&&typeof w.finished.catch=="function"&&w.finished.catch(()=>{})}catch{X()}else X();et(u,s).then(()=>{try{nt(),g()}catch(w){try{let q=globalThis.__krate_onHydrationError;typeof q=="function"&&q(w)}catch{}location.href=s}}),Y();let st=location.pathname+location.search;if(m)history.replaceState({},"",s);else{if(!E){if(I.size>=Wt){let w=I.keys().next().value;w!==void 0&&I.delete(w)}I.set(st,window.scrollY)}history.pushState({},"",s)}Ee(s,{restoreScroll:E,scroll:y}),E||Xe(),we(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}})),V("krate:navigate-end",s),C(s)}function Ze(o){let s=o.indexOf("#");if(s<0||s===o.length-1)return!1;let u=o.slice(s);try{let d=document.querySelector(u);if(d)return d.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function Ee(o,s){if(s.restoreScroll){let u=I.get(o);if(u!==void 0){window.scrollTo(0,u);return}}Ze(o)||s.scroll&&window.scrollTo(0,0)}function we(){let o=Ue(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(s=>{let u=s.getAttribute("href");if(!u){s.removeAttribute("aria-current");return}let d=u;try{d=Ue(new URL(u,location.origin).pathname)}catch{return}d===o||o==="/"&&(d===""||d==="/")||d!=="/"&&d.length>1&&o.startsWith(d)?s.setAttribute("aria-current","page"):s.removeAttribute("aria-current")})}function et(o,s){return o.length===0?Promise.resolve():Promise.all(o.map(u=>{let d=u.getAttribute("src");return d?tt(d,s):Promise.resolve()})).then(()=>{})}function tt(o,s){return new Promise(u=>{let d=document.createElement("script"),m=ke(o,s);d.src=m,ze.test(m)||d.setAttribute("data-krate-spa",""),d.onload=()=>u(),d.onerror=()=>u(),document.body.appendChild(d)})}function ke(o,s){if(/^(https?:)?\/\//.test(o)||o.startsWith("/"))return new URL(o,s).href;let u=s;if(!u.endsWith("/")){let d=u.lastIndexOf("/");u=d>0?u.slice(0,d+1):"/"}return new URL(o,u).href}function nt(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function rt(o,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),C(s),document.open(),document.write(o),document.close()}function ot(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(r=o,o)).catch(()=>null)}function it(){return i!==null?Promise.resolve(i):fetch("/500.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(i=o,o)).catch(()=>null)}function Ce(o,s){document.querySelectorAll("script[data-krate-spa]").forEach(m=>m.remove());let u=[],d=new Set;return document.querySelectorAll("script[src]").forEach(m=>{d.add(m.src)}),o.querySelectorAll("script[src]").forEach(m=>{let y=m.getAttribute("src");y&&!d.has(ke(y,s))&&u.push(m)}),u}function J(o,s={}){let u=++B,d=P.get(o);if(d){let E=new DOMParser().parseFromString(d,"text/html");xe(d,o,Ce(E,o),s);return}x(),K&&K.abort(),K=new AbortController;let m=K.signal;fetch(o,{headers:{Accept:"text/html"},signal:m}).then(y=>{if(u===B)return y.ok?y.text().then(E=>{if(u!==B)return;let M=new DOMParser().parseFromString(E,"text/html");xe(E,o,Ce(M,o),s)}):(y.status>=500?it():ot()).then(R=>{u===B&&(R?rt(R,o):location.href=o)})}).catch(y=>{y?.name!=="AbortError"&&(Y(),location.href=o)}).finally(()=>{K&&!m.aborted&&(K=void 0)})}let Ne=o=>{if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;let s=o.target.closest("a[data-krate-link]");if(!s||!f(s))return;o.preventDefault();let u=s.getAttribute("href");if(!u)return;let d=new URL(u,location.origin).href,m=s.hasAttribute("data-krate-replace"),y=s.getAttribute("data-krate-scroll")!=="false";if(u===location.pathname+location.search+location.hash){m&&history.replaceState({},"",u),Ee(d,{scroll:y});return}J(d,{replace:m,scroll:y})},Ae=()=>{J(location.href,{restoreScroll:!0})};document.addEventListener("click",Ne),window.addEventListener("popstate",Ae),h(),Ge(),we(),Te(document),$=(o,s={})=>{let u=!0;try{u=new URL(o,location.href).origin===location.origin}catch{u=!1}if(!u){location.href=o;return}J(new URL(o,location.href).href,s)},document.querySelectorAll("script[src]").forEach(o=>{ze.test(o.src)||o.setAttribute("data-krate-spa","")}),W=()=>{document.removeEventListener("click",Ne),window.removeEventListener("popstate",Ae),p(),$=null}}function Jt(){W&&(W(),W=null),he=!1,We()}function me(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)me(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function ye(...e){let t=[];for(let n of e)me(n,t);return t.join(" ")}function Se(...e){let t=[];for(let i of e)me(i,t);let n=new Map,r=[];for(let i of t){let c=Xt(i);n.has(c)||r.push(c),n.set(c,i)}return r.map(i=>n.get(i)).join(" ")}function Xt(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let i=t.indexOf("-"),c=i>=0?t.slice(0,i):t,a=i>=0?t.slice(i+1,i+2):"";return n+c+(a&&/[0-9]/.test(a)?"-"+a:"")}function Gt(...e){return Se(ye(...e))}function Qt(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return i=>{let c={};for(let f of Object.keys(n)){let l=i?.[f]??r[f];l!=null&&(c[f]=String(l))}let a=[e];for(let f of Object.keys(n)){let l=c[f];l&&n[f][l]&&a.push(n[f][l])}for(let f of t?.compoundVariants??[])if(Zt(f,c,r)){let l=f.class;typeof l=="string"&&a.push(l)}let S=i?.class??i?.className;return typeof S=="string"&&a.push(S),Se(ye(a))}}function Zt(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let i=e[r],c=t[r]??n[r]??void 0;if(Array.isArray(i)){if(!i.includes(c))return!1}else if(i!==c)return!1}return!0}function en(e){let t=$e(e?.children);return t?(Ye(t,e),t):null}function $e(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=$e(t);if(n)return n}return null}return e instanceof Node?e:null}function Ye(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let i=e.getAttribute("class"),c=i?i+" "+String(r):String(r);e.setAttribute("class",c);continue}if(n==="style"&&typeof r=="object"){for(let[i,c]of Object.entries(r))e.style.setProperty(tn(i),String(c));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function tn(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function nn(e,t,...n){if(!(e instanceof Node))return e;if(t&&Ye(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}return pt(rn);})();
1
+ var __krate_exports=(()=>{var Q=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var ht=Object.prototype.hasOwnProperty;var mt=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},yt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of gt(t))!ht.call(e,s)&&s!==n&&Q(e,s,{get:()=>t[s],enumerable:!(r=pt(t,s))||r.enumerable});return e};var St=e=>yt(Q({},"__esModule",{value:!0}),e);var un={};mt(un,{Slot:()=>cn,clearNodes:()=>Fe,clearPersisted:()=>xt,cloneElement:()=>ln,clsx:()=>ve,cn:()=>rn,conditional:()=>Xt,createCSSChoice:()=>Ct,createCSSFlags:()=>Nt,createCSSGroup:()=>Rt,createCSSRange:()=>Lt,createCSSStack:()=>Pt,createCSSToggle:()=>At,createContext:()=>ee,createEffect:()=>A,createMemo:()=>Kt,createReducer:()=>It,createResource:()=>Wt,createScope:()=>bt,createScopeFlags:()=>vt,createSignal:()=>E,cva:()=>on,disposeAll:()=>kt,disposeNode:()=>C,forwardRef:()=>Vt,h:()=>zt,hydrate:()=>Bt,initRouter:()=>Ge,insert:()=>Ft,mount:()=>Ut,navigate:()=>en,onCleanup:()=>U,onMount:()=>Ot,pageAssetURLs:()=>Je,readDurableState:()=>oe,readPersisted:()=>ie,reconcile:()=>$t,reconcileTrees:()=>Yt,reinitRouter:()=>tn,resetContexts:()=>Z,resolvePersist:()=>re,subscribePersist:()=>ce,twMerge:()=>Ee,useRef:()=>qt,writePersisted:()=>se});var Tt=0,M=new Map;function Z(){for(let[e,t]of M)if(t.length>0){let n=t[0];M.set(e,[n])}}function bt(){return ee({})}function vt(){return ee({})}function ee(e){let t=Tt++;M.set(t,[e]);let n=()=>{let r=M.get(t);return r&&r.length>0?r[r.length-1]:e};return{id:t,defaultValue:e,Provider:r=>{let s=M.get(t)||[e];s.push(r.value),M.set(t,s);let c=document.createElement("div");if(c.style.display="contents",r.children)for(let l of r.children)l instanceof Node?c.appendChild(l):l!=null&&c.appendChild(document.createTextNode(String(l)));return s.pop(),s.length===0&&s.push(e),c},useContext:n,use:n}}function Et(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var te=Et();function Ie(){return typeof window<"u"}function ne(e){if(e&&typeof e=="object")return e;if(!Ie())return te;try{return e==="session"?window.sessionStorage:e==="memory"?te:window.localStorage}catch{return te}}function re(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function oe(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let s=r[e];if(typeof s=="string")try{return{found:!0,value:t(s)}}catch{return{found:!0,value:s}}return{found:!0,value:s}}function ie(e){let t=ne(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function se(e,t){let n=ne(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function xt(e){let t=ne(e.store);try{t.removeItem(e.key)}catch{}}var D=new Map,Ke=!1;function wt(){Ke||!Ie()||(Ke=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=D.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function ce(e,t){if(!e.sync)return()=>{};let n=D.get(e.key)??new Set;return n.add(t),D.set(e.key,n),wt(),()=>{n.delete(t),n.size===0&&D.delete(e.key)}}var R=[],qe=[],ae=!1,O=new Set,le=[],ue=[],j=!1;function Ve(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function fe(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function kt(){for(let n of O)fe(n);O.clear();for(let n of le)try{n()}catch{}le.length=0;let e=globalThis,t=e.__krate_island_cleanups;if(Array.isArray(t)){e.__krate_island_cleanups=[];for(let n of t)try{n()}catch{}}ue.length=0,j=!1,Z()}function Ct(e,t){return z(E(e))}function At(e,t){return z(E(e))}function Nt(e,t){let n={};for(let c of e){let[l]=E(!1);n[c]=l}let s=[n,(c,l)=>{}];return s.trigger=c=>({"data-krate-scope":"trigger",value:c}),s.panel=c=>({"data-krate-scope":"panel",value:c}),s.close=()=>({"data-krate-scope":"close"}),s}function Rt(e,t){return z(E(e))}function Lt(e,t){return z(E(e))}function z(e){let t=e;return t.trigger=n=>({"data-krate-scope":"trigger",value:n}),t.panel=n=>({"data-krate-scope":"panel",value:n}),t.close=()=>({"data-krate-scope":"close"}),t.current=()=>e[0](),t}function Pt(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function E(e,t){let n=e,r=null;if(t?.persist){r=re(t.persist);let a=oe(r.key,r.deserialize);if(a.found)n=a.value;else{let f=ie(r);f.found&&(n=f.value)}}let s=new Set,c=()=>{let a=R[R.length-1];return a&&!a.disposed&&(s.add(a),a.sources.add(s)),n},l=()=>{let a=Array.from(s);for(let f of a){if(f.disposed){s.delete(f);continue}if(f.running){f.rerun=!0;continue}f.queued||(f.queued=!0,ue.push(f))}_t()},y=a=>{let f=typeof a=="function"?a(n):a;f!==n&&(n=f,r&&se(r,n),l())};if(r&&r.sync){let a=r,f=ce(a,h=>{if(h!==null)try{let d=a.deserialize(h);d!==n&&(n=d,l())}catch{}});U(f)}return[c,y]}function _t(){j||(j=!0,queueMicrotask(Mt))}function Mt(){j=!1;let e=ue.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,F(t),t.rerun&&!t.disposed&&(t.rerun=!1,F(t)))}function F(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,R.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{R.pop(),e.running=!1}}function A(e){let t=Ve(e);return O.add(t),F(t),()=>{fe(t),O.delete(t)}}function U(e){let t=R[R.length-1];t?t.cleanups.push(e):le.push(e)}function Ot(e){qe.push(e),ae||(ae=!0,queueMicrotask(Ht))}function Ht(){ae=!1;let e=qe.splice(0);for(let t of e)t()}function Kt(e){let[t,n]=E(void 0),r=Ve(()=>{let c=e();n(c)});O.add(r),F(r);let s=R[R.length-1];return s&&s.cleanups.push(()=>{r.disposed||(fe(r),O.delete(r))}),t}function It(e,t){let[n,r]=E(t);return[n,c=>r(l=>e(l,c))]}function qt(e){return{current:e}}function Vt(e){return t=>e(t,t.ref||(()=>{}))}var Dt={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},de=new WeakMap;function je(e,t){let n=de.get(e);n||(n=[],de.set(e,n)),n.push(t)}function C(e){let t=de.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)C(e.childNodes[n])}function jt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Fe(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let s=r.nextSibling;C(r),n.removeChild(r),r=s}}function Ft(e,t,n){let r=jt(n);r?(Fe(n,r),pe(e,t,r)):pe(e,t,null)}function pe(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)pe(e,r,n)}}function De(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),s=Dt[r]||r,c=`__krate_${s}`,l=e[c];l&&e.removeEventListener(s,l),e.addEventListener(s,n),e[c]=n}else t==="value"||t==="checked"||t==="selected"?t==="value"?e.value=n==null||n===!1?"":n:e[t]=!!n:t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function ze(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)ze(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),je(n,A(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function zt(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[s,c]of Object.entries(t))typeof c=="function"&&!s.startsWith("on")?je(r,A(()=>De(r,s,c()))):De(r,s,c);for(let s of n)ze(r,s);return r}function Ue(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function Ut(e,t){let n=Ue(t),r=!1;A(()=>{r||(r=!0,n.appendChild(e()))})}function Bt(e,t){let n=Ue(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&C(r)}function Wt(e,t){let[n,r]=E(void 0),[s,c]=E(!0),[l,y]=E(void 0),[a,f]=E("unresolved"),[h,d]=E(0),g,T=()=>typeof e=="function"?e():e,v=async()=>{g&&g.abort(),g=new AbortController;let b=g,X=T();f(h()>0?"refreshing":"loading"),c(!0),y(void 0);try{let L=await t(X,{signal:b.signal});b.signal.aborted||(r(()=>L),f("ready"))}catch(L){L?.name!=="AbortError"&&!b.signal.aborted&&(y(L),f("error"))}finally{b.signal.aborted||c(!1)}};A(()=>{typeof e=="function"&&e.length===0&&e(),h(),v(),U(()=>{g&&(g.abort(),g=void 0)})});let x=function(){return n()};return Object.defineProperties(x,{loading:{get:()=>s()},error:{get:()=>l()},state:{get:()=>a()}}),[x,{mutate:b=>{r(b)},refetch:()=>{d(b=>b+1)}}]}function $t(e,t,n,r,s,c){let l=[],y=t.nextSibling;for(;y&&y!==n;)l.push(y),y=y.nextSibling;if(c){let a=new Map;for(let d of l){let g=d.__k;g!=null&&!a.has(g)&&a.set(g,d)}let f=[];for(let d=0;d<r.length;d++){let g=c(r[d]),T=a.get(g);T?a.delete(g):(T=s(r[d],d),T.__k=g),f.push(T)}for(let d of a.values())d.parentNode===e&&(C(d),e.removeChild(d));let h=0;for(;h<f.length;){let d=h===0?t:f[h-1];if(f[h].parentNode!==e){let g=document.createDocumentFragment(),T=d.nextSibling;do g.appendChild(f[h]),h++;while(h<f.length&&f[h].parentNode!==e);e.insertBefore(g,T)}else f[h]!==d.nextSibling&&e.insertBefore(f[h],d.nextSibling),h++}}else{let a=l.length,f=Math.min(a,r.length);for(let h=0;h<f;h++){let d=s(r[h],h);l[h]!==d&&(C(l[h]),e.replaceChild(d,l[h]))}for(let h=r.length;h<a;h++)l[h].parentNode===e&&(C(l[h]),e.removeChild(l[h]));if(r.length>a){let h=document.createDocumentFragment();for(let d=a;d<r.length;d++)h.appendChild(s(r[d],d));e.insertBefore(h,n)}}}function Xt(e,t,n,r,s,c){let l=null;A(()=>{let a=r()?s():c?c():null;l?a?(C(l),e.replaceChild(a,l)):(C(l),e.removeChild(l)):a&&e.insertBefore(a,n),l=a})}function H(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function Be(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let s=t.attributes[r].name,c=t.attributes[r].value;n.add(s),e.getAttribute(s)!==c&&e.setAttribute(s,c)}for(let r=0;r<e.attributes.length;r++){let s=e.attributes[r].name;n.has(s)||e.removeAttribute(s)}}function ge(e,t){let n=document.importNode(t,!0);return e.parentNode&&(C(e),e.parentNode.replaceChild(n,e)),n}function We(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function he(e,t){if(!We(e,t))return ge(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?ge(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return H(n)!==H(r)?ge(n,r):(Be(n,r),$e(n,r),n)}function $e(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let d=!0;for(let g=0;g<r.length;g++)if(H(n[g])!==H(r[g])){d=!1;break}if(d){for(let g=0;g<r.length;g++)he(n[g],r[g]);return}}let s=new Map,c=[];n.forEach((d,g)=>{let T=H(d);T!=null?s.has(T)||s.set(T,g):c.push(g)});let l=new Set,y=0,a=null,f=0,h=()=>{for(;f<c.length&&l.has(c[f]);)f++;return f<c.length?c[f]:-1};for(let d of r){let g=H(d),T;if(g!=null&&s.has(g)){let v=s.get(g);s.delete(g),l.add(v);let x=n[v];v<y?e.insertBefore(x,a):y=v,T=he(x,d)}else if(g==null){let v=h();if(v>=0&&We(n[v],d)){l.add(v);let x=n[v];x.parentNode===e&&x.nextSibling!==a&&e.insertBefore(x,a),T=he(x,d)}else T=document.importNode(d,!0),e.insertBefore(T,a)}else T=document.importNode(d,!0),e.insertBefore(T,a);a=T.nextSibling}n.forEach((d,g)=>{!l.has(g)&&d.parentNode===e&&(C(d),e.removeChild(d))})}function Yt(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let s=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(s,n);return}Be(n,r),$e(n,r)}var ye=!1,K,W=null,B=0,P=new Map,Jt=30,q=new Map,Gt=50,Se=/\/chunks\/runtime\.[^/]+\.js$/;function Ye(){return globalThis.__KRATE_CFG__||{}}function Qt(){let e=Ye().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function Xe(e){let t=Qt();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var $=null;function Te(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}var me=new Set,Zt=128;function Je(e,t,n){let r=new DOMParser().parseFromString(e,"text/html"),s=[],c=new Set,l=y=>{if(!y)return;let a;try{a=Te(y,t)}catch{return}c.has(a)||n.has(a)||Se.test(a)||(c.add(a),s.push(a))};return r.querySelectorAll("script[src]").forEach(y=>l(y.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(y=>l(y.getAttribute("href"))),s}function en(e,t={}){return $?($(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function Ge(){if(typeof document>"u"||ye)return;ye=!0;let e="#root, main, .docs-content",t=150,n=200,r=null,s=null,c=new Map,l=null;function y(o){for(let i of e.split(", ")){let u=o.querySelector(i.trim());if(u)return u}return o.body}function a(o){if(o.hasAttribute("data-krate-external"))return!1;let i=o.getAttribute("href");return!(!i||i.startsWith("#")||i.startsWith("javascript:")||o.origin!==location.origin||o.target==="_blank")}function f(o){let i=window.requestIdleCallback;typeof i=="function"?i(o,{timeout:1e3}):setTimeout(o,50)}function h(o){let i=o.getAttribute("data-prefetch");return o.hasAttribute("data-prefetch")&&i!=="false"&&i!=="0"}function d(o){if(me.has(o)||me.size>=Zt)return;me.add(o);let i=document.createElement("link");i.rel="prefetch",i.as="script",i.href=o,document.head.appendChild(i)}function g(o){P.has(o)||fetch(o,{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>{if(!i)return;if(P.size>=Jt){let p=P.keys().next().value;p!==void 0&&P.delete(p)}P.set(o,i);let u=new Set;document.querySelectorAll("script[src]").forEach(p=>u.add(p.src));for(let p of Je(i,o,u))d(p)}).catch(()=>{})}function T(){document.addEventListener("mouseover",I),document.addEventListener("focusin",I),typeof IntersectionObserver<"u"&&(l=new IntersectionObserver(o=>{for(let i of o)if(i.isIntersecting){let u=i.target,p=u.getAttribute("href");if(p&&a(u)&&h(u)){let m=new URL(p,location.origin).href;f(()=>g(m))}l.unobserve(i.target)}},{rootMargin:"200px"}),v())}function v(){l&&document.querySelectorAll("a[data-prefetch]").forEach(o=>{h(o)&&l.observe(o)})}function x(){document.removeEventListener("mouseover",I),document.removeEventListener("focusin",I);for(let o of c.values())clearTimeout(o);c.clear(),l&&(l.disconnect(),l=null)}function I(o){let i=o.target.closest("a[data-prefetch]");if(!i||!h(i)||!a(i))return;let u=i.getAttribute("href");if(!u)return;let p=new URL(u,location.origin).href;if(P.has(p))return;let m=c.get(i);m&&clearTimeout(m);let S=setTimeout(()=>{c.delete(i),g(p)},n);c.set(i,S)}let b=null;function X(){if(Y())return;let o=y(document),i=document.querySelector("template[data-krate-loading]");i&&i.content&&o&&(b=i.content.cloneNode(!0),document.body.appendChild(b)),o&&(o.style.transition=`opacity ${t}ms ease`,o.style.opacity="0")}function L(){if(Y())return;b&&b.parentNode&&b.parentNode.removeChild(b),b=null;let o=y(document);o&&(o.style.opacity="1")}function xe(o){try{let i=globalThis.__krate_onNavigation;typeof i=="function"&&i(o)}catch{}}function we(o,i){try{window.dispatchEvent(new CustomEvent(o,{detail:{url:i}}))}catch{}}function Y(){if(Ye().viewTransitions===!1)return!1;if(typeof window<"u"&&window.matchMedia)try{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return typeof document.startViewTransition=="function"}function et(o){let i=o.querySelectorAll('link[rel="stylesheet"]'),u=new Set;i.forEach(m=>{let S=m.getAttribute("href");S&&u.add(new URL(S,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>{let S=m.href;S&&!u.has(S)&&m.remove()});let p=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>p.add(m.href)),i.forEach(m=>{let S=m.getAttribute("href");if(!S)return;let w=new URL(S,location.origin).href;if(!p.has(w)){let N=document.createElement("link");N.rel="stylesheet",N.href=w,document.head.appendChild(N)}})}function ke(o){o.querySelectorAll("[data-view-transition]").forEach(i=>{let u=i.getAttribute("data-view-transition");u&&(i.style.viewTransitionName=u)})}function tt(){let o=y(document);if(o){o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1");try{o.focus({preventScroll:!0})}catch{try{o.focus()}catch{}}}}function nt(){let o=HTMLScriptElement.supports;if(!(typeof o!="function"||!o("speculationrules")))try{let i=document.createElement("script");i.type="speculationrules",i.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(i)}catch{}}function Ce(o){return o.getElementById("root")||o.body}let Ae='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function rt(o){document.head.querySelectorAll(Ae).forEach(i=>i.remove()),o.head.querySelectorAll(Ae).forEach(i=>{document.head.appendChild(document.importNode(i,!0))})}function Ne(o,i,u,p={}){let{replace:m=!1,scroll:S=!0,restoreScroll:w=!1}=p,_=new DOMParser().parseFromString(o,"text/html"),Oe=Ce(_),He=Ce(document);if(!Oe||!He){location.href=i;return}we("krate:navigate-start",i);let G=()=>{let k=_.querySelector("title");k&&(document.title=k.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let V=Array.from(Oe.childNodes).map(dt=>document.importNode(dt,!0));He.replaceChildren(...V),et(_),rt(_),ke(document)};if(Y())try{let k=document.startViewTransition(G);k&&k.finished&&typeof k.finished.catch=="function"&&k.finished.catch(()=>{})}catch{G()}else G();it(u,i).then(()=>{try{ct(),v()}catch(k){try{let V=globalThis.__krate_onHydrationError;typeof V=="function"&&V(k)}catch{}location.href=i}}),L();let ft=location.pathname+location.search;if(m)history.replaceState({},"",i);else{if(!w){if(q.size>=Gt){let k=q.keys().next().value;k!==void 0&&q.delete(k)}q.set(ft,window.scrollY)}history.pushState({},"",i)}Re(i,{restoreScroll:w,scroll:S}),w||tt(),Le(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:i}})),we("krate:navigate-end",i),xe(i)}function ot(o){let i=o.indexOf("#");if(i<0||i===o.length-1)return!1;let u=o.slice(i);try{let p=document.querySelector(u);if(p)return p.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function Re(o,i){if(i.restoreScroll){let u=q.get(o);if(u!==void 0){window.scrollTo(0,u);return}}ot(o)||i.scroll&&window.scrollTo(0,0)}function Le(){let o=Xe(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(i=>{let u=i.getAttribute("href");if(!u){i.removeAttribute("aria-current");return}let p=u;try{p=Xe(new URL(u,location.origin).pathname)}catch{return}p===o||o==="/"&&(p===""||p==="/")||p!=="/"&&p.length>1&&o.startsWith(p)?i.setAttribute("aria-current","page"):i.removeAttribute("aria-current")})}function it(o,i){return o.length===0?Promise.resolve():Promise.all(o.map(u=>{let p=u.getAttribute("src");return p?st(p,i):Promise.resolve()})).then(()=>{})}function st(o,i){return new Promise(u=>{let p=document.createElement("script"),m=Te(o,i);p.src=m,Se.test(m)||p.setAttribute("data-krate-spa",""),p.onload=()=>u(),p.onerror=()=>u(),document.body.appendChild(p)})}function ct(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function at(o,i){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",i),xe(i),document.open(),document.write(o),document.close()}function lt(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(r=o,o)).catch(()=>null)}function ut(){return s!==null?Promise.resolve(s):fetch("/500.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(s=o,o)).catch(()=>null)}function Pe(o,i){document.querySelectorAll("script[data-krate-spa]").forEach(m=>m.remove());let u=[],p=new Set;return document.querySelectorAll("script[src]").forEach(m=>{p.add(m.src)}),o.querySelectorAll("script[src]").forEach(m=>{let S=m.getAttribute("src");S&&!p.has(Te(S,i))&&u.push(m)}),u}function J(o,i={}){let u=++B,p=P.get(o);if(p){let w=new DOMParser().parseFromString(p,"text/html");Ne(p,o,Pe(w,o),i);return}X(),K&&K.abort(),K=new AbortController;let m=K.signal;fetch(o,{headers:{Accept:"text/html"},signal:m}).then(S=>{if(u===B)return S.ok?S.text().then(w=>{if(u!==B)return;let _=new DOMParser().parseFromString(w,"text/html");Ne(w,o,Pe(_,o),i)}):(S.status>=500?ut():lt()).then(N=>{u===B&&(N?at(N,o):location.href=o)})}).catch(S=>{S?.name!=="AbortError"&&(L(),location.href=o)}).finally(()=>{K&&!m.aborted&&(K=void 0)})}let _e=o=>{if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;let i=o.target.closest("a[data-krate-link]");if(!i||!a(i))return;o.preventDefault();let u=i.getAttribute("href");if(!u)return;let p=new URL(u,location.origin).href,m=i.hasAttribute("data-krate-replace"),S=i.getAttribute("data-krate-scroll")!=="false";if(u===location.pathname+location.search+location.hash){m&&history.replaceState({},"",u),Re(p,{scroll:S});return}J(p,{replace:m,scroll:S})},Me=()=>{J(location.href,{restoreScroll:!0})};document.addEventListener("click",_e),window.addEventListener("popstate",Me),T(),nt(),Le(),ke(document),$=(o,i={})=>{let u=!0;try{u=new URL(o,location.href).origin===location.origin}catch{u=!1}if(!u){location.href=o;return}J(new URL(o,location.href).href,i)},document.querySelectorAll("script[src]").forEach(o=>{Se.test(o.src)||o.setAttribute("data-krate-spa","")}),W=()=>{document.removeEventListener("click",_e),window.removeEventListener("popstate",Me),x(),$=null}}function tn(){W&&(W(),W=null),ye=!1,Ge()}function be(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)be(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function ve(...e){let t=[];for(let n of e)be(n,t);return t.join(" ")}function Ee(...e){let t=[];for(let s of e)be(s,t);let n=new Map,r=[];for(let s of t){let c=nn(s);n.has(c)||r.push(c),n.set(c,s)}return r.map(s=>n.get(s)).join(" ")}function nn(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let s=t.indexOf("-"),c=s>=0?t.slice(0,s):t,l=s>=0?t.slice(s+1,s+2):"";return n+c+(l&&/[0-9]/.test(l)?"-"+l:"")}function rn(...e){return Ee(ve(...e))}function on(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return s=>{let c={};for(let a of Object.keys(n)){let f=s?.[a]??r[a];f!=null&&(c[a]=String(f))}let l=[e];for(let a of Object.keys(n)){let f=c[a];f&&n[a][f]&&l.push(n[a][f])}for(let a of t?.compoundVariants??[])if(sn(a,c,r)){let f=a.class;typeof f=="string"&&l.push(f)}let y=s?.class??s?.className;return typeof y=="string"&&l.push(y),Ee(ve(l))}}function sn(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let s=e[r],c=t[r]??n[r]??void 0;if(Array.isArray(s)){if(!s.includes(c))return!1}else if(s!==c)return!1}return!0}function cn(e){let t=Qe(e?.children);return t?(Ze(t,e),t):null}function Qe(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=Qe(t);if(n)return n}return null}return e instanceof Node?e:null}function Ze(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let s=e.getAttribute("class"),c=s?s+" "+String(r):String(r);e.setAttribute("class",c);continue}if(n==="style"&&typeof r=="object"){for(let[s,c]of Object.entries(r))e.style.setProperty(an(s),String(c));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function an(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function ln(e,t,...n){if(!(e instanceof Node))return e;if(t&&Ze(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}return St(un);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var Q=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var ft=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},bt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dt(t))!gt.call(e,s)&&s!==n&&Q(e,s,{get:()=>t[s],enumerable:!(r=ct(t,s))||r.enumerable});return e};var mt=e=>bt(Q({},"__esModule",{value:!0}),e);var an={};ft(an,{Fragment:()=>zt,Slot:()=>rn,clearNodes:()=>Ke,clearPersisted:()=>Et,cloneElement:()=>on,clsx:()=>Te,cn:()=>en,conditional:()=>Wt,createCSSChoice:()=>Ht,createCSSFlags:()=>Lt,createCSSGroup:()=>St,createCSSRange:()=>xt,createCSSStack:()=>kt,createCSSToggle:()=>Mt,createContext:()=>ee,createEffect:()=>x,createMemo:()=>Rt,createReducer:()=>Ot,createResource:()=>qt,createScope:()=>ht,createScopeFlags:()=>Tt,createSignal:()=>y,cva:()=>tn,disposeAll:()=>At,disposeNode:()=>L,forwardRef:()=>_t,h:()=>U,hydrate:()=>Ft,initRouter:()=>Ge,insert:()=>Bt,jsx:()=>Fe,jsxs:()=>jt,mount:()=>Vt,navigate:()=>$t,onCleanup:()=>j,onMount:()=>Pt,readDurableState:()=>ie,readPersisted:()=>se,reconcile:()=>Ut,reconcileTrees:()=>Xt,reinitRouter:()=>Qt,resetContexts:()=>Z,resolvePersist:()=>re,subscribePersist:()=>ae,twMerge:()=>ve,useRef:()=>It,writePersisted:()=>oe});var pt=0,R=new Map;function Z(){for(let[e,t]of R)if(t.length>0){let n=t[0];R.set(e,[n])}}function ht(){return ee({})}function Tt(){return ee({})}function ee(e){let t=pt++;R.set(t,[e]);let n=()=>{let r=R.get(t);return r&&r.length>0?r[r.length-1]:e};return{id:t,defaultValue:e,Provider:r=>{let s=R.get(t)||[e];s.push(r.value),R.set(t,s);let a=document.createElement("div");if(a.style.display="contents",r.children)for(let u of r.children)u instanceof Node?a.appendChild(u):u!=null&&a.appendChild(document.createTextNode(String(u)));return s.pop(),s.length===0&&s.push(e),a},useContext:n,use:n}}function vt(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var te=vt();function Re(){return typeof window<"u"}function ne(e){if(e&&typeof e=="object")return e;if(!Re())return te;try{return e==="session"?window.sessionStorage:e==="memory"?te:window.localStorage}catch{return te}}function re(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function ie(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let s=r[e];if(typeof s=="string")try{return{found:!0,value:t(s)}}catch{return{found:!0,value:s}}return{found:!0,value:s}}function se(e){let t=ne(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function oe(e,t){let n=ne(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function Et(e){let t=ne(e.store);try{t.removeItem(e.key)}catch{}}var V=new Map,Ne=!1;function yt(){Ne||!Re()||(Ne=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=V.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function ae(e,t){if(!e.sync)return()=>{};let n=V.get(e.key)??new Set;return n.add(t),V.set(e.key,n),yt(),()=>{n.delete(t),n.size===0&&V.delete(e.key)}}var C=[],Oe=[],ue=!1,O=new Set,le=[],ce=[],F=!1;function Ie(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function de(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function At(){for(let e of O)de(e);O.clear();for(let e of le)try{e()}catch{}le.length=0,ce.length=0,F=!1,Z()}function Ht(e,t){return z(y(e))}function Mt(e,t){return z(y(e))}function Lt(e,t){let n={};for(let a of e){let[u]=y(!1);n[a]=u}let s=[n,(a,u)=>{}];return s.trigger=a=>({"data-krate-scope":"trigger",value:a}),s.panel=a=>({"data-krate-scope":"panel",value:a}),s.close=()=>({"data-krate-scope":"close"}),s}function St(e,t){return z(y(e))}function xt(e,t){return z(y(e))}function z(e){let t=e;return t.trigger=n=>({"data-krate-scope":"trigger",value:n}),t.panel=n=>({"data-krate-scope":"panel",value:n}),t.close=()=>({"data-krate-scope":"close"}),t.current=()=>e[0](),t}function kt(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function y(e,t){let n=e,r=null;if(t?.persist){r=re(t.persist);let d=ie(r.key,r.deserialize);if(d.found)n=d.value;else{let l=se(r);l.found&&(n=l.value)}}let s=new Set,a=()=>{let d=C[C.length-1];return d&&!d.disposed&&(s.add(d),d.sources.add(s)),n},u=()=>{let d=Array.from(s);for(let l of d){if(l.disposed){s.delete(l);continue}if(l.running){l.rerun=!0;continue}l.queued||(l.queued=!0,ce.push(l))}wt()},T=d=>{let l=typeof d=="function"?d(n):d;l!==n&&(n=l,r&&oe(r,n),u())};if(r&&r.sync){let d=r,l=ae(d,m=>{if(m!==null)try{let b=d.deserialize(m);b!==n&&(n=b,u())}catch{}});j(l)}return[a,T]}function wt(){F||(F=!0,queueMicrotask(Ct))}function Ct(){F=!1;let e=ce.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,q(t),t.rerun&&!t.disposed&&(t.rerun=!1,q(t)))}function q(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,C.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{C.pop(),e.running=!1}}function x(e){let t=Ie(e);return O.add(t),q(t),()=>{de(t),O.delete(t)}}function j(e){let t=C[C.length-1];t?t.cleanups.push(e):le.push(e)}function Pt(e){Oe.push(e),ue||(ue=!0,queueMicrotask(Nt))}function Nt(){ue=!1;let e=Oe.splice(0);for(let t of e)t()}function Rt(e){let[t,n]=y(void 0),r=Ie(()=>{let a=e();n(a)});O.add(r),q(r);let s=C[C.length-1];return s&&s.cleanups.push(()=>{r.disposed||(de(r),O.delete(r))}),t}function Ot(e,t){let[n,r]=y(t);return[n,a=>r(u=>e(u,a))]}function It(e){return{current:e}}function _t(e){return t=>e(t,t.ref||(()=>{}))}var Dt={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},ge=new WeakMap;function De(e,t){let n=ge.get(e);n||(n=[],ge.set(e,n)),n.push(t)}function L(e){let t=ge.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)L(e.childNodes[n])}function Kt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Ke(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let s=r.nextSibling;L(r),n.removeChild(r),r=s}}function Bt(e,t,n){let r=Kt(n);r?(Ke(n,r),fe(e,t,r)):fe(e,t,null)}function fe(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)fe(e,r,n)}}function _e(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),s=Dt[r]||r,a=`__krate_${s}`,u=e[a];u&&e.removeEventListener(s,u),e.addEventListener(s,n),e[a]=n}else t==="value"||t==="checked"||t==="selected"?t==="value"?e.value=n==null||n===!1?"":n:e[t]=!!n:t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function Be(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Be(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),De(n,x(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function U(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[s,a]of Object.entries(t))typeof a=="function"&&!s.startsWith("on")?De(r,x(()=>_e(r,s,a()))):_e(r,s,a);for(let s of n)Be(r,s);return r}function Ve(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function Vt(e,t){let n=Ve(t),r=!1;x(()=>{r||(r=!0,n.appendChild(e()))})}function Ft(e,t){let n=Ve(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&L(r)}function qt(e,t){let[n,r]=y(void 0),[s,a]=y(!0),[u,T]=y(void 0),[d,l]=y("unresolved"),[m,b]=y(0),f,E=()=>typeof e=="function"?e():e,v=async()=>{f&&f.abort(),f=new AbortController;let S=f,K=E();l(m()>0?"refreshing":"loading"),a(!0),T(void 0);try{let k=await t(K,{signal:S.signal});S.signal.aborted||(r(()=>k),l("ready"))}catch(k){k?.name!=="AbortError"&&!S.signal.aborted&&(T(k),l("error"))}finally{S.signal.aborted||a(!1)}};x(()=>{typeof e=="function"&&e.length===0&&e(),m(),v(),j(()=>{f&&(f.abort(),f=void 0)})});let A=function(){return n()};return Object.defineProperties(A,{loading:{get:()=>s()},error:{get:()=>u()},state:{get:()=>d()}}),[A,{mutate:S=>{r(S)},refetch:()=>{b(S=>S+1)}}]}function zt(e){let t=document.createDocumentFragment(),n=e.children;if(n){let r=Array.isArray(n)?n:[n];for(let s of r)s instanceof Node?t.appendChild(s):t.appendChild(document.createTextNode(String(s)))}return t}function Fe(e,t,n){let r=e;if(!t)return U(r,null);let{children:s,...a}=t,u=s!==void 0?Array.isArray(s)?s:[s]:[];return U(r,Object.keys(a).length>0?a:null,...u)}function jt(e,t,n){return Fe(e,t,n)}function Ut(e,t,n,r,s,a){let u=[],T=t.nextSibling;for(;T&&T!==n;)u.push(T),T=T.nextSibling;if(a){let d=new Map;for(let m of u){let b=m.__k;b!=null&&!d.has(b)&&d.set(b,m)}let l=[];for(let m=0;m<r.length;m++){let b=a(r[m]),f=d.get(b);f?d.delete(b):(f=s(r[m],m),f.__k=b),l.push(f)}for(let m of d.values())m.parentNode===e&&(L(m),e.removeChild(m));for(let m=0;m<l.length;m++){let b=m===0?t:l[m-1];l[m]!==b.nextSibling&&e.insertBefore(l[m],b.nextSibling)}}else{let d=Math.max(u.length,r.length);for(let l=0;l<d;l++)if(l<r.length){let m=s(r[l],l);l<u.length?u[l]!==m&&(L(u[l]),e.replaceChild(m,u[l])):e.insertBefore(m,n)}else l<u.length&&u[l].parentNode===e&&(L(u[l]),e.removeChild(u[l]))}}function Wt(e,t,n,r,s,a){let u=null;x(()=>{let d=r()?s():a?a():null;u?d?(L(u),e.replaceChild(d,u)):(L(u),e.removeChild(u)):d&&e.insertBefore(d,n),u=d})}function I(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function qe(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let s=t.attributes[r].name,a=t.attributes[r].value;n.add(s),e.getAttribute(s)!==a&&e.setAttribute(s,a)}for(let r=0;r<e.attributes.length;r++){let s=e.attributes[r].name;n.has(s)||e.removeAttribute(s)}}function be(e,t){let n=document.importNode(t,!0);return e.parentNode&&(L(e),e.parentNode.replaceChild(n,e)),n}function ze(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function me(e,t){if(!ze(e,t))return be(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?be(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return I(n)!==I(r)?be(n,r):(qe(n,r),je(n,r),n)}function je(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let b=!0;for(let f=0;f<r.length;f++)if(I(n[f])!==I(r[f])){b=!1;break}if(b){for(let f=0;f<r.length;f++)me(n[f],r[f]);return}}let s=new Map,a=[];n.forEach((b,f)=>{let E=I(b);E!=null?s.has(E)||s.set(E,f):a.push(f)});let u=new Set,T=0,d=null,l=0,m=()=>{for(;l<a.length&&u.has(a[l]);)l++;return l<a.length?a[l]:-1};for(let b of r){let f=I(b),E;if(f!=null&&s.has(f)){let v=s.get(f);s.delete(f),u.add(v);let A=n[v];v<T?e.insertBefore(A,d):T=v,E=me(A,b)}else if(f==null){let v=m();if(v>=0&&ze(n[v],b)){u.add(v);let A=n[v];A.parentNode===e&&A.nextSibling!==d&&e.insertBefore(A,d),E=me(A,b)}else E=document.importNode(b,!0),e.insertBefore(E,d)}else E=document.importNode(b,!0),e.insertBefore(E,d);d=E.nextSibling}n.forEach((b,f)=>{!u.has(f)&&b.parentNode===e&&(L(b),e.removeChild(b))})}function Xt(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let s=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(s,n);return}qe(n,r),je(n,r)}var pe=!1,_,X=null,W=0,P=new Map,Gt=30,D=new Map,Jt=50,Ue=/\/chunks\/runtime\.[^/]+\.js$/;function Xe(){return globalThis.__KRATE_CFG__||{}}function Yt(){let e=Xe().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function We(e){let t=Yt();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var G=null;function $t(e,t={}){return G?(G(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function Ge(){if(typeof document>"u"||pe)return;pe=!0;let e="#root, main, .docs-content",t=150,n=200,r=null,s=null,a=new Map,u=null;function T(i){for(let o of e.split(", ")){let c=i.querySelector(o.trim());if(c)return c}return i.body}function d(i){if(i.hasAttribute("data-krate-external"))return!1;let o=i.getAttribute("href");return!(!o||o.startsWith("#")||o.startsWith("javascript:")||i.origin!==location.origin||i.target==="_blank")}function l(i){P.has(i)||fetch(i,{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>{if(o){if(P.size>=Gt){let c=P.keys().next().value;c!==void 0&&P.delete(c)}P.set(i,o)}}).catch(()=>{})}function m(){document.addEventListener("mouseover",E),document.addEventListener("focusin",E),typeof IntersectionObserver<"u"&&(u=new IntersectionObserver(i=>{for(let o of i)if(o.isIntersecting){let c=o.target,g=c.getAttribute("href");if(g&&d(c)){let p=new URL(g,location.origin).href;l(p)}u.unobserve(o.target)}},{rootMargin:"200px"}),b())}function b(){u&&document.querySelectorAll("a[data-prefetch]").forEach(i=>{u.observe(i)})}function f(){document.removeEventListener("mouseover",E),document.removeEventListener("focusin",E);for(let i of a.values())clearTimeout(i);a.clear(),u&&(u.disconnect(),u=null)}function E(i){let o=i.target.closest("a[data-prefetch]");if(!o||!d(o))return;let c=o.getAttribute("href");if(!c)return;let g=new URL(c,location.origin).href;if(P.has(g))return;let p=a.get(o);p&&clearTimeout(p);let h=setTimeout(()=>{a.delete(o),l(g)},n);a.set(o,h)}let v=null;function A(){if(k())return;let i=T(document),o=document.querySelector("template[data-krate-loading]");o&&o.content&&i&&(v=o.content.cloneNode(!0),document.body.appendChild(v)),i&&(i.style.transition=`opacity ${t}ms ease`,i.style.opacity="0")}function J(){if(k())return;v&&v.parentNode&&v.parentNode.removeChild(v),v=null;let i=T(document);i&&(i.style.opacity="1")}function S(i){try{let o=globalThis.__krate_onNavigation;typeof o=="function"&&o(i)}catch{}}function K(i,o){try{window.dispatchEvent(new CustomEvent(i,{detail:{url:o}}))}catch{}}function k(){if(Xe().viewTransitions===!1)return!1;if(typeof window<"u"&&window.matchMedia)try{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return typeof document.startViewTransition=="function"}function $e(i){let o=i.querySelectorAll('link[rel="stylesheet"]'),c=new Set;o.forEach(p=>{let h=p.getAttribute("href");h&&c.add(new URL(h,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(p=>{let h=p.href;h&&!c.has(h)&&p.remove()});let g=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(p=>g.add(p.href)),o.forEach(p=>{let h=p.getAttribute("href");if(!h)return;let H=new URL(h,location.origin).href;if(!g.has(H)){let w=document.createElement("link");w.rel="stylesheet",w.href=H,document.head.appendChild(w)}})}function Ee(i){i.querySelectorAll("[data-view-transition]").forEach(o=>{let c=o.getAttribute("data-view-transition");c&&(o.style.viewTransitionName=c)})}function Qe(){let i=T(document);if(i){i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1");try{i.focus({preventScroll:!0})}catch{try{i.focus()}catch{}}}}function Ze(){let i=HTMLScriptElement.supports;if(!(typeof i!="function"||!i("speculationrules")))try{let o=document.createElement("script");o.type="speculationrules",o.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(o)}catch{}}function ye(i){return i.getElementById("root")||i.body}let Ae='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function et(i){document.head.querySelectorAll(Ae).forEach(o=>o.remove()),i.head.querySelectorAll(Ae).forEach(o=>{document.head.appendChild(document.importNode(o,!0))})}function He(i,o,c,g={}){let{replace:p=!1,scroll:h=!0,restoreScroll:H=!1}=g,N=new DOMParser().parseFromString(i,"text/html"),Ce=ye(N),Pe=ye(document);if(!Ce||!Pe){location.href=o;return}K("krate:navigate-start",o);let $=()=>{let M=N.querySelector("title");M&&(document.title=M.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let B=Array.from(Ce.childNodes).map(lt=>document.importNode(lt,!0));Pe.replaceChildren(...B),$e(N),et(N),Ee(document)};if(k())try{let M=document.startViewTransition($);M&&M.finished&&typeof M.finished.catch=="function"&&M.finished.catch(()=>{})}catch{$()}else $();nt(c,o).then(()=>{try{it(),b()}catch(M){try{let B=globalThis.__krate_onHydrationError;typeof B=="function"&&B(M)}catch{}location.href=o}}),J();let ut=location.pathname+location.search;if(p)history.replaceState({},"",o);else{if(!H){if(D.size>=Jt){let M=D.keys().next().value;M!==void 0&&D.delete(M)}D.set(ut,window.scrollY)}history.pushState({},"",o)}Me(o,{restoreScroll:H,scroll:h}),H||Qe(),Le(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:o}})),K("krate:navigate-end",o),S(o)}function tt(i){let o=i.indexOf("#");if(o<0||o===i.length-1)return!1;let c=i.slice(o);try{let g=document.querySelector(c);if(g)return g.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function Me(i,o){if(o.restoreScroll){let c=D.get(i);if(c!==void 0){window.scrollTo(0,c);return}}tt(i)||o.scroll&&window.scrollTo(0,0)}function Le(){let i=We(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(o=>{let c=o.getAttribute("href");if(!c){o.removeAttribute("aria-current");return}let g=c;try{g=We(new URL(c,location.origin).pathname)}catch{return}g===i||i==="/"&&(g===""||g==="/")||g!=="/"&&g.length>1&&i.startsWith(g)?o.setAttribute("aria-current","page"):o.removeAttribute("aria-current")})}function nt(i,o){return i.length===0?Promise.resolve():Promise.all(i.map(c=>{let g=c.getAttribute("src");return g?rt(g,o):Promise.resolve()})).then(()=>{})}function rt(i,o){return new Promise(c=>{let g=document.createElement("script"),p=Se(i,o);g.src=p,Ue.test(p)||g.setAttribute("data-krate-spa",""),g.onload=()=>c(),g.onerror=()=>c(),document.body.appendChild(g)})}function Se(i,o){if(/^(https?:)?\/\//.test(i)||i.startsWith("/"))return new URL(i,o).href;let c=o;if(!c.endsWith("/")){let g=c.lastIndexOf("/");c=g>0?c.slice(0,g+1):"/"}return new URL(i,c).href}function it(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function st(i,o){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",o),S(o),document.open(),document.write(i),document.close()}function ot(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(r=i,i)).catch(()=>null)}function at(){return s!==null?Promise.resolve(s):fetch("/500.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(s=i,i)).catch(()=>null)}function xe(i,o){document.querySelectorAll("script[data-krate-spa]").forEach(p=>p.remove());let c=[],g=new Set;return document.querySelectorAll("script[src]").forEach(p=>{g.add(p.src)}),i.querySelectorAll("script[src]").forEach(p=>{let h=p.getAttribute("src");h&&!g.has(Se(h,o))&&c.push(p)}),c}function Y(i,o={}){let c=++W,g=P.get(i);if(g){let H=new DOMParser().parseFromString(g,"text/html");He(g,i,xe(H,i),o);return}A(),_&&_.abort(),_=new AbortController;let p=_.signal;fetch(i,{headers:{Accept:"text/html"},signal:p}).then(h=>{if(c===W)return h.ok?h.text().then(H=>{if(c!==W)return;let N=new DOMParser().parseFromString(H,"text/html");He(H,i,xe(N,i),o)}):(h.status>=500?at():ot()).then(w=>{c===W&&(w?st(w,i):location.href=i)})}).catch(h=>{h?.name!=="AbortError"&&(J(),location.href=i)}).finally(()=>{_&&!p.aborted&&(_=void 0)})}let ke=i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;let o=i.target.closest("a[data-krate-link]");if(!o||!d(o))return;i.preventDefault();let c=o.getAttribute("href");if(!c)return;let g=new URL(c,location.origin).href,p=o.hasAttribute("data-krate-replace"),h=o.getAttribute("data-krate-scroll")!=="false";if(c===location.pathname+location.search+location.hash){p&&history.replaceState({},"",c),Me(g,{scroll:h});return}Y(g,{replace:p,scroll:h})},we=()=>{Y(location.href,{restoreScroll:!0})};document.addEventListener("click",ke),window.addEventListener("popstate",we),m(),Ze(),Le(),Ee(document),G=(i,o={})=>{let c=!0;try{c=new URL(i,location.href).origin===location.origin}catch{c=!1}if(!c){location.href=i;return}Y(new URL(i,location.href).href,o)},document.querySelectorAll("script[src]").forEach(i=>{Ue.test(i.src)||i.setAttribute("data-krate-spa","")}),X=()=>{document.removeEventListener("click",ke),window.removeEventListener("popstate",we),f(),G=null}}function Qt(){X&&(X(),X=null),pe=!1,Ge()}function he(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)he(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function Te(...e){let t=[];for(let n of e)he(n,t);return t.join(" ")}function ve(...e){let t=[];for(let s of e)he(s,t);let n=new Map,r=[];for(let s of t){let a=Zt(s);n.has(a)||r.push(a),n.set(a,s)}return r.map(s=>n.get(s)).join(" ")}function Zt(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let s=t.indexOf("-"),a=s>=0?t.slice(0,s):t,u=s>=0?t.slice(s+1,s+2):"";return n+a+(u&&/[0-9]/.test(u)?"-"+u:"")}function en(...e){return ve(Te(...e))}function tn(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return s=>{let a={};for(let d of Object.keys(n)){let l=s?.[d]??r[d];l!=null&&(a[d]=String(l))}let u=[e];for(let d of Object.keys(n)){let l=a[d];l&&n[d][l]&&u.push(n[d][l])}for(let d of t?.compoundVariants??[])if(nn(d,a,r)){let l=d.class;typeof l=="string"&&u.push(l)}let T=s?.class??s?.className;return typeof T=="string"&&u.push(T),ve(Te(u))}}function nn(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let s=e[r],a=t[r]??n[r]??void 0;if(Array.isArray(s)){if(!s.includes(a))return!1}else if(s!==a)return!1}return!0}function rn(e){let t=Je(e?.children);return t?(Ye(t,e),t):null}function Je(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=Je(t);if(n)return n}return null}return e instanceof Node?e:null}function Ye(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let s=e.getAttribute("class"),a=s?s+" "+String(r):String(r);e.setAttribute("class",a);continue}if(n==="style"&&typeof r=="object"){for(let[s,a]of Object.entries(r))e.style.setProperty(sn(s),String(a));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function sn(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function on(e,t,...n){if(!(e instanceof Node))return e;if(t&&Ye(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}return mt(an);})();
1
+ var __krate_exports=(()=>{var Z=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var ht=Object.prototype.hasOwnProperty;var Tt=(e,t)=>{for(var n in t)Z(e,n,{get:t[n],enumerable:!0})},vt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of pt(t))!ht.call(e,s)&&s!==n&&Z(e,s,{get:()=>t[s],enumerable:!(r=mt(t,s))||r.enumerable});return e};var Et=e=>vt(Z({},"__esModule",{value:!0}),e);var fn={};Tt(fn,{Fragment:()=>Gt,Slot:()=>cn,clearNodes:()=>ze,clearPersisted:()=>Lt,cloneElement:()=>gn,clsx:()=>ye,cn:()=>an,conditional:()=>$t,createCSSChoice:()=>kt,createCSSFlags:()=>Ct,createCSSGroup:()=>Pt,createCSSRange:()=>Nt,createCSSStack:()=>Rt,createCSSToggle:()=>wt,createContext:()=>te,createEffect:()=>x,createMemo:()=>Kt,createReducer:()=>Bt,createResource:()=>Xt,createScope:()=>yt,createScopeFlags:()=>Ht,createSignal:()=>y,cva:()=>un,disposeAll:()=>xt,disposeNode:()=>S,forwardRef:()=>Ft,h:()=>U,hydrate:()=>Wt,initRouter:()=>Ze,insert:()=>jt,jsx:()=>We,jsxs:()=>Jt,mount:()=>Ut,navigate:()=>rn,onCleanup:()=>j,onMount:()=>It,pageAssetURLs:()=>Qe,readDurableState:()=>se,readPersisted:()=>oe,reconcile:()=>Yt,reconcileTrees:()=>Qt,reinitRouter:()=>sn,resetContexts:()=>ee,resolvePersist:()=>ie,subscribePersist:()=>ue,twMerge:()=>He,useRef:()=>Vt,writePersisted:()=>ae});var At=0,R=new Map;function ee(){for(let[e,t]of R)if(t.length>0){let n=t[0];R.set(e,[n])}}function yt(){return te({})}function Ht(){return te({})}function te(e){let t=At++;R.set(t,[e]);let n=()=>{let r=R.get(t);return r&&r.length>0?r[r.length-1]:e};return{id:t,defaultValue:e,Provider:r=>{let s=R.get(t)||[e];s.push(r.value),R.set(t,s);let a=document.createElement("div");if(a.style.display="contents",r.children)for(let l of r.children)l instanceof Node?a.appendChild(l):l!=null&&a.appendChild(document.createTextNode(String(l)));return s.pop(),s.length===0&&s.push(e),a},useContext:n,use:n}}function Mt(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var ne=Mt();function Ke(){return typeof window<"u"}function re(e){if(e&&typeof e=="object")return e;if(!Ke())return ne;try{return e==="session"?window.sessionStorage:e==="memory"?ne:window.localStorage}catch{return ne}}function ie(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function se(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let s=r[e];if(typeof s=="string")try{return{found:!0,value:t(s)}}catch{return{found:!0,value:s}}return{found:!0,value:s}}function oe(e){let t=re(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function ae(e,t){let n=re(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function Lt(e){let t=re(e.store);try{t.removeItem(e.key)}catch{}}var V=new Map,De=!1;function St(){De||!Ke()||(De=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=V.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function ue(e,t){if(!e.sync)return()=>{};let n=V.get(e.key)??new Set;return n.add(t),V.set(e.key,n),St(),()=>{n.delete(t),n.size===0&&V.delete(e.key)}}var w=[],Be=[],le=!1,O=new Set,ce=[],de=[],F=!1;function Ve(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function ge(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function xt(){for(let n of O)ge(n);O.clear();for(let n of ce)try{n()}catch{}ce.length=0;let e=globalThis,t=e.__krate_island_cleanups;if(Array.isArray(t)){e.__krate_island_cleanups=[];for(let n of t)try{n()}catch{}}de.length=0,F=!1,ee()}function kt(e,t){return z(y(e))}function wt(e,t){return z(y(e))}function Ct(e,t){let n={};for(let a of e){let[l]=y(!1);n[a]=l}let s=[n,(a,l)=>{}];return s.trigger=a=>({"data-krate-scope":"trigger",value:a}),s.panel=a=>({"data-krate-scope":"panel",value:a}),s.close=()=>({"data-krate-scope":"close"}),s}function Pt(e,t){return z(y(e))}function Nt(e,t){return z(y(e))}function z(e){let t=e;return t.trigger=n=>({"data-krate-scope":"trigger",value:n}),t.panel=n=>({"data-krate-scope":"panel",value:n}),t.close=()=>({"data-krate-scope":"close"}),t.current=()=>e[0](),t}function Rt(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function y(e,t){let n=e,r=null;if(t?.persist){r=ie(t.persist);let u=se(r.key,r.deserialize);if(u.found)n=u.value;else{let d=oe(r);d.found&&(n=d.value)}}let s=new Set,a=()=>{let u=w[w.length-1];return u&&!u.disposed&&(s.add(u),u.sources.add(s)),n},l=()=>{let u=Array.from(s);for(let d of u){if(d.disposed){s.delete(d);continue}if(d.running){d.rerun=!0;continue}d.queued||(d.queued=!0,de.push(d))}Ot()},h=u=>{let d=typeof u=="function"?u(n):u;d!==n&&(n=d,r&&ae(r,n),l())};if(r&&r.sync){let u=r,d=ue(u,m=>{if(m!==null)try{let g=u.deserialize(m);g!==n&&(n=g,l())}catch{}});j(d)}return[a,h]}function Ot(){F||(F=!0,queueMicrotask(_t))}function _t(){F=!1;let e=de.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,q(t),t.rerun&&!t.disposed&&(t.rerun=!1,q(t)))}function q(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,w.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{w.pop(),e.running=!1}}function x(e){let t=Ve(e);return O.add(t),q(t),()=>{ge(t),O.delete(t)}}function j(e){let t=w[w.length-1];t?t.cleanups.push(e):ce.push(e)}function It(e){Be.push(e),le||(le=!0,queueMicrotask(Dt))}function Dt(){le=!1;let e=Be.splice(0);for(let t of e)t()}function Kt(e){let[t,n]=y(void 0),r=Ve(()=>{let a=e();n(a)});O.add(r),q(r);let s=w[w.length-1];return s&&s.cleanups.push(()=>{r.disposed||(ge(r),O.delete(r))}),t}function Bt(e,t){let[n,r]=y(t);return[n,a=>r(l=>e(l,a))]}function Vt(e){return{current:e}}function Ft(e){return t=>e(t,t.ref||(()=>{}))}var qt={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},fe=new WeakMap;function qe(e,t){let n=fe.get(e);n||(n=[],fe.set(e,n)),n.push(t)}function S(e){let t=fe.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)S(e.childNodes[n])}function zt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function ze(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let s=r.nextSibling;S(r),n.removeChild(r),r=s}}function jt(e,t,n){let r=zt(n);r?(ze(n,r),be(e,t,r)):be(e,t,null)}function be(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)be(e,r,n)}}function Fe(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),s=qt[r]||r,a=`__krate_${s}`,l=e[a];l&&e.removeEventListener(s,l),e.addEventListener(s,n),e[a]=n}else t==="value"||t==="checked"||t==="selected"?t==="value"?e.value=n==null||n===!1?"":n:e[t]=!!n:t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function je(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)je(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),qe(n,x(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function U(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[s,a]of Object.entries(t))typeof a=="function"&&!s.startsWith("on")?qe(r,x(()=>Fe(r,s,a()))):Fe(r,s,a);for(let s of n)je(r,s);return r}function Ue(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function Ut(e,t){let n=Ue(t),r=!1;x(()=>{r||(r=!0,n.appendChild(e()))})}function Wt(e,t){let n=Ue(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&S(r)}function Xt(e,t){let[n,r]=y(void 0),[s,a]=y(!0),[l,h]=y(void 0),[u,d]=y("unresolved"),[m,g]=y(0),b,v=()=>typeof e=="function"?e():e,A=async()=>{b&&b.abort(),b=new AbortController;let E=b,J=v();d(m()>0?"refreshing":"loading"),a(!0),h(void 0);try{let C=await t(J,{signal:E.signal});E.signal.aborted||(r(()=>C),d("ready"))}catch(C){C?.name!=="AbortError"&&!E.signal.aborted&&(h(C),d("error"))}finally{E.signal.aborted||a(!1)}};x(()=>{typeof e=="function"&&e.length===0&&e(),m(),A(),j(()=>{b&&(b.abort(),b=void 0)})});let H=function(){return n()};return Object.defineProperties(H,{loading:{get:()=>s()},error:{get:()=>l()},state:{get:()=>u()}}),[H,{mutate:E=>{r(E)},refetch:()=>{g(E=>E+1)}}]}function Gt(e){let t=document.createDocumentFragment(),n=e.children;if(n){let r=Array.isArray(n)?n:[n];for(let s of r)s instanceof Node?t.appendChild(s):t.appendChild(document.createTextNode(String(s)))}return t}function We(e,t,n){let r=e;if(!t)return U(r,null);let{children:s,...a}=t,l=s!==void 0?Array.isArray(s)?s:[s]:[];return U(r,Object.keys(a).length>0?a:null,...l)}function Jt(e,t,n){return We(e,t,n)}function Yt(e,t,n,r,s,a){let l=[],h=t.nextSibling;for(;h&&h!==n;)l.push(h),h=h.nextSibling;if(a){let u=new Map;for(let g of l){let b=g.__k;b!=null&&!u.has(b)&&u.set(b,g)}let d=[];for(let g=0;g<r.length;g++){let b=a(r[g]),v=u.get(b);v?u.delete(b):(v=s(r[g],g),v.__k=b),d.push(v)}for(let g of u.values())g.parentNode===e&&(S(g),e.removeChild(g));let m=0;for(;m<d.length;){let g=m===0?t:d[m-1];if(d[m].parentNode!==e){let b=document.createDocumentFragment(),v=g.nextSibling;do b.appendChild(d[m]),m++;while(m<d.length&&d[m].parentNode!==e);e.insertBefore(b,v)}else d[m]!==g.nextSibling&&e.insertBefore(d[m],g.nextSibling),m++}}else{let u=l.length,d=Math.min(u,r.length);for(let m=0;m<d;m++){let g=s(r[m],m);l[m]!==g&&(S(l[m]),e.replaceChild(g,l[m]))}for(let m=r.length;m<u;m++)l[m].parentNode===e&&(S(l[m]),e.removeChild(l[m]));if(r.length>u){let m=document.createDocumentFragment();for(let g=u;g<r.length;g++)m.appendChild(s(r[g],g));e.insertBefore(m,n)}}}function $t(e,t,n,r,s,a){let l=null;x(()=>{let u=r()?s():a?a():null;l?u?(S(l),e.replaceChild(u,l)):(S(l),e.removeChild(l)):u&&e.insertBefore(u,n),l=u})}function _(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function Xe(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let s=t.attributes[r].name,a=t.attributes[r].value;n.add(s),e.getAttribute(s)!==a&&e.setAttribute(s,a)}for(let r=0;r<e.attributes.length;r++){let s=e.attributes[r].name;n.has(s)||e.removeAttribute(s)}}function me(e,t){let n=document.importNode(t,!0);return e.parentNode&&(S(e),e.parentNode.replaceChild(n,e)),n}function Ge(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function pe(e,t){if(!Ge(e,t))return me(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?me(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return _(n)!==_(r)?me(n,r):(Xe(n,r),Je(n,r),n)}function Je(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let g=!0;for(let b=0;b<r.length;b++)if(_(n[b])!==_(r[b])){g=!1;break}if(g){for(let b=0;b<r.length;b++)pe(n[b],r[b]);return}}let s=new Map,a=[];n.forEach((g,b)=>{let v=_(g);v!=null?s.has(v)||s.set(v,b):a.push(b)});let l=new Set,h=0,u=null,d=0,m=()=>{for(;d<a.length&&l.has(a[d]);)d++;return d<a.length?a[d]:-1};for(let g of r){let b=_(g),v;if(b!=null&&s.has(b)){let A=s.get(b);s.delete(b),l.add(A);let H=n[A];A<h?e.insertBefore(H,u):h=A,v=pe(H,g)}else if(b==null){let A=m();if(A>=0&&Ge(n[A],g)){l.add(A);let H=n[A];H.parentNode===e&&H.nextSibling!==u&&e.insertBefore(H,u),v=pe(H,g)}else v=document.importNode(g,!0),e.insertBefore(v,u)}else v=document.importNode(g,!0),e.insertBefore(v,u);u=v.nextSibling}n.forEach((g,b)=>{!l.has(b)&&g.parentNode===e&&(S(g),e.removeChild(g))})}function Qt(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let s=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(s,n);return}Xe(n,r),Je(n,r)}var Te=!1,I,X=null,W=0,P=new Map,Zt=30,K=new Map,en=50,ve=/\/chunks\/runtime\.[^/]+\.js$/;function $e(){return globalThis.__KRATE_CFG__||{}}function tn(){let e=$e().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function Ye(e){let t=tn();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var G=null;function Ee(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}var he=new Set,nn=128;function Qe(e,t,n){let r=new DOMParser().parseFromString(e,"text/html"),s=[],a=new Set,l=h=>{if(!h)return;let u;try{u=Ee(h,t)}catch{return}a.has(u)||n.has(u)||ve.test(u)||(a.add(u),s.push(u))};return r.querySelectorAll("script[src]").forEach(h=>l(h.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(h=>l(h.getAttribute("href"))),s}function rn(e,t={}){return G?(G(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function Ze(){if(typeof document>"u"||Te)return;Te=!0;let e="#root, main, .docs-content",t=150,n=200,r=null,s=null,a=new Map,l=null;function h(i){for(let o of e.split(", ")){let c=i.querySelector(o.trim());if(c)return c}return i.body}function u(i){if(i.hasAttribute("data-krate-external"))return!1;let o=i.getAttribute("href");return!(!o||o.startsWith("#")||o.startsWith("javascript:")||i.origin!==location.origin||i.target==="_blank")}function d(i){let o=window.requestIdleCallback;typeof o=="function"?o(i,{timeout:1e3}):setTimeout(i,50)}function m(i){let o=i.getAttribute("data-prefetch");return i.hasAttribute("data-prefetch")&&o!=="false"&&o!=="0"}function g(i){if(he.has(i)||he.size>=nn)return;he.add(i);let o=document.createElement("link");o.rel="prefetch",o.as="script",o.href=i,document.head.appendChild(o)}function b(i){P.has(i)||fetch(i,{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>{if(!o)return;if(P.size>=Zt){let f=P.keys().next().value;f!==void 0&&P.delete(f)}P.set(i,o);let c=new Set;document.querySelectorAll("script[src]").forEach(f=>c.add(f.src));for(let f of Qe(o,i,c))g(f)}).catch(()=>{})}function v(){document.addEventListener("mouseover",D),document.addEventListener("focusin",D),typeof IntersectionObserver<"u"&&(l=new IntersectionObserver(i=>{for(let o of i)if(o.isIntersecting){let c=o.target,f=c.getAttribute("href");if(f&&u(c)&&m(c)){let p=new URL(f,location.origin).href;d(()=>b(p))}l.unobserve(o.target)}},{rootMargin:"200px"}),A())}function A(){l&&document.querySelectorAll("a[data-prefetch]").forEach(i=>{m(i)&&l.observe(i)})}function H(){document.removeEventListener("mouseover",D),document.removeEventListener("focusin",D);for(let i of a.values())clearTimeout(i);a.clear(),l&&(l.disconnect(),l=null)}function D(i){let o=i.target.closest("a[data-prefetch]");if(!o||!m(o)||!u(o))return;let c=o.getAttribute("href");if(!c)return;let f=new URL(c,location.origin).href;if(P.has(f))return;let p=a.get(o);p&&clearTimeout(p);let T=setTimeout(()=>{a.delete(o),b(f)},n);a.set(o,T)}let E=null;function J(){if(Y())return;let i=h(document),o=document.querySelector("template[data-krate-loading]");o&&o.content&&i&&(E=o.content.cloneNode(!0),document.body.appendChild(E)),i&&(i.style.transition=`opacity ${t}ms ease`,i.style.opacity="0")}function C(){if(Y())return;E&&E.parentNode&&E.parentNode.removeChild(E),E=null;let i=h(document);i&&(i.style.opacity="1")}function Me(i){try{let o=globalThis.__krate_onNavigation;typeof o=="function"&&o(i)}catch{}}function Le(i,o){try{window.dispatchEvent(new CustomEvent(i,{detail:{url:o}}))}catch{}}function Y(){if($e().viewTransitions===!1)return!1;if(typeof window<"u"&&window.matchMedia)try{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return typeof document.startViewTransition=="function"}function nt(i){let o=i.querySelectorAll('link[rel="stylesheet"]'),c=new Set;o.forEach(p=>{let T=p.getAttribute("href");T&&c.add(new URL(T,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(p=>{let T=p.href;T&&!c.has(T)&&p.remove()});let f=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(p=>f.add(p.href)),o.forEach(p=>{let T=p.getAttribute("href");if(!T)return;let M=new URL(T,location.origin).href;if(!f.has(M)){let k=document.createElement("link");k.rel="stylesheet",k.href=M,document.head.appendChild(k)}})}function Se(i){i.querySelectorAll("[data-view-transition]").forEach(o=>{let c=o.getAttribute("data-view-transition");c&&(o.style.viewTransitionName=c)})}function rt(){let i=h(document);if(i){i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1");try{i.focus({preventScroll:!0})}catch{try{i.focus()}catch{}}}}function it(){let i=HTMLScriptElement.supports;if(!(typeof i!="function"||!i("speculationrules")))try{let o=document.createElement("script");o.type="speculationrules",o.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(o)}catch{}}function xe(i){return i.getElementById("root")||i.body}let ke='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function st(i){document.head.querySelectorAll(ke).forEach(o=>o.remove()),i.head.querySelectorAll(ke).forEach(o=>{document.head.appendChild(document.importNode(o,!0))})}function we(i,o,c,f={}){let{replace:p=!1,scroll:T=!0,restoreScroll:M=!1}=f,N=new DOMParser().parseFromString(i,"text/html"),_e=xe(N),Ie=xe(document);if(!_e||!Ie){location.href=o;return}Le("krate:navigate-start",o);let Q=()=>{let L=N.querySelector("title");L&&(document.title=L.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let B=Array.from(_e.childNodes).map(bt=>document.importNode(bt,!0));Ie.replaceChildren(...B),nt(N),st(N),Se(document)};if(Y())try{let L=document.startViewTransition(Q);L&&L.finished&&typeof L.finished.catch=="function"&&L.finished.catch(()=>{})}catch{Q()}else Q();at(c,o).then(()=>{try{lt(),A()}catch(L){try{let B=globalThis.__krate_onHydrationError;typeof B=="function"&&B(L)}catch{}location.href=o}}),C();let ft=location.pathname+location.search;if(p)history.replaceState({},"",o);else{if(!M){if(K.size>=en){let L=K.keys().next().value;L!==void 0&&K.delete(L)}K.set(ft,window.scrollY)}history.pushState({},"",o)}Ce(o,{restoreScroll:M,scroll:T}),M||rt(),Pe(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:o}})),Le("krate:navigate-end",o),Me(o)}function ot(i){let o=i.indexOf("#");if(o<0||o===i.length-1)return!1;let c=i.slice(o);try{let f=document.querySelector(c);if(f)return f.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function Ce(i,o){if(o.restoreScroll){let c=K.get(i);if(c!==void 0){window.scrollTo(0,c);return}}ot(i)||o.scroll&&window.scrollTo(0,0)}function Pe(){let i=Ye(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(o=>{let c=o.getAttribute("href");if(!c){o.removeAttribute("aria-current");return}let f=c;try{f=Ye(new URL(c,location.origin).pathname)}catch{return}f===i||i==="/"&&(f===""||f==="/")||f!=="/"&&f.length>1&&i.startsWith(f)?o.setAttribute("aria-current","page"):o.removeAttribute("aria-current")})}function at(i,o){return i.length===0?Promise.resolve():Promise.all(i.map(c=>{let f=c.getAttribute("src");return f?ut(f,o):Promise.resolve()})).then(()=>{})}function ut(i,o){return new Promise(c=>{let f=document.createElement("script"),p=Ee(i,o);f.src=p,ve.test(p)||f.setAttribute("data-krate-spa",""),f.onload=()=>c(),f.onerror=()=>c(),document.body.appendChild(f)})}function lt(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function ct(i,o){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",o),Me(o),document.open(),document.write(i),document.close()}function dt(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(r=i,i)).catch(()=>null)}function gt(){return s!==null?Promise.resolve(s):fetch("/500.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(s=i,i)).catch(()=>null)}function Ne(i,o){document.querySelectorAll("script[data-krate-spa]").forEach(p=>p.remove());let c=[],f=new Set;return document.querySelectorAll("script[src]").forEach(p=>{f.add(p.src)}),i.querySelectorAll("script[src]").forEach(p=>{let T=p.getAttribute("src");T&&!f.has(Ee(T,o))&&c.push(p)}),c}function $(i,o={}){let c=++W,f=P.get(i);if(f){let M=new DOMParser().parseFromString(f,"text/html");we(f,i,Ne(M,i),o);return}J(),I&&I.abort(),I=new AbortController;let p=I.signal;fetch(i,{headers:{Accept:"text/html"},signal:p}).then(T=>{if(c===W)return T.ok?T.text().then(M=>{if(c!==W)return;let N=new DOMParser().parseFromString(M,"text/html");we(M,i,Ne(N,i),o)}):(T.status>=500?gt():dt()).then(k=>{c===W&&(k?ct(k,i):location.href=i)})}).catch(T=>{T?.name!=="AbortError"&&(C(),location.href=i)}).finally(()=>{I&&!p.aborted&&(I=void 0)})}let Re=i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;let o=i.target.closest("a[data-krate-link]");if(!o||!u(o))return;i.preventDefault();let c=o.getAttribute("href");if(!c)return;let f=new URL(c,location.origin).href,p=o.hasAttribute("data-krate-replace"),T=o.getAttribute("data-krate-scroll")!=="false";if(c===location.pathname+location.search+location.hash){p&&history.replaceState({},"",c),Ce(f,{scroll:T});return}$(f,{replace:p,scroll:T})},Oe=()=>{$(location.href,{restoreScroll:!0})};document.addEventListener("click",Re),window.addEventListener("popstate",Oe),v(),it(),Pe(),Se(document),G=(i,o={})=>{let c=!0;try{c=new URL(i,location.href).origin===location.origin}catch{c=!1}if(!c){location.href=i;return}$(new URL(i,location.href).href,o)},document.querySelectorAll("script[src]").forEach(i=>{ve.test(i.src)||i.setAttribute("data-krate-spa","")}),X=()=>{document.removeEventListener("click",Re),window.removeEventListener("popstate",Oe),H(),G=null}}function sn(){X&&(X(),X=null),Te=!1,Ze()}function Ae(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)Ae(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function ye(...e){let t=[];for(let n of e)Ae(n,t);return t.join(" ")}function He(...e){let t=[];for(let s of e)Ae(s,t);let n=new Map,r=[];for(let s of t){let a=on(s);n.has(a)||r.push(a),n.set(a,s)}return r.map(s=>n.get(s)).join(" ")}function on(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let s=t.indexOf("-"),a=s>=0?t.slice(0,s):t,l=s>=0?t.slice(s+1,s+2):"";return n+a+(l&&/[0-9]/.test(l)?"-"+l:"")}function an(...e){return He(ye(...e))}function un(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return s=>{let a={};for(let u of Object.keys(n)){let d=s?.[u]??r[u];d!=null&&(a[u]=String(d))}let l=[e];for(let u of Object.keys(n)){let d=a[u];d&&n[u][d]&&l.push(n[u][d])}for(let u of t?.compoundVariants??[])if(ln(u,a,r)){let d=u.class;typeof d=="string"&&l.push(d)}let h=s?.class??s?.className;return typeof h=="string"&&l.push(h),He(ye(l))}}function ln(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let s=e[r],a=t[r]??n[r]??void 0;if(Array.isArray(s)){if(!s.includes(a))return!1}else if(s!==a)return!1}return!0}function cn(e){let t=et(e?.children);return t?(tt(t,e),t):null}function et(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=et(t);if(n)return n}return null}return e instanceof Node?e:null}function tt(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let s=e.getAttribute("class"),a=s?s+" "+String(r):String(r);e.setAttribute("class",a);continue}if(n==="style"&&typeof r=="object"){for(let[s,a]of Object.entries(r))e.style.setProperty(dn(s),String(a));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function dn(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function gn(e,t,...n){if(!(e instanceof Node))return e;if(t&&tt(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}return Et(fn);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -0,0 +1 @@
1
+ export { jsx, jsxs, jsxDEV, Fragment } from './react.js';
@@ -0,0 +1,3 @@
1
+ // React automatic-JSX-runtime shim: `react/jsx-runtime` and
2
+ // `react/jsx-dev-runtime` resolve here for compiled React code.
3
+ export { jsx, jsxs, jsxDEV, Fragment } from './react.js';
@@ -0,0 +1,100 @@
1
+ /**
2
+ * React compatibility runtime.
3
+ *
4
+ * Compiled React libraries (for example `@radix-ui/react-*`) and React source
5
+ * that the compiler could not lower statically resolve to this module. It
6
+ * implements the React API surface on top of Krate's DOM factory, signals, and
7
+ * context so that code can execute without shipping React.
8
+ *
9
+ * Krate components run once and update through signals, so hooks here are
10
+ * signal-backed rather than re-render based. Pure APIs (`createElement`,
11
+ * `Children`, `cloneElement`, `isValidElement`, `createRef`, `createContext`)
12
+ * behave as expected; scheduling APIs (`useTransition`, `startTransition`,
13
+ * `useDeferredValue`) are best-effort. Class components are intentionally
14
+ * minimal.
15
+ */
16
+ import { h, type Component } from './dom.js';
17
+ import { jsx as krateJsx } from './jsx-runtime.js';
18
+ /** React's `Fragment` marker; `createElement(Fragment, ...)` yields a fragment. */
19
+ export declare const Fragment: unique symbol;
20
+ export type ReactChild = unknown;
21
+ /**
22
+ * `React.createElement(type, config, ...children)`. Returns a Krate DOM node
23
+ * (elements) or the result of the component function, matching `h`.
24
+ */
25
+ export declare function createElement(type: unknown, config?: Record<string, unknown> | null, ...children: unknown[]): Node;
26
+ export declare const jsx: typeof krateJsx;
27
+ export declare const jsxs: typeof krateJsx;
28
+ export declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, _key?: unknown, _isStatic?: boolean, _source?: unknown, _self?: unknown): Node;
29
+ /** `React.Children` helpers over arrays and single values. */
30
+ export declare const Children: {
31
+ map(children: unknown, fn: (child: unknown, index: number) => unknown): unknown[];
32
+ forEach(children: unknown, fn: (child: unknown, index: number) => void): void;
33
+ count(children: unknown): number;
34
+ toArray(children: unknown): unknown[];
35
+ only(children: unknown): unknown;
36
+ };
37
+ export declare function cloneElement(element: Node, props?: Record<string, unknown> | null, ...children: unknown[]): Node;
38
+ export declare function isValidElement(value: unknown): boolean;
39
+ export interface RefObject<T> {
40
+ current: T | null;
41
+ }
42
+ export declare function createRef<T = unknown>(): RefObject<T>;
43
+ export declare function forwardRef(render: unknown): unknown;
44
+ export declare function memo<P>(component: Component<P>, _compare?: unknown): Component<P>;
45
+ export declare function lazy(loader: unknown): unknown;
46
+ export declare const StrictMode: symbol;
47
+ export declare const Profiler: symbol;
48
+ export declare const Suspense: symbol;
49
+ export interface ReactContext<T> {
50
+ readonly _id: number;
51
+ readonly defaultValue: T;
52
+ readonly Provider: (props: {
53
+ value: T;
54
+ children?: unknown;
55
+ }) => Node;
56
+ readonly Consumer: (props: {
57
+ children: (value: T) => unknown;
58
+ }) => unknown;
59
+ useContext(): T;
60
+ use(): T;
61
+ }
62
+ export declare function createContext<T>(defaultValue: T): ReactContext<T>;
63
+ export declare function useContext<T>(ctx: ReactContext<T>): T;
64
+ export declare function useState<T>(initial: T | (() => T)): [() => T, (value: T | ((prev: T) => T)) => void];
65
+ export declare function useReducer<S, A>(reducer: (state: S, action: A) => S, initial: S): [() => S, (action: A) => void];
66
+ export declare function useMemo<T>(factory: () => T, _deps?: unknown[]): T;
67
+ export declare function useCallback<T extends (...args: never[]) => unknown>(fn: T, _deps?: unknown[]): T;
68
+ export declare function useRef<T = unknown>(initial?: T): RefObject<T>;
69
+ export declare function useEffect(effect: () => void | (() => void), _deps?: unknown[]): void;
70
+ export declare const useLayoutEffect: typeof useEffect;
71
+ export declare const useInsertionEffect: typeof useEffect;
72
+ export declare function useImperativeHandle<T>(ref: RefObject<T> | ((v: T) => void) | null, create: () => T): void;
73
+ export declare function useDebugValue(_value?: unknown): void;
74
+ export declare function useSyncExternalStore<T>(subscribe: (onChange: () => void) => () => void, getSnapshot: () => T): () => T;
75
+ export declare function useTransition(): [() => boolean, (fn: () => void) => void];
76
+ export declare function useOptimistic<T>(initial: T, update?: (state: T, action: T) => T): [() => T, (action: T) => void];
77
+ export declare function useActionState<State, Payload>(action: (prev: State, payload: Payload) => State | Promise<State>, initial: State): [() => State, (payload: Payload) => Promise<void>, () => boolean];
78
+ export declare function useFormStatus(): {
79
+ pending: boolean;
80
+ data: FormData | null;
81
+ method: string | null;
82
+ action: string | null;
83
+ };
84
+ export declare function useDeferredValue<T>(value: T): T;
85
+ export declare function startTransition(fn: () => void): void;
86
+ export declare function use<T>(value: T | ReactContext<T>): T;
87
+ export declare function flushSync<T>(fn: () => T): T;
88
+ export declare function createPortal(children: unknown, container: Element | DocumentFragment): Element | DocumentFragment;
89
+ /** Minimal class base so compiled code that `extends React.Component` resolves. */
90
+ export declare class ComponentBase {
91
+ props: Record<string, unknown>;
92
+ state: Record<string, unknown>;
93
+ constructor(props?: Record<string, unknown>);
94
+ setState(update: unknown): void;
95
+ render(): Node | null;
96
+ }
97
+ export declare const reactCompat: {
98
+ h: typeof h;
99
+ Fragment: symbol;
100
+ };
package/dist/react.js ADDED
@@ -0,0 +1,255 @@
1
+ /**
2
+ * React compatibility runtime.
3
+ *
4
+ * Compiled React libraries (for example `@radix-ui/react-*`) and React source
5
+ * that the compiler could not lower statically resolve to this module. It
6
+ * implements the React API surface on top of Krate's DOM factory, signals, and
7
+ * context so that code can execute without shipping React.
8
+ *
9
+ * Krate components run once and update through signals, so hooks here are
10
+ * signal-backed rather than re-render based. Pure APIs (`createElement`,
11
+ * `Children`, `cloneElement`, `isValidElement`, `createRef`, `createContext`)
12
+ * behave as expected; scheduling APIs (`useTransition`, `startTransition`,
13
+ * `useDeferredValue`) are best-effort. Class components are intentionally
14
+ * minimal.
15
+ */
16
+ import { h } from './dom.js';
17
+ import { createSignal, createEffect } from './signal.js';
18
+ import { createContext as krateCreateContext } from './context.js';
19
+ import { cloneElement as krateCloneElement } from './class-helpers.js';
20
+ import { jsx as krateJsx } from './jsx-runtime.js';
21
+ /** React's `Fragment` marker; `createElement(Fragment, ...)` yields a fragment. */
22
+ export const Fragment = Symbol.for('krate.react.fragment');
23
+ function fragmentChildren(children) {
24
+ const frag = document.createDocumentFragment();
25
+ for (const child of children) {
26
+ if (child == null || child === false || child === true)
27
+ continue;
28
+ if (child instanceof Node)
29
+ frag.appendChild(child);
30
+ else if (Array.isArray(child))
31
+ frag.appendChild(fragmentChildren(child));
32
+ else
33
+ frag.appendChild(document.createTextNode(String(child)));
34
+ }
35
+ return frag;
36
+ }
37
+ /**
38
+ * `React.createElement(type, config, ...children)`. Returns a Krate DOM node
39
+ * (elements) or the result of the component function, matching `h`.
40
+ */
41
+ export function createElement(type, config, ...children) {
42
+ if (type === Fragment)
43
+ return fragmentChildren(children);
44
+ const props = config ? { ...config } : {};
45
+ if (children.length === 1)
46
+ props.children = children[0];
47
+ else if (children.length > 1)
48
+ props.children = children;
49
+ return krateJsx(type, props);
50
+ }
51
+ export const jsx = krateJsx;
52
+ export const jsxs = krateJsx;
53
+ export function jsxDEV(type, props, _key, _isStatic, _source, _self) {
54
+ return krateJsx(type, props);
55
+ }
56
+ /** `React.Children` helpers over arrays and single values. */
57
+ export const Children = {
58
+ map(children, fn) {
59
+ return toArray(children).map((child, i) => fn(child, i));
60
+ },
61
+ forEach(children, fn) {
62
+ toArray(children).forEach((child, i) => fn(child, i));
63
+ },
64
+ count(children) {
65
+ return toArray(children).length;
66
+ },
67
+ toArray(children) {
68
+ return toArray(children);
69
+ },
70
+ only(children) {
71
+ const list = toArray(children);
72
+ if (list.length !== 1) {
73
+ throw new Error(`React.Children.only expected a single child, got ${list.length}`);
74
+ }
75
+ return list[0];
76
+ },
77
+ };
78
+ function toArray(children) {
79
+ if (children == null || children === false || children === true)
80
+ return [];
81
+ if (Array.isArray(children)) {
82
+ const out = [];
83
+ for (const child of children)
84
+ out.push(...toArray(child));
85
+ return out;
86
+ }
87
+ return [children];
88
+ }
89
+ export function cloneElement(element, props, ...children) {
90
+ return krateCloneElement(element, props, ...children);
91
+ }
92
+ export function isValidElement(value) {
93
+ return value instanceof Node || (typeof value === 'object' && value !== null);
94
+ }
95
+ export function createRef() {
96
+ return { current: null };
97
+ }
98
+ export function forwardRef(render) {
99
+ // Krate binds refs at compile time; render is returned unchanged.
100
+ return render;
101
+ }
102
+ export function memo(component, _compare) {
103
+ return component;
104
+ }
105
+ export function lazy(loader) {
106
+ // A synchronous passthrough: Krate cannot await a dynamic import at render
107
+ // time. Dynamic/lazy components require the SSR/islands path.
108
+ return loader;
109
+ }
110
+ export const StrictMode = Fragment;
111
+ export const Profiler = Fragment;
112
+ export const Suspense = Fragment;
113
+ export function createContext(defaultValue) {
114
+ const ctx = krateCreateContext(defaultValue);
115
+ return {
116
+ _id: ctx.id,
117
+ defaultValue,
118
+ Provider: (props) => ctx.Provider(props),
119
+ Consumer: (props) => props.children(ctx.useContext()),
120
+ useContext: ctx.useContext,
121
+ use: ctx.useContext,
122
+ };
123
+ }
124
+ export function useContext(ctx) {
125
+ return ctx.useContext();
126
+ }
127
+ // --- hooks ---
128
+ export function useState(initial) {
129
+ const value = typeof initial === 'function' ? initial() : initial;
130
+ return createSignal(value);
131
+ }
132
+ export function useReducer(reducer, initial) {
133
+ const [get, set] = createSignal(initial);
134
+ const dispatch = (action) => set((prev) => reducer(prev, action));
135
+ return [get, dispatch];
136
+ }
137
+ export function useMemo(factory, _deps) {
138
+ return factory();
139
+ }
140
+ export function useCallback(fn, _deps) {
141
+ return fn;
142
+ }
143
+ export function useRef(initial) {
144
+ return { current: initial ?? null };
145
+ }
146
+ export function useEffect(effect, _deps) {
147
+ createEffect(effect);
148
+ }
149
+ export const useLayoutEffect = useEffect;
150
+ export const useInsertionEffect = useEffect;
151
+ export function useImperativeHandle(ref, create) {
152
+ if (!ref)
153
+ return;
154
+ const value = create();
155
+ if (typeof ref === 'function')
156
+ ref(value);
157
+ else
158
+ ref.current = value;
159
+ }
160
+ export function useDebugValue(_value) {
161
+ // no-op
162
+ }
163
+ export function useSyncExternalStore(subscribe, getSnapshot) {
164
+ const [get, set] = createSignal(getSnapshot());
165
+ createEffect(() => {
166
+ const unsubscribe = subscribe(() => set(getSnapshot()));
167
+ return () => unsubscribe();
168
+ });
169
+ return get;
170
+ }
171
+ export function useTransition() {
172
+ const [pending, setPending] = createSignal(false);
173
+ const start = (fn) => {
174
+ setPending(true);
175
+ try {
176
+ fn();
177
+ }
178
+ finally {
179
+ setPending(false);
180
+ }
181
+ };
182
+ return [pending, start];
183
+ }
184
+ export function useOptimistic(initial, update) {
185
+ const [state, setState] = createSignal(initial);
186
+ const add = (action) => {
187
+ setState((prev) => (update ? update(prev, action) : action));
188
+ };
189
+ return [state, add];
190
+ }
191
+ export function useActionState(action, initial) {
192
+ const [state, setState] = createSignal(initial);
193
+ const [pending, setPending] = createSignal(false);
194
+ const dispatch = async (payload) => {
195
+ setPending(true);
196
+ try {
197
+ setState(await action(state(), payload));
198
+ }
199
+ finally {
200
+ setPending(false);
201
+ }
202
+ };
203
+ return [state, dispatch, pending];
204
+ }
205
+ export function useFormStatus() {
206
+ return { pending: false, data: null, method: null, action: null };
207
+ }
208
+ export function useDeferredValue(value) {
209
+ return value;
210
+ }
211
+ export function startTransition(fn) {
212
+ fn();
213
+ }
214
+ export function use(value) {
215
+ const ctx = value;
216
+ if (ctx && typeof ctx.useContext === 'function')
217
+ return ctx.useContext();
218
+ return value;
219
+ }
220
+ export function flushSync(fn) {
221
+ return fn();
222
+ }
223
+ export function createPortal(children, container) {
224
+ if (children instanceof Node)
225
+ container.appendChild(children);
226
+ else if (Array.isArray(children)) {
227
+ for (const child of children) {
228
+ if (child instanceof Node)
229
+ container.appendChild(child);
230
+ else if (child != null)
231
+ container.appendChild(document.createTextNode(String(child)));
232
+ }
233
+ }
234
+ else if (children != null) {
235
+ container.appendChild(document.createTextNode(String(children)));
236
+ }
237
+ return container;
238
+ }
239
+ /** Minimal class base so compiled code that `extends React.Component` resolves. */
240
+ export class ComponentBase {
241
+ constructor(props) {
242
+ this.props = props ?? {};
243
+ this.state = {};
244
+ }
245
+ setState(update) {
246
+ const next = typeof update === 'function'
247
+ ? update(this.state, this.props)
248
+ : update;
249
+ this.state = { ...this.state, ...next };
250
+ }
251
+ render() {
252
+ return null;
253
+ }
254
+ }
255
+ export const reactCompat = { h, Fragment };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,50 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { Children, Fragment, cloneElement, createContext, createElement, createRef, isValidElement, useContext, useOptimistic, useFormStatus, } from './react.js';
3
+ describe('react compat runtime', () => {
4
+ it('createElement builds DOM elements with props and children', () => {
5
+ const el = createElement('div', { class: 'x', id: 'a' }, 'hi');
6
+ expect(el.tagName).toBe('DIV');
7
+ expect(el.getAttribute('class')).toBe('x');
8
+ expect(el.getAttribute('id')).toBe('a');
9
+ expect(el.textContent).toBe('hi');
10
+ });
11
+ it('createElement(Fragment) flattens children', () => {
12
+ const frag = createElement(Fragment, null, createElement('a', null), createElement('b', null));
13
+ expect(frag.childNodes.length).toBe(2);
14
+ });
15
+ it('Children helpers flatten and map', () => {
16
+ expect(Children.map([1, 2, 3], (n) => n * 2)).toEqual([2, 4, 6]);
17
+ expect(Children.count([1, [2, 3]])).toBe(3);
18
+ expect(Children.toArray([1, [2, 3]])).toEqual([1, 2, 3]);
19
+ expect(() => Children.only([1, 2])).toThrow();
20
+ });
21
+ it('cloneElement applies props and replaces children', () => {
22
+ const el = createElement('span', { id: 'a' }, 'old');
23
+ const cloned = cloneElement(el, { id: 'b' }, 'new');
24
+ expect(cloned.getAttribute('id')).toBe('b');
25
+ expect(cloned.textContent).toBe('new');
26
+ });
27
+ it('isValidElement distinguishes elements', () => {
28
+ expect(isValidElement(createElement('div', null))).toBe(true);
29
+ expect(isValidElement(null)).toBe(false);
30
+ });
31
+ it('createRef starts empty', () => {
32
+ expect(createRef().current).toBeNull();
33
+ });
34
+ it('createContext falls back to its default', () => {
35
+ const Ctx = createContext('fallback');
36
+ expect(useContext(Ctx)).toBe('fallback');
37
+ expect(Ctx.defaultValue).toBe('fallback');
38
+ });
39
+ });
40
+ describe('react 19 compat shims', () => {
41
+ it('useOptimistic updates its getter', () => {
42
+ const [state, add] = useOptimistic(1);
43
+ expect(state()).toBe(1);
44
+ add(2);
45
+ expect(state()).toBe(2);
46
+ });
47
+ it('useFormStatus exposes an idle status', () => {
48
+ expect(useFormStatus()).toEqual({ pending: false, data: null, method: null, action: null });
49
+ });
50
+ });
package/dist/reconcile.js CHANGED
@@ -51,39 +51,55 @@ export function reconcile(parent, startMarker, endMarker, items, mapFn, keyFn) {
51
51
  parent.removeChild(child);
52
52
  }
53
53
  }
54
- // Reorder: insert nodes in the correct order before endMarker.
55
- for (let i = 0; i < newNodes.length; i++) {
54
+ // Place nodes in order. Newly created nodes (not yet attached) are gathered
55
+ // into consecutive runs and inserted as a single DocumentFragment, so a
56
+ // block of new items costs one DOM mutation instead of one per node. Reused
57
+ // nodes are moved individually only when they are out of position.
58
+ let i = 0;
59
+ while (i < newNodes.length) {
56
60
  const prevNode = i === 0 ? startMarker : newNodes[i - 1];
57
- if (newNodes[i] !== prevNode.nextSibling) {
58
- parent.insertBefore(newNodes[i], prevNode.nextSibling);
61
+ if (newNodes[i].parentNode !== parent) {
62
+ const frag = document.createDocumentFragment();
63
+ const ref = prevNode.nextSibling;
64
+ do {
65
+ frag.appendChild(newNodes[i]);
66
+ i++;
67
+ } while (i < newNodes.length && newNodes[i].parentNode !== parent);
68
+ parent.insertBefore(frag, ref);
69
+ }
70
+ else {
71
+ if (newNodes[i] !== prevNode.nextSibling) {
72
+ parent.insertBefore(newNodes[i], prevNode.nextSibling);
73
+ }
74
+ i++;
59
75
  }
60
76
  }
61
77
  }
62
78
  else {
63
- // Unkeyed: simple index-based reconciliation
64
- const maxLen = Math.max(existing.length, items.length);
65
- for (let i = 0; i < maxLen; i++) {
66
- if (i < items.length) {
67
- const newNode = mapFn(items[i], i);
68
- if (i < existing.length) {
69
- // Replace existing node
70
- if (existing[i] !== newNode) {
71
- disposeNode(existing[i]);
72
- parent.replaceChild(newNode, existing[i]);
73
- }
74
- }
75
- else {
76
- // Append new node before endMarker
77
- parent.insertBefore(newNode, endMarker);
78
- }
79
+ // Unkeyed: index-based reconciliation. Existing nodes are replaced in
80
+ // place, excess nodes are dropped, and the new tail is appended as a single
81
+ // DocumentFragment insert.
82
+ const existingLen = existing.length;
83
+ const replacementLen = Math.min(existingLen, items.length);
84
+ for (let i = 0; i < replacementLen; i++) {
85
+ const newNode = mapFn(items[i], i);
86
+ if (existing[i] !== newNode) {
87
+ disposeNode(existing[i]);
88
+ parent.replaceChild(newNode, existing[i]);
79
89
  }
80
- else if (i < existing.length) {
81
- // Remove excess existing nodes
82
- if (existing[i].parentNode === parent) {
83
- disposeNode(existing[i]);
84
- parent.removeChild(existing[i]);
85
- }
90
+ }
91
+ for (let i = items.length; i < existingLen; i++) {
92
+ if (existing[i].parentNode === parent) {
93
+ disposeNode(existing[i]);
94
+ parent.removeChild(existing[i]);
95
+ }
96
+ }
97
+ if (items.length > existingLen) {
98
+ const frag = document.createDocumentFragment();
99
+ for (let i = existingLen; i < items.length; i++) {
100
+ frag.appendChild(mapFn(items[i], i));
86
101
  }
102
+ parent.insertBefore(frag, endMarker);
87
103
  }
88
104
  }
89
105
  }
@@ -44,4 +44,67 @@ describe('reconcile', () => {
44
44
  reconcile(parent, start, end, [4, 2], map, (n) => n);
45
45
  expect(texts(parent, start, end)).toEqual(['4', '2']);
46
46
  });
47
+ it('reuses existing DOM nodes when reordering keys (no node thrash)', () => {
48
+ const parent = document.createElement('div');
49
+ const { start, end } = markers(parent);
50
+ let created = 0;
51
+ const map = (n) => {
52
+ created++;
53
+ return span(String(n));
54
+ };
55
+ reconcile(parent, start, end, [1, 2, 3, 4, 5], map, (n) => n);
56
+ expect(created).toBe(5);
57
+ // Full reversal: every key still exists, so no node should be recreated.
58
+ reconcile(parent, start, end, [5, 4, 3, 2, 1], map, (n) => n);
59
+ expect(created).toBe(5);
60
+ expect(texts(parent, start, end)).toEqual(['5', '4', '3', '2', '1']);
61
+ });
62
+ it('preserves the same node object for a persistent key', () => {
63
+ const parent = document.createElement('div');
64
+ const { start, end } = markers(parent);
65
+ reconcile(parent, start, end, ['a', 'b'], span, (s) => s);
66
+ const aNode = start.nextSibling; // the 'a' span
67
+ reconcile(parent, start, end, ['x', 'a', 'b'], span, (s) => s); // prepend
68
+ expect(texts(parent, start, end)).toEqual(['x', 'a', 'b']);
69
+ expect(start.nextSibling.nextSibling).toBe(aNode);
70
+ });
71
+ it('inserts a block of new keyed items in order', () => {
72
+ const parent = document.createElement('div');
73
+ const { start, end } = markers(parent);
74
+ reconcile(parent, start, end, ['3', '4', '5'], span, (s) => s);
75
+ reconcile(parent, start, end, ['1', '2', '3', '4', '5', '6'], span, (s) => s);
76
+ expect(texts(parent, start, end)).toEqual(['1', '2', '3', '4', '5', '6']);
77
+ });
78
+ it('handles a large keyed reorder without thrash', () => {
79
+ const parent = document.createElement('div');
80
+ const { start, end } = markers(parent);
81
+ const n = 1000;
82
+ const range = Array.from({ length: n }, (_, i) => i);
83
+ let created = 0;
84
+ const map = (v) => {
85
+ created++;
86
+ return span(String(v));
87
+ };
88
+ reconcile(parent, start, end, range, map, (v) => v);
89
+ expect(created).toBe(n);
90
+ // Rotate by half: all keys persist, order changes.
91
+ const rotated = range.slice(n / 2).concat(range.slice(0, n / 2));
92
+ reconcile(parent, start, end, rotated, map, (v) => v);
93
+ expect(created).toBe(n); // nothing recreated
94
+ const got = texts(parent, start, end);
95
+ expect(got.length).toBe(n);
96
+ expect(got[0]).toBe(String(n / 2));
97
+ expect(got[n - 1]).toBe(String(n / 2 - 1));
98
+ });
99
+ it('appends a large unkeyed tail in order', () => {
100
+ const parent = document.createElement('div');
101
+ const { start, end } = markers(parent);
102
+ reconcile(parent, start, end, ['a', 'b'], span);
103
+ const big = Array.from({ length: 500 }, (_, i) => 'v' + i);
104
+ reconcile(parent, start, end, ['a', 'b'].concat(big), span);
105
+ const got = texts(parent, start, end);
106
+ expect(got.length).toBe(502);
107
+ expect(got[0]).toBe('a');
108
+ expect(got[501]).toBe('v499');
109
+ });
47
110
  });
package/dist/router.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * The per-page hydration chunk(s) a prefetched document will need, as absolute
3
+ * URLs, excluding the shared runtime chunk and anything already loaded. Prefetching
4
+ * these warms the route's JS in addition to its HTML, so an SPA navigation does
5
+ * not stall waiting on the chunk after the HTML swap.
6
+ */
7
+ export declare function pageAssetURLs(html: string, baseUrl: string, loaded: Set<string>): string[];
1
8
  export interface NavigateOptions {
2
9
  replace?: boolean;
3
10
  scroll?: boolean;
package/dist/router.js CHANGED
@@ -38,6 +38,55 @@ function stripBase(pathname) {
38
38
  }
39
39
  // Set during initRouter so the exported `navigate()` can drive the SPA router.
40
40
  let navigateImpl = null;
41
+ // Resolve an asset URL against the navigated-to page (not the current one), so
42
+ // relative srcs like "index.a1b2c3.js" load from the new page's directory.
43
+ function resolveSrc(src, baseUrl) {
44
+ if (/^(https?:)?\/\//.test(src) || src.startsWith('/')) {
45
+ return new URL(src, baseUrl).href;
46
+ }
47
+ // Relative path: resolve against the base page's directory, accounting for
48
+ // both "/about" and "/about/" style targets.
49
+ let base = baseUrl;
50
+ if (!base.endsWith('/')) {
51
+ const idx = base.lastIndexOf('/');
52
+ base = idx > 0 ? base.slice(0, idx + 1) : '/';
53
+ }
54
+ return new URL(src, base).href;
55
+ }
56
+ /** Bounded set of asset URLs already emitted as `<link rel="prefetch">`. */
57
+ const prefetchedAssets = new Set();
58
+ const PREFETCHED_ASSETS_MAX = 128;
59
+ /**
60
+ * The per-page hydration chunk(s) a prefetched document will need, as absolute
61
+ * URLs, excluding the shared runtime chunk and anything already loaded. Prefetching
62
+ * these warms the route's JS in addition to its HTML, so an SPA navigation does
63
+ * not stall waiting on the chunk after the HTML swap.
64
+ */
65
+ export function pageAssetURLs(html, baseUrl, loaded) {
66
+ const doc = new DOMParser().parseFromString(html, 'text/html');
67
+ const out = [];
68
+ const seen = new Set();
69
+ const consider = (src) => {
70
+ if (!src)
71
+ return;
72
+ let abs;
73
+ try {
74
+ abs = resolveSrc(src, baseUrl);
75
+ }
76
+ catch {
77
+ return;
78
+ }
79
+ if (seen.has(abs) || loaded.has(abs) || RUNTIME_CHUNK_RE.test(abs))
80
+ return;
81
+ seen.add(abs);
82
+ out.push(abs);
83
+ };
84
+ doc.querySelectorAll('script[src]').forEach((s) => consider(s.getAttribute('src')));
85
+ doc
86
+ .querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]')
87
+ .forEach((l) => consider(l.getAttribute('href')));
88
+ return out;
89
+ }
41
90
  /**
42
91
  * Programmatic SPA navigation. Falls back to a full page load when the router
43
92
  * has not initialized (e.g. before hydration). Returns false when handled
@@ -94,25 +143,50 @@ export function initRouter() {
94
143
  return false;
95
144
  return true;
96
145
  }
146
+ // Above-the-fold/viewport prefetch is deferred to idle time so it never
147
+ // competes with first paint; hover/focus keeps the 200ms intent debounce.
148
+ function idle(fn) {
149
+ const ric = window.requestIdleCallback;
150
+ if (typeof ric === 'function')
151
+ ric(fn, { timeout: 1000 });
152
+ else
153
+ setTimeout(fn, 50);
154
+ }
155
+ // Prefetch only links that opted in and did not opt out (prefetch={false}).
156
+ function shouldPrefetch(a) {
157
+ const v = a.getAttribute('data-prefetch');
158
+ return a.hasAttribute('data-prefetch') && v !== 'false' && v !== '0';
159
+ }
160
+ function prefetchAsset(url) {
161
+ if (prefetchedAssets.has(url) || prefetchedAssets.size >= PREFETCHED_ASSETS_MAX)
162
+ return;
163
+ prefetchedAssets.add(url);
164
+ const link = document.createElement('link');
165
+ link.rel = 'prefetch';
166
+ link.as = 'script';
167
+ link.href = url;
168
+ document.head.appendChild(link);
169
+ }
97
170
  function prefetchPage(url) {
98
171
  if (prefetchCache.has(url))
99
172
  return;
100
173
  fetch(url, { headers: { Accept: 'text/html' } })
101
- .then((res) => {
102
- if (res.ok)
103
- return res.text();
104
- return null;
105
- })
174
+ .then((res) => (res.ok ? res.text() : null))
106
175
  .then((html) => {
107
- if (html) {
108
- // Bounded LRU: evict the oldest entry when the cache is full.
109
- if (prefetchCache.size >= PREFETCH_CACHE_MAX) {
110
- const oldest = prefetchCache.keys().next().value;
111
- if (oldest !== undefined)
112
- prefetchCache.delete(oldest);
113
- }
114
- prefetchCache.set(url, html);
176
+ if (!html)
177
+ return;
178
+ // Bounded LRU: evict the oldest entry when the cache is full.
179
+ if (prefetchCache.size >= PREFETCH_CACHE_MAX) {
180
+ const oldest = prefetchCache.keys().next().value;
181
+ if (oldest !== undefined)
182
+ prefetchCache.delete(oldest);
115
183
  }
184
+ prefetchCache.set(url, html);
185
+ // Warm the route's hydration chunk(s) too, not just its HTML.
186
+ const loaded = new Set();
187
+ document.querySelectorAll('script[src]').forEach((s) => loaded.add(s.src));
188
+ for (const asset of pageAssetURLs(html, url, loaded))
189
+ prefetchAsset(asset);
116
190
  })
117
191
  .catch(() => { });
118
192
  }
@@ -127,9 +201,9 @@ export function initRouter() {
127
201
  if (entry.isIntersecting) {
128
202
  const a = entry.target;
129
203
  const href = a.getAttribute('href');
130
- if (href && isLocalLink(a)) {
204
+ if (href && isLocalLink(a) && shouldPrefetch(a)) {
131
205
  const url = new URL(href, location.origin).href;
132
- prefetchPage(url);
206
+ idle(() => prefetchPage(url));
133
207
  }
134
208
  prefetchObserver.unobserve(entry.target);
135
209
  }
@@ -142,7 +216,8 @@ export function initRouter() {
142
216
  if (!prefetchObserver)
143
217
  return;
144
218
  document.querySelectorAll('a[data-prefetch]').forEach((a) => {
145
- prefetchObserver.observe(a);
219
+ if (shouldPrefetch(a))
220
+ prefetchObserver.observe(a);
146
221
  });
147
222
  }
148
223
  function cleanupPrefetch() {
@@ -159,7 +234,7 @@ export function initRouter() {
159
234
  }
160
235
  function prefetchHoverHandler(e) {
161
236
  const a = e.target.closest('a[data-prefetch]');
162
- if (!a || !isLocalLink(a))
237
+ if (!a || !shouldPrefetch(a) || !isLocalLink(a))
163
238
  return;
164
239
  const href = a.getAttribute('href');
165
240
  if (!href)
@@ -522,21 +597,8 @@ export function initRouter() {
522
597
  document.body.appendChild(s);
523
598
  });
524
599
  }
525
- // Resolve a script URL against the navigated-to page (not the current one),
526
- // so relative srcs like "index.a1b2c3.js" load from the new page's directory.
527
- function resolveSrc(src, baseUrl) {
528
- if (/^(https?:)?\/\//.test(src) || src.startsWith('/')) {
529
- return new URL(src, baseUrl).href;
530
- }
531
- // Relative path: resolve against the base page's directory, accounting for
532
- // both "/about" and "/about/" style targets.
533
- let base = baseUrl;
534
- if (!base.endsWith('/')) {
535
- const idx = base.lastIndexOf('/');
536
- base = idx > 0 ? base.slice(0, idx + 1) : '/';
537
- }
538
- return new URL(src, base).href;
539
- }
600
+ // Resolve a script URL against the navigated-to page (see module-level
601
+ // resolveSrc), kept as a local alias for readability at call sites.
540
602
  function rehydrate() {
541
603
  if (typeof globalThis.__krate_hydrate === 'function') {
542
604
  globalThis.__krate_hydrate();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { pageAssetURLs } from './router';
3
+ const HTML = `<!doctype html><html><head>
4
+ <link rel="modulepreload" href="/chunks/runtime.abc123.js">
5
+ <link rel="modulepreload" href="index.1234.js">
6
+ <link rel="preload" as="script" href="/assets/extra-5678.js">
7
+ </head><body>
8
+ <script src="/chunks/runtime.abc123.js"></script>
9
+ <script src="index.1234.js"></script>
10
+ <script src="/api/track.js"></script>
11
+ </body></html>`;
12
+ describe('pageAssetURLs', () => {
13
+ it('extracts page scripts, excluding the shared runtime chunk', () => {
14
+ const urls = pageAssetURLs(HTML, 'https://example.com/about/', new Set());
15
+ expect(urls).toContain('https://example.com/about/index.1234.js');
16
+ expect(urls).toContain('https://example.com/api/track.js');
17
+ expect(urls).not.toContain('https://example.com/chunks/runtime.abc123.js');
18
+ });
19
+ it('dedupes across script and modulepreload tags', () => {
20
+ const urls = pageAssetURLs(HTML, 'https://example.com/about/', new Set());
21
+ expect(urls.filter((u) => u.endsWith('/index.1234.js')).length).toBe(1);
22
+ });
23
+ it('picks up preload/modulepreload-only assets', () => {
24
+ const urls = pageAssetURLs(HTML, 'https://example.com/about/', new Set());
25
+ expect(urls).toContain('https://example.com/assets/extra-5678.js');
26
+ });
27
+ it('skips already-loaded assets', () => {
28
+ const loaded = new Set(['https://example.com/about/index.1234.js']);
29
+ const urls = pageAssetURLs(HTML, 'https://example.com/about/', loaded);
30
+ expect(urls).not.toContain('https://example.com/about/index.1234.js');
31
+ });
32
+ it('resolves relative srcs against the target page directory', () => {
33
+ const urls = pageAssetURLs(HTML, 'https://example.com/about', new Set());
34
+ expect(urls).toContain('https://example.com/index.1234.js');
35
+ });
36
+ });
package/dist/signal.js CHANGED
@@ -46,6 +46,20 @@ export function disposeAll() {
46
46
  }
47
47
  }
48
48
  rootCleanups.length = 0;
49
+ // Unmount external Preact islands mounted by the page before the DOM swap.
50
+ const g = globalThis;
51
+ const islands = g.__krate_island_cleanups;
52
+ if (Array.isArray(islands)) {
53
+ g.__krate_island_cleanups = [];
54
+ for (const cleanup of islands) {
55
+ try {
56
+ cleanup();
57
+ }
58
+ catch {
59
+ // Island unmount errors must not prevent the SPA swap.
60
+ }
61
+ }
62
+ }
49
63
  pending.length = 0;
50
64
  flushScheduled = false;
51
65
  // Reset every context stack to its default so provider values from the page
package/dist/slot.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Slot as KrateSlot } from './class-helpers.js';
2
+ export declare const Slot: typeof KrateSlot;
3
+ export declare const Root: typeof KrateSlot;
4
+ /** Radix's `Slottable` marker: the wrapped children are rendered in place. */
5
+ export declare function Slottable(props: {
6
+ children?: unknown;
7
+ }): unknown;
8
+ export default Slot;
package/dist/slot.js ADDED
@@ -0,0 +1,11 @@
1
+ // Krate-native replacement for `@radix-ui/react-slot` (used by shadcn's
2
+ // `asChild` pattern). The compiler aliases the Radix package here so copied
3
+ // shadcn source compiles without React or a compiled package dependency.
4
+ import { Slot as KrateSlot } from './class-helpers.js';
5
+ export const Slot = KrateSlot;
6
+ export const Root = KrateSlot;
7
+ /** Radix's `Slottable` marker: the wrapped children are rendered in place. */
8
+ export function Slottable(props) {
9
+ return props?.children;
10
+ }
11
+ export default Slot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krate/runtime",
3
- "version": "0.4.0",
3
+ "version": "0.5.0-alpha.1",
4
4
  "description": "Client-side runtime for Krate — signals, hydration, SPA router, resources, and context.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -49,6 +49,18 @@
49
49
  "./jsx-types": {
50
50
  "types": "./dist/jsx-types.d.ts",
51
51
  "default": "./dist/jsx-types.js"
52
+ },
53
+ "./react": {
54
+ "types": "./dist/react.d.ts",
55
+ "default": "./dist/react.js"
56
+ },
57
+ "./react/jsx-runtime": {
58
+ "types": "./dist/react-jsx-runtime.d.ts",
59
+ "default": "./dist/react-jsx-runtime.js"
60
+ },
61
+ "./slot": {
62
+ "types": "./dist/slot.d.ts",
63
+ "default": "./dist/slot.js"
52
64
  }
53
65
  },
54
66
  "files": [