123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803 |
- import {
- M,
- e2,
- e4 as e3
- } from "./chunk-PB5D5C6Y.js";
- import {
- n2 as n4,
- v as v2
- } from "./chunk-GZBNC76D.js";
- import "./chunk-2TTT3V5O.js";
- import "./chunk-IOZKU7B2.js";
- import {
- s as s3
- } from "./chunk-S6EFEKAU.js";
- import "./chunk-I4RYNNL6.js";
- import "./chunk-TV3CFJQR.js";
- import {
- l as l2
- } from "./chunk-TJV6ODRM.js";
- import "./chunk-HWSWTWZD.js";
- import "./chunk-ZLNEXZAN.js";
- import "./chunk-5UVJ64RB.js";
- import {
- n as n3
- } from "./chunk-IM3LVQXV.js";
- import "./chunk-55RWC67C.js";
- import "./chunk-HZRKBTHJ.js";
- import {
- U,
- t as t2
- } from "./chunk-DVUG3KID.js";
- import {
- n as n5,
- s as s4
- } from "./chunk-FWSQEIAR.js";
- import {
- Bt,
- F,
- I,
- J,
- L,
- Q,
- Z,
- j,
- y as y2,
- z
- } from "./chunk-VEGAOVMY.js";
- import "./chunk-YEJL5NEF.js";
- import {
- e,
- l3 as l,
- n2 as n,
- n5 as n2,
- y3 as y
- } from "./chunk-2Z2TG5CU.js";
- import "./chunk-6KZ2LTDA.js";
- import "./chunk-U2XHEJM7.js";
- import "./chunk-SQOPWYIT.js";
- import {
- D,
- p as p2,
- r2 as r,
- v
- } from "./chunk-V6P2MAQQ.js";
- import {
- s,
- s3 as s2
- } from "./chunk-E5O6P5I2.js";
- import {
- p,
- t
- } from "./chunk-SPWQ3AWG.js";
- import "./chunk-2TIUKVZN.js";
- import "./chunk-YXWMMD76.js";
- import "./chunk-S5KM4IGW.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 p3 = class extends M {
- constructor(s8, e5) {
- super(s8, e5), this._usernameInputNode = null, this._passwordInputNode = null, this.signingIn = false, this.server = null, this.resource = null, this.error = null, this.oAuthPrompt = false;
- }
- render() {
- const { error: s8, server: e5, resource: t4, signingIn: o, oAuthPrompt: n6, messages: p6 } = this, d2 = n4("div", { class: a.group }, s3(n6 ? p6.oAuthInfo : p6.info, { server: e5 && /\.arcgis\.com/i.test(e5) ? l3 : e5, resource: `(${t4 || p6.lblItem})` })), c = n6 ? null : n4("div", { class: a.group, key: "username" }, n4("label", { class: a.label }, p6.lblUser, n4("input", { value: "", required: true, autocomplete: "off", spellcheck: false, type: "text", bind: this, afterCreate: v2, "data-node-ref": "_usernameInputNode", class: a.esriInput }))), m = n6 ? null : n4("div", { class: a.group, key: "password" }, n4("label", { class: a.label }, p6.lblPwd, n4("input", { value: "", required: true, type: "password", bind: this, afterCreate: v2, "data-node-ref": "_passwordInputNode", class: a.esriInput }))), h = n4("div", { class: this.classes(a.group, a.footer) }, n4("input", { type: "submit", disabled: !!o, value: o ? p6.lblSigning : p6.lblOk, class: a.esriButton }), n4("input", { type: "button", value: p6.lblCancel, bind: this, onclick: this._cancel, class: this.classes(a.esriButton, a.esriButtonSecondary) })), b2 = s8 ? n4("div", null, s8.details && s8.details.httpStatus ? p6.invalidUser : p6.noAuthService) : null;
- return n4("form", { class: a.base, bind: this, onsubmit: this._submit }, d2, b2, c, m, h);
- }
- _cancel() {
- this._set("signingIn", false), this._usernameInputNode && (this._usernameInputNode.value = ""), this._passwordInputNode && (this._passwordInputNode.value = ""), this.emit("cancel");
- }
- _submit(s8) {
- s8.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([y(), e2("esri/identity/t9n/identity")], p3.prototype, "messages", void 0), e([y()], p3.prototype, "signingIn", void 0), e([y()], p3.prototype, "server", void 0), e([y()], p3.prototype, "resource", void 0), e([y()], p3.prototype, "error", void 0), e([y()], p3.prototype, "oAuthPrompt", void 0), p3 = e([n2("esri.identity.IdentityForm")], p3);
- var d = p3;
- // 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({
- scopeParent: 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({
- scopeParent: 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 r3 = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
- return child.tagName === "SUMMARY";
- });
- return r3;
- };
- 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 isNodeAttached = function isNodeAttached2(node) {
- var _nodeRootHost;
- var nodeRootHost = getRootNode(node).host;
- var attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && _nodeRootHost.ownerDocument.contains(nodeRootHost) || node.ownerDocument.contains(node));
- while (!attached && nodeRootHost) {
- var _nodeRootHost2;
- nodeRootHost = getRootNode(nodeRootHost).host;
- attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && _nodeRootHost2.ownerDocument.contains(nodeRootHost));
- }
- return attached;
- };
- 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;
- }
- if (!displayCheck || displayCheck === "full" || displayCheck === "legacy-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 (isNodeAttached(node)) {
- return !node.getClientRects().length;
- }
- if (displayCheck !== "legacy-full") {
- return true;
- }
- } 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.scopeParent;
- var element = isScope ? item.scopeParent : 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 = null != arguments[i3] ? 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 p4 = class extends M {
- constructor(t4, e5) {
- super(t4, e5), this.container = document.createElement("div"), this.content = null, this.open = false, this._focusTrap = null, this._close = () => {
- this.open = false;
- }, document.body.appendChild(this.container), this.addHandles(l2(() => this.open, () => this._toggleFocusTrap()));
- }
- destroy() {
- this._destroyFocusTrap();
- }
- get title() {
- var _a;
- return (_a = this.messages) == null ? void 0 : _a.auth.signIn;
- }
- render() {
- const t4 = this.id, { open: e5, content: o, title: s8, messages: i3 } = this, r3 = e5 && !!o, n6 = { [l4.open]: r3, [l4.closed]: !r3 }, 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 })), d2 = `${t4}_title`, p6 = `${t4}_content`, u2 = s8 ? n4("h1", { id: d2, class: l4.title }, s8) : null, m = r3 ? n4("div", { bind: this, class: l4.dialog, role: "dialog", "aria-labelledby": d2, "aria-describedby": p6, afterCreate: this._createFocusTrap }, a2, u2, this._renderContent(p6)) : null;
- return n4("div", { tabIndex: -1, class: this.classes(l4.base, n6) }, m);
- }
- _destroyFocusTrap() {
- var _a;
- (_a = this._focusTrap) == null ? void 0 : _a.deactivate({ onDeactivate: () => {
- } }), this._focusTrap = null;
- }
- _toggleFocusTrap() {
- const { _focusTrap: t4, open: e5 } = this;
- t4 && (e5 ? t4.activate() : t4.deactivate());
- }
- _createFocusTrap(t4) {
- this._destroyFocusTrap();
- const o = requestAnimationFrame(() => {
- this._focusTrap = createFocusTrap(t4, { initialFocus: "input", onDeactivate: this._close }), this._toggleFocusTrap();
- });
- this.addHandles(n(() => cancelAnimationFrame(o)));
- }
- _renderContent(t4) {
- const e5 = this.content;
- return "string" == typeof e5 ? n4("div", { class: l4.content, id: t4, innerHTML: e5 }) : e3(e5) ? n4("div", { class: l4.content, id: t4 }, e5.render()) : e5 instanceof HTMLElement ? n4("div", { class: l4.content, id: t4, bind: e5, afterCreate: this._attachToNode }) : null;
- }
- _attachToNode(t4) {
- const e5 = this;
- t4.appendChild(e5);
- }
- };
- e([y({ readOnly: true })], p4.prototype, "container", void 0), e([y()], p4.prototype, "content", void 0), e([y()], p4.prototype, "open", void 0), e([y(), e2("esri/t9n/common")], p4.prototype, "messages", void 0), e([y()], p4.prototype, "title", null), p4 = e([n2("esri.identity.IdentityModal")], p4);
- var u = p4;
- // node_modules/@arcgis/core/identity/OAuthCredential.js
- var t3 = "esriJSAPIOAuth";
- var e4 = class {
- constructor(t4, 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 = t4, this.storage = e5, this._init();
- }
- isValid() {
- let t4 = false;
- if (this.oAuthInfo && this.userId && (this.refreshToken || this.token)) {
- if (null == this.expires && this.refreshToken)
- t4 = true;
- else if (this.expires) {
- const e5 = Date.now();
- if (this.expires > e5) {
- (this.expires - e5) / 1e3 > 60 * this.oAuthInfo.minTimeUntilExpiration && (t4 = true);
- }
- }
- }
- return t4;
- }
- save() {
- if (!this.storage)
- return false;
- const e5 = this._load(), s8 = this.oAuthInfo;
- if (s8 && s8.authNamespace && s8.portalUrl) {
- let r3 = e5[s8.authNamespace];
- r3 || (r3 = e5[s8.authNamespace] = {}), this.appId || (this.appId = s8.appId), r3[s8.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(t3, JSON.stringify(e5));
- } catch (i3) {
- return console.warn(i3), false;
- }
- return true;
- }
- return false;
- }
- destroy() {
- const e5 = this._load(), s8 = this.oAuthInfo;
- if (s8 && s8.appId && s8.portalUrl && (null == this.expires || this.expires > Date.now()) && (this.refreshToken || this.token)) {
- const t4 = s8.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", s8.appId), e6.append("token_type_hint", this.refreshToken ? "refresh_token" : "access_token"), "function" == typeof navigator.sendBeacon)
- navigator.sendBeacon(t4, e6);
- else {
- const s9 = new XMLHttpRequest();
- s9.open("POST", t4), s9.send(e6);
- }
- }
- if (s8 && s8.authNamespace && s8.portalUrl && this.storage) {
- const r3 = e5[s8.authNamespace];
- if (r3) {
- delete r3[s8.portalUrl];
- try {
- this.storage.setItem(t3, JSON.stringify(e5));
- } catch (i3) {
- console.log(i3);
- }
- }
- }
- s8 && (s8._oAuthCred = null, this.oAuthInfo = null);
- }
- _init() {
- const t4 = this._load(), e5 = this.oAuthInfo;
- if (e5 && e5.authNamespace && e5.portalUrl) {
- let s8 = t4[e5.authNamespace];
- s8 && (s8 = s8[e5.portalUrl], s8 && (this.appId = s8.appId, this.codeVerifier = s8.codeVerifier, this.expires = s8.expires, this.refreshToken = s8.refreshToken, this.ssl = s8.ssl, this.stateUID = s8.stateUID, this.token = s8.token, this.userId = s8.userId));
- }
- }
- _load() {
- let e5 = {};
- if (this.storage) {
- const i3 = this.storage.getItem(t3);
- if (i3)
- try {
- e5 = JSON.parse(i3);
- } catch (s8) {
- console.warn(s8);
- }
- }
- return e5;
- }
- };
- e4.prototype.declaredClass = "esri.identity.OAuthCredential";
- // node_modules/@arcgis/core/identity/OAuthInfo.js
- var p5;
- var s5 = p5 = class extends l {
- constructor(o) {
- super(o), 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 p5.fromJSON(this.toJSON());
- }
- };
- e([y({ json: { write: true } })], s5.prototype, "appId", void 0), e([y({ json: { write: true } })], s5.prototype, "authNamespace", void 0), e([y({ json: { write: true } })], s5.prototype, "expiration", void 0), e([y({ json: { write: true } })], s5.prototype, "flowType", void 0), e([y({ json: { write: true } })], s5.prototype, "forceLogin", void 0), e([y({ json: { write: true } })], s5.prototype, "forceUserId", void 0), e([y({ json: { write: true } })], s5.prototype, "locale", void 0), e([y({ json: { write: true } })], s5.prototype, "minTimeUntilExpiration", void 0), e([y({ json: { write: true } })], s5.prototype, "popup", void 0), e([y({ json: { write: true } })], s5.prototype, "popupCallbackUrl", void 0), e([y({ json: { write: true } })], s5.prototype, "popupWindowFeatures", void 0), e([y({ json: { write: true } })], s5.prototype, "portalUrl", void 0), e([y({ json: { write: true } })], s5.prototype, "preserveUrlHash", void 0), e([y({ json: { write: true } })], s5.prototype, "userId", void 0), s5 = p5 = e([n2("esri.identity.OAuthInfo")], s5);
- var i = s5;
- // node_modules/@arcgis/core/identity/ServerInfo.js
- var s6 = class extends l {
- constructor(o) {
- super(o), 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([y({ json: { write: true } })], s6.prototype, "adminTokenServiceUrl", void 0), e([y({ json: { write: true } })], s6.prototype, "currentVersion", void 0), e([y({ json: { write: true } })], s6.prototype, "hasPortal", void 0), e([y({ json: { write: true } })], s6.prototype, "hasServer", void 0), e([y({ json: { write: true } })], s6.prototype, "owningSystemUrl", void 0), e([y({ json: { write: true } })], s6.prototype, "owningTenant", void 0), e([y({ json: { write: true } })], s6.prototype, "server", void 0), e([y({ json: { write: true } })], s6.prototype, "shortLivedTokenValidity", void 0), e([y({ json: { write: true } })], s6.prototype, "tokenServiceUrl", void 0), e([y({ json: { write: true } })], s6.prototype, "webTierAuth", void 0), s6 = e([n2("esri.identity.ServerInfo")], s6);
- var i2 = s6;
- // node_modules/@arcgis/core/identity/IdentityManagerBase.js
- var C = {};
- var b = (e5) => {
- const t4 = new y2(e5.owningSystemUrl).host, r3 = new y2(e5.server).host, s8 = /.+\.arcgis\.com$/i;
- return s8.test(t4) && s8.test(r3);
- };
- var D2 = (e5, t4) => !!(b(e5) && t4 && t4.some((t5) => t5.test(e5.server)));
- var q = null;
- var j2 = null;
- try {
- q = window.localStorage, j2 = window.sessionStorage;
- } catch {
- }
- var E = 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 = d, this.tokenValidity = null, this.normalizeWebTierAuth = false, this._appOrigin = "null" !== window.origin ? 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 t4 = this.serverInfos;
- t4 ? (e5 = e5.filter((e6) => !this.findServerInfo(e6.server)), this.serverInfos = t4.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 t4 = this.oAuthInfos;
- if (t4) {
- for (const r3 of e5) {
- const e6 = this.findOAuthInfo(r3.portalUrl);
- e6 && t4.splice(t4.indexOf(e6), 1);
- }
- this.oAuthInfos = t4.concat(e5);
- } else
- this.oAuthInfos = e5;
- }
- registerToken(e5) {
- e5 = { ...e5 };
- const t4 = this._sanitizeUrl(e5.server), r3 = this._isServerRsrc(t4);
- let s8, i3 = this.findServerInfo(t4), o = true;
- i3 || (i3 = new i2(), i3.server = this._getServerInstanceRoot(t4), r3 ? i3.hasServer = true : (i3.tokenServiceUrl = this._getTokenSvcUrl(t4), i3.hasPortal = true), this.registerServers([i3])), s8 = this._findCredential(t4), s8 ? (delete e5.server, Object.assign(s8, e5), o = false) : (s8 = new L2({ userId: e5.userId, server: i3.server, token: e5.token, expires: e5.expires, ssl: e5.ssl, scope: r3 ? "server" : "portal" }), s8.resources = [t4], this.credentials.push(s8)), s8.emitTokenChange(false), o || s8.refreshServerTokens();
- }
- toJSON() {
- return p({ 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;
- "string" == typeof e5 && (e5 = JSON.parse(e5));
- const t4 = e5.serverInfos, r3 = e5.oAuthInfos, s8 = e5.credentials;
- if (t4) {
- const e6 = [];
- t4.forEach((t5) => {
- t5.server && t5.tokenServiceUrl && e6.push(t5.declaredClass ? t5 : new i2(t5));
- }), e6.length && this.registerServers(e6);
- }
- if (r3) {
- const e6 = [];
- r3.forEach((t5) => {
- t5.appId && e6.push(t5.declaredClass ? t5 : new i(t5));
- }), e6.length && this.registerOAuthInfos(e6);
- }
- s8 && s8.forEach((e6) => {
- e6.server && e6.token && e6.expires && e6.expires > Date.now() && ((e6 = e6.declaredClass ? e6 : new L2(e6)).emitTokenChange(), this.credentials.push(e6));
- });
- }
- findServerInfo(e5) {
- let t4;
- e5 = this._sanitizeUrl(e5);
- for (const r3 of this.serverInfos)
- if (this._hasSameServerInstance(r3.server, e5)) {
- t4 = r3;
- break;
- }
- return t4;
- }
- findOAuthInfo(e5) {
- let t4;
- e5 = this._sanitizeUrl(e5);
- for (const r3 of this.oAuthInfos)
- if (this._hasSameServerInstance(r3.portalUrl, e5)) {
- t4 = r3;
- break;
- }
- return t4;
- }
- findCredential(e5, t4) {
- if (!e5)
- return;
- let r3;
- e5 = this._sanitizeUrl(e5);
- const s8 = this._isServerRsrc(e5) ? "server" : "portal";
- if (t4) {
- for (const i3 of this.credentials)
- if (this._hasSameServerInstance(i3.server, e5) && t4 === i3.userId && i3.scope === s8) {
- r3 = i3;
- break;
- }
- } else
- for (const i3 of this.credentials)
- if (this._hasSameServerInstance(i3.server, e5) && -1 !== this._getIdenticalSvcIdx(e5, i3) && i3.scope === s8) {
- r3 = i3;
- break;
- }
- return r3;
- }
- getCredential(e5, t4) {
- let r3, s8, o = true;
- t4 && (r3 = !!t4.token, s8 = t4.error, o = false !== t4.prompt), t4 = { ...t4 }, e5 = this._sanitizeUrl(e5);
- const n6 = new AbortController(), a2 = D();
- if (t4.signal && v(t4.signal, () => {
- n6.abort();
- }), v(n6, () => {
- a2.reject(new s2("identity-manager:user-aborted", "ABORTED"));
- }), p2(n6))
- return a2.promise;
- t4.signal = n6.signal;
- const h = this._isAdminResource(e5), u2 = r3 ? this.findCredential(e5) : null;
- let p6;
- if (u2 && s8 && s8.details && 498 === s8.details.httpStatus)
- u2.destroy();
- else if (u2)
- return p6 = new s2("identity-manager:not-authorized", "You are currently signed in as: '" + u2.userId + "'. You do not have access to this resource: " + e5, { error: s8 }), a2.reject(p6), a2.promise;
- const f = this._findCredential(e5, t4);
- if (f)
- return a2.resolve(f), a2.promise;
- let g = this.findServerInfo(e5);
- if (g)
- !g.hasServer && this._isServerRsrc(e5) && (g._restInfoPms = this._getTokenSvcUrl(e5), g.hasServer = true);
- else {
- const t5 = this._getTokenSvcUrl(e5);
- if (!t5)
- return p6 = new s2("identity-manager:unknown-resource", "Unknown resource - could not find token service endpoint."), a2.reject(p6), a2.promise;
- g = new i2(), g.server = this._getServerInstanceRoot(e5), "string" == typeof t5 ? (g.tokenServiceUrl = t5, g.hasPortal = true) : (g._restInfoPms = t5, g.hasServer = true), this.registerServers([g]);
- }
- return g.hasPortal && void 0 === g._selfReq && (o || z(g.tokenServiceUrl, this._appOrigin) || this._gwDomains.some((e6) => e6.tokenServiceUrl === g.tokenServiceUrl)) && (g._selfReq = { owningTenant: t4 && t4.owningTenant, selfDfd: this._getPortalSelf(g.tokenServiceUrl.replace(this._rePortalTokenSvc, "/sharing/rest/portals/self"), e5) }), this._enqueue(e5, g, t4, 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, t4, r3) {
- const o = this._rePortalTokenSvc.test(e5.tokenServiceUrl), n6 = new y2(this._appOrigin), a2 = e5.shortLivedTokenValidity;
- let h, l5, c, d2, u2, p6, g, m;
- t4 && (m = this.tokenValidity || a2 || this._defaultTokenValidity, m > a2 && a2 > 0 && (m = a2)), r3 && (h = r3.isAdmin, l5 = r3.serverUrl, c = r3.token, p6 = r3.signal, g = r3.ssl, e5.customParameters = r3.customParameters), h ? d2 = e5.adminTokenServiceUrl : (d2 = e5.tokenServiceUrl, u2 = new y2(d2.toLowerCase()), e5.webTierAuth && (r3 == null ? void 0 : r3.serverUrl) && !g && "http" === n6.scheme && (z(n6.uri, d2, true) || "https" === u2.scheme && n6.host === u2.host && "7080" === n6.port && "7443" === u2.port) && (d2 = d2.replace(/^https:/i, "http:").replace(/:7443/i, ":7080")));
- const v3 = { query: { request: "getToken", username: t4 == null ? void 0 : t4.username, password: t4 == null ? void 0 : t4.password, serverUrl: l5, token: c, expiration: m, referer: h || o ? this._appOrigin : null, client: h ? "referer" : null, f: "json", ...e5.customParameters }, method: "post", authMode: "anonymous", useProxy: this._useProxy(e5, r3), signal: p6, ...r3 == null ? void 0 : r3.ioArgs };
- o || (v3.withCredentials = false);
- return U(d2, v3).then((r4) => {
- const s8 = r4.data;
- if (!s8 || !s8.token)
- return new s2("identity-manager:authentication-failed", "Unable to generate token");
- const o2 = e5.server;
- return C[o2] || (C[o2] = {}), t4 && (C[o2][t4.username] = t4.password), s8.validity = m, s8;
- });
- }
- isBusy() {
- return !!this._busy;
- }
- checkSignInStatus(e5) {
- return this.checkAppAccess(e5, "").then((e6) => e6.credential);
- }
- checkAppAccess(e5, t4, r3) {
- let o = false;
- return this.getCredential(e5, { prompt: false }).then((n6) => {
- let a2;
- const h = { f: "json" };
- if ("portal" === n6.scope)
- if (t4 && (this._doPortalSignIn(e5) || r3 && r3.force))
- a2 = n6.server + "/sharing/rest/oauth2/validateAppAccess", h.client_id = t4;
- 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 (false === e6.data.valid)
- throw new s2("identity-manager:not-authorized", `You are currently signed in as: '${n6.userId}'.`, e6.data);
- return o = !!e6.data.viewOnlyUserTypeApp, { credential: n6 };
- }).catch((e6) => {
- if ("identity-manager:not-authorized" === e6.name)
- throw e6;
- const t5 = e6.details && e6.details.httpStatus;
- if (498 === t5)
- throw n6.destroy(), new s2("identity-manager:not-authenticated", "User is not signed in.");
- if (400 === t5)
- throw new s2("identity-manager:invalid-request");
- return { credential: n6 };
- });
- }).then((e6) => ({ credential: e6.credential, viewOnly: o }));
- }
- setOAuthResponseHash(e5) {
- e5 && ("#" === e5.charAt(0) && (e5 = e5.substring(1)), this._processOAuthPopupParams(L(e5)));
- }
- setOAuthRedirectionHandler(e5) {
- this._oAuthRedirectFunc = e5;
- }
- setProtocolErrorHandler(e5) {
- this._protocolFunc = e5;
- }
- signIn(e5, t4, r3 = {}) {
- const s8 = D(), o = () => {
- var _a;
- h == null ? void 0 : h.remove(), d2 == null ? void 0 : d2.remove(), p6 == null ? void 0 : p6.remove(), a2 == null ? void 0 : a2.destroy(), (_a = this.dialog) == null ? void 0 : _a.destroy(), this.dialog = a2 = h = d2 = p6 = null;
- }, n6 = () => {
- o(), this._oAuthDfd = null, s8.reject(new s2("identity-manager:user-aborted", "ABORTED"));
- };
- r3.signal && v(r3.signal, () => {
- n6();
- });
- let a2 = new this.formConstructor();
- a2.resource = this.getResourceName(e5), a2.server = t4.server, this.dialog = new u(), this.dialog.content = a2, this.dialog.open = true, this.emit("dialog-create");
- let h = a2.on("cancel", n6), d2 = l2(() => this.dialog.open, n6), p6 = a2.on("submit", (e6) => {
- this.generateToken(t4, e6, { isAdmin: r3.isAdmin, signal: r3.signal }).then((i3) => {
- o();
- const n7 = new L2({ userId: e6.username, server: t4.server, token: i3.token, expires: null != i3.expires ? Number(i3.expires) : null, ssl: !!i3.ssl, isAdmin: r3.isAdmin, validity: i3.validity });
- s8.resolve(n7);
- }).catch((e7) => {
- a2.error = e7, a2.signingIn = false;
- });
- });
- return s8.promise;
- }
- oAuthSignIn(e5, t4, r3, s8) {
- this._oAuthDfd = D();
- const o = this._oAuthDfd;
- let n6;
- (s8 == null ? void 0 : s8.signal) && v(s8.signal, () => {
- const e6 = this._oAuthDfd && this._oAuthDfd.oAuthWin_;
- e6 && !e6.closed ? e6.close() : this.dialog && f();
- }), o.resUrl_ = e5, o.sinfo_ = t4, o.oinfo_ = r3;
- const a2 = r3._oAuthCred;
- if (a2.storage && ("authorization-code" === r3.flowType || "auto" === r3.flowType && !r3.popup && t4.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, d2, p6, _;
- this._getCodeChallenge(n6).then((i3) => {
- const o2 = !s8 || false !== s8.oAuthPopupConfirmation;
- r3.popup && o2 ? (h = new this.formConstructor(), h.oAuthPrompt = true, h.server = t4.server, this.dialog = new u(), this.dialog.content = h, this.dialog.open = true, this.emit("dialog-create"), d2 = h.on("cancel", f), p6 = l2(() => this.dialog.open, f), _ = h.on("submit", () => {
- g(), this._doOAuthSignIn(e5, t4, r3, i3);
- })) : this._doOAuthSignIn(e5, t4, r3, i3);
- });
- const f = () => {
- g(), this._oAuthDfd = null, o.reject(new s2("identity-manager:user-aborted", "ABORTED"));
- }, g = () => {
- var _a;
- d2 == null ? void 0 : d2.remove(), p6 == null ? void 0 : p6.remove(), _ == null ? void 0 : _.remove(), h == null ? void 0 : h.destroy(), (_a = this.dialog) == null ? void 0 : _a.destroy(), this.dialog = null;
- };
- return o.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 = r(window, "message", (t4) => {
- var _a;
- if ((t4.origin === this._appOrigin || t4.origin.endsWith(".arcgis.com")) && "arcgis:auth:requestCredential" === ((_a = t4.data) == null ? void 0 : _a.type)) {
- const r3 = t4.source;
- this.getCredential(e5).then((e6) => {
- r3.postMessage({ type: "arcgis:auth:credential", credential: { expires: e6.expires, server: e6.server, ssl: e6.ssl, token: e6.token, userId: e6.userId } }, t4.origin);
- }).catch((e6) => {
- r3.postMessage({ type: "arcgis:auth:error", error: { name: e6.name, message: e6.message } }, t4.origin);
- });
- }
- });
- }
- disablePostMessageAuth() {
- this._postMessageAuthHandle && (this._postMessageAuthHandle.remove(), this._postMessageAuthHandle = null);
- }
- _getOAuthLocationParams() {
- var _a, _b;
- let e5 = window.location.hash;
- if (e5) {
- "#" === e5.charAt(0) && (e5 = e5.substring(1));
- const t5 = L(e5);
- let r3 = false;
- if (t5.access_token && t5.expires_in && t5.state && t5.hasOwnProperty("username"))
- try {
- t5.state = JSON.parse(t5.state), t5.state.portalUrl && (this._oAuthLocationParams = t5, r3 = true);
- } catch {
- }
- else if (t5.error && t5.error_description && (console.log("IdentityManager OAuth Error: ", t5.error, " - ", t5.error_description), "access_denied" === t5.error && (r3 = true, t5.state)))
- try {
- t5.state = JSON.parse(t5.state);
- } catch {
- }
- r3 && (window.location.hash = ((_a = t5.state) == null ? void 0 : _a.hash) || "");
- }
- let t4 = window.location.search;
- if (t4) {
- "?" === t4.charAt(0) && (t4 = t4.substring(1));
- const e6 = L(t4);
- let r3 = false;
- if (e6.code && e6.state)
- try {
- e6.state = JSON.parse(e6.state), e6.state.portalUrl && e6.state.uid && (this._oAuthLocationParams = e6, r3 = true);
- } catch {
- }
- else if (e6.error && e6.error_description && (console.log("IdentityManager OAuth Error: ", e6.error, " - ", e6.error_description), "access_denied" === e6.error && (r3 = true, e6.state)))
- try {
- e6.state = JSON.parse(e6.state);
- } catch {
- }
- if (r3) {
- const t5 = { ...e6 };
- ["code", "error", "error_description", "message_code", "persist", "state"].forEach((e7) => {
- delete t5[e7];
- });
- const r4 = I(t5), s8 = window.location.pathname + (r4 ? `?${r4}` : "") + (((_b = e6.state) == null ? void 0 : _b.hash) || "");
- window.history.replaceState(window.history.state, "", s8);
- }
- }
- }
- _getOAuthToken(e5, t4, r3, i3, o) {
- return e5 = e5.replace(/^http:/i, "https:"), U(`${e5}/sharing/rest/oauth2/token`, { authMode: "anonymous", method: "post", query: i3 && o ? { grant_type: "authorization_code", code: t4, redirect_uri: i3, client_id: r3, code_verifier: o } : { grant_type: "refresh_token", refresh_token: t4, client_id: r3 } }).then((e6) => e6.data);
- }
- _getCodeChallenge(e5) {
- if (e5 && globalThis.isSecureContext) {
- const t4 = new TextEncoder().encode(e5);
- return crypto.subtle.digest("SHA-256", t4).then((e6) => Z(new Uint8Array(e6)));
- }
- return Promise.resolve(null);
- }
- _pageShowHandler(e5) {
- if (e5.persisted && this.isBusy() && this._rejectOnPersistedPageShow) {
- const e6 = new s2("identity-manager:user-aborted", "ABORTED");
- this._errbackFunc(e6);
- }
- }
- _findCredential(e5, t4) {
- let r3, s8, i3, o, n6 = -1;
- const a2 = t4 && t4.token, h = t4 && t4.resource, l5 = this._isServerRsrc(e5) ? "server" : "portal", c = this.credentials.filter((t5) => this._hasSameServerInstance(t5.server, e5) && t5.scope === l5);
- if (e5 = h || e5, c.length)
- if (1 === c.length) {
- if (r3 = c[0], i3 = this.findServerInfo(r3.server), s8 = i3 && i3.owningSystemUrl, o = s8 ? this.findCredential(s8, r3.userId) : void 0, n6 = this._getIdenticalSvcIdx(e5, r3), !a2)
- return -1 === n6 && r3.resources.push(e5), this._addResource(e5, o), r3;
- -1 !== n6 && (r3.resources.splice(n6, 1), this._removeResource(e5, o));
- } else {
- let t5, r4;
- if (c.some((a3) => (r4 = this._getIdenticalSvcIdx(e5, a3), -1 !== r4 && (t5 = a3, i3 = this.findServerInfo(t5.server), s8 = i3 && i3.owningSystemUrl, o = s8 ? this.findCredential(s8, t5.userId) : void 0, n6 = r4, true))), a2)
- t5 && (t5.resources.splice(n6, 1), this._removeResource(e5, o));
- else if (t5)
- return this._addResource(e5, o), t5;
- }
- }
- _findOAuthInfo(e5) {
- let t4 = this.findOAuthInfo(e5);
- if (!t4) {
- for (const r3 of this.oAuthInfos)
- if (this._isIdProvider(r3.portalUrl, e5)) {
- t4 = r3;
- break;
- }
- }
- return t4;
- }
- _addResource(e5, t4) {
- t4 && -1 === this._getIdenticalSvcIdx(e5, t4) && t4.resources.push(e5);
- }
- _removeResource(e5, t4) {
- let r3 = -1;
- t4 && (r3 = this._getIdenticalSvcIdx(e5, t4), r3 > -1 && t4.resources.splice(r3, 1));
- }
- _useProxy(e5, t4) {
- return t4 && t4.isAdmin && !z(e5.adminTokenServiceUrl, this._appOrigin) || !this._isPortalDomain(e5.tokenServiceUrl) && "10.1" === String(e5.currentVersion) && !z(e5.tokenServiceUrl, this._appOrigin);
- }
- _getOrigin(e5) {
- const t4 = new y2(e5);
- return t4.scheme + "://" + t4.host + (null != t4.port ? ":" + t4.port : "");
- }
- _getServerInstanceRoot(e5) {
- const t4 = e5.toLowerCase();
- let r3 = t4.indexOf(this._agsRest);
- return -1 === r3 && this._isAdminResource(e5) && (r3 = this._agsAdmin.test(e5) ? e5.replace(this._agsAdmin, "$1").length : e5.search(this._adminSvcs)), -1 !== r3 || t2(t4) || (r3 = t4.indexOf("/sharing")), -1 === r3 && "/" === t4.substr(-1) && (r3 = t4.length - 1), r3 > -1 ? e5.substring(0, r3) : e5;
- }
- _hasSameServerInstance(e5, t4) {
- return "/" === e5.substr(-1) && (e5 = e5.slice(0, -1)), e5 = e5.toLowerCase(), t4 = this._getServerInstanceRoot(t4).toLowerCase(), e5 = this._normalizeAGOLorgDomain(e5), t4 = this._normalizeAGOLorgDomain(t4), (e5 = e5.substr(e5.indexOf(":"))) === (t4 = t4.substr(t4.indexOf(":")));
- }
- _normalizeAGOLorgDomain(e5) {
- const t4 = /^https?:\/\/(?:cdn|[a-z\d-]+\.maps)\.arcgis\.com/i, r3 = /^https?:\/\/(?:cdndev|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i, s8 = /^https?:\/\/(?:cdnqa|[a-z\d-]+\.mapsqa)\.arcgis\.com/i;
- return t4.test(e5) ? e5 = e5.replace(t4, "https://www.arcgis.com") : r3.test(e5) ? e5 = e5.replace(r3, "https://devext.arcgis.com") : s8.test(e5) && (e5 = e5.replace(s8, "https://qaext.arcgis.com")), e5;
- }
- _sanitizeUrl(e5) {
- const r3 = (s.request.proxyUrl || "").toLowerCase(), s8 = r3 ? e5.toLowerCase().indexOf(r3 + "?") : -1;
- return -1 !== s8 && (e5 = e5.substring(s8 + r3.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, t4) {
- let r3 = false;
- if (this._isRESTService(e5) && this._isRESTService(t4)) {
- const s8 = this._getSuffix(e5).toLowerCase(), i3 = this._getSuffix(t4).toLowerCase();
- if (r3 = s8 === i3, !r3) {
- const e6 = /(.*)\/(MapServer|FeatureServer|UtilityNetworkServer).*/gi;
- r3 = s8.replace(e6, "$1") === i3.replace(e6, "$1");
- }
- } else
- this._isAdminResource(e5) && this._isAdminResource(t4) ? r3 = true : this._isServerRsrc(e5) || this._isServerRsrc(t4) || !this._isPortalDomain(e5) || (r3 = true);
- return r3;
- }
- _isPortalDomain(e5) {
- const r3 = new y2(e5.toLowerCase()), s8 = this._portalConfig;
- let i3 = this._gwDomains.some((e6) => e6.regex.test(r3.uri));
- return !i3 && s8 && (i3 = this._hasSameServerInstance(this._getServerInstanceRoot(s8.restBaseUrl), r3.uri)), i3 || s.portalUrl && (i3 = z(r3, s.portalUrl, true)), i3 || (i3 = this._portals.some((e6) => this._hasSameServerInstance(e6, r3.uri))), i3 = i3 || this._agsPortal.test(r3.path), i3;
- }
- _isIdProvider(e5, t4) {
- let r3 = -1, s8 = -1;
- this._gwDomains.forEach((i4, o) => {
- -1 === r3 && i4.regex.test(e5) && (r3 = o), -1 === s8 && i4.regex.test(t4) && (s8 = o);
- });
- let i3 = false;
- if (r3 > -1 && s8 > -1 && (0 === r3 || 4 === r3 ? 0 !== s8 && 4 !== s8 || (i3 = true) : 1 === r3 ? 1 !== s8 && 2 !== s8 || (i3 = true) : 2 === r3 ? 2 === s8 && (i3 = true) : 3 === r3 && 3 === s8 && (i3 = true)), !i3) {
- const r4 = this.findServerInfo(t4), s9 = r4 && r4.owningSystemUrl;
- s9 && b(r4) && this._isPortalDomain(s9) && this._isIdProvider(e5, s9) && (i3 = true);
- }
- return i3;
- }
- _getIdenticalSvcIdx(e5, t4) {
- let r3 = -1;
- for (let s8 = 0; s8 < t4.resources.length; s8++) {
- const i3 = t4.resources[s8];
- if (this._isIdenticalService(e5, i3)) {
- r3 = s8;
- break;
- }
- }
- return r3;
- }
- _getSuffix(e5) {
- return e5.replace(this._regexSDirUrl, "").replace(this._regexServerType, "$1");
- }
- _getTokenSvcUrl(e5) {
- let t4, r3, i3;
- if (this._isRESTService(e5) || this._isAdminResource(e5)) {
- const i4 = this._getServerInstanceRoot(e5);
- return t4 = i4 + "/admin/generateToken", r3 = U(e5 = i4 + "/rest/info", { query: { f: "json" } }).then((e6) => e6.data), { adminUrl: t4, promise: r3 };
- }
- if (this._isPortalDomain(e5)) {
- let t5 = "";
- if (this._gwDomains.some((r4) => (r4.regex.test(e5) && (t5 = r4.tokenServiceUrl), !!t5)), t5 || this._portals.some((r4) => (this._hasSameServerInstance(r4, e5) && (t5 = r4 + this._gwTokenUrl), !!t5)), t5 || (i3 = e5.toLowerCase().indexOf("/sharing"), -1 !== i3 && (t5 = e5.substring(0, i3) + this._gwTokenUrl)), t5 || (t5 = this._getOrigin(e5) + this._gwTokenUrl), t5) {
- const r4 = new y2(e5).port;
- /^http:\/\//i.test(e5) && "7080" === r4 && (t5 = t5.replace(/:7080/i, ":7443")), t5 = t5.replace(/http:/i, "https:");
- }
- return t5;
- }
- if (e5.toLowerCase().includes("premium.arcgisonline.com"))
- return "https://premium.arcgisonline.com/server/tokens";
- }
- _processOAuthResponseParams(e5, t4, r3) {
- const s8 = t4._oAuthCred;
- if (e5.code) {
- const i4 = s8.codeVerifier;
- return s8.codeVerifier = null, s8.stateUID = null, s8.save(), this._getOAuthToken(r3.server, e5.code, t4.appId, this._getRedirectURI(t4, true), i4).then((i5) => {
- const o = new L2({ userId: i5.username, server: r3.server, token: i5.access_token, expires: Date.now() + 1e3 * i5.expires_in, ssl: i5.ssl, oAuthState: e5.state, _oAuthCred: s8 });
- return t4.userId = o.userId, s8.storage = i5.persist ? q : j2, s8.refreshToken = i5.refresh_token, s8.token = null, s8.expires = i5.refresh_token_expires_in ? Date.now() + 1e3 * i5.refresh_token_expires_in : null, s8.userId = o.userId, s8.ssl = o.ssl, s8.save(), o;
- });
- }
- const i3 = new L2({ userId: e5.username, server: r3.server, token: e5.access_token, expires: Date.now() + 1e3 * Number(e5.expires_in), ssl: "true" === e5.ssl, oAuthState: e5.state, _oAuthCred: s8 });
- return t4.userId = i3.userId, s8.storage = e5.persist ? q : j2, s8.refreshToken = null, s8.token = i3.token, s8.expires = i3.expires, s8.userId = i3.userId, s8.ssl = i3.ssl, s8.save(), Promise.resolve(i3);
- }
- _processOAuthPopupParams(e5) {
- var _a;
- const t4 = this._oAuthDfd;
- if (this._oAuthDfd = null, t4)
- if (clearInterval(this._oAuthIntervalId), (_a = this._oAuthOnPopupHandle) == null ? void 0 : _a.remove(), e5.error) {
- const r3 = "access_denied" === e5.error, s8 = new s2(r3 ? "identity-manager:user-aborted" : "identity-manager:authentication-failed", r3 ? "ABORTED" : "OAuth: " + e5.error + " - " + e5.error_description);
- t4.reject(s8);
- } else
- this._processOAuthResponseParams(e5, t4.oinfo_, t4.sinfo_).then((e6) => {
- t4.resolve(e6);
- }).catch((e6) => {
- t4.reject(e6);
- });
- }
- _setOAuthResponseQueryString(e5) {
- e5 && ("?" === e5.charAt(0) && (e5 = e5.substring(1)), this._processOAuthPopupParams(L(e5)));
- }
- _exchangeToken(e5, t4, r3) {
- return U(`${e5}/sharing/rest/oauth2/exchangeToken`, { authMode: "anonymous", method: "post", query: { f: "json", client_id: t4, token: r3 } }).then((e6) => e6.data.token);
- }
- _getPlatformSelf(e5, t4) {
- return e5 = e5.replace(/^http:/i, "https:"), U(`${e5}/sharing/rest/oauth2/platformSelf`, { authMode: "anonymous", headers: { "X-Esri-Auth-Client-Id": t4, "X-Esri-Auth-Redirect-Uri": window.location.href.replace(/#.*$/, "") }, method: "post", query: { f: "json", expiration: 30 }, withCredentials: true }).then((e6) => e6.data);
- }
- _getPortalSelf(e5, t4) {
- let r3;
- if (this._gwDomains.some((t5) => (t5.regex.test(e5) && (r3 = t5.customBaseUrl), !!r3)), r3)
- return Promise.resolve({ allSSL: true, currentVersion: "8.4", customBaseUrl: r3, portalMode: "multitenant", supportsOAuth: true });
- this._appOrigin.startsWith("https:") ? e5 = e5.replace(/^http:/i, "https:").replace(/:7080/i, ":7443") : /^http:/i.test(t4) && (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 t4 = this._portalConfig, r3 = window.location.href, s8 = this.findServerInfo(e5);
- return !(!t4 && !this._isPortalDomain(r3) || !(s8 ? s8.hasPortal || s8.owningSystemUrl && this._isPortalDomain(s8.owningSystemUrl) : this._isPortalDomain(e5)) || !(this._isIdProvider(r3, e5) || t4 && (this._hasSameServerInstance(this._getServerInstanceRoot(t4.restBaseUrl), e5) || this._isIdProvider(t4.restBaseUrl, e5)) || z(r3, e5, true)));
- }
- _checkProtocol(e5, t4, r3, s8) {
- let o = true;
- const n6 = s8 ? t4.adminTokenServiceUrl : t4.tokenServiceUrl;
- if (n6.trim().toLowerCase().startsWith("https:") && !this._appOrigin.startsWith("https:") && J(n6) && (o = !!this._protocolFunc && !!this._protocolFunc({ resourceUrl: e5, serverInfo: t4 }), !o)) {
- r3(new s2("identity-manager:aborted", "Aborted the Sign-In process to avoid sending password over insecure connection."));
- }
- return o;
- }
- _enqueue(e5, t4, r3, s8, i3, o) {
- return s8 || (s8 = D()), s8.resUrl_ = e5, s8.sinfo_ = t4, s8.options_ = r3, s8.admin_ = i3, s8.refresh_ = o, this._busy ? this._hasSameServerInstance(this._getServerInstanceRoot(e5), this._busy.resUrl_) ? (this._oAuthDfd && this._oAuthDfd.oAuthWin_ && this._oAuthDfd.oAuthWin_.focus(), this._soReqs.push(s8)) : this._xoReqs.push(s8) : this._doSignIn(s8), s8.promise;
- }
- _doSignIn(e5) {
- this._busy = e5, this._rejectOnPersistedPageShow = false;
- const t4 = (t5) => {
- const r4 = e5.options_ && e5.options_.resource, s9 = e5.resUrl_, i3 = e5.refresh_;
- let o2 = false;
- this.credentials.includes(t5) || (i3 && this.credentials.includes(i3) ? (i3.userId = t5.userId, i3.token = t5.token, i3.expires = t5.expires, i3.validity = t5.validity, i3.ssl = t5.ssl, i3.creationTime = t5.creationTime, o2 = true, t5 = i3) : this.credentials.push(t5)), t5.resources || (t5.resources = []), t5.resources.includes(r4 || s9) || t5.resources.push(r4 || s9), t5.scope = this._isServerRsrc(s9) ? "server" : "portal", t5.emitTokenChange();
- const n6 = this._soReqs, a3 = {};
- this._soReqs = [], n6.forEach((e6) => {
- if (!this._isIdenticalService(s9, e6.resUrl_)) {
- const r5 = this._getSuffix(e6.resUrl_);
- a3[r5] || (a3[r5] = true, t5.resources.push(e6.resUrl_));
- }
- }), e5.resolve(t5), n6.forEach((e6) => {
- this._hasSameServerInstance(this._getServerInstanceRoot(s9), e6.resUrl_) ? e6.resolve(t5) : this._soReqs.push(e6);
- }), this._busy = e5.resUrl_ = e5.sinfo_ = e5.refresh_ = null, o2 || this.emit("credential-create", { credential: t5 }), this._soReqs.length ? this._doSignIn(this._soReqs.shift()) : this._xoReqs.length && this._doSignIn(this._xoReqs.shift());
- }, r3 = (t5) => {
- e5.reject(t5), 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());
- }, s8 = (o2, a3, h, l6) => {
- var _a, _b, _c;
- const d3 = e5.sinfo_, u2 = !e5.options_ || false !== e5.options_.prompt, p6 = d3.hasPortal && this._findOAuthInfo(e5.resUrl_);
- let f, g;
- if (o2)
- t4(new L2({ userId: o2, server: d3.server, token: h || null, expires: null != l6 ? Number(l6) : null, ssl: !!a3 }));
- else if (window !== window.parent && ((_a = this._appUrlObj.query) == null ? void 0 : _a["arcgis-auth-origin"]) && ((_b = this._appUrlObj.query) == null ? void 0 : _b["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 s9 = r(window, "message", (e6) => {
- e6.source === window.parent && e6.data && ("arcgis:auth:credential" === e6.data.type ? (s9.remove(), e6.data.credential.expires < Date.now() ? r3(new s2("identity-manager:credential-request-failed", "Parent application's token has expired.")) : t4(new L2(e6.data.credential))) : "arcgis:auth:error" === e6.data.type && (s9.remove(), "tokenExpiredError" === e6.data.error.name ? r3(new s2("identity-manager:credential-request-failed", "Parent application's token has expired.")) : r3(s2.fromJSON(e6.data.error))));
- });
- v((_c = e5.options_) == null ? void 0 : _c.signal, () => {
- s9.remove();
- });
- } else if (p6) {
- let o3 = p6._oAuthCred;
- if (!o3) {
- const e6 = new e4(p6, q), t5 = new e4(p6, j2);
- e6.isValid() && t5.isValid() ? e6.expires > t5.expires ? (o3 = e6, t5.destroy()) : (o3 = t5, e6.destroy()) : o3 = e6.isValid() ? e6 : t5, p6._oAuthCred = o3;
- }
- if (o3.isValid()) {
- f = new L2({ userId: o3.userId, server: d3.server, token: o3.token, expires: o3.expires, ssl: o3.ssl, _oAuthCred: o3 });
- const r4 = p6.appId !== o3.appId && this._doPortalSignIn(e5.resUrl_);
- r4 || o3.refreshToken ? (e5._pendingDfd = o3.refreshToken ? this._getOAuthToken(d3.server, o3.refreshToken, o3.appId).then((e6) => (f.expires = Date.now() + 1e3 * e6.expires_in, f.token = e6.access_token, f)) : Promise.resolve(f), e5._pendingDfd.then((e6) => r4 ? this._exchangeToken(e6.server, p6.appId, e6.token).then((t5) => (e6.token = t5, e6)).catch(() => e6) : e6).then((e6) => {
- t4(e6);
- }).catch(() => {
- o3 == null ? void 0 : o3.destroy(), s8();
- })) : t4(f);
- } else if (this._oAuthLocationParams && this._hasSameServerInstance(p6.portalUrl, this._oAuthLocationParams.state.portalUrl) && (this._oAuthLocationParams.access_token || this._oAuthLocationParams.code && this._oAuthLocationParams.state.uid === o3.stateUID && o3.codeVerifier)) {
- const s9 = this._oAuthLocationParams;
- this._oAuthLocationParams = null, e5._pendingDfd = this._processOAuthResponseParams(s9, p6, d3).then((e6) => {
- t4(e6);
- }).catch(r3);
- } else {
- const s9 = () => {
- u2 ? e5._pendingDfd = this.oAuthSignIn(e5.resUrl_, d3, p6, e5.options_).then(t4, r3) : (g = new s2("identity-manager:not-authenticated", "User is not signed in."), r3(g));
- };
- this._doPortalSignIn(e5.resUrl_) ? e5._pendingDfd = this._getPlatformSelf(d3.server, p6.appId).then((e6) => {
- z(e6.portalUrl, this._appOrigin, true) ? (f = new L2({ userId: e6.username, server: d3.server, expires: Date.now() + 1e3 * e6.expires_in, token: e6.token }), t4(f)) : s9();
- }).catch(s9) : s9();
- }
- } else if (u2) {
- if (this._checkProtocol(e5.resUrl_, d3, r3, e5.admin_)) {
- let s9 = e5.options_;
- e5.admin_ && (s9 = s9 || {}, s9.isAdmin = true), e5._pendingDfd = this.signIn(e5.resUrl_, d3, s9).then(t4, r3);
- }
- } else
- g = new s2("identity-manager:not-authenticated", "User is not signed in."), r3(g);
- }, o = () => {
- const s9 = e5.sinfo_, i3 = s9.owningSystemUrl, o2 = e5.options_;
- let n6, a3, h, l6;
- if (o2 && (n6 = o2.token, a3 = o2.error, h = o2.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)
- t4(i4);
- else if (D2(s9, this._legacyFed)) {
- const e6 = l6.toJSON();
- e6.server = s9.server, e6.resources = null, t4(new L2(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((r4) => {
- t4(new L2({ userId: l6 == null ? void 0 : l6.userId, server: s9.server, token: r4.token, expires: null != r4.expires ? Number(r4.expires) : null, ssl: !!r4.ssl, isAdmin: e5.admin_, validity: r4.validity }));
- }, r3);
- }
- } else {
- this._busy = null, n6 && (e5.options_.token = null);
- (e5._pendingDfd = this.getCredential(i3.replace(/\/?$/, "/sharing"), { resource: e5.resUrl_, owningTenant: s9.owningTenant, signal: e5.options_.signal, token: n6, error: a3, prompt: h })).then(() => {
- this._enqueue(e5.resUrl_, e5.sinfo_, e5.options_, e5, e5.admin_);
- }, (t5) => {
- e5.resUrl_ = e5.sinfo_ = e5.refresh_ = null, e5.reject(t5);
- });
- }
- };
- this._errbackFunc = r3;
- const a2 = e5.sinfo_.owningSystemUrl, l5 = this._isServerRsrc(e5.resUrl_), d2 = e5.sinfo_._restInfoPms;
- d2 ? d2.promise.then((t5) => {
- var _a, _b;
- const r4 = e5.sinfo_;
- if (r4._restInfoPms) {
- r4.adminTokenServiceUrl = r4._restInfoPms.adminUrl, r4._restInfoPms = null, r4.tokenServiceUrl = (_a = t("authInfo.tokenServicesUrl", t5) || t("authInfo.tokenServiceUrl", t5) || t("tokenServiceUrl", t5)) != null ? _a : null, r4.shortLivedTokenValidity = (_b = t("authInfo.shortLivedTokenValidity", t5)) != null ? _b : null, r4.currentVersion = t5.currentVersion, r4.owningTenant = t5.owningTenant;
- const e6 = r4.owningSystemUrl = t5.owningSystemUrl;
- e6 && this._portals.push(e6);
- }
- l5 && r4.owningSystemUrl ? o() : s8();
- }, () => {
- e5.sinfo_._restInfoPms = null;
- const t5 = new s2("identity-manager:server-identification-failed", "Unknown resource - could not find token service endpoint.");
- r3(t5);
- }) : l5 && a2 ? o() : e5.sinfo_._selfReq ? e5.sinfo_._selfReq.selfDfd.then((t5) => {
- const r4 = {};
- let s9, i3, o2, n6;
- return t5 && (s9 = t5.user && t5.user.username, r4.username = s9, r4.allSSL = t5.allSSL, i3 = t5.supportsOAuth, n6 = parseFloat(t5.currentVersion), "multitenant" === t5.portalMode && (o2 = t5.customBaseUrl), e5.sinfo_.currentVersion = n6), e5.sinfo_.webTierAuth = !!s9, s9 && this.normalizeWebTierAuth ? this.generateToken(e5.sinfo_, null, { ssl: r4.allSSL }).catch(() => null).then((e6) => (r4.portalToken = e6 && e6.token, r4.tokenExpiration = e6 && e6.expires, r4)) : !s9 && i3 && n6 >= 4.4 && !this._findOAuthInfo(e5.resUrl_) ? this._generateOAuthInfo({ portalUrl: e5.sinfo_.server, customBaseUrl: o2, owningTenant: e5.sinfo_._selfReq.owningTenant }).catch(() => null).then(() => r4) : r4;
- }).catch(() => null).then((t5) => {
- e5.sinfo_._selfReq = null, t5 ? s8(t5.username, t5.allSSL, t5.portalToken, t5.tokenExpiration) : s8();
- }) : s8();
- }
- _generateOAuthInfo(e5) {
- let t4, r3 = null, i3 = e5.portalUrl;
- const o = e5.customBaseUrl, n6 = e5.owningTenant, a2 = !this._defaultOAuthInfo && this._createDefaultOAuthInfo && !this._hasTestedIfAppIsOnPortal;
- if (a2) {
- r3 = window.location.href;
- let e6 = r3.indexOf("?");
- e6 > -1 && (r3 = r3.slice(0, e6)), e6 = r3.search(/\/(apps|home)\//), r3 = e6 > -1 ? r3.slice(0, e6) : null;
- }
- return a2 && r3 ? (this._hasTestedIfAppIsOnPortal = true, t4 = U(r3 + "/sharing/rest", { query: { f: "json" } }).then(() => {
- this._defaultOAuthInfo = new i({ appId: "arcgisonline", popupCallbackUrl: r3 + "/home/oauth-callback.html" });
- })) : t4 = Promise.resolve(), t4.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 t5 = this._defaultOAuthInfo.clone();
- e6.data.urlKey && o ? t5.portalUrl = "https://" + e6.data.urlKey.toLowerCase() + "." + o : t5.portalUrl = i3, t5.popup = window !== window.top || !(z(i3, this._appOrigin) || this._gwDomains.some((e7) => e7.regex.test(i3) && e7.regex.test(this._appOrigin))), this.oAuthInfos.push(t5);
- }
- });
- });
- }
- _doOAuthSignIn(e5, t4, r3, s8) {
- const o = r3._oAuthCred, a2 = { portalUrl: r3.portalUrl };
- !r3.popup && r3.preserveUrlHash && window.location.hash && (a2.hash = window.location.hash), o.stateUID && (a2.uid = o.stateUID);
- const h = { client_id: r3.appId, response_type: o.codeVerifier ? "code" : "token", state: JSON.stringify(a2), expiration: r3.expiration, locale: r3.locale, redirect_uri: this._getRedirectURI(r3, !!o.codeVerifier) };
- r3.forceLogin && (h.force_login = true), r3.forceUserId && r3.userId && (h.prepopulatedusername = r3.userId), !r3.popup && this._doPortalSignIn(e5) && (h.redirectToUserOrgUrl = true), o.codeVerifier && (h.code_challenge = s8 || o.codeVerifier, h.code_challenge_method = s8 ? "S256" : "plain");
- const l5 = r3.portalUrl.replace(/^http:/i, "https:") + "/sharing/oauth2/authorize", c = l5 + "?" + I(h);
- if (r3.popup) {
- const e6 = window.open(c, "esriJSAPIOAuth", r3.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 t5 = new s2("identity-manager:user-aborted", "ABORTED");
- e7.reject(t5);
- }
- }
- }, 500), this._oAuthOnPopupHandle = r(window, ["arcgis:auth:hash", "arcgis:auth:location:search"], (e7) => {
- "arcgis:auth:hash" === e7.type ? this.setOAuthResponseHash(e7.detail) : this._setOAuthResponseQueryString(e7.detail);
- });
- else {
- const e7 = new s2("identity-manager:popup-blocked", "ABORTED");
- this._oAuthDfd.reject(e7);
- }
- } else
- this._rejectOnPersistedPageShow = true, this._oAuthRedirectFunc ? this._oAuthRedirectFunc({ authorizeParams: h, authorizeUrl: l5, resourceUrl: e5, serverInfo: t4, oAuthInfo: r3 }) : window.location.href = c;
- }
- _getRedirectURI(e5, t4) {
- const r3 = window.location.href.replace(/#.*$/, "");
- if (e5.popup)
- return Q(e5.popupCallbackUrl);
- if (t4) {
- const e6 = j(r3);
- return e6.query && ["code", "error", "error_description", "message_code", "persist", "state"].forEach((t5) => {
- delete e6.query[t5];
- }), Bt(e6.path, e6.query);
- }
- return r3;
- }
- };
- E.prototype.declaredClass = "esri.identity.IdentityManagerBase";
- var L2 = 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 || [], null == this.creationTime && (this.creationTime = Date.now());
- }
- refreshToken() {
- const e5 = s4.findServerInfo(this.server), t4 = e5 && e5.owningSystemUrl, s8 = !!t4 && "server" === this.scope, i3 = s8 && D2(e5, s4._legacyFed), o = e5.webTierAuth, n6 = o && s4.normalizeWebTierAuth, a2 = C[this.server], h = a2 && a2[this.userId];
- let l5, c = this.resources && this.resources[0], d2 = s8 ? s4.findServerInfo(t4) : null, u2 = { username: this.userId, password: h };
- if (o && !n6)
- return;
- s8 && !d2 && s4.serverInfos.some((e6) => (s4._isIdProvider(t4, e6.server) && (d2 = e6), !!d2));
- const p6 = d2 ? s4.findCredential(d2.server, this.userId) : null;
- if (!s8 || p6) {
- if (!i3) {
- if (s8)
- l5 = { serverUrl: c, token: p6 && p6.token, ssl: p6 && p6.ssl };
- else if (n6)
- u2 = null, l5 = { ssl: this.ssl };
- else {
- if (!h) {
- let t5;
- return c && (c = s4._sanitizeUrl(c), this._enqueued = 1, t5 = s4._enqueue(c, e5, null, null, this.isAdmin, this), t5.then(() => {
- this._enqueued = 0, this.refreshServerTokens();
- }).catch(() => {
- this._enqueued = 0;
- })), t5;
- }
- this.isAdmin && (l5 = { isAdmin: true });
- }
- return s4.generateToken(s8 ? d2 : e5, s8 ? null : u2, l5).then((e6) => {
- this.token = e6.token, this.expires = null != e6.expires ? Number(e6.expires) : null, this.creationTime = Date.now(), this.validity = e6.validity, this.emitTokenChange(), this.refreshServerTokens();
- }).catch(() => {
- });
- }
- p6 == null ? void 0 : p6.refreshToken();
- }
- }
- refreshServerTokens() {
- "portal" === this.scope && s4.credentials.forEach((e5) => {
- const t4 = s4.findServerInfo(e5.server), s8 = t4 && t4.owningSystemUrl;
- e5 !== this && e5.userId === this.userId && s8 && "server" === e5.scope && (s4._hasSameServerInstance(this.server, s8) || s4._isIdProvider(s8, this.server)) && (D2(t4, s4._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 t4 = this.server && s4.findServerInfo(this.server), s8 = t4 && t4.owningSystemUrl, i3 = s8 && s4.findServerInfo(s8);
- false === e5 || s8 && "portal" !== this.scope && (!i3 || !i3.webTierAuth || s4.normalizeWebTierAuth) || null == this.expires && null == this.validity || 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 = s4.credentials.indexOf(this);
- e5 > -1 && s4.credentials.splice(e5, 1), this.emitTokenChange(), this.emit("destroy");
- }
- toJSON() {
- const e5 = p({ 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 }), t4 = this.resources;
- return t4 && t4.length > 0 && (e5.resources = t4.slice()), e5;
- }
- _startRefreshTimer() {
- clearTimeout(this._refreshTimer);
- const e5 = 6e4 * this.tokenRefreshBuffer, t4 = 2 ** 31 - 1;
- let r3 = (this.validity ? this.creationTime + 6e4 * this.validity : this.expires) - Date.now();
- r3 < 0 ? r3 = 0 : r3 > t4 && (r3 = t4), this._refreshTimer = setTimeout(this.refreshToken.bind(this), r3 > e5 ? r3 - e5 : r3);
- }
- };
- e([y()], L2.prototype, "creationTime", void 0), e([y()], L2.prototype, "expires", void 0), e([y()], L2.prototype, "isAdmin", void 0), e([y()], L2.prototype, "oAuthState", void 0), e([y()], L2.prototype, "resources", void 0), e([y()], L2.prototype, "scope", void 0), e([y()], L2.prototype, "server", void 0), e([y()], L2.prototype, "ssl", void 0), e([y()], L2.prototype, "token", void 0), e([y()], L2.prototype, "tokenRefreshBuffer", void 0), e([y()], L2.prototype, "userId", void 0), e([y()], L2.prototype, "validity", void 0), L2 = e([n2("esri.identity.Credential")], L2);
- // node_modules/@arcgis/core/identity/IdentityManager.js
- var r2 = class extends E {
- };
- r2.prototype.declaredClass = "esri.identity.IdentityManager";
- var s7 = new r2();
- n5(s7);
- export {
- s7 as default
- };
- /*!
- * focus-trap 7.0.0
- * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
- */
- /*!
- * tabbable 6.0.1
- * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
- */
- //# sourceMappingURL=IdentityManager-RSGL7L3S.js.map
|