(function(){page.onInit=function(){page.campaignManagement={copy:t,copyActivityAndSubTree:e}};page.onFormCreate=function(e){var t=e.getComponent("$context");var a=page.url.get("defaultDate");if(a){t.set("date",a)}};function e(e){var t=e.page;var a=u8.Base.Widgets.Tools.closest(e,"Form").context,i=a.get("date")||new Date;u8.services.campaignManagement.copyActivityAndSubTree({templateUid:t.url.getUid(),newStart:i,campaignUid:t.url.getLinkUid()},function(e,a){if(u8.isValidRecordUid(a.uid)){t.proceed({newUid:a.uid})}})}function t(e){var t=e.page;var a=u8.Base.Widgets.Tools.closest(e,"Form").context,i=a.get("date")||new Date;e.setDisabled(true);u8.services.campaignManagement.copyFromTemplate({templateUid:t.url.getUid(),newStart:i,parentUid:t.url.getLinkUid()},function(a,i){if(u8.isValidRecordUid(i.uid)){t.proceed({newUid:i.uid});t.popup.close()}else{e.setDisabled(false)}})}})();