Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.179/page_editor/plugins/fragments_and_widgets/components/TabsPanel",["module","exports","require","@frontend-taglib-clay$clayui/loading-indicator","@frontend-taglib-clay$clayui/tabs","frontend-js-components-web","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../app/config/constants/fragmentsDisplayStyles","../../../app/config/index","../../../app/contexts/StoreContext","../../../app/selectors/selectWidgetFragmentEntryLinks","../../../app/thunks/loadWidgets","./FragmentsSidebar","./TabCollection"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function TabsPanel({activeTabId:t,displayStyle:a,setActiveTabId:b,tabs:y}){const _=(0,l.useId)(),getTabId=e=>"".concat(_,"tab").concat(e),getTabPanelId=e=>"".concat(_,"tabPanel").concat(e),m=(0,o.useRef)(null),v=(0,u.useDispatch)(),w=(0,u.useSelectorRef)(d.default),E=(0,u.useSelector)((e=>e.widgets)),[S,R]=(0,l.useSessionState)("".concat(s.config.portletNamespace,"_fragments-sidebar_").concat(t,"_scroll-position"),0),j=(0,o.useRef)(S);return j.current=S,(0,o.useEffect)((()=>{t!==p.COLLECTION_IDS.widgets||E||v((0,f.default)({fragmentEntryLinks:w.current}))}),[t,v,w,E]),(0,o.useLayoutEffect)((()=>{const e=m.current,t=j.current;e&&t&&e.scrollBy({behavior:"auto",left:0,top:t})}),[]),(0,o.useEffect)((()=>{const e=m.current;if(!e)return;const t=(0,i.debounce)((()=>{R(e.scrollTop)}),300);return e.addEventListener("scroll",t,{passive:!0}),()=>{e.removeEventListener("scroll",t)}}),[R]),o.default.createElement(o.default.Fragment,null,o.default.createElement(r.default,{activation:"automatic",active:t,className:"flex-shrink-0 page-editor__sidebar__fragments-widgets-panel__tabs px-3",onActiveChange:e=>{b(e),R(0),m.current&&(m.current.scrollTop=0)}},y.map(((e,a)=>o.default.createElement(r.default.Item,{active:e.id===t,innerProps:{"aria-controls":getTabPanelId(a),id:getTabId(a)},key:a},e.label)))),o.default.createElement("div",{className:"overflow-auto pt-4 px-3",ref:m},o.default.createElement(r.default.Content,{activeIndex:t,className:"page-editor__sidebar__fragments-widgets-panel__tab-content",fade:!0},y.map(((t,l)=>o.default.createElement(r.default.TabPane,{"aria-labelledby":getTabId(l),id:getTabPanelId(l),key:l},t.collections.length?o.default.createElement("ul",{"aria-orientation":"vertical",className:"list-unstyled panel-group-sm",role:"menubar"},t.collections.map(((n,r)=>o.default.createElement(g.default,{collection:n,displayStyle:t.id===p.COLLECTION_IDS.widgets?c.FRAGMENTS_DISPLAY_STYLES.LIST:a,initialOpen:r<e,key:n.collectionId})))):o.default.createElement(n.default,{size:"sm"})))))))};var n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/loading-indicator")),r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/tabs")),l=a("frontend-js-components-web"),i=a("frontend-js-web"),o=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"))),c=a("../../../app/config/constants/fragmentsDisplayStyles"),s=a("../../../app/config/index"),u=a("../../../app/contexts/StoreContext"),d=_interopRequireDefault(a("../../../app/selectors/selectWidgetFragmentEntryLinks")),f=_interopRequireDefault(a("../../../app/thunks/loadWidgets")),p=a("./FragmentsSidebar"),g=_interopRequireDefault(a("./TabCollection"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e=3}}));
//# sourceMappingURL=TabsPanel.js.map