/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../chunks/_rollupPluginBabelHelpers","../core/Error","../core/promiseUtils","./locale"],(function(e,t,n,r,s){"use strict";const o=/^([a-z]{2})(?:[-_]([A-Za-z]{2}))?$/,i={ar:!0,bg:!0,bs:!0,ca:!0,cs:!0,da:!0,de:!0,el:!0,en:!0,es:!0,et:!0,fi:!0,fr:!0,he:!0,hr:!0,hu:!0,id:!0,it:!0,ja:!0,ko:!0,lt:!0,lv:!0,nb:!0,nl:!0,pl:!0,"pt-BR":!0,"pt-PT":!0,ro:!0,ru:!0,sk:!0,sl:!0,sr:!0,sv:!0,th:!0,tr:!0,uk:!0,vi:!0,"zh-CN":!0,"zh-HK":!0,"zh-TW":!0};function a(e){var t;return null!=(t=i[e])&&t}const u=[],l=new Map;function c(e){for(const t of l.keys())y(e.pattern,t)&&l.delete(t)}function d(e){return u.includes(e)||(c(e),u.unshift(e)),{remove(){const t=u.indexOf(e);t>-1&&(u.splice(t,1),c(e))}}}function f(e){return h.apply(this,arguments)}function h(){return(h=t._asyncToGenerator((function*(e){const t=s.getLocale();l.has(e)||l.set(e,_(e,t));const n=l.get(e);return yield m.add(n),n}))).apply(this,arguments)}function p(e){if(!o.test(e))return null;const[,t,n]=o.exec(e),r=t+(n?"-"+n.toUpperCase():"");return a(r)?r:a(t)?t:null}function _(e,t){return g.apply(this,arguments)}function g(){return(g=t._asyncToGenerator((function*(e,t){const r=[];for(const n of u)if(y(n.pattern,e))try{return yield n.fetchMessageBundle(e,t)}catch(s){r.push(s)}if(r.length)throw new n("intl:message-bundle-error",`Errors occurred while loading "${e}"`,{errors:r});throw new n("intl:no-message-bundle-loader",`No loader found for message bundle "${e}"`)}))).apply(this,arguments)}function y(e,t){return"string"==typeof e?t.startsWith(e):e.test(t)}s.beforeLocaleChange((()=>{l.clear()}));const m=new(function(){function e(){this._numLoading=0}var n=e.prototype;return n.waitForAll=function(){var e=t._asyncToGenerator((function*(){this._dfd&&(yield this._dfd.promise)}));function n(){return e.apply(this,arguments)}return n}(),n.add=function(e){return this._increase(),e.then((()=>this._decrease()),(()=>this._decrease())),this.waitForAll()},n._increase=function(){this._numLoading++,this._dfd||(this._dfd=r.createDeferred())},n._decrease=function(){this._numLoading=Math.max(this._numLoading-1,0),this._dfd&&0===this._numLoading&&(this._dfd.resolve(),this._dfd=null)},e}()),b={cache:l,loaders:u};e.fetchMessageBundle=f,e.normalizeMessageBundleLocale=p,e.registerMessageBundleLoader=d,e.test=b,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
