define(["require","exports","tslib","./esriDelegate!esri/portal/Portal","./ArcGisApiVersion","../../Errors"],function(n,r,u,i,a,c){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var e=(t.prototype.execute=function(i,s){return u.__awaiter(this,void 0,void 0,function(){var e,t,o,n;return u.__generator(this,function(r){switch(r.label){case 0:e={user:void 0,groups:[]},r.label=1;case 1:return r.trys.push([1,5,,6]),t=a.isArcGisApiVersion3x?this.getPortalUrl(s):void 0,[4,this.getPortalUser(t)];case 2:return(n=r.sent())?(e.user=n,!1===i.loadGroups?[3,4]:(o=e,[4,this.getPortalGroups(n)])):[3,4];case 3:o.groups=r.sent(),r.label=4;case 4:return[3,6];case 5:throw n=r.sent(),console.error(n),new c.GenericActivityError('Error running the "Get Portal User" activity. The requested resource failed to load.');case 6:return[2,e]}})})},t.prototype.getPortalUser=function(t){return u.__awaiter(this,void 0,void 0,function(){var o,e;return u.__generator(this,function(r){switch(r.label){case 0:return a.isArcGisApiVersion3x?(e=function(){return new Promise(function(e,t){n(["dojo/on"],function(r){r(o,"load",function(r){return r.signIn().then(e,t)})})})},t?(o=new i.Portal(t),[4,e()]):[3,2]):[3,3];case 1:return r.sent(),[2,o.getPortalUser()];case 2:return[2,void 0];case 3:return[4,(o=new i.Portal).load()];case 4:return r.sent(),[2,o.user]}})})},t.prototype.getPortalUrl=function(r){throw new c.ActivityNotImplementedError(t.action)},t.prototype.getPortalGroups=function(t){return u.__awaiter(this,void 0,void 0,function(){var e;return u.__generator(this,function(r){return e=a.isArcGisApiVersion3x?"getGroups":"fetchGroups",[2,t[e]()]})})},t.action="gcx:wf:arcgis::GetPortalUser",t.suite="gcx:wf:builtin",t);function t(){}r.GetPortalUser=e});