/*
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/devEnvironmentUtils","../../../../core/Error","../../../../core/maybe","../../../../core/promiseUtils","../../../../core/urlUtils","../../../../portal/Portal","../../../../chunks/persistableUrlUtils","../../../../symbols/support/styleUtils"],(function(e,t,r,n,o,l,s,i,a,u){"use strict";function c(e,t,r){return m.apply(this,arguments)}function m(){return(m=t._asyncToGenerator((function*(e,t,r){if(!e.name)throw new n("style-symbol-reference-name-missing","Missing name in style symbol reference");if(e.styleName&&"Esri2DPointSymbolsStyle"===e.styleName)return y(e,r);try{return p(yield u.fetchStyle(e,t,r),e.name,t,r)}catch(o){return l.throwIfAborted(o),null}}))).apply(this,arguments)}function y(e,t){return f.apply(this,arguments)}function f(){return(f=t._asyncToGenerator((function*(e,t){const r=u.Style2DUrlTemplate.replace(/\{SymbolName\}/gi,e.name);try{const e=yield u.requestJSON(r,t);return u.makeCIMSymbolRef(e.data)}catch(n){return l.throwIfAborted(n),null}}))).apply(this,arguments)}function p(e,t,r,n){return b.apply(this,arguments)}function b(){return(b=t._asyncToGenerator((function*(e,t,c,m){const y=e.data,f={portal:c&&o.isSome(c.portal)?c.portal:i.getDefault(),url:s.urlToObject(e.baseUrl),origin:"portal-item"},p=y.items.find((e=>e.name===t));if(!p){throw new n("symbolstyleutils:symbol-name-not-found",`The symbol name '${t}' could not be found`,{symbolName:t})}let b=a.fromJSON(u.symbolUrlFromStyleItem(p,"cimRef"),f);r.isDevEnvironment()&&(b=r.adjustStaticAGOUrl(b));try{const e=yield u.requestJSON(b,m);return u.makeCIMSymbolRef(e.data)}catch(d){return l.throwIfAborted(d),null}}))).apply(this,arguments)}e.fetchCIMSymbolReference=c,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
