/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import t from"../config.js";import{id as n}from"../kernel.js";import{clone as r}from"../core/lang.js";import{urlToObject as e}from"../core/urlUtils.js";import{supportsApiKey as i,getApiKey as o}from"../support/apiKeyUtils.js";function s(t,n){return n?{...n,query:{...t,...n.query}}:{query:t}}function f(t){return"string"==typeof t?e(t):r(t)}function u(t,n,r){const e={};for(const i in t){if("declaredClass"===i)continue;const o=t[i];if(null!=o&&"function"!=typeof o)if(Array.isArray(o))e[i]=o.map(t=>u(t));else if("object"==typeof o)if(o.toJSON){const t=o.toJSON(r?.[i]);e[i]=n?t:JSON.stringify(t)}else e[i]=n?o:JSON.stringify(o);else e[i]=o}return e}function c(t,r){return t?r&&i(t)?r:o(t)??n?.findCredential(t)?.token:null}async function a(r,e,i){const o=c(r,e);if(o)return o;!n&&t.request.useIdentity&&await import("../identity/IdentityManager.js");const s=await n.getCredential(r,i);return s?.token}export{s as asValidOptions,u as encode,c as findToken,a as getToken,f as parseUrl};
