@datosgeo-atdt/geo-ui 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -819,5 +819,5 @@ License: MIT
819
819
  `&&(ze=`
820
820
  `);var Fe=0,Lt=!1;this.parse=function(et,ot,Je){if(typeof et!="string")throw new Error("Input must be a string");var zt=et.length,xt=he.length,$t=ze.length,gi=qe.length,ut=st(Ue),Et=[],Vt=[],dt=[],Bt=Fe=0;if(!et)return Di();if(Ut||Ut!==!1&&et.indexOf(nt)===-1){for(var ni=et.split(ze),vt=0;vt<ni.length;vt++){if(dt=ni[vt],Fe+=dt.length,vt!==ni.length-1)Fe+=ze.length;else if(Je)return Di();if(!qe||dt.substring(0,gi)!==qe){if(ut){if(Et=[],mr(dt.split(he)),vi(),Lt)return Di()}else mr(dt.split(he));if(ct&&ct<=vt)return Et=Et.slice(0,ct),Di(!0)}}return Di()}for(var Ft=et.indexOf(he,Fe),bt=et.indexOf(ze,Fe),Gt=new RegExp(ge(ft)+ge(nt),"g"),mt=et.indexOf(nt,Fe);;)if(et[Fe]===nt)for(mt=Fe,Fe++;;){if((mt=et.indexOf(nt,mt+1))===-1)return Je||Vt.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:Et.length,index:Fe}),Oi();if(mt===zt-1)return Oi(et.substring(Fe,mt).replace(Gt,nt));if(nt===ft&&et[mt+1]===ft)mt++;else if(nt===ft||mt===0||et[mt-1]!==ft){Ft!==-1&&Ft<mt+1&&(Ft=et.indexOf(he,mt+1));var Yt=gr((bt=bt!==-1&&bt<mt+1?et.indexOf(ze,mt+1):bt)===-1?Ft:Math.min(Ft,bt));if(et.substr(mt+1+Yt,xt)===he){dt.push(et.substring(Fe,mt).replace(Gt,nt)),et[Fe=mt+1+Yt+xt]!==nt&&(mt=et.indexOf(nt,Fe)),Ft=et.indexOf(he,Fe),bt=et.indexOf(ze,Fe);break}if(Yt=gr(bt),et.substring(mt+1+Yt,mt+1+Yt+$t)===ze){if(dt.push(et.substring(Fe,mt).replace(Gt,nt)),Or(mt+1+Yt+$t),Ft=et.indexOf(he,Fe),mt=et.indexOf(nt,Fe),ut&&(vi(),Lt))return Di();if(ct&&Et.length>=ct)return Di(!0);break}Vt.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:Et.length,index:Fe}),mt++}}else if(qe&&dt.length===0&&et.substring(Fe,Fe+gi)===qe){if(bt===-1)return Di();Fe=bt+$t,bt=et.indexOf(ze,Fe),Ft=et.indexOf(he,Fe)}else if(Ft!==-1&&(Ft<bt||bt===-1))dt.push(et.substring(Fe,Ft)),Fe=Ft+xt,Ft=et.indexOf(he,Fe);else{if(bt===-1)break;if(dt.push(et.substring(Fe,bt)),Or(bt+$t),ut&&(vi(),Lt))return Di();if(ct&&Et.length>=ct)return Di(!0)}return Oi();function mr(ce){Et.push(ce),Bt=Fe}function gr(ce){var B=0;return B=ce!==-1&&(ce=et.substring(mt+1,ce))&&ce.trim()===""?ce.length:B}function Oi(ce){return Je||(ce===void 0&&(ce=et.substring(Fe)),dt.push(ce),Fe=zt,mr(dt),ut&&vi()),Di()}function Or(ce){Fe=ce,mr(dt),dt=[],bt=et.indexOf(ze,Fe)}function Di(ce){if(pe.header&&!ot&&Et.length&&!Zt){var B=Et[0],O=Object.create(null),U=new Set(B);let re=!1;for(let ne=0;ne<B.length;ne++){let fe=B[ne];if(O[fe=st(pe.transformHeader)?pe.transformHeader(fe,ne):fe]){let de,ae=O[fe];for(;de=fe+"_"+ae,ae++,U.has(de););U.add(de),B[ne]=de,O[fe]++,re=!0,(qt=qt===null?{}:qt)[de]=fe}else O[fe]=1,B[ne]=fe;U.add(fe)}re&&console.warn("Duplicate headers found and renamed."),Zt=!0}return{data:Et,errors:Vt,meta:{delimiter:he,linebreak:ze,aborted:Lt,truncated:!!ce,cursor:Bt+(ot||0),renamedHeaders:qt}}}function vi(){Ue(Di()),Et=[],Vt=[]}},this.abort=function(){Lt=!0},this.getCharIndex=function(){return Fe}}function Dt(pe){var he=pe.data,ze=c[he.workerId],qe=!1;if(he.error)ze.userError(he.error,he.file);else if(he.results&&he.results.data){var Ue={abort:function(){qe=!0,ht(he.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:ri,resume:ri};if(st(ze.userStep)){for(var ct=0;ct<he.results.data.length&&(ze.userStep({data:he.results.data[ct],errors:he.results.errors,meta:he.results.meta},Ue),!qe);ct++);delete he.results}else st(ze.userChunk)&&(ze.userChunk(he.results,Ue,he.file),delete he.results)}he.finished&&!qe&&ht(he.workerId,he.results)}function ht(pe,he){var ze=c[pe];st(ze.userComplete)&&ze.userComplete(he),ze.terminate(),delete c[pe]}function ri(){throw new Error("Not implemented.")}function di(pe){if(typeof pe!="object"||pe===null)return pe;var he,ze=Array.isArray(pe)?[]:{};for(he in pe)ze[he]=di(pe[he]);return ze}function Mi(pe,he){return function(){pe.apply(he,arguments)}}function st(pe){return typeof pe=="function"}return Pe.parse=function(pe,he){var ze=(he=he||{}).dynamicTyping||!1;if(st(ze)&&(he.dynamicTypingFunction=ze,ze={}),he.dynamicTyping=ze,he.transform=!!st(he.transform)&&he.transform,!he.worker||!Pe.WORKERS_SUPPORTED)return ze=null,Pe.NODE_STREAM_INPUT,typeof pe=="string"?(pe=(qe=>qe.charCodeAt(0)!==65279?qe:qe.slice(1))(pe),ze=new(he.download?je:at)(he)):pe.readable===!0&&st(pe.read)&&st(pe.on)?ze=new At(he):($.File&&pe instanceof File||pe instanceof Object)&&(ze=new Ye(he)),ze.stream(pe);(ze=(()=>{var qe;return!!Pe.WORKERS_SUPPORTED&&(qe=(()=>{var Ue=$.URL||$.webkitURL||null,ct=D.toString();return Pe.BLOB_URL||(Pe.BLOB_URL=Ue.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",ct,")();"],{type:"text/javascript"})))})(),(qe=new $.Worker(qe)).onmessage=Dt,qe.id=le++,c[qe.id]=qe)})()).userStep=he.step,ze.userChunk=he.chunk,ze.userComplete=he.complete,ze.userError=he.error,he.step=st(he.step),he.chunk=st(he.chunk),he.complete=st(he.complete),he.error=st(he.error),delete he.worker,ze.postMessage({input:pe,config:he,workerId:ze.id})},Pe.unparse=function(pe,he){var ze=!1,qe=!0,Ue=",",ct=`\r
821
821
  `,Ut='"',qt=Ut+Ut,Zt=!1,nt=null,ft=!1,Fe=((()=>{if(typeof he=="object"){if(typeof he.delimiter!="string"||Pe.BAD_DELIMITERS.filter(function(ot){return he.delimiter.indexOf(ot)!==-1}).length||(Ue=he.delimiter),typeof he.quotes!="boolean"&&typeof he.quotes!="function"&&!Array.isArray(he.quotes)||(ze=he.quotes),typeof he.skipEmptyLines!="boolean"&&typeof he.skipEmptyLines!="string"||(Zt=he.skipEmptyLines),typeof he.newline=="string"&&(ct=he.newline),typeof he.quoteChar=="string"&&(Ut=he.quoteChar),typeof he.header=="boolean"&&(qe=he.header),Array.isArray(he.columns)){if(he.columns.length===0)throw new Error("Option columns is empty");nt=he.columns}he.escapeChar!==void 0&&(qt=he.escapeChar+Ut),he.escapeFormulae instanceof RegExp?ft=he.escapeFormulae:typeof he.escapeFormulae=="boolean"&&he.escapeFormulae&&(ft=/^[=+\-@\t\r].*$/)}})(),new RegExp(ge(Ut),"g"));if(typeof pe=="string"&&(pe=JSON.parse(pe)),Array.isArray(pe)){if(!pe.length||Array.isArray(pe[0]))return Lt(null,pe,Zt);if(typeof pe[0]=="object")return Lt(nt||Object.keys(pe[0]),pe,Zt)}else if(typeof pe=="object")return typeof pe.data=="string"&&(pe.data=JSON.parse(pe.data)),Array.isArray(pe.data)&&(pe.fields||(pe.fields=pe.meta&&pe.meta.fields||nt),pe.fields||(pe.fields=Array.isArray(pe.data[0])?pe.fields:typeof pe.data[0]=="object"?Object.keys(pe.data[0]):[]),Array.isArray(pe.data[0])||typeof pe.data[0]=="object"||(pe.data=[pe.data])),Lt(pe.fields||[],pe.data||[],Zt);throw new Error("Unable to serialize unrecognized input");function Lt(ot,Je,zt){var xt="",$t=(typeof ot=="string"&&(ot=JSON.parse(ot)),typeof Je=="string"&&(Je=JSON.parse(Je)),Array.isArray(ot)&&0<ot.length),gi=!Array.isArray(Je[0]);if($t&&qe){for(var ut=0;ut<ot.length;ut++)0<ut&&(xt+=Ue),xt+=et(ot[ut],ut);0<Je.length&&(xt+=ct)}for(var Et=0;Et<Je.length;Et++){var Vt=($t?ot:Je[Et]).length,dt=!1,Bt=$t?Object.keys(Je[Et]).length===0:Je[Et].length===0;if(zt&&!$t&&(dt=zt==="greedy"?Je[Et].join("").trim()==="":Je[Et].length===1&&Je[Et][0].length===0),zt==="greedy"&&$t){for(var ni=[],vt=0;vt<Vt;vt++){var Ft=gi?ot[vt]:vt;ni.push(Je[Et][Ft])}dt=ni.join("").trim()===""}if(!dt){for(var bt=0;bt<Vt;bt++){0<bt&&!Bt&&(xt+=Ue);var Gt=$t&&gi?ot[bt]:bt;xt+=et(Je[Et][Gt],bt)}Et<Je.length-1&&(!zt||0<Vt&&!Bt)&&(xt+=ct)}}return xt}function et(ot,Je){var zt,xt;return ot==null?"":ot.constructor===Date?JSON.stringify(ot).slice(1,25):(xt=!1,ft&&typeof ot=="string"&&ft.test(ot)&&(ot="'"+ot,xt=!0),zt=ot.toString().replace(Fe,qt),(xt=xt||ze===!0||typeof ze=="function"&&ze(ot,Je)||Array.isArray(ze)&&ze[Je]||(($t,gi)=>{for(var ut=0;ut<gi.length;ut++)if(-1<$t.indexOf(gi[ut]))return!0;return!1})(zt,Pe.BAD_DELIMITERS)||-1<zt.indexOf(Ue)||zt.charAt(0)===" "||zt.charAt(zt.length-1)===" ")?Ut+zt+Ut:zt)}},Pe.RECORD_SEP="",Pe.UNIT_SEP="",Pe.BYTE_ORDER_MARK="\uFEFF",Pe.BAD_DELIMITERS=["\r",`
822
- `,'"',Pe.BYTE_ORDER_MARK],Pe.WORKERS_SUPPORTED=!ue&&!!$.Worker,Pe.NODE_STREAM_INPUT=1,Pe.LocalChunkSize=10485760,Pe.RemoteChunkSize=5242880,Pe.DefaultDelimiter=",",Pe.Parser=ei,Pe.ParserHandle=Qe,Pe.NetworkStreamer=je,Pe.FileStreamer=Ye,Pe.StringStreamer=at,Pe.ReadableStreamStreamer=At,$.jQuery&&((Q=$.jQuery).fn.parse=function(pe){var he=pe.config||{},ze=[];return this.each(function(ct){if(!(Q(this).prop("tagName").toUpperCase()==="INPUT"&&Q(this).attr("type").toLowerCase()==="file"&&$.FileReader)||!this.files||this.files.length===0)return!0;for(var Ut=0;Ut<this.files.length;Ut++)ze.push({file:this.files[Ut],inputElem:this,instanceConfig:Q.extend({},he)})}),qe(),this;function qe(){if(ze.length===0)st(pe.complete)&&pe.complete();else{var ct,Ut,qt,Zt,nt=ze[0];if(st(pe.before)){var ft=pe.before(nt.file,nt.inputElem);if(typeof ft=="object"){if(ft.action==="abort")return ct="AbortError",Ut=nt.file,qt=nt.inputElem,Zt=ft.reason,void(st(pe.error)&&pe.error({name:ct},Ut,qt,Zt));if(ft.action==="skip")return void Ue();typeof ft.config=="object"&&(nt.instanceConfig=Q.extend(nt.instanceConfig,ft.config))}else if(ft==="skip")return void Ue()}var Fe=nt.instanceConfig.complete;nt.instanceConfig.complete=function(Lt){st(Fe)&&Fe(Lt,nt.file,nt.inputElem),Ue()},Pe.parse(nt.file,nt.instanceConfig)}}function Ue(){ze.splice(0,1),qe()}}),P&&($.onmessage=function(pe){pe=pe.data,Pe.WORKER_ID===void 0&&pe&&(Pe.WORKER_ID=pe.workerId),typeof pe.input=="string"?$.postMessage({workerId:Pe.WORKER_ID,results:Pe.parse(pe.input,pe.config),finished:!0}):($.File&&pe.input instanceof File||pe.input instanceof Object)&&(pe=Pe.parse(pe.input,pe.config))&&$.postMessage({workerId:Pe.WORKER_ID,results:pe,finished:!0})}),(je.prototype=Object.create(Oe.prototype)).constructor=je,(Ye.prototype=Object.create(Oe.prototype)).constructor=Ye,(at.prototype=Object.create(at.prototype)).constructor=at,(At.prototype=Object.create(Oe.prototype)).constructor=At,Pe})})(gc)),gc.exports}var lg=og();const rp=Rd(lg);async function np(F,C,D){return new Promise(($,Q)=>{rp.parse(F,{download:!0,header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Oe=Pe[C],je=Pe[D];if(Oe!=null){const Ye=parseFloat(je),at=isNaN(Ye)?je:Ye;le.set(String(Oe),at)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}async function sp(F,C,D){return new Promise(($,Q)=>{rp.parse(F,{header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Oe=Pe[C],je=Pe[D];if(Oe!=null){const Ye=parseFloat(je),at=isNaN(Ye)?je:Ye;le.set(String(Oe),at)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}function ap(F,C){if(F.length===0)return[];if(C>=F.length)return[...new Set(F)].sort((le,Pe)=>le-Pe);const D=[...F].sort((le,Pe)=>le-Pe);let $=D.length;const Q=Array($+1).fill(0).map(()=>Array(C+1).fill(0)),ue=Array($+1).fill(0).map(()=>Array(C+1).fill(0));for(let le=1;le<=C;le++){Q[1][le]=1,ue[1][le]=0;for(let Pe=2;Pe<=$;Pe++)ue[Pe][le]=1/0}for(let le=2;le<=$;le++){let Pe=0,Oe=0,je=0;for(let Ye=1;Ye<=le;Ye++){const at=le-Ye+1,At=D[at-1];Oe+=At*At,Pe+=At,je++;const Qe=Oe-Pe*Pe/je,ge=at-1;if(ge!==0)for(let ei=2;ei<=C;ei++)ue[le][ei]>=Qe+ue[ge][ei-1]&&(Q[le][ei]=at,ue[le][ei]=Qe+ue[ge][ei-1])}Q[le][1]=1,ue[le][1]=ue[le-1][1]+(le-1)*(D[le-1]-D[le-2])**2}const P=[];let c=C;for(;c>=2;){const le=Q[$][c]-1;P.push(D[le]),$=Q[$][c]-1,c--}return P.push(D[0]),P.reverse(),P.push(D[D.length-1]),[...new Set(P)].sort((le,Pe)=>le-Pe)}function op(F,C,D){const $=[],Q=c=>{const le=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c);return le?{r:parseInt(le[1],16),g:parseInt(le[2],16),b:parseInt(le[3],16)}:{r:0,g:0,b:0}},ue=Q(F),P=Q(C);for(let c=0;c<D;c++){const le=c/(D-1),Pe=Math.round(ue.r+le*(P.r-ue.r)),Oe=Math.round(ue.g+le*(P.g-ue.g)),je=Math.round(ue.b+le*(P.b-ue.b));$.push(`rgb(${Pe}, ${Oe}, ${je})`)}return $}function ls(F,C){this.x=F,this.y=C}ls.prototype={clone(){return new ls(this.x,this.y)},add(F){return this.clone()._add(F)},sub(F){return this.clone()._sub(F)},multByPoint(F){return this.clone()._multByPoint(F)},divByPoint(F){return this.clone()._divByPoint(F)},mult(F){return this.clone()._mult(F)},div(F){return this.clone()._div(F)},rotate(F){return this.clone()._rotate(F)},rotateAround(F,C){return this.clone()._rotateAround(F,C)},matMult(F){return this.clone()._matMult(F)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(F){return this.x===F.x&&this.y===F.y},dist(F){return Math.sqrt(this.distSqr(F))},distSqr(F){const C=F.x-this.x,D=F.y-this.y;return C*C+D*D},angle(){return Math.atan2(this.y,this.x)},angleTo(F){return Math.atan2(this.y-F.y,this.x-F.x)},angleWith(F){return this.angleWithSep(F.x,F.y)},angleWithSep(F,C){return Math.atan2(this.x*C-this.y*F,this.x*F+this.y*C)},_matMult(F){const C=F[0]*this.x+F[1]*this.y,D=F[2]*this.x+F[3]*this.y;return this.x=C,this.y=D,this},_add(F){return this.x+=F.x,this.y+=F.y,this},_sub(F){return this.x-=F.x,this.y-=F.y,this},_mult(F){return this.x*=F,this.y*=F,this},_div(F){return this.x/=F,this.y/=F,this},_multByPoint(F){return this.x*=F.x,this.y*=F.y,this},_divByPoint(F){return this.x/=F.x,this.y/=F.y,this},_unit(){return this._div(this.mag()),this},_perp(){const F=this.y;return this.y=this.x,this.x=-F,this},_rotate(F){const C=Math.cos(F),D=Math.sin(F),$=C*this.x-D*this.y,Q=D*this.x+C*this.y;return this.x=$,this.y=Q,this},_rotateAround(F,C){const D=Math.cos(F),$=Math.sin(F),Q=C.x+D*(this.x-C.x)-$*(this.y-C.y),ue=C.y+$*(this.x-C.x)+D*(this.y-C.y);return this.x=Q,this.y=ue,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:ls},ls.convert=function(F){if(F instanceof ls)return F;if(Array.isArray(F))return new ls(+F[0],+F[1]);if(F.x!==void 0&&F.y!==void 0)return new ls(+F.x,+F.y);throw new Error("Expected [x, y] or {x, y} point format")};class lp{constructor(C,D,$,Q,ue){this.properties={},this.extent=$,this.type=0,this.id=void 0,this._pbf=C,this._geometry=-1,this._keys=Q,this._values=ue,C.readFields(cg,this,D)}loadGeometry(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos,$=[];let Q,ue=1,P=0,c=0,le=0;for(;C.pos<D;){if(P<=0){const Pe=C.readVarint();ue=Pe&7,P=Pe>>3}if(P--,ue===1||ue===2)c+=C.readSVarint(),le+=C.readSVarint(),ue===1&&(Q&&$.push(Q),Q=[]),Q&&Q.push(new ls(c,le));else if(ue===7)Q&&Q.push(Q[0].clone());else throw new Error(`unknown command ${ue}`)}return Q&&$.push(Q),$}bbox(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos;let $=1,Q=0,ue=0,P=0,c=1/0,le=-1/0,Pe=1/0,Oe=-1/0;for(;C.pos<D;){if(Q<=0){const je=C.readVarint();$=je&7,Q=je>>3}if(Q--,$===1||$===2)ue+=C.readSVarint(),P+=C.readSVarint(),ue<c&&(c=ue),ue>le&&(le=ue),P<Pe&&(Pe=P),P>Oe&&(Oe=P);else if($!==7)throw new Error(`unknown command ${$}`)}return[c,Pe,le,Oe]}toGeoJSON(C,D,$){const Q=this.extent*Math.pow(2,$),ue=this.extent*C,P=this.extent*D,c=this.loadGeometry();function le(Ye){return[(Ye.x+ue)*360/Q-180,360/Math.PI*Math.atan(Math.exp((1-(Ye.y+P)*2/Q)*Math.PI))-90]}function Pe(Ye){return Ye.map(le)}let Oe;if(this.type===1){const Ye=[];for(const At of c)Ye.push(At[0]);const at=Pe(Ye);Oe=Ye.length===1?{type:"Point",coordinates:at[0]}:{type:"MultiPoint",coordinates:at}}else if(this.type===2){const Ye=c.map(Pe);Oe=Ye.length===1?{type:"LineString",coordinates:Ye[0]}:{type:"MultiLineString",coordinates:Ye}}else if(this.type===3){const Ye=hg(c),at=[];for(const At of Ye)at.push(At.map(Pe));Oe=at.length===1?{type:"Polygon",coordinates:at[0]}:{type:"MultiPolygon",coordinates:at}}else throw new Error("unknown feature type");const je={type:"Feature",geometry:Oe,properties:this.properties};return this.id!=null&&(je.id=this.id),je}}lp.types=["Unknown","Point","LineString","Polygon"];function cg(F,C,D){F===1?C.id=D.readVarint():F===2?ug(D,C):F===3?C.type=D.readVarint():F===4&&(C._geometry=D.pos)}function ug(F,C){const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=C._keys[F.readVarint()],Q=C._values[F.readVarint()];C.properties[$]=Q}}function hg(F){const C=F.length;if(C<=1)return[F];const D=[];let $,Q;for(let ue=0;ue<C;ue++){const P=dg(F[ue]);P!==0&&(Q===void 0&&(Q=P<0),Q===P<0?($&&D.push($),$=[F[ue]]):$&&$.push(F[ue]))}return $&&D.push($),D}function dg(F){let C=0;for(let D=0,$=F.length,Q=$-1,ue,P;D<$;Q=D++)ue=F[D],P=F[Q],C+=(P.x-ue.x)*(ue.y+P.y);return C}class pg{constructor(C,D){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=C,this._keys=[],this._values=[],this._features=[],C.readFields(fg,this,D),this.length=this._features.length}feature(C){if(C<0||C>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[C];const D=this._pbf.readVarint()+this._pbf.pos;return new lp(this._pbf,D,this.extent,this._keys,this._values)}}function fg(F,C,D){F===15?C.version=D.readVarint():F===1?C.name=D.readString():F===5?C.extent=D.readVarint():F===2?C._features.push(D.pos):F===3?C._keys.push(D.readString()):F===4&&C._values.push(mg(D))}function mg(F){let C=null;const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=F.readVarint()>>3;C=$===1?F.readString():$===2?F.readFloat():$===3?F.readDouble():$===4?F.readVarint64():$===5?F.readVarint():$===6?F.readSVarint():$===7?F.readBoolean():null}if(C==null)throw new Error("unknown feature value");return C}class gg{constructor(C,D){this.layers=C.readFields(_g,{},D)}}function _g(F,C,D){if(F===3){const $=new pg(D,D.readVarint()+D.pos);$.length&&(C[$.name]=$)}}const ah=65536*65536,cp=1/ah,yg=12,up=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),oh=0,_c=1,Ko=2,yc=5;class xg{constructor(C=new Uint8Array(16)){this.buf=ArrayBuffer.isView(C)?C:new Uint8Array(C),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(C,D,$=this.length){for(;this.pos<$;){const Q=this.readVarint(),ue=Q>>3,P=this.pos;this.type=Q&7,C(ue,D,this),this.pos===P&&this.skip(Q)}return D}readMessage(C,D){return this.readFields(C,D,this.readVarint()+this.pos)}readFixed32(){const C=this.dataView.getUint32(this.pos,!0);return this.pos+=4,C}readSFixed32(){const C=this.dataView.getInt32(this.pos,!0);return this.pos+=4,C}readFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*ah;return this.pos+=8,C}readSFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ah;return this.pos+=8,C}readFloat(){const C=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,C}readDouble(){const C=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,C}readVarint(C){const D=this.buf;let $,Q;return Q=D[this.pos++],$=Q&127,Q<128||(Q=D[this.pos++],$|=(Q&127)<<7,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<14,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<21,Q<128)?$:(Q=D[this.pos],$|=(Q&15)<<28,vg($,C,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const C=this.readVarint();return C%2===1?(C+1)/-2:C/2}readBoolean(){return!!this.readVarint()}readString(){const C=this.readVarint()+this.pos,D=this.pos;return this.pos=C,C-D>=yg&&up?up.decode(this.buf.subarray(D,C)):kg(this.buf,D,C)}readBytes(){const C=this.readVarint()+this.pos,D=this.buf.subarray(this.pos,C);return this.pos=C,D}readPackedVarint(C=[],D){const $=this.readPackedEnd();for(;this.pos<$;)C.push(this.readVarint(D));return C}readPackedSVarint(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSVarint());return C}readPackedBoolean(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readBoolean());return C}readPackedFloat(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFloat());return C}readPackedDouble(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readDouble());return C}readPackedFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed32());return C}readPackedSFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed32());return C}readPackedFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed64());return C}readPackedSFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed64());return C}readPackedEnd(){return this.type===Ko?this.readVarint()+this.pos:this.pos+1}skip(C){const D=C&7;if(D===oh)for(;this.buf[this.pos++]>127;);else if(D===Ko)this.pos=this.readVarint()+this.pos;else if(D===yc)this.pos+=4;else if(D===_c)this.pos+=8;else throw new Error(`Unimplemented type: ${D}`)}writeTag(C,D){this.writeVarint(C<<3|D)}realloc(C){let D=this.length||16;for(;D<this.pos+C;)D*=2;if(D!==this.length){const $=new Uint8Array(D);$.set(this.buf),this.buf=$,this.dataView=new DataView($.buffer),this.length=D}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeSFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*cp),!0),this.pos+=8}writeSFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*cp),!0),this.pos+=8}writeVarint(C){if(C=+C||0,C>268435455||C<0){bg(C,this);return}this.realloc(4),this.buf[this.pos++]=C&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=C>>>7&127)))}writeSVarint(C){this.writeVarint(C<0?-C*2-1:C*2)}writeBoolean(C){this.writeVarint(+C)}writeString(C){C=String(C),this.realloc(C.length*4),this.pos++;const D=this.pos;this.pos=Rg(this.buf,C,this.pos);const $=this.pos-D;$>=128&&hp(D,$,this),this.pos=D-1,this.writeVarint($),this.pos+=$}writeFloat(C){this.realloc(4),this.dataView.setFloat32(this.pos,C,!0),this.pos+=4}writeDouble(C){this.realloc(8),this.dataView.setFloat64(this.pos,C,!0),this.pos+=8}writeBytes(C){const D=C.length;this.writeVarint(D),this.realloc(D);for(let $=0;$<D;$++)this.buf[this.pos++]=C[$]}writeRawMessage(C,D){this.pos++;const $=this.pos;C(D,this);const Q=this.pos-$;Q>=128&&hp($,Q,this),this.pos=$-1,this.writeVarint(Q),this.pos+=Q}writeMessage(C,D,$){this.writeTag(C,Ko),this.writeRawMessage(D,$)}writePackedVarint(C,D){D.length&&this.writeMessage(C,Sg,D)}writePackedSVarint(C,D){D.length&&this.writeMessage(C,Pg,D)}writePackedBoolean(C,D){D.length&&this.writeMessage(C,Eg,D)}writePackedFloat(C,D){D.length&&this.writeMessage(C,Mg,D)}writePackedDouble(C,D){D.length&&this.writeMessage(C,Ig,D)}writePackedFixed32(C,D){D.length&&this.writeMessage(C,Cg,D)}writePackedSFixed32(C,D){D.length&&this.writeMessage(C,Ag,D)}writePackedFixed64(C,D){D.length&&this.writeMessage(C,Dg,D)}writePackedSFixed64(C,D){D.length&&this.writeMessage(C,zg,D)}writeBytesField(C,D){this.writeTag(C,Ko),this.writeBytes(D)}writeFixed32Field(C,D){this.writeTag(C,yc),this.writeFixed32(D)}writeSFixed32Field(C,D){this.writeTag(C,yc),this.writeSFixed32(D)}writeFixed64Field(C,D){this.writeTag(C,_c),this.writeFixed64(D)}writeSFixed64Field(C,D){this.writeTag(C,_c),this.writeSFixed64(D)}writeVarintField(C,D){this.writeTag(C,oh),this.writeVarint(D)}writeSVarintField(C,D){this.writeTag(C,oh),this.writeSVarint(D)}writeStringField(C,D){this.writeTag(C,Ko),this.writeString(D)}writeFloatField(C,D){this.writeTag(C,yc),this.writeFloat(D)}writeDoubleField(C,D){this.writeTag(C,_c),this.writeDouble(D)}writeBooleanField(C,D){this.writeVarintField(C,+D)}}function vg(F,C,D){const $=D.buf;let Q,ue;if(ue=$[D.pos++],Q=(ue&112)>>4,ue<128||(ue=$[D.pos++],Q|=(ue&127)<<3,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<10,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<17,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<24,ue<128)||(ue=$[D.pos++],Q|=(ue&1)<<31,ue<128))return Va(F,Q,C);throw new Error("Expected varint not more than 10 bytes")}function Va(F,C,D){return D?C*4294967296+(F>>>0):(C>>>0)*4294967296+(F>>>0)}function bg(F,C){let D,$;if(F>=0?(D=F%4294967296|0,$=F/4294967296|0):(D=~(-F%4294967296),$=~(-F/4294967296),D^4294967295?D=D+1|0:(D=0,$=$+1|0)),F>=18446744073709552e3||F<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");C.realloc(10),wg(D,$,C),Tg($,C)}function wg(F,C,D){D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos]=F&127}function Tg(F,C){const D=(F&7)<<4;C.buf[C.pos++]|=D|((F>>>=3)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127)))))}function hp(F,C,D){const $=C<=16383?1:C<=2097151?2:C<=268435455?3:Math.floor(Math.log(C)/(Math.LN2*7));D.realloc($);for(let Q=D.pos-1;Q>=F;Q--)D.buf[Q+$]=D.buf[Q]}function Sg(F,C){for(let D=0;D<F.length;D++)C.writeVarint(F[D])}function Pg(F,C){for(let D=0;D<F.length;D++)C.writeSVarint(F[D])}function Mg(F,C){for(let D=0;D<F.length;D++)C.writeFloat(F[D])}function Ig(F,C){for(let D=0;D<F.length;D++)C.writeDouble(F[D])}function Eg(F,C){for(let D=0;D<F.length;D++)C.writeBoolean(F[D])}function Cg(F,C){for(let D=0;D<F.length;D++)C.writeFixed32(F[D])}function Ag(F,C){for(let D=0;D<F.length;D++)C.writeSFixed32(F[D])}function Dg(F,C){for(let D=0;D<F.length;D++)C.writeFixed64(F[D])}function zg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed64(F[D])}function kg(F,C,D){let $="",Q=C;for(;Q<D;){const ue=F[Q];let P=null,c=ue>239?4:ue>223?3:ue>191?2:1;if(Q+c>D)break;let le,Pe,Oe;c===1?ue<128&&(P=ue):c===2?(le=F[Q+1],(le&192)===128&&(P=(ue&31)<<6|le&63,P<=127&&(P=null))):c===3?(le=F[Q+1],Pe=F[Q+2],(le&192)===128&&(Pe&192)===128&&(P=(ue&15)<<12|(le&63)<<6|Pe&63,(P<=2047||P>=55296&&P<=57343)&&(P=null))):c===4&&(le=F[Q+1],Pe=F[Q+2],Oe=F[Q+3],(le&192)===128&&(Pe&192)===128&&(Oe&192)===128&&(P=(ue&15)<<18|(le&63)<<12|(Pe&63)<<6|Oe&63,(P<=65535||P>=1114112)&&(P=null))),P===null?(P=65533,c=1):P>65535&&(P-=65536,$+=String.fromCharCode(P>>>10&1023|55296),P=56320|P&1023),$+=String.fromCharCode(P),Q+=c}return $}function Rg(F,C,D){for(let $=0,Q,ue;$<C.length;$++){if(Q=C.charCodeAt($),Q>55295&&Q<57344)if(ue)if(Q<56320){F[D++]=239,F[D++]=191,F[D++]=189,ue=Q;continue}else Q=ue-55296<<10|Q-56320|65536,ue=null;else{Q>56319||$+1===C.length?(F[D++]=239,F[D++]=191,F[D++]=189):ue=Q;continue}else ue&&(F[D++]=239,F[D++]=191,F[D++]=189,ue=null);Q<128?F[D++]=Q:(Q<2048?F[D++]=Q>>6|192:(Q<65536?F[D++]=Q>>12|224:(F[D++]=Q>>18|240,F[D++]=Q>>12&63|128),F[D++]=Q>>6&63|128),F[D++]=Q&63|128)}return D}async function Fg(F,C,D,$="bbox",Q){try{const ue=new sh(F),P=await ue.getHeader(),c=Math.min(Math.floor((P.minZoom+P.maxZoom)/2),8),le=Math.pow(2,c);for(let Pe=0;Pe<le;Pe++)for(let Oe=0;Oe<le;Oe++)try{const je=await ue.getZxy(c,Pe,Oe);if(!je||!je.data)continue;const at=new gg(new xg(je.data)).layers[C];if(!at)continue;for(let At=0;At<at.length;At++){const Qe=at.feature(At),ge=Qe.properties,ei=String(Q?ge[Q]:Qe.id);if(ei===String(D)){let Dt=null;if(ge[$]){const ht=ge[$];if(typeof ht=="string")try{const ri=JSON.parse(ht);Array.isArray(ri)&&ri.length===4&&(Dt=ri)}catch{const ri=ht.split(",").map(di=>parseFloat(di.trim()));ri.length===4&&ri.every(di=>!isNaN(di))&&(Dt=ri)}else Array.isArray(ht)&&ht.length===4&&(Dt=ht)}if(!Dt){const ht=Qe.loadGeometry();let ri=1/0,di=1/0,Mi=-1/0,st=-1/0;ht.forEach(qt=>{qt.forEach(Zt=>{ri=Math.min(ri,Zt.x),di=Math.min(di,Zt.y),Mi=Math.max(Mi,Zt.x),st=Math.max(st,Zt.y)})});const pe=4096,he=(Pe+ri/pe)/le*360-180,ze=(Pe+Mi/pe)/le*360-180,qe=Math.PI-2*Math.PI*(Oe+di/pe)/le,Ue=Math.PI-2*Math.PI*(Oe+st/pe)/le,ct=180/Math.PI*Math.atan(.5*(Math.exp(qe)-Math.exp(-qe))),Ut=180/Math.PI*Math.atan(.5*(Math.exp(Ue)-Math.exp(-Ue)));Dt=[Math.min(he,ze),Math.min(ct,Ut),Math.max(he,ze),Math.max(ct,Ut)]}return{id:ei,bbox:Dt,properties:ge}}}}catch{continue}return console.warn(`Feature con id "${D}" no encontrada en PMTiles`),null}catch(ue){return console.error("Error buscando feature en PMTiles:",ue),null}}const xc="pmtiles-source",dp="pmtiles-fill",Jo="municipios-source",lh="municipios-fill",Lg="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/componente/entidad.pmtiles",Bg="entidad",Og="cvegeo",Vg="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/transformador/municipio.pmtiles",vc="municipio",ch="CVEGEO",jg=({pmtilesUrl:F=Lg,sourceLayer:C=Bg,joinGeomKey:D=Og,csvUrl:$,csvFile:Q,joinCsvKey:ue,field:P="valor",mode:c="boolean",width:le="100%",height:Pe=520,initialView:Oe,fitToIds:je,bboxField:Ye="bbox",jenksK:at=5,showMunicipios:At=!1,municipiosCsvUrl:Qe,municipiosCsvFile:ge,municipiosField:ei="valor"})=>{const Dt=Ln.useRef(null),ht=Ln.useRef(null),[ri,di]=Ln.useState(null);Ln.useEffect(()=>{if(!Dt.current)return;if(!$&&!Q){di("Debe proporcionar csvUrl o csvFile"),console.error("MapaPMTiles: Debe proporcionar csvUrl o csvFile");return}let st=null;return(async()=>{try{const he=new Ym;Bd.addProtocol("pmtiles",he.tile);const ze=(Oe==null?void 0:Oe.center)||[-102,23],qe=(Oe==null?void 0:Oe.zoom)||4;st=new Ld.Map({container:Dt.current,style:{version:8,sources:{},layers:[]},center:ze,zoom:qe,boxZoom:!1,doubleClickZoom:!1,dragRotate:!1,keyboard:!1,scrollZoom:!1,touchPitch:!1,touchZoomRotate:!0,dragPan:!1,maxBounds:void 0,attributionControl:!1}),ht.current=st,st.on("load",async()=>{if(st)try{st.addSource(xc,{type:"vector",url:`pmtiles://${F}`,promoteId:D});const Ue=ue||D,ct=Q?await sp(Q,Ue,P):await np($,Ue,P);ct.joinMap.forEach((nt,ft)=>{try{st.setFeatureState({source:xc,sourceLayer:C,id:ft},{value:nt})}catch(Fe){console.warn(`Error setting feature state for key ${ft}:`,Fe)}});let Ut;if(c==="boolean")Ut=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const nt=Array.from(ct.joinMap.values()).filter(ft=>typeof ft=="number").map(ft=>ft);if(nt.length===0)console.warn("No hay valores numéricos para clasificación Jenks"),Ut=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"];else{const ft=ap(nt,at),Fe=ft.length-1,Lt=op("#f3f3f3","#66827f",Fe),et=["step",["feature-state","value"],Lt[0]];for(let ot=1;ot<Fe;ot++)et.push(ft[ot]),et.push(Lt[ot]);Ut=et}}const qt=je?Array.isArray(je)?je:[je]:[];let Zt;if(qt.length>0&&(Zt=["in",["get",D],["literal",qt]]),st.addLayer({id:dp,type:"fill",source:xc,"source-layer":C,paint:{"fill-color":Ut,"fill-opacity":.75},filter:Zt}),st.addLayer({id:`${dp}-outline`,type:"line",source:xc,"source-layer":C,paint:{"line-color":"#2c3e50","line-width":At?1.5:.5},filter:Zt}),At&&qt.length>0){st.addSource(Jo,{type:"vector",url:`pmtiles://${Vg}`,promoteId:ch});const nt=["in",["slice",["get","CVE_ENT"],0,2],["literal",qt]];if(Qe||ge){const ft=ge?await sp(ge,ch,ei):await np(Qe,ch,ei);ft.joinMap.forEach((Lt,et)=>{try{st.setFeatureState({source:Jo,sourceLayer:vc,id:et},{value:Lt})}catch(ot){console.warn(`Error setting municipio feature state for key ${et}:`,ot)}});let Fe;if(c==="boolean")Fe=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const Lt=Array.from(ft.joinMap.values()).filter(et=>typeof et=="number").map(et=>et);if(Lt.length>0){const et=ap(Lt,at),ot=et.length-1,Je=op("#f3f3f3","#66827f",ot),zt=["step",["feature-state","value"],Je[0]];for(let xt=1;xt<ot;xt++)zt.push(et[xt]),zt.push(Je[xt]);Fe=zt}else Fe=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"]}st.addLayer({id:lh,type:"fill",source:Jo,"source-layer":vc,paint:{"fill-color":Fe,"fill-opacity":.75},filter:nt})}else st.addLayer({id:lh,type:"line",source:Jo,"source-layer":vc,paint:{"line-color":"#2c3e50","line-width":.5},filter:nt});st.addLayer({id:`${lh}-outline`,type:"line",source:Jo,"source-layer":vc,paint:{"line-color":"#2c3e50","line-width":.5},filter:nt})}if(qt.length>0){const ft=(await Promise.all(qt.map(Fe=>Fg(F,C,Fe,Ye,D)))).filter(Fe=>Fe!==null&&Fe.bbox);if(ft.length>0){let Fe=1/0,Lt=1/0,et=-1/0,ot=-1/0;ft.forEach(zt=>{zt&&zt.bbox&&(Fe=Math.min(Fe,zt.bbox[0]),Lt=Math.min(Lt,zt.bbox[1]),et=Math.max(et,zt.bbox[2]),ot=Math.max(ot,zt.bbox[3]))});const Je=[[Fe,Lt],[et,ot]];st.fitBounds(Je,{padding:50,duration:0})}else console.warn(`No se pudieron encontrar bboxes para los IDs: ${qt.join(", ")}`)}}catch(Ue){console.error("Error cargando datos en el mapa:",Ue),di(`Error cargando datos: ${Ue instanceof Error?Ue.message:String(Ue)}`)}}),st.on("error",Ue=>{var ct;console.error("Error del mapa:",Ue),di(`Error del mapa: ${((ct=Ue.error)==null?void 0:ct.message)||"Error desconocido"}`)})}catch(he){console.error("Error inicializando mapa:",he),di(`Error inicializando: ${he instanceof Error?he.message:String(he)}`)}})(),()=>{ht.current&&(ht.current.remove(),ht.current=null),Bd.removeProtocol("pmtiles")}},[F,C,D,$,Q,ue,P,c,at,je,Ye,Oe,At,Qe,ge,ei]);const Mi={width:typeof le=="number"?`${le}px`:le,height:typeof Pe=="number"?`${Pe}px`:Pe,position:"relative"};return Ar.jsxs("div",{style:Mi,children:[Ar.jsx("div",{ref:Dt,style:{width:"100%",height:"100%"}}),ri&&Ar.jsx("div",{style:{position:"absolute",top:10,left:10,right:10,background:"rgba(231, 76, 60, 0.9)",color:"white",padding:"10px",borderRadius:"4px",fontSize:"12px",zIndex:1e3},children:ri})]})};Br.MapaPMTiles=jg,Object.defineProperty(Br,Symbol.toStringTag,{value:"Module"})}));
822
+ `,'"',Pe.BYTE_ORDER_MARK],Pe.WORKERS_SUPPORTED=!ue&&!!$.Worker,Pe.NODE_STREAM_INPUT=1,Pe.LocalChunkSize=10485760,Pe.RemoteChunkSize=5242880,Pe.DefaultDelimiter=",",Pe.Parser=ei,Pe.ParserHandle=Qe,Pe.NetworkStreamer=je,Pe.FileStreamer=Ye,Pe.StringStreamer=at,Pe.ReadableStreamStreamer=At,$.jQuery&&((Q=$.jQuery).fn.parse=function(pe){var he=pe.config||{},ze=[];return this.each(function(ct){if(!(Q(this).prop("tagName").toUpperCase()==="INPUT"&&Q(this).attr("type").toLowerCase()==="file"&&$.FileReader)||!this.files||this.files.length===0)return!0;for(var Ut=0;Ut<this.files.length;Ut++)ze.push({file:this.files[Ut],inputElem:this,instanceConfig:Q.extend({},he)})}),qe(),this;function qe(){if(ze.length===0)st(pe.complete)&&pe.complete();else{var ct,Ut,qt,Zt,nt=ze[0];if(st(pe.before)){var ft=pe.before(nt.file,nt.inputElem);if(typeof ft=="object"){if(ft.action==="abort")return ct="AbortError",Ut=nt.file,qt=nt.inputElem,Zt=ft.reason,void(st(pe.error)&&pe.error({name:ct},Ut,qt,Zt));if(ft.action==="skip")return void Ue();typeof ft.config=="object"&&(nt.instanceConfig=Q.extend(nt.instanceConfig,ft.config))}else if(ft==="skip")return void Ue()}var Fe=nt.instanceConfig.complete;nt.instanceConfig.complete=function(Lt){st(Fe)&&Fe(Lt,nt.file,nt.inputElem),Ue()},Pe.parse(nt.file,nt.instanceConfig)}}function Ue(){ze.splice(0,1),qe()}}),P&&($.onmessage=function(pe){pe=pe.data,Pe.WORKER_ID===void 0&&pe&&(Pe.WORKER_ID=pe.workerId),typeof pe.input=="string"?$.postMessage({workerId:Pe.WORKER_ID,results:Pe.parse(pe.input,pe.config),finished:!0}):($.File&&pe.input instanceof File||pe.input instanceof Object)&&(pe=Pe.parse(pe.input,pe.config))&&$.postMessage({workerId:Pe.WORKER_ID,results:pe,finished:!0})}),(je.prototype=Object.create(Oe.prototype)).constructor=je,(Ye.prototype=Object.create(Oe.prototype)).constructor=Ye,(at.prototype=Object.create(at.prototype)).constructor=at,(At.prototype=Object.create(Oe.prototype)).constructor=At,Pe})})(gc)),gc.exports}var lg=og();const rp=Rd(lg);async function np(F,C,D){return new Promise(($,Q)=>{rp.parse(F,{download:!0,header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Oe=Pe[C],je=Pe[D];if(Oe!=null){const Ye=parseFloat(je),at=isNaN(Ye)?je:Ye;le.set(String(Oe),at)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}async function sp(F,C,D){return new Promise(($,Q)=>{rp.parse(F,{header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Oe=Pe[C],je=Pe[D];if(Oe!=null){const Ye=parseFloat(je),at=isNaN(Ye)?je:Ye;le.set(String(Oe),at)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}function ap(F,C){if(F.length===0)return[];if(C>=F.length)return[...new Set(F)].sort((le,Pe)=>le-Pe);const D=[...F].sort((le,Pe)=>le-Pe);let $=D.length;const Q=Array($+1).fill(0).map(()=>Array(C+1).fill(0)),ue=Array($+1).fill(0).map(()=>Array(C+1).fill(0));for(let le=1;le<=C;le++){Q[1][le]=1,ue[1][le]=0;for(let Pe=2;Pe<=$;Pe++)ue[Pe][le]=1/0}for(let le=2;le<=$;le++){let Pe=0,Oe=0,je=0;for(let Ye=1;Ye<=le;Ye++){const at=le-Ye+1,At=D[at-1];Oe+=At*At,Pe+=At,je++;const Qe=Oe-Pe*Pe/je,ge=at-1;if(ge!==0)for(let ei=2;ei<=C;ei++)ue[le][ei]>=Qe+ue[ge][ei-1]&&(Q[le][ei]=at,ue[le][ei]=Qe+ue[ge][ei-1])}Q[le][1]=1,ue[le][1]=ue[le-1][1]+(le-1)*(D[le-1]-D[le-2])**2}const P=[];let c=C;for(;c>=2;){const le=Q[$][c]-1;P.push(D[le]),$=Q[$][c]-1,c--}return P.push(D[0]),P.reverse(),P.push(D[D.length-1]),[...new Set(P)].sort((le,Pe)=>le-Pe)}function op(F,C,D){const $=[],Q=c=>{const le=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c);return le?{r:parseInt(le[1],16),g:parseInt(le[2],16),b:parseInt(le[3],16)}:{r:0,g:0,b:0}},ue=Q(F),P=Q(C);for(let c=0;c<D;c++){const le=c/(D-1),Pe=Math.round(ue.r+le*(P.r-ue.r)),Oe=Math.round(ue.g+le*(P.g-ue.g)),je=Math.round(ue.b+le*(P.b-ue.b));$.push(`rgb(${Pe}, ${Oe}, ${je})`)}return $}function ls(F,C){this.x=F,this.y=C}ls.prototype={clone(){return new ls(this.x,this.y)},add(F){return this.clone()._add(F)},sub(F){return this.clone()._sub(F)},multByPoint(F){return this.clone()._multByPoint(F)},divByPoint(F){return this.clone()._divByPoint(F)},mult(F){return this.clone()._mult(F)},div(F){return this.clone()._div(F)},rotate(F){return this.clone()._rotate(F)},rotateAround(F,C){return this.clone()._rotateAround(F,C)},matMult(F){return this.clone()._matMult(F)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(F){return this.x===F.x&&this.y===F.y},dist(F){return Math.sqrt(this.distSqr(F))},distSqr(F){const C=F.x-this.x,D=F.y-this.y;return C*C+D*D},angle(){return Math.atan2(this.y,this.x)},angleTo(F){return Math.atan2(this.y-F.y,this.x-F.x)},angleWith(F){return this.angleWithSep(F.x,F.y)},angleWithSep(F,C){return Math.atan2(this.x*C-this.y*F,this.x*F+this.y*C)},_matMult(F){const C=F[0]*this.x+F[1]*this.y,D=F[2]*this.x+F[3]*this.y;return this.x=C,this.y=D,this},_add(F){return this.x+=F.x,this.y+=F.y,this},_sub(F){return this.x-=F.x,this.y-=F.y,this},_mult(F){return this.x*=F,this.y*=F,this},_div(F){return this.x/=F,this.y/=F,this},_multByPoint(F){return this.x*=F.x,this.y*=F.y,this},_divByPoint(F){return this.x/=F.x,this.y/=F.y,this},_unit(){return this._div(this.mag()),this},_perp(){const F=this.y;return this.y=this.x,this.x=-F,this},_rotate(F){const C=Math.cos(F),D=Math.sin(F),$=C*this.x-D*this.y,Q=D*this.x+C*this.y;return this.x=$,this.y=Q,this},_rotateAround(F,C){const D=Math.cos(F),$=Math.sin(F),Q=C.x+D*(this.x-C.x)-$*(this.y-C.y),ue=C.y+$*(this.x-C.x)+D*(this.y-C.y);return this.x=Q,this.y=ue,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:ls},ls.convert=function(F){if(F instanceof ls)return F;if(Array.isArray(F))return new ls(+F[0],+F[1]);if(F.x!==void 0&&F.y!==void 0)return new ls(+F.x,+F.y);throw new Error("Expected [x, y] or {x, y} point format")};class lp{constructor(C,D,$,Q,ue){this.properties={},this.extent=$,this.type=0,this.id=void 0,this._pbf=C,this._geometry=-1,this._keys=Q,this._values=ue,C.readFields(cg,this,D)}loadGeometry(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos,$=[];let Q,ue=1,P=0,c=0,le=0;for(;C.pos<D;){if(P<=0){const Pe=C.readVarint();ue=Pe&7,P=Pe>>3}if(P--,ue===1||ue===2)c+=C.readSVarint(),le+=C.readSVarint(),ue===1&&(Q&&$.push(Q),Q=[]),Q&&Q.push(new ls(c,le));else if(ue===7)Q&&Q.push(Q[0].clone());else throw new Error(`unknown command ${ue}`)}return Q&&$.push(Q),$}bbox(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos;let $=1,Q=0,ue=0,P=0,c=1/0,le=-1/0,Pe=1/0,Oe=-1/0;for(;C.pos<D;){if(Q<=0){const je=C.readVarint();$=je&7,Q=je>>3}if(Q--,$===1||$===2)ue+=C.readSVarint(),P+=C.readSVarint(),ue<c&&(c=ue),ue>le&&(le=ue),P<Pe&&(Pe=P),P>Oe&&(Oe=P);else if($!==7)throw new Error(`unknown command ${$}`)}return[c,Pe,le,Oe]}toGeoJSON(C,D,$){const Q=this.extent*Math.pow(2,$),ue=this.extent*C,P=this.extent*D,c=this.loadGeometry();function le(Ye){return[(Ye.x+ue)*360/Q-180,360/Math.PI*Math.atan(Math.exp((1-(Ye.y+P)*2/Q)*Math.PI))-90]}function Pe(Ye){return Ye.map(le)}let Oe;if(this.type===1){const Ye=[];for(const At of c)Ye.push(At[0]);const at=Pe(Ye);Oe=Ye.length===1?{type:"Point",coordinates:at[0]}:{type:"MultiPoint",coordinates:at}}else if(this.type===2){const Ye=c.map(Pe);Oe=Ye.length===1?{type:"LineString",coordinates:Ye[0]}:{type:"MultiLineString",coordinates:Ye}}else if(this.type===3){const Ye=hg(c),at=[];for(const At of Ye)at.push(At.map(Pe));Oe=at.length===1?{type:"Polygon",coordinates:at[0]}:{type:"MultiPolygon",coordinates:at}}else throw new Error("unknown feature type");const je={type:"Feature",geometry:Oe,properties:this.properties};return this.id!=null&&(je.id=this.id),je}}lp.types=["Unknown","Point","LineString","Polygon"];function cg(F,C,D){F===1?C.id=D.readVarint():F===2?ug(D,C):F===3?C.type=D.readVarint():F===4&&(C._geometry=D.pos)}function ug(F,C){const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=C._keys[F.readVarint()],Q=C._values[F.readVarint()];C.properties[$]=Q}}function hg(F){const C=F.length;if(C<=1)return[F];const D=[];let $,Q;for(let ue=0;ue<C;ue++){const P=dg(F[ue]);P!==0&&(Q===void 0&&(Q=P<0),Q===P<0?($&&D.push($),$=[F[ue]]):$&&$.push(F[ue]))}return $&&D.push($),D}function dg(F){let C=0;for(let D=0,$=F.length,Q=$-1,ue,P;D<$;Q=D++)ue=F[D],P=F[Q],C+=(P.x-ue.x)*(ue.y+P.y);return C}class pg{constructor(C,D){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=C,this._keys=[],this._values=[],this._features=[],C.readFields(fg,this,D),this.length=this._features.length}feature(C){if(C<0||C>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[C];const D=this._pbf.readVarint()+this._pbf.pos;return new lp(this._pbf,D,this.extent,this._keys,this._values)}}function fg(F,C,D){F===15?C.version=D.readVarint():F===1?C.name=D.readString():F===5?C.extent=D.readVarint():F===2?C._features.push(D.pos):F===3?C._keys.push(D.readString()):F===4&&C._values.push(mg(D))}function mg(F){let C=null;const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=F.readVarint()>>3;C=$===1?F.readString():$===2?F.readFloat():$===3?F.readDouble():$===4?F.readVarint64():$===5?F.readVarint():$===6?F.readSVarint():$===7?F.readBoolean():null}if(C==null)throw new Error("unknown feature value");return C}class gg{constructor(C,D){this.layers=C.readFields(_g,{},D)}}function _g(F,C,D){if(F===3){const $=new pg(D,D.readVarint()+D.pos);$.length&&(C[$.name]=$)}}const ah=65536*65536,cp=1/ah,yg=12,up=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),oh=0,_c=1,Ko=2,yc=5;class xg{constructor(C=new Uint8Array(16)){this.buf=ArrayBuffer.isView(C)?C:new Uint8Array(C),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(C,D,$=this.length){for(;this.pos<$;){const Q=this.readVarint(),ue=Q>>3,P=this.pos;this.type=Q&7,C(ue,D,this),this.pos===P&&this.skip(Q)}return D}readMessage(C,D){return this.readFields(C,D,this.readVarint()+this.pos)}readFixed32(){const C=this.dataView.getUint32(this.pos,!0);return this.pos+=4,C}readSFixed32(){const C=this.dataView.getInt32(this.pos,!0);return this.pos+=4,C}readFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*ah;return this.pos+=8,C}readSFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ah;return this.pos+=8,C}readFloat(){const C=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,C}readDouble(){const C=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,C}readVarint(C){const D=this.buf;let $,Q;return Q=D[this.pos++],$=Q&127,Q<128||(Q=D[this.pos++],$|=(Q&127)<<7,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<14,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<21,Q<128)?$:(Q=D[this.pos],$|=(Q&15)<<28,vg($,C,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const C=this.readVarint();return C%2===1?(C+1)/-2:C/2}readBoolean(){return!!this.readVarint()}readString(){const C=this.readVarint()+this.pos,D=this.pos;return this.pos=C,C-D>=yg&&up?up.decode(this.buf.subarray(D,C)):kg(this.buf,D,C)}readBytes(){const C=this.readVarint()+this.pos,D=this.buf.subarray(this.pos,C);return this.pos=C,D}readPackedVarint(C=[],D){const $=this.readPackedEnd();for(;this.pos<$;)C.push(this.readVarint(D));return C}readPackedSVarint(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSVarint());return C}readPackedBoolean(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readBoolean());return C}readPackedFloat(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFloat());return C}readPackedDouble(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readDouble());return C}readPackedFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed32());return C}readPackedSFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed32());return C}readPackedFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed64());return C}readPackedSFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed64());return C}readPackedEnd(){return this.type===Ko?this.readVarint()+this.pos:this.pos+1}skip(C){const D=C&7;if(D===oh)for(;this.buf[this.pos++]>127;);else if(D===Ko)this.pos=this.readVarint()+this.pos;else if(D===yc)this.pos+=4;else if(D===_c)this.pos+=8;else throw new Error(`Unimplemented type: ${D}`)}writeTag(C,D){this.writeVarint(C<<3|D)}realloc(C){let D=this.length||16;for(;D<this.pos+C;)D*=2;if(D!==this.length){const $=new Uint8Array(D);$.set(this.buf),this.buf=$,this.dataView=new DataView($.buffer),this.length=D}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeSFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*cp),!0),this.pos+=8}writeSFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*cp),!0),this.pos+=8}writeVarint(C){if(C=+C||0,C>268435455||C<0){bg(C,this);return}this.realloc(4),this.buf[this.pos++]=C&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=C>>>7&127)))}writeSVarint(C){this.writeVarint(C<0?-C*2-1:C*2)}writeBoolean(C){this.writeVarint(+C)}writeString(C){C=String(C),this.realloc(C.length*4),this.pos++;const D=this.pos;this.pos=Rg(this.buf,C,this.pos);const $=this.pos-D;$>=128&&hp(D,$,this),this.pos=D-1,this.writeVarint($),this.pos+=$}writeFloat(C){this.realloc(4),this.dataView.setFloat32(this.pos,C,!0),this.pos+=4}writeDouble(C){this.realloc(8),this.dataView.setFloat64(this.pos,C,!0),this.pos+=8}writeBytes(C){const D=C.length;this.writeVarint(D),this.realloc(D);for(let $=0;$<D;$++)this.buf[this.pos++]=C[$]}writeRawMessage(C,D){this.pos++;const $=this.pos;C(D,this);const Q=this.pos-$;Q>=128&&hp($,Q,this),this.pos=$-1,this.writeVarint(Q),this.pos+=Q}writeMessage(C,D,$){this.writeTag(C,Ko),this.writeRawMessage(D,$)}writePackedVarint(C,D){D.length&&this.writeMessage(C,Sg,D)}writePackedSVarint(C,D){D.length&&this.writeMessage(C,Pg,D)}writePackedBoolean(C,D){D.length&&this.writeMessage(C,Eg,D)}writePackedFloat(C,D){D.length&&this.writeMessage(C,Mg,D)}writePackedDouble(C,D){D.length&&this.writeMessage(C,Ig,D)}writePackedFixed32(C,D){D.length&&this.writeMessage(C,Cg,D)}writePackedSFixed32(C,D){D.length&&this.writeMessage(C,Ag,D)}writePackedFixed64(C,D){D.length&&this.writeMessage(C,Dg,D)}writePackedSFixed64(C,D){D.length&&this.writeMessage(C,zg,D)}writeBytesField(C,D){this.writeTag(C,Ko),this.writeBytes(D)}writeFixed32Field(C,D){this.writeTag(C,yc),this.writeFixed32(D)}writeSFixed32Field(C,D){this.writeTag(C,yc),this.writeSFixed32(D)}writeFixed64Field(C,D){this.writeTag(C,_c),this.writeFixed64(D)}writeSFixed64Field(C,D){this.writeTag(C,_c),this.writeSFixed64(D)}writeVarintField(C,D){this.writeTag(C,oh),this.writeVarint(D)}writeSVarintField(C,D){this.writeTag(C,oh),this.writeSVarint(D)}writeStringField(C,D){this.writeTag(C,Ko),this.writeString(D)}writeFloatField(C,D){this.writeTag(C,yc),this.writeFloat(D)}writeDoubleField(C,D){this.writeTag(C,_c),this.writeDouble(D)}writeBooleanField(C,D){this.writeVarintField(C,+D)}}function vg(F,C,D){const $=D.buf;let Q,ue;if(ue=$[D.pos++],Q=(ue&112)>>4,ue<128||(ue=$[D.pos++],Q|=(ue&127)<<3,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<10,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<17,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<24,ue<128)||(ue=$[D.pos++],Q|=(ue&1)<<31,ue<128))return Va(F,Q,C);throw new Error("Expected varint not more than 10 bytes")}function Va(F,C,D){return D?C*4294967296+(F>>>0):(C>>>0)*4294967296+(F>>>0)}function bg(F,C){let D,$;if(F>=0?(D=F%4294967296|0,$=F/4294967296|0):(D=~(-F%4294967296),$=~(-F/4294967296),D^4294967295?D=D+1|0:(D=0,$=$+1|0)),F>=18446744073709552e3||F<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");C.realloc(10),wg(D,$,C),Tg($,C)}function wg(F,C,D){D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos]=F&127}function Tg(F,C){const D=(F&7)<<4;C.buf[C.pos++]|=D|((F>>>=3)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127)))))}function hp(F,C,D){const $=C<=16383?1:C<=2097151?2:C<=268435455?3:Math.floor(Math.log(C)/(Math.LN2*7));D.realloc($);for(let Q=D.pos-1;Q>=F;Q--)D.buf[Q+$]=D.buf[Q]}function Sg(F,C){for(let D=0;D<F.length;D++)C.writeVarint(F[D])}function Pg(F,C){for(let D=0;D<F.length;D++)C.writeSVarint(F[D])}function Mg(F,C){for(let D=0;D<F.length;D++)C.writeFloat(F[D])}function Ig(F,C){for(let D=0;D<F.length;D++)C.writeDouble(F[D])}function Eg(F,C){for(let D=0;D<F.length;D++)C.writeBoolean(F[D])}function Cg(F,C){for(let D=0;D<F.length;D++)C.writeFixed32(F[D])}function Ag(F,C){for(let D=0;D<F.length;D++)C.writeSFixed32(F[D])}function Dg(F,C){for(let D=0;D<F.length;D++)C.writeFixed64(F[D])}function zg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed64(F[D])}function kg(F,C,D){let $="",Q=C;for(;Q<D;){const ue=F[Q];let P=null,c=ue>239?4:ue>223?3:ue>191?2:1;if(Q+c>D)break;let le,Pe,Oe;c===1?ue<128&&(P=ue):c===2?(le=F[Q+1],(le&192)===128&&(P=(ue&31)<<6|le&63,P<=127&&(P=null))):c===3?(le=F[Q+1],Pe=F[Q+2],(le&192)===128&&(Pe&192)===128&&(P=(ue&15)<<12|(le&63)<<6|Pe&63,(P<=2047||P>=55296&&P<=57343)&&(P=null))):c===4&&(le=F[Q+1],Pe=F[Q+2],Oe=F[Q+3],(le&192)===128&&(Pe&192)===128&&(Oe&192)===128&&(P=(ue&15)<<18|(le&63)<<12|(Pe&63)<<6|Oe&63,(P<=65535||P>=1114112)&&(P=null))),P===null?(P=65533,c=1):P>65535&&(P-=65536,$+=String.fromCharCode(P>>>10&1023|55296),P=56320|P&1023),$+=String.fromCharCode(P),Q+=c}return $}function Rg(F,C,D){for(let $=0,Q,ue;$<C.length;$++){if(Q=C.charCodeAt($),Q>55295&&Q<57344)if(ue)if(Q<56320){F[D++]=239,F[D++]=191,F[D++]=189,ue=Q;continue}else Q=ue-55296<<10|Q-56320|65536,ue=null;else{Q>56319||$+1===C.length?(F[D++]=239,F[D++]=191,F[D++]=189):ue=Q;continue}else ue&&(F[D++]=239,F[D++]=191,F[D++]=189,ue=null);Q<128?F[D++]=Q:(Q<2048?F[D++]=Q>>6|192:(Q<65536?F[D++]=Q>>12|224:(F[D++]=Q>>18|240,F[D++]=Q>>12&63|128),F[D++]=Q>>6&63|128),F[D++]=Q&63|128)}return D}async function Fg(F,C,D,$="bbox",Q){try{const ue=new sh(F),P=await ue.getHeader(),c=Math.min(Math.floor((P.minZoom+P.maxZoom)/2),8),le=Math.pow(2,c);for(let Pe=0;Pe<le;Pe++)for(let Oe=0;Oe<le;Oe++)try{const je=await ue.getZxy(c,Pe,Oe);if(!je||!je.data)continue;const at=new gg(new xg(je.data)).layers[C];if(!at)continue;for(let At=0;At<at.length;At++){const Qe=at.feature(At),ge=Qe.properties,ei=String(Q?ge[Q]:Qe.id);if(ei===String(D)){let Dt=null;if(ge[$]){const ht=ge[$];if(typeof ht=="string")try{const ri=JSON.parse(ht);Array.isArray(ri)&&ri.length===4&&(Dt=ri)}catch{const ri=ht.split(",").map(di=>parseFloat(di.trim()));ri.length===4&&ri.every(di=>!isNaN(di))&&(Dt=ri)}else Array.isArray(ht)&&ht.length===4&&(Dt=ht)}if(!Dt){const ht=Qe.loadGeometry();let ri=1/0,di=1/0,Mi=-1/0,st=-1/0;ht.forEach(qt=>{qt.forEach(Zt=>{ri=Math.min(ri,Zt.x),di=Math.min(di,Zt.y),Mi=Math.max(Mi,Zt.x),st=Math.max(st,Zt.y)})});const pe=4096,he=(Pe+ri/pe)/le*360-180,ze=(Pe+Mi/pe)/le*360-180,qe=Math.PI-2*Math.PI*(Oe+di/pe)/le,Ue=Math.PI-2*Math.PI*(Oe+st/pe)/le,ct=180/Math.PI*Math.atan(.5*(Math.exp(qe)-Math.exp(-qe))),Ut=180/Math.PI*Math.atan(.5*(Math.exp(Ue)-Math.exp(-Ue)));Dt=[Math.min(he,ze),Math.min(ct,Ut),Math.max(he,ze),Math.max(ct,Ut)]}return{id:ei,bbox:Dt,properties:ge}}}}catch{continue}return console.warn(`Feature con id "${D}" no encontrada en PMTiles`),null}catch(ue){return console.error("Error buscando feature en PMTiles:",ue),null}}const xc="pmtiles-source",dp="pmtiles-fill",Jo="municipios-source",lh="municipios-fill",Lg="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/componente/entidad.pmtiles",Bg="entidad",Og="cvegeo",Vg="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/transformador/municipio.pmtiles",vc="municipio",ch="CVEGEO",jg=({pmtilesUrl:F=Lg,sourceLayer:C=Bg,joinGeomKey:D=Og,csvUrl:$,csvFile:Q,joinCsvKey:ue,field:P="valor",mode:c="boolean",width:le="100%",height:Pe=520,initialView:Oe,fitToIds:je,bboxField:Ye="bbox",jenksK:at=5,showMunicipios:At=!1,municipiosCsvUrl:Qe,municipiosCsvFile:ge,municipiosField:ei="valor"})=>{const Dt=Ln.useRef(null),ht=Ln.useRef(null),[ri,di]=Ln.useState(null);Ln.useEffect(()=>{if(!Dt.current)return;if(!$&&!Q){di("Debe proporcionar csvUrl o csvFile"),console.error("MapaPMTiles: Debe proporcionar csvUrl o csvFile");return}let st=null;return(async()=>{try{const he=new Ym;Bd.addProtocol("pmtiles",he.tile);const ze=(Oe==null?void 0:Oe.center)||[-102,23],qe=(Oe==null?void 0:Oe.zoom)||4;st=new Ld.Map({container:Dt.current,style:{version:8,sources:{},layers:[]},center:ze,zoom:qe,boxZoom:!1,doubleClickZoom:!1,dragRotate:!1,keyboard:!1,scrollZoom:!1,touchPitch:!1,touchZoomRotate:!0,dragPan:!1,maxBounds:void 0,attributionControl:!1}),ht.current=st,st.on("load",async()=>{if(st)try{st.addSource(xc,{type:"vector",url:`pmtiles://${F}`,promoteId:D});const Ue=ue||D,ct=Q?await sp(Q,Ue,P):await np($,Ue,P);ct.joinMap.forEach((nt,ft)=>{try{st.setFeatureState({source:xc,sourceLayer:C,id:ft},{value:nt})}catch(Fe){console.warn(`Error setting feature state for key ${ft}:`,Fe)}});let Ut;if(c==="boolean")Ut=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const nt=Array.from(ct.joinMap.values()).filter(ft=>typeof ft=="number").map(ft=>ft);if(nt.length===0)console.warn("No hay valores numéricos para clasificación Jenks"),Ut=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"];else{const ft=ap(nt,at),Fe=ft.length-1,Lt=op("#f3f3f3","#66827f",Fe),et=["step",["feature-state","value"],Lt[0]];for(let ot=1;ot<Fe;ot++)et.push(ft[ot]),et.push(Lt[ot]);Ut=et}}const qt=je?Array.isArray(je)?je:[je]:[];let Zt;if(qt.length>0&&(Zt=["in",["get",D],["literal",qt]]),st.addLayer({id:dp,type:"fill",source:xc,"source-layer":C,paint:{"fill-color":Ut,"fill-opacity":.75},filter:Zt}),st.addLayer({id:`${dp}-outline`,type:"line",source:xc,"source-layer":C,paint:{"line-color":"#2c3e50","line-width":At?1.5:.5},filter:Zt}),At&&qt.length>0){st.addSource(Jo,{type:"vector",url:`pmtiles://${Vg}`,promoteId:ch});const nt=["in",["get","CVE_ENT"],["literal",qt]];if(Qe||ge){const ft=ge?await sp(ge,ch,ei):await np(Qe,ch,ei);ft.joinMap.forEach((Lt,et)=>{try{st.setFeatureState({source:Jo,sourceLayer:vc,id:et},{value:Lt})}catch(ot){console.warn(`Error setting municipio feature state for key ${et}:`,ot)}});let Fe;if(c==="boolean")Fe=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const Lt=Array.from(ft.joinMap.values()).filter(et=>typeof et=="number").map(et=>et);if(Lt.length>0){const et=ap(Lt,at),ot=et.length-1,Je=op("#f3f3f3","#66827f",ot),zt=["step",["feature-state","value"],Je[0]];for(let xt=1;xt<ot;xt++)zt.push(et[xt]),zt.push(Je[xt]);Fe=zt}else Fe=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"]}st.addLayer({id:lh,type:"fill",source:Jo,"source-layer":vc,paint:{"fill-color":Fe,"fill-opacity":.75},filter:nt})}else st.addLayer({id:lh,type:"line",source:Jo,"source-layer":vc,paint:{"line-color":"#2c3e50","line-width":.5},filter:nt});st.addLayer({id:`${lh}-outline`,type:"line",source:Jo,"source-layer":vc,paint:{"line-color":"#2c3e50","line-width":.5},filter:nt})}if(qt.length>0){const ft=(await Promise.all(qt.map(Fe=>Fg(F,C,Fe,Ye,D)))).filter(Fe=>Fe!==null&&Fe.bbox);if(ft.length>0){let Fe=1/0,Lt=1/0,et=-1/0,ot=-1/0;ft.forEach(zt=>{zt&&zt.bbox&&(Fe=Math.min(Fe,zt.bbox[0]),Lt=Math.min(Lt,zt.bbox[1]),et=Math.max(et,zt.bbox[2]),ot=Math.max(ot,zt.bbox[3]))});const Je=[[Fe,Lt],[et,ot]];st.fitBounds(Je,{padding:50,duration:0})}else console.warn(`No se pudieron encontrar bboxes para los IDs: ${qt.join(", ")}`)}}catch(Ue){console.error("Error cargando datos en el mapa:",Ue),di(`Error cargando datos: ${Ue instanceof Error?Ue.message:String(Ue)}`)}}),st.on("error",Ue=>{var ct;console.error("Error del mapa:",Ue),di(`Error del mapa: ${((ct=Ue.error)==null?void 0:ct.message)||"Error desconocido"}`)})}catch(he){console.error("Error inicializando mapa:",he),di(`Error inicializando: ${he instanceof Error?he.message:String(he)}`)}})(),()=>{ht.current&&(ht.current.remove(),ht.current=null),Bd.removeProtocol("pmtiles")}},[F,C,D,$,Q,ue,P,c,at,je,Ye,Oe,At,Qe,ge,ei]);const Mi={width:typeof le=="number"?`${le}px`:le,height:typeof Pe=="number"?`${Pe}px`:Pe,position:"relative"};return Ar.jsxs("div",{style:Mi,children:[Ar.jsx("div",{ref:Dt,style:{width:"100%",height:"100%"}}),ri&&Ar.jsx("div",{style:{position:"absolute",top:10,left:10,right:10,background:"rgba(231, 76, 60, 0.9)",color:"white",padding:"10px",borderRadius:"4px",fontSize:"12px",zIndex:1e3},children:ri})]})};Br.MapaPMTiles=jg,Object.defineProperty(Br,Symbol.toStringTag,{value:"Module"})}));
823
823
  //# sourceMappingURL=geo-ui.umd.cjs.map