import{s as fe,aB as z,w as x,aI as ae,aH as ge,y,aG as se,an as Ce,aA as ue,a5 as D,E as ne,G as ie,da as Ke,K as ce,f as b,ad as H,a3 as he,ao as ve,cm as pe,a6 as W,ae as re,cl as Ne,z as T,P as N,Q as c,T as Ae,D as Se,ah as ye,cn as Ee}from"./index-BPRWoLf4.js";var _e=function(M){fe(l,M);function l(e){var t=M.call(this,e)||this;t.newTabDefaultId=3;var a=e.location||window.location,n=e.tabs,r=e.source,o=e.data,i=0;if(typeof e.activeKey<"u")i=e.activeKey;else if(a&&Array.isArray(n)){var h=a.hash.substring(1),u=z(n,function(A){return A.hash===h});u?i=u.hash:e.defaultKey!==void 0?i=typeof e.defaultKey=="string"?x(e.defaultKey,e.data):e.defaultKey:e.defaultActiveKey&&(i=typeof e.defaultActiveKey=="string"?x(e.defaultActiveKey,e.data):e.defaultActiveKey),i=i||n[0]&&n[0].hash||0}var p=ae(t.initTabArray(n,r,o),2),v=p[0],g=p[1];return t.state={prevKey:void 0,activeKey:t.activeKey=i,localTabs:v,isFromSource:g},t}return l.prototype.initTabArray=function(e,t,a){if(!e)return[[],!1];var n=x(t,a,"| raw");if(!Array.isArray(n))return[e,!1];e=Array.isArray(e)?e:[e];var r=[];return n.forEach(function(o){r.push.apply(r,ge([],ae(e.map(function(i){return y(y({},i),{data:o})})),!1))}),[r,!0]},l.prototype.componentDidMount=function(){var e,t;this.autoJumpToNeighbour(this.activeKey);var a=this.props,n=a.name,r=a.value,o=a.onChange,i=a.source;a.tabs;var h=a.data,u=this.state.localTabs;if(!(!n||typeof o!="function"||i))if(r=r??se(h,n),r&&Array.isArray(u)){var p=this.resolveKeyByValue(r);p!==void 0&&this.handleSelect(p)}else{var v=this.resolveTabByKey(this.activeKey);v&&r!==((e=v.value)!==null&&e!==void 0?e:v.title)&&o((t=v.value)!==null&&t!==void 0?t:v.title,n)}},l.prototype.componentDidUpdate=function(e,t){var a,n,r,o=this.props,i=this.state.localTabs,h=x(e.defaultActiveKey,e.data),u=x(o.defaultActiveKey,o.data),p=Ce({tabs:o.tabs,source:x(o.source,o.data,"| raw")},{tabs:e.tabs,source:x(e.source,e.data,"| raw")},!1);if(p){var v=ae(this.initTabArray(o.tabs,o.source,o.data),2),g=v[0],A=v[1];this.setState({localTabs:g,isFromSource:A}),i=g}if(o.location&&e.location&&o.location.hash!==e.location.hash){var _=o.location.hash.substring(1);if(!_)return;var f=z(i,function(F){return F.hash===_});f&&f.hash&&f.hash!==this.state.activeKey&&this.setState({activeKey:this.activeKey=f.hash,prevKey:this.state.activeKey})}else if(Array.isArray(i)&&Array.isArray(t.localTabs)&&JSON.stringify(i.map(function(F){return F.hash}))!==JSON.stringify(t.localTabs.map(function(F){return F.hash}))){var S=this.state.activeKey,U=o.location,f=null;if(U&&Array.isArray(i)){var J=U.hash.substring(1);f=z(i,function(E){return E.hash===J})}f?S=f.hash:(!i||!i.some(function(E,X){return E.hash?E.hash===S:X===S}))&&(S=i&&i[0]&&i[0].hash||0),this.setState({prevKey:void 0,activeKey:this.activeKey=S})}else if(h!==u){if(u==null)return;var w=null,f=z(i,function(E){return E.hash===u});f?w=f.hash:typeof u=="number"&&i[u]&&(w=u),w!==null&&this.setState({prevKey:h,activeKey:this.activeKey=w})}this.autoJumpToNeighbour(this.activeKey);var O=this.props,R=O.name,C=O.value,k=O.onChange,P=O.source,Q=O.data;if(!(!R||typeof k!="function"||P)){var V;C=C??se(Q,R);var q=(a=e.value)!==null&&a!==void 0?a:se(e.data,e.name);if(C!==q&&(V=this.resolveKeyByValue(C))!==void 0&&V!==this.activeKey)this.handleSelect(V);else if(this.activeKey!==t.activeKey){var f=this.resolveTabByKey(this.activeKey);f&&C!==((n=f.value)!==null&&n!==void 0?n:f.title)&&k((r=f.value)!==null&&r!==void 0?r:f.title,R)}}},l.prototype.resolveTabByKey=function(e){var t=this.state.localTabs;if(Array.isArray(t))return z(t,function(a,n){return a.hash?a.hash===e:n===e})},l.prototype.resolveKeyByValue=function(e){var t=this.state.localTabs;if(Array.isArray(t)){var a=z(t,function(n){var r;return((r=n.value)!==null&&r!==void 0?r:n.title)===e});return a&&a.hash?a.hash:t.indexOf(a)}},l.prototype.autoJumpToNeighbour=function(e){var t=this.props;t.tabs;var a=t.data,n=this.state.localTabs;if(Array.isArray(n)){var r=ue(n,function(p,v){return p.hash?p.hash===e:v===e});if(n[r]&&!D(n[r],this.props.data))for(var o=n.length,i=r,h=r;i-->=0||h++=0&&D(n[i],a)?u=n[i].hash||i:h0?((K=m[d-1])===null||K===void 0?void 0:K.hash)||d-1:0,nextKey:d0?((K=m[d-1])===null||K===void 0?void 0:K.hash)||d-1:0,nextKey:d a"},focused:{important:!0,suf:".is-active",inner:"> a"},hover:{important:!0,inner:"> a"},disabled:{important:!0,suf:".is-disabled",inner:"> a"}}},{key:"toolbarControlClassName",weights:{default:{important:!0}}},{key:"contentControlClassName",weights:{default:{important:!0}}}]},env:me})))},l.prototype.render=function(){return this.renderTabs()},l.defaultProps={className:"",mode:"",mountOnEnter:!0,unmountOnExit:!1},T([N,c("design:type",Function),c("design:paramtypes",[Array,String,Object]),c("design:returntype",Array)],l.prototype,"initTabArray",null),T([N,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],l.prototype,"autoJumpToNeighbour",null),T([N,c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",void 0)],l.prototype,"handleAdd",null),T([N,c("design:type",Function),c("design:paramtypes",[Object,Boolean]),c("design:returntype",Promise)],l.prototype,"handleClose",null),T([N,c("design:type",Function),c("design:paramtypes",[Number,String]),c("design:returntype",void 0)],l.prototype,"handleEdit",null),T([N,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",Promise)],l.prototype,"handleDragChange",null),T([N,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",Promise)],l.prototype,"handleSelect",null),T([N,c("design:type",Function),c("design:paramtypes",[Number]),c("design:returntype",void 0)],l.prototype,"switchTo",null),T([N,c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",Number)],l.prototype,"currentIndex",null),l}(b.Component),Oe=function(M){fe(l,M);function l(e,t){var a=M.call(this,e)||this,n=t;return n.registerComponent(a),a}return l.prototype.componentWillUnmount=function(){var e;(e=M.prototype.componentWillUnmount)===null||e===void 0||e.call(this);var t=this.context;t.unRegisterComponent(this)},l.contextType=Ae,l=T([Se({type:"tabs"}),c("design:paramtypes",[Object,Object])],l),l}(_e);export{Oe as TabsRenderer,_e as default};