"use client";
import{c as F}from"./chunk-SUBVXXYD.js";import{a as V}from"./chunk-CRUBRFDA.js";import{e as N,i as L,j as M}from"./chunk-CLTGASR6.js";import{a as B,c as H,d as U,m as x,n as b}from"./chunk-3CHPBNY2.js";import{cloneElement as ot,forwardRef as nt,useState as pt}from"react";import rt from"clsx";import{cloneElement as D,isValidElement as Y}from"react";import E from"clsx";var q=B("EulTooltip",["anchorEl","open","content","panel","placementBottom","placementBottomEnd","placementBottomStart","placementLeft","placementLeftEnd","placementLeftStart","placementRight","placementRightEnd","placementRightStart","placementTop","placementTopEnd","placementTopStart","popper","root","tip"]),C=t=>N("EulTooltip",{anchorEl:["anchorEl"],content:["content"],popper:["popper",t.placement&&`placement${U(H(t.placement))}`,t.placement?.indexOf("bottom")!==-1&&"placementBottom",t.placement?.indexOf("top")!==-1&&"placementTop",t.placement?.indexOf("left")!==-1&&"placementLeft",t.placement?.indexOf("right")!==-1&&"placementRight",t.isPanel&&"panel"],root:["root",t.open&&"open"],tip:["tip"]}),p=q;import{forwardRef as J}from"react";import{jsx as O,jsxs as K}from"react/jsx-runtime";var G=J(({className:t},s)=>{let o=b();return K("svg",{className:t,fill:"none",height:"10",ref:s,viewBox:"0 0 34 10",width:"34",xmlns:"http://www.w3.org/2000/svg",children:[O("path",{d:"M0 0H34H26.8873C26.0072 0 25.1715 0.386467 24.6015 1.05705L19.2858 7.3108C18.0878 8.72021 15.9122 8.72021 14.7142 7.3108L9.3985 1.05706C8.8285 0.386469 7.99278 0 7.11268 0H0Z",fill:o.palette.background[500]}),O("path",{d:"M7.11268 1H6V0H7.11268C7.96751 0 8.78047 0.364595 9.34875 1C9.36555 1.01878 9.38213 1.0378 9.3985 1.05706L14.7142 7.3108C15.9122 8.72021 18.0878 8.72021 19.2858 7.3108L24.6015 1.05705C24.6179 1.0378 24.6345 1.01878 24.6513 1C25.2195 0.364594 26.0325 0 26.8873 0H28V1H26.8873C26.3006 1 25.7434 1.25765 25.3634 1.7047L20.0478 7.95845C18.4504 9.83766 15.5496 9.83766 13.9522 7.95845L8.63656 1.7047C8.25656 1.25765 7.69942 1 7.11268 1Z",fill:o.palette.background[600]})]})});G.displayName="Tip";var v=G;import{css as Q}from"@emotion/react";var I=x("div")`
  .${p.anchorEl} {
    cursor: pointer;
  }
`,z=x("div")(({theme:t})=>Q`
    position: relative;
    display: flex;
    gap: ${t.spacing(4)};
    padding: ${t.spacing(2)} ${t.spacing(3)};
    color: ${t.palette.background[900]};
    font-size: ${t.typography.pxToRem(12)};
    line-height: ${t.typography.pxToRem(16)};
    background: ${t.palette.background[500]};
    border: 1px solid ${t.palette.background[600]};
    border-radius: ${t.spacing(1.5)};

    > svg {
      position: absolute;

      .${p.popper}[data-popper-placement*="top"]  & {
        top: 100%;
      }

      .${p.popper}[data-popper-placement*="bottom"] & {
        bottom: 100%;
        transform: rotate(180deg);
      }

      .${p.popper}[data-popper-placement*="left"] & {
        left: calc(100% - 12px);
        transform: rotate(-90deg);
      }

      .${p.popper}[data-popper-placement*="right"] & {
        right: calc(100% - 12px);
        transform: rotate(90deg);
      }
    }

    .${p.popper}[data-popper-placement*="top"] & {
      margin-bottom: ${t.spacing(3)};
    }

    .${p.popper}[data-popper-placement*="bottom"] & {
      margin-top: ${t.spacing(3)};
    }

    .${p.popper}[data-popper-placement*="left"] & {
      margin-right: ${t.spacing(3)};
    }

    .${p.popper}[data-popper-placement*="right"] & {
      margin-left: ${t.spacing(3)};
    }

    .${p.popper}.${p.panel} & {
      padding: ${t.spacing(3)};
      margin: ${t.spacing(1)} 0 0;
      background: ${t.palette.background[300]};
      border: 1px solid ${t.palette.background[500]};
      border-radius: ${t.spacing(2)};
    }
  `),W=x(F)(({theme:t})=>({zIndex:t.zIndex.tooltip}));import{jsx as R,jsxs as Z}from"react/jsx-runtime";var _=t=>{let{anchorEl:s,children:o,className:S,content:i,id:T,isPanel:c=!1,open:m=!1,placement:l="bottom"}=t,d=b(),n=C(t),g=r=>{setTimeout(()=>{if(s&&r?.parentElement?.parentElement){let f=s.getBoundingClientRect(),e=r.parentElement.parentElement.getBoundingClientRect(),h=r.getBoundingClientRect(),a;r.style.opacity="0",l.includes("bottom")||l.includes("top")?(a=f.left+f.width/2-(e.left+h.width/2),a=Math.max(8,a),a=Math.min(e.width-h.width-8,a),r.style.left=`${a}px`):(a=f.top+f.height/2-(e.top+h.height/2),a=Math.min(e.height-h.height/2-5,Math.max(a,h.height/2+5)),r.style.top=`${a}px`),r.style.opacity="1"}},100)},u=D(o,{...o.props,className:E(o.props.className,n.anchorEl)}),y=i&&Y(i)?D(i,{...i.props,className:E(i.props.className,n.content)}):i;return Z(I,{className:E(n.root,S),children:[u,R(W,{anchorEl:s,className:E(n.popper),open:m,placement:l,transition:!0,children:({TransitionProps:r})=>R(V,{timeout:d.transitions.duration.shorter,...r,children:Z(z,{className:E(n.content),id:T,children:[y,!c&&R(v,{className:E(n.tip),ref:g})]})})})]})},$=_;import{useCallback as j,useEffect as tt,useRef as P,useState as et}from"react";function k({onClose:t,onOpen:s,touchDelay:o,touchEndDelay:S}){let[i,T]=et(!1),c=P("initial"),m=P(!1),l=P(),d=P(),n=j(()=>{c.current!=="initial"&&(document.body.style.webkitUserSelect=c.current,c.current="initial"),clearTimeout(d.current)},[]);tt(()=>()=>{clearTimeout(l.current),n()},[n]);let g=e=>{T(!0),s?.(e)},u=e=>{T(!1),m.current=!1,t?.(e)},y=e=>{m.current&&e.type!=="touchstart"||(clearTimeout(l.current),g(e))};return{handleClose:u,handleEnter:y,handleTouchEnd:e=>{n(),clearTimeout(l.current),l.current=setTimeout(()=>{u(e)},S)},handleTouchStart:e=>{m.current=!0,clearTimeout(l.current),n(),c.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",d.current=setTimeout(()=>{document.body.style.webkitUserSelect=c.current,y(e)},o)},open:i}}import{jsx as lt}from"react/jsx-runtime";var w=nt((t,s)=>{let{children:o,content:S,id:i,isPanel:T,open:c,placement:m}=t,l=M(),[d,n]=pt(null),{handleClose:g,handleEnter:u,handleTouchEnd:y,handleTouchStart:r,open:f}=k(t),e=L(o.props.ref,n,s),h=C(t),a=o&&ot(o,{...o.props,className:rt(o.props.className,h.anchorEl),key:"tooltip-child",onBlur:g,onFocus:A=>{l==="keyboard"&&u(A)},onMouseEnter:u,onMouseLeave:g,onTouchEnd:y,onTouchStart:r,ref:e});return lt($,{anchorEl:d,content:S,id:i,isPanel:T,open:c||f&&Boolean(d),placement:m,children:a})});w.displayName="Tooltip";w.defaultProps={placement:"bottom",touchDelay:700,touchEndDelay:1500};var at=w;export{p as a,$ as b,at as c};
