@tempots/ui 0.22.0 → 0.22.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.
Files changed (3) hide show
  1. package/index.cjs +1 -1
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -1 +1 @@
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,S)=>V.overflows[1]-S.overflows[1])[0])==null?void 0:wt.placement;if(!B)switch(h){case"bestFit":{var yt;const V=(yt=H.filter(S=>{if(N){const T=_(S.placement);return T===v||T==="y"}return!0}).map(S=>[S.placement,S.overflows.filter(T=>T>0).reduce((T,re)=>T+re,0)]).sort((S,T)=>S[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 ke=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}}}}},Se=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 k(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||k(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=k(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(k(t)).left+it(t).scrollLeft}function De(t){const e=k(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=k(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(k(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=k(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:k,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=k(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=ke,Xe=Se,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,kt=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:kt*18,value:kt,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 St(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?St(e,n.value,n.past.singular,n.past.plural):St(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.handleAnchorClick=Ct;exports.locationFromURL=Wt;exports.makeRelativeTime=on;exports.matchesRoute=Zt;exports.setLocationFromUrl=Dt;exports.timeDiffToString=ne;exports.urlFromLocation=Nt;
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,S)=>V.overflows[1]-S.overflows[1])[0])==null?void 0:wt.placement;if(!B)switch(h){case"bestFit":{var yt;const V=(yt=H.filter(S=>{if(N){const T=_(S.placement);return T===v||T==="y"}return!0}).map(S=>[S.placement,S.overflows.filter(T=>T>0).reduce((T,re)=>T+re,0)]).sort((S,T)=>S[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 ke=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}}}}},Se=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 k(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||k(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=k(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(k(t)).left+it(t).scrollLeft}function De(t){const e=k(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=k(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(k(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=k(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:k,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=k(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=ke,Xe=Se,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,kt=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:kt*18,value:kt,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 St(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?St(e,n.value,n.past.singular,n.past.plural):St(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=i.getTime()-s.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.handleAnchorClick=Ct;exports.locationFromURL=Wt;exports.makeRelativeTime=on;exports.matchesRoute=Zt;exports.setLocationFromUrl=Dt;exports.timeDiffToString=ne;exports.urlFromLocation=Nt;
package/index.js CHANGED
@@ -1265,7 +1265,7 @@ const On = (t, e) => {
1265
1265
  t,
1266
1266
  n
1267
1267
  )((r, s) => {
1268
- const c = s.getTime() - r.getTime();
1268
+ const c = r.getTime() - s.getTime();
1269
1269
  return fn(c);
1270
1270
  }), i = le.is(n) ? setInterval(() => n.set(/* @__PURE__ */ new Date()), 5e3) : void 0;
1271
1271
  return o.onDispose(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/ui",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",