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