/*
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","./byteStreamUtils"],(function(e,t){"use strict";function n(e){const t=e.fields,n=e.records,r=t.some((e=>"oid"===e.name.toLowerCase()))?"OBJECTID":"OID",i=[{name:r,type:"esriFieldTypeOID",alias:"OID"}].concat(t.map((e=>({name:e.name,type:"esriFieldType"+e.typeName,alias:e.name})))),s=i.map((e=>e.name)),a=[];let o=0,l=0;return n.forEach((e=>{const t={};for(t[r]=o++,l=1;l<s.length;l++)t[s[l]]=e[l-1];a.push({attributes:t})})),{displayFieldName:"",fields:i,features:a}}return function(){function r(){}return r.parse=function(e){const r=new DataView(e),i=3&r.getUint8(0);if(3!==i)return{header:{version:i},recordSet:null};const s=r.getUint32(4,!0),a=r.getUint16(8,!0),o=r.getUint16(10,!0),l={version:i,recordCount:s,headerByteCount:a,recordByteCount:o};let u=32;const p=[],g=[];let f;if(3===i){for(;13!==r.getUint8(u);)f=String.fromCharCode(r.getUint8(u+11)).trim(),p.push({name:t.bytesToUTF8(new Uint8Array(e,u,11)),type:f,typeName:["String","Date","Double","Boolean","String","Integer"][["C","D","F","L","M","N"].indexOf(f)],length:r.getUint8(u+16)}),u+=32;if(u+=1,p.length>0)for(;g.length<s&&e.byteLength-u>o;){const n=[];32===r.getUint8(u)?(u+=1,p.forEach((r=>{if("C"===r.type)n.push(t.bytesToUTF8(new Uint8Array(e,u,r.length)).trim());else if("N"===r.type)n.push(parseInt(String.fromCharCode.apply(null,new Uint8Array(e,u,r.length)).trim(),10));else if("F"===r.type)n.push(parseFloat(String.fromCharCode.apply(null,new Uint8Array(e,u,r.length)).trim()));else if("D"===r.type){const t=String.fromCharCode.apply(null,new Uint8Array(e,u,r.length)).trim();n.push(new Date(parseInt(t.substring(0,4),10),parseInt(t.substring(4,6),10)-1,parseInt(t.substring(6,8),10)))}u+=r.length})),g.push(n)):u+=o}}return{header:l,fields:p,records:g,recordSet:n({fields:p,records:g})}},e._createClass(r,null,[{key:"supportedVersions",get:function(){return[5]}}]),r}()}));
