var B=Object.defineProperty;var h=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var _=(n,r,t)=>r in n?B(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t,j=(n,r)=>{for(var t in r||(r={}))z.call(r,t)&&_(n,t,r[t]);if(h)for(var t of h(r))C.call(r,t)&&_(n,t,r[t]);return n};var R=(n,r)=>{var t={};for(var l in n)z.call(n,l)&&r.indexOf(l)<0&&(t[l]=n[l]);if(n!=null&&h)for(var l of h(n))r.indexOf(l)<0&&C.call(n,l)&&(t[l]=n[l]);return t};import{r as p,j as a,a as G,c_ as I,_ as K}from"./main-634.js";import{o as M,e as L}from"./bf-25-81.js";function W(l){var y=l,{children:n,delay:r=300}=y,t=R(y,["children","delay"]);const i=p.useId(),[g,$]=M();return a.jsxs(a.Fragment,{children:[a.jsx(L,{singleton:g,delay:r,interactive:t.interactive}),n.map((c,m)=>{var w;return((w=c==null?void 0:c.type)==null?void 0:w.name)==="Tip"?p.cloneElement(c,j({key:`tip-grp-${i+m*2}`,singleton:$},t)):c})]})}function P({defaultActive:n,className:r,options:t,size:l=100,onChange:y,show:i,width:g,tipPlace:$="top",borderRadius:c="var(--bf-bdr-radius-sm)",activeShow:m,noShadow:w,defaultItmWidth:q,wideTab:S,h:D}){const{css:f}=G(),F=Number(l),H=e=>Math.floor(F/e),b={wrapper:j({ta:"center"},g&&{w:g}),tabs:{fs:13,bd:"var(--white-0-95)",py:1.5,flx:"center",px:3,ls:"none",brs:c,pn:"relative","& .active":{cr:"var(--b-50) !important"},"& button":{bd:"none",oe:"none",b:"none"}},selector:{w:0,h:"80%",dy:"inline-block",pn:"absolute",lt:5,tp:"50%",tm:"translatey(-50%)",zx:1,brs:c-2,tdn:"0.3s",ttf:"cubic-bezier(0.42, 0.44, 0.57, 1.35)",willChange:"transform",bs:"0 2px 3px -1px #84848485",bd:"linear-gradient(0deg, #efefef 0%, white 20%)"},tab_link:{curp:1,td:"none",fw:500,pn:"relative",p:0,zx:1,mnh:24,w:S?"100%":24,h:S?30:24,brs:c,flx:"center",tdy:"0.3s",tdn:"0.6s","transition-property":"color",cr:"var(--white-0-0-29)",":hover:not(.active)":{cr:"var(--white-0-31)",tdy:"0s",tdn:"300ms"},":focus-visible":{oe:"2px solid var(--b-50)"},"& .icn":{mr:i!=null&&i.includes("label")?H(20):0,lh:"75%",flx:"center"}}},o=p.useRef(null),k=p.useRef(null),x=p.useRef(null),[v,T]=p.useState(n||t[0].label);p.useEffect(()=>{v!==n&&T(n)},[n]),p.useLayoutEffect(()=>{var s;const e=(s=x==null?void 0:x.current)==null?void 0:s.querySelector(`[data-label="${v}"]`);if(e){const{width:d}=e.getBoundingClientRect()||{width:0};if(!o.current)return;o.current.style.width===""?(k.transition=o.current.style.transition,o.current.style.transition="all 0s"):o.current.style.transition=k.transition,o.current.style.width=`${d}px`,o.current.style.transform=`translate(${e.offsetLeft-5}px, -50%)`}});const N=(e,s)=>{if(e.preventDefault(),e.type==="keypress"&&e.code!=="Space"||e.type==="keypress"&&e.code!=="Enter")return;const d=e.currentTarget;if(!e.type==="keypress"||!e.type==="click")return;const u=x.current.querySelector(".tabs button.active");d!==u&&(u==null||u.classList.remove("active"),T(t[s].label)),y&&y(t[s].label)},E=(e,s)=>!!(e[s]&&(m&&v===e.label&&m.includes(s)||i&&i.includes(s)||!i&&!m));return a.jsx("div",{className:`${f(b.wrapper)} ${r}`,children:a.jsxs("div",{ref:x,className:`${f(b.tabs)} tabs`,style:{height:D},children:[a.jsx("div",{ref:o,className:`selector ${f(b.selector)}`,style:{width:q}}),a.jsx(W,{children:t==null?void 0:t.map((e,s)=>{const d=a.jsxs("button",{type:"button",className:`${f(b.tab_link)} ${v===e.label?" active":""}`,onClick:u=>N(u,s),onKeyDown:u=>N(u,s),"data-label":e.label,"data-testid":`${I(e.label)}-tab`,children:[E(e,"icn")&&a.jsx("span",{className:`icn ${f(b.icn)} ${v===e.label?f(b.segment_img):""}`,children:e.icn}),E(e,"label")&&K(e.label)]},`segment-option-${s*10}`);return e.tip?a.jsx(L,{className:f({w:"100%",dy:"inline-block"}),msg:e.tip,place:$,whiteSpaceNowrap:!0,theme:"light-border",delay:300,children:d},`segment-option-${s*100}`):d})})]})})}export{P as S,W as T};
