/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import e from"../../../core/Error.js";import{wasmFailedToInit as r}from"../../../layers/ILyr3DWasmPerSceneView.js";let i,t=null;const a=new Map;async function n(n){null==t&&(null==i&&(i=import("../../../layers/Lyr3DWasmPerSceneView.js")),t=await i);const l=n.view;let s=a.get(l);s||(s=new t.default({view:l}),a.set(l,s));const o=!!l.stage.renderView.renderingContext.capabilities.compressedTextureS3TC,d=!!l.stage.renderView.renderingContext.capabilities.compressedTextureETC;await s.initializeWasm(o,d);const w=s.addLayerView(n);if(w.wasmLayerId<0)throw s.getValidLayerViewCount()<1&&(a.delete(l),0===a.size&&(i=null,t=null)),w.wasmLayerId===r?new e("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{}):new e("tiles3d:addLayer-failure",w.check?.errorDescription??"The 3d tiles layer description was invalid.",{});return w.wasmLayerId}function l(e){return a.get(e)}function s(e){const r=e.view,n=a.get(r);if(n){n.removeLayerView(e)<1&&(a.delete(r),0===a.size&&(i=null,t=null))}}export{n as addLayerViewToWasm,l as getLyr3DWasm,s as removeLayerViewFromWasm};
