Liferay.Loader.define("@liferay/object-web@1.0.181/js/components/ObjectField/Tabs/Advanced/DefaultValueContainer",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/button","@liferay/object-js-components-web","liferay!frontend-js-react-web$classnames","frontend-js-components-web","liferay!frontend-js-react-web$react","../../../../utils/defaultValues","../../../../utils/fieldSettings","../../DefaultValueFields/PicklistDefaultValueSelect"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultValueContainer=function DefaultValueContainer({creationLanguageId:t,errors:a,learnResources:f,setValues:c,sidebarElements:g,values:p}){const{defaultValue:y,defaultValueType:b}=(0,o.getDefaultValueFieldSettings)(p),[V,v]=(0,s.useState)(!!b&&!!y),[L,j]=(0,s.useState)(b||"inputAsValue");(0,s.useEffect)((()=>{p.state&&(v(!0),j("inputAsValue"))}),[p]);const m=e[p.businessType];return s.default.createElement(r.Card,{disabled:!1,title:Liferay.Language.get("default-value")},!p.state&&s.default.createElement(l.default,{displayType:"info",title:"Info"},Liferay.Language.get("enter-a-value-or-use-expressions-to-set-default-values")," ",s.default.createElement(i.LearnResourcesContext.Provider,{value:f},s.default.createElement(i.LearnMessage,{className:"alert-link",resource:"object-web",resourceKey:"general"}))),!p.state&&s.default.createElement(r.Toggle,{label:Liferay.Language.get("use-default-value"),onToggle:e=>{(e=>{c(e?{objectFieldSettings:(0,o.getUpdatedDefaultValueType)(p,"inputAsValue")}:{objectFieldSettings:(0,d.removeFieldSettings)(["defaultValueType","defaultValue"],p)}),v(e)})(e)},toggled:V}),V&&!p.state&&s.default.createElement(u.default.Group,null,s.default.createElement(u.default,{className:(0,n.default)({active:"inputAsValue"===L}),displayType:"secondary",onClick:()=>{j("inputAsValue"),c({objectFieldSettings:(0,o.getUpdatedDefaultValueType)(p,"inputAsValue")})},size:"sm"},Liferay.Language.get("input-as-value")),s.default.createElement(u.default,{className:(0,n.default)({active:"expressionBuilder"===L}),displayType:"secondary",onClick:()=>{j("expressionBuilder"),c({objectFieldSettings:(0,o.getUpdatedDefaultValueType)(p,"expressionBuilder")})},size:"sm"},Liferay.Language.get("expression-builder"))),V&&"inputAsValue"===L&&m&&s.default.createElement(m,{creationLanguageId:t,defaultValue:"inputAsValue"===b&&y,error:a.defaultValue,label:p.state?Liferay.Language.get("input-as-value"):Liferay.Language.get("default-value"),required:!0,setValues:c,values:p}),V&&"expressionBuilder"===L&&s.default.createElement(r.ExpressionBuilder,{error:a.defaultValue,feedbackMessage:Liferay.Language.get("use-expressions-to-create-a-condition"),label:Liferay.Language.get("default-value"),onChange:({target:{value:e}})=>{c({objectFieldSettings:(0,o.getUpdatedDefaultValueFieldSettings)(p,e,"expressionBuilder")})},onOpenModal:()=>{Liferay.Util.getOpener().Liferay.fire("openExpressionBuilderModal",{eventSidebarElements:g,onSave:e=>{c({objectFieldSettings:(0,o.getUpdatedDefaultValueFieldSettings)(p,e,"expressionBuilder")})},placeholder:"<#-- ".concat(Liferay.Language.get("create-a-condition-to-set-the-default-value")," --\x3e"),required:!1,source:"expressionBuilder"===b&&y?y:"",validateExpressionURL:""})},required:!0,value:"expressionBuilder"===b?y:""}))};var l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/alert")),u=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=a("@liferay/object-js-components-web"),n=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),i=a("frontend-js-components-web"),s=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if(Object.prototype.hasOwnProperty.call(e,u)){var r=l?Object.getOwnPropertyDescriptor(e,u):null;r&&(r.get||r.set)?Object.defineProperty(a,u,r):a[u]=e[u]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),o=a("../../../../utils/defaultValues"),d=a("../../../../utils/fieldSettings");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e={Picklist:_interopRequireDefault(a("../../DefaultValueFields/PicklistDefaultValueSelect")).default}}}));
//# sourceMappingURL=DefaultValueContainer.js.map