import{a as e}from"./rolldown-runtime.BRE-HNa9.js";import{p as t}from"./nc-util.BWncs0l6.js";import{t as n}from"./element-resize-detector.CBKJ7I8g.js";/* empty css                */import{Fragment as r,createBlock as i,createCommentVNode as a,createElementBlock as o,createElementVNode as s,createTextVNode as c,createVNode as l,inject as u,normalizeClass as d,normalizeStyle as f,onBeforeUnmount as p,onMounted as m,openBlock as h,ref as g,renderList as _,renderSlot as v,resolveComponent as y,toDisplayString as b,unref as x,vShow as S,watch as C,withDirectives as w}from"/vue.js";var T=e(n()),E={class:`nc-tab-wrapper`},D=[`id`,`onClick`,`onDblclick`],O=Object.assign({name:`NcTab`},{__name:`nc-tab`,props:{id:{type:String,default:void 0},model:{type:String,default:()=>``},class:{type:[Object,Array,String],default:void 0},style:{type:[Array,Object,String],default:()=>void 0},itemStyle:{type:[Array,Object,String],default:()=>void 0}},emits:[`change`,`dblclick`],setup(e,{emit:n}){let O=n,k=e,A=g(null),j=g(null),M=g(null),N=g(!1),P=g(!1),F=g(!1),I,L=u(`state`),R=k.model&&k.model.substring(k.model.indexOf(`.`)+1),z=g(R&&t.recData(L.arr,R)||[]);function B(){A.value&&(A.value.scrollBy({left:-200,behavior:`smooth`}),setTimeout(W,300))}function V(){A.value&&(A.value.scrollBy({left:200,behavior:`smooth`}),setTimeout(W,300))}function H(){A.value&&(A.value.scrollTo({left:0,behavior:`smooth`}),setTimeout(W,300))}function U(){A.value&&(A.value.scrollTo({left:A.value.scrollWidth,behavior:`smooth`}),setTimeout(W,300))}function W(){if(!A.value)return;let e=A.value,t=e.scrollLeft>0,n=M.value?M.value.$el.offsetWidth+4:44,r=e.scrollLeft<e.scrollWidth-e.clientWidth-n;P.value=N.value&&t,F.value=N.value&&r}function G(){setTimeout(()=>{N.value=A.value?A.value.scrollWidth>A.value.clientWidth:!1,W()},0)}function K(e){return e==null?!1:e===t.recData(L.rec,R)}function q(e,n,r,i){!n||n.value==null?console.error(`nc-tab selected item or item.value at index ${r} is null, item, tab, event:`,n,z,e):(R&&t.setRec(L,R,n.value),O(i?`dblclick`:`change`,n.value,r,e,z.value))}return m(()=>{I=(0,T.default)({strategy:`scroll`}),G(),setTimeout(()=>{I.listenTo(A.value,()=>{G()})},100),A.value&&A.value.addEventListener(`scroll`,W)}),p(()=>{I&&(I.uninstall(A.value),I=null),A.value&&A.value.removeEventListener(`scroll`,W)}),C(L.rec,()=>{if(R&&L.arr){let e=t.recData(L.arr,R);e!=null&&(z.value=Object.assign([],e))}}),C(L.arr,()=>{if(R&&L.arr){let e=t.recData(L.arr,R);e!=null&&(z.value=e)}G()}),(R==null||t.recData(L.rec,R)==null)&&(t.isArray(z.value)||(console.warn(`nc-tab '${k.model}' array does not exist`),z.value=[{show:`undefined tab`,value:`undefined`}]),z.value[0]&&t.setRec(L,R,z.value[0].value)),(t,n)=>{let u=y(`nc-button`),p=y(`nc-icon`);return h(),o(r,null,[s(`div`,E,[w(l(u,{class:`nc-tab-scroll-left`,ref_key:`leftArrowRef`,ref:j,icon:`chevron-left`,size:`tiny`,onClick:B,onDblclick:H},null,512),[[S,x(P)]]),s(`div`,{class:d([`nc-tab ui secondary pointing menu nc-no-print`,x(N)?`overflownElement`:``]),ref_key:`element`,ref:A,style:f(e.style)},[(h(!0),o(r,null,_(x(z),(t,n)=>(h(),o(`a`,{class:d([`link item nc-tab-item`,[x(N)?`overflownItem`:``,{active:K(t.value),disabled:t.disabled==1}]]),id:t.value,key:t.value,style:f(e.itemStyle),onClick:e=>q(e,t,n),onDblclick:e=>q(e,t,n,!0)},[t.icon?(h(),i(p,{key:0,icon:t.icon},null,8,[`icon`])):a(``,!0),c(b(t.show),1)],46,D))),128))],6),w(l(u,{class:`nc-tab-scroll-right`,ref_key:`rightArrowRef`,ref:M,icon:`chevron-right`,size:`tiny`,onClick:V,onDblclick:U},null,512),[[S,x(F)]])]),v(t.$slots,`default`)],64)}}});export{O as default};