Liferay.Loader.define("dynamic-data-mapping-form-web@4.0.150/admin/js/hooks/useStateSync.es",["module","exports","require","data-engine-js-components-web","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.useStateSync=function useStateSync(){const{portletNamespace:e,sidebarPanels:t}=(0,n.useConfig)(),{availableLanguageIds:a,defaultLanguageId:o,localizedDescription:i,localizedName:c,pages:s,paginationMode:d,rules:l,successPageSettings:u}=(0,n.useFormState)();return(0,r.useCallback)((()=>{const n={availableLanguageIds:a,defaultLanguageId:o,description:i,name:c,pages:s,paginationMode:d,rules:l,sidebarPanels:t,successPageSettings:u};Object.keys(n.name).forEach((e=>{n.name[e]=Liferay.Util.unescape(n.name[e])})),Object.keys(n.description).forEach((e=>{n.description[e]=Liferay.Util.unescape(n.description[e])})),document.querySelector("#".concat(e,"name")).value=JSON.stringify(c),document.querySelector("#".concat(e,"description")).value=JSON.stringify(i),document.querySelector("#".concat(e,"serializedFormBuilderContext")).value=getSerializedFormBuilderContext(n,o)}),[a,o,i,c,s,d,e,l,t,u])};var n=a("data-engine-js-components-web"),r=a("liferay!frontend-js-react-web$react");function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const getSerializedSettingsContextPages=(e,t)=>new n.PagesVisitor(e).mapFields((e=>{if("options"===e.type){const{value:a}=e,n={};Object.keys(a).forEach((e=>{n[e]=a[e].filter((({value:e})=>""!==e))})),n[t]||(n[t]=[]),e=_objectSpread(_objectSpread({},e),{},{value:n})}return e})),getSerializedFormBuilderContext=(e,t)=>{const a=e.pages.map((e=>_objectSpread(_objectSpread({},e),{},{description:e.localizedDescription,title:e.localizedTitle}))).filter((({contentRenderer:e})=>"success"!==e)),r=new n.PagesVisitor(a);return JSON.stringify(_objectSpread(_objectSpread({},e),{},{pages:r.mapFields((a=>_objectSpread(_objectSpread({},a),{},{settingsContext:_objectSpread(_objectSpread({},a.settingsContext),{},{availableLanguageIds:e.availableLanguageIds,defaultLanguageId:e.defaultLanguageId,pages:getSerializedSettingsContextPages(a.settingsContext.pages,t)})})),!0,!0)}))}}}));
//# sourceMappingURL=useStateSync.es.js.map