Liferay.Loader.define("product-navigation-control-menu@6.0.52/js/TabsContent",["module","exports","require","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./AddPanel","./Collection","./ContentOptions","./SearchForm","./SearchResultPanel"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n("frontend-js-web"),o=(f(n("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=s();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var l=r?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(n,o,l):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react"))),l=n("./AddPanel"),a=f(n("./Collection")),c=f(n("./ContentOptions")),i=f(n("./SearchForm")),u=f(n("./SearchResultPanel"));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function f(e){return e&&e.__esModule?e:{default:e}}function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach((function(t){b(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const e="content",O={collections:[]},g=3,h=(e,t)=>{const n=t.toLowerCase(),r=e=>-1!==e.label.toLowerCase().indexOf(n),o=e=>{var t,n,r;return!!(null===(t=e.children)||void 0===t?void 0:t.length)||null!==(n=null===(r=e.collections)||void 0===r?void 0:r.some(o))&&void 0!==n&&n};return e.reduce(((e,t)=>{if(r(t))return[...e,t];{var o;const l=p(p({},t),{},{children:t.children.filter((e=>{var t;return r(e)||(null===(t=e.portletItems)||void 0===t?void 0:t.some(r))}))},(null===(o=t.collections)||void 0===o?void 0:o.length)&&{collections:h(t.collections,n)});return[...e,l]}}),[]).filter(o)};var y=({tab:t,tabIndex:n})=>{const{getContentsURL:s,namespace:f}=(0,o.useContext)(l.AddPanelContext),[d,b]=(0,o.useState)(t),[y,j]=(0,o.useState)(0),[v,m]=(0,o.useState)(""),w=t.id===e,P=w?d.collections:t.collections,C=(0,o.useMemo)((()=>v?[p(p({},t),{},{collections:h(t.collections,v)})]:t),[v,t]);return(0,o.useEffect)((()=>{if(!v&&!y)return b(t);{const e={["".concat(f,"keywords")]:v.toLowerCase()};y&&(e["".concat(f,"delta")]=y),(0,r.fetch)(s,{body:(0,r.objectToFormData)(e),method:"post"}).then((e=>e.json())).then((e=>{const n=p(p({},t),{},{collections:e.contents.length?t.collections.map((t=>p(p({},t),{},{children:e.contents.map(l.normalizeContent)}))):e.contents});return b(n)})).catch((()=>b([O])))}}),[s,f,v,t,y]),o.default.createElement(o.default.Fragment,null,o.default.createElement(i.default,{onChange:m,tabIndex:n,value:v}),w&&o.default.createElement(c.default,{onChangeSelect:j}),v?o.default.createElement(u.default,{alertTitle:w?Liferay.Language.get("there-is-no-content-on-this-page"):Liferay.Language.get("there-are-no-widgets-on-this-page"),filteredTabs:w?[d]:C}):o.default.createElement("ul",{className:"list-unstyled"},P.map(((e,t)=>o.default.createElement(a.default,{collection:e,isContentTab:w,key:t,open:t<g})))))};t.default=y}}));
//# sourceMappingURL=TabsContent.js.map