@tempots/ui 0.19.0 → 0.20.0

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@tempots/dom"),Et=t=>{const e=t.split("/").pop();if(e==null||e.startsWith("."))return;const o=e.split(".")||[];return o.length>1?"."+o.pop():void 0},Rt=(t,e)=>{const o=Et(e);return o!=null&&(t.length===0||!t.some(n=>o==n))},Qt=(t,e,o,n)=>{let i=t.target;for(;i!=null&&!(i instanceof HTMLAnchorElement);)i=i.parentElement;if(i==null)return!0;const r=i;if(t.button!==0||t.ctrlKey||t.metaKey||r.target!=="_self"&&r.target!==""||r.getAttribute("download")!=null)return!0;const{pathname:s,search:c,hash:a}=r;if(n){const l=s+c+a,f=r.getAttribute("href");if(!(f!=null&&f.startsWith("#"))&&f!==l)return!0}return e?!1:Rt(o,s)},Ot=(t,e={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const o=e.ignoreUrlWithExtension===!0&&Array.isArray(e.allowedExtensions)?e.allowedExtensions.map(n=>n.startsWith(".")?n:"."+n):[];return n=>{Qt(n,e.ignoreUrlWithExtension??!0,o,e.ignoreExternalUrl??!0)||t()&&n.preventDefault()}},ct=u.makeProviderMark("LocationProvider"),Lt=()=>{const t=(window==null?void 0:window.location.hash)===""?void 0:(window==null?void 0:window.location.hash.substring(1))??void 0;return{pathname:(window==null?void 0:window.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((window==null?void 0:window.location.search)??"").entries()),hash:t}},St=(t,e)=>t.pathname===e.pathname&&JSON.stringify(t.search)===JSON.stringify(e.search)&&t.hash===e.hash,kt=t=>{const e=new URL(t,(window==null?void 0:window.location.toString())??""),o=Object.fromEntries(e.searchParams.entries());let n=e.hash;return n.startsWith("#")&&(n=n.substring(1)),{pathname:e.pathname,search:o,hash:n===""?void 0:n}},Tt=(t,e)=>{const o=kt(e);return t.set(o),t},Pt=t=>{const o=new URLSearchParams(t.search).toString(),n=t.hash;return`${t.pathname}${o?`?${o}`:""}${n?`#${n}`:""}`},Ct=()=>{const t=u.makeProp(Lt(),St),e=()=>{let o=(window==null?void 0:window.location.hash)??"";o.startsWith("#")&&(o=o.substring(1));const n={pathname:(window==null?void 0:window.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((window==null?void 0:window.location.search)??"").entries()),hash:o===""?void 0:o};t.set(n)};return window==null||window.addEventListener("popstate",e),t.onDispose(()=>{window==null||window.removeEventListener("popstate",e)}),t.on(o=>{window==null||window.history.pushState({},"",Pt(o))}),t},Zt=t=>{const e=Ct();return u.Fragment(u.OnUnmount(e.dispose),u.WithProvider(ct,e,t))},lt=t=>u.UseProvider(ct,e=>o=>{const n=u.makeProp(e.value,e.equals);e.feedProp(n),n.on(e.set);const i=u.renderableOfTNode(t(n))(o);return r=>{n.dispose(),i(r)}}),Ft=(t,...e)=>{if(typeof t=="string"||u.Signal.is(t))return Ft({href:t},...e);const{href:o,...n}=t;return lt(i=>u.html.a(u.on.click(Ot(()=>(Tt(i,u.Value.get(o)),!0),n)),u.attr.href(o),...e))},at=u.makeProviderMark("Appearance"),te=t=>{const e=window.matchMedia!=null&&window.matchMedia("(prefers-color-scheme: dark)").matches,o=u.makeProp(e?"dark":"light"),n=r=>{o.set(r.matches?"dark":"light")},i=window.matchMedia!=null?window.matchMedia("(prefers-color-scheme: dark)"):void 0;return i==null||i.addEventListener("change",n),u.Fragment(u.WithProvider(at,o,t),u.OnUnmount(()=>i==null?void 0:i.removeEventListener("change",n)))},ee=t=>u.UseProvider(at,t),Mt=(t,e)=>{if(typeof e=="function")return Mt(t,{success:e});const o=e.failure??(s=>u.Fragment(u.OnUnmount(s.on(console.error)),s.map(c=>`Error: ${c}`))),n=e.success,i=e.loading??(()=>u.Empty),r=e.notAsked??(()=>u.Empty);return u.OneOfType(u.Value.toSignal(t),{AsyncSuccess:s=>n(s.$.value),AsyncFailure:s=>o(s.$.error),Loading:s=>i(s.$.previousValue??u.makeSignal(void 0)),NotAsked:r})},ne=(t=10)=>e=>{const o=setTimeout(()=>{var n;(n=e.element)==null||n.focus()},t);return n=>clearTimeout(o)},oe=(t=10)=>e=>{const o=setTimeout(()=>{var n;(n=e.element)==null||n.select()},t);return n=>{clearTimeout(o)}},ie=t=>{const e=t.element,o=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),n=>{n&&e.style.setProperty(":empty",o)}},re=t=>u.Portal("head > title",u.attr.innerText(t)),se={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},K={partial:new Map,full:new Map},I={partial:null,full:null};function ce(t){return I[t]==null&&(I[t]=new IntersectionObserver(e=>{e.forEach(o=>{const n=K[t].get(o.target);n==null||n.set(o.isIntersecting)})},se[t])),I[t]}const Wt=(t,e)=>{const o=u.makeProp(u.isSSR());return u.Fragment(u.OnMount(n=>{const i=typeof IntersectionObserver<"u"?ce(t):null;return K[t].set(n,o),i==null||i.observe(n),()=>{var r;i==null||i.unobserve(n),K[t].delete(n),K[t].size===0&&((r=I[t])==null||r.disconnect(),I[t]=null)}}),u.OnUnmount(o.dispose),u.renderableOfTNode(e(o)))},le=(t,e,o)=>Wt(t,n=>u.When(n,e,o??u.Empty)),J=Math.min,M=Math.max,G=Math.round,Y=Math.floor,P=t=>({x:t,y:t}),ae={left:"right",right:"left",bottom:"top",top:"bottom"},ue={start:"end",end:"start"};function wt(t,e,o){return M(t,J(e,o))}function tt(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function et(t){return t.split("-")[1]}function Vt(t){return t==="x"?"y":"x"}function Dt(t){return t==="y"?"height":"width"}function _(t){return["top","bottom"].includes(W(t))?"y":"x"}function Nt(t){return Vt(_(t))}function fe(t,e,o){o===void 0&&(o=!1);const n=et(t),i=Nt(t),r=Dt(i);let s=i==="x"?n===(o?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=Q(s)),[s,Q(s)]}function de(t){const e=Q(t);return[st(t),e,st(e)]}function st(t){return t.replace(/start|end/g,e=>ue[e])}function he(t,e,o){const n=["left","right"],i=["right","left"],r=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return o?e?i:n:e?n:i;case"left":case"right":return e?r:s;default:return[]}}function me(t,e,o,n){const i=et(t);let r=he(W(t),o==="start",n);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(st)))),r}function Q(t){return t.replace(/left|right|bottom|top/g,e=>ae[e])}function pe(t){return{top:0,right:0,bottom:0,left:0,...t}}function ge(t){return typeof t!="number"?pe(t):{top:t,right:t,bottom:t,left:t}}function Z(t){const{x:e,y:o,width:n,height:i}=t;return{width:n,height:i,top:o,left:e,right:e+n,bottom:o+i,x:e,y:o}}function yt(t,e,o){let{reference:n,floating:i}=t;const r=_(e),s=Nt(e),c=Dt(s),a=W(e),l=r==="y",f=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,p=n[c]/2-i[c]/2;let h;switch(a){case"top":h={x:f,y:n.y-i.height};break;case"bottom":h={x:f,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:d};break;case"left":h={x:n.x-i.width,y:d};break;default:h={x:n.x,y:n.y}}switch(et(e)){case"start":h[s]-=p*(o&&l?-1:1);break;case"end":h[s]+=p*(o&&l?-1:1);break}return h}const we=async(t,e,o)=>{const{placement:n="bottom",strategy:i="absolute",middleware:r=[],platform:s}=o,c=r.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e));let l=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:d}=yt(l,n,a),p=n,h={},g=0;for(let w=0;w<c.length;w++){const{name:y,fn:m}=c[w],{x:v,y:x,data:A,reset:b}=await m({x:f,y:d,initialPlacement:n,placement:p,strategy:i,middlewareData:h,rects:l,platform:s,elements:{reference:t,floating:e}});f=v??f,d=x??d,h={...h,[y]:{...h[y],...A}},b&&g<=50&&(g++,typeof b=="object"&&(b.placement&&(p=b.placement),b.rects&&(l=b.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):b.rects),{x:f,y:d}=yt(l,p,a)),w=-1)}return{x:f,y:d,placement:p,strategy:i,middlewareData:h}};async function Ut(t,e){var o;e===void 0&&(e={});const{x:n,y:i,platform:r,rects:s,elements:c,strategy:a}=t,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:p=!1,padding:h=0}=tt(e,t),g=ge(h),y=c[p?d==="floating"?"reference":"floating":d],m=Z(await r.getClippingRect({element:(o=await(r.isElement==null?void 0:r.isElement(y)))==null||o?y:y.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:l,rootBoundary:f,strategy:a})),v=d==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,x=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),A=await(r.isElement==null?void 0:r.isElement(x))?await(r.getScale==null?void 0:r.getScale(x))||{x:1,y:1}:{x:1,y:1},b=Z(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:x,strategy:a}):v);return{top:(m.top-b.top+g.top)/A.y,bottom:(b.bottom-m.bottom+g.bottom)/A.y,left:(m.left-b.left+g.left)/A.x,right:(b.right-m.right+g.right)/A.x}}const ye=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var o,n;const{placement:i,middlewareData:r,rects:s,initialPlacement:c,platform:a,elements:l}=e,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:w=!0,...y}=tt(t,e);if((o=r.arrow)!=null&&o.alignmentOffset)return{};const m=W(i),v=_(c),x=W(c)===c,A=await(a.isRTL==null?void 0:a.isRTL(l.floating)),b=p||(x||!w?[Q(c)]:de(c)),D=g!=="none";!p&&D&&b.push(...me(c,w,g,A));const Jt=[c,...b],it=await Ut(e,y),X=[];let H=((n=r.flip)==null?void 0:n.overflows)||[];if(f&&X.push(it[m]),d){const F=fe(i,s,A);X.push(it[F[0]],it[F[1]])}if(H=[...H,{placement:i,overflows:X}],!X.every(F=>F<=0)){var ht,mt;const F=(((ht=r.flip)==null?void 0:ht.index)||0)+1,gt=Jt[F];if(gt)return{data:{index:F,overflows:H},reset:{placement:gt}};let B=(mt=H.filter(N=>N.overflows[0]<=0).sort((N,k)=>N.overflows[1]-k.overflows[1])[0])==null?void 0:mt.placement;if(!B)switch(h){case"bestFit":{var pt;const N=(pt=H.filter(k=>{if(D){const T=_(k.placement);return T===v||T==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(T=>T>0).reduce((T,Gt)=>T+Gt,0)]).sort((k,T)=>k[1]-T[1])[0])==null?void 0:pt[0];N&&(B=N);break}case"initialPlacement":B=c;break}if(i!==B)return{reset:{placement:B}}}return{}}}};async function ve(t,e){const{placement:o,platform:n,elements:i}=t,r=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=W(o),c=et(o),a=_(o)==="y",l=["left","top"].includes(s)?-1:1,f=r&&a?-1:1,d=tt(e,t);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),a?{x:h*f,y:p*l}:{x:p*l,y:h*f}}const xe=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var o,n;const{x:i,y:r,placement:s,middlewareData:c}=e,a=await ve(e,t);return s===((o=c.offset)==null?void 0:o.placement)&&(n=c.arrow)!=null&&n.alignmentOffset?{}:{x:i+a.x,y:r+a.y,data:{...a,placement:s}}}}},be=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:o,y:n,placement:i}=e,{mainAxis:r=!0,crossAxis:s=!1,limiter:c={fn:y=>{let{x:m,y:v}=y;return{x:m,y:v}}},...a}=tt(t,e),l={x:o,y:n},f=await Ut(e,a),d=_(W(i)),p=Vt(d);let h=l[p],g=l[d];if(r){const y=p==="y"?"top":"left",m=p==="y"?"bottom":"right",v=h+f[y],x=h-f[m];h=wt(v,h,x)}if(s){const y=d==="y"?"top":"left",m=d==="y"?"bottom":"right",v=g+f[y],x=g-f[m];g=wt(v,g,x)}const w=c.fn({...e,[p]:h,[d]:g});return{...w,data:{x:w.x-o,y:w.y-n}}}}};function z(t){return _t(t)?(t.nodeName||"").toLowerCase():"#document"}function E(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function S(t){var e;return(e=(_t(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function _t(t){return t instanceof Node||t instanceof E(t).Node}function O(t){return t instanceof Element||t instanceof E(t).Element}function L(t){return t instanceof HTMLElement||t instanceof E(t).HTMLElement}function vt(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof E(t).ShadowRoot}function q(t){const{overflow:e,overflowX:o,overflowY:n,display:i}=R(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+o)&&!["inline","contents"].includes(i)}function Ae(t){return["table","td","th"].includes(z(t))}function nt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function ut(t){const e=ft(),o=R(t);return o.transform!=="none"||o.perspective!=="none"||(o.containerType?o.containerType!=="normal":!1)||!e&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!e&&(o.filter?o.filter!=="none":!1)||["transform","perspective","filter"].some(n=>(o.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(o.contain||"").includes(n))}function Ee(t){let e=C(t);for(;L(e)&&!$(e);){if(nt(e))return null;if(ut(e))return e;e=C(e)}return null}function ft(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function $(t){return["html","body","#document"].includes(z(t))}function R(t){return E(t).getComputedStyle(t)}function ot(t){return O(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function C(t){if(z(t)==="html")return t;const e=t.assignedSlot||t.parentNode||vt(t)&&t.host||S(t);return vt(e)?e.host:e}function $t(t){const e=C(t);return $(e)?t.ownerDocument?t.ownerDocument.body:t.body:L(e)&&q(e)?e:$t(e)}function j(t,e,o){var n;e===void 0&&(e=[]),o===void 0&&(o=!0);const i=$t(t),r=i===((n=t.ownerDocument)==null?void 0:n.body),s=E(i);return r?e.concat(s,s.visualViewport||[],q(i)?i:[],s.frameElement&&o?j(s.frameElement):[]):e.concat(i,j(i,[],o))}function zt(t){const e=R(t);let o=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const i=L(t),r=i?t.offsetWidth:o,s=i?t.offsetHeight:n,c=G(o)!==r||G(n)!==s;return c&&(o=r,n=s),{width:o,height:n,$:c}}function dt(t){return O(t)?t:t.contextElement}function U(t){const e=dt(t);if(!L(e))return P(1);const o=e.getBoundingClientRect(),{width:n,height:i,$:r}=zt(e);let s=(r?G(o.width):o.width)/n,c=(r?G(o.height):o.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const Re=P(0);function Ht(t){const e=E(t);return!ft()||!e.visualViewport?Re:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Oe(t,e,o){return e===void 0&&(e=!1),!o||e&&o!==E(t)?!1:e}function V(t,e,o,n){e===void 0&&(e=!1),o===void 0&&(o=!1);const i=t.getBoundingClientRect(),r=dt(t);let s=P(1);e&&(n?O(n)&&(s=U(n)):s=U(t));const c=Oe(r,o,n)?Ht(r):P(0);let a=(i.left+c.x)/s.x,l=(i.top+c.y)/s.y,f=i.width/s.x,d=i.height/s.y;if(r){const p=E(r),h=n&&O(n)?E(n):n;let g=p,w=g.frameElement;for(;w&&n&&h!==g;){const y=U(w),m=w.getBoundingClientRect(),v=R(w),x=m.left+(w.clientLeft+parseFloat(v.paddingLeft))*y.x,A=m.top+(w.clientTop+parseFloat(v.paddingTop))*y.y;a*=y.x,l*=y.y,f*=y.x,d*=y.y,a+=x,l+=A,g=E(w),w=g.frameElement}}return Z({width:f,height:d,x:a,y:l})}function Le(t){let{elements:e,rect:o,offsetParent:n,strategy:i}=t;const r=i==="fixed",s=S(n),c=e?nt(e.floating):!1;if(n===s||c&&r)return o;let a={scrollLeft:0,scrollTop:0},l=P(1);const f=P(0),d=L(n);if((d||!d&&!r)&&((z(n)!=="body"||q(s))&&(a=ot(n)),L(n))){const p=V(n);l=U(n),f.x=p.x+n.clientLeft,f.y=p.y+n.clientTop}return{width:o.width*l.x,height:o.height*l.y,x:o.x*l.x-a.scrollLeft*l.x+f.x,y:o.y*l.y-a.scrollTop*l.y+f.y}}function Se(t){return Array.from(t.getClientRects())}function Bt(t){return V(S(t)).left+ot(t).scrollLeft}function ke(t){const e=S(t),o=ot(t),n=t.ownerDocument.body,i=M(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=M(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-o.scrollLeft+Bt(t);const c=-o.scrollTop;return R(n).direction==="rtl"&&(s+=M(e.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:c}}function Te(t,e){const o=E(t),n=S(t),i=o.visualViewport;let r=n.clientWidth,s=n.clientHeight,c=0,a=0;if(i){r=i.width,s=i.height;const l=ft();(!l||l&&e==="fixed")&&(c=i.offsetLeft,a=i.offsetTop)}return{width:r,height:s,x:c,y:a}}function Pe(t,e){const o=V(t,!0,e==="fixed"),n=o.top+t.clientTop,i=o.left+t.clientLeft,r=L(t)?U(t):P(1),s=t.clientWidth*r.x,c=t.clientHeight*r.y,a=i*r.x,l=n*r.y;return{width:s,height:c,x:a,y:l}}function xt(t,e,o){let n;if(e==="viewport")n=Te(t,o);else if(e==="document")n=ke(S(t));else if(O(e))n=Pe(e,o);else{const i=Ht(t);n={...e,x:e.x-i.x,y:e.y-i.y}}return Z(n)}function It(t,e){const o=C(t);return o===e||!O(o)||$(o)?!1:R(o).position==="fixed"||It(o,e)}function Ce(t,e){const o=e.get(t);if(o)return o;let n=j(t,[],!1).filter(c=>O(c)&&z(c)!=="body"),i=null;const r=R(t).position==="fixed";let s=r?C(t):t;for(;O(s)&&!$(s);){const c=R(s),a=ut(s);!a&&c.position==="fixed"&&(i=null),(r?!a&&!i:!a&&c.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||q(s)&&!a&&It(t,s))?n=n.filter(f=>f!==s):i=c,s=C(s)}return e.set(t,n),n}function Fe(t){let{element:e,boundary:o,rootBoundary:n,strategy:i}=t;const s=[...o==="clippingAncestors"?nt(e)?[]:Ce(e,this._c):[].concat(o),n],c=s[0],a=s.reduce((l,f)=>{const d=xt(e,f,i);return l.top=M(d.top,l.top),l.right=J(d.right,l.right),l.bottom=J(d.bottom,l.bottom),l.left=M(d.left,l.left),l},xt(e,c,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Me(t){const{width:e,height:o}=zt(t);return{width:e,height:o}}function We(t,e,o){const n=L(e),i=S(e),r=o==="fixed",s=V(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const a=P(0);if(n||!n&&!r)if((z(e)!=="body"||q(i))&&(c=ot(e)),n){const d=V(e,!0,r,e);a.x=d.x+e.clientLeft,a.y=d.y+e.clientTop}else i&&(a.x=Bt(i));const l=s.left+c.scrollLeft-a.x,f=s.top+c.scrollTop-a.y;return{x:l,y:f,width:s.width,height:s.height}}function rt(t){return R(t).position==="static"}function bt(t,e){return!L(t)||R(t).position==="fixed"?null:e?e(t):t.offsetParent}function jt(t,e){const o=E(t);if(nt(t))return o;if(!L(t)){let i=C(t);for(;i&&!$(i);){if(O(i)&&!rt(i))return i;i=C(i)}return o}let n=bt(t,e);for(;n&&Ae(n)&&rt(n);)n=bt(n,e);return n&&$(n)&&rt(n)&&!ut(n)?o:n||Ee(t)||o}const Ve=async function(t){const e=this.getOffsetParent||jt,o=this.getDimensions,n=await o(t.floating);return{reference:We(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function De(t){return R(t).direction==="rtl"}const Ne={convertOffsetParentRelativeRectToViewportRelativeRect:Le,getDocumentElement:S,getClippingRect:Fe,getOffsetParent:jt,getElementRects:Ve,getClientRects:Se,getDimensions:Me,getScale:U,isElement:O,isRTL:De};function Ue(t,e){let o=null,n;const i=S(t);function r(){var c;clearTimeout(n),(c=o)==null||c.disconnect(),o=null}function s(c,a){c===void 0&&(c=!1),a===void 0&&(a=1),r();const{left:l,top:f,width:d,height:p}=t.getBoundingClientRect();if(c||e(),!d||!p)return;const h=Y(f),g=Y(i.clientWidth-(l+d)),w=Y(i.clientHeight-(f+p)),y=Y(l),v={rootMargin:-h+"px "+-g+"px "+-w+"px "+-y+"px",threshold:M(0,J(1,a))||1};let x=!0;function A(b){const D=b[0].intersectionRatio;if(D!==a){if(!x)return s();D?s(!1,D):n=setTimeout(()=>{s(!1,1e-7)},1e3)}x=!1}try{o=new IntersectionObserver(A,{...v,root:i.ownerDocument})}catch{o=new IntersectionObserver(A,v)}o.observe(t)}return s(!0),r}function _e(t,e,o,n){n===void 0&&(n={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=n,l=dt(t),f=i||r?[...l?j(l):[],...j(e)]:[];f.forEach(m=>{i&&m.addEventListener("scroll",o,{passive:!0}),r&&m.addEventListener("resize",o)});const d=l&&c?Ue(l,o):null;let p=-1,h=null;s&&(h=new ResizeObserver(m=>{let[v]=m;v&&v.target===l&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),o()}),l&&!a&&h.observe(l),h.observe(e));let g,w=a?V(t):null;a&&y();function y(){const m=V(t);w&&(m.x!==w.x||m.y!==w.y||m.width!==w.width||m.height!==w.height)&&o(),w=m,g=requestAnimationFrame(y)}return o(),()=>{var m;f.forEach(v=>{i&&v.removeEventListener("scroll",o),r&&v.removeEventListener("resize",o)}),d==null||d(),(m=h)==null||m.disconnect(),h=null,a&&cancelAnimationFrame(g)}}const $e=xe,ze=be,At=ye,He=(t,e,o)=>{const n=new Map,i={platform:Ne,...o},r={...i.platform,_c:n};return we(t,e,{...i,platform:r})},Be=({content:t,open:e,placement:o,offset:{mainAxis:n,crossAxis:i}={mainAxis:0,crossAxis:0}})=>r=>{const s=r.element,c=u.Value.toSignal(e);return u.When(c,u.Portal("body",u.html.div(u.OnMount(a=>{const l=a;return l.style.position="absolute",_e(s,l,()=>{He(s,l,{placement:o,strategy:"absolute",middleware:[At(),$e({mainAxis:n,crossAxis:i}),ze(),At()]}).then(({x:f,y:d})=>{l.style.top=`${d}px`,l.style.left=`${f}px`})})}),t())))(r)},qt=(t,e)=>{if(typeof e=="function")return qt(t,{success:e});const o=e.failure??(i=>u.Fragment(u.OnUnmount(i.on(console.error)),i.map(r=>`Error: ${r}`))),n=e.success;return u.OneOfType(u.Value.toSignal(t),{Success:i=>n(i.$.value),Failure:i=>o(i.$.error)})},Ie=()=>u.on.focus(t=>{var e;return(e=t.target)==null?void 0:e.select()}),je=t=>e=>{const o=e.element,n=u.makeProp({width:o.clientWidth,height:o.clientHeight}),i=u.renderableOfTNode(t(n))(e),r=()=>{n.set({width:o.clientWidth,height:o.clientHeight})};let s;return typeof ResizeObserver=="function"&&(s=new ResizeObserver(r),s.observe(o)),c=>{s==null||s.disconnect(),i(c)}},qe=t=>e=>{const o=u.makeProp({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0}),n=u.renderableOfTNode(t(o))(e),i=()=>{o.set({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0})};return window==null||window.addEventListener("resize",i),r=>{window==null||window.removeEventListener("resize",i),n(r)}},Xt=(t,e)=>{const o=e.split("/").filter(i=>i!==""),n={};for(let i=0;i<t.length;i++){const r=t[i],s=o[i];if(!s&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==s)return null}else if(r.type==="param")n[r.name]=s;else if(r.type==="catch-all")return{params:n,path:e}}return o.length!==t.length?null:{params:n,path:e}},Yt=t=>t.split("/").map(e=>e.startsWith(":")?{type:"param",name:e.slice(1)}:e==="*"?{type:"catch-all"}:{type:"literal",value:e}).filter(e=>e.type!=="literal"||e.value!==""),Kt=t=>{const e=t.map(o=>{const n=Yt(o);return{route:o,segments:n}});return function(n){for(const{segments:i,route:r}of e){const s=Xt(i,n);if(s)return{...s,route:r}}return null}},Xe=t=>{const e=Kt(Object.keys(t));return lt(o=>{const n=o.map(i=>{const r=e(i.pathname);if(r==null)throw console.error("No route found for",i),new Error("No route found");return{params:r.params,route:r.route,path:r.path,search:i.search,hash:i.hash}});return u.OneOfTuple(n.map(i=>[i.route,i]),t)})};exports.Anchor=Ft;exports.AsyncResultView=Mt;exports.AutoFocus=ne;exports.AutoSelect=oe;exports.ElementSize=je;exports.HTMLTitle=re;exports.HiddenWhenEmpty=ie;exports.InViewport=Wt;exports.LocationProviderMarker=ct;exports.PopOver=Be;exports.ProvideAppearance=te;exports.ProvideLocation=Zt;exports.ResultView=qt;exports.Router=Xe;exports.SelectOnFocus=Ie;exports.UseAppearance=ee;exports.UseLocation=lt;exports.WhenInViewport=le;exports.WindowSize=qe;exports._checkExtensionCondition=Rt;exports._getExtension=Et;exports._makeLocation=Lt;exports._makeLocationProp=Ct;exports._makeRouteMatcher=Kt;exports._parseRouteSegments=Yt;exports.appearanceMarker=at;exports.areLocationsEqual=St;exports.handleAnchorClick=Ot;exports.locationFromURL=kt;exports.matchesRoute=Xt;exports.setLocationFromUrl=Tt;exports.urlFromLocation=Pt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@tempots/dom"),Tt=t=>{const e=t.split("/").pop();if(e==null||e.startsWith("."))return;const n=e.split(".")||[];return n.length>1?"."+n.pop():void 0},Pt=(t,e)=>{const n=Tt(e);return n!=null&&(t.length===0||!t.some(o=>n==o))},ie=(t,e,n,o)=>{let r=t.target;for(;r!=null&&!(r instanceof HTMLAnchorElement);)r=r.parentElement;if(r==null)return!0;const i=r;if(t.button!==0||t.ctrlKey||t.metaKey||i.target!=="_self"&&i.target!==""||i.getAttribute("download")!=null)return!0;const{pathname:s,search:c,hash:a}=i;if(o){const l=s+c+a,f=i.getAttribute("href");if(!(f!=null&&f.startsWith("#"))&&f!==l)return!0}return e?!1:Pt(n,s)},Ct=(t,e={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const n=e.ignoreUrlWithExtension===!0&&Array.isArray(e.allowedExtensions)?e.allowedExtensions.map(o=>o.startsWith(".")?o:"."+o):[];return o=>{ie(o,e.ignoreUrlWithExtension??!0,n,e.ignoreExternalUrl??!0)||t()&&o.preventDefault()}},ut=u.makeProviderMark("LocationProvider"),Ft=()=>{const t=(window==null?void 0:window.location.hash)===""?void 0:(window==null?void 0:window.location.hash.substring(1))??void 0;return{pathname:(window==null?void 0:window.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((window==null?void 0:window.location.search)??"").entries()),hash:t}},Mt=(t,e)=>t.pathname===e.pathname&&JSON.stringify(t.search)===JSON.stringify(e.search)&&t.hash===e.hash,Wt=t=>{const e=new URL(t,(window==null?void 0:window.location.toString())??""),n=Object.fromEntries(e.searchParams.entries());let o=e.hash;return o.startsWith("#")&&(o=o.substring(1)),{pathname:e.pathname,search:n,hash:o===""?void 0:o}},Dt=(t,e)=>{const n=Wt(e);return t.set(n),t},Nt=t=>{const n=new URLSearchParams(t.search).toString(),o=t.hash;return`${t.pathname}${n?`?${n}`:""}${o?`#${o}`:""}`},Vt=()=>{const t=u.makeProp(Ft(),Mt),e=()=>{let n=(window==null?void 0:window.location.hash)??"";n.startsWith("#")&&(n=n.substring(1));const o={pathname:(window==null?void 0:window.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((window==null?void 0:window.location.search)??"").entries()),hash:n===""?void 0:n};t.set(o)};return window==null||window.addEventListener("popstate",e),t.onDispose(()=>{window==null||window.removeEventListener("popstate",e)}),t.on(n=>{window==null||window.history.pushState({},"",Nt(n))}),t},se=t=>{const e=Vt();return u.Fragment(u.OnUnmount(e.dispose),u.WithProvider(ut,e,t))},ft=t=>u.UseProvider(ut,e=>n=>{const o=u.makeProp(e.value,e.equals);e.feedProp(o),o.on(e.set);const r=u.renderableOfTNode(t(o))(n);return i=>{o.dispose(),r(i)}}),Ut=(t,...e)=>{if(typeof t=="string"||u.Signal.is(t))return Ut({href:t},...e);const{href:n,...o}=t;return ft(r=>u.html.a(u.on.click(Ct(()=>(Dt(r,u.Value.get(n)),!0),o)),u.attr.href(n),...e))},mt=u.makeProviderMark("Appearance"),ce=t=>{const e=window.matchMedia!=null&&window.matchMedia("(prefers-color-scheme: dark)").matches,n=u.makeProp(e?"dark":"light"),o=i=>{n.set(i.matches?"dark":"light")},r=window.matchMedia!=null?window.matchMedia("(prefers-color-scheme: dark)"):void 0;return r==null||r.addEventListener("change",o),u.Fragment(u.WithProvider(mt,n,t),u.OnUnmount(()=>r==null?void 0:r.removeEventListener("change",o)))},le=t=>u.UseProvider(mt,t),_t=(t,e)=>{if(typeof e=="function")return _t(t,{success:e});const n=e.failure??(s=>u.Fragment(u.OnUnmount(s.on(console.error)),s.map(c=>`Error: ${c}`))),o=e.success,r=e.loading??(()=>u.Empty),i=e.notAsked??(()=>u.Empty);return u.OneOfType(u.Value.toSignal(t),{AsyncSuccess:s=>o(s.$.value),AsyncFailure:s=>n(s.$.error),Loading:s=>r(s.$.previousValue??u.makeSignal(void 0)),NotAsked:i})},ae=(t=10)=>e=>{const n=setTimeout(()=>{var o;(o=e.element)==null||o.focus()},t);return o=>clearTimeout(n)},ue=(t=10)=>e=>{const n=setTimeout(()=>{var o;(o=e.element)==null||o.select()},t);return o=>{clearTimeout(n)}},fe=t=>{const e=t.element,n=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),o=>{o&&e.style.setProperty(":empty",n)}},me=t=>u.Portal("head > title",u.attr.innerText(t)),he={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},J={partial:new Map,full:new Map},I={partial:null,full:null};function de(t){return I[t]==null&&(I[t]=new IntersectionObserver(e=>{e.forEach(n=>{const o=J[t].get(n.target);o==null||o.set(n.isIntersecting)})},he[t])),I[t]}const $t=(t,e)=>{const n=u.makeProp(u.isSSR());return u.Fragment(u.OnMount(o=>{const r=typeof IntersectionObserver<"u"?de(t):null;return J[t].set(o,n),r==null||r.observe(o),()=>{var i;r==null||r.unobserve(o),J[t].delete(o),J[t].size===0&&((i=I[t])==null||i.disconnect(),I[t]=null)}}),u.OnUnmount(n.dispose),u.renderableOfTNode(e(n)))},pe=(t,e,n)=>$t(t,o=>u.When(o,e,n??u.Empty)),G=Math.min,M=Math.max,Q=Math.round,K=Math.floor,P=t=>({x:t,y:t}),ge={left:"right",right:"left",bottom:"top",top:"bottom"},we={start:"end",end:"start"};function xt(t,e,n){return M(t,G(e,n))}function nt(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function ot(t){return t.split("-")[1]}function zt(t){return t==="x"?"y":"x"}function Ht(t){return t==="y"?"height":"width"}function _(t){return["top","bottom"].includes(W(t))?"y":"x"}function Bt(t){return zt(_(t))}function ye(t,e,n){n===void 0&&(n=!1);const o=ot(t),r=Bt(t),i=Ht(r);let s=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=Z(s)),[s,Z(s)]}function ve(t){const e=Z(t);return[lt(t),e,lt(e)]}function lt(t){return t.replace(/start|end/g,e=>we[e])}function xe(t,e,n){const o=["left","right"],r=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return n?e?r:o:e?o:r;case"left":case"right":return e?i:s;default:return[]}}function be(t,e,n,o){const r=ot(t);let i=xe(W(t),n==="start",o);return r&&(i=i.map(s=>s+"-"+r),e&&(i=i.concat(i.map(lt)))),i}function Z(t){return t.replace(/left|right|bottom|top/g,e=>ge[e])}function Ae(t){return{top:0,right:0,bottom:0,left:0,...t}}function Ee(t){return typeof t!="number"?Ae(t):{top:t,right:t,bottom:t,left:t}}function tt(t){const{x:e,y:n,width:o,height:r}=t;return{width:o,height:r,top:n,left:e,right:e+o,bottom:n+r,x:e,y:n}}function bt(t,e,n){let{reference:o,floating:r}=t;const i=_(e),s=Bt(e),c=Ht(s),a=W(e),l=i==="y",f=o.x+o.width/2-r.width/2,m=o.y+o.height/2-r.height/2,p=o[c]/2-r[c]/2;let h;switch(a){case"top":h={x:f,y:o.y-r.height};break;case"bottom":h={x:f,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:m};break;case"left":h={x:o.x-r.width,y:m};break;default:h={x:o.x,y:o.y}}switch(ot(e)){case"start":h[s]-=p*(n&&l?-1:1);break;case"end":h[s]+=p*(n&&l?-1:1);break}return h}const Re=async(t,e,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:s}=n,c=i.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e));let l=await s.getElementRects({reference:t,floating:e,strategy:r}),{x:f,y:m}=bt(l,o,a),p=o,h={},g=0;for(let w=0;w<c.length;w++){const{name:y,fn:d}=c[w],{x:v,y:x,data:A,reset:b}=await d({x:f,y:m,initialPlacement:o,placement:p,strategy:r,middlewareData:h,rects:l,platform:s,elements:{reference:t,floating:e}});f=v??f,m=x??m,h={...h,[y]:{...h[y],...A}},b&&g<=50&&(g++,typeof b=="object"&&(b.placement&&(p=b.placement),b.rects&&(l=b.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:r}):b.rects),{x:f,y:m}=bt(l,p,a)),w=-1)}return{x:f,y:m,placement:p,strategy:r,middlewareData:h}};async function It(t,e){var n;e===void 0&&(e={});const{x:o,y:r,platform:i,rects:s,elements:c,strategy:a}=t,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:p=!1,padding:h=0}=nt(e,t),g=Ee(h),y=c[p?m==="floating"?"reference":"floating":m],d=tt(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:l,rootBoundary:f,strategy:a})),v=m==="floating"?{x:o,y:r,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),A=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},b=tt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:x,strategy:a}):v);return{top:(d.top-b.top+g.top)/A.y,bottom:(b.bottom-d.bottom+g.bottom)/A.y,left:(d.left-b.left+g.left)/A.x,right:(b.right-d.right+g.right)/A.x}}const Oe=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:r,middlewareData:i,rects:s,initialPlacement:c,platform:a,elements:l}=e,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:w=!0,...y}=nt(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const d=W(r),v=_(c),x=W(c)===c,A=await(a.isRTL==null?void 0:a.isRTL(l.floating)),b=p||(x||!w?[Z(c)]:ve(c)),N=g!=="none";!p&&N&&b.push(...be(c,w,g,A));const oe=[c,...b],st=await It(e,y),X=[];let H=((o=i.flip)==null?void 0:o.overflows)||[];if(f&&X.push(st[d]),m){const F=ye(r,s,A);X.push(st[F[0]],st[F[1]])}if(H=[...H,{placement:r,overflows:X}],!X.every(F=>F<=0)){var gt,wt;const F=(((gt=i.flip)==null?void 0:gt.index)||0)+1,vt=oe[F];if(vt)return{data:{index:F,overflows:H},reset:{placement:vt}};let B=(wt=H.filter(V=>V.overflows[0]<=0).sort((V,k)=>V.overflows[1]-k.overflows[1])[0])==null?void 0:wt.placement;if(!B)switch(h){case"bestFit":{var yt;const V=(yt=H.filter(k=>{if(N){const T=_(k.placement);return T===v||T==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(T=>T>0).reduce((T,re)=>T+re,0)]).sort((k,T)=>k[1]-T[1])[0])==null?void 0:yt[0];V&&(B=V);break}case"initialPlacement":B=c;break}if(r!==B)return{reset:{placement:B}}}return{}}}};async function Le(t,e){const{placement:n,platform:o,elements:r}=t,i=await(o.isRTL==null?void 0:o.isRTL(r.floating)),s=W(n),c=ot(n),a=_(n)==="y",l=["left","top"].includes(s)?-1:1,f=i&&a?-1:1,m=nt(e,t);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...m};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),a?{x:h*f,y:p*l}:{x:p*l,y:h*f}}const Se=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:r,y:i,placement:s,middlewareData:c}=e,a=await Le(e,t);return s===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+a.x,y:i+a.y,data:{...a,placement:s}}}}},ke=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:r}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:c={fn:y=>{let{x:d,y:v}=y;return{x:d,y:v}}},...a}=nt(t,e),l={x:n,y:o},f=await It(e,a),m=_(W(r)),p=zt(m);let h=l[p],g=l[m];if(i){const y=p==="y"?"top":"left",d=p==="y"?"bottom":"right",v=h+f[y],x=h-f[d];h=xt(v,h,x)}if(s){const y=m==="y"?"top":"left",d=m==="y"?"bottom":"right",v=g+f[y],x=g-f[d];g=xt(v,g,x)}const w=c.fn({...e,[p]:h,[m]:g});return{...w,data:{x:w.x-n,y:w.y-o}}}}};function z(t){return jt(t)?(t.nodeName||"").toLowerCase():"#document"}function E(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function S(t){var e;return(e=(jt(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function jt(t){return t instanceof Node||t instanceof E(t).Node}function O(t){return t instanceof Element||t instanceof E(t).Element}function L(t){return t instanceof HTMLElement||t instanceof E(t).HTMLElement}function At(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof E(t).ShadowRoot}function Y(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=R(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(r)}function Te(t){return["table","td","th"].includes(z(t))}function rt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function ht(t){const e=dt(),n=R(t);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(o=>(n.willChange||"").includes(o))||["paint","layout","strict","content"].some(o=>(n.contain||"").includes(o))}function Pe(t){let e=C(t);for(;L(e)&&!$(e);){if(rt(e))return null;if(ht(e))return e;e=C(e)}return null}function dt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function $(t){return["html","body","#document"].includes(z(t))}function R(t){return E(t).getComputedStyle(t)}function it(t){return O(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function C(t){if(z(t)==="html")return t;const e=t.assignedSlot||t.parentNode||At(t)&&t.host||S(t);return At(e)?e.host:e}function qt(t){const e=C(t);return $(e)?t.ownerDocument?t.ownerDocument.body:t.body:L(e)&&Y(e)?e:qt(e)}function j(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=qt(t),i=r===((o=t.ownerDocument)==null?void 0:o.body),s=E(r);return i?e.concat(s,s.visualViewport||[],Y(r)?r:[],s.frameElement&&n?j(s.frameElement):[]):e.concat(r,j(r,[],n))}function Yt(t){const e=R(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=L(t),i=r?t.offsetWidth:n,s=r?t.offsetHeight:o,c=Q(n)!==i||Q(o)!==s;return c&&(n=i,o=s),{width:n,height:o,$:c}}function pt(t){return O(t)?t:t.contextElement}function U(t){const e=pt(t);if(!L(e))return P(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:i}=Yt(e);let s=(i?Q(n.width):n.width)/o,c=(i?Q(n.height):n.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const Ce=P(0);function Xt(t){const e=E(t);return!dt()||!e.visualViewport?Ce:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Fe(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==E(t)?!1:e}function D(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=pt(t);let s=P(1);e&&(o?O(o)&&(s=U(o)):s=U(t));const c=Fe(i,n,o)?Xt(i):P(0);let a=(r.left+c.x)/s.x,l=(r.top+c.y)/s.y,f=r.width/s.x,m=r.height/s.y;if(i){const p=E(i),h=o&&O(o)?E(o):o;let g=p,w=g.frameElement;for(;w&&o&&h!==g;){const y=U(w),d=w.getBoundingClientRect(),v=R(w),x=d.left+(w.clientLeft+parseFloat(v.paddingLeft))*y.x,A=d.top+(w.clientTop+parseFloat(v.paddingTop))*y.y;a*=y.x,l*=y.y,f*=y.x,m*=y.y,a+=x,l+=A,g=E(w),w=g.frameElement}}return tt({width:f,height:m,x:a,y:l})}function Me(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const i=r==="fixed",s=S(o),c=e?rt(e.floating):!1;if(o===s||c&&i)return n;let a={scrollLeft:0,scrollTop:0},l=P(1);const f=P(0),m=L(o);if((m||!m&&!i)&&((z(o)!=="body"||Y(s))&&(a=it(o)),L(o))){const p=D(o);l=U(o),f.x=p.x+o.clientLeft,f.y=p.y+o.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-a.scrollLeft*l.x+f.x,y:n.y*l.y-a.scrollTop*l.y+f.y}}function We(t){return Array.from(t.getClientRects())}function Kt(t){return D(S(t)).left+it(t).scrollLeft}function De(t){const e=S(t),n=it(t),o=t.ownerDocument.body,r=M(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=M(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let s=-n.scrollLeft+Kt(t);const c=-n.scrollTop;return R(o).direction==="rtl"&&(s+=M(e.clientWidth,o.clientWidth)-r),{width:r,height:i,x:s,y:c}}function Ne(t,e){const n=E(t),o=S(t),r=n.visualViewport;let i=o.clientWidth,s=o.clientHeight,c=0,a=0;if(r){i=r.width,s=r.height;const l=dt();(!l||l&&e==="fixed")&&(c=r.offsetLeft,a=r.offsetTop)}return{width:i,height:s,x:c,y:a}}function Ve(t,e){const n=D(t,!0,e==="fixed"),o=n.top+t.clientTop,r=n.left+t.clientLeft,i=L(t)?U(t):P(1),s=t.clientWidth*i.x,c=t.clientHeight*i.y,a=r*i.x,l=o*i.y;return{width:s,height:c,x:a,y:l}}function Et(t,e,n){let o;if(e==="viewport")o=Ne(t,n);else if(e==="document")o=De(S(t));else if(O(e))o=Ve(e,n);else{const r=Xt(t);o={...e,x:e.x-r.x,y:e.y-r.y}}return tt(o)}function Jt(t,e){const n=C(t);return n===e||!O(n)||$(n)?!1:R(n).position==="fixed"||Jt(n,e)}function Ue(t,e){const n=e.get(t);if(n)return n;let o=j(t,[],!1).filter(c=>O(c)&&z(c)!=="body"),r=null;const i=R(t).position==="fixed";let s=i?C(t):t;for(;O(s)&&!$(s);){const c=R(s),a=ht(s);!a&&c.position==="fixed"&&(r=null),(i?!a&&!r:!a&&c.position==="static"&&!!r&&["absolute","fixed"].includes(r.position)||Y(s)&&!a&&Jt(t,s))?o=o.filter(f=>f!==s):r=c,s=C(s)}return e.set(t,o),o}function _e(t){let{element:e,boundary:n,rootBoundary:o,strategy:r}=t;const s=[...n==="clippingAncestors"?rt(e)?[]:Ue(e,this._c):[].concat(n),o],c=s[0],a=s.reduce((l,f)=>{const m=Et(e,f,r);return l.top=M(m.top,l.top),l.right=G(m.right,l.right),l.bottom=G(m.bottom,l.bottom),l.left=M(m.left,l.left),l},Et(e,c,r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function $e(t){const{width:e,height:n}=Yt(t);return{width:e,height:n}}function ze(t,e,n){const o=L(e),r=S(e),i=n==="fixed",s=D(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const a=P(0);if(o||!o&&!i)if((z(e)!=="body"||Y(r))&&(c=it(e)),o){const m=D(e,!0,i,e);a.x=m.x+e.clientLeft,a.y=m.y+e.clientTop}else r&&(a.x=Kt(r));const l=s.left+c.scrollLeft-a.x,f=s.top+c.scrollTop-a.y;return{x:l,y:f,width:s.width,height:s.height}}function ct(t){return R(t).position==="static"}function Rt(t,e){return!L(t)||R(t).position==="fixed"?null:e?e(t):t.offsetParent}function Gt(t,e){const n=E(t);if(rt(t))return n;if(!L(t)){let r=C(t);for(;r&&!$(r);){if(O(r)&&!ct(r))return r;r=C(r)}return n}let o=Rt(t,e);for(;o&&Te(o)&&ct(o);)o=Rt(o,e);return o&&$(o)&&ct(o)&&!ht(o)?n:o||Pe(t)||n}const He=async function(t){const e=this.getOffsetParent||Gt,n=this.getDimensions,o=await n(t.floating);return{reference:ze(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Be(t){return R(t).direction==="rtl"}const Ie={convertOffsetParentRelativeRectToViewportRelativeRect:Me,getDocumentElement:S,getClippingRect:_e,getOffsetParent:Gt,getElementRects:He,getClientRects:We,getDimensions:$e,getScale:U,isElement:O,isRTL:Be};function je(t,e){let n=null,o;const r=S(t);function i(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function s(c,a){c===void 0&&(c=!1),a===void 0&&(a=1),i();const{left:l,top:f,width:m,height:p}=t.getBoundingClientRect();if(c||e(),!m||!p)return;const h=K(f),g=K(r.clientWidth-(l+m)),w=K(r.clientHeight-(f+p)),y=K(l),v={rootMargin:-h+"px "+-g+"px "+-w+"px "+-y+"px",threshold:M(0,G(1,a))||1};let x=!0;function A(b){const N=b[0].intersectionRatio;if(N!==a){if(!x)return s();N?s(!1,N):o=setTimeout(()=>{s(!1,1e-7)},1e3)}x=!1}try{n=new IntersectionObserver(A,{...v,root:r.ownerDocument})}catch{n=new IntersectionObserver(A,v)}n.observe(t)}return s(!0),i}function qe(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=o,l=pt(t),f=r||i?[...l?j(l):[],...j(e)]:[];f.forEach(d=>{r&&d.addEventListener("scroll",n,{passive:!0}),i&&d.addEventListener("resize",n)});const m=l&&c?je(l,n):null;let p=-1,h=null;s&&(h=new ResizeObserver(d=>{let[v]=d;v&&v.target===l&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),n()}),l&&!a&&h.observe(l),h.observe(e));let g,w=a?D(t):null;a&&y();function y(){const d=D(t);w&&(d.x!==w.x||d.y!==w.y||d.width!==w.width||d.height!==w.height)&&n(),w=d,g=requestAnimationFrame(y)}return n(),()=>{var d;f.forEach(v=>{r&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),m==null||m(),(d=h)==null||d.disconnect(),h=null,a&&cancelAnimationFrame(g)}}const Ye=Se,Xe=ke,Ot=Oe,Ke=(t,e,n)=>{const o=new Map,r={platform:Ie,...n},i={...r.platform,_c:o};return Re(t,e,{...r,platform:i})},Je=({content:t,open:e,placement:n,offset:{mainAxis:o,crossAxis:r}={mainAxis:0,crossAxis:0}})=>i=>{const s=i.element,c=u.Value.toSignal(e);return u.When(c,u.Portal("body",u.html.div(u.OnMount(a=>{const l=a;return l.style.position="absolute",qe(s,l,()=>{Ke(s,l,{placement:n,strategy:"absolute",middleware:[Ot(),Ye({mainAxis:o,crossAxis:r}),Xe(),Ot()]}).then(({x:f,y:m})=>{l.style.top=`${m}px`,l.style.left=`${f}px`})})}),t())))(i)},Qt=(t,e)=>{if(typeof e=="function")return Qt(t,{success:e});const n=e.failure??(r=>u.Fragment(u.OnUnmount(r.on(console.error)),r.map(i=>`Error: ${i}`))),o=e.success;return u.OneOfType(u.Value.toSignal(t),{Success:r=>o(r.$.value),Failure:r=>n(r.$.error)})},Ge=()=>u.on.focus(t=>{var e;return(e=t.target)==null?void 0:e.select()}),Qe=t=>e=>{const n=e.element,o=u.makeProp({width:n.clientWidth,height:n.clientHeight}),r=u.renderableOfTNode(t(o))(e),i=()=>{o.set({width:n.clientWidth,height:n.clientHeight})};let s;return typeof ResizeObserver=="function"&&(s=new ResizeObserver(i),s.observe(n)),c=>{s==null||s.disconnect(),r(c)}},Ze=t=>e=>{const n=u.makeProp({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0}),o=u.renderableOfTNode(t(n))(e),r=()=>{n.set({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0})};return window==null||window.addEventListener("resize",r),i=>{window==null||window.removeEventListener("resize",r),o(i)}},Zt=(t,e)=>{const n=e.split("/").filter(r=>r!==""),o={};for(let r=0;r<t.length;r++){const i=t[r],s=n[r];if(!s&&i.type!=="catch-all")return null;if(i.type==="literal"){if(i.value!==s)return null}else if(i.type==="param")o[i.name]=s;else if(i.type==="catch-all")return{params:o,path:e}}return n.length!==t.length?null:{params:o,path:e}},te=t=>t.split("/").map(e=>e.startsWith(":")?{type:"param",name:e.slice(1)}:e==="*"?{type:"catch-all"}:{type:"literal",value:e}).filter(e=>e.type!=="literal"||e.value!==""),ee=t=>{const e=t.map(n=>{const o=te(n);return{route:n,segments:o}});return function(o){for(const{segments:r,route:i}of e){const s=Zt(r,o);if(s)return{...s,route:i}}return null}},tn=t=>{const e=ee(Object.keys(t));return ft(n=>{const o=n.map(r=>{const i=e(r.pathname);if(i==null)throw console.error("No route found for",r),new Error("No route found");return{params:i.params,route:i.route,path:i.path,search:r.search,hash:r.hash}});return u.OneOfTuple(o.map(r=>[r.route,r]),t)})},et=60*1e3,at=60*et,q=24*at,Lt=7*q,St=30*q,en=365*q,nn=[{max:et*90,value:et,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:at*36,value:at,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:q*10,value:q,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:Lt*6,value:Lt,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:en,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function kt(t,e,n,o){const r=Math.round(t/e);return r<=1?n:o.replace("{}",r.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}function ne(t){const e=Math.abs(t);if(e<et)return t<0?"just now":"in a moment";for(const n of nn)if(e<n.max)return t<0?kt(e,n.value,n.past.singular,n.past.plural):kt(e,n.value,n.future.singular,n.future.plural);throw new Error("unreachable")}const on=(t,e)=>{const n=e!=null?u.Signal.is(e)?e.map(i=>i):u.makeProp(e):u.makeProp(new Date),o=u.makeComputedOf(t,n)((i,s)=>{const c=s.getTime()-i.getTime();return ne(c)}),r=u.Prop.is(n)?setInterval(()=>n.set(new Date),5e3):void 0;return o.onDispose(()=>{r!=null&&clearInterval(r),n.dispose()}),o};exports.Anchor=Ut;exports.AsyncResultView=_t;exports.AutoFocus=ae;exports.AutoSelect=ue;exports.ElementSize=Qe;exports.HTMLTitle=me;exports.HiddenWhenEmpty=fe;exports.InViewport=$t;exports.LocationProviderMarker=ut;exports.PopOver=Je;exports.ProvideAppearance=ce;exports.ProvideLocation=se;exports.ResultView=Qt;exports.Router=tn;exports.SelectOnFocus=Ge;exports.UseAppearance=le;exports.UseLocation=ft;exports.WhenInViewport=pe;exports.WindowSize=Ze;exports._checkExtensionCondition=Pt;exports._getExtension=Tt;exports._makeLocation=Ft;exports._makeLocationProp=Vt;exports._makeRouteMatcher=ee;exports._parseRouteSegments=te;exports.appearanceMarker=mt;exports.areLocationsEqual=Mt;exports.formatRelativeTime=on;exports.handleAnchorClick=Ct;exports.locationFromURL=Wt;exports.matchesRoute=Zt;exports.setLocationFromUrl=Dt;exports.timeDiffToString=ne;exports.urlFromLocation=Nt;
package/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export * from './renderables/router/location';
15
15
  export * from './renderables/router/match';
16
16
  export * from './renderables/router/route-info';
17
17
  export * from './renderables/router/router';
18
+ export * from './utils/format-relative-time';