/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import o from"../config.js";import{getOrigin as s,hasSameOrigin as r,getAppUrl as t,urlToObject as e}from"../core/urlUtils.js";function n(r){o.request.crossOriginNoCorsDomains||(o.request.crossOriginNoCorsDomains={});const t=o.request.crossOriginNoCorsDomains;for(let o of r)o=o.toLowerCase(),/^https?:\/\//.test(o)?t[s(o)??""]=0:(t[s("http://"+o)??""]=0,t[s("https://"+o)??""]=0)}function i(e){const n=o.request.crossOriginNoCorsDomains;if(n){let o=s(e);if(o)return o=o.toLowerCase(),!r(o,t())&&n[o]<Date.now()-36e5}return!1}async function c(r){const t=e(r);r=t.path,"json"===t.query?.f&&(r+="?f=json");try{await fetch(r,{mode:"no-cors",credentials:"include"})}catch{}const n=o.request.crossOriginNoCorsDomains,i=s(r);n&&i&&(n[i.toLowerCase()]=Date.now())}export{i as isNoCorsRequestRequired,n as registerNoCorsDomains,c as sendNoCorsRequest};
