@datosgeo-atdt/geo-ui 0.2.3 → 0.3.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.
- package/README.md +1 -1
- package/dist/geo-ui.js +1 -1
- package/dist/geo-ui.js.map +1 -1
- package/dist/geo-ui.umd.cjs +1 -1
- package/dist/geo-ui.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/geo-ui.umd.cjs
CHANGED
|
@@ -819,5 +819,5 @@ License: MIT
|
|
|
819
819
|
`&&(De=`
|
|
820
820
|
`);var Ge=0,Wt=!1;this.parse=function(ht,_t,tt){if(typeof ht!="string")throw new Error("Input must be a string");var Jt=ht.length,St=pe.length,qt=De.length,gi=Ne.length,lt=dt($e),Ct=[],jt=[],ct=[],Bt=Ge=0;if(!ht)return Di();if(Tt||Tt!==!1&&ht.indexOf(rt)===-1){for(var ni=ht.split(De),yt=0;yt<ni.length;yt++){if(ct=ni[yt],Ge+=ct.length,yt!==ni.length-1)Ge+=De.length;else if(tt)return Di();if(!Ne||ct.substring(0,gi)!==Ne){if(lt){if(Ct=[],mr(ct.split(pe)),vi(),Wt)return Di()}else mr(ct.split(pe));if(ot&&ot<=yt)return Ct=Ct.slice(0,ot),Di(!0)}}return Di()}for(var Lt=ht.indexOf(pe,Ge),xt=ht.indexOf(De,Ge),Gt=new RegExp(ge(Et)+ge(rt),"g"),pt=ht.indexOf(rt,Ge);;)if(ht[Ge]===rt)for(pt=Ge,Ge++;;){if((pt=ht.indexOf(rt,pt+1))===-1)return tt||jt.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:Ct.length,index:Ge}),Oi();if(pt===Jt-1)return Oi(ht.substring(Ge,pt).replace(Gt,rt));if(rt===Et&&ht[pt+1]===Et)pt++;else if(rt===Et||pt===0||ht[pt-1]!==Et){Lt!==-1&&Lt<pt+1&&(Lt=ht.indexOf(pe,pt+1));var Xt=gr((xt=xt!==-1&&xt<pt+1?ht.indexOf(De,pt+1):xt)===-1?Lt:Math.min(Lt,xt));if(ht.substr(pt+1+Xt,St)===pe){ct.push(ht.substring(Ge,pt).replace(Gt,rt)),ht[Ge=pt+1+Xt+St]!==rt&&(pt=ht.indexOf(rt,Ge)),Lt=ht.indexOf(pe,Ge),xt=ht.indexOf(De,Ge);break}if(Xt=gr(xt),ht.substring(pt+1+Xt,pt+1+Xt+qt)===De){if(ct.push(ht.substring(Ge,pt).replace(Gt,rt)),Or(pt+1+Xt+qt),Lt=ht.indexOf(pe,Ge),pt=ht.indexOf(rt,Ge),lt&&(vi(),Wt))return Di();if(ot&&Ct.length>=ot)return Di(!0);break}jt.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:Ct.length,index:Ge}),pt++}}else if(Ne&&ct.length===0&&ht.substring(Ge,Ge+gi)===Ne){if(xt===-1)return Di();Ge=xt+qt,xt=ht.indexOf(De,Ge),Lt=ht.indexOf(pe,Ge)}else if(Lt!==-1&&(Lt<xt||xt===-1))ct.push(ht.substring(Ge,Lt)),Ge=Lt+St,Lt=ht.indexOf(pe,Ge);else{if(xt===-1)break;if(ct.push(ht.substring(Ge,xt)),Or(xt+qt),lt&&(vi(),Wt))return Di();if(ot&&Ct.length>=ot)return Di(!0)}return Oi();function mr(ce){Ct.push(ce),Bt=Ge}function gr(ce){var B=0;return B=ce!==-1&&(ce=ht.substring(pt+1,ce))&&ce.trim()===""?ce.length:B}function Oi(ce){return tt||(ce===void 0&&(ce=ht.substring(Ge)),ct.push(ce),Ge=Jt,mr(ct),lt&&vi()),Di()}function Or(ce){Ge=ce,mr(ct),ct=[],xt=ht.indexOf(De,Ge)}function Di(ce){if(he.header&&!_t&&Ct.length&&!Vt){var B=Ct[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=dt(he.transformHeader)?he.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,(Ft=Ft===null?{}:Ft)[de]=fe}else O[fe]=1,B[ne]=fe;U.add(fe)}re&&console.warn("Duplicate headers found and renamed."),Vt=!0}return{data:Ct,errors:jt,meta:{delimiter:pe,linebreak:De,aborted:Wt,truncated:!!ce,cursor:Bt+(_t||0),renamedHeaders:Ft}}}function vi(){$e(Di()),Ct=[],jt=[]}},this.abort=function(){Wt=!0},this.getCharIndex=function(){return Ge}}function Rt(he){var pe=he.data,De=c[pe.workerId],Ne=!1;if(pe.error)De.userError(pe.error,pe.file);else if(pe.results&&pe.results.data){var $e={abort:function(){Ne=!0,at(pe.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:mi,resume:mi};if(dt(De.userStep)){for(var ot=0;ot<pe.results.data.length&&(De.userStep({data:pe.results.data[ot],errors:pe.results.errors,meta:pe.results.meta},$e),!Ne);ot++);delete pe.results}else dt(De.userChunk)&&(De.userChunk(pe.results,$e,pe.file),delete pe.results)}pe.finished&&!Ne&&at(pe.workerId,pe.results)}function at(he,pe){var De=c[he];dt(De.userComplete)&&De.userComplete(pe),De.terminate(),delete c[he]}function mi(){throw new Error("Not implemented.")}function ti(he){if(typeof he!="object"||he===null)return he;var pe,De=Array.isArray(he)?[]:{};for(pe in he)De[pe]=ti(he[pe]);return De}function Mi(he,pe){return function(){he.apply(pe,arguments)}}function dt(he){return typeof he=="function"}return Pe.parse=function(he,pe){var De=(pe=pe||{}).dynamicTyping||!1;if(dt(De)&&(pe.dynamicTypingFunction=De,De={}),pe.dynamicTyping=De,pe.transform=!!dt(pe.transform)&&pe.transform,!pe.worker||!Pe.WORKERS_SUPPORTED)return De=null,Pe.NODE_STREAM_INPUT,typeof he=="string"?(he=(Ne=>Ne.charCodeAt(0)!==65279?Ne:Ne.slice(1))(he),De=new(pe.download?Ve:nt)(pe)):he.readable===!0&&dt(he.read)&&dt(he.on)?De=new Dt(pe):($.File&&he instanceof File||he instanceof Object)&&(De=new Ye(pe)),De.stream(he);(De=(()=>{var Ne;return!!Pe.WORKERS_SUPPORTED&&(Ne=(()=>{var $e=$.URL||$.webkitURL||null,ot=D.toString();return Pe.BLOB_URL||(Pe.BLOB_URL=$e.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; ","(",ot,")();"],{type:"text/javascript"})))})(),(Ne=new $.Worker(Ne)).onmessage=Rt,Ne.id=le++,c[Ne.id]=Ne)})()).userStep=pe.step,De.userChunk=pe.chunk,De.userComplete=pe.complete,De.userError=pe.error,pe.step=dt(pe.step),pe.chunk=dt(pe.chunk),pe.complete=dt(pe.complete),pe.error=dt(pe.error),delete pe.worker,De.postMessage({input:he,config:pe,workerId:De.id})},Pe.unparse=function(he,pe){var De=!1,Ne=!0,$e=",",ot=`\r
|
|
821
821
|
`,Tt='"',Ft=Tt+Tt,Vt=!1,rt=null,Et=!1,Ge=((()=>{if(typeof pe=="object"){if(typeof pe.delimiter!="string"||Pe.BAD_DELIMITERS.filter(function(_t){return pe.delimiter.indexOf(_t)!==-1}).length||($e=pe.delimiter),typeof pe.quotes!="boolean"&&typeof pe.quotes!="function"&&!Array.isArray(pe.quotes)||(De=pe.quotes),typeof pe.skipEmptyLines!="boolean"&&typeof pe.skipEmptyLines!="string"||(Vt=pe.skipEmptyLines),typeof pe.newline=="string"&&(ot=pe.newline),typeof pe.quoteChar=="string"&&(Tt=pe.quoteChar),typeof pe.header=="boolean"&&(Ne=pe.header),Array.isArray(pe.columns)){if(pe.columns.length===0)throw new Error("Option columns is empty");rt=pe.columns}pe.escapeChar!==void 0&&(Ft=pe.escapeChar+Tt),pe.escapeFormulae instanceof RegExp?Et=pe.escapeFormulae:typeof pe.escapeFormulae=="boolean"&&pe.escapeFormulae&&(Et=/^[=+\-@\t\r].*$/)}})(),new RegExp(ge(Tt),"g"));if(typeof he=="string"&&(he=JSON.parse(he)),Array.isArray(he)){if(!he.length||Array.isArray(he[0]))return Wt(null,he,Vt);if(typeof he[0]=="object")return Wt(rt||Object.keys(he[0]),he,Vt)}else if(typeof he=="object")return typeof he.data=="string"&&(he.data=JSON.parse(he.data)),Array.isArray(he.data)&&(he.fields||(he.fields=he.meta&&he.meta.fields||rt),he.fields||(he.fields=Array.isArray(he.data[0])?he.fields:typeof he.data[0]=="object"?Object.keys(he.data[0]):[]),Array.isArray(he.data[0])||typeof he.data[0]=="object"||(he.data=[he.data])),Wt(he.fields||[],he.data||[],Vt);throw new Error("Unable to serialize unrecognized input");function Wt(_t,tt,Jt){var St="",qt=(typeof _t=="string"&&(_t=JSON.parse(_t)),typeof tt=="string"&&(tt=JSON.parse(tt)),Array.isArray(_t)&&0<_t.length),gi=!Array.isArray(tt[0]);if(qt&&Ne){for(var lt=0;lt<_t.length;lt++)0<lt&&(St+=$e),St+=ht(_t[lt],lt);0<tt.length&&(St+=ot)}for(var Ct=0;Ct<tt.length;Ct++){var jt=(qt?_t:tt[Ct]).length,ct=!1,Bt=qt?Object.keys(tt[Ct]).length===0:tt[Ct].length===0;if(Jt&&!qt&&(ct=Jt==="greedy"?tt[Ct].join("").trim()==="":tt[Ct].length===1&&tt[Ct][0].length===0),Jt==="greedy"&&qt){for(var ni=[],yt=0;yt<jt;yt++){var Lt=gi?_t[yt]:yt;ni.push(tt[Ct][Lt])}ct=ni.join("").trim()===""}if(!ct){for(var xt=0;xt<jt;xt++){0<xt&&!Bt&&(St+=$e);var Gt=qt&&gi?_t[xt]:xt;St+=ht(tt[Ct][Gt],xt)}Ct<tt.length-1&&(!Jt||0<jt&&!Bt)&&(St+=ot)}}return St}function ht(_t,tt){var Jt,St;return _t==null?"":_t.constructor===Date?JSON.stringify(_t).slice(1,25):(St=!1,Et&&typeof _t=="string"&&Et.test(_t)&&(_t="'"+_t,St=!0),Jt=_t.toString().replace(Ge,Ft),(St=St||De===!0||typeof De=="function"&&De(_t,tt)||Array.isArray(De)&&De[tt]||((qt,gi)=>{for(var lt=0;lt<gi.length;lt++)if(-1<qt.indexOf(gi[lt]))return!0;return!1})(Jt,Pe.BAD_DELIMITERS)||-1<Jt.indexOf($e)||Jt.charAt(0)===" "||Jt.charAt(Jt.length-1)===" ")?Tt+Jt+Tt:Jt)}},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=Kt,Pe.ParserHandle=Je,Pe.NetworkStreamer=Ve,Pe.FileStreamer=Ye,Pe.StringStreamer=nt,Pe.ReadableStreamStreamer=Dt,$.jQuery&&((Q=$.jQuery).fn.parse=function(he){var pe=he.config||{},De=[];return this.each(function(ot){if(!(Q(this).prop("tagName").toUpperCase()==="INPUT"&&Q(this).attr("type").toLowerCase()==="file"&&$.FileReader)||!this.files||this.files.length===0)return!0;for(var Tt=0;Tt<this.files.length;Tt++)De.push({file:this.files[Tt],inputElem:this,instanceConfig:Q.extend({},pe)})}),Ne(),this;function Ne(){if(De.length===0)dt(he.complete)&&he.complete();else{var ot,Tt,Ft,Vt,rt=De[0];if(dt(he.before)){var Et=he.before(rt.file,rt.inputElem);if(typeof Et=="object"){if(Et.action==="abort")return ot="AbortError",Tt=rt.file,Ft=rt.inputElem,Vt=Et.reason,void(dt(he.error)&&he.error({name:ot},Tt,Ft,Vt));if(Et.action==="skip")return void $e();typeof Et.config=="object"&&(rt.instanceConfig=Q.extend(rt.instanceConfig,Et.config))}else if(Et==="skip")return void $e()}var Ge=rt.instanceConfig.complete;rt.instanceConfig.complete=function(Wt){dt(Ge)&&Ge(Wt,rt.file,rt.inputElem),$e()},Pe.parse(rt.file,rt.instanceConfig)}}function $e(){De.splice(0,1),Ne()}}),P&&($.onmessage=function(he){he=he.data,Pe.WORKER_ID===void 0&&he&&(Pe.WORKER_ID=he.workerId),typeof he.input=="string"?$.postMessage({workerId:Pe.WORKER_ID,results:Pe.parse(he.input,he.config),finished:!0}):($.File&&he.input instanceof File||he.input instanceof Object)&&(he=Pe.parse(he.input,he.config))&&$.postMessage({workerId:Pe.WORKER_ID,results:he,finished:!0})}),(Ve.prototype=Object.create(Be.prototype)).constructor=Ve,(Ye.prototype=Object.create(Be.prototype)).constructor=Ye,(nt.prototype=Object.create(nt.prototype)).constructor=nt,(Dt.prototype=Object.create(Be.prototype)).constructor=Dt,Pe})})(mc)),mc.exports}var eg=Qm();const Qd=Ad(eg);async function tg(F,C,D){return new Promise(($,Q)=>{Qd.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 Be=Pe[C],Ve=Pe[D];if(Be!=null){const Ye=parseFloat(Ve),nt=isNaN(Ye)?Ve:Ye;le.set(String(Be),nt)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}async function ig(F,C,D){return new Promise(($,Q)=>{Qd.parse(F,{header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Be=Pe[C],Ve=Pe[D];if(Be!=null){const Ye=parseFloat(Ve),nt=isNaN(Ye)?Ve:Ye;le.set(String(Be),nt)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}function rg(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,Be=0,Ve=0;for(let Ye=1;Ye<=le;Ye++){const nt=le-Ye+1,Dt=D[nt-1];Be+=Dt*Dt,Pe+=Dt,Ve++;const Je=Be-Pe*Pe/Ve,ge=nt-1;if(ge!==0)for(let Kt=2;Kt<=C;Kt++)ue[le][Kt]>=Je+ue[ge][Kt-1]&&(Q[le][Kt]=nt,ue[le][Kt]=Je+ue[ge][Kt-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 ng(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)),Be=Math.round(ue.g+le*(P.g-ue.g)),Ve=Math.round(ue.b+le*(P.b-ue.b));$.push(`rgb(${Pe}, ${Be}, ${Ve})`)}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 ep{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(sg,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,Be=-1/0;for(;C.pos<D;){if(Q<=0){const Ve=C.readVarint();$=Ve&7,Q=Ve>>3}if(Q--,$===1||$===2)ue+=C.readSVarint(),P+=C.readSVarint(),ue<c&&(c=ue),ue>le&&(le=ue),P<Pe&&(Pe=P),P>Be&&(Be=P);else if($!==7)throw new Error(`unknown command ${$}`)}return[c,Pe,le,Be]}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 Be;if(this.type===1){const Ye=[];for(const Dt of c)Ye.push(Dt[0]);const nt=Pe(Ye);Be=Ye.length===1?{type:"Point",coordinates:nt[0]}:{type:"MultiPoint",coordinates:nt}}else if(this.type===2){const Ye=c.map(Pe);Be=Ye.length===1?{type:"LineString",coordinates:Ye[0]}:{type:"MultiLineString",coordinates:Ye}}else if(this.type===3){const Ye=og(c),nt=[];for(const Dt of Ye)nt.push(Dt.map(Pe));Be=nt.length===1?{type:"Polygon",coordinates:nt[0]}:{type:"MultiPolygon",coordinates:nt}}else throw new Error("unknown feature type");const Ve={type:"Feature",geometry:Be,properties:this.properties};return this.id!=null&&(Ve.id=this.id),Ve}}ep.types=["Unknown","Point","LineString","Polygon"];function sg(F,C,D){F===1?C.id=D.readVarint():F===2?ag(D,C):F===3?C.type=D.readVarint():F===4&&(C._geometry=D.pos)}function ag(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 og(F){const C=F.length;if(C<=1)return[F];const D=[];let $,Q;for(let ue=0;ue<C;ue++){const P=lg(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 lg(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 cg{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(ug,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 ep(this._pbf,D,this.extent,this._keys,this._values)}}function ug(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(hg(D))}function hg(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 dg{constructor(C,D){this.layers=C.readFields(pg,{},D)}}function pg(F,C,D){if(F===3){const $=new cg(D,D.readVarint()+D.pos);$.length&&(C[$.name]=$)}}const nh=65536*65536,tp=1/nh,fg=12,ip=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),sh=0,gc=1,Ko=2,_c=5;class mg{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)*nh;return this.pos+=8,C}readSFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*nh;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,gg($,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>=fg&&ip?ip.decode(this.buf.subarray(D,C)):Cg(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===sh)for(;this.buf[this.pos++]>127;);else if(D===Ko)this.pos=this.readVarint()+this.pos;else if(D===_c)this.pos+=4;else if(D===gc)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*tp),!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*tp),!0),this.pos+=8}writeVarint(C){if(C=+C||0,C>268435455||C<0){_g(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=Ag(this.buf,C,this.pos);const $=this.pos-D;$>=128&&rp(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&&rp($,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,vg,D)}writePackedSVarint(C,D){D.length&&this.writeMessage(C,bg,D)}writePackedBoolean(C,D){D.length&&this.writeMessage(C,Sg,D)}writePackedFloat(C,D){D.length&&this.writeMessage(C,wg,D)}writePackedDouble(C,D){D.length&&this.writeMessage(C,Tg,D)}writePackedFixed32(C,D){D.length&&this.writeMessage(C,Pg,D)}writePackedSFixed32(C,D){D.length&&this.writeMessage(C,Mg,D)}writePackedFixed64(C,D){D.length&&this.writeMessage(C,Ig,D)}writePackedSFixed64(C,D){D.length&&this.writeMessage(C,Eg,D)}writeBytesField(C,D){this.writeTag(C,Ko),this.writeBytes(D)}writeFixed32Field(C,D){this.writeTag(C,_c),this.writeFixed32(D)}writeSFixed32Field(C,D){this.writeTag(C,_c),this.writeSFixed32(D)}writeFixed64Field(C,D){this.writeTag(C,gc),this.writeFixed64(D)}writeSFixed64Field(C,D){this.writeTag(C,gc),this.writeSFixed64(D)}writeVarintField(C,D){this.writeTag(C,sh),this.writeVarint(D)}writeSVarintField(C,D){this.writeTag(C,sh),this.writeSVarint(D)}writeStringField(C,D){this.writeTag(C,Ko),this.writeString(D)}writeFloatField(C,D){this.writeTag(C,_c),this.writeFloat(D)}writeDoubleField(C,D){this.writeTag(C,gc),this.writeDouble(D)}writeBooleanField(C,D){this.writeVarintField(C,+D)}}function gg(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 _g(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),yg(D,$,C),xg($,C)}function yg(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 xg(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 rp(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 vg(F,C){for(let D=0;D<F.length;D++)C.writeVarint(F[D])}function bg(F,C){for(let D=0;D<F.length;D++)C.writeSVarint(F[D])}function wg(F,C){for(let D=0;D<F.length;D++)C.writeFloat(F[D])}function Tg(F,C){for(let D=0;D<F.length;D++)C.writeDouble(F[D])}function Sg(F,C){for(let D=0;D<F.length;D++)C.writeBoolean(F[D])}function Pg(F,C){for(let D=0;D<F.length;D++)C.writeFixed32(F[D])}function Mg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed32(F[D])}function Ig(F,C){for(let D=0;D<F.length;D++)C.writeFixed64(F[D])}function Eg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed64(F[D])}function Cg(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,Be;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],Be=F[Q+3],(le&192)===128&&(Pe&192)===128&&(Be&192)===128&&(P=(ue&15)<<18|(le&63)<<12|(Pe&63)<<6|Be&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 Ag(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 Dg(F,C,D,$="bbox",Q){try{const ue=new rh(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 Be=0;Be<le;Be++)try{const Ve=await ue.getZxy(c,Pe,Be);if(!Ve||!Ve.data)continue;const nt=new dg(new mg(Ve.data)).layers[C];if(!nt)continue;for(let Dt=0;Dt<nt.length;Dt++){const Je=nt.feature(Dt),ge=Je.properties,Kt=String(Q?ge[Q]:Je.id);if(Kt===String(D)){let Rt=null;if(ge[$]){const at=ge[$];if(typeof at=="string")try{const mi=JSON.parse(at);Array.isArray(mi)&&mi.length===4&&(Rt=mi)}catch{const mi=at.split(",").map(ti=>parseFloat(ti.trim()));mi.length===4&&mi.every(ti=>!isNaN(ti))&&(Rt=mi)}else Array.isArray(at)&&at.length===4&&(Rt=at)}if(!Rt){const at=Je.loadGeometry();let mi=1/0,ti=1/0,Mi=-1/0,dt=-1/0;at.forEach(Ft=>{Ft.forEach(Vt=>{mi=Math.min(mi,Vt.x),ti=Math.min(ti,Vt.y),Mi=Math.max(Mi,Vt.x),dt=Math.max(dt,Vt.y)})});const he=4096,pe=(Pe+mi/he)/le*360-180,De=(Pe+Mi/he)/le*360-180,Ne=Math.PI-2*Math.PI*(Be+ti/he)/le,$e=Math.PI-2*Math.PI*(Be+dt/he)/le,ot=180/Math.PI*Math.atan(.5*(Math.exp(Ne)-Math.exp(-Ne))),Tt=180/Math.PI*Math.atan(.5*(Math.exp($e)-Math.exp(-$e)));Rt=[Math.min(pe,De),Math.min(ot,Tt),Math.max(pe,De),Math.max(ot,Tt)]}return{id:Kt,bbox:Rt,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 yc="pmtiles-source",np="pmtiles-fill",zg="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/componente/entidad.pmtiles",kg="entidad",Rg="CVE_ENT",Fg=({pmtilesUrl:F=zg,sourceLayer:C=kg,joinGeomKey:D=Rg,csvUrl:$,csvFile:Q,joinCsvKey:ue,field:P="valor",mode:c="boolean",width:le="100%",height:Pe=520,initialView:Be,fitToIds:Ve,bboxField:Ye="bbox",jenksK:nt=5})=>{const Dt=Ln.useRef(null),Je=Ln.useRef(null),[ge,Kt]=Ln.useState(null);Ln.useEffect(()=>{if(!Dt.current)return;if(!$&&!Q){Kt("Debe proporcionar csvUrl o csvFile"),console.error("MapaPMTiles: Debe proporcionar csvUrl o csvFile");return}let at=null;return(async()=>{try{const ti=new Um;kd.addProtocol("pmtiles",ti.tile);const Mi=(Be==null?void 0:Be.center)||[-102,23],dt=(Be==null?void 0:Be.zoom)||4;at=new zd.Map({container:Dt.current,style:{version:8,sources:{},layers:[]},center:Mi,zoom:dt,boxZoom:!1,doubleClickZoom:!1,dragRotate:!1,keyboard:!1,scrollZoom:!1,touchPitch:!1,touchZoomRotate:!0,dragPan:!1,maxBounds:void 0}),Je.current=at,at.on("load",async()=>{if(at)try{at.addSource(yc,{type:"vector",url:`pmtiles://${F}`,promoteId:D});const he=ue||D,pe=Q?await ig(Q,he,P):await tg($,he,P);pe.joinMap.forEach((ot,Tt)=>{try{at.setFeatureState({source:yc,sourceLayer:C,id:Tt},{value:ot})}catch(Ft){console.warn(`Error setting feature state for key ${Tt}:`,Ft)}});let De;if(c==="boolean")De=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const ot=Array.from(pe.joinMap.values()).filter(Tt=>typeof Tt=="number").map(Tt=>Tt);if(ot.length===0)console.warn("No hay valores numéricos para clasificación Jenks"),De=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"];else{const Tt=rg(ot,nt),Ft=Tt.length-1,Vt=ng("#f3f3f3","#66827f",Ft),rt=["step",["feature-state","value"],Vt[0]];for(let Et=1;Et<Ft;Et++)rt.push(Tt[Et]),rt.push(Vt[Et]);De=rt}}const Ne=Ve?Array.isArray(Ve)?Ve:[Ve]:[];let $e;if(Ne.length>0&&($e=["in",["get",D],["literal",Ne]]),at.addLayer({id:np,type:"fill",source:yc,"source-layer":C,paint:{"fill-color":De,"fill-opacity":.75},filter:$e}),at.addLayer({id:`${np}-outline`,type:"line",source:yc,"source-layer":C,paint:{"line-color":"#2c3e50","line-width":.5},filter:$e}),Ne.length>0){const Tt=(await Promise.all(Ne.map(Ft=>Dg(F,C,Ft,Ye,D)))).filter(Ft=>Ft!==null&&Ft.bbox);if(Tt.length>0){let Ft=1/0,Vt=1/0,rt=-1/0,Et=-1/0;Tt.forEach(Wt=>{Wt&&Wt.bbox&&(Ft=Math.min(Ft,Wt.bbox[0]),Vt=Math.min(Vt,Wt.bbox[1]),rt=Math.max(rt,Wt.bbox[2]),Et=Math.max(Et,Wt.bbox[3]))});const Ge=[[Ft,Vt],[rt,Et]];at.fitBounds(Ge,{padding:50,duration:0})}else console.warn(`No se pudieron encontrar bboxes para los IDs: ${Ne.join(", ")}`)}}catch(he){console.error("Error cargando datos en el mapa:",he),Kt(`Error cargando datos: ${he instanceof Error?he.message:String(he)}`)}}),at.on("error",he=>{var pe;console.error("Error del mapa:",he),Kt(`Error del mapa: ${((pe=he.error)==null?void 0:pe.message)||"Error desconocido"}`)})}catch(ti){console.error("Error inicializando mapa:",ti),Kt(`Error inicializando: ${ti instanceof Error?ti.message:String(ti)}`)}})(),()=>{Je.current&&(Je.current.remove(),Je.current=null),kd.removeProtocol("pmtiles")}},[F,C,D,$,Q,ue,P,c,nt,Ve,Ye,Be]);const Rt={width:typeof le=="number"?`${le}px`:le,height:typeof Pe=="number"?`${Pe}px`:Pe,position:"relative"};return Ar.jsxs("div",{style:Rt,children:[Ar.jsx("div",{ref:Dt,style:{width:"100%",height:"100%"}}),ge&&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:ge})]})};Br.MapaPMTiles=Fg,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=Kt,Pe.ParserHandle=Je,Pe.NetworkStreamer=Ve,Pe.FileStreamer=Ye,Pe.StringStreamer=nt,Pe.ReadableStreamStreamer=Dt,$.jQuery&&((Q=$.jQuery).fn.parse=function(he){var pe=he.config||{},De=[];return this.each(function(ot){if(!(Q(this).prop("tagName").toUpperCase()==="INPUT"&&Q(this).attr("type").toLowerCase()==="file"&&$.FileReader)||!this.files||this.files.length===0)return!0;for(var Tt=0;Tt<this.files.length;Tt++)De.push({file:this.files[Tt],inputElem:this,instanceConfig:Q.extend({},pe)})}),Ne(),this;function Ne(){if(De.length===0)dt(he.complete)&&he.complete();else{var ot,Tt,Ft,Vt,rt=De[0];if(dt(he.before)){var Et=he.before(rt.file,rt.inputElem);if(typeof Et=="object"){if(Et.action==="abort")return ot="AbortError",Tt=rt.file,Ft=rt.inputElem,Vt=Et.reason,void(dt(he.error)&&he.error({name:ot},Tt,Ft,Vt));if(Et.action==="skip")return void $e();typeof Et.config=="object"&&(rt.instanceConfig=Q.extend(rt.instanceConfig,Et.config))}else if(Et==="skip")return void $e()}var Ge=rt.instanceConfig.complete;rt.instanceConfig.complete=function(Wt){dt(Ge)&&Ge(Wt,rt.file,rt.inputElem),$e()},Pe.parse(rt.file,rt.instanceConfig)}}function $e(){De.splice(0,1),Ne()}}),P&&($.onmessage=function(he){he=he.data,Pe.WORKER_ID===void 0&&he&&(Pe.WORKER_ID=he.workerId),typeof he.input=="string"?$.postMessage({workerId:Pe.WORKER_ID,results:Pe.parse(he.input,he.config),finished:!0}):($.File&&he.input instanceof File||he.input instanceof Object)&&(he=Pe.parse(he.input,he.config))&&$.postMessage({workerId:Pe.WORKER_ID,results:he,finished:!0})}),(Ve.prototype=Object.create(Be.prototype)).constructor=Ve,(Ye.prototype=Object.create(Be.prototype)).constructor=Ye,(nt.prototype=Object.create(nt.prototype)).constructor=nt,(Dt.prototype=Object.create(Be.prototype)).constructor=Dt,Pe})})(mc)),mc.exports}var eg=Qm();const Qd=Ad(eg);async function tg(F,C,D){return new Promise(($,Q)=>{Qd.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 Be=Pe[C],Ve=Pe[D];if(Be!=null){const Ye=parseFloat(Ve),nt=isNaN(Ye)?Ve:Ye;le.set(String(Be),nt)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}async function ig(F,C,D){return new Promise(($,Q)=>{Qd.parse(F,{header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Be=Pe[C],Ve=Pe[D];if(Be!=null){const Ye=parseFloat(Ve),nt=isNaN(Ye)?Ve:Ye;le.set(String(Be),nt)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}function rg(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,Be=0,Ve=0;for(let Ye=1;Ye<=le;Ye++){const nt=le-Ye+1,Dt=D[nt-1];Be+=Dt*Dt,Pe+=Dt,Ve++;const Je=Be-Pe*Pe/Ve,ge=nt-1;if(ge!==0)for(let Kt=2;Kt<=C;Kt++)ue[le][Kt]>=Je+ue[ge][Kt-1]&&(Q[le][Kt]=nt,ue[le][Kt]=Je+ue[ge][Kt-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 ng(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)),Be=Math.round(ue.g+le*(P.g-ue.g)),Ve=Math.round(ue.b+le*(P.b-ue.b));$.push(`rgb(${Pe}, ${Be}, ${Ve})`)}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 ep{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(sg,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,Be=-1/0;for(;C.pos<D;){if(Q<=0){const Ve=C.readVarint();$=Ve&7,Q=Ve>>3}if(Q--,$===1||$===2)ue+=C.readSVarint(),P+=C.readSVarint(),ue<c&&(c=ue),ue>le&&(le=ue),P<Pe&&(Pe=P),P>Be&&(Be=P);else if($!==7)throw new Error(`unknown command ${$}`)}return[c,Pe,le,Be]}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 Be;if(this.type===1){const Ye=[];for(const Dt of c)Ye.push(Dt[0]);const nt=Pe(Ye);Be=Ye.length===1?{type:"Point",coordinates:nt[0]}:{type:"MultiPoint",coordinates:nt}}else if(this.type===2){const Ye=c.map(Pe);Be=Ye.length===1?{type:"LineString",coordinates:Ye[0]}:{type:"MultiLineString",coordinates:Ye}}else if(this.type===3){const Ye=og(c),nt=[];for(const Dt of Ye)nt.push(Dt.map(Pe));Be=nt.length===1?{type:"Polygon",coordinates:nt[0]}:{type:"MultiPolygon",coordinates:nt}}else throw new Error("unknown feature type");const Ve={type:"Feature",geometry:Be,properties:this.properties};return this.id!=null&&(Ve.id=this.id),Ve}}ep.types=["Unknown","Point","LineString","Polygon"];function sg(F,C,D){F===1?C.id=D.readVarint():F===2?ag(D,C):F===3?C.type=D.readVarint():F===4&&(C._geometry=D.pos)}function ag(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 og(F){const C=F.length;if(C<=1)return[F];const D=[];let $,Q;for(let ue=0;ue<C;ue++){const P=lg(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 lg(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 cg{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(ug,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 ep(this._pbf,D,this.extent,this._keys,this._values)}}function ug(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(hg(D))}function hg(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 dg{constructor(C,D){this.layers=C.readFields(pg,{},D)}}function pg(F,C,D){if(F===3){const $=new cg(D,D.readVarint()+D.pos);$.length&&(C[$.name]=$)}}const nh=65536*65536,tp=1/nh,fg=12,ip=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),sh=0,gc=1,Ko=2,_c=5;class mg{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)*nh;return this.pos+=8,C}readSFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*nh;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,gg($,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>=fg&&ip?ip.decode(this.buf.subarray(D,C)):Cg(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===sh)for(;this.buf[this.pos++]>127;);else if(D===Ko)this.pos=this.readVarint()+this.pos;else if(D===_c)this.pos+=4;else if(D===gc)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*tp),!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*tp),!0),this.pos+=8}writeVarint(C){if(C=+C||0,C>268435455||C<0){_g(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=Ag(this.buf,C,this.pos);const $=this.pos-D;$>=128&&rp(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&&rp($,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,vg,D)}writePackedSVarint(C,D){D.length&&this.writeMessage(C,bg,D)}writePackedBoolean(C,D){D.length&&this.writeMessage(C,Sg,D)}writePackedFloat(C,D){D.length&&this.writeMessage(C,wg,D)}writePackedDouble(C,D){D.length&&this.writeMessage(C,Tg,D)}writePackedFixed32(C,D){D.length&&this.writeMessage(C,Pg,D)}writePackedSFixed32(C,D){D.length&&this.writeMessage(C,Mg,D)}writePackedFixed64(C,D){D.length&&this.writeMessage(C,Ig,D)}writePackedSFixed64(C,D){D.length&&this.writeMessage(C,Eg,D)}writeBytesField(C,D){this.writeTag(C,Ko),this.writeBytes(D)}writeFixed32Field(C,D){this.writeTag(C,_c),this.writeFixed32(D)}writeSFixed32Field(C,D){this.writeTag(C,_c),this.writeSFixed32(D)}writeFixed64Field(C,D){this.writeTag(C,gc),this.writeFixed64(D)}writeSFixed64Field(C,D){this.writeTag(C,gc),this.writeSFixed64(D)}writeVarintField(C,D){this.writeTag(C,sh),this.writeVarint(D)}writeSVarintField(C,D){this.writeTag(C,sh),this.writeSVarint(D)}writeStringField(C,D){this.writeTag(C,Ko),this.writeString(D)}writeFloatField(C,D){this.writeTag(C,_c),this.writeFloat(D)}writeDoubleField(C,D){this.writeTag(C,gc),this.writeDouble(D)}writeBooleanField(C,D){this.writeVarintField(C,+D)}}function gg(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 _g(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),yg(D,$,C),xg($,C)}function yg(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 xg(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 rp(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 vg(F,C){for(let D=0;D<F.length;D++)C.writeVarint(F[D])}function bg(F,C){for(let D=0;D<F.length;D++)C.writeSVarint(F[D])}function wg(F,C){for(let D=0;D<F.length;D++)C.writeFloat(F[D])}function Tg(F,C){for(let D=0;D<F.length;D++)C.writeDouble(F[D])}function Sg(F,C){for(let D=0;D<F.length;D++)C.writeBoolean(F[D])}function Pg(F,C){for(let D=0;D<F.length;D++)C.writeFixed32(F[D])}function Mg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed32(F[D])}function Ig(F,C){for(let D=0;D<F.length;D++)C.writeFixed64(F[D])}function Eg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed64(F[D])}function Cg(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,Be;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],Be=F[Q+3],(le&192)===128&&(Pe&192)===128&&(Be&192)===128&&(P=(ue&15)<<18|(le&63)<<12|(Pe&63)<<6|Be&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 Ag(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 Dg(F,C,D,$="bbox",Q){try{const ue=new rh(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 Be=0;Be<le;Be++)try{const Ve=await ue.getZxy(c,Pe,Be);if(!Ve||!Ve.data)continue;const nt=new dg(new mg(Ve.data)).layers[C];if(!nt)continue;for(let Dt=0;Dt<nt.length;Dt++){const Je=nt.feature(Dt),ge=Je.properties,Kt=String(Q?ge[Q]:Je.id);if(Kt===String(D)){let Rt=null;if(ge[$]){const at=ge[$];if(typeof at=="string")try{const mi=JSON.parse(at);Array.isArray(mi)&&mi.length===4&&(Rt=mi)}catch{const mi=at.split(",").map(ti=>parseFloat(ti.trim()));mi.length===4&&mi.every(ti=>!isNaN(ti))&&(Rt=mi)}else Array.isArray(at)&&at.length===4&&(Rt=at)}if(!Rt){const at=Je.loadGeometry();let mi=1/0,ti=1/0,Mi=-1/0,dt=-1/0;at.forEach(Ft=>{Ft.forEach(Vt=>{mi=Math.min(mi,Vt.x),ti=Math.min(ti,Vt.y),Mi=Math.max(Mi,Vt.x),dt=Math.max(dt,Vt.y)})});const he=4096,pe=(Pe+mi/he)/le*360-180,De=(Pe+Mi/he)/le*360-180,Ne=Math.PI-2*Math.PI*(Be+ti/he)/le,$e=Math.PI-2*Math.PI*(Be+dt/he)/le,ot=180/Math.PI*Math.atan(.5*(Math.exp(Ne)-Math.exp(-Ne))),Tt=180/Math.PI*Math.atan(.5*(Math.exp($e)-Math.exp(-$e)));Rt=[Math.min(pe,De),Math.min(ot,Tt),Math.max(pe,De),Math.max(ot,Tt)]}return{id:Kt,bbox:Rt,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 yc="pmtiles-source",np="pmtiles-fill",zg="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/componente/entidad.pmtiles",kg="entidad",Rg="cvegeo",Fg=({pmtilesUrl:F=zg,sourceLayer:C=kg,joinGeomKey:D=Rg,csvUrl:$,csvFile:Q,joinCsvKey:ue,field:P="valor",mode:c="boolean",width:le="100%",height:Pe=520,initialView:Be,fitToIds:Ve,bboxField:Ye="bbox",jenksK:nt=5})=>{const Dt=Ln.useRef(null),Je=Ln.useRef(null),[ge,Kt]=Ln.useState(null);Ln.useEffect(()=>{if(!Dt.current)return;if(!$&&!Q){Kt("Debe proporcionar csvUrl o csvFile"),console.error("MapaPMTiles: Debe proporcionar csvUrl o csvFile");return}let at=null;return(async()=>{try{const ti=new Um;kd.addProtocol("pmtiles",ti.tile);const Mi=(Be==null?void 0:Be.center)||[-102,23],dt=(Be==null?void 0:Be.zoom)||4;at=new zd.Map({container:Dt.current,style:{version:8,sources:{},layers:[]},center:Mi,zoom:dt,boxZoom:!1,doubleClickZoom:!1,dragRotate:!1,keyboard:!1,scrollZoom:!1,touchPitch:!1,touchZoomRotate:!0,dragPan:!1,maxBounds:void 0}),Je.current=at,at.on("load",async()=>{if(at)try{at.addSource(yc,{type:"vector",url:`pmtiles://${F}`,promoteId:D});const he=ue||D,pe=Q?await ig(Q,he,P):await tg($,he,P);pe.joinMap.forEach((ot,Tt)=>{try{at.setFeatureState({source:yc,sourceLayer:C,id:Tt},{value:ot})}catch(Ft){console.warn(`Error setting feature state for key ${Tt}:`,Ft)}});let De;if(c==="boolean")De=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const ot=Array.from(pe.joinMap.values()).filter(Tt=>typeof Tt=="number").map(Tt=>Tt);if(ot.length===0)console.warn("No hay valores numéricos para clasificación Jenks"),De=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"];else{const Tt=rg(ot,nt),Ft=Tt.length-1,Vt=ng("#f3f3f3","#66827f",Ft),rt=["step",["feature-state","value"],Vt[0]];for(let Et=1;Et<Ft;Et++)rt.push(Tt[Et]),rt.push(Vt[Et]);De=rt}}const Ne=Ve?Array.isArray(Ve)?Ve:[Ve]:[];let $e;if(Ne.length>0&&($e=["in",["get",D],["literal",Ne]]),at.addLayer({id:np,type:"fill",source:yc,"source-layer":C,paint:{"fill-color":De,"fill-opacity":.75},filter:$e}),at.addLayer({id:`${np}-outline`,type:"line",source:yc,"source-layer":C,paint:{"line-color":"#2c3e50","line-width":.5},filter:$e}),Ne.length>0){const Tt=(await Promise.all(Ne.map(Ft=>Dg(F,C,Ft,Ye,D)))).filter(Ft=>Ft!==null&&Ft.bbox);if(Tt.length>0){let Ft=1/0,Vt=1/0,rt=-1/0,Et=-1/0;Tt.forEach(Wt=>{Wt&&Wt.bbox&&(Ft=Math.min(Ft,Wt.bbox[0]),Vt=Math.min(Vt,Wt.bbox[1]),rt=Math.max(rt,Wt.bbox[2]),Et=Math.max(Et,Wt.bbox[3]))});const Ge=[[Ft,Vt],[rt,Et]];at.fitBounds(Ge,{padding:50,duration:0})}else console.warn(`No se pudieron encontrar bboxes para los IDs: ${Ne.join(", ")}`)}}catch(he){console.error("Error cargando datos en el mapa:",he),Kt(`Error cargando datos: ${he instanceof Error?he.message:String(he)}`)}}),at.on("error",he=>{var pe;console.error("Error del mapa:",he),Kt(`Error del mapa: ${((pe=he.error)==null?void 0:pe.message)||"Error desconocido"}`)})}catch(ti){console.error("Error inicializando mapa:",ti),Kt(`Error inicializando: ${ti instanceof Error?ti.message:String(ti)}`)}})(),()=>{Je.current&&(Je.current.remove(),Je.current=null),kd.removeProtocol("pmtiles")}},[F,C,D,$,Q,ue,P,c,nt,Ve,Ye,Be]);const Rt={width:typeof le=="number"?`${le}px`:le,height:typeof Pe=="number"?`${Pe}px`:Pe,position:"relative"};return Ar.jsxs("div",{style:Rt,children:[Ar.jsx("div",{ref:Dt,style:{width:"100%",height:"100%"}}),ge&&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:ge})]})};Br.MapaPMTiles=Fg,Object.defineProperty(Br,Symbol.toStringTag,{value:"Module"})}));
|
|
823
823
|
//# sourceMappingURL=geo-ui.umd.cjs.map
|