@zag-js/tooltip 0.0.0-dev-20220412160604 → 0.0.0-dev-20220412212252
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +3 -3
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var q=Object.defineProperty,j=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var I=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))U.call(t,n)&&I(e,n,t[n]);if(k)for(var n of k(t))Y.call(t,n)&&I(e,n,t[n]);return e},S=(e,t)=>j(e,z(t));var C=e=>e?"":void 0;var A=new WeakMap;function $(e){var t;if(!e)return{};let n=A.get(e);return n||(n=((t=e==null?void 0:e.ownerDocument.defaultView)!=null?t:window).getComputedStyle(e),A.set(e,n)),n}function x(e){let t=globalThis.requestAnimationFrame(e);return function(){globalThis.cancelAnimationFrame(t)}}var X=()=>{};var Le=(()=>{let e=0;return()=>(e++,e.toString(36))})();var g=new Map,p=new Map;function G(e,t,n,o){var l;if(!e)return X;let r=JSON.stringify({type:t,options:o}),c=g.get(e);if(g.has(e))(c==null?void 0:c.has(r))?(l=c==null?void 0:c.get(r))==null||l.add(n):c==null||c.set(r,new Set([n]));else{let a=new Map([[r,new Set([n])]]);g.set(e,a)}function v(a){var m,f;function u(d){var E;let T=g.get(a);(E=T==null?void 0:T.get(r))==null||E.forEach(W=>W(d))}if(!(p==null?void 0:p.has(a))){p.set(a,new Map([[r,u]])),a.addEventListener(t,u,o);return}((m=p==null?void 0:p.get(a))==null?void 0:m.has(r))||((f=p.get(a))==null||f.set(r,u),a.addEventListener(t,u,o))}return v(e),function(){var a,m,f,u;if(!g.has(e))return;let d=g.get(e);if((a=d==null?void 0:d.get(r))==null||a.delete(n),((m=d==null?void 0:d.get(r))==null?void 0:m.size)===0){let E=(f=p.get(e))==null?void 0:f.get(r);e.removeEventListener(t,E,o),d==null||d.delete(r),(u=p.get(e))==null||u.delete(r),(d==null?void 0:d.size)===0&&(g.delete(e),p.delete(e))}}}var w=e=>Object.prototype.toString.call(e).slice(8,-1),Z=e=>w(e)==="Object"&&"current"in e,J=e=>w(e)==="Function"?e():e,Q=e=>w(e)==="Object"&&!!e.touches,ee={pageX:0,pageY:0,clientX:0,clientY:0};function te(e,t="page"){let n=Q(e)?e.touches[0]||e.changedTouches[0]||ee:e;return{point:{x:n[`${t}X`],y:n[`${t}Y`]}}}function h(e,t,n,o){let l=Z(e)?e.current:J(e);return G(l,t,n,o)}function D(e,t,n,o){var l;let r=(l=ce(t))!=null?l:t;return h(e,r,ne(n,t==="pointerdown"),o)}function ne(e,t=!1){let n=o=>{e(o,te(o))};return t?oe(n):n}function oe(e){return t=>{var n;let o=(n=t.view)!=null?n:window,l=t instanceof o.MouseEvent;(!l||l&&t.button===0)&&e(t)}}var re=()=>typeof window!="undefined"&&window.onpointerdown===null,ie=()=>typeof window!="undefined"&&window.ontouchstart===null,le=()=>typeof window!="undefined"&&window.onmousedown===null,ae={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},se={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function ce(e){return re()?e:ie()?se[e]:le()?ae[e]:e}function b(e){var t;return M(e)?e.document:(t=e==null?void 0:e.ownerDocument)!=null?t:document}function ue(e){var t;return(t=e==null?void 0:e.ownerDocument.defaultView)!=null?t:window}function N(e){return M(e)?"":e&&e.localName||""}function R(e){let t=b(e);return N(e)==="html"?e:e.assignedSlot||e.parentElement||t.documentElement}function P(e){return typeof e=="object"&&(e==null?void 0:e.nodeType)===Node.ELEMENT_NODE&&typeof(e==null?void 0:e.nodeName)=="string"}function M(e){return(e==null?void 0:e.toString())==="[object Window]"}function _(e){let{overflow:t,overflowX:n,overflowY:o}=$(e);return/auto|scroll|overlay|hidden/.test(t+o+n)}function y(e){return["html","body","#document"].includes(N(e))?b(e).body:P(e)&&_(e)?e:y(R(e))}function L(e,t=[]){let n=y(e),o=n===b(e).body,l=ue(n),r=o?[l].concat(l.visualViewport||[],_(n)?n:[]):n,c=t.concat(r);return o?c:c.concat(L(R(r)))}var Te=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");var V={border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"};function F(e,t){return e.addEventListener("webkitpointerlockchange",t,!1),e.addEventListener("mozpointerlockchange",t,!1),e.addEventListener("pointerlockchange",t,!1),function(){e.removeEventListener("mozpointerlockchange",t,!1),e.removeEventListener("pointerlockchange",t,!1)}}import{getPlacementStyles as fe}from"@zag-js/popper";function de(e){return{button:e,label:e,input:e,output:e,element:e}}var H=de(e=>e);var i={getDoc:e=>e.doc||document,getWin:e=>{var t;return((t=e.doc)==null?void 0:t.defaultView)||window},getTriggerId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.trigger)!=null?n:`tooltip-${e.id}--trigger`},getContentId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.content)!=null?n:`tooltip-${e.id}--content`},getArrowId:e=>`tooltip-${e.id}--arrow`,getPositionerId:e=>`tooltip-${e.id}--popper`,portalId:"tooltip-portal",getTriggerEl:e=>i.getDoc(e).getElementById(i.getTriggerId(e)),getContentEl:e=>i.getDoc(e).getElementById(i.getContentId(e)),getPositionerEl:e=>i.getDoc(e).getElementById(i.getPositionerId(e)),getArrowEl:e=>i.getDoc(e).getElementById(i.getArrowId(e)),getScrollParent:e=>y(i.getTriggerEl(e)),getPortalEl:e=>i.getDoc(e).getElementById(i.portalId),createPortalEl:e=>{let t=i.getDoc(e).createElement("tooltip-portal");return t.id=i.portalId,t}};import{proxy as pe}from"@zag-js/core";var s=pe({id:null,prevId:null,setId(e){this.prevId=this.id,this.id=e}});function me(e,t,n=H){let o=e.context.id,l=e.context.hasAriaLabel,r=e.hasTag("open"),c=i.getTriggerId(e.context),v=i.getContentId(e.context),a=fe({measured:!!e.context.isPlacementComplete});return{isOpen:r,open(){t("OPEN")},close(){t("CLOSE")},getAnimationState(){return{enter:s.prevId===null&&o===s.id,exit:s.id===null}},triggerProps:n.button({"data-part":"trigger",id:c,"data-expanded":C(r),"aria-describedby":r?v:void 0,onClick(){t("CLICK")},onFocus(){t("FOCUS")},onBlur(){o===s.id&&t("BLUR")},onPointerDown(){o===s.id&&t("POINTER_DOWN")},onPointerMove(){t("POINTER_ENTER")},onPointerLeave(){t("POINTER_LEAVE")},onPointerCancel(){t("POINTER_LEAVE")}}),arrowProps:n.element({id:i.getArrowId(e.context),"data-part":"arrow",style:a.arrow}),innerArrowProps:n.element({"data-part":"arrow-inner",style:a.innerArrow}),positionerProps:n.element({id:i.getPositionerId(e.context),"data-part":"positioner",style:a.floating}),contentProps:n.element({"data-part":"content",role:l?void 0:"tooltip",id:l?void 0:v,"data-placement":e.context.currentPlacement,onPointerEnter(){t("TOOLTIP_POINTER_ENTER")},onPointerLeave(){t("TOOLTIP_POINTER_LEAVE")},style:{pointerEvents:e.context.interactive?"auto":"none"}}),labelProps:n.element({"data-part":"label",id:v,role:"tooltip",style:V,children:e.context["aria-label"]}),createPortal(){let m=i.getDoc(e.context),f=i.getPortalEl(e.context);if(f)return f;let u=i.createPortalEl(e.context);return m.body.appendChild(u),u}}}import{createMachine as Ee,ref as he,subscribe as ye}from"@zag-js/core";import{getPlacement as we}from"@zag-js/popper";var B=()=>{};var He=(()=>{let e=0;return()=>(e++,e.toString(36))})();var ge=e=>ve()&&e.test(navigator.userAgent);var ve=()=>typeof window!="undefined";var K=()=>ge(/^((?!chrome|android).)*safari/i);var be=Ee({id:"tooltip",initial:"unknown",context:{id:"",openDelay:1e3,closeDelay:500,closeOnPointerDown:!0,closeOnEsc:!0,interactive:!0,positioning:{placement:"bottom"},currentPlacement:void 0},computed:{hasAriaLabel:e=>!!e["aria-label"]},on:{OPEN:"open",CLOSE:"closed"},states:{unknown:{on:{SETUP:{target:"closed",actions:"setupDocument"}}},closed:{tags:["closed"],entry:["clearGlobalId","invokeOnClose"],on:{FOCUS:"open",POINTER_ENTER:[{guard:"noVisibleTooltip",target:"opening"},{target:"open"}]}},opening:{tags:["closed"],activities:["trackScroll","trackPointerlockChange"],after:{OPEN_DELAY:"open"},on:{POINTER_LEAVE:"closed",BLUR:"closed",SCROLL:"closed",POINTER_LOCK_CHANGE:"closed",POINTER_DOWN:{guard:"closeOnPointerDown",target:"closed"}}},open:{tags:["open"],activities:["trackEscapeKey","trackDisabledTriggerOnSafari","trackScroll","trackPointerlockChange","computePlacement"],entry:["setGlobalId","invokeOnOpen"],on:{POINTER_LEAVE:[{guard:"isVisible",target:"closing"},{target:"closed"}],BLUR:"closed",ESCAPE:"closed",SCROLL:"closed",POINTER_LOCK_CHANGE:"closed",TOOLTIP_POINTER_LEAVE:{guard:"isInteractive",target:"closing"},POINTER_DOWN:{guard:"closeOnPointerDown",target:"closed"},CLICK:"closed"}},closing:{tags:["open"],activities:["trackStore","computePlacement"],after:{CLOSE_DELAY:"closed"},on:{FORCE_CLOSE:"closed",POINTER_ENTER:"open",TOOLTIP_POINTER_ENTER:{guard:"isInteractive",target:"open"}}}}},{activities:{computePlacement(e){e.currentPlacement=e.positioning.placement;let t;return x(()=>{t=we(i.getTriggerEl(e),i.getPositionerEl(e),S(O({},e.positioning),{onComplete(n){e.currentPlacement=n.placement,e.isPlacementComplete=!0},onCleanup(){e.currentPlacement=void 0,e.isPlacementComplete=!1}}))}),t},trackPointerlockChange(e,t,{send:n}){return F(i.getDoc(e),()=>{n("POINTER_LOCK_CHANGE")})},trackScroll(e,t,{send:n}){let o=i.getTriggerEl(e);if(!o)return;let l=L(o).map(r=>h(r,"scroll",()=>n("SCROLL"),{passive:!0,capture:!0}));return()=>{l.forEach(r=>r==null?void 0:r())}},trackStore(e,t,{send:n}){return ye(s,()=>{s.id!==e.id&&n("FORCE_CLOSE")})},trackDisabledTriggerOnSafari(e,t,{send:n}){if(!K())return B;let o=i.getDoc(e);return D(o,"pointermove",l=>{let r="[data-part=trigger][data-expanded]";P(l.target)&&l.target.closest(r)||n("POINTER_LEAVE")})},trackEscapeKey(e,t,{send:n}){if(!e.closeOnEsc)return;let o=i.getDoc(e);return h(o,"keydown",l=>{l.key==="Escape"&&n("ESCAPE")})}},actions:{setupDocument(e,t){e.id=t.id,t.doc&&(e.doc=he(t.doc))},setGlobalId(e){s.setId(e.id)},clearGlobalId(e){e.id===s.id&&s.setId(null)},invokeOnOpen(e,t){var o;["TOOLTIP_POINTER_ENTER","POINTER_ENTER"].includes(t.type)||(o=e.onOpen)==null||o.call(e)},invokeOnClose(e,t){var o;["SETUP"].includes(t.type)||(o=e.onClose)==null||o.call(e)}},guards:{closeOnPointerDown:e=>e.closeOnPointerDown,noVisibleTooltip:()=>s.id===null,isVisible:e=>e.id===s.id,isInteractive:e=>e.interactive},delays:{OPEN_DELAY:e=>e.openDelay,CLOSE_DELAY:e=>e.closeDelay}});export{me as connect,be as machine};
|
|
1
|
+
var Ft=t=>t?"":void 0;var Bt=new WeakMap;function Ve(t){var e;if(!t)return{};let n=Bt.get(t);return n||(n=((e=t?.ownerDocument.defaultView)!=null?e:window).getComputedStyle(t),Bt.set(t,n)),n}function Kt(t){let e=globalThis.requestAnimationFrame(t);return function(){globalThis.cancelAnimationFrame(e)}}var ze=()=>{};var yr=(()=>{let t=0;return()=>(t++,t.toString(36))})();var V=new Map,M=new Map;function Be(t,e,n,r){var o;if(!t)return ze;let l=JSON.stringify({type:e,options:r}),d=V.get(t);if(V.has(t))d!=null&&d.has(l)?(o=d?.get(l))==null||o.add(n):d?.set(l,new Set([n]));else{let s=new Map([[l,new Set([n])]]);V.set(t,s)}function f(s){var y,w;function g(u){var p;let i=V.get(s);(p=i?.get(l))==null||p.forEach(a=>a(u))}if(!(M!=null&&M.has(s))){M.set(s,new Map([[l,g]])),s.addEventListener(e,g,r);return}(y=M?.get(s))!=null&&y.has(l)||((w=M.get(s))==null||w.set(l,g),s.addEventListener(e,g,r))}return f(t),function(){var s,y,w,g;if(!V.has(t))return;let u=V.get(t);if((s=u?.get(l))==null||s.delete(n),((y=u?.get(l))==null?void 0:y.size)===0){let p=(w=M.get(t))==null?void 0:w.get(l);t.removeEventListener(e,p,r),u?.delete(l),(g=M.get(t))==null||g.delete(l),u?.size===0&&(V.delete(t),M.delete(t))}}}var xt=t=>Object.prototype.toString.call(t).slice(8,-1),Fe=t=>xt(t)==="Object"&&"current"in t,Ke=t=>xt(t)==="Function"?t():t,$e=t=>xt(t)==="Object"&&!!t.touches,qe={pageX:0,pageY:0,clientX:0,clientY:0};function Ye(t,e="page"){let n=$e(t)?t.touches[0]||t.changedTouches[0]||qe:t;return{point:{x:n[`${e}X`],y:n[`${e}Y`]}}}function at(t,e,n,r){let o=Fe(t)?t.current:Ke(t);return Be(o,e,n,r)}function $t(t,e,n,r){var o;let l=(o=en(e))!=null?o:e;return at(t,l,Ue(n,e==="pointerdown"),r)}function Ue(t,e=!1){let n=r=>{t(r,Ye(r))};return e?Xe(n):n}function Xe(t){return e=>{var n;let r=(n=e.view)!=null?n:window,o=e instanceof r.MouseEvent;(!o||o&&e.button===0)&&t(e)}}var Ge=()=>typeof window<"u"&&window.onpointerdown===null,Je=()=>typeof window<"u"&&window.ontouchstart===null,Ze=()=>typeof window<"u"&&window.onmousedown===null,Qe={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},tn={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function en(t){return Ge()?t:Je()?tn[t]:Ze()?Qe[t]:t}function St(t){var e;return Ut(t)?t.document:(e=t?.ownerDocument)!=null?e:document}function nn(t){var e;return(e=t?.ownerDocument.defaultView)!=null?e:window}function qt(t){return Ut(t)?"":t&&t.localName||""}function Yt(t){let e=St(t);return qt(t)==="html"?t:t.assignedSlot||t.parentElement||e.documentElement}function Pt(t){return typeof t=="object"&&t?.nodeType===Node.ELEMENT_NODE&&typeof t?.nodeName=="string"}function Ut(t){return t?.toString()==="[object Window]"}function Xt(t){let{overflow:e,overflowX:n,overflowY:r}=Ve(t);return/auto|scroll|overlay|hidden/.test(e+r+n)}function st(t){return["html","body","#document"].includes(qt(t))?St(t).body:Pt(t)&&Xt(t)?t:st(Yt(t))}function Lt(t,e=[]){let n=st(t),r=n===St(t).body,o=nn(n),l=r?[o].concat(o.visualViewport||[],Xt(n)?n:[]):n,d=e.concat(l);return r?d:d.concat(Lt(Yt(l)))}var wr=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");var Gt={border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"};function Jt(t,e){return t.addEventListener("webkitpointerlockchange",e,!1),t.addEventListener("mozpointerlockchange",e,!1),t.addEventListener("pointerlockchange",e,!1),function(){t.removeEventListener("mozpointerlockchange",e,!1),t.removeEventListener("pointerlockchange",e,!1)}}function U(t){return t.split("-")[0]}function ht(t){return t.split("-")[1]}function J(t){return["top","bottom"].includes(U(t))?"x":"y"}function Ct(t){return t==="y"?"height":"width"}function Zt(t,e,n){let{reference:r,floating:o}=t,l=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=J(e),s=Ct(f),y=r[s]/2-o[s]/2,w=U(e),g=f==="x",u;switch(w){case"top":u={x:l,y:r.y-o.height};break;case"bottom":u={x:l,y:r.y+r.height};break;case"right":u={x:r.x+r.width,y:d};break;case"left":u={x:r.x-o.width,y:d};break;default:u={x:r.x,y:r.y}}switch(ht(e)){case"start":u[f]-=y*(n&&g?-1:1);break;case"end":u[f]+=y*(n&&g?-1:1);break}return u}var rn=async(t,e,n)=>{let{placement:r="bottom",strategy:o="absolute",middleware:l=[],platform:d}=n,f=await(d.isRTL==null?void 0:d.isRTL(e)),s=await d.getElementRects({reference:t,floating:e,strategy:o}),{x:y,y:w}=Zt(s,r,f),g=r,u={},p=0;for(let i=0;i<l.length;i++){let{name:a,fn:c}=l[i],{x:h,y:m,data:v,reset:b}=await c({x:y,y:w,initialPlacement:r,placement:g,strategy:o,middlewareData:u,rects:s,platform:d,elements:{reference:t,floating:e}});if(y=h??y,w=m??w,u={...u,[a]:{...u[a],...v}},b){typeof b=="object"&&(b.placement&&(g=b.placement),b.rects&&(s=b.rects===!0?await d.getElementRects({reference:t,floating:e,strategy:o}):b.rects),{x:y,y:w}=Zt(s,g,f)),i=-1;continue}}return{x:y,y:w,placement:g,strategy:o,middlewareData:u}};function on(t){return{top:0,right:0,bottom:0,left:0,...t}}function ce(t){return typeof t!="number"?on(t):{top:t,right:t,bottom:t,left:t}}function ut(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function kt(t,e){var n;e===void 0&&(e={});let{x:r,y:o,platform:l,rects:d,elements:f,strategy:s}=t,{boundary:y="clippingAncestors",rootBoundary:w="viewport",elementContext:g="floating",altBoundary:u=!1,padding:p=0}=e,i=ce(p),a=f[u?g==="floating"?"reference":"floating":g],c=ut(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(a)))==null||n?a:a.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(f.floating)),boundary:y,rootBoundary:w,strategy:s})),h=ut(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({rect:g==="floating"?{...d.floating,x:r,y:o}:d.reference,offsetParent:await(l.getOffsetParent==null?void 0:l.getOffsetParent(f.floating)),strategy:s}):d[g]);return{top:c.top-h.top+i.top,bottom:h.bottom-c.bottom+i.bottom,left:c.left-h.left+i.left,right:h.right-c.right+i.right}}var ln=Math.min,F=Math.max;function Tt(t,e,n){return F(t,ln(e,n))}var an=t=>({name:"arrow",options:t,async fn(e){let{element:n,padding:r=0}=t??{},{x:o,y:l,placement:d,rects:f,platform:s}=e;if(n==null)return{};let y=ce(r),w={x:o,y:l},g=J(d),u=Ct(g),p=await s.getDimensions(n),i=g==="y"?"top":"left",a=g==="y"?"bottom":"right",c=f.reference[u]+f.reference[g]-w[g]-f.floating[u],h=w[g]-f.reference[g],m=await(s.getOffsetParent==null?void 0:s.getOffsetParent(n)),v=m?g==="y"?m.clientHeight||0:m.clientWidth||0:0,b=c/2-h/2,x=y[i],A=v-p[u]-y[a],T=v/2-p[u]/2+b,O=Tt(x,T,A);return{data:{[g]:O,centerOffset:T-O}}}}),sn={left:"right",right:"left",bottom:"top",top:"bottom"};function dt(t){return t.replace(/left|right|bottom|top/g,e=>sn[e])}function cn(t,e,n){n===void 0&&(n=!1);let r=ht(t),o=J(t),l=Ct(o),d=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[l]>e.floating[l]&&(d=dt(d)),{main:d,cross:dt(d)}}var un={start:"end",end:"start"};function Qt(t){return t.replace(/start|end/g,e=>un[e])}function dn(t){let e=dt(t);return[Qt(t),e,Qt(e)]}var fn=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n;let{placement:r,middlewareData:o,rects:l,initialPlacement:d,platform:f,elements:s}=e,{mainAxis:y=!0,crossAxis:w=!0,fallbackPlacements:g,fallbackStrategy:u="bestFit",flipAlignment:p=!0,...i}=t,a=U(r),c=g||(a===d||!p?[dt(d)]:dn(d)),h=[d,...c],m=await kt(e,i),v=[],b=((n=o.flip)==null?void 0:n.overflows)||[];if(y&&v.push(m[a]),w){let{main:O,cross:ot}=cn(r,l,await(f.isRTL==null?void 0:f.isRTL(s.floating)));v.push(m[O],m[ot])}if(b=[...b,{placement:r,overflows:v}],!v.every(O=>O<=0)){var x,A;let O=((x=(A=o.flip)==null?void 0:A.index)!=null?x:0)+1,ot=h[O];if(ot)return{data:{index:O,overflows:b},reset:{placement:ot}};let lt="bottom";switch(u){case"bestFit":{var T;let zt=(T=b.slice().sort((_e,He)=>_e.overflows.filter(H=>H>0).reduce((H,Et)=>H+Et,0)-He.overflows.filter(H=>H>0).reduce((H,Et)=>H+Et,0))[0])==null?void 0:T.placement;zt&&(lt=zt);break}case"initialPlacement":lt=d;break}if(r!==lt)return{reset:{placement:lt}}}return{}}}};function hn(t,e,n,r){r===void 0&&(r=!1);let o=U(t),l=ht(t),d=J(t)==="x",f=["left","top"].includes(o)?-1:1,s=r&&d?-1:1,y=typeof n=="function"?n({...e,placement:t}):n,w=typeof y=="number",{mainAxis:g,crossAxis:u,alignmentAxis:p}=w?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...y};return l&&typeof p=="number"&&(u=l==="end"?p*-1:p),d?{x:u*s,y:g*f}:{x:g*f,y:u*s}}var pn=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:n,y:r,placement:o,rects:l,platform:d,elements:f}=e,s=hn(o,l,t,await(d.isRTL==null?void 0:d.isRTL(f.floating)));return{x:n+s.x,y:r+s.y,data:s}}}};function gn(t){return t==="x"?"y":"x"}var mn=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:r,placement:o}=e,{mainAxis:l=!0,crossAxis:d=!1,limiter:f={fn:c=>{let{x:h,y:m}=c;return{x:h,y:m}}},...s}=t,y={x:n,y:r},w=await kt(e,s),g=J(U(o)),u=gn(g),p=y[g],i=y[u];if(l){let c=g==="y"?"top":"left",h=g==="y"?"bottom":"right",m=p+w[c],v=p-w[h];p=Tt(m,p,v)}if(d){let c=u==="y"?"top":"left",h=u==="y"?"bottom":"right",m=i+w[c],v=i-w[h];i=Tt(m,i,v)}let a=f.fn({...e,[g]:p,[u]:i});return{...a,data:{x:a.x-n,y:a.y-r}}}}},vn=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){let{placement:n,rects:r,platform:o,elements:l}=e,{apply:d,...f}=t,s=await kt(e,f),y=U(n),w=ht(n),g,u;y==="top"||y==="bottom"?(g=y,u=w===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(u=y,g=w==="end"?"top":"bottom");let p=F(s.left,0),i=F(s.right,0),a=F(s.top,0),c=F(s.bottom,0),h={height:r.floating.height-(["left","right"].includes(n)?2*(a!==0||c!==0?a+c:F(s.top,s.bottom)):s[g]),width:r.floating.width-(["top","bottom"].includes(n)?2*(p!==0||i!==0?p+i:F(s.left,s.right)):s[u])},m=await o.getDimensions(l.floating);d?.({...h,...r});let v=await o.getDimensions(l.floating);return m.width!==v.width||m.height!==v.height?{reset:{rects:!0}}:{}}}};function ue(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function N(t){if(t==null)return window;if(!ue(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function Z(t){return N(t).getComputedStyle(t)}function D(t){return ue(t)?"":t?(t.nodeName||"").toLowerCase():""}function C(t){return t instanceof N(t).HTMLElement}function Y(t){return t instanceof N(t).Element}function yn(t){return t instanceof N(t).Node}function Rt(t){let e=N(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function pt(t){let{overflow:e,overflowX:n,overflowY:r}=Z(t);return/auto|scroll|overlay|hidden/.test(e+r+n)}function wn(t){return["table","td","th"].includes(D(t))}function de(t){let e=navigator.userAgent.toLowerCase().includes("firefox"),n=Z(t);return n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].includes(n.willChange)||e&&n.willChange==="filter"||e&&(n.filter?n.filter!=="none":!1)}function fe(){return!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}var te=Math.min,G=Math.max,ft=Math.round;function $(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);let r=t.getBoundingClientRect(),o=1,l=1;e&&C(t)&&(o=t.offsetWidth>0&&ft(r.width)/t.offsetWidth||1,l=t.offsetHeight>0&&ft(r.height)/t.offsetHeight||1);let d=Y(t)?N(t):window,f=!fe()&&n,s=(r.left+(f?d.visualViewport.offsetLeft:0))/o,y=(r.top+(f?d.visualViewport.offsetTop:0))/l,w=r.width/o,g=r.height/l;return{width:w,height:g,top:y,right:s+w,bottom:y+g,left:s,x:s,y}}function j(t){return((yn(t)?t.ownerDocument:t.document)||window.document).documentElement}function gt(t){return Y(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function he(t){return $(j(t)).left+gt(t).scrollLeft}function bn(t){let e=$(t);return ft(e.width)!==t.offsetWidth||ft(e.height)!==t.offsetHeight}function En(t,e,n){let r=C(e),o=j(e),l=$(t,r&&bn(e),n==="fixed"),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};if(r||!r&&n!=="fixed")if((D(e)!=="body"||pt(o))&&(d=gt(e)),C(e)){let s=$(e,!0);f.x=s.x+e.clientLeft,f.y=s.y+e.clientTop}else o&&(f.x=he(o));return{x:l.left+d.scrollLeft-f.x,y:l.top+d.scrollTop-f.y,width:l.width,height:l.height}}function It(t){return D(t)==="html"?t:t.assignedSlot||t.parentNode||(Rt(t)?t.host:null)||j(t)}function ee(t){return!C(t)||getComputedStyle(t).position==="fixed"?null:t.offsetParent}function xn(t){let e=It(t);for(Rt(e)&&(e=e.host);C(e)&&!["html","body"].includes(D(e));){if(de(e))return e;e=e.parentNode}return null}function Ot(t){let e=N(t),n=ee(t);for(;n&&wn(n)&&getComputedStyle(n).position==="static";)n=ee(n);return n&&(D(n)==="html"||D(n)==="body"&&getComputedStyle(n).position==="static"&&!de(n))?e:n||xn(t)||e}function ne(t){if(C(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=$(t);return{width:e.width,height:e.height}}function Sn(t){let{rect:e,offsetParent:n,strategy:r}=t,o=C(n),l=j(n);if(n===l)return e;let d={scrollLeft:0,scrollTop:0},f={x:0,y:0};if((o||!o&&r!=="fixed")&&((D(n)!=="body"||pt(l))&&(d=gt(n)),C(n))){let s=$(n,!0);f.x=s.x+n.clientLeft,f.y=s.y+n.clientTop}return{...e,x:e.x-d.scrollLeft+f.x,y:e.y-d.scrollTop+f.y}}function Pn(t,e){let n=N(t),r=j(t),o=n.visualViewport,l=r.clientWidth,d=r.clientHeight,f=0,s=0;if(o){l=o.width,d=o.height;let y=fe();(y||!y&&e==="fixed")&&(f=o.offsetLeft,s=o.offsetTop)}return{width:l,height:d,x:f,y:s}}function Ln(t){var e;let n=j(t),r=gt(t),o=(e=t.ownerDocument)==null?void 0:e.body,l=G(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),d=G(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),f=-r.scrollLeft+he(t),s=-r.scrollTop;return Z(o||n).direction==="rtl"&&(f+=G(n.clientWidth,o?o.clientWidth:0)-l),{width:l,height:d,x:f,y:s}}function pe(t){let e=It(t);return["html","body","#document"].includes(D(e))?t.ownerDocument.body:C(e)&&pt(e)?e:pe(e)}function Mt(t,e){var n;e===void 0&&(e=[]);let r=pe(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),l=N(r),d=o?[l].concat(l.visualViewport||[],pt(r)?r:[]):r,f=e.concat(d);return o?f:f.concat(Mt(It(d)))}function Tn(t,e){let n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&Rt(n)){let r=e;do{if(r&&t===r)return!0;r=r.parentNode||r.host}while(r)}return!1}function On(t,e){let n=$(t,!1,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft;return{top:r,left:o,x:o,y:r,right:o+t.clientWidth,bottom:r+t.clientHeight,width:t.clientWidth,height:t.clientHeight}}function re(t,e,n){return e==="viewport"?ut(Pn(t,n)):Y(e)?On(e,n):ut(Ln(j(t)))}function An(t){let e=Mt(t),n=["absolute","fixed"].includes(Z(t).position)&&C(t)?Ot(t):t;return Y(n)?e.filter(r=>Y(r)&&Tn(r,n)&&D(r)!=="body"):[]}function Cn(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t,l=[...n==="clippingAncestors"?An(e):[].concat(n),r],d=l[0],f=l.reduce((s,y)=>{let w=re(e,y,o);return s.top=G(w.top,s.top),s.right=te(w.right,s.right),s.bottom=te(w.bottom,s.bottom),s.left=G(w.left,s.left),s},re(e,d,o));return{width:f.right-f.left,height:f.bottom-f.top,x:f.left,y:f.top}}var kn={getClippingRect:Cn,convertOffsetParentRelativeRectToViewportRelativeRect:Sn,isElement:Y,getDimensions:ne,getOffsetParent:Ot,getDocumentElement:j,getElementRects:t=>{let{reference:e,floating:n,strategy:r}=t;return{reference:En(e,Ot(n),r),floating:{...ne(n),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>Z(t).direction==="rtl"},Rn=(t,e,n)=>rn(t,e,{platform:kn,...n}),In=()=>{},Er=(()=>{let t=0;return()=>(t++,t.toString(36))})(),z=new Map,W=new Map;function Mn(t,e,n,r){var o;if(!t)return In;let l=JSON.stringify({type:e,options:r}),d=z.get(t);if(z.has(t))d!=null&&d.has(l)?(o=d?.get(l))==null||o.add(n):d?.set(l,new Set([n]));else{let s=new Map([[l,new Set([n])]]);z.set(t,s)}function f(s){var y,w;function g(u){var p;(p=z.get(s)?.get(l))==null||p.forEach(a=>a(u))}if(!(W!=null&&W.has(s))){W.set(s,new Map([[l,g]])),s.addEventListener(e,g,r);return}(y=W?.get(s))!=null&&y.has(l)||((w=W.get(s))==null||w.set(l,g),s.addEventListener(e,g,r))}return f(t),function(){var s,y,w,g;if(!z.has(t))return;let u=z.get(t);if((s=u?.get(l))==null||s.delete(n),((y=u?.get(l))==null?void 0:y.size)===0){let p=(w=W.get(t))==null?void 0:w.get(l);t.removeEventListener(e,p,r),u?.delete(l),(g=W.get(t))==null||g.delete(l),u?.size===0&&(z.delete(t),W.delete(t))}}}var ge=t=>Object.prototype.toString.call(t).slice(8,-1),Dn=t=>ge(t)==="Object"&&"current"in t,Nn=t=>ge(t)==="Function"?t():t;function ie(t,e,n,r){let o=Dn(t)?t.current:Nn(t);return Mn(o,e,n,r)}function Wn(t){var e;return jn(t)?t.document:(e=t?.ownerDocument)!=null?e:document}function oe(t){return typeof t=="object"&&t?.nodeType===Node.ELEMENT_NODE&&typeof t?.nodeName=="string"}function jn(t){return t?.toString()==="[object Window]"}var xr=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(","),K=new Map;function le(t,e){let n=K.get(t);return n?(n.callbacks.push(e),e(t.getBoundingClientRect())):(K.set(t,{rect:{},callbacks:[e]}),K.size===1&&(At=requestAnimationFrame(me))),function(){let r=K.get(t);if(!r)return;let o=r.callbacks.indexOf(e);o>-1&&r.callbacks.splice(o,1),r.callbacks.length===0&&(K.delete(t),K.size===0&&cancelAnimationFrame(At))}}var At;function me(){let t=[];K.forEach((e,n)=>{let r=n.getBoundingClientRect();_n(e.rect,r)||(e.rect=r,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(n=>n(e.rect))}),At=requestAnimationFrame(me)}function _n(t,e){return t.width===e.width&&t.height===e.height&&t.top===e.top&&t.right===e.right&&t.bottom===e.bottom&&t.left===e.left}var ae=()=>{},ct=(...t)=>e=>t.reduce((n,r)=>r(n),e),Sr=(()=>{let t=0;return()=>(t++,t.toString(36))})(),Hn=t=>t===!0||t===!1;function Vn(t){return Hn(t)?{ancestorResize:t,ancestorScroll:t,referenceResize:t}:Object.assign({ancestorResize:!0,ancestorScroll:!0,referenceResize:!0},t)}function zn(t,e,n,r=!1){let{ancestorScroll:o,ancestorResize:l,referenceResize:d}=Vn(r),f=o||l,s=[];f&&oe(t)&&s.push(...Mt(t));function y(){let g=[le(e,n)];return d&&oe(t)&&g.push(le(t,n)),g.push(ct(...s.map(u=>ie(u,"resize",n)))),()=>g.forEach(u=>u())}function w(){return ct(...s.map(g=>ie(g,"scroll",n,{passive:!0})))}return ct(y(),w())}var B=t=>({variable:t,reference:`var(${t})`}),S={arrowShadowColor:B("--arrow-shadow-color"),arrowSize:B("--arrow-size"),arrowSizeHalf:B("--arrow-size-half"),arrowBg:B("--arrow-background"),transformOrigin:B("--transform-origin"),arrowOffset:B("--arrow-offset"),boxShadow:B("--arrow-box-shadow")},se={top:"bottom center","top-start":"bottom left","top-end":"bottom right",bottom:"top center","bottom-start":"top left","bottom-end":"top right",left:"right center","left-start":"right top","left-end":"right bottom",right:"left center","right-start":"left top","right-end":"left bottom"},Bn={name:"transformOrigin",fn({placement:t,elements:e}){let{floating:n}=e;return n.style.setProperty(S.transformOrigin.variable,se[t]),{data:{transformOrigin:se[t]}}}},Fn=t=>({name:"shiftArrow",fn({placement:e,middlewareData:n}){var r;let{element:o}=t,{x:l,y:d}=(r=n.arrow)!=null?r:{x:0,y:0},f={top:"bottom",right:"left",bottom:"top",left:"right"}[e.split("-")[0]];return Object.assign(o.style,{top:`${d}px`,left:`${l}px`,[f]:S.arrowOffset.reference,[S.boxShadow.variable]:Kn(e)}),{}}});function Kn(t){if(t.includes("top"))return`1px 1px 1px 0 ${S.arrowShadowColor.reference}`;if(t.includes("bottom"))return`-1px -1px 1px 0 ${S.arrowShadowColor.reference}`;if(t.includes("right"))return`-1px 1px 1px 0 ${S.arrowShadowColor.reference}`;if(t.includes("left"))return`1px -1px 1px 0 ${S.arrowShadowColor.reference}`}var $n={strategy:"absolute",placement:"bottom",listeners:!0,gutter:8,flip:!0,sameWidth:!1};function ve(t,e,n={}){var r;if(t==null||e==null)return ae;n=Object.assign({},$n,n);let o=[Bn];if(n.flip&&o.push(fn({boundary:n.boundary,padding:8})),n.gutter||n.offset){let f=n.gutter?{mainAxis:n.gutter}:n.offset;o.push(pn(f))}o.push(mn({boundary:n.boundary}));let l=Wn(e).querySelector("[data-part=arrow]");l&&o.push(an({element:l,padding:8}),Fn({element:l})),n.sameWidth&&o.push(vn({apply(f){let{width:s}=f.reference;Object.assign(e.style,{width:`${s}px`,minWidth:"unset"})}}));function d(){if(t==null||e==null)return;let{placement:f,strategy:s}=n;Rn(t,e,{placement:f,middleware:o,strategy:s}).then(y=>{let{x:w,y:g,strategy:u}=y;return Object.assign(e.style,{left:`${w}px`,top:`${g}px`,position:u}),y}).then(y=>{var w;(w=n.onComplete)==null||w.call(n,y)})}return d(),ct(zn(t,e,d,n.listeners),(r=n.onCleanup)!=null?r:ae)}var qn={position:"fixed",top:0,left:0,opacity:0,transform:"translate3d(0, -200%, 0)",pointerEvents:"none"};function ye(t){let{measured:e,strategy:n="absolute"}=t;return{arrow:{position:"absolute",width:S.arrowSize.reference,height:S.arrowSize.reference,[S.arrowSizeHalf.variable]:`calc(${S.arrowSize.reference} / 2)`,[S.arrowOffset.variable]:`calc(${S.arrowSizeHalf.reference} * -1)`,opacity:e?void 0:0},innerArrow:{transform:"rotate(45deg)",background:S.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:n,minWidth:"max-content",...!e&&qn}}}function Yn(t){return{button:t,label:t,input:t,output:t,element:t}}var we=Yn(t=>t);var E={getDoc:t=>t.doc||document,getWin:t=>{var e;return((e=t.doc)==null?void 0:e.defaultView)||window},getTriggerId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.trigger)!=null?n:`tooltip-${t.id}--trigger`},getContentId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.content)!=null?n:`tooltip-${t.id}--content`},getArrowId:t=>`tooltip-${t.id}--arrow`,getPositionerId:t=>`tooltip-${t.id}--popper`,portalId:"tooltip-portal",getTriggerEl:t=>E.getDoc(t).getElementById(E.getTriggerId(t)),getContentEl:t=>E.getDoc(t).getElementById(E.getContentId(t)),getPositionerEl:t=>E.getDoc(t).getElementById(E.getPositionerId(t)),getArrowEl:t=>E.getDoc(t).getElementById(E.getArrowId(t)),getScrollParent:t=>st(E.getTriggerEl(t)),getPortalEl:t=>E.getDoc(t).getElementById(E.portalId),createPortalEl:t=>{let e=E.getDoc(t).createElement("tooltip-portal");return e.id=E.portalId,e}};var Ar=Symbol(),Cr=Symbol(),Un=Symbol(),be=Object.getPrototypeOf,jt=new WeakMap,Xn=t=>t&&(jt.has(t)?jt.get(t):be(t)===Object.prototype||be(t)===Array.prototype),Gn=t=>Xn(t)&&t[Un]||null,Ee=(t,e=!0)=>{jt.set(t,e)},ke=Symbol(),k=Symbol(),yt=Symbol(),Jn=Symbol(),Q=Symbol(),xe=Symbol(),Vt=new WeakSet;function wt(t){return Vt.add(t),t}var bt=t=>typeof t=="object"&&t!==null,Zn=t=>bt(t)&&!Vt.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),Se=new WeakMap,Pe=1,Le=new WeakMap;function rt(t={}){if(!bt(t))throw new Error("object required");let e=Se.get(t);if(e)return e;let n=Pe,r=new Set,o=(u,p=++Pe)=>{n!==p&&(n=p,r.forEach(i=>i(u,p)))},l=new Map,d=u=>{let p=l.get(u);return p||(p=(i,a)=>{let c=[...i];c[1]=[u,...c[1]],o(c,a)},l.set(u,p)),p},f=u=>{let p=l.get(u);return l.delete(u),p},s=(u,p)=>{let i=Le.get(p);if(i?.[0]===n)return i[1];let a=Array.isArray(u)?[]:Object.create(Object.getPrototypeOf(u));return Ee(a,!0),Le.set(p,[n,a]),Reflect.ownKeys(u).forEach(c=>{let h=Reflect.get(u,c,p);if(Vt.has(h))Ee(h,!1),a[c]=h;else if(h instanceof Promise)if(Q in h)a[c]=h[Q];else{let m=h[xe]||h;Object.defineProperty(a,c,{get(){if(Q in h)return h[Q];throw m}})}else h?.[k]?a[c]=h[yt]:a[c]=h}),Object.freeze(a),a},y=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),w={get(u,p,i){return p===ke?n:p===k?r:p===yt?s(u,i):p===Jn?w:Reflect.get(u,p,i)},deleteProperty(u,p){let i=Reflect.get(u,p),a=i?.[k];a&&a.delete(f(p));let c=Reflect.deleteProperty(u,p);return c&&o(["delete",[p],i]),c},is:Object.is,canProxy:Zn,set(u,p,i,a){var c;let h=Reflect.get(u,p,a);if(this.is(h,i))return!0;let m=h?.[k];m&&m.delete(f(p)),bt(i)&&(i=Gn(i)||i);let v;return(c=Object.getOwnPropertyDescriptor(u,p))!=null&&c.set?v=i:i instanceof Promise?v=i.then(b=>(v[Q]=b,o(["resolve",[p],b]),b)).catch(b=>{v[xe]=b,o(["reject",[p],b])}):i?.[k]?(v=i,v[k].add(d(p))):this.canProxy(i)?(v=rt(i),v[k].add(d(p))):v=i,Reflect.set(u,p,v,a),o(["set",[p],i,h]),!0}},g=new Proxy(y,w);return Se.set(t,g),Reflect.ownKeys(t).forEach(u=>{let p=Object.getOwnPropertyDescriptor(t,u);p.get||p.set?Object.defineProperty(y,u,p):g[u]=t[u]}),g}function Te(t){return bt(t)?t[ke]:void 0}function it(t,e,n){(import.meta.env&&import.meta.env.MODE)!=="production"&&!t?.[k]&&console.warn("Please use proxy object");let r,o=[],l=d=>{if(o.push(d),n){e(o.splice(0));return}r||(r=Promise.resolve().then(()=>{r=void 0,e(o.splice(0))}))};return t[k].add(l),()=>{t[k].delete(l)}}function Qn(t){return(import.meta.env&&import.meta.env.MODE)!=="production"&&!t?.[yt]&&console.warn("Please use proxy object"),t[yt]}function tr(t){for(;t.length>0;)t.pop();return t}var Oe=(t,...e)=>(typeof t=="function"?t(...e):t)??void 0,R=t=>t,Ae=()=>{};var er=(()=>{let t=0;return()=>(t++,t.toString(36))})(),X=t=>Array.isArray(t),et=t=>!(t==null||typeof t!="object"||X(t)),nr=t=>typeof t=="number"&&!Number.isNaN(t),I=t=>typeof t=="string",_t=t=>typeof t=="function";function Dt(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function Nt(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function rr(t){return et(t)&&t.predicate!=null}function Wt(t,e){return(n,r)=>rr(t)?t.predicate(e??{})(n,r):t}function ir(t){return et(t)&&t.predicate!=null}var or=()=>!0;function Re(t,e){return t=t??or,(n,r)=>{if(I(t)){let o=e?.[t];return _t(o)?o(n,r):o}return ir(t)?t.predicate(e??{})(n,r):t?.(n,r)}}function tt(t){var e,n,r;if(Array.isArray(t)){for(n=Array(e=t.length);e--;)n[e]=(r=t[e])&&typeof r=="object"?tt(r):r;return n}if(Object.prototype.toString.call(t)==="[object Object]"){n={};for(e in t)e==="__proto__"?Object.defineProperty(n,e,{value:tt(t[e]),configurable:!0,enumerable:!0,writable:!0}):n[e]=(r=t[e])&&typeof r=="object"?tt(r):r;return n}return t}function Ce(t,e,n,r){return it(t,o=>{o.some(l=>l[1][0]===e)&&n(t[e])},r)}var kr=Symbol(),q=new WeakMap,nt=new WeakMap,Ie=(t,e)=>{let n=q.get(t);n&&(n[0].forEach(r=>{let{d:o}=r;t!==o&&Ie(o)}),++n[2],e&&n[3].add(e))},lr=(t,e)=>{let n=q.get(t);return n?.[2]?(n[3].add(e),!0):!1},Ht=t=>{let e=q.get(t);e&&(--e[2],e[2]||(e[3].forEach(n=>n()),e[3].clear()),e[0].forEach(n=>{let{d:r}=n;t!==r&&Ht(r)}))},ar=t=>{let{s:e,d:n}=t,r=nt.get(n);r||(r=[new Set],nt.set(t.d,r)),r[0].add(t);let o=q.get(e);if(!o){let l=new Set,d=it(e,f=>{l.forEach(s=>{let{d:y,c:w,n:g,i:u}=s;e===y&&f.every(p=>p[1].length===1&&u.includes(p[1][0]))||s.p||(Ie(e,w),g?Ht(e):s.p=Promise.resolve().then(()=>{delete s.p,Ht(e)}))})},!0);o=[l,d,0,new Set],q.set(e,o)}o[0].add(t)},Me=t=>{let{s:e,d:n}=t,r=nt.get(n);r?.[0].delete(t),r?.[0].size===0&&nt.delete(n);let o=q.get(e);if(o){let[l,d]=o;l.delete(t),l.size||(d(),q.delete(e))}},sr=t=>{let e=nt.get(t);return e?Array.from(e[0]):[]};function cr(t,e){let n=e?.proxy||rt({}),r=!!e?.sync,o=Object.keys(t);return o.forEach(l=>{if(Object.getOwnPropertyDescriptor(n,l))throw new Error("object property already defined");let d=t[l],f=null,s=()=>{if(f&&(Array.from(f).map(([u])=>lr(u,s)).some(u=>u)||Array.from(f).every(([u,p])=>Te(u)===p.v)))return;let y=new Map,w=d(u=>(y.set(u,{v:Te(u)}),u)),g=()=>{y.forEach((u,p)=>{var i;let a=(i=f?.get(p))==null?void 0:i.s;if(a)u.s=a;else{let c={s:p,d:n,k:l,c:s,n:r,i:o};ar(c),u.s=c}}),f?.forEach((u,p)=>{!y.has(p)&&u.s&&Me(u.s)}),f=y};w instanceof Promise?w.finally(g):g(),n[l]=w};s()}),n}function ur(t,e){let n=e?.delete?new Set:null;sr(t).forEach(r=>{let{k:o}=r;(!e?.keys||e.keys.includes(o))&&(Me(r),n&&n.add(o))}),n&&n.forEach(r=>{delete t[r]})}function dr(t){var e;let n=rt({value:"",previousValue:"",event:R({}),context:(e=t.context)!=null?e:R({}),done:!1,tags:[],hasTag(r){return this.tags.includes(r)},matches(...r){return r.includes(this.value)},can(r){return R(this).nextEvents.includes(r)},get nextEvents(){var r,o,l,d;let f=(l=(o=(r=t.states)==null?void 0:r[this.value])==null?void 0:o.on)!=null?l:{},s=(d=t?.on)!=null?d:{};return Object.keys({...f,...s})},get changed(){return this.event.value==="machine.init"||!this.previousValue?!1:this.value!==this.previousValue}});return R(n)}function mt(t,e){return(n,r)=>{if(nr(t))return t;if(_t(t))return t(n,r);if(I(t)){let o=Number.parseFloat(t);if(!Number.isNaN(o))return o;if(e){let l=e?.[t];if(l==null){let d=`[machine] Cannot determine delay for ${t}. It doesn't exist in options.delays`;throw new Error(d)}return _t(l)?l(n,r):l}}}}function L(t){return I(t)?{type:t}:t}function _(t){return t?X(t)?t:[t]:[]}function De(t){return I(t)?{target:t}:t}function fr(t,e){return(n,r)=>_(t).map(De).find(o=>{var l;let d=Re(o.guard,e)(n,r);return(l=d??o.target)!=null?l:o.actions})}function hr(t,e){let n=I(t)?De(t):t,r=o=>(o.actions&&!o.target&&e&&(o.target=e),o);if(X(n))return n.map(r);if(et(n))return r(R(n))}var vt=class{constructor(t,e){this.config=t,this.status="Not Started",this.type="machine",this.activityEvents=new Map,this.delayedEvents=new Map,this.stateListeners=new Set,this.eventListeners=new Set,this.doneListeners=new Set,this.contextWatchers=new Set,this.removeStateListener=Ae,this.removeEventListener=Ae,this.children=new Map,this.start=i=>{if(this.status==="Running")return this;this.status="Running";let a=L("machine.init");if(i){let m=et(i)?i:{context:this.config.context,value:i};this.setState(m.value),this.setContext(m.context)}let c={target:i?void 0:this.config.initial},h=this.getNextStateInfo(c,a);return h.target=R(h.target||c.target),this.initialState=h,this.performStateChangeEffects(h.target,h,a),this.removeStateListener=it(this.state,()=>{this.stateListeners.forEach(m=>{m(this.stateSnapshot)})},this.sync),this.removeEventListener=Ce(this.state,"event",m=>{this.config.onEvent&&this.executeActions(this.config.onEvent,m);for(let v of this.eventListeners)v(m)}),this.setupContextWatchers(),this.executeActivities(L("machine.start"),_(this.config.activities),"machine.start"),this.executeActions(this.config.entry,L("machine.start")),this},this.setupContextWatchers=()=>{var i;for(let[a,c]of Object.entries((i=this.config.watch)!=null?i:{}))this.contextWatchers.add(Ce(this.state.context,a,()=>{this.executeActions(c,this.state.event)}))},this.setupComputed=()=>{var i;let a=R((i=this.config.computed)!=null?i:{}),c=Object.fromEntries(Object.entries(a).map(([h,m])=>[h,v=>m(v(this.state.context))]));cr(c,{proxy:this.state.context})},this.detachComputed=()=>{ur(this.state.context,{delete:!0})},this.stop=()=>{if(this.status!=="Stopped")return this.setState(null),this.setEvent("machine.stop"),this.config.context&&this.setContext(this.config.context),this.stopStateListeners(),this.stopChildren(),this.stopActivities(),this.stopDelayedEvents(),this.stopContextWatchers(),this.stopEventListeners(),this.detachComputed(),this.status="Stopped",this.executeActions(this.config.exit,L("machine.stop")),this},this.stopEventListeners=()=>{this.eventListeners.clear(),this.removeEventListener()},this.stopStateListeners=()=>{this.removeStateListener(),this.stateListeners.clear()},this.stopContextWatchers=()=>{this.contextWatchers.forEach(i=>i()),this.contextWatchers.clear()},this.stopDelayedEvents=()=>{this.delayedEvents.forEach(i=>{i.forEach(a=>a())}),this.delayedEvents.clear()},this.stopActivities=i=>{var a,c;i?((a=this.activityEvents.get(i))==null||a.forEach(h=>h()),(c=this.activityEvents.get(i))==null||c.clear(),this.activityEvents.delete(i)):(this.activityEvents.forEach(h=>{h.forEach(m=>m()),h.clear()}),this.activityEvents.clear())},this.sendChild=(i,a)=>{let c=L(i),h=Oe(a,this.contextSnapshot),m=this.children.get(h);m||Nt(`[machine/send-child] Cannot send '${c.type}' event to unknown child`),m.send(c)},this.stopChild=i=>{this.children.has(i)||Nt("[machine/stop-child] Cannot stop unknown child"),this.children.get(i).stop(),this.children.delete(i)},this.removeChild=i=>{this.children.delete(i)},this.stopChildren=()=>{this.children.forEach(i=>i.stop()),this.children.clear()},this.setParent=i=>{this.parent=i},this.spawn=(i,a)=>{let c=Oe(i);return a&&(c.id=a),c.type="machine.actor",c.setParent(this),this.children.set(c.id,R(c)),c.onDone(()=>{this.removeChild(c.id)}).start(),R(wt(c))},this.addActivityCleanup=(i,a)=>{var c;!i||(this.activityEvents.has(i)?(c=this.activityEvents.get(i))==null||c.add(a):this.activityEvents.set(i,new Set([a])))},this.setState=i=>{this.state.previousValue=this.state.value,this.state.value=i;let a=this.getStateNode(i);i==null?tr(this.state.tags):this.state.tags=_(a?.tags)},this.setContext=i=>{for(let a in i)this.state.context[a]=i[a]},this.withContext=i=>{this.detachComputed();let a={...this.config.context,...i};return new vt({...this.config,context:a},this.options)},this.withOptions=i=>(this.detachComputed(),new vt(this.config,{...this.options,...i})),this.setActions=i=>{this.actionMap={...this.actionMap,...i}},this.clone=()=>(this.detachComputed(),new vt(this.config,this.options)),this.getStateNode=i=>{var a;if(i)return(a=this.config.states)==null?void 0:a[i]},this.getNextStateInfo=(i,a)=>{var c;let h=this.determineTransition(i,a),m=(c=h?.target)!=null?c:this.state.value,v=this.getStateNode(m);return{transition:h,stateNode:v,target:m}},this.getActionFromDelayedTransition=i=>{let a=L("machine.after"),c=mt(i.delay,this.delayMap)(this.contextSnapshot,a),h;return{entry:()=>{h=globalThis.setTimeout(()=>{let m=this.state.value,v=this.getNextStateInfo(i,a);this.performStateChangeEffects(m,v,a)},c)},exit:()=>{globalThis.clearTimeout(h)}}},this.getDelayedEventActions=i=>{let a=this.getStateNode(i),c=L("machine.after");if(!a||!a.after)return;let h=[],m=[];if(X(a.after)){let v=this.determineTransition(a.after,c);if(!v)return;let b=this.getActionFromDelayedTransition(v);h.push(b.entry),m.push(b.exit)}else if(et(a.after))for(let v in a.after){let b=a.after[v],x={};if(X(b)){let T=this.determineTransition(b,c);T&&(x=T)}else I(b)?x={target:b,delay:v}:x={...b,delay:v};let A=this.getActionFromDelayedTransition(x);h.push(A.entry),m.push(A.exit)}return{entries:h,exits:m}},this.executeActions=(i,a)=>{var c;let h=Wt(i,this.guardMap)(this.contextSnapshot,a);for(let m of _(h)){let v=I(m)?(c=this.actionMap)==null?void 0:c[m]:m;Dt(I(m)&&!v,`[machine/exec-action] No implementation found for action: \`${m}\``),v?.(this.state.context,a,this.meta)}},this.executeActivities=(i,a,c)=>{var h;for(let m of a){let v=I(m)?(h=this.activityMap)==null?void 0:h[m]:m;if(!v){Dt(`[machine/exec-activity] No implementation found for activity: \`${m}\``);continue}let b=v(this.state.context,i,this.meta);b&&this.addActivityCleanup(c??this.state.value,b)}},this.createEveryActivities=(i,a)=>{if(!i)return;let c=L("machine.every");if(X(i)){let h=_(i).find(v=>{let b=mt(v.delay,this.delayMap);v.delay=b(this.contextSnapshot,c);let x=Re(v.guard,this.guardMap)(this.contextSnapshot,c);return x??v.delay});if(!h)return;let m=mt(h.delay,this.delayMap)(this.contextSnapshot,c);a(()=>{let v=globalThis.setInterval(()=>{this.executeActions(h.actions,c)},m);return()=>{globalThis.clearInterval(v)}})}else for(let h in i){let m=i?.[h],v=mt(h,this.delayMap)(this.contextSnapshot,c);a(()=>{let b=globalThis.setInterval(()=>{this.executeActions(m,c)},v);return()=>{globalThis.clearInterval(b)}})}},this.setEvent=i=>{this.state.event=wt(L(i))},this.performExitEffects=(i,a)=>{let c=this.state.value,h=i?this.getStateNode(i):void 0;this.stopActivities(c);let m=Wt(h?.exit,this.guardMap)(this.contextSnapshot,a),v=_(m),b=this.delayedEvents.get(c);b&&v.push(...b),this.executeActions(v,a),this.eventListeners.clear()},this.performEntryEffects=(i,a)=>{let c=this.getStateNode(i),h=_(c?.activities);this.createEveryActivities(c?.every,x=>{h.unshift(x)}),h.length>0&&this.executeActivities(a,h);let m=Wt(c?.entry,this.guardMap)(this.contextSnapshot,a),v=_(m),b=this.getDelayedEventActions(i);c?.after&&b&&(this.delayedEvents.set(i,b?.exits),v.push(...b.entries)),this.executeActions(v,a),c?.type==="final"&&(this.state.done=!0,this.doneListeners.forEach(x=>{x(this.stateSnapshot)}),this.stop())},this.performTransitionEffects=(i,a)=>{let c=this.determineTransition(i,a);this.executeActions(c?.actions,a)},this.performStateChangeEffects=(i,a,c)=>{var h,m;this.setEvent(c),a.target=(m=(h=a.target)!=null?h:this.state.value)!=null?m:void 0;let v=a.target&&a.target!==this.state.value;v&&this.performExitEffects(i,c),this.performTransitionEffects(a?.transition,c),this.setState(a.target),v&&this.performEntryEffects(a.target,c)},this.determineTransition=(i,a)=>{let c=fr(i,this.guardMap);return c?.(this.contextSnapshot,a)},this.sendParent=i=>{var a;this.parent||Nt("[machine/send-parent] Cannot send event to an unknown parent");let c=L(i);(a=this.parent)==null||a.send(c)},this.send=i=>{let a=L(i);this.transition(this.state.value,a)},this.transition=(i,a)=>{var c,h,m;let v=I(i)?this.getStateNode(i):i?.stateNode,b=L(a);if(!v&&!this.config.on){let O=this.status==="Stopped"?"[machine/transition] Cannot transition a stopped machine":"[machine/transition] State does not have a definition";Dt(O);return}let x=(m=(c=v?.on)==null?void 0:c[b.type])!=null?m:(h=this.config.on)==null?void 0:h[b.type],A=hr(x,this.state.value);if(!A)return;let T=this.getNextStateInfo(A,b);return this.performStateChangeEffects(this.state.value,T,b),T.stateNode},this.subscribe=i=>(this.stateListeners.add(i),this.status==="Running"&&i(this.stateSnapshot),()=>{this.stateListeners.delete(i)}),this.onDone=i=>(this.doneListeners.add(i),this),this.onTransition=i=>(this.stateListeners.add(i),this.status==="Running"&&i(this.stateSnapshot),this),this.onEvent=i=>(i(this.state.event),this.eventListeners.add(i),this);var n,r,o,l,d,f,s,y,w,g,u;this.options=tt(e),this.id=(n=t.id)!=null?n:`machine-${er()}`,this.guardMap=(o=(r=this.options)==null?void 0:r.guards)!=null?o:{},this.actionMap=(d=(l=this.options)==null?void 0:l.actions)!=null?d:{},this.delayMap=(s=(f=this.options)==null?void 0:f.delays)!=null?s:{},this.activityMap=(w=(y=this.options)==null?void 0:y.activities)!=null?w:{},this.sync=(u=(g=this.options)==null?void 0:g.sync)!=null?u:!1,this.state=dr(tt(t)),this.setupComputed();let p=L("machine.created");this.executeActions(t?.created,p)}get stateSnapshot(){return R(Qn(this.state))}get contextSnapshot(){return this.stateSnapshot.context}get self(){let t=this;return{id:this.id,send:this.send.bind(this),sendParent:this.sendParent.bind(this),sendChild:this.sendChild.bind(this),stop:this.stop.bind(this),stopChild:this.stopChild.bind(this),spawn:this.spawn.bind(this),get state(){return t.stateSnapshot}}}get meta(){return{state:this.stateSnapshot,guards:this.guardMap,send:this.send.bind(this),listen:this.onEvent.bind(this),self:this.self,getState:()=>this.stateSnapshot}}},Ne=(t,e)=>new vt(t,e);var P=rt({id:null,prevId:null,setId(t){this.prevId=this.id,this.id=t}});function pr(t,e,n=we){let r=t.context.id,o=t.context.hasAriaLabel,l=t.hasTag("open"),d=E.getTriggerId(t.context),f=E.getContentId(t.context),s=ye({measured:!!t.context.isPlacementComplete});return{isOpen:l,open(){e("OPEN")},close(){e("CLOSE")},getAnimationState(){return{enter:P.prevId===null&&r===P.id,exit:P.id===null}},triggerProps:n.button({"data-part":"trigger",id:d,"data-expanded":Ft(l),"aria-describedby":l?f:void 0,onClick(){e("CLICK")},onFocus(){e("FOCUS")},onBlur(){r===P.id&&e("BLUR")},onPointerDown(){r===P.id&&e("POINTER_DOWN")},onPointerMove(){e("POINTER_ENTER")},onPointerLeave(){e("POINTER_LEAVE")},onPointerCancel(){e("POINTER_LEAVE")}}),arrowProps:n.element({id:E.getArrowId(t.context),"data-part":"arrow",style:s.arrow}),innerArrowProps:n.element({"data-part":"arrow-inner",style:s.innerArrow}),positionerProps:n.element({id:E.getPositionerId(t.context),"data-part":"positioner",style:s.floating}),contentProps:n.element({"data-part":"content",role:o?void 0:"tooltip",id:o?void 0:f,"data-placement":t.context.currentPlacement,onPointerEnter(){e("TOOLTIP_POINTER_ENTER")},onPointerLeave(){e("TOOLTIP_POINTER_LEAVE")},style:{pointerEvents:t.context.interactive?"auto":"none"}}),labelProps:n.element({"data-part":"label",id:f,role:"tooltip",style:Gt,children:t.context["aria-label"]}),createPortal(){let y=E.getDoc(t.context),w=E.getPortalEl(t.context);if(w)return w;let g=E.createPortalEl(t.context);return y.body.appendChild(g),g}}}var We=()=>{};var Fr=(()=>{let t=0;return()=>(t++,t.toString(36))})();var gr=t=>mr()&&t.test(navigator.userAgent);var mr=()=>typeof window<"u";var je=()=>gr(/^((?!chrome|android).)*safari/i);var vr=Ne({id:"tooltip",initial:"unknown",context:{id:"",openDelay:1e3,closeDelay:500,closeOnPointerDown:!0,closeOnEsc:!0,interactive:!0,positioning:{placement:"bottom"},currentPlacement:void 0},computed:{hasAriaLabel:t=>!!t["aria-label"]},on:{OPEN:"open",CLOSE:"closed"},states:{unknown:{on:{SETUP:{target:"closed",actions:"setupDocument"}}},closed:{tags:["closed"],entry:["clearGlobalId","invokeOnClose"],on:{FOCUS:"open",POINTER_ENTER:[{guard:"noVisibleTooltip",target:"opening"},{target:"open"}]}},opening:{tags:["closed"],activities:["trackScroll","trackPointerlockChange"],after:{OPEN_DELAY:"open"},on:{POINTER_LEAVE:"closed",BLUR:"closed",SCROLL:"closed",POINTER_LOCK_CHANGE:"closed",POINTER_DOWN:{guard:"closeOnPointerDown",target:"closed"}}},open:{tags:["open"],activities:["trackEscapeKey","trackDisabledTriggerOnSafari","trackScroll","trackPointerlockChange","computePlacement"],entry:["setGlobalId","invokeOnOpen"],on:{POINTER_LEAVE:[{guard:"isVisible",target:"closing"},{target:"closed"}],BLUR:"closed",ESCAPE:"closed",SCROLL:"closed",POINTER_LOCK_CHANGE:"closed",TOOLTIP_POINTER_LEAVE:{guard:"isInteractive",target:"closing"},POINTER_DOWN:{guard:"closeOnPointerDown",target:"closed"},CLICK:"closed"}},closing:{tags:["open"],activities:["trackStore","computePlacement"],after:{CLOSE_DELAY:"closed"},on:{FORCE_CLOSE:"closed",POINTER_ENTER:"open",TOOLTIP_POINTER_ENTER:{guard:"isInteractive",target:"open"}}}}},{activities:{computePlacement(t){t.currentPlacement=t.positioning.placement;let e;return Kt(()=>{e=ve(E.getTriggerEl(t),E.getPositionerEl(t),{...t.positioning,onComplete(n){t.currentPlacement=n.placement,t.isPlacementComplete=!0},onCleanup(){t.currentPlacement=void 0,t.isPlacementComplete=!1}})}),e},trackPointerlockChange(t,e,{send:n}){return Jt(E.getDoc(t),()=>{n("POINTER_LOCK_CHANGE")})},trackScroll(t,e,{send:n}){let r=E.getTriggerEl(t);if(!r)return;let o=Lt(r).map(l=>at(l,"scroll",()=>n("SCROLL"),{passive:!0,capture:!0}));return()=>{o.forEach(l=>l==null?void 0:l())}},trackStore(t,e,{send:n}){return it(P,()=>{P.id!==t.id&&n("FORCE_CLOSE")})},trackDisabledTriggerOnSafari(t,e,{send:n}){if(!je())return We;let r=E.getDoc(t);return $t(r,"pointermove",o=>{let l="[data-part=trigger][data-expanded]";Pt(o.target)&&o.target.closest(l)||n("POINTER_LEAVE")})},trackEscapeKey(t,e,{send:n}){if(!t.closeOnEsc)return;let r=E.getDoc(t);return at(r,"keydown",o=>{o.key==="Escape"&&n("ESCAPE")})}},actions:{setupDocument(t,e){t.id=e.id,e.doc&&(t.doc=wt(e.doc))},setGlobalId(t){P.setId(t.id)},clearGlobalId(t){t.id===P.id&&P.setId(null)},invokeOnOpen(t,e){var r;["TOOLTIP_POINTER_ENTER","POINTER_ENTER"].includes(e.type)||(r=t.onOpen)==null||r.call(t)},invokeOnClose(t,e){var r;["SETUP"].includes(e.type)||(r=t.onClose)==null||r.call(t)}},guards:{closeOnPointerDown:t=>t.closeOnPointerDown,noVisibleTooltip:()=>P.id===null,isVisible:t=>t.id===P.id,isInteractive:t=>t.interactive},delays:{OPEN_DELAY:t=>t.openDelay,CLOSE_DELAY:t=>t.closeDelay}});export{pr as connect,vr as machine};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|