Liferay.Loader.define("data-engine-taglib@3.3.26/data_layout_builder/js/FormBuilder",["module","exports","require","@frontend-taglib-clay$clayui/layout","@frontend-taglib-clay$clayui/modal","liferay!frontend-js-react-web$classnames","data-engine-js-components-web","data-engine-js-components-web/js/core/thunks/fieldDelete.es","liferay!frontend-js-react-web$react","./components/sidebar/MultiPanelSidebar.es","./components/sidebar/initializeSidebarConfig.es","./drag-and-drop/DragLayer.es","./eventTypes","./utils/client.es"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.FormBuilder=function(){const e=(0,l.useForm)(),[{onClose:a},t]=(0,s.useContext)(r.Context),{focusedField:b,rules:m,sidebarPanels:g}=(0,l.useFormState)(),{allowFieldSets:y,contentType:E,dataDefinitionId:P,groupId:j,portletNamespace:w}=(0,l.useConfig)(),[{sidebarOpen:I,sidebarPanelId:S},v]=(0,s.useState)({sidebarOpen:!0,sidebarPanelId:"fields"}),{panels:O,sidebarPanels:D,sidebarVariant:L}=(0,s.useMemo)((()=>(0,c.default)({portletNamespace:w,sidebarPanels:g})),[g,w]);return(0,s.useEffect)((()=>{if(y&&E){let a=[];j&&(a=(0,p.getItem)("/o/data-engine/v2.0/sites/".concat(j,"/data-definitions/by-content-type/").concat(E,"?page=-1&pageSize=-1")));const t=(0,p.getItem)("/o/data-engine/v2.0/data-definitions/by-content-type/".concat(E,"?page=-1&pageSize=-1"));(async()=>{try{const[{items:n=[]},{items:r=[]}]=await Promise.all([a,t]),i=[...n,...r].filter((({id:e})=>e!==parseInt(P,10)));e({payload:{fieldSets:i},type:f.EVENT_TYPES.FIELD_SET.UPDATE_LIST})}catch(e){}})()}}),[y,E,P,e,j]),(0,s.useEffect)((()=>{const e=document.querySelector(".data-engine-form-builder-messages");e&&(e.className=(0,i.default)("data-engine-form-builder-messages",{"data-engine-form-builder-messages--collapsed":I}))}),[I]),(0,s.useEffect)((()=>{Object.keys(b).length>0&&v((({sidebarPanelId:e})=>({sidebarOpen:!0,sidebarPanelId:e})))}),[b]),s.default.createElement("div",{className:(0,i.default)("data-engine-form-builder ddm-form-builder pb-5",{"ddm-form-builder--sidebar-open":I})},s.default.createElement(n.default.Sheet,null,s.default.createElement("div",{className:"ddm-form-builder-wrapper"},s.default.createElement("div",{className:"container ddm-form-builder"},s.default.createElement(u.default,null),s.default.createElement(l.Pages,{editable:!0,fieldActions:[{action:a=>e({payload:a,type:l.EVENT_TYPES.FIELD.DUPLICATE}),label:Liferay.Language.get("duplicate")},{action:n=>e((0,d.default)({action:{payload:n,type:l.EVENT_TYPES.FIELD.DELETE},modalDispatch:t,onClose:a,rules:m})),label:Liferay.Language.get("delete")}]}),s.default.createElement(o.default,{createPlugin:({panel:a,sidebarOpen:t,sidebarPanelId:n})=>({dispatch:e,panel:a,sidebarOpen:t,sidebarPanelId:n}),currentPanelId:S,onChange:v,open:I,panels:O,sidebarPanels:D,variant:L})))))};var n=m(t("@frontend-taglib-clay$clayui/layout")),r=t("@frontend-taglib-clay$clayui/modal"),i=m(t("liferay!frontend-js-react-web$classnames")),l=t("data-engine-js-components-web"),d=m(t("data-engine-js-components-web/js/core/thunks/fieldDelete.es")),s=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var a=b();if(a&&a.has(e))return a.get(e);var t={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=n?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(t,r,i):t[r]=e[r]}t.default=e,a&&a.set(e,t);return t}(t("liferay!frontend-js-react-web$react")),o=m(t("./components/sidebar/MultiPanelSidebar.es")),c=m(t("./components/sidebar/initializeSidebarConfig.es")),u=m(t("./drag-and-drop/DragLayer.es")),f=t("./eventTypes"),p=t("./utils/client.es");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}}}}));
//# sourceMappingURL=FormBuilder.js.map