"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),n=require("react"),H=require("react-redux"),a=require("../utils/parseUtils.js"),U=require("./Map.js"),$=require("./BaseLayer.js"),G=require("./DataLayer.js"),K=require("./LatLongLayer.js"),Q=require("./ZoomControl.js"),X=require("./ProjectedContainer.js"),Y=require("./Legends.js"),ee=require("./FlowLayer.js"),te=g=>{const{unique:d,editing:i,"data-identifier":Z,"data-group":f,"data-layers":h="[]","data-height":j=400,"data-width":ae=1e3,"data-back-ground-color":v="#88e8dc","data-map-position":w="{}","data-projection":E="geoMercator","data-zoom-enabled":M=!0,"data-rotation-enabled":q=!1,"data-wait-for-filters":u="false",intl:p}=g,[x,R]=n.useState(null),F=x,S=Number(j),[P,T]=n.useState(a.parse(w,i),[]),[r,b]=n.useState(a.parse(h),[]),l=n.useRef(null);n.useEffect(()=>{if(!l.current)return;const e=l.current.clientWidth;e>0&&R(e);let o=null;const t=()=>{o&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{if(!l.current)return;const z=l.current.clientWidth;z>0&&R(z)})},c=new ResizeObserver(t);return c.observe(l.current),()=>{c.disconnect(),o&&cancelAnimationFrame(o)}},[]);const m=n.useRef(null),[y,W]=n.useState(null),[C,k]=n.useState(null),[A,I]=n.useState(null);n.useEffect(()=>{const e=a.parse(w,i);a.compareJsonProps(P,e)||T(e)},[w]),n.useEffect(()=>{const e=a.parse(h);a.compareJsonProps(r,e)||b(e)},[h]);const N=e=>{const o=r.slice(),t=o.find(c=>c.id==e);t&&(t.visible=!t.visible),b(o)},D=e=>{const o=r.slice(),t=o.find(c=>c.id==e);t&&(t.patternsVisible=t.patternsVisible==null?!1:!t.patternsVisible),b(o)},J=e=>{I(e)},O=e=>{const o=r.slice(),t=o.find(c=>c.id==e);t&&(t.colorLayerVisible=t.colorLayerVisible==null?!1:!t.colorLayerVisible),b(o)},[_,B]=n.useState(!1),V=n.useRef(0);r.length;const L=()=>{V.current+=1,V.current>=r.length&&B(!0)};return x?s.jsx("div",{ref:l,className:"d3map-container",style:{width:"100%"},children:s.jsxs(X.default,{backgroundColor:a.decode(v),height:S,width:F,projectionName:E,editing:i,initialPosition:P,children:[s.jsx(U.default,{rotationEnabled:a.parse(q,i),children:r.map((e,o)=>{if(e.type==="base")return s.jsx($.default,{minLabelZoomVisible:e.minLabelZoomVisible,onReady:L,transform:y,intl:p,zoom:m,unique:d,...e},e.id);if(e.type==="data")return s.jsx(G.default,{minLabelZoomVisible:e.minLabelZoomVisible,editing:i,onLayerCreated:t=>{},onReady:L,transform:y,intl:p,group:f,zoom:m,unique:d,...e,settings:g.wordress,togglePatterns:D,initialPosition:P,waitForFilters:u=="true"||u==!0},e.id);if(e.type==="flow")return s.jsx(ee.default,{onReady:L,transform:y,intl:p,group:f,zoom:m,unique:d,...e,waitForFilters:u=="true"||u==!0},e.id);if(e.type==="dataPoints")return s.jsx(K.default,{onReady:L,onZoomToPoint:J,selectedItem:C,transform:y,intl:p,group:f,zoom:m,unique:d,...e,waitForFilters:u=="true"||u==!0},e.id)})}),s.jsx(Y.default,{selectedItem:C,unique:d,d2Click:e=>k(e),patternsData:null,layers:r,group:f,onItemClick:N,toggleColorLayer:O}),s.jsx(Q.default,{readyToZoom:_,selectedPoint:A,rootationEmabled:a.parse(q,i),zoomEnabled:a.parse(M,i),onZoomed:W,width:F,height:S,ref:m,group:f,identifier:Z,editing:i})]})}):s.jsx("div",{ref:l,className:"d3map-container",style:{width:"100%",height:`${j}px`}})},oe=(g,d)=>({}),ne={},se=H.connect(oe,ne)(te);exports.default=se;
