@tempots/ui 16.0.10 → 16.1.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.
package/README.md CHANGED
@@ -92,13 +92,12 @@ const userProfile = Query({
92
92
  if (!response.ok) throw new Error('Failed to load user')
93
93
  return response.json()
94
94
  },
95
- mapError: error => error instanceof Error ? error.message : String(error),
96
- })({
97
- loading: () => html.div('Loading user...'),
98
- failure: error => html.div(error.map(message => `Error: ${message}`)),
99
- success: user => html.div(
100
- html.h2(user.map(u => u.name)),
101
- html.p(user.map(u => u.email)),
95
+ convertError: error => error instanceof Error ? error.message : String(error),
96
+ pending: () => html.div('Loading user...'),
97
+ failure: ({ error }) => html.div(error.map(message => `Error: ${message}`)),
98
+ success: ({ value }) => html.div(
99
+ html.h2(value.map(u => u.name)),
100
+ html.p(value.map(u => u.email)),
102
101
  ),
103
102
  })
104
103
 
@@ -114,29 +113,25 @@ import { html, render, prop, on, attr } from '@tempots/dom'
114
113
  import { PopOver } from '@tempots/ui'
115
114
 
116
115
  function TooltipExample() {
117
- const showTooltip = prop(false)
118
-
119
116
  return html.div(
120
- html.button(
121
- on.mouseenter(() => showTooltip.value = true),
122
- on.mouseleave(() => showTooltip.value = false),
123
- 'Hover me',
124
- PopOver({
125
- open: showTooltip,
126
- placement: 'top',
127
- content: () => html.div(
128
- { style: 'padding: 8px; background: white; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);' },
129
- 'This is a tooltip with an arrow!'
130
- ),
131
- arrow: {
132
- padding: 4,
117
+ PopOver((open, close) => {
118
+ return html.button(
119
+ on.click(() => open({
133
120
  content: html.div(
121
+ attr.style('padding: 8px; background: white; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);'),
122
+ 'This is a tooltip with an arrow!'
123
+ ),
124
+ placement: 'top',
125
+ arrowPadding: 4,
126
+ arrow: (arrowSignal) => html.div(
134
127
  attr.class('tooltip-arrow'),
135
128
  attr.style('background: white; border: 1px solid #ccc; transform: rotate(45deg); width: 8px; height: 8px;')
136
- )
137
- }
138
- })
139
- )
129
+ ),
130
+ onClickOutside: close,
131
+ })),
132
+ 'Click me'
133
+ )
134
+ })
140
135
  )
141
136
  }
142
137
  ```
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@tempots/dom"),f=require("@tempots/std"),P=require("@floating-ui/dom"),at=e=>{const t=e.split("/").pop();if(t==null||t.startsWith("."))return;const n=t.split(".")||[];return n.length>1?"."+n.pop():void 0},ot=(e,t)=>{const n=at(t);return n!=null&&(e.length===0||!e.some(s=>n==s))},bt=(e,t,n,s)=>{let a=e.target;for(;a!=null&&!(a instanceof HTMLAnchorElement);)a=a.parentElement;if(a==null)return!0;const o=a;if(e.button!==0||e.ctrlKey||e.metaKey||o.target!=="_self"&&o.target!==""||o.getAttribute("download")!=null)return!0;const{pathname:r,search:c,hash:l}=o;if(s){const h=r+c+l,d=o.getAttribute("href");if(!d?.startsWith("#")&&d!==h)return!0}return t?!1:ot(n,r)},it=(e,t={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const n=t.ignoreUrlWithExtension===!0&&Array.isArray(t.allowedExtensions)?t.allowedExtensions.map(s=>s.startsWith(".")?s:"."+s):[];return s=>{bt(s,t.ignoreUrlWithExtension??!0,n,t.ignoreExternalUrl??!0)||e()&&s.preventDefault()}},ct=(e,t)=>e.pathname===t.pathname&&JSON.stringify(e.search)===JSON.stringify(t.search)&&e.hash===t.hash,V=(e,t)=>{const n=new URL(e,t??i.getWindow()?.location.toString()),s=Object.fromEntries(n.searchParams?.entries()??[]);let a=n.hash;return a.startsWith("#")&&(a=a.substring(1)),{pathname:n.pathname,search:s,hash:a===""?void 0:a}},b=e=>{const n=new URLSearchParams(e.search).toString(),s=e.hash;return`${e.pathname}${n?`?${n}`:""}${s?`#${s}`:""}`},xt=e=>{document.startViewTransition?document.startViewTransition(e):e()},X=()=>{const e=i.getWindow(),t=e?.location.hash??"";return{pathname:e?.location.pathname??"",search:Object.fromEntries(new URLSearchParams(e?.location.search??"").entries()),hash:t.startsWith("#")?t.substring(1)||void 0:t===""?void 0:t}},G=e=>{if(e?.scroll!=="auto")return;const t=i.getWindow();t&&t.requestAnimationFrame(()=>t.scrollTo({top:0,left:0,behavior:"auto"}))},Z=(e,t)=>{t?.viewTransition?xt(e):e()},Lt=()=>{const e=i.prop(X(),ct),t=i.getWindow(),n=()=>{e.set(X())};t?.addEventListener("popstate",n),t?.addEventListener("hashchange",n);const s=(l,h,d)=>{Z(()=>{if(t){const w=b(l),R=h?.state??{};d==="replaceState"||h?.replace?t.history.replaceState(R,"",w):t.history.pushState(R,"",w)}e.set(l)},h),G(h)},a=(l,h)=>{Z(()=>{t?.history.go(l)},h),G(h)};return{location:e,commit:s,go:a,back:l=>a(-1,l),forward:l=>a(1,l),resolve:l=>V(l),dispose:()=>{t?.removeEventListener("popstate",n),t?.removeEventListener("hashchange",n),e.dispose()}}},Wt=e=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//"),Tt=e=>{const t=e.container.currentURL,n=t.iso(r=>V(r,t.value),r=>{if(Wt(r.pathname))return b(r);const c=new URL(r.pathname,t.value),l=c.origin+c.pathname;return b({...r,pathname:l})});return{location:n,dispose:()=>{n.dispose()},commit:(r,c,l)=>{n.set(r)},go:(r,c)=>{},back:r=>{},forward:r=>{},resolve:r=>V(r,t.value)}},L=e=>({pathname:e.pathname,search:{...e.search},hash:e.hash??void 0}),N=e=>{if(e==null)return;const t=`${e}`;return t===""?void 0:t},lt=(e,t)=>{const n={...e};for(const[s,a]of Object.entries(t))a==null?delete n[s]:n[s]=a;return n},Ht=(e,t)=>{const n=t?.includeSearch??!0,s=t?.includeHash??!0,a=t?.ignoreSearchParams??[];let o;if(!n)o={};else if(a.length===0)o={...e.search};else{const r=new Set(a);o={};for(const[c,l]of Object.entries(e.search))r.has(c)||(o[c]=l)}return{pathname:e.pathname,search:o,hash:s?e.hash:void 0}},z=(e,t,n)=>{const s=Ht(e,n);return typeof t=="string"?b(s)===t:t instanceof RegExp?((t.global||t.sticky)&&(t.lastIndex=0),t.test(b(s))):t(s)};class Dt{constructor(t){this.current=t}get location(){return this.current}setLocation(t){return this.current=L(t),this}setPathname(t){return this.current={...this.current,pathname:t},this}setHash(t){const n=N(t);if(n==null){const{hash:s,...a}=this.current;this.current=a}else this.current={...this.current,hash:n};return this}clearHash(){const{hash:t,...n}=this.current;return this.current=n,this}setSearch(t){return this.current={...this.current,search:lt(this.current.search,t)},this}setSearchParam(t,n){return this.setSearch({[t]:n})}updateSearch(t){return this.current={...this.current,search:{...t({...this.current.search})}},this}}const Mt=(e,t)=>e?.replace?"replaceState":t,Vt=e=>{const t=e.location,n=t.map(b),s=t.map(u=>u.pathname),a=t.map(u=>({...u.search})),o=t.map(u=>u.hash),r=(u,p)=>z(e.location.value,u,p),c=(u,p)=>i.computedOf(t,u)((m,k)=>z(m,k,p)),l=(u,p,m)=>{const k=L({...u,hash:N(u.hash??void 0)});e.commit(k,p,m)},h=(u,p)=>{const m=Mt(p,"pushState");l(u,p,m)},d=(u,p)=>{const m=u(L(e.location.value));h(m,p)},w=(u,p)=>{const m=e.resolve(u);h(m,p)},R=(u,p)=>{const m={...p,replace:!0};w(u,m)},O=(u,p)=>{e.go(u,p)},g=u=>{e.back(u)},E=u=>{e.forward(u)},v=(u,p)=>d(m=>({...m,pathname:u}),p),S=(u,p)=>d(m=>{const k={...m},J=N(u);return J==null?delete k.hash:k.hash=J,k},p),A=u=>S(void 0,u),y=(u,p)=>d(m=>({...m,search:lt(m.search,u)}),p);return{handle:{location:t,url:n,pathname:s,search:a,hash:o,setLocation:h,updateLocation:d,navigate:w,replace:R,go:O,back:g,forward:E,setPathname:v,setHash:S,clearHash:A,setSearch:y,setSearchParam:(u,p,m)=>y({[u]:p},m),updateSearch:(u,p)=>d(m=>({...m,search:{...u({...m.search})}}),p),queryParam:u=>t.map(p=>p.search[u]),run:(u,p)=>{const m=new Dt(L(e.location.value));u(m),h(L(m.location),p)},match:r,matchSignal:c},dispose:()=>{e.dispose(),n.dispose(),s.dispose(),a.dispose(),o.dispose()}}},Ft=e=>{if(e.isBrowser())return Lt();if(e.isHeadless())return Tt(e);throw new Error("Unknown context")},K={mark:i.makeProviderMark("Location"),create:(e,t)=>{const n=Ft(t),{handle:s,dispose:a}=Vt(n);return{value:s,dispose:a}}},ut=(e,...t)=>{if(typeof e=="string"||i.Signal.is(e))return ut({href:e},...t);const{href:n,state:s,scroll:a,viewTransition:o,replace:r,...c}=e;return i.Use(K,l=>i.html.a(i.on.click(it(()=>{let h=!1;const d={};return s!==void 0&&(d.state=s,h=!0),a!==void 0&&(d.scroll=a,h=!0),o!==void 0&&(d.viewTransition=o,h=!0),r!==void 0&&(d.replace=r,h=!0),l.navigate(i.Value.get(n),h?d:void 0),!0},c)),i.attr.href(n),...t))},Ut={mark:i.makeProviderMark("Appearance"),create:()=>{const e=ht();return{value:e,dispose:()=>e.dispose()}}};function ht(){const e=i.getWindow(),t=e!=null&&e.matchMedia!=null?e.matchMedia("(prefers-color-scheme: dark)"):void 0,n=t?.matches??!1,s=i.prop(n?"dark":"light"),a=o=>s.set(o.matches?"dark":"light");return t?.addEventListener("change",a),s.onDispose(()=>t?.removeEventListener("change",a)),s}const j=(e,t)=>{if(typeof t=="function")return j(e,{success:t});const n=t.failure??(r=>r.map(c=>`Error: ${c}`)),s=t.success,a=t.loading??(()=>i.Empty),o=t.notAsked??(()=>i.Empty);return i.OneOfType(i.Value.toSignal(e),{AsyncSuccess:r=>s(r.$.value),AsyncFailure:r=>n(r.$.error),Loading:r=>a(r.map(c=>c.previousValue)),NotAsked:o})},Kt=(e=10)=>i.WithElement(t=>i.OnDispose(f.delayed(()=>t?.focus(),e))),Ct=(e=10)=>i.WithElement(t=>{const n=f.delayed(()=>t.select(),e);return i.OnDispose(n)});function Nt(e){const t=Object.entries(e);return i.Fragment(...t.map(([n,s])=>i.attr.class(i.Value.map(s,a=>a?n:void 0))))}const zt=i.WithElement(e=>{const t=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),i.OnDispose(n=>{n&&e.style.setProperty(":empty",t)})}),_t=e=>i.Portal("head > title",i.attr.innerText(e)),$t={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},M={partial:new Map,full:new Map},W={partial:null,full:null};function jt(e){return W[e]==null&&(W[e]=new IntersectionObserver(t=>{t.forEach(n=>{M[e].get(n.target)?.set(n.isIntersecting)})},$t[e])),W[e]}const pt=({mode:e="partial",once:t=!1},n)=>{const s=i.prop(!1);return i.Fragment(i.WithElement(a=>{const o=typeof IntersectionObserver<"u"?jt(e):null;M[e].set(a,s),o?.observe(a);function r(){o?.unobserve(a),M[e].delete(a),M[e].size===0&&(W[e]?.disconnect(),W[e]=null)}let c=null;return t&&(c=s.on(l=>{l&&r()})),i.OnDispose(()=>{s.dispose(),r(),c?.()})}),i.renderableOfTNode(n(s)))},It=(e,t,n)=>pt(e,s=>i.When(s,t,n??(()=>i.Empty)));function dt(e){return i.WithElement(t=>{const n=s=>{t.contains(s.target)||e(s)};return document.addEventListener("click",n),i.OnDispose(()=>{document.removeEventListener("click",n)})})}const x=(e,t)=>e===void 0||e===t,tt=(e,t)=>e===void 0||e===t;function mt(e,t){return typeof e=="string"?t.key===e:tt(e.key,t.key)&&tt(e.code,t.code)&&x(e.ctrlKey,t.ctrlKey)&&x(e.altKey,t.altKey)&&x(e.shiftKey,t.shiftKey)&&x(e.metaKey,t.metaKey)&&x(e.repeat,t.repeat)&&x(e.commandOrControlKey,t.metaKey||t.ctrlKey)}function I({allowedKeys:e,handler:t}){return i.WithElement(n=>{const s=a=>{if(n.contains(a.target)){for(const o of e)if(mt(o,a)){t(a);break}}};return document.addEventListener("keydown",s),i.OnDispose(()=>{document.removeEventListener("keydown",s)})})}function qt(e){return I({allowedKeys:["Enter"],handler:e})}function Qt(e){return I({allowedKeys:["Escape"],handler:e})}const ft=({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a})=>{let o;const r=i.prop(f.AsyncResult.notAsked),c=r.map(g=>f.AsyncResult.isSuccess(g)?g.value:void 0),l=r.map(g=>f.AsyncResult.isFailure(g)?g.error:void 0),h=r.map(g=>f.AsyncResult.isLoading(g)),d=()=>{o?.abort(),o=void 0};return{status:r,value:c,error:l,pending:h,execute:async(g,E)=>{d(),o=new AbortController;const v=o.signal,S=r.get(),A=E?.optimisticValue??(E?.optimisticFromRequest!=null?E.optimisticFromRequest(g):void 0);A!=null?r.set(f.AsyncResult.loading(A)):r.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(S)));try{const y=await e({request:g,abortSignal:v,previous:S});o=void 0,r.set(f.AsyncResult.success(y)),n?.(y,g)}catch(y){o=void 0,r.set(f.AsyncResult.failure(t(y))),s?.(t(y),g)}a?.(r.get(),g)},cancel:g=>{d(),r.set(g??f.AsyncResult.notAsked)},dispose:()=>{o?.abort(),o=void 0,r.dispose()}}},gt=(e,t)=>{const{status:n,dispose:s,execute:a,cancel:o,pending:r,error:c,value:l}=e,{content:h}=t,d=i.previousSignal(l);return i.Fragment(i.OnDispose(s),h({previous:d,execute:a,cancel:o,pending:r,error:c,value:l,status:n}))},Bt=({mutate:e,convertError:t=r=>r,onSuccess:n,onError:s,onSettled:a,content:o})=>{const r=ft({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a});return gt(r,{content:o})},Yt=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],Jt=(e,t={isOpen:!1})=>{const n=[];let s=null;const a=i.Value.deriveProp(t.isOpen);function o(c){s=c,a.set(!0)}function r(){a.set(!1),n.forEach(c=>c()),n.length=0}return i.Fragment(e(o,r),i.When(a,()=>i.Fragment(s?.onClickOutside!=null?dt(s.onClickOutside):null,i.WithElement(c=>i.Portal("body",i.html.div(i.WithElement(l=>{l.style.position="absolute",l.style.width="max-content";const h=typeof s?.target=="string"?c.querySelector(s.target):s?.target??c;if(h==null)throw new Error(`Target not found: ${s?.target}`);let d=null;const w=i.Value.toSignal(s?.mainAxisOffset??0),R=i.Value.toSignal(s?.crossAxisOffset??0),O=i.Value.toSignal(s?.placement??"top"),g=i.Value.toSignal(s?.arrowPadding??0),E=s?.arrow,v=i.prop({centerOffset:0,alignmentOffset:0,containerWidth:0,containerHeight:0,x:void 0,y:void 0});async function S(){const y=[P.flip(),P.offset({mainAxis:w.get(),crossAxis:R.get()}),P.shift(),P.flip()];E!=null&&d!=null&&y.push(P.arrow({element:d,padding:g.get()}));const D=await P.computePosition(h,l,{placement:O.get(),strategy:"absolute",middleware:y}),{x:Q,y:B,middlewareData:C}=D;if(l.style.top=`${B}px`,l.style.left=`${Q}px`,d!=null&&C.arrow!=null){const{x:Y,y:u,centerOffset:p,alignmentOffset:m}=C.arrow;v.set({x:Y,y:u,centerOffset:p,alignmentOffset:m,containerWidth:l.offsetWidth,containerHeight:l.offsetHeight})}}const A=i.effectOf(w,R,O)(S);return i.Fragment(s?.content,s?.arrow!=null?i.html.div(s?.arrow(i.computedOf(v,O)((y,D)=>({...y,placement:D}))),i.WithElement(y=>{d=y,S()})):null,i.OnDispose(P.autoUpdate(h,l,S),A))})))))))},vt=({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o})=>{let r;const c=i.prop(f.AsyncResult.notAsked),l=c.map(v=>f.AsyncResult.isSuccess(v)?v.value:void 0),h=c.map(v=>f.AsyncResult.isFailure(v)?v.error:void 0),d=c.map(v=>f.AsyncResult.isLoading(v)),w=()=>{r?.abort(),r=void 0},R=v=>{w(),c.set(v??f.AsyncResult.notAsked)},O=async v=>{w(),r=new AbortController;const S=r.signal,A=c.get();c.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(A)));try{const y=await t({request:v,abortSignal:S,previous:A});await Promise.resolve(),r=void 0,c.set(f.AsyncResult.success(y)),s?.(y,v)}catch(y){r=void 0,c.set(f.AsyncResult.failure(n(y))),a?.(n(y),v)}o?.(c.get(),v)},g=()=>O(i.Value.get(e)),E=()=>{r?.abort(),r=void 0,c.dispose()};return c.onDispose(i.Value.on(e,O)),{status:c,value:l,error:h,loading:d,cancel:R,reload:g,dispose:E}},yt=(e,t)=>{const{status:n,dispose:s,reload:a}=e,{pending:o,failure:r,success:c}=t;return i.Fragment(i.OnDispose(s),j(n,{loading:o!=null?l=>o({previous:l,reload:a,cancel:e.cancel}):void 0,failure:r!=null?l=>r({error:l,reload:a}):void 0,success:l=>c({value:l,reload:a})}))},Xt=({request:e,load:t,convertError:n=h=>h,onSuccess:s,onError:a,onSettled:o,success:r,pending:c,failure:l})=>{const h=vt({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o});return yt(h,{success:r,pending:c,failure:l})},wt=(e,t)=>{if(typeof t=="function")return wt(e,{success:t});const n=t.failure??(a=>(a.on(console.error),a.map(o=>`Error: ${o}`))),s=t.success;return i.OneOfType(i.Value.toSignal(e),{Success:a=>s(a.$.value),Failure:a=>n(a.$.error)})},Gt=()=>i.on.focus(e=>e.target?.select());class H{constructor(t,n,s,a,o,r){this.left=t,this.top=n,this.width=s,this.height=a,this.localLeft=o,this.localTop=r}static of({left:t=0,top:n=0,width:s=0,height:a=0,localLeft:o=0,localTop:r=0}){return new H(t,n,s,a,o,r)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return{x:this.left+this.width/2,y:this.top+this.height/2}}get localCenter(){return{x:this.localLeft+this.width/2,y:this.localTop+this.height/2}}get localBottom(){return this.localTop+this.height}get localRight(){return this.localLeft+this.width}get size(){return{width:this.width,height:this.height}}equals=t=>f.nearEqual(this.left,t.left)&&f.nearEqual(this.top,t.top)&&f.nearEqual(this.width,t.width)&&f.nearEqual(this.height,t.height)}function _(e){const t=e.getBoundingClientRect();return H.of({top:t.top+window.scrollY,left:t.left+window.scrollX,width:t.width,height:t.height,localLeft:e.offsetLeft,localTop:e.offsetTop})}const Zt=e=>i.WithBrowserCtx(t=>{const{element:n}=t,s=i.prop(_(n),(c,l)=>c.equals(l)),a=i.renderableOfTNode(e(s)).render(t),o=()=>s.set(H.of(_(n)));let r=null;return typeof ResizeObserver<"u"&&(r=new ResizeObserver(o)),r?.observe(n),i.OnDispose(c=>{r?.disconnect(),a(c)})});function et(e){return{width:e?.innerWidth??0,height:e?.innerHeight??0}}const te=e=>i.WithCtx(()=>{const t=i.getWindow(),n=i.prop(et(t),(a,o)=>a.width===o.width&&a.height===o.height),s=()=>n.set(et(t));return t?.addEventListener("resize",s),i.Fragment(i.OnDispose(()=>{t?.removeEventListener("resize",s)}),e(n))}),St=(e,t)=>{const n=t.split("/").filter(o=>o!==""),s=o=>{try{return decodeURIComponent(o)}catch{return o}},a={};for(let o=0;o<e.length;o++){const r=e[o],c=n[o];if(!c&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==c)return null}else if(r.type==="param")a[r.name]=s(c);else if(r.type==="catch-all"){if(r.name){const l=n.slice(o).join("/");a[r.name]=s(l)}return{params:a,path:t}}}return n.length!==e.length?null:{params:a,path:t}},q=e=>e.split("/").map(t=>{if(t.startsWith(":"))return{type:"param",name:t.slice(1)};if(t.startsWith("*")){const n=t.slice(1);return n!=""?{type:"catch-all",name:n}:{type:"catch-all"}}else return{type:"literal",value:t}}).filter(t=>t.type!=="literal"||t.value!==""),ee=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=St(a,s);if(r)return{...r,route:o}}return null}},ne=e=>{if(e==null)throw new Error("NavigationService: no Location handle attached. Make sure to attach one before calling navigation helpers.");return e};class se{handles=[];attach(t){const n=this.handles.lastIndexOf(t);return n!==-1&&this.handles.splice(n,1),this.handles.push(t),()=>this.detach(t)}detach(t){for(let n=this.handles.length-1;n>=0;n--)if(this.handles[n]===t){this.handles.splice(n,1);break}}get current(){return this.handles[this.handles.length-1]}getHandle(){return ne(this.current)}navigate(t,n){this.getHandle().navigate(t,n)}replace(t,n){this.getHandle().replace(t,n)}go(t,n){this.getHandle().go(t,n)}back(t){this.getHandle().back(t)}forward(t){this.getHandle().forward(t)}setPathname(t,n){this.getHandle().setPathname(t,n)}setSearch(t,n){this.getHandle().setSearch(t,n)}setSearchParam(t,n,s){this.getHandle().setSearchParam(t,n,s)}updateSearch(t,n){this.getHandle().updateSearch(t,n)}setHash(t,n){this.getHandle().setHash(t,n)}clearHash(t){this.getHandle().clearHash(t)}run(t,n){this.getHandle().run(t,n)}}const re=new se,F={mark:i.makeProviderMark("RouterContext"),create:()=>{const e=i.prop([]);return{value:e,dispose:()=>e.dispose()}}},ae=(e,t,n)=>{const s=n.split("/").filter(r=>r!==""),a={};let o=0;for(let r=0;r<e.length;r++){const c=e[r],l=s[r];if(!l&&c.type!=="catch-all")return null;if(c.type==="literal"){if(c.value!==l)return null;o++}else if(c.type==="param")a[c.name]=l,o++;else if(c.type==="catch-all"){c.name&&(a[c.name]=s.slice(o).join("/"));const h="/"+s.slice(0,o).join("/"),d="/"+s.slice(o).join("/");return{params:a,matchedPath:h==="/"?"":h,remainingPath:d==="/"?"":d,route:t}}}if(s.length===e.length){const r="/"+s.join("/");return{params:a,matchedPath:r==="/"?"":r,remainingPath:"",route:t}}return null},Rt=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=ae(a,o,s);if(r)return r}return null}},oe=e=>{const t=Rt(Object.keys(e));return i.Provide(F,{},()=>i.Use(K,n=>i.Use(F,s=>{const a=n.location.map(o=>{const r=t(o.pathname);if(r==null)throw console.error("No route found for",o),new Error("No route found");const c={matchedPath:r.matchedPath,remainingPath:r.remainingPath,fullPath:o.pathname,params:r.params};return s.value=[...s.value,c],{params:r.params,route:r.route,path:r.matchedPath||o.pathname,search:o.search,hash:o.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)})))},ie=e=>{const t=Rt(Object.keys(e));return i.Use(F,n=>i.Use(K,s=>{const a=n.map(o=>{const r=o[o.length-1];if(r==null)throw console.error("No router context available for ChildRouter",o),new Error("No router context available for ChildRouter");const c=r.remainingPath??"",l=t(c);if(l==null)throw console.error("No route found for remaining path",c),new Error("No route found");return{params:l.params,route:l.route,path:l.matchedPath,search:s.location.value.search,hash:s.location.value.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)}))},U=60*1e3,$=60*U,T=24*$,nt=7*T,st=30*T,ce=365*T,le=[{max:U*90,value:U,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:$*36,value:$,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:T*10,value:T,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:nt*6,value:nt,name:"week",past:{singular:"last week",plural:"{} weeks ago"},future:{singular:"in a week",plural:"in {} weeks"}},{max:st*18,value:st,name:"month",past:{singular:"last month",plural:"{} months ago"},future:{singular:"in a month",plural:"in {} months"}},{max:1/0,value:ce,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function rt(e,t,n,s){const a=Math.round(e/t);return a<=1?n:s.replace("{}",a.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}const Ot=(e=1e3)=>{const t=i.prop(new Date),n=f.interval(()=>t.set(new Date),e);return t.onDispose(n),t},Et=e=>{const t=Math.abs(e);if(t<U)return e<0?"just now":"in a moment";for(const n of le)if(t<n.max)return e<0?rt(t,n.value,n.past.singular,n.past.plural):rt(t,n.value,n.future.singular,n.future.plural);throw new Error("unreachable")},At=(e,{now:t,frequency:n=1e4}={})=>{const s=t!=null?i.Signal.is(t)?t.derive():i.prop(t):Ot(n),a=i.computedOf(e,s)((o,r)=>o.getTime()-r.getTime());return a.onDispose(()=>i.Value.dispose(s)),a},kt=(e,t={})=>{const n=At(e,t),s=n.map(Et);return s.onDispose(()=>n.dispose()),s},ue=(e,t={})=>kt(e,t);class Pt extends i.Prop{tick=()=>this.update(t=>t+1)}const he=(e=0)=>new Pt(e,i.strictEquals);exports.Anchor=ut;exports.Appearance=Ut;exports.AsyncResultView=j;exports.AutoFocus=Kt;exports.AutoSelect=Ct;exports.ChildRouter=ie;exports.ElementRect=Zt;exports.HTMLTitle=_t;exports.HiddenWhenEmpty=zt;exports.InViewport=pt;exports.Location=K;exports.Mutation=Bt;exports.MutationDisplay=gt;exports.NavigationService=re;exports.OnClickOutside=dt;exports.OnEnterKey=qt;exports.OnEscapeKey=Qt;exports.OnKeyPressed=I;exports.PopOver=Jt;exports.Query=Xt;exports.QueryDisplay=yt;exports.Rect=H;exports.ResultView=wt;exports.RootRouter=oe;exports.RouterContextProvider=F;exports.SelectOnFocus=Gt;exports.Ticker=Pt;exports.WhenInViewport=It;exports.WindowSize=te;exports._checkExtensionCondition=ot;exports._getExtension=at;exports._makeRouteMatcher=ee;exports._parseRouteSegments=q;exports.allPlacements=Yt;exports.areLocationsEqual=ct;exports.classes=Nt;exports.evaluateLocationMatch=z;exports.getAbsoluteRect=_;exports.handleAnchorClick=it;exports.locationFromURL=V;exports.makeMutationResource=ft;exports.makeQueryResource=vt;exports.matchesKeyCombo=mt;exports.matchesRoute=St;exports.nowSignal=Ot;exports.relativeTime=ue;exports.relativeTimeMillisSignal=At;exports.relativeTimeSignal=kt;exports.ticker=he;exports.timeDiffToString=Et;exports.urlFromLocation=b;exports.useAppearance=ht;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@tempots/dom"),m=require("@tempots/std"),x=require("@floating-ui/dom"),ae=t=>{const e=t.split("/").pop();if(e==null||e.startsWith("."))return;const n=e.split(".")||[];return n.length>1?"."+n.pop():void 0},oe=(t,e)=>{const n=ae(e);return n!=null&&(t.length===0||!t.some(s=>n==s))},be=(t,e,n,s)=>{let a=t.target;for(;a!=null&&!(a instanceof HTMLAnchorElement);)a=a.parentElement;if(a==null)return!0;const o=a;if(t.button!==0||t.ctrlKey||t.metaKey||o.target!=="_self"&&o.target!==""||o.getAttribute("download")!=null)return!0;const{pathname:r,search:c,hash:l}=o;if(s){const h=r+c+l,p=o.getAttribute("href");if(!p?.startsWith("#")&&p!==h)return!0}return e?!1:oe(n,r)},ie=(t,e={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const n=e.ignoreUrlWithExtension===!0&&Array.isArray(e.allowedExtensions)?e.allowedExtensions.map(s=>s.startsWith(".")?s:"."+s):[];return s=>{be(s,e.ignoreUrlWithExtension??!0,n,e.ignoreExternalUrl??!0)||t()&&s.preventDefault()}},ce=(t,e)=>t.pathname===e.pathname&&JSON.stringify(t.search)===JSON.stringify(e.search)&&t.hash===e.hash,V=(t,e)=>{const n=new URL(t,e??i.getWindow()?.location.toString()),s=Object.fromEntries(n.searchParams?.entries()??[]);let a=n.hash;return a.startsWith("#")&&(a=a.substring(1)),{pathname:n.pathname,search:s,hash:a===""?void 0:a}},b=t=>{const n=new URLSearchParams(t.search).toString(),s=t.hash;return`${t.pathname}${n?`?${n}`:""}${s?`#${s}`:""}`},xe=t=>{document.startViewTransition?document.startViewTransition(t):t()},X=()=>{const t=i.getWindow(),e=t?.location.hash??"";return{pathname:t?.location.pathname??"",search:Object.fromEntries(new URLSearchParams(t?.location.search??"").entries()),hash:e.startsWith("#")?e.substring(1)||void 0:e===""?void 0:e}},G=t=>{if(t?.scroll!=="auto")return;const e=i.getWindow();e&&e.requestAnimationFrame(()=>e.scrollTo({top:0,left:0,behavior:"auto"}))},Z=(t,e)=>{e?.viewTransition?xe(t):t()},Le=()=>{const t=i.prop(X(),ce),e=i.getWindow(),n=()=>{t.set(X())};e?.addEventListener("popstate",n),e?.addEventListener("hashchange",n);const s=(l,h,p)=>{Z(()=>{if(e){const w=b(l),g=h?.state??{};p==="replaceState"||h?.replace?e.history.replaceState(g,"",w):e.history.pushState(g,"",w)}t.set(l)},h),G(h)},a=(l,h)=>{Z(()=>{e?.history.go(l)},h),G(h)};return{location:t,commit:s,go:a,back:l=>a(-1,l),forward:l=>a(1,l),resolve:l=>V(l),dispose:()=>{e?.removeEventListener("popstate",n),e?.removeEventListener("hashchange",n),t.dispose()}}},We=t=>t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//"),Te=t=>{const e=t.container.currentURL,n=e.iso(r=>V(r,e.value),r=>{if(We(r.pathname))return b(r);const c=new URL(r.pathname,e.value),l=c.origin+c.pathname;return b({...r,pathname:l})});return{location:n,dispose:()=>{n.dispose()},commit:(r,c,l)=>{n.set(r)},go:(r,c)=>{},back:r=>{},forward:r=>{},resolve:r=>V(r,e.value)}},W=t=>({pathname:t.pathname,search:{...t.search},hash:t.hash??void 0}),N=t=>{if(t==null)return;const e=`${t}`;return e===""?void 0:e},le=(t,e)=>{const n={...t};for(const[s,a]of Object.entries(e))a==null?delete n[s]:n[s]=a;return n},He=(t,e)=>{const n=e?.includeSearch??!0,s=e?.includeHash??!0,a=e?.ignoreSearchParams??[];let o;if(!n)o={};else if(a.length===0)o={...t.search};else{const r=new Set(a);o={};for(const[c,l]of Object.entries(t.search))r.has(c)||(o[c]=l)}return{pathname:t.pathname,search:o,hash:s?t.hash:void 0}},z=(t,e,n)=>{const s=He(t,n);return typeof e=="string"?b(s)===e:e instanceof RegExp?((e.global||e.sticky)&&(e.lastIndex=0),e.test(b(s))):e(s)};class De{constructor(e){this.current=e}get location(){return this.current}setLocation(e){return this.current=W(e),this}setPathname(e){return this.current={...this.current,pathname:e},this}setHash(e){const n=N(e);if(n==null){const{hash:s,...a}=this.current;this.current=a}else this.current={...this.current,hash:n};return this}clearHash(){const{hash:e,...n}=this.current;return this.current=n,this}setSearch(e){return this.current={...this.current,search:le(this.current.search,e)},this}setSearchParam(e,n){return this.setSearch({[e]:n})}updateSearch(e){return this.current={...this.current,search:{...e({...this.current.search})}},this}}const Me=(t,e)=>t?.replace?"replaceState":e,Ve=t=>{const e=t.location,n=e.map(b),s=e.map(u=>u.pathname),a=e.map(u=>({...u.search})),o=e.map(u=>u.hash),r=(u,d)=>z(t.location.value,u,d),c=(u,d)=>i.computedOf(e,u)((f,P)=>z(f,P,d)),l=(u,d,f)=>{const P=W({...u,hash:N(u.hash??void 0)});t.commit(P,d,f)},h=(u,d)=>{const f=Me(d,"pushState");l(u,d,f)},p=(u,d)=>{const f=u(W(t.location.value));h(f,d)},w=(u,d)=>{const f=t.resolve(u);h(f,d)},g=(u,d)=>{const f={...d,replace:!0};w(u,f)},k=(u,d)=>{t.go(u,d)},y=u=>{t.back(u)},O=u=>{t.forward(u)},v=(u,d)=>p(f=>({...f,pathname:u}),d),E=(u,d)=>p(f=>{const P={...f},J=N(u);return J==null?delete P.hash:P.hash=J,P},d),R=u=>E(void 0,u),S=(u,d)=>p(f=>({...f,search:le(f.search,u)}),d);return{handle:{location:e,url:n,pathname:s,search:a,hash:o,setLocation:h,updateLocation:p,navigate:w,replace:g,go:k,back:y,forward:O,setPathname:v,setHash:E,clearHash:R,setSearch:S,setSearchParam:(u,d,f)=>S({[u]:d},f),updateSearch:(u,d)=>p(f=>({...f,search:{...u({...f.search})}}),d),queryParam:u=>e.map(d=>d.search[u]),run:(u,d)=>{const f=new De(W(t.location.value));u(f),h(W(f.location),d)},match:r,matchSignal:c},dispose:()=>{t.dispose(),n.dispose(),s.dispose(),a.dispose(),o.dispose()}}},Fe=t=>{if(t.isBrowser())return Le();if(t.isHeadless())return Te(t);throw new Error("Unknown context")},K={mark:i.makeProviderMark("Location"),create:(t,e)=>{const n=Fe(e),{handle:s,dispose:a}=Ve(n);return{value:s,dispose:a}}},ue=(t,...e)=>{if(typeof t=="string"||i.Signal.is(t))return ue({href:t},...e);const{href:n,state:s,scroll:a,viewTransition:o,replace:r,...c}=t;return i.Use(K,l=>i.html.a(i.on.click(ie(()=>{let h=!1;const p={};return s!==void 0&&(p.state=s,h=!0),a!==void 0&&(p.scroll=a,h=!0),o!==void 0&&(p.viewTransition=o,h=!0),r!==void 0&&(p.replace=r,h=!0),l.navigate(i.Value.get(n),h?p:void 0),!0},c)),i.attr.href(n),...e))},Ue={mark:i.makeProviderMark("Appearance"),create:()=>{const t=he();return{value:t,dispose:()=>t.dispose()}}};function he(){const t=i.getWindow(),e=t!=null&&t.matchMedia!=null?t.matchMedia("(prefers-color-scheme: dark)"):void 0,n=e?.matches??!1,s=i.prop(n?"dark":"light"),a=o=>s.set(o.matches?"dark":"light");return e?.addEventListener("change",a),s.onDispose(()=>e?.removeEventListener("change",a)),s}const j=(t,e)=>{if(typeof e=="function")return j(t,{success:e});const n=e.failure??(r=>r.map(c=>`Error: ${c}`)),s=e.success,a=e.loading??(()=>i.Empty),o=e.notAsked??(()=>i.Empty);return i.OneOfType(i.Value.toSignal(t),{AsyncSuccess:r=>s(r.$.value),AsyncFailure:r=>n(r.$.error),Loading:r=>a(r.map(c=>c.previousValue)),NotAsked:o})},Ke=(t=10)=>i.WithElement(e=>i.OnDispose(m.delayed(()=>e?.focus(),t))),Ce=(t=10)=>i.WithElement(e=>{const n=m.delayed(()=>e.select(),t);return i.OnDispose(n)});function Ne(t){const e=Object.entries(t);return i.Fragment(...e.map(([n,s])=>i.attr.class(i.Value.map(s,a=>a?n:void 0))))}const ze=i.WithElement(t=>{const e=t.style.getPropertyValue(":empty");return t.style.setProperty(":empty","display:none"),i.OnDispose(n=>{n&&t.style.setProperty(":empty",e)})}),_e=t=>i.Portal("head > title",i.attr.innerText(t)),$e={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},M={partial:new Map,full:new Map},T={partial:null,full:null};function je(t){return T[t]==null&&(T[t]=new IntersectionObserver(e=>{e.forEach(n=>{M[t].get(n.target)?.set(n.isIntersecting)})},$e[t])),T[t]}const pe=({mode:t="partial",once:e=!1},n)=>{const s=i.prop(!1);return i.Fragment(i.WithElement(a=>{const o=typeof IntersectionObserver<"u"?je(t):null;M[t].set(a,s),o?.observe(a);function r(){o?.unobserve(a),M[t].delete(a),M[t].size===0&&(T[t]?.disconnect(),T[t]=null)}let c=null;return e&&(c=s.on(l=>{l&&r()})),i.OnDispose(()=>{s.dispose(),r(),c?.()})}),i.renderableOfTNode(n(s)))},qe=(t,e,n)=>pe(t,s=>i.When(s,e,n??(()=>i.Empty)));function de(t){return i.WithElement(e=>{const n=s=>{e.contains(s.target)||t(s)};return document.addEventListener("click",n),i.OnDispose(()=>{document.removeEventListener("click",n)})})}const L=(t,e)=>t===void 0||t===e,ee=(t,e)=>t===void 0||t===e;function me(t,e){return typeof t=="string"?e.key===t:ee(t.key,e.key)&&ee(t.code,e.code)&&L(t.ctrlKey,e.ctrlKey)&&L(t.altKey,e.altKey)&&L(t.shiftKey,e.shiftKey)&&L(t.metaKey,e.metaKey)&&L(t.repeat,e.repeat)&&L(t.commandOrControlKey,e.metaKey||e.ctrlKey)}function q({allowedKeys:t,handler:e}){return i.WithElement(n=>{const s=a=>{if(n.contains(a.target)){for(const o of t)if(me(o,a)){e(a);break}}};return document.addEventListener("keydown",s),i.OnDispose(()=>{document.removeEventListener("keydown",s)})})}function Ie(t){return q({allowedKeys:["Enter"],handler:t})}function Qe(t){return q({allowedKeys:["Escape"],handler:t})}const fe=({mutate:t,convertError:e,onSuccess:n,onError:s,onSettled:a})=>{let o;const r=i.prop(m.AsyncResult.notAsked),c=r.map(y=>m.AsyncResult.isSuccess(y)?y.value:void 0),l=r.map(y=>m.AsyncResult.isFailure(y)?y.error:void 0),h=r.map(y=>m.AsyncResult.isLoading(y)),p=()=>{o?.abort(),o=void 0},w=y=>{p(),r.set(y??m.AsyncResult.notAsked)};return{status:r,value:c,error:l,pending:h,execute:async(y,O)=>{p(),o=new AbortController;const v=o.signal,E=r.get(),R=O?.optimisticValue??(O?.optimisticFromRequest!=null?O.optimisticFromRequest(y):void 0);R!=null?r.set(m.AsyncResult.loading(R)):r.set(m.AsyncResult.loading(m.AsyncResult.getOrUndefined(E)));try{const S=await t({request:y,abortSignal:v,previous:E,cancel:w});o=void 0,r.set(m.AsyncResult.success(S)),n?.(S,y)}catch(S){o=void 0;const A=e(S);r.set(m.AsyncResult.failure(A)),s?.(A,y)}a?.(r.get(),y)},cancel:w,dispose:()=>{o?.abort(),o=void 0,r.dispose()}}},ge=(t,e)=>{const{status:n,dispose:s,execute:a,cancel:o,pending:r,error:c,value:l}=t,{content:h}=e,p=i.previousSignal(l);return i.Fragment(i.OnDispose(s),h({previous:p,execute:a,cancel:o,pending:r,error:c,value:l,status:n}))},Be=({mutate:t,convertError:e=r=>r,onSuccess:n,onError:s,onSettled:a,content:o})=>{const r=fe({mutate:t,convertError:e,onSuccess:n,onError:s,onSettled:a});return ge(r,{content:o})},Ye=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],Je=(t,e={isOpen:!1})=>{let n=null;const s=i.Value.deriveProp(e.isOpen);function a(r){n=r,s.set(!0)}function o(){s.set(!1)}return i.Fragment(t(a,o),i.When(s,()=>i.Fragment(n?.onClickOutside!=null?de(n.onClickOutside):null,i.WithElement(r=>i.Portal("body",i.html.div(i.WithElement(c=>{c.style.position="absolute",c.style.width="max-content";const l=typeof n?.target=="string"?r.querySelector(n.target):n?.target??r;if(l==null)throw new Error(`Target not found: ${n?.target}`);let h=null;const p=i.Value.toSignal(n?.mainAxisOffset??0),w=i.Value.toSignal(n?.crossAxisOffset??0),g=i.Value.toSignal(n?.placement??"top"),k=i.Value.toSignal(n?.arrowPadding??0),y=n?.arrow,O=i.prop({centerOffset:0,alignmentOffset:0,containerWidth:0,containerHeight:0,x:void 0,y:void 0});async function v(){const R=[x.flip(),x.offset({mainAxis:p.get(),crossAxis:w.get()}),x.shift()];y!=null&&h!=null&&R.push(x.arrow({element:h,padding:k.get()}));const S=await x.computePosition(l,c,{placement:g.get(),strategy:"absolute",middleware:R}),{x:A,y:Q,middlewareData:C}=S;if(c.style.top=`${Q}px`,c.style.left=`${A}px`,h!=null&&C.arrow!=null){const{x:B,y:Y,centerOffset:u,alignmentOffset:d}=C.arrow;O.set({x:B,y:Y,centerOffset:u,alignmentOffset:d,containerWidth:c.offsetWidth,containerHeight:c.offsetHeight})}}const E=i.effectOf(p,w,g)(v);return i.Fragment(n?.content,n?.arrow!=null?i.html.div(n?.arrow(i.computedOf(O,g)((R,S)=>({...R,placement:S}))),i.WithElement(R=>{h=R,v()})):null,i.OnDispose(x.autoUpdate(l,c,v),E))})))))))},ve=({request:t,load:e,convertError:n,onSuccess:s,onError:a,onSettled:o})=>{let r;const c=i.prop(m.AsyncResult.notAsked),l=c.map(v=>m.AsyncResult.isSuccess(v)?v.value:void 0),h=c.map(v=>m.AsyncResult.isFailure(v)?v.error:void 0),p=c.map(v=>m.AsyncResult.isLoading(v)),w=()=>{r?.abort(),r=void 0},g=v=>{w(),c.set(v??m.AsyncResult.notAsked)},k=async v=>{w(),r=new AbortController;const E=r.signal,R=c.get();c.set(m.AsyncResult.loading(m.AsyncResult.getOrUndefined(R)));try{const S=await e({request:v,abortSignal:E,previous:R,cancel:g});await Promise.resolve(),r=void 0,c.set(m.AsyncResult.success(S)),s?.(S,v)}catch(S){r=void 0;const A=n(S);c.set(m.AsyncResult.failure(A)),a?.(A,v)}o?.(c.get(),v)},y=()=>k(i.Value.get(t)),O=()=>{r?.abort(),r=void 0,c.dispose()};return c.onDispose(i.Value.on(t,k)),{status:c,value:l,error:h,loading:p,cancel:g,reload:y,dispose:O}},ye=(t,e)=>{const{status:n,dispose:s,reload:a,loading:o}=t,{notAsked:r,pending:c,failure:l,success:h,keepOnReload:p=!1}=e,w=p?n.map(g=>m.AsyncResult.isLoading(g)&&g.previousValue!==void 0?m.AsyncResult.success(g.previousValue):g):n;return i.Fragment(i.OnDispose(s),j(w,{notAsked:r,loading:c!=null?g=>c({previous:g,reload:a,cancel:t.cancel}):void 0,failure:l!=null?g=>l({error:g,reload:a}):void 0,success:g=>h({value:g,reload:a,loading:o})}))},Xe=({request:t,load:e,convertError:n=w=>w,onSuccess:s,onError:a,onSettled:o,notAsked:r,success:c,pending:l,failure:h,keepOnReload:p})=>{const w=ve({request:t,load:e,convertError:n,onSuccess:s,onError:a,onSettled:o});return ye(w,{notAsked:r,success:c,pending:l,failure:h,keepOnReload:p})},we=(t,e)=>{if(typeof e=="function")return we(t,{success:e});const n=e.failure??(a=>(a.on(console.error),a.map(o=>`Error: ${o}`))),s=e.success;return i.OneOfType(i.Value.toSignal(t),{Success:a=>s(a.$.value),Failure:a=>n(a.$.error)})},Ge=()=>i.on.focus(t=>t.target?.select());class D{constructor(e,n,s,a,o,r){this.left=e,this.top=n,this.width=s,this.height=a,this.localLeft=o,this.localTop=r}static of({left:e=0,top:n=0,width:s=0,height:a=0,localLeft:o=0,localTop:r=0}){return new D(e,n,s,a,o,r)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return{x:this.left+this.width/2,y:this.top+this.height/2}}get localCenter(){return{x:this.localLeft+this.width/2,y:this.localTop+this.height/2}}get localBottom(){return this.localTop+this.height}get localRight(){return this.localLeft+this.width}get size(){return{width:this.width,height:this.height}}equals=e=>m.nearEqual(this.left,e.left)&&m.nearEqual(this.top,e.top)&&m.nearEqual(this.width,e.width)&&m.nearEqual(this.height,e.height)&&m.nearEqual(this.localLeft,e.localLeft)&&m.nearEqual(this.localTop,e.localTop)}function _(t){const e=t.getBoundingClientRect();return D.of({top:e.top+window.scrollY,left:e.left+window.scrollX,width:e.width,height:e.height,localLeft:t.offsetLeft,localTop:t.offsetTop})}const Ze=t=>i.WithBrowserCtx(e=>{const{element:n}=e,s=i.prop(_(n),(c,l)=>c.equals(l)),a=i.renderableOfTNode(t(s)).render(e),o=()=>s.set(D.of(_(n)));let r=null;return typeof ResizeObserver<"u"&&(r=new ResizeObserver(o)),r?.observe(n),i.OnDispose(c=>{r?.disconnect(),a(c)})});function te(t){return{width:t?.innerWidth??0,height:t?.innerHeight??0}}const et=t=>i.WithCtx(()=>{const e=i.getWindow(),n=i.prop(te(e),(a,o)=>a.width===o.width&&a.height===o.height),s=()=>n.set(te(e));return e?.addEventListener("resize",s),i.Fragment(i.OnDispose(()=>{e?.removeEventListener("resize",s)}),t(n))}),Se=(t,e)=>{const n=e.split("/").filter(o=>o!==""),s=o=>{try{return decodeURIComponent(o)}catch{return o}},a={};for(let o=0;o<t.length;o++){const r=t[o],c=n[o];if(!c&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==c)return null}else if(r.type==="param")a[r.name]=s(c);else if(r.type==="catch-all"){if(r.name){const l=n.slice(o).join("/");a[r.name]=s(l)}return{params:a,path:e}}}return n.length!==t.length?null:{params:a,path:e}},I=t=>t.split("/").map(e=>{if(e.startsWith(":"))return{type:"param",name:e.slice(1)};if(e.startsWith("*")){const n=e.slice(1);return n!=""?{type:"catch-all",name:n}:{type:"catch-all"}}else return{type:"literal",value:e}}).filter(e=>e.type!=="literal"||e.value!==""),tt=t=>{const e=t.map(n=>{const s=I(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of e){const r=Se(a,s);if(r)return{...r,route:o}}return null}},nt=t=>{if(t==null)throw new Error("NavigationService: no Location handle attached. Make sure to attach one before calling navigation helpers.");return t};class st{handles=[];attach(e){const n=this.handles.lastIndexOf(e);return n!==-1&&this.handles.splice(n,1),this.handles.push(e),()=>this.detach(e)}detach(e){for(let n=this.handles.length-1;n>=0;n--)if(this.handles[n]===e){this.handles.splice(n,1);break}}get current(){return this.handles[this.handles.length-1]}getHandle(){return nt(this.current)}navigate(e,n){this.getHandle().navigate(e,n)}replace(e,n){this.getHandle().replace(e,n)}go(e,n){this.getHandle().go(e,n)}back(e){this.getHandle().back(e)}forward(e){this.getHandle().forward(e)}setPathname(e,n){this.getHandle().setPathname(e,n)}setSearch(e,n){this.getHandle().setSearch(e,n)}setSearchParam(e,n,s){this.getHandle().setSearchParam(e,n,s)}updateSearch(e,n){this.getHandle().updateSearch(e,n)}setHash(e,n){this.getHandle().setHash(e,n)}clearHash(e){this.getHandle().clearHash(e)}run(e,n){this.getHandle().run(e,n)}}const rt=new st,F={mark:i.makeProviderMark("RouterContext"),create:()=>{const t=i.prop([]);return{value:t,dispose:()=>t.dispose()}}},at=(t,e,n)=>{const s=n.split("/").filter(r=>r!==""),a={};let o=0;for(let r=0;r<t.length;r++){const c=t[r],l=s[r];if(!l&&c.type!=="catch-all")return null;if(c.type==="literal"){if(c.value!==l)return null;o++}else if(c.type==="param")a[c.name]=l,o++;else if(c.type==="catch-all"){c.name&&(a[c.name]=s.slice(o).join("/"));const h="/"+s.slice(0,o).join("/"),p="/"+s.slice(o).join("/");return{params:a,matchedPath:h==="/"?"":h,remainingPath:p==="/"?"":p,route:e}}}if(s.length===t.length){const r="/"+s.join("/");return{params:a,matchedPath:r==="/"?"":r,remainingPath:"",route:e}}return null},Re=t=>{const e=t.map(n=>{const s=I(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of e){const r=at(a,o,s);if(r)return r}return null}},ot=t=>{const e=Re(Object.keys(t));return i.Provide(F,{},()=>i.Use(K,n=>i.Use(F,s=>{const a=n.location.map(o=>{const r=e(o.pathname);if(r==null)throw console.error("No route found for",o),new Error("No route found");const c={matchedPath:r.matchedPath,remainingPath:r.remainingPath,fullPath:o.pathname,params:r.params};return s.value=[...s.value,c],{params:r.params,route:r.route,path:r.matchedPath||o.pathname,search:o.search,hash:o.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),t)})))},it=t=>{const e=Re(Object.keys(t));return i.Use(F,n=>i.Use(K,s=>{const a=n.map(o=>{const r=o[o.length-1];if(r==null)throw console.error("No router context available for ChildRouter",o),new Error("No router context available for ChildRouter");const c=r.remainingPath??"",l=e(c);if(l==null)throw console.error("No route found for remaining path",c),new Error("No route found");return{params:l.params,route:l.route,path:l.matchedPath,search:s.location.value.search,hash:s.location.value.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),t)}))},U=60*1e3,$=60*U,H=24*$,ne=7*H,se=30*H,ct=365*H,lt=[{max:U*90,value:U,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:$*36,value:$,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:H*10,value:H,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:ne*6,value:ne,name:"week",past:{singular:"last week",plural:"{} weeks ago"},future:{singular:"in a week",plural:"in {} weeks"}},{max:se*18,value:se,name:"month",past:{singular:"last month",plural:"{} months ago"},future:{singular:"in a month",plural:"in {} months"}},{max:1/0,value:ct,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function re(t,e,n,s){const a=Math.round(t/e);return a<=1?n:s.replace("{}",a.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}const Oe=(t=1e3)=>{const e=i.prop(new Date),n=m.interval(()=>e.set(new Date),t);return e.onDispose(n),e},Ee=t=>{const e=Math.abs(t);if(e<U)return t<0?"just now":"in a moment";for(const n of lt)if(e<n.max)return t<0?re(e,n.value,n.past.singular,n.past.plural):re(e,n.value,n.future.singular,n.future.plural);throw new Error("unreachable")},Ae=(t,{now:e,frequency:n=1e4}={})=>{const s=e!=null?i.Signal.is(e)?e.derive():i.prop(e):Oe(n),a=i.computedOf(t,s)((o,r)=>o.getTime()-r.getTime());return a.onDispose(()=>i.Value.dispose(s)),a},ke=(t,e={})=>{const n=Ae(t,e),s=n.map(Ee);return s.onDispose(()=>n.dispose()),s},ut=(t,e={})=>ke(t,e);class Pe extends i.Prop{tick=()=>this.update(e=>e+1)}const ht=(t=0)=>new Pe(t,i.strictEquals);exports.Anchor=ue;exports.Appearance=Ue;exports.AsyncResultView=j;exports.AutoFocus=Ke;exports.AutoSelect=Ce;exports.ChildRouter=it;exports.ElementRect=Ze;exports.HTMLTitle=_e;exports.HiddenWhenEmpty=ze;exports.InViewport=pe;exports.Location=K;exports.Mutation=Be;exports.MutationDisplay=ge;exports.NavigationService=rt;exports.OnClickOutside=de;exports.OnEnterKey=Ie;exports.OnEscapeKey=Qe;exports.OnKeyPressed=q;exports.PopOver=Je;exports.Query=Xe;exports.QueryDisplay=ye;exports.Rect=D;exports.ResultView=we;exports.RootRouter=ot;exports.RouterContextProvider=F;exports.SelectOnFocus=Ge;exports.Ticker=Pe;exports.WhenInViewport=qe;exports.WindowSize=et;exports._checkExtensionCondition=oe;exports._getExtension=ae;exports._makeRouteMatcher=tt;exports._parseRouteSegments=I;exports.allPlacements=Ye;exports.areLocationsEqual=ce;exports.classes=Ne;exports.evaluateLocationMatch=z;exports.getAbsoluteRect=_;exports.handleAnchorClick=ie;exports.locationFromURL=V;exports.makeMutationResource=fe;exports.makeQueryResource=ve;exports.matchesKeyCombo=me;exports.matchesRoute=Se;exports.nowSignal=Oe;exports.relativeTime=ut;exports.relativeTimeMillisSignal=Ae;exports.relativeTimeSignal=ke;exports.ticker=ht;exports.timeDiffToString=Ee;exports.urlFromLocation=b;exports.useAppearance=he;