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,i.useForm)(),[{onClose:a},t]=(0,s.useContext)(r.Context),{focusedField:p,rules:m,sidebarPanels:y}=(0,i.useFormState)(),{allowFieldSets:g,contentType:E,dataDefinitionId:P,groupId:j,portletNamespace:w}=(0,i.useConfig)(),[{sidebarOpen:I,sidebarPanelId:v},O]=(0,s.useState)({sidebarOpen:!0,sidebarPanelId:"fields"}),{panels:S,sidebarPanels:D,sidebarVariant:L}=(0,s.useMemo)((()=>(0,c.default)({portletNamespace:w,sidebarPanels:y})),[y,w]);return(0,s.useEffect)((()=>{if(g&&E){let a=[];j&&(a=(0,b.getItem)("/o/data-engine/v2.0/sites/".concat(j,"/data-definitions/by-content-type/").concat(E)));const t=(0,b.getItem)("/o/data-engine/v2.0/data-definitions/by-content-type/".concat(E));(async()=>{try{const[{items:n=[]},{items:r=[]}]=await Promise.all([a,t]),l=[...n,...r].filter((({id:e})=>e!==parseInt(P,10)));e({payload:{fieldSets:l},type:f.EVENT_TYPES.FIELD_SET.UPDATE_LIST})}catch(e){}})()}}),[g,E,P,e,j]),(0,s.useEffect)((()=>{const e=document.querySelector(".data-engine-form-builder-messages");e&&(e.className=(0,l.default)("data-engine-form-builder-messages",{"data-engine-form-builder-messages--collapsed":I}))}),[I]),(0,s.useEffect)((()=>{Object.keys(p).length>0&&O((({sidebarPanelId:e})=>({sidebarOpen:!0,sidebarPanelId:e})))}),[p]),s.default.createElement("div",{className:(0,l.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(i.Pages,{editable:!0,fieldActions:[{action:a=>e({payload:a,type:i.EVENT_TYPES.FIELD.DUPLICATE}),label:Liferay.Language.get("duplicate")},{action:n=>e((0,d.default)({action:{payload:n,type:i.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:v,onChange:O,open:I,panels:S,sidebarPanels:D,variant:L})))))};var n=m(t("@frontend-taglib-clay$clayui/layout")),r=t("@frontend-taglib-clay$clayui/modal"),l=m(t("liferay!frontend-js-react-web$classnames")),i=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=p();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 l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(t,r,l):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"),b=t("./utils/client.es");function p(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return p=function(){return e},e}function m(e){return e&&e.__esModule?e:{default:e}}}}));
//# sourceMappingURL=FormBuilder.js.map