"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerBrowserApp = registerBrowserApp;
const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
const get_portal_api_url_1 = require("../urls/get-portal-api-url");
/**
 * @private
 * @internal
 * Register an Item as an application, enabling oAuth flows at custom
 * domains. Only item types with "Application" in the name are valid
 * with this API call.
 * @param {string} itemId Item Id of item to create an application for
 * @param {Array} redirectUris Array of valid redirect uris for the app
 * @param {string} appType Defaults to "browser"
 * @param {IRequestOptions} requestOptions
 */
function registerBrowserApp(itemId, redirectUris, requestOptions) {
    const url = `${(0, get_portal_api_url_1.getPortalApiUrl)(requestOptions)}/oauth2/registerApp`;
    const options = {
        method: "POST",
        authentication: requestOptions.authentication,
        params: {
            itemId,
            appType: "browser",
            redirect_uris: JSON.stringify(redirectUris),
        },
    };
    return (0, arcgis_rest_request_1.request)(url, options);
}
//# sourceMappingURL=registerBrowserApp.js.map