/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{Point as e}from"../../../../geometry/support/TileClipper.js";class t{constructor(e,t,s=0){this.values={},this._geometry=void 0,this._pbfGeometry=null,this.featureIndex=s;const r=t.keys,a=t.values,o=e.asUnsafe();for(;o.next();)switch(o.tag()){case 1:this.id=o.getUInt64();break;case 2:{const e=o.getMessage().asUnsafe(),t=this.values;for(;!e.empty();){const s=e.getUInt32(),o=e.getUInt32();t[r[s]]=a[o]}e.release();break}case 3:this.type=o.getUInt32();break;case 4:this._pbfGeometry=o.getMessage();break;default:o.skip()}}getGeometry(t){if(void 0!==this._geometry)return this._geometry;if(!this._pbfGeometry)return null;const s=this._pbfGeometry.asUnsafe();let r,a;this._pbfGeometry=null,t?t.reset(this.type):r=[];let o,n=1,i=0,l=0,h=0;for(;!s.empty();){if(0===i){const e=s.getUInt32();n=7&e,i=e>>3}switch(i--,n){case 1:l+=s.getSInt32(),h+=s.getSInt32(),t?t.moveTo(l,h):r&&(a&&r.push(a),a=[],a.push(new e(l,h)));break;case 2:l+=s.getSInt32(),h+=s.getSInt32(),t?t.lineTo(l,h):a&&a.push(new e(l,h));break;case 7:t?t.close():a&&!a[0].equals(l,h)&&a.push(a[0].clone());break;default:throw s.release(),new Error("Invalid path operation")}}return t?o=t.result():r&&(a&&r.push(a),o=r),s.release(),this._geometry=o,o}}export{t as default};
