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