// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/urlUtils","dojo/_base/lang dojo/_base/array dojo/_base/url dojo/io-query ./kernel ./lang ./config ./sniff dojo/i18n!./nls/jsapi".split(" "),function(g,w,m,q,k,x,r,p,y){var l=function(){return this}(),b={},n=r.defaults.io,z=/^[a-z][a-z0-9\+\-\.]*:/i,t=/^\s*http:/i,u=/^\s*https:/i,A=/^https?:\/\/[^/]+\.arcgis.com\/sharing(\/|$)/i;b.isHTTP=function(a){var c=l.location.protocol;return null==a?"http:"===c||"https:"===c:a?"https:"===c:"http:"===c};b.getProtocolForWebResource=function(a){return b.isHTTP()?
l.location.protocol:a?"https:":"http:"};b.urlToObject=function(a){var c={},b=new m(a),e=a.indexOf("?");null===b.query?c={path:a,query:null}:(c.path=a.substring(0,e),c.query=q.queryToObject(b.query));b.fragment&&(c.hash=b.fragment,null===b.query&&(c.path=c.path.substring(0,c.path.length-(b.fragment.length+1))));return c};b.getProxyUrl=function(a,c){var d=g.isString(a)?0===g.trim(a).toLowerCase().indexOf("https:"):a,e=n.proxyUrl,f,h,v=y.io.proxyNotSet;g.isString(a)&&(h=b.getProxyRule(a))&&(e=h.proxyUrl);
if(!e)throw console.log(v),Error(v);d&&!1!==c&&0!==l.location.href.toLowerCase().indexOf("https:")&&(d=e,0!==d.toLowerCase().indexOf("http")&&(d=b.getAbsoluteUrl(d)),d=d.replace(/^http:/i,"https:"),b.canUseXhr(d)&&(e=d,f=1));e=b.urlToObject(e);e._xo=f;return e};b.addProxy=function(a){var c=b.getProxyRule(a),d;c?d=b.urlToObject(c.proxyUrl):n.alwaysUseProxy&&(d=b.getProxyUrl());d&&(c=b.urlToObject(a),a=d.path+"?"+c.path,(d=q.objectToQuery(g.mixin(d.query||{},c.query)))&&(a+="?"+d));return a};b.addProxyRule=
function(a){var c=a.urlPrefix=b.urlToObject(a.urlPrefix).path.replace(/([^\/])$/,"$1/").replace(/^https?:\/\//ig,"").toLowerCase(),d=n.proxyRules,e,f=d.length,h,g=f;for(e=0;e<f;e++)if(h=d[e].urlPrefix,0===c.indexOf(h)){if(c.length===h)return-1;g=e;break}else 0===h.indexOf(c)&&(g=e+1);d.splice(g,0,a);return g};b.getProxyRule=function(a){var c=n.proxyRules,d=c.length,e=b.urlToObject(a).path.replace(/([^\/])$/,"$1/").replace(/^https?:\/\//ig,"").toLowerCase(),f;for(a=0;a<d;a++)if(0===e.indexOf(c[a].urlPrefix)){f=
c[a];break}return f};b.hasSameOrigin=function(a,b,d){a=a.toLowerCase();b=b.toLowerCase();var c=l.location.href.toLowerCase();a=0===a.indexOf("http")?new m(a):c=new m(c);b=0===b.indexOf("http")?new m(b):g.isString(c)?new m(c):c;return(d||a.scheme===b.scheme)&&a.host===b.host&&a.port===b.port};b.canUseXhr=function(a,c){var d=p("esri-phonegap")?!0:!1,e=b.hasSameOrigin,f=n.corsEnabledServers,h,k=-1;!d&&p("esri-cors")&&f&&f.length&&(d=w.some(f,function(b,c){var d=b&&"object"===typeof b?b.host:b;return d&&
(h=0!==g.trim(d).toLowerCase().indexOf("http"),e(a,h?"http://"+d:d)||h&&e(a,"https://"+d))?(k=c,!0):!1}));return c?k:d};b.getAbsoluteUrl=function(a){var c=b.getProtocolForWebResource();return g.isString(a)&&!z.test(a)?0===a.indexOf("//")?c+a:0===a.indexOf("/")?c+"//"+l.location.host+a:k._appBaseUrl+a:a};b.fixUrl=function(a){a=g.trim(a);a=b.getAbsoluteUrl(a);a=b.downgradeToHTTP(a);a=b.upgradeToHTTPS(a);return a=a.replace(/^(https?:\/\/)(arcgis\.com)/i,"$1www.$2")};b.normalize=function(a){return b.fixUrl(a)};
b.downgradeToHTTP=function(a){return b.isHTTP(!1)&&u.test(a)&&b.hasSameOrigin(l.location.href,a,!0)&&!b.canUseXhr(a)?a.replace(u,"http:"):a};b.upgradeToHTTPS=function(a){var c=r.defaults.io.httpsDomains,d=b.isHTTP(!1),e=b.isHTTP(!0);if(!t.test(a))return a;a=g.trim(a);var f=a.indexOf("/",7),f=-1===f?a:a.slice(0,f),f=f.toLowerCase().slice(7);if(d&&f===l.location.host&&(!A.test(a)||!b.canUseXhr(a)))return a;d=!1;if(e&&f===l.location.host)d=!0;else if(c)for(e=0;e<c.length;e++){var h=c[e];if(f===h||x.endsWith(f,
"."+h)){d=!0;break}}d&&(a=a.replace(t,"https:"));return a};p("extend-esri")&&(g.mixin(k,b),k._getProxyUrl=b.getProxyUrl,k._getProxiedUrl=b.addProxy,k._hasSameOrigin=b.hasSameOrigin,k._canDoXOXHR=b.canUseXhr,k._getAbsoluteUrl=b.getAbsoluteUrl,k.fixUrl=b.fixUrl);return b});