/*
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/maybe","../../../core/promiseUtils","../../../core/urlUtils","./TextureCollection","../webgl-engine/lib/basicInterfaces","../webgl-engine/lib/Texture"],(function(e,t,r,n,i,o,s,l){"use strict";let u=function(e){function o(t,r,n,i){var o;return(o=e.call(this,r,i)||this)._streamDataRequester=t,o._parameters=n,o}t._inheritsLoose(o,e);var u=o.prototype;return u.fromUrl=function(){var e=t._asyncToGenerator((function*(e,i,o){var s=this;n.throwIfAborted(o);const l=r.isSome(o)&&o.signal,u=this.makeUid(e,i);let a=this._textureRequests.get(u);if(!a){const r=new AbortController,n=this._streamDataRequester.request(e,"image",{uid:u,signal:r.signal});a={referenceCount:0,texture:null,textureAsync:null,abortController:r},this._textureRequests.set(u,a),a.textureAsync=n.then(function(){var r=t._asyncToGenerator((function*(t){const r=s._createTexture(e,t,i);return a.texture=r,a.abortController=null,s._stage.add(r),yield s._stage.load(r),{uid:u,texture:r,release:()=>s._release(u)}}));return function(e){return r.apply(this,arguments)}}(),(e=>{throw a.abortController=null,e}))}return a.referenceCount++,new Promise(((e,t)=>{n.onAbort(l,(()=>{t(n.createAbortError())})),a.textureAsync.then(e,t)})).catch((e=>{throw this._release(u),e}))}));function i(t,r,n){return e.apply(this,arguments)}return i}(),u._createTexture=function(e,t,r){const n={...this._parameters,powerOfTwoResizeMode:s.PowerOfTwoResizeMode.PAD};if(i.isSVG(e)){if(r||0===t.width&&0===t.height){const e=t.width?t.height/t.width:1;r=r||64,e>1?(t.width=Math.round(r/e),t.height=r):(t.width=r,t.height=Math.round(r*e))}this._stage.renderView&&this._stage.renderView.renderingContext.driverTest.svgAlwaysPremultipliesAlpha&&(n.preMultiplyAlpha=!1)}return n.width=t.width,n.height=t.height,new l.Texture(t,n)},o}(o.TextureCollection);e.StreamTextureCollection=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
