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