/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../../chunks/_rollupPluginBabelHelpers","../../../../core/maybe","../../../../core/promiseUtils","./Placement","./TileParser","../../tiling/enums"],(function(t,e,s,r,n,i){"use strict";let a=function(){function a(t,e,s,n){this.status=i.TileStatus.INITIALIZED,this.placementEngine=new r.PlacementEngine,this.tileKey=t,this.refKeys=e,this._workerTileHandler=s,this._styleRepository=n}var u=a.prototype;return u.release=function(){this.tileKey="",this.refKeys=null,this.status=i.TileStatus.INITIALIZED,this._workerTileHandler=null},u.parse=function(){var r=t._asyncToGenerator((function*(t,r){const n=r&&r.signal;if(e.isSome(n)){const t=()=>{n.removeEventListener("abort",t),this.status=i.TileStatus.INVALID};n.addEventListener("abort",t)}let a;const u={bucketsWithData:[],emptyBuckets:null};try{a=yield this._parse(t,r)}catch(f){if(s.isAbortError(f))throw f;return{result:u,transferList:[]}}this.status=i.TileStatus.READY;const l=u.bucketsWithData,o=[];for(const e of a)if(e.hasFeatures()){const t=e.serialize();l.push(t)}else o.push(e.layer.uid);const c=[...l];let h=null;return o.length>0&&(h=Uint32Array.from(o),c.push(h.buffer)),u.emptyBuckets=h,{result:u,transferList:c}}));function n(t,e){return r.apply(this,arguments)}return n}(),u.setObsolete=function(){this.status=i.TileStatus.INVALID},u.getLayers=function(){return this._workerTileHandler.getLayers()},u.getWorkerTileHandler=function(){return this._workerTileHandler},u._parse=function(){var e=t._asyncToGenerator((function*(t,e){const s=t.sourceName2DataAndRefKey;if(0===Object.keys(s).length)return[];this.status=i.TileStatus.MODIFIED;return new n(s,this,e.client,this._styleRepository,t.styleLayerUIDs).parse(e)}));function s(t,s){return e.apply(this,arguments)}return s}(),a}();return a}));
