????

Your IP : 18.220.192.109


Current Path : C:/inetpub/vhost/binhdinhinvest.gdtvietnam.com/www/
Upload File :
Current File : C:/inetpub/vhost/binhdinhinvest.gdtvietnam.com/www/60.1135a7425e5ee21984ef.js

(function(){var e={"esri/identity/IdentityManager":"0g2X","esri/identity/OAuthCredential":"1nXt","esri/identity/IdentityModal":"5zKl","esri/identity/IdentityForm":"7/+m","esri/identity/OAuthInfo":"DEfM","esri/identity/IdentityManagerBase":"VS9W","esri/identity/ServerInfo":"jdHw","esri/core/cookie":"pUXy"},t=this||window,r=t.webpackJsonp=t.webpackJsonp||[];r.registerAbsMids?r.registerAbsMids(e):(r.absMidsWaiting=r.absMidsWaiting||[]).push(e)})(),(window.webpackJsonp=window.webpackJsonp||[]).push([[60],{"0g2X":function(e,t,r){var i,n;i=[r.dj.c(e.i),t,r("zOht"),r("urqW"),r("Vx27"),r("VS9W")],n=(function(e,t,r,i,n,o){var s=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.__extends(t,e),r.__decorate([n.subclass("esri.identity.IdentityManager")],t)}(o.IdentityManagerBase));return i.setId(s),s}).apply(null,i),void 0===n||(e.exports=n)},"1nXt":function(e,t,r){var i,n;i=[r.dj.c(e.i),t],void 0===(n=(function(e,t){var r=function(){function e(e,t){this.oAuthInfo=null,this.storage=null,this.appId=null,this.expires=null,this.ssl=null,this.token=null,this.userId=null,this.oAuthInfo=e,this.storage=t,this._init()}return e.prototype.isValid=function(){var e=!1;if(this.oAuthInfo&&this.token&&this.userId){var t=Date.now();this.expires>t&&(this.expires-t)/1e3>60*this.oAuthInfo.minTimeUntilExpiration&&(e=!0)}return e},e.prototype.save=function(){if(this.storage){var e=this._load(),t=this.oAuthInfo;if(t&&t.authNamespace&&t.portalUrl){var r=e[t.authNamespace];r||(r=e[t.authNamespace]={}),r[t.portalUrl]={appId:this.appId=t.appId,expires:this.expires,ssl:this.ssl,token:this.token,userId:this.userId};try{this.storage.setItem("esriJSAPIOAuth",JSON.stringify(e))}catch(e){console.log(e)}}}},e.prototype.destroy=function(){var e=this._load(),t=this.oAuthInfo;if(t&&t.appId&&t.portalUrl&&this.token&&this.expires>Date.now()){var r=t.portalUrl.replace(/^http:/i,"https:")+"/sharing/rest/oauth2/revokeToken",i=new FormData;if(i.append("f","json"),i.append("auth_token",this.token),i.append("client_id",t.appId),i.append("token_type_hint","access_token"),"function"==typeof navigator.sendBeacon)navigator.sendBeacon(r,i);else{var n=new XMLHttpRequest;n.open("POST",r),n.send(i)}}if(t&&t.authNamespace&&t.portalUrl&&this.storage){var o=e[t.authNamespace];if(o){delete o[t.portalUrl];try{this.storage.setItem("esriJSAPIOAuth",JSON.stringify(e))}catch(e){console.log(e)}}}t&&(t._oAuthCred=null,this.oAuthInfo=null)},e.prototype._init=function(){var e=this._load(),t=this.oAuthInfo;if(t&&t.authNamespace&&t.portalUrl){var r=e[t.authNamespace];r&&(r=r[t.portalUrl])&&(this.appId=r.appId,this.expires=r.expires,this.ssl=r.ssl,this.token=r.token,this.userId=r.userId)}},e.prototype._load=function(){var e={};if(this.storage){var t=this.storage.getItem("esriJSAPIOAuth");if(t)try{e=JSON.parse(t)}catch(e){console.log(e)}}return e},e}();return r.prototype.declaredClass="esri.identity.OAuthCredential",r}).apply(null,i))||(e.exports=n)},"5zKl":function(e,t,r){var i,n;i=[r.dj.c(e.i),t,r("zOht"),r("Vx27"),r("RHxK"),r("bC3G")],void 0===(n=(function(e,t,r,i,n,o){var s="esri-identity-modal__content";return function(e){function t(t,r){var i=e.call(this,t,r)||this;return i.container=document.createElement("div"),i.content=null,i.open=!1,document.body.appendChild(i.container),i}return r.__extends(t,e),t.prototype.render=function(){var e,t=this.id,r=this.title,i=this.messages,n=this.open&&!!this.content,s=((e={})["esri-identity-modal--open"]=n,e["esri-identity-modal--closed"]=!n,e),a=o.tsx("button",{class:"esri-identity-modal__close-button","aria-label":i.close,bind:this,onclick:this._close},o.tsx("span",{"aria-hidden":"true",class:"esri-icon-close"})),l=t+"_title",u=t+"_content",c=r?o.tsx("h1",{id:l,class:"esri-identity-modal__title"},r):null,p=n?o.tsx("div",{class:"esri-identity-modal__dialog",role:"dialog","aria-labelledby":l,"aria-describedby":u},a,c,this._renderContent(u)):null;return o.tsx("div",{tabIndex:-1,class:this.classes("esri-identity-modal",s)},p)},t.prototype._close=function(){this.open=!1},t.prototype._renderContent=function(e){var t=this.content;return"string"==typeof t?o.tsx("div",{class:s,id:e,innerHTML:t}):o.isWidget(t)?o.tsx("div",{class:s,id:e},t.render()):t instanceof HTMLElement?o.tsx("div",{class:s,id:e,bind:t,afterCreate:this._attachToNode}):null},t.prototype._attachToNode=function(e){e.appendChild(this)},r.__decorate([i.property({readOnly:!0})],t.prototype,"container",void 0),r.__decorate([i.property(),o.renderable()],t.prototype,"content",void 0),r.__decorate([i.property(),o.renderable()],t.prototype,"open",void 0),r.__decorate([i.property(),o.renderable(),o.messageBundle("esri/t9n/common")],t.prototype,"messages",void 0),r.__decorate([i.property({aliasOf:"messages.auth.signIn"}),o.renderable()],t.prototype,"title",void 0),r.__decorate([i.subclass("esri.identity.IdentityModal")],t)}(n)}).apply(null,i))||(e.exports=n)},"7/+m":function(e,t,r){var i,n;i=[r.dj.c(e.i),t,r("zOht"),r("Vx27"),r("xKeD"),r("RHxK"),r("bC3G")],void 0===(n=(function(e,t,r,i,n,o,s){var a="esri-identity-form__group",l="esri-identity-form__label",u="esri-input",c="esri-button";return function(e){function t(t,r){var i=e.call(this,t,r)||this;return i._usernameInputNode=null,i._passwordInputNode=null,i.messages=null,i.signingIn=!1,i.server=null,i.resource=null,i.error=null,i.oAuthPrompt=!1,i}return r.__extends(t,e),t.prototype.render=function(){var e=this,t=e.error,r=e.server,i=e.resource,o=e.signingIn,p=e.oAuthPrompt,d=e.messages,h=s.tsx("div",{class:a},n.substitute(p?d.oAuthInfo:d.info,{server:/\.arcgis\.com/i.test(r)?"ArcGIS Online":r,resource:"("+(i||d.lblItem)+")"})),f=p?null:s.tsx("div",{class:a},s.tsx("label",{class:l},d.lblUser,s.tsx("input",{value:"",required:!0,autofocus:!0,autocomplete:"off",spellcheck:!1,type:"text",bind:this,afterCreate:s.storeNode,"data-node-ref":"_usernameInputNode",class:u}))),_=p?null:s.tsx("div",{class:a},s.tsx("label",{class:l},d.lblPwd,s.tsx("input",{value:"",required:!0,type:"password",bind:this,afterCreate:s.storeNode,"data-node-ref":"_passwordInputNode",class:u}))),v=s.tsx("div",{class:this.classes(a,"esri-identity-form__footer")},s.tsx("input",{type:"submit",disabled:!!o,value:o?d.lblSigning:d.lblOk,class:c}),s.tsx("input",{type:"button",value:d.lblCancel,bind:this,onclick:this._cancel,class:this.classes(c,"esri-button--secondary")})),g=t?s.tsx("div",null,t.details&&t.details.httpStatus?d.invalidUser:d.noAuthService):null;return s.tsx("form",{class:"esri-identity-form",bind:this,onsubmit:this._submit},h,g,f,_,v)},t.prototype._cancel=function(){this._set("signingIn",!1),this._usernameInputNode&&(this._usernameInputNode.value=""),this._passwordInputNode&&(this._passwordInputNode.value=""),this.emit("cancel")},t.prototype._submit=function(e){e.preventDefault(),this._set("signingIn",!0),this.emit("submit",this.oAuthPrompt?{}:{username:this._usernameInputNode&&this._usernameInputNode.value,password:this._passwordInputNode&&this._passwordInputNode.value})},r.__decorate([i.property(),s.renderable(),s.messageBundle("esri/identity/t9n/identity")],t.prototype,"messages",void 0),r.__decorate([i.property(),s.renderable()],t.prototype,"signingIn",void 0),r.__decorate([i.property(),s.renderable()],t.prototype,"server",void 0),r.__decorate([i.property(),s.renderable()],t.prototype,"resource",void 0),r.__decorate([i.property(),s.renderable()],t.prototype,"error",void 0),r.__decorate([i.property(),s.renderable()],t.prototype,"oAuthPrompt",void 0),r.__decorate([i.subclass("esri.identity.IdentityForm")],t)}(o)}).apply(null,i))||(e.exports=n)},DEfM:function(e,t,r){var i,n;i=[r.dj.c(e.i),t,r("zOht"),r("ycL1"),r("Vx27")],void 0===(n=(function(e,t,r,i,n){return function(e){function t(t){var r=e.call(this,t)||this;return r._oAuthCred=null,r.appId=null,r.authNamespace="/",r.expiration=20160,r.forceLogin=!1,r.locale=null,r.minTimeUntilExpiration=30,r.popup=!1,r.popupCallbackUrl="oauth-callback.html",r.popupWindowFeatures="height=490,width=800,resizable,scrollbars,status",r.portalUrl="https://www.arcgis.com",r.preserveUrlHash=!1,r}var i;return r.__extends(t,e),i=t,t.prototype.clone=function(){return i.fromJSON(this.toJSON())},r.__decorate([n.property({json:{write:!0}})],t.prototype,"appId",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"authNamespace",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"expiration",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"forceLogin",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"locale",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"minTimeUntilExpiration",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"popup",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"popupCallbackUrl",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"popupWindowFeatures",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"portalUrl",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"preserveUrlHash",void 0),i=r.__decorate([n.subclass("esri.identity.OAuthInfo")],t)}(i.JSONSupport)}).apply(null,i))||(e.exports=n)},VS9W:function(e,t,r){var i,n;i=[r.dj.c(e.i),t,r("zOht"),r("0J3i"),r("urqW"),r("zp6E"),r("pUXy"),r("ma1f"),r("BcWh"),r("J3YA"),r("rg9i"),r("TTKK"),r("qMld"),r("nRUF"),r("jfWY"),r("jfWY"),r("Vx27"),r("7/+m"),r("5zKl"),r("1nXt"),r("DEfM"),r("jdHw")],void 0===(n=(function(e,t,r,i,n,o,s,a,l,u,c,p,d,h,f,_,v,g,m,y,w,I){Object.defineProperty(t,"__esModule",{value:!0});var S={},k=function(e){var t=new _.Url(e.owningSystemUrl).host,r=new _.Url(e.server).host,i=/.+\.arcgis\.com$/i;return i.test(t)&&i.test(r)},A=function(e,t){return!!(k(e)&&t&&t.some((function(t){return t.test(e.server)})))},x=function(e){function t(){var t=e.call(this)||this;return t._portalConfig=u.esriGeowConfig,t.serverInfos=[],t.oAuthInfos=[],t.credentials=[],t._soReqs=[],t._xoReqs=[],t._portals=[],t.defaultOAuthInfo=null,t.defaultTokenValidity=60,t.dialog=null,t.formConstructor=g,t.tokenValidity=null,t.signInPage=null,t.useSignInPage=!0,t.normalizeWebTierAuth=!1,t._busy=null,t._rejectOnPersistedPageShow=!1,t._oAuthHash=null,t._gwTokenUrl="/sharing/rest/generateToken",t._agsRest="/rest/services",t._agsPortal=/\/sharing(\/|$)/i,t._agsAdmin=/(https?:\/\/[^\/]+\/[^\/]+)\/admin\/?(\/.*)?$/i,t._adminSvcs=/\/rest\/admin\/services(\/|$)/i,t._gwDomains=[{regex:/^https?:\/\/www\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:dev|[a-z\d-]+\.mapsdev)\.arcgis\.com/i,customBaseUrl:"mapsdev.arcgis.com",tokenServiceUrl:"https://dev.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:devext|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i,customBaseUrl:"mapsdevext.arcgis.com",tokenServiceUrl:"https://devext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:qaext|[a-z\d-]+\.mapsqa)\.arcgis\.com/i,customBaseUrl:"mapsqa.arcgis.com",tokenServiceUrl:"https://qaext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/[a-z\d-]+\.maps\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"}],t._legacyFed=[],t._regexSDirUrl=/http.+\/rest\/services\/?/gi,t._regexServerType=/(\/(MapServer|GeocodeServer|GPServer|GeometryServer|ImageServer|NAServer|FeatureServer|GeoDataServer|GlobeServer|MobileServer|GeoenrichmentServer|VectorTileServer|SceneServer)).*/gi,t._gwUser=/http.+\/users\/([^\/]+)\/?.*/i,t._gwItem=/http.+\/items\/([^\/]+)\/?.*/i,t._gwGroup=/http.+\/groups\/([^\/]+)\/?.*/i,t._rePortalTokenSvc=/\/sharing(\/rest)?\/generatetoken/i,t._createDefaultOAuthInfo=!0,t._hasTestedIfAppIsOnPortal=!1,t._getOAuthHash(),window.addEventListener("pageshow",(function(e){t._pageShowHandler(e)})),t}return r.__extends(t,e),t.prototype.registerServers=function(e){var t=this,r=this.serverInfos;r?(e=e.filter((function(e){return!t.findServerInfo(e.server)})),this.serverInfos=r.concat(e)):this.serverInfos=e,e.forEach((function(e){e.owningSystemUrl&&t._portals.push(e.owningSystemUrl),e.hasPortal&&t._portals.push(e.server)}))},t.prototype.registerOAuthInfos=function(e){var t=this,r=this.oAuthInfos;r?(e=e.filter((function(e){return!t.findOAuthInfo(e.portalUrl)})),this.oAuthInfos=r.concat(e)):this.oAuthInfos=e},t.prototype.registerToken=function(e){e=r.__assign({},e);var t,i=this._sanitizeUrl(e.server),n=this._isServerRsrc(i),o=this.findServerInfo(i),s=!0;o||((o=new I).server=this._getServerInstanceRoot(i),n?o.hasServer=!0:(o.tokenServiceUrl=this._getTokenSvcUrl(i),o.hasPortal=!0),this.registerServers([o])),(t=this._findCredential(i))?(delete e.server,c.mixin(t,e),s=!1):((t=new U({userId:e.userId,server:o.server,token:e.token,expires:e.expires,ssl:e.ssl,scope:n?"server":"portal"})).resources=[i],this.credentials.push(t)),t.emitTokenChange(!1),s||t.refreshServerTokens()},t.prototype.toJSON=function(){return c.fixJson({serverInfos:this.serverInfos.map((function(e){return e.toJSON()})),oAuthInfos:this.oAuthInfos.map((function(e){return e.toJSON()})),credentials:this.credentials.map((function(e){return e.toJSON()}))})},t.prototype.initialize=function(e){var t=this;if(e){"string"==typeof e&&(e=JSON.parse(e));var r=e.serverInfos,i=e.oAuthInfos,n=e.credentials;if(r){var o=[];r.forEach((function(e){e.server&&e.tokenServiceUrl&&o.push(e.declaredClass?e:new I(e))})),o.length&&this.registerServers(o)}if(i){var s=[];i.forEach((function(e){e.appId&&s.push(e.declaredClass?e:new w(e))})),s.length&&this.registerOAuthInfos(s)}n&&n.forEach((function(e){e.server&&e.token&&e.expires&&e.expires>Date.now()&&((e=e.declaredClass?e:new U(e)).emitTokenChange(),t.credentials.push(e))}))}},t.prototype.findServerInfo=function(e){var t;e=this._sanitizeUrl(e);for(var r=0,i=this.serverInfos;r<i.length;r++){var n=i[r];if(this._hasSameServerInstance(n.server,e)){t=n;break}}return t},t.prototype.findOAuthInfo=function(e){var t;e=this._sanitizeUrl(e);for(var r=0,i=this.oAuthInfos;r<i.length;r++){var n=i[r];if(this._hasSameServerInstance(n.portalUrl,e)){t=n;break}}return t},t.prototype.findCredential=function(e,t){var r,i;if(e=this._sanitizeUrl(e),i=this._isServerRsrc(e)?"server":"portal",t)for(var n=0,o=this.credentials;n<o.length;n++){var s=o[n];if(this._hasSameServerInstance(s.server,e)&&t===s.userId&&s.scope===i){r=s;break}}else for(var a=0,l=this.credentials;a<l.length;a++)if(this._hasSameServerInstance((s=l[a]).server,e)&&-1!==this._getIdenticalSvcIdx(e,s)&&s.scope===i){r=s;break}return r},t.prototype.getCredential=function(e,t){var i,n,o=!0;t&&(i=!!t.token,n=t.error,o=!1!==t.prompt),t=r.__assign({},t),e=this._sanitizeUrl(e);var l=d.createAbortController(),u=d.createResolver();if(t.signal&&d.onAbort(t.signal,(function(){l.abort()})),d.onAbort(l,(function(){u.reject(new a("identity-manager:user-aborted","ABORTED"))})),d.isAborted(l))return u.promise;t.signal=l.signal;var c,p=this._isAdminResource(e),f=i&&this._doPortalSignIn(e)?this._getEsriAuthCookie():null,_=i?this.findCredential(e):null;if(_&&n&&n.details&&498===n.details.httpStatus)_.destroy(),f&&f.token===t.token&&(s.writeCookie("esri_auth",null,{expires:-1,path:"/",domain:document.domain}),h.endsWith(window.location.hostname,".arcgis.com")&&s.writeCookie("esri_auth",null,{expires:-1,path:"/",domain:"arcgis.com"}));else if(f||_)return c=new a("identity-manager:not-authorized","You are currently signed in as: '"+(f&&f.email||_&&_.userId)+"'. You do not have access to this resource: "+e,{error:n}),u.reject(c),u.promise;var v=this._findCredential(e,t);if(v)return u.resolve(v),u.promise;var g=this.findServerInfo(e);if(g)!g.hasServer&&this._isServerRsrc(e)&&(g._restInfoPms=this._getTokenSvcUrl(e),g.hasServer=!0);else{var m=this._getTokenSvcUrl(e);if(!m)return c=new a("identity-manager:unknown-resource","Unknown resource - could not find token service endpoint."),u.reject(c),u.promise;(g=new I).server=this._getServerInstanceRoot(e),"string"==typeof m?(g.tokenServiceUrl=m,g.hasPortal=!0):(g._restInfoPms=m,g.hasServer=!0),this.registerServers([g])}return o&&g.hasPortal&&void 0===g._selfReq&&!this._findOAuthInfo(e)&&(g._selfReq={owningTenant:t&&t.owningTenant,selfDfd:this._getPortalSelf(g.tokenServiceUrl.replace(this._rePortalTokenSvc,"/sharing/rest/portals/self"),e)}),this._enqueue(e,g,t,u,p)},t.prototype.getResourceName=function(e){return this._isRESTService(e)?e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"")||"":this._gwUser.test(e)&&e.replace(this._gwUser,"$1")||this._gwItem.test(e)&&e.replace(this._gwItem,"$1")||this._gwGroup.test(e)&&e.replace(this._gwGroup,"$1")||""},t.prototype.generateToken=function(e,t,r){var i,n,s,l,u,p,d,h,v,g,m=this._rePortalTokenSvc.test(e.tokenServiceUrl),y=new _.Url(window.location.href.toLowerCase()),w=this._getEsriAuthCookie(),I=e.shortLivedTokenValidity;return t&&(g=this.tokenValidity||I||this.defaultTokenValidity)>I&&I>0&&(g=I),r&&(n=r.isAdmin,s=r.serverUrl,l=r.token,d=r.signal,h=r.ssl,e.customParameters=r.customParameters),n?u=e.adminTokenServiceUrl:(p=new _.Url((u=e.tokenServiceUrl).toLowerCase()),w&&(i=(i=w.auth_tier)&&i.toLowerCase()),("web"===i||e.webTierAuth)&&r&&r.serverUrl&&!h&&"http"===y.scheme&&(f.hasSameOrigin(y.uri,u,!0)||"https"===p.scheme&&y.host===p.host&&"7080"===y.port&&"7443"===p.port)&&(u=u.replace(/^https:/i,"http:").replace(/:7443/i,":7080"))),v=c.mixin({query:c.mixin({request:"getToken",username:t&&t.username,password:t&&t.password,serverUrl:s,token:l,expiration:g,referer:n||m?window.location.host:null,client:n?"referer":null,f:"json"},e.customParameters),method:"post",authMode:"anonymous",useProxy:this._useProxy(e,r),signal:d},r&&r.ioArgs),m||(v.withCredentials=!1),o(u,v).then((function(r){var i=r.data;if(!i||!i.token)return new a("identity-manager:authentication-failed","Unable to generate token");var n=e.server;return S[n]||(S[n]={}),t&&(S[n][t.username]=t.password),i.validity=g,i}))},t.prototype.isBusy=function(){return!!this._busy},t.prototype.checkSignInStatus=function(e){return this.checkAppAccess(e,"").then((function(e){return e.credential}))},t.prototype.checkAppAccess=function(e,t,r){var i=this,n=!1;return this.getCredential(e,{prompt:!1}).then((function(s){var l,u={f:"json"};if("portal"===s.scope)if(t&&(i._doPortalSignIn(e,!0)||r&&r.force))l=s.server+"/sharing/rest/oauth2/validateAppAccess",u.client_id=t;else{if(!s.token)return{credential:s};l=s.server+"/sharing/rest"}else{if(!s.token)return{credential:s};l=s.server+"/rest/services"}return s.token&&(u.token=s.token),o(l,{query:u,authMode:"anonymous"}).then((function(e){if(!1===e.data.valid)throw new a("identity-manager:not-authorized","You are currently signed in as: '"+s.userId+"'.");return n=!!e.data.viewOnlyUserTypeApp,{credential:s}})).catch((function(e){if("identity-manager:not-authorized"===e.name)throw e;var t=e.details&&e.details.httpStatus;if(498===t)throw s.destroy(),new a("identity-manager:not-authenticated","User is not signed in.");if(400===t)throw new a("identity-manager:invalid-request");return{credential:s}}))})).then((function(e){return{credential:e.credential,viewOnly:n}}))},t.prototype.setOAuthResponseHash=function(e){var t=this._oAuthDfd;if(this._oAuthDfd=null,t&&e){clearInterval(this._oAuthIntervalId),"#"===e.charAt(0)&&(e=e.substring(1));var r=f.queryToObject(e);if(r.error){var i="access_denied"===r.error,n=new a(i?"identity-manager:user-aborted":"identity-manager:authentication-failed",i?"ABORTED":"OAuth: "+r.error+" - "+r.error_description);t.reject(n)}else{var o=t.oinfo_._oAuthCred,s=new U({userId:r.username,server:t.sinfo_.server,token:r.access_token,expires:Date.now()+1e3*Number(r.expires_in),ssl:"true"===r.ssl,_oAuthCred:o});o.storage=r.persist?window.localStorage:window.sessionStorage,o.token=s.token,o.expires=s.expires,o.userId=s.userId,o.ssl=s.ssl,o.save(),t.resolve(s)}}},t.prototype.setRedirectionHandler=function(e){this._redirectFunc=e},t.prototype.setOAuthRedirectionHandler=function(e){this._oAuthRedirectFunc=e},t.prototype.setProtocolErrorHandler=function(e){this._protocolFunc=e},t.prototype.signIn=function(e,t,r){var i=this;void 0===r&&(r={});var n=d.createResolver(),o=function(){u&&u.remove(),c&&c.remove(),p&&p.remove(),l&&l.destroy(),i.dialog&&i.dialog.destroy(),i.dialog=null},s=function(){o(),i._oAuthDfd=null,n.reject(new a("identity-manager:user-aborted","ABORTED"))};r.signal&&d.onAbort(r.signal,(function(){s()}));var l=new this.formConstructor;l.resource=this.getResourceName(e),l.server=t.server,this.dialog=new m,this.dialog.content=l,this.dialog.open=!0,this.emit("dialog-create");var u=l.on("cancel",s),c=this.dialog.watch("open",s),p=l.on("submit",(function(e){i.generateToken(t,e,{isAdmin:r.isAdmin,signal:r.signal}).then((function(i){o();var s=new U({userId:e.username,server:t.server,token:i.token,expires:null!=i.expires?Number(i.expires):null,ssl:!!i.ssl,isAdmin:r.isAdmin,validity:i.validity});n.resolve(s)})).catch((function(e){l.error=e,l.signingIn=!1}))}));return n.promise},t.prototype.oAuthSignIn=function(e,t,r,i){var n=this;this._oAuthDfd=d.createResolver();var o=this._oAuthDfd;if(i&&i.signal&&d.onAbort(i.signal,(function(){var e=n._oAuthDfd&&n._oAuthDfd.oAuthWin_;e&&!e.closed?e.close():n.dialog&&l()})),o.resUrl_=e,o.sinfo_=t,o.oinfo_=r,!r.popup||i&&!1===i.oAuthPopupConfirmation)return this._doOAuthSignIn(e,t,r),o.promise;var s=new this.formConstructor;s.oAuthPrompt=!0,s.server=t.server,this.dialog=new m,this.dialog.content=s,this.dialog.open=!0,this.emit("dialog-create");var l=function(){h(),n._oAuthDfd=null,o.reject(new a("identity-manager:user-aborted","ABORTED"))},u=s.on("cancel",l),c=this.dialog.watch("open",l),p=s.on("submit",(function(){h(),n._doOAuthSignIn(e,t,r)})),h=function(){u.remove(),c.remove(),p.remove(),s.destroy(),n.dialog.destroy(),n.dialog=null};return o.promise},t.prototype.destroyCredentials=function(){this.credentials&&this.credentials.slice().forEach((function(e){e.destroy()})),this.emit("credentials-destroy")},t.prototype._getOAuthHash=function(){var e=window.location.hash;if(e){"#"===e.charAt(0)&&(e=e.substring(1));var t=f.queryToObject(e),r=!1;t.access_token&&t.expires_in&&t.state&&t.hasOwnProperty("username")?(t.state=JSON.parse(t.state),this._oAuthHash=t,r=!0):t.error&&t.error_description&&(console.log("IdentityManager OAuth Error: ",t.error," - ",t.error_description),"access_denied"===t.error&&(r=!0)),r&&(window.location.hash="object"==typeof t.state&&t.state.hash||"")}},t.prototype._pageShowHandler=function(e){if(e.persisted&&this.isBusy()&&this._rejectOnPersistedPageShow){var t=new a("identity-manager:user-aborted","ABORTED");this._errbackFunc(t)}},t.prototype._findCredential=function(e,t){var r,i,n,o,s=this,a=-1,l=t&&t.token,u=t&&t.resource,c=this._isServerRsrc(e)?"server":"portal",p=this.credentials.filter((function(t){return s._hasSameServerInstance(t.server,e)&&t.scope===c}));if(e=u||e,p.length)if(1===p.length){if(o=this.findServerInfo((r=p[0]).server),n=(i=o&&o.owningSystemUrl)&&this.findCredential(i,r.userId),a=this._getIdenticalSvcIdx(e,r),!l)return-1===a&&r.resources.push(e),this._addResource(e,n),r;-1!==a&&(r.resources.splice(a,1),this._removeResource(e,n))}else{var d,h;if(p.some((function(t){return-1!==(h=s._getIdenticalSvcIdx(e,t))&&(o=s.findServerInfo((d=t).server),n=(i=o&&o.owningSystemUrl)&&s.findCredential(i,d.userId),a=h,!0)})),l)d&&(d.resources.splice(a,1),this._removeResource(e,n));else if(d)return this._addResource(e,n),d}},t.prototype._findOAuthInfo=function(e){var t=this.findOAuthInfo(e);if(!t)for(var r=0,i=this.oAuthInfos;r<i.length;r++){var n=i[r];if(this._isIdProvider(n.portalUrl,e)){t=n;break}}return t},t.prototype._addResource=function(e,t){t&&-1===this._getIdenticalSvcIdx(e,t)&&t.resources.push(e)},t.prototype._removeResource=function(e,t){var r=-1;t&&(r=this._getIdenticalSvcIdx(e,t))>-1&&t.resources.splice(r,1)},t.prototype._useProxy=function(e,t){return t&&t.isAdmin&&!f.hasSameOrigin(e.adminTokenServiceUrl,window.location.href)||!this._isPortalDomain(e.tokenServiceUrl)&&"10.1"===String(e.currentVersion)&&!f.hasSameOrigin(e.tokenServiceUrl,window.location.href)},t.prototype._getOrigin=function(e){var t=new _.Url(e);return t.scheme+"://"+t.host+(null!=t.port?":"+t.port:"")},t.prototype._getServerInstanceRoot=function(e){var t=e.toLowerCase(),r=t.indexOf(this._agsRest);return-1===r&&this._isAdminResource(e)&&(r=this._agsAdmin.test(e)?e.replace(this._agsAdmin,"$1").length:e.search(this._adminSvcs)),-1===r&&(r=t.indexOf("/sharing")),-1===r&&"/"===t.substr(-1)&&(r=t.length-1),r>-1?e.substring(0,r):e},t.prototype._hasSameServerInstance=function(e,t){return"/"===e.substr(-1)&&(e=e.slice(0,-1)),e=e.toLowerCase(),t=this._getServerInstanceRoot(t).toLowerCase(),e=this._normalizeAGOLorgDomain(e),t=this._normalizeAGOLorgDomain(t),(e=e.substr(e.indexOf(":")))===t.substr(t.indexOf(":"))},t.prototype._normalizeAGOLorgDomain=function(e){var t=/^https?:\/\/(?:cdn|[a-z\d-]+\.maps)\.arcgis\.com/i,r=/^https?:\/\/(?:cdndev|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i,i=/^https?:\/\/(?:cdnqa|[a-z\d-]+\.mapsqa)\.arcgis\.com/i;return t.test(e)?e=e.replace(t,"https://www.arcgis.com"):r.test(e)?e=e.replace(r,"https://devext.arcgis.com"):i.test(e)&&(e=e.replace(i,"https://qaext.arcgis.com")),e},t.prototype._sanitizeUrl=function(e){var t=(i.request.proxyUrl||"").toLowerCase(),r=t?e.toLowerCase().indexOf(t+"?"):-1;return-1!==r&&(e=e.substring(r+t.length+1)),e=f.normalize(e),f.urlToObject(e).path},t.prototype._isRESTService=function(e){return e.indexOf(this._agsRest)>-1},t.prototype._isAdminResource=function(e){return this._agsAdmin.test(e)||this._adminSvcs.test(e)},t.prototype._isServerRsrc=function(e){return this._isRESTService(e)||this._isAdminResource(e)},t.prototype._isIdenticalService=function(e,t){var r;if(this._isRESTService(e)&&this._isRESTService(t)){var i=this._getSuffix(e).toLowerCase(),n=this._getSuffix(t).toLowerCase();if(!(r=i===n)){var o=/(.*)\/(MapServer|FeatureServer).*/gi;r=i.replace(o,"$1")===n.replace(o,"$1")}}else this._isAdminResource(e)&&this._isAdminResource(t)?r=!0:this._isServerRsrc(e)||this._isServerRsrc(t)||!this._isPortalDomain(e)||(r=!0);return r},t.prototype._isPortalDomain=function(e){var t=this,r=new _.Url(e.toLowerCase()),n=this._portalConfig,o=this._gwDomains.some((function(e){return e.regex.test(r.uri)}));return!o&&n&&(o=this._hasSameServerInstance(this._getServerInstanceRoot(n.restBaseUrl),r.uri)),o||i.portalUrl&&(o=f.hasSameOrigin(r,i.portalUrl,!0)),o||(o=this._portals.some((function(e){return t._hasSameServerInstance(e,r.uri)}))),o||this._agsPortal.test(r.path)},t.prototype._isIdProvider=function(e,t){var r=-1,i=-1;this._gwDomains.forEach((function(n,o){-1===r&&n.regex.test(e)&&(r=o),-1===i&&n.regex.test(t)&&(i=o)}));var n=!1;if(r>-1&&i>-1&&(0===r||4===r?0!==i&&4!==i||(n=!0):1===r?1!==i&&2!==i||(n=!0):2===r?2===i&&(n=!0):3===r&&3===i&&(n=!0)),!n){var o=this.findServerInfo(t),s=o&&o.owningSystemUrl;s&&k(o)&&this._isPortalDomain(s)&&this._isIdProvider(e,s)&&(n=!0)}return n},t.prototype._getIdenticalSvcIdx=function(e,t){for(var r=-1,i=0;i<t.resources.length;i++)if(this._isIdenticalService(e,t.resources[i])){r=i;break}return r},t.prototype._getSuffix=function(e){return e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"$1")},t.prototype._getTokenSvcUrl=function(e){var t,r=this;if(this._isRESTService(e)||this._isAdminResource(e)){var i=this._getServerInstanceRoot(e);return{adminUrl:i+"/admin/generateToken",promise:o(e=i+"/rest/info",{query:{f:"json"}}).then((function(e){return e.data}))}}if(this._isPortalDomain(e)){var n="";if(this._gwDomains.some((function(t){return t.regex.test(e)&&(n=t.tokenServiceUrl),!!n})),n||this._portals.some((function(t){return r._hasSameServerInstance(t,e)&&(n=t+r._gwTokenUrl),!!n})),n||-1!==(t=e.toLowerCase().indexOf("/sharing"))&&(n=e.substring(0,t)+this._gwTokenUrl),n||(n=this._getOrigin(e)+this._gwTokenUrl),n){var s=new _.Url(e).port;/^http:\/\//i.test(e)&&"7080"===s&&(n=n.replace(/:7080/i,":7443")),n=n.replace(/http:/i,"https:")}return n}if(-1!==e.toLowerCase().indexOf("premium.arcgisonline.com"))return"https://premium.arcgisonline.com/server/tokens"},t.prototype._exchangeToken=function(e,t,r){return o(e+"/sharing/rest/oauth2/exchangeToken",{authMode:"anonymous",method:"post",query:{f:"json",client_id:t,token:r}}).then((function(e){return e.data.token}))},t.prototype._getPortalSelf=function(e,t){var r;return this._gwDomains.some((function(t){return t.regex.test(e)&&(r=t.customBaseUrl),!!r})),r?d.resolve({allSSL:!0,currentVersion:"4.4",customBaseUrl:r,portalMode:"multitenant",supportsOAuth:!0}):("https:"===window.location.protocol?e=e.replace(/^http:/i,"https:").replace(/:7080/i,":7443"):/^http:/i.test(t)&&(e=e.replace(/^https:/i,"http:").replace(/:7443/i,":7080")),o(e,{query:{f:"json"},authMode:"anonymous",withCredentials:!0}).then((function(e){return e.data})))},t.prototype._hasPortalSession=function(){return!!this._getEsriAuthCookie()},t.prototype._getEsriAuthCookie=function(){var e=null;if(navigator.cookieEnabled){for(var t=this._getAllCookies("esri_auth"),r=void 0,i=0;i<t.length;i++){if((s=JSON.parse(t[i])).portalApp){e=s;break}r?r.push(s):r=[s]}if(!e&&r)for(var n=0,o=r;n<o.length;n++){var s;if((s=o[n]).urlKey&&window.location.hostname===s.urlKey.toLowerCase()+"."+s.customBaseUrl){e=s;break}}}if(e){var a=null;e.expires&&("number"==typeof e.expires?a=e.expires:"string"==typeof e.expires&&(a=Date.parse(e.expires)),isNaN(a)&&(a=null),e.expires=a),a&&a<Date.now()&&(e=null)}return e},t.prototype._getAllCookies=function(e){var t=[],r=document.cookie.match(new RegExp("(?:^|; )"+h.escapeRegExpString(e)+"=([^;]*)","g"));if(r)for(var i=0;i<r.length;i++){var n=r[i],o=n.indexOf("=");o>-1&&(n=n.substring(o+1),t.push(decodeURIComponent(n)))}return t},t.prototype._doPortalSignIn=function(e,t){if(navigator.cookieEnabled){var r=this._getEsriAuthCookie(),i=this._portalConfig,n=window.location.href,o=this.findServerInfo(e);if((t||this.useSignInPage)&&(i||this._isPortalDomain(n)||r)&&(o?o.hasPortal||o.owningSystemUrl&&this._isPortalDomain(o.owningSystemUrl):this._isPortalDomain(e))&&(this._isIdProvider(n,e)||i&&(this._hasSameServerInstance(this._getServerInstanceRoot(i.restBaseUrl),e)||this._isIdProvider(i.restBaseUrl,e))||f.hasSameOrigin(n,e,!0)))return!0}return!1},t.prototype._canUsePortalSignInWorkflow=function(e){return this._doPortalSignIn(e)&&(window===window.top||this._hasPortalSession())},t.prototype._checkProtocol=function(e,t,r,i){var n=!0,o=i?t.adminTokenServiceUrl:t.tokenServiceUrl;return 0===o.trim().toLowerCase().indexOf("https:")&&0!==window.location.href.toLowerCase().indexOf("https:")&&f.getProxyRule(o)&&((n=!!this._protocolFunc&&!!this._protocolFunc({resourceUrl:e,serverInfo:t}))||r(new a("identity-manager:aborted","Aborted the Sign-In process to avoid sending password over insecure connection."))),n},t.prototype._enqueue=function(e,t,r,i,n,o){return i||(i=d.createResolver()),i.resUrl_=e,i.sinfo_=t,i.options_=r,i.admin_=n,i.refresh_=o,this._busy?this._hasSameServerInstance(this._getServerInstanceRoot(e),this._busy.resUrl_)?(this._oAuthDfd&&this._oAuthDfd.oAuthWin_&&this._oAuthDfd.oAuthWin_.focus(),this._soReqs.push(i)):this._xoReqs.push(i):this._doSignIn(i),i.promise},t.prototype._doSignIn=function(e){var t=this;this._busy=e,this._rejectOnPersistedPageShow=!1;var r=function(r){var i=e.options_&&e.options_.resource,n=e.resUrl_,o=e.refresh_,s=!1;-1===t.credentials.indexOf(r)&&(o&&-1!==t.credentials.indexOf(o)?(o.userId=r.userId,o.token=r.token,o.expires=r.expires,o.validity=r.validity,o.ssl=r.ssl,o.creationTime=r.creationTime,s=!0,r=o):t.credentials.push(r)),r.resources||(r.resources=[]),r.resources.push(i||n),r.scope=t._isServerRsrc(n)?"server":"portal",r.emitTokenChange();var a=t._soReqs,l={};t._soReqs=[],a.forEach((function(e){if(!t._isIdenticalService(n,e.resUrl_)){var i=t._getSuffix(e.resUrl_);l[i]||(l[i]=!0,r.resources.push(e.resUrl_))}})),e.resolve(r),a.forEach((function(e){t._hasSameServerInstance(t._getServerInstanceRoot(n),e.resUrl_)?e.resolve(r):t._soReqs.push(e)})),t._busy=e.resUrl_=e.sinfo_=e.refresh_=null,s||t.emit("credential-create",{credential:r}),t._soReqs.length?t._doSignIn(t._soReqs.shift()):t._xoReqs.length&&t._doSignIn(t._xoReqs.shift())},i=function(r){e.reject(r),t._busy=e.resUrl_=e.sinfo_=e.refresh_=null,t._soReqs.length?t._doSignIn(t._soReqs.shift()):t._xoReqs.length&&t._doSignIn(t._xoReqs.shift())},n=function(n,o,s,l){var u,c,p=e.sinfo_,d=!e.options_||!1!==e.options_.prompt,h=p.hasPortal&&t._findOAuthInfo(e.resUrl_);if(t._canUsePortalSignInWorkflow(e.resUrl_)){var f=t._getEsriAuthCookie(),_=t._portalConfig;if(f)return p.webTierAuth||"web"===(f.auth_tier&&f.auth_tier.toLowerCase())&&(p.webTierAuth=!0),void((u=new U({userId:f.email,server:p.server,token:p.webTierAuth?null:f.token,expires:f.expires})).token?e._pendingDfd=t._exchangeToken(u.server,h?h.appId:"arcgisonline",u.token).then((function(e){u.token=e,r(u)})).catch((function(){r(u)})):r(u));if(d){var v="",g=window.location.href;return v=(v=t.signInPage?t.signInPage:_?_.baseUrl+_.signin:t._isIdProvider(g,e.resUrl_)?t._getOrigin(g)+"/home/signin.html":p.tokenServiceUrl.replace(t._rePortalTokenSvc,"")+"/home/signin.html").replace(/http:/i,"https:"),_&&!1===_.useSSL&&(v=v.replace(/https:/i,"http:")),void(0===g.toLowerCase().replace("https","http").indexOf(v.toLowerCase().replace("https","http"))?(c=new a("identity-manager:unexpected-error","Cannot redirect to Sign-In page from within Sign-In page. URL of the resource that triggered this workflow: "+e.resUrl_),i(c)):(t._rejectOnPersistedPageShow=!0,t._redirectFunc?t._redirectFunc({signInPage:v,returnUrlParamName:"returnUrl",returnUrl:g,resourceUrl:e.resUrl_,serverInfo:p}):window.location.href=v+"?returnUrl="+encodeURIComponent(g)))}c=new a("identity-manager:not-authenticated","User is not signed in."),i(c)}else if(n)r(new U({userId:n,server:p.server,token:s,expires:null!=l?Number(l):null,ssl:!!o}));else if(h){var m=h._oAuthCred;if(!m){var w=new y(h,window.localStorage),I=new y(h,window.sessionStorage);w.isValid()&&I.isValid()?w.expires>I.expires?(m=w,I.destroy()):(m=I,w.destroy()):m=w.isValid()?w:I,h._oAuthCred=m}if(m.isValid())u=new U({userId:m.userId,server:p.server,token:m.token,expires:m.expires,ssl:m.ssl,_oAuthCred:m}),h.appId!==m.appId&&t._doPortalSignIn(e.resUrl_,!0)?e._pendingDfd=t._exchangeToken(u.server,h.appId,u.token).then((function(e){u.token=e,m.token=e,m.save(),r(u)})).catch((function(){r(u)})):r(u);else if(t._oAuthHash&&t._oAuthHash.state.portalUrl===h.portalUrl){var S=t._oAuthHash;u=new U({userId:S.username,server:p.server,token:S.access_token,expires:Date.now()+1e3*Number(S.expires_in),ssl:"true"===S.ssl,oAuthState:S.state,_oAuthCred:m}),m.storage=S.persist?window.localStorage:window.sessionStorage,m.token=u.token,m.expires=u.expires,m.userId=u.userId,m.ssl=u.ssl,m.save(),t._oAuthHash=null,r(u)}else d?e._pendingDfd=t.oAuthSignIn(e.resUrl_,p,h,e.options_).then(r,i):(c=new a("identity-manager:not-authenticated","User is not signed in."),i(c))}else if(d){if(t._checkProtocol(e.resUrl_,p,i,e.admin_)){var k=e.options_;e.admin_&&((k=k||{}).isAdmin=!0),e._pendingDfd=t.signIn(e.resUrl_,p,k).then(r,i)}}else c=new a("identity-manager:not-authenticated","User is not signed in."),i(c)},o=function(){var n,o,s,a,l=e.sinfo_,u=l.owningSystemUrl,c=e.options_;if(c&&(n=c.token,o=c.error,s=c.prompt),!(a=t._findCredential(u,{token:n,resource:e.resUrl_})))for(var p=0,d=t.credentials;p<d.length;p++){var h=d[p];if(t._isIdProvider(u,h.server)){a=h;break}}if(a){var f=t.findCredential(e.resUrl_,a.userId);f?r(f):A(l,t._legacyFed)?((h=a.toJSON()).server=l.server,h.resources=null,r(new U(h))):(e._pendingDfd=t.generateToken(t.findServerInfo(a.server),null,{serverUrl:e.resUrl_,token:a.token,signal:e.options_.signal,ssl:a.ssl})).then((function(t){r(new U({userId:a.userId,server:l.server,token:t.token,expires:null!=t.expires?Number(t.expires):null,ssl:!!t.ssl,isAdmin:e.admin_,validity:t.validity}))}),i)}else t._busy=null,n&&(e.options_.token=null),(e._pendingDfd=t.getCredential(u.replace(/\/?$/,"/sharing"),{resource:e.resUrl_,owningTenant:l.owningTenant,signal:e.options_.signal,token:n,error:o,prompt:s})).then((function(){t._enqueue(e.resUrl_,e.sinfo_,e.options_,e,e.admin_)}),(function(e){i(e)}))};this._errbackFunc=i;var s=e.sinfo_.owningSystemUrl,l=this._isServerRsrc(e.resUrl_),u=e.sinfo_._restInfoPms;u?u.promise.then((function(r){var i=e.sinfo_;if(i._restInfoPms){i.adminTokenServiceUrl=i._restInfoPms.adminUrl,i._restInfoPms=null,i.tokenServiceUrl=p.getDeepValue("authInfo.tokenServicesUrl",r)||p.getDeepValue("authInfo.tokenServiceUrl",r)||p.getDeepValue("tokenServiceUrl",r),i.shortLivedTokenValidity=p.getDeepValue("authInfo.shortLivedTokenValidity",r),i.currentVersion=r.currentVersion,i.owningTenant=r.owningTenant;var s=i.owningSystemUrl=r.owningSystemUrl;s&&t._portals.push(s)}l&&i.owningSystemUrl?o():n()}),(function(){e.sinfo_._restInfoPms=null;var t=new a("identity-manager:server-identification-failed","Unknown resource - could not find token service endpoint.");i(t)})):l&&s?o():e.sinfo_._selfReq?e.sinfo_._selfReq.selfDfd.then((function(r){var i,n,o,s,a={};return r&&(a.username=i=r.user&&r.user.username,a.allSSL=r.allSSL,n=r.supportsOAuth,o=r.currentVersion,"multitenant"===r.portalMode&&(s=r.customBaseUrl)),e.sinfo_.webTierAuth=!!i,i&&t.normalizeWebTierAuth?t.generateToken(e.sinfo_,null,{ssl:a.allSSL}).catch((function(){return null})).then((function(e){return a.portalToken=e&&e.token,a.tokenExpiration=e&&e.expires,a})):!i&&n&&parseFloat(o)>=4.4&&!t._canUsePortalSignInWorkflow(e.resUrl_)?t._generateOAuthInfo({portalUrl:e.sinfo_.server,customBaseUrl:s,owningTenant:e.sinfo_._selfReq.owningTenant}).catch((function(){return null})).then((function(){return a})):a})).catch((function(){return null})).then((function(t){e.sinfo_._selfReq=null,t?n(t.username,t.allSSL,t.portalToken,t.tokenExpiration):n()})):n()},t.prototype._generateOAuthInfo=function(e){var t,r,i=this,n=e.portalUrl,s=e.customBaseUrl,a=e.owningTenant,l=!this.defaultOAuthInfo&&this._createDefaultOAuthInfo&&!this._hasTestedIfAppIsOnPortal;if(l){var u=(r=window.location.href).indexOf("?");u>-1&&(r=r.slice(0,u)),u=r.search(/\/(apps|home)\//),r=u>-1?r.slice(0,u):null}return l&&r?(this._hasTestedIfAppIsOnPortal=!0,t=o(r+"/sharing/rest",{query:{f:"json"}}).then((function(){i.defaultOAuthInfo=new w({appId:"arcgisonline",popup:!0,popupCallbackUrl:r+"/home/oauth-callback.html"})}))):t=d.resolve(),t.then((function(){if(i.defaultOAuthInfo)return n=n.replace(/^http:/i,"https:"),o(n+"/sharing/rest/oauth2/validateRedirectUri",{query:{accountId:a,client_id:i.defaultOAuthInfo.appId,redirect_uri:f.makeAbsolute(i.defaultOAuthInfo.popupCallbackUrl),f:"json"}}).then((function(e){if(e.data.valid){var t=i.defaultOAuthInfo.clone();t.portalUrl=e.data.urlKey&&s?"https://"+e.data.urlKey.toLowerCase()+"."+s:n,i.oAuthInfos.push(t)}}))}))},t.prototype._doOAuthSignIn=function(e,t,r){var i=this,n={portalUrl:r.portalUrl};!r.popup&&r.preserveUrlHash&&window.location.hash&&(n.hash=window.location.hash);var o={client_id:r.appId,response_type:"token",state:JSON.stringify(n),expiration:r.expiration,locale:r.locale,redirect_uri:r.popup?f.makeAbsolute(r.popupCallbackUrl):window.location.href.replace(/#.*$/,"")};r.forceLogin&&(o.force_login=!0);var s=r.portalUrl.replace(/^http:/i,"https:")+"/sharing/oauth2/authorize",l=s+"?"+f.objectToQuery(o);if(r.popup){var u=window.open(l,"esriJSAPIOAuth",r.popupWindowFeatures);if(u)u.focus(),this._oAuthDfd.oAuthWin_=u,this._oAuthIntervalId=setInterval((function(){if(u.closed){clearInterval(i._oAuthIntervalId);var e=i._oAuthDfd;if(e){var t=new a("identity-manager:user-aborted","ABORTED");e.reject(t)}}}),500);else{var c=new a("identity-manager:popup-blocked","ABORTED");this._oAuthDfd.reject(c)}}else this._rejectOnPersistedPageShow=!0,this._oAuthRedirectFunc?this._oAuthRedirectFunc({authorizeParams:o,authorizeUrl:s,resourceUrl:e,serverInfo:t,oAuthInfo:r}):window.location.href=l},r.__decorate([v.subclass("esri.identity.IdentityManagerBase")],t)}(l);t.IdentityManagerBase=x;var U=function(e){function t(t){var r=e.call(this,t)||this;return r._oAuthCred=null,r.tokenRefreshBuffer=2,t&&t._oAuthCred&&(r._oAuthCred=t._oAuthCred),r}return r.__extends(t,e),t.prototype.initialize=function(){this.resources=this.resources||[],null==this.creationTime&&(this.creationTime=Date.now())},t.prototype.refreshToken=function(){var e,t,r=this,i=n.id.findServerInfo(this.server),o=i&&i.owningSystemUrl,s=!!o&&"server"===this.scope,a=s&&A(i,n.id._legacyFed),l=i.webTierAuth,u=l&&n.id.normalizeWebTierAuth,c=S[this.server],p=c&&c[this.userId],d=this.resources&&this.resources[0],h=s&&n.id.findServerInfo(o),f={username:this.userId,password:p};if((!l||u)&&(s&&!h&&n.id.serverInfos.some((function(e){return n.id._isIdProvider(o,e.server)&&(h=e),!!h})),e=h&&n.id.findCredential(h.server,this.userId),!s||e)){if(!a){if(s)t={serverUrl:d,token:e&&e.token,ssl:e&&e.ssl};else if(u)f=null,t={ssl:this.ssl};else{if(!p){var _=void 0;return d&&(d=n.id._sanitizeUrl(d),this._enqueued=1,(_=n.id._enqueue(d,i,null,null,this.isAdmin,this)).then((function(){r._enqueued=0,r.refreshServerTokens()})).catch((function(){r._enqueued=0}))),_}this.isAdmin&&(t={isAdmin:!0})}return n.id.generateToken(s?h:i,s?null:f,t).then((function(e){r.token=e.token,r.expires=null!=e.expires?Number(e.expires):null,r.creationTime=Date.now(),r.validity=e.validity,r.emitTokenChange(),r.refreshServerTokens()})).catch((function(){}))}e.refreshToken()}},t.prototype.refreshServerTokens=function(){var e=this;"portal"===this.scope&&n.id.credentials.forEach((function(t){var r=n.id.findServerInfo(t.server),i=r&&r.owningSystemUrl;t!==e&&t.userId===e.userId&&i&&"server"===t.scope&&(n.id._hasSameServerInstance(e.server,i)||n.id._isIdProvider(i,e.server))&&(A(r,n.id._legacyFed)?(t.token=e.token,t.expires=e.expires,t.creationTime=e.creationTime,t.validity=e.validity,t.emitTokenChange()):t.refreshToken())}))},t.prototype.emitTokenChange=function(e){clearTimeout(this._refreshTimer);var t=this.server&&n.id.findServerInfo(this.server),r=t&&t.owningSystemUrl,i=r&&n.id.findServerInfo(r);!1===e||r&&"portal"!==this.scope&&(!i||!i.webTierAuth||n.id.normalizeWebTierAuth)||null==this.expires&&null==this.validity||this._startRefreshTimer(),this.emit("token-change")},t.prototype.destroy=function(){this.userId=this.server=this.token=this.expires=this.validity=this.resources=this.creationTime=null,this._oAuthCred&&(this._oAuthCred.destroy(),this._oAuthCred=null);var e=n.id.credentials.indexOf(this);e>-1&&n.id.credentials.splice(e,1),this.emitTokenChange(),this.emit("destroy")},t.prototype.toJSON=function(){var e=c.fixJson({userId:this.userId,server:this.server,token:this.token,expires:this.expires,validity:this.validity,ssl:this.ssl,isAdmin:this.isAdmin,creationTime:this.creationTime,scope:this.scope}),t=this.resources;return t&&t.length>0&&(e.resources=t.slice()),e},t.prototype._startRefreshTimer=function(){clearTimeout(this._refreshTimer);var e=6e4*this.tokenRefreshBuffer,t=(this.validity?this.creationTime+6e4*this.validity:this.expires)-Date.now();t<0&&(t=0),this._refreshTimer=setTimeout(this.refreshToken.bind(this),t>e?t-e:t)},r.__decorate([v.property()],t.prototype,"creationTime",void 0),r.__decorate([v.property()],t.prototype,"expires",void 0),r.__decorate([v.property()],t.prototype,"isAdmin",void 0),r.__decorate([v.property()],t.prototype,"oAuthState",void 0),r.__decorate([v.property()],t.prototype,"resources",void 0),r.__decorate([v.property()],t.prototype,"scope",void 0),r.__decorate([v.property()],t.prototype,"server",void 0),r.__decorate([v.property()],t.prototype,"ssl",void 0),r.__decorate([v.property()],t.prototype,"token",void 0),r.__decorate([v.property()],t.prototype,"tokenRefreshBuffer",void 0),r.__decorate([v.property()],t.prototype,"userId",void 0),r.__decorate([v.property()],t.prototype,"validity",void 0),r.__decorate([v.subclass("esri.identity.Credential")],t)}(l.EventedAccessor);t.Credential=U}).apply(null,i))||(e.exports=n)},jdHw:function(e,t,r){var i,n;i=[r.dj.c(e.i),t,r("zOht"),r("ycL1"),r("Vx27")],void 0===(n=(function(e,t,r,i,n){return function(e){function t(t){var r=e.call(this,t)||this;return r.adminTokenServiceUrl=null,r.currentVersion=null,r.hasPortal=null,r.hasServer=null,r.owningSystemUrl=null,r.owningTenant=null,r.server=null,r.shortLivedTokenValidity=null,r.tokenServiceUrl=null,r.webTierAuth=null,r}return r.__extends(t,e),r.__decorate([n.property({json:{write:!0}})],t.prototype,"adminTokenServiceUrl",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"currentVersion",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"hasPortal",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"hasServer",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"owningSystemUrl",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"owningTenant",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"server",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"shortLivedTokenValidity",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"tokenServiceUrl",void 0),r.__decorate([n.property({json:{write:!0}})],t.prototype,"webTierAuth",void 0),r.__decorate([n.subclass("esri.identity.ServerInfo")],t)}(i.JSONSupport)}).apply(null,i))||(e.exports=n)},pUXy:function(e,t,r){var i,n;i=[r.dj.c(e.i),t],void 0===(n=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.writeCookie=function(e,t,r){void 0===r&&(r={});var i=r.expires;if("number"==typeof i){var n=new Date;n.setTime(n.getTime()+24*i*60*60*1e3),i=r.expires=n}"string"!=typeof i&&(r.expires=i.toUTCString());var o=e+"="+encodeURIComponent(t);for(var s in r){o+="; "+s;var a=r[s];!0!==a&&(o+="="+a)}document.cookie=o}}).apply(null,i))||(e.exports=n)}}]);