import{s as re,aA as M,w as B,aH as Z,aG as ue,y as j,aF as $,an as ce,az as ae,a5 as H,E as ne,G as ie,d5 as he,K as se,f as R,a3 as ve,ao as ye,ci as oe,a6 as G,ch as pe,z as b,P as g,Q as d,T as fe,D as be,ah as me,cj as Te}from"./index-DT8qTvyx.js";var ge=function(I){re(r,I);function r(e){var t=I.call(this,e)||this;t.newTabDefaultId=3;var a=e.location||window.location,n=e.tabs,s=e.source,l=e.data,o=0;if(typeof e.activeKey<"u")o=e.activeKey;else if(a&&Array.isArray(n)){var v=a.hash.substring(1),u=M(n,function(K){return K.hash===v});u?o=u.hash:e.defaultKey!==void 0?o=typeof e.defaultKey=="string"?B(e.defaultKey,e.data):e.defaultKey:e.defaultActiveKey&&(o=typeof e.defaultActiveKey=="string"?B(e.defaultActiveKey,e.data):e.defaultActiveKey),o=o||n[0]&&n[0].hash||0}var p=Z(t.initTabArray(n,s,l),2),h=p[0],m=p[1];return t.state={prevKey:void 0,activeKey:t.activeKey=o,localTabs:h,isFromSource:m},t}return r.prototype.initTabArray=function(e,t,a){if(!e)return[[],!1];var n=B(t,a,"| raw");if(!Array.isArray(n))return[e,!1];e=Array.isArray(e)?e:[e];var s=[];return n.forEach(function(l){s.push.apply(s,ue([],Z(e.map(function(o){return j(j({},o),{data:l})})),!1))}),[s,!0]},r.prototype.componentDidMount=function(){var e,t;this.autoJumpToNeighbour(this.activeKey);var a=this.props,n=a.name,s=a.value,l=a.onChange,o=a.source;a.tabs;var v=a.data,u=this.state.localTabs;if(!(!n||typeof l!="function"||o))if(s=s??$(v,n),s&&Array.isArray(u)){var p=this.resolveKeyByValue(s);p!==void 0&&this.handleSelect(p)}else{var h=this.resolveTabByKey(this.activeKey);h&&s!==((e=h.value)!==null&&e!==void 0?e:h.title)&&l((t=h.value)!==null&&t!==void 0?t:h.title,n)}},r.prototype.componentDidUpdate=function(e,t){var a,n,s,l=this.props,o=this.state.localTabs,v=B(e.defaultActiveKey,e.data),u=B(l.defaultActiveKey,l.data),p=ce({tabs:l.tabs,source:B(l.source,l.data,"| raw")},{tabs:e.tabs,source:B(e.source,e.data,"| raw")},!1);if(p){var h=Z(this.initTabArray(l.tabs,l.source,l.data),2),m=h[0],K=h[1];this.setState({localTabs:m,isFromSource:K}),o=m}if(l.location&&e.location&&l.location.hash!==e.location.hash){var S=l.location.hash.substring(1);if(!S)return;var y=M(o,function(C){return C.hash===S});y&&y.hash&&y.hash!==this.state.activeKey&&this.setState({activeKey:this.activeKey=y.hash,prevKey:this.state.activeKey})}else if(Array.isArray(o)&&Array.isArray(t.localTabs)&&JSON.stringify(o.map(function(C){return C.hash}))!==JSON.stringify(t.localTabs.map(function(C){return C.hash}))){var A=this.state.activeKey,x=l.location,y=null;if(x&&Array.isArray(o)){var V=x.hash.substring(1);y=M(o,function(_){return _.hash===V})}y?A=y.hash:(!o||!o.some(function(_,q){return _.hash?_.hash===A:q===A}))&&(A=o&&o[0]&&o[0].hash||0),this.setState({prevKey:void 0,activeKey:this.activeKey=A})}else if(v!==u){if(u==null)return;var E=null,y=M(o,function(_){return _.hash===u});y?E=y.hash:typeof u=="number"&&o[u]&&(E=u),E!==null&&this.setState({prevKey:v,activeKey:this.activeKey=E})}this.autoJumpToNeighbour(this.activeKey);var O=this.props,z=O.name,T=O.value,J=O.onChange,W=O.source,k=O.data;if(!(!z||typeof J!="function"||W)){var U;T=T??$(k,z);var Q=(a=e.value)!==null&&a!==void 0?a:$(e.data,e.name);if(T!==Q&&(U=this.resolveKeyByValue(T))!==void 0&&U!==this.activeKey)this.handleSelect(U);else if(this.activeKey!==t.activeKey){var y=this.resolveTabByKey(this.activeKey);y&&T!==((n=y.value)!==null&&n!==void 0?n:y.title)&&J((s=y.value)!==null&&s!==void 0?s:y.title,z)}}},r.prototype.resolveTabByKey=function(e){var t=this.state.localTabs;if(Array.isArray(t))return M(t,function(a,n){return a.hash?a.hash===e:n===e})},r.prototype.resolveKeyByValue=function(e){var t=this.state.localTabs;if(Array.isArray(t)){var a=M(t,function(n){var s;return((s=n.value)!==null&&s!==void 0?s:n.title)===e});return a&&a.hash?a.hash:t.indexOf(a)}},r.prototype.autoJumpToNeighbour=function(e){var t=this.props;t.tabs;var a=t.data,n=this.state.localTabs;if(Array.isArray(n)){var s=ae(n,function(p,h){return p.hash?p.hash===e:h===e});if(n[s]&&!H(n[s],this.props.data))for(var l=n.length,o=s,v=s;o-->=0||v++=0&&H(n[o],a)?u=n[o].hash||o:v0?((w=f[c-1])===null||w===void 0?void 0:w.hash)||c-1:0,nextKey:c0?((w=f[c-1])===null||w===void 0?void 0:w.hash)||c-1:0,nextKey:c