Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/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({activeTabId:t,displayStyle:a,setActiveTabId:b,tabs:m}){const _=(0,u.useId)(),S=e=>"".concat(_,"tab").concat(e),E=e=>"".concat(_,"tabPanel").concat(e),w=(0,l.useRef)(null),v=(0,i.useDispatch)(),k=(0,i.useSelectorRef)(d.default),L=(0,i.useSelector)((e=>e.widgets)),[I,O]=(0,p.useSessionState)("".concat(c.config.portletNamespace,"_fragments-sidebar_").concat(t,"_scroll-position"),0),j=(0,l.useRef)(I);return j.current=I,(0,l.useEffect)((()=>{t!==y.COLLECTION_IDS.widgets||L||v((0,f.default)({fragmentEntryLinks:k.current}))}),[t,v,k,L]),(0,l.useLayoutEffect)((()=>{const e=w.current,t=j.current;e&&t&&e.scrollBy({behavior:"auto",left:0,top:t})}),[]),(0,l.useEffect)((()=>{const e=w.current;if(!e)return;const t=(0,o.debounce)((()=>{O(e.scrollTop)}),300);return e.addEventListener("scroll",t,{passive:!0}),()=>{e.removeEventListener("scroll",t)}}),[O]),l.default.createElement(l.default.Fragment,null,l.default.createElement(r.default,{className:"flex-shrink-0 page-editor__sidebar__fragments-widgets-panel__tabs px-3"},m.map(((e,a)=>l.default.createElement(r.default.Item,{active:e.id===t,innerProps:{"aria-controls":E(a),id:S(a)},key:a,onClick:()=>{b(e.id),O(0),w.current&&(w.current.scrollTop=0)}},e.label)))),l.default.createElement("div",{className:"overflow-auto pt-4 px-3",ref:w},l.default.createElement(r.default.Content,{activeIndex:m.findIndex((e=>e.id===t)),className:"page-editor__sidebar__fragments-widgets-panel__tab-content",fade:!0},m.map(((t,o)=>l.default.createElement(r.default.TabPane,{"aria-labelledby":S(o),id:E(o),key:o},l.default.createElement("ul",{className:"list-unstyled"},t.collections.length?t.collections.map(((n,r)=>l.default.createElement(g.default,{collection:n,displayStyle:t.id===y.COLLECTION_IDS.widgets?s.FRAGMENTS_DISPLAY_STYLES.LIST:a,initialOpen:r<e,key:r}))):l.default.createElement(n.default,{small:!0}))))))))};var n=m(a("@frontend-taglib-clay$clayui/loading-indicator")),r=m(a("@frontend-taglib-clay$clayui/tabs")),o=a("frontend-js-web"),l=(m(a("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=b();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"))),s=a("../../../app/config/constants/fragmentsDisplayStyles"),c=a("../../../app/config/index"),i=a("../../../app/contexts/StoreContext"),d=m(a("../../../app/selectors/selectWidgetFragmentEntryLinks")),f=m(a("../../../app/thunks/loadWidgets")),u=a("../../../core/hooks/useId"),p=a("../../../core/hooks/useSessionState"),y=a("./FragmentsSidebar"),g=m(a("./TabCollection"));function b(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return b=function(){return e},e}function m(e){return e&&e.__esModule?e:{default:e}}const e=3}}));
//# sourceMappingURL=TabsPanel.js.map