@esri/hub-common 9.3.0 → 9.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es2017/search/_searchContent.js +62 -0
- package/dist/es2017/search/_searchContent.js.map +1 -0
- package/dist/es2017/search/content-utils.js +422 -0
- package/dist/es2017/search/content-utils.js.map +1 -0
- package/dist/es2017/search/index.js +4 -0
- package/dist/es2017/search/index.js.map +1 -1
- package/dist/es2017/search/types.js +1 -0
- package/dist/es2017/search/types.js.map +1 -0
- package/dist/es2017/search/utils.js +344 -0
- package/dist/es2017/search/utils.js.map +1 -0
- package/dist/esm/search/_searchContent.js +70 -0
- package/dist/esm/search/_searchContent.js.map +1 -0
- package/dist/esm/search/content-utils.js +426 -0
- package/dist/esm/search/content-utils.js.map +1 -0
- package/dist/esm/search/index.js +4 -0
- package/dist/esm/search/index.js.map +1 -1
- package/dist/esm/search/types.js +1 -0
- package/dist/esm/search/types.js.map +1 -0
- package/dist/esm/search/utils.js +341 -0
- package/dist/esm/search/utils.js.map +1 -0
- package/dist/node/search/_searchContent.js +66 -0
- package/dist/node/search/_searchContent.js.map +1 -0
- package/dist/node/search/content-utils.js +432 -0
- package/dist/node/search/content-utils.js.map +1 -0
- package/dist/node/search/index.js +4 -0
- package/dist/node/search/index.js.map +1 -1
- package/dist/node/search/types.js +3 -0
- package/dist/node/search/types.js.map +1 -0
- package/dist/node/search/utils.js +357 -0
- package/dist/node/search/utils.js.map +1 -0
- package/dist/types/search/_searchContent.d.ts +7 -0
- package/dist/types/search/content-utils.d.ts +70 -0
- package/dist/types/search/index.d.ts +4 -0
- package/dist/types/search/types.d.ts +294 -0
- package/dist/types/search/utils.d.ts +92 -0
- package/dist/umd/common.umd.js +842 -1
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisHub=e.arcgisHub||{})}(this,function(n){"use strict";function o(r,n){return Object.keys(r).reduce(function(e,t){return e[t]=n(r[t],t,r),e},{})}function i(e,r,n){return n=n||"",Array.isArray(e)?e.map(t):!e||!c(e)||s(e)||p(e)||u(e)?r(e,n):Object.assign({},e,o(e,t));function t(e,t){return i(e,r,""+(n?n+"."+t:t))}}function a(e){return"string"==typeof e||e instanceof String}function s(e){return e instanceof Date}function u(e){return"function"==typeof e}function c(e){return"object"==typeof e}function p(e){return e instanceof RegExp}function d(e,t){return t.split(".").reduce(function(e,t){return e?e[t]:void 0},e)}function l(e){var t,r={};if(Array.isArray(e))r=e.map(l);else if("object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(null!=(t=e[n])&&"object"==typeof t?t instanceof Date?r[n]=new Date(t.getTime()):r[n]=l(t):r[n]=t);else r=e;return r}function f(e,r,n){return e?e.reduce(function(e,t){return e=d(t,r)===n?t:e},null):null}function r(e){return""+(e=void 0===e?"i":e)+Math.random().toString(36).substr(2,8)}function m(e,t){return null!=e&&(t=l(t)).push(e),t}function t(e){return(e=(e=e.toLowerCase()).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi," ")).replace(/(\-|\_|\.|\s)+(.)?/g,function(e,t,r){return r?r.toUpperCase():""}).replace(/(^|\/)([A-Z])/g,function(e,t,r){return e.toLowerCase()})}function h(e){return(e=Array.from(e))[0]=e[0].toUpperCase(),e.join("")}function g(e){return e.reduce(function(e,t){return e.concat(t)},[])}function v(e,t,r){void 0===r&&(r={});var t=t.split("."),n=e,o=t.length-1;t.forEach(function(e,t){n.hasOwnProperty(e)&&null!==n[e]?t===o&&("object"!=typeof n[e]||Array.isArray(n[e])?n[e]=r:n[e]=Object.assign(n[e],l(r))):n[e]=t===o?r:{},n=n[e]})}function y(e,t,r){t=d(e,t);return void 0!==t?t:r}function b(e,r,n){return i(e,function(e){if(!a(e))return e;var t=p(r)?r:new RegExp(r,"g");return e.replace(t,n)})}function w(t,r,e){return Array.isArray(e)&&e.length?(e.forEach(function(e){void 0!==d(t,e)&&v(r,e,d(t,e))}),r):t}function C(e,t,r){v(r,e=Array.isArray(e)?e.join("."):e,t)}function k(e,n,o){void 0===o&&(o=5);return e.reduce(function(e,t){var r=e[e.length-1];return r&&r.length!==o||e.push(r=[]),r.push(t),e},[]).reduce(function(e,r){return e.then(function(t){var e=r.map(function(e){return n(e)});return Promise.all(e).then(function(e){return t.concat(e)})})},Promise.resolve([]))}function S(e,t){return-1!==e.indexOf(t)}var T=function(e,t){return(T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function e(e,t){function r(){this.constructor=e}T(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var A=function(){return(A=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function I(e,a,s,u){return new(s=s||Promise)(function(r,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function o(e){try{i(u.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(n,o)}i((u=u.apply(e,a||[])).next())})}function E(r,n){var o,i,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,i&&(a=2&t[0]?i.return:t[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,t[1])).done)return a;switch(i=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,i=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){s.label=t[1];break}if(6===t[0]&&s.label<a[1]){s.label=a[1],a=t;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(t);break}a[2]&&s.ops.pop(),s.trys.pop();continue}t=n.call(r,s)}catch(e){t=[6,e],i=0}finally{o=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function P(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),o=0,t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n}var x,D=(e(O,x=Error),O);function O(e,t,r){var n=this;return t=t||"UNKNOWN_ERROR",r=y(r,"rootCause",r),(n=x.call(this,t)||this).operation=e,n.name="OperationError",n.rootCause=r,Object.setPrototypeOf(n,O.prototype),n.stack=y(r,"stack",(new Error).stack),n}function R(r,n){return void 0===n&&(n={}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.apply(void 0,e).catch(function(e){return n})}}function N(e){var r=(new Date).getTime();return Array(e).fill(0).reduce(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),e=""+e+t.toString(16)},"")}function _(e){"{"===e[0]&&(e=e.substring(1,e.length-1));return/^(\{){0,1}[0-9a-fA-F]{8}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{12}(\}){0,1}$/gi.test(e)}n.Level=void 0,(at=n.Level||(n.Level={}))[at.all=0]="all",at[at.debug=1]="debug",at[at.info=2]="info",at[at.warn=3]="warn",at[at.error=4]="error",at[at.off=5]="off";var U=(j.setLogLevel=function(e){this.logLevel=e},j.log=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.debug)&&console.log.apply(console,P([e],t))},j.debug=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.debug)&&console.debug.apply(console,P([e],t))},j.info=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.info)&&console.info.apply(console,P([e],t))},j.warn=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.warn)&&console.warn.apply(console,P([e],t))},j.error=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.error)&&console.error.apply(console,P([e],t))},j.isLevelPermitted=function(e){return this.logLevel<=e},j.logLevel=n.Level.off,j);function j(){}function L(e){return e.capabilities.includes("updateitemcontrol")}function M(e){e=e.privileges;return S(void 0===e?[]:e,"portal:user:createItem")}function G(e,t){var r,n=!1,o=e.itemControl,i=e.owner,a=e.orgId,s=t.roleId,u=t.role,c=t.username,p=t.groups,l=t.orgId,u=S(["admin","update"],o)||!!i&&i===c||!!(!!a&&a===l)&&!s&&"org_admin"===u,t=M(t);return t&&u?n=!0:t&&(r=P(d(e,"groupIds")||[],[d(e,"properties.collaborationGroupId")]),n=p.some(function(e){return L(e)&&S(r,e.id)})),n}var B=["portal:user:createGroup","portal:user:createItem","portal:user:shareToGroup","portal:user:viewOrgGroups","portal:user:viewOrgItems"];function q(e){var t=e.host,r=e.path,e=e.query,t=t.endsWith("/")?t:t+"/",t=new URL(r,t);return t.search=function(r){void 0===r&&(r={});var e=Object.keys(r).filter(function(e){return void 0!==r[e]}).reduce(function(e,t){return e[t]=r[t],e},{});return new URLSearchParams(e).toString()}(e),t.toString()}function F(t){return Object.keys(t).some(function(e){e=t[e];if(!e)return!1;switch((e=e&&e.toParam?e.toParam():e).constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function Y(o){var i={};return Object.keys(o).forEach(function(e){var t=o[e];if((t=t&&t.toParam?t.toParam():t)||0===t||"boolean"==typeof t||"string"==typeof t){switch(t.constructor.name){case"Array":var r=null===(r=null===(r=t[0])||void 0===r?void 0:r.constructor)||void 0===r?void 0:r.name,n="Array"===r?t:"Object"===r?JSON.stringify(t):t.join(",");break;case"Object":n=JSON.stringify(t);break;case"Date":n=t.valueOf();break;case"Function":n=null;break;case"Boolean":n=t+"";break;default:n=t}(n||0===n||"string"==typeof n||Array.isArray(n))&&(i[e]=n)}}),i}function H(e){var t=Y(e);return Object.keys(t).map(function(e){return function t(r,e){return Array.isArray(e)&&e[0]&&Array.isArray(e[0])?e.map(function(e){return t(r,e)}).join("&"):encodeURIComponent(r)+"="+encodeURIComponent(e)}(e,t[e])}).join("&")}var W=function(e,t,r,n,o){e=e||"UNKNOWN_ERROR",t=t||"UNKNOWN_ERROR_CODE",this.name="ArcGISRequestError",this.message="UNKNOWN_ERROR_CODE"===t?e:t+": "+e,this.originalMessage=e,this.code=t,this.response=r,this.url=n,this.options=o};function z(e){console&&console.warn&&console.warn.apply(console,[e])}W.prototype=Object.create(Error.prototype),W.prototype.constructor=W;var V,J="@esri/arcgis-rest-js",K={httpMethod:"POST",params:{f:"json"}},$=(e(Q,V=W),Q.prototype.retry=function(e,n){var o=this;void 0===n&&(n=3);var i=0,a=function(t,r){e(o.url,o.options).then(function(e){e=A(A({},o.options),{authentication:e});return i+=1,X(o.url,e)}).then(function(e){t(e)}).catch(function(e){"ArcGISAuthError"===e.name&&i<n?a(t,r):"ArcGISAuthError"===e.name&&n<=i?r(o):r(e)})};return new Promise(function(e,t){a(e,t)})},Q);function Q(e,t,r,n,o){o=V.call(this,e=void 0===e?"AUTHENTICATION_ERROR":e,t=void 0===t?"AUTHENTICATION_ERROR_CODE":t,r,n,o)||this;return o.name="ArcGISAuthError",o.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,o}function X(n,e){void 0===e&&(e={params:{f:"json"}});var o=A(A(A({httpMethod:"POST"},K),e),{params:A(A({},K.params),e.params),headers:A(A({},K.headers),e.headers)}),t=[],e=[];if(o.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),e.push("`node-fetch`")):o.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),e.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),e.push("`isomorphic-form-data`")),!o.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires a `fetch` implementation and global variables for `Promise` and `FormData` to be present in the global scope. You are missing "+t.join(", ")+". We recommend installing the "+e.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var e=o.httpMethod,i=o.authentication,a=o.rawResponse,s=A({f:"json"},o.params),r=null,u={method:e,credentials:o.credentials||"same-origin"};return o.headers&&o.headers["X-Esri-Auth-Client-Id"]&&-1<n.indexOf("/oauth2/platformSelf")&&(u.credentials="include"),(i?i.getToken(n,{fetch:o.fetch}).catch(function(e){return e.url=n,e.options=o,r=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){e.length&&(s.token=e),i&&i.getDomainCredentials&&(u.credentials=i.getDomainCredentials(n));var t={};"GET"===u.method&&(s.token&&o.hideToken&&"undefined"==typeof window&&(t["X-Esri-Authorization"]="Bearer "+s.token,delete s.token),r=""===H(s)?n:n+"?"+H(s),o.maxUrlLength&&r.length>o.maxUrlLength||s.token&&o.hideToken?(u.method="POST",e.length&&o.hideToken&&(s.token=e,delete t["X-Esri-Authorization"])):n=r);var r=new RegExp("/items/.+/updateResources").test(n);return"POST"===u.method&&(u.body=function(e,t){var t=F(e)||t,r=Y(e);if(t){var n=new FormData;return Object.keys(r).forEach(function(e){var t;"undefined"!=typeof Blob&&r[e]instanceof Blob?(t=r.fileName||r[e].name||e,n.append(e,r[e],t)):n.append(e,r[e])}),n}return H(e)}(s,r)),u.headers=A(A({},t),o.headers),"undefined"!=typeof window||u.headers.referer||(u.headers.referer=J),F(s)||r||(u.headers["Content-Type"]="application/x-www-form-urlencoded"),o.fetch(n,u)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new W(r,"HTTP "+t,e,n,o)}if(a)return e;switch(s.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==s.f&&"geojson"!==s.f||a)return e;var t=function(t,e,r,n){if(400<=t.code){var o=t.message,i=t.code;throw new W(o,i,t,e,r)}if(t.error){var a=t.error,o=a.message,i=a.code,s=a.messageCode,a=s||i||"UNKNOWN_ERROR_CODE";if(498===i||499===i||"GWM_0003"===s||400===i&&"Unable to generate token."===o)throw n||new $(o,a,t,e,r);throw new W(o,a,t,e,r)}if("failed"!==t.status&&"failure"!==t.status)return t;o=void 0,i="UNKNOWN_ERROR_CODE";try{o=JSON.parse(t.statusMessage).message,i=JSON.parse(t.statusMessage).code}catch(e){o=t.statusMessage||t.message}throw new W(o,i,t,e,r)}(e,n,o,r);return r&&(e=n.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0],o.authentication.federatedServers[e]={token:[],expires:new Date(Date.now()+864e5)},r=null),t})}function Z(e){return"string"==typeof e&&"/"===(e=e.trim())[e.length-1]?e.slice(0,-1):e}function ee(e){return e.replace(/^#/,"").split("&").reduce(function(e,t){var r,t=(r=t,r=(t=t.split("="))[0],t=t[1],{key:decodeURIComponent(r),value:decodeURIComponent(t)});return e[t.key]=t.value,e},{})}function te(e){return(e=void 0===e?{}:e).portal?Z(e.portal):e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function re(e){return e.owner?Promise.resolve(e.owner):e.item&&e.item.owner?Promise.resolve(e.item.owner):e.authentication&&e.authentication.getUsername?e.authentication.getUsername():Promise.reject(new Error("Could not determine the owner of this item. Pass the `owner`, `item.owner`, or `authentication` option."))}function ne(n){return re(n).then(function(e){var t,r=n.folderId?te(n)+"/content/users/"+e+"/"+n.folderId+"/items/"+n.item.id+"/update":te(n)+"/content/users/"+e+"/items/"+n.item.id+"/update";return n.params=A(A({},n.params),(t=n.item,(e=JSON.parse(JSON.stringify(t))).data&&("undefined"!=typeof Blob&&t.data instanceof Blob||"ReadStream"===t.data.constructor.name?e.file=t.data:e.text=t.data,delete e.data),e)),X(r,n)})}function oe(e,t){return X(ie(e,t),A({httpMethod:"GET"},t))}var ie=function(e,t){return("string"==typeof t?t:te(t))+"/content/items/"+e};function ae(e){var t=ie(e.id,e)+"/relatedItems",r=A({httpMethod:"GET",params:{direction:e.direction}},e);return"string"==typeof e.relationshipType?r.params.relationshipType=e.relationshipType:r.params.relationshipTypes=e.relationshipType,delete r.direction,delete r.relationshipType,X(t,r)}function se(t){return re(t).then(function(e){return X(te(t)+"/content/users/"+e+"/items/"+t.id+"/unprotect",t)})}function ue(e){return t=e.groupId,X(te(e=e)+"/community/groups/"+t,A({httpMethod:"GET"},e)).then(function(e){return e.userMembership.memberType}).catch(function(){return"none"});var t}function ce(t){return re(t).then(function(e){return X(te(t)+"/content/users/"+e+"/items/"+t.id+"/delete",t)})}var pe=(le.prototype.match=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.termStack=this.termStack.concat(e),this},le.prototype.in=function(e){return this.hasRange||this.hasTerms?(e&&"*"!==e&&(this.q+=e+":"),this.commit()):(z("`in("+(e?'"'+e+'"':"")+")`"+" was called with no call to `match(...)` or `from(...)`/`to(...)`. Your query was not modified."),this)},le.prototype.startGroup=function(){return this.commit(),0<this.openGroups&&(this.q+=" "),this.openGroups++,this.q+="(",this},le.prototype.endGroup=function(){return this.openGroups<=0?z("`endGroup(...)` was called without calling `startGroup(...)` first. Your query was not modified."):(this.commit(),this.openGroups--,this.q+=")"),this},le.prototype.and=function(){return this.addModifier("and")},le.prototype.or=function(){return this.addModifier("or")},le.prototype.not=function(){return this.addModifier("not")},le.prototype.from=function(e){return this.hasTerms?z('`from(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'):this.rangeStack[0]=e,this},le.prototype.to=function(e){return this.hasTerms?z('`to(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'):this.rangeStack[1]=e,this},le.prototype.boost=function(e){return this.commit(),this.q+="^"+e,this},le.prototype.toParam=function(){return this.commit(),this.cleanup(),this.q},le.prototype.clone=function(){return this.commit(),this.cleanup(),new le(this.q+"")},le.prototype.addModifier=function(e){return this.currentModifer?(z("You have called `"+this.currentModifer+"()` after `"+e+"()`. Your current query was not modified."),this):(this.commit(),""===this.q&&"not"!==e?z("You have called `"+e+"()` without calling another method to modify your query first. Try calling `match()` first."):(this.currentModifer=e,this.q+=""===this.q?"":" ",this.q+=e.toUpperCase()+" "),this)},le.prototype.needsQuotes=function(e){return/\s|:/g.test(e)},le.prototype.formatTerm=function(e){return e instanceof Date?e.getTime():"string"==typeof e&&this.needsQuotes(e)?'"'+e+'"':e},le.prototype.commit=function(){var t=this;return this.currentModifer=void 0,this.hasRange&&(this.q+="["+this.formatTerm(this.rangeStack[0])+" TO "+this.formatTerm(this.rangeStack[1])+"]",this.rangeStack=[void 0,void 0]),this.hasTerms&&(this.q+=this.termStack.map(function(e){return t.formatTerm(e)}).join(" "),this.termStack=[]),this},Object.defineProperty(le.prototype,"hasTerms",{get:function(){return 0<this.termStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(le.prototype,"hasRange",{get:function(){return this.rangeStack.length&&this.rangeStack[0]&&this.rangeStack[1]},enumerable:!1,configurable:!0}),le.prototype.cleanup=function(){if(0<this.openGroups)for(z("Automatically closing "+this.openGroups+" group(s). You can use `endGroup(...)` to remove this warning.");0<this.openGroups;)this.q+=")",this.openGroups--;var e=this.q;this.q=e.replace(/( AND ?| NOT ?| OR ?)*$/,""),e!==this.q&&z("`startGroup(...)` was called without calling `endGroup(...)` first. Your query was not modified."),this.q=this.q.replace(/(\(\))*/,"")},le);function le(e){void 0===e&&(e=""),this.termStack=[],this.rangeStack=[],this.openGroups=0,this.q=e}function de(r,n){var o,i,e,t="string"==typeof r||r instanceof pe?{httpMethod:"GET",params:{q:r}}:(o=r,t=["q","num","start","sortField","sortOrder","searchUserAccess","searchUserName","filter","countFields","countSize","categories","categoryFilters"],(i=A(A({params:{}},{httpMethod:"GET"}),o)).params=t.reduce(function(e,t){return!o[t]&&"boolean"!=typeof o[t]||(e[t]=o[t]),e},i.params),["params","httpMethod","rawResponse","authentication","portal","fetch","maxUrlLength","headers"].reduce(function(e,t){return i[t]&&(e[t]=i[t]),e},{}));switch(n){case"item":e="/search";break;case"group":e="/community/groups";break;case"groupContent":if("string"==typeof r||r instanceof pe||!r.groupId)return Promise.reject(new Error("you must pass a `groupId` option to `searchGroupContent`"));e="/content/groups/"+r.groupId+"/search";break;default:e="/portals/self/users/search"}return X(te(t)+e,t).then(function(t){return t.nextStart&&-1!==t.nextStart&&(t.nextPage=function(){var e;return"string"==typeof r||r instanceof pe?e={q:r,start:t.nextStart}:(e=r).start=t.nextStart,de(e,n)}),t})}function fe(e){return de(e,"item")}function me(e,t){if(0===e.length)return[];for(var r=[],n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function he(e){var t=e.id,r=te(e)+"/community/groups/"+t+"/addUsers",t=Object.assign({},e,{admins:void 0,users:void 0}),t=P(ge("users",e.users,t),ge("admins",e.admins,t)).map(function(e){return X(r,e).catch(function(e){return{errors:[e]}})});return Promise.all(t).then(ve)}function ge(o,e,i){return!e||e.length<1?[]:me(e,25).map(function(e){return t=o,r=e,n=i,Object.assign({},n,((e={})[t]=r,e.params=A(A({},n.params),((n={})[t]=r,n)),e));var t,r,n})}function ve(e){var t=e.filter(function(e){return e.notAdded}).reduce(function(e,t){return e.concat(t.notAdded)},[]),e=e.filter(function(e){return e.errors}).reduce(function(e,t){return e.concat(t.errors)},[]),t={notAdded:t};return 0<e.length&&(t.errors=e),t}function ye(t){var e=t.id,r=t.users,n=te(t)+"/community/groups/"+e+"/removeUsers",r=me(r,25).map(function(e){e=A(A({},t),{users:e,params:{users:e}});return X(n,e).catch(function(e){return{errors:[e]}})});return Promise.all(r).then(function(e){var t=function(r){return e.filter(function(e){return e[r]}).reduce(function(e,t){return e.concat(t[r])},[])},r=t("errors"),t={notRemoved:t("notRemoved")};return r.length?A(A({},t),{errors:r}):t})}function be(e){var t,r=e.id,n=te(e)+"/community/groups/"+r+"/invite",e=me((t=e).users,25).map(function(e){return function(e,t){t=Object.assign({},t);return t.params=A(A({},t.params),{users:e,role:t.role,expiration:t.expiration}),t}(e,t)}).map(function(e){return X(n,e).catch(function(e){return{errors:[e]}})});return Promise.all(e).then(we)}function we(e){var t=e.every(function(e){return e.success}),e=e.reduce(function(e,t){return e.concat(t.errors||[])},[]),t={success:t};return 0<e.length&&(t.errors=e),t}function Ce(e){return X(te(e)+"/community/groups/"+e.id+"/unprotect",e)}function ke(e){return X(te(e)+"/community/groups/"+e.id+"/delete",A({},e))}function Se(e){var t=te(e)+"/community/groups/"+e.id+"/updateUsers",r={authentication:e.authentication,params:{}};return"admin"===e.newMemberType?r.params.admins=e.users:r.params.users=e.users,X(t,r)}function Te(e){var n,t=te(e)+"/portals/self/createNotification",e=me((n=e).users,n.batchSize||25).map(function(e){return t=e,r=n,(e=Object.assign({},r)).params=A(A({},e.params),{users:t,subject:r.subject,message:r.message,notificationChannelType:e.notificationChannelType}),e;var t,r}).map(function(e){return X(t,e).catch(function(e){return{errors:[e]}})});return Promise.all(e).then(Ae)}function Ae(e){var t=e.every(function(e){return e.success}),e=e.reduce(function(e,t){return e.concat(t.errors||[])},[]),t={success:t};return 0<e.length&&(t.errors=e),t}function Ie(e){var t,r,n={httpMethod:"GET"};return"string"==typeof e?r="https://www.arcgis.com/sharing/rest/community/users/"+e:(t=e.username||e.authentication.username,r=te(e)+"/community/users/"+encodeURIComponent(t),n=A(A({},e),n)),X(r,n)}function Ee(t){return fe({q:"id: "+t.id+" AND group: "+t.groupId,start:1,num:10,sortField:"title",authentication:t.authentication,httpMethod:"POST"}).then(function(e){if(0<e.total)return e.results.some(function(e){return e.id===t.id})})}function Pe(a){return Ee(a).then(function(e){if(e)return{itemId:a.id,shortcut:!0,notSharedWith:[]};var t=a.authentication.username,e=a.owner,n=a.confirmItemControl,e=e||t;if(e===t)return xe(a);var o=!1,i=!1;return Promise.all([Ie({username:t,authentication:a.authentication}),Ie({username:e,authentication:a.authentication}),ue(a)]).then(function(e){var t=e[0],r=e[1],e=e[2];return o="org_admin"===t.role&&!t.roleId,i=t.orgId!==r.orgId,function(e,t,r,n,o,i){var a=[];if(i.groupId!==e.favGroupId)if(t){if(!n)throw Error("This item can not be shared to shared editing group "+i.groupId+" by "+e.username+" as they not the item owner or org admin.");a.push(De(e,e,!1,"Error adding "+e.username+" as member to edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i),De(e,o,!0,"none"===r?"Error adding user "+o.username+" to edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.":"Error promoting user "+o.username+" to admin in edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i))}else if(n)a.push(De(e,e,!1,"Error adding "+e.username+" as member to view group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i));else if("none"===r)throw new Error("This item can not be shared by "+e.username+" as they are not a member of the specified group "+i.groupId+".");return a}(t,!!n,e,o,r,a)}).then(function(e){var t=e[0],r=(void 0===t?{promise:Promise.resolve({notAdded:[]}),revert:function(e){return Promise.resolve(e)}}:t).revert;return Promise.all(e.map(function(e){return e.promise})).then(function(){return xe(a,o,i)}).then(function(e){return r(e)})})}).then(function(e){if(e.notSharedWith.length)throw Error("Item "+a.id+" could not be shared to group "+a.groupId+".");return e})}function xe(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);var n=e.authentication.username,o=e.owner||n,i=te(e)+"/content/items/"+e.id+"/share";return(o===n||t&&!r)&&(i=te(e)+"/content/users/"+o+"/items/"+e.id+"/share"),e.params={groups:e.groupId,confirmItemControl:e.confirmItemControl},X(i,e)}function De(e,t,r,n,o){var i,a,s=t.groups||[],u=s.find(function(e){return e.id===o.groupId});if(e.orgId!==t.orgId)throw Error("User "+t.username+" is not a member of the same org as "+e.username+". Consequently they can not be added added to group "+o.groupId+" nor can item "+o.id+" be shared to the group.");if(!u&&511<s.length)throw Error("User "+t.username+" already has 512 groups, and can not be added to group "+o.groupId+". Consequently item "+o.id+" can not be shared to the group.");return a=u?r&&"member"===u.userMembership.memberType?(i=Se({id:o.groupId,users:[t.username],newMemberType:"admin",authentication:o.authentication}).then(function(e){e=e.results.reduce(function(e,t){return t.success||e.push(t.username),e},[]);return Promise.resolve({notAdded:e})}).catch(function(){return{notAdded:[t.username]}}),function(e){return Se({id:o.groupId,users:[t.username],newMemberType:"member",authentication:o.authentication}).then(function(){return e}).catch(function(){return e})}):(i=Promise.resolve({notAdded:[]}),function(e){return Promise.resolve(e)}):(i=he(((a={id:o.groupId})[r?"admins":"users"]=[t.username],a.authentication=o.authentication,a)).then(function(e){if(e.errors&&e.errors.length)throw e.errors[0];return e}).catch(function(){return{notAdded:[t.username]}}),function(e){return ye({id:o.groupId,users:[t.username],authentication:o.authentication}).then(function(){return e})}),{promise:i.then(function(e){if(e.notAdded.length)throw new Error(n);return e}),revert:a}}function Oe(o){return Ee(o).then(function(e){if(!e)return Promise.resolve({itemId:o.id,shortcut:!0,notUnsharedFrom:[]});var r=o.authentication.username,n=o.owner;return Promise.all([ue(o),Ie({username:r,authentication:o.authentication})]).then(function(e){var t=e[0],e=e[1],e="org_admin"===e.role&&!e.roleId;if(!((n||r)===r)&&!e&&["admin","owner"].indexOf(t)<0)throw Error("This item can not be unshared from group "+o.groupId+" by "+r+" as they not the item owner, an org admin, group admin or group owner.");return function(e){var t=e.authentication.username,r=e.owner||t,n=te(e)+"/content/items/"+e.id+"/unshare";r===t&&(n=te(e)+"/content/users/"+r+"/items/"+e.id+"/unshare");return e.params={groups:e.groupId},X(n,e)}(o)}).then(function(e){if(e.notUnsharedFrom.length)throw Error("Item "+o.id+" could not be unshared to group "+o.groupId);return e})})}function Re(e){if("string"==typeof e)return e.replace(/\/sharing\/rest\/?$/,"");if("object"==typeof e){var t=e.portalSelf||e,r=t.portalHostname,n=t.urlKey,o=t.customBaseUrl;if(r||n&&o)return t.isPortal?"https://"+t.portalHostname:"https://"+t.urlKey+"."+t.customBaseUrl}return Re(te(e))}var Ne={devext:"https://d1011m9qpnz5mw.cloudfront.net",qaext:"https://dyq9ux9ryu4qj.cloudfront.net",www:"https://d1iq7pbacwn5rb.cloudfront.net"};function _e(e){if(e.isPortal)return Re(e)+"/apps/sites";e=e.portalHostname.split(".")[0];return(Ne[e]||Ne.www)+"/opendata-ui/assets"}function Ue(e){return Re(e)+"/sharing/rest"}function je(e){return e=(e=e.toLowerCase()).includes("//")?e.split("//")[1]:e}function Le(e){var t;return e.match(/(qaext|\.mapsqa)\.arcgis.com/)?t="https://hubqa.arcgis.com":e.match(/(devext|\.mapsdevext)\.arcgis.com/)?t="https://hubdev.arcgis.com":e.match(/(www|\.maps)\.arcgis.com/)&&(t="https://hub.arcgis.com"),t}function Me(e){if(e.isPortal)throw new Error("Hub Url is not available in ArcGIS Enterprise");return Le(e.portalHostname)}var Ge=function(e,t,r){var n=e.id,e=e.access,t=Ue(t)+"/content/items/"+n,n=new URLSearchParams({f:"json"});return"public"!==e&&r&&n.append("token",r),t+"?"+n.toString()},Be=/\/(map|feature)server/i,qe=function(e){e=e.match(Be),e=e&&e[1];return e&&h(e)+" Service"};function Fe(e){var t=e&&e.hubApiUrl;return t||Le(Ue(e))}function Ye(e,t){return t.rawResponse=!1,X(e,t).then(function(e){var t={token:e.access_token,username:e.username,expires:new Date(Date.now()+(1e3*e.expires_in-1e3)),ssl:!0===e.ssl};return e.refresh_token&&(t.refreshToken=e.refresh_token),t})}function He(e,t){return"undefined"!=typeof window&&window.location&&window.location.host?t.params.referer=window.location.host:t.params.referer=J,X(e,t)}var We=/^https?:\/\/(\S+)\.arcgis\.com.+/;function ze(e){return We.test(e)}function Ve(e){if(!We.test(e))return null;e=e.match(We)[1].split(".").pop();return e.includes("dev")?"dev":e.includes("qa")?"qa":"production"}function Je(e,t){t=Z(function(e){if(!We.test(e))return e;switch(Ve(e)){case"dev":return"https://devext.arcgis.com/sharing/rest";case"qa":return"https://qaext.arcgis.com/sharing/rest";default:return"https://www.arcgis.com/sharing/rest"}}(t)).replace(/https?:\/\//,""),e=Z(e).replace(/https?:\/\//,"");return new RegExp(e,"i").test(t)}var Ke=(Object.defineProperty($e.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),Object.defineProperty($e.prototype,"tokenExpires",{get:function(){return this._tokenExpires},enumerable:!1,configurable:!0}),Object.defineProperty($e.prototype,"refreshToken",{get:function(){return this._refreshToken},enumerable:!1,configurable:!0}),Object.defineProperty($e.prototype,"refreshTokenExpires",{get:function(){return this._refreshTokenExpires},enumerable:!1,configurable:!0}),Object.defineProperty($e.prototype,"trustedServers",{get:function(){return console.log("DEPRECATED: use federatedServers instead"),this.federatedServers},enumerable:!1,configurable:!0}),$e.beginOAuth2=function(e,t){void 0===t&&(t=window),e.duration&&console.log("DEPRECATED: 'duration' is deprecated - use 'expiration' instead");var r=A({portal:"https://www.arcgis.com/sharing/rest",provider:"arcgis",expiration:20160,popup:!0,popupWindowFeatures:"height=400,width=600,menubar=no,location=yes,resizable=yes,scrollbars=yes,status=yes",state:e.clientId,locale:""},e),n=r.portal,o=r.provider,i=r.clientId,a=r.expiration,s=r.redirectUri,u=r.popup,c=r.popupWindowFeatures,p=r.state,l=r.locale,r=r.params,l="arcgis"===o?n+"/oauth2/authorize?client_id="+i+"&response_type=token&expiration="+(e.duration||a)+"&redirect_uri="+encodeURIComponent(s)+"&state="+p+"&locale="+l:n+"/oauth2/social/authorize?client_id="+i+"&socialLoginProviderName="+o+"&autoAccountCreateForSocial=true&response_type=token&expiration="+(e.duration||a)+"&redirect_uri="+encodeURIComponent(s)+"&state="+p+"&locale="+l;if(r&&(l=l+"&"+H(r)),u){var d,f=((d={promise:null,resolve:null,reject:null}).promise=new Promise(function(e,t){d.resolve=e,d.reject=t}),d);return t["__ESRI_REST_AUTH_HANDLER_"+i]=function(e,t){e?(e=JSON.parse(e),f.reject(new $(e.errorMessage,e.error))):t&&(t=JSON.parse(t),f.resolve(new $e({clientId:i,portal:n,ssl:t.ssl,token:t.token,tokenExpires:new Date(t.expires),username:t.username})))},t.open(l,"oauth-window",c),f.promise}t.location.href=l},$e.completeOAuth2=function(e,o){void 0===o&&(o=window);var t=A({portal:"https://www.arcgis.com/sharing/rest",popup:!0},e),i=t.portal,a=t.clientId,s=t.popup;function r(e,t){try{var r=void 0,n="__ESRI_REST_AUTH_HANDLER_"+a;if(s&&(o.opener?o.opener.parent&&o.opener.parent[n]?r=o.opener.parent[n]:o.opener&&o.opener[n]&&(r=o.opener[n]):o!==o.parent&&o.parent&&o.parent[n]&&(r=o.parent[n]),r))return r(e?JSON.stringify(e):void 0,JSON.stringify(t)),void o.close()}catch(e){throw new $('Unable to complete authentication. It\'s possible you specified popup based oAuth2 but no handler from "beginOAuth2()" present. This generally happens because the "popup" option differs between "beginOAuth2()" and "completeOAuth2()".')}if(e)throw new $(e.errorMessage,e.error);return new $e({clientId:a,portal:i,ssl:t.ssl,token:t.token,tokenExpires:t.expires,username:t.username})}e=ee(o.location.hash);if(!e.access_token){var n=void 0,u="Unknown error";return e.error&&(n=e.error,u=e.error_description),r({error:n,errorMessage:u})}t=e.access_token,n=new Date(Date.now()+1e3*parseInt(e.expires_in,10)-6e4),u=e.username;return r(void 0,{token:t,expires:n,ssl:"true"===e.ssl,username:u})},$e.fromParent=function(e,n){var o;return!n&&window&&(n=window),new Promise(function(t,r){o=function(e){if(e.source===n.parent&&e.data)try{return t($e.parentMessageHandler(e))}catch(e){return r(e)}},n.addEventListener("message",o,!1),n.parent.postMessage({type:"arcgis:auth:requestCredential"},e)}).then(function(e){return n.removeEventListener("message",o,!1),e})},$e.authorize=function(e,t){e.duration&&console.log("DEPRECATED: 'duration' is deprecated - use 'expiration' instead");var r=A({portal:"https://arcgis.com/sharing/rest",expiration:20160},e),n=r.portal,o=r.clientId,i=r.expiration,r=r.redirectUri;t.writeHead(301,{Location:n+"/oauth2/authorize?client_id="+o+"&expiration="+(e.duration||i)+"&response_type=code&redirect_uri="+encodeURIComponent(r)}),t.end()},$e.exchangeAuthorizationCode=function(e,t){var e=A({portal:"https://www.arcgis.com/sharing/rest",refreshTokenTTL:20160},e),r=e.portal,n=e.clientId,o=e.redirectUri,i=e.refreshTokenTTL;return Ye(r+"/oauth2/token",{params:{grant_type:"authorization_code",client_id:n,redirect_uri:o,code:t}}).then(function(e){return new $e({clientId:n,portal:r,ssl:e.ssl,redirectUri:o,refreshToken:e.refreshToken,refreshTokenTTL:i,refreshTokenExpires:new Date(Date.now()+60*(i-1)*1e3),token:e.token,tokenExpires:e.expires,username:e.username})})},$e.deserialize=function(e){e=JSON.parse(e);return new $e({clientId:e.clientId,refreshToken:e.refreshToken,refreshTokenExpires:new Date(e.refreshTokenExpires),username:e.username,password:e.password,token:e.token,tokenExpires:new Date(e.tokenExpires),portal:e.portal,ssl:e.ssl,tokenDuration:e.tokenDuration,redirectUri:e.redirectUri,refreshTokenTTL:e.refreshTokenTTL})},$e.fromCredential=function(e){var t=void 0===e.ssl||e.ssl,r=e.expires||Date.now()+72e5;return new $e({portal:e.server.includes("sharing/rest")?e.server:e.server+"/sharing/rest",ssl:t,token:e.token,username:e.userId,tokenExpires:new Date(r)})},$e.parentMessageHandler=function(e){if("arcgis:auth:credential"===e.data.type)return $e.fromCredential(e.data.credential);if("arcgis:auth:error"!==e.data.type)throw new Error("Unknown message type.");var t=new Error(e.data.error.message);throw t.name=e.data.error.name,t},$e.prototype.toCredential=function(){return{expires:this.tokenExpires.getTime(),server:this.portal,ssl:this.ssl,token:this.token,userId:this.username}},$e.prototype.getUser=function(e){var t=this;if(this._pendingUserRequest)return this._pendingUserRequest;if(this._user)return Promise.resolve(this._user);var r=this.portal+"/community/self",e=A(A({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingUserRequest=X(r,e).then(function(e){return t._user=e,t._pendingUserRequest=null,e}),this._pendingUserRequest},$e.prototype.getPortal=function(e){var t=this;if(this._pendingPortalRequest)return this._pendingPortalRequest;if(this._portalInfo)return Promise.resolve(this._portalInfo);var r=this.portal+"/portals/self",e=A(A({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingPortalRequest=X(r,e).then(function(e){return t._portalInfo=e,t._pendingPortalRequest=null,e}),this._pendingPortalRequest},$e.prototype.getUsername=function(){return this.username?Promise.resolve(this.username):this._user?Promise.resolve(this._user.username):this.getUser().then(function(e){return e.username})},$e.prototype.getToken=function(e,t){return r=this.portal,n=e,o=ze(r),i=ze(n),r=Ve(r),n=Ve(n),o&&i&&r===n||new RegExp(this.portal,"i").test(e)?this.getFreshToken(t):this.getTokenForServer(e,t);var r,n,o,i},$e.prototype.validateAppAccess=function(r){return this.getToken(this.portal).then(function(e){return X((t=void 0===t?"https://www.arcgis.com/sharing/rest":t)+"/oauth2/validateAppAccess",{method:"POST",params:{f:"json",client_id:r,token:e}});var t})},$e.prototype.toJSON=function(){return{clientId:this.clientId,refreshToken:this.refreshToken,refreshTokenExpires:this.refreshTokenExpires,username:this.username,password:this.password,token:this.token,tokenExpires:this.tokenExpires,portal:this.portal,ssl:this.ssl,tokenDuration:this.tokenDuration,redirectUri:this.redirectUri,refreshTokenTTL:this.refreshTokenTTL}},$e.prototype.serialize=function(){return JSON.stringify(this)},$e.prototype.enablePostMessageAuth=function(e,t){!t&&window&&(t=window),this._hostHandler=this.createPostMessageHandler(e),t.addEventListener("message",this._hostHandler,!1)},$e.prototype.disablePostMessageAuth=function(e){(e=!e&&window?window:e).removeEventListener("message",this._hostHandler,!1)},$e.prototype.refreshSession=function(e){return this._user=null,this.username&&this.password?this.refreshWithUsernameAndPassword(e):this.clientId&&this.refreshToken?this.refreshWithRefreshToken():Promise.reject(new $("Unable to refresh token."))},$e.prototype.getServerRootUrl=function(e){var t=Z(e).split(/\/rest(\/admin)?\/services(?:\/|#|\?|$)/)[0].match(/(https?:\/\/)(.+)/);t[0];var r=t[1],e=t[2].split("/"),t=e[0],e=e.slice(1);return""+r+t.toLowerCase()+"/"+e.join("/")},$e.prototype.getDomainCredentials=function(t){return this.trustedDomains&&this.trustedDomains.length&&this.trustedDomains.some(function(e){return t.startsWith(e)})?"include":"same-origin"},$e.prototype.createPostMessageHandler=function(n){var o=this;return function(e){var t=-1<n.indexOf(e.origin),r="arcgis:auth:requestCredential"===e.data.type;t&&r&&((r=o.toCredential()).server=r.server.replace("/sharing/rest",""),e.source.postMessage({type:"arcgis:auth:credential",credential:r},e.origin))}},$e.prototype.getTokenForServer=function(t,r){var n=this,o=this.getServerRootUrl(t),e=this.federatedServers[o];return e&&e.expires&&e.expires.getTime()>Date.now()?Promise.resolve(e.token):this._pendingTokenRequests[o]||(this._pendingTokenRequests[o]=this.fetchAuthorizedDomains().then(function(){return X(o+"/rest/info",{credentials:n.getDomainCredentials(t)}).then(function(e){if(e.owningSystemUrl){if(Je(e.owningSystemUrl,n.portal))return X(e.owningSystemUrl+"/sharing/rest/info",r);throw new $(t+" is not federated with "+n.portal+".","NOT_FEDERATED")}if(e.authInfo&&void 0!==n.federatedServers[o])return Promise.resolve({authInfo:e.authInfo});throw new $(t+" is not federated with any portal and is not explicitly trusted.","NOT_FEDERATED")}).then(function(e){return e.authInfo.tokenServicesUrl}).then(function(e){return n.token&&n.tokenExpires.getTime()>Date.now()?He(e,{params:{token:n.token,serverUrl:t,expiration:n.tokenDuration,client:"referer"}}):He(e,{params:{username:n.username,password:n.password,expiration:n.tokenDuration,client:"referer"}}).then(function(e){return n._token=e.token,n._tokenExpires=new Date(e.expires),e})}).then(function(e){return n.federatedServers[o]={expires:new Date(e.expires),token:e.token},delete n._pendingTokenRequests[o],e.token})}),this._pendingTokenRequests[o])},$e.prototype.getFreshToken=function(e){var t=this;return this.token&&!this.tokenExpires||this.token&&this.tokenExpires&&this.tokenExpires.getTime()>Date.now()?Promise.resolve(this.token):(this._pendingTokenRequests[this.portal]||(this._pendingTokenRequests[this.portal]=this.refreshSession(e).then(function(e){return t._pendingTokenRequests[t.portal]=null,e.token})),this._pendingTokenRequests[this.portal])},$e.prototype.refreshWithUsernameAndPassword=function(e){var t=this,e=A({params:{username:this.username,password:this.password,expiration:this.tokenDuration}},e);return He(this.portal+"/generateToken",e).then(function(e){return t._token=e.token,t._tokenExpires=new Date(e.expires),t})},$e.prototype.refreshWithRefreshToken=function(e){var t=this;if(this.refreshToken&&this.refreshTokenExpires&&this.refreshTokenExpires.getTime()<Date.now())return this.refreshRefreshToken(e);e=A({params:{client_id:this.clientId,refresh_token:this.refreshToken,grant_type:"refresh_token"}},e);return Ye(this.portal+"/oauth2/token",e).then(function(e){return t._token=e.token,t._tokenExpires=e.expires,t})},$e.prototype.refreshRefreshToken=function(e){var t=this,e=A({params:{client_id:this.clientId,refresh_token:this.refreshToken,redirect_uri:this.redirectUri,grant_type:"exchange_refresh_token"}},e);return Ye(this.portal+"/oauth2/token",e).then(function(e){return t._token=e.token,t._tokenExpires=e.expires,t._refreshToken=e.refreshToken,t._refreshTokenExpires=new Date(Date.now()+60*(t.refreshTokenTTL-1)*1e3),t})},$e.prototype.fetchAuthorizedDomains=function(){var t=this;return this.server||!this.portal?Promise.resolve(this):this.getPortal().then(function(e){return e.authorizedCrossOriginDomains&&e.authorizedCrossOriginDomains.length&&(t.trustedDomains=e.authorizedCrossOriginDomains.filter(function(e){return!e.startsWith("http://")}).map(function(e){return e.startsWith("https://")?e:"https://"+e})),t})},$e);function $e(e){var t;this.clientId=e.clientId,this._refreshToken=e.refreshToken,this._refreshTokenExpires=e.refreshTokenExpires,this.username=e.username,this.password=e.password,this._token=e.token,this._tokenExpires=e.tokenExpires,this.portal=e.portal?Z(e.portal):"https://www.arcgis.com/sharing/rest",this.ssl=e.ssl,this.provider=e.provider||"arcgis",this.tokenDuration=e.tokenDuration||20160,this.redirectUri=e.redirectUri,this.refreshTokenTTL=e.refreshTokenTTL||20160,this.server=e.server,this.federatedServers={},this.trustedDomains=[],e.server&&(t=this.getServerRootUrl(e.server),this.federatedServers[t]={token:e.token,expires:e.tokenExpires}),this._pendingTokenRequests={}}var Qe={app:["Application","City Engine Web Scene","CityEngine Web Scene","Dashboard","Insights Page","Insights Workbook","Operation View","Web Mapping Application","StoryMap","Web Experience","Urban Model"],dataset:["CSV Collection","CSV","Feature Collection Template","Feature Collection","Feature Layer","Feature Service","File Geodatabase","GeoJSON","GeoJson","KML Collection","KML","Microsoft Excel","Raster Layer","Shapefile","Stream Service","Table"],document:["CAD Drawing","Document Link","Hub Page","Site Page","Image","iWork Keynote","iWork Numbers","iWork Pages","Microsoft Powerpoint","Microsoft Visio","Microsoft Word","Notebook","PDF","Pro Map","Report Template"],event:["Hub Event"],feedback:["Form","Quick Capture Project"],initiative:["Hub Initiative"],template:["Hub Initiative Template"],solution:["Solution"],map:["Image Collection","Image Service","Map Service Layer","Map Service","Scene Service","Scene Layer","Vector Tile Service","Web Map Service","Web Map Tile Service","Web Map","Web Scene","WFS","WMS","WMTS"],other:["360 VR Experience","AppBuilder Widget Package","Application Configuration","ArcPad Package","Code Attachment","Code Sample","Desktop Add In","Desktop Application Template","Desktop Application","Desktop Style","Explorer Add In","Explorer Layer","Geocoding Service","Geometry Service","Geoprocessing Package","Geoprocessing Sample","Geoprocessing Service","Layer File","Layer Package","Layer Template","Layer","Layout","Locator Package","Map Area","Map Document","Map Package","Map Service Definition","Map Template","Mobile Application","Mobile Map Package","Native Application","Network Analysis Service","Operations Dashboard Add In","Project Package","Project Template","Raster Function Template","Rule Package","Scene Package","Service Definition","SQLite Geodatabase","Style","Tile Package","Vector Tile Package","Workflow Manager Package"],site:["Hub Site Application","Site Application"]},Xe=Qe.app,Ze=Qe.dataset,et=Qe.document,tt=Qe.event,rt=Qe.feedback,nt=Qe.initiative,ot=Qe.map,it=Qe.other,at=Qe.site,st=["360 VR Experience","Application","CityEngine Web Scene","Code Sample","CSV Collection","CSV","CAD Drawing","Desktop Application","Desktop Application Template","Desktop Style","File Geodatabase","GeoJson","Geoprocessing Package","Geoprocessing Sample","Image","iWork Keynote","iWork Numbers","KML Collection","KML","Layer","Layer File","Layer Package","Layout","Locator Package","Map Package","Map Service Definition","Map Template","Microsoft Excel","Microsoft Powerpoint","Microsoft Visio","Microsoft Word","Notebook","Operations Dashboard Add In","PDF","Pro Map","Project Package","Project Template","Raster function template","Rule Package","Service Definition","Shapefile","Vector Tile Package","Workflow Manager Package"],ut=["Data"],ct={app:Xe.concat(rt),dataset:Ze,document:et,event:tt,initiative:nt,map:ot,other:it,site:at,downloadableTypes:st,downloadableTypeKeywords:ut,apiTypes:["Feature Service","Map Service","Image Service"]};function pt(e){return-1!==st.indexOf(e.type)||e.typeKeywords&&ut.some(function(t){return e.typeKeywords.some(function(e){return e===t})})}function lt(e,t,r,n,o){return{xmin:e,ymin:t,xmax:r,ymax:n,spatialReference:{wkid:o=void 0===o?4326:o}}}function dt(e){return[[e.xmin,e.ymin],[e.xmax,e.ymax]]}var ft={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}};function mt(e){var t=e.portalSelf,r=t.defaultExtent,t=d(t,"helperServices.geometry.url");if(!t)return Promise.resolve(ft);if(!r)return Promise.resolve(ft);t+="/project",r={httpMethod:"POST",params:{geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[r]}),transformForward:!1,transformation:"",inSR:r.spatialReference.wkid,outSR:4326,f:"json"}};return e.authentication&&(r.authentication=e.authentication),X(t,r).then(function(e){e=e.geometries[0];return{xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:e.ymax,spatialReference:{wkid:4326}}}).catch(function(e){return ft})}function ht(e){return Array.isArray(e)&&Array.isArray(e[0])&&Array.isArray(e[1])}var gt=[{type:"CC0-1.0",abbr:"CC0",name:"Public Domain Dedication",url:"http://creativecommons.org/publicdomain/zero/1.0"},{type:"CC-BY-4.0",abbr:"CC BY",name:"Attribution 4.0 International",url:"http://creativecommons.org/licenses/by/4.0"},{type:"CC-BY-3.0",abbr:"CC BY 3.0",name:"Attribution 3.0 Unported",url:"http://creativecommons.org/licenses/by/3.0"},{type:"CC-BY-2.5",abbr:"CC BY 2.5",name:"Attribution 2.5 Generic",url:"http://creativecommons.org/licenses/by/2.5"},{type:"CC-BY-2.0",abbr:"CC BY 2.0",name:"Attribution 2.0 Generic",url:"http://creativecommons.org/licenses/by/2.0"},{type:"CC-BY-1.0",abbr:"CC BY 1.0",name:"Attribution 1.0 Generic",url:"http://creativecommons.org/licenses/by/1.0"},{type:"CC-BY-SA-4.0",abbr:"CC BY-SA",name:"Attribution-ShareAlike 4.0 International",url:"http://creativecommons.org/licenses/by-sa/4.0"},{type:"CC-BY-SA-3.0",abbr:"CC BY-SA 3.0",name:"Attribution-ShareAlike 3.0 Unported",url:"http://creativecommons.org/licenses/by-sa/3.0"},{type:"CC-BY-SA-2.5",abbr:"CC BY-SA 2.5",name:"Attribution-ShareAlike 2.5 Generic",url:"http://creativecommons.org/licenses/by-sa/2.5"},{type:"CC-BY-SA-2.0",abbr:"CC BY-SA 2.0",name:"Attribution-ShareAlike 2.0 Generic",url:"http://creativecommons.org/licenses/by-sa/2.0"},{type:"CC-BY-SA-1.0",abbr:"CC BY-SA 1.0",name:"Attribution-ShareAlike 1.0 Generic",url:"http://creativecommons.org/licenses/by-sa/1.0"},{type:"CC-BY-ND-4.0",abbr:"CC BY-ND",name:"Attribution-NoDerivatives 4.0 International",url:"http://creativecommons.org/licenses/by-nd/4.0"},{type:"CC-BY-ND-3.0",abbr:"CC BY-ND 3.0",name:"Attribution-NoDerivs 3.0 Unported",url:"http://creativecommons.org/licenses/by-nd/3.0"},{type:"CC-BY-ND-2.5",abbr:"CC BY-ND 2.5",name:"Attribution-NoDerivs 2.5 Generic",url:"http://creativecommons.org/licenses/by-nd/2.5"},{type:"CC-BY-ND-2.0",abbr:"CC BY-ND 2.0",name:"Attribution-NoDerivs 2.0 Generic",url:"http://creativecommons.org/licenses/by-nd/2.0"},{type:"CC-BY-ND-1.0",abbr:"CC BY-ND 1.0",name:"Attribution-NoDerivs 1.0 Generic",url:"http://creativecommons.org/licenses/by-nd/1.0"},{type:"CC-BY-NC-4.0",abbr:"CC BY-NC",name:"Attribution-NonCommercial 4.0 International",url:"https://creativecommons.org/licenses/by-nc/4.0"},{type:"CC-BY-NC-3.0",abbr:"CC BY-NC 3.0",name:"Attribution-NonCommercial 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc/3.0"},{type:"CC-BY-NC-2.5",abbr:"CC BY-NC 2.5",name:"Attribution-NonCommercial 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc/2.5"},{type:"CC-BY-NC-2.0",abbr:"CC BY-NC 2.0",name:"Attribution-NonCommercial 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc/2.0"},{type:"CC-BY-NC-1.0",abbr:"CC BY-NC 1.0",name:"Attribution-NonCommercial 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc/1.0"},{type:"CC-BY-NC-SA-4.0",abbr:"CC BY-NC-SA",name:"Attribution-NonCommercial-ShareAlike 4.0 International",url:"https://creativecommons.org/licenses/by-nc-sa/4.0"},{type:"CC-BY-NC-SA-3.0",abbr:"CC BY-NC-SA 3.0",name:"Attribution-NonCommercial-ShareAlike 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc-sa/3.0"},{type:"CC-BY-NC-SA-2.5",abbr:"CC BY-NC-SA 2.5",name:"Attribution-NonCommercial-ShareAlike 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/2.5"},{type:"CC-BY-NC-SA-2.0",abbr:"CC BY-NC-SA 2.0",name:"Attribution-NonCommercial-ShareAlike 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/2.0"},{type:"CC-BY-NC-SA-1.0",abbr:"CC BY-NC-SA 1.0",name:"Attribution-NonCommercial-ShareAlike 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/1.0"},{type:"CC-BY-NC-ND-4.0",abbr:"CC BY-NC-ND",name:"Attribution-NonCommercial-NoDerivatives 4.0 International",url:"https://creativecommons.org/licenses/by-nc-nd/4.0"},{type:"CC-BY-NC-ND-3.0",abbr:"CC BY-NC-ND 3.0",name:"Attribution-NonCommercial-NoDerivs 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc-nd/3.0"},{type:"CC-BY-NC-ND-2.5",abbr:"CC BY-NC-ND 2.5",name:"Attribution-NonCommercial-NoDerivs 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/2.5"},{type:"CC-BY-NC-ND-2.0",abbr:"CC BY-NC-ND 2.0",name:"Attribution-NonCommercial-NoDerivs 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/2.0"},{type:"CC-BY-NC-ND-1.0",abbr:"CC BY-NC-ND 1.0",name:"Attribution-NonCommercial-NoDerivs 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/1.0"},{type:"PDDL-1.0",abbr:"PDDL",name:"ODC Public Domain Dedication and License",url:"http://opendatacommons.org/licenses/pddl/summary"},{type:"ODbL-1.0",abbr:"ODbL",name:"ODC Open Database License",url:"http://opendatacommons.org/licenses/odbl/summary"},{type:"ODC-BY-1.0",abbr:"ODC BY",name:"ODC Attribution License",url:"http://opendatacommons.org/licenses/by/summary"}];function vt(r){var e={type:(r=r||"")?"custom":"none",text:r},t=!1,n=gt.filter(function(e){return t=e,(e=(e=r).toLowerCase()).includes(t.name.toLowerCase())||e.includes(t.url.toLowerCase())||e.includes(t.abbr.toLowerCase());var t});return n.length&&(t=!0,e=n.pop()),t||(n=void 0,!function(e){try{return!!new URL(e).protocol}catch(e){return!1}}(r)?(t=r,new RegExp(/^<a[\s]+(href\s?=\s?["'].*?["'])+([^>]?)>((?:.(?!\<\/a\>))*.)?<\/a>$|^<a[\s]+(href\s?=\s?["'].*?["'])+([^>]?)\/>/).test(t)&&(t=new RegExp(/href\s?=\s?["'](.*?)["']/),n=r.match(t)[1])):n=r,n&&(e.url=n,e.text="")),e.text||delete e.text,e}var yt={};function bt(e){void 0===e&&(e=""),console.warn("DEPRECATED: Use getCollection() instead. getCategory will be removed at v9.0.0");e=Ct(e);return"feedback"===e?"app":e}function wt(e){var t=(e=void 0===e?{}:e).type,r=e.typeKeywords||[];return("Site Application"===e.type||"Web Mapping Application"===e.type&&S(r,"hubSite"))&&(t="Hub Site Application"),("Site Page"===e.type||"Web Mapping Application"===e.type&&S(r,"hubPage"))&&(t="Hub Page"),"Hub Initiative"===e.type&&S(r,"hubInitiativeTemplate")&&(t="Hub Initiative Template"),t="Web Mapping Application"===e.type&&S(r,"hubSolutionTemplate")?"Solution":t}function Ct(e){if(yt[e=void 0===e?"":e])return yt[e];for(var t=0,r=Object.keys(Qe);t<r.length;t++)for(var n=r[t],o=0,i=Qe[n];o<i.length;o++){var a=i[o];if(e.toLowerCase()===a.toLowerCase())return yt[e]=n}}function kt(e){return e&&"feature service"===e.toLowerCase()}function St(e){return(e=e&&e.match(/\/\d+$/))&&e[0].slice(1)}function Tt(e){return St(e.url)||kt(e.type)&&S(e.typeKeywords,"Singlelayer")&&"0"}function At(t,e){if(S(["template","feedback"],t.family))return t.id;if(Mt(t)){var r=(d(e,"data.values.pages")||[]).find(function(e){return e.id===t.id});return r?r.slug:t.id}if(t.slug){r=d(e,"domainInfo.orgKey");return d(e,"data.values.isUmbrella")?t.slug:Et(t.slug,r)}return t.hubId||t.id}function It(e){e=e?e.split("_"):[];return{itemId:e[0],layerId:e[1]}}function Et(e,t){return t&&e.match(t+"::")?e.split(t+"::")[1]:e}function Pt(e){if(!e)return e;var t=["categories",""];return e.map(function(e){return e.split("/")}).reduce(function(e,t,r){return P(e,t)},[]).filter(function(e){return!S(t,e.toLowerCase())})}function xt(e){var t,r;switch((e||"").toLowerCase()){case"image service":t="dataset";break;case"feature service":case"raster layer":t="map";break;case"microsoft excel":t="document";break;case"cad drawing":case"feature collection template":case"report template":t="content";break;default:t={other:"content",solution:"template"}[r=Ct(e)]||r}return t}function Dt(e){return console.warn("DEPRECATED: Use getFamily() instead. getItemHubType() will be removed at v9.0.0"),Ct(wt(e="string"==typeof e?{type:e}:e))}function Ot(e){var t=new Date(e.created),r="item.created",n=e.properties,r=Object.assign({},e,{identifier:e.id,errors:[],item:e,name:e.title,hubType:Dt(e),categories:Pt(e.categories),itemCategories:e.categories,summary:e.snippet||e.description,publisher:{name:e.owner,username:e.owner},permissions:{visibility:e.access,control:e.itemControl||"view"},actionLinks:n&&n.links,hubActions:n&&n.actions,metrics:n&&n.metrics,isDownloadable:pt(e),boundary:(n=e.extent)&&n.length&&{geometry:lt(n[0][0],n[0][1],n[1][0],n[1][1])},license:{name:"Custom License",description:e.accessInformation},createdDate:t,createdDateSource:r,publishedDate:t,publishedDateSource:r,updatedDate:new Date(e.modified),updatedDateSource:"item.modified",structuredLicense:vt(e.licenseInfo)});return _t(r,e.type)}function Rt(e){if(e){var t=e.id,r=e.attributes;if(r){var n=It(t).itemId,o=r.owner,i=r.orgId,a=r.created,s=r.modified,u=r.name,c=r.title,p=r.type,l=r.typeKeywords,d=r.description,f=r.snippet,m=r.tags,h=r.thumbnail,g=r.categories,v=r.contentStatus,y=r.spatialReference,b=r.accessInformation,w=r.licenseInfo,C=r.culture,k=r.url,S=r.access,T=r.proxyFilter,A=r.properties,I=r.appCategories,E=r.industries,P=r.languages,x=r.largeThumbnail,D=r.banner,O=r.screenshots,R=r.listed,N=r.ownerFolder,_=r.size,U=r.protected,j=r.commentsEnabled,L=r.numComments,M=r.numRatings,G=r.avgRating,B=r.numViews,q=r.itemControl,F=r.scoreCompleteness,Y=r.itemExtent,e=r.itemModified,t=r.modifiedProvenance,r=r.serviceSpatialReference;return{id:n,owner:o,orgId:i,created:a,modified:e||"item.modified"===t&&s,title:c||u,type:k&&qe(k)||p,typeKeywords:l,description:d,tags:m,snippet:f,thumbnail:h,extent:Y||[],categories:g,contentStatus:v,spatialReference:y||r,accessInformation:b,licenseInfo:w,culture:C,url:k,access:S,size:_,protected:U,proxyFilter:T,properties:A,appCategories:I,industries:E,languages:P,largeThumbnail:x,banner:D,screenshots:O,listed:R,ownerFolder:N,commentsEnabled:j,numComments:L,numRatings:M,avgRating:G,numViews:B,itemControl:q,scoreCompleteness:F}}}}function Nt(e,t){var r=e.id,r=e.slug||t||r,r=A(A({},e),{hubId:t,identifier:r});return Ut(r,{relative:jt(r)})}var _t=function(e,t){var r=xt(t),n=wt(A(A({},e.item),{type:t})),n=A(A({},e),{type:t,family:r,normalizedType:n});return Ut(n,{relative:jt(n)})},Ut=function(e,t){t=A(A({},e.urls),t);return A(A({},e),{urls:t})},jt=function(e,t){var r=e.family,n=t||e.identifier,o=Lt(e);return o||(t="/content","feedback"===e.family?t="/feedback/surveys":Mt(e)?t="/pages":-1<["app","dataset","document","map","template"].indexOf(r)&&(t="/"+r+"s"),o=t+"/"+n),o},Lt=function(e){var t,r=e.normalizedType,n=e.identifier;return"Solution"===r&&(0<(null===(e=e.typeKeywords)||void 0===e?void 0:e.indexOf("Deployed"))&&(t="/content/"+n),t="/templates/"+n+"/about"),t},Mt=function(e){return S(["Hub Page","Site Page"],e.type)};const Gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";const Bt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var qt={atob:function(t){if((t=(t=(t=`${t}`).replace(/[ \t\n\f\r]/g,"")).length%4==0?t.replace(/==?$/,""):t).length%4==1||/[^+/0-9A-Za-z]/.test(t))return null;let r="",n=0,o=0;for(let e=0;e<t.length;e++)n<<=6,n|=function(e){e=Gt.indexOf(e);return e<0?void 0:e}(t[e]),o+=6,24===o&&(r+=String.fromCharCode((16711680&n)>>16),r+=String.fromCharCode((65280&n)>>8),r+=String.fromCharCode(255&n),n=o=0);return 12===o?(n>>=4,r+=String.fromCharCode(n)):18===o&&(n>>=2,r+=String.fromCharCode((65280&n)>>8),r+=String.fromCharCode(255&n)),r},btoa:function(e){let t;for(e=`${e}`,t=0;t<e.length;t++)if(255<e.charCodeAt(t))return null;let r="";for(t=0;t<e.length;t+=3){const n=[void 0,void 0,void 0,void 0];n[0]=e.charCodeAt(t)>>2,n[1]=(3&e.charCodeAt(t))<<4,e.length>t+1&&(n[1]|=e.charCodeAt(t+1)>>4,n[2]=(15&e.charCodeAt(t+1))<<2),e.length>t+2&&(n[2]|=e.charCodeAt(t+2)>>6,n[3]=63&e.charCodeAt(t+2));for(let e=0;e<n.length;e++)void 0===n[e]?r+="=":r+=function(e){if(0<=e&&e<64)return Bt[e];return}(n[e])}return r}},Ft="4326",Yt={csv:{name:"CSV",itemTypes:["CSV","CSV Collection"],supportsProjection:!0},kml:{name:"KML",itemTypes:["KML","KML Collection"],supportsProjection:!1},shapefile:{name:"Shapefile",itemTypes:["Shapefile"],supportsProjection:!0},fileGeodatabase:{name:"File Geodatabase",itemTypes:["File Geodatabase"],supportsProjection:!0},geojson:{name:"GeoJson",itemTypes:["GeoJson"],supportsProjection:!1},excel:{name:"Excel",itemTypes:["Microsoft Excel"],supportsProjection:!0},featureCollection:{name:"Feature Collection",itemTypes:["Feature Collection"],supportsProjection:!0}};function Ht(e){if("object"!=typeof e)return e;var t=e.wkid,e=e.wkt;return t?t+"":qt.btoa(e)}function Wt(e){return"spatialRefId:"+Ht(function(t){var r;try{r=JSON.parse(t)}catch(e){r=t}return r}(e))}function zt(e){return"exportItem:"+e}function Vt(e){return e?"exportLayer:0"+e:"exportLayer:null"}function Jt(e){var t,r=e.autoAddResult,n=e.inviteResult,o=e.primaryEmailResult,e=e.secondaryEmailResult;return(o||e)&&(t={success:(e=[o,e].filter(function(e){return e})).every(function(e){return e.success})},(e=e.reduce(function(e,t){return e.concat(y(t,"errors",[]))},[])).length&&(t.errors=e)),{success:[r,n,t].filter(function(e){return e}).every(function(e){return e.success}),autoAdd:r,invite:n,email:t}}function Kt(t,e){var r;return t&&(r=!d(t,"notAdded.length")&&!t.errors,e.autoAddResult={success:r},r||(r=t.errors||[],d(t,"notAdded.length")&&r.push(new W("Users not auto-added: "+t.notAdded.join(", "))),e.autoAddResult.errors=r,r=e.usersToAutoAdd.filter(function(e){return S(t.notAdded,e.username)}),e.usersToInvite=e.usersToInvite.concat(r))),e}function $t(e,t){return e.orgId===t.orgId}function Qt(e){return"org_admin"===e.role&&!e.roleId}function Xt(e,t,r,n){var o=Promise.resolve(null);return e.length&&(e={authentication:r,message:t.body,subject:t.subject,notificationChannelType:"email",users:e.map(function(e){return e.username})},n||(e.batchSize=1),o=Te(e)),o}function Zt(t){var r,e=Promise.resolve(t);return t.email&&t.secondaryRO&&d(t,"inviteResult.success")&&(r=y(t,"secondaryRO.portalSelf.user",{}),e=Xt(t.usersToInvite.filter(function(e){return $t(e,r)}),t.email,t.secondaryRO.authentication,Qt(r)).then(function(e){return t.secondaryEmailResult=e,t})),e}function er(e,t,r){var n=Promise.resolve(null);return n=t.length?he({id:e,users:t.map(function(e){return e.username}),authentication:r}):n}function tr(t){return er(d(t,"groupId"),d(t,"usersToAutoAdd"),d(t,"primaryRO.authentication")).then(function(e){return Kt(e,t)})}function rr(e,t,r,n,o){void 0===n&&(n=20160),void 0===o&&(o="group_member");var i=Promise.resolve(null);return i=t.length?be({id:e,users:t.map(function(e){return e.username}),authentication:r,role:o,expiration:n}):i}function nr(t){return rr(d(t,"groupId"),d(t,"usersToInvite"),d(t,"primaryRO.authentication")).then(function(e){return t.inviteResult=e,t})}function or(t){var e=Promise.resolve(t);return e=t.email&&d(t,"inviteResult.success")?Xt(t.usersToEmail,t.email,t.primaryRO.authentication,Qt(t.requestingUser)).then(function(e){return t.primaryEmailResult=e,t}):e}function ir(e,t){var r,n=[];return-1!==t.privileges.indexOf("portal:admin:assignToGroups")&&(r=[t.orgId,t.cOrgId].filter(function(e){return e}),n=e.filter(function(e){return-1!==r.indexOf(e.orgId)})),n}function ar(e,t){var r=ir(e,t);return e.filter(function(t){return!r.some(function(e){return e.username===t.username})})}function sr(e,t,r){void 0===r&&(r=!1);e=ar(e,t).filter(function(e){return $t(e,t)});return r&&e.push(t),e}function ur(e,t){if("object"==typeof e&&null!==e&&"string"==typeof t){for(var r=t.split("."),n=0;n<r.length-1;n++){if(!e.hasOwnProperty(r[n]))return;e=e[r[n]]}delete e[r[r.length-1]]}}function cr(e){var t=l(e.item);return t.text=JSON.stringify(e.data),t}function pr(e,t){return Promise.all([oe(e,t),(r=e,r=ie(e,t=t)+"/data",(t=A({httpMethod:"GET",params:{}},t)).file&&(t.params.f=null),X(r,t).catch(function(e){var t=RegExp(/The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i);if(!t.test(e.message))throw e}))]).then(function(e){return{item:e[0],data:e[1]}});var r}var lr=function(e,t,r){return void 0===r&&(r=void 0),t.split(".").reduce(function(e,t){return e?e[t]:r},e)};function dr(r,n){return Object.keys(r).reduce(function(e,t){return e[t]=n(r[t],t,r),e},{})}var fr=function(e){return e instanceof Date},mr=function(e){return"function"==typeof e},hr=function(e){return"object"==typeof e},gr=function(e){return e instanceof RegExp};var vr=function(e){return"object"==typeof e};function yr(e){return Array.isArray(e)?function(e){var t=e,e=e.reduce(function(e,t){return Cr(t)&&wr(t)&&(e<(t=br(t))&&(e=t)),e},-1);-1<e&&(t=0===e?[]:"{{delete:"+(e-1)+"}}");return t}(e.map(t).filter(function(e){return null!=e})):e&&vr(e)?function(o){var e=Object.keys(o).reduce(function(e,t){var r,n=o[t];return Cr(n)&&wr(n)?(r=br(n))>e.maxLevel&&(e.maxLevel=r):e.obj[t]=n,e},{obj:{},maxLevel:-1});e=0<e.maxLevel?1===e.maxLevel?void 0:"{{delete:"+(e.maxLevel-1)+"}}":e.obj;return e}(dr(e,t)):function(e){var t=e;"string"==typeof e&&wr(e)&&(t=function(e){var t=e,e=br(e);t=0===e?void 0:"{{delete:"+e+"}}";return t}(e));return t}(e);function t(e,t){return yr(e)}}var br=function(e){return parseInt(e.replace(/{|}/g,"").split(":")[1])};function wr(e){return e&&"string"==typeof e&&-1<e.indexOf("{{delete")}var Cr=function(e){return"string"==typeof e};function kr(e,t,r,n){return void 0===n&&(n=0),t?t:"{{delete:"+n+"}}"}var Sr=function(e){var t={};if(Array.isArray(e))t=e.map(Sr);else if("object"==typeof e)for(var r in e)null!=e[r]&&"object"==typeof e[r]?t[r]=Sr(e[r]):t[r]=e[r];else t=e;return t},Tr=/{{\s*?[\w].*?}}/g,Ar=function(e){return"string"==typeof e};function Ir(e){return e||""===e||0===e}function Er(e,a,s){if((s=Sr(s=void 0===s?null:s)||{}).optional)throw new Error("Please do not pass in an `optional` transform; adlib provides that internally.");return s.optional=kr,yr(function r(e,n,o){return o=o||"",Array.isArray(e)?e.map(t):!e||!hr(e)||fr(e)||gr(e)||mr(e)?n(e,o):Object.assign({},e,dr(e,t));function t(e,t){return r(e,n,o?o+"."+t:t)}}(e,function(t,e){if(!Ar(t))return t;var r,n=t.match(Tr);return n&&n.length?(n.map(function(e){var o,i=!1,t=e.replace(/{|}/g,"").trim();-1<t.indexOf("||")&&(r=t.split("||").map(function(e){return e.trim()}),o=r.length,t=r.find(function(e,t){var r,n;return(n=a,r=(r=e).split(":")[0],null!=(r=lr(n,r,null)))?e:t+1===o&&(i=!0,isNaN(e)?e:parseInt(e))}));var r={key:e,value:t};return i||(t=function(e,t,r){var n,o=e.split(":");if(1<o.length){var i,a=o[0],s=o[1];if(o[2]&&(i=o[2]),!r||!r[s]||"function"!=typeof r[s])throw new Error("Attempted to apply non-existant transform "+s+" on "+a+" with params "+e);n=lr(t,a),n=r[s](a,n,t,i)}else n=lr(t,e);return n}(t,a,s),r.value=Ir(t)?t:e),r}).forEach(function(e){t===e.key?("string"==typeof e.value&&(isNaN(e.value)||""===e.value||(-1<e.value.indexOf(".")?e.value=parseFloat(e.value):e.value=parseInt(e.value))),r=e.value):t=t.replace(e.key,e.value)}),Ir(r)?r:t):t}))}function Pr(e,t,r){return Er(e,t,r)}var xr=["id","isOrgItem","proxyFilter","ownerFolder","protected","owner","created","modified","guid","name","access","size","listed","numComments","numRatings","avgRating","numViews","scoreCompleteness","groupDesignations","listed","screenshots","banner","appCategories","industries","languages","largeThumbnail"];function Dr(e,t,r){return fe({q:'title:"'+e+'" AND '+Object.keys(t).map(function(e){return e+':"'+t[e]+'"'}).join(" AND "),authentication:r}).then(function(e){return 0<e.results.length}).catch(function(e){throw Error("Error in doesItemExistWithTitle "+e)})}function Or(e,t){var r=e;return r=-1===e.indexOf("token")&&-1<e.indexOf(t.authentication.portal)?e+"?token="+t.authentication.token:r}function Rr(e,t){return(t=void 0===t?{}:t).credentials||(t.credentials="same-origin"),fetch(e,t).then(function(e){return e.blob()})}function Nr(r){return Rr(r.url).then(function(e){return re(t={id:r.id,owner:r.owner,name:r.fileName,resource:e,authentication:r.authentication}).then(function(e){e=te(t)+"/content/users/"+e+"/items/"+t.id+"/addResources";return t.params=A({file:t.resource,fileName:t.name,resourcesPrefix:t.prefix,text:t.content,access:t.private?"private":"inherit"},t.params),X(e,t)});var t})}function _r(t){return Rr(t.url).then(function(e){return ne({item:{id:t.id,owner:t.owner},params:{fileName:t.fileName,thumbnail:e},authentication:t.authentication}).catch(function(e){return Promise.resolve()})}).catch(function(e){return Promise.resolve()})}function Ur(e,t,r){if(!e||!e.thumbnail)return null;var n=r||{},o=n.token,n=n.width,r=Ge(e,t,o=!o&&"string"==typeof r?r:o).split("?"),o=r[0],r=r[1],r=new URLSearchParams(r);r.delete("f"),n&&r.append("w",n+"");r=r.toString(),e=o+"/info/"+e.thumbnail;return r?e+"?"+r:e}function jr(t){return I(this,void 0,void 0,function(){return E(this,function(e){return 200<=t.status&&t.status<300?[2,t.json()]:[2,t.json().then(function(e){if(e.error)throw new Error(e.error.title+" :: "+e.error.detail+" :: "+t.status);throw new Error("Got "+t.status+" "+t.statusText)})]})})}function Lr(e){var t={},e=d(e,"authentication.token");return e&&(t.Authorization=e),t}function Mr(e){return(e||"https://hub.arcgis.com")+"/api/v3/domains"}function Gr(e,t){var r=e,n="hubsubdomain|"+(r=-1<e.indexOf("#/")?e.split("#/")[1]:r);return fe(Object.assign({q:"typekeywords: "+n},t)).then(function(e){return e.results.filter(function(e){return S(e.typeKeywords,n)})[0]}).then(function(e){if(!e)throw new Error("site not found");return{hostname:e.url,siteId:e.id}})}function Br(e,t){if(t.isPortal)throw new Error("domainExists is not available in ArcGIS Enterprise.");e=je(e);e=Mr(t.hubApiUrl)+"/"+e,t=Lr(t);return fetch(e,{method:"GET",headers:t,mode:"cors"}).then(function(e){return 404!==e.status})}function qr(e,t){return Gr(e,t).then(function(e){return!0}).catch(function(e){return!1})}function Fr(t,r,n,o){var i=t;return Br((i=(o=void 0===o?0:o)?t+"-"+o:t)+"-"+r,n).then(function(e){return e?Fr(t,r,n,o+1):i})}function Yr(t,r,n){var o=(n=void 0===n?0:n)?t+"-"+n:t;return qr(o,r).then(function(e){return e?Yr(t,r,n+1):o})}function Hr(e,t){if(t.isPortal)return Gr(e,t);e=Mr(t.hubApiUrl)+"/"+e,t=Lr(t);return fetch(e,{method:"GET",headers:t,mode:"cors"}).then(jr)}function Wr(e,t){var r=l(e),e=63;return t&&(e-=t.length+1),r=r.length>e?r.slice(0,e-6)+"-"+N(5):r}function zr(e,t){return pr(e,t).then(Qr)}function Vr(e){if(1.4<=d(e,"item.properties.schemaVersion"))return e;var t=l(e),e=d(t,"data.values.gacode");return t.data.values.telemetry={consentNotice:{isTheme:!0,consentText:"",policyURL:""},customAnalytics:{ga:{customerTracker:{enabled:Boolean(e),id:e}}}},ur(t,"data.values.gacode"),C("item.properties.schemaVersion",1.4,t),t}var Jr=1.5;function Kr(e){if(1.5<=d(e,"item.properties.schemaVersion"))return e;var r,t=l(e),e=t.data.values.dcatConfig;return t.data.feeds={},e&&(t.data.feeds.dcatUS11=(r=JSON.stringify(e),Object.keys($r).forEach(function(e){var t=$r[e];r=r.split(e).join(t)}),JSON.parse(r))),t.item.properties.schemaVersion=1.5,t}var $r={"{{default.name}}":"{{name}}","{{default.description}}":"{{description}}","{{item.tags}}":"{{tags}}","{{item.created:toISO}}":"{{created:toISO}}","{{item.modified:toISO}}":"{{modified:toISO}}","{{default.source.source}}":"{{source}}","{{item.owner}}":"{{owner}}","{{org.portalProperties.links.contactUs.url}}":"{{orgContactEmail}}","{{org.name}}":"{{orgName}}","{{item.categories}}":"{{categories}}","{{item.licenseInfo}}":"{{licenseInfo}}","{{item.modified}}":"{{modified}}","{{enrichments.categories}}":"{{categories}}","{{default.id}}":"{{id}}","{{item.licenseInfo || No License}}":"{{licenseInfo || No License}}","{{org.portalProperties.links.contactUs.url || mailto:data@tempe.gov}}":"{{orgContactEmail || mailto:data@tempe.gov}}","{{default.description || No Description}}":"{{description || No Description}}","{{item.id}}":"{{id}}"};function Qr(e){return d(e,"item.properties.schemaVersion")===Jr?e:e=Kr(e=Vr(e=function(e){if(1.3<=d(e,"item.properties.schemaVersion"))return e;var t=l(e),e=d(t,"data.catalog.groups")||[];return t.data.catalog.groups=e.filter(_),t.item.properties.schemaVersion=1.3,t}(e=function(e){if(1.2<=d(e,"item.properties.schemaVersion"))return e;var t=l(e),e=d(t,"data.catalog")||{};return d(t,"data.values.groups")&&(e.groups=l(t.data.values.groups),delete t.data.values.groups),t.data.catalog=e,t.item.properties.schemaVersion=1.2,t}(e=function(e){if(1.1<=d(e,"item.properties.schemaVersion"))return e;var t=l(e);return["subdomain","defaultHostname","internalUrl","customHostname","externalUrl"].forEach(function(e){t.data.values[e]&&"string"==typeof t.data.values[e]&&(t.data.values[e]=t.data.values[e].toLowerCase())}),t.item.properties.schemaVersion=1.1,t}(e=function(e){if(1<=d(e,"item.properties.schemaVersion"))return e;var t=l(e);return["groupId","title"].forEach(function(e){delete t.data.values[e]}),t.item.properties||(t.item.properties={}),t.item.properties.schemaVersion=1,t.data.values.groups&&Array.isArray(t.data.values.groups)&&(e=t.data.values.groups.map(function(e){return"object"==typeof e?e.id:e}).filter(function(e){return!!e}),t.data.values.groups=e),t}(e))))))}var Xr=["ar","bs","ca","cs","da","de","en","es","et","el","fi","fr","hr","he","hu","it","id","ja","ko","lt","lv","nb","nl","pl","pt","pt-br","pt-pt","ro","ru","sl","sr","sv","th","tr","uk","vi","zh","zh-cn","zh-tw","zh-hk"];var Zr,en=(e(tn,Zr=Error),tn);function tn(e,t,r){e=Zr.call(this,e)||this;return e.status=r,e.url=t,e}function rn(e,t){var r,n,o=A({httpMethod:"GET"},t),i=o.fetch||fetch,t=A({"Content-Type":"application/json"},o.headers);"GET"===o.httpMethod?r=o.params:n=JSON.stringify(o.params);var a=q({host:Fe(o),path:("/api/v3/"+e).replace(/\/\//g,"/"),query:r});return i(a,{method:o.httpMethod,headers:t,body:n}).then(function(e){if(e.ok)return e.json();throw new en(e.statusText,a,e.status)})}function nn(e,t){return ae(A({id:e,relationshipType:"Survey2Service",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function on(e,t){return ae(A({id:e,relationshipType:"Service2Data",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function an(e,t){return ae(A({id:e,relationshipType:"Survey2Data",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function sn(t){function e(e){return-1<t.typeKeywords.indexOf(e)}var r=e("FieldworkerView");return r=r||["Survey123","Feature Service","View Service"].every(e)&&!e("StakeholderView")}un.prototype.startOperation=function(e){e=l(e);e.startedAt=(new Date).getTime(),e.state="working",this.operations.push(e)},un.prototype.start=function(e,t){t={type:e,id:y(t,"id",r(e+"_")),inputs:y(t,"inputs",{}),cleanup:y(t,"cleanup","n/a"),startedAt:(new Date).getTime(),state:"working"};return this.operations.push(t),t.id},un.prototype.getOperation=function(t){return this.operations.find(function(e){return e.id===t})},un.prototype.getOperations=function(){return this.operations},un.prototype.finish=function(e,t){var r=this.getOperation(e);if(!r)throw new Error("No operation with id "+e+" present in stack");r.duration=(new Date).getTime()-r.startedAt,r.state="completed",t&&(r.output=l(t))},un.prototype.merge=function(e){this.operations=P(this.operations,e.operations)},un.prototype.getCompleted=function(){return l(this.operations.filter(function(e){return"completed"===e.state}))},un.prototype.getWorking=function(){return l(this.operations.filter(function(e){return"working"===e.state}))},un.prototype.toString=function(){return this.operations.sort(function(e,t){return e.startedAt<t.startedAt?-1:t.startedAt<e.startedAt?1:0}).map(cn).join("\n")},un.prototype.serialize=function(){return{operations:l(this.getOperations())}},at=un;function un(){this.operations=[]}function cn(e){var t=e.startedAt+" : Operation "+e.id+" started with inputs "+JSON.stringify(e.inputs)+" but was not completed";return t="completed"===e.state?e.startedAt+" : Operation "+e.id+" took "+e.duration+" ms with inputs "+JSON.stringify(e.inputs)+" and output "+(e.output?JSON.stringify(e.output):"n/a"):t}n.GLOBAL_EXTENT=ft,n.HUB_CDN_URLMAP=Ne,n.HUB_LOCALES=Xr,n.Logger=U,n.OperationError=D,n.OperationStack=at,n.PORTAL_EXPORT_TYPES=Yt,n.REQUIRED_PRIVS=B,n.RemoteServerError=en,n.SITE_SCHEMA_VERSION=Jr,n.STANDARD_LICENSES=gt,n.WGS84_WKID=Ft,n._addTokenToResourceUrl=Or,n._canEmailUser=$t,n._checkStatusAndParseJson=jr,n._consolidateResults=Jt,n._deepMapValues=i,n._ensureSafeDomainLength=Wr,n._ensureTelemetry=Vr,n._formatAutoAddResponse=Kt,n._getAuthHeader=Lr,n._getAutoAddUsers=ir,n._getDomainServiceUrl=Mr,n._getEmailUsers=sr,n._getHttpAndHttpsUris=function(e){return e?["http://"+(e=e.replace(/^http(s?):\/\//,"")),"https://"+e]:[]},n._getInviteUsers=ar,n._getLocation=function(){if(window)return window.location},n._isDate=s,n._isFunction=u,n._isObject=c,n._isOrgAdmin=Qt,n._isRegExp=p,n._isString=a,n._lookupPortal=Gr,n._mapValues=o,n._processAutoAdd=tr,n._processInvite=nr,n._processPrimaryEmail=or,n._processSecondaryEmail=Zt,n._unprotectAndRemoveGroup=function(e){var t=R(Ce,{success:!0}),r=R(ke,{success:!0});return t(e).then(function(){return r(e)})},n._unprotectAndRemoveItem=function(e){var t=R(se,{success:!0}),r=R(ce,{success:!0});return t(e).then(function(){return r(e)})},n.addContextToSlug=function(e,t){return/.+::.+/.test(e)?e:t+"::"+e},n.addDays=function(e,t){try{var r=new Date(e);return new Date(r.setDate(r.getDate()+t)).toISOString().split("T")[0]}catch(e){throw new Error("Invalid Date")}},n.addDomain=function(e,t){if(t.isPortal)throw new Error("addDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=Lr(t);r["Content-Type"]="application/json";var n=""+Mr(t.hubApiUrl);return"number"==typeof(t=e.siteTitle)&&(e.siteTitle=t.toString()),fetch(n,{method:"POST",headers:r,mode:"cors",body:JSON.stringify(e)}).then(jr)},n.addSolutionResourceUrlToAssets=function(e,t){var r,n,o=e.assets||e.resources||[];return e.bundleItemId&&(r=Ue(t.portalSelf)+"/content/items/"+e.bundleItemId,n=e.itemId,o=o.map(function(e){return{name:e.name,type:e.type||"resource",url:r+"/resources/"+n+"-"+e.name}})),o},n.addUsersToGroup=function(e,t,r,n,o){var i=l(y(r,"portalSelf.user",{}));return i.cOrgId=d(r,"portalSelf.portalProperties.hub.settings.communityOrg.orgId"),tr({groupId:e,allUsers:t,primaryRO:r,email:n,secondaryRO:o,requestingUser:i,usersToAutoAdd:ir(t,i),usersToInvite:ar(t,i),usersToEmail:sr(t,i,d(n,"copyMe"))}).then(nr).then(or).then(Zt).then(Jt)},n.applyPropertiesToItems=function(e,t){return e.map(function(e){return e.properties||(e.properties={}),Object.assign(e.properties,t),e})},n.arrayToObject=function(e,r){return e.reduce(function(e,t){return e[d(t,r)]=t,e},{})},n.atob=qt.atob,n.autoAddUsers=er,n.batch=k,n.btoa=qt.btoa,n.buildDraft=function(e,t){return w(e,{},t)},n.buildExistingExportsPortalQuery=function(e,t){var r,n,o,i,a=(c=function(e){if(e)return{onlyTypes:e.onlyTypes,layerId:e.layerId,spatialRefId:e.spatialRefId};return{}}(t)).onlyTypes,s=c.layerId,u=c.spatialRefId,t=Object.keys(Yt).map(function(e){return Yt[e]}),c=new Set(g(t.filter(function(e){return!e.supportsProjection}).map(function(e){return e.itemTypes}))),t=a||g(t.map(function(e){return e.itemTypes})),s=(new pe).startGroup().match(zt(e)).in("typekeywords").and().match(Vt(s)).in("typekeywords").endGroup().and().startGroup();function p(e,t){var r;t.startGroup().match(/\s/g.test(e)?e:'"'+e+'"').in("type").and().match(Wt((r=e,t=Ft,t=(e=i)&&!o.has(r)?e:t))).in("typekeywords").endGroup()}return r=s,n=(c={types:t,spatialRefId:u,noProjectionItemTypes:c}).types,o=c.noProjectionItemTypes,i=c.spatialRefId,n.forEach(function(e,t){p(e,r),t<n.length-1&&r.or()}),s.endGroup(),s.toParam()},n.buildUrl=q,n.camelize=t,n.canEditEvent=function(e,t){var r=!1;return M(t)&&(e=d(e,"initiative.item.properties.collaborationGroupId"),t=t.groups,r=!!e&&!!f(void 0===t?[]:t,"id",e)),r},n.canEditItem=G,n.canEditSite=function(e,t){var r=!1;return r=!d(e,"properties.isDefaultHubHome")&&M(t)?G(e,t):r},n.canEditSiteContent=function(e,t){var r,n=!1,o=d(e,"properties.isDefaultHubHome"),i=M(t);return!o&&i?n=G(e,t):i&&(i=t.orgId,e=e.orgId,i&&i===e&&(r=t.privileges||[],n=B.every(function(e){return S(r,e)}))),n},n.capitalize=h,n.categories=ct,n.chunkArray=function(e,t){for(var r=[],n=0;n<e.length;)r.push(e.slice(n,n+t)),n+=t;return r},n.cloneObject=l,n.completeOAuth2=function(t,e){var r=(e=(e=void 0===e?window:e).location.href.match(/access_token=(.+)&expires_in=.+&username=([^&]+)/))[1],n="https://www.arcgis.com/sharing/rest/community/users/"+decodeURIComponent(e[2]);return X(n,{params:{token:r},httpMethod:"GET"}).then(function(e){return Date.now()-e.created<5e3?X(n+"/update",{params:{token:r,tags:["hubRole:participant","org:"+e.orgId],access:"public"}}).then(function(){return Ke.completeOAuth2(t)}):Ke.completeOAuth2(t)})},n.compose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce(function(r,n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(n.apply(void 0,e))}})},n.convertSolutionTemplateResourcesToAssets=function(e,t){var r,n,o=[];return e.resources&&e.bundleItemId&&(r=Ue(t.portalSelf)+"/content/items/"+e.bundleItemId,n=e.itemId,o=e.resources.map(function(e){return{name:e,type:"resource",url:r+"/resources/"+n+"-"+e}})),o},n.convertToWellKnownLocale=function(e){var t="en";return e=(e=void 0===e?"en":e).toLowerCase(),-1<Xr.indexOf(e)?t=e:1<(e=e.split("-")).length&&-1<Xr.indexOf(e[0])&&(t=e[0]),t},n.createExtent=lt,n.createId=r,n.createOperationPipeline=function(e){return function(r){return e.reduce(function(e,t){return e.then(t).catch(function(e){if("OperationError"===e.name)return Promise.reject(e);e="IPipeableFn did not reject with an OperationError \n Operation Stack: \n "+r.stack.toString(),e=new D("pipeline execution error",e);return e.operationStack=r.stack.serialize(),Promise.reject(e)})},Promise.resolve(r))}},n.datasetToContent=function(e){var t=Rt(e),r=Ot(t);delete r.itemCategories;var n=e.id,o=(C=e.attributes).errors,i=C.boundary,a=C.extent,s=C.metadata,u=C.modified,c=C.modifiedProvenance,p=C.slug,l=C.searchDescription,d=C.groupIds,f=C.server,m=C.layers,h=C.layer,g=C.recordCount,v=C.statistics,y=C.orgId,b=C.orgName,w=C.organization,e=C.orgExtent,C=C.type;return r.errors=o,r.boundary=i,!ht(t.extent)&&a&&ht(a.coordinates)&&(r.extent=a.coordinates),r.metadata=s||null,r.modified!==u&&(r.modified=u,r.updatedDate=new Date(u),r.updatedDateSource=c),r.slug=p,l&&(r.summary=l),r.groupIds=d,r.server=f,r.layers=m,r.layer=h,r.recordCount=g,r.statistics=v,y&&(r.org={id:y,name:b||w,extent:e}),_t(Nt(r,n),C)},n.datasetToItem=Rt,n.deepSet=v,n.deepStringReplace=b,n.deleteProp=ur,n.doesItemExistWithTitle=Dr,n.domainExists=Br,n.domainExistsPortal=qr,n.emailOrgUsers=Xt,n.ensureProp=function(e,t){return v(e,t)},n.ensureUniqueDomainName=function(e,t){return(t.isPortal?Yr(e,t):Fr(e,t.portalSelf.urlKey+"."+je(Fe(t)),t)).then(function(e){return Wr(e,t.portalSelf.urlKey)})},n.ensureUniqueString=function(e,t){for(var r=!1,n=0,o=t;!r;)S(e,o)?o=t+"-"+ ++n:r=!0;return o},n.extend=function n(e,o,i){void 0===i&&(i=!0);e=l(e);return Object.keys(o).reduce(function(e,t){var r;return null!==o[t]&&void 0!==o[t]&&(r=l(o[t]),Array.isArray(r)?e[t]=r:e[t]=i&&"object"==typeof r?n(e[t]||{},r,i):r),e},e)},n.extentToBBox=dt,n.failSafe=R,n.failSafeUpdate=function(e,t){return R(ne,{id:e.item.id,success:!0})(Object.assign({item:cr(e)},t))},n.fetchAllPages=function(n,o,r,i){var a=o.num||100,e=o.start||1;return(-1===(r=void 0===r?-1:r)?n(A(A({},o),{num:a,start:e})):Promise.resolve({nextStart:e,total:r,results:[],num:a})).then(function(t){if(-1===t.nextStart)return[t];for(var e=[],r=t.nextStart;r<=t.total;r+=a)e.push(r);return k(e,function(e){return n(A(A({},o),{start:e,num:a}))},i).then(function(e){return P([t],e)})}).then(function(e){var t=e.reduce(function(e,t){return P(e,t.results)},[]),e=-1===r?t.length:r;return t.slice(0,e)})},n.fetchAndUploadResource=Nr,n.fetchAndUploadThumbnail=_r,n.fetchHubTranslation=function(t,e,r){void 0===r&&(r="cors");var n=(_e(e)+"/locales/"+t+".json").toLocaleLowerCase();return fetch(n,{method:"GET",credentials:"same-origin",mode:r}).then(function(e){return e.json()}).catch(function(e){throw Error("Attempt to fetch locale "+t+" from "+n+" failed: "+JSON.stringify(e))})},n.fetchImageAsBlob=Rr,n.fetchSite=function(e,t){return _(e)?zr(e,t):Hr(je(e).split("/")[0],t).then(function(e){return zr(e.siteId,t)})},n.filterBy=function(e,t,r){return e.filter(function(e){return d(e,t)===r})},n.findBy=f,n.flattenArray=g,n.generateRandomString=N,n.getCategory=bt,n.getCollection=Ct,n.getContentIdentifier=At,n.getCulture=function(e){return d(e,"portalSelf.user.culture")||d(e,"portalSelf.culture")||"en-us"},n.getDomainsForSite=function(e,t){return t.isPortal?Promise.resolve([]):(e=Mr(t.hubApiUrl)+"?siteId="+e,t=Lr(t),fetch(e,{method:"GET",headers:t,mode:"cors"}).then(jr).catch(function(e){throw Error("Error in getDomainsForSite "+e)}))},n.getExportItemTypeKeyword=zt,n.getExportLayerTypeKeyword=Vt,n.getFamily=xt,n.getGeographicOrgExtent=mt,n.getHubApiUrl=Fe,n.getHubApiUrlFromPortal=function(e){return Me(e)+"/api/v3"},n.getHubLocaleAssetUrl=_e,n.getHubProduct=function(e){var t=d(e,"portalProperties.hub.enabled")||!1?"premium":"basic";return t=e.isPortal&&"singletenant"===e.portalMode?"portal":t},n.getHubUrlFromPortal=Me,n.getInputFeatureServiceModel=nn,n.getItemApiUrl=Ge,n.getItemAssets=function(e,t){var r=Ue(t.portalSelf)+"/content/items/"+e.id,n=Ur(e,t),o=[];return n&&o.push({name:e.thumbnail,url:n,type:"thumbnail"}),e=e.id,e=ie(e,t=t)+"/resources",(t=A({},t)).params=A({num:1e3},t.params),X(e,t).then(function(e){e=e.resources.map(function(e){return{name:e.resource,type:"resource",url:r+"/resources/"+e.resource}});return o.concat(e)})},n.getItemDataUrl=function(e,t,r){t=Ge(e,t,r),r="\\/"+e.id+"\\?f=json",r=new RegExp(r);return t&&t.replace(r,"/"+e.id+"/data").replace(/\&token/,"?token")},n.getItemHomeUrl=function(e,t){return Re(t)+"/home/item.html?id="+e},n.getItemHubId=function(e){if("public"===e.access){var t=e.id,e=Tt(e);return e?t+"_"+e:t}},n.getItemHubType=Dt,n.getItemLayerId=Tt,n.getItemThumbnailUrl=Ur,n.getLayerIdFromUrl=St,n.getModel=pr,n.getModelFromOptions=function(e,t){var r=e+"Model",e=e+"Id";if(t[r])return Promise.resolve(t[r]);if(t[e])return R(pr,{item:{id:t[e]},isMissing:!0})(t[e],t);throw new Error("getModelFromOptions requires either a ."+r+" or ."+e+" property.")},n.getOrgExtentAsBBox=function(e){return mt(e).then(dt)},n.getPortalApiUrl=Ue,n.getPortalUrl=Re,n.getProp=d,n.getProps=function(r,e){return e.reduce(function(e,t){t=d(r,t);return t&&e.push(t),e},[])},n.getServiceTypeFromUrl=qe,n.getSiteById=zr,n.getSourceFeatureServiceModelFromFieldworker=on,n.getSpatialRefTypeKeyword=Wt,n.getStakeholderModel=an,n.getStructuredLicense=vt,n.getSubscriptionType=function(e){return y(e,"subscriptionInfo.type","Enterprise")},n.getSurveyModels=function(e,r){var n,o;return("string"==typeof e?oe(e,r):Promise.resolve(e)).then(function(t){var e=[nn(t.id,r),an(t.id,r)];return Promise.all(e).then(function(e){var t=e[0],e=e[1];return o=e,t&&sn(t.item)?on((n=t).item.id,r):t}).then(function(e){return{form:{item:t},featureService:e,fieldworker:n,stakeholder:o}})})},n.getTypeCategories=function(e){if(e=bt(wt(e=void 0===e?{}:e))){e=Array.from(e);return e[0]=e[0].toUpperCase(),[e.join("")]}return["Other"]},n.getTypes=function(e){return ct[(e=void 0===e?"":e).toLowerCase()]},n.getUniqueDomainName=Fr,n.getUniqueDomainNamePortal=Yr,n.getUniqueItemTitle=function t(r,n,o,i){var a=(i=void 0===i?0:i)?r+" "+i:r;return Dr(a,n,o).then(function(e){return e?t(r,n,o,++i):a}).catch(function(e){throw Error("Error in getUniqueItemTitle "+e)})},n.getWithDefault=y,n.hasBasePriv=M,n.hubApiRequest=rn,n.hubApiSearch=function(e){var t=(t=e.authentication)&&t.serialize&&{authentication:t.serialize()};return rn("/search",A(A({},{headers:t,httpMethod:"POST"}),e))},n.includes=S,n.incrementString=function(e){var t=e.match(/-\s(\d+$)/);return t?(t=parseInt(t[1],10),e=e.replace("- "+t,"- "+(t+1))):e+=" - 1",e},n.interpolate=Pr,n.interpolateItemId=function(e){return Pr(e,{item:{id:e.item.id},appid:e.item.id},{toISO:function(e,t){return t}})},n.inviteUsers=rr,n.isDomainForLegacySite=function(e){return!_(e.siteId)},n.isDomainUsedElsewhere=function(e,t,r){return Hr(e,r).then(function(e){return e.siteId!==t}).catch(function(){return!1})},n.isDownloadable=pt,n.isExtentCoordinateArray=ht,n.isFeatureService=kt,n.isFieldworkerView=sn,n.isGuid=_,n.isMapOrFeatureServerUrl=function(e){return Be.test(e)},n.isNil=function(e){return null==e},n.isSlug=function(e){return!(!(e=It(e).itemId)||_(e))},n.isUpdateGroup=L,n.isValidDomain=function(t,e){if(e.isPortal)throw new Error("isValidDomain is not available in ArcGIS Enterprise.");var r=Mr(e.hubApiUrl)+"/validate?hostname="+t,e=Lr(e);return fetch(r,{method:"GET",headers:e,mode:"cors"}).then(function(e){return e.json()}).catch(function(e){return{success:!1,input:t,error:{code:400,detail:e,message:"lookupFailed"}}})},n.isValidExtent=function(t){return!!t&&[ht,function(t){return["xmin","ymin","xmax","ymax"].every(function(e){return"number"==typeof t[e]})}].some(function(e){return e(t)})},n.itemPropsNotInTemplates=xr,n.itemToContent=Ot,n.last=function(e){return e[e.length-1]},n.lookupDomain=Hr,n.mapBy=function(t,e){return(e=void 0===e?[]:e).map(function(e){return e[t]})},n.maybeAdd=function(e,t,r){return null!=t&&((r=l(r))[e]=t),r},n.maybePush=m,n.mergeObjects=w,n.normalizeItemType=wt,n.normalizeSolutionTemplateItem=function(e){var t=l(e);return xr.forEach(function(e){delete t[e]}),t.extent="{{organization.defaultExtentBBox}}",t},n.objectToArray=function(r,n){return void 0===n&&(n="id"),Object.keys(r).reduce(function(e,t){return r[t][n]=t,e.push(l(r[t])),e},[])},n.objectToJsonBlob=function(e){if("undefined"!=typeof Blob)return new Blob([JSON.stringify(e)],{type:"application/json"});throw new Error("objectToJsonBlob is not currently supported on Node")},n.parseDatasetId=It,n.parseItemCategories=Pt,n.processRevertableTasks=function(e){return Promise.all(e).then(function(e){function t(e){return"fullfilled"===e.status}var r=e.filter(t),n=e.filter(function(e){return!t(e)});if(n.length){e=r.map(function(e){return e.revert()});throw Promise.all(e).catch(function(){}),n[0].error}return r.map(function(e){return e.results})})},n.propifyString=function(e){return t(e.replace(/^[0-9]*/g,"").replace(/[^\w\s]/g,""))},n.removeContextFromSlug=Et,n.removeDomain=function(e,t){if(t.isPortal)throw new Error("removeDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=Lr(t);return r["Content-Type"]="application/json",e=Mr(t.hubApiUrl)+"/"+e,fetch(e,{method:"DELETE",headers:r,mode:"cors"}).then(jr)},n.removeEmptyProps=function t(r){return Object.keys(r).forEach(function(e){r[e]&&"object"==typeof r[e]?t(r[e]):null==r[e]&&delete r[e]}),r},n.replaceItemId=function(e,t,r){return void 0===r&&(r="{{appid}}"),b(l(e),new RegExp(t,"g"),r)},n.runRevertableTask=function(e,t){return e().then(function(e){return{status:"fullfilled",results:e,revert:t}}).catch(function(e){return{status:"rejected",error:e}})},n.serializeModel=cr,n.serializeSpatialReference=Ht,n.setContentHubId=Nt,n.setContentSiteUrls=function(e,t){var r=At(e,t),r=jt(e,r),t=d(t,"item.url").replace(/\/$/,"");return Ut(e,{relative:r,site:""+t+r})},n.setContentType=_t,n.setProp=C,n.shareItemToGroups=function(t,e,r){return Promise.all(e.map(function(e){return Pe(Object.assign({},{id:t,groupId:e},r))}))},n.slugify=function(e){return"string"==typeof e?e.trim().toLowerCase().replace(/ +/g,"-").replace(/[^\w-]/g,"").replace(/-+/g,"-"):e},n.stringToBlob=function(e,t){if(void 0===t&&(t="application/octet-stream"),"undefined"==typeof Blob)throw new Error("stringToBlob is not currently supported on Node");for(var r=[],n=0;n<e.length;n++)r[n]=e.charCodeAt(n);var o=new Uint8Array(r);return new Blob([o],{type:t})},n.stripProtocol=je,n.unique=function(e,t,r){return r.indexOf(e)===t},n.uniqueBy=function(e,r){return e.reduce(function(e,t){return m(e.find(function(e){return d(e,r)===d(t,r)})?null:t,e)},[])},n.unprotectModel=function(e,t){return e.item.protected?se(Object.assign({id:e.item.id},t)):Promise.resolve({success:!0})},n.unshareItemFromGroups=function(t,e,r){return Promise.all(e.map(function(e){return Oe(Object.assign({},{id:t,groupId:e},r))}))},n.updateDomain=function(e,t){if(t.isPortal)throw new Error("updateDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=Lr(t);r["Content-Type"]="application/json";var n=Mr(t.hubApiUrl)+"/"+e.id;return"number"==typeof(t=e.siteTitle)&&(e.siteTitle=t.toString()),fetch(n,{method:"PUT",headers:r,mode:"cors",body:JSON.stringify(e)}).then(jr)},n.upgradeSiteSchema=Qr,n.uploadResourcesFromUrl=function(n,e,o){if(Array.isArray(e)){e=e.reduce(function(e,t){var r;return t.url&&(r={id:n.item.id,owner:n.item.owner,fileName:t.name,url:Or(t.url,o),authentication:o.authentication},"thumbnail"===t.type?e.push(_r(r)):e.push(Nr(r))),e},[]);return Promise.all(e)}return Promise.resolve([])},n.without=function(e,t){return e.filter(function(e){return e!==t})},n.withoutByProp=function(t,r,e){return e.filter(function(e){return e[t]!==r})},Object.defineProperty(n,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisHub=e.arcgisHub||{})}(this,function(n){"use strict";function o(r,n){return Object.keys(r).reduce(function(e,t){return e[t]=n(r[t],t,r),e},{})}function i(e,r,n){return n=n||"",Array.isArray(e)?e.map(t):!e||!c(e)||s(e)||p(e)||u(e)?r(e,n):Object.assign({},e,o(e,t));function t(e,t){return i(e,r,""+(n?n+"."+t:t))}}function a(e){return"string"==typeof e||e instanceof String}function s(e){return e instanceof Date}function u(e){return"function"==typeof e}function c(e){return"object"==typeof e}function p(e){return e instanceof RegExp}function f(e,t){return t.split(".").reduce(function(e,t){return e?e[t]:void 0},e)}function l(e){var t,r={};if(Array.isArray(e))r=e.map(l);else if("object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(null!=(t=e[n])&&"object"==typeof t?t instanceof Date?r[n]=new Date(t.getTime()):r[n]=l(t):r[n]=t);else r=e;return r}function d(e,r,n){return e?e.reduce(function(e,t){return e=f(t,r)===n?t:e},null):null}function r(e){return""+(e=void 0===e?"i":e)+Math.random().toString(36).substr(2,8)}function m(e,t){return null!=e&&(t=l(t)).push(e),t}function t(e){return(e=(e=e.toLowerCase()).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi," ")).replace(/(\-|\_|\.|\s)+(.)?/g,function(e,t,r){return r?r.toUpperCase():""}).replace(/(^|\/)([A-Z])/g,function(e,t,r){return e.toLowerCase()})}function h(e,t,r){return r.indexOf(e)===t}function g(e){return(e=Array.from(e))[0]=e[0].toUpperCase(),e.join("")}function y(e){return e.reduce(function(e,t){return e.concat(t)},[])}function v(e,t,r){void 0===r&&(r={});var t=t.split("."),n=e,o=t.length-1;t.forEach(function(e,t){n.hasOwnProperty(e)&&null!==n[e]?t===o&&("object"!=typeof n[e]||Array.isArray(n[e])?n[e]=r:n[e]=Object.assign(n[e],l(r))):n[e]=t===o?r:{},n=n[e]})}function b(e,t,r){t=f(e,t);return void 0!==t?t:r}function w(e,r,n){return i(e,function(e){if(!a(e))return e;var t=p(r)?r:new RegExp(r,"g");return e.replace(t,n)})}function C(t,r,e){return Array.isArray(e)&&e.length?(e.forEach(function(e){void 0!==f(t,e)&&v(r,e,f(t,e))}),r):t}function k(e,t,r){v(r,e=Array.isArray(e)?e.join("."):e,t)}function S(e,n,o){void 0===o&&(o=5);return e.reduce(function(e,t){var r=e[e.length-1];return r&&r.length!==o||e.push(r=[]),r.push(t),e},[]).reduce(function(e,r){return e.then(function(t){var e=r.map(function(e){return n(e)});return Promise.all(e).then(function(e){return t.concat(e)})})},Promise.resolve([]))}function A(e,t){return-1!==e.indexOf(t)}var T=function(e,t){return(T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function e(e,t){function r(){this.constructor=e}T(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var I=function(){return(I=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function E(e,a,s,u){return new(s=s||Promise)(function(r,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function o(e){try{i(u.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(n,o)}i((u=u.apply(e,a||[])).next())})}function x(r,n){var o,i,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,i&&(a=2&t[0]?i.return:t[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,t[1])).done)return a;switch(i=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,i=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){s.label=t[1];break}if(6===t[0]&&s.label<a[1]){s.label=a[1],a=t;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(t);break}a[2]&&s.ops.pop(),s.trys.pop();continue}t=n.call(r,s)}catch(e){t=[6,e],i=0}finally{o=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function D(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),o=0,t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n}var P,O=(e(R,P=Error),R);function R(e,t,r){var n=this;return t=t||"UNKNOWN_ERROR",r=b(r,"rootCause",r),(n=P.call(this,t)||this).operation=e,n.name="OperationError",n.rootCause=r,Object.setPrototypeOf(n,R.prototype),n.stack=b(r,"stack",(new Error).stack),n}function N(r,n){return void 0===n&&(n={}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.apply(void 0,e).catch(function(e){return n})}}function _(e){var r=(new Date).getTime();return Array(e).fill(0).reduce(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),e=""+e+t.toString(16)},"")}function U(e){"{"===e[0]&&(e=e.substring(1,e.length-1));return/^(\{){0,1}[0-9a-fA-F]{8}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{4}[-]?[0-9a-fA-F]{12}(\}){0,1}$/gi.test(e)}n.Level=void 0,(st=n.Level||(n.Level={}))[st.all=0]="all",st[st.debug=1]="debug",st[st.info=2]="info",st[st.warn=3]="warn",st[st.error=4]="error",st[st.off=5]="off";var j=(M.setLogLevel=function(e){this.logLevel=e},M.log=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.debug)&&console.log.apply(console,D([e],t))},M.debug=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.debug)&&console.debug.apply(console,D([e],t))},M.info=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.info)&&console.info.apply(console,D([e],t))},M.warn=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.warn)&&console.warn.apply(console,D([e],t))},M.error=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.isLevelPermitted(n.Level.error)&&console.error.apply(console,D([e],t))},M.isLevelPermitted=function(e){return this.logLevel<=e},M.logLevel=n.Level.off,M);function M(){}function L(e){return e.capabilities.includes("updateitemcontrol")}function F(e){e=e.privileges;return A(void 0===e?[]:e,"portal:user:createItem")}function G(e,t){var r,n=!1,o=e.itemControl,i=e.owner,a=e.orgId,s=t.roleId,u=t.role,c=t.username,p=t.groups,l=t.orgId,u=A(["admin","update"],o)||!!i&&i===c||!!(!!a&&a===l)&&!s&&"org_admin"===u,t=F(t);return t&&u?n=!0:t&&(r=D(f(e,"groupIds")||[],[f(e,"properties.collaborationGroupId")]),n=p.some(function(e){return L(e)&&A(r,e.id)})),n}var q=["portal:user:createGroup","portal:user:createItem","portal:user:shareToGroup","portal:user:viewOrgGroups","portal:user:viewOrgItems"];function B(e){var t=e.host,r=e.path,e=e.query,t=t.endsWith("/")?t:t+"/",t=new URL(r,t);return t.search=function(r){void 0===r&&(r={});var e=Object.keys(r).filter(function(e){return void 0!==r[e]}).reduce(function(e,t){return e[t]=r[t],e},{});return new URLSearchParams(e).toString()}(e),t.toString()}function Y(t){return Object.keys(t).some(function(e){e=t[e];if(!e)return!1;switch((e=e&&e.toParam?e.toParam():e).constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function W(o){var i={};return Object.keys(o).forEach(function(e){var t=o[e];if((t=t&&t.toParam?t.toParam():t)||0===t||"boolean"==typeof t||"string"==typeof t){switch(t.constructor.name){case"Array":var r=null===(r=null===(r=t[0])||void 0===r?void 0:r.constructor)||void 0===r?void 0:r.name,n="Array"===r?t:"Object"===r?JSON.stringify(t):t.join(",");break;case"Object":n=JSON.stringify(t);break;case"Date":n=t.valueOf();break;case"Function":n=null;break;case"Boolean":n=t+"";break;default:n=t}(n||0===n||"string"==typeof n||Array.isArray(n))&&(i[e]=n)}}),i}function H(e){var t=W(e);return Object.keys(t).map(function(e){return function t(r,e){return Array.isArray(e)&&e[0]&&Array.isArray(e[0])?e.map(function(e){return t(r,e)}).join("&"):encodeURIComponent(r)+"="+encodeURIComponent(e)}(e,t[e])}).join("&")}var V=function(e,t,r,n,o){e=e||"UNKNOWN_ERROR",t=t||"UNKNOWN_ERROR_CODE",this.name="ArcGISRequestError",this.message="UNKNOWN_ERROR_CODE"===t?e:t+": "+e,this.originalMessage=e,this.code=t,this.response=r,this.url=n,this.options=o};function z(e){console&&console.warn&&console.warn.apply(console,[e])}V.prototype=Object.create(Error.prototype),V.prototype.constructor=V;var J,K="@esri/arcgis-rest-js",$={httpMethod:"POST",params:{f:"json"}},Q=(e(X,J=V),X.prototype.retry=function(e,n){var o=this;void 0===n&&(n=3);var i=0,a=function(t,r){e(o.url,o.options).then(function(e){e=I(I({},o.options),{authentication:e});return i+=1,Z(o.url,e)}).then(function(e){t(e)}).catch(function(e){"ArcGISAuthError"===e.name&&i<n?a(t,r):"ArcGISAuthError"===e.name&&n<=i?r(o):r(e)})};return new Promise(function(e,t){a(e,t)})},X);function X(e,t,r,n,o){o=J.call(this,e=void 0===e?"AUTHENTICATION_ERROR":e,t=void 0===t?"AUTHENTICATION_ERROR_CODE":t,r,n,o)||this;return o.name="ArcGISAuthError",o.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,o}function Z(n,e){void 0===e&&(e={params:{f:"json"}});var o=I(I(I({httpMethod:"POST"},$),e),{params:I(I({},$.params),e.params),headers:I(I({},$.headers),e.headers)}),t=[],e=[];if(o.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),e.push("`node-fetch`")):o.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),e.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),e.push("`isomorphic-form-data`")),!o.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires a `fetch` implementation and global variables for `Promise` and `FormData` to be present in the global scope. You are missing "+t.join(", ")+". We recommend installing the "+e.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var e=o.httpMethod,i=o.authentication,a=o.rawResponse,s=I({f:"json"},o.params),r=null,u={method:e,credentials:o.credentials||"same-origin"};return o.headers&&o.headers["X-Esri-Auth-Client-Id"]&&-1<n.indexOf("/oauth2/platformSelf")&&(u.credentials="include"),(i?i.getToken(n,{fetch:o.fetch}).catch(function(e){return e.url=n,e.options=o,r=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){e.length&&(s.token=e),i&&i.getDomainCredentials&&(u.credentials=i.getDomainCredentials(n));var t={};"GET"===u.method&&(s.token&&o.hideToken&&"undefined"==typeof window&&(t["X-Esri-Authorization"]="Bearer "+s.token,delete s.token),r=""===H(s)?n:n+"?"+H(s),o.maxUrlLength&&r.length>o.maxUrlLength||s.token&&o.hideToken?(u.method="POST",e.length&&o.hideToken&&(s.token=e,delete t["X-Esri-Authorization"])):n=r);var r=new RegExp("/items/.+/updateResources").test(n);return"POST"===u.method&&(u.body=function(e,t){var t=Y(e)||t,r=W(e);if(t){var n=new FormData;return Object.keys(r).forEach(function(e){var t;"undefined"!=typeof Blob&&r[e]instanceof Blob?(t=r.fileName||r[e].name||e,n.append(e,r[e],t)):n.append(e,r[e])}),n}return H(e)}(s,r)),u.headers=I(I({},t),o.headers),"undefined"!=typeof window||u.headers.referer||(u.headers.referer=K),Y(s)||r||(u.headers["Content-Type"]="application/x-www-form-urlencoded"),o.fetch(n,u)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new V(r,"HTTP "+t,e,n,o)}if(a)return e;switch(s.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==s.f&&"geojson"!==s.f||a)return e;var t=function(t,e,r,n){if(400<=t.code){var o=t.message,i=t.code;throw new V(o,i,t,e,r)}if(t.error){var a=t.error,o=a.message,i=a.code,s=a.messageCode,a=s||i||"UNKNOWN_ERROR_CODE";if(498===i||499===i||"GWM_0003"===s||400===i&&"Unable to generate token."===o)throw n||new Q(o,a,t,e,r);throw new V(o,a,t,e,r)}if("failed"!==t.status&&"failure"!==t.status)return t;o=void 0,i="UNKNOWN_ERROR_CODE";try{o=JSON.parse(t.statusMessage).message,i=JSON.parse(t.statusMessage).code}catch(e){o=t.statusMessage||t.message}throw new V(o,i,t,e,r)}(e,n,o,r);return r&&(e=n.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0],o.authentication.federatedServers[e]={token:[],expires:new Date(Date.now()+864e5)},r=null),t})}function ee(e){return"string"==typeof e&&"/"===(e=e.trim())[e.length-1]?e.slice(0,-1):e}function te(e){return e.replace(/^#/,"").split("&").reduce(function(e,t){var r,t=(r=t,r=(t=t.split("="))[0],t=t[1],{key:decodeURIComponent(r),value:decodeURIComponent(t)});return e[t.key]=t.value,e},{})}function re(e){return(e=void 0===e?{}:e).portal?ee(e.portal):e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function ne(e){return e.owner?Promise.resolve(e.owner):e.item&&e.item.owner?Promise.resolve(e.item.owner):e.authentication&&e.authentication.getUsername?e.authentication.getUsername():Promise.reject(new Error("Could not determine the owner of this item. Pass the `owner`, `item.owner`, or `authentication` option."))}function oe(n){return ne(n).then(function(e){var t,r=n.folderId?re(n)+"/content/users/"+e+"/"+n.folderId+"/items/"+n.item.id+"/update":re(n)+"/content/users/"+e+"/items/"+n.item.id+"/update";return n.params=I(I({},n.params),(t=n.item,(e=JSON.parse(JSON.stringify(t))).data&&("undefined"!=typeof Blob&&t.data instanceof Blob||"ReadStream"===t.data.constructor.name?e.file=t.data:e.text=t.data,delete e.data),e)),Z(r,n)})}function ie(e,t){return Z(ae(e,t),I({httpMethod:"GET"},t))}var ae=function(e,t){return("string"==typeof t?t:re(t))+"/content/items/"+e};function se(e){var t=ae(e.id,e)+"/relatedItems",r=I({httpMethod:"GET",params:{direction:e.direction}},e);return"string"==typeof e.relationshipType?r.params.relationshipType=e.relationshipType:r.params.relationshipTypes=e.relationshipType,delete r.direction,delete r.relationshipType,Z(t,r)}function ue(t){return ne(t).then(function(e){return Z(re(t)+"/content/users/"+e+"/items/"+t.id+"/unprotect",t)})}function ce(e){return t=e.groupId,Z(re(e=e)+"/community/groups/"+t,I({httpMethod:"GET"},e)).then(function(e){return e.userMembership.memberType}).catch(function(){return"none"});var t}function pe(t){return ne(t).then(function(e){return Z(re(t)+"/content/users/"+e+"/items/"+t.id+"/delete",t)})}var le=(fe.prototype.match=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.termStack=this.termStack.concat(e),this},fe.prototype.in=function(e){return this.hasRange||this.hasTerms?(e&&"*"!==e&&(this.q+=e+":"),this.commit()):(z("`in("+(e?'"'+e+'"':"")+")`"+" was called with no call to `match(...)` or `from(...)`/`to(...)`. Your query was not modified."),this)},fe.prototype.startGroup=function(){return this.commit(),0<this.openGroups&&(this.q+=" "),this.openGroups++,this.q+="(",this},fe.prototype.endGroup=function(){return this.openGroups<=0?z("`endGroup(...)` was called without calling `startGroup(...)` first. Your query was not modified."):(this.commit(),this.openGroups--,this.q+=")"),this},fe.prototype.and=function(){return this.addModifier("and")},fe.prototype.or=function(){return this.addModifier("or")},fe.prototype.not=function(){return this.addModifier("not")},fe.prototype.from=function(e){return this.hasTerms?z('`from(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'):this.rangeStack[0]=e,this},fe.prototype.to=function(e){return this.hasTerms?z('`to(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'):this.rangeStack[1]=e,this},fe.prototype.boost=function(e){return this.commit(),this.q+="^"+e,this},fe.prototype.toParam=function(){return this.commit(),this.cleanup(),this.q},fe.prototype.clone=function(){return this.commit(),this.cleanup(),new fe(this.q+"")},fe.prototype.addModifier=function(e){return this.currentModifer?(z("You have called `"+this.currentModifer+"()` after `"+e+"()`. Your current query was not modified."),this):(this.commit(),""===this.q&&"not"!==e?z("You have called `"+e+"()` without calling another method to modify your query first. Try calling `match()` first."):(this.currentModifer=e,this.q+=""===this.q?"":" ",this.q+=e.toUpperCase()+" "),this)},fe.prototype.needsQuotes=function(e){return/\s|:/g.test(e)},fe.prototype.formatTerm=function(e){return e instanceof Date?e.getTime():"string"==typeof e&&this.needsQuotes(e)?'"'+e+'"':e},fe.prototype.commit=function(){var t=this;return this.currentModifer=void 0,this.hasRange&&(this.q+="["+this.formatTerm(this.rangeStack[0])+" TO "+this.formatTerm(this.rangeStack[1])+"]",this.rangeStack=[void 0,void 0]),this.hasTerms&&(this.q+=this.termStack.map(function(e){return t.formatTerm(e)}).join(" "),this.termStack=[]),this},Object.defineProperty(fe.prototype,"hasTerms",{get:function(){return 0<this.termStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasRange",{get:function(){return this.rangeStack.length&&this.rangeStack[0]&&this.rangeStack[1]},enumerable:!1,configurable:!0}),fe.prototype.cleanup=function(){if(0<this.openGroups)for(z("Automatically closing "+this.openGroups+" group(s). You can use `endGroup(...)` to remove this warning.");0<this.openGroups;)this.q+=")",this.openGroups--;var e=this.q;this.q=e.replace(/( AND ?| NOT ?| OR ?)*$/,""),e!==this.q&&z("`startGroup(...)` was called without calling `endGroup(...)` first. Your query was not modified."),this.q=this.q.replace(/(\(\))*/,"")},fe);function fe(e){void 0===e&&(e=""),this.termStack=[],this.rangeStack=[],this.openGroups=0,this.q=e}function de(r,n){var o,i,e,t="string"==typeof r||r instanceof le?{httpMethod:"GET",params:{q:r}}:(o=r,t=["q","num","start","sortField","sortOrder","searchUserAccess","searchUserName","filter","countFields","countSize","categories","categoryFilters"],(i=I(I({params:{}},{httpMethod:"GET"}),o)).params=t.reduce(function(e,t){return!o[t]&&"boolean"!=typeof o[t]||(e[t]=o[t]),e},i.params),["params","httpMethod","rawResponse","authentication","portal","fetch","maxUrlLength","headers"].reduce(function(e,t){return i[t]&&(e[t]=i[t]),e},{}));switch(n){case"item":e="/search";break;case"group":e="/community/groups";break;case"groupContent":if("string"==typeof r||r instanceof le||!r.groupId)return Promise.reject(new Error("you must pass a `groupId` option to `searchGroupContent`"));e="/content/groups/"+r.groupId+"/search";break;default:e="/portals/self/users/search"}return Z(re(t)+e,t).then(function(t){return t.nextStart&&-1!==t.nextStart&&(t.nextPage=function(){var e;return"string"==typeof r||r instanceof le?e={q:r,start:t.nextStart}:(e=r).start=t.nextStart,de(e,n)}),t})}function me(e){return de(e,"item")}function he(e,t){if(0===e.length)return[];for(var r=[],n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function ge(e){var t=e.id,r=re(e)+"/community/groups/"+t+"/addUsers",t=Object.assign({},e,{admins:void 0,users:void 0}),t=D(ye("users",e.users,t),ye("admins",e.admins,t)).map(function(e){return Z(r,e).catch(function(e){return{errors:[e]}})});return Promise.all(t).then(ve)}function ye(o,e,i){return!e||e.length<1?[]:he(e,25).map(function(e){return t=o,r=e,n=i,Object.assign({},n,((e={})[t]=r,e.params=I(I({},n.params),((n={})[t]=r,n)),e));var t,r,n})}function ve(e){var t=e.filter(function(e){return e.notAdded}).reduce(function(e,t){return e.concat(t.notAdded)},[]),e=e.filter(function(e){return e.errors}).reduce(function(e,t){return e.concat(t.errors)},[]),t={notAdded:t};return 0<e.length&&(t.errors=e),t}function be(t){var e=t.id,r=t.users,n=re(t)+"/community/groups/"+e+"/removeUsers",r=he(r,25).map(function(e){e=I(I({},t),{users:e,params:{users:e}});return Z(n,e).catch(function(e){return{errors:[e]}})});return Promise.all(r).then(function(e){var t=function(r){return e.filter(function(e){return e[r]}).reduce(function(e,t){return e.concat(t[r])},[])},r=t("errors"),t={notRemoved:t("notRemoved")};return r.length?I(I({},t),{errors:r}):t})}function we(e){var t,r=e.id,n=re(e)+"/community/groups/"+r+"/invite",e=he((t=e).users,25).map(function(e){return function(e,t){t=Object.assign({},t);return t.params=I(I({},t.params),{users:e,role:t.role,expiration:t.expiration}),t}(e,t)}).map(function(e){return Z(n,e).catch(function(e){return{errors:[e]}})});return Promise.all(e).then(Ce)}function Ce(e){var t=e.every(function(e){return e.success}),e=e.reduce(function(e,t){return e.concat(t.errors||[])},[]),t={success:t};return 0<e.length&&(t.errors=e),t}function ke(e){return Z(re(e)+"/community/groups/"+e.id+"/unprotect",e)}function Se(e){return Z(re(e)+"/community/groups/"+e.id+"/delete",I({},e))}function Ae(e){var t=re(e)+"/community/groups/"+e.id+"/updateUsers",r={authentication:e.authentication,params:{}};return"admin"===e.newMemberType?r.params.admins=e.users:r.params.users=e.users,Z(t,r)}function Te(e){var n,t=re(e)+"/portals/self/createNotification",e=he((n=e).users,n.batchSize||25).map(function(e){return t=e,r=n,(e=Object.assign({},r)).params=I(I({},e.params),{users:t,subject:r.subject,message:r.message,notificationChannelType:e.notificationChannelType}),e;var t,r}).map(function(e){return Z(t,e).catch(function(e){return{errors:[e]}})});return Promise.all(e).then(Ie)}function Ie(e){var t=e.every(function(e){return e.success}),e=e.reduce(function(e,t){return e.concat(t.errors||[])},[]),t={success:t};return 0<e.length&&(t.errors=e),t}function Ee(e){var t,r,n={httpMethod:"GET"};return"string"==typeof e?r="https://www.arcgis.com/sharing/rest/community/users/"+e:(t=e.username||e.authentication.username,r=re(e)+"/community/users/"+encodeURIComponent(t),n=I(I({},e),n)),Z(r,n)}function xe(t){return me({q:"id: "+t.id+" AND group: "+t.groupId,start:1,num:10,sortField:"title",authentication:t.authentication,httpMethod:"POST"}).then(function(e){if(0<e.total)return e.results.some(function(e){return e.id===t.id})})}function De(a){return xe(a).then(function(e){if(e)return{itemId:a.id,shortcut:!0,notSharedWith:[]};var t=a.authentication.username,e=a.owner,n=a.confirmItemControl,e=e||t;if(e===t)return Pe(a);var o=!1,i=!1;return Promise.all([Ee({username:t,authentication:a.authentication}),Ee({username:e,authentication:a.authentication}),ce(a)]).then(function(e){var t=e[0],r=e[1],e=e[2];return o="org_admin"===t.role&&!t.roleId,i=t.orgId!==r.orgId,function(e,t,r,n,o,i){var a=[];if(i.groupId!==e.favGroupId)if(t){if(!n)throw Error("This item can not be shared to shared editing group "+i.groupId+" by "+e.username+" as they not the item owner or org admin.");a.push(Oe(e,e,!1,"Error adding "+e.username+" as member to edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i),Oe(e,o,!0,"none"===r?"Error adding user "+o.username+" to edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.":"Error promoting user "+o.username+" to admin in edit group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i))}else if(n)a.push(Oe(e,e,!1,"Error adding "+e.username+" as member to view group "+i.groupId+". Consequently item "+i.id+" was not shared to the group.",i));else if("none"===r)throw new Error("This item can not be shared by "+e.username+" as they are not a member of the specified group "+i.groupId+".");return a}(t,!!n,e,o,r,a)}).then(function(e){var t=e[0],r=(void 0===t?{promise:Promise.resolve({notAdded:[]}),revert:function(e){return Promise.resolve(e)}}:t).revert;return Promise.all(e.map(function(e){return e.promise})).then(function(){return Pe(a,o,i)}).then(function(e){return r(e)})})}).then(function(e){if(e.notSharedWith.length)throw Error("Item "+a.id+" could not be shared to group "+a.groupId+".");return e})}function Pe(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);var n=e.authentication.username,o=e.owner||n,i=re(e)+"/content/items/"+e.id+"/share";return(o===n||t&&!r)&&(i=re(e)+"/content/users/"+o+"/items/"+e.id+"/share"),e.params={groups:e.groupId,confirmItemControl:e.confirmItemControl},Z(i,e)}function Oe(e,t,r,n,o){var i,a,s=t.groups||[],u=s.find(function(e){return e.id===o.groupId});if(e.orgId!==t.orgId)throw Error("User "+t.username+" is not a member of the same org as "+e.username+". Consequently they can not be added added to group "+o.groupId+" nor can item "+o.id+" be shared to the group.");if(!u&&511<s.length)throw Error("User "+t.username+" already has 512 groups, and can not be added to group "+o.groupId+". Consequently item "+o.id+" can not be shared to the group.");return a=u?r&&"member"===u.userMembership.memberType?(i=Ae({id:o.groupId,users:[t.username],newMemberType:"admin",authentication:o.authentication}).then(function(e){e=e.results.reduce(function(e,t){return t.success||e.push(t.username),e},[]);return Promise.resolve({notAdded:e})}).catch(function(){return{notAdded:[t.username]}}),function(e){return Ae({id:o.groupId,users:[t.username],newMemberType:"member",authentication:o.authentication}).then(function(){return e}).catch(function(){return e})}):(i=Promise.resolve({notAdded:[]}),function(e){return Promise.resolve(e)}):(i=ge(((a={id:o.groupId})[r?"admins":"users"]=[t.username],a.authentication=o.authentication,a)).then(function(e){if(e.errors&&e.errors.length)throw e.errors[0];return e}).catch(function(){return{notAdded:[t.username]}}),function(e){return be({id:o.groupId,users:[t.username],authentication:o.authentication}).then(function(){return e})}),{promise:i.then(function(e){if(e.notAdded.length)throw new Error(n);return e}),revert:a}}function Re(o){return xe(o).then(function(e){if(!e)return Promise.resolve({itemId:o.id,shortcut:!0,notUnsharedFrom:[]});var r=o.authentication.username,n=o.owner;return Promise.all([ce(o),Ee({username:r,authentication:o.authentication})]).then(function(e){var t=e[0],e=e[1],e="org_admin"===e.role&&!e.roleId;if(!((n||r)===r)&&!e&&["admin","owner"].indexOf(t)<0)throw Error("This item can not be unshared from group "+o.groupId+" by "+r+" as they not the item owner, an org admin, group admin or group owner.");return function(e){var t=e.authentication.username,r=e.owner||t,n=re(e)+"/content/items/"+e.id+"/unshare";r===t&&(n=re(e)+"/content/users/"+r+"/items/"+e.id+"/unshare");return e.params={groups:e.groupId},Z(n,e)}(o)}).then(function(e){if(e.notUnsharedFrom.length)throw Error("Item "+o.id+" could not be unshared to group "+o.groupId);return e})})}function Ne(e){if("string"==typeof e)return e.replace(/\/sharing\/rest\/?$/,"");if("object"==typeof e){var t=e.portalSelf||e,r=t.portalHostname,n=t.urlKey,o=t.customBaseUrl;if(r||n&&o)return t.isPortal?"https://"+t.portalHostname:"https://"+t.urlKey+"."+t.customBaseUrl}return Ne(re(e))}var _e={devext:"https://d1011m9qpnz5mw.cloudfront.net",qaext:"https://dyq9ux9ryu4qj.cloudfront.net",www:"https://d1iq7pbacwn5rb.cloudfront.net"};function Ue(e){if(e.isPortal)return Ne(e)+"/apps/sites";e=e.portalHostname.split(".")[0];return(_e[e]||_e.www)+"/opendata-ui/assets"}function je(e){return Ne(e)+"/sharing/rest"}function Me(e){return e=(e=e.toLowerCase()).includes("//")?e.split("//")[1]:e}function Le(e){var t;return e.match(/(qaext|\.mapsqa)\.arcgis.com/)?t="https://hubqa.arcgis.com":e.match(/(devext|\.mapsdevext)\.arcgis.com/)?t="https://hubdev.arcgis.com":e.match(/(www|\.maps)\.arcgis.com/)&&(t="https://hub.arcgis.com"),t}function Fe(e){if(e.isPortal)throw new Error("Hub Url is not available in ArcGIS Enterprise");return Le(e.portalHostname)}var Ge=function(e,t,r){var n=e.id,e=e.access,t=je(t)+"/content/items/"+n,n=new URLSearchParams({f:"json"});return"public"!==e&&r&&n.append("token",r),t+"?"+n.toString()},qe=/\/(map|feature)server/i,Be=function(e){e=e.match(qe),e=e&&e[1];return e&&g(e)+" Service"};function Ye(e){var t=e&&e.hubApiUrl;return t||Le(je(e))}function We(e,t){return t.rawResponse=!1,Z(e,t).then(function(e){var t={token:e.access_token,username:e.username,expires:new Date(Date.now()+(1e3*e.expires_in-1e3)),ssl:!0===e.ssl};return e.refresh_token&&(t.refreshToken=e.refresh_token),t})}function He(e,t){return"undefined"!=typeof window&&window.location&&window.location.host?t.params.referer=window.location.host:t.params.referer=K,Z(e,t)}var Ve=/^https?:\/\/(\S+)\.arcgis\.com.+/;function ze(e){return Ve.test(e)}function Je(e){if(!Ve.test(e))return null;e=e.match(Ve)[1].split(".").pop();return e.includes("dev")?"dev":e.includes("qa")?"qa":"production"}function Ke(e,t){t=ee(function(e){if(!Ve.test(e))return e;switch(Je(e)){case"dev":return"https://devext.arcgis.com/sharing/rest";case"qa":return"https://qaext.arcgis.com/sharing/rest";default:return"https://www.arcgis.com/sharing/rest"}}(t)).replace(/https?:\/\//,""),e=ee(e).replace(/https?:\/\//,"");return new RegExp(e,"i").test(t)}var $e=(Object.defineProperty(Qe.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),Object.defineProperty(Qe.prototype,"tokenExpires",{get:function(){return this._tokenExpires},enumerable:!1,configurable:!0}),Object.defineProperty(Qe.prototype,"refreshToken",{get:function(){return this._refreshToken},enumerable:!1,configurable:!0}),Object.defineProperty(Qe.prototype,"refreshTokenExpires",{get:function(){return this._refreshTokenExpires},enumerable:!1,configurable:!0}),Object.defineProperty(Qe.prototype,"trustedServers",{get:function(){return console.log("DEPRECATED: use federatedServers instead"),this.federatedServers},enumerable:!1,configurable:!0}),Qe.beginOAuth2=function(e,t){void 0===t&&(t=window),e.duration&&console.log("DEPRECATED: 'duration' is deprecated - use 'expiration' instead");var r=I({portal:"https://www.arcgis.com/sharing/rest",provider:"arcgis",expiration:20160,popup:!0,popupWindowFeatures:"height=400,width=600,menubar=no,location=yes,resizable=yes,scrollbars=yes,status=yes",state:e.clientId,locale:""},e),n=r.portal,o=r.provider,i=r.clientId,a=r.expiration,s=r.redirectUri,u=r.popup,c=r.popupWindowFeatures,p=r.state,l=r.locale,r=r.params,l="arcgis"===o?n+"/oauth2/authorize?client_id="+i+"&response_type=token&expiration="+(e.duration||a)+"&redirect_uri="+encodeURIComponent(s)+"&state="+p+"&locale="+l:n+"/oauth2/social/authorize?client_id="+i+"&socialLoginProviderName="+o+"&autoAccountCreateForSocial=true&response_type=token&expiration="+(e.duration||a)+"&redirect_uri="+encodeURIComponent(s)+"&state="+p+"&locale="+l;if(r&&(l=l+"&"+H(r)),u){var f,d=((f={promise:null,resolve:null,reject:null}).promise=new Promise(function(e,t){f.resolve=e,f.reject=t}),f);return t["__ESRI_REST_AUTH_HANDLER_"+i]=function(e,t){e?(e=JSON.parse(e),d.reject(new Q(e.errorMessage,e.error))):t&&(t=JSON.parse(t),d.resolve(new Qe({clientId:i,portal:n,ssl:t.ssl,token:t.token,tokenExpires:new Date(t.expires),username:t.username})))},t.open(l,"oauth-window",c),d.promise}t.location.href=l},Qe.completeOAuth2=function(e,o){void 0===o&&(o=window);var t=I({portal:"https://www.arcgis.com/sharing/rest",popup:!0},e),i=t.portal,a=t.clientId,s=t.popup;function r(e,t){try{var r=void 0,n="__ESRI_REST_AUTH_HANDLER_"+a;if(s&&(o.opener?o.opener.parent&&o.opener.parent[n]?r=o.opener.parent[n]:o.opener&&o.opener[n]&&(r=o.opener[n]):o!==o.parent&&o.parent&&o.parent[n]&&(r=o.parent[n]),r))return r(e?JSON.stringify(e):void 0,JSON.stringify(t)),void o.close()}catch(e){throw new Q('Unable to complete authentication. It\'s possible you specified popup based oAuth2 but no handler from "beginOAuth2()" present. This generally happens because the "popup" option differs between "beginOAuth2()" and "completeOAuth2()".')}if(e)throw new Q(e.errorMessage,e.error);return new Qe({clientId:a,portal:i,ssl:t.ssl,token:t.token,tokenExpires:t.expires,username:t.username})}e=te(o.location.hash);if(!e.access_token){var n=void 0,u="Unknown error";return e.error&&(n=e.error,u=e.error_description),r({error:n,errorMessage:u})}t=e.access_token,n=new Date(Date.now()+1e3*parseInt(e.expires_in,10)-6e4),u=e.username;return r(void 0,{token:t,expires:n,ssl:"true"===e.ssl,username:u})},Qe.fromParent=function(e,n){var o;return!n&&window&&(n=window),new Promise(function(t,r){o=function(e){if(e.source===n.parent&&e.data)try{return t(Qe.parentMessageHandler(e))}catch(e){return r(e)}},n.addEventListener("message",o,!1),n.parent.postMessage({type:"arcgis:auth:requestCredential"},e)}).then(function(e){return n.removeEventListener("message",o,!1),e})},Qe.authorize=function(e,t){e.duration&&console.log("DEPRECATED: 'duration' is deprecated - use 'expiration' instead");var r=I({portal:"https://arcgis.com/sharing/rest",expiration:20160},e),n=r.portal,o=r.clientId,i=r.expiration,r=r.redirectUri;t.writeHead(301,{Location:n+"/oauth2/authorize?client_id="+o+"&expiration="+(e.duration||i)+"&response_type=code&redirect_uri="+encodeURIComponent(r)}),t.end()},Qe.exchangeAuthorizationCode=function(e,t){var e=I({portal:"https://www.arcgis.com/sharing/rest",refreshTokenTTL:20160},e),r=e.portal,n=e.clientId,o=e.redirectUri,i=e.refreshTokenTTL;return We(r+"/oauth2/token",{params:{grant_type:"authorization_code",client_id:n,redirect_uri:o,code:t}}).then(function(e){return new Qe({clientId:n,portal:r,ssl:e.ssl,redirectUri:o,refreshToken:e.refreshToken,refreshTokenTTL:i,refreshTokenExpires:new Date(Date.now()+60*(i-1)*1e3),token:e.token,tokenExpires:e.expires,username:e.username})})},Qe.deserialize=function(e){e=JSON.parse(e);return new Qe({clientId:e.clientId,refreshToken:e.refreshToken,refreshTokenExpires:new Date(e.refreshTokenExpires),username:e.username,password:e.password,token:e.token,tokenExpires:new Date(e.tokenExpires),portal:e.portal,ssl:e.ssl,tokenDuration:e.tokenDuration,redirectUri:e.redirectUri,refreshTokenTTL:e.refreshTokenTTL})},Qe.fromCredential=function(e){var t=void 0===e.ssl||e.ssl,r=e.expires||Date.now()+72e5;return new Qe({portal:e.server.includes("sharing/rest")?e.server:e.server+"/sharing/rest",ssl:t,token:e.token,username:e.userId,tokenExpires:new Date(r)})},Qe.parentMessageHandler=function(e){if("arcgis:auth:credential"===e.data.type)return Qe.fromCredential(e.data.credential);if("arcgis:auth:error"!==e.data.type)throw new Error("Unknown message type.");var t=new Error(e.data.error.message);throw t.name=e.data.error.name,t},Qe.prototype.toCredential=function(){return{expires:this.tokenExpires.getTime(),server:this.portal,ssl:this.ssl,token:this.token,userId:this.username}},Qe.prototype.getUser=function(e){var t=this;if(this._pendingUserRequest)return this._pendingUserRequest;if(this._user)return Promise.resolve(this._user);var r=this.portal+"/community/self",e=I(I({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingUserRequest=Z(r,e).then(function(e){return t._user=e,t._pendingUserRequest=null,e}),this._pendingUserRequest},Qe.prototype.getPortal=function(e){var t=this;if(this._pendingPortalRequest)return this._pendingPortalRequest;if(this._portalInfo)return Promise.resolve(this._portalInfo);var r=this.portal+"/portals/self",e=I(I({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingPortalRequest=Z(r,e).then(function(e){return t._portalInfo=e,t._pendingPortalRequest=null,e}),this._pendingPortalRequest},Qe.prototype.getUsername=function(){return this.username?Promise.resolve(this.username):this._user?Promise.resolve(this._user.username):this.getUser().then(function(e){return e.username})},Qe.prototype.getToken=function(e,t){return r=this.portal,n=e,o=ze(r),i=ze(n),r=Je(r),n=Je(n),o&&i&&r===n||new RegExp(this.portal,"i").test(e)?this.getFreshToken(t):this.getTokenForServer(e,t);var r,n,o,i},Qe.prototype.validateAppAccess=function(r){return this.getToken(this.portal).then(function(e){return Z((t=void 0===t?"https://www.arcgis.com/sharing/rest":t)+"/oauth2/validateAppAccess",{method:"POST",params:{f:"json",client_id:r,token:e}});var t})},Qe.prototype.toJSON=function(){return{clientId:this.clientId,refreshToken:this.refreshToken,refreshTokenExpires:this.refreshTokenExpires,username:this.username,password:this.password,token:this.token,tokenExpires:this.tokenExpires,portal:this.portal,ssl:this.ssl,tokenDuration:this.tokenDuration,redirectUri:this.redirectUri,refreshTokenTTL:this.refreshTokenTTL}},Qe.prototype.serialize=function(){return JSON.stringify(this)},Qe.prototype.enablePostMessageAuth=function(e,t){!t&&window&&(t=window),this._hostHandler=this.createPostMessageHandler(e),t.addEventListener("message",this._hostHandler,!1)},Qe.prototype.disablePostMessageAuth=function(e){(e=!e&&window?window:e).removeEventListener("message",this._hostHandler,!1)},Qe.prototype.refreshSession=function(e){return this._user=null,this.username&&this.password?this.refreshWithUsernameAndPassword(e):this.clientId&&this.refreshToken?this.refreshWithRefreshToken():Promise.reject(new Q("Unable to refresh token."))},Qe.prototype.getServerRootUrl=function(e){var t=ee(e).split(/\/rest(\/admin)?\/services(?:\/|#|\?|$)/)[0].match(/(https?:\/\/)(.+)/);t[0];var r=t[1],e=t[2].split("/"),t=e[0],e=e.slice(1);return""+r+t.toLowerCase()+"/"+e.join("/")},Qe.prototype.getDomainCredentials=function(t){return this.trustedDomains&&this.trustedDomains.length&&this.trustedDomains.some(function(e){return t.startsWith(e)})?"include":"same-origin"},Qe.prototype.createPostMessageHandler=function(n){var o=this;return function(e){var t=-1<n.indexOf(e.origin),r="arcgis:auth:requestCredential"===e.data.type;t&&r&&((r=o.toCredential()).server=r.server.replace("/sharing/rest",""),e.source.postMessage({type:"arcgis:auth:credential",credential:r},e.origin))}},Qe.prototype.getTokenForServer=function(t,r){var n=this,o=this.getServerRootUrl(t),e=this.federatedServers[o];return e&&e.expires&&e.expires.getTime()>Date.now()?Promise.resolve(e.token):this._pendingTokenRequests[o]||(this._pendingTokenRequests[o]=this.fetchAuthorizedDomains().then(function(){return Z(o+"/rest/info",{credentials:n.getDomainCredentials(t)}).then(function(e){if(e.owningSystemUrl){if(Ke(e.owningSystemUrl,n.portal))return Z(e.owningSystemUrl+"/sharing/rest/info",r);throw new Q(t+" is not federated with "+n.portal+".","NOT_FEDERATED")}if(e.authInfo&&void 0!==n.federatedServers[o])return Promise.resolve({authInfo:e.authInfo});throw new Q(t+" is not federated with any portal and is not explicitly trusted.","NOT_FEDERATED")}).then(function(e){return e.authInfo.tokenServicesUrl}).then(function(e){return n.token&&n.tokenExpires.getTime()>Date.now()?He(e,{params:{token:n.token,serverUrl:t,expiration:n.tokenDuration,client:"referer"}}):He(e,{params:{username:n.username,password:n.password,expiration:n.tokenDuration,client:"referer"}}).then(function(e){return n._token=e.token,n._tokenExpires=new Date(e.expires),e})}).then(function(e){return n.federatedServers[o]={expires:new Date(e.expires),token:e.token},delete n._pendingTokenRequests[o],e.token})}),this._pendingTokenRequests[o])},Qe.prototype.getFreshToken=function(e){var t=this;return this.token&&!this.tokenExpires||this.token&&this.tokenExpires&&this.tokenExpires.getTime()>Date.now()?Promise.resolve(this.token):(this._pendingTokenRequests[this.portal]||(this._pendingTokenRequests[this.portal]=this.refreshSession(e).then(function(e){return t._pendingTokenRequests[t.portal]=null,e.token})),this._pendingTokenRequests[this.portal])},Qe.prototype.refreshWithUsernameAndPassword=function(e){var t=this,e=I({params:{username:this.username,password:this.password,expiration:this.tokenDuration}},e);return He(this.portal+"/generateToken",e).then(function(e){return t._token=e.token,t._tokenExpires=new Date(e.expires),t})},Qe.prototype.refreshWithRefreshToken=function(e){var t=this;if(this.refreshToken&&this.refreshTokenExpires&&this.refreshTokenExpires.getTime()<Date.now())return this.refreshRefreshToken(e);e=I({params:{client_id:this.clientId,refresh_token:this.refreshToken,grant_type:"refresh_token"}},e);return We(this.portal+"/oauth2/token",e).then(function(e){return t._token=e.token,t._tokenExpires=e.expires,t})},Qe.prototype.refreshRefreshToken=function(e){var t=this,e=I({params:{client_id:this.clientId,refresh_token:this.refreshToken,redirect_uri:this.redirectUri,grant_type:"exchange_refresh_token"}},e);return We(this.portal+"/oauth2/token",e).then(function(e){return t._token=e.token,t._tokenExpires=e.expires,t._refreshToken=e.refreshToken,t._refreshTokenExpires=new Date(Date.now()+60*(t.refreshTokenTTL-1)*1e3),t})},Qe.prototype.fetchAuthorizedDomains=function(){var t=this;return this.server||!this.portal?Promise.resolve(this):this.getPortal().then(function(e){return e.authorizedCrossOriginDomains&&e.authorizedCrossOriginDomains.length&&(t.trustedDomains=e.authorizedCrossOriginDomains.filter(function(e){return!e.startsWith("http://")}).map(function(e){return e.startsWith("https://")?e:"https://"+e})),t})},Qe);function Qe(e){var t;this.clientId=e.clientId,this._refreshToken=e.refreshToken,this._refreshTokenExpires=e.refreshTokenExpires,this.username=e.username,this.password=e.password,this._token=e.token,this._tokenExpires=e.tokenExpires,this.portal=e.portal?ee(e.portal):"https://www.arcgis.com/sharing/rest",this.ssl=e.ssl,this.provider=e.provider||"arcgis",this.tokenDuration=e.tokenDuration||20160,this.redirectUri=e.redirectUri,this.refreshTokenTTL=e.refreshTokenTTL||20160,this.server=e.server,this.federatedServers={},this.trustedDomains=[],e.server&&(t=this.getServerRootUrl(e.server),this.federatedServers[t]={token:e.token,expires:e.tokenExpires}),this._pendingTokenRequests={}}var Xe={app:["Application","City Engine Web Scene","CityEngine Web Scene","Dashboard","Insights Page","Insights Workbook","Operation View","Web Mapping Application","StoryMap","Web Experience","Urban Model"],dataset:["CSV Collection","CSV","Feature Collection Template","Feature Collection","Feature Layer","Feature Service","File Geodatabase","GeoJSON","GeoJson","KML Collection","KML","Microsoft Excel","Raster Layer","Shapefile","Stream Service","Table"],document:["CAD Drawing","Document Link","Hub Page","Site Page","Image","iWork Keynote","iWork Numbers","iWork Pages","Microsoft Powerpoint","Microsoft Visio","Microsoft Word","Notebook","PDF","Pro Map","Report Template"],event:["Hub Event"],feedback:["Form","Quick Capture Project"],initiative:["Hub Initiative"],template:["Hub Initiative Template"],solution:["Solution"],map:["Image Collection","Image Service","Map Service Layer","Map Service","Scene Service","Scene Layer","Vector Tile Service","Web Map Service","Web Map Tile Service","Web Map","Web Scene","WFS","WMS","WMTS"],other:["360 VR Experience","AppBuilder Widget Package","Application Configuration","ArcPad Package","Code Attachment","Code Sample","Desktop Add In","Desktop Application Template","Desktop Application","Desktop Style","Explorer Add In","Explorer Layer","Geocoding Service","Geometry Service","Geoprocessing Package","Geoprocessing Sample","Geoprocessing Service","Layer File","Layer Package","Layer Template","Layer","Layout","Locator Package","Map Area","Map Document","Map Package","Map Service Definition","Map Template","Mobile Application","Mobile Map Package","Native Application","Network Analysis Service","Operations Dashboard Add In","Project Package","Project Template","Raster Function Template","Rule Package","Scene Package","Service Definition","SQLite Geodatabase","Style","Tile Package","Vector Tile Package","Workflow Manager Package"],site:["Hub Site Application","Site Application"]},Ze=Xe.app,et=Xe.dataset,tt=Xe.document,rt=Xe.event,nt=Xe.feedback,ot=Xe.initiative,it=Xe.map,at=Xe.other,st=Xe.site,ut=["360 VR Experience","Application","CityEngine Web Scene","Code Sample","CSV Collection","CSV","CAD Drawing","Desktop Application","Desktop Application Template","Desktop Style","File Geodatabase","GeoJson","Geoprocessing Package","Geoprocessing Sample","Image","iWork Keynote","iWork Numbers","KML Collection","KML","Layer","Layer File","Layer Package","Layout","Locator Package","Map Package","Map Service Definition","Map Template","Microsoft Excel","Microsoft Powerpoint","Microsoft Visio","Microsoft Word","Notebook","Operations Dashboard Add In","PDF","Pro Map","Project Package","Project Template","Raster function template","Rule Package","Service Definition","Shapefile","Vector Tile Package","Workflow Manager Package"],ct=["Data"],pt={app:Ze.concat(nt),dataset:et,document:tt,event:rt,initiative:ot,map:it,other:at,site:st,downloadableTypes:ut,downloadableTypeKeywords:ct,apiTypes:["Feature Service","Map Service","Image Service"]};function lt(e){return-1!==ut.indexOf(e.type)||e.typeKeywords&&ct.some(function(t){return e.typeKeywords.some(function(e){return e===t})})}function ft(e,t,r,n,o){return{xmin:e,ymin:t,xmax:r,ymax:n,spatialReference:{wkid:o=void 0===o?4326:o}}}function dt(e){return[[e.xmin,e.ymin],[e.xmax,e.ymax]]}var mt={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}};function ht(e){var t=e.portalSelf,r=t.defaultExtent,t=f(t,"helperServices.geometry.url");if(!t)return Promise.resolve(mt);if(!r)return Promise.resolve(mt);t+="/project",r={httpMethod:"POST",params:{geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[r]}),transformForward:!1,transformation:"",inSR:r.spatialReference.wkid,outSR:4326,f:"json"}};return e.authentication&&(r.authentication=e.authentication),Z(t,r).then(function(e){e=e.geometries[0];return{xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:e.ymax,spatialReference:{wkid:4326}}}).catch(function(e){return mt})}function gt(e){return Array.isArray(e)&&Array.isArray(e[0])&&Array.isArray(e[1])}var yt=[{type:"CC0-1.0",abbr:"CC0",name:"Public Domain Dedication",url:"http://creativecommons.org/publicdomain/zero/1.0"},{type:"CC-BY-4.0",abbr:"CC BY",name:"Attribution 4.0 International",url:"http://creativecommons.org/licenses/by/4.0"},{type:"CC-BY-3.0",abbr:"CC BY 3.0",name:"Attribution 3.0 Unported",url:"http://creativecommons.org/licenses/by/3.0"},{type:"CC-BY-2.5",abbr:"CC BY 2.5",name:"Attribution 2.5 Generic",url:"http://creativecommons.org/licenses/by/2.5"},{type:"CC-BY-2.0",abbr:"CC BY 2.0",name:"Attribution 2.0 Generic",url:"http://creativecommons.org/licenses/by/2.0"},{type:"CC-BY-1.0",abbr:"CC BY 1.0",name:"Attribution 1.0 Generic",url:"http://creativecommons.org/licenses/by/1.0"},{type:"CC-BY-SA-4.0",abbr:"CC BY-SA",name:"Attribution-ShareAlike 4.0 International",url:"http://creativecommons.org/licenses/by-sa/4.0"},{type:"CC-BY-SA-3.0",abbr:"CC BY-SA 3.0",name:"Attribution-ShareAlike 3.0 Unported",url:"http://creativecommons.org/licenses/by-sa/3.0"},{type:"CC-BY-SA-2.5",abbr:"CC BY-SA 2.5",name:"Attribution-ShareAlike 2.5 Generic",url:"http://creativecommons.org/licenses/by-sa/2.5"},{type:"CC-BY-SA-2.0",abbr:"CC BY-SA 2.0",name:"Attribution-ShareAlike 2.0 Generic",url:"http://creativecommons.org/licenses/by-sa/2.0"},{type:"CC-BY-SA-1.0",abbr:"CC BY-SA 1.0",name:"Attribution-ShareAlike 1.0 Generic",url:"http://creativecommons.org/licenses/by-sa/1.0"},{type:"CC-BY-ND-4.0",abbr:"CC BY-ND",name:"Attribution-NoDerivatives 4.0 International",url:"http://creativecommons.org/licenses/by-nd/4.0"},{type:"CC-BY-ND-3.0",abbr:"CC BY-ND 3.0",name:"Attribution-NoDerivs 3.0 Unported",url:"http://creativecommons.org/licenses/by-nd/3.0"},{type:"CC-BY-ND-2.5",abbr:"CC BY-ND 2.5",name:"Attribution-NoDerivs 2.5 Generic",url:"http://creativecommons.org/licenses/by-nd/2.5"},{type:"CC-BY-ND-2.0",abbr:"CC BY-ND 2.0",name:"Attribution-NoDerivs 2.0 Generic",url:"http://creativecommons.org/licenses/by-nd/2.0"},{type:"CC-BY-ND-1.0",abbr:"CC BY-ND 1.0",name:"Attribution-NoDerivs 1.0 Generic",url:"http://creativecommons.org/licenses/by-nd/1.0"},{type:"CC-BY-NC-4.0",abbr:"CC BY-NC",name:"Attribution-NonCommercial 4.0 International",url:"https://creativecommons.org/licenses/by-nc/4.0"},{type:"CC-BY-NC-3.0",abbr:"CC BY-NC 3.0",name:"Attribution-NonCommercial 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc/3.0"},{type:"CC-BY-NC-2.5",abbr:"CC BY-NC 2.5",name:"Attribution-NonCommercial 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc/2.5"},{type:"CC-BY-NC-2.0",abbr:"CC BY-NC 2.0",name:"Attribution-NonCommercial 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc/2.0"},{type:"CC-BY-NC-1.0",abbr:"CC BY-NC 1.0",name:"Attribution-NonCommercial 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc/1.0"},{type:"CC-BY-NC-SA-4.0",abbr:"CC BY-NC-SA",name:"Attribution-NonCommercial-ShareAlike 4.0 International",url:"https://creativecommons.org/licenses/by-nc-sa/4.0"},{type:"CC-BY-NC-SA-3.0",abbr:"CC BY-NC-SA 3.0",name:"Attribution-NonCommercial-ShareAlike 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc-sa/3.0"},{type:"CC-BY-NC-SA-2.5",abbr:"CC BY-NC-SA 2.5",name:"Attribution-NonCommercial-ShareAlike 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/2.5"},{type:"CC-BY-NC-SA-2.0",abbr:"CC BY-NC-SA 2.0",name:"Attribution-NonCommercial-ShareAlike 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/2.0"},{type:"CC-BY-NC-SA-1.0",abbr:"CC BY-NC-SA 1.0",name:"Attribution-NonCommercial-ShareAlike 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc-sa/1.0"},{type:"CC-BY-NC-ND-4.0",abbr:"CC BY-NC-ND",name:"Attribution-NonCommercial-NoDerivatives 4.0 International",url:"https://creativecommons.org/licenses/by-nc-nd/4.0"},{type:"CC-BY-NC-ND-3.0",abbr:"CC BY-NC-ND 3.0",name:"Attribution-NonCommercial-NoDerivs 3.0 Unported",url:"https://creativecommons.org/licenses/by-nc-nd/3.0"},{type:"CC-BY-NC-ND-2.5",abbr:"CC BY-NC-ND 2.5",name:"Attribution-NonCommercial-NoDerivs 2.5 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/2.5"},{type:"CC-BY-NC-ND-2.0",abbr:"CC BY-NC-ND 2.0",name:"Attribution-NonCommercial-NoDerivs 2.0 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/2.0"},{type:"CC-BY-NC-ND-1.0",abbr:"CC BY-NC-ND 1.0",name:"Attribution-NonCommercial-NoDerivs 1.0 Generic",url:"https://creativecommons.org/licenses/by-nc-nd/1.0"},{type:"PDDL-1.0",abbr:"PDDL",name:"ODC Public Domain Dedication and License",url:"http://opendatacommons.org/licenses/pddl/summary"},{type:"ODbL-1.0",abbr:"ODbL",name:"ODC Open Database License",url:"http://opendatacommons.org/licenses/odbl/summary"},{type:"ODC-BY-1.0",abbr:"ODC BY",name:"ODC Attribution License",url:"http://opendatacommons.org/licenses/by/summary"}];function vt(r){var e={type:(r=r||"")?"custom":"none",text:r},t=!1,n=yt.filter(function(e){return t=e,(e=(e=r).toLowerCase()).includes(t.name.toLowerCase())||e.includes(t.url.toLowerCase())||e.includes(t.abbr.toLowerCase());var t});return n.length&&(t=!0,e=n.pop()),t||(n=void 0,!function(e){try{return!!new URL(e).protocol}catch(e){return!1}}(r)?(t=r,new RegExp(/^<a[\s]+(href\s?=\s?["'].*?["'])+([^>]?)>((?:.(?!\<\/a\>))*.)?<\/a>$|^<a[\s]+(href\s?=\s?["'].*?["'])+([^>]?)\/>/).test(t)&&(t=new RegExp(/href\s?=\s?["'](.*?)["']/),n=r.match(t)[1])):n=r,n&&(e.url=n,e.text="")),e.text||delete e.text,e}var bt={};function wt(e){void 0===e&&(e=""),console.warn("DEPRECATED: Use getCollection() instead. getCategory will be removed at v9.0.0");e=kt(e);return"feedback"===e?"app":e}function Ct(e){var t=(e=void 0===e?{}:e).type,r=e.typeKeywords||[];return("Site Application"===e.type||"Web Mapping Application"===e.type&&A(r,"hubSite"))&&(t="Hub Site Application"),("Site Page"===e.type||"Web Mapping Application"===e.type&&A(r,"hubPage"))&&(t="Hub Page"),"Hub Initiative"===e.type&&A(r,"hubInitiativeTemplate")&&(t="Hub Initiative Template"),t="Web Mapping Application"===e.type&&A(r,"hubSolutionTemplate")?"Solution":t}function kt(e){if(bt[e=void 0===e?"":e])return bt[e];for(var t=0,r=Object.keys(Xe);t<r.length;t++)for(var n=r[t],o=0,i=Xe[n];o<i.length;o++){var a=i[o];if(e.toLowerCase()===a.toLowerCase())return bt[e]=n}}function St(e){return e&&"feature service"===e.toLowerCase()}function At(e){return(e=e&&e.match(/\/\d+$/))&&e[0].slice(1)}function Tt(e){return At(e.url)||St(e.type)&&A(e.typeKeywords,"Singlelayer")&&"0"}function It(t,e){if(A(["template","feedback"],t.family))return t.id;if(Ft(t)){var r=(f(e,"data.values.pages")||[]).find(function(e){return e.id===t.id});return r?r.slug:t.id}if(t.slug){r=f(e,"domainInfo.orgKey");return f(e,"data.values.isUmbrella")?t.slug:xt(t.slug,r)}return t.hubId||t.id}function Et(e){e=e?e.split("_"):[];return{itemId:e[0],layerId:e[1]}}function xt(e,t){return t&&e.match(t+"::")?e.split(t+"::")[1]:e}function Dt(e){if(!e)return e;var t=["categories",""];return e.map(function(e){return e.split("/")}).reduce(function(e,t,r){return D(e,t)},[]).filter(function(e){return!A(t,e.toLowerCase())})}function Pt(e){var t,r;switch((e||"").toLowerCase()){case"image service":t="dataset";break;case"feature service":case"raster layer":t="map";break;case"microsoft excel":t="document";break;case"cad drawing":case"feature collection template":case"report template":t="content";break;default:t={other:"content",solution:"template"}[r=kt(e)]||r}return t}function Ot(e){return console.warn("DEPRECATED: Use getFamily() instead. getItemHubType() will be removed at v9.0.0"),kt(Ct(e="string"==typeof e?{type:e}:e))}function Rt(e){var t=new Date(e.created),r="item.created",n=e.properties,r=Object.assign({},e,{identifier:e.id,errors:[],item:e,name:e.title,hubType:Ot(e),categories:Dt(e.categories),itemCategories:e.categories,summary:e.snippet||e.description,publisher:{name:e.owner,username:e.owner},permissions:{visibility:e.access,control:e.itemControl||"view"},actionLinks:n&&n.links,hubActions:n&&n.actions,metrics:n&&n.metrics,isDownloadable:lt(e),boundary:(n=e.extent)&&n.length&&{geometry:ft(n[0][0],n[0][1],n[1][0],n[1][1])},license:{name:"Custom License",description:e.accessInformation},createdDate:t,createdDateSource:r,publishedDate:t,publishedDateSource:r,updatedDate:new Date(e.modified),updatedDateSource:"item.modified",structuredLicense:vt(e.licenseInfo)});return Ut(r,e.type)}function Nt(e){if(e){var t=e.id,r=e.attributes;if(r){var n=Et(t).itemId,o=r.owner,i=r.orgId,a=r.created,s=r.modified,u=r.name,c=r.title,p=r.type,l=r.typeKeywords,f=r.description,d=r.snippet,m=r.tags,h=r.thumbnail,g=r.categories,y=r.contentStatus,v=r.spatialReference,b=r.accessInformation,w=r.licenseInfo,C=r.culture,k=r.url,S=r.access,A=r.proxyFilter,T=r.properties,I=r.appCategories,E=r.industries,x=r.languages,D=r.largeThumbnail,P=r.banner,O=r.screenshots,R=r.listed,N=r.ownerFolder,_=r.size,U=r.protected,j=r.commentsEnabled,M=r.numComments,L=r.numRatings,F=r.avgRating,G=r.numViews,q=r.itemControl,B=r.scoreCompleteness,Y=r.itemExtent,e=r.itemModified,t=r.modifiedProvenance,r=r.serviceSpatialReference;return{id:n,owner:o,orgId:i,created:a,modified:e||"item.modified"===t&&s,title:c||u,type:k&&Be(k)||p,typeKeywords:l,description:f,tags:m,snippet:d,thumbnail:h,extent:Y||[],categories:g,contentStatus:y,spatialReference:v||r,accessInformation:b,licenseInfo:w,culture:C,url:k,access:S,size:_,protected:U,proxyFilter:A,properties:T,appCategories:I,industries:E,languages:x,largeThumbnail:D,banner:P,screenshots:O,listed:R,ownerFolder:N,commentsEnabled:j,numComments:M,numRatings:L,avgRating:F,numViews:G,itemControl:q,scoreCompleteness:B}}}}function _t(e,t){var r=e.id,r=e.slug||t||r,r=I(I({},e),{hubId:t,identifier:r});return jt(r,{relative:Mt(r)})}var Ut=function(e,t){var r=Pt(t),n=Ct(I(I({},e.item),{type:t})),n=I(I({},e),{type:t,family:r,normalizedType:n});return jt(n,{relative:Mt(n)})},jt=function(e,t){t=I(I({},e.urls),t);return I(I({},e),{urls:t})},Mt=function(e,t){var r=e.family,n=t||e.identifier,o=Lt(e);return o||(t="/content","feedback"===e.family?t="/feedback/surveys":Ft(e)?t="/pages":-1<["app","dataset","document","map","template"].indexOf(r)&&(t="/"+r+"s"),o=t+"/"+n),o},Lt=function(e){var t,r=e.normalizedType,n=e.identifier;return"Solution"===r&&(0<(null===(e=e.typeKeywords)||void 0===e?void 0:e.indexOf("Deployed"))&&(t="/content/"+n),t="/templates/"+n+"/about"),t},Ft=function(e){return A(["Hub Page","Site Page"],e.type)};const Gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";const qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var Bt={atob:function(t){if((t=(t=(t=`${t}`).replace(/[ \t\n\f\r]/g,"")).length%4==0?t.replace(/==?$/,""):t).length%4==1||/[^+/0-9A-Za-z]/.test(t))return null;let r="",n=0,o=0;for(let e=0;e<t.length;e++)n<<=6,n|=function(e){e=Gt.indexOf(e);return e<0?void 0:e}(t[e]),o+=6,24===o&&(r+=String.fromCharCode((16711680&n)>>16),r+=String.fromCharCode((65280&n)>>8),r+=String.fromCharCode(255&n),n=o=0);return 12===o?(n>>=4,r+=String.fromCharCode(n)):18===o&&(n>>=2,r+=String.fromCharCode((65280&n)>>8),r+=String.fromCharCode(255&n)),r},btoa:function(e){let t;for(e=`${e}`,t=0;t<e.length;t++)if(255<e.charCodeAt(t))return null;let r="";for(t=0;t<e.length;t+=3){const n=[void 0,void 0,void 0,void 0];n[0]=e.charCodeAt(t)>>2,n[1]=(3&e.charCodeAt(t))<<4,e.length>t+1&&(n[1]|=e.charCodeAt(t+1)>>4,n[2]=(15&e.charCodeAt(t+1))<<2),e.length>t+2&&(n[2]|=e.charCodeAt(t+2)>>6,n[3]=63&e.charCodeAt(t+2));for(let e=0;e<n.length;e++)void 0===n[e]?r+="=":r+=function(e){if(0<=e&&e<64)return qt[e];return}(n[e])}return r}},Yt="4326",Wt={csv:{name:"CSV",itemTypes:["CSV","CSV Collection"],supportsProjection:!0},kml:{name:"KML",itemTypes:["KML","KML Collection"],supportsProjection:!1},shapefile:{name:"Shapefile",itemTypes:["Shapefile"],supportsProjection:!0},fileGeodatabase:{name:"File Geodatabase",itemTypes:["File Geodatabase"],supportsProjection:!0},geojson:{name:"GeoJson",itemTypes:["GeoJson"],supportsProjection:!1},excel:{name:"Excel",itemTypes:["Microsoft Excel"],supportsProjection:!0},featureCollection:{name:"Feature Collection",itemTypes:["Feature Collection"],supportsProjection:!0}};function Ht(e){if("object"!=typeof e)return e;var t=e.wkid,e=e.wkt;return t?t+"":Bt.btoa(e)}function Vt(e){return"spatialRefId:"+Ht(function(t){var r;try{r=JSON.parse(t)}catch(e){r=t}return r}(e))}function zt(e){return"exportItem:"+e}function Jt(e){return e?"exportLayer:0"+e:"exportLayer:null"}function Kt(e){var t,r=e.autoAddResult,n=e.inviteResult,o=e.primaryEmailResult,e=e.secondaryEmailResult;return(o||e)&&(t={success:(e=[o,e].filter(function(e){return e})).every(function(e){return e.success})},(e=e.reduce(function(e,t){return e.concat(b(t,"errors",[]))},[])).length&&(t.errors=e)),{success:[r,n,t].filter(function(e){return e}).every(function(e){return e.success}),autoAdd:r,invite:n,email:t}}function $t(t,e){var r;return t&&(r=!f(t,"notAdded.length")&&!t.errors,e.autoAddResult={success:r},r||(r=t.errors||[],f(t,"notAdded.length")&&r.push(new V("Users not auto-added: "+t.notAdded.join(", "))),e.autoAddResult.errors=r,r=e.usersToAutoAdd.filter(function(e){return A(t.notAdded,e.username)}),e.usersToInvite=e.usersToInvite.concat(r))),e}function Qt(e,t){return e.orgId===t.orgId}function Xt(e){return"org_admin"===e.role&&!e.roleId}function Zt(e,t,r,n){var o=Promise.resolve(null);return e.length&&(e={authentication:r,message:t.body,subject:t.subject,notificationChannelType:"email",users:e.map(function(e){return e.username})},n||(e.batchSize=1),o=Te(e)),o}function er(t){var r,e=Promise.resolve(t);return t.email&&t.secondaryRO&&f(t,"inviteResult.success")&&(r=b(t,"secondaryRO.portalSelf.user",{}),e=Zt(t.usersToInvite.filter(function(e){return Qt(e,r)}),t.email,t.secondaryRO.authentication,Xt(r)).then(function(e){return t.secondaryEmailResult=e,t})),e}function tr(e,t,r){var n=Promise.resolve(null);return n=t.length?ge({id:e,users:t.map(function(e){return e.username}),authentication:r}):n}function rr(t){return tr(f(t,"groupId"),f(t,"usersToAutoAdd"),f(t,"primaryRO.authentication")).then(function(e){return $t(e,t)})}function nr(e,t,r,n,o){void 0===n&&(n=20160),void 0===o&&(o="group_member");var i=Promise.resolve(null);return i=t.length?we({id:e,users:t.map(function(e){return e.username}),authentication:r,role:o,expiration:n}):i}function or(t){return nr(f(t,"groupId"),f(t,"usersToInvite"),f(t,"primaryRO.authentication")).then(function(e){return t.inviteResult=e,t})}function ir(t){var e=Promise.resolve(t);return e=t.email&&f(t,"inviteResult.success")?Zt(t.usersToEmail,t.email,t.primaryRO.authentication,Xt(t.requestingUser)).then(function(e){return t.primaryEmailResult=e,t}):e}function ar(e,t){var r,n=[];return-1!==t.privileges.indexOf("portal:admin:assignToGroups")&&(r=[t.orgId,t.cOrgId].filter(function(e){return e}),n=e.filter(function(e){return-1!==r.indexOf(e.orgId)})),n}function sr(e,t){var r=ar(e,t);return e.filter(function(t){return!r.some(function(e){return e.username===t.username})})}function ur(e,t,r){void 0===r&&(r=!1);e=sr(e,t).filter(function(e){return Qt(e,t)});return r&&e.push(t),e}function cr(e,t){if("object"==typeof e&&null!==e&&"string"==typeof t){for(var r=t.split("."),n=0;n<r.length-1;n++){if(!e.hasOwnProperty(r[n]))return;e=e[r[n]]}delete e[r[r.length-1]]}}function pr(e){var t=l(e.item);return t.text=JSON.stringify(e.data),t}function lr(e,t){return Promise.all([ie(e,t),(r=e,r=ae(e,t=t)+"/data",(t=I({httpMethod:"GET",params:{}},t)).file&&(t.params.f=null),Z(r,t).catch(function(e){var t=RegExp(/The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i);if(!t.test(e.message))throw e}))]).then(function(e){return{item:e[0],data:e[1]}});var r}var fr=function(e,t,r){return void 0===r&&(r=void 0),t.split(".").reduce(function(e,t){return e?e[t]:r},e)};function dr(r,n){return Object.keys(r).reduce(function(e,t){return e[t]=n(r[t],t,r),e},{})}var mr=function(e){return e instanceof Date},hr=function(e){return"function"==typeof e},gr=function(e){return"object"==typeof e},yr=function(e){return e instanceof RegExp};var vr=function(e){return"object"==typeof e};function br(e){return Array.isArray(e)?function(e){var t=e,e=e.reduce(function(e,t){return kr(t)&&Cr(t)&&(e<(t=wr(t))&&(e=t)),e},-1);-1<e&&(t=0===e?[]:"{{delete:"+(e-1)+"}}");return t}(e.map(t).filter(function(e){return null!=e})):e&&vr(e)?function(o){var e=Object.keys(o).reduce(function(e,t){var r,n=o[t];return kr(n)&&Cr(n)?(r=wr(n))>e.maxLevel&&(e.maxLevel=r):e.obj[t]=n,e},{obj:{},maxLevel:-1});e=0<e.maxLevel?1===e.maxLevel?void 0:"{{delete:"+(e.maxLevel-1)+"}}":e.obj;return e}(dr(e,t)):function(e){var t=e;"string"==typeof e&&Cr(e)&&(t=function(e){var t=e,e=wr(e);t=0===e?void 0:"{{delete:"+e+"}}";return t}(e));return t}(e);function t(e,t){return br(e)}}var wr=function(e){return parseInt(e.replace(/{|}/g,"").split(":")[1])};function Cr(e){return e&&"string"==typeof e&&-1<e.indexOf("{{delete")}var kr=function(e){return"string"==typeof e};function Sr(e,t,r,n){return void 0===n&&(n=0),t?t:"{{delete:"+n+"}}"}var Ar=function(e){var t={};if(Array.isArray(e))t=e.map(Ar);else if("object"==typeof e)for(var r in e)null!=e[r]&&"object"==typeof e[r]?t[r]=Ar(e[r]):t[r]=e[r];else t=e;return t},Tr=/{{\s*?[\w].*?}}/g,Ir=function(e){return"string"==typeof e};function Er(e){return e||""===e||0===e}function xr(e,a,s){if((s=Ar(s=void 0===s?null:s)||{}).optional)throw new Error("Please do not pass in an `optional` transform; adlib provides that internally.");return s.optional=Sr,br(function r(e,n,o){return o=o||"",Array.isArray(e)?e.map(t):!e||!gr(e)||mr(e)||yr(e)||hr(e)?n(e,o):Object.assign({},e,dr(e,t));function t(e,t){return r(e,n,o?o+"."+t:t)}}(e,function(t,e){if(!Ir(t))return t;var r,n=t.match(Tr);return n&&n.length?(n.map(function(e){var o,i=!1,t=e.replace(/{|}/g,"").trim();-1<t.indexOf("||")&&(r=t.split("||").map(function(e){return e.trim()}),o=r.length,t=r.find(function(e,t){var r,n;return(n=a,r=(r=e).split(":")[0],null!=(r=fr(n,r,null)))?e:t+1===o&&(i=!0,isNaN(e)?e:parseInt(e))}));var r={key:e,value:t};return i||(t=function(e,t,r){var n,o=e.split(":");if(1<o.length){var i,a=o[0],s=o[1];if(o[2]&&(i=o[2]),!r||!r[s]||"function"!=typeof r[s])throw new Error("Attempted to apply non-existant transform "+s+" on "+a+" with params "+e);n=fr(t,a),n=r[s](a,n,t,i)}else n=fr(t,e);return n}(t,a,s),r.value=Er(t)?t:e),r}).forEach(function(e){t===e.key?("string"==typeof e.value&&(isNaN(e.value)||""===e.value||(-1<e.value.indexOf(".")?e.value=parseFloat(e.value):e.value=parseInt(e.value))),r=e.value):t=t.replace(e.key,e.value)}),Er(r)?r:t):t}))}function Dr(e,t,r){return xr(e,t,r)}var Pr=["id","isOrgItem","proxyFilter","ownerFolder","protected","owner","created","modified","guid","name","access","size","listed","numComments","numRatings","avgRating","numViews","scoreCompleteness","groupDesignations","listed","screenshots","banner","appCategories","industries","languages","largeThumbnail"];function Or(e,t,r){return me({q:'title:"'+e+'" AND '+Object.keys(t).map(function(e){return e+':"'+t[e]+'"'}).join(" AND "),authentication:r}).then(function(e){return 0<e.results.length}).catch(function(e){throw Error("Error in doesItemExistWithTitle "+e)})}function Rr(e,t){var r=e;return r=-1===e.indexOf("token")&&-1<e.indexOf(t.authentication.portal)?e+"?token="+t.authentication.token:r}function Nr(e,t){return(t=void 0===t?{}:t).credentials||(t.credentials="same-origin"),fetch(e,t).then(function(e){return e.blob()})}function _r(r){return Nr(r.url).then(function(e){return ne(t={id:r.id,owner:r.owner,name:r.fileName,resource:e,authentication:r.authentication}).then(function(e){e=re(t)+"/content/users/"+e+"/items/"+t.id+"/addResources";return t.params=I({file:t.resource,fileName:t.name,resourcesPrefix:t.prefix,text:t.content,access:t.private?"private":"inherit"},t.params),Z(e,t)});var t})}function Ur(t){return Nr(t.url).then(function(e){return oe({item:{id:t.id,owner:t.owner},params:{fileName:t.fileName,thumbnail:e},authentication:t.authentication}).catch(function(e){return Promise.resolve()})}).catch(function(e){return Promise.resolve()})}function jr(e,t,r){if(!e||!e.thumbnail)return null;var n=r||{},o=n.token,n=n.width,r=Ge(e,t,o=!o&&"string"==typeof r?r:o).split("?"),o=r[0],r=r[1],r=new URLSearchParams(r);r.delete("f"),n&&r.append("w",n+"");r=r.toString(),e=o+"/info/"+e.thumbnail;return r?e+"?"+r:e}var Mr={arcgis:{label:"ArcGIS Online",url:"https://www.arcgis.com",type:"arcgis"},arcgisQA:{label:"ArcGIS Online QAEXT",url:"https://qaext.arcgis.com",type:"arcgis"},arcgisDEV:{label:"ArcGIS Online DEVEXT",url:"https://devext.arcgis.com",type:"arcgis"},hub:{label:"ArcGIS Hub",url:"https://hub.arcgis.com/api",type:"arcgis-hub"},hubDEV:{label:"ArcGIS Hub DEV",url:"https://hubdev.arcgis.com/api",type:"arcgis-hub"},hubQA:{label:"ArcGIS Hub QA",url:"https://hubqa.arcgis.com/api",type:"arcgis-hub"}};function Lr(e){return e.map(function(e){return"string"==typeof e&&e in Mr?Mr[e]:e})}function Fr(e){return{content:e.reduce(function(e,t){return e=t.content?e.concat(t.content):e},[]),facets:e.reduce(function(e,t){return e=t.facets?e.concat(t.facets):e},[])}}function Gr(e,t){var r=l(e);return t.from<e.from&&(r.from=t.from),t.to>e.to&&(r.to=t.to),r}function qr(r,n){var o={};return["any","all","not","exact"].forEach(function(e){var t=e,e=D(Br(r,t),Br(n,t));e.length&&(o[t]=e.filter(h))}),o}function Br(e,t){var r=[];return e[t]&&(t=e[t],r=Array.isArray(t)?t:[t]),r}function Yr(e){var t={};return Array.isArray(e)?t={any:e}:("string"==typeof e&&(t={any:[e]}),"object"==typeof e&&(t=e)),t}function Wr(e){var t=new Date,r={type:"date-range",from:t.getTime(),to:t.getTime()};switch(e.unit){case"hours":case"days":case"weeks":r.from=r.to-{min:6e4,hours:36e5,days:864e5,weeks:6048e5}[e.unit]*e.num;break;case"months":t.setMonth(t.getMonth()-e.num),r.from=t.getTime();break;case"years":t.setFullYear(t.getFullYear()-e.num),r.from=t.getTime()}return r}function Hr(e,t,r){var n=l(e),e=t.q,t=t.filter;return e&&(n.q=(n.q?" ("+n.q+" "+r+" "+e+")":e).trim()),t&&(n.filter=(n.filter?"("+n.filter+" "+r+" "+t+")":t).trim()),n}function Vr(e,t){var r={q:"",filter:""};return t.exact&&(D(["username","firstname","lastname","fullname","email"],["title","tags","typekeywords","type","name","owner"],["title","typekeywords","owner"]).includes(e)?r.filter=Jr("AND",e,t.exact):("string"==typeof t.exact&&(t.all||(t.all=[]),"string"==typeof t.all&&(t.all=[t.all]),t.all.push(t.exact)),Array.isArray(t.exact)&&(t.all||(t.all=[]),"string"==typeof t.all&&(t.all=[t.all]),t.all=t.all.concat(t.exact)))),t.any&&(r.q=Jr("OR",e,t.any)),t.all&&(r.q=(r.q?r.q+" AND ":"")+Jr("AND",e,t.all)),t.not&&(r.q=(r.q?r.q+" AND ":"")+Jr("OR","-"+e,t.not)),r}function zr(e,t){return{q:e+":["+t.from+" TO "+t.to+"]",filter:""}}function Jr(e,t,r){return Array.isArray(r)?"("+t+':"'+r.join('" '+e+" "+t+':"')+'")':t+':"'+r+'"'}var Kr={$apps:[{type:{any:["Code Sample","Web Mapping Application","Mobile Application","Application","Desktop Application Template","Desktop Application","Operation View","Dashboard","Operations Dashboard Extension","Workforce Project","Insights Workbook","Insights Page","Insights Model","Hub Page","Hub Initiative","Hub Site Application","StoryMap","Web Experience","Web Experience Template","Form"],not:["Code Attachment","Featured Items","Symbol Set","Color Set","Windows Viewer Add In","Windows Viewer Configuration","Map Area","Indoors Map Configuration"]},typekeywords:{not:["MapAreaPackage","SMX"]}}],$storymap:[{type:"StoryMap"},{type:"Web Mapping Application",typekeywords:["Story Map"]}],$dashboard:[{type:"Dashboard",typekeywords:{any:["Dashboard"],not:["ArcGIS Operation View","Add In","Extension"]}}],$dataset:[],$experience:[{type:{any:["Web Experience"],not:["Web Experience Template"]}}],$site:[{type:["Hub Site Application","Site Application"]},{type:["Web Mapping Application"],typekeywords:["hubSite"]}],$initiative:[{type:{any:"Hub Initiative",not:"Hub Initiative Template"}}],$document:[{typekeywords:{any:"Document",not:["MapAreaPackage","SMX"]},type:{any:["Image","Layout","Desktop Style","Project Template","Report Template","Pro Report","Statistical Data Collection","360 VR Experience","netCDF","PDF","CSV","Administrative Report","Raster function template"],not:["Image Service","Explorer Document","Explorer Map","Globe Document","Scene Document","Code Attachment","Featured Items","Symbol Set","ColorSet","Windows Viewer Add In","Windows Viewer Configuration","Map Area","Indoors Map Configuration"]}}]};function $r(e){var t,o=[];return null!==(t=e.aggregations)&&void 0!==t&&t.counts&&e.aggregations.counts.forEach(function(r){var e={label:r.fieldName,attribute:r.fieldName,type:"multi-select"},n=[];r.fieldValues.forEach(function(e){var t={filterType:"content"};t[r.fieldName]=e.value;t={label:e.value,value:e.value,count:e.count,selected:!1,filter:t};n.push(t)}),e.options=n,o.push(e)}),o}function Qr(e){var t=Xr(e);return Array.isArray(e.subFilters)&&(t.subFilters=t.subFilters.reduce(function(e,t){return"string"==typeof t?Kr[t]&&(e=e.concat(Kr[t])):e.push(t),e},[])),tn(t)}function Xr(e){var r=l(e);return r.subFilters=r.subFilters||[],r.type&&(Array.isArray(r.type)?r.type=r.type.reduce(function(e,t){return Zr(t)?r.subFilters=r.subFilters.concat(en(t)):e.push(t),e},[]):Zr(r.type)&&(e=r.type,r.subFilters=r.subFilters.concat(en(e)),delete r.type)),r}function Zr(e){var t=!1;return t="string"==typeof e?e in Kr:t}function en(e){return Kr[e]}function tn(t){var r={};t.term&&(r.term=t.term);var e,n=["created","modified"],o=D(["filterType","subFilters","term"],n);return Object.entries(t).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r[t]=Yr(e))}),t.subFilters&&Array.isArray(t.subFilters)&&(e=t.subFilters,r.subFilters=e.map(tn)),n.forEach(function(e){t[e]&&("relative-date"===t[e].type?r[e]=Wr(t[e]):r[e]=l(t[e]))}),r}function rn(e){var t,r=nn(e);return e.subFilters&&(t=e.subFilters.reduce(function(e,t){return e="object"==typeof t?Hr(e,nn(t),"OR"):e},{q:"",filter:""}),r=Hr(r,t,"AND")),e.term&&(r.q=(e.term+" "+r.q).trim()),r}function nn(e){var r={q:"",filter:""},n=["created","modified"],o=D(["filterType","subFilters","term"],n);return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r=Hr(r,Vr(t,e),"AND")),n.includes(t)&&(r=Hr(r,zr(t,e),"AND"))}),r}function on(t){return E(this,void 0,void 0,function(){return x(this,function(e){return 200<=t.status&&t.status<300?[2,t.json()]:[2,t.json().then(function(e){if(e.error)throw new Error(e.error.title+" :: "+e.error.detail+" :: "+t.status);throw new Error("Got "+t.status+" "+t.statusText)})]})})}function an(e){var t={},e=f(e,"authentication.token");return e&&(t.Authorization=e),t}function sn(e){return(e||"https://hub.arcgis.com")+"/api/v3/domains"}function un(e,t){var r=e,n="hubsubdomain|"+(r=-1<e.indexOf("#/")?e.split("#/")[1]:r);return me(Object.assign({q:"typekeywords: "+n},t)).then(function(e){return e.results.filter(function(e){return A(e.typeKeywords,n)})[0]}).then(function(e){if(!e)throw new Error("site not found");return{hostname:e.url,siteId:e.id}})}function cn(e,t){if(t.isPortal)throw new Error("domainExists is not available in ArcGIS Enterprise.");e=Me(e);e=sn(t.hubApiUrl)+"/"+e,t=an(t);return fetch(e,{method:"GET",headers:t,mode:"cors"}).then(function(e){return 404!==e.status})}function pn(e,t){return un(e,t).then(function(e){return!0}).catch(function(e){return!1})}function ln(t,r,n,o){var i=t;return cn((i=(o=void 0===o?0:o)?t+"-"+o:t)+"-"+r,n).then(function(e){return e?ln(t,r,n,o+1):i})}function fn(t,r,n){var o=(n=void 0===n?0:n)?t+"-"+n:t;return pn(o,r).then(function(e){return e?fn(t,r,n+1):o})}function dn(e,t){if(t.isPortal)return un(e,t);e=sn(t.hubApiUrl)+"/"+e,t=an(t);return fetch(e,{method:"GET",headers:t,mode:"cors"}).then(on)}function mn(e,t){var r=l(e),e=63;return t&&(e-=t.length+1),r=r.length>e?r.slice(0,e-6)+"-"+_(5):r}function hn(e,t){return lr(e,t).then(wn)}function gn(e){if(1.4<=f(e,"item.properties.schemaVersion"))return e;var t=l(e),e=f(t,"data.values.gacode");return t.data.values.telemetry={consentNotice:{isTheme:!0,consentText:"",policyURL:""},customAnalytics:{ga:{customerTracker:{enabled:Boolean(e),id:e}}}},cr(t,"data.values.gacode"),k("item.properties.schemaVersion",1.4,t),t}var yn=1.5;function vn(e){if(1.5<=f(e,"item.properties.schemaVersion"))return e;var r,t=l(e),e=t.data.values.dcatConfig;return t.data.feeds={},e&&(t.data.feeds.dcatUS11=(r=JSON.stringify(e),Object.keys(bn).forEach(function(e){var t=bn[e];r=r.split(e).join(t)}),JSON.parse(r))),t.item.properties.schemaVersion=1.5,t}var bn={"{{default.name}}":"{{name}}","{{default.description}}":"{{description}}","{{item.tags}}":"{{tags}}","{{item.created:toISO}}":"{{created:toISO}}","{{item.modified:toISO}}":"{{modified:toISO}}","{{default.source.source}}":"{{source}}","{{item.owner}}":"{{owner}}","{{org.portalProperties.links.contactUs.url}}":"{{orgContactEmail}}","{{org.name}}":"{{orgName}}","{{item.categories}}":"{{categories}}","{{item.licenseInfo}}":"{{licenseInfo}}","{{item.modified}}":"{{modified}}","{{enrichments.categories}}":"{{categories}}","{{default.id}}":"{{id}}","{{item.licenseInfo || No License}}":"{{licenseInfo || No License}}","{{org.portalProperties.links.contactUs.url || mailto:data@tempe.gov}}":"{{orgContactEmail || mailto:data@tempe.gov}}","{{default.description || No Description}}":"{{description || No Description}}","{{item.id}}":"{{id}}"};function wn(e){return f(e,"item.properties.schemaVersion")===yn?e:e=vn(e=gn(e=function(e){if(1.3<=f(e,"item.properties.schemaVersion"))return e;var t=l(e),e=f(t,"data.catalog.groups")||[];return t.data.catalog.groups=e.filter(U),t.item.properties.schemaVersion=1.3,t}(e=function(e){if(1.2<=f(e,"item.properties.schemaVersion"))return e;var t=l(e),e=f(t,"data.catalog")||{};return f(t,"data.values.groups")&&(e.groups=l(t.data.values.groups),delete t.data.values.groups),t.data.catalog=e,t.item.properties.schemaVersion=1.2,t}(e=function(e){if(1.1<=f(e,"item.properties.schemaVersion"))return e;var t=l(e);return["subdomain","defaultHostname","internalUrl","customHostname","externalUrl"].forEach(function(e){t.data.values[e]&&"string"==typeof t.data.values[e]&&(t.data.values[e]=t.data.values[e].toLowerCase())}),t.item.properties.schemaVersion=1.1,t}(e=function(e){if(1<=f(e,"item.properties.schemaVersion"))return e;var t=l(e);return["groupId","title"].forEach(function(e){delete t.data.values[e]}),t.item.properties||(t.item.properties={}),t.item.properties.schemaVersion=1,t.data.values.groups&&Array.isArray(t.data.values.groups)&&(e=t.data.values.groups.map(function(e){return"object"==typeof e?e.id:e}).filter(function(e){return!!e}),t.data.values.groups=e),t}(e))))))}var Cn=["ar","bs","ca","cs","da","de","en","es","et","el","fi","fr","hr","he","hu","it","id","ja","ko","lt","lv","nb","nl","pl","pt","pt-br","pt-pt","ro","ru","sl","sr","sv","th","tr","uk","vi","zh","zh-cn","zh-tw","zh-hk"];var kn,Sn=(e(An,kn=Error),An);function An(e,t,r){e=kn.call(this,e)||this;return e.status=r,e.url=t,e}function Tn(e,t){var r,n,o=I({httpMethod:"GET"},t),i=o.fetch||fetch,t=I({"Content-Type":"application/json"},o.headers);"GET"===o.httpMethod?r=o.params:n=JSON.stringify(o.params);var a=B({host:Ye(o),path:("/api/v3/"+e).replace(/\/\//g,"/"),query:r});return i(a,{method:o.httpMethod,headers:t,body:n}).then(function(e){if(e.ok)return e.json();throw new Sn(e.statusText,a,e.status)})}function In(e,t){return se(I({id:e,relationshipType:"Survey2Service",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function En(e,t){return se(I({id:e,relationshipType:"Service2Data",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function xn(e,t){return se(I({id:e,relationshipType:"Survey2Data",direction:"forward"},t)).then(function(e){var t,e=e.relatedItems[0];return t=e?{item:e}:t})}function Dn(t){function e(e){return-1<t.typeKeywords.indexOf(e)}var r=e("FieldworkerView");return r=r||["Survey123","Feature Service","View Service"].every(e)&&!e("StakeholderView")}Pn.prototype.startOperation=function(e){e=l(e);e.startedAt=(new Date).getTime(),e.state="working",this.operations.push(e)},Pn.prototype.start=function(e,t){t={type:e,id:b(t,"id",r(e+"_")),inputs:b(t,"inputs",{}),cleanup:b(t,"cleanup","n/a"),startedAt:(new Date).getTime(),state:"working"};return this.operations.push(t),t.id},Pn.prototype.getOperation=function(t){return this.operations.find(function(e){return e.id===t})},Pn.prototype.getOperations=function(){return this.operations},Pn.prototype.finish=function(e,t){var r=this.getOperation(e);if(!r)throw new Error("No operation with id "+e+" present in stack");r.duration=(new Date).getTime()-r.startedAt,r.state="completed",t&&(r.output=l(t))},Pn.prototype.merge=function(e){this.operations=D(this.operations,e.operations)},Pn.prototype.getCompleted=function(){return l(this.operations.filter(function(e){return"completed"===e.state}))},Pn.prototype.getWorking=function(){return l(this.operations.filter(function(e){return"working"===e.state}))},Pn.prototype.toString=function(){return this.operations.sort(function(e,t){return e.startedAt<t.startedAt?-1:t.startedAt<e.startedAt?1:0}).map(On).join("\n")},Pn.prototype.serialize=function(){return{operations:l(this.getOperations())}},st=Pn;function Pn(){this.operations=[]}function On(e){var t=e.startedAt+" : Operation "+e.id+" started with inputs "+JSON.stringify(e.inputs)+" but was not completed";return t="completed"===e.state?e.startedAt+" : Operation "+e.id+" took "+e.duration+" ms with inputs "+JSON.stringify(e.inputs)+" and output "+(e.output?JSON.stringify(e.output):"n/a"):t}n.GLOBAL_EXTENT=mt,n.HUB_CDN_URLMAP=_e,n.HUB_LOCALES=Cn,n.Logger=j,n.OperationError=O,n.OperationStack=st,n.PORTAL_EXPORT_TYPES=Wt,n.REQUIRED_PRIVS=q,n.RemoteServerError=Sn,n.SEARCH_APIS=Mr,n.SITE_SCHEMA_VERSION=yn,n.STANDARD_LICENSES=yt,n.WGS84_WKID=Yt,n._addTokenToResourceUrl=Rr,n._canEmailUser=Qt,n._checkStatusAndParseJson=on,n._consolidateResults=Kt,n._deepMapValues=i,n._ensureSafeDomainLength=mn,n._ensureTelemetry=gn,n._formatAutoAddResponse=$t,n._getAuthHeader=an,n._getAutoAddUsers=ar,n._getDomainServiceUrl=sn,n._getEmailUsers=ur,n._getHttpAndHttpsUris=function(e){return e?["http://"+(e=e.replace(/^http(s?):\/\//,"")),"https://"+e]:[]},n._getInviteUsers=sr,n._getLocation=function(){if(window)return window.location},n._isDate=s,n._isFunction=u,n._isObject=c,n._isOrgAdmin=Xt,n._isRegExp=p,n._isString=a,n._lookupPortal=un,n._mapValues=o,n._processAutoAdd=rr,n._processInvite=or,n._processPrimaryEmail=ir,n._processSecondaryEmail=er,n._searchContent=function(n,o){return E(this,void 0,void 0,function(){var r,t;return x(this,function(e){switch(e.label){case 0:return r=Qr(n),o.apis||(o.apis=["arcgis"]),t=Lr(o.apis),t=t.map(function(e){if("arcgis"!==e.type)return Promise.resolve({content:[],facets:[]});var t=rn(r);return o.authentication&&(t.authentication=o.authentication),null!==(e=o.aggregations)&&void 0!==e&&e.length&&(t.countFields=o.aggregations.join(","),t.countSize=200),o.num&&(t.num=o.num),me(t).then(function(e){return{content:e.results.map(Rt),facets:$r(e)}})}),[4,Promise.all(t)];case 1:return[2,Fr(e.sent())]}})})},n._unprotectAndRemoveGroup=function(e){var t=N(ke,{success:!0}),r=N(Se,{success:!0});return t(e).then(function(){return r(e)})},n._unprotectAndRemoveItem=function(e){var t=N(ue,{success:!0}),r=N(pe,{success:!0});return t(e).then(function(){return r(e)})},n.addContextToSlug=function(e,t){return/.+::.+/.test(e)?e:t+"::"+e},n.addDays=function(e,t){try{var r=new Date(e);return new Date(r.setDate(r.getDate()+t)).toISOString().split("T")[0]}catch(e){throw new Error("Invalid Date")}},n.addDomain=function(e,t){if(t.isPortal)throw new Error("addDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=an(t);r["Content-Type"]="application/json";var n=""+sn(t.hubApiUrl);return"number"==typeof(t=e.siteTitle)&&(e.siteTitle=t.toString()),fetch(n,{method:"POST",headers:r,mode:"cors",body:JSON.stringify(e)}).then(on)},n.addSolutionResourceUrlToAssets=function(e,t){var r,n,o=e.assets||e.resources||[];return e.bundleItemId&&(r=je(t.portalSelf)+"/content/items/"+e.bundleItemId,n=e.itemId,o=o.map(function(e){return{name:e.name,type:e.type||"resource",url:r+"/resources/"+n+"-"+e.name}})),o},n.addUsersToGroup=function(e,t,r,n,o){var i=l(b(r,"portalSelf.user",{}));return i.cOrgId=f(r,"portalSelf.portalProperties.hub.settings.communityOrg.orgId"),rr({groupId:e,allUsers:t,primaryRO:r,email:n,secondaryRO:o,requestingUser:i,usersToAutoAdd:ar(t,i),usersToInvite:sr(t,i),usersToEmail:ur(t,i,f(n,"copyMe"))}).then(or).then(ir).then(er).then(Kt)},n.applyPropertiesToItems=function(e,t){return e.map(function(e){return e.properties||(e.properties={}),Object.assign(e.properties,t),e})},n.arrayToObject=function(e,r){return e.reduce(function(e,t){return e[f(t,r)]=t,e},{})},n.atob=Bt.atob,n.autoAddUsers=tr,n.batch=S,n.btoa=Bt.btoa,n.buildDraft=function(e,t){return C(e,{},t)},n.buildExistingExportsPortalQuery=function(e,t){var r,n,o,i,a=(c=function(e){if(e)return{onlyTypes:e.onlyTypes,layerId:e.layerId,spatialRefId:e.spatialRefId};return{}}(t)).onlyTypes,s=c.layerId,u=c.spatialRefId,t=Object.keys(Wt).map(function(e){return Wt[e]}),c=new Set(y(t.filter(function(e){return!e.supportsProjection}).map(function(e){return e.itemTypes}))),t=a||y(t.map(function(e){return e.itemTypes})),s=(new le).startGroup().match(zt(e)).in("typekeywords").and().match(Jt(s)).in("typekeywords").endGroup().and().startGroup();function p(e,t){var r;t.startGroup().match(/\s/g.test(e)?e:'"'+e+'"').in("type").and().match(Vt((r=e,t=Yt,t=(e=i)&&!o.has(r)?e:t))).in("typekeywords").endGroup()}return r=s,n=(c={types:t,spatialRefId:u,noProjectionItemTypes:c}).types,o=c.noProjectionItemTypes,i=c.spatialRefId,n.forEach(function(e,t){p(e,r),t<n.length-1&&r.or()}),s.endGroup(),s.toParam()},n.buildUrl=B,n.camelize=t,n.canEditEvent=function(e,t){var r=!1;return F(t)&&(e=f(e,"initiative.item.properties.collaborationGroupId"),t=t.groups,r=!!e&&!!d(void 0===t?[]:t,"id",e)),r},n.canEditItem=G,n.canEditSite=function(e,t){var r=!1;return r=!f(e,"properties.isDefaultHubHome")&&F(t)?G(e,t):r},n.canEditSiteContent=function(e,t){var r,n=!1,o=f(e,"properties.isDefaultHubHome"),i=F(t);return!o&&i?n=G(e,t):i&&(i=t.orgId,e=e.orgId,i&&i===e&&(r=t.privileges||[],n=q.every(function(e){return A(r,e)}))),n},n.capitalize=g,n.categories=pt,n.chunkArray=function(e,t){for(var r=[],n=0;n<e.length;)r.push(e.slice(n,n+t)),n+=t;return r},n.cloneObject=l,n.completeOAuth2=function(t,e){var r=(e=(e=void 0===e?window:e).location.href.match(/access_token=(.+)&expires_in=.+&username=([^&]+)/))[1],n="https://www.arcgis.com/sharing/rest/community/users/"+decodeURIComponent(e[2]);return Z(n,{params:{token:r},httpMethod:"GET"}).then(function(e){return Date.now()-e.created<5e3?Z(n+"/update",{params:{token:r,tags:["hubRole:participant","org:"+e.orgId],access:"public"}}).then(function(){return $e.completeOAuth2(t)}):$e.completeOAuth2(t)})},n.compose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce(function(r,n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(n.apply(void 0,e))}})},n.convertContentDefinitionToFilter=tn,n.convertContentFilterToSearchOptions=nn,n.convertPortalResponseToFacets=$r,n.convertSolutionTemplateResourcesToAssets=function(e,t){var r,n,o=[];return e.resources&&e.bundleItemId&&(r=je(t.portalSelf)+"/content/items/"+e.bundleItemId,n=e.itemId,o=e.resources.map(function(e){return{name:e,type:"resource",url:r+"/resources/"+n+"-"+e}})),o},n.convertToWellKnownLocale=function(e){var t="en";return e=(e=void 0===e?"en":e).toLowerCase(),-1<Cn.indexOf(e)?t=e:1<(e=e.split("-")).length&&-1<Cn.indexOf(e[0])&&(t=e[0]),t},n.createExtent=ft,n.createId=r,n.createOperationPipeline=function(e){return function(r){return e.reduce(function(e,t){return e.then(t).catch(function(e){if("OperationError"===e.name)return Promise.reject(e);e="IPipeableFn did not reject with an OperationError \n Operation Stack: \n "+r.stack.toString(),e=new O("pipeline execution error",e);return e.operationStack=r.stack.serialize(),Promise.reject(e)})},Promise.resolve(r))}},n.datasetToContent=function(e){var t=Nt(e),r=Rt(t);delete r.itemCategories;var n=e.id,o=(C=e.attributes).errors,i=C.boundary,a=C.extent,s=C.metadata,u=C.modified,c=C.modifiedProvenance,p=C.slug,l=C.searchDescription,f=C.groupIds,d=C.server,m=C.layers,h=C.layer,g=C.recordCount,y=C.statistics,v=C.orgId,b=C.orgName,w=C.organization,e=C.orgExtent,C=C.type;return r.errors=o,r.boundary=i,!gt(t.extent)&&a&>(a.coordinates)&&(r.extent=a.coordinates),r.metadata=s||null,r.modified!==u&&(r.modified=u,r.updatedDate=new Date(u),r.updatedDateSource=c),r.slug=p,l&&(r.summary=l),r.groupIds=f,r.server=d,r.layers=m,r.layer=h,r.recordCount=g,r.statistics=y,v&&(r.org={id:v,name:b||w,extent:e}),Ut(_t(r,n),C)},n.datasetToItem=Nt,n.deepSet=v,n.deepStringReplace=w,n.deleteProp=cr,n.doesItemExistWithTitle=Or,n.domainExists=cn,n.domainExistsPortal=pn,n.emailOrgUsers=Zt,n.ensureProp=function(e,t){return v(e,t)},n.ensureUniqueDomainName=function(e,t){return(t.isPortal?fn(e,t):ln(e,t.portalSelf.urlKey+"."+Me(Ye(t)),t)).then(function(e){return mn(e,t.portalSelf.urlKey)})},n.ensureUniqueString=function(e,t){for(var r=!1,n=0,o=t;!r;)A(e,o)?o=t+"-"+ ++n:r=!0;return o},n.expandApis=Lr,n.expandContentFilter=Qr,n.expandTypeField=Xr,n.extend=function n(e,o,i){void 0===i&&(i=!0);e=l(e);return Object.keys(o).reduce(function(e,t){var r;return null!==o[t]&&void 0!==o[t]&&(r=l(o[t]),Array.isArray(r)?e[t]=r:e[t]=i&&"object"==typeof r?n(e[t]||{},r,i):r),e},e)},n.extentToBBox=dt,n.failSafe=N,n.failSafeUpdate=function(e,t){return N(oe,{id:e.item.id,success:!0})(Object.assign({item:pr(e)},t))},n.fetchAllPages=function(n,o,r,i){var a=o.num||100,e=o.start||1;return(-1===(r=void 0===r?-1:r)?n(I(I({},o),{num:a,start:e})):Promise.resolve({nextStart:e,total:r,results:[],num:a})).then(function(t){if(-1===t.nextStart)return[t];for(var e=[],r=t.nextStart;r<=t.total;r+=a)e.push(r);return S(e,function(e){return n(I(I({},o),{start:e,num:a}))},i).then(function(e){return D([t],e)})}).then(function(e){var t=e.reduce(function(e,t){return D(e,t.results)},[]),e=-1===r?t.length:r;return t.slice(0,e)})},n.fetchAndUploadResource=_r,n.fetchAndUploadThumbnail=Ur,n.fetchHubTranslation=function(t,e,r){void 0===r&&(r="cors");var n=(Ue(e)+"/locales/"+t+".json").toLocaleLowerCase();return fetch(n,{method:"GET",credentials:"same-origin",mode:r}).then(function(e){return e.json()}).catch(function(e){throw Error("Attempt to fetch locale "+t+" from "+n+" failed: "+JSON.stringify(e))})},n.fetchImageAsBlob=Nr,n.fetchSite=function(e,t){return U(e)?hn(e,t):dn(Me(e).split("/")[0],t).then(function(e){return hn(e.siteId,t)})},n.filterBy=function(e,t,r){return e.filter(function(e){return f(e,t)===r})},n.findBy=d,n.flattenArray=y,n.generateRandomString=_,n.getCategory=wt,n.getCollection=kt,n.getContentIdentifier=It,n.getCulture=function(e){return f(e,"portalSelf.user.culture")||f(e,"portalSelf.culture")||"en-us"},n.getDomainsForSite=function(e,t){return t.isPortal?Promise.resolve([]):(e=sn(t.hubApiUrl)+"?siteId="+e,t=an(t),fetch(e,{method:"GET",headers:t,mode:"cors"}).then(on).catch(function(e){throw Error("Error in getDomainsForSite "+e)}))},n.getExportItemTypeKeyword=zt,n.getExportLayerTypeKeyword=Jt,n.getFamily=Pt,n.getGeographicOrgExtent=ht,n.getHubApiUrl=Ye,n.getHubApiUrlFromPortal=function(e){return Fe(e)+"/api/v3"},n.getHubLocaleAssetUrl=Ue,n.getHubProduct=function(e){var t=f(e,"portalProperties.hub.enabled")||!1?"premium":"basic";return t=e.isPortal&&"singletenant"===e.portalMode?"portal":t},n.getHubUrlFromPortal=Fe,n.getInputFeatureServiceModel=In,n.getItemApiUrl=Ge,n.getItemAssets=function(e,t){var r=je(t.portalSelf)+"/content/items/"+e.id,n=jr(e,t),o=[];return n&&o.push({name:e.thumbnail,url:n,type:"thumbnail"}),e=e.id,e=ae(e,t=t)+"/resources",(t=I({},t)).params=I({num:1e3},t.params),Z(e,t).then(function(e){e=e.resources.map(function(e){return{name:e.resource,type:"resource",url:r+"/resources/"+e.resource}});return o.concat(e)})},n.getItemDataUrl=function(e,t,r){t=Ge(e,t,r),r="\\/"+e.id+"\\?f=json",r=new RegExp(r);return t&&t.replace(r,"/"+e.id+"/data").replace(/\&token/,"?token")},n.getItemHomeUrl=function(e,t){return Ne(t)+"/home/item.html?id="+e},n.getItemHubId=function(e){if("public"===e.access){var t=e.id,e=Tt(e);return e?t+"_"+e:t}},n.getItemHubType=Ot,n.getItemLayerId=Tt,n.getItemThumbnailUrl=jr,n.getLayerIdFromUrl=At,n.getModel=lr,n.getModelFromOptions=function(e,t){var r=e+"Model",e=e+"Id";if(t[r])return Promise.resolve(t[r]);if(t[e])return N(lr,{item:{id:t[e]},isMissing:!0})(t[e],t);throw new Error("getModelFromOptions requires either a ."+r+" or ."+e+" property.")},n.getOrgExtentAsBBox=function(e){return ht(e).then(dt)},n.getPortalApiUrl=je,n.getPortalUrl=Ne,n.getProp=f,n.getProps=function(r,e){return e.reduce(function(e,t){t=f(r,t);return t&&e.push(t),e},[])},n.getServiceTypeFromUrl=Be,n.getSiteById=hn,n.getSourceFeatureServiceModelFromFieldworker=En,n.getSpatialRefTypeKeyword=Vt,n.getStakeholderModel=xn,n.getStructuredLicense=vt,n.getSubscriptionType=function(e){return b(e,"subscriptionInfo.type","Enterprise")},n.getSurveyModels=function(e,r){var n,o;return("string"==typeof e?ie(e,r):Promise.resolve(e)).then(function(t){var e=[In(t.id,r),xn(t.id,r)];return Promise.all(e).then(function(e){var t=e[0],e=e[1];return o=e,t&&Dn(t.item)?En((n=t).item.id,r):t}).then(function(e){return{form:{item:t},featureService:e,fieldworker:n,stakeholder:o}})})},n.getTypeCategories=function(e){if(e=wt(Ct(e=void 0===e?{}:e))){e=Array.from(e);return e[0]=e[0].toUpperCase(),[e.join("")]}return["Other"]},n.getTypes=function(e){return pt[(e=void 0===e?"":e).toLowerCase()]},n.getUniqueDomainName=ln,n.getUniqueDomainNamePortal=fn,n.getUniqueItemTitle=function t(r,n,o,i){var a=(i=void 0===i?0:i)?r+" "+i:r;return Or(a,n,o).then(function(e){return e?t(r,n,o,++i):a}).catch(function(e){throw Error("Error in getUniqueItemTitle "+e)})},n.getWithDefault=b,n.hasBasePriv=F,n.hubApiRequest=Tn,n.hubApiSearch=function(e){var t=(t=e.authentication)&&t.serialize&&{authentication:t.serialize()};return Tn("/search",I(I({},{headers:t,httpMethod:"POST"}),e))},n.includes=A,n.incrementString=function(e){var t=e.match(/-\s(\d+$)/);return t?(t=parseInt(t[1],10),e=e.replace("- "+t,"- "+(t+1))):e+=" - 1",e},n.interpolate=Dr,n.interpolateItemId=function(e){return Dr(e,{item:{id:e.item.id},appid:e.item.id},{toISO:function(e,t){return t}})},n.inviteUsers=nr,n.isDomainForLegacySite=function(e){return!U(e.siteId)},n.isDomainUsedElsewhere=function(e,t,r){return dn(e,r).then(function(e){return e.siteId!==t}).catch(function(){return!1})},n.isDownloadable=lt,n.isExtentCoordinateArray=gt,n.isFeatureService=St,n.isFieldworkerView=Dn,n.isGuid=U,n.isMapOrFeatureServerUrl=function(e){return qe.test(e)},n.isNil=function(e){return null==e},n.isSlug=function(e){return!(!(e=Et(e).itemId)||U(e))},n.isUpdateGroup=L,n.isValidDomain=function(t,e){if(e.isPortal)throw new Error("isValidDomain is not available in ArcGIS Enterprise.");var r=sn(e.hubApiUrl)+"/validate?hostname="+t,e=an(e);return fetch(r,{method:"GET",headers:e,mode:"cors"}).then(function(e){return e.json()}).catch(function(e){return{success:!1,input:t,error:{code:400,detail:e,message:"lookupFailed"}}})},n.isValidExtent=function(t){return!!t&&[gt,function(t){return["xmin","ymin","xmax","ymax"].every(function(e){return"number"==typeof t[e]})}].some(function(e){return e(t)})},n.itemPropsNotInTemplates=Pr,n.itemToContent=Rt,n.last=function(e){return e[e.length-1]},n.lookupDomain=dn,n.mapBy=function(t,e){return(e=void 0===e?[]:e).map(function(e){return e[t]})},n.maybeAdd=function(e,t,r){return null!=t&&((r=l(r))[e]=t),r},n.maybePush=m,n.mergeContentFilter=function(e){var e=e.map(Qr),n=["created","modified"],o=D(["filterType","subFilters"],n);return(e=e.reduce(function(r,e){return Object.entries(e).forEach(function(e){var t=e[0],e=e[1];o.includes(t)||(r[t]?r[t]=qr(r[t],e):r[t]=l(e)),n.includes(t)&&(r[t]?r[t]=Gr(r[t],e):r[t]=l(e)),"subFilters"===t&&Array.isArray(e)&&(r.subFilters?r.subFilters=D(r.subFilters,e):r.subFilters=l(e))}),r},{})).filterType="content",e},n.mergeDateRange=Gr,n.mergeMatchOptions=qr,n.mergeObjects=C,n.mergeSearchOptions=Hr,n.mergeSearchResults=Fr,n.normalizeItemType=Ct,n.normalizeSolutionTemplateItem=function(e){var t=l(e);return Pr.forEach(function(e){delete t[e]}),t.extent="{{organization.defaultExtentBBox}}",t},n.objectToArray=function(r,n){return void 0===n&&(n="id"),Object.keys(r).reduce(function(e,t){return r[t][n]=t,e.push(l(r[t])),e},[])},n.objectToJsonBlob=function(e){if("undefined"!=typeof Blob)return new Blob([JSON.stringify(e)],{type:"application/json"});throw new Error("objectToJsonBlob is not currently supported on Node")},n.parseDatasetId=Et,n.parseItemCategories=Dt,n.processRevertableTasks=function(e){return Promise.all(e).then(function(e){function t(e){return"fullfilled"===e.status}var r=e.filter(t),n=e.filter(function(e){return!t(e)});if(n.length){e=r.map(function(e){return e.revert()});throw Promise.all(e).catch(function(){}),n[0].error}return r.map(function(e){return e.results})})},n.propifyString=function(e){return t(e.replace(/^[0-9]*/g,"").replace(/[^\w\s]/g,""))},n.relativeDateToDateRange=Wr,n.removeContextFromSlug=xt,n.removeDomain=function(e,t){if(t.isPortal)throw new Error("removeDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=an(t);return r["Content-Type"]="application/json",e=sn(t.hubApiUrl)+"/"+e,fetch(e,{method:"DELETE",headers:r,mode:"cors"}).then(on)},n.removeEmptyProps=function t(r){return Object.keys(r).forEach(function(e){r[e]&&"object"==typeof r[e]?t(r[e]):null==r[e]&&delete r[e]}),r},n.replaceItemId=function(e,t,r){return void 0===r&&(r="{{appid}}"),w(l(e),new RegExp(t,"g"),r)},n.runRevertableTask=function(e,t){return e().then(function(e){return{status:"fullfilled",results:e,revert:t}}).catch(function(e){return{status:"rejected",error:e}})},n.serializeContentFilterForPortal=rn,n.serializeDateRange=zr,n.serializeMatchOptions=Vr,n.serializeModel=pr,n.serializeSpatialReference=Ht,n.serializeStringOrArray=Jr,n.setContentHubId=_t,n.setContentSiteUrls=function(e,t){var r=It(e,t),r=Mt(e,r),t=f(t,"item.url").replace(/\/$/,"");return jt(e,{relative:r,site:""+t+r})},n.setContentType=Ut,n.setProp=k,n.shareItemToGroups=function(t,e,r){return Promise.all(e.map(function(e){return De(Object.assign({},{id:t,groupId:e},r))}))},n.slugify=function(e){return"string"==typeof e?e.trim().toLowerCase().replace(/ +/g,"-").replace(/[^\w-]/g,"").replace(/-+/g,"-"):e},n.stringToBlob=function(e,t){if(void 0===t&&(t="application/octet-stream"),"undefined"==typeof Blob)throw new Error("stringToBlob is not currently supported on Node");for(var r=[],n=0;n<e.length;n++)r[n]=e.charCodeAt(n);var o=new Uint8Array(r);return new Blob([o],{type:t})},n.stripProtocol=Me,n.unique=h,n.uniqueBy=function(e,r){return e.reduce(function(e,t){return m(e.find(function(e){return f(e,r)===f(t,r)})?null:t,e)},[])},n.unprotectModel=function(e,t){return e.item.protected?ue(Object.assign({id:e.item.id},t)):Promise.resolve({success:!0})},n.unshareItemFromGroups=function(t,e,r){return Promise.all(e.map(function(e){return Re(Object.assign({},{id:t,groupId:e},r))}))},n.updateDomain=function(e,t){if(t.isPortal)throw new Error("updateDomain is not available in ArcGIS Enterprise. Instead, edit the hubdomain typekeyword on the item");var r=an(t);r["Content-Type"]="application/json";var n=sn(t.hubApiUrl)+"/"+e.id;return"number"==typeof(t=e.siteTitle)&&(e.siteTitle=t.toString()),fetch(n,{method:"PUT",headers:r,mode:"cors",body:JSON.stringify(e)}).then(on)},n.upgradeSiteSchema=wn,n.uploadResourcesFromUrl=function(n,e,o){if(Array.isArray(e)){e=e.reduce(function(e,t){var r;return t.url&&(r={id:n.item.id,owner:n.item.owner,fileName:t.name,url:Rr(t.url,o),authentication:o.authentication},"thumbnail"===t.type?e.push(Ur(r)):e.push(_r(r))),e},[]);return Promise.all(e)}return Promise.resolve([])},n.valueToMatchOptions=Yr,n.without=function(e,t){return e.filter(function(e){return e!==t})},n.withoutByProp=function(t,r,e){return e.filter(function(e){return e[t]!==r})},Object.defineProperty(n,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=common.umd.min.js.map
|