bbl-mapbox-react 0.0.34 → 0.0.35

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/dist/index.cjs CHANGED
@@ -48,13 +48,13 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
48
48
  ${a?`<div class="road-highlight-popup__title">${a}</div>`:``}
49
49
  <div class="road-highlight-popup__info">${g.join(``)}</div>
50
50
  </div>
51
- `;O.current||=new l.default.Popup({closeButton:!1,closeOnClick:!1,offset:15,className:`road-highlight-popup`}),O.current.setLngLat(r).setHTML(_).addTo(e),e.getCanvas().style.cursor=`pointer`}else O.current&&O.current.remove(),e.getCanvas().style.cursor=``},[e,v,ee,o]);(0,c.useEffect)(()=>{if(!(!e||!b))return e.on(`mousemove`,A),()=>{if(e)try{e.off(`mousemove`,A),O.current&&O.current.remove(),e.getCanvas().style.cursor=``}catch{}}},[e,b,A]);let j=(e,t)=>{y(n=>t?[...n,e]:n.filter(t=>t!==e))},M=e=>{y(e?E.map(e=>e.class):[])},te=v.length>0,ne=()=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control__panel-header`,children:[(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__panel-title`,children:`道路类型`}),(0,p.jsx)(m.Checkbox,{checked:v.length===E.length,indeterminate:v.length>0&&v.length<E.length,onChange:M,style:{"--color-text-1":`#fff`,"--color-border-2":`rgba(255, 255, 255, 0.3)`},children:(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__type-label`,children:`全选`})})]}),(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__scroll`,children:(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__type-list`,children:E.map(e=>(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control__type-item`,onClick:()=>j(e.class,!v.includes(e.class)),children:[(0,p.jsx)(m.Checkbox,{checked:v.includes(e.class),onChange:t=>j(e.class,t),onClick:e=>e.stopPropagation(),style:{"--color-text-1":`#fff`,"--color-border-2":`rgba(255, 255, 255, 0.3)`,marginRight:0,flexShrink:0}}),(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__color-indicator`,style:{backgroundColor:e.color}}),(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__type-label`,children:e.label})]},e.class))})}),(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__tip`,children:`选中道路类型后立即显示高亮`}),!b&&(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__warning`,children:`正在初始化图层...`})]});return(0,c.useImperativeHandle)(h,()=>({setPortalContainer:C})),(0,p.jsxs)(p.Fragment,{children:[d&&(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control ${s}`,style:u,children:[(0,p.jsxs)(`button`,{ref:D,className:`mapbox-control-btn mapbox-road-highlight-control__btn ${te?`mapbox-road-highlight-control__btn--active`:``}`,onClick:()=>_(!g),title:`路网高亮${v.length>0?` (已选 ${v.length})`:``}`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769487141027'%20class='icon'%20viewBox='0%200%201517%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='2644'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='189.625'%20height='128'%3e%3cpath%20d='M1.68121071-242.12320149h1508.24640296v1508.24640298h-1508.24640296z'%20fill='%23ffffff'%20fill-opacity='0'%20p-id='2645'%3e%3c/path%3e%3cpath%20d='M437.30078846%20170.6624h682.66239999v682.6624H437.30078846z'%20fill='%23ffffff'%20fill-opacity='0'%20p-id='2646'%3e%3c/path%3e%3cpath%20d='M1151.68343834%2040.66710748H373.42829443A81.76345149%2081.76345149%200%200%200%20292.90207634%20121.49379654v784.42363608c0%2040.42218191%2036.92257893%2077.41545989%2080.5262181%2077.4154599h781.6133488a81.76345149%2081.76345149%200%200%200%2080.52621814-80.82668906V121.49379654C1232.08593315%2077.76643404%201195.25172802%2040.66710748%201151.6657636%2040.66710748z%20m-325.39237822%20616.14222197H618.29445458V451.37556451h53.66057906c6.71640976%200%2013.41514477-3.35820487%2020.11387975-6.73408452l97.28189301-100.99359314h134.18679716v208.72127078c-46.96184405%2013.50351858-87.22495312%2053.90802574-97.28189299%20104.4048223z%20m130.7932427-20.23760311c23.50743418%200%2043.65666346%2020.21992834%2043.65666349%2043.76271204a44.50505206%2044.50505206%200%200%201-43.62131391%2043.7803868%2044.50505206%2044.50505206%200%200%201-43.6036392-43.7803868c0-23.54278369%2020.096205-43.76271203%2043.6036392-43.76271204h-0.05302433zM564.63387554%20926.10201142H373.42829443a22.87114272%2022.87114272%200%200%201-16.79102442-6.71640975%2023.04789036%2023.04789036%200%200%201-6.71640975-16.82637394V714.02253578h214.73069002v212.07947564z%20m0-269.31035673H349.92086026V118.13559167c0-10.1453137%2010.05693988-20.2376031%2023.50743417-20.23760309h553.4321645v188.53669194h-147.54891766c-6.69873499%200-13.39747001%203.35820487-20.096205%206.71640977l-97.28189297%2097.653063H460.61789801a26.44144475%2026.44144475%200%200%200-19.08874355%207.79457028%2026.63586714%2026.63586714%200%200%200-7.72387123%2019.1594426c0%2016.80869917%2013.39747001%2026.90098858%2026.81261478%2026.90098857h104.03365227v212.13249995z%20m610.48629795%20245.71454877c0.17674763%206.29221547-2.24469484%2012.37233377-6.68106024%2016.84404869s-10.49880895%206.89315739-16.77334965%206.75175927h-533.42433329v-212.0971504H829.63159021c13.39747001%2057.24855586%2067.07572382%2097.65306301%20127.48806219%2097.653063a128.67227125%20128.67227125%200%200%200%2093.05762473-37.87701612%20129.60903367%20129.60903367%200%200%200%2037.73561801-93.39344522c0-64.00031515-46.96184405-117.8553166-103.98062799-128.00063029v-208.73894554h194.56378599v558.91134088h-3.35820489v-0.05302427z%20m0-616.07152294H980.57406228V97.89798858h171.10937607c13.39747001%200%2023.45440988%2010.07461465%2023.4544099%2023.59580796v164.94088398z'%20fill='%23ffffff'%20p-id='2647'%3e%3c/path%3e%3c/svg%3e`,alt:`road`,className:`mapbox-road-highlight-control__btn-icon`}),(0,p.jsxs)(`span`,{children:[`路网`,v.length>0?` (${v.length})`:``]})]}),g&&(0,p.jsx)(`div`,{ref:T,className:`mapbox-road-highlight-control__panel`,children:ne()})]}),S&&(0,f.createPortal)(ne(),S)]})});Pe.displayName=`RoadHighlightControl`;var Fe=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1773733446763'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='1802'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M110.34624%20352.01024a30.72%2030.72%200%201%200%2061.44%200v-38.46144h680.42752v38.5024a30.72%2030.72%200%200%200%2061.44%200V213.72928a30.72%2030.72%200%200%200-61.44%200v38.33856H171.78624v-38.33856a30.72%2030.72%200%200%200-61.44%200v138.28096z%20m34.816%20127.22176a34.816%2034.816%200%200%200-34.816%2034.816v312.60672c0%2019.2512%2015.5648%2034.816%2034.816%2034.816h733.5936c19.2512%200%2034.816-15.5648%2034.816-34.816V514.048a34.816%2034.816%200%200%200-34.816-34.816H145.2032z%20m26.624%20320.79872V540.672h680.3456v259.35872H171.8272z'%20fill='white'%20p-id='1804'%3e%3c/path%3e%3c/svg%3e`,Ie=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Le=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Re=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,ze=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e`,Be=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e`,Ve=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`;function H(e){if(e.type===`circle`)return A(Math.PI*e.radius*e.radius);if(e.type===`square`)return A(e.length*e.length);if(e.type===`rectangle`){let[[t,n],[r,i]]=e.bounds,a=[Math.min(t,r),Math.max(n,i)],o=[Math.max(t,r),Math.max(n,i)],s=[Math.max(t,r),Math.min(n,i)],c=O(a,o),l=O(o,s);return A(c*l)}if(e.type===`polygon`){let t=[...e.coordinates,e.coordinates[0]];return A(ee(t))}}function He(e){if(e.type===`circle`)return j(e.radius);if(e.type===`square`)return j(e.length);if(e.type===`rectangle`){let[[t,n],[r,i]]=e.bounds,a=[Math.min(t,r),Math.max(n,i)],o=[Math.max(t,r),Math.max(n,i)],s=[Math.max(t,r),Math.min(n,i)],c=O(a,o),l=O(o,s);return j(2*(c+l))}if(e.type===`polygon`){let t=0,n=e.coordinates;for(let e=0;e<n.length;e++)t+=O(n[e],n[(e+1)%n.length]);return j(t)}if(e.type===`polyline`){let t=0;for(let n=0;n<e.coordinates.length-1;n++)t+=O(e.coordinates[n],e.coordinates[n+1]);return j(t)}}var Ue={square:`正方形`,rectangle:`矩形`,circle:`圆形`,polygon:`多边形`,polyline:`折线`},We=[{mode:`square`,icon:Ie,label:`正方形`},{mode:`rectangle`,icon:Le,label:`矩形`},{mode:`circle`,icon:Re,label:`圆形`},{mode:`polygon`,icon:ze,label:`多边形`},{mode:`polyline`,icon:Be,label:`折线`}];function Ge(e,t){let[n,r]=e,[i,a]=t,o=(a-r)*Math.PI/180,s=(i-n)*Math.PI/180,c=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function Ke(e,t,n=64){let[r,i]=e,a=[],o=t/6371e3,s=i*Math.PI/180;for(let e=0;e<=n;e++){let t=e/n*2*Math.PI,c=o*Math.cos(t),l=o*Math.sin(t)/Math.cos(s);a.push([r+l*180/Math.PI,i+c*180/Math.PI])}return a}function U(e,t){let[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r+o],[n+s,r+o],[n+s,r-o],[n-s,r-o],[n-s,r+o]]}var W=`measure-`;function G(e,t){e.getSource(t)||e.addSource(t,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}})}function qe(e,t){let n=e.getSource(t);n&&n.setData({type:`FeatureCollection`,features:[]})}function Je(e){if(!e.getStyle().glyphs){let t=e.style,n=`/gis-fonts/{fontstack}/{range}.pbf`;t.glyphs=n,t.stylesheet&&(t.stylesheet.glyphs=n)}}function K(e){Je(e);for(let t of[`rect`,`circle`,`square`,`polygon`]){let n=`${W}${t}-preview-source`,r=`${W}${t}-preview-fill`,i=`${W}${t}-preview-line`,a=`${W}${t}-preview-measure-source`,o=`${W}${t}-preview-measure-label`;G(e,n),e.getLayer(r)||e.addLayer({id:r,type:`fill`,source:n,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.getLayer(i)||e.addLayer({id:i,type:`line`,source:n,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),G(e,a),e.getLayer(o)||e.addLayer({id:o,type:`symbol`,source:a,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0,0,0,0.8)`,"text-halo-width":1}})}let t=`${W}polyline-preview-source`,n=`${W}polyline-preview-line`,r=`${W}polyline-vertices-source`,i=`${W}polyline-vertices`,a=`${W}polyline-preview-measure-source`,o=`${W}polyline-preview-measure-label`;G(e,t),e.getLayer(n)||e.addLayer({id:n,type:`line`,source:t,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),G(e,r),e.getLayer(i)||e.addLayer({id:i,type:`circle`,source:r,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}}),G(e,a),e.getLayer(o)||e.addLayer({id:o,type:`symbol`,source:a,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0,0,0,0.8)`,"text-halo-width":1}});let s=`${W}polygon-vertices-source`,c=`${W}polygon-vertices`;G(e,s),e.getLayer(c)||e.addLayer({id:c,type:`circle`,source:s,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}});let l=`${W}circle-radius-source`,u=`${W}circle-radius-line`;G(e,l),e.getLayer(u)||e.addLayer({id:u,type:`line`,source:l,paint:{"line-color":`#ffffff`,"line-width":1,"line-dasharray":[4,4]}})}function q(e){for(let t of[`rect-preview-source`,`rect-preview-measure-source`,`circle-preview-source`,`circle-preview-measure-source`,`circle-radius-source`,`square-preview-source`,`square-preview-measure-source`,`polygon-preview-source`,`polygon-preview-measure-source`,`polygon-vertices-source`,`polyline-preview-source`,`polyline-preview-measure-source`,`polyline-vertices-source`])qe(e,`${W}${t}`)}function Ye({map:e,entityConfig:t,onEntityConfigChange:n,onDrawModeChange:r,className:i=``,style:a}){let[o,s]=(0,c.useState)(!1),[l,u]=(0,c.useState)(null),[d,f]=(0,c.useState)({showArea:!0,showLength:!0,showRadius:!0}),h=t!==void 0,g=h?{showArea:t.showArea??!0,showLength:t.showLength??!0,showRadius:t.showRadius??!0}:d,[_,v]=(0,c.useState)([]),y=(0,c.useRef)(new Map),b=(0,c.useRef)(0),x=(0,c.useRef)(null),C=(0,c.useRef)(null),w=(0,c.useRef)(null),T=(0,c.useRef)(null),E=(0,c.useRef)(null),k=(0,c.useRef)([]),M=(0,c.useRef)([]),te=(0,c.useRef)(g);te.current=g;let ne=(0,c.useRef)(l);ne.current=l;let N=(0,c.useCallback)(()=>`measure-${++b.current}`,[]);(0,c.useEffect)(()=>{r?.(l!==null)},[l,r]);let P=(0,c.useRef)(!1),re=(0,c.useCallback)(()=>{!e||!e.isStyleLoaded()||(K(e),P.current=!0)},[e]);(0,c.useEffect)(()=>{if(!e)return;let t=()=>{K(e),P.current=!0};e.isStyleLoaded()?t():e.once(`load`,t);let n=()=>{P.current=!1};return e.on(`style.load`,n),()=>{if(e)try{e.off(`style.load`,n)}catch{}}},[e]),(0,c.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&C.current&&!C.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let ie=(0,c.useCallback)(t=>{if(!e)return;let n=S(t,te.current),r=null;if(n.type===`circle`?r=new ye(e,n):n.type===`square`?r=new Ce(e,n):n.type===`rectangle`?r=new we(e,n):n.type===`polygon`?r=new fe(e,n):n.type===`polyline`&&(r=new _e(e,n)),r){y.current.set(n.id,r);let e={entity:n,shapeLabel:Ue[n.type]||n.type,area:H(n),lengthOrRadius:He(n)};v(t=>[...t,e])}},[e]),ae=(0,c.useCallback)(e=>{let t=y.current.get(e);t&&(t.destroy(),y.current.delete(e)),v(t=>t.filter(t=>t.entity.id!==e))},[]),F=(0,c.useCallback)(()=>{y.current.forEach(e=>e.destroy()),y.current.clear(),v([])},[]),I=(0,c.useCallback)(t=>{if(!e)return;let n=y.current.get(t);if(!n)return;let r=n.getBounds();e.fitBounds(r,{padding:80,maxZoom:18,duration:1e3})},[e]),oe=(0,c.useCallback)((e,t)=>{let r={...te.current,[e]:t};h?n?.({...r}):f(r),v(t=>t.map(t=>{let n={...t.entity};n[e]=void 0;let i=S(n,r),a=y.current.get(t.entity.id);return a&&a.update(i),{...t,entity:i}}))},[h,n]),se=(0,c.useCallback)((t,n)=>{if(!e)return;let[r,i]=t,[a,o]=n,s=[[Math.min(r,a),Math.max(i,o)],[Math.max(r,a),Math.max(i,o)],[Math.max(r,a),Math.min(i,o)],[Math.min(r,a),Math.min(i,o)],[Math.min(r,a),Math.max(i,o)]],c=e.getSource(`${W}rect-preview-source`);c&&c.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[s]},properties:{}});let l=e.getSource(`${W}rect-preview-measure-source`);if(l){let e=te.current,t=[],n=s[0],r=s[1],i=s[2];if(e?.showArea){let e=O(n,r),a=O(r,i);t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:A(e*a)}})}e?.showLength&&(t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+r[0])/2,(n[1]+r[1])/2]},properties:{label:j(O(n,r))}}),t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(r[0]+i[0])/2,(r[1]+i[1])/2]},properties:{label:j(O(r,i))}})),l.setData({type:`FeatureCollection`,features:t})}},[e]),ce=(0,c.useCallback)((t,n)=>{if(!e)return;let r=Ge(t,n),i=Ke(t,r),a=e.getSource(`${W}circle-preview-source`);a&&a.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[i]},properties:{}});let o=te.current,s=[],c=[];if(o?.showArea&&s.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{label:A(Math.PI*r*r)}}),o?.showRadius){let e=D(t,r,90),n=[(t[0]+e[0])/2,(t[1]+e[1])/2];c.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[t,e]},properties:{}}),s.push({type:`Feature`,geometry:{type:`Point`,coordinates:n},properties:{label:j(r)}})}let l=e.getSource(`${W}circle-preview-measure-source`);l&&l.setData({type:`FeatureCollection`,features:s});let u=e.getSource(`${W}circle-radius-source`);u&&u.setData({type:`FeatureCollection`,features:c})},[e]),le=(0,c.useCallback)((t,n)=>{if(!e)return;let r=Ge(t,n)*2,i=U(t,r),a=e.getSource(`${W}square-preview-source`);a&&a.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[i]},properties:{}});let o=e.getSource(`${W}square-preview-measure-source`);if(o){let e=te.current,n=[];if(e?.showArea&&n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{label:A(r*r)}}),e?.showLength){let e=[(i[1][0]+i[2][0])/2,(i[1][1]+i[2][1])/2];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:j(r)}})}o.setData({type:`FeatureCollection`,features:n})}},[e]),ue=(0,c.useCallback)((t,n)=>{if(!e)return;let r=[...t,n],i=e.getSource(`${W}polygon-preview-source`);i&&(r.length>=3?i.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[[...r,r[0]]]},properties:{}}):r.length===2?i.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:r},properties:{}}):i.setData({type:`FeatureCollection`,features:[]}));let a=e.getSource(`${W}polygon-vertices-source`);a&&a.setData({type:`FeatureCollection`,features:t.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=e.getSource(`${W}polygon-preview-measure-source`);if(o){let e=te.current,t=[];if(e?.showArea&&r.length>=3){let e=ee([...r,r[0]]),n=0,i=0;for(let e of r)n+=e[0],i+=e[1];n/=r.length,i/=r.length,t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[n,i]},properties:{label:A(e)}})}if(e?.showLength&&r.length>=2){for(let e=0;e<r.length-1;e++){let n=r[e],i=r[e+1];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:j(O(n,i))}})}if(r.length>=3){let e=r[r.length-1],n=r[0];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(e[0]+n[0])/2,(e[1]+n[1])/2]},properties:{label:j(O(e,n))}})}}o.setData({type:`FeatureCollection`,features:t})}},[e]),de=(0,c.useCallback)((t,n)=>{if(!e)return;let r=[...t,n],i=e.getSource(`${W}polyline-preview-source`);i&&(r.length>=2?i.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:r},properties:{}}):i.setData({type:`FeatureCollection`,features:[]}));let a=e.getSource(`${W}polyline-vertices-source`);a&&a.setData({type:`FeatureCollection`,features:t.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=e.getSource(`${W}polyline-preview-measure-source`);if(o){let e=te.current,t=[];if(e?.showLength&&r.length>=2)for(let e=0;e<r.length-1;e++){let n=r[e],i=r[e+1];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:j(O(n,i))}})}o.setData({type:`FeatureCollection`,features:t})}},[e]);(0,c.useEffect)(()=>{if(!e||!l)return;re(),e.getCanvas().style.cursor=`crosshair`;let t=t=>{let n=[t.lngLat.lng,t.lngLat.lat],r=ne.current;if(r===`rectangle`){let t=w.current;if(!t)w.current=n;else{let r={id:N(),type:`rectangle`,bounds:[t,n]};ie(r),w.current=null,q(e),u(null)}}else if(r===`circle`){let t=T.current;if(!t)T.current={center:n};else{let r=Ge(t.center,n),i={id:N(),type:`circle`,center:t.center,radius:r};ie(i),T.current=null,q(e),u(null)}}else if(r===`square`){let t=E.current;if(!t)E.current={center:n};else{let r=Ge(t.center,n)*2,i={id:N(),type:`square`,center:t.center,length:r};ie(i),E.current=null,q(e),u(null)}}else if(r===`polygon`){let t=k.current;if(t.length>=3&&Ge(t[0],n)<20){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],q(e),u(null);return}k.current=[...t,n]}else r===`polyline`&&(M.current=[...M.current,n])},n=e=>{let t=[e.lngLat.lng,e.lngLat.lat],n=ne.current;if(n===`rectangle`&&w.current)se(w.current,t);else if(n===`circle`&&T.current)ce(T.current.center,t);else if(n===`square`&&E.current)le(E.current.center,t);else if(n===`polygon`){let e=k.current;e.length>0&&ue(e,t)}else if(n===`polyline`){let e=M.current;e.length>0&&de(e,t)}},r=t=>{t.preventDefault();let n=ne.current;if(n===`polygon`){let t=k.current;if(t.length>=3){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],q(e),u(null)}else k.current=[],q(e)}else if(n===`polyline`){let t=M.current;if(t.length>=2){let n={id:N(),type:`polyline`,coordinates:[...t]};ie(n),M.current=[],q(e),u(null)}else M.current=[],q(e)}},i=t=>{t.key===`Escape`&&(w.current=null,T.current=null,E.current=null,k.current=[],M.current=[],q(e),u(null))},a=t=>{t.preventDefault();let n=ne.current;if(n===`polygon`){let t=k.current;if(t.length>=3){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],q(e),u(null)}}else if(n===`polyline`){let t=M.current;if(t.length>=2){let n={id:N(),type:`polyline`,coordinates:[...t]};ie(n),M.current=[],q(e),u(null)}}};return e.doubleClickZoom.disable(),e.on(`click`,t),e.on(`mousemove`,n),e.on(`contextmenu`,r),e.on(`dblclick`,a),document.addEventListener(`keydown`,i),()=>{if(document.removeEventListener(`keydown`,i),e)try{e.off(`click`,t),e.off(`mousemove`,n),e.off(`contextmenu`,r),e.off(`dblclick`,a),e.getCanvas().style.cursor=``,e.doubleClickZoom.enable(),q(e)}catch{}}},[e,l,N,ie,re,se,ce,le,ue,de]),(0,c.useEffect)(()=>()=>{y.current.forEach(e=>e.destroy()),y.current.clear()},[]);let pe=(0,c.useCallback)(t=>{u(e=>e===t?null:t),w.current=null,T.current=null,E.current=null,k.current=[],M.current=[],e&&q(e)},[e]);return e?(0,p.jsxs)(`div`,{className:`mapbox-measure-control ${i}`,style:a,children:[(0,p.jsxs)(`button`,{ref:C,className:`mapbox-control-btn mapbox-measure-control__btn ${o?`mapbox-measure-control__btn--active`:``}`,onClick:()=>s(!o),title:`测量`,children:[(0,p.jsx)(`img`,{src:Fe,alt:`measure`,className:`mapbox-measure-control__btn-icon`}),(0,p.jsx)(`span`,{children:`测量`}),_.length>0&&(0,p.jsxs)(`span`,{children:[`(`,_.length,`)`]})]}),o&&(0,p.jsxs)(`div`,{ref:x,className:`mapbox-measure-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-measure-control__section-title`,children:`显示设置`}),(0,p.jsxs)(`div`,{className:`mapbox-measure-control__settings`,children:[(0,p.jsx)(m.Checkbox,{checked:g.showArea,onChange:e=>oe(`showArea`,e),children:`面积`}),(0,p.jsx)(m.Checkbox,{checked:g.showLength,onChange:e=>oe(`showLength`,e),children:`长度`}),(0,p.jsx)(m.Checkbox,{checked:g.showRadius,onChange:e=>oe(`showRadius`,e),children:`半径`})]}),(0,p.jsx)(`div`,{className:`mapbox-measure-control__section-title`,children:`绘制工具`}),(0,p.jsxs)(`div`,{className:`mapbox-measure-control__tools`,children:[We.map(e=>(0,p.jsx)(`button`,{className:`mapbox-measure-control__tool-btn ${l===e.mode?`mapbox-measure-control__tool-btn--active`:``}`,onClick:()=>pe(e.mode),title:e.label,children:(0,p.jsx)(`img`,{src:e.icon,alt:e.label})},e.mode)),_.length>0&&(0,p.jsx)(`button`,{className:`mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger`,onClick:F,title:`清除全部`,children:(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,alt:`clear`})})]}),_.length>0?(0,p.jsx)(`div`,{className:`mapbox-measure-control__list`,children:(0,p.jsxs)(`table`,{className:`mapbox-measure-control__table`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`类型`}),(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`面积`}),(0,p.jsx)(`th`,{children:`长度/半径`}),(0,p.jsx)(`th`,{})]})}),(0,p.jsx)(`tbody`,{children:_.map(e=>(0,p.jsxs)(`tr`,{className:`mapbox-measure-control__table-row`,onClick:()=>I(e.entity.id),children:[(0,p.jsx)(`td`,{children:e.shapeLabel}),(0,p.jsx)(`td`,{children:String(e.entity.id)}),(0,p.jsx)(`td`,{children:e.area??`-`}),(0,p.jsx)(`td`,{children:e.lengthOrRadius??`-`}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`button`,{className:`mapbox-measure-control__delete-btn`,onClick:t=>{t.stopPropagation(),ae(e.entity.id)},title:`删除`,children:(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,alt:`delete`})})})]},String(e.entity.id)))})]})}):(0,p.jsx)(`div`,{className:`mapbox-measure-control__empty`,children:`选择工具后在地图上点击绘制`})]})]}):null}var Xe=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1773803353422'%20class='icon'%20viewBox='0%200%201028%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6757'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128.5'%20height='128'%3e%3cpath%20d='M835.073959%20357.94044V345.56192a345.170251%20345.170251%200%201%200-686.690426%2049.672777A345.090902%20345.090902%200%200%200%20523.706588%20974.009826a345.090902%20345.090902%200%201%200%20311.049973-616.069386zM490.141757%2048.001359a297.877959%20297.877959%200%200%201%20297.560561%20297.560561c0%207.934948%200%2016.345994-1.031543%2025.074437A297.639911%20297.639911%200%200%201%20490.141757%20643.122482h-15.869897a289.943011%20289.943011%200%200%201-104.106522-24.757039A297.481212%20297.481212%200%200%201%20490.141757%2048.001359zM345.170251%20976.39031a297.560561%20297.560561%200%200%201-185.281043-530.371944c0%201.031543%200.714145%202.142436%201.031544%203.253328s1.50764%204.522921%202.301135%206.824056c1.269592%203.888125%202.697882%207.934948%204.126173%2011.743724%200.952194%202.301135%201.825038%204.60227%202.697882%206.903405%201.58699%203.808775%203.253329%207.934948%204.919668%2011.505675%200.952194%202.142436%201.904388%204.284872%202.935931%206.347958%201.983737%204.284872%204.126173%208.490395%206.268609%2012.695918l2.380485%204.60227c3.01528%205.633813%206.268609%2011.108928%209.601287%2016.504692%200.793495%201.428291%201.745689%202.777232%202.618533%204.126173%202.539183%204.046824%205.157716%207.934948%207.934948%2011.981772l4.205523%205.792512c2.380484%203.253329%204.760969%206.506658%207.220803%209.680637l4.840318%206.030561c2.459834%203.01528%204.999017%205.951211%207.538201%208.887142l5.157717%205.792512c2.777232%203.01528%205.633813%205.951211%208.569744%208.887142l4.840318%204.999018c4.205523%204.046824%208.411045%207.934948%2012.775267%2011.823073l3.09463%202.618533c4.205523%203.650076%208.490395%207.220803%2012.854616%2010.63283l5.713163%204.205523c3.332678%202.459834%206.586007%204.919668%209.998035%207.220803l6.506657%204.364222q4.999017%203.332678%209.998035%206.427308c2.221786%201.348941%204.443571%202.697882%206.744706%203.967474%203.570727%202.142436%207.300152%204.126173%2010.950229%206.10991l6.18926%203.253329%202.301135%201.269592v12.378519c0%207.379502%200%2014.759004%200.793494%2021.979807%200%202.459834%200.396747%204.840318%200.634796%207.220803%200%204.840318%200.793495%209.759986%201.428291%2014.600305%200%202.777232%200.872844%205.554464%201.269592%208.411045%200.714145%204.364222%201.428291%208.728443%202.221785%2013.013315%200.555446%202.935931%201.190242%205.871862%201.825038%208.728443%200.952194%204.205523%201.904388%207.934948%203.015281%2012.457869s1.50764%205.871862%202.380484%208.728443%202.380484%207.934948%203.729426%2012.140471c0.952194%202.856581%201.825038%205.633813%202.856581%208.490395%201.428291%204.046824%203.01528%207.934948%204.60227%2012.061121%201.110893%202.618533%202.142436%205.316415%203.253329%207.934948%201.825038%204.284872%203.729426%208.411045%205.713163%2012.537219%201.110893%202.301135%202.142436%204.681619%203.332678%206.903405%202.618533%205.316415%205.475114%2010.474132%208.411045%2015.869896%200.555446%201.110893%201.110893%202.221786%201.745689%203.332679%203.570727%206.10991%207.379502%2012.061121%2011.346976%2018.012332%201.269592%201.904388%202.697882%203.808775%204.046824%205.713163%202.777232%203.967474%205.475114%207.934948%208.411045%2011.664374%201.745689%202.301135%203.570727%204.443571%205.395765%206.744706s5.316415%206.586007%207.934948%209.839336%204.046824%204.60227%206.10991%206.824056%205.633813%206.030561%208.490395%209.045841l6.744706%206.586007c2.935931%202.856581%205.871862%205.633813%208.966492%207.934948s4.681619%204.205523%207.062104%206.268609%206.427308%205.316415%209.759986%207.934948%204.760969%203.888125%207.300152%205.713163l2.380485%201.904388A295.894222%20295.894222%200%200%201%20345.170251%20976.39031z%20m335.965711-11.981772a296.608368%20296.608368%200%200%201-146.479145-38.563848c-5.792512-3.332678-11.426326-6.744706-16.90144-10.315433-1.825038-1.190242-3.491377-2.539183-5.237066-3.729426-3.650076-2.459834-7.300152-4.999017-10.79153-7.934948-2.063087-1.50764-3.967474-3.173979-5.871862-4.760969-3.173979-2.459834-6.268609-4.919668-9.283889-7.934949s-3.967474-3.650076-5.951211-5.475114-5.633813-5.078367-7.934949-7.934948-3.808775-4.046824-5.792512-6.10991-5.078367-5.157716-7.458851-7.934949l-5.554464-6.506657c-1.825038-2.142436-4.60227-5.475114-6.824056-7.934949s-3.412028-4.681619-5.157716-7.062104-4.205523-5.633813-6.10991-8.490394-3.253329-4.999017-4.840319-7.458852-3.729426-5.792512-5.475114-8.807792-2.935931-5.157716-4.364222-7.934949-3.332678-6.030561-4.919668-9.045841-2.539183-5.395765-3.808775-7.934948-2.935931-6.18926-4.284872-9.363239-2.301135-5.554464-3.412028-8.411045-2.459834-6.268609-3.570726-9.521938-1.983737-5.792512-2.856582-8.649094-2.063087-6.506658-3.01528-9.759986-1.58699-5.951211-2.301135-8.887142-1.666339-6.586007-2.380485-9.918686S388.812467%20722.471965%20388.812467%20719.536034s-1.190242-6.665357-1.666339-9.998035-0.793495-6.18926-1.110893-9.28389-0.793495-6.824056-1.031543-10.236083%200-6.268609-0.555447-9.363239v-6.665357h0.396748l2.142436%200.634796c4.364222%201.428291%208.807793%202.697882%2013.251363%203.967474l4.840319%201.269592%2011.505675%202.697883%204.52292%201.031543c5.237066%201.031543%2010.474132%201.983737%2015.869897%202.856581h1.348941c4.840318%200.793495%209.759986%201.348941%2014.600305%201.904388l4.919668%200.476097q5.951211%200.634796%2011.902422%200.952194H490.855902a344.456106%20344.456106%200%200%200%20183.138607-52.529358c5.395765-3.412028%2010.71218-7.062104%2015.869896-10.71218%201.745689-1.190242%203.332678-2.539183%205.078367-3.729426%203.412028-2.539183%206.903405-5.157716%2010.236084-7.934948l5.713162-4.760969c3.01528-2.459834%206.030561-4.999017%208.966492-7.934949l5.633813-5.237066c2.856581-2.618533%205.554464-5.237066%207.934949-7.934948l5.475114-5.633813c2.618533-2.697882%205.237066-5.475114%207.934948-8.331696l5.078367-5.713163%207.458851-9.045841%204.522921-5.633813%207.934948-10.315433%203.570727-4.999017c3.173979-4.60227%206.268609-9.363239%209.20454-14.203558l1.031543-1.586989c3.332678-5.475114%206.506658-11.029578%209.601288-16.663392%200.634796-1.190242%201.190242-2.380484%201.745688-3.570727%202.301135-4.443571%204.60227-8.887142%206.665357-13.410062%200.872844-1.825038%201.666339-3.729426%202.539183-5.554464%201.745689-3.967474%203.491377-7.934948%205.078367-11.902422%200.793495-2.063087%201.58699-4.205523%202.459834-6.347959%201.428291-3.808775%202.856581-7.934948%204.126173-11.505675%200.793495-2.221786%201.50764-4.522921%202.221786-6.744706%201.190242-3.808775%202.380484-7.934948%203.491377-11.585025%200.634796-2.301135%201.269592-4.60227%201.825038-6.903405%201.031543-3.967474%201.904388-7.934948%202.777232-11.902422%200.555446-2.301135%201.031543-4.522921%201.50764-6.824056%200-1.031543%200.476097-2.142436%200.634796-3.173979a297.560561%20297.560561%200%200%201-148.304183%20555.446381z'%20fill='%23ffffff'%20p-id='6758'%3e%3c/path%3e%3c/svg%3e`,J={brightness:1,saturation:0,contrast:0,hueRotate:0},Ze=[{key:`brightness`,label:`亮度`,min:0,max:1,step:.01},{key:`saturation`,label:`饱和度`,min:-1,max:1,step:.01},{key:`contrast`,label:`对比度`,min:-1,max:1,step:.01},{key:`hueRotate`,label:`色相`,min:0,max:360,step:1}];function Qe({map:e,value:t,onChange:n,rasterPaintLayerIds:r=[],className:i,style:a}){let[o,s]=(0,c.useState)(!1),[l,u]=(0,c.useState)({...J}),d=(0,c.useRef)(null),f=(0,c.useRef)(null),h=t!==void 0;(0,c.useEffect)(()=>{let e=e=>{d.current&&!d.current.contains(e.target)&&f.current&&!f.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=(0,c.useMemo)(()=>h?{brightness:t.brightness??J.brightness,saturation:t.saturation??J.saturation,contrast:t.contrast??J.contrast,hueRotate:t.hueRotate??J.hueRotate}:l,[h,t,l]),_=(0,c.useRef)(h);(0,c.useEffect)(()=>{h&&!_.current&&u({...g}),_.current=h},[h,g]);let v=(0,c.useCallback)(t=>{if(!(!e||r.length===0))for(let n of r)e.getLayer(n)&&(e.setPaintProperty(n,`raster-brightness-min`,0),e.setPaintProperty(n,`raster-brightness-max`,t.brightness),e.setPaintProperty(n,`raster-saturation`,t.saturation),e.setPaintProperty(n,`raster-contrast`,t.contrast),e.setPaintProperty(n,`raster-hue-rotate`,t.hueRotate))},[e,r]),y=(0,c.useCallback)((e,t)=>{if(h)n?.({...g,[e]:t});else{let n={...l,[e]:t};u(n),v(n)}},[h,n,g,l,v]),b=(0,c.useCallback)(()=>{h?n?.({...J}):(u({...J}),v({...J}))},[h,n,v]);(0,c.useEffect)(()=>{!h&&r.length>0&&v(l)},[r,h,v,l]);let x=(e,t)=>e===`hueRotate`?`${Math.round(t)}°`:t.toFixed(2);return(0,p.jsxs)(`div`,{className:`mapbox-raster-paint-control${i?` ${i}`:``}`,style:a,children:[(0,p.jsxs)(`button`,{ref:f,className:`mapbox-control-btn mapbox-raster-paint-control__btn${o?` mapbox-raster-paint-control__btn--active`:``}`,onClick:()=>s(!o),title:`栅格渲染调节`,children:[(0,p.jsx)(`img`,{className:`mapbox-control-btn__icon mapbox-raster-paint-control__btn-icon`,src:Xe,alt:`raster paint`}),(0,p.jsx)(`span`,{children:`渲染`})]}),o&&(0,p.jsxs)(`div`,{ref:d,className:`mapbox-raster-paint-control__panel`,children:[Ze.map(({key:e,label:t,min:n,max:r,step:i})=>(0,p.jsxs)(`div`,{className:`mapbox-raster-paint-control__slider-row`,children:[(0,p.jsx)(`span`,{className:`mapbox-raster-paint-control__label`,children:t}),(0,p.jsx)(m.Slider,{className:`mapbox-raster-paint-control__slider`,min:n,max:r,step:i,value:g[e],onChange:t=>y(e,t),tooltipVisible:!1}),(0,p.jsx)(`span`,{className:`mapbox-raster-paint-control__value`,children:x(e,g[e])})]},e)),(0,p.jsx)(`button`,{className:`mapbox-raster-paint-control__reset`,onClick:b,children:`重置`})]})]})}var Y=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769397418113'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='10253'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M755.4048%20217.2928A348.3648%20348.3648%200%200%200%20512%20119.3472a348.3136%20348.3136%200%200%200-243.3536%2097.8944%20328.4992%20328.4992%200%200%200-100.864%20236.3392c0%2049.408%2011.7248%2095.744%2032%20137.728a378.0096%20378.0096%200%200%200%2091.136%20118.4256l203.5712%20179.456%2017.5104%2015.4624%2017.5104-15.4624%20203.4176-179.3536a378.6752%20378.6752%200%200%200%2091.2384-118.4768c20.2752-41.984%2032.0512-88.32%2032.0512-137.7792a328.448%20328.448%200%200%200-100.8128-236.288z%20m24.1152%20353.3824a329.216%20329.216%200%200%201-79.872%20103.0656l-188.0064%20164.6592-187.1872-164.7616a329.0624%20329.0624%200%200%201-79.7696-103.0144%20267.0592%20267.0592%200%200%201-27.136-117.0944c0-78.7968%2032.9728-150.1184%2086.272-201.728a298.3936%20298.3936%200%200%201%20208.2816-83.5584c81.3056%200%20154.9824%2031.9488%20208.2304%2083.6096a279.9104%20279.9104%200%200%201%2086.272%20201.728%20266.496%20266.496%200%200%201-27.0848%20117.0944z%20m-164.1472-212.1728l0.0512-0.0512a146.9952%20146.9952%200%200%200-104.2432-43.2128c-40.6528%200-77.568%2016.5376-104.2432%2043.2128l0.0512%200.0512a147.3536%20147.3536%200%200%200-0.0512%20208.6912%20147.0464%20147.0464%200%200%200%20208.4864%200%20147.5072%20147.5072%200%200%200-0.0512-208.6912z%20m-34.1504%20174.2336a97.536%2097.536%200%200%201-69.2736%2028.7232%2097.6384%2097.6384%200%200%201-69.3248-28.7232%2097.792%2097.792%200%200%201-0.1536-138.4448h0.1024a97.9456%2097.9456%200%200%201%20138.5984%200h0.1536c17.664%2017.6128%2028.5696%2042.1376%2028.5696%2069.2224a97.1776%2097.1776%200%200%201-28.672%2069.2224z'%20fill='%23ffffff'%20p-id='10254'%3e%3c/path%3e%3c/svg%3e`;const $e=({markerTemplates:e,selectedTemplate:t,onTemplateSelect:n,drawMode:r,onDrawModeChange:i,showRectangleTool:a=!1,showCircleTool:o=!1,showPolygonTool:s=!1,showSquareTool:l=!1,showPolylineTool:u=!1})=>{let[d,f]=(0,c.useState)(!1),m=(0,c.useRef)(null);(0,c.useEffect)(()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&f(!1)};if(d)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[d]);let h=e=>{t?.id===e.id?(n(null),i(null)):(n(e),i(`marker`)),f(!1)},g=()=>{r===`rectangle`?i(null):(n(null),i(`rectangle`))},_=()=>{r===`circle`?i(null):(n(null),i(`circle`))},v=()=>{r===`polygon`?i(null):(n(null),i(`polygon`))},y=()=>{r===`square`?i(null):(n(null),i(`square`))},b=()=>{r===`polyline`?i(null):(n(null),i(`polyline`))},x=()=>{(r===`rectangle`||r===`circle`||r===`polygon`||r===`square`||r===`polyline`)&&i(null),f(!d)},S=e=>e.size?{width:e.size,height:e.size}:{width:e.width||32,height:e.height||32},C=d||t,w=r===`rectangle`,T=r===`circle`,E=r===`polygon`,D=r===`square`,O=r===`polyline`;return(0,p.jsxs)(`div`,{ref:m,className:`mapbox-edit-control`,children:[(0,p.jsxs)(`div`,{className:`mapbox-edit-control__btn-group`,children:[(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${C?`mapbox-control-btn--active`:``}`,onClick:x,title:`Marker`,children:[t?(0,p.jsx)(`img`,{src:t.icon,alt:t.name,className:`mapbox-edit-control__btn-icon`}):(0,p.jsx)(`img`,{src:Y,alt:`marker`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:t?t.name:`Marker`})]}),l&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${D?`mapbox-control-btn--active`:``}`,onClick:y,title:`绘制正方形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`square`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`正方形`})]}),a&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${w?`mapbox-control-btn--active`:``}`,onClick:g,title:`绘制矩形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`rectangle`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`矩形`})]}),o&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${T?`mapbox-control-btn--active`:``}`,onClick:_,title:`绘制圆形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`circle`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`圆形`})]}),s&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${E?`mapbox-control-btn--active`:``}`,onClick:v,title:`绘制多边形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e`,alt:`polygon`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`多边形`})]}),u&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${O?`mapbox-control-btn--active`:``}`,onClick:b,title:`绘制折线`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e`,alt:`polyline`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`折线`})]})]}),d&&(0,p.jsxs)(`div`,{className:`mapbox-edit-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-edit-control__panel-header`,children:`选择 Marker`}),(0,p.jsx)(`div`,{className:`mapbox-edit-control__template-list`,children:e.map(e=>{let n=S(e),r=t?.id===e.id;return(0,p.jsxs)(`div`,{className:`mapbox-edit-control__template-item ${r?`mapbox-edit-control__template-item--selected`:``}`,onClick:()=>h(e),title:e.name,children:[(0,p.jsx)(`img`,{src:e.icon,alt:e.name,className:`mapbox-edit-control__template-icon`,style:{width:Math.min(n.width,24),height:Math.min(n.height,24)}}),(0,p.jsx)(`span`,{className:`mapbox-edit-control__template-name`,children:e.name})]},e.id)})})]})]})},et=({menuState:e,onClose:t,portalContainer:n,menuRef:r})=>{let i=(0,c.useRef)(null);(0,c.useEffect)(()=>(r&&(r.current=i.current),()=>{r&&(r.current=null)}));let a=(0,c.useCallback)(e=>{i.current&&!i.current.contains(e.target)&&t()},[t]),o=(0,c.useCallback)(e=>{e.key===`Escape`&&t()},[t]);(0,c.useEffect)(()=>{let e=setTimeout(()=>{document.addEventListener(`click`,a,!0),document.addEventListener(`contextmenu`,a,!0)},0);return document.addEventListener(`keydown`,o),()=>{clearTimeout(e),document.removeEventListener(`click`,a,!0),document.removeEventListener(`contextmenu`,a,!0),document.removeEventListener(`keydown`,o)}},[a,o]);let s={...e.position};if(i.current){let e=i.current.getBoundingClientRect();s.x+e.width>window.innerWidth&&(s.x=window.innerWidth-e.width-10),s.y+e.height>window.innerHeight&&(s.y=window.innerHeight-e.height-10)}let l=(0,p.jsx)(`div`,{ref:i,className:`context-menu`,style:{position:`fixed`,left:`${s.x}px`,top:`${s.y}px`,pointerEvents:`all`},children:e.items.map(e=>(0,p.jsxs)(`div`,{className:`context-menu__item ${e.danger?`context-menu__item--danger`:``}`,onClick:()=>{e.onClick(),t()},children:[e.icon&&(0,p.jsx)(`span`,{className:`context-menu__item-icon`,children:e.icon}),(0,p.jsx)(`span`,{className:`context-menu__item-label`,children:e.label})]},e.key))});return(0,f.createPortal)(l,n)};var tt=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775031767174'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='30653'%20data-spm-anchor-id='a313x.search_index.0.i6.78953a81FCkAe0'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='64'%20height='64'%3e%3cpath%20d='M322.24%20479.210667l-42.453333-42.432%20198.826666-198.826667c53.397333-53.376%20139.306667-53.568%20191.914667-0.981333%2052.608%2052.608%2052.416%20138.517333-0.981333%20191.914666L455.722667%20642.709333l-42.432-42.453333%20213.824-213.802667a74.773333%2074.773333%200%200%200-0.341334-105.728%2074.773333%2074.773333%200%200%200-105.728-0.341333l-198.826666%20198.826667z'%20fill='%23ffffff'%20p-id='30654'%3e%3c/path%3e%3cpath%20d='M699.093333%20613.333333l42.453334%2042.432-169.429334%20169.408c-48.341333%2048.341333-129.28%2042.282667-181.248-9.664-51.968-51.968-58.026667-132.906667-9.664-181.248l234.346667-234.346666%2042.432%2042.410666L423.616%20676.693333c-22.250667%2022.250667-19.050667%2065.024%2011.008%2095.061334%2030.037333%2030.058667%2072.810667%2033.258667%2095.061333%2010.986666l169.429334-169.408zM187.989333%20571.029333c-38.933333-38.933333-38.805333-102.613333%200.853334-142.293333%2039.68-39.68%20103.381333-39.808%20142.293333-0.853333%2038.954667%2038.912%2038.826667%20102.613333-0.853333%20142.293333-39.68%2039.658667-103.381333%2039.786667-142.293334%200.853333z%20m43.733334-43.733333c15.744%2015.744%2040.874667%2015.68%2056.128%200.426667%2015.253333-15.232%2015.296-40.362667-0.426667-56.106667-15.765333-15.744-40.896-15.701333-56.149333-0.448-15.232%2015.232-15.296%2040.384%200.448%2056.106667z'%20fill='%23ffffff'%20p-id='30655'%3e%3c/path%3e%3cpath%20d='M846.144%20489.728l-31.466667%20198.784-56.96-101.461333-104.042666-38.506667z'%20fill='%23ffffff'%20p-id='30656'%3e%3c/path%3e%3c/svg%3e`,X=`route-planning-temp-line`,nt=`route-planning-temp-line-layer`,rt=`route-planning-temp-point-layer`;const it=(0,c.forwardRef)(({map:e,pointCount:t=2,showPointCountInput:n=!1,visualType:r=`marker`,onSelectFinished:i,showButton:a=!0},o)=>{let[s,u]=(0,c.useState)(`idle`),[d,f]=(0,c.useState)(0),[m,h]=(0,c.useState)(t),[g,_]=(0,c.useState)(!1),v=(0,c.useRef)(null),y=(0,c.useRef)(null),b=(0,c.useRef)([]),x=(0,c.useRef)([]),S=(0,c.useRef)(`idle`),C=(0,c.useRef)(null),w=(0,c.useRef)(``);(0,c.useEffect)(()=>{S.current=s},[s]),(0,c.useEffect)(()=>{h(t)},[t]),(0,c.useEffect)(()=>{if(!g)return;let e=e=>{y.current&&!y.current.contains(e.target)&&v.current&&!v.current.contains(e.target)&&_(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[g]);let T=(0,c.useCallback)(()=>{for(let e of x.current)e.remove();x.current=[],e&&(e.getLayer(nt)&&e.removeLayer(nt),e.getLayer(rt)&&e.removeLayer(rt),e.getSource(X)&&e.removeSource(X))},[e]),E=(0,c.useCallback)(()=>{if(!e)return;let t=b.current,n={type:`FeatureCollection`,features:[{type:`Feature`,properties:{},geometry:{type:`LineString`,coordinates:t.length>=2?t:[]}},...t.map((e,t)=>({type:`Feature`,properties:{index:t},geometry:{type:`Point`,coordinates:e}}))]},r=e.getSource(X);r?r.setData(n):(e.addSource(X,{type:`geojson`,data:n}),e.addLayer({id:nt,type:`line`,source:X,filter:[`==`,`$type`,`LineString`],paint:{"line-color":`#4A90D9`,"line-width":3,"line-dasharray":[2,2]}}),e.addLayer({id:rt,type:`circle`,source:X,filter:[`==`,`$type`,`Point`],paint:{"circle-radius":6,"circle-color":`#4A90D9`,"circle-stroke-width":2,"circle-stroke-color":`#fff`}}))},[e]),D=(0,c.useCallback)(t=>{if(!e||!C.current)return;let{visualType:n}=C.current;if(n===`marker`){let n=document.createElement(`div`);n.className=`route-planning-temp-marker`,n.textContent=String(b.current.length);let r=new l.default.Marker({element:n}).setLngLat(t).addTo(e);x.current.push(r)}else E()},[e,E]),O=(0,c.useCallback)(()=>{if(T(),b.current=[],C.current=null,f(0),u(`idle`),e)try{e.getCanvas().style.cursor=w.current}catch{}},[T,e]),k=(0,c.useCallback)(async()=>{let e=C.current,t=[...b.current];if(!e||t.length<2){O();return}u(`planning`);try{await e.onSelectFinished(t)}catch(e){console.error(`Route planning onSelectFinished failed:`,e)}finally{O()}},[O]),ee=(0,c.useCallback)(e=>{if(S.current!==`selecting`||!C.current)return;let t=[e.lngLat.lng,e.lngLat.lat];b.current.push(t);let n=b.current.length;f(n),D(t),n>=C.current.pointCount&&k()},[D,k]),A=(0,c.useCallback)(e=>{S.current===`selecting`&&(e.preventDefault(),O())},[O]);(0,c.useEffect)(()=>{if(e&&s===`selecting`)return e.on(`click`,ee),e.on(`contextmenu`,A),()=>{if(e)try{e.off(`click`,ee),e.off(`contextmenu`,A)}catch{}}},[e,s,ee,A]);let j=(0,c.useCallback)(n=>{if(!e)return;S.current!==`idle`&&O();let i=Math.max(2,n.pointCount??t),a=n.visualType??r;C.current={pointCount:i,visualType:a,onSelectFinished:n.onSelectFinished},b.current=[],f(0),h(i),_(!1),w.current=e.getCanvas().style.cursor,e.getCanvas().style.cursor=`crosshair`,u(`selecting`)},[e,t,r,O]);(0,c.useImperativeHandle)(o,()=>({startPlanning:j}),[j]);let M=()=>{s===`idle`?_(e=>!e):s===`selecting`&&O()},te=()=>{i&&j({pointCount:Math.max(2,m),visualType:r,onSelectFinished:i})},ne=e=>{let t=parseInt(e.target.value,10);!isNaN(t)&&t>=2?h(t):e.target.value===``&&h(2)},N=()=>{if(s===`planning`)return(0,p.jsx)(`span`,{children:`规划中...`});if(s===`selecting`){let e=C.current?.pointCount??m;return(0,p.jsxs)(`span`,{children:[d,`/`,e]})}return`路径规划`},P=s===`selecting`,re=s===`planning`;return!a&&s===`idle`?null:(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control${a?``:` mapbox-route-planning-control--floating`}`,children:[(0,p.jsxs)(`button`,{ref:v,className:`mapbox-control-btn mapbox-route-planning-control__btn${P?` mapbox-route-planning-control__btn--active`:``}${re?` mapbox-route-planning-control__btn--planning`:``}${g?` mapbox-route-planning-control__btn--active`:``}`,onClick:M,disabled:re,title:s===`idle`?`路径规划`:s===`selecting`?`取消选点`:`规划中...`,children:[(0,p.jsx)(`img`,{src:tt,alt:`route`,className:`mapbox-route-planning-control__btn-icon`}),N()]}),g&&s===`idle`&&(0,p.jsxs)(`div`,{ref:y,className:`mapbox-route-planning-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-route-planning-control__panel-header`,children:(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-title`,children:`路径规划`})}),(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control__panel-body`,children:[(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control__panel-row`,children:[(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-label`,children:`选点数量`}),n?(0,p.jsx)(`input`,{type:`number`,className:`mapbox-route-planning-control__panel-input`,value:m,min:2,onChange:ne}):(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-value`,children:m})]}),(0,p.jsx)(`div`,{className:`mapbox-route-planning-control__panel-tip`,children:`左键点击地图选点,右键取消`}),(0,p.jsx)(`button`,{className:`mapbox-route-planning-control__panel-start`,onClick:te,disabled:!i,children:`开始规划`})]})]})]})});it.displayName=`RoutePlanningControl`;function at(e,t,n){return{content:e.content??n??null,trigger:e.trigger??t?.trigger??T.trigger,position:e.position??t?.position??T.position,offset:e.offset??t?.offset??T.offset,showCloseButton:e.showCloseButton??t?.showCloseButton??T.showCloseButton,animation:e.animation??t?.animation??T.animation,className:e.className??``,style:e.style??{},closeOnClickOutside:e.closeOnClickOutside??t?.closeOnClickOutside??T.closeOnClickOutside,closeOnEscape:e.closeOnEscape??t?.closeOnEscape??T.closeOnEscape,hoverDelay:e.hoverDelay??t?.hoverDelay??T.hoverDelay,maxWidth:e.maxWidth??t?.maxWidth??T.maxWidth,zIndex:e.zIndex??t?.zIndex??T.zIndex}}function ot(e,t,n,r,i){let a,o;if(e.type===`polygon`)o=e.center??st(e.coordinates);else if(e.type===`polyline`)o=e.center??ct(e.coordinates);else if(e.type===`rectangle`)if(e.center)o=e.center;else{let[[t,n],[r,i]]=e.bounds;o=[(t+r)/2,(n+i)/2]}else if(e.type===`attack-direction`){let t=e.coordinates;o=e.center??[(t[0][0]+t[1][0]+t[2][0])/3,(t[0][1]+t[1][1]+t[2][1])/3]}else o=e.center;if(!o)return{position:{x:0,y:0},actualPosition:t.position};let s=n.project(o);a={x:s.x,y:s.y};let c=lt(i,t);return ut(a,t.position,t.offset,c)}function st(e){if(!e||e.length===0)return[0,0];let t=[...e];(e[0][0]!==e[e.length-1][0]||e[0][1]!==e[e.length-1][1])&&t.push(e[0]);let n=(0,u.polygon)([t]);return(0,u.centroid)(n).geometry.coordinates}function ct(e){if(!e||e.length===0)return[0,0];let t=0,n=0;for(let r of e)t+=r[0],n+=r[1];return[t/e.length,n/e.length]}function lt(e,t){if(e){let t=e.getBoundingClientRect();return{width:t.width||320,height:t.height||200}}return{width:typeof t.maxWidth==`number`?t.maxWidth:320,height:200}}function ut(e,t,n,r){let i={width:window.innerWidth,height:window.innerHeight},a=(()=>{switch(t){case`top`:return[`top`,`bottom`,`right`,`left`,`center`];case`bottom`:return[`bottom`,`top`,`right`,`left`,`center`];case`left`:return[`left`,`right`,`top`,`bottom`,`center`];case`right`:return[`right`,`left`,`top`,`bottom`,`center`];case`center`:default:return[`center`,`top`,`bottom`,`left`,`right`]}})(),o={top:()=>({x:e.x-r.width/2+n[0],y:e.y-r.height-20+n[1]}),bottom:()=>({x:e.x-r.width/2+n[0],y:e.y+20+n[1]}),left:()=>({x:e.x-r.width-20+n[0],y:e.y-r.height/2+n[1]}),right:()=>({x:e.x+20+n[0],y:e.y-r.height/2+n[1]}),center:()=>({x:e.x-r.width/2+n[0],y:e.y-r.height/2+n[1]})},s=e=>e.x>=10&&e.y>=10&&e.x+r.width+10<=i.width&&e.y+r.height+10<=i.height;for(let e of a){let t=o[e]();if(s(t))return{position:t,actualPosition:e}}let c=o[t]();return{position:dt(c,r),actualPosition:t}}function dt(e,t){let n={width:window.innerWidth,height:window.innerHeight},r={...e};return r.x+t.width+10>n.width&&(r.x=n.width-t.width-10),r.x<10&&(r.x=10),r.y+t.height+10>n.height&&(r.y=n.height-t.height-10),r.y<10&&(r.y=10),r}const ft=(0,c.forwardRef)((e,t)=>{let{center:n=[116.4074,39.9042],zoom:r=12,pitch:i=0,bearing:a=0,style:o=`mapbox://styles/mapbox/dark-v11`,maxBounds:s,mode:u=`display`,editConfig:d={},pickerConfig:f={},onPick:m,interactive:h={},layers:g=[],rasterPaint:_,entities:v=[],selectedIds:y=[],entityConfig:b,nameConfig:C,selectNameConfig:w,areaConfig:T,circleConfig:E,lengthConfig:k,showCoordinates:M=!0,showScale:te=!0,showResetView:ne=!0,showRoadHighlight:N=!1,showMeasure:P=!1,showRasterPaint:re=!1,showRoutePlanning:ie,onRasterPaintChange:ae,popupDefaults:F,renderPopup:I,onMapLoad:oe,onEntityClick:ce,onPopupOpen:pe,onPopupClose:me,className:he=``,containerStyle:ve}=e,L=(0,c.useRef)(null),be=(0,c.useRef)(null),Se=(0,c.useRef)(null),R=(0,c.useRef)(null),z=(0,c.useRef)(new Map),B=(0,c.useRef)(new Map),Oe=(0,c.useRef)(new Set),[V,Ae]=(0,c.useState)(null),je=(0,c.useRef)(null),Me=(0,c.useRef)(null),Ne=(0,c.useRef)(null),[Fe,Ie]=(0,c.useState)(null),Le=(0,c.useRef)(null),Re=(0,c.useRef)(null),[ze,Be]=(0,c.useState)(null),[H,He]=(0,c.useState)(u),[Ue,We]=(0,c.useState)(null),Ge=(0,c.useRef)(null),[Ke,U]=(0,c.useState)(null),[W,G]=(0,c.useState)(null),[qe,Je]=(0,c.useState)(null),K=(0,c.useRef)(!1),q=(0,c.useRef)(null),Xe=(0,c.useRef)(null),J=(0,c.useRef)(null),Ze=(0,c.useRef)(null),Y=(0,c.useRef)(null),tt=(0,c.useRef)([]),X=(0,c.useRef)(null),nt=(0,c.useRef)(null),rt=(0,c.useRef)(null),st=(0,c.useRef)([]),ct=(0,c.useRef)(null),lt=(0,c.useRef)(!1),[ut,dt]=(0,c.useState)([]),ft=(0,c.useRef)([]);ft.current=ut;let Z=(0,c.useRef)(null);(0,c.useEffect)(()=>{He(u)},[u]);let pt=(0,c.useCallback)(e=>{let t=z.current.get(e),n=B.current.get(e);if(t&&n){if(n.type===`radar`&&t instanceof se){let r={...n,isAnimating:!0};B.current.set(e,r),t.startAnimation()}else if(n.type===`circle`&&t instanceof xe){let r={...n,isAnimating:!0};B.current.set(e,r),t.startAnimation()}}},[]),mt=(0,c.useCallback)(e=>{let t=z.current.get(e),n=B.current.get(e);if(t&&n){if(n.type===`radar`&&t instanceof se){let r={...n,isAnimating:!1};B.current.set(e,r),t.stopAnimation()}else if(n.type===`circle`&&t instanceof xe){let r={...n,isAnimating:!1};B.current.set(e,r),t.stopAnimation()}}},[]),ht=(0,c.useCallback)(e=>{let t=B.current.get(e);t&&(t.type===`radar`||t.type===`circle`)&&(t.type,t.isAnimating?mt(e):pt(e))},[pt,mt]),gt=(0,c.useCallback)(e=>{if(e===void 0){let e=!1;for(let[,t]of z.current)if(t instanceof de){let n=t.getShowTrajectory();if(n===`all`||typeof n==`number`&&n>0){e=!0;break}}let t=e?0:`all`;for(let[,e]of z.current)e instanceof de&&e.setShowTrajectory(t)}else{let t=new Set(e.map(String));for(let[e,n]of z.current)n instanceof de&&n.setShowTrajectory(t.has(String(e))?`all`:0)}},[]),_t=(0,c.useCallback)((e,t,n)=>{let r=v.find(t=>String(t.id)===String(e));if(!r?.popup||!R.current)return;let i=r.popup.content??I?.(r);if(!i)return;let a=at(r.popup,F,i),{position:o,actualPosition:s}=ot(r,a,R.current,n);Ae({entityId:e,position:o,config:a,openedBy:t,actualPosition:s}),pe?.(e)},[v,F,I,pe]),vt=(0,c.useCallback)(e=>{V?.entityId===e&&(Ae(null),me?.(e))},[V,me]),yt=(0,c.useCallback)(()=>{Ae(e=>(e&&me?.(e.entityId),null))},[me]),bt=(0,c.useCallback)(e=>V?.entityId===e,[V]),xt=(0,c.useCallback)((e,t,n)=>{let r=R.current;r&&r.flyTo({center:e,zoom:t??r.getZoom(),...n})},[]),St=(0,c.useCallback)(e=>{if(e.length===0)return null;let t=1/0,n=-1/0,r=1/0,i=-1/0,a=!1;for(let o of e){let e=z.current.get(o);if(e){let[[o,s],[c,l]]=e.getBounds();t=Math.min(t,o),n=Math.max(n,c),r=Math.min(r,s),i=Math.max(i,l),a=!0}}return a?[(t+n)/2,(r+i)/2]:null},[]),Ct=(0,c.useCallback)((e,t,n)=>{let r=R.current;if(!r||e.length===0)return;let i=St(e);if(!i)return;let a=[];for(let t of e){let e=z.current.get(t);e&&a.push(e.getBounds())}let o=1/0,s=-1/0,c=1/0,l=-1/0;for(let[[e,t],[n,r]]of a)o=Math.min(o,e),s=Math.max(s,n),c=Math.min(c,t),l=Math.max(l,r);let u=o===s&&c===l;if(a.length===1||u){let e={center:i,zoom:t??r.getZoom()};n?.duration!==void 0&&(e.duration=n.duration),n?.pitch!==void 0&&(e.pitch=n.pitch),n?.bearing!==void 0&&(e.bearing=n.bearing),n?.essential!==void 0&&(e.essential=n.essential),r.flyTo(e);return}let d=[[o,c],[s,l]],f={padding:n?.padding??50,duration:n?.duration??1e3,bearing:n?.bearing??r.getBearing(),pitch:n?.pitch??r.getPitch()};t!==void 0&&(f.maxZoom=t),n?.essential!==void 0&&(f.essential=n.essential),r.fitBounds(d,f)},[St]),wt=(0,c.useRef)(null),Tt=(0,c.useRef)(`display`),[Et,Dt]=(0,c.useState)({}),Q=(0,c.useMemo)(()=>({...f,...Et}),[f,Et]),Ot=(0,c.useCallback)(e=>{let t=R.current;if(!t||!t.getContainer())return;let{showMarker:n=!0,markerColor:r=`#3388ff`,name:i,nameConfig:a}=Q;if(!n){Ge.current&&=(Ge.current.remove(),null);return}if(Ge.current){Ge.current.setLngLat(e);let t=Ge.current.getElement(),n=t.querySelector(`.marker-label`);if(i){let e=x(a,C);if(n)n.textContent=i,n.style.color=e.fillColor,n.style.opacity=String(e.fillOpacity),n.style.webkitTextStrokeColor=e.strokeColor,n.style.webkitTextStrokeWidth=`${e.strokeWidth}px`;else{let n=document.createElement(`div`);n.className=`marker-label`,n.textContent=i,n.style.color=e.fillColor,n.style.opacity=String(e.fillOpacity),n.style.webkitTextStrokeColor=e.strokeColor,n.style.webkitTextStrokeWidth=`${e.strokeWidth}px`,t.appendChild(n)}}else n&&n.remove()}else{let n=document.createElement(`div`);n.className=`mapbox-picker-marker`;let o=document.createElement(`div`);if(o.className=`marker-inner`,o.style.background=r,n.appendChild(o),i){let e=x(a,C),t=document.createElement(`div`);t.className=`marker-label`,t.textContent=i,t.style.color=e.fillColor,t.style.opacity=String(e.fillOpacity),t.style.webkitTextStrokeColor=e.strokeColor,t.style.webkitTextStrokeWidth=`${e.strokeWidth}px`,n.appendChild(t)}Ge.current=new l.default.Marker({element:n,anchor:`bottom`}).setLngLat(e).addTo(t)}},[Q,C]),kt=(0,c.useCallback)(()=>{Ge.current&&=(Ge.current.remove(),null)},[]),At=(0,c.useCallback)(()=>`marker-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,[]),jt=(0,c.useCallback)(e=>{let t=R.current;if(L.current)if(ct.current&&=(ct.current.remove(),null),e&&t){t.getCanvas().style.cursor=`none`;let n=document.createElement(`div`);n.className=`mapbox-custom-cursor`;let r=e.size||e.width||32;n.style.cssText=`
51
+ `;O.current||=new l.default.Popup({closeButton:!1,closeOnClick:!1,offset:15,className:`road-highlight-popup`}),O.current.setLngLat(r).setHTML(_).addTo(e),e.getCanvas().style.cursor=`pointer`}else O.current&&O.current.remove(),e.getCanvas().style.cursor=``},[e,v,ee,o]);(0,c.useEffect)(()=>{if(!(!e||!b))return e.on(`mousemove`,A),()=>{if(e)try{e.off(`mousemove`,A),O.current&&O.current.remove(),e.getCanvas().style.cursor=``}catch{}}},[e,b,A]);let j=(e,t)=>{y(n=>t?[...n,e]:n.filter(t=>t!==e))},M=e=>{y(e?E.map(e=>e.class):[])},te=v.length>0,ne=()=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control__panel-header`,children:[(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__panel-title`,children:`道路类型`}),(0,p.jsx)(m.Checkbox,{checked:v.length===E.length,indeterminate:v.length>0&&v.length<E.length,onChange:M,style:{"--color-text-1":`#fff`,"--color-border-2":`rgba(255, 255, 255, 0.3)`},children:(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__type-label`,children:`全选`})})]}),(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__scroll`,children:(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__type-list`,children:E.map(e=>(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control__type-item`,onClick:()=>j(e.class,!v.includes(e.class)),children:[(0,p.jsx)(m.Checkbox,{checked:v.includes(e.class),onChange:t=>j(e.class,t),onClick:e=>e.stopPropagation(),style:{"--color-text-1":`#fff`,"--color-border-2":`rgba(255, 255, 255, 0.3)`,marginRight:0,flexShrink:0}}),(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__color-indicator`,style:{backgroundColor:e.color}}),(0,p.jsx)(`span`,{className:`mapbox-road-highlight-control__type-label`,children:e.label})]},e.class))})}),(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__tip`,children:`选中道路类型后立即显示高亮`}),!b&&(0,p.jsx)(`div`,{className:`mapbox-road-highlight-control__warning`,children:`正在初始化图层...`})]});return(0,c.useImperativeHandle)(h,()=>({setPortalContainer:C})),(0,p.jsxs)(p.Fragment,{children:[d&&(0,p.jsxs)(`div`,{className:`mapbox-road-highlight-control ${s}`,style:u,children:[(0,p.jsxs)(`button`,{ref:D,className:`mapbox-control-btn mapbox-road-highlight-control__btn ${te?`mapbox-road-highlight-control__btn--active`:``}`,onClick:()=>_(!g),title:`路网高亮${v.length>0?` (已选 ${v.length})`:``}`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769487141027'%20class='icon'%20viewBox='0%200%201517%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='2644'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='189.625'%20height='128'%3e%3cpath%20d='M1.68121071-242.12320149h1508.24640296v1508.24640298h-1508.24640296z'%20fill='%23ffffff'%20fill-opacity='0'%20p-id='2645'%3e%3c/path%3e%3cpath%20d='M437.30078846%20170.6624h682.66239999v682.6624H437.30078846z'%20fill='%23ffffff'%20fill-opacity='0'%20p-id='2646'%3e%3c/path%3e%3cpath%20d='M1151.68343834%2040.66710748H373.42829443A81.76345149%2081.76345149%200%200%200%20292.90207634%20121.49379654v784.42363608c0%2040.42218191%2036.92257893%2077.41545989%2080.5262181%2077.4154599h781.6133488a81.76345149%2081.76345149%200%200%200%2080.52621814-80.82668906V121.49379654C1232.08593315%2077.76643404%201195.25172802%2040.66710748%201151.6657636%2040.66710748z%20m-325.39237822%20616.14222197H618.29445458V451.37556451h53.66057906c6.71640976%200%2013.41514477-3.35820487%2020.11387975-6.73408452l97.28189301-100.99359314h134.18679716v208.72127078c-46.96184405%2013.50351858-87.22495312%2053.90802574-97.28189299%20104.4048223z%20m130.7932427-20.23760311c23.50743418%200%2043.65666346%2020.21992834%2043.65666349%2043.76271204a44.50505206%2044.50505206%200%200%201-43.62131391%2043.7803868%2044.50505206%2044.50505206%200%200%201-43.6036392-43.7803868c0-23.54278369%2020.096205-43.76271203%2043.6036392-43.76271204h-0.05302433zM564.63387554%20926.10201142H373.42829443a22.87114272%2022.87114272%200%200%201-16.79102442-6.71640975%2023.04789036%2023.04789036%200%200%201-6.71640975-16.82637394V714.02253578h214.73069002v212.07947564z%20m0-269.31035673H349.92086026V118.13559167c0-10.1453137%2010.05693988-20.2376031%2023.50743417-20.23760309h553.4321645v188.53669194h-147.54891766c-6.69873499%200-13.39747001%203.35820487-20.096205%206.71640977l-97.28189297%2097.653063H460.61789801a26.44144475%2026.44144475%200%200%200-19.08874355%207.79457028%2026.63586714%2026.63586714%200%200%200-7.72387123%2019.1594426c0%2016.80869917%2013.39747001%2026.90098858%2026.81261478%2026.90098857h104.03365227v212.13249995z%20m610.48629795%20245.71454877c0.17674763%206.29221547-2.24469484%2012.37233377-6.68106024%2016.84404869s-10.49880895%206.89315739-16.77334965%206.75175927h-533.42433329v-212.0971504H829.63159021c13.39747001%2057.24855586%2067.07572382%2097.65306301%20127.48806219%2097.653063a128.67227125%20128.67227125%200%200%200%2093.05762473-37.87701612%20129.60903367%20129.60903367%200%200%200%2037.73561801-93.39344522c0-64.00031515-46.96184405-117.8553166-103.98062799-128.00063029v-208.73894554h194.56378599v558.91134088h-3.35820489v-0.05302427z%20m0-616.07152294H980.57406228V97.89798858h171.10937607c13.39747001%200%2023.45440988%2010.07461465%2023.4544099%2023.59580796v164.94088398z'%20fill='%23ffffff'%20p-id='2647'%3e%3c/path%3e%3c/svg%3e`,alt:`road`,className:`mapbox-road-highlight-control__btn-icon`}),(0,p.jsxs)(`span`,{children:[`路网`,v.length>0?` (${v.length})`:``]})]}),g&&(0,p.jsx)(`div`,{ref:T,className:`mapbox-road-highlight-control__panel`,children:ne()})]}),S&&(0,f.createPortal)(ne(),S)]})});Pe.displayName=`RoadHighlightControl`;var Fe=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1773733446763'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='1802'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M110.34624%20352.01024a30.72%2030.72%200%201%200%2061.44%200v-38.46144h680.42752v38.5024a30.72%2030.72%200%200%200%2061.44%200V213.72928a30.72%2030.72%200%200%200-61.44%200v38.33856H171.78624v-38.33856a30.72%2030.72%200%200%200-61.44%200v138.28096z%20m34.816%20127.22176a34.816%2034.816%200%200%200-34.816%2034.816v312.60672c0%2019.2512%2015.5648%2034.816%2034.816%2034.816h733.5936c19.2512%200%2034.816-15.5648%2034.816-34.816V514.048a34.816%2034.816%200%200%200-34.816-34.816H145.2032z%20m26.624%20320.79872V540.672h680.3456v259.35872H171.8272z'%20fill='white'%20p-id='1804'%3e%3c/path%3e%3c/svg%3e`,Ie=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Le=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,Re=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,ze=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e`,Be=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e`,Ve=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`;function H(e){if(e.type===`circle`)return A(Math.PI*e.radius*e.radius);if(e.type===`square`)return A(e.length*e.length);if(e.type===`rectangle`){let[[t,n],[r,i]]=e.bounds,a=[Math.min(t,r),Math.max(n,i)],o=[Math.max(t,r),Math.max(n,i)],s=[Math.max(t,r),Math.min(n,i)],c=O(a,o),l=O(o,s);return A(c*l)}if(e.type===`polygon`){let t=[...e.coordinates,e.coordinates[0]];return A(ee(t))}}function He(e){if(e.type===`circle`)return j(e.radius);if(e.type===`square`)return j(e.length);if(e.type===`rectangle`){let[[t,n],[r,i]]=e.bounds,a=[Math.min(t,r),Math.max(n,i)],o=[Math.max(t,r),Math.max(n,i)],s=[Math.max(t,r),Math.min(n,i)],c=O(a,o),l=O(o,s);return j(2*(c+l))}if(e.type===`polygon`){let t=0,n=e.coordinates;for(let e=0;e<n.length;e++)t+=O(n[e],n[(e+1)%n.length]);return j(t)}if(e.type===`polyline`){let t=0;for(let n=0;n<e.coordinates.length-1;n++)t+=O(e.coordinates[n],e.coordinates[n+1]);return j(t)}}var Ue={square:`正方形`,rectangle:`矩形`,circle:`圆形`,polygon:`多边形`,polyline:`折线`},We=[{mode:`square`,icon:Ie,label:`正方形`},{mode:`rectangle`,icon:Le,label:`矩形`},{mode:`circle`,icon:Re,label:`圆形`},{mode:`polygon`,icon:ze,label:`多边形`},{mode:`polyline`,icon:Be,label:`折线`}];function Ge(e,t){let[n,r]=e,[i,a]=t,o=(a-r)*Math.PI/180,s=(i-n)*Math.PI/180,c=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function Ke(e,t,n=64){let[r,i]=e,a=[],o=t/6371e3,s=i*Math.PI/180;for(let e=0;e<=n;e++){let t=e/n*2*Math.PI,c=o*Math.cos(t),l=o*Math.sin(t)/Math.cos(s);a.push([r+l*180/Math.PI,i+c*180/Math.PI])}return a}function U(e,t){let[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r+o],[n+s,r+o],[n+s,r-o],[n-s,r-o],[n-s,r+o]]}var W=`measure-`;function G(e,t){e.getSource(t)||e.addSource(t,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}})}function qe(e,t){let n=e.getSource(t);n&&n.setData({type:`FeatureCollection`,features:[]})}function Je(e){if(!e.getStyle().glyphs){let t=e.style,n=`/gis-fonts/{fontstack}/{range}.pbf`;t.glyphs=n,t.stylesheet&&(t.stylesheet.glyphs=n)}}function K(e){Je(e);for(let t of[`rect`,`circle`,`square`,`polygon`]){let n=`${W}${t}-preview-source`,r=`${W}${t}-preview-fill`,i=`${W}${t}-preview-line`,a=`${W}${t}-preview-measure-source`,o=`${W}${t}-preview-measure-label`;G(e,n),e.getLayer(r)||e.addLayer({id:r,type:`fill`,source:n,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.getLayer(i)||e.addLayer({id:i,type:`line`,source:n,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),G(e,a),e.getLayer(o)||e.addLayer({id:o,type:`symbol`,source:a,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0,0,0,0.8)`,"text-halo-width":1}})}let t=`${W}polyline-preview-source`,n=`${W}polyline-preview-line`,r=`${W}polyline-vertices-source`,i=`${W}polyline-vertices`,a=`${W}polyline-preview-measure-source`,o=`${W}polyline-preview-measure-label`;G(e,t),e.getLayer(n)||e.addLayer({id:n,type:`line`,source:t,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),G(e,r),e.getLayer(i)||e.addLayer({id:i,type:`circle`,source:r,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}}),G(e,a),e.getLayer(o)||e.addLayer({id:o,type:`symbol`,source:a,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0,0,0,0.8)`,"text-halo-width":1}});let s=`${W}polygon-vertices-source`,c=`${W}polygon-vertices`;G(e,s),e.getLayer(c)||e.addLayer({id:c,type:`circle`,source:s,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}});let l=`${W}circle-radius-source`,u=`${W}circle-radius-line`;G(e,l),e.getLayer(u)||e.addLayer({id:u,type:`line`,source:l,paint:{"line-color":`#ffffff`,"line-width":1,"line-dasharray":[4,4]}})}function q(e){for(let t of[`rect-preview-source`,`rect-preview-measure-source`,`circle-preview-source`,`circle-preview-measure-source`,`circle-radius-source`,`square-preview-source`,`square-preview-measure-source`,`polygon-preview-source`,`polygon-preview-measure-source`,`polygon-vertices-source`,`polyline-preview-source`,`polyline-preview-measure-source`,`polyline-vertices-source`])qe(e,`${W}${t}`)}function Ye({map:e,entityConfig:t,onEntityConfigChange:n,onDrawModeChange:r,className:i=``,style:a}){let[o,s]=(0,c.useState)(!1),[l,u]=(0,c.useState)(null),[d,f]=(0,c.useState)({showArea:!0,showLength:!0,showRadius:!0}),h=t!==void 0,g=h?{showArea:t.showArea??!0,showLength:t.showLength??!0,showRadius:t.showRadius??!0}:d,[_,v]=(0,c.useState)([]),y=(0,c.useRef)(new Map),b=(0,c.useRef)(0),x=(0,c.useRef)(null),C=(0,c.useRef)(null),w=(0,c.useRef)(null),T=(0,c.useRef)(null),E=(0,c.useRef)(null),k=(0,c.useRef)([]),M=(0,c.useRef)([]),te=(0,c.useRef)(g);te.current=g;let ne=(0,c.useRef)(l);ne.current=l;let N=(0,c.useCallback)(()=>`measure-${++b.current}`,[]);(0,c.useEffect)(()=>{r?.(l!==null)},[l,r]);let P=(0,c.useRef)(!1),re=(0,c.useCallback)(()=>{!e||!e.isStyleLoaded()||(K(e),P.current=!0)},[e]);(0,c.useEffect)(()=>{if(!e)return;let t=()=>{K(e),P.current=!0};e.isStyleLoaded()?t():e.once(`load`,t);let n=()=>{P.current=!1};return e.on(`style.load`,n),()=>{if(e)try{e.off(`style.load`,n)}catch{}}},[e]),(0,c.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&C.current&&!C.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let ie=(0,c.useCallback)(t=>{if(!e)return;let n=S(t,te.current),r=null;if(n.type===`circle`?r=new ye(e,n):n.type===`square`?r=new Ce(e,n):n.type===`rectangle`?r=new we(e,n):n.type===`polygon`?r=new fe(e,n):n.type===`polyline`&&(r=new _e(e,n)),r){y.current.set(n.id,r);let e={entity:n,shapeLabel:Ue[n.type]||n.type,area:H(n),lengthOrRadius:He(n)};v(t=>[...t,e])}},[e]),ae=(0,c.useCallback)(e=>{let t=y.current.get(e);t&&(t.destroy(),y.current.delete(e)),v(t=>t.filter(t=>t.entity.id!==e))},[]),F=(0,c.useCallback)(()=>{y.current.forEach(e=>e.destroy()),y.current.clear(),v([])},[]),I=(0,c.useCallback)(t=>{if(!e)return;let n=y.current.get(t);if(!n)return;let r=n.getBounds();e.fitBounds(r,{padding:80,maxZoom:18,duration:1e3})},[e]),oe=(0,c.useCallback)((e,t)=>{let r={...te.current,[e]:t};h?n?.({...r}):f(r),v(t=>t.map(t=>{let n={...t.entity};n[e]=void 0;let i=S(n,r),a=y.current.get(t.entity.id);return a&&a.update(i),{...t,entity:i}}))},[h,n]),se=(0,c.useCallback)((t,n)=>{if(!e)return;let[r,i]=t,[a,o]=n,s=[[Math.min(r,a),Math.max(i,o)],[Math.max(r,a),Math.max(i,o)],[Math.max(r,a),Math.min(i,o)],[Math.min(r,a),Math.min(i,o)],[Math.min(r,a),Math.max(i,o)]],c=e.getSource(`${W}rect-preview-source`);c&&c.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[s]},properties:{}});let l=e.getSource(`${W}rect-preview-measure-source`);if(l){let e=te.current,t=[],n=s[0],r=s[1],i=s[2];if(e?.showArea){let e=O(n,r),a=O(r,i);t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:A(e*a)}})}e?.showLength&&(t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+r[0])/2,(n[1]+r[1])/2]},properties:{label:j(O(n,r))}}),t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(r[0]+i[0])/2,(r[1]+i[1])/2]},properties:{label:j(O(r,i))}})),l.setData({type:`FeatureCollection`,features:t})}},[e]),ce=(0,c.useCallback)((t,n)=>{if(!e)return;let r=Ge(t,n),i=Ke(t,r),a=e.getSource(`${W}circle-preview-source`);a&&a.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[i]},properties:{}});let o=te.current,s=[],c=[];if(o?.showArea&&s.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{label:A(Math.PI*r*r)}}),o?.showRadius){let e=D(t,r,90),n=[(t[0]+e[0])/2,(t[1]+e[1])/2];c.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[t,e]},properties:{}}),s.push({type:`Feature`,geometry:{type:`Point`,coordinates:n},properties:{label:j(r)}})}let l=e.getSource(`${W}circle-preview-measure-source`);l&&l.setData({type:`FeatureCollection`,features:s});let u=e.getSource(`${W}circle-radius-source`);u&&u.setData({type:`FeatureCollection`,features:c})},[e]),le=(0,c.useCallback)((t,n)=>{if(!e)return;let r=Ge(t,n)*2,i=U(t,r),a=e.getSource(`${W}square-preview-source`);a&&a.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[i]},properties:{}});let o=e.getSource(`${W}square-preview-measure-source`);if(o){let e=te.current,n=[];if(e?.showArea&&n.push({type:`Feature`,geometry:{type:`Point`,coordinates:t},properties:{label:A(r*r)}}),e?.showLength){let e=[(i[1][0]+i[2][0])/2,(i[1][1]+i[2][1])/2];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:j(r)}})}o.setData({type:`FeatureCollection`,features:n})}},[e]),ue=(0,c.useCallback)((t,n)=>{if(!e)return;let r=[...t,n],i=e.getSource(`${W}polygon-preview-source`);i&&(r.length>=3?i.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[[...r,r[0]]]},properties:{}}):r.length===2?i.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:r},properties:{}}):i.setData({type:`FeatureCollection`,features:[]}));let a=e.getSource(`${W}polygon-vertices-source`);a&&a.setData({type:`FeatureCollection`,features:t.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=e.getSource(`${W}polygon-preview-measure-source`);if(o){let e=te.current,t=[];if(e?.showArea&&r.length>=3){let e=ee([...r,r[0]]),n=0,i=0;for(let e of r)n+=e[0],i+=e[1];n/=r.length,i/=r.length,t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[n,i]},properties:{label:A(e)}})}if(e?.showLength&&r.length>=2){for(let e=0;e<r.length-1;e++){let n=r[e],i=r[e+1];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:j(O(n,i))}})}if(r.length>=3){let e=r[r.length-1],n=r[0];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(e[0]+n[0])/2,(e[1]+n[1])/2]},properties:{label:j(O(e,n))}})}}o.setData({type:`FeatureCollection`,features:t})}},[e]),de=(0,c.useCallback)((t,n)=>{if(!e)return;let r=[...t,n],i=e.getSource(`${W}polyline-preview-source`);i&&(r.length>=2?i.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:r},properties:{}}):i.setData({type:`FeatureCollection`,features:[]}));let a=e.getSource(`${W}polyline-vertices-source`);a&&a.setData({type:`FeatureCollection`,features:t.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=e.getSource(`${W}polyline-preview-measure-source`);if(o){let e=te.current,t=[];if(e?.showLength&&r.length>=2)for(let e=0;e<r.length-1;e++){let n=r[e],i=r[e+1];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[(n[0]+i[0])/2,(n[1]+i[1])/2]},properties:{label:j(O(n,i))}})}o.setData({type:`FeatureCollection`,features:t})}},[e]);(0,c.useEffect)(()=>{if(!e||!l)return;re(),e.getCanvas().style.cursor=`crosshair`;let t=t=>{let n=[t.lngLat.lng,t.lngLat.lat],r=ne.current;if(r===`rectangle`){let t=w.current;if(!t)w.current=n;else{let r={id:N(),type:`rectangle`,bounds:[t,n]};ie(r),w.current=null,q(e),u(null)}}else if(r===`circle`){let t=T.current;if(!t)T.current={center:n};else{let r=Ge(t.center,n),i={id:N(),type:`circle`,center:t.center,radius:r};ie(i),T.current=null,q(e),u(null)}}else if(r===`square`){let t=E.current;if(!t)E.current={center:n};else{let r=Ge(t.center,n)*2,i={id:N(),type:`square`,center:t.center,length:r};ie(i),E.current=null,q(e),u(null)}}else if(r===`polygon`){let t=k.current;if(t.length>=3&&Ge(t[0],n)<20){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],q(e),u(null);return}k.current=[...t,n]}else r===`polyline`&&(M.current=[...M.current,n])},n=e=>{let t=[e.lngLat.lng,e.lngLat.lat],n=ne.current;if(n===`rectangle`&&w.current)se(w.current,t);else if(n===`circle`&&T.current)ce(T.current.center,t);else if(n===`square`&&E.current)le(E.current.center,t);else if(n===`polygon`){let e=k.current;e.length>0&&ue(e,t)}else if(n===`polyline`){let e=M.current;e.length>0&&de(e,t)}},r=t=>{t.preventDefault();let n=ne.current;if(n===`polygon`){let t=k.current;if(t.length>=3){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],q(e),u(null)}else k.current=[],q(e)}else if(n===`polyline`){let t=M.current;if(t.length>=2){let n={id:N(),type:`polyline`,coordinates:[...t]};ie(n),M.current=[],q(e),u(null)}else M.current=[],q(e)}},i=t=>{t.key===`Escape`&&(w.current=null,T.current=null,E.current=null,k.current=[],M.current=[],q(e),u(null))},a=t=>{t.preventDefault();let n=ne.current;if(n===`polygon`){let t=k.current;if(t.length>=3){let n={id:N(),type:`polygon`,coordinates:[...t]};ie(n),k.current=[],q(e),u(null)}}else if(n===`polyline`){let t=M.current;if(t.length>=2){let n={id:N(),type:`polyline`,coordinates:[...t]};ie(n),M.current=[],q(e),u(null)}}};return e.doubleClickZoom.disable(),e.on(`click`,t),e.on(`mousemove`,n),e.on(`contextmenu`,r),e.on(`dblclick`,a),document.addEventListener(`keydown`,i),()=>{if(document.removeEventListener(`keydown`,i),e)try{e.off(`click`,t),e.off(`mousemove`,n),e.off(`contextmenu`,r),e.off(`dblclick`,a),e.getCanvas().style.cursor=``,e.doubleClickZoom.enable(),q(e)}catch{}}},[e,l,N,ie,re,se,ce,le,ue,de]),(0,c.useEffect)(()=>()=>{y.current.forEach(e=>e.destroy()),y.current.clear()},[]);let pe=(0,c.useCallback)(t=>{u(e=>e===t?null:t),w.current=null,T.current=null,E.current=null,k.current=[],M.current=[],e&&q(e)},[e]);return e?(0,p.jsxs)(`div`,{className:`mapbox-measure-control ${i}`,style:a,children:[(0,p.jsxs)(`button`,{ref:C,className:`mapbox-control-btn mapbox-measure-control__btn ${o?`mapbox-measure-control__btn--active`:``}`,onClick:()=>s(!o),title:`测量`,children:[(0,p.jsx)(`img`,{src:Fe,alt:`measure`,className:`mapbox-measure-control__btn-icon`}),(0,p.jsx)(`span`,{children:`测量`}),_.length>0&&(0,p.jsxs)(`span`,{children:[`(`,_.length,`)`]})]}),o&&(0,p.jsxs)(`div`,{ref:x,className:`mapbox-measure-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-measure-control__section-title`,children:`显示设置`}),(0,p.jsxs)(`div`,{className:`mapbox-measure-control__settings`,children:[(0,p.jsx)(m.Checkbox,{checked:g.showArea,onChange:e=>oe(`showArea`,e),children:`面积`}),(0,p.jsx)(m.Checkbox,{checked:g.showLength,onChange:e=>oe(`showLength`,e),children:`长度`}),(0,p.jsx)(m.Checkbox,{checked:g.showRadius,onChange:e=>oe(`showRadius`,e),children:`半径`})]}),(0,p.jsx)(`div`,{className:`mapbox-measure-control__section-title`,children:`绘制工具`}),(0,p.jsxs)(`div`,{className:`mapbox-measure-control__tools`,children:[We.map(e=>(0,p.jsx)(`button`,{className:`mapbox-measure-control__tool-btn ${l===e.mode?`mapbox-measure-control__tool-btn--active`:``}`,onClick:()=>pe(e.mode),title:e.label,children:(0,p.jsx)(`img`,{src:e.icon,alt:e.label})},e.mode)),_.length>0&&(0,p.jsx)(`button`,{className:`mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger`,onClick:F,title:`清除全部`,children:(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,alt:`clear`})})]}),_.length>0?(0,p.jsx)(`div`,{className:`mapbox-measure-control__list`,children:(0,p.jsxs)(`table`,{className:`mapbox-measure-control__table`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`类型`}),(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`面积`}),(0,p.jsx)(`th`,{children:`长度/半径`}),(0,p.jsx)(`th`,{})]})}),(0,p.jsx)(`tbody`,{children:_.map(e=>(0,p.jsxs)(`tr`,{className:`mapbox-measure-control__table-row`,onClick:()=>I(e.entity.id),children:[(0,p.jsx)(`td`,{children:e.shapeLabel}),(0,p.jsx)(`td`,{children:String(e.entity.id)}),(0,p.jsx)(`td`,{children:e.area??`-`}),(0,p.jsx)(`td`,{children:e.lengthOrRadius??`-`}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`button`,{className:`mapbox-measure-control__delete-btn`,onClick:t=>{t.stopPropagation(),ae(e.entity.id)},title:`删除`,children:(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e`,alt:`delete`})})})]},String(e.entity.id)))})]})}):(0,p.jsx)(`div`,{className:`mapbox-measure-control__empty`,children:`选择工具后在地图上点击绘制`})]})]}):null}var Xe=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1773803353422'%20class='icon'%20viewBox='0%200%201028%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6757'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128.5'%20height='128'%3e%3cpath%20d='M835.073959%20357.94044V345.56192a345.170251%20345.170251%200%201%200-686.690426%2049.672777A345.090902%20345.090902%200%200%200%20523.706588%20974.009826a345.090902%20345.090902%200%201%200%20311.049973-616.069386zM490.141757%2048.001359a297.877959%20297.877959%200%200%201%20297.560561%20297.560561c0%207.934948%200%2016.345994-1.031543%2025.074437A297.639911%20297.639911%200%200%201%20490.141757%20643.122482h-15.869897a289.943011%20289.943011%200%200%201-104.106522-24.757039A297.481212%20297.481212%200%200%201%20490.141757%2048.001359zM345.170251%20976.39031a297.560561%20297.560561%200%200%201-185.281043-530.371944c0%201.031543%200.714145%202.142436%201.031544%203.253328s1.50764%204.522921%202.301135%206.824056c1.269592%203.888125%202.697882%207.934948%204.126173%2011.743724%200.952194%202.301135%201.825038%204.60227%202.697882%206.903405%201.58699%203.808775%203.253329%207.934948%204.919668%2011.505675%200.952194%202.142436%201.904388%204.284872%202.935931%206.347958%201.983737%204.284872%204.126173%208.490395%206.268609%2012.695918l2.380485%204.60227c3.01528%205.633813%206.268609%2011.108928%209.601287%2016.504692%200.793495%201.428291%201.745689%202.777232%202.618533%204.126173%202.539183%204.046824%205.157716%207.934948%207.934948%2011.981772l4.205523%205.792512c2.380484%203.253329%204.760969%206.506658%207.220803%209.680637l4.840318%206.030561c2.459834%203.01528%204.999017%205.951211%207.538201%208.887142l5.157717%205.792512c2.777232%203.01528%205.633813%205.951211%208.569744%208.887142l4.840318%204.999018c4.205523%204.046824%208.411045%207.934948%2012.775267%2011.823073l3.09463%202.618533c4.205523%203.650076%208.490395%207.220803%2012.854616%2010.63283l5.713163%204.205523c3.332678%202.459834%206.586007%204.919668%209.998035%207.220803l6.506657%204.364222q4.999017%203.332678%209.998035%206.427308c2.221786%201.348941%204.443571%202.697882%206.744706%203.967474%203.570727%202.142436%207.300152%204.126173%2010.950229%206.10991l6.18926%203.253329%202.301135%201.269592v12.378519c0%207.379502%200%2014.759004%200.793494%2021.979807%200%202.459834%200.396747%204.840318%200.634796%207.220803%200%204.840318%200.793495%209.759986%201.428291%2014.600305%200%202.777232%200.872844%205.554464%201.269592%208.411045%200.714145%204.364222%201.428291%208.728443%202.221785%2013.013315%200.555446%202.935931%201.190242%205.871862%201.825038%208.728443%200.952194%204.205523%201.904388%207.934948%203.015281%2012.457869s1.50764%205.871862%202.380484%208.728443%202.380484%207.934948%203.729426%2012.140471c0.952194%202.856581%201.825038%205.633813%202.856581%208.490395%201.428291%204.046824%203.01528%207.934948%204.60227%2012.061121%201.110893%202.618533%202.142436%205.316415%203.253329%207.934948%201.825038%204.284872%203.729426%208.411045%205.713163%2012.537219%201.110893%202.301135%202.142436%204.681619%203.332678%206.903405%202.618533%205.316415%205.475114%2010.474132%208.411045%2015.869896%200.555446%201.110893%201.110893%202.221786%201.745689%203.332679%203.570727%206.10991%207.379502%2012.061121%2011.346976%2018.012332%201.269592%201.904388%202.697882%203.808775%204.046824%205.713163%202.777232%203.967474%205.475114%207.934948%208.411045%2011.664374%201.745689%202.301135%203.570727%204.443571%205.395765%206.744706s5.316415%206.586007%207.934948%209.839336%204.046824%204.60227%206.10991%206.824056%205.633813%206.030561%208.490395%209.045841l6.744706%206.586007c2.935931%202.856581%205.871862%205.633813%208.966492%207.934948s4.681619%204.205523%207.062104%206.268609%206.427308%205.316415%209.759986%207.934948%204.760969%203.888125%207.300152%205.713163l2.380485%201.904388A295.894222%20295.894222%200%200%201%20345.170251%20976.39031z%20m335.965711-11.981772a296.608368%20296.608368%200%200%201-146.479145-38.563848c-5.792512-3.332678-11.426326-6.744706-16.90144-10.315433-1.825038-1.190242-3.491377-2.539183-5.237066-3.729426-3.650076-2.459834-7.300152-4.999017-10.79153-7.934948-2.063087-1.50764-3.967474-3.173979-5.871862-4.760969-3.173979-2.459834-6.268609-4.919668-9.283889-7.934949s-3.967474-3.650076-5.951211-5.475114-5.633813-5.078367-7.934949-7.934948-3.808775-4.046824-5.792512-6.10991-5.078367-5.157716-7.458851-7.934949l-5.554464-6.506657c-1.825038-2.142436-4.60227-5.475114-6.824056-7.934949s-3.412028-4.681619-5.157716-7.062104-4.205523-5.633813-6.10991-8.490394-3.253329-4.999017-4.840319-7.458852-3.729426-5.792512-5.475114-8.807792-2.935931-5.157716-4.364222-7.934949-3.332678-6.030561-4.919668-9.045841-2.539183-5.395765-3.808775-7.934948-2.935931-6.18926-4.284872-9.363239-2.301135-5.554464-3.412028-8.411045-2.459834-6.268609-3.570726-9.521938-1.983737-5.792512-2.856582-8.649094-2.063087-6.506658-3.01528-9.759986-1.58699-5.951211-2.301135-8.887142-1.666339-6.586007-2.380485-9.918686S388.812467%20722.471965%20388.812467%20719.536034s-1.190242-6.665357-1.666339-9.998035-0.793495-6.18926-1.110893-9.28389-0.793495-6.824056-1.031543-10.236083%200-6.268609-0.555447-9.363239v-6.665357h0.396748l2.142436%200.634796c4.364222%201.428291%208.807793%202.697882%2013.251363%203.967474l4.840319%201.269592%2011.505675%202.697883%204.52292%201.031543c5.237066%201.031543%2010.474132%201.983737%2015.869897%202.856581h1.348941c4.840318%200.793495%209.759986%201.348941%2014.600305%201.904388l4.919668%200.476097q5.951211%200.634796%2011.902422%200.952194H490.855902a344.456106%20344.456106%200%200%200%20183.138607-52.529358c5.395765-3.412028%2010.71218-7.062104%2015.869896-10.71218%201.745689-1.190242%203.332678-2.539183%205.078367-3.729426%203.412028-2.539183%206.903405-5.157716%2010.236084-7.934948l5.713162-4.760969c3.01528-2.459834%206.030561-4.999017%208.966492-7.934949l5.633813-5.237066c2.856581-2.618533%205.554464-5.237066%207.934949-7.934948l5.475114-5.633813c2.618533-2.697882%205.237066-5.475114%207.934948-8.331696l5.078367-5.713163%207.458851-9.045841%204.522921-5.633813%207.934948-10.315433%203.570727-4.999017c3.173979-4.60227%206.268609-9.363239%209.20454-14.203558l1.031543-1.586989c3.332678-5.475114%206.506658-11.029578%209.601288-16.663392%200.634796-1.190242%201.190242-2.380484%201.745688-3.570727%202.301135-4.443571%204.60227-8.887142%206.665357-13.410062%200.872844-1.825038%201.666339-3.729426%202.539183-5.554464%201.745689-3.967474%203.491377-7.934948%205.078367-11.902422%200.793495-2.063087%201.58699-4.205523%202.459834-6.347959%201.428291-3.808775%202.856581-7.934948%204.126173-11.505675%200.793495-2.221786%201.50764-4.522921%202.221786-6.744706%201.190242-3.808775%202.380484-7.934948%203.491377-11.585025%200.634796-2.301135%201.269592-4.60227%201.825038-6.903405%201.031543-3.967474%201.904388-7.934948%202.777232-11.902422%200.555446-2.301135%201.031543-4.522921%201.50764-6.824056%200-1.031543%200.476097-2.142436%200.634796-3.173979a297.560561%20297.560561%200%200%201-148.304183%20555.446381z'%20fill='%23ffffff'%20p-id='6758'%3e%3c/path%3e%3c/svg%3e`,J={brightness:1,saturation:0,contrast:0,hueRotate:0},Ze=[{key:`brightness`,label:`亮度`,min:0,max:1,step:.01},{key:`saturation`,label:`饱和度`,min:-1,max:1,step:.01},{key:`contrast`,label:`对比度`,min:-1,max:1,step:.01},{key:`hueRotate`,label:`色相`,min:0,max:360,step:1}];function Qe({map:e,value:t,onChange:n,rasterPaintLayerIds:r=[],className:i,style:a}){let[o,s]=(0,c.useState)(!1),[l,u]=(0,c.useState)({...J}),d=(0,c.useRef)(null),f=(0,c.useRef)(null),h=t!==void 0;(0,c.useEffect)(()=>{let e=e=>{d.current&&!d.current.contains(e.target)&&f.current&&!f.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=(0,c.useMemo)(()=>h?{brightness:t.brightness??J.brightness,saturation:t.saturation??J.saturation,contrast:t.contrast??J.contrast,hueRotate:t.hueRotate??J.hueRotate}:l,[h,t,l]),_=(0,c.useRef)(h);(0,c.useEffect)(()=>{h&&!_.current&&u({...g}),_.current=h},[h,g]);let v=(0,c.useCallback)(t=>{if(!(!e||r.length===0))for(let n of r)e.getLayer(n)&&(e.setPaintProperty(n,`raster-brightness-min`,0),e.setPaintProperty(n,`raster-brightness-max`,t.brightness),e.setPaintProperty(n,`raster-saturation`,t.saturation),e.setPaintProperty(n,`raster-contrast`,t.contrast),e.setPaintProperty(n,`raster-hue-rotate`,t.hueRotate))},[e,r]),y=(0,c.useCallback)((e,t)=>{if(h)n?.({...g,[e]:t});else{let n={...l,[e]:t};u(n),v(n)}},[h,n,g,l,v]),b=(0,c.useCallback)(()=>{h?n?.({...J}):(u({...J}),v({...J}))},[h,n,v]);(0,c.useEffect)(()=>{!h&&r.length>0&&v(l)},[r,h,v,l]);let x=(e,t)=>e===`hueRotate`?`${Math.round(t)}°`:t.toFixed(2);return(0,p.jsxs)(`div`,{className:`mapbox-raster-paint-control${i?` ${i}`:``}`,style:a,children:[(0,p.jsxs)(`button`,{ref:f,className:`mapbox-control-btn mapbox-raster-paint-control__btn${o?` mapbox-raster-paint-control__btn--active`:``}`,onClick:()=>s(!o),title:`栅格渲染调节`,children:[(0,p.jsx)(`img`,{className:`mapbox-control-btn__icon mapbox-raster-paint-control__btn-icon`,src:Xe,alt:`raster paint`}),(0,p.jsx)(`span`,{children:`渲染`})]}),o&&(0,p.jsxs)(`div`,{ref:d,className:`mapbox-raster-paint-control__panel`,children:[Ze.map(({key:e,label:t,min:n,max:r,step:i})=>(0,p.jsxs)(`div`,{className:`mapbox-raster-paint-control__slider-row`,children:[(0,p.jsx)(`span`,{className:`mapbox-raster-paint-control__label`,children:t}),(0,p.jsx)(m.Slider,{className:`mapbox-raster-paint-control__slider`,min:n,max:r,step:i,value:g[e],onChange:t=>y(e,t),tooltipVisible:!1}),(0,p.jsx)(`span`,{className:`mapbox-raster-paint-control__value`,children:x(e,g[e])})]},e)),(0,p.jsx)(`button`,{className:`mapbox-raster-paint-control__reset`,onClick:b,children:`重置`})]})]})}var $e=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769397418113'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='10253'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M755.4048%20217.2928A348.3648%20348.3648%200%200%200%20512%20119.3472a348.3136%20348.3136%200%200%200-243.3536%2097.8944%20328.4992%20328.4992%200%200%200-100.864%20236.3392c0%2049.408%2011.7248%2095.744%2032%20137.728a378.0096%20378.0096%200%200%200%2091.136%20118.4256l203.5712%20179.456%2017.5104%2015.4624%2017.5104-15.4624%20203.4176-179.3536a378.6752%20378.6752%200%200%200%2091.2384-118.4768c20.2752-41.984%2032.0512-88.32%2032.0512-137.7792a328.448%20328.448%200%200%200-100.8128-236.288z%20m24.1152%20353.3824a329.216%20329.216%200%200%201-79.872%20103.0656l-188.0064%20164.6592-187.1872-164.7616a329.0624%20329.0624%200%200%201-79.7696-103.0144%20267.0592%20267.0592%200%200%201-27.136-117.0944c0-78.7968%2032.9728-150.1184%2086.272-201.728a298.3936%20298.3936%200%200%201%20208.2816-83.5584c81.3056%200%20154.9824%2031.9488%20208.2304%2083.6096a279.9104%20279.9104%200%200%201%2086.272%20201.728%20266.496%20266.496%200%200%201-27.0848%20117.0944z%20m-164.1472-212.1728l0.0512-0.0512a146.9952%20146.9952%200%200%200-104.2432-43.2128c-40.6528%200-77.568%2016.5376-104.2432%2043.2128l0.0512%200.0512a147.3536%20147.3536%200%200%200-0.0512%20208.6912%20147.0464%20147.0464%200%200%200%20208.4864%200%20147.5072%20147.5072%200%200%200-0.0512-208.6912z%20m-34.1504%20174.2336a97.536%2097.536%200%200%201-69.2736%2028.7232%2097.6384%2097.6384%200%200%201-69.3248-28.7232%2097.792%2097.792%200%200%201-0.1536-138.4448h0.1024a97.9456%2097.9456%200%200%201%20138.5984%200h0.1536c17.664%2017.6128%2028.5696%2042.1376%2028.5696%2069.2224a97.1776%2097.1776%200%200%201-28.672%2069.2224z'%20fill='%23ffffff'%20p-id='10254'%3e%3c/path%3e%3c/svg%3e`;const et=({markerTemplates:e,selectedTemplate:t,onTemplateSelect:n,drawMode:r,onDrawModeChange:i,showRectangleTool:a=!1,showCircleTool:o=!1,showPolygonTool:s=!1,showSquareTool:l=!1,showPolylineTool:u=!1})=>{let[d,f]=(0,c.useState)(!1),m=(0,c.useRef)(null);(0,c.useEffect)(()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&f(!1)};if(d)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[d]);let h=e=>{t?.id===e.id?(n(null),i(null)):(n(e),i(`marker`)),f(!1)},g=()=>{r===`rectangle`?i(null):(n(null),i(`rectangle`))},_=()=>{r===`circle`?i(null):(n(null),i(`circle`))},v=()=>{r===`polygon`?i(null):(n(null),i(`polygon`))},y=()=>{r===`square`?i(null):(n(null),i(`square`))},b=()=>{r===`polyline`?i(null):(n(null),i(`polyline`))},x=()=>{(r===`rectangle`||r===`circle`||r===`polygon`||r===`square`||r===`polyline`)&&i(null),f(!d)},S=e=>e.size?{width:e.size,height:e.size}:{width:e.width||32,height:e.height||32},C=d||t,w=r===`rectangle`,T=r===`circle`,E=r===`polygon`,D=r===`square`,O=r===`polyline`;return(0,p.jsxs)(`div`,{ref:m,className:`mapbox-edit-control`,children:[(0,p.jsxs)(`div`,{className:`mapbox-edit-control__btn-group`,children:[(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${C?`mapbox-control-btn--active`:``}`,onClick:x,title:`Marker`,children:[t?(0,p.jsx)(`img`,{src:t.icon,alt:t.name,className:`mapbox-edit-control__btn-icon`}):(0,p.jsx)(`img`,{src:$e,alt:`marker`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:t?t.name:`Marker`})]}),l&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${D?`mapbox-control-btn--active`:``}`,onClick:y,title:`绘制正方形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='192'%20y='192'%20width='640'%20height='640'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`square`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`正方形`})]}),a&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${w?`mapbox-control-btn--active`:``}`,onClick:g,title:`绘制矩形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3crect%20x='160'%20y='240'%20width='704'%20height='544'%20rx='32'%20ry='32'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`rectangle`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`矩形`})]}),o&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${T?`mapbox-control-btn--active`:``}`,onClick:_,title:`绘制圆形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3ccircle%20cx='512'%20cy='512'%20r='384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'/%3e%3c/svg%3e`,alt:`circle`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`圆形`})]}),s&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${E?`mapbox-control-btn--active`:``}`,onClick:v,title:`绘制多边形`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolygon%20points='512,128%20864,384%20736,800%20288,800%20160,384'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'/%3e%3c/svg%3e`,alt:`polygon`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`多边形`})]}),u&&(0,p.jsxs)(`button`,{className:`mapbox-control-btn ${O?`mapbox-control-btn--active`:``}`,onClick:b,title:`绘制折线`,children:[(0,p.jsx)(`img`,{src:`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='128'%20height='128'%3e%3cpolyline%20points='160,768%20384,256%20640,576%20864,192'%20fill='none'%20stroke='%23ffffff'%20stroke-width='64'%20stroke-linejoin='round'%20stroke-linecap='round'/%3e%3c/svg%3e`,alt:`polyline`,className:`mapbox-edit-control__btn-icon mapbox-edit-control__btn-icon--lg`}),(0,p.jsx)(`span`,{children:`折线`})]})]}),d&&(0,p.jsxs)(`div`,{className:`mapbox-edit-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-edit-control__panel-header`,children:`选择 Marker`}),(0,p.jsx)(`div`,{className:`mapbox-edit-control__template-list`,children:e.map(e=>{let n=S(e),r=t?.id===e.id;return(0,p.jsxs)(`div`,{className:`mapbox-edit-control__template-item ${r?`mapbox-edit-control__template-item--selected`:``}`,onClick:()=>h(e),title:e.name,children:[(0,p.jsx)(`img`,{src:e.icon,alt:e.name,className:`mapbox-edit-control__template-icon`,style:{width:Math.min(n.width,24),height:Math.min(n.height,24)}}),(0,p.jsx)(`span`,{className:`mapbox-edit-control__template-name`,children:e.name})]},e.id)})})]})]})},tt=({menuState:e,onClose:t,portalContainer:n,menuRef:r})=>{let i=(0,c.useRef)(null);(0,c.useEffect)(()=>(r&&(r.current=i.current),()=>{r&&(r.current=null)}));let a=(0,c.useCallback)(e=>{i.current&&!i.current.contains(e.target)&&t()},[t]),o=(0,c.useCallback)(e=>{e.key===`Escape`&&t()},[t]);(0,c.useEffect)(()=>{let e=setTimeout(()=>{document.addEventListener(`click`,a,!0),document.addEventListener(`contextmenu`,a,!0)},0);return document.addEventListener(`keydown`,o),()=>{clearTimeout(e),document.removeEventListener(`click`,a,!0),document.removeEventListener(`contextmenu`,a,!0),document.removeEventListener(`keydown`,o)}},[a,o]);let s={...e.position};if(i.current){let e=i.current.getBoundingClientRect();s.x+e.width>window.innerWidth&&(s.x=window.innerWidth-e.width-10),s.y+e.height>window.innerHeight&&(s.y=window.innerHeight-e.height-10)}let l=(0,p.jsx)(`div`,{ref:i,className:`context-menu`,style:{position:`fixed`,left:`${s.x}px`,top:`${s.y}px`,pointerEvents:`all`},children:e.items.map(e=>(0,p.jsxs)(`div`,{className:`context-menu__item ${e.danger?`context-menu__item--danger`:``}`,onClick:()=>{e.onClick(),t()},children:[e.icon&&(0,p.jsx)(`span`,{className:`context-menu__item-icon`,children:e.icon}),(0,p.jsx)(`span`,{className:`context-menu__item-label`,children:e.label})]},e.key))});return(0,f.createPortal)(l,n)};var nt=`data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775031767174'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='30653'%20data-spm-anchor-id='a313x.search_index.0.i6.78953a81FCkAe0'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='64'%20height='64'%3e%3cpath%20d='M322.24%20479.210667l-42.453333-42.432%20198.826666-198.826667c53.397333-53.376%20139.306667-53.568%20191.914667-0.981333%2052.608%2052.608%2052.416%20138.517333-0.981333%20191.914666L455.722667%20642.709333l-42.432-42.453333%20213.824-213.802667a74.773333%2074.773333%200%200%200-0.341334-105.728%2074.773333%2074.773333%200%200%200-105.728-0.341333l-198.826666%20198.826667z'%20fill='%23ffffff'%20p-id='30654'%3e%3c/path%3e%3cpath%20d='M699.093333%20613.333333l42.453334%2042.432-169.429334%20169.408c-48.341333%2048.341333-129.28%2042.282667-181.248-9.664-51.968-51.968-58.026667-132.906667-9.664-181.248l234.346667-234.346666%2042.432%2042.410666L423.616%20676.693333c-22.250667%2022.250667-19.050667%2065.024%2011.008%2095.061334%2030.037333%2030.058667%2072.810667%2033.258667%2095.061333%2010.986666l169.429334-169.408zM187.989333%20571.029333c-38.933333-38.933333-38.805333-102.613333%200.853334-142.293333%2039.68-39.68%20103.381333-39.808%20142.293333-0.853333%2038.954667%2038.912%2038.826667%20102.613333-0.853333%20142.293333-39.68%2039.658667-103.381333%2039.786667-142.293334%200.853333z%20m43.733334-43.733333c15.744%2015.744%2040.874667%2015.68%2056.128%200.426667%2015.253333-15.232%2015.296-40.362667-0.426667-56.106667-15.765333-15.744-40.896-15.701333-56.149333-0.448-15.232%2015.232-15.296%2040.384%200.448%2056.106667z'%20fill='%23ffffff'%20p-id='30655'%3e%3c/path%3e%3cpath%20d='M846.144%20489.728l-31.466667%20198.784-56.96-101.461333-104.042666-38.506667z'%20fill='%23ffffff'%20p-id='30656'%3e%3c/path%3e%3c/svg%3e`,Y=`route-planning-temp-line`,rt=`route-planning-temp-line-layer`,X=`route-planning-temp-point-layer`;const it=(0,c.forwardRef)(({map:e,pointCount:t=2,showPointCountInput:n=!1,visualType:r=`marker`,onSelectFinished:i,showButton:a=!0},o)=>{let[s,u]=(0,c.useState)(`idle`),[d,f]=(0,c.useState)(0),[m,h]=(0,c.useState)(t),[g,_]=(0,c.useState)(!1),v=(0,c.useRef)(null),y=(0,c.useRef)(null),b=(0,c.useRef)([]),x=(0,c.useRef)([]),S=(0,c.useRef)(`idle`),C=(0,c.useRef)(null),w=(0,c.useRef)(``);(0,c.useEffect)(()=>{S.current=s},[s]),(0,c.useEffect)(()=>{h(t)},[t]),(0,c.useEffect)(()=>{if(!g)return;let e=e=>{y.current&&!y.current.contains(e.target)&&v.current&&!v.current.contains(e.target)&&_(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[g]);let T=(0,c.useCallback)(()=>{for(let e of x.current)e.remove();x.current=[],e&&(e.getLayer(rt)&&e.removeLayer(rt),e.getLayer(X)&&e.removeLayer(X),e.getSource(Y)&&e.removeSource(Y))},[e]),E=(0,c.useCallback)(()=>{if(!e)return;let t=b.current,n={type:`FeatureCollection`,features:[{type:`Feature`,properties:{},geometry:{type:`LineString`,coordinates:t.length>=2?t:[]}},...t.map((e,t)=>({type:`Feature`,properties:{index:t},geometry:{type:`Point`,coordinates:e}}))]},r=e.getSource(Y);r?r.setData(n):(e.addSource(Y,{type:`geojson`,data:n}),e.addLayer({id:rt,type:`line`,source:Y,filter:[`==`,`$type`,`LineString`],paint:{"line-color":`#4A90D9`,"line-width":3,"line-dasharray":[2,2]}}),e.addLayer({id:X,type:`circle`,source:Y,filter:[`==`,`$type`,`Point`],paint:{"circle-radius":6,"circle-color":`#4A90D9`,"circle-stroke-width":2,"circle-stroke-color":`#fff`}}))},[e]),D=(0,c.useCallback)(t=>{if(!e||!C.current)return;let{visualType:n}=C.current;if(n===`marker`){let n=document.createElement(`div`);n.className=`route-planning-temp-marker`,n.textContent=String(b.current.length);let r=new l.default.Marker({element:n}).setLngLat(t).addTo(e);x.current.push(r)}else E()},[e,E]),O=(0,c.useCallback)(()=>{if(T(),b.current=[],C.current=null,f(0),u(`idle`),e)try{e.getCanvas().style.cursor=w.current}catch{}},[T,e]),k=(0,c.useCallback)(async()=>{let e=C.current,t=[...b.current];if(!e||t.length<2){O();return}u(`planning`);try{await e.onSelectFinished(t)}catch(e){console.error(`Route planning onSelectFinished failed:`,e)}finally{O()}},[O]),ee=(0,c.useCallback)(e=>{if(S.current!==`selecting`||!C.current)return;let t=[e.lngLat.lng,e.lngLat.lat];b.current.push(t);let n=b.current.length;f(n),D(t),n>=C.current.pointCount&&k()},[D,k]),A=(0,c.useCallback)(e=>{S.current===`selecting`&&(e.preventDefault(),O())},[O]);(0,c.useEffect)(()=>{if(e&&s===`selecting`)return e.on(`click`,ee),e.on(`contextmenu`,A),()=>{if(e)try{e.off(`click`,ee),e.off(`contextmenu`,A)}catch{}}},[e,s,ee,A]);let j=(0,c.useCallback)(n=>{if(!e)return;S.current!==`idle`&&O();let i=Math.max(2,n.pointCount??t),a=n.visualType??r;C.current={pointCount:i,visualType:a,onSelectFinished:n.onSelectFinished},b.current=[],f(0),h(i),_(!1),w.current=e.getCanvas().style.cursor,e.getCanvas().style.cursor=`crosshair`,u(`selecting`)},[e,t,r,O]);(0,c.useImperativeHandle)(o,()=>({startPlanning:j}),[j]);let M=()=>{s===`idle`?_(e=>!e):s===`selecting`&&O()},te=()=>{i&&j({pointCount:Math.max(2,m),visualType:r,onSelectFinished:i})},ne=e=>{let t=parseInt(e.target.value,10);!isNaN(t)&&t>=2?h(t):e.target.value===``&&h(2)},N=()=>{if(s===`planning`)return(0,p.jsx)(`span`,{children:`规划中...`});if(s===`selecting`){let e=C.current?.pointCount??m;return(0,p.jsxs)(`span`,{children:[d,`/`,e]})}return`路径规划`},P=s===`selecting`,re=s===`planning`;return!a&&s===`idle`?null:(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control${a?``:` mapbox-route-planning-control--floating`}`,children:[(0,p.jsxs)(`button`,{ref:v,className:`mapbox-control-btn mapbox-route-planning-control__btn${P?` mapbox-route-planning-control__btn--active`:``}${re?` mapbox-route-planning-control__btn--planning`:``}${g?` mapbox-route-planning-control__btn--active`:``}`,onClick:M,disabled:re,title:s===`idle`?`路径规划`:s===`selecting`?`取消选点`:`规划中...`,children:[(0,p.jsx)(`img`,{src:nt,alt:`route`,className:`mapbox-route-planning-control__btn-icon`}),N()]}),g&&s===`idle`&&(0,p.jsxs)(`div`,{ref:y,className:`mapbox-route-planning-control__panel`,children:[(0,p.jsx)(`div`,{className:`mapbox-route-planning-control__panel-header`,children:(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-title`,children:`路径规划`})}),(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control__panel-body`,children:[(0,p.jsxs)(`div`,{className:`mapbox-route-planning-control__panel-row`,children:[(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-label`,children:`选点数量`}),n?(0,p.jsx)(`input`,{type:`number`,className:`mapbox-route-planning-control__panel-input`,value:m,min:2,onChange:ne}):(0,p.jsx)(`span`,{className:`mapbox-route-planning-control__panel-value`,children:m})]}),(0,p.jsx)(`div`,{className:`mapbox-route-planning-control__panel-tip`,children:`左键点击地图选点,右键取消`}),(0,p.jsx)(`button`,{className:`mapbox-route-planning-control__panel-start`,onClick:te,disabled:!i,children:`开始规划`})]})]})]})});it.displayName=`RoutePlanningControl`;function at(e,t,n){return{content:e.content??n??null,trigger:e.trigger??t?.trigger??T.trigger,position:e.position??t?.position??T.position,offset:e.offset??t?.offset??T.offset,showCloseButton:e.showCloseButton??t?.showCloseButton??T.showCloseButton,animation:e.animation??t?.animation??T.animation,className:e.className??``,style:e.style??{},closeOnClickOutside:e.closeOnClickOutside??t?.closeOnClickOutside??T.closeOnClickOutside,closeOnEscape:e.closeOnEscape??t?.closeOnEscape??T.closeOnEscape,hoverDelay:e.hoverDelay??t?.hoverDelay??T.hoverDelay,maxWidth:e.maxWidth??t?.maxWidth??T.maxWidth,zIndex:e.zIndex??t?.zIndex??T.zIndex}}function ot(e,t,n,r,i){let a,o;if(e.type===`polygon`)o=e.center??st(e.coordinates);else if(e.type===`polyline`)o=e.center??ct(e.coordinates);else if(e.type===`rectangle`)if(e.center)o=e.center;else{let[[t,n],[r,i]]=e.bounds;o=[(t+r)/2,(n+i)/2]}else if(e.type===`attack-direction`){let t=e.coordinates;o=e.center??[(t[0][0]+t[1][0]+t[2][0])/3,(t[0][1]+t[1][1]+t[2][1])/3]}else o=e.center;if(!o)return{position:{x:0,y:0},actualPosition:t.position};let s=n.project(o);a={x:s.x,y:s.y};let c=lt(i,t);return ut(a,t.position,t.offset,c)}function st(e){if(!e||e.length===0)return[0,0];let t=[...e];(e[0][0]!==e[e.length-1][0]||e[0][1]!==e[e.length-1][1])&&t.push(e[0]);let n=(0,u.polygon)([t]);return(0,u.centroid)(n).geometry.coordinates}function ct(e){if(!e||e.length===0)return[0,0];let t=0,n=0;for(let r of e)t+=r[0],n+=r[1];return[t/e.length,n/e.length]}function lt(e,t){if(e){let t=e.getBoundingClientRect();return{width:t.width||320,height:t.height||200}}return{width:typeof t.maxWidth==`number`?t.maxWidth:320,height:200}}function ut(e,t,n,r){let i={width:window.innerWidth,height:window.innerHeight},a=(()=>{switch(t){case`top`:return[`top`,`bottom`,`right`,`left`,`center`];case`bottom`:return[`bottom`,`top`,`right`,`left`,`center`];case`left`:return[`left`,`right`,`top`,`bottom`,`center`];case`right`:return[`right`,`left`,`top`,`bottom`,`center`];case`center`:default:return[`center`,`top`,`bottom`,`left`,`right`]}})(),o={top:()=>({x:e.x-r.width/2+n[0],y:e.y-r.height-20+n[1]}),bottom:()=>({x:e.x-r.width/2+n[0],y:e.y+20+n[1]}),left:()=>({x:e.x-r.width-20+n[0],y:e.y-r.height/2+n[1]}),right:()=>({x:e.x+20+n[0],y:e.y-r.height/2+n[1]}),center:()=>({x:e.x-r.width/2+n[0],y:e.y-r.height/2+n[1]})},s=e=>e.x>=10&&e.y>=10&&e.x+r.width+10<=i.width&&e.y+r.height+10<=i.height;for(let e of a){let t=o[e]();if(s(t))return{position:t,actualPosition:e}}let c=o[t]();return{position:dt(c,r),actualPosition:t}}function dt(e,t){let n={width:window.innerWidth,height:window.innerHeight},r={...e};return r.x+t.width+10>n.width&&(r.x=n.width-t.width-10),r.x<10&&(r.x=10),r.y+t.height+10>n.height&&(r.y=n.height-t.height-10),r.y<10&&(r.y=10),r}const ft=(0,c.forwardRef)((e,t)=>{let{center:n=[116.4074,39.9042],zoom:r=12,pitch:i=0,bearing:a=0,style:o=`mapbox://styles/mapbox/dark-v11`,maxBounds:s,mode:u=`display`,editConfig:d={},pickerConfig:f={},onPick:m,interactive:h={},layers:g=[],rasterPaint:_,entities:v=[],selectedIds:y=[],entityConfig:b,nameConfig:C,selectNameConfig:w,areaConfig:T,circleConfig:E,lengthConfig:k,showCoordinates:M=!0,showScale:te=!0,showResetView:ne=!0,showRoadHighlight:N=!1,showMeasure:P=!1,showRasterPaint:re=!1,showRoutePlanning:ie,onRasterPaintChange:ae,popupDefaults:F,renderPopup:I,onMapLoad:oe,onEntityClick:ce,onPopupOpen:pe,onPopupClose:me,className:he=``,containerStyle:ve}=e,L=(0,c.useRef)(null),be=(0,c.useRef)(null),Se=(0,c.useRef)(null),R=(0,c.useRef)(null),z=(0,c.useRef)(new Map),B=(0,c.useRef)(new Map),Oe=(0,c.useRef)(new Set),[V,Ae]=(0,c.useState)(null),je=(0,c.useRef)(null),Me=(0,c.useRef)(null),Ne=(0,c.useRef)(null),[Fe,Ie]=(0,c.useState)(null),Le=(0,c.useRef)(null),Re=(0,c.useRef)(null),[ze,Be]=(0,c.useState)(null),[H,He]=(0,c.useState)(u),[Ue,We]=(0,c.useState)(null),Ge=(0,c.useRef)(null),[Ke,U]=(0,c.useState)(null),[W,G]=(0,c.useState)(null),[qe,Je]=(0,c.useState)(null),K=(0,c.useRef)(!1),q=(0,c.useRef)(null),Xe=(0,c.useRef)(null),J=(0,c.useRef)(null),Ze=(0,c.useRef)(null),$e=(0,c.useRef)(null),nt=(0,c.useRef)(null),Y=(0,c.useRef)(null),rt=(0,c.useRef)([]),X=(0,c.useRef)(null),st=(0,c.useRef)(null),ct=(0,c.useRef)(null),lt=(0,c.useRef)([]),ut=(0,c.useRef)(null),dt=(0,c.useRef)(!1),[ft,pt]=(0,c.useState)([]),mt=(0,c.useRef)([]);mt.current=ft;let Z=(0,c.useRef)(null);(0,c.useEffect)(()=>{He(u)},[u]);let ht=(0,c.useCallback)(e=>{let t=z.current.get(e),n=B.current.get(e);if(t&&n){if(n.type===`radar`&&t instanceof se){let r={...n,isAnimating:!0};B.current.set(e,r),t.startAnimation()}else if(n.type===`circle`&&t instanceof xe){let r={...n,isAnimating:!0};B.current.set(e,r),t.startAnimation()}}},[]),gt=(0,c.useCallback)(e=>{let t=z.current.get(e),n=B.current.get(e);if(t&&n){if(n.type===`radar`&&t instanceof se){let r={...n,isAnimating:!1};B.current.set(e,r),t.stopAnimation()}else if(n.type===`circle`&&t instanceof xe){let r={...n,isAnimating:!1};B.current.set(e,r),t.stopAnimation()}}},[]),_t=(0,c.useCallback)(e=>{let t=B.current.get(e);t&&(t.type===`radar`||t.type===`circle`)&&(t.type,t.isAnimating?gt(e):ht(e))},[ht,gt]),vt=(0,c.useCallback)(e=>{if(e===void 0){let e=!1;for(let[,t]of z.current)if(t instanceof de){let n=t.getShowTrajectory();if(n===`all`||typeof n==`number`&&n>0){e=!0;break}}let t=e?0:`all`;for(let[,e]of z.current)e instanceof de&&e.setShowTrajectory(t)}else{let t=new Set(e.map(String));for(let[e,n]of z.current)n instanceof de&&n.setShowTrajectory(t.has(String(e))?`all`:0)}},[]),yt=(0,c.useCallback)((e,t,n)=>{let r=v.find(t=>String(t.id)===String(e));if(!r?.popup||!R.current)return;let i=r.popup.content??I?.(r);if(!i)return;let a=at(r.popup,F,i),{position:o,actualPosition:s}=ot(r,a,R.current,n);Ae({entityId:e,position:o,config:a,openedBy:t,actualPosition:s}),pe?.(e)},[v,F,I,pe]),bt=(0,c.useCallback)(e=>{V?.entityId===e&&(Ae(null),me?.(e))},[V,me]),xt=(0,c.useCallback)(()=>{Ae(e=>(e&&me?.(e.entityId),null))},[me]),St=(0,c.useCallback)(e=>V?.entityId===e,[V]),Ct=(0,c.useCallback)((e,t,n)=>{let r=R.current;r&&r.flyTo({center:e,zoom:t??r.getZoom(),...n})},[]),wt=(0,c.useCallback)(e=>{if(e.length===0)return null;let t=1/0,n=-1/0,r=1/0,i=-1/0,a=!1;for(let o of e){let e=z.current.get(o);if(e){let[[o,s],[c,l]]=e.getBounds();t=Math.min(t,o),n=Math.max(n,c),r=Math.min(r,s),i=Math.max(i,l),a=!0}}return a?[(t+n)/2,(r+i)/2]:null},[]),Tt=(0,c.useCallback)((e,t,n)=>{let r=R.current;if(!r||e.length===0)return;let i=wt(e);if(!i)return;let a=[];for(let t of e){let e=z.current.get(t);e&&a.push(e.getBounds())}let o=1/0,s=-1/0,c=1/0,l=-1/0;for(let[[e,t],[n,r]]of a)o=Math.min(o,e),s=Math.max(s,n),c=Math.min(c,t),l=Math.max(l,r);let u=o===s&&c===l;if(a.length===1||u){let e={center:i,zoom:t??r.getZoom()};n?.duration!==void 0&&(e.duration=n.duration),n?.pitch!==void 0&&(e.pitch=n.pitch),n?.bearing!==void 0&&(e.bearing=n.bearing),n?.essential!==void 0&&(e.essential=n.essential),r.flyTo(e);return}let d=[[o,c],[s,l]],f={padding:n?.padding??50,duration:n?.duration??1e3,bearing:n?.bearing??r.getBearing(),pitch:n?.pitch??r.getPitch()};t!==void 0&&(f.maxZoom=t),n?.essential!==void 0&&(f.essential=n.essential),r.fitBounds(d,f)},[wt]),Et=(0,c.useRef)(null),Dt=(0,c.useRef)(`display`),[Ot,kt]=(0,c.useState)({}),Q=(0,c.useMemo)(()=>({...f,...Ot}),[f,Ot]),At=(0,c.useCallback)(e=>{let t=R.current;if(!t||!t.getContainer())return;let{showMarker:n=!0,markerColor:r=`#3388ff`,name:i,nameConfig:a}=Q;if(!n){Ge.current&&=(Ge.current.remove(),null);return}if(Ge.current){Ge.current.setLngLat(e);let t=Ge.current.getElement(),n=t.querySelector(`.marker-label`);if(i){let e=x(a,C);if(n)n.textContent=i,n.style.color=e.fillColor,n.style.opacity=String(e.fillOpacity),n.style.webkitTextStrokeColor=e.strokeColor,n.style.webkitTextStrokeWidth=`${e.strokeWidth}px`;else{let n=document.createElement(`div`);n.className=`marker-label`,n.textContent=i,n.style.color=e.fillColor,n.style.opacity=String(e.fillOpacity),n.style.webkitTextStrokeColor=e.strokeColor,n.style.webkitTextStrokeWidth=`${e.strokeWidth}px`,t.appendChild(n)}}else n&&n.remove()}else{let n=document.createElement(`div`);n.className=`mapbox-picker-marker`;let o=document.createElement(`div`);if(o.className=`marker-inner`,o.style.background=r,n.appendChild(o),i){let e=x(a,C),t=document.createElement(`div`);t.className=`marker-label`,t.textContent=i,t.style.color=e.fillColor,t.style.opacity=String(e.fillOpacity),t.style.webkitTextStrokeColor=e.strokeColor,t.style.webkitTextStrokeWidth=`${e.strokeWidth}px`,n.appendChild(t)}Ge.current=new l.default.Marker({element:n,anchor:`bottom`}).setLngLat(e).addTo(t)}},[Q,C]),jt=(0,c.useCallback)(()=>{Ge.current&&=(Ge.current.remove(),null)},[]),Mt=(0,c.useCallback)(()=>`marker-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,[]),Nt=(0,c.useCallback)(e=>{let t=R.current;if(L.current)if(ut.current&&=(ut.current.remove(),null),e&&t){t.getCanvas().style.cursor=`none`;let n=document.createElement(`div`);n.className=`mapbox-custom-cursor`;let r=e.size||e.width||32;n.style.cssText=`
52
52
  position: fixed;
53
53
  pointer-events: none;
54
54
  z-index: 9999;
55
55
  transform: translate(-50%, -50%);
56
56
  opacity: 0.8;
57
- `;let i=document.createElement(`img`);i.src=e.icon,i.style.width=`${r}px`,i.style.height=`${e.size||e.height||r}px`,i.style.objectFit=`contain`,n.appendChild(i),document.body.appendChild(n),ct.current=n;let a=e=>{ct.current&&(ct.current.style.left=`${e.clientX}px`,ct.current.style.top=`${e.clientY}px`)};document.addEventListener(`mousemove`,a),n.dataset.cleanup=`true`,n._cleanup=()=>{document.removeEventListener(`mousemove`,a)}}else t&&(t.getCanvas().style.cursor=``)},[]),$=(0,c.useCallback)(()=>{if(ct.current){let e=ct.current._cleanup;e&&e(),ct.current.remove(),ct.current=null}let e=R.current;e&&(e.getCanvas().style.cursor=``)},[]),Mt=(0,c.useCallback)((e,t,n)=>{if(!e.getSource(t)){if(!e.getStyle().glyphs){let t=e.style,n=`/gis-fonts/{fontstack}/{range}.pbf`;t.glyphs=n,t.stylesheet&&(t.stylesheet.glyphs=n)}e.addSource(t,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:n,type:`symbol`,source:t,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-rotation-alignment":`map`,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0, 0, 0, 0.8)`,"text-halo-width":1}})}},[]),Nt=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`rect-preview-source`)||(e.addSource(`rect-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`rect-preview-fill`,type:`fill`,source:`rect-preview-source`,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.addLayer({id:`rect-preview-line`,type:`line`,source:`rect-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),Mt(e,`rect-preview-measure-source`,`rect-preview-measure-label`)))},[Mt]),Pt=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`rect-preview-source`);if(!r)return;let[i,a]=e,[o,s]=t,c=[[Math.min(i,o),Math.max(a,s)],[Math.max(i,o),Math.max(a,s)],[Math.max(i,o),Math.min(a,s)],[Math.min(i,o),Math.min(a,s)],[Math.min(i,o),Math.max(a,s)]];r.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[c]},properties:{}});let l=q.current,u=l?.strokeColor??`#3388ff`,d=l?.strokeWidth??2,f=l?.fillColor??`#3388ff`,p=l?.fillOpacity??.1;n.getLayer(`rect-preview-line`)&&(n.setPaintProperty(`rect-preview-line`,`line-color`,u),n.setPaintProperty(`rect-preview-line`,`line-width`,d)),n.getLayer(`rect-preview-fill`)&&(n.setPaintProperty(`rect-preview-fill`,`fill-color`,f),n.setPaintProperty(`rect-preview-fill`,`fill-opacity`,p));let m=n.getSource(`rect-preview-measure-source`);if(m){let e=In.current,t=[],n=c[0],r=c[1],i=c[2];if(e?.showArea){let e=[(n[0]+i[0])/2,(n[1]+i[1])/2],a=O(n,r),o=O(r,i);t.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:A(a*o)}})}if(e?.showLength){let e=[(n[0]+r[0])/2,(n[1]+r[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:j(O(n,r))}});let a=[(r[0]+i[0])/2,(r[1]+i[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{label:j(O(r,i))}})}m.setData({type:`FeatureCollection`,features:t})}},[]),Ft=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`rect-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`rect-preview-measure-source`);n&&n.setData({type:`FeatureCollection`,features:[]})},[]),It=(0,c.useCallback)(()=>{Je(null),Ft()},[Ft]),Lt=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`circle-preview-source`)||(e.addSource(`circle-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`circle-preview-fill`,type:`fill`,source:`circle-preview-source`,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.addLayer({id:`circle-preview-line`,type:`line`,source:`circle-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),Mt(e,`circle-preview-measure-source`,`circle-preview-measure-label`),e.getSource(`circle-preview-radius-source`)||(e.addSource(`circle-preview-radius-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`circle-preview-radius-line`,type:`line`,source:`circle-preview-radius-source`,paint:{"line-color":`#ffffff`,"line-width":1,"line-opacity":1,"line-dasharray":[4,4]}}))))},[Mt]),Rt=(0,c.useCallback)((e,t,n=64)=>{let[r,i]=e,a=[],o=t/6371e3,s=i*Math.PI/180;for(let e=0;e<=n;e++){let t=e/n*2*Math.PI,c=o*Math.cos(t),l=o*Math.sin(t)/Math.cos(s),u=i+c*180/Math.PI,d=r+l*180/Math.PI;a.push([d,u])}return a},[]),zt=(0,c.useCallback)((e,t)=>{let[n,r]=e,[i,a]=t,o=(a-r)*Math.PI/180,s=(i-n)*Math.PI/180,c=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))},[]),Bt=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`circle-preview-source`);if(!r)return;let i=zt(e,t),a=Rt(e,i);r.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[a]},properties:{}});let o=J.current,s=o?.strokeColor??`#3388ff`,c=o?.strokeWidth??2,l=o?.fillColor??`#3388ff`,u=o?.fillOpacity??.1;n.getLayer(`circle-preview-line`)&&(n.setPaintProperty(`circle-preview-line`,`line-color`,s),n.setPaintProperty(`circle-preview-line`,`line-width`,c)),n.getLayer(`circle-preview-fill`)&&(n.setPaintProperty(`circle-preview-fill`,`fill-color`,l),n.setPaintProperty(`circle-preview-fill`,`fill-opacity`,u));let d=In.current,f=[],p=[];if(d?.showArea){let t=Math.PI*i*i;f.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:A(t)}})}if(d?.showRadius){let t=J.current?.radiusAngle??90,n=D(e,i,t),r=[(e[0]+n[0])/2,(e[1]+n[1])/2];p.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[e,n]},properties:{}}),f.push({type:`Feature`,geometry:{type:`Point`,coordinates:r},properties:{label:j(i)}})}let m=n.getSource(`circle-preview-measure-source`);m&&m.setData({type:`FeatureCollection`,features:f});let h=n.getSource(`circle-preview-radius-source`);h&&h.setData({type:`FeatureCollection`,features:p})},[zt,Rt]),Vt=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`circle-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`circle-preview-measure-source`);n&&n.setData({type:`FeatureCollection`,features:[]});let r=e.getSource(`circle-preview-radius-source`);r&&r.setData({type:`FeatureCollection`,features:[]})},[]),Ht=(0,c.useCallback)(()=>{Ze.current=null,Vt()},[Vt]),Ut=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`polygon-preview-source`)||(e.addSource(`polygon-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`polygon-preview-fill`,type:`fill`,source:`polygon-preview-source`,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.addLayer({id:`polygon-preview-line`,type:`line`,source:`polygon-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),e.addSource(`polygon-vertices-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`polygon-vertices`,type:`circle`,source:`polygon-vertices-source`,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}}),Mt(e,`polygon-preview-measure-source`,`polygon-preview-measure-label`)))},[Mt]),Wt=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`polygon-preview-source`),i=n.getSource(`polygon-vertices-source`);if(!r||!i)return;let a=[...e,t];if(a.length>=3){let e=[...a,a[0]];r.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[e]},properties:{}})}else a.length===2?r.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:a},properties:{}}):r.setData({type:`FeatureCollection`,features:[]});i.setData({type:`FeatureCollection`,features:e.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=Y.current,s=o?.strokeColor??`#3388ff`,c=o?.strokeWidth??2,l=o?.fillColor??`#3388ff`,u=o?.fillOpacity??.1;n.getLayer(`polygon-preview-line`)&&(n.setPaintProperty(`polygon-preview-line`,`line-color`,s),n.setPaintProperty(`polygon-preview-line`,`line-width`,c)),n.getLayer(`polygon-preview-fill`)&&(n.setPaintProperty(`polygon-preview-fill`,`fill-color`,l),n.setPaintProperty(`polygon-preview-fill`,`fill-opacity`,u)),n.getLayer(`polygon-vertices`)&&n.setPaintProperty(`polygon-vertices`,`circle-color`,s);let d=n.getSource(`polygon-preview-measure-source`);if(d){let e=In.current,t=[];if(e?.showArea&&a.length>=3){let e=[...a,a[0]],n=ee(e),r=0,i=0;for(let e of a)r+=e[0],i+=e[1];r/=a.length,i/=a.length,t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r,i]},properties:{label:A(n)}})}if(e?.showLength&&a.length>=2){for(let e=0;e<a.length-1;e++){let n=a[e],r=a[e+1],i=[(n[0]+r[0])/2,(n[1]+r[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:i},properties:{label:j(O(n,r))}})}if(a.length>=3){let e=a[a.length-1],n=a[0],r=[(e[0]+n[0])/2,(e[1]+n[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:r},properties:{label:j(O(e,n))}})}}d.setData({type:`FeatureCollection`,features:t})}},[]),Gt=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`polygon-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`polygon-vertices-source`);n&&n.setData({type:`FeatureCollection`,features:[]});let r=e.getSource(`polygon-preview-measure-source`);r&&r.setData({type:`FeatureCollection`,features:[]})},[]),Kt=(0,c.useCallback)(()=>{tt.current=[],Gt()},[Gt]),qt=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`square-preview-source`)||(e.addSource(`square-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`square-preview-fill`,type:`fill`,source:`square-preview-source`,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.addLayer({id:`square-preview-line`,type:`line`,source:`square-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),Mt(e,`square-preview-measure-source`,`square-preview-measure-label`)))},[Mt]),Jt=(0,c.useCallback)((e,t)=>{let[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r+o],[n+s,r+o],[n+s,r-o],[n-s,r-o],[n-s,r+o]]},[]),Yt=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`square-preview-source`);if(!r)return;let i=zt(e,t)*2,a=Jt(e,i);r.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[a]},properties:{}});let o=X.current,s=o?.strokeColor??`#3388ff`,c=o?.strokeWidth??2,l=o?.fillColor??`#3388ff`,u=o?.fillOpacity??.1;n.getLayer(`square-preview-line`)&&(n.setPaintProperty(`square-preview-line`,`line-color`,s),n.setPaintProperty(`square-preview-line`,`line-width`,c)),n.getLayer(`square-preview-fill`)&&(n.setPaintProperty(`square-preview-fill`,`fill-color`,l),n.setPaintProperty(`square-preview-fill`,`fill-opacity`,u));let d=n.getSource(`square-preview-measure-source`);if(d){let t=In.current,n=[];if(t?.showArea&&n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:A(i*i)}}),t?.showLength){let e=[(a[1][0]+a[2][0])/2,(a[1][1]+a[2][1])/2];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:j(i)}})}d.setData({type:`FeatureCollection`,features:n})}},[zt,Jt]),Xt=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`square-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`square-preview-measure-source`);n&&n.setData({type:`FeatureCollection`,features:[]})},[]),Zt=(0,c.useCallback)(()=>{nt.current=null,Xt()},[Xt]),Qt=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`polyline-preview-source`)||(e.addSource(`polyline-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`polyline-preview-line`,type:`line`,source:`polyline-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),e.addSource(`polyline-vertices-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`polyline-vertices`,type:`circle`,source:`polyline-vertices-source`,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}}),Mt(e,`polyline-preview-measure-source`,`polyline-preview-measure-label`)))},[Mt]),$t=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`polyline-preview-source`),i=n.getSource(`polyline-vertices-source`);if(!r||!i)return;let a=[...e,t];a.length>=2?r.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:a},properties:{}}):r.setData({type:`FeatureCollection`,features:[]}),i.setData({type:`FeatureCollection`,features:e.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=rt.current,s=o?.strokeColor??`#3388ff`,c=o?.strokeWidth??2;n.getLayer(`polyline-preview-line`)&&(n.setPaintProperty(`polyline-preview-line`,`line-color`,s),n.setPaintProperty(`polyline-preview-line`,`line-width`,c)),n.getLayer(`polyline-vertices`)&&n.setPaintProperty(`polyline-vertices`,`circle-color`,s);let l=n.getSource(`polyline-preview-measure-source`);if(l){let e=In.current,t=[];if(e?.showLength&&a.length>=2)for(let e=0;e<a.length-1;e++){let n=a[e],r=a[e+1],i=[(n[0]+r[0])/2,(n[1]+r[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:i},properties:{label:j(O(n,r))}})}l.setData({type:`FeatureCollection`,features:t})}},[]),en=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`polyline-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`polyline-vertices-source`);n&&n.setData({type:`FeatureCollection`,features:[]});let r=e.getSource(`polyline-preview-measure-source`);r&&r.setData({type:`FeatureCollection`,features:[]})},[]),tn=(0,c.useCallback)(()=>{st.current=[],en()},[en]),nn=(0,c.useCallback)(e=>{U(e),jt(e),e?(G(`marker`),It(),Ht(),Kt(),Zt(),tn()):G(null)},[jt,It,Ht,Kt,Zt,tn]),rn=(0,c.useCallback)(e=>{if(G(e),e===`rectangle`){U(null),$(),Ht(),Kt(),Zt(),tn();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else if(e===`circle`){U(null),$(),It(),Kt(),Zt(),tn();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else if(e===`polygon`){U(null),$(),It(),Ht(),Zt(),tn();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else if(e===`square`){U(null),$(),It(),Ht(),Kt(),tn();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else if(e===`polyline`){U(null),$(),It(),Ht(),Kt(),Zt();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else e===`marker`?(It(),Ht(),Kt(),Zt(),tn()):(U(null),$(),It(),Ht(),Kt(),Zt(),tn())},[$,It,Ht,Kt,Zt,tn]),an=(0,c.useCallback)(e=>{if(e!==`picker`){let e=Q.value&&isFinite(Q.value.lng)&&isFinite(Q.value.lat),t=Q.showMarker!==!1;(!e||!t)&&kt(),We(null)}e!==`edit`&&(U(null),G(null),It(),tn(),$()),He(e)},[kt,$,It,tn]),on=(0,c.useCallback)(()=>H,[H]),sn=(0,c.useCallback)(()=>Ue,[Ue]),cn=(0,c.useCallback)(()=>{kt(),We(null)},[kt]),ln=(0,c.useCallback)((e={})=>(wt.current&&=(wt.current(null),null),new Promise(t=>{wt.current=t,Tt.current=An.current,Dt(e),an(`picker`)})),[an]);(0,c.useEffect)(()=>{if(!ze)return;let e=Q.value;if(e&&isFinite(e.lng)&&isFinite(e.lat)){let t=[e.lng,e.lat];We(e),Ot(t)}},[Q.value,Ot,ze]);let un=e=>`mode`in e,dn=(0,c.useCallback)((e,t=!0)=>{if(He(`edit`),t&&(kt(),We(null)),K.current=!0,un(e)){if(e.mode===`marker`)e.markerStyle?(Xe.current=e.markerStyle,q.current=null,J.current=null,Y.current=null,X.current=null,rt.current=null,U(null),G(`marker`),e.markerStyle.src&&e.markerStyle.width?jt({id:`custom`,name:e.markerStyle.name||`Marker`,icon:e.markerStyle.src,width:e.markerStyle.width}):$()):e.template&&(Xe.current=null,q.current=null,J.current=null,Y.current=null,X.current=null,rt.current=null,U(e.template),G(`marker`),jt(e.template));else if(e.mode===`rectangle`){q.current=e.rectangleStyle||null,Xe.current=null,J.current=null,Y.current=null,X.current=null,rt.current=null,U(null),G(`rectangle`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}else if(e.mode===`circle`){J.current=e.circleStyle||null,q.current=null,Xe.current=null,Y.current=null,X.current=null,rt.current=null,U(null),G(`circle`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}else if(e.mode===`polygon`){Y.current=e.polygonStyle||null,q.current=null,Xe.current=null,J.current=null,X.current=null,rt.current=null,U(null),G(`polygon`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}else if(e.mode===`square`){X.current=e.squareStyle||null,q.current=null,Xe.current=null,J.current=null,Y.current=null,rt.current=null,U(null),G(`square`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}else if(e.mode===`polyline`){rt.current=e.polylineStyle||null,q.current=null,Xe.current=null,J.current=null,Y.current=null,X.current=null,U(null),G(`polyline`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}}else U(e),G(`marker`),jt(e),q.current=null,Xe.current=null,J.current=null,Y.current=null,X.current=null,rt.current=null},[kt,jt,$]);(0,c.useImperativeHandle)(t,()=>({startAnimation:pt,stopAnimation:mt,toggleAnimation:ht,getMap:()=>R.current,openPopup:e=>_t(e,`programmatic`),closePopup:vt,closeAllPopups:yt,isPopupOpen:bt,toggleUnitTrajectory:gt,flyTo:xt,getCenterByIds:St,flyToEntities:Ct,getMode:on,setMode:an,getPickedLocation:sn,clearPickedLocation:cn,startDrawing:dn,getRenderer:e=>z.current.get(e),setEditingEntities:e=>{for(let t of ft.current)e.map(String).includes(String(t))||z.current.get(t)?.setEditing?.(!1);for(let t of e)z.current.get(t)?.setEditing?.(!0);Z.current&&=(z.current.get(Z.current.entityId)?.cancelEditPreview?.(),null),dt(e)},getEditingEntities:()=>ft.current,startPicking:ln,startRoutePlanning:e=>{be.current?.startPlanning(e)},getRoadHighlightControl:()=>Se.current}),[pt,mt,ht,_t,vt,yt,bt,gt,xt,St,Ct,on,an,sn,cn,dn,ln]);let fn=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=new Set(v.map(e=>e.id)),n=new Set(z.current.keys());for(let e of n)t.has(e)||(z.current.get(e)?.destroy(),z.current.delete(e));let r=new Set(y.map(String));for(let t of v){let n=S(t,b),i=z.current.get(n.id);if(i)if(n.type===`radar`&&i instanceof se)i.update(n);else if(n.type===`image`&&i instanceof le)i.update(n);else if(n.type===`marker`&&i instanceof ue)i.update(n);else if(n.type===`unit`&&i instanceof de)i.update(n);else if(n.type===`polygon`&&i instanceof fe)i.update(n);else if(n.type===`circle`)if(n.fillType===`radial-gradient`)if(i instanceof xe)i.update(n);else{i.destroy();let t=new xe(e,n,C,w,T,E);z.current.set(n.id,t),t.setSelected(r.has(String(n.id)))}else if(i instanceof ye)i.update(n);else{i.destroy();let t=new ye(e,n,C,w,T,E);z.current.set(n.id,t),t.setSelected(r.has(String(n.id)))}else (n.type===`square`&&i instanceof Ce||n.type===`rectangle`&&i instanceof we||n.type===`polyline`&&i instanceof _e||n.type===`attack-direction`&&i instanceof ge)&&i.update(n);else{let t=null;n.type===`radar`?t=new se(e,n,C,w):n.type===`image`?t=new le(e,n,C,w):n.type===`marker`?t=new ue(e,n,C,w):n.type===`unit`?t=new de(e,n,C,w):n.type===`polygon`?t=new fe(e,n,C,w,T,k):n.type===`circle`?t=n.fillType===`radial-gradient`?new xe(e,n,C,w,T,E):new ye(e,n,C,w,T,E):n.type===`square`?t=new Ce(e,n,C,w,T,k):n.type===`rectangle`?t=new we(e,n,C,w,T,k):n.type===`polyline`?t=new _e(e,n,C,w,k):n.type===`attack-direction`&&(t=new ge(e,n,C,w)),t&&(z.current.set(n.id,t),t.setSelected(r.has(String(n.id))),ft.current.map(String).includes(String(n.id))&&t.setEditing?.(!0))}}for(let e of ft.current){let t=z.current.get(e);t&&t.setEditing?.(!0)}},[v,y,b,C,w,T,E,k]),pn=(0,c.useCallback)(()=>{for(let e of z.current.values())e.destroy();z.current.clear()},[]),mn=(0,c.useCallback)(e=>{let t=e.getStyle();if(!t?.layers)return;let n=[`polygon-`,`polyline-`,`circle-`,`square-`,`rectangle-`,`radar-`,`image-`,`unit-`,`marker-`,`attack-direction-`];for(let e of t.layers)if(n.some(t=>e.id.startsWith(t)))return e.id},[]),hn=(0,c.useCallback)(e=>{let t=_,n={"raster-opacity":e.opacity??1},r=e.brightness??t?.brightness,i=e.saturation??t?.saturation,a=e.contrast??t?.contrast,o=e.hueRotate??t?.hueRotate;return r!==void 0&&(n[`raster-brightness-min`]=0,n[`raster-brightness-max`]=r),i!==void 0&&(n[`raster-saturation`]=i),a!==void 0&&(n[`raster-contrast`]=a),o!==void 0&&(n[`raster-hue-rotate`]=o),n},[_]),gn=(0,c.useCallback)((e,t)=>{let n=`base-layer-source-${t.id}`,r=`base-layer-${t.id}`,i={type:`raster`,tiles:[t.url],tileSize:t.tileSize??256,minzoom:t.minzoom??0,maxzoom:t.maxzoom??22,scheme:t.scheme??`xyz`};t.bounds&&(i.bounds=t.bounds),t.attribution&&(i.attribution=t.attribution),e.addSource(n,i);let a=mn(e);e.addLayer({id:r,type:`raster`,source:n,paint:hn(t),layout:{visibility:t.visible===!1?`none`:`visible`}},a)},[mn,hn]),_n=(0,c.useCallback)(async(e,t)=>{try{let n=await(await fetch(t.url)).json(),r=`base-layer-source-${t.id}`,i=`base-layer-${t.id}`;if(!Oe.current.has(t.id))return;let a=n.format===`pbf`||n.vector_layers,o=mn(e);if(a){let t={type:`vector`,tiles:n.tiles,minzoom:n.minzoom??0,maxzoom:n.maxzoom??22};n.bounds&&(t.bounds=n.bounds),n.attribution&&(t.attribution=n.attribution),e.addSource(r,t)}else e.addSource(r,{type:`raster`,tiles:n.tiles,tileSize:t.tileSize??n.tileSize??256,minzoom:n.minzoom??0,maxzoom:n.maxzoom??22,bounds:n.bounds,attribution:n.attribution}),e.addLayer({id:i,type:`raster`,source:r,paint:hn(t),layout:{visibility:t.visible===!1?`none`:`visible`}},o)}catch(e){console.error(`Failed to load TileJSON from ${t.url}:`,e)}},[mn,hn]),vn=(0,c.useCallback)(async(e,t)=>{try{let n=await(await fetch(t.url)).json();if(!Oe.current.has(t.id))return;if(n.sources)for(let[r,i]of Object.entries(n.sources)){let n=`base-layer-source-${t.id}-${r}`;e.getSource(n)||e.addSource(n,i)}let r=mn(e);if(n.layers)for(let i of n.layers){let n=`base-layer-${t.id}-${i.id}`;if(e.getLayer(n))continue;let a={...i,id:n,source:i.source?`base-layer-source-${t.id}-${i.source}`:void 0};i.type===`raster`&&(a.paint={...a.paint,...hn(t)}),t.visible===!1&&(a.layout={...a.layout,visibility:`none`}),e.addLayer(a,r)}if(n.glyphs&&!e.getStyle().glyphs){let t=e.style;t.glyphs=n.glyphs,t.stylesheet&&(t.stylesheet.glyphs=n.glyphs)}}catch(e){console.error(`Failed to load Style JSON from ${t.url}:`,e)}},[mn,hn]),yn=(0,c.useCallback)((e,t)=>{let n=e.getStyle();if(!n)return;let r=`base-layer-${t}`,i=n.layers?.filter(e=>e.id.startsWith(r))??[];for(let t of i)e.getLayer(t.id)&&e.removeLayer(t.id);let a=`base-layer-source-${t}`,o=n.sources??{};for(let t of Object.keys(o))t.startsWith(a)&&e.getSource(t)&&e.removeSource(t)},[]),bn=(0,c.useCallback)(e=>{let t=R.current;if(!t)return;let n=new Set(e.map(e=>e.id)),r=Oe.current;for(let e of r)n.has(e)||(yn(t,e),r.delete(e));for(let n of e)if(r.has(n.id)){let e=`base-layer-${n.id}`;if(t.getLayer(e)){let r=hn(n);for(let[n,i]of Object.entries(r))t.setPaintProperty(e,n,i);t.setLayoutProperty(e,`visibility`,n.visible===!1?`none`:`visible`)}}else switch(r.add(n.id),n.type){case`raster`:gn(t,n);break;case`tilejson`:_n(t,n);break;case`style`:vn(t,n);break;default:{let e=n;e.url&&gn(t,{...e,type:`raster`})}}},[gn,_n,vn,yn,hn]),xn=(0,c.useCallback)(e=>{let t=e;for(;t;){let e=t.getAttribute?.(`data-entity-id`);if(e)return e;t=t.parentElement}return null},[]),Sn=(0,c.useCallback)(e=>{let t=[e.lngLat.lng,e.lngLat.lat],n={x:e.point.x,y:e.point.y},r=An.current;if(r===`picker`){let e={lng:t[0],lat:t[1]};We(e),Ot(t),jn.current?.(e),wt.current&&(wt.current(e),wt.current=null,Dt({}),kt(),We(null),an(Tt.current));return}if(lt.current)return;if(r===`edit`){let e=Nn.current;if(e===`rectangle`){let e=Pn.current;if(!e)Je(t);else{let n=q.current,r=S({...n,id:n?.id??At(),type:`rectangle`,bounds:[e,t]},b);Ft();let i=R.current;if(i&&!z.current.has(r.id)){let e=new we(i,r,C,w,T,k);z.current.set(r.id,e)}Fn.current.onRectangleAdd?.(r),Je(null),q.current=null,K.current&&(K.current=!1,G(null),i&&(i.getCanvas().style.cursor=``))}return}if(e===`circle`){let e=Ze.current;if(!e)Ze.current={center:t};else{let n=zt(e.center,t),r=J.current,i=S({...r,id:r?.id??At(),type:`circle`,center:e.center,radius:n},b);Vt();let a=R.current;if(a&&!z.current.has(i.id)){let e=new ye(a,i,C,w,T,E);z.current.set(i.id,e)}Fn.current.onCircleAdd?.(i),Ze.current=null,J.current=null,K.current&&(K.current=!1,G(null),a&&(a.getCanvas().style.cursor=``))}return}if(e===`polygon`){let e=tt.current;if(e.length>=3){let n=e[0];if(zt(n,t)<20){let t=Y.current,n=S({...t,id:t?.id??At(),type:`polygon`,coordinates:[...e]},b);Gt();let r=R.current;if(r&&!z.current.has(n.id)){let e=new fe(r,n,C,w,T,k);z.current.set(n.id,e)}Fn.current.onPolygonAdd?.(n),tt.current=[],Y.current=null,K.current&&(K.current=!1,G(null),r&&(r.getCanvas().style.cursor=``));return}}tt.current=[...e,t];return}if(e===`square`){let e=nt.current;if(!e)nt.current={center:t};else{let n=zt(e.center,t)*2,r=X.current,i=S({...r,id:r?.id??At(),type:`square`,center:e.center,length:n},b);Xt();let a=R.current;if(a&&!z.current.has(i.id)){let e=new Ce(a,i,C,w,T,k);z.current.set(i.id,e)}Fn.current.onSquareAdd?.(i),nt.current=null,X.current=null,K.current&&(K.current=!1,G(null),a&&(a.getCanvas().style.cursor=``))}return}if(e===`polyline`){st.current=[...st.current,t];return}let n=Xe.current;if(n&&n.src&&n.width){let e={...n,id:n.id??At(),type:`marker`,center:t,src:n.src,width:n.width};Fn.current.onMarkerAdd?.(e),U(null),G(null),$(),Xe.current=null,K.current=!1;return}let r=Mn.current;if(r){let e={id:At(),type:`marker`,name:r.name,center:t,src:r.icon,width:r.size||r.width||32};r.customData!==void 0&&(e.customData=r.customData),Fn.current.onMarkerAdd?.(e),U(null),G(null),$(),K.current=!1;return}}if(ft.current.length>0){let e=R.current?.getZoom()??12;if(Z.current){let{entityId:e,activeHandle:n}=Z.current,r=z.current.get(e);if(r?.applyHandleMove){let e=r.applyHandleMove(n,t);Fn.current.onEntityEdit?.(e)}Z.current=null;return}for(let n of ft.current){let r=z.current.get(n);if(!r?.getEditHandleAt)continue;let i=r.getEditHandleAt(t,e);if(i){if(i.type===`midpoint`&&r.addVertex){let e=r.addVertex(i.index,i.position);Fn.current.onEntityEdit?.(e),Z.current={entityId:n,activeHandle:{type:`vertex`,index:i.index+1,position:i.position}}}else Z.current={entityId:n,activeHandle:i};return}}}let i=Dn.current,a=On.current,o=kn.current,s=xn(e.originalEvent.target);if(s){let e=i.find(e=>String(e.id)===s);if(e){if(a?.(e),e.popup){let t=e.popup.content??I?.(e);t&&at(e.popup,F,t).trigger===`click`&&o(s,`click`,n)}return}}for(let[t,r]of z.current){let s=r.getLabelLayerId();if(s&&R.current?.getLayer(s)&&R.current.queryRenderedFeatures(e.point,{layers:[s]}).length>0){let e=i.find(e=>e.id===t);if(e){if(a?.(e),e.popup){let r=e.popup.content??I?.(e);r&&at(e.popup,F,r).trigger===`click`&&o(t,`click`,n)}return}}}for(let[e,r]of z.current)if(r.isPointInEntity(t)){let t=i.find(t=>t.id===e);if(t){if(a?.(t),t.popup){let r=t.popup.content??I?.(t);r&&at(t.popup,F,r).trigger===`click`&&o(e,`click`,n)}return}}},[F,I,xn]),Cn=(0,c.useCallback)(e=>{let t=[e.lngLat.lng,e.lngLat.lat];if(Z.current){let{entityId:e,activeHandle:n}=Z.current;z.current.get(e)?.updateEditPreview?.(n,t);return}let n=Nn.current,r=Pn.current;n===`rectangle`&&r&&Pt(r,t);let i=Ze.current;n===`circle`&&i&&Bt(i.center,t);let a=tt.current;n===`polygon`&&a.length>0&&Wt(a,t);let o=nt.current;n===`square`&&o&&Yt(o.center,t);let s=st.current;n===`polyline`&&s.length>0&&$t(s,t);let c=Dn.current,l=kn.current;for(let[e,n]of z.current)if(n.isPointInEntity(t)){let t=c.find(t=>t.id===e);if(!t?.popup)continue;let n=t.popup.content??I?.(t);if(!n)continue;let r=at(t.popup,F,n);if(r.trigger===`hover`){Ne.current&&clearTimeout(Ne.current),Ne.current=window.setTimeout(()=>{l(e,`hover`)},r.hoverDelay);return}}if(Ne.current&&=(clearTimeout(Ne.current),null),V?.openedBy===`hover`){let e=z.current.get(V.entityId);e&&!e.isPointInEntity(t)&&vt(V.entityId)}},[F,I,V,vt,Pt,Bt,Wt,Yt,$t]),wn=(0,c.useCallback)(e=>{if(e.preventDefault(),wt.current){wt.current(null),wt.current=null,Dt({}),kt(),We(null),an(Tt.current);return}if(lt.current)return;if(ft.current.length>0){let t=[e.lngLat.lng,e.lngLat.lat];if(Z.current){z.current.get(Z.current.entityId)?.cancelEditPreview?.(),Z.current=null;return}let n=R.current?.getZoom()??12;for(let e of ft.current){let r=z.current.get(e);if(!r?.getEditHandleAt||!r.deleteVertex)continue;let i=r.getEditHandleAt(t,n);if(i&&i.type===`vertex`){let e=r.deleteVertex(i.index);e&&Fn.current.onEntityEdit?.(e);return}}}if(An.current!==`edit`)return;if(Mn.current){U(null),G(null),$();return}let t=Nn.current;if(t===`rectangle`){if(Pn.current)Je(null),Ft();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}if(t===`circle`){if(Ze.current)Ze.current=null,Vt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}if(t===`polygon`){let e=tt.current;if(e.length>=3){let t=Y.current,n=S({...t,id:t?.id??At(),type:`polygon`,coordinates:[...e]},b);Gt();let r=R.current;if(r&&!z.current.has(n.id)){let e=new fe(r,n,C,w,T,k);z.current.set(n.id,e)}Fn.current.onPolygonAdd?.(n),tt.current=[],Y.current=null,K.current&&(K.current=!1,G(null),r&&(r.getCanvas().style.cursor=``))}else if(e.length>0)tt.current=[],Gt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}if(t===`square`){if(nt.current)nt.current=null,Xt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}if(t===`polyline`){let e=st.current;if(e.length>=2){let t=rt.current,n=S({...t,id:t?.id??At(),type:`polyline`,coordinates:[...e]},b);en();let r=R.current;if(r&&!z.current.has(n.id)){let e=new _e(r,n,C,w,k);z.current.set(n.id,e)}Fn.current.onPolylineAdd?.(n),st.current=[],rt.current=null,K.current&&(K.current=!1,G(null),r&&(r.getCanvas().style.cursor=``))}else if(e.length>0)st.current=[],en();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}let n=[e.lngLat.lng,e.lngLat.lat],r={x:e.point.x,y:e.point.y},i=Dn.current,a=xn(e.originalEvent.target);if(a){let e=i.find(e=>String(e.id)===a);if(e){Tn(e,r,n);return}}for(let[t,a]of z.current){let o=a.getLabelLayerId();if(o&&R.current?.getLayer(o)&&R.current.queryRenderedFeatures(e.point,{layers:[o]}).length>0){let e=i.find(e=>e.id===t);if(e){Tn(e,r,n);return}}}for(let[e,t]of z.current)if(t.isPointInEntity(n)){let t=i.find(t=>t.id===e);if(t){Tn(t,r,n);return}}},[xn,$,Ft,Vt,Gt,Xt,en]),Tn=(0,c.useCallback)((e,t,n)=>{let r=L.current?.getBoundingClientRect(),i=r?{x:t.x+r.left,y:t.y+r.top}:t;Ie({position:i,lngLat:n,items:[{key:`delete`,label:`删除`,icon:(0,p.jsx)(`img`,{src:Ve,alt:`delete`,style:{width:`18px`,flexShrink:0}}),danger:!0,onClick:()=>{Fn.current.onEntityDelete?.(e)}}]})},[]),En=(0,c.useCallback)(()=>{Ie(null)},[]);(0,c.useEffect)(()=>{let e=document.createElement(`div`);return e.id=`mapbox-popup-container-${Date.now()}`,e.style.cssText=`
57
+ `;let i=document.createElement(`img`);i.src=e.icon,i.style.width=`${r}px`,i.style.height=`${e.size||e.height||r}px`,i.style.objectFit=`contain`,n.appendChild(i),document.body.appendChild(n),ut.current=n;let a=e=>{ut.current&&(ut.current.style.left=`${e.clientX}px`,ut.current.style.top=`${e.clientY}px`)};document.addEventListener(`mousemove`,a),n.dataset.cleanup=`true`,n._cleanup=()=>{document.removeEventListener(`mousemove`,a)}}else t&&(t.getCanvas().style.cursor=``)},[]),$=(0,c.useCallback)(()=>{if(ut.current){let e=ut.current._cleanup;e&&e(),ut.current.remove(),ut.current=null}let e=R.current;e&&(e.getCanvas().style.cursor=``)},[]),Pt=(0,c.useCallback)((e,t,n)=>{if(!e.getSource(t)){if(!e.getStyle().glyphs){let t=e.style,n=`/gis-fonts/{fontstack}/{range}.pbf`;t.glyphs=n,t.stylesheet&&(t.stylesheet.glyphs=n)}e.addSource(t,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:n,type:`symbol`,source:t,filter:[`==`,`$type`,`Point`],layout:{"text-field":[`get`,`label`],"text-size":12,"text-font":[`Open Sans Bold`,`Arial Unicode MS Bold`],"text-allow-overlap":!0,"text-rotation-alignment":`map`,"text-offset":[0,-.8]},paint:{"text-color":`#ffffff`,"text-halo-color":`rgba(0, 0, 0, 0.8)`,"text-halo-width":1}})}},[]),Ft=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`rect-preview-source`)||(e.addSource(`rect-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`rect-preview-fill`,type:`fill`,source:`rect-preview-source`,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.addLayer({id:`rect-preview-line`,type:`line`,source:`rect-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),Pt(e,`rect-preview-measure-source`,`rect-preview-measure-label`)))},[Pt]),It=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`rect-preview-source`);if(!r)return;let[i,a]=e,[o,s]=t,c=[[Math.min(i,o),Math.max(a,s)],[Math.max(i,o),Math.max(a,s)],[Math.max(i,o),Math.min(a,s)],[Math.min(i,o),Math.min(a,s)],[Math.min(i,o),Math.max(a,s)]];r.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[c]},properties:{}});let l=J.current,u=l?.strokeColor??`#3388ff`,d=l?.strokeWidth??2,f=l?.fillColor??`#3388ff`,p=l?.fillOpacity??.1;n.getLayer(`rect-preview-line`)&&(n.setPaintProperty(`rect-preview-line`,`line-color`,u),n.setPaintProperty(`rect-preview-line`,`line-width`,d)),n.getLayer(`rect-preview-fill`)&&(n.setPaintProperty(`rect-preview-fill`,`fill-color`,f),n.setPaintProperty(`rect-preview-fill`,`fill-opacity`,p));let m=n.getSource(`rect-preview-measure-source`);if(m){let e=Bn.current,t=[],n=c[0],r=c[1],i=c[2];if(e?.showArea){let e=[(n[0]+i[0])/2,(n[1]+i[1])/2],a=O(n,r),o=O(r,i);t.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:A(a*o)}})}if(e?.showLength){let e=[(n[0]+r[0])/2,(n[1]+r[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:j(O(n,r))}});let a=[(r[0]+i[0])/2,(r[1]+i[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:a},properties:{label:j(O(r,i))}})}m.setData({type:`FeatureCollection`,features:t})}},[]),Lt=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`rect-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`rect-preview-measure-source`);n&&n.setData({type:`FeatureCollection`,features:[]})},[]),Rt=(0,c.useCallback)(()=>{Je(null),Lt()},[Lt]),zt=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`circle-preview-source`)||(e.addSource(`circle-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`circle-preview-fill`,type:`fill`,source:`circle-preview-source`,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.addLayer({id:`circle-preview-line`,type:`line`,source:`circle-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),Pt(e,`circle-preview-measure-source`,`circle-preview-measure-label`),e.getSource(`circle-preview-radius-source`)||(e.addSource(`circle-preview-radius-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`circle-preview-radius-line`,type:`line`,source:`circle-preview-radius-source`,paint:{"line-color":`#ffffff`,"line-width":1,"line-opacity":1,"line-dasharray":[4,4]}}))))},[Pt]),Bt=(0,c.useCallback)((e,t,n=64)=>{let[r,i]=e,a=[],o=t/6371e3,s=i*Math.PI/180;for(let e=0;e<=n;e++){let t=e/n*2*Math.PI,c=o*Math.cos(t),l=o*Math.sin(t)/Math.cos(s),u=i+c*180/Math.PI,d=r+l*180/Math.PI;a.push([d,u])}return a},[]),Vt=(0,c.useCallback)((e,t)=>{let[n,r]=e,[i,a]=t,o=(a-r)*Math.PI/180,s=(i-n)*Math.PI/180,c=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))},[]),Ht=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`circle-preview-source`);if(!r)return;let i=Vt(e,t),a=Bt(e,i);r.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[a]},properties:{}});let o=$e.current,s=o?.strokeColor??`#3388ff`,c=o?.strokeWidth??2,l=o?.fillColor??`#3388ff`,u=o?.fillOpacity??.1;n.getLayer(`circle-preview-line`)&&(n.setPaintProperty(`circle-preview-line`,`line-color`,s),n.setPaintProperty(`circle-preview-line`,`line-width`,c)),n.getLayer(`circle-preview-fill`)&&(n.setPaintProperty(`circle-preview-fill`,`fill-color`,l),n.setPaintProperty(`circle-preview-fill`,`fill-opacity`,u));let d=Bn.current,f=[],p=[];if(d?.showArea){let t=Math.PI*i*i;f.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:A(t)}})}if(d?.showRadius){let t=$e.current?.radiusAngle??90,n=D(e,i,t),r=[(e[0]+n[0])/2,(e[1]+n[1])/2];p.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[e,n]},properties:{}}),f.push({type:`Feature`,geometry:{type:`Point`,coordinates:r},properties:{label:j(i)}})}let m=n.getSource(`circle-preview-measure-source`);m&&m.setData({type:`FeatureCollection`,features:f});let h=n.getSource(`circle-preview-radius-source`);h&&h.setData({type:`FeatureCollection`,features:p})},[Vt,Bt]),Ut=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`circle-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`circle-preview-measure-source`);n&&n.setData({type:`FeatureCollection`,features:[]});let r=e.getSource(`circle-preview-radius-source`);r&&r.setData({type:`FeatureCollection`,features:[]})},[]),Wt=(0,c.useCallback)(()=>{nt.current=null,Ut()},[Ut]),Gt=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`polygon-preview-source`)||(e.addSource(`polygon-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`polygon-preview-fill`,type:`fill`,source:`polygon-preview-source`,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.addLayer({id:`polygon-preview-line`,type:`line`,source:`polygon-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),e.addSource(`polygon-vertices-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`polygon-vertices`,type:`circle`,source:`polygon-vertices-source`,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}}),Pt(e,`polygon-preview-measure-source`,`polygon-preview-measure-label`)))},[Pt]),Kt=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`polygon-preview-source`),i=n.getSource(`polygon-vertices-source`);if(!r||!i)return;let a=[...e,t];if(a.length>=3){let e=[...a,a[0]];r.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[e]},properties:{}})}else a.length===2?r.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:a},properties:{}}):r.setData({type:`FeatureCollection`,features:[]});i.setData({type:`FeatureCollection`,features:e.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=Y.current,s=o?.strokeColor??`#3388ff`,c=o?.strokeWidth??2,l=o?.fillColor??`#3388ff`,u=o?.fillOpacity??.1;n.getLayer(`polygon-preview-line`)&&(n.setPaintProperty(`polygon-preview-line`,`line-color`,s),n.setPaintProperty(`polygon-preview-line`,`line-width`,c)),n.getLayer(`polygon-preview-fill`)&&(n.setPaintProperty(`polygon-preview-fill`,`fill-color`,l),n.setPaintProperty(`polygon-preview-fill`,`fill-opacity`,u)),n.getLayer(`polygon-vertices`)&&n.setPaintProperty(`polygon-vertices`,`circle-color`,s);let d=n.getSource(`polygon-preview-measure-source`);if(d){let e=Bn.current,t=[];if(e?.showArea&&a.length>=3){let e=[...a,a[0]],n=ee(e),r=0,i=0;for(let e of a)r+=e[0],i+=e[1];r/=a.length,i/=a.length,t.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r,i]},properties:{label:A(n)}})}if(e?.showLength&&a.length>=2){for(let e=0;e<a.length-1;e++){let n=a[e],r=a[e+1],i=[(n[0]+r[0])/2,(n[1]+r[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:i},properties:{label:j(O(n,r))}})}if(a.length>=3){let e=a[a.length-1],n=a[0],r=[(e[0]+n[0])/2,(e[1]+n[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:r},properties:{label:j(O(e,n))}})}}d.setData({type:`FeatureCollection`,features:t})}},[]),qt=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`polygon-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`polygon-vertices-source`);n&&n.setData({type:`FeatureCollection`,features:[]});let r=e.getSource(`polygon-preview-measure-source`);r&&r.setData({type:`FeatureCollection`,features:[]})},[]),Jt=(0,c.useCallback)(()=>{rt.current=[],qt()},[qt]),Yt=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`square-preview-source`)||(e.addSource(`square-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`square-preview-fill`,type:`fill`,source:`square-preview-source`,paint:{"fill-color":`#3388ff`,"fill-opacity":.1}}),e.addLayer({id:`square-preview-line`,type:`line`,source:`square-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),Pt(e,`square-preview-measure-source`,`square-preview-measure-label`)))},[Pt]),Xt=(0,c.useCallback)((e,t)=>{let[n,r]=e,i=t/2/6371e3,a=r*Math.PI/180,o=i*180/Math.PI,s=i*180/Math.PI/Math.cos(a);return[[n-s,r+o],[n+s,r+o],[n+s,r-o],[n-s,r-o],[n-s,r+o]]},[]),Zt=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`square-preview-source`);if(!r)return;let i=Vt(e,t)*2,a=Xt(e,i);r.setData({type:`Feature`,geometry:{type:`Polygon`,coordinates:[a]},properties:{}});let o=X.current,s=o?.strokeColor??`#3388ff`,c=o?.strokeWidth??2,l=o?.fillColor??`#3388ff`,u=o?.fillOpacity??.1;n.getLayer(`square-preview-line`)&&(n.setPaintProperty(`square-preview-line`,`line-color`,s),n.setPaintProperty(`square-preview-line`,`line-width`,c)),n.getLayer(`square-preview-fill`)&&(n.setPaintProperty(`square-preview-fill`,`fill-color`,l),n.setPaintProperty(`square-preview-fill`,`fill-opacity`,u));let d=n.getSource(`square-preview-measure-source`);if(d){let t=Bn.current,n=[];if(t?.showArea&&n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:A(i*i)}}),t?.showLength){let e=[(a[1][0]+a[2][0])/2,(a[1][1]+a[2][1])/2];n.push({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{label:j(i)}})}d.setData({type:`FeatureCollection`,features:n})}},[Vt,Xt]),Qt=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`square-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`square-preview-measure-source`);n&&n.setData({type:`FeatureCollection`,features:[]})},[]),$t=(0,c.useCallback)(()=>{st.current=null,Qt()},[Qt]),en=(0,c.useCallback)(()=>{let e=R.current;e&&(e.getSource(`polyline-preview-source`)||(e.addSource(`polyline-preview-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`polyline-preview-line`,type:`line`,source:`polyline-preview-source`,paint:{"line-color":`#3388ff`,"line-width":2,"line-dasharray":[4,4]}}),e.addSource(`polyline-vertices-source`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.addLayer({id:`polyline-vertices`,type:`circle`,source:`polyline-vertices-source`,paint:{"circle-radius":5,"circle-color":`#3388ff`,"circle-stroke-color":`#ffffff`,"circle-stroke-width":2}}),Pt(e,`polyline-preview-measure-source`,`polyline-preview-measure-label`)))},[Pt]),tn=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=n.getSource(`polyline-preview-source`),i=n.getSource(`polyline-vertices-source`);if(!r||!i)return;let a=[...e,t];a.length>=2?r.setData({type:`Feature`,geometry:{type:`LineString`,coordinates:a},properties:{}}):r.setData({type:`FeatureCollection`,features:[]}),i.setData({type:`FeatureCollection`,features:e.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{}}))});let o=ct.current,s=o?.strokeColor??`#3388ff`,c=o?.strokeWidth??2;n.getLayer(`polyline-preview-line`)&&(n.setPaintProperty(`polyline-preview-line`,`line-color`,s),n.setPaintProperty(`polyline-preview-line`,`line-width`,c)),n.getLayer(`polyline-vertices`)&&n.setPaintProperty(`polyline-vertices`,`circle-color`,s);let l=n.getSource(`polyline-preview-measure-source`);if(l){let e=Bn.current,t=[];if(e?.showLength&&a.length>=2)for(let e=0;e<a.length-1;e++){let n=a[e],r=a[e+1],i=[(n[0]+r[0])/2,(n[1]+r[1])/2];t.push({type:`Feature`,geometry:{type:`Point`,coordinates:i},properties:{label:j(O(n,r))}})}l.setData({type:`FeatureCollection`,features:t})}},[]),nn=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=e.getSource(`polyline-preview-source`);t&&t.setData({type:`FeatureCollection`,features:[]});let n=e.getSource(`polyline-vertices-source`);n&&n.setData({type:`FeatureCollection`,features:[]});let r=e.getSource(`polyline-preview-measure-source`);r&&r.setData({type:`FeatureCollection`,features:[]})},[]),rn=(0,c.useCallback)(()=>{lt.current=[],nn()},[nn]),an=(0,c.useCallback)(e=>{U(e),Nt(e),e?(G(`marker`),Rt(),Wt(),Jt(),$t(),rn()):G(null)},[Nt,Rt,Wt,Jt,$t,rn]),on=(0,c.useCallback)(e=>{if(G(e),e===`rectangle`){U(null),$(),Wt(),Jt(),$t(),rn();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else if(e===`circle`){U(null),$(),Rt(),Jt(),$t(),rn();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else if(e===`polygon`){U(null),$(),Rt(),Wt(),$t(),rn();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else if(e===`square`){U(null),$(),Rt(),Wt(),Jt(),rn();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else if(e===`polyline`){U(null),$(),Rt(),Wt(),Jt(),$t();let e=R.current;e&&(e.getCanvas().style.cursor=`crosshair`)}else e===`marker`?(Rt(),Wt(),Jt(),$t(),rn()):(U(null),$(),Rt(),Wt(),Jt(),$t(),rn())},[$,Rt,Wt,Jt,$t,rn]),sn=(0,c.useCallback)(e=>{if(e!==`picker`){let e=Q.value&&isFinite(Q.value.lng)&&isFinite(Q.value.lat),t=Q.showMarker!==!1;(!e||!t)&&jt(),We(null)}e!==`edit`&&(U(null),G(null),Rt(),rn(),$()),He(e)},[jt,$,Rt,rn]),cn=(0,c.useCallback)(()=>H,[H]),ln=(0,c.useCallback)(()=>Ue,[Ue]),un=(0,c.useCallback)(()=>{jt(),We(null)},[jt]),dn=(0,c.useCallback)((e={})=>(Et.current&&=(Et.current(null),null),new Promise(t=>{Et.current=t,Dt.current=Pn.current,kt(e),sn(`picker`)})),[sn]);(0,c.useEffect)(()=>{if(!ze)return;let e=Q.value;if(e&&isFinite(e.lng)&&isFinite(e.lat)){let t=[e.lng,e.lat];We(e),At(t)}},[Q.value,At,ze]);let fn=e=>`mode`in e,pn=(0,c.useCallback)((e,t=!0)=>(Xe.current&&=(Xe.current(`cancelled: new drawing started`),q.current=null,null),new Promise((n,r)=>{if(q.current=n,Xe.current=r,t&&(jt(),We(null)),K.current=!0,fn(e)){if(e.mode===`marker`)e.markerStyle?(Ze.current=e.markerStyle,J.current=null,$e.current=null,Y.current=null,X.current=null,ct.current=null,U(null),G(`marker`),e.markerStyle.src&&e.markerStyle.width?Nt({id:`custom`,name:e.markerStyle.name||`Marker`,icon:e.markerStyle.src,width:e.markerStyle.width}):$()):e.template&&(Ze.current=null,J.current=null,$e.current=null,Y.current=null,X.current=null,ct.current=null,U(e.template),G(`marker`),Nt(e.template));else if(e.mode===`rectangle`){J.current=e.rectangleStyle||null,Ze.current=null,$e.current=null,Y.current=null,X.current=null,ct.current=null,U(null),G(`rectangle`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}else if(e.mode===`circle`){$e.current=e.circleStyle||null,J.current=null,Ze.current=null,Y.current=null,X.current=null,ct.current=null,U(null),G(`circle`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}else if(e.mode===`polygon`){Y.current=e.polygonStyle||null,J.current=null,Ze.current=null,$e.current=null,X.current=null,ct.current=null,U(null),G(`polygon`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}else if(e.mode===`square`){X.current=e.squareStyle||null,J.current=null,Ze.current=null,$e.current=null,Y.current=null,ct.current=null,U(null),G(`square`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}else if(e.mode===`polyline`){ct.current=e.polylineStyle||null,J.current=null,Ze.current=null,$e.current=null,Y.current=null,X.current=null,U(null),G(`polyline`),$();let t=R.current;t&&(t.getCanvas().style.cursor=`crosshair`)}}else U(e),G(`marker`),Nt(e),J.current=null,Ze.current=null,$e.current=null,Y.current=null,X.current=null,ct.current=null})),[jt,Nt,$]),mn=(0,c.useCallback)(e=>{q.current&&(q.current(e),q.current=null,Xe.current=null)},[]),hn=(0,c.useCallback)(e=>{Xe.current&&=(Xe.current(e),q.current=null,null)},[]);(0,c.useImperativeHandle)(t,()=>({startAnimation:ht,stopAnimation:gt,toggleAnimation:_t,getMap:()=>R.current,openPopup:e=>yt(e,`programmatic`),closePopup:bt,closeAllPopups:xt,isPopupOpen:St,toggleUnitTrajectory:vt,flyTo:Ct,getCenterByIds:wt,flyToEntities:Tt,getMode:cn,setMode:sn,getPickedLocation:ln,clearPickedLocation:un,startDrawing:pn,getRenderer:e=>z.current.get(e),setEditingEntities:e=>{for(let t of mt.current)e.map(String).includes(String(t))||z.current.get(t)?.setEditing?.(!1);for(let t of e)z.current.get(t)?.setEditing?.(!0);Z.current&&=(z.current.get(Z.current.entityId)?.cancelEditPreview?.(),null),pt(e)},getEditingEntities:()=>mt.current,startPicking:dn,startRoutePlanning:e=>{be.current?.startPlanning(e)},getRoadHighlightControl:()=>Se.current}),[ht,gt,_t,yt,bt,xt,St,vt,Ct,wt,Tt,cn,sn,ln,un,pn,dn]);let gn=(0,c.useCallback)(()=>{let e=R.current;if(!e)return;let t=new Set(v.map(e=>e.id)),n=new Set(z.current.keys());for(let e of n)t.has(e)||(z.current.get(e)?.destroy(),z.current.delete(e));let r=new Set(y.map(String));for(let t of v){let n=S(t,b),i=z.current.get(n.id);if(i)if(n.type===`radar`&&i instanceof se)i.update(n);else if(n.type===`image`&&i instanceof le)i.update(n);else if(n.type===`marker`&&i instanceof ue)i.update(n);else if(n.type===`unit`&&i instanceof de)i.update(n);else if(n.type===`polygon`&&i instanceof fe)i.update(n);else if(n.type===`circle`)if(n.fillType===`radial-gradient`)if(i instanceof xe)i.update(n);else{i.destroy();let t=new xe(e,n,C,w,T,E);z.current.set(n.id,t),t.setSelected(r.has(String(n.id)))}else if(i instanceof ye)i.update(n);else{i.destroy();let t=new ye(e,n,C,w,T,E);z.current.set(n.id,t),t.setSelected(r.has(String(n.id)))}else (n.type===`square`&&i instanceof Ce||n.type===`rectangle`&&i instanceof we||n.type===`polyline`&&i instanceof _e||n.type===`attack-direction`&&i instanceof ge)&&i.update(n);else{let t=null;n.type===`radar`?t=new se(e,n,C,w):n.type===`image`?t=new le(e,n,C,w):n.type===`marker`?t=new ue(e,n,C,w):n.type===`unit`?t=new de(e,n,C,w):n.type===`polygon`?t=new fe(e,n,C,w,T,k):n.type===`circle`?t=n.fillType===`radial-gradient`?new xe(e,n,C,w,T,E):new ye(e,n,C,w,T,E):n.type===`square`?t=new Ce(e,n,C,w,T,k):n.type===`rectangle`?t=new we(e,n,C,w,T,k):n.type===`polyline`?t=new _e(e,n,C,w,k):n.type===`attack-direction`&&(t=new ge(e,n,C,w)),t&&(z.current.set(n.id,t),t.setSelected(r.has(String(n.id))),mt.current.map(String).includes(String(n.id))&&t.setEditing?.(!0))}}for(let e of mt.current){let t=z.current.get(e);t&&t.setEditing?.(!0)}},[v,y,b,C,w,T,E,k]),_n=(0,c.useCallback)(()=>{for(let e of z.current.values())e.destroy();z.current.clear()},[]),vn=(0,c.useCallback)(e=>{let t=e.getStyle();if(!t?.layers)return;let n=[`polygon-`,`polyline-`,`circle-`,`square-`,`rectangle-`,`radar-`,`image-`,`unit-`,`marker-`,`attack-direction-`];for(let e of t.layers)if(n.some(t=>e.id.startsWith(t)))return e.id},[]),yn=(0,c.useCallback)(e=>{let t=_,n={"raster-opacity":e.opacity??1},r=e.brightness??t?.brightness,i=e.saturation??t?.saturation,a=e.contrast??t?.contrast,o=e.hueRotate??t?.hueRotate;return r!==void 0&&(n[`raster-brightness-min`]=0,n[`raster-brightness-max`]=r),i!==void 0&&(n[`raster-saturation`]=i),a!==void 0&&(n[`raster-contrast`]=a),o!==void 0&&(n[`raster-hue-rotate`]=o),n},[_]),bn=(0,c.useCallback)((e,t)=>{let n=`base-layer-source-${t.id}`,r=`base-layer-${t.id}`,i={type:`raster`,tiles:[t.url],tileSize:t.tileSize??256,minzoom:t.minzoom??0,maxzoom:t.maxzoom??22,scheme:t.scheme??`xyz`};t.bounds&&(i.bounds=t.bounds),t.attribution&&(i.attribution=t.attribution),e.addSource(n,i);let a=vn(e);e.addLayer({id:r,type:`raster`,source:n,paint:yn(t),layout:{visibility:t.visible===!1?`none`:`visible`}},a)},[vn,yn]),xn=(0,c.useCallback)(async(e,t)=>{try{let n=await(await fetch(t.url)).json(),r=`base-layer-source-${t.id}`,i=`base-layer-${t.id}`;if(!Oe.current.has(t.id))return;let a=n.format===`pbf`||n.vector_layers,o=vn(e);if(a){let t={type:`vector`,tiles:n.tiles,minzoom:n.minzoom??0,maxzoom:n.maxzoom??22};n.bounds&&(t.bounds=n.bounds),n.attribution&&(t.attribution=n.attribution),e.addSource(r,t)}else e.addSource(r,{type:`raster`,tiles:n.tiles,tileSize:t.tileSize??n.tileSize??256,minzoom:n.minzoom??0,maxzoom:n.maxzoom??22,bounds:n.bounds,attribution:n.attribution}),e.addLayer({id:i,type:`raster`,source:r,paint:yn(t),layout:{visibility:t.visible===!1?`none`:`visible`}},o)}catch(e){console.error(`Failed to load TileJSON from ${t.url}:`,e)}},[vn,yn]),Sn=(0,c.useCallback)(async(e,t)=>{try{let n=await(await fetch(t.url)).json();if(!Oe.current.has(t.id))return;if(n.sources)for(let[r,i]of Object.entries(n.sources)){let n=`base-layer-source-${t.id}-${r}`;e.getSource(n)||e.addSource(n,i)}let r=vn(e);if(n.layers)for(let i of n.layers){let n=`base-layer-${t.id}-${i.id}`;if(e.getLayer(n))continue;let a={...i,id:n,source:i.source?`base-layer-source-${t.id}-${i.source}`:void 0};i.type===`raster`&&(a.paint={...a.paint,...yn(t)}),t.visible===!1&&(a.layout={...a.layout,visibility:`none`}),e.addLayer(a,r)}if(n.glyphs&&!e.getStyle().glyphs){let t=e.style;t.glyphs=n.glyphs,t.stylesheet&&(t.stylesheet.glyphs=n.glyphs)}}catch(e){console.error(`Failed to load Style JSON from ${t.url}:`,e)}},[vn,yn]),Cn=(0,c.useCallback)((e,t)=>{let n=e.getStyle();if(!n)return;let r=`base-layer-${t}`,i=n.layers?.filter(e=>e.id.startsWith(r))??[];for(let t of i)e.getLayer(t.id)&&e.removeLayer(t.id);let a=`base-layer-source-${t}`,o=n.sources??{};for(let t of Object.keys(o))t.startsWith(a)&&e.getSource(t)&&e.removeSource(t)},[]),wn=(0,c.useCallback)(e=>{let t=R.current;if(!t)return;let n=new Set(e.map(e=>e.id)),r=Oe.current;for(let e of r)n.has(e)||(Cn(t,e),r.delete(e));for(let n of e)if(r.has(n.id)){let e=`base-layer-${n.id}`;if(t.getLayer(e)){let r=yn(n);for(let[n,i]of Object.entries(r))t.setPaintProperty(e,n,i);t.setLayoutProperty(e,`visibility`,n.visible===!1?`none`:`visible`)}}else switch(r.add(n.id),n.type){case`raster`:bn(t,n);break;case`tilejson`:xn(t,n);break;case`style`:Sn(t,n);break;default:{let e=n;e.url&&bn(t,{...e,type:`raster`})}}},[bn,xn,Sn,Cn,yn]),Tn=(0,c.useCallback)(e=>{let t=e;for(;t;){let e=t.getAttribute?.(`data-entity-id`);if(e)return e;t=t.parentElement}return null},[]),En=(0,c.useCallback)(e=>{let t=[e.lngLat.lng,e.lngLat.lat],n={x:e.point.x,y:e.point.y},r=Pn.current;if(r===`picker`){let e={lng:t[0],lat:t[1]};We(e),At(t),Fn.current?.(e),Et.current&&(Et.current(e),Et.current=null,kt({}),jt(),We(null),sn(Dt.current));return}if(dt.current)return;if(r===`edit`||K.current){let e=Ln.current;if(e===`rectangle`){let e=Rn.current;if(!e)Je(t);else{let n=J.current,r=S({...n,id:n?.id??Mt(),type:`rectangle`,bounds:[e,t]},b);Lt();let i=R.current;if(i&&!z.current.has(r.id)){let e=new we(i,r,C,w,T,k);z.current.set(r.id,e)}zn.current.onRectangleAdd?.(r),mn(r),Je(null),J.current=null,K.current&&(K.current=!1,G(null),i&&(i.getCanvas().style.cursor=``))}return}if(e===`circle`){let e=nt.current;if(!e)nt.current={center:t};else{let n=Vt(e.center,t),r=$e.current,i=S({...r,id:r?.id??Mt(),type:`circle`,center:e.center,radius:n},b);Ut();let a=R.current;if(a&&!z.current.has(i.id)){let e=new ye(a,i,C,w,T,E);z.current.set(i.id,e)}zn.current.onCircleAdd?.(i),mn(i),nt.current=null,$e.current=null,K.current&&(K.current=!1,G(null),a&&(a.getCanvas().style.cursor=``))}return}if(e===`polygon`){let e=rt.current;if(e.length>=3){let n=e[0];if(Vt(n,t)<20){let t=Y.current,n=S({...t,id:t?.id??Mt(),type:`polygon`,coordinates:[...e]},b);qt();let r=R.current;if(r&&!z.current.has(n.id)){let e=new fe(r,n,C,w,T,k);z.current.set(n.id,e)}zn.current.onPolygonAdd?.(n),mn(n),rt.current=[],Y.current=null,K.current&&(K.current=!1,G(null),r&&(r.getCanvas().style.cursor=``));return}}rt.current=[...e,t];return}if(e===`square`){let e=st.current;if(!e)st.current={center:t};else{let n=Vt(e.center,t)*2,r=X.current,i=S({...r,id:r?.id??Mt(),type:`square`,center:e.center,length:n},b);Qt();let a=R.current;if(a&&!z.current.has(i.id)){let e=new Ce(a,i,C,w,T,k);z.current.set(i.id,e)}zn.current.onSquareAdd?.(i),mn(i),st.current=null,X.current=null,K.current&&(K.current=!1,G(null),a&&(a.getCanvas().style.cursor=``))}return}if(e===`polyline`){lt.current=[...lt.current,t];return}let n=Ze.current;if(n&&n.src&&n.width){let e={...n,id:n.id??Mt(),type:`marker`,center:t,src:n.src,width:n.width};zn.current.onMarkerAdd?.(e),mn(e),U(null),G(null),$(),Ze.current=null,K.current=!1;return}let r=In.current;if(r){let e={id:Mt(),type:`marker`,name:r.name,center:t,src:r.icon,width:r.size||r.width||32};r.customData!==void 0&&(e.customData=r.customData),zn.current.onMarkerAdd?.(e),mn(e),U(null),G(null),$(),K.current=!1;return}}if(mt.current.length>0){let e=R.current?.getZoom()??12;if(Z.current){let{entityId:e,activeHandle:n}=Z.current,r=z.current.get(e);if(r?.applyHandleMove){let e=r.applyHandleMove(n,t);zn.current.onEntityEdit?.(e)}Z.current=null;return}for(let n of mt.current){let r=z.current.get(n);if(!r?.getEditHandleAt)continue;let i=r.getEditHandleAt(t,e);if(i){if(i.type===`midpoint`&&r.addVertex){let e=r.addVertex(i.index,i.position);zn.current.onEntityEdit?.(e),Z.current={entityId:n,activeHandle:{type:`vertex`,index:i.index+1,position:i.position}}}else Z.current={entityId:n,activeHandle:i};return}}}let i=jn.current,a=Mn.current,o=Nn.current,s=Tn(e.originalEvent.target);if(s){let e=i.find(e=>String(e.id)===s);if(e){if(a?.(e),e.popup){let t=e.popup.content??I?.(e);t&&at(e.popup,F,t).trigger===`click`&&o(s,`click`,n)}return}}for(let[t,r]of z.current){let s=r.getLabelLayerId();if(s&&R.current?.getLayer(s)&&R.current.queryRenderedFeatures(e.point,{layers:[s]}).length>0){let e=i.find(e=>e.id===t);if(e){if(a?.(e),e.popup){let r=e.popup.content??I?.(e);r&&at(e.popup,F,r).trigger===`click`&&o(t,`click`,n)}return}}}for(let[e,r]of z.current)if(r.isPointInEntity(t)){let t=i.find(t=>t.id===e);if(t){if(a?.(t),t.popup){let r=t.popup.content??I?.(t);r&&at(t.popup,F,r).trigger===`click`&&o(e,`click`,n)}return}}},[F,I,Tn]),Dn=(0,c.useCallback)(e=>{let t=[e.lngLat.lng,e.lngLat.lat];if(Z.current){let{entityId:e,activeHandle:n}=Z.current;z.current.get(e)?.updateEditPreview?.(n,t);return}let n=Ln.current,r=Rn.current;n===`rectangle`&&r&&It(r,t);let i=nt.current;n===`circle`&&i&&Ht(i.center,t);let a=rt.current;n===`polygon`&&a.length>0&&Kt(a,t);let o=st.current;n===`square`&&o&&Zt(o.center,t);let s=lt.current;n===`polyline`&&s.length>0&&tn(s,t);let c=jn.current,l=Nn.current;for(let[e,n]of z.current)if(n.isPointInEntity(t)){let t=c.find(t=>t.id===e);if(!t?.popup)continue;let n=t.popup.content??I?.(t);if(!n)continue;let r=at(t.popup,F,n);if(r.trigger===`hover`){Ne.current&&clearTimeout(Ne.current),Ne.current=window.setTimeout(()=>{l(e,`hover`)},r.hoverDelay);return}}if(Ne.current&&=(clearTimeout(Ne.current),null),V?.openedBy===`hover`){let e=z.current.get(V.entityId);e&&!e.isPointInEntity(t)&&bt(V.entityId)}},[F,I,V,bt,It,Ht,Kt,Zt,tn]),On=(0,c.useCallback)(e=>{if(e.preventDefault(),Et.current){Et.current(null),Et.current=null,kt({}),jt(),We(null),sn(Dt.current);return}if(dt.current)return;if(mt.current.length>0){let t=[e.lngLat.lng,e.lngLat.lat];if(Z.current){z.current.get(Z.current.entityId)?.cancelEditPreview?.(),Z.current=null;return}let n=R.current?.getZoom()??12;for(let e of mt.current){let r=z.current.get(e);if(!r?.getEditHandleAt||!r.deleteVertex)continue;let i=r.getEditHandleAt(t,n);if(i&&i.type===`vertex`){let e=r.deleteVertex(i.index);e&&zn.current.onEntityEdit?.(e);return}}}if(In.current){U(null),G(null),$();return}let t=Ln.current;if(t===`rectangle`){if(Rn.current)Je(null),Lt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}if(t===`circle`){if(nt.current)nt.current=null,Ut();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}if(t===`polygon`){let e=rt.current;if(e.length>=3){let t=Y.current,n=S({...t,id:t?.id??Mt(),type:`polygon`,coordinates:[...e]},b);qt();let r=R.current;if(r&&!z.current.has(n.id)){let e=new fe(r,n,C,w,T,k);z.current.set(n.id,e)}zn.current.onPolygonAdd?.(n),mn(n),rt.current=[],Y.current=null,K.current&&(K.current=!1,G(null),r&&(r.getCanvas().style.cursor=``))}else if(e.length>0)K.current&&=(hn(`cancelled: insufficient points for polygon`),!1),rt.current=[],qt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}if(t===`square`){if(st.current)st.current=null,Qt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}if(t===`polyline`){let e=lt.current;if(e.length>=2){let t=ct.current,n=S({...t,id:t?.id??Mt(),type:`polyline`,coordinates:[...e]},b);nn();let r=R.current;if(r&&!z.current.has(n.id)){let e=new _e(r,n,C,w,k);z.current.set(n.id,e)}zn.current.onPolylineAdd?.(n),mn(n),lt.current=[],ct.current=null,K.current&&(K.current=!1,G(null),r&&(r.getCanvas().style.cursor=``))}else if(e.length>0)K.current&&=(hn(`cancelled: insufficient points for polyline`),!1),lt.current=[],nn();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}return}let n=[e.lngLat.lng,e.lngLat.lat],r={x:e.point.x,y:e.point.y},i=jn.current,a=Tn(e.originalEvent.target);if(a){let e=i.find(e=>String(e.id)===a);if(e){kn(e,r,n);return}}for(let[t,a]of z.current){let o=a.getLabelLayerId();if(o&&R.current?.getLayer(o)&&R.current.queryRenderedFeatures(e.point,{layers:[o]}).length>0){let e=i.find(e=>e.id===t);if(e){kn(e,r,n);return}}}for(let[e,t]of z.current)if(t.isPointInEntity(n)){let t=i.find(t=>t.id===e);if(t){kn(t,r,n);return}}},[Tn,$,Lt,Ut,qt,Qt,nn]),kn=(0,c.useCallback)((e,t,n)=>{let r=L.current?.getBoundingClientRect(),i=r?{x:t.x+r.left,y:t.y+r.top}:t;Ie({position:i,lngLat:n,items:[{key:`delete`,label:`删除`,icon:(0,p.jsx)(`img`,{src:Ve,alt:`delete`,style:{width:`18px`,flexShrink:0}}),danger:!0,onClick:()=>{zn.current.onEntityDelete?.(e)}}]})},[]),An=(0,c.useCallback)(()=>{Ie(null)},[]);(0,c.useEffect)(()=>{let e=document.createElement(`div`);return e.id=`mapbox-popup-container-${Date.now()}`,e.style.cssText=`
58
58
  position: fixed;
59
59
  top: 0;
60
60
  left: 0;
@@ -70,4 +70,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
70
70
  pointer-events: none;
71
71
  height: 100%;
72
72
  z-index: ${(F?.zIndex??1e3)+100};
73
- `,document.body.appendChild(e),Le.current=e,()=>{document.body.contains(e)&&document.body.removeChild(e)}},[F?.zIndex]);let Dn=(0,c.useRef)(v);Dn.current=v;let On=(0,c.useRef)(ce);On.current=ce;let kn=(0,c.useRef)(_t);kn.current=_t;let An=(0,c.useRef)(H);An.current=H;let jn=(0,c.useRef)(m);jn.current=m;let Mn=(0,c.useRef)(Ke);Mn.current=Ke;let Nn=(0,c.useRef)(W);Nn.current=W;let Pn=(0,c.useRef)(qe);Pn.current=qe;let Fn=(0,c.useRef)(d);Fn.current=d;let In=(0,c.useRef)(b);In.current=b,(0,c.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&Z.current){z.current.get(Z.current.entityId)?.cancelEditPreview?.(),Z.current=null;return}if(e.key===`Escape`&&H===`edit`){if(Ke&&(U(null),G(null),$()),W===`rectangle`)if(qe)Je(null),Ft();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}if(W===`circle`)if(Ze.current)Ze.current=null,Vt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}if(W===`polygon`)if(tt.current.length>0)tt.current=[],Gt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}if(W===`square`)if(nt.current)nt.current=null,Xt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}if(W===`polyline`)if(st.current.length>0)st.current=[],en();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[H,Ke,W,qe,$,Ft,Vt,Gt,Xt,en]),(0,c.useEffect)(()=>{let e=R.current;if(!e||!V)return;let t=V.entityId,n=V.config,r=()=>{let r=Dn.current.find(e=>e.id===t);if(!r){yt();return}let{position:i}=ot(r,n,e,void 0,Me.current);Me.current&&(Me.current.style.left=`${i.x}px`,Me.current.style.top=`${i.y}px`)},i=setTimeout(()=>{r()},50);return e.on(`move`,r),e.on(`zoom`,r),e.on(`rotate`,r),e.on(`pitch`,r),()=>{clearTimeout(i),e.off(`move`,r),e.off(`zoom`,r),e.off(`rotate`,r),e.off(`pitch`,r)}},[V?.entityId,yt]),(0,c.useEffect)(()=>{let e=R.current,t=L.current;if(!e||!Fe||!t)return;let n=Fe.lngLat,r=()=>{let r=e.project(n),i=t.clientWidth,a=t.clientHeight;if(r.x<0||r.x>i||r.y<0||r.y>a){En();return}let o=t.getBoundingClientRect(),s=r.x+o.left,c=r.y+o.top;Re.current&&(Re.current.style.left=`${s}px`,Re.current.style.top=`${c}px`)};return e.on(`move`,r),e.on(`zoom`,r),e.on(`rotate`,r),e.on(`pitch`,r),()=>{e.off(`move`,r),e.off(`zoom`,r),e.off(`rotate`,r),e.off(`pitch`,r)}},[Fe?.lngLat,En]),(0,c.useEffect)(()=>{if(!L.current)return;let e={version:8,sources:{},layers:[]},{dragPan:t=!0,scrollZoom:c=!0,doubleClickZoom:u=!0,touchZoomRotate:d=!0,keyboard:f=!0,dragRotate:p=!0,pitchWithRotate:m=!0,touchPitch:_=!0,boxZoom:y=!0}=h,b=new l.default.Map({container:L.current,style:o||e,center:n,zoom:r,pitch:i,bearing:a,maxBounds:s,dragPan:t,scrollZoom:c,doubleClickZoom:u,touchZoomRotate:d,keyboard:f,dragRotate:p,pitchWithRotate:m,touchPitch:_,boxZoom:y,transformRequest:(e,t)=>{if(t===`Glyphs`){let t=e.match(/\/fonts\/([^/]+)\/(\d+-\d+)\.pbf/);if(t){let e=decodeURIComponent(t[1]),n=t[2],r=e.split(`,`)[0].trim();return{url:`/gis-fonts/${encodeURIComponent(r)}/${n}.pbf`}}}return{url:e}}});return R.current=b,b.on(`load`,()=>{if(!b.getStyle().glyphs){let e=b.style,t=`/gis-fonts/{fontstack}/{range}.pbf`;e.glyphs=t,e.stylesheet&&(e.stylesheet.glyphs=t)}B.current.clear(),v.forEach(e=>{B.current.set(e.id,e)}),bn(g),fn(),Nt(),Lt(),Ut(),qt(),Qt(),Be(b),oe?.(b)}),b.on(`click`,Sn),b.on(`mousemove`,Cn),b.on(`contextmenu`,wn),()=>{b.off(`click`,Sn),b.off(`mousemove`,Cn),b.off(`contextmenu`,wn),pn(),kt(),$(),It(),tn(),b.remove(),R.current=null}},[]),(0,c.useEffect)(()=>{if(R.current){if(!R.current.isStyleLoaded()){R.current.once(`load`,()=>{B.current.clear(),v.forEach(e=>{B.current.set(e.id,e)}),fn()});return}B.current.clear(),v.forEach(e=>{B.current.set(e.id,e)}),fn()}},[v,fn]),(0,c.useEffect)(()=>{!R.current||!R.current.isStyleLoaded()||(pn(),fn())},[C,w,T,E,k,pn,fn]),(0,c.useEffect)(()=>{if(R.current){if(!R.current.isStyleLoaded()){R.current.once(`load`,()=>{bn(g)});return}bn(g)}},[g,bn]);let Ln=(0,c.useRef)(void 0),Rn=(0,c.useRef)(!0),zn=(0,c.useRef)(g);zn.current=g;let Bn=(0,c.useRef)(bn);Bn.current=bn;let Vn=(0,c.useRef)(pn);Vn.current=pn;let Hn=(0,c.useRef)(fn);Hn.current=fn;let Un=(0,c.useRef)(Nt);Un.current=Nt;let Wn=(0,c.useRef)(Lt);Wn.current=Lt;let Gn=(0,c.useRef)(Ut);Gn.current=Ut;let Kn=(0,c.useRef)(qt);Kn.current=qt;let qn=(0,c.useRef)(Qt);qn.current=Qt,(0,c.useEffect)(()=>{let e=R.current;if(!e)return;let t=o||{version:8,sources:{},layers:[]};if(Rn.current){Rn.current=!1,Ln.current=o;return}Ln.current!==o&&(Ln.current=o,e.setStyle(t),e.once(`style.load`,()=>{if(!e.getStyle().glyphs){let t=e.style,n=`/gis-fonts/{fontstack}/{range}.pbf`;t.glyphs=n,t.stylesheet&&(t.stylesheet.glyphs=n)}Oe.current.clear(),Bn.current(zn.current),Vn.current(),Hn.current(),Un.current(),Wn.current(),Gn.current(),Kn.current(),qn.current()}))},[o]),(0,c.useEffect)(()=>{let e=new Set(y.map(String));for(let[t,n]of z.current)n.setSelected(e.has(String(t)))},[y]);let Jn=(0,c.useRef)({});(0,c.useEffect)(()=>{let e=R.current;if(!e)return;let t=Jn.current,o=n&&(t.center?.[0]!==n[0]||t.center?.[1]!==n[1]),s=t.zoom!==r,c=t.pitch!==i,l=t.bearing!==a;!o&&!s&&!c&&!l||(Jn.current={center:n,zoom:r,pitch:i,bearing:a},e.jumpTo({center:n,zoom:r,pitch:i,bearing:a}))},[n,r,i,a]);let Yn=(()=>M===!1?null:M===!0?{enabled:!0}:M)(),Xn=(()=>te===!1?null:te===!0?{enabled:!0}:te)(),Zn=(()=>ne===!1?null:ne===!0?{enabled:!0}:ne)(),Qn=(()=>{if(N===!1)return null;let e,t,n;if(g&&g.length>0){let r=g.find(e=>e.hasRoadNetwork===!0)||g[0];if(r.type===`style`){let t=R.current?.getStyle();if(t?.sources){let n=`base-layer-source-${r.id}-`,i=Object.keys(t.sources).find(e=>e.startsWith(n));i&&(e=i)}}else e=`base-layer-source-${r.id}`;t=r.roadNetworkSourceLayer||`road`,n=r.roadNetworkClassField}return N===!0?{enabled:!0,source:e,sourceLayer:t,classField:n}:{...N,source:N.source||e,sourceLayer:N.sourceLayer||t,classField:N.classField||n}})(),$n=(()=>P?P===!0?{enabled:!0}:P:null)(),er=(()=>re?re===!0?{enabled:!0}:re:null)(),tr=(()=>ie||null)(),nr=(0,c.useMemo)(()=>{let e=[];for(let t of g)if(t.applyRasterPaint)if(t.type===`style`){let n=R.current;if(n){let r=`base-layer-${t.id}-`,i=n.getStyle();if(i?.layers)for(let t of i.layers)t.id.startsWith(r)&&t.type===`raster`&&e.push(t.id)}}else e.push(`base-layer-${t.id}`);return e},[g,ze]),rr=(0,c.useMemo)(()=>{if(H!==`picker`)return;let e=Q.cursorImage;if(!e)return;let t=e.width??32,n=e.height??32,r=e.anchor??`center`,i=t/2,a=n/2;switch(r){case`top-left`:i=0,a=0;break;case`top`:i=t/2,a=0;break;case`top-right`:i=t,a=0;break;case`left`:i=0,a=n/2;break;case`center`:i=t/2,a=n/2;break;case`right`:i=t,a=n/2;break;case`bottom-left`:i=0,a=n;break;case`bottom`:i=t/2,a=n;break;case`bottom-right`:i=t,a=n;break}return`url(${e.url}) ${i} ${a}, crosshair`},[H,Q.cursorImage]),ir=(0,c.useMemo)(()=>rr?{...ve,"--mapbox-picker-cursor":rr}:ve,[ve,rr]);return(0,p.jsxs)(`div`,{className:`comp-mapbox ${H===`picker`?`comp-mapbox--picker-mode`:``} ${he}`,style:ir,children:[(0,p.jsx)(`div`,{ref:L,className:`comp-mapbox__map`}),H===`picker`&&Q.showCrosshair===!0&&(0,p.jsxs)(`div`,{className:`comp-mapbox__crosshair`,children:[(0,p.jsx)(`div`,{className:`comp-mapbox__crosshair-h`,style:Q.crosshairColor?{backgroundColor:Q.crosshairColor}:void 0}),(0,p.jsx)(`div`,{className:`comp-mapbox__crosshair-v`,style:Q.crosshairColor?{backgroundColor:Q.crosshairColor}:void 0})]}),(0,p.jsxs)(`div`,{className:`comp-mapbox__edit-controls${H===`edit`&&d.showEditTools!==!1&&(d.markerTemplates&&d.markerTemplates.length>0||d.showRectangleTool||d.showCircleTool||d.showPolygonTool||d.showSquareTool||d.showPolylineTool)||Qn&&Qn.enabled!==!1||tr&&tr.enabled!==!1?``:` comp-mapbox__edit-controls--hidden`}`,children:[H===`edit`&&d.showEditTools!==!1&&(d.markerTemplates&&d.markerTemplates.length>0||d.showRectangleTool||d.showCircleTool||d.showPolygonTool||d.showSquareTool||d.showPolylineTool)&&(0,p.jsx)($e,{markerTemplates:d.markerTemplates||[],selectedTemplate:Ke,onTemplateSelect:nn,drawMode:W,onDrawModeChange:rn,showRectangleTool:d.showRectangleTool,showCircleTool:d.showCircleTool,showPolygonTool:d.showPolygonTool,showSquareTool:d.showSquareTool,showPolylineTool:d.showPolylineTool}),(0,p.jsx)(Pe,{ref:Se,map:ze,showButton:!!(Qn&&Qn.enabled!==!1),highlightWidth:Qn?.highlightWidth,defaultRoadTypes:Qn?.defaultRoadTypes,defaultMinWidth:Qn?.defaultMinWidth,source:Qn?.source,sourceLayer:Qn?.sourceLayer,classField:Qn?.classField,className:Qn?.className,style:Qn?.style}),tr&&tr.enabled!==!1&&(0,p.jsx)(it,{ref:be,map:ze,pointCount:tr.pointCount,showPointCountInput:tr.showPointCountInput,visualType:tr.visualType,onSelectFinished:tr.onSelectFinished})]}),(Yn?.enabled!==!1||Xn?.enabled!==!1||Zn?.enabled!==!1||$n&&$n.enabled!==!1||er&&er.enabled!==!1)&&(0,p.jsxs)(`div`,{className:`comp-mapbox__controls`,children:[Yn&&Yn.enabled!==!1&&(0,p.jsx)(Ee,{map:ze,precision:Yn.precision,className:Yn.className,style:Yn.style}),Xn&&Xn.enabled!==!1&&(0,p.jsx)(De,{map:ze,maxWidth:Xn.maxWidth,unit:Xn.unit,className:Xn.className,style:Xn.style}),$n&&$n.enabled!==!1&&(0,p.jsx)(Ye,{map:ze,entityConfig:b,onDrawModeChange:e=>{lt.current=e},className:$n.className,style:$n.style}),er&&er.enabled!==!1&&(0,p.jsx)(Qe,{map:ze,value:_,onChange:ae,rasterPaintLayerIds:nr,className:er.className,style:er.style}),Zn&&Zn.enabled!==!1&&(0,p.jsx)(ke,{map:ze,initialCenter:n,initialZoom:r,initialPitch:i,initialBearing:a,duration:Zn.duration,className:Zn.className,style:Zn.style})]}),!(tr&&tr.enabled!==!1)&&(0,p.jsx)(it,{ref:be,map:ze,showButton:!1}),V&&je.current&&(0,p.jsx)(Te,{popupState:V,onClose:()=>vt(V.entityId),portalContainer:je.current,popupRef:Me}),Fe&&Le.current&&(0,p.jsx)(et,{menuState:Fe,onClose:En,portalContainer:Le.current,menuRef:Re})]})});ft.displayName=`Mapbox`,exports.AttackDirectionRenderer=ge,exports.BaseCanvasRenderer=re,exports.COLOR_SCHEMES=C,exports.CanvasCircleRenderer=xe,exports.CanvasImageRenderer=le,exports.CanvasRadarRenderer=se,exports.CircleRenderer=ye,exports.ContextMenu=et,exports.CoordinateDisplay=Ee,exports.DEFAULT_NAME_CONFIG=h,exports.DEFAULT_SELECT_NAME_CONFIG=g,exports.EditControl=$e,exports.EntityPopup=Te,exports.Mapbox=ft,exports.MarkerRenderer=ue,exports.POPUP_DEFAULTS=T,exports.PolygonRenderer=fe,exports.PolylineRenderer=_e,exports.RADAR_DEFAULTS=w,exports.ROAD_TYPE_OPTIONS=E,exports.RectangleRenderer=we,exports.ResetViewControl=ke,exports.RoadHighlightControl=Pe,exports.ScaleControl=De,exports.SquareRenderer=Ce,exports.UnitRenderer=de,exports.bearing=k,exports.calculatePopupPosition=ot,exports.computeEntityArea=H,exports.computeEntityLengthOrRadius=He,exports.confidenceToOpacity=P,exports.destinationPoint=D,exports.distance=O,exports.formatArea=A,exports.formatLength=j,exports.mergePopupConfig=at,exports.polygonArea=ee,exports.resolveNameConfig=x;
73
+ `,document.body.appendChild(e),Le.current=e,()=>{document.body.contains(e)&&document.body.removeChild(e)}},[F?.zIndex]);let jn=(0,c.useRef)(v);jn.current=v;let Mn=(0,c.useRef)(ce);Mn.current=ce;let Nn=(0,c.useRef)(yt);Nn.current=yt;let Pn=(0,c.useRef)(H);Pn.current=H;let Fn=(0,c.useRef)(m);Fn.current=m;let In=(0,c.useRef)(Ke);In.current=Ke;let Ln=(0,c.useRef)(W);Ln.current=W;let Rn=(0,c.useRef)(qe);Rn.current=qe;let zn=(0,c.useRef)(d);zn.current=d;let Bn=(0,c.useRef)(b);Bn.current=b,(0,c.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&Z.current){z.current.get(Z.current.entityId)?.cancelEditPreview?.(),Z.current=null;return}if(e.key===`Escape`&&(H===`edit`||K.current)){if(K.current&&=(hn(`cancelled: escape`),!1),Ke&&(U(null),G(null),$()),W===`rectangle`)if(qe)Je(null),Lt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}if(W===`circle`)if(nt.current)nt.current=null,Ut();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}if(W===`polygon`)if(rt.current.length>0)rt.current=[],qt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}if(W===`square`)if(st.current)st.current=null,Qt();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}if(W===`polyline`)if(lt.current.length>0)lt.current=[],nn();else{G(null);let e=R.current;e&&(e.getCanvas().style.cursor=``)}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[H,Ke,W,qe,$,Lt,Ut,qt,Qt,nn,hn]),(0,c.useEffect)(()=>{let e=R.current;if(!e||!V)return;let t=V.entityId,n=V.config,r=()=>{let r=jn.current.find(e=>e.id===t);if(!r){xt();return}let{position:i}=ot(r,n,e,void 0,Me.current);Me.current&&(Me.current.style.left=`${i.x}px`,Me.current.style.top=`${i.y}px`)},i=setTimeout(()=>{r()},50);return e.on(`move`,r),e.on(`zoom`,r),e.on(`rotate`,r),e.on(`pitch`,r),()=>{clearTimeout(i),e.off(`move`,r),e.off(`zoom`,r),e.off(`rotate`,r),e.off(`pitch`,r)}},[V?.entityId,xt]),(0,c.useEffect)(()=>{let e=R.current,t=L.current;if(!e||!Fe||!t)return;let n=Fe.lngLat,r=()=>{let r=e.project(n),i=t.clientWidth,a=t.clientHeight;if(r.x<0||r.x>i||r.y<0||r.y>a){An();return}let o=t.getBoundingClientRect(),s=r.x+o.left,c=r.y+o.top;Re.current&&(Re.current.style.left=`${s}px`,Re.current.style.top=`${c}px`)};return e.on(`move`,r),e.on(`zoom`,r),e.on(`rotate`,r),e.on(`pitch`,r),()=>{e.off(`move`,r),e.off(`zoom`,r),e.off(`rotate`,r),e.off(`pitch`,r)}},[Fe?.lngLat,An]),(0,c.useEffect)(()=>{if(!L.current)return;let e={version:8,sources:{},layers:[]},{dragPan:t=!0,scrollZoom:c=!0,doubleClickZoom:u=!0,touchZoomRotate:d=!0,keyboard:f=!0,dragRotate:p=!0,pitchWithRotate:m=!0,touchPitch:_=!0,boxZoom:y=!0}=h,b=new l.default.Map({container:L.current,style:o||e,center:n,zoom:r,pitch:i,bearing:a,maxBounds:s,dragPan:t,scrollZoom:c,doubleClickZoom:u,touchZoomRotate:d,keyboard:f,dragRotate:p,pitchWithRotate:m,touchPitch:_,boxZoom:y,transformRequest:(e,t)=>{if(t===`Glyphs`){let t=e.match(/\/fonts\/([^/]+)\/(\d+-\d+)\.pbf/);if(t){let e=decodeURIComponent(t[1]),n=t[2],r=e.split(`,`)[0].trim();return{url:`/gis-fonts/${encodeURIComponent(r)}/${n}.pbf`}}}return{url:e}}});return R.current=b,b.on(`load`,()=>{if(!b.getStyle().glyphs){let e=b.style,t=`/gis-fonts/{fontstack}/{range}.pbf`;e.glyphs=t,e.stylesheet&&(e.stylesheet.glyphs=t)}B.current.clear(),v.forEach(e=>{B.current.set(e.id,e)}),wn(g),gn(),Ft(),zt(),Gt(),Yt(),en(),Be(b),oe?.(b)}),b.on(`click`,En),b.on(`mousemove`,Dn),b.on(`contextmenu`,On),()=>{b.off(`click`,En),b.off(`mousemove`,Dn),b.off(`contextmenu`,On),_n(),jt(),$(),Rt(),rn(),b.remove(),R.current=null}},[]),(0,c.useEffect)(()=>{if(R.current){if(!R.current.isStyleLoaded()){R.current.once(`load`,()=>{B.current.clear(),v.forEach(e=>{B.current.set(e.id,e)}),gn()});return}B.current.clear(),v.forEach(e=>{B.current.set(e.id,e)}),gn()}},[v,gn]),(0,c.useEffect)(()=>{!R.current||!R.current.isStyleLoaded()||(_n(),gn())},[C,w,T,E,k,_n,gn]),(0,c.useEffect)(()=>{if(R.current){if(!R.current.isStyleLoaded()){R.current.once(`load`,()=>{wn(g)});return}wn(g)}},[g,wn]);let Vn=(0,c.useRef)(void 0),Hn=(0,c.useRef)(!0),Un=(0,c.useRef)(g);Un.current=g;let Wn=(0,c.useRef)(wn);Wn.current=wn;let Gn=(0,c.useRef)(_n);Gn.current=_n;let Kn=(0,c.useRef)(gn);Kn.current=gn;let qn=(0,c.useRef)(Ft);qn.current=Ft;let Jn=(0,c.useRef)(zt);Jn.current=zt;let Yn=(0,c.useRef)(Gt);Yn.current=Gt;let Xn=(0,c.useRef)(Yt);Xn.current=Yt;let Zn=(0,c.useRef)(en);Zn.current=en,(0,c.useEffect)(()=>{let e=R.current;if(!e)return;let t=o||{version:8,sources:{},layers:[]};if(Hn.current){Hn.current=!1,Vn.current=o;return}Vn.current!==o&&(Vn.current=o,e.setStyle(t),e.once(`style.load`,()=>{if(!e.getStyle().glyphs){let t=e.style,n=`/gis-fonts/{fontstack}/{range}.pbf`;t.glyphs=n,t.stylesheet&&(t.stylesheet.glyphs=n)}Oe.current.clear(),Wn.current(Un.current),Gn.current(),Kn.current(),qn.current(),Jn.current(),Yn.current(),Xn.current(),Zn.current()}))},[o]),(0,c.useEffect)(()=>{let e=new Set(y.map(String));for(let[t,n]of z.current)n.setSelected(e.has(String(t)))},[y]);let Qn=(0,c.useRef)({});(0,c.useEffect)(()=>{let e=R.current;if(!e)return;let t=Qn.current,o=n&&(t.center?.[0]!==n[0]||t.center?.[1]!==n[1]),s=t.zoom!==r,c=t.pitch!==i,l=t.bearing!==a;!o&&!s&&!c&&!l||(Qn.current={center:n,zoom:r,pitch:i,bearing:a},e.jumpTo({center:n,zoom:r,pitch:i,bearing:a}))},[n,r,i,a]);let $n=(()=>M===!1?null:M===!0?{enabled:!0}:M)(),er=(()=>te===!1?null:te===!0?{enabled:!0}:te)(),tr=(()=>ne===!1?null:ne===!0?{enabled:!0}:ne)(),nr=(()=>{if(N===!1)return null;let e,t,n;if(g&&g.length>0){let r=g.find(e=>e.hasRoadNetwork===!0)||g[0];if(r.type===`style`){let t=R.current?.getStyle();if(t?.sources){let n=`base-layer-source-${r.id}-`,i=Object.keys(t.sources).find(e=>e.startsWith(n));i&&(e=i)}}else e=`base-layer-source-${r.id}`;t=r.roadNetworkSourceLayer||`road`,n=r.roadNetworkClassField}return N===!0?{enabled:!0,source:e,sourceLayer:t,classField:n}:{...N,source:N.source||e,sourceLayer:N.sourceLayer||t,classField:N.classField||n}})(),rr=(()=>P?P===!0?{enabled:!0}:P:null)(),ir=(()=>re?re===!0?{enabled:!0}:re:null)(),ar=(()=>ie||null)(),or=(0,c.useMemo)(()=>{let e=[];for(let t of g)if(t.applyRasterPaint)if(t.type===`style`){let n=R.current;if(n){let r=`base-layer-${t.id}-`,i=n.getStyle();if(i?.layers)for(let t of i.layers)t.id.startsWith(r)&&t.type===`raster`&&e.push(t.id)}}else e.push(`base-layer-${t.id}`);return e},[g,ze]),sr=(0,c.useMemo)(()=>{if(H!==`picker`)return;let e=Q.cursorImage;if(!e)return;let t=e.width??32,n=e.height??32,r=e.anchor??`center`,i=t/2,a=n/2;switch(r){case`top-left`:i=0,a=0;break;case`top`:i=t/2,a=0;break;case`top-right`:i=t,a=0;break;case`left`:i=0,a=n/2;break;case`center`:i=t/2,a=n/2;break;case`right`:i=t,a=n/2;break;case`bottom-left`:i=0,a=n;break;case`bottom`:i=t/2,a=n;break;case`bottom-right`:i=t,a=n;break}return`url(${e.url}) ${i} ${a}, crosshair`},[H,Q.cursorImage]),cr=(0,c.useMemo)(()=>sr?{...ve,"--mapbox-picker-cursor":sr}:ve,[ve,sr]);return(0,p.jsxs)(`div`,{className:`comp-mapbox ${H===`picker`?`comp-mapbox--picker-mode`:``} ${he}`,style:cr,children:[(0,p.jsx)(`div`,{ref:L,className:`comp-mapbox__map`}),H===`picker`&&Q.showCrosshair===!0&&(0,p.jsxs)(`div`,{className:`comp-mapbox__crosshair`,children:[(0,p.jsx)(`div`,{className:`comp-mapbox__crosshair-h`,style:Q.crosshairColor?{backgroundColor:Q.crosshairColor}:void 0}),(0,p.jsx)(`div`,{className:`comp-mapbox__crosshair-v`,style:Q.crosshairColor?{backgroundColor:Q.crosshairColor}:void 0})]}),(0,p.jsxs)(`div`,{className:`comp-mapbox__edit-controls${H===`edit`&&d.showEditTools!==!1&&(d.markerTemplates&&d.markerTemplates.length>0||d.showRectangleTool||d.showCircleTool||d.showPolygonTool||d.showSquareTool||d.showPolylineTool)||nr&&nr.enabled!==!1||ar&&ar.enabled!==!1?``:` comp-mapbox__edit-controls--hidden`}`,children:[H===`edit`&&d.showEditTools!==!1&&(d.markerTemplates&&d.markerTemplates.length>0||d.showRectangleTool||d.showCircleTool||d.showPolygonTool||d.showSquareTool||d.showPolylineTool)&&(0,p.jsx)(et,{markerTemplates:d.markerTemplates||[],selectedTemplate:Ke,onTemplateSelect:an,drawMode:W,onDrawModeChange:on,showRectangleTool:d.showRectangleTool,showCircleTool:d.showCircleTool,showPolygonTool:d.showPolygonTool,showSquareTool:d.showSquareTool,showPolylineTool:d.showPolylineTool}),(0,p.jsx)(Pe,{ref:Se,map:ze,showButton:!!(nr&&nr.enabled!==!1),highlightWidth:nr?.highlightWidth,defaultRoadTypes:nr?.defaultRoadTypes,defaultMinWidth:nr?.defaultMinWidth,source:nr?.source,sourceLayer:nr?.sourceLayer,classField:nr?.classField,className:nr?.className,style:nr?.style}),ar&&ar.enabled!==!1&&(0,p.jsx)(it,{ref:be,map:ze,pointCount:ar.pointCount,showPointCountInput:ar.showPointCountInput,visualType:ar.visualType,onSelectFinished:ar.onSelectFinished})]}),($n?.enabled!==!1||er?.enabled!==!1||tr?.enabled!==!1||rr&&rr.enabled!==!1||ir&&ir.enabled!==!1)&&(0,p.jsxs)(`div`,{className:`comp-mapbox__controls`,children:[$n&&$n.enabled!==!1&&(0,p.jsx)(Ee,{map:ze,precision:$n.precision,className:$n.className,style:$n.style}),er&&er.enabled!==!1&&(0,p.jsx)(De,{map:ze,maxWidth:er.maxWidth,unit:er.unit,className:er.className,style:er.style}),rr&&rr.enabled!==!1&&(0,p.jsx)(Ye,{map:ze,entityConfig:b,onDrawModeChange:e=>{dt.current=e},className:rr.className,style:rr.style}),ir&&ir.enabled!==!1&&(0,p.jsx)(Qe,{map:ze,value:_,onChange:ae,rasterPaintLayerIds:or,className:ir.className,style:ir.style}),tr&&tr.enabled!==!1&&(0,p.jsx)(ke,{map:ze,initialCenter:n,initialZoom:r,initialPitch:i,initialBearing:a,duration:tr.duration,className:tr.className,style:tr.style})]}),!(ar&&ar.enabled!==!1)&&(0,p.jsx)(it,{ref:be,map:ze,showButton:!1}),V&&je.current&&(0,p.jsx)(Te,{popupState:V,onClose:()=>bt(V.entityId),portalContainer:je.current,popupRef:Me}),Fe&&Le.current&&(0,p.jsx)(tt,{menuState:Fe,onClose:An,portalContainer:Le.current,menuRef:Re})]})});ft.displayName=`Mapbox`,exports.AttackDirectionRenderer=ge,exports.BaseCanvasRenderer=re,exports.COLOR_SCHEMES=C,exports.CanvasCircleRenderer=xe,exports.CanvasImageRenderer=le,exports.CanvasRadarRenderer=se,exports.CircleRenderer=ye,exports.ContextMenu=tt,exports.CoordinateDisplay=Ee,exports.DEFAULT_NAME_CONFIG=h,exports.DEFAULT_SELECT_NAME_CONFIG=g,exports.EditControl=et,exports.EntityPopup=Te,exports.Mapbox=ft,exports.MarkerRenderer=ue,exports.POPUP_DEFAULTS=T,exports.PolygonRenderer=fe,exports.PolylineRenderer=_e,exports.RADAR_DEFAULTS=w,exports.ROAD_TYPE_OPTIONS=E,exports.RectangleRenderer=we,exports.ResetViewControl=ke,exports.RoadHighlightControl=Pe,exports.ScaleControl=De,exports.SquareRenderer=Ce,exports.UnitRenderer=de,exports.bearing=k,exports.calculatePopupPosition=ot,exports.computeEntityArea=H,exports.computeEntityLengthOrRadius=He,exports.confidenceToOpacity=P,exports.destinationPoint=D,exports.distance=O,exports.formatArea=A,exports.formatLength=j,exports.mergePopupConfig=at,exports.polygonArea=ee,exports.resolveNameConfig=x;