Liferay.Loader.define("@liferay/analytics-settings-web@5.0.51/js/components/properties/AssignModal",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/modal","@frontend-taglib-clay$clayui/tabs","frontend-js-web","liferay!frontend-js-react-web$react","../../utils/api","../Loading","./ChannelTab","./SitesTab"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.ETabs=void 0;var n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/modal")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/tabs")),i=a("frontend-js-web"),o=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={},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(a,r,l):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),u=a("../../utils/api"),d=_interopRequireDefault(a("../Loading")),c=_interopRequireDefault(a("./ChannelTab")),f=_interopRequireDefault(a("./SitesTab"));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}}function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}function _objectWithoutProperties(e,t){if(null==e)return{};var a,n,r=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var a,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}let e;t.ETabs=e,function(e){e[e.Channel=0]="Channel",e[e.Sites=1]="Sites"}(e||(t.ETabs=e={}));const AssignModal=({observer:t,onCancel:a,onSubmit:s,property:p})=>{const{name:y,dataSources:[{commerceChannelIds:b,siteIds:g}]}=p,[m,h]=(0,o.useState)(e.Channel),[C,_]=(0,o.useState)(!1),[v,E]=(0,o.useState)(b),[j,S]=(0,o.useState)(g);return o.default.createElement(r.default,{center:!0,observer:t,size:"lg"},o.default.createElement(r.default.Header,null,(0,i.sub)(Liferay.Language.get("assign-to-x"),y)),o.default.createElement(r.default.Body,null,o.default.createElement(l.default,{displayType:"underline",modern:!0},o.default.createElement(l.default.Item,{active:m===e.Channel,innerProps:{"aria-controls":"tabpanel-1"},onClick:()=>h(e.Channel)},Liferay.Language.get("channel")),o.default.createElement(l.default.Item,{active:m===e.Sites,innerProps:{"aria-controls":"tabpanel-2"},onClick:()=>h(e.Sites)},Liferay.Language.get("sites"))),o.default.createElement(l.default.Content,{activeIndex:m,fade:!0},o.default.createElement(l.default.TabPane,{"aria-labelledby":"tab-1","data-testid":e.Channel},o.default.createElement(c.default,{initialIds:v,onChannelsChange:E,property:p})),o.default.createElement(l.default.TabPane,{"aria-labelledby":"tab-2","data-testid":e.Sites},o.default.createElement(f.default,{initialIds:j,onSitesChange:S,property:p})))),o.default.createElement(r.default.Footer,{last:o.default.createElement(n.default.Group,{spaced:!0},o.default.createElement(n.default,{displayType:"secondary",onClick:()=>a()},Liferay.Language.get("cancel")),o.default.createElement(n.default,{disabled:C,displayType:"primary",onClick:async()=>{var e;const{channelId:t,commerceSyncEnabled:a,dataSources:n}=p,{ok:r}=await(0,u.updateProperty)({channelId:t,commerceChannelIds:v,commerceSyncEnabled:a,dataSourceId:null===(e=n[0])||void 0===e?void 0:e.dataSourceId,siteIds:j});_(!1),r&&s({commerceChannelIds:v,siteIds:j})}},C&&o.default.createElement(d.default,{inline:!0}),Liferay.Language.get("assign")))}))};var _default=e=>{let{property:t}=e,a=_objectWithoutProperties(e,["property"]);return t?o.default.createElement(AssignModal,_extends({},a,{property:t})):null};t.default=_default}}));
//# sourceMappingURL=AssignModal.js.map