Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/plugins/experience/components/ExperienceModal",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/modal","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../app/config/index","../../../common/components/Button"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=g(a("@frontend-taglib-clay$clayui/alert")),l=g(a("@frontend-taglib-clay$clayui/button")),r=y(a("@frontend-taglib-clay$clayui/form")),c=g(a("@frontend-taglib-clay$clayui/icon")),o=g(a("@frontend-taglib-clay$clayui/modal")),i=a("@liferay/frontend-js-react-web"),u=g(a("liferay!frontend-js-react-web$classnames")),d=(g(a("liferay!frontend-js-react-web$prop-types")),y(a("liferay!frontend-js-react-web$react"))),f=a("../../../app/config/index"),s=g(a("../../../common/components/Button"));function m(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return m=function(){return e},e}function y(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=m();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var r=n?Object.getOwnPropertyDescriptor(e,l):null;r&&(r.get||r.set)?Object.defineProperty(a,l,r):a[l]=e[l]}return a.default=e,t&&t.set(e,a),a}function g(e){return e&&e.__esModule?e:{default:e}}function p(e){return e&&e.replace(/ /g,"")}var b=({canUpdateSegments:e,errorMessage:t,experienceId:a,initialName:m="",observer:y,onClose:g,onErrorDismiss:b,onNewSegmentClick:E,onSubmit:v,segmentId:L,segments:x=[]})=>{const[w,$]=(0,d.useState)(void 0!==L?L:x[0]&&x[0].segmentsEntryId),j=(0,i.useIsMounted)(),[N,k]=(0,d.useState)(m),[C,I]=(0,d.useState)(!1),[S,h]=(0,d.useState)(!1),O=e=>{e.preventDefault();p(N)?(h(!0),v({name:N,segmentsEntryId:w,segmentsExperienceId:a}).finally((()=>{j()&&h(!1)}))):I(!0)},M="".concat(f.config.portletNamespace,"segmentsExperienceName"),P="".concat(f.config.portletNamespace,"segmentsExperienceSegment"),_=(0,u.default)("my-2",{"has-error":C}),F=a?Liferay.Language.get("edit-experience"):Liferay.Language.get("new-experience");return d.default.createElement(o.default,{containerProps:{className:"cadmin"},observer:y,size:"md"},d.default.createElement(o.default.Header,null,F),d.default.createElement(o.default.Body,null,d.default.createElement(r.default,{autoComplete:"off",className:"mb-3",noValidate:!0,onSubmit:O},t&&d.default.createElement(n.default,{displayType:"danger",onClose:b,title:t}),d.default.createElement(r.default.Group,{className:_},d.default.createElement("label",{htmlFor:M},Liferay.Language.get("name"),d.default.createElement(c.default,{className:"ml-1 reference-mark",focusable:"false",role:"presentation",symbol:"asterisk"})),d.default.createElement(r.ClayInput,{autoFocus:!0,id:M,onChange:e=>{const{value:t}=e.target;p(t)?I(!1):I(!0),k(t)},placeholder:Liferay.Language.get("experience-name"),required:!0,type:"text",value:N}),C&&d.default.createElement(r.default.FeedbackItem,null,d.default.createElement(r.default.FeedbackIndicator,{className:"mr-1",symbol:"exclamation-full"}),Liferay.Language.get("an-experience-name-is-required"))),d.default.createElement(r.default.Group,{className:"my-2"},d.default.createElement("label",{htmlFor:P},Liferay.Language.get("audience"),d.default.createElement(c.default,{className:"ml-1 reference-mark",focusable:"false",role:"presentation",symbol:"asterisk"})),d.default.createElement("div",{className:"d-flex"},d.default.createElement(r.ClaySelect,{disabled:!x.length,id:P,onChange:e=>{$(e.target.value)},value:w},x.length?x.map((e=>d.default.createElement(r.ClaySelect.Option,{key:e.segmentsEntryId,label:e.name,value:e.segmentsEntryId}))):d.default.createElement(r.ClaySelect.Option,{label:Liferay.Language.get("no-segments"),value:""})),!0===e&&d.default.createElement(s.default,{className:"flex-shrink-0 ml-2",disabled:S,displayType:"secondary",onClick:e=>{e.preventDefault(),E({experienceId:a,experienceName:N,segmentId:w})},type:"button"},Liferay.Language.get("new-segment")))))),d.default.createElement(o.default.Footer,{last:d.default.createElement(l.default.Group,{spaced:!0},d.default.createElement(l.default,{disabled:S,displayType:"secondary",onClick:g},Liferay.Language.get("cancel")),d.default.createElement(s.default,{disabled:S,displayType:"primary",loading:S,onClick:O},Liferay.Language.get("save")))}))};t.default=b}}));
//# sourceMappingURL=ExperienceModal.js.map