@datosgeo-atdt/geo-ui 0.11.0 → 0.11.2

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 CHANGED
@@ -651,11 +651,7 @@ import { DataTable } from '@atdt/geo-ui';
651
651
 
652
652
  function App() {
653
653
  return (
654
- <DataTable
655
- csvPath="/alcaldias.csv"
656
- width="600px"
657
- height="400px"
658
- />
654
+ <DataTable csvPath="/alcaldias.csv" />
659
655
  );
660
656
  }
661
657
  ```
@@ -666,6 +662,7 @@ function App() {
666
662
  - Los usa como headers de la tabla
667
663
  - Parsea los datos y los muestra
668
664
  - Formatea números con separadores de miles (1,815,786)
665
+ - Distribuye las columnas equitativamente (50% cada una en este caso)
669
666
 
670
667
  #### Ejemplo 2: Personalizar nombres de columnas
671
668
 
@@ -682,8 +679,6 @@ function App() {
682
679
  { key: 'alcaldia', label: 'Alcaldía', width: '60%' },
683
680
  { key: 'poblacion', label: 'Población Total', width: '40%' }
684
681
  ]}
685
- width="800px"
686
- height="500px"
687
682
  showIndex={true}
688
683
  indexLabel="#"
689
684
  />
@@ -709,34 +704,41 @@ function App() {
709
704
  <DataTable
710
705
  data={datos}
711
706
  columns={[
712
- { key: 'nombre', label: 'Ciudad', width: '50%' },
713
- { key: 'habitantes', label: 'Habitantes', width: '50%' }
707
+ { key: 'nombre', label: 'Ciudad' },
708
+ { key: 'habitantes', label: 'Habitantes' }
714
709
  ]}
715
- width="100%"
716
710
  />
717
711
  );
718
712
  }
719
713
  ```
720
714
 
721
- #### Ejemplo 4: Con índice numérico
715
+ #### Ejemplo 4: Múltiples columnas con distribución automática
722
716
 
723
717
  ```tsx
718
+ // Con 4 columnas, cada una ocupa automáticamente 25% del ancho
724
719
  <DataTable
725
- csvPath="/datos.csv"
720
+ csvPath="/productos.csv"
721
+ columns={[
722
+ { key: 'nombre', label: 'Producto' },
723
+ { key: 'categoria', label: 'Categoría' },
724
+ { key: 'precio', label: 'Precio' },
725
+ { key: 'stock', label: 'Stock' }
726
+ ]}
726
727
  showIndex={true}
727
- indexLabel="#"
728
- width="700px"
729
728
  />
730
729
  ```
731
730
 
732
- #### Ejemplo 5: Tabla responsive
731
+ #### Ejemplo 5: Control manual de anchos de columnas
733
732
 
734
733
  ```tsx
735
- // Se adapta automáticamente a móvil
734
+ // Especifica anchos personalizados cuando necesites distribución no equitativa
736
735
  <DataTable
737
- csvPath="/estadisticas.csv"
738
- width="100%"
739
- height="auto"
736
+ csvPath="/datos.csv"
737
+ columns={[
738
+ { key: 'nombre', label: 'Nombre', width: '50%' },
739
+ { key: 'valor1', label: 'Valor 1', width: '25%' },
740
+ { key: 'valor2', label: 'Valor 2', width: '25%' }
741
+ ]}
740
742
  />
741
743
  ```
742
744
 
@@ -754,8 +756,8 @@ function App() {
754
756
  | Prop | Tipo | Default | Descripción |
755
757
  |------|------|---------|-------------|
756
758
  | `columns` | `DataTableColumn[]` | Auto-detectado | Definición de columnas a mostrar |
757
- | `width` | `string` | `"100%"` | Ancho de la tabla |
758
- | `height` | `string` | `"auto"` | Alto de la tabla |
759
+ | `width` | `string` | Controlado por CSS | Ancho del contenedor (por defecto 50% del viewport en desktop, 100% en móvil) |
760
+ | `height` | `string` | Controlado por CSS | Alto del contenedor (por defecto 100% con scroll interno cuando excede 70vh) |
759
761
  | `className` | `string` | `""` | Clases CSS adicionales |
760
762
  | `showIndex` | `boolean` | `false` | Mostrar columna con índice numérico |
761
763
  | `indexLabel` | `string` | `"#"` | Etiqueta para la columna de índice |
@@ -831,13 +833,16 @@ function App() {
831
833
 
832
834
  #### Ejemplo integrando con MapaPMTiles
833
835
 
836
+ Layout tipo dashboard con mapa y tabla lado a lado:
837
+
834
838
  ```tsx
835
839
  import { MapaPMTiles, DataTable } from '@atdt/geo-ui';
836
840
  import '@atdt/geo-ui/style.css';
837
841
 
838
842
  function App() {
839
843
  return (
840
- <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '20px' }}>
844
+ <div style={{ display: 'flex', width: '100%', height: '100vh' }}>
845
+ {/* Mapa ocupa 50% */}
841
846
  <MapaPMTiles
842
847
  csvPath="/datos_entidades.csv"
843
848
  fitToIds={["09", "15", "14"]}
@@ -845,14 +850,13 @@ function App() {
845
850
  enablePopup={true}
846
851
  />
847
852
 
853
+ {/* DataTable ocupa 50% automáticamente */}
848
854
  <DataTable
849
855
  csvPath="/datos_entidades.csv"
850
856
  columns={[
851
- { key: 'entidad', label: 'Entidad', width: '60%' },
852
- { key: 'valor', label: 'Valor', width: '40%' }
857
+ { key: 'entidad', label: 'Entidad' },
858
+ { key: 'valor', label: 'Valor' }
853
859
  ]}
854
- width="100%"
855
- height="600px"
856
860
  />
857
861
  </div>
858
862
  );
@@ -876,15 +880,23 @@ El componente muestra diferentes estados:
876
880
  3. **Vacío**: "No hay datos para mostrar" si el CSV está vacío
877
881
  4. **Datos**: Tabla renderizada con los datos
878
882
 
879
- ### Responsive
883
+ ### Diseño y Layout
884
+
885
+ El componente está diseñado para integrarse con layouts tipo dashboard:
880
886
 
881
- El componente se adapta automáticamente a diferentes tamaños de pantalla:
887
+ - **Desktop**:
888
+ - Ocupa **50% del ancho** del contenedor padre por defecto
889
+ - Centrado vertical y horizontal
890
+ - Scroll interno cuando el contenido excede **70vh**
891
+ - Headers y celdas con tamaño `1.11vw`
892
+ - Columnas se distribuyen automáticamente usando flexbox
882
893
 
883
- - **Desktop**: Headers y celdas con tamaño `1.11vw`
884
894
  - **Mobile** (≤600px):
895
+ - Ocupa **100% del ancho**
885
896
  - Headers con tamaño `3.5vw`
886
897
  - Celdas con tamaño `4vw`
887
898
  - Padding ajustado para pantallas pequeñas
899
+ - Box shadow más pronunciado
888
900
 
889
901
  ### Personalización de Estilos
890
902
 
package/dist/geo-ui.js CHANGED
@@ -26533,7 +26533,7 @@ const Xo = "pmtiles-source", Ln = "pmtiles-fill", os = "municipios-source", Us =
26533
26533
  ": ",
26534
26534
  /* @__PURE__ */ tr("span", { className: "totales-value", children: fe.value })
26535
26535
  ] }, Bt)) });
26536
- }, gx = "_mainContainer_11ge4_1", _x = "_tableContainer_11ge4_9", yx = "_tableHeader_11ge4_21", xx = "_headerCell_11ge4_37", vx = "_tableBody_11ge4_43", bx = "_tableRow_11ge4_49", wx = "_tableCell_11ge4_70", Tx = "_emptyState_11ge4_76", zr = {
26536
+ }, gx = "_mainContainer_d339g_1", _x = "_tableContainer_d339g_13", yx = "_tableHeader_d339g_26", xx = "_headerCell_d339g_42", vx = "_tableBody_d339g_47", bx = "_tableRow_d339g_51", wx = "_tableCell_d339g_68", Tx = "_emptyState_d339g_73", zr = {
26537
26537
  mainContainer: gx,
26538
26538
  tableContainer: _x,
26539
26539
  tableHeader: yx,
@@ -821,5 +821,5 @@ License: MIT
821
821
  `,ii='"',et=ii+ii,Qt=!1,ct=null,Gt=!1,Ge=((()=>{if(typeof de=="object"){if(typeof de.delimiter!="string"||Se.BAD_DELIMITERS.filter(function(It){return de.delimiter.indexOf(It)!==-1}).length||(We=de.delimiter),typeof de.quotes!="boolean"&&typeof de.quotes!="function"&&!Array.isArray(de.quotes)||(De=de.quotes),typeof de.skipEmptyLines!="boolean"&&typeof de.skipEmptyLines!="string"||(Qt=de.skipEmptyLines),typeof de.newline=="string"&&(_t=de.newline),typeof de.quoteChar=="string"&&(ii=de.quoteChar),typeof de.header=="boolean"&&(je=de.header),Array.isArray(de.columns)){if(de.columns.length===0)throw new Error("Option columns is empty");ct=de.columns}de.escapeChar!==void 0&&(et=de.escapeChar+ii),de.escapeFormulae instanceof RegExp?Gt=de.escapeFormulae:typeof de.escapeFormulae=="boolean"&&de.escapeFormulae&&(Gt=/^[=+\-@\t\r].*$/)}})(),new RegExp(fe(ii),"g"));if(typeof he=="string"&&(he=JSON.parse(he)),Array.isArray(he)){if(!he.length||Array.isArray(he[0]))return Wt(null,he,Qt);if(typeof he[0]=="object")return Wt(ct||Object.keys(he[0]),he,Qt)}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||ct),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||[],Qt);throw new Error("Unable to serialize unrecognized input");function Wt(It,nt,qt){var Tt="",Nt=(typeof It=="string"&&(It=JSON.parse(It)),typeof nt=="string"&&(nt=JSON.parse(nt)),Array.isArray(It)&&0<It.length),Et=!Array.isArray(nt[0]);if(Nt&&je){for(var Qe=0;Qe<It.length;Qe++)0<Qe&&(Tt+=We),Tt+=dt(It[Qe],Qe);0<nt.length&&(Tt+=_t)}for(var tt=0;tt<nt.length;tt++){var yt=(Nt?It:nt[tt]).length,ot=!1,ut=Nt?Object.keys(nt[tt]).length===0:nt[tt].length===0;if(qt&&!Nt&&(ot=qt==="greedy"?nt[tt].join("").trim()==="":nt[tt].length===1&&nt[tt][0].length===0),qt==="greedy"&&Nt){for(var Ht=[],ht=0;ht<yt;ht++){var zt=Et?It[ht]:ht;Ht.push(nt[tt][zt])}ot=Ht.join("").trim()===""}if(!ot){for(var bt=0;bt<yt;bt++){0<bt&&!ut&&(Tt+=We);var wt=Nt&&Et?It[bt]:bt;Tt+=dt(nt[tt][wt],bt)}tt<nt.length-1&&(!qt||0<yt&&!ut)&&(Tt+=_t)}}return Tt}function dt(It,nt){var qt,Tt;return It==null?"":It.constructor===Date?JSON.stringify(It).slice(1,25):(Tt=!1,Gt&&typeof It=="string"&&Gt.test(It)&&(It="'"+It,Tt=!0),qt=It.toString().replace(Ge,et),(Tt=Tt||De===!0||typeof De=="function"&&De(It,nt)||Array.isArray(De)&&De[nt]||((Nt,Et)=>{for(var Qe=0;Qe<Et.length;Qe++)if(-1<Nt.indexOf(Et[Qe]))return!0;return!1})(qt,Se.BAD_DELIMITERS)||-1<qt.indexOf(We)||qt.charAt(0)===" "||qt.charAt(qt.length-1)===" ")?ii+qt+ii:qt)}},Se.RECORD_SEP="",Se.UNIT_SEP="",Se.BYTE_ORDER_MARK="\uFEFF",Se.BAD_DELIMITERS=["\r",`
822
822
  `,'"',Se.BYTE_ORDER_MARK],Se.WORKERS_SUPPORTED=!ce&&!!q.Worker,Se.NODE_STREAM_INPUT=1,Se.LocalChunkSize=10485760,Se.RemoteChunkSize=5242880,Se.DefaultDelimiter=",",Se.Parser=Bt,Se.ParserHandle=Ke,Se.NetworkStreamer=Be,Se.FileStreamer=Ze,Se.StringStreamer=it,Se.ReadableStreamStreamer=vt,q.jQuery&&((J=q.jQuery).fn.parse=function(he){var de=he.config||{},De=[];return this.each(function(_t){if(!(J(this).prop("tagName").toUpperCase()==="INPUT"&&J(this).attr("type").toLowerCase()==="file"&&q.FileReader)||!this.files||this.files.length===0)return!0;for(var ii=0;ii<this.files.length;ii++)De.push({file:this.files[ii],inputElem:this,instanceConfig:J.extend({},de)})}),je(),this;function je(){if(De.length===0)gt(he.complete)&&he.complete();else{var _t,ii,et,Qt,ct=De[0];if(gt(he.before)){var Gt=he.before(ct.file,ct.inputElem);if(typeof Gt=="object"){if(Gt.action==="abort")return _t="AbortError",ii=ct.file,et=ct.inputElem,Qt=Gt.reason,void(gt(he.error)&&he.error({name:_t},ii,et,Qt));if(Gt.action==="skip")return void We();typeof Gt.config=="object"&&(ct.instanceConfig=J.extend(ct.instanceConfig,Gt.config))}else if(Gt==="skip")return void We()}var Ge=ct.instanceConfig.complete;ct.instanceConfig.complete=function(Wt){gt(Ge)&&Ge(Wt,ct.file,ct.inputElem),We()},Se.parse(ct.file,ct.instanceConfig)}}function We(){De.splice(0,1),je()}}),P&&(q.onmessage=function(he){he=he.data,Se.WORKER_ID===void 0&&he&&(Se.WORKER_ID=he.workerId),typeof he.input=="string"?q.postMessage({workerId:Se.WORKER_ID,results:Se.parse(he.input,he.config),finished:!0}):(q.File&&he.input instanceof File||he.input instanceof Object)&&(he=Se.parse(he.input,he.config))&&q.postMessage({workerId:Se.WORKER_ID,results:he,finished:!0})}),(Be.prototype=Object.create(Re.prototype)).constructor=Be,(Ze.prototype=Object.create(Re.prototype)).constructor=Ze,(it.prototype=Object.create(it.prototype)).constructor=it,(vt.prototype=Object.create(Re.prototype)).constructor=vt,Se})})(bc)),bc.exports}var hg=ug();const uh=Vd(hg);async function hh(F,E,D){return new Promise((q,J)=>{uh.parse(F,{download:!0,header:!0,skipEmptyLines:!0,complete:ce=>{try{const P=ce.data,c=ce.meta.fields||[],le=new Map;P.forEach(Se=>{const Re=Se[E],Be=Se[D];if(Re!=null){const Ze=parseFloat(Be),it=isNaN(Ze)?Be:Ze;le.set(String(Re),it)}}),q({headers:c,rows:P,joinMap:le})}catch(P){J(P)}},error:ce=>{J(ce)}})})}async function dh(F,E,D){return new Promise((q,J)=>{uh.parse(F,{header:!0,skipEmptyLines:!0,complete:ce=>{try{const P=ce.data,c=ce.meta.fields||[],le=new Map;P.forEach(Se=>{const Re=Se[E],Be=Se[D];if(Re!=null){const Ze=parseFloat(Be),it=isNaN(Ze)?Be:Ze;le.set(String(Re),it)}}),q({headers:c,rows:P,joinMap:le})}catch(P){J(P)}},error:ce=>{J(ce)}})})}function op(F,E){if(F.length===0)return[];if(E>=F.length)return[...new Set(F)].sort((le,Se)=>le-Se);const D=[...F].sort((le,Se)=>le-Se);let q=D.length;const J=Array(q+1).fill(0).map(()=>Array(E+1).fill(0)),ce=Array(q+1).fill(0).map(()=>Array(E+1).fill(0));for(let le=1;le<=E;le++){J[1][le]=1,ce[1][le]=0;for(let Se=2;Se<=q;Se++)ce[Se][le]=1/0}for(let le=2;le<=q;le++){let Se=0,Re=0,Be=0;for(let Ze=1;Ze<=le;Ze++){const it=le-Ze+1,vt=D[it-1];Re+=vt*vt,Se+=vt,Be++;const Ke=Re-Se*Se/Be,fe=it-1;if(fe!==0)for(let Bt=2;Bt<=E;Bt++)ce[le][Bt]>=Ke+ce[fe][Bt-1]&&(J[le][Bt]=it,ce[le][Bt]=Ke+ce[fe][Bt-1])}J[le][1]=1,ce[le][1]=ce[le-1][1]+(le-1)*(D[le-1]-D[le-2])**2}const P=[];let c=E;for(;c>=2;){const le=J[q][c]-1;P.push(D[le]),q=J[q][c]-1,c--}return P.push(D[0]),P.reverse(),P.push(D[D.length-1]),[...new Set(P)].sort((le,Se)=>le-Se)}function lp(F,E,D){const q=[],J=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}},ce=J(F),P=J(E);for(let c=0;c<D;c++){const le=c/(D-1),Se=Math.round(ce.r+le*(P.r-ce.r)),Re=Math.round(ce.g+le*(P.g-ce.g)),Be=Math.round(ce.b+le*(P.b-ce.b));q.push(`rgb(${Se}, ${Re}, ${Be})`)}return q}function hs(F,E){this.x=F,this.y=E}hs.prototype={clone(){return new hs(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,E){return this.clone()._rotateAround(F,E)},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 E=F.x-this.x,D=F.y-this.y;return E*E+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,E){return Math.atan2(this.x*E-this.y*F,this.x*F+this.y*E)},_matMult(F){const E=F[0]*this.x+F[1]*this.y,D=F[2]*this.x+F[3]*this.y;return this.x=E,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 E=Math.cos(F),D=Math.sin(F),q=E*this.x-D*this.y,J=D*this.x+E*this.y;return this.x=q,this.y=J,this},_rotateAround(F,E){const D=Math.cos(F),q=Math.sin(F),J=E.x+D*(this.x-E.x)-q*(this.y-E.y),ce=E.y+q*(this.x-E.x)+D*(this.y-E.y);return this.x=J,this.y=ce,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:hs},hs.convert=function(F){if(F instanceof hs)return F;if(Array.isArray(F))return new hs(+F[0],+F[1]);if(F.x!==void 0&&F.y!==void 0)return new hs(+F.x,+F.y);throw new Error("Expected [x, y] or {x, y} point format")};class cp{constructor(E,D,q,J,ce){this.properties={},this.extent=q,this.type=0,this.id=void 0,this._pbf=E,this._geometry=-1,this._keys=J,this._values=ce,E.readFields(dg,this,D)}loadGeometry(){const E=this._pbf;E.pos=this._geometry;const D=E.readVarint()+E.pos,q=[];let J,ce=1,P=0,c=0,le=0;for(;E.pos<D;){if(P<=0){const Se=E.readVarint();ce=Se&7,P=Se>>3}if(P--,ce===1||ce===2)c+=E.readSVarint(),le+=E.readSVarint(),ce===1&&(J&&q.push(J),J=[]),J&&J.push(new hs(c,le));else if(ce===7)J&&J.push(J[0].clone());else throw new Error(`unknown command ${ce}`)}return J&&q.push(J),q}bbox(){const E=this._pbf;E.pos=this._geometry;const D=E.readVarint()+E.pos;let q=1,J=0,ce=0,P=0,c=1/0,le=-1/0,Se=1/0,Re=-1/0;for(;E.pos<D;){if(J<=0){const Be=E.readVarint();q=Be&7,J=Be>>3}if(J--,q===1||q===2)ce+=E.readSVarint(),P+=E.readSVarint(),ce<c&&(c=ce),ce>le&&(le=ce),P<Se&&(Se=P),P>Re&&(Re=P);else if(q!==7)throw new Error(`unknown command ${q}`)}return[c,Se,le,Re]}toGeoJSON(E,D,q){const J=this.extent*Math.pow(2,q),ce=this.extent*E,P=this.extent*D,c=this.loadGeometry();function le(Ze){return[(Ze.x+ce)*360/J-180,360/Math.PI*Math.atan(Math.exp((1-(Ze.y+P)*2/J)*Math.PI))-90]}function Se(Ze){return Ze.map(le)}let Re;if(this.type===1){const Ze=[];for(const vt of c)Ze.push(vt[0]);const it=Se(Ze);Re=Ze.length===1?{type:"Point",coordinates:it[0]}:{type:"MultiPoint",coordinates:it}}else if(this.type===2){const Ze=c.map(Se);Re=Ze.length===1?{type:"LineString",coordinates:Ze[0]}:{type:"MultiLineString",coordinates:Ze}}else if(this.type===3){const Ze=fg(c),it=[];for(const vt of Ze)it.push(vt.map(Se));Re=it.length===1?{type:"Polygon",coordinates:it[0]}:{type:"MultiPolygon",coordinates:it}}else throw new Error("unknown feature type");const Be={type:"Feature",geometry:Re,properties:this.properties};return this.id!=null&&(Be.id=this.id),Be}}cp.types=["Unknown","Point","LineString","Polygon"];function dg(F,E,D){F===1?E.id=D.readVarint():F===2?pg(D,E):F===3?E.type=D.readVarint():F===4&&(E._geometry=D.pos)}function pg(F,E){const D=F.readVarint()+F.pos;for(;F.pos<D;){const q=E._keys[F.readVarint()],J=E._values[F.readVarint()];E.properties[q]=J}}function fg(F){const E=F.length;if(E<=1)return[F];const D=[];let q,J;for(let ce=0;ce<E;ce++){const P=mg(F[ce]);P!==0&&(J===void 0&&(J=P<0),J===P<0?(q&&D.push(q),q=[F[ce]]):q&&q.push(F[ce]))}return q&&D.push(q),D}function mg(F){let E=0;for(let D=0,q=F.length,J=q-1,ce,P;D<q;J=D++)ce=F[D],P=F[J],E+=(P.x-ce.x)*(ce.y+P.y);return E}class gg{constructor(E,D){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=E,this._keys=[],this._values=[],this._features=[],E.readFields(_g,this,D),this.length=this._features.length}feature(E){if(E<0||E>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[E];const D=this._pbf.readVarint()+this._pbf.pos;return new cp(this._pbf,D,this.extent,this._keys,this._values)}}function _g(F,E,D){F===15?E.version=D.readVarint():F===1?E.name=D.readString():F===5?E.extent=D.readVarint():F===2?E._features.push(D.pos):F===3?E._keys.push(D.readString()):F===4&&E._values.push(yg(D))}function yg(F){let E=null;const D=F.readVarint()+F.pos;for(;F.pos<D;){const q=F.readVarint()>>3;E=q===1?F.readString():q===2?F.readFloat():q===3?F.readDouble():q===4?F.readVarint64():q===5?F.readVarint():q===6?F.readSVarint():q===7?F.readBoolean():null}if(E==null)throw new Error("unknown feature value");return E}class xg{constructor(E,D){this.layers=E.readFields(vg,{},D)}}function vg(F,E,D){if(F===3){const q=new gg(D,D.readVarint()+D.pos);q.length&&(E[q.name]=q)}}const ph=65536*65536,up=1/ph,bg=12,hp=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),fh=0,wc=1,rl=2,Tc=5;class wg{constructor(E=new Uint8Array(16)){this.buf=ArrayBuffer.isView(E)?E:new Uint8Array(E),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(E,D,q=this.length){for(;this.pos<q;){const J=this.readVarint(),ce=J>>3,P=this.pos;this.type=J&7,E(ce,D,this),this.pos===P&&this.skip(J)}return D}readMessage(E,D){return this.readFields(E,D,this.readVarint()+this.pos)}readFixed32(){const E=this.dataView.getUint32(this.pos,!0);return this.pos+=4,E}readSFixed32(){const E=this.dataView.getInt32(this.pos,!0);return this.pos+=4,E}readFixed64(){const E=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*ph;return this.pos+=8,E}readSFixed64(){const E=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ph;return this.pos+=8,E}readFloat(){const E=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,E}readDouble(){const E=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,E}readVarint(E){const D=this.buf;let q,J;return J=D[this.pos++],q=J&127,J<128||(J=D[this.pos++],q|=(J&127)<<7,J<128)||(J=D[this.pos++],q|=(J&127)<<14,J<128)||(J=D[this.pos++],q|=(J&127)<<21,J<128)?q:(J=D[this.pos],q|=(J&15)<<28,Tg(q,E,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const E=this.readVarint();return E%2===1?(E+1)/-2:E/2}readBoolean(){return!!this.readVarint()}readString(){const E=this.readVarint()+this.pos,D=this.pos;return this.pos=E,E-D>=bg&&hp?hp.decode(this.buf.subarray(D,E)):Lg(this.buf,D,E)}readBytes(){const E=this.readVarint()+this.pos,D=this.buf.subarray(this.pos,E);return this.pos=E,D}readPackedVarint(E=[],D){const q=this.readPackedEnd();for(;this.pos<q;)E.push(this.readVarint(D));return E}readPackedSVarint(E=[]){const D=this.readPackedEnd();for(;this.pos<D;)E.push(this.readSVarint());return E}readPackedBoolean(E=[]){const D=this.readPackedEnd();for(;this.pos<D;)E.push(this.readBoolean());return E}readPackedFloat(E=[]){const D=this.readPackedEnd();for(;this.pos<D;)E.push(this.readFloat());return E}readPackedDouble(E=[]){const D=this.readPackedEnd();for(;this.pos<D;)E.push(this.readDouble());return E}readPackedFixed32(E=[]){const D=this.readPackedEnd();for(;this.pos<D;)E.push(this.readFixed32());return E}readPackedSFixed32(E=[]){const D=this.readPackedEnd();for(;this.pos<D;)E.push(this.readSFixed32());return E}readPackedFixed64(E=[]){const D=this.readPackedEnd();for(;this.pos<D;)E.push(this.readFixed64());return E}readPackedSFixed64(E=[]){const D=this.readPackedEnd();for(;this.pos<D;)E.push(this.readSFixed64());return E}readPackedEnd(){return this.type===rl?this.readVarint()+this.pos:this.pos+1}skip(E){const D=E&7;if(D===fh)for(;this.buf[this.pos++]>127;);else if(D===rl)this.pos=this.readVarint()+this.pos;else if(D===Tc)this.pos+=4;else if(D===wc)this.pos+=8;else throw new Error(`Unimplemented type: ${D}`)}writeTag(E,D){this.writeVarint(E<<3|D)}realloc(E){let D=this.length||16;for(;D<this.pos+E;)D*=2;if(D!==this.length){const q=new Uint8Array(D);q.set(this.buf),this.buf=q,this.dataView=new DataView(q.buffer),this.length=D}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(E){this.realloc(4),this.dataView.setInt32(this.pos,E,!0),this.pos+=4}writeSFixed32(E){this.realloc(4),this.dataView.setInt32(this.pos,E,!0),this.pos+=4}writeFixed64(E){this.realloc(8),this.dataView.setInt32(this.pos,E&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(E*up),!0),this.pos+=8}writeSFixed64(E){this.realloc(8),this.dataView.setInt32(this.pos,E&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(E*up),!0),this.pos+=8}writeVarint(E){if(E=+E||0,E>268435455||E<0){Sg(E,this);return}this.realloc(4),this.buf[this.pos++]=E&127|(E>127?128:0),!(E<=127)&&(this.buf[this.pos++]=(E>>>=7)&127|(E>127?128:0),!(E<=127)&&(this.buf[this.pos++]=(E>>>=7)&127|(E>127?128:0),!(E<=127)&&(this.buf[this.pos++]=E>>>7&127)))}writeSVarint(E){this.writeVarint(E<0?-E*2-1:E*2)}writeBoolean(E){this.writeVarint(+E)}writeString(E){E=String(E),this.realloc(E.length*4),this.pos++;const D=this.pos;this.pos=Bg(this.buf,E,this.pos);const q=this.pos-D;q>=128&&dp(D,q,this),this.pos=D-1,this.writeVarint(q),this.pos+=q}writeFloat(E){this.realloc(4),this.dataView.setFloat32(this.pos,E,!0),this.pos+=4}writeDouble(E){this.realloc(8),this.dataView.setFloat64(this.pos,E,!0),this.pos+=8}writeBytes(E){const D=E.length;this.writeVarint(D),this.realloc(D);for(let q=0;q<D;q++)this.buf[this.pos++]=E[q]}writeRawMessage(E,D){this.pos++;const q=this.pos;E(D,this);const J=this.pos-q;J>=128&&dp(q,J,this),this.pos=q-1,this.writeVarint(J),this.pos+=J}writeMessage(E,D,q){this.writeTag(E,rl),this.writeRawMessage(D,q)}writePackedVarint(E,D){D.length&&this.writeMessage(E,Ig,D)}writePackedSVarint(E,D){D.length&&this.writeMessage(E,Eg,D)}writePackedBoolean(E,D){D.length&&this.writeMessage(E,Dg,D)}writePackedFloat(E,D){D.length&&this.writeMessage(E,Cg,D)}writePackedDouble(E,D){D.length&&this.writeMessage(E,Ag,D)}writePackedFixed32(E,D){D.length&&this.writeMessage(E,zg,D)}writePackedSFixed32(E,D){D.length&&this.writeMessage(E,kg,D)}writePackedFixed64(E,D){D.length&&this.writeMessage(E,Rg,D)}writePackedSFixed64(E,D){D.length&&this.writeMessage(E,Fg,D)}writeBytesField(E,D){this.writeTag(E,rl),this.writeBytes(D)}writeFixed32Field(E,D){this.writeTag(E,Tc),this.writeFixed32(D)}writeSFixed32Field(E,D){this.writeTag(E,Tc),this.writeSFixed32(D)}writeFixed64Field(E,D){this.writeTag(E,wc),this.writeFixed64(D)}writeSFixed64Field(E,D){this.writeTag(E,wc),this.writeSFixed64(D)}writeVarintField(E,D){this.writeTag(E,fh),this.writeVarint(D)}writeSVarintField(E,D){this.writeTag(E,fh),this.writeSVarint(D)}writeStringField(E,D){this.writeTag(E,rl),this.writeString(D)}writeFloatField(E,D){this.writeTag(E,Tc),this.writeFloat(D)}writeDoubleField(E,D){this.writeTag(E,wc),this.writeDouble(D)}writeBooleanField(E,D){this.writeVarintField(E,+D)}}function Tg(F,E,D){const q=D.buf;let J,ce;if(ce=q[D.pos++],J=(ce&112)>>4,ce<128||(ce=q[D.pos++],J|=(ce&127)<<3,ce<128)||(ce=q[D.pos++],J|=(ce&127)<<10,ce<128)||(ce=q[D.pos++],J|=(ce&127)<<17,ce<128)||(ce=q[D.pos++],J|=(ce&127)<<24,ce<128)||(ce=q[D.pos++],J|=(ce&1)<<31,ce<128))return Ga(F,J,E);throw new Error("Expected varint not more than 10 bytes")}function Ga(F,E,D){return D?E*4294967296+(F>>>0):(E>>>0)*4294967296+(F>>>0)}function Sg(F,E){let D,q;if(F>=0?(D=F%4294967296|0,q=F/4294967296|0):(D=~(-F%4294967296),q=~(-F/4294967296),D^4294967295?D=D+1|0:(D=0,q=q+1|0)),F>=18446744073709552e3||F<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");E.realloc(10),Pg(D,q,E),Mg(q,E)}function Pg(F,E,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 Mg(F,E){const D=(F&7)<<4;E.buf[E.pos++]|=D|((F>>>=3)?128:0),F&&(E.buf[E.pos++]=F&127|((F>>>=7)?128:0),F&&(E.buf[E.pos++]=F&127|((F>>>=7)?128:0),F&&(E.buf[E.pos++]=F&127|((F>>>=7)?128:0),F&&(E.buf[E.pos++]=F&127|((F>>>=7)?128:0),F&&(E.buf[E.pos++]=F&127)))))}function dp(F,E,D){const q=E<=16383?1:E<=2097151?2:E<=268435455?3:Math.floor(Math.log(E)/(Math.LN2*7));D.realloc(q);for(let J=D.pos-1;J>=F;J--)D.buf[J+q]=D.buf[J]}function Ig(F,E){for(let D=0;D<F.length;D++)E.writeVarint(F[D])}function Eg(F,E){for(let D=0;D<F.length;D++)E.writeSVarint(F[D])}function Cg(F,E){for(let D=0;D<F.length;D++)E.writeFloat(F[D])}function Ag(F,E){for(let D=0;D<F.length;D++)E.writeDouble(F[D])}function Dg(F,E){for(let D=0;D<F.length;D++)E.writeBoolean(F[D])}function zg(F,E){for(let D=0;D<F.length;D++)E.writeFixed32(F[D])}function kg(F,E){for(let D=0;D<F.length;D++)E.writeSFixed32(F[D])}function Rg(F,E){for(let D=0;D<F.length;D++)E.writeFixed64(F[D])}function Fg(F,E){for(let D=0;D<F.length;D++)E.writeSFixed64(F[D])}function Lg(F,E,D){let q="",J=E;for(;J<D;){const ce=F[J];let P=null,c=ce>239?4:ce>223?3:ce>191?2:1;if(J+c>D)break;let le,Se,Re;c===1?ce<128&&(P=ce):c===2?(le=F[J+1],(le&192)===128&&(P=(ce&31)<<6|le&63,P<=127&&(P=null))):c===3?(le=F[J+1],Se=F[J+2],(le&192)===128&&(Se&192)===128&&(P=(ce&15)<<12|(le&63)<<6|Se&63,(P<=2047||P>=55296&&P<=57343)&&(P=null))):c===4&&(le=F[J+1],Se=F[J+2],Re=F[J+3],(le&192)===128&&(Se&192)===128&&(Re&192)===128&&(P=(ce&15)<<18|(le&63)<<12|(Se&63)<<6|Re&63,(P<=65535||P>=1114112)&&(P=null))),P===null?(P=65533,c=1):P>65535&&(P-=65536,q+=String.fromCharCode(P>>>10&1023|55296),P=56320|P&1023),q+=String.fromCharCode(P),J+=c}return q}function Bg(F,E,D){for(let q=0,J,ce;q<E.length;q++){if(J=E.charCodeAt(q),J>55295&&J<57344)if(ce)if(J<56320){F[D++]=239,F[D++]=191,F[D++]=189,ce=J;continue}else J=ce-55296<<10|J-56320|65536,ce=null;else{J>56319||q+1===E.length?(F[D++]=239,F[D++]=191,F[D++]=189):ce=J;continue}else ce&&(F[D++]=239,F[D++]=191,F[D++]=189,ce=null);J<128?F[D++]=J:(J<2048?F[D++]=J>>6|192:(J<65536?F[D++]=J>>12|224:(F[D++]=J>>18|240,F[D++]=J>>12&63|128),F[D++]=J>>6&63|128),F[D++]=J&63|128)}return D}async function pp(F,E,D,q="bbox",J){try{const ce=new ch(F),P=await ce.getHeader(),c=Math.min(Math.floor((P.minZoom+P.maxZoom)/2),8),le=Math.pow(2,c);for(let Se=0;Se<le;Se++)for(let Re=0;Re<le;Re++)try{const Be=await ce.getZxy(c,Se,Re);if(!Be||!Be.data)continue;const it=new xg(new wg(Be.data)).layers[E];if(!it)continue;for(let vt=0;vt<it.length;vt++){const Ke=it.feature(vt),fe=Ke.properties,Bt=String(J?fe[J]:Ke.id);if(Bt===String(D)){let mt=null;if(fe[q]){const rt=fe[q];if(typeof rt=="string")try{const jt=JSON.parse(rt);Array.isArray(jt)&&jt.length===4&&(mt=jt)}catch{const jt=rt.split(",").map(Ut=>parseFloat(Ut.trim()));jt.length===4&&jt.every(Ut=>!isNaN(Ut))&&(mt=jt)}else Array.isArray(rt)&&rt.length===4&&(mt=rt)}if(!mt){const rt=Ke.loadGeometry();let jt=1/0,Ut=1/0,ai=-1/0,gt=-1/0;rt.forEach(et=>{et.forEach(Qt=>{jt=Math.min(jt,Qt.x),Ut=Math.min(Ut,Qt.y),ai=Math.max(ai,Qt.x),gt=Math.max(gt,Qt.y)})});const he=4096,de=(Se+jt/he)/le*360-180,De=(Se+ai/he)/le*360-180,je=Math.PI-2*Math.PI*(Re+Ut/he)/le,We=Math.PI-2*Math.PI*(Re+gt/he)/le,_t=180/Math.PI*Math.atan(.5*(Math.exp(je)-Math.exp(-je))),ii=180/Math.PI*Math.atan(.5*(Math.exp(We)-Math.exp(-We)));mt=[Math.min(de,De),Math.min(_t,ii),Math.max(de,De),Math.max(_t,ii)]}return{id:Bt,bbox:mt,properties:fe}}}}catch{continue}return console.warn(`Feature con id "${D}" no encontrada en PMTiles`),null}catch(ce){return console.error("Error buscando feature en PMTiles:",ce),null}}const qa="pmtiles-source",Sn="pmtiles-fill",Vn="municipios-source",ds="municipios-fill",fp="entidad-outline",Og="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/componente/entidad.pmtiles",Vg="entidad",Ng="cvegeo",mp="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/componente/municipios.pmtiles",$a="municipios_tile",jg={"01":"Aguascalientes","02":"Baja California","03":"Baja California Sur","04":"Campeche","05":"Coahuila","06":"Colima","07":"Chiapas","08":"Chihuahua","09":"Ciudad de México",10:"Durango",11:"Guanajuato",12:"Guerrero",13:"Hidalgo",14:"Jalisco",15:"Estado de México",16:"Michoacán de Ocampo",17:"Morelos",18:"Nayarit",19:"Nuevo León",20:"Oaxaca",21:"Puebla",22:"Querétaro",23:"Quintana Roo",24:"San Luis Potosí",25:"Sinaloa",26:"Sonora",27:"Tabasco",28:"Tamaulipas",29:"Tlaxcala",30:"Veracruz",31:"Yucatán",32:"Zacatecas"},Ug=({pmtilesUrl:F=Og,sourceLayer:E=Vg,joinGeomKey:D=Ng,csvUrl:q,csvFile:J,joinCsvKey:ce,field:P="valor",mode:c="boolean",width:le="100%",height:Se=520,initialView:Re,fitToIds:Be,bboxField:Ze="bbox",jenksK:it=5,showMunicipios:vt=!1,enablePopup:Ke=!1,popupDataLabel:fe,popupDataField:Bt,csvUrlMunicipios:mt,csvFileMunicipios:rt,joinCsvKeyMunicipios:jt,fieldMunicipios:Ut,modeMunicipios:ai})=>{const gt=Qi.useRef(null),he=Qi.useRef(null),de=Qi.useRef(null),[De,je]=Qi.useState(null),[We,_t]=Qi.useState(null);Qi.useEffect(()=>{if(!gt.current)return;if(!q&&!J){je("Debe proporcionar csvUrl o csvFile"),console.error("MapaPMTiles: Debe proporcionar csvUrl o csvFile");return}let et=null;return(async()=>{try{const ct=new Qm;jd.addProtocol("pmtiles",ct.tile);const Gt=(Re==null?void 0:Re.center)||[-102,23],Ge=(Re==null?void 0:Re.zoom)||4;et=new Qu.Map({container:gt.current,style:{version:8,sources:{},layers:[]},center:Gt,zoom:Ge,boxZoom:!1,doubleClickZoom:!1,dragRotate:!1,keyboard:!1,scrollZoom:!1,touchPitch:!1,touchZoomRotate:!0,dragPan:!1,maxBounds:void 0,attributionControl:!1}),he.current=et,et.on("load",async()=>{if(et)try{et.addSource(qa,{type:"vector",url:`pmtiles://${F}`,promoteId:D}),vt&&et.addSource(Vn,{type:"vector",url:`pmtiles://${mp}`,promoteId:"cvegeo"});const Wt=ce||D,dt=J?await dh(J,Wt,P):await hh(q,Wt,P);et.__csvDataMap=dt.joinMap;const It=vt?Vn:qa,nt=vt?$a:E;dt.joinMap.forEach((Et,Qe)=>{try{et.setFeatureState({source:It,sourceLayer:nt,id:Qe},{value:Et})}catch(tt){console.warn(`Error setting feature state for key ${Qe}:`,tt)}});let qt;if(c==="boolean")qt=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const Et=Array.from(dt.joinMap.values()).filter(Qe=>typeof Qe=="number").map(Qe=>Qe);if(Et.length===0)console.warn("No hay valores numéricos para clasificación Jenks"),qt=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"];else{const Qe=op(Et,it),tt=Qe.length-1,yt=lp("#f3f3f3","#66827f",tt),ot=["step",["feature-state","value"],yt[0]];for(let ut=1;ut<tt;ut++)ot.push(Qe[ut]),ot.push(yt[ut]);qt=ot}}const Tt=Be?Array.isArray(Be)?Be:[Be]:[];if(vt&&Tt.length>0){const Et=Tt.map(yt=>yt.substring(0,2)),Qe=["in",["get",D],["literal",Tt]];et.addLayer({id:fp,type:"line",source:qa,"source-layer":E,paint:{"line-color":"#2c3e50","line-width":2},filter:Qe});const tt=["in",["get","cve_ent"],["literal",Et]];et.addLayer({id:ds,type:"fill",source:Vn,"source-layer":$a,paint:{"fill-color":qt,"fill-opacity":.75},filter:tt}),et.addLayer({id:`${ds}-outline`,type:"line",source:Vn,"source-layer":$a,paint:{"line-color":"#2c3e50","line-width":.5},filter:tt})}else{let Et;Tt.length>0&&(Et=["in",["get",D],["literal",Tt]]),et.addLayer({id:Sn,type:"fill",source:qa,"source-layer":E,paint:{"fill-color":qt,"fill-opacity":.75},filter:Et}),et.addLayer({id:`${Sn}-outline`,type:"line",source:qa,"source-layer":E,paint:{"line-color":"#2c3e50","line-width":.5},filter:Et})}if(Ke){const Et=vt?ds:Sn,Qe=new Qu.Popup({closeButton:!1,closeOnClick:!1,closeOnMove:!1,className:"geo-ui-popup"});de.current=Qe,et.on("mouseenter",Et,()=>{et.getCanvas().style.cursor="pointer"}),et.on("mouseleave",Et,()=>{et.getCanvas().style.cursor="",Qe.remove()}),et.on("mousemove",Et,tt=>{var yt;if(tt.features&&tt.features.length>0){const ut=tt.features[0].properties;let Ht="";if(vt)Ht=(ut==null?void 0:ut.nomgeo)||"Sin nombre";else{const wt=(ut==null?void 0:ut[D])||"";Ht=jg[wt]||wt}let ht;if(Bt&&(vt||!mt&&!rt)){const wt=ut==null?void 0:ut[D];wt&&(ht=(yt=et.__csvDataMap)==null?void 0:yt.get(wt))}let bt=`<div class="geo-ui-popup-content">
823
823
  <div class="geo-ui-popup-title">${Ht}</div>`;if(ht!==void 0&&fe){const wt=typeof ht=="number"?ht.toLocaleString("es-MX"):ht;bt+=`<div class="geo-ui-popup-data">${fe}: ${wt}</div>`}bt+="</div>",Qe.setLngLat([tt.lngLat.lng,tt.lngLat.lat]).setHTML(bt).addTo(et)}})}const Nt=Be?Array.isArray(Be)?Be:[Be]:[];if(Nt.length>=2&&!vt&&(et.on("click",Sn,async Et=>{var Qe;if(Et.features&&Et.features.length>0){const tt=(Qe=Et.features[0].properties)==null?void 0:Qe[D];if(tt){const yt=await pp(F,E,tt,Ze,D);if(yt&&yt.bbox){et.getLayer(Sn)&&et.removeLayer(Sn),et.getLayer(`${Sn}-outline`)&&et.removeLayer(`${Sn}-outline`),et.getSource(Vn)||et.addSource(Vn,{type:"vector",url:`pmtiles://${mp}`,promoteId:"cvegeo"});let ot=dt,ut=qt;if(mt||rt){const wt=jt||"cvegeo",pt=Ut||P;if(ot=rt?await dh(rt,wt,pt):await hh(mt,wt,pt),(ai||c)==="boolean")ut=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const er=Array.from(ot.joinMap.values()).filter(ci=>typeof ci=="number").map(ci=>ci);if(er.length===0)ut=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"];else{const ci=op(er,it),xi=ci.length-1,Zi=lp("#f3f3f3","#66827f",xi),ni=["step",["feature-state","value"],Zi[0]];for(let Jt=1;Jt<xi;Jt++)ni.push(ci[Jt]),ni.push(Zi[Jt]);ut=ni}}et.__csvDataMap=ot.joinMap}ot.joinMap.forEach((wt,pt)=>{try{et.setFeatureState({source:Vn,sourceLayer:$a,id:pt},{value:wt})}catch{}});const Ht=["==",["get",D],tt];et.addLayer({id:fp,type:"line",source:qa,"source-layer":E,paint:{"line-color":"#2c3e50","line-width":2},filter:Ht});const ht=tt.substring(0,2),zt=["==",["get","cve_ent"],ht];et.addLayer({id:ds,type:"fill",source:Vn,"source-layer":$a,paint:{"fill-color":ut,"fill-opacity":.75},filter:zt}),et.addLayer({id:`${ds}-outline`,type:"line",source:Vn,"source-layer":$a,paint:{"line-color":"#2c3e50","line-width":.5},filter:zt});const bt=[[yt.bbox[0],yt.bbox[1]],[yt.bbox[2],yt.bbox[3]]];if(et.fitBounds(bt,{padding:20,duration:500}),Ke&&de.current){const wt=de.current;et.on("mouseenter",ds,()=>{et.getCanvas().style.cursor="pointer"}),et.on("mouseleave",ds,()=>{et.getCanvas().style.cursor="",wt.remove()}),et.on("mousemove",ds,pt=>{var Xt;if(pt.features&&pt.features.length>0){const ci=pt.features[0].properties,xi=(ci==null?void 0:ci.nomgeo)||"Sin nombre";let Zi;if(Bt){const Jt=ci==null?void 0:ci.cvegeo;Jt&&(Zi=(Xt=et.__csvDataMap)==null?void 0:Xt.get(Jt))}let ni=`<div class="geo-ui-popup-content">
824
- <div class="geo-ui-popup-title">${xi}</div>`;if(Zi!==void 0&&fe){const Jt=typeof Zi=="number"?Zi.toLocaleString("es-MX"):Zi;ni+=`<div class="geo-ui-popup-data">${fe}: ${Jt}</div>`}ni+="</div>",wt.setLngLat([pt.lngLat.lng,pt.lngLat.lat]).setHTML(ni).addTo(et)}})}_t(tt)}}}}),et.on("mouseenter",Sn,()=>{et.getCanvas().style.cursor="pointer"}),et.on("mouseleave",Sn,()=>{Ke||(et.getCanvas().style.cursor="")})),Nt.length>0){const Qe=(await Promise.all(Nt.map(tt=>pp(F,E,tt,Ze,D)))).filter(tt=>tt!==null&&tt.bbox);if(Qe.length>0){let tt=1/0,yt=1/0,ot=-1/0,ut=-1/0;Qe.forEach(ht=>{ht&&ht.bbox&&(tt=Math.min(tt,ht.bbox[0]),yt=Math.min(yt,ht.bbox[1]),ot=Math.max(ot,ht.bbox[2]),ut=Math.max(ut,ht.bbox[3]))});const Ht=[[tt,yt],[ot,ut]];et.fitBounds(Ht,{padding:20,duration:0})}else console.warn(`No se pudieron encontrar bboxes para los IDs: ${Nt.join(", ")}`)}}catch(Wt){console.error("Error cargando datos en el mapa:",Wt),je(`Error cargando datos: ${Wt instanceof Error?Wt.message:String(Wt)}`)}}),et.on("error",Wt=>{var dt;console.error("Error del mapa:",Wt),je(`Error del mapa: ${((dt=Wt.error)==null?void 0:dt.message)||"Error desconocido"}`)})}catch(ct){console.error("Error inicializando mapa:",ct),je(`Error inicializando: ${ct instanceof Error?ct.message:String(ct)}`)}})(),()=>{he.current&&(he.current.remove(),he.current=null),jd.removeProtocol("pmtiles")}},[F,E,D,q,J,ce,P,c,it,Be,Ze,Re,vt,Ke,fe,Bt,mt,rt,jt,Ut,ai]),Qi.useEffect(()=>{if(!We||!he.current)return;const et=he.current,Qt=Gt=>{Gt.key==="Escape"&&We&&window.location.reload()},ct=()=>{We&&window.location.reload()};return window.addEventListener("keydown",Qt),et.on("dblclick",ct),()=>{window.removeEventListener("keydown",Qt),et.off("dblclick",ct)}},[We]);const ii={width:typeof le=="number"?`${le}px`:le,height:typeof Se=="number"?`${Se}px`:Se,position:"relative"};return Zt.jsxs("div",{style:ii,children:[Zt.jsx("div",{ref:gt,style:{width:"100%",height:"100%"}}),De&&Zt.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:De})]})},Gg=({items:F,csvUrl:E,csvFile:D,joinCsvKey:q,field:J="valor",filterKey:ce,centered:P=!0,className:c="",labelFormatter:le,valueFormatter:Se})=>{const[Re,Be]=Qi.useState([]),[Ze,it]=Qi.useState(null),[vt,Ke]=Qi.useState(!1);return Qi.useEffect(()=>{(async()=>{if(F&&F.length>0){Be(F);return}if(!E&&!D){Be([]);return}Ke(!0),it(null);try{const Bt=q||"key",mt=D?await dh(D,Bt,J):await hh(E,Bt,J),rt=[];mt.joinMap.forEach((jt,Ut)=>{if(ce&&Ut!==ce)return;const ai=le?le(Ut,jt):Ut,gt=Se?Se(jt):jt;rt.push({label:ai,value:gt})}),Be(rt)}catch(Bt){console.error("Error cargando datos CSV:",Bt),it(`Error cargando datos: ${Bt instanceof Error?Bt.message:String(Bt)}`)}finally{Ke(!1)}})()},[F,E,D,q,J,ce,le,Se]),vt?Zt.jsx("div",{className:`totales-display-container ${P?"totales-centered":""} ${c}`,children:Zt.jsx("div",{className:"totales-loading",children:"Cargando datos..."})}):Ze?Zt.jsx("div",{className:`totales-display-container ${P?"totales-centered":""} ${c}`,children:Zt.jsx("div",{className:"totales-error",children:Ze})}):Re.length===0?null:Zt.jsx("div",{className:`totales-display-container ${P?"totales-centered":""} ${c}`,children:Re.map((fe,Bt)=>Zt.jsxs("div",{className:"totales-item",children:[fe.label,": ",Zt.jsx("span",{className:"totales-value",children:fe.value})]},Bt))})},Cr={mainContainer:"_mainContainer_11ge4_1",tableContainer:"_tableContainer_11ge4_9",tableHeader:"_tableHeader_11ge4_21",headerCell:"_headerCell_11ge4_37",tableBody:"_tableBody_11ge4_43",tableRow:"_tableRow_11ge4_49",tableCell:"_tableCell_11ge4_70",emptyState:"_emptyState_11ge4_76"},qg=({data:F,columns:E,csvPath:D,width:q="100%",height:J="auto",className:ce="",showIndex:P=!1,indexLabel:c="#"})=>{const[le,Se]=Qi.useState(F||[]),[Re,Be]=Qi.useState(E||[]),[Ze,it]=Qi.useState(!1),[vt,Ke]=Qi.useState(null);Qi.useEffect(()=>{D?fe(D):F&&(Se(F),E&&Be(E))},[D,F,E]);const fe=async mt=>{it(!0),Ke(null);try{const rt=await fetch(mt);if(!rt.ok)throw new Error(`No se pudo cargar el archivo: ${mt}`);const jt=await rt.text();uh.parse(jt,{header:!0,skipEmptyLines:!0,dynamicTyping:!0,complete:Ut=>{if(Ut.data&&Ut.data.length>0){const ai=Ut.data;if(Se(ai),!E){const he=Object.keys(ai[0]).map(de=>({key:de,label:de}));Be(he)}}it(!1)},error:Ut=>{Ke(`Error al parsear CSV: ${Ut.message}`),it(!1)}})}catch(rt){Ke(rt instanceof Error?rt.message:"Error desconocido"),it(!1)}},Bt=mt=>mt==null?"-":typeof mt=="number"?mt.toLocaleString("es-MX"):String(mt);return Ze?Zt.jsx("div",{className:`${Cr.mainContainer} ${ce}`,style:{width:q,height:J},children:Zt.jsx("div",{className:Cr.tableContainer,children:Zt.jsx("div",{className:Cr.emptyState,children:"Cargando datos..."})})}):vt?Zt.jsx("div",{className:`${Cr.mainContainer} ${ce}`,style:{width:q,height:J},children:Zt.jsx("div",{className:Cr.tableContainer,children:Zt.jsx("div",{className:Cr.emptyState,style:{color:"#d32f2f"},children:vt})})}):Zt.jsx("div",{className:`${Cr.mainContainer} ${ce}`,style:{width:q,height:J},children:Zt.jsxs("div",{className:Cr.tableContainer,children:[Zt.jsxs("div",{className:Cr.tableHeader,children:[P&&Zt.jsx("div",{className:Cr.headerCell,style:{width:"60px"},children:c}),Re.map((mt,rt)=>Zt.jsx("div",{className:Cr.headerCell,style:{width:mt.width||"auto"},children:mt.label},`header-${mt.key}-${rt}`))]}),Zt.jsx("div",{className:Cr.tableBody,children:le.length===0?Zt.jsx("div",{className:Cr.emptyState,children:"No hay datos para mostrar"}):le.map((mt,rt)=>Zt.jsxs("div",{className:Cr.tableRow,children:[P&&Zt.jsx("div",{className:Cr.tableCell,style:{width:"60px"},children:rt+1}),Re.map((jt,Ut)=>Zt.jsx("div",{className:Cr.tableCell,style:{width:jt.width||"auto"},children:Bt(mt[jt.key])},`cell-${rt}-${Ut}`))]},`row-${rt}`))})]})})};Er.DataTable=qg,Er.MapaPMTiles=Ug,Er.TotalesDisplay=Gg,Object.defineProperty(Er,Symbol.toStringTag,{value:"Module"})}));
824
+ <div class="geo-ui-popup-title">${xi}</div>`;if(Zi!==void 0&&fe){const Jt=typeof Zi=="number"?Zi.toLocaleString("es-MX"):Zi;ni+=`<div class="geo-ui-popup-data">${fe}: ${Jt}</div>`}ni+="</div>",wt.setLngLat([pt.lngLat.lng,pt.lngLat.lat]).setHTML(ni).addTo(et)}})}_t(tt)}}}}),et.on("mouseenter",Sn,()=>{et.getCanvas().style.cursor="pointer"}),et.on("mouseleave",Sn,()=>{Ke||(et.getCanvas().style.cursor="")})),Nt.length>0){const Qe=(await Promise.all(Nt.map(tt=>pp(F,E,tt,Ze,D)))).filter(tt=>tt!==null&&tt.bbox);if(Qe.length>0){let tt=1/0,yt=1/0,ot=-1/0,ut=-1/0;Qe.forEach(ht=>{ht&&ht.bbox&&(tt=Math.min(tt,ht.bbox[0]),yt=Math.min(yt,ht.bbox[1]),ot=Math.max(ot,ht.bbox[2]),ut=Math.max(ut,ht.bbox[3]))});const Ht=[[tt,yt],[ot,ut]];et.fitBounds(Ht,{padding:20,duration:0})}else console.warn(`No se pudieron encontrar bboxes para los IDs: ${Nt.join(", ")}`)}}catch(Wt){console.error("Error cargando datos en el mapa:",Wt),je(`Error cargando datos: ${Wt instanceof Error?Wt.message:String(Wt)}`)}}),et.on("error",Wt=>{var dt;console.error("Error del mapa:",Wt),je(`Error del mapa: ${((dt=Wt.error)==null?void 0:dt.message)||"Error desconocido"}`)})}catch(ct){console.error("Error inicializando mapa:",ct),je(`Error inicializando: ${ct instanceof Error?ct.message:String(ct)}`)}})(),()=>{he.current&&(he.current.remove(),he.current=null),jd.removeProtocol("pmtiles")}},[F,E,D,q,J,ce,P,c,it,Be,Ze,Re,vt,Ke,fe,Bt,mt,rt,jt,Ut,ai]),Qi.useEffect(()=>{if(!We||!he.current)return;const et=he.current,Qt=Gt=>{Gt.key==="Escape"&&We&&window.location.reload()},ct=()=>{We&&window.location.reload()};return window.addEventListener("keydown",Qt),et.on("dblclick",ct),()=>{window.removeEventListener("keydown",Qt),et.off("dblclick",ct)}},[We]);const ii={width:typeof le=="number"?`${le}px`:le,height:typeof Se=="number"?`${Se}px`:Se,position:"relative"};return Zt.jsxs("div",{style:ii,children:[Zt.jsx("div",{ref:gt,style:{width:"100%",height:"100%"}}),De&&Zt.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:De})]})},Gg=({items:F,csvUrl:E,csvFile:D,joinCsvKey:q,field:J="valor",filterKey:ce,centered:P=!0,className:c="",labelFormatter:le,valueFormatter:Se})=>{const[Re,Be]=Qi.useState([]),[Ze,it]=Qi.useState(null),[vt,Ke]=Qi.useState(!1);return Qi.useEffect(()=>{(async()=>{if(F&&F.length>0){Be(F);return}if(!E&&!D){Be([]);return}Ke(!0),it(null);try{const Bt=q||"key",mt=D?await dh(D,Bt,J):await hh(E,Bt,J),rt=[];mt.joinMap.forEach((jt,Ut)=>{if(ce&&Ut!==ce)return;const ai=le?le(Ut,jt):Ut,gt=Se?Se(jt):jt;rt.push({label:ai,value:gt})}),Be(rt)}catch(Bt){console.error("Error cargando datos CSV:",Bt),it(`Error cargando datos: ${Bt instanceof Error?Bt.message:String(Bt)}`)}finally{Ke(!1)}})()},[F,E,D,q,J,ce,le,Se]),vt?Zt.jsx("div",{className:`totales-display-container ${P?"totales-centered":""} ${c}`,children:Zt.jsx("div",{className:"totales-loading",children:"Cargando datos..."})}):Ze?Zt.jsx("div",{className:`totales-display-container ${P?"totales-centered":""} ${c}`,children:Zt.jsx("div",{className:"totales-error",children:Ze})}):Re.length===0?null:Zt.jsx("div",{className:`totales-display-container ${P?"totales-centered":""} ${c}`,children:Re.map((fe,Bt)=>Zt.jsxs("div",{className:"totales-item",children:[fe.label,": ",Zt.jsx("span",{className:"totales-value",children:fe.value})]},Bt))})},Cr={mainContainer:"_mainContainer_d339g_1",tableContainer:"_tableContainer_d339g_13",tableHeader:"_tableHeader_d339g_26",headerCell:"_headerCell_d339g_42",tableBody:"_tableBody_d339g_47",tableRow:"_tableRow_d339g_51",tableCell:"_tableCell_d339g_68",emptyState:"_emptyState_d339g_73"},qg=({data:F,columns:E,csvPath:D,width:q="100%",height:J="auto",className:ce="",showIndex:P=!1,indexLabel:c="#"})=>{const[le,Se]=Qi.useState(F||[]),[Re,Be]=Qi.useState(E||[]),[Ze,it]=Qi.useState(!1),[vt,Ke]=Qi.useState(null);Qi.useEffect(()=>{D?fe(D):F&&(Se(F),E&&Be(E))},[D,F,E]);const fe=async mt=>{it(!0),Ke(null);try{const rt=await fetch(mt);if(!rt.ok)throw new Error(`No se pudo cargar el archivo: ${mt}`);const jt=await rt.text();uh.parse(jt,{header:!0,skipEmptyLines:!0,dynamicTyping:!0,complete:Ut=>{if(Ut.data&&Ut.data.length>0){const ai=Ut.data;if(Se(ai),!E){const he=Object.keys(ai[0]).map(de=>({key:de,label:de}));Be(he)}}it(!1)},error:Ut=>{Ke(`Error al parsear CSV: ${Ut.message}`),it(!1)}})}catch(rt){Ke(rt instanceof Error?rt.message:"Error desconocido"),it(!1)}},Bt=mt=>mt==null?"-":typeof mt=="number"?mt.toLocaleString("es-MX"):String(mt);return Ze?Zt.jsx("div",{className:`${Cr.mainContainer} ${ce}`,style:{width:q,height:J},children:Zt.jsx("div",{className:Cr.tableContainer,children:Zt.jsx("div",{className:Cr.emptyState,children:"Cargando datos..."})})}):vt?Zt.jsx("div",{className:`${Cr.mainContainer} ${ce}`,style:{width:q,height:J},children:Zt.jsx("div",{className:Cr.tableContainer,children:Zt.jsx("div",{className:Cr.emptyState,style:{color:"#d32f2f"},children:vt})})}):Zt.jsx("div",{className:`${Cr.mainContainer} ${ce}`,style:{width:q,height:J},children:Zt.jsxs("div",{className:Cr.tableContainer,children:[Zt.jsxs("div",{className:Cr.tableHeader,children:[P&&Zt.jsx("div",{className:Cr.headerCell,style:{width:"60px"},children:c}),Re.map((mt,rt)=>Zt.jsx("div",{className:Cr.headerCell,style:{width:mt.width||"auto"},children:mt.label},`header-${mt.key}-${rt}`))]}),Zt.jsx("div",{className:Cr.tableBody,children:le.length===0?Zt.jsx("div",{className:Cr.emptyState,children:"No hay datos para mostrar"}):le.map((mt,rt)=>Zt.jsxs("div",{className:Cr.tableRow,children:[P&&Zt.jsx("div",{className:Cr.tableCell,style:{width:"60px"},children:rt+1}),Re.map((jt,Ut)=>Zt.jsx("div",{className:Cr.tableCell,style:{width:jt.width||"auto"},children:Bt(mt[jt.key])},`cell-${rt}-${Ut}`))]},`row-${rt}`))})]})})};Er.DataTable=qg,Er.MapaPMTiles=Ug,Er.TotalesDisplay=Gg,Object.defineProperty(Er,Symbol.toStringTag,{value:"Module"})}));
825
825
  //# sourceMappingURL=geo-ui.umd.cjs.map