import { O, e2, e3 } from "./chunk-E6CBEY54.js"; import "./chunk-P6MX663D.js"; import { n2 as n4, v as v3 } from "./chunk-7256PFPA.js"; import "./chunk-QY775BFA.js"; import { s as s2 } from "./chunk-2SJEIKRW.js"; import "./chunk-PHRSJJ3U.js"; import "./chunk-PIGRDDRG.js"; import "./chunk-NE3ESGA6.js"; import { l as l2 } from "./chunk-YIS6BAC3.js"; import "./chunk-MXB2XLKV.js"; import "./chunk-XH7RUGVZ.js"; import "./chunk-YBSUITLL.js"; import "./chunk-ALDCDSPV.js"; import { n as n3 } from "./chunk-DT6EAZQ5.js"; import "./chunk-HNOZUNJ4.js"; import { U } from "./chunk-VNFRAYHO.js"; import { n as n5, o } from "./chunk-R5IG2D6H.js"; import { Bt, F, I, J, Q, Z, j, v as v2, y as y2, z } from "./chunk-VBRY5KJM.js"; import "./chunk-PDKDCAAD.js"; import "./chunk-GCDJLKH4.js"; import { d, e, l3 as l, n, n2 } from "./chunk-Y3WMVFTW.js"; import "./chunk-SAS7RONY.js"; import "./chunk-WSRBH7BF.js"; import "./chunk-IHXECKQQ.js"; import { D, p, r2, v } from "./chunk-ULGDPLM2.js"; import { r, s3 as s } from "./chunk-EMJ4ZSM2.js"; import { t, y } from "./chunk-IKP3YN53.js"; import "./chunk-GZT4BVFP.js"; import "./chunk-A5ICIBVI.js"; // node_modules/@arcgis/core/identity/IdentityForm.js var a = { base: "esri-identity-form", group: "esri-identity-form__group", label: "esri-identity-form__label", footer: "esri-identity-form__footer", esriInput: "esri-input", esriButton: "esri-button", esriButtonSecondary: "esri-button--secondary" }; var l3 = "ArcGIS Online"; var p2 = class extends O { constructor(s6, e5) { super(s6, e5), this._usernameInputNode = null, this._passwordInputNode = null, this.messages = null, this.signingIn = false, this.server = null, this.resource = null, this.error = null, this.oAuthPrompt = false; } render() { const { error: s6, server: e5, resource: t3, signingIn: o2, oAuthPrompt: n6, messages: p5 } = this, d3 = n4("div", { class: a.group }, s2(n6 ? p5.oAuthInfo : p5.info, { server: /\.arcgis\.com/i.test(e5) ? l3 : e5, resource: `(${t3 || p5.lblItem})` })), c = n6 ? null : n4("div", { class: a.group, key: "username" }, n4("label", { class: a.label }, p5.lblUser, n4("input", { value: "", required: true, autocomplete: "off", spellcheck: false, type: "text", bind: this, afterCreate: v3, "data-node-ref": "_usernameInputNode", class: a.esriInput }))), m = n6 ? null : n4("div", { class: a.group, key: "password" }, n4("label", { class: a.label }, p5.lblPwd, n4("input", { value: "", required: true, type: "password", bind: this, afterCreate: v3, "data-node-ref": "_passwordInputNode", class: a.esriInput }))), h = n4("div", { class: this.classes(a.group, a.footer) }, n4("input", { type: "submit", disabled: !!o2, value: o2 ? p5.lblSigning : p5.lblOk, class: a.esriButton }), n4("input", { type: "button", value: p5.lblCancel, bind: this, onclick: this._cancel, class: this.classes(a.esriButton, a.esriButtonSecondary) })), b2 = s6 ? n4("div", null, s6.details && s6.details.httpStatus ? p5.invalidUser : p5.noAuthService) : null; return n4("form", { class: a.base, bind: this, onsubmit: this._submit }, d3, b2, c, m, h); } _cancel() { this._set("signingIn", false), this._usernameInputNode && (this._usernameInputNode.value = ""), this._passwordInputNode && (this._passwordInputNode.value = ""), this.emit("cancel"); } _submit(s6) { s6.preventDefault(), this._set("signingIn", true); const e5 = this.oAuthPrompt ? {} : { username: this._usernameInputNode && this._usernameInputNode.value, password: this._passwordInputNode && this._passwordInputNode.value }; this.emit("submit", e5); } }; e([d(), e2("esri/identity/t9n/identity")], p2.prototype, "messages", void 0), e([d()], p2.prototype, "signingIn", void 0), e([d()], p2.prototype, "server", void 0), e([d()], p2.prototype, "resource", void 0), e([d()], p2.prototype, "error", void 0), e([d()], p2.prototype, "oAuthPrompt", void 0), p2 = e([n2("esri.identity.IdentityForm")], p2); var d2 = p2; // node_modules/tabbable/dist/index.esm.js var candidateSelectors = ["input", "select", "textarea", "a[href]", "button", "[tabindex]:not(slot)", "audio[controls]", "video[controls]", '[contenteditable]:not([contenteditable="false"])', "details>summary:first-of-type", "details"]; var candidateSelector = candidateSelectors.join(","); var NoElement = typeof Element === "undefined"; var matches = NoElement ? function() { } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) { return element.getRootNode(); } : function(element) { return element.ownerDocument; }; var getCandidates = function getCandidates2(el, includeContainer, filter) { var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector)); if (includeContainer && matches.call(el, candidateSelector)) { candidates.unshift(el); } candidates = candidates.filter(filter); return candidates; }; var getCandidatesIteratively = function getCandidatesIteratively2(elements, includeContainer, options) { var candidates = []; var elementsToCheck = Array.from(elements); while (elementsToCheck.length) { var element = elementsToCheck.shift(); if (element.tagName === "SLOT") { var assigned = element.assignedElements(); var content = assigned.length ? assigned : element.children; var nestedCandidates = getCandidatesIteratively2(content, true, options); if (options.flatten) { candidates.push.apply(candidates, nestedCandidates); } else { candidates.push({ scope: element, candidates: nestedCandidates }); } } else { var validCandidate = matches.call(element, candidateSelector); if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) { candidates.push(element); } var shadowRoot = element.shadowRoot || typeof options.getShadowRoot === "function" && options.getShadowRoot(element); var validShadowRoot = !options.shadowRootFilter || options.shadowRootFilter(element); if (shadowRoot && validShadowRoot) { var _nestedCandidates = getCandidatesIteratively2(shadowRoot === true ? element.children : shadowRoot.children, true, options); if (options.flatten) { candidates.push.apply(candidates, _nestedCandidates); } else { candidates.push({ scope: element, candidates: _nestedCandidates }); } } else { elementsToCheck.unshift.apply(elementsToCheck, element.children); } } } return candidates; }; var getTabindex = function getTabindex2(node, isScope) { if (node.tabIndex < 0) { if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || node.isContentEditable) && isNaN(parseInt(node.getAttribute("tabindex"), 10))) { return 0; } } return node.tabIndex; }; var sortOrderedTabbables = function sortOrderedTabbables2(a2, b2) { return a2.tabIndex === b2.tabIndex ? a2.documentOrder - b2.documentOrder : a2.tabIndex - b2.tabIndex; }; var isInput = function isInput2(node) { return node.tagName === "INPUT"; }; var isHiddenInput = function isHiddenInput2(node) { return isInput(node) && node.type === "hidden"; }; var isDetailsWithSummary = function isDetailsWithSummary2(node) { var r4 = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) { return child.tagName === "SUMMARY"; }); return r4; }; var getCheckedRadio = function getCheckedRadio2(nodes, form) { for (var i3 = 0; i3 < nodes.length; i3++) { if (nodes[i3].checked && nodes[i3].form === form) { return nodes[i3]; } } }; var isTabbableRadio = function isTabbableRadio2(node) { if (!node.name) { return true; } var radioScope = node.form || getRootNode(node); var queryRadios = function queryRadios2(name) { return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]'); }; var radioSet; if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") { radioSet = queryRadios(window.CSS.escape(node.name)); } else { try { radioSet = queryRadios(node.name); } catch (err) { console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message); return false; } } var checked = getCheckedRadio(radioSet, node.form); return !checked || checked === node; }; var isRadio = function isRadio2(node) { return isInput(node) && node.type === "radio"; }; var isNonTabbableRadio = function isNonTabbableRadio2(node) { return isRadio(node) && !isTabbableRadio(node); }; var isZeroArea = function isZeroArea2(node) { var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height; return width === 0 && height === 0; }; var isHidden = function isHidden2(node, _ref) { var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot; if (getComputedStyle(node).visibility === "hidden") { return true; } var isDirectSummary = matches.call(node, "details>summary:first-of-type"); var nodeUnderDetails = isDirectSummary ? node.parentElement : node; if (matches.call(nodeUnderDetails, "details:not([open]) *")) { return true; } var nodeRootHost = getRootNode(node).host; var nodeIsAttached = (nodeRootHost === null || nodeRootHost === void 0 ? void 0 : nodeRootHost.ownerDocument.contains(nodeRootHost)) || node.ownerDocument.contains(node); if (!displayCheck || displayCheck === "full") { if (typeof getShadowRoot === "function") { var originalNode = node; while (node) { var parentElement = node.parentElement; var rootNode = getRootNode(node); if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) { return isZeroArea(node); } else if (node.assignedSlot) { node = node.assignedSlot; } else if (!parentElement && rootNode !== node.ownerDocument) { node = rootNode.host; } else { node = parentElement; } } node = originalNode; } if (nodeIsAttached) { return !node.getClientRects().length; } } else if (displayCheck === "non-zero-area") { return isZeroArea(node); } return false; }; var isDisabledFromFieldset = function isDisabledFromFieldset2(node) { if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) { var parentNode = node.parentElement; while (parentNode) { if (parentNode.tagName === "FIELDSET" && parentNode.disabled) { for (var i3 = 0; i3 < parentNode.children.length; i3++) { var child = parentNode.children.item(i3); if (child.tagName === "LEGEND") { return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node); } } return true; } parentNode = parentNode.parentElement; } } return false; }; var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) { if (node.disabled || isHiddenInput(node) || isHidden(node, options) || isDetailsWithSummary(node) || isDisabledFromFieldset(node)) { return false; } return true; }; var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) { if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) { return false; } return true; }; var isValidShadowRootTabbable = function isValidShadowRootTabbable2(shadowHostNode) { var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10); if (isNaN(tabIndex) || tabIndex >= 0) { return true; } return false; }; var sortByOrder = function sortByOrder2(candidates) { var regularTabbables = []; var orderedTabbables = []; candidates.forEach(function(item, i3) { var isScope = !!item.scope; var element = isScope ? item.scope : item; var candidateTabindex = getTabindex(element, isScope); var elements = isScope ? sortByOrder2(item.candidates) : element; if (candidateTabindex === 0) { isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element); } else { orderedTabbables.push({ documentOrder: i3, tabIndex: candidateTabindex, item, isScope, content: elements }); } }); return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) { sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content); return acc; }, []).concat(regularTabbables); }; var tabbable = function tabbable2(el, options) { options = options || {}; var candidates; if (options.getShadowRoot) { candidates = getCandidatesIteratively([el], options.includeContainer, { filter: isNodeMatchingSelectorTabbable.bind(null, options), flatten: false, getShadowRoot: options.getShadowRoot, shadowRootFilter: isValidShadowRootTabbable }); } else { candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options)); } return sortByOrder(candidates); }; var focusable = function focusable2(el, options) { options = options || {}; var candidates; if (options.getShadowRoot) { candidates = getCandidatesIteratively([el], options.includeContainer, { filter: isNodeMatchingSelectorFocusable.bind(null, options), flatten: true, getShadowRoot: options.getShadowRoot }); } else { candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options)); } return candidates; }; var isTabbable = function isTabbable2(node, options) { options = options || {}; if (!node) { throw new Error("No node provided"); } if (matches.call(node, candidateSelector) === false) { return false; } return isNodeMatchingSelectorTabbable(options, node); }; var focusableCandidateSelector = candidateSelectors.concat("iframe").join(","); var isFocusable = function isFocusable2(node, options) { options = options || {}; if (!node) { throw new Error("No node provided"); } if (matches.call(node, focusableCandidateSelector) === false) { return false; } return isNodeMatchingSelectorFocusable(options, node); }; // node_modules/focus-trap/dist/focus-trap.esm.js function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function(sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread2(target) { for (var i3 = 1; i3 < arguments.length; i3++) { var source = arguments[i3] != null ? arguments[i3] : {}; i3 % 2 ? ownKeys(Object(source), true).forEach(function(key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var activeFocusTraps = function() { var trapQueue = []; return { activateTrap: function activateTrap(trap) { if (trapQueue.length > 0) { var activeTrap = trapQueue[trapQueue.length - 1]; if (activeTrap !== trap) { activeTrap.pause(); } } var trapIndex = trapQueue.indexOf(trap); if (trapIndex === -1) { trapQueue.push(trap); } else { trapQueue.splice(trapIndex, 1); trapQueue.push(trap); } }, deactivateTrap: function deactivateTrap(trap) { var trapIndex = trapQueue.indexOf(trap); if (trapIndex !== -1) { trapQueue.splice(trapIndex, 1); } if (trapQueue.length > 0) { trapQueue[trapQueue.length - 1].unpause(); } } }; }(); var isSelectableInput = function isSelectableInput2(node) { return node.tagName && node.tagName.toLowerCase() === "input" && typeof node.select === "function"; }; var isEscapeEvent = function isEscapeEvent2(e5) { return e5.key === "Escape" || e5.key === "Esc" || e5.keyCode === 27; }; var isTabEvent = function isTabEvent2(e5) { return e5.key === "Tab" || e5.keyCode === 9; }; var delay = function delay2(fn) { return setTimeout(fn, 0); }; var findIndex = function findIndex2(arr, fn) { var idx = -1; arr.every(function(value, i3) { if (fn(value)) { idx = i3; return false; } return true; }); return idx; }; var valueOrHandler = function valueOrHandler2(value) { for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { params[_key - 1] = arguments[_key]; } return typeof value === "function" ? value.apply(void 0, params) : value; }; var getActualTarget = function getActualTarget2(event) { return event.target.shadowRoot && typeof event.composedPath === "function" ? event.composedPath()[0] : event.target; }; var createFocusTrap = function createFocusTrap2(elements, userOptions) { var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document; var config = _objectSpread2({ returnFocusOnDeactivate: true, escapeDeactivates: true, delayInitialFocus: true }, userOptions); var state = { containers: [], containerGroups: [], tabbableGroups: [], nodeFocusedBeforeActivation: null, mostRecentlyFocusedNode: null, active: false, paused: false, delayInitialFocusTimer: void 0 }; var trap; var getOption = function getOption2(configOverrideOptions, optionName, configOptionName) { return configOverrideOptions && configOverrideOptions[optionName] !== void 0 ? configOverrideOptions[optionName] : config[configOptionName || optionName]; }; var findContainerIndex = function findContainerIndex2(element) { return state.containerGroups.findIndex(function(_ref) { var container = _ref.container, tabbableNodes = _ref.tabbableNodes; return container.contains(element) || tabbableNodes.find(function(node) { return node === element; }); }); }; var getNodeForOption = function getNodeForOption2(optionName) { var optionValue = config[optionName]; if (typeof optionValue === "function") { for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { params[_key2 - 1] = arguments[_key2]; } optionValue = optionValue.apply(void 0, params); } if (optionValue === true) { optionValue = void 0; } if (!optionValue) { if (optionValue === void 0 || optionValue === false) { return optionValue; } throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node")); } var node = optionValue; if (typeof optionValue === "string") { node = doc.querySelector(optionValue); if (!node) { throw new Error("`".concat(optionName, "` as selector refers to no known node")); } } return node; }; var getInitialFocusNode = function getInitialFocusNode2() { var node = getNodeForOption("initialFocus"); if (node === false) { return false; } if (node === void 0) { if (findContainerIndex(doc.activeElement) >= 0) { node = doc.activeElement; } else { var firstTabbableGroup = state.tabbableGroups[0]; var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode; node = firstTabbableNode || getNodeForOption("fallbackFocus"); } } if (!node) { throw new Error("Your focus-trap needs to have at least one focusable element"); } return node; }; var updateTabbableNodes = function updateTabbableNodes2() { state.containerGroups = state.containers.map(function(container) { var tabbableNodes = tabbable(container, config.tabbableOptions); var focusableNodes = focusable(container, config.tabbableOptions); return { container, tabbableNodes, focusableNodes, firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null, lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null, nextTabbableNode: function nextTabbableNode(node) { var forward = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true; var nodeIdx = focusableNodes.findIndex(function(n6) { return n6 === node; }); if (nodeIdx < 0) { return void 0; } if (forward) { return focusableNodes.slice(nodeIdx + 1).find(function(n6) { return isTabbable(n6, config.tabbableOptions); }); } return focusableNodes.slice(0, nodeIdx).reverse().find(function(n6) { return isTabbable(n6, config.tabbableOptions); }); } }; }); state.tabbableGroups = state.containerGroups.filter(function(group) { return group.tabbableNodes.length > 0; }); if (state.tabbableGroups.length <= 0 && !getNodeForOption("fallbackFocus")) { throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times"); } }; var tryFocus = function tryFocus2(node) { if (node === false) { return; } if (node === doc.activeElement) { return; } if (!node || !node.focus) { tryFocus2(getInitialFocusNode()); return; } node.focus({ preventScroll: !!config.preventScroll }); state.mostRecentlyFocusedNode = node; if (isSelectableInput(node)) { node.select(); } }; var getReturnFocusNode = function getReturnFocusNode2(previousActiveElement) { var node = getNodeForOption("setReturnFocus", previousActiveElement); return node ? node : node === false ? false : previousActiveElement; }; var checkPointerDown = function checkPointerDown2(e5) { var target = getActualTarget(e5); if (findContainerIndex(target) >= 0) { return; } if (valueOrHandler(config.clickOutsideDeactivates, e5)) { trap.deactivate({ returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions) }); return; } if (valueOrHandler(config.allowOutsideClick, e5)) { return; } e5.preventDefault(); }; var checkFocusIn = function checkFocusIn2(e5) { var target = getActualTarget(e5); var targetContained = findContainerIndex(target) >= 0; if (targetContained || target instanceof Document) { if (targetContained) { state.mostRecentlyFocusedNode = target; } } else { e5.stopImmediatePropagation(); tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode()); } }; var checkTab = function checkTab2(e5) { var target = getActualTarget(e5); updateTabbableNodes(); var destinationNode = null; if (state.tabbableGroups.length > 0) { var containerIndex = findContainerIndex(target); var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : void 0; if (containerIndex < 0) { if (e5.shiftKey) { destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode; } else { destinationNode = state.tabbableGroups[0].firstTabbableNode; } } else if (e5.shiftKey) { var startOfGroupIndex = findIndex(state.tabbableGroups, function(_ref2) { var firstTabbableNode = _ref2.firstTabbableNode; return target === firstTabbableNode; }); if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) { startOfGroupIndex = containerIndex; } if (startOfGroupIndex >= 0) { var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1; var destinationGroup = state.tabbableGroups[destinationGroupIndex]; destinationNode = destinationGroup.lastTabbableNode; } } else { var lastOfGroupIndex = findIndex(state.tabbableGroups, function(_ref3) { var lastTabbableNode = _ref3.lastTabbableNode; return target === lastTabbableNode; }); if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) { lastOfGroupIndex = containerIndex; } if (lastOfGroupIndex >= 0) { var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1; var _destinationGroup = state.tabbableGroups[_destinationGroupIndex]; destinationNode = _destinationGroup.firstTabbableNode; } } } else { destinationNode = getNodeForOption("fallbackFocus"); } if (destinationNode) { e5.preventDefault(); tryFocus(destinationNode); } }; var checkKey = function checkKey2(e5) { if (isEscapeEvent(e5) && valueOrHandler(config.escapeDeactivates, e5) !== false) { e5.preventDefault(); trap.deactivate(); return; } if (isTabEvent(e5)) { checkTab(e5); return; } }; var checkClick = function checkClick2(e5) { var target = getActualTarget(e5); if (findContainerIndex(target) >= 0) { return; } if (valueOrHandler(config.clickOutsideDeactivates, e5)) { return; } if (valueOrHandler(config.allowOutsideClick, e5)) { return; } e5.preventDefault(); e5.stopImmediatePropagation(); }; var addListeners = function addListeners2() { if (!state.active) { return; } activeFocusTraps.activateTrap(trap); state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function() { tryFocus(getInitialFocusNode()); }) : tryFocus(getInitialFocusNode()); doc.addEventListener("focusin", checkFocusIn, true); doc.addEventListener("mousedown", checkPointerDown, { capture: true, passive: false }); doc.addEventListener("touchstart", checkPointerDown, { capture: true, passive: false }); doc.addEventListener("click", checkClick, { capture: true, passive: false }); doc.addEventListener("keydown", checkKey, { capture: true, passive: false }); return trap; }; var removeListeners = function removeListeners2() { if (!state.active) { return; } doc.removeEventListener("focusin", checkFocusIn, true); doc.removeEventListener("mousedown", checkPointerDown, true); doc.removeEventListener("touchstart", checkPointerDown, true); doc.removeEventListener("click", checkClick, true); doc.removeEventListener("keydown", checkKey, true); return trap; }; trap = { get active() { return state.active; }, get paused() { return state.paused; }, activate: function activate(activateOptions) { if (state.active) { return this; } var onActivate = getOption(activateOptions, "onActivate"); var onPostActivate = getOption(activateOptions, "onPostActivate"); var checkCanFocusTrap = getOption(activateOptions, "checkCanFocusTrap"); if (!checkCanFocusTrap) { updateTabbableNodes(); } state.active = true; state.paused = false; state.nodeFocusedBeforeActivation = doc.activeElement; if (onActivate) { onActivate(); } var finishActivation = function finishActivation2() { if (checkCanFocusTrap) { updateTabbableNodes(); } addListeners(); if (onPostActivate) { onPostActivate(); } }; if (checkCanFocusTrap) { checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation); return this; } finishActivation(); return this; }, deactivate: function deactivate(deactivateOptions) { if (!state.active) { return this; } var options = _objectSpread2({ onDeactivate: config.onDeactivate, onPostDeactivate: config.onPostDeactivate, checkCanReturnFocus: config.checkCanReturnFocus }, deactivateOptions); clearTimeout(state.delayInitialFocusTimer); state.delayInitialFocusTimer = void 0; removeListeners(); state.active = false; state.paused = false; activeFocusTraps.deactivateTrap(trap); var onDeactivate = getOption(options, "onDeactivate"); var onPostDeactivate = getOption(options, "onPostDeactivate"); var checkCanReturnFocus = getOption(options, "checkCanReturnFocus"); var returnFocus = getOption(options, "returnFocus", "returnFocusOnDeactivate"); if (onDeactivate) { onDeactivate(); } var finishDeactivation = function finishDeactivation2() { delay(function() { if (returnFocus) { tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)); } if (onPostDeactivate) { onPostDeactivate(); } }); }; if (returnFocus && checkCanReturnFocus) { checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation); return this; } finishDeactivation(); return this; }, pause: function pause() { if (state.paused || !state.active) { return this; } state.paused = true; removeListeners(); return this; }, unpause: function unpause() { if (!state.paused || !state.active) { return this; } state.paused = false; updateTabbableNodes(); addListeners(); return this; }, updateContainerElements: function updateContainerElements(containerElements) { var elementsAsArray = [].concat(containerElements).filter(Boolean); state.containers = elementsAsArray.map(function(element) { return typeof element === "string" ? doc.querySelector(element) : element; }); if (state.active) { updateTabbableNodes(); } return this; } }; trap.updateContainerElements(elements); return trap; }; // node_modules/@arcgis/core/identity/IdentityModal.js var l4 = { base: "esri-identity-modal", open: "esri-identity-modal--open", closed: "esri-identity-modal--closed", title: "esri-identity-modal__title", dialog: "esri-identity-modal__dialog", content: "esri-identity-modal__content", closeButton: "esri-identity-modal__close-button", iconClose: "esri-icon-close" }; var p3 = class extends O { constructor(t3, e5) { super(t3, e5), this.container = document.createElement("div"), this.content = null, this.open = false, this._close = () => { this.open = false; }, document.body.appendChild(this.container), this.own(l2(() => this.open, () => this._toggleFocusTrap())); } destroy() { this._destroyFocusTrap(); } render() { const t3 = this.id, { open: e5, content: o2, title: s6, messages: i3 } = this, r4 = e5 && !!o2, n6 = { [l4.open]: r4, [l4.closed]: !r4 }, a2 = n4("button", { class: l4.closeButton, "aria-label": i3.close, title: i3.close, bind: this, onclick: this._close, type: "button" }, n4("span", { "aria-hidden": "true", class: l4.iconClose })), c = `${t3}_title`, p5 = `${t3}_content`, u2 = s6 ? n4("h1", { id: c, class: l4.title }, s6) : null, m = r4 ? n4("div", { bind: this, class: l4.dialog, role: "dialog", "aria-labelledby": c, "aria-describedby": p5, afterCreate: this._createFocusTrap }, a2, u2, this._renderContent(p5)) : null; return n4("div", { tabIndex: -1, class: this.classes(l4.base, n6) }, m); } _destroyFocusTrap() { this._focusTrap?.deactivate({ onDeactivate: null }), this._focusTrap = null; } _toggleFocusTrap() { const { _focusTrap: t3, open: e5 } = this; t3 && (e5 ? t3.activate() : t3.deactivate()); } _createFocusTrap(t3) { this._destroyFocusTrap(); const o2 = requestAnimationFrame(() => { this._focusTrap = createFocusTrap(t3, { initialFocus: "input", onDeactivate: this._close }), this._toggleFocusTrap(); }); this.own(n(() => cancelAnimationFrame(o2))); } _renderContent(t3) { const e5 = this.content; return typeof e5 == "string" ? n4("div", { class: l4.content, id: t3, innerHTML: e5 }) : e3(e5) ? n4("div", { class: l4.content, id: t3 }, e5.render()) : e5 instanceof HTMLElement ? n4("div", { class: l4.content, id: t3, bind: e5, afterCreate: this._attachToNode }) : null; } _attachToNode(t3) { const e5 = this; t3.appendChild(e5); } }; e([d({ readOnly: true })], p3.prototype, "container", void 0), e([d()], p3.prototype, "content", void 0), e([d()], p3.prototype, "open", void 0), e([d(), e2("esri/t9n/common")], p3.prototype, "messages", void 0), e([d({ aliasOf: "messages.auth.signIn" })], p3.prototype, "title", void 0), p3 = e([n2("esri.identity.IdentityModal")], p3); var u = p3; // node_modules/@arcgis/core/identity/OAuthCredential.js var t2 = "esriJSAPIOAuth"; var e4 = class { constructor(t3, e5) { this.oAuthInfo = null, this.storage = null, this.appId = null, this.codeVerifier = null, this.expires = null, this.refreshToken = null, this.ssl = null, this.stateUID = null, this.token = null, this.userId = null, this.oAuthInfo = t3, this.storage = e5, this._init(); } isValid() { let t3 = false; if (this.oAuthInfo && this.userId && (this.refreshToken || this.token)) if (this.expires == null && this.refreshToken) t3 = true; else { const e5 = Date.now(); if (this.expires > e5) { (this.expires - e5) / 1e3 > 60 * this.oAuthInfo.minTimeUntilExpiration && (t3 = true); } } return t3; } save() { if (!this.storage) return false; const e5 = this._load(), s6 = this.oAuthInfo; if (s6 && s6.authNamespace && s6.portalUrl) { let r4 = e5[s6.authNamespace]; r4 || (r4 = e5[s6.authNamespace] = {}), this.appId || (this.appId = s6.appId), r4[s6.portalUrl] = { appId: this.appId, codeVerifier: this.codeVerifier, expires: this.expires, refreshToken: this.refreshToken, ssl: this.ssl, stateUID: this.stateUID, token: this.token, userId: this.userId }; try { this.storage.setItem(t2, JSON.stringify(e5)); } catch (i3) { return console.warn(i3), false; } return true; } return false; } destroy() { const e5 = this._load(), s6 = this.oAuthInfo; if (s6 && s6.appId && s6.portalUrl && (this.expires == null || this.expires > Date.now()) && (this.refreshToken || this.token)) { const t3 = s6.portalUrl.replace(/^http:/i, "https:") + "/sharing/rest/oauth2/revokeToken", e6 = new FormData(); if (e6.append("f", "json"), e6.append("auth_token", this.refreshToken || this.token), e6.append("client_id", s6.appId), e6.append("token_type_hint", this.refreshToken ? "refresh_token" : "access_token"), typeof navigator.sendBeacon == "function") navigator.sendBeacon(t3, e6); else { const s7 = new XMLHttpRequest(); s7.open("POST", t3), s7.send(e6); } } if (s6 && s6.authNamespace && s6.portalUrl && this.storage) { const r4 = e5[s6.authNamespace]; if (r4) { delete r4[s6.portalUrl]; try { this.storage.setItem(t2, JSON.stringify(e5)); } catch (i3) { console.log(i3); } } } s6 && (s6._oAuthCred = null, this.oAuthInfo = null); } _init() { const t3 = this._load(), e5 = this.oAuthInfo; if (e5 && e5.authNamespace && e5.portalUrl) { let s6 = t3[e5.authNamespace]; s6 && (s6 = s6[e5.portalUrl], s6 && (this.appId = s6.appId, this.codeVerifier = s6.codeVerifier, this.expires = s6.expires, this.refreshToken = s6.refreshToken, this.ssl = s6.ssl, this.stateUID = s6.stateUID, this.token = s6.token, this.userId = s6.userId)); } } _load() { let e5 = {}; if (this.storage) { const i3 = this.storage.getItem(t2); if (i3) try { e5 = JSON.parse(i3); } catch (s6) { console.warn(s6); } } return e5; } }; e4.prototype.declaredClass = "esri.identity.OAuthCredential"; // node_modules/@arcgis/core/identity/OAuthInfo.js var p4; var s3 = p4 = class extends l { constructor(o2) { super(o2), this._oAuthCred = null, this.appId = null, this.authNamespace = "/", this.expiration = 20160, this.flowType = "auto", this.forceLogin = false, this.forceUserId = false, this.locale = null, this.minTimeUntilExpiration = 30, this.popup = false, this.popupCallbackUrl = "oauth-callback.html", this.popupWindowFeatures = "height=490,width=800,resizable,scrollbars,status", this.portalUrl = "https://www.arcgis.com", this.preserveUrlHash = false, this.userId = null; } clone() { return p4.fromJSON(this.toJSON()); } }; e([d({ json: { write: true } })], s3.prototype, "appId", void 0), e([d({ json: { write: true } })], s3.prototype, "authNamespace", void 0), e([d({ json: { write: true } })], s3.prototype, "expiration", void 0), e([d({ json: { write: true } })], s3.prototype, "flowType", void 0), e([d({ json: { write: true } })], s3.prototype, "forceLogin", void 0), e([d({ json: { write: true } })], s3.prototype, "forceUserId", void 0), e([d({ json: { write: true } })], s3.prototype, "locale", void 0), e([d({ json: { write: true } })], s3.prototype, "minTimeUntilExpiration", void 0), e([d({ json: { write: true } })], s3.prototype, "popup", void 0), e([d({ json: { write: true } })], s3.prototype, "popupCallbackUrl", void 0), e([d({ json: { write: true } })], s3.prototype, "popupWindowFeatures", void 0), e([d({ json: { write: true } })], s3.prototype, "portalUrl", void 0), e([d({ json: { write: true } })], s3.prototype, "preserveUrlHash", void 0), e([d({ json: { write: true } })], s3.prototype, "userId", void 0), s3 = p4 = e([n2("esri.identity.OAuthInfo")], s3); var i = s3; // node_modules/@arcgis/core/identity/ServerInfo.js var s4 = class extends l { constructor(o2) { super(o2), this.adminTokenServiceUrl = null, this.currentVersion = null, this.hasPortal = null, this.hasServer = null, this.owningSystemUrl = null, this.owningTenant = null, this.server = null, this.shortLivedTokenValidity = null, this.tokenServiceUrl = null, this.webTierAuth = null; } }; e([d({ json: { write: true } })], s4.prototype, "adminTokenServiceUrl", void 0), e([d({ json: { write: true } })], s4.prototype, "currentVersion", void 0), e([d({ json: { write: true } })], s4.prototype, "hasPortal", void 0), e([d({ json: { write: true } })], s4.prototype, "hasServer", void 0), e([d({ json: { write: true } })], s4.prototype, "owningSystemUrl", void 0), e([d({ json: { write: true } })], s4.prototype, "owningTenant", void 0), e([d({ json: { write: true } })], s4.prototype, "server", void 0), e([d({ json: { write: true } })], s4.prototype, "shortLivedTokenValidity", void 0), e([d({ json: { write: true } })], s4.prototype, "tokenServiceUrl", void 0), e([d({ json: { write: true } })], s4.prototype, "webTierAuth", void 0), s4 = e([n2("esri.identity.ServerInfo")], s4); var i2 = s4; // node_modules/@arcgis/core/identity/IdentityManagerBase.js var R = {}; var C = (e5) => { const t3 = new y2(e5.owningSystemUrl).host, r4 = new y2(e5.server).host, s6 = /.+\.arcgis\.com$/i; return s6.test(t3) && s6.test(r4); }; var b = (e5, t3) => !!(C(e5) && t3 && t3.some((t4) => t4.test(e5.server))); var D2 = null; var q = null; try { D2 = window.localStorage, q = window.sessionStorage; } catch { } var j2 = class extends n3 { constructor() { super(), this._portalConfig = globalThis.esriGeowConfig, this.serverInfos = [], this.oAuthInfos = [], this.credentials = [], this._soReqs = [], this._xoReqs = [], this._portals = [], this.defaultOAuthInfo = null, this.defaultTokenValidity = 60, this.dialog = null, this.formConstructor = d2, this.tokenValidity = null, this.normalizeWebTierAuth = false, this._appOrigin = window.origin !== "null" ? window.origin : window.location.origin, this._appUrlObj = j(window.location.href), this._busy = null, this._rejectOnPersistedPageShow = false, this._oAuthLocationParams = null, this._gwTokenUrl = "/sharing/rest/generateToken", this._agsRest = "/rest/services", this._agsPortal = /\/sharing(\/|$)/i, this._agsAdmin = /(https?:\/\/[^\/]+\/[^\/]+)\/admin\/?(\/.*)?$/i, this._adminSvcs = /\/rest\/admin\/services(\/|$)/i, this._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" }], this._legacyFed = [], this._regexSDirUrl = /http.+\/rest\/services\/?/gi, this._regexServerType = /(\/(FeatureServer|GPServer|GeoDataServer|GeocodeServer|GeoenrichmentServer|GeometryServer|GlobeServer|ImageServer|KnowledgeGraphServer|MapServer|MobileServer|NAServer|NetworkDiagramServer|OGCFeatureServer|ParcelFabricServer|RelationalCatalogServer|SceneServer|StreamServer|UtilityNetworkServer|ValidationServer|VectorTileServer|VersionManagementServer)).*/gi, this._gwUser = /http.+\/users\/([^\/]+)\/?.*/i, this._gwItem = /http.+\/items\/([^\/]+)\/?.*/i, this._gwGroup = /http.+\/groups\/([^\/]+)\/?.*/i, this._rePortalTokenSvc = /\/sharing(\/rest)?\/generatetoken/i, this._createDefaultOAuthInfo = true, this._hasTestedIfAppIsOnPortal = false, this._getOAuthLocationParams(), window.addEventListener("pageshow", (e5) => { this._pageShowHandler(e5); }); } registerServers(e5) { const t3 = this.serverInfos; t3 ? (e5 = e5.filter((e6) => !this.findServerInfo(e6.server)), this.serverInfos = t3.concat(e5)) : this.serverInfos = e5, e5.forEach((e6) => { e6.owningSystemUrl && this._portals.push(e6.owningSystemUrl), e6.hasPortal && this._portals.push(e6.server); }); } registerOAuthInfos(e5) { const t3 = this.oAuthInfos; if (t3) { for (const r4 of e5) { const e6 = this.findOAuthInfo(r4.portalUrl); e6 && t3.splice(t3.indexOf(e6), 1); } this.oAuthInfos = t3.concat(e5); } else this.oAuthInfos = e5; } registerToken(e5) { e5 = { ...e5 }; const t3 = this._sanitizeUrl(e5.server), r4 = this._isServerRsrc(t3); let s6, i3 = this.findServerInfo(t3), o2 = true; i3 || (i3 = new i2(), i3.server = this._getServerInstanceRoot(t3), r4 ? i3.hasServer = true : (i3.tokenServiceUrl = this._getTokenSvcUrl(t3), i3.hasPortal = true), this.registerServers([i3])), s6 = this._findCredential(t3), s6 ? (delete e5.server, Object.assign(s6, e5), o2 = false) : (s6 = new E({ userId: e5.userId, server: i3.server, token: e5.token, expires: e5.expires, ssl: e5.ssl, scope: r4 ? "server" : "portal" }), s6.resources = [t3], this.credentials.push(s6)), s6.emitTokenChange(false), o2 || s6.refreshServerTokens(); } toJSON() { return y({ serverInfos: this.serverInfos.map((e5) => e5.toJSON()), oAuthInfos: this.oAuthInfos.map((e5) => e5.toJSON()), credentials: this.credentials.map((e5) => e5.toJSON()) }); } initialize(e5) { if (!e5) return; typeof e5 == "string" && (e5 = JSON.parse(e5)); const t3 = e5.serverInfos, r4 = e5.oAuthInfos, s6 = e5.credentials; if (t3) { const e6 = []; t3.forEach((t4) => { t4.server && t4.tokenServiceUrl && e6.push(t4.declaredClass ? t4 : new i2(t4)); }), e6.length && this.registerServers(e6); } if (r4) { const e6 = []; r4.forEach((t4) => { t4.appId && e6.push(t4.declaredClass ? t4 : new i(t4)); }), e6.length && this.registerOAuthInfos(e6); } s6 && s6.forEach((e6) => { e6.server && e6.token && e6.expires && e6.expires > Date.now() && ((e6 = e6.declaredClass ? e6 : new E(e6)).emitTokenChange(), this.credentials.push(e6)); }); } findServerInfo(e5) { let t3; e5 = this._sanitizeUrl(e5); for (const r4 of this.serverInfos) if (this._hasSameServerInstance(r4.server, e5)) { t3 = r4; break; } return t3; } findOAuthInfo(e5) { let t3; e5 = this._sanitizeUrl(e5); for (const r4 of this.oAuthInfos) if (this._hasSameServerInstance(r4.portalUrl, e5)) { t3 = r4; break; } return t3; } findCredential(e5, t3) { let r4; e5 = this._sanitizeUrl(e5); const s6 = this._isServerRsrc(e5) ? "server" : "portal"; if (t3) { for (const i3 of this.credentials) if (this._hasSameServerInstance(i3.server, e5) && t3 === i3.userId && i3.scope === s6) { r4 = i3; break; } } else for (const i3 of this.credentials) if (this._hasSameServerInstance(i3.server, e5) && this._getIdenticalSvcIdx(e5, i3) !== -1 && i3.scope === s6) { r4 = i3; break; } return r4; } getCredential(e5, t3) { let r4, s6, o2 = true; t3 && (r4 = !!t3.token, s6 = t3.error, o2 = t3.prompt !== false), t3 = { ...t3 }, e5 = this._sanitizeUrl(e5); const n6 = new AbortController(), a2 = D(); if (t3.signal && v(t3.signal, () => { n6.abort(); }), v(n6, () => { a2.reject(new s("identity-manager:user-aborted", "ABORTED")); }), p(n6)) return a2.promise; t3.signal = n6.signal; const h = this._isAdminResource(e5), u2 = r4 ? this.findCredential(e5) : null; let p5; if (u2 && s6 && s6.details && s6.details.httpStatus === 498) u2.destroy(); else if (u2) return p5 = new s("identity-manager:not-authorized", "You are currently signed in as: '" + u2.userId + "'. You do not have access to this resource: " + e5, { error: s6 }), a2.reject(p5), a2.promise; const _ = this._findCredential(e5, t3); if (_) return a2.resolve(_), a2.promise; let f = this.findServerInfo(e5); if (f) !f.hasServer && this._isServerRsrc(e5) && (f._restInfoPms = this._getTokenSvcUrl(e5), f.hasServer = true); else { const t4 = this._getTokenSvcUrl(e5); if (!t4) return p5 = new s("identity-manager:unknown-resource", "Unknown resource - could not find token service endpoint."), a2.reject(p5), a2.promise; f = new i2(), f.server = this._getServerInstanceRoot(e5), typeof t4 == "string" ? (f.tokenServiceUrl = t4, f.hasPortal = true) : (f._restInfoPms = t4, f.hasServer = true), this.registerServers([f]); } return f.hasPortal && f._selfReq === void 0 && (o2 || z(f.tokenServiceUrl, this._appOrigin) || this._gwDomains.some((e6) => e6.tokenServiceUrl === f.tokenServiceUrl)) && (f._selfReq = { owningTenant: t3 && t3.owningTenant, selfDfd: this._getPortalSelf(f.tokenServiceUrl.replace(this._rePortalTokenSvc, "/sharing/rest/portals/self"), e5) }), this._enqueue(e5, f, t3, a2, h); } getResourceName(e5) { return this._isRESTService(e5) ? e5.replace(this._regexSDirUrl, "").replace(this._regexServerType, "") || "" : this._gwUser.test(e5) && e5.replace(this._gwUser, "$1") || this._gwItem.test(e5) && e5.replace(this._gwItem, "$1") || this._gwGroup.test(e5) && e5.replace(this._gwGroup, "$1") || ""; } generateToken(e5, t3, r4) { const o2 = this._rePortalTokenSvc.test(e5.tokenServiceUrl), n6 = new y2(this._appOrigin), a2 = e5.shortLivedTokenValidity; let h, l5, c, d3, u2, _, f, m; t3 && (m = this.tokenValidity || a2 || this.defaultTokenValidity, m > a2 && a2 > 0 && (m = a2)), r4 && (h = r4.isAdmin, l5 = r4.serverUrl, c = r4.token, _ = r4.signal, f = r4.ssl, e5.customParameters = r4.customParameters), h ? d3 = e5.adminTokenServiceUrl : (d3 = e5.tokenServiceUrl, u2 = new y2(d3.toLowerCase()), e5.webTierAuth && r4?.serverUrl && !f && n6.scheme === "http" && (z(n6.uri, d3, true) || u2.scheme === "https" && n6.host === u2.host && n6.port === "7080" && u2.port === "7443") && (d3 = d3.replace(/^https:/i, "http:").replace(/:7443/i, ":7080"))); const v4 = { query: { request: "getToken", username: t3?.username, password: t3?.password, serverUrl: l5, token: c, expiration: m, referer: h || o2 ? this._appOrigin : null, client: h ? "referer" : null, f: "json", ...e5.customParameters }, method: "post", authMode: "anonymous", useProxy: this._useProxy(e5, r4), signal: _, ...r4?.ioArgs }; o2 || (v4.withCredentials = false); return U(d3, v4).then((r5) => { const s6 = r5.data; if (!s6 || !s6.token) return new s("identity-manager:authentication-failed", "Unable to generate token"); const o3 = e5.server; return R[o3] || (R[o3] = {}), t3 && (R[o3][t3.username] = t3.password), s6.validity = m, s6; }); } isBusy() { return !!this._busy; } checkSignInStatus(e5) { return this.checkAppAccess(e5, "").then((e6) => e6.credential); } checkAppAccess(e5, t3, r4) { let o2 = false; return this.getCredential(e5, { prompt: false }).then((n6) => { let a2; const h = { f: "json" }; if (n6.scope === "portal") if (t3 && (this._doPortalSignIn(e5) || r4 && r4.force)) a2 = n6.server + "/sharing/rest/oauth2/validateAppAccess", h.client_id = t3; else { if (!n6.token) return { credential: n6 }; a2 = n6.server + "/sharing/rest"; } else { if (!n6.token) return { credential: n6 }; a2 = n6.server + "/rest/services"; } return n6.token && (h.token = n6.token), U(a2, { query: h, authMode: "anonymous" }).then((e6) => { if (e6.data.valid === false) throw new s("identity-manager:not-authorized", `You are currently signed in as: '${n6.userId}'.`, e6.data); return o2 = !!e6.data.viewOnlyUserTypeApp, { credential: n6 }; }).catch((e6) => { if (e6.name === "identity-manager:not-authorized") throw e6; const t4 = e6.details && e6.details.httpStatus; if (t4 === 498) throw n6.destroy(), new s("identity-manager:not-authenticated", "User is not signed in."); if (t4 === 400) throw new s("identity-manager:invalid-request"); return { credential: n6 }; }); }).then((e6) => ({ credential: e6.credential, viewOnly: o2 })); } setOAuthResponseHash(e5) { e5 && (e5.charAt(0) === "#" && (e5 = e5.substring(1)), this._processOAuthPopupParams(v2(e5))); } setOAuthRedirectionHandler(e5) { this._oAuthRedirectFunc = e5; } setProtocolErrorHandler(e5) { this._protocolFunc = e5; } signIn(e5, t3, r4 = {}) { const s6 = D(), o2 = () => { h?.remove(), d3?.remove(), p5?.remove(), a2?.destroy(), this.dialog?.destroy(), this.dialog = a2 = h = d3 = p5 = null; }, n6 = () => { o2(), this._oAuthDfd = null, s6.reject(new s("identity-manager:user-aborted", "ABORTED")); }; r4.signal && v(r4.signal, () => { n6(); }); let a2 = new this.formConstructor(); a2.resource = this.getResourceName(e5), a2.server = t3.server, this.dialog = new u(), this.dialog.content = a2, this.dialog.open = true, this.emit("dialog-create"); let h = a2.on("cancel", n6), d3 = l2(() => this.dialog.open, n6), p5 = a2.on("submit", (e6) => { this.generateToken(t3, e6, { isAdmin: r4.isAdmin, signal: r4.signal }).then((i3) => { o2(); const n7 = new E({ userId: e6.username, server: t3.server, token: i3.token, expires: i3.expires != null ? Number(i3.expires) : null, ssl: !!i3.ssl, isAdmin: r4.isAdmin, validity: i3.validity }); s6.resolve(n7); }).catch((e7) => { a2.error = e7, a2.signingIn = false; }); }); return s6.promise; } oAuthSignIn(e5, t3, r4, s6) { this._oAuthDfd = D(); const o2 = this._oAuthDfd; let n6; s6?.signal && v(s6.signal, () => { const e6 = this._oAuthDfd && this._oAuthDfd.oAuthWin_; e6 && !e6.closed ? e6.close() : this.dialog && g(); }), o2.resUrl_ = e5, o2.sinfo_ = t3, o2.oinfo_ = r4; const a2 = r4._oAuthCred; if (a2.storage && (r4.flowType === "authorization-code" || r4.flowType === "auto" && !r4.popup && t3.currentVersion >= 8.4)) { let e6 = crypto.getRandomValues(new Uint8Array(32)); n6 = Z(e6), a2.codeVerifier = n6, e6 = crypto.getRandomValues(new Uint8Array(32)), a2.stateUID = Z(e6), a2.save() || (a2.codeVerifier = n6 = null); } else a2.codeVerifier = null; let h, d3, p5, _; this._getCodeChallenge(n6).then((i3) => { const o3 = !s6 || s6.oAuthPopupConfirmation !== false; r4.popup && o3 ? (h = new this.formConstructor(), h.oAuthPrompt = true, h.server = t3.server, this.dialog = new u(), this.dialog.content = h, this.dialog.open = true, this.emit("dialog-create"), d3 = h.on("cancel", g), p5 = l2(() => this.dialog.open, g), _ = h.on("submit", () => { f(), this._doOAuthSignIn(e5, t3, r4, i3); })) : this._doOAuthSignIn(e5, t3, r4, i3); }); const g = () => { f(), this._oAuthDfd = null, o2.reject(new s("identity-manager:user-aborted", "ABORTED")); }, f = () => { d3?.remove(), p5?.remove(), _?.remove(), h?.destroy(), this.dialog?.destroy(), this.dialog = null; }; return o2.promise; } destroyCredentials() { if (this.credentials) { this.credentials.slice().forEach((e5) => { e5.destroy(); }); } this.emit("credentials-destroy"); } enablePostMessageAuth(e5 = "https://www.arcgis.com/sharing/rest") { this._postMessageAuthHandle && this._postMessageAuthHandle.remove(), this._postMessageAuthHandle = r2(window, "message", (t3) => { if ((t3.origin === this._appOrigin || t3.origin.endsWith(".arcgis.com")) && t3.data?.type === "arcgis:auth:requestCredential") { const r4 = t3.source; this.getCredential(e5).then((e6) => { r4.postMessage({ type: "arcgis:auth:credential", credential: { expires: e6.expires, server: e6.server, ssl: e6.ssl, token: e6.token, userId: e6.userId } }, t3.origin); }).catch((e6) => { r4.postMessage({ type: "arcgis:auth:error", error: { name: e6.name, message: e6.message } }, t3.origin); }); } }); } disablePostMessageAuth() { this._postMessageAuthHandle && (this._postMessageAuthHandle.remove(), this._postMessageAuthHandle = null); } _getOAuthLocationParams() { let e5 = window.location.hash; if (e5) { e5.charAt(0) === "#" && (e5 = e5.substring(1)); const t4 = v2(e5); let r4 = false; if (t4.access_token && t4.expires_in && t4.state && t4.hasOwnProperty("username")) try { t4.state = JSON.parse(t4.state), t4.state.portalUrl && (this._oAuthLocationParams = t4, r4 = true); } catch { } else if (t4.error && t4.error_description && (console.log("IdentityManager OAuth Error: ", t4.error, " - ", t4.error_description), t4.error === "access_denied" && (r4 = true, t4.state))) try { t4.state = JSON.parse(t4.state); } catch { } r4 && (window.location.hash = t4.state?.hash || ""); } let t3 = window.location.search; if (t3) { t3.charAt(0) === "?" && (t3 = t3.substring(1)); const e6 = v2(t3); let r4 = false; if (e6.code && e6.state) try { e6.state = JSON.parse(e6.state), e6.state.portalUrl && e6.state.uid && (this._oAuthLocationParams = e6, r4 = true); } catch { } else if (e6.error && e6.error_description && (console.log("IdentityManager OAuth Error: ", e6.error, " - ", e6.error_description), e6.error === "access_denied" && (r4 = true, e6.state))) try { e6.state = JSON.parse(e6.state); } catch { } if (r4) { const t4 = { ...e6 }; ["code", "error", "error_description", "message_code", "persist", "state"].forEach((e7) => { delete t4[e7]; }); const r5 = I(t4), s6 = window.location.pathname + (r5 ? `?${r5}` : "") + (e6.state?.hash || ""); window.history.replaceState(window.history.state, "", s6); } } } _getOAuthToken(e5, t3, r4, i3, o2) { return e5 = e5.replace(/^http:/i, "https:"), U(`${e5}/sharing/rest/oauth2/token`, { authMode: "anonymous", method: "post", query: i3 && o2 ? { grant_type: "authorization_code", code: t3, redirect_uri: i3, client_id: r4, code_verifier: o2 } : { grant_type: "refresh_token", refresh_token: t3, client_id: r4 } }).then((e6) => e6.data); } _getCodeChallenge(e5) { if (e5 && globalThis.isSecureContext) { const t3 = new TextEncoder().encode(e5); return crypto.subtle.digest("SHA-256", t3).then((e6) => Z(new Uint8Array(e6))); } return Promise.resolve(null); } _pageShowHandler(e5) { if (e5.persisted && this.isBusy() && this._rejectOnPersistedPageShow) { const e6 = new s("identity-manager:user-aborted", "ABORTED"); this._errbackFunc(e6); } } _findCredential(e5, t3) { let r4, s6, i3, o2, n6 = -1; const a2 = t3 && t3.token, h = t3 && t3.resource, l5 = this._isServerRsrc(e5) ? "server" : "portal", c = this.credentials.filter((t4) => this._hasSameServerInstance(t4.server, e5) && t4.scope === l5); if (e5 = h || e5, c.length) if (c.length === 1) { if (r4 = c[0], o2 = this.findServerInfo(r4.server), s6 = o2 && o2.owningSystemUrl, i3 = s6 && this.findCredential(s6, r4.userId), n6 = this._getIdenticalSvcIdx(e5, r4), !a2) return n6 === -1 && r4.resources.push(e5), this._addResource(e5, i3), r4; n6 !== -1 && (r4.resources.splice(n6, 1), this._removeResource(e5, i3)); } else { let t4, r5; if (c.some((a3) => (r5 = this._getIdenticalSvcIdx(e5, a3), r5 !== -1 && (t4 = a3, o2 = this.findServerInfo(t4.server), s6 = o2 && o2.owningSystemUrl, i3 = s6 && this.findCredential(s6, t4.userId), n6 = r5, true))), a2) t4 && (t4.resources.splice(n6, 1), this._removeResource(e5, i3)); else if (t4) return this._addResource(e5, i3), t4; } } _findOAuthInfo(e5) { let t3 = this.findOAuthInfo(e5); if (!t3) { for (const r4 of this.oAuthInfos) if (this._isIdProvider(r4.portalUrl, e5)) { t3 = r4; break; } } return t3; } _addResource(e5, t3) { t3 && this._getIdenticalSvcIdx(e5, t3) === -1 && t3.resources.push(e5); } _removeResource(e5, t3) { let r4 = -1; t3 && (r4 = this._getIdenticalSvcIdx(e5, t3), r4 > -1 && t3.resources.splice(r4, 1)); } _useProxy(e5, t3) { return t3 && t3.isAdmin && !z(e5.adminTokenServiceUrl, this._appOrigin) || !this._isPortalDomain(e5.tokenServiceUrl) && String(e5.currentVersion) === "10.1" && !z(e5.tokenServiceUrl, this._appOrigin); } _getOrigin(e5) { const t3 = new y2(e5); return t3.scheme + "://" + t3.host + (t3.port != null ? ":" + t3.port : ""); } _getServerInstanceRoot(e5) { const t3 = e5.toLowerCase(); let r4 = t3.indexOf(this._agsRest); return r4 === -1 && this._isAdminResource(e5) && (r4 = this._agsAdmin.test(e5) ? e5.replace(this._agsAdmin, "$1").length : e5.search(this._adminSvcs)), r4 === -1 && (r4 = t3.indexOf("/sharing")), r4 === -1 && t3.substr(-1) === "/" && (r4 = t3.length - 1), r4 > -1 ? e5.substring(0, r4) : e5; } _hasSameServerInstance(e5, t3) { return e5.substr(-1) === "/" && (e5 = e5.slice(0, -1)), e5 = e5.toLowerCase(), t3 = this._getServerInstanceRoot(t3).toLowerCase(), e5 = this._normalizeAGOLorgDomain(e5), t3 = this._normalizeAGOLorgDomain(t3), (e5 = e5.substr(e5.indexOf(":"))) === (t3 = t3.substr(t3.indexOf(":"))); } _normalizeAGOLorgDomain(e5) { const t3 = /^https?:\/\/(?:cdn|[a-z\d-]+\.maps)\.arcgis\.com/i, r4 = /^https?:\/\/(?:cdndev|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i, s6 = /^https?:\/\/(?:cdnqa|[a-z\d-]+\.mapsqa)\.arcgis\.com/i; return t3.test(e5) ? e5 = e5.replace(t3, "https://www.arcgis.com") : r4.test(e5) ? e5 = e5.replace(r4, "https://devext.arcgis.com") : s6.test(e5) && (e5 = e5.replace(s6, "https://qaext.arcgis.com")), e5; } _sanitizeUrl(e5) { const r4 = (r.request.proxyUrl || "").toLowerCase(), s6 = r4 ? e5.toLowerCase().indexOf(r4 + "?") : -1; return s6 !== -1 && (e5 = e5.substring(s6 + r4.length + 1)), e5 = F(e5), j(e5).path; } _isRESTService(e5) { return e5.includes(this._agsRest); } _isAdminResource(e5) { return this._agsAdmin.test(e5) || this._adminSvcs.test(e5); } _isServerRsrc(e5) { return this._isRESTService(e5) || this._isAdminResource(e5); } _isIdenticalService(e5, t3) { let r4; if (this._isRESTService(e5) && this._isRESTService(t3)) { const s6 = this._getSuffix(e5).toLowerCase(), i3 = this._getSuffix(t3).toLowerCase(); if (r4 = s6 === i3, !r4) { const e6 = /(.*)\/(MapServer|FeatureServer|UtilityNetworkServer).*/gi; r4 = s6.replace(e6, "$1") === i3.replace(e6, "$1"); } } else this._isAdminResource(e5) && this._isAdminResource(t3) ? r4 = true : this._isServerRsrc(e5) || this._isServerRsrc(t3) || !this._isPortalDomain(e5) || (r4 = true); return r4; } _isPortalDomain(e5) { const r4 = new y2(e5.toLowerCase()), s6 = this._portalConfig; let i3 = this._gwDomains.some((e6) => e6.regex.test(r4.uri)); return !i3 && s6 && (i3 = this._hasSameServerInstance(this._getServerInstanceRoot(s6.restBaseUrl), r4.uri)), i3 || r.portalUrl && (i3 = z(r4, r.portalUrl, true)), i3 || (i3 = this._portals.some((e6) => this._hasSameServerInstance(e6, r4.uri))), i3 = i3 || this._agsPortal.test(r4.path), i3; } _isIdProvider(e5, t3) { let r4 = -1, s6 = -1; this._gwDomains.forEach((i4, o2) => { r4 === -1 && i4.regex.test(e5) && (r4 = o2), s6 === -1 && i4.regex.test(t3) && (s6 = o2); }); let i3 = false; if (r4 > -1 && s6 > -1 && (r4 === 0 || r4 === 4 ? s6 !== 0 && s6 !== 4 || (i3 = true) : r4 === 1 ? s6 !== 1 && s6 !== 2 || (i3 = true) : r4 === 2 ? s6 === 2 && (i3 = true) : r4 === 3 && s6 === 3 && (i3 = true)), !i3) { const r5 = this.findServerInfo(t3), s7 = r5 && r5.owningSystemUrl; s7 && C(r5) && this._isPortalDomain(s7) && this._isIdProvider(e5, s7) && (i3 = true); } return i3; } _getIdenticalSvcIdx(e5, t3) { let r4 = -1; for (let s6 = 0; s6 < t3.resources.length; s6++) { const i3 = t3.resources[s6]; if (this._isIdenticalService(e5, i3)) { r4 = s6; break; } } return r4; } _getSuffix(e5) { return e5.replace(this._regexSDirUrl, "").replace(this._regexServerType, "$1"); } _getTokenSvcUrl(e5) { let t3, r4, i3; if (this._isRESTService(e5) || this._isAdminResource(e5)) { const i4 = this._getServerInstanceRoot(e5); return t3 = i4 + "/admin/generateToken", r4 = U(e5 = i4 + "/rest/info", { query: { f: "json" } }).then((e6) => e6.data), { adminUrl: t3, promise: r4 }; } if (this._isPortalDomain(e5)) { let t4 = ""; if (this._gwDomains.some((r5) => (r5.regex.test(e5) && (t4 = r5.tokenServiceUrl), !!t4)), t4 || this._portals.some((r5) => (this._hasSameServerInstance(r5, e5) && (t4 = r5 + this._gwTokenUrl), !!t4)), t4 || (i3 = e5.toLowerCase().indexOf("/sharing"), i3 !== -1 && (t4 = e5.substring(0, i3) + this._gwTokenUrl)), t4 || (t4 = this._getOrigin(e5) + this._gwTokenUrl), t4) { const r5 = new y2(e5).port; /^http:\/\//i.test(e5) && r5 === "7080" && (t4 = t4.replace(/:7080/i, ":7443")), t4 = t4.replace(/http:/i, "https:"); } return t4; } if (e5.toLowerCase().includes("premium.arcgisonline.com")) return "https://premium.arcgisonline.com/server/tokens"; } _processOAuthResponseParams(e5, t3, r4) { const s6 = t3._oAuthCred; if (e5.code) { const i4 = s6.codeVerifier; return s6.codeVerifier = null, s6.stateUID = null, s6.save(), this._getOAuthToken(r4.server, e5.code, t3.appId, this._getRedirectURI(t3, true), i4).then((i5) => { const o2 = new E({ userId: i5.username, server: r4.server, token: i5.access_token, expires: Date.now() + 1e3 * i5.expires_in, ssl: i5.ssl, oAuthState: e5.state, _oAuthCred: s6 }); return t3.userId = o2.userId, s6.storage = i5.persist ? D2 : q, s6.refreshToken = i5.refresh_token, s6.token = null, s6.expires = i5.refresh_token_expires_in ? Date.now() + 1e3 * i5.refresh_token_expires_in : null, s6.userId = o2.userId, s6.ssl = o2.ssl, s6.save(), o2; }); } const i3 = new E({ userId: e5.username, server: r4.server, token: e5.access_token, expires: Date.now() + 1e3 * Number(e5.expires_in), ssl: e5.ssl === "true", oAuthState: e5.state, _oAuthCred: s6 }); return t3.userId = i3.userId, s6.storage = e5.persist ? D2 : q, s6.refreshToken = null, s6.token = i3.token, s6.expires = i3.expires, s6.userId = i3.userId, s6.ssl = i3.ssl, s6.save(), Promise.resolve(i3); } _processOAuthPopupParams(e5) { const t3 = this._oAuthDfd; if (this._oAuthDfd = null, t3) if (clearInterval(this._oAuthIntervalId), this._oAuthOnPopupHandle?.remove(), e5.error) { const r4 = e5.error === "access_denied", s6 = new s(r4 ? "identity-manager:user-aborted" : "identity-manager:authentication-failed", r4 ? "ABORTED" : "OAuth: " + e5.error + " - " + e5.error_description); t3.reject(s6); } else this._processOAuthResponseParams(e5, t3.oinfo_, t3.sinfo_).then((e6) => { t3.resolve(e6); }).catch((e6) => { t3.reject(e6); }); } _setOAuthResponseQueryString(e5) { e5 && (e5.charAt(0) === "?" && (e5 = e5.substring(1)), this._processOAuthPopupParams(v2(e5))); } _exchangeToken(e5, t3, r4) { return U(`${e5}/sharing/rest/oauth2/exchangeToken`, { authMode: "anonymous", method: "post", query: { f: "json", client_id: t3, token: r4 } }).then((e6) => e6.data.token); } _getPlatformSelf(e5, t3) { return e5 = e5.replace(/^http:/i, "https:"), U(`${e5}/sharing/rest/oauth2/platformSelf`, { authMode: "anonymous", headers: { "X-Esri-Auth-Client-Id": t3, "X-Esri-Auth-Redirect-Uri": window.location.href.replace(/#.*$/, "") }, method: "post", query: { f: "json", expiration: 30 }, withCredentials: true }).then((e6) => e6.data); } _getPortalSelf(e5, t3) { let r4; if (this._gwDomains.some((t4) => (t4.regex.test(e5) && (r4 = t4.customBaseUrl), !!r4)), r4) return Promise.resolve({ allSSL: true, currentVersion: "8.4", customBaseUrl: r4, portalMode: "multitenant", supportsOAuth: true }); this._appOrigin.startsWith("https:") ? e5 = e5.replace(/^http:/i, "https:").replace(/:7080/i, ":7443") : /^http:/i.test(t3) && (e5 = e5.replace(/^https:/i, "http:").replace(/:7443/i, ":7080")); return U(e5, { query: { f: "json" }, authMode: "anonymous", withCredentials: true }).then((e6) => e6.data); } _doPortalSignIn(e5) { const t3 = this._portalConfig, r4 = window.location.href, s6 = this.findServerInfo(e5); return !(!t3 && !this._isPortalDomain(r4) || !(s6 ? s6.hasPortal || s6.owningSystemUrl && this._isPortalDomain(s6.owningSystemUrl) : this._isPortalDomain(e5)) || !(this._isIdProvider(r4, e5) || t3 && (this._hasSameServerInstance(this._getServerInstanceRoot(t3.restBaseUrl), e5) || this._isIdProvider(t3.restBaseUrl, e5)) || z(r4, e5, true))); } _checkProtocol(e5, t3, r4, s6) { let o2 = true; const n6 = s6 ? t3.adminTokenServiceUrl : t3.tokenServiceUrl; if (n6.trim().toLowerCase().startsWith("https:") && !this._appOrigin.startsWith("https:") && J(n6) && (o2 = !!this._protocolFunc && !!this._protocolFunc({ resourceUrl: e5, serverInfo: t3 }), !o2)) { r4(new s("identity-manager:aborted", "Aborted the Sign-In process to avoid sending password over insecure connection.")); } return o2; } _enqueue(e5, t3, r4, s6, i3, o2) { return s6 || (s6 = D()), s6.resUrl_ = e5, s6.sinfo_ = t3, s6.options_ = r4, s6.admin_ = i3, s6.refresh_ = o2, this._busy ? this._hasSameServerInstance(this._getServerInstanceRoot(e5), this._busy.resUrl_) ? (this._oAuthDfd && this._oAuthDfd.oAuthWin_ && this._oAuthDfd.oAuthWin_.focus(), this._soReqs.push(s6)) : this._xoReqs.push(s6) : this._doSignIn(s6), s6.promise; } _doSignIn(e5) { this._busy = e5, this._rejectOnPersistedPageShow = false; const t3 = (t4) => { const r5 = e5.options_ && e5.options_.resource, s7 = e5.resUrl_, i3 = e5.refresh_; let o3 = false; this.credentials.includes(t4) || (i3 && this.credentials.includes(i3) ? (i3.userId = t4.userId, i3.token = t4.token, i3.expires = t4.expires, i3.validity = t4.validity, i3.ssl = t4.ssl, i3.creationTime = t4.creationTime, o3 = true, t4 = i3) : this.credentials.push(t4)), t4.resources || (t4.resources = []), t4.resources.includes(r5 || s7) || t4.resources.push(r5 || s7), t4.scope = this._isServerRsrc(s7) ? "server" : "portal", t4.emitTokenChange(); const n6 = this._soReqs, a3 = {}; this._soReqs = [], n6.forEach((e6) => { if (!this._isIdenticalService(s7, e6.resUrl_)) { const r6 = this._getSuffix(e6.resUrl_); a3[r6] || (a3[r6] = true, t4.resources.push(e6.resUrl_)); } }), e5.resolve(t4), n6.forEach((e6) => { this._hasSameServerInstance(this._getServerInstanceRoot(s7), e6.resUrl_) ? e6.resolve(t4) : this._soReqs.push(e6); }), this._busy = e5.resUrl_ = e5.sinfo_ = e5.refresh_ = null, o3 || this.emit("credential-create", { credential: t4 }), this._soReqs.length ? this._doSignIn(this._soReqs.shift()) : this._xoReqs.length && this._doSignIn(this._xoReqs.shift()); }, r4 = (t4) => { e5.reject(t4), this._busy = e5.resUrl_ = e5.sinfo_ = e5.refresh_ = null, this._soReqs.length ? this._doSignIn(this._soReqs.shift()) : this._xoReqs.length && this._doSignIn(this._xoReqs.shift()); }, s6 = (o3, a3, h, l6) => { const d4 = e5.sinfo_, u2 = !e5.options_ || e5.options_.prompt !== false, p5 = d4.hasPortal && this._findOAuthInfo(e5.resUrl_); let _, f; if (o3) t3(new E({ userId: o3, server: d4.server, token: h || null, expires: l6 != null ? Number(l6) : null, ssl: !!a3 })); else if (window !== window.parent && this._appUrlObj.query?.["arcgis-auth-origin"] && this._appUrlObj.query?.["arcgis-auth-portal"] && this._hasSameServerInstance(this._getServerInstanceRoot(this._appUrlObj.query["arcgis-auth-portal"]), e5.resUrl_)) { window.parent.postMessage({ type: "arcgis:auth:requestCredential" }, this._appUrlObj.query["arcgis-auth-origin"]); const s7 = r2(window, "message", (e6) => { e6.source === window.parent && e6.data && (e6.data.type === "arcgis:auth:credential" ? (s7.remove(), e6.data.credential.expires < Date.now() ? r4(new s("identity-manager:credential-request-failed", "Parent application's token has expired.")) : t3(new E(e6.data.credential))) : e6.data.type === "arcgis:auth:error" && (s7.remove(), e6.data.error.name === "tokenExpiredError" ? r4(new s("identity-manager:credential-request-failed", "Parent application's token has expired.")) : r4(s.fromJSON(e6.data.error)))); }); v(e5.options_?.signal, () => { s7.remove(); }); } else if (p5) { let o4 = p5._oAuthCred; if (!o4) { const e6 = new e4(p5, D2), t4 = new e4(p5, q); e6.isValid() && t4.isValid() ? e6.expires > t4.expires ? (o4 = e6, t4.destroy()) : (o4 = t4, e6.destroy()) : o4 = e6.isValid() ? e6 : t4, p5._oAuthCred = o4; } if (o4.isValid()) { _ = new E({ userId: o4.userId, server: d4.server, token: o4.token, expires: o4.expires, ssl: o4.ssl, _oAuthCred: o4 }); const r5 = p5.appId !== o4.appId && this._doPortalSignIn(e5.resUrl_); r5 || o4.refreshToken ? (e5._pendingDfd = o4.refreshToken ? this._getOAuthToken(d4.server, o4.refreshToken, o4.appId).then((e6) => (_.expires = Date.now() + 1e3 * e6.expires_in, _.token = e6.access_token, _)) : Promise.resolve(_), e5._pendingDfd.then((e6) => r5 ? this._exchangeToken(e6.server, p5.appId, e6.token).then((t4) => (e6.token = t4, e6)).catch(() => e6) : e6).then((e6) => { t3(e6); }).catch(() => { o4.destroy(), s6(); })) : t3(_); } else if (this._oAuthLocationParams && this._hasSameServerInstance(p5.portalUrl, this._oAuthLocationParams.state.portalUrl) && (this._oAuthLocationParams.access_token || this._oAuthLocationParams.code && this._oAuthLocationParams.state.uid === o4.stateUID && o4.codeVerifier)) { const s7 = this._oAuthLocationParams; this._oAuthLocationParams = null, e5._pendingDfd = this._processOAuthResponseParams(s7, p5, d4).then((e6) => { t3(e6); }).catch(r4); } else { const s7 = () => { u2 ? e5._pendingDfd = this.oAuthSignIn(e5.resUrl_, d4, p5, e5.options_).then(t3, r4) : (f = new s("identity-manager:not-authenticated", "User is not signed in."), r4(f)); }; this._doPortalSignIn(e5.resUrl_) ? e5._pendingDfd = this._getPlatformSelf(d4.server, p5.appId).then((e6) => { z(e6.portalUrl, this._appOrigin, true) ? (_ = new E({ userId: e6.username, server: d4.server, expires: Date.now() + 1e3 * e6.expires_in, token: e6.token }), t3(_)) : s7(); }).catch(s7) : s7(); } } else if (u2) { if (this._checkProtocol(e5.resUrl_, d4, r4, e5.admin_)) { let s7 = e5.options_; e5.admin_ && (s7 = s7 || {}, s7.isAdmin = true), e5._pendingDfd = this.signIn(e5.resUrl_, d4, s7).then(t3, r4); } } else f = new s("identity-manager:not-authenticated", "User is not signed in."), r4(f); }, o2 = () => { const s7 = e5.sinfo_, i3 = s7.owningSystemUrl, o3 = e5.options_; let n6, a3, h, l6; if (o3 && (n6 = o3.token, a3 = o3.error, h = o3.prompt), l6 = this._findCredential(i3, { token: n6, resource: e5.resUrl_ }), !l6) { for (const e6 of this.credentials) if (this._isIdProvider(i3, e6.server)) { l6 = e6; break; } } if (l6) { const i4 = this.findCredential(e5.resUrl_, l6.userId); if (i4) t3(i4); else if (b(s7, this._legacyFed)) { const e6 = l6.toJSON(); e6.server = s7.server, e6.resources = null, t3(new E(e6)); } else { (e5._pendingDfd = this.generateToken(this.findServerInfo(l6.server), null, { serverUrl: e5.resUrl_, token: l6.token, signal: e5.options_.signal, ssl: l6.ssl })).then((r5) => { t3(new E({ userId: l6.userId, server: s7.server, token: r5.token, expires: r5.expires != null ? Number(r5.expires) : null, ssl: !!r5.ssl, isAdmin: e5.admin_, validity: r5.validity })); }, r4); } } else { this._busy = null, n6 && (e5.options_.token = null); (e5._pendingDfd = this.getCredential(i3.replace(/\/?$/, "/sharing"), { resource: e5.resUrl_, owningTenant: s7.owningTenant, signal: e5.options_.signal, token: n6, error: a3, prompt: h })).then(() => { this._enqueue(e5.resUrl_, e5.sinfo_, e5.options_, e5, e5.admin_); }, (t4) => { e5.resUrl_ = e5.sinfo_ = e5.refresh_ = null, e5.reject(t4); }); } }; this._errbackFunc = r4; const a2 = e5.sinfo_.owningSystemUrl, l5 = this._isServerRsrc(e5.resUrl_), d3 = e5.sinfo_._restInfoPms; d3 ? d3.promise.then((t4) => { const r5 = e5.sinfo_; if (r5._restInfoPms) { r5.adminTokenServiceUrl = r5._restInfoPms.adminUrl, r5._restInfoPms = null, r5.tokenServiceUrl = t("authInfo.tokenServicesUrl", t4) || t("authInfo.tokenServiceUrl", t4) || t("tokenServiceUrl", t4), r5.shortLivedTokenValidity = t("authInfo.shortLivedTokenValidity", t4), r5.currentVersion = t4.currentVersion, r5.owningTenant = t4.owningTenant; const e6 = r5.owningSystemUrl = t4.owningSystemUrl; e6 && this._portals.push(e6); } l5 && r5.owningSystemUrl ? o2() : s6(); }, () => { e5.sinfo_._restInfoPms = null; const t4 = new s("identity-manager:server-identification-failed", "Unknown resource - could not find token service endpoint."); r4(t4); }) : l5 && a2 ? o2() : e5.sinfo_._selfReq ? e5.sinfo_._selfReq.selfDfd.then((t4) => { const r5 = {}; let s7, i3, o3, n6; return t4 && (s7 = t4.user && t4.user.username, r5.username = s7, r5.allSSL = t4.allSSL, i3 = t4.supportsOAuth, o3 = parseFloat(t4.currentVersion), t4.portalMode === "multitenant" && (n6 = t4.customBaseUrl), e5.sinfo_.currentVersion = o3), e5.sinfo_.webTierAuth = !!s7, s7 && this.normalizeWebTierAuth ? this.generateToken(e5.sinfo_, null, { ssl: r5.allSSL }).catch(() => null).then((e6) => (r5.portalToken = e6 && e6.token, r5.tokenExpiration = e6 && e6.expires, r5)) : !s7 && i3 && o3 >= 4.4 && !this._findOAuthInfo(e5.resUrl_) ? this._generateOAuthInfo({ portalUrl: e5.sinfo_.server, customBaseUrl: n6, owningTenant: e5.sinfo_._selfReq.owningTenant }).catch(() => null).then(() => r5) : r5; }).catch(() => null).then((t4) => { e5.sinfo_._selfReq = null, t4 ? s6(t4.username, t4.allSSL, t4.portalToken, t4.tokenExpiration) : s6(); }) : s6(); } _generateOAuthInfo(e5) { let t3, r4, i3 = e5.portalUrl; const o2 = e5.customBaseUrl, n6 = e5.owningTenant, a2 = !this.defaultOAuthInfo && this._createDefaultOAuthInfo && !this._hasTestedIfAppIsOnPortal; if (a2) { r4 = window.location.href; let e6 = r4.indexOf("?"); e6 > -1 && (r4 = r4.slice(0, e6)), e6 = r4.search(/\/(apps|home)\//), r4 = e6 > -1 ? r4.slice(0, e6) : null; } return a2 && r4 ? (this._hasTestedIfAppIsOnPortal = true, t3 = U(r4 + "/sharing/rest", { query: { f: "json" } }).then(() => { this.defaultOAuthInfo = new i({ appId: "arcgisonline", popupCallbackUrl: r4 + "/home/oauth-callback.html" }); })) : t3 = Promise.resolve(), t3.then(() => { if (this.defaultOAuthInfo) return i3 = i3.replace(/^http:/i, "https:"), U(i3 + "/sharing/rest/oauth2/validateRedirectUri", { query: { accountId: n6, client_id: this.defaultOAuthInfo.appId, redirect_uri: Q(this.defaultOAuthInfo.popupCallbackUrl), f: "json" } }).then((e6) => { if (e6.data.valid) { const t4 = this.defaultOAuthInfo.clone(); e6.data.urlKey && o2 ? t4.portalUrl = "https://" + e6.data.urlKey.toLowerCase() + "." + o2 : t4.portalUrl = i3, t4.popup = window !== window.top || !(z(i3, this._appOrigin) || this._gwDomains.some((e7) => e7.regex.test(i3) && e7.regex.test(this._appOrigin))), this.oAuthInfos.push(t4); } }); }); } _doOAuthSignIn(e5, t3, r4, s6) { const o2 = r4._oAuthCred, a2 = { portalUrl: r4.portalUrl }; !r4.popup && r4.preserveUrlHash && window.location.hash && (a2.hash = window.location.hash), o2.stateUID && (a2.uid = o2.stateUID); const h = { client_id: r4.appId, response_type: o2.codeVerifier ? "code" : "token", state: JSON.stringify(a2), expiration: r4.expiration, locale: r4.locale, redirect_uri: this._getRedirectURI(r4, !!o2.codeVerifier) }; r4.forceLogin && (h.force_login = true), r4.forceUserId && r4.userId && (h.prepopulatedusername = r4.userId), !r4.popup && this._doPortalSignIn(e5) && (h.redirectToUserOrgUrl = true), o2.codeVerifier && (h.code_challenge = s6 || o2.codeVerifier, h.code_challenge_method = s6 ? "S256" : "plain"); const l5 = r4.portalUrl.replace(/^http:/i, "https:") + "/sharing/oauth2/authorize", c = l5 + "?" + I(h); if (r4.popup) { const e6 = window.open(c, "esriJSAPIOAuth", r4.popupWindowFeatures); if (e6) e6.focus(), this._oAuthDfd.oAuthWin_ = e6, this._oAuthIntervalId = setInterval(() => { if (e6.closed) { clearInterval(this._oAuthIntervalId), this._oAuthOnPopupHandle.remove(); const e7 = this._oAuthDfd; if (e7) { const t4 = new s("identity-manager:user-aborted", "ABORTED"); e7.reject(t4); } } }, 500), this._oAuthOnPopupHandle = r2(window, ["arcgis:auth:hash", "arcgis:auth:location:search"], (e7) => { e7.type === "arcgis:auth:hash" ? this.setOAuthResponseHash(e7.detail) : this._setOAuthResponseQueryString(e7.detail); }); else { const e7 = new s("identity-manager:popup-blocked", "ABORTED"); this._oAuthDfd.reject(e7); } } else this._rejectOnPersistedPageShow = true, this._oAuthRedirectFunc ? this._oAuthRedirectFunc({ authorizeParams: h, authorizeUrl: l5, resourceUrl: e5, serverInfo: t3, oAuthInfo: r4 }) : window.location.href = c; } _getRedirectURI(e5, t3) { const r4 = window.location.href.replace(/#.*$/, ""); if (e5.popup) return Q(e5.popupCallbackUrl); if (t3) { const e6 = j(r4); return e6.query && ["code", "error", "error_description", "message_code", "persist", "state"].forEach((t4) => { delete e6.query[t4]; }), Bt(e6.path, e6.query); } return r4; } }; j2.prototype.declaredClass = "esri.identity.IdentityManagerBase"; var E = class extends n3.EventedAccessor { constructor(e5) { super(e5), this._oAuthCred = null, this.tokenRefreshBuffer = 2, e5 && e5._oAuthCred && (this._oAuthCred = e5._oAuthCred); } initialize() { this.resources = this.resources || [], this.creationTime == null && (this.creationTime = Date.now()); } refreshToken() { const e5 = n5.findServerInfo(this.server), t3 = e5 && e5.owningSystemUrl, s6 = !!t3 && this.scope === "server", i3 = s6 && b(e5, n5._legacyFed), o2 = e5.webTierAuth, n6 = o2 && n5.normalizeWebTierAuth, a2 = R[this.server], h = a2 && a2[this.userId]; let l5, c = this.resources && this.resources[0], d3 = s6 && n5.findServerInfo(t3), u2 = { username: this.userId, password: h }; if (o2 && !n6) return; s6 && !d3 && n5.serverInfos.some((e6) => (n5._isIdProvider(t3, e6.server) && (d3 = e6), !!d3)); const p5 = d3 && n5.findCredential(d3.server, this.userId); if (!s6 || p5) { if (!i3) { if (s6) l5 = { serverUrl: c, token: p5 && p5.token, ssl: p5 && p5.ssl }; else if (n6) u2 = null, l5 = { ssl: this.ssl }; else { if (!h) { let t4; return c && (c = n5._sanitizeUrl(c), this._enqueued = 1, t4 = n5._enqueue(c, e5, null, null, this.isAdmin, this), t4.then(() => { this._enqueued = 0, this.refreshServerTokens(); }).catch(() => { this._enqueued = 0; })), t4; } this.isAdmin && (l5 = { isAdmin: true }); } return n5.generateToken(s6 ? d3 : e5, s6 ? null : u2, l5).then((e6) => { this.token = e6.token, this.expires = e6.expires != null ? Number(e6.expires) : null, this.creationTime = Date.now(), this.validity = e6.validity, this.emitTokenChange(), this.refreshServerTokens(); }).catch(() => { }); } p5.refreshToken(); } } refreshServerTokens() { this.scope === "portal" && n5.credentials.forEach((e5) => { const t3 = n5.findServerInfo(e5.server), s6 = t3 && t3.owningSystemUrl; e5 !== this && e5.userId === this.userId && s6 && e5.scope === "server" && (n5._hasSameServerInstance(this.server, s6) || n5._isIdProvider(s6, this.server)) && (b(t3, n5._legacyFed) ? (e5.token = this.token, e5.expires = this.expires, e5.creationTime = this.creationTime, e5.validity = this.validity, e5.emitTokenChange()) : e5.refreshToken()); }); } emitTokenChange(e5) { clearTimeout(this._refreshTimer); const t3 = this.server && n5.findServerInfo(this.server), s6 = t3 && t3.owningSystemUrl, i3 = s6 && n5.findServerInfo(s6); e5 === false || s6 && this.scope !== "portal" && (!i3 || !i3.webTierAuth || n5.normalizeWebTierAuth) || this.expires == null && this.validity == null || this._startRefreshTimer(), this.emit("token-change"); } destroy() { this.userId = this.server = this.token = this.expires = this.validity = this.resources = this.creationTime = null, this._oAuthCred && (this._oAuthCred.destroy(), this._oAuthCred = null); const e5 = n5.credentials.indexOf(this); e5 > -1 && n5.credentials.splice(e5, 1), this.emitTokenChange(), this.emit("destroy"); } toJSON() { const e5 = y({ 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 }), t3 = this.resources; return t3 && t3.length > 0 && (e5.resources = t3.slice()), e5; } _startRefreshTimer() { clearTimeout(this._refreshTimer); const e5 = 6e4 * this.tokenRefreshBuffer, t3 = 2 ** 31 - 1; let r4 = (this.validity ? this.creationTime + 6e4 * this.validity : this.expires) - Date.now(); r4 < 0 ? r4 = 0 : r4 > t3 && (r4 = t3), this._refreshTimer = setTimeout(this.refreshToken.bind(this), r4 > e5 ? r4 - e5 : r4); } }; e([d()], E.prototype, "creationTime", void 0), e([d()], E.prototype, "expires", void 0), e([d()], E.prototype, "isAdmin", void 0), e([d()], E.prototype, "oAuthState", void 0), e([d()], E.prototype, "resources", void 0), e([d()], E.prototype, "scope", void 0), e([d()], E.prototype, "server", void 0), e([d()], E.prototype, "ssl", void 0), e([d()], E.prototype, "token", void 0), e([d()], E.prototype, "tokenRefreshBuffer", void 0), e([d()], E.prototype, "userId", void 0), e([d()], E.prototype, "validity", void 0), E = e([n2("esri.identity.Credential")], E); // node_modules/@arcgis/core/identity/IdentityManager.js var r3 = class extends j2 { }; r3.prototype.declaredClass = "esri.identity.IdentityManager"; var s5 = new r3(); o(s5); export { s5 as default }; /*! * focus-trap 6.9.4 * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE */ /*! * tabbable 5.3.3 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE */ //# sourceMappingURL=IdentityManager-CNNYIJFK.js.map