1import{r as a,j as h}from"./react-CC1faa-K.js";import{O as ne,V as ce,f as S,a as v,F as L,P as k,C as oe,b,S as K,T as se,c as ae,d as P,e as ue,t as Y,I as ie,g as le,h as fe}from"./neshan-D5pLIdoN.js";import{S as B,I as de,bo as ge,bp as we}from"./mui-DWCKKmMe.js";import"./dates-DjetTc6v.js";const ye="web.1e6d226d441648509c7bbfdde1e37b99";function F(r){return Array.isArray(r)?[r[1],r[0]]:[r.lng,r.lat]}function he(r){return r?.options?.iconUrl??r?.iconUrl}const xe="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png";function V(r){return new K({image:new ie({src:he(r)||xe,scale:1,anchor:[.5,1],anchorXUnits:"fraction",anchorYUnits:"fraction"})})}const ke=({mode:r,defaultPosition:x,positions:j,onChangePosition:C,editingIcon:M,zoom:X=13,height:q="400px",fullScreenButton:J=!1,autoBounds:Q=!1,onClickMarker:A=()=>{}})=>{const p=a.useRef(null),g=a.useRef(null),c=a.useRef(null),W=a.useRef(null),w=a.useRef(null),u=a.useRef(null),[E,$]=a.useState(!1),T=x?F(x):[51.337,35.7003],R=e=>{w.current&&(e.un("click",w.current),w.current=null),u.current&&(e.un("moveend",u.current),u.current=null);const s=new v;W.current=s,j?.forEach((n,o)=>{const[f,t]=F(n.position),m=new L({geometry:new k(S([f,t]))});m.set("markerData",n),m.set("markerIndex",o),m.setStyle(V(n.icon)),s.addFeature(m)});const i=new oe({distance:40,source:s}),y=new b({source:i,style:n=>{const o=n.get("features");if(o?.length)return o.length===1?o[0].getStyle():new K({image:new ae({radius:18,fill:new P({color:"#3a8ee6"}),stroke:new ue({color:"#fff",width:2})}),text:new se({text:String(o.length),fill:new P({color:"#fff"}),font:"bold 13px sans-serif"})})}});e.addLayer(y),c.current=y;const l=n=>{e.forEachFeatureAtPixel(n.pixel,o=>{if(!o.get("features")){const t=o.get("markerData");return t&&A(t),!0}const f=o.get("features");if(!f?.length)return!1;if(f.length===1){const t=f[0].get("markerData");t&&A(t)}else{const t=fe();if(f.forEach(d=>le(t,d.getGeometry().getExtent())),t[0]===t[2]&&t[1]===t[3]){c.current&&(e.removeLayer(c.current),c.current=null);const d=f.length,[U,z]=[t[0],t[1]],O=180,_=new v;f.forEach((G,re)=>{const H=2*Math.PI*re/d-Math.PI/2,D=new L({geometry:new k([U+O*Math.cos(H),z+O*Math.sin(H)])});D.setStyle(G.getStyle()),D.set("markerData",G.get("markerData")),_.addFeature(D)});const N=new b({source:_});e.addLayer(N),c.current=N;let Z=!1;const I=()=>{if(!Z){Z=!0;return}e.un("moveend",I),u.current=null,c.current&&(e.removeLayer(c.current),c.current=null),R(e)};u.current=I,e.on("moveend",I),e.getView().animate({center:[U,z],zoom:Math.min((e.getView().getZoom()??13)+1,17),duration:300})}else{const d=c.current?.getSource();d&&typeof d.setDistance=="function"&&(d.setDistance(0),d.setMinDistance?.(0)),e.getView().fit(t,{duration:400,padding:[60,60,60,60],maxZoom:18})}}return!0})};w.current=l,e.on("click",l),Q&&s.getFeatures().length>0&&setTimeout(()=>{const n=s.getExtent();e.getView().fit(n,{padding:[40,40,40,40],maxZoom:15})},300)},ee=e=>{const s=S(T),i=new L({geometry:new k(s)});i.setStyle(V(M));const y=new v({features:[i]});e.addLayer(new b({source:y})),e.on("moveend",()=>{const l=e.getView().getCenter();if(!l)return;const[n,o]=Y(l);i.getGeometry()?.setCoordinates(l),C?.([o,n])})},te=e=>{const s=new v({});e.addLayer(new b({source:s})),e.on("click",i=>{const[y,l]=Y(i.coordinate);s.clear();const n=new L({geometry:new k(i.coordinate)});n.setStyle(V(M)),s.addFeature(n),C?.([l,y])})};return a.useEffect(()=>{if(!p.current)return;const e=new ne({mapType:"neshan",target:p.current,key:ye,view:new ce({center:S(T),zoom:X})});return g.current=e,r==="view"?R(e):r==="editing"?ee(e):r==="drag-to-add"&&te(e),()=>{w.current&&(e.un("click",w.current),w.current=null),u.current&&(e.un("moveend",u.current),u.current=null),e.setTarget(void 0),g.current=null}},[]),a.useEffect(()=>{if(!g.current||!x)return;const e=S(F(x));g.current.getView().animate({center:e,duration:400})},[x]),a.useEffect(()=>{!g.current||r!=="view"||(c.current&&(g.current.removeLayer(c.current),c.current=null),R(g.current))},[j]),h.jsxs(B,{sx:{width:"100%",...E&&{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",zIndex:2e4}},children:[h.jsx(B,{position:"relative",children:J&&h.jsx(de,{onClick:()=>$(e=>!e),sx:{position:"absolute",top:"20px",left:"20px",zIndex:1e3,backgroundColor:"white",py:1,borderRadius:"4px",boxShadow:1,fontSize:"0.875rem"},children:E?h.jsx(ge,{}):h.jsx(we,{})})}),h.jsx("div",{ref:p,style:{width:"100%",height:E?"100vh":q}})]})};export{ke as NeshanInteractiveMap,ke as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.