/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","exports","../../chunks/_rollupPluginBabelHelpers","../../request","../../core/Error","../../core/ItemCache","../../core/maybe","../../geometry/support/aaBoundingBox","./symbolLayerUtils3D"],(function(e,r,t,o,n,i,u,s,c){"use strict";let l=a();function a(){return new i(50)}function y(){l=a()}function p(e,r){if("icon"===e.type)return h(e,r);if("object"===e.type)return w(e,r);throw new n("symbol3d:unsupported-symbol-layer","computeLayerSize only works with symbol layers of type Icon and Object")}function f(e,r){return m.apply(this,arguments)}function m(){return(m=t._asyncToGenerator((function*(e,r){if("icon"===e.type)return b(e,r);if("object"===e.type)return g(e,r);throw new n("symbol3d:unsupported-symbol-layer","computeLayerSize only works with symbol layers of type Icon and Object")}))).apply(this,arguments)}function h(e,r){return d.apply(this,arguments)}function d(){return(d=t._asyncToGenerator((function*(e,r){if(e.resource.href)return v(e.resource.href).then((e=>[e.width,e.height]));if(e.resource.primitive)return u.isSome(r)?[r,r]:[256,256];throw new n("symbol3d:invalid-symbol-layer","symbol layers of type Icon must have either an href or a primitive resource")}))).apply(this,arguments)}function b(e,r){return h(e,r).then((r=>{if(null==e.size)return r;const t=r[0]/r[1];return t>1?[e.size,e.size/t]:[e.size*t,e.size]}))}function v(e){return o(e,{responseType:"image"}).then((e=>e.data))}function w(e,r){return S(e,r).then((e=>s.size(e)))}function g(e,r){return z.apply(this,arguments)}function z(){return(z=t._asyncToGenerator((function*(e,r){const t=yield w(e,r);return c.objectSymbolLayerSizeWithResourceSize(t,e)}))).apply(this,arguments)}function S(e,r){return B.apply(this,arguments)}function B(){return(B=t._asyncToGenerator((function*(r,t){if(!r.isPrimitive){const t=r.resource.href,o=l.get(t);if(void 0!==o)return o;const n=yield new Promise(((r,t)=>e(["../../views/3d/layers/graphics/objectResourceUtils"],r,t))),i=yield n.fetch(t,{disableTextures:!0});return l.put(t,i.referenceBoundingBox),i.referenceBoundingBox}let o=null;if(r.resource&&r.resource.primitive&&(o=s.create(c.objectSymbolLayerPrimitiveBoundingBox(r.resource.primitive)),u.isSome(t)))for(let e=0;e<o.length;e++)o[e]*=t;return o?Promise.resolve(o):Promise.reject(new n("symbol:invalid-resource","The symbol does not have a valid resource"))}))).apply(this,arguments)}r.clearBoundingBoxCache=y,r.computeIconLayerResourceSize=h,r.computeLayerResourceSize=p,r.computeLayerSize=f,r.computeObjectLayerResourceSize=w,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
