@defra/interactive-map 0.0.56-alpha → 0.0.58-alpha

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.
Files changed (138) hide show
  1. package/dist/esm/im-core.js +1 -1
  2. package/dist/umd/im-core.js +1 -1
  3. package/dist/umd/index.js +1 -1
  4. package/docs/api/button-definition.md +11 -0
  5. package/docs/api/context.md +2 -0
  6. package/docs/api.md +3 -1
  7. package/docs/assets/css/docusaurus.scss +7 -1
  8. package/docs/plugins/draw.md +326 -121
  9. package/package.json +1 -1
  10. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  11. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  12. package/plugins/datasets/dist/umd/index.js +1 -1
  13. package/plugins/datasets/src/initialise/DatasetsInit.jsx +6 -17
  14. package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +3 -43
  15. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  16. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  17. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  18. package/plugins/draw/dist/esm/index.js +1 -1
  19. package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
  20. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  21. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  22. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  23. package/plugins/draw/dist/umd/index.js +1 -1
  24. package/plugins/draw/src/DrawInit.jsx +9 -6
  25. package/plugins/draw/src/DrawInit.test.jsx +15 -0
  26. package/plugins/draw/src/adapterEvents.js +82 -44
  27. package/plugins/draw/src/adapters/adapterContract.test.js +3 -3
  28. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +18 -10
  29. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +31 -22
  30. package/plugins/draw/src/adapters/maplibre/drawEvents.js +2 -1
  31. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +13 -12
  32. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +5 -5
  33. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +1 -1
  34. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +2 -2
  35. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +6 -9
  36. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +4 -4
  37. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +6 -9
  38. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +1 -1
  39. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +8 -14
  40. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +37 -8
  41. package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +11 -1
  42. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +14 -19
  43. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +41 -4
  44. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +12 -1
  45. package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +3 -1
  46. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +9 -10
  47. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +5 -24
  48. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -7
  49. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +12 -7
  50. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
  51. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +7 -3
  52. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +11 -11
  53. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -15
  54. package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +21 -28
  55. package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +26 -5
  56. package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +5 -6
  57. package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +2 -12
  58. package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +9 -0
  59. package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +7 -0
  60. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +6 -9
  61. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +3 -3
  62. package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +18 -9
  63. package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +29 -4
  64. package/plugins/draw/src/adapters/openlayers/point/pointOps.js +3 -2
  65. package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +6 -0
  66. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +3 -4
  67. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +2 -12
  68. package/plugins/draw/src/api/createNewShape.js +4 -4
  69. package/plugins/draw/src/api/createNewShape.test.js +1 -1
  70. package/plugins/draw/src/api/editFeature.js +8 -11
  71. package/plugins/draw/src/api/editFeature.test.js +33 -22
  72. package/plugins/draw/src/api/newLine.test.js +3 -3
  73. package/plugins/draw/src/api/newPoint.js +4 -5
  74. package/plugins/draw/src/api/newPoint.test.js +11 -3
  75. package/plugins/draw/src/api/newPolygon.test.js +11 -3
  76. package/plugins/draw/src/api/recheckGeometry.js +32 -0
  77. package/plugins/draw/src/api/recheckGeometry.test.js +55 -0
  78. package/plugins/draw/src/api/setGeometry.js +33 -0
  79. package/plugins/draw/src/api/setGeometry.test.js +48 -0
  80. package/plugins/draw/src/api/split.js +26 -22
  81. package/plugins/draw/src/api/split.test.js +38 -18
  82. package/plugins/draw/src/events.js +269 -77
  83. package/plugins/draw/src/events.test.js +779 -34
  84. package/plugins/draw/src/hooks/useSpatialList.js +10 -11
  85. package/plugins/draw/src/hooks/useSpatialList.test.js +3 -3
  86. package/plugins/draw/src/manifest.js +30 -15
  87. package/plugins/draw/src/manifest.test.js +91 -9
  88. package/plugins/draw/src/reducer.js +31 -9
  89. package/plugins/draw/src/reducer.test.js +35 -3
  90. package/plugins/draw/src/utils/drawModes.js +27 -0
  91. package/plugins/draw/src/utils/drawModes.test.js +27 -0
  92. package/plugins/draw/src/utils/needsDrawTarget.js +1 -5
  93. package/plugins/draw/src/utils/needsDrawTarget.test.js +1 -11
  94. package/plugins/draw/src/utils/touchTarget.js +34 -26
  95. package/plugins/draw/src/utils/touchTarget.test.js +32 -20
  96. package/plugins/draw/src/validation/commitChecks.js +187 -0
  97. package/plugins/draw/src/validation/commitChecks.test.js +209 -0
  98. package/plugins/draw/src/validation/liveDrawChecks.js +11 -11
  99. package/plugins/draw/src/validation/liveDrawChecks.test.js +37 -37
  100. package/plugins/draw/src/validation/liveStroke.js +6 -6
  101. package/plugins/draw/src/validation/liveStroke.test.js +27 -27
  102. package/plugins/draw/src/validation/rules.js +16 -14
  103. package/plugins/draw/src/validation/rules.test.js +5 -5
  104. package/plugins/draw/src/validation/validateGeometry.js +58 -31
  105. package/plugins/draw/src/validation/validateGeometry.test.js +68 -44
  106. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  107. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  108. package/plugins/interact/dist/umd/index.js +1 -1
  109. package/plugins/interact/src/hooks/useInteractionHandlers.js +3 -5
  110. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +4 -3
  111. package/plugins/interact/src/hooks/useSpatialList.js +16 -17
  112. package/plugins/interact/src/hooks/useSpatialList.test.js +9 -9
  113. package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
  114. package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
  115. package/plugins/map-styles/src/MapStyles.jsx +2 -2
  116. package/providers/maplibre/dist/esm/index.js +1 -1
  117. package/providers/maplibre/dist/umd/index.js +1 -1
  118. package/providers/maplibre/src/index.js +11 -2
  119. package/providers/maplibre/src/index.test.js +23 -1
  120. package/providers/maplibre/src/utils/detectModuleWorker.js +8 -19
  121. package/providers/maplibre/src/utils/detectModuleWorker.test.js +19 -23
  122. package/providers/maplibre/src/utils/workerUrl.js +12 -0
  123. package/providers/maplibre/src/utils/workerUrl.test.js +14 -1
  124. package/src/App/components/MapButton/MapButton.jsx +6 -0
  125. package/src/App/components/MapButton/MapButton.test.jsx +10 -0
  126. package/src/App/components/Markers/Markers.jsx +3 -5
  127. package/src/App/components/Markers/Markers.test.jsx +9 -11
  128. package/src/App/components/Panel/Panel.jsx +2 -9
  129. package/src/App/hooks/useInterfaceAPI.js +16 -4
  130. package/src/App/hooks/useInterfaceAPI.test.js +66 -1
  131. package/src/App/renderer/mapButtons.js +2 -1
  132. package/src/App/renderer/mapButtons.test.js +9 -0
  133. package/src/App/store/MapProvider.jsx +3 -0
  134. package/src/App/store/MapProvider.test.jsx +24 -0
  135. package/src/config/mapSizeScales.js +3 -0
  136. package/src/types.js +4 -0
  137. package/src/utils/focusAfterPanelClose.js +9 -0
  138. package/src/utils/focusAfterPanelClose.test.js +40 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/interactive-map",
3
- "version": "0.0.56-alpha",
3
+ "version": "0.0.58-alpha",
4
4
  "description": "An accessible map component",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- import{useRef as t,useEffect as e}from"preact/compat";import{jsx as a,jsxs as s,Fragment as i}from"preact/jsx-runtime";const r=t=>{const{datasets:e=[]}=t,a=[],s=e.filter(t=>t.showInMenu||t.sublayers?.some(t=>t.showInMenu)),i=new Map;return s.forEach(t=>{if(t.sublayers?.length){const e=t.sublayers.filter(e=>t.showInMenu?!1!==e.showInMenu:e.showInMenu);if(!1===t.showInMenu&&!e.length)return;const s={id:t.id,groupLabel:t.label,visibleWhen:!0,type:"checkbox",items:e.map(e=>({id:`${t.id}-${e.id}`,label:e.label}))};0===s.items.length&&(delete s.groupLabel,s.items.push({id:t.id,label:t.label})),a.push(s)}else if(t.groupLabel){const e=i.has(t.groupLabel)?i.get(t.groupLabel):{id:t.groupLabel,groupLabel:t.groupLabel,visibleWhen:!0,type:"checkbox",items:[]};i.has(t.groupLabel)||(i.set(t.groupLabel,e),a.push(e)),e.items.push({id:t.id,label:t.label})}else a.push({visibleWhen:!0,type:"checkbox",id:t.id,items:[{id:t.id,label:t.label}]})}),a},n=(t,e)=>t.reduce((t,a)=>{const s=a.items.filter(t=>!e.includes(t.id));return s.length&&t.push({...a,items:s}),t},[]),o={minZoom:6,maxZoom:24,showInKey:!1,showInMenu:!1,visible:!0,style:{stroke:"#d4351c",strokeWidth:2,symbolDescription:"red outline"}},l=["stroke","strokeWidth","strokeDashArray","fill","fillPattern","fillPatternSvgContent","fillPatternForegroundColor","fillPatternBackgroundColor","opacity","symbolDescription","symbol","symbolSvgContent","symbolViewBox","symbolAnchor","symbolSize","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"],d=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"],u=t=>d.some(e=>e in t),p=(t={})=>u(t)?{strokeWidth:o.style.strokeWidth,...t}:{...o.style,...t},h=(t,e)=>{const{id:a}=e,s=(t=>{!0!==t.visible&&!1!==t.visible&&(t.visible="hidden"!==t.visibility);const e={...o,...t,style:{...t.style}};return l.forEach(t=>delete e[t]),e})(e);e.parentId&&("showInKey"in e||delete s.showInKey,"showInMenu"in e||delete s.showInMenu),t[a]=s;const{orderedDatasets:i}=t;i.push(a);const r=e.sublayers?.map(t=>((t,e)=>{const a=`${t}-${e.id}`,s=e.id;return"hidden"!==e.visibility&&(e.visibility="visible"),{...e,id:a,parentId:t,sublayerId:s}})(a,t));if(r?.length){const e=r?.map(t=>t.id),s=r?.reduce(h,{orderedDatasets:i});return t[a].sublayerIds=e,delete t[a].sublayers,{...t,...s,orderedDatasets:i}}return{...t,orderedDatasets:i}},c=t=>{const e=(t.datasets||[]).reduce(h,{orderedDatasets:[]}),{orderedDatasets:a}=e;return delete e.orderedDatasets,{...t,mappedDatasets:e,orderedDatasets:a}},y="[interactive-map]",m={warn:(...t)=>console.warn(y,...t),error:(...t)=>console.error(y,...t)},g={globals:{visible:!0,opacity:1,opacityMode:"dataset"},key:{items:[],hasGroups:!1},mappedDatasets:{},orderedDatasets:[],actionsArray:[],menu:[],menuInitialised:!1},b=(t,e,a,s="not found")=>!!t.mappedDatasets[e]||(m.error(`${a}: Dataset with id '${e}' ${s}`),!1),f=(t,e,a)=>({...a,actionsArray:[...a.actionsArray,{method:t,parameters:e}]}),D={SET_DATASETS:(t,e)=>{const{mappedDatasets:a,orderedDatasets:s}=e;return{...t,mappedDatasets:a,orderedDatasets:s}},ADD_DATASET:(t,e)=>{const{dataset:a,mapStyle:s}=e;if(t.mappedDatasets[a.id])return m.error(`addDataset: Dataset with id '${a.id}' already exists`),t;const{mappedDatasets:i,orderedDatasets:n}=c({datasets:[a]}),o=((t,e)=>{const a=[...t.menu],s=r({datasets:[e]}),i=a.find(t=>t.groupLabel===s[0].groupLabel);return i?i.items.push(...s[0].items):a.push(...s),a})(t,a);return f("addDataset",[a.id,s],{...t,mappedDatasets:{...t.mappedDatasets,...i},orderedDatasets:[...t.orderedDatasets,...n],menu:o})},REMOVE_DATASET:(t,e)=>{const{id:a}=e;if(!b(t,a,"removeDataset"))return t;const s={...t.mappedDatasets},i=[a,...s[a]?.sublayerIds||[]];i.forEach(t=>delete s[t]);const r=t.orderedDatasets.filter(t=>!i.includes(t));return{...t,mappedDatasets:s,orderedDatasets:r,menu:n(t.menu,i)}},SET_DATASET_VISIBILITY:(t,e)=>{const{datasetId:a,visible:s}=e;return b(t,a,"setDatasetVisibility")?t.mappedDatasets[a].visible===s?t:f("applyDatasetVisibility",[a,s],{...t,mappedDatasets:{...t.mappedDatasets,[a]:{...t.mappedDatasets[a],visible:s}}}):t},SET_GLOBAL_VISIBILITY:(t,e)=>{const{visible:a}=e;return f("applyGlobalVisibility",[a],{...t,globals:{...t.globals,visible:a}})},SET_DATASET_STYLE:(t,e)=>{const{datasetId:a,styleChanges:s,mapStyle:i}=e;if(!b(t,a,"setDatasetStyle"))return t;const r={...t.mappedDatasets[a].style,...s},n={...t.mappedDatasets[a],...s,style:r};return f("applyStyle",[a,i],{...t,mappedDatasets:{...t.mappedDatasets,[a]:n}})},SET_OPACITY:(t,e)=>{const{datasetId:a,opacity:s}=e;if(!b(t,a,"setOpacity"))return t;const i={...t.mappedDatasets[a].style,opacity:s},r={...t.mappedDatasets[a],style:i};return f("applyDatasetOpacity",[a],{...t,mappedDatasets:{...t.mappedDatasets,[a]:r}})},SET_GLOBAL_OPACITY:(t,e)=>{const{opacity:a}=e;return f("applyGlobalOpacity",[],{...t,globals:{...t.globals,opacity:a}})},HIDE_FEATURES:(t,e)=>{const{datasetId:a,featureIds:s}=e;if(!b(t,a,"setFeatureVisibility - hideFeatures"))return t;const i={...t.mappedDatasets[a]},r=i.hiddenFeatures||[],n=Array.from(new Set([...r,...s]));return i.hiddenFeatures=n,f("applyFeatureFilter",[a],{...t,mappedDatasets:{...t.mappedDatasets,[a]:i}})},SHOW_FEATURES:(t,e)=>{const{datasetId:a,featureIds:s}=e;if(!b(t,a,"setFeatureVisibility - showFeatures"))return t;const i={...t.mappedDatasets[a]},r=(i.hiddenFeatures||[]).filter(t=>!s.includes(t));return i.hiddenFeatures=r.length?r:[-1],f("applyFeatureFilter",[a],{...t,mappedDatasets:{...t.mappedDatasets,[a]:i}})},REMOVE_ADAPTER_ACTIONS:(t,e)=>e?.length?{...t,actionsArray:t.actionsArray.filter(t=>!e.includes(t))}:t,SET_GLOBAL_STATE:(t,e)=>f("applyGlobalOpacity",[],{...t,globals:{...t.globals,...e}}),SET_MENU:(t,e)=>{const{menu:a}=e;return{...t,menu:a,menuInitialised:!0}}},S={APP_HIDE_PANEL:"app:hidepanel",MAP_SIZE_CHANGE:"map:sizechange",MAP_DATA_CHANGE:"map:datachange"},_=(t,e)=>!(!t||!e)&&!(t[2]<e[0]||t[0]>e[2]||t[3]<e[1]||t[1]>e[3]),I=t=>{let e=1/0,a=1/0,s=-1/0,i=-1/0;const r=(t,n)=>{var o;0===n?(o=t,e=Math.min(e,o[0]),a=Math.min(a,o[1]),s=Math.max(s,o[0]),i=Math.max(i,o[1])):t.forEach(t=>r(t,n-1))};switch(t.type){case"Point":r(t.coordinates,0);break;case"LineString":case"MultiPoint":r(t.coordinates,1);break;case"Polygon":case"MultiLineString":r(t.coordinates,2);break;case"MultiPolygon":r(t.coordinates,3);break;case"GeometryCollection":t.geometries.forEach(t=>{const r=I(t);e=Math.min(e,r[0]),a=Math.min(a,r[1]),s=Math.max(s,r[2]),i=Math.max(i,r[3])});break;default:throw new Error(`Unsupported geometry type: ${t.type}`)}return[e,a,s,i]},v=t=>({type:"FeatureCollection",features:Array.from(t.values()).map(t=>t.feature)}),A=async(t,{mapProvider:e,dynamicGeoJSON:a,onUpdate:s})=>{const{url:i,idProperty:r,transformRequest:n,maxFeatures:o,minZoom:l=0}=a,d=e.getZoom();if(d<l)return;const u=(t=>t.getBounds())(e);if(!(t.fetchedBbox&&(p=t.fetchedBbox,h=u,p&&h&&h[0]>=p[0]&&h[1]>=p[1]&&h[2]<=p[2]&&h[3]<=p[3]))){var p,h,c,y;t.currentController&&t.currentController.abort(),t.currentController=new AbortController;try{const e={bbox:u,zoom:d},l=await(async(t,e,a,s)=>{const i=a(t,e),r="string"==typeof i?{url:i}:i,{url:n,headers:o={}}=r,l=await fetch(n,{headers:o,signal:s});if(!l.ok)throw new Error(`Failed to fetch GeoJSON: ${l.status} ${l.statusText}`);const d=await l.json();if("FeatureCollection"===d.type)return d;if("Feature"===d.type)return{type:"FeatureCollection",features:[d]};if(Array.isArray(d))return{type:"FeatureCollection",features:d};throw new Error("Invalid GeoJSON response")})(i,e,n,t.currentController.signal);((t,e,a)=>{const s=Date.now();e.features.forEach(e=>{const i=((t,e)=>e?t.properties?.[e]??t.id:t.id)(e,a);null!=i?t.set(i,{feature:e,bbox:I(e.geometry),lastSeenAt:s}):console.warn("Feature missing ID, skipping:",e)})})(t.features,l,r),t.fetchedBbox=(c=t.fetchedBbox,y=u,c?[Math.min(c[0],y[0]),Math.min(c[1],y[1]),Math.max(c[2],y[2]),Math.max(c[3],y[3])]:[...y]);const p=t.features.size;((t,e,a)=>{if(!a||t.size<=1.2*a)return;const s=a,i=[],r=[];for(const[a,s]of t)_(s.bbox,e)?i.push(a):r.push({id:a,lastSeenAt:s.lastSeenAt});r.sort((t,e)=>t.lastSeenAt-e.lastSeenAt);const n=t.size-s;for(let e=0;e<n&&e<r.length;e++)t.delete(r[e].id);if(t.size>s){const e=t.size-s,a=i.map(e=>({id:e,lastSeenAt:t.get(e).lastSeenAt})).sort((t,e)=>t.lastSeenAt-e.lastSeenAt);for(let s=0;s<e&&s<a.length;s++)t.delete(a[s].id)}})(t.features,u,o),t.features.size<p&&(t.fetchedBbox=u),s(a.id,v(t.features))}catch(t){if("AbortError"===t.name)return;console.error(`Failed to fetch dynamic GeoJSON for ${a.id}:`,t)}}},C=({dynamicGeoJSON:t,mapProvider:e,onUpdate:a})=>{const s={features:new Map,fetchedBbox:null,currentController:null},i=()=>A(s,{mapProvider:e,dynamicGeoJSON:t,onUpdate:a}),r=((t,e)=>{let a;const s=(...s)=>{clearTimeout(a),a=setTimeout(()=>t(...s),e)};return s.cancel=()=>{clearTimeout(a),a=null},s})(i,200),n=()=>{r()};return e.map.on("moveend",n),i(),{destroy(){var t,a;t=e.map,a=n,(t.off||t.un).call(t,"moveend",a),r.cancel(),s.currentController&&s.currentController.abort()},clear(){s.features.clear(),s.fetchedBbox=null,a(t.id,{type:"FeatureCollection",features:[]})},refresh(){s.features.clear(),s.fetchedBbox=null,i()},getFeatureCount:()=>s.features.size,reapply(){s.features.size>0&&a(t.id,v(s.features))}}},E=async(t,e,a,s)=>{const i=await(async t=>{switch(t.name){case"MapLibreProvider":{const{default:t}=await import(/* webpackChunkName: "im-datasets-ml-adapter" */ "./im-datasets-ml-adapter.js");return t}case"EsriProvider":{const{default:t}=await import(/* webpackChunkName: "im-datasets-esri-adapter" */ "./im-datasets-esri-adapter.js");return t}case"OpenLayersProvider":{const{default:t}=await import(/* webpackChunkName: "im-datasets-ol-adapter" */ "./im-datasets-ol-adapter.js");return t}default:throw new Error(`No layer adapter available for map provider ${t.name}. Please provide a compatible layer adapter.`)}})(t);return new i(t,e,a,s)},M=({pluginConfig:t,pluginState:e})=>!1!==t.hasMenu&&(e.menuInitialised?e.menu.length>0:(t.datasets||[]).some(t=>t.showInMenu||t.sublayers?.some(t=>t.showInMenu)));const T="datasetsLayers";function w({appConfig:a,appState:s,pluginConfig:i,pluginState:n,mapState:o,mapProvider:l,services:d}){const{dispatch:u,datasetRegistry:p}=n,{eventBus:h,symbolRegistry:y,patternRegistry:m}=d,g=Boolean(l?.isBaseMapReady());!function({appConfig:a,appState:s,pluginConfig:i,pluginState:r,services:n}){const{eventBus:o,focusMap:l}=n,d=M({pluginConfig:i,pluginState:r}),u=Boolean(s.openPanels[T]),p=t(null);e(()=>{if(d||!u)return;const t=document.getElementById(`${a.id}-panel-${e=T,e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`);var e;const s=Boolean(t?.contains(document.activeElement));o.emit(S.APP_HIDE_PANEL,T),s&&(p.current=requestAnimationFrame(()=>l()))},[d,u]),e(()=>()=>cancelAnimationFrame(p.current),[])}({appConfig:a,appState:s,pluginConfig:i,pluginState:n,services:d});const b=t(n);b.current=n;const f=t(null),D=t=>{const e=l?.datasets;t.length&&e&&(t.forEach(({method:t,parameters:a})=>e[t](...a)),u({type:"REMOVE_ADAPTER_ACTIONS",payload:t}))};return e(()=>{if(!g)return;if(f.current)return;(async()=>{const t=await E(l,y,m,p);f.current=(({adapter:t,datasetRegistry:e,pluginConfig:a,mapStyle:s,mapProvider:i,events:n,dispatch:o,eventBus:l})=>{const{datasets:d}=a,u=new Map;a.globals&&o({type:"SET_GLOBAL_STATE",payload:a.globals});const{mappedDatasets:p,orderedDatasets:h}=c({datasets:d});t.createDataset&&e.attachCreateDataset(t.createDataset),e.attach(p,h,s);const y=r({datasets:d});l.requestOnce("menu:state",t=>e.attachMenuStateRef(t)),o({type:"SET_MENU",payload:{menu:y}}),o({type:"SET_DATASETS",payload:{mappedDatasets:p,orderedDatasets:h}}),t.init().then(()=>{e.forEachDataset(e=>{if(!e.hasDynamicGeoJSON)return;const{dynamicGeoJSON:a}=e,s=C({dynamicGeoJSON:a,mapProvider:i,onUpdate:(e,a)=>t.setData(e,a)});u.set(e.id,s)}),t.attachDynamicSources(u),l.emit("datasets:ready")});const m=()=>{t.onMapSizeChange()};l.on(n.MAP_SIZE_CHANGE,m);const g=l.emitWhenRequested("datasets:registry",e);return l.on("menu:changed",a=>{e.invalidateKeyItemsOnMenuStateChange(a),t.applyGlobalVisibility()}),{remove(){l.off(n.MAP_SIZE_CHANGE,m),g(),u.forEach(t=>t.destroy()),u.clear(),t.destroy()},refreshDataset(t){u.get(t)?.refresh()},clearDatasetCache(t){u.get(t)?.clear()},getFeatureCount:t=>u.get(t)?.getFeatureCount()??null}})({adapter:t,datasetRegistry:p,pluginConfig:i,mapStyle:o.mapStyle,mapProvider:l,events:S,dispatch:u,eventBus:h}),l.datasets=t,D(b.current.actionsArray)})()},[g]),e(()=>{p.attach(n.mappedDatasets,n.orderedDatasets),h.emit("datasets:changed")},[n.mappedDatasets,n.orderedDatasets]),e(()=>{p.attachMapStyle(o.mapStyle);const t=l?.datasets;t?.onMapStyleChange&&Promise.resolve(t.onMapStyleChange()).then(()=>{h.emit(S.MAP_DATA_CHANGE)})},[o.mapStyle]),e(()=>p.attachGlobals(n.globals),[n.globals]),e(()=>D(n.actionsArray),[n.actionsArray]),e(()=>()=>{f.current&&(f.current.remove(),f.current=null,l.datasets=null)},[]),null}const L=({pluginState:{dispatch:t}},e,a={})=>{const{datasetId:s,sublayerId:i}=a,r=i?`${s}-${i}`:s;t(r?{type:"SET_DATASET_VISIBILITY",payload:{datasetId:r,visible:e}}:{type:"SET_GLOBAL_VISIBILITY",payload:{visible:e}})},P=({menuGroupItem:t,datasetRegistry:e,onChange:i})=>{const r=e.getDataset(t.id);if(!r)return null;const n=r.isSublayer?r.parentId:r.id,o=r.isSublayer?r.id:void 0,l="im-c-datasets-layers__item govuk-checkboxes govuk-checkboxes--small"+(r.visible?"":" im-c-datasets-layers__item--checked");return a("div",{className:l,"data-module":"govuk-checkboxes",children:s("div",{className:"govuk-checkboxes__item",children:[a("input",{className:"govuk-checkboxes__input",id:r.id,"data-dataset-id":n,"data-sublayer-id":o,name:"layers",type:"checkbox",value:r.id,checked:r.isLocallyVisible,onChange:i}),a("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:r.id,children:r.label})]})},r.id)},k=({menuGroup:t,children:e})=>{if(!t.groupLabel)return a(i,{children:e});return a("div",{className:"govuk-form-group im-c-datasets-layers-group",children:s("fieldset",{className:"im-c-datasets-layers-group__fieldset",children:[a("legend",{className:"im-c-datasets-layers-group__legend",children:a("h3",{children:t.groupLabel})}),e]})},t.id)},O=({pluginState:{dispatch:t},mapState:e},a)=>{t({type:"ADD_DATASET",payload:{dataset:a,mapStyle:e.mapStyle}})},F=({pluginState:{dispatch:t},mapProvider:e},a)=>{e.datasets?.removeDataset(a),t({type:"REMOVE_DATASET",payload:{id:a}})},x=({pluginState:{dispatch:t,datasetRegistry:e}},a,s,{datasetId:i=null}={})=>{if(i){const t=e.getDataset(i);!t||t.idProperty||t.generateIds||m.warn(`setFeatureVisibility: Dataset "${i}" has no idProperty or generateIds configured. Features may not be matched correctly. Add idProperty to match by a feature property, or add generateIds: true to use auto-generated IDs.`)}t({type:a?"SHOW_FEATURES":"HIDE_FEATURES",payload:{datasetId:i,featureIds:s}})},G=({pluginState:{dispatch:t},mapState:e},a,{datasetId:s,sublayerId:i}={})=>{t({type:"SET_DATASET_STYLE",payload:{datasetId:s=i?`${s}-${i}`:s,styleChanges:a,mapStyle:e.mapStyle}})},B=({pluginState:{datasetRegistry:t}},{datasetId:e,sublayerId:a}={})=>{e=a?`${e}-${a}`:e;const s=t.getDataset(e);return s?s.style:(m.warn(`getStyle: Dataset with id ${e} not found`),null)},R=({pluginState:{dispatch:t}},e,a={})=>{const{datasetId:s,sublayerId:i}=a,r=i?`${s}-${i}`:s;t(r?{type:"SET_OPACITY",payload:{datasetId:r,opacity:e}}:{type:"SET_GLOBAL_OPACITY",payload:{opacity:e}})},N=({pluginState:{globals:t,datasetRegistry:e}},a={})=>{const{datasetId:s,sublayerId:i}=a,r=i?`${s}-${i}`:s;if(r){const t=e.getDataset(r);return t?t.opacity??null:(m.warn(`getOpacity: Dataset with id ${r} not found`),null)}return t.opacity??null},$=({pluginState:{datasetRegistry:t},mapProvider:e},a,{datasetId:s})=>{const i=t.getDataset(s);i?i?.tiles?m.warn(`setData called on vector tile dataset "${s}" — has no effect`):e.datasets?.setData(s,a):m.warn(`setData: Dataset with id ${s} not found`)},V=({pluginState:{dispatch:t}},e)=>{const{opacityMode:a}=e,s={};let i=!1;a&&(["dataset","global","multiply"].includes(a)?(i=!0,s.opacityMode=a):m.warn(`Ignoring invalid opacityMode: ${a}. Must be one of 'dataset', 'global' or 'multiply'.`)),i?t({type:"SET_GLOBAL_STATE",payload:s}):m.warn("setGlobals: requires a valid value for opacityMode to be set")};class W{constructor(t){this.id=t.id,this.url=t.url,this.transformRequest=t.transformRequest,this.maxFeatures=t.maxFeatures,this.minZoom=t.minZoom,this.idProperty=t.idProperty,this.hiddenFeaturesIdExpression=["to-string",["get",this.idProperty]],this.sourceId=`geojson-dynamic-${this.id}`,this.source={type:"geojson",data:{type:"FeatureCollection",features:[]},...this.idProperty?{promoteId:this.idProperty}:{generateId:!0}}}}const j=(t,e,a)=>{switch(t.opacityMode){case"global":return t.opacity;case"multiply":return((t,e=1,a=1)=>Math.round(100*(e*a*t.opacity+Number.EPSILON))/100)(t,e,a);default:return((t,e,a)=>void 0===e?void 0===a?t.opacity:a:e)(t,e,a)}};class Z{constructor(t,e){this._datasetDefinition=t,this._datasetRegistry=e}get id(){return this._datasetDefinition.id}get label(){return this._datasetDefinition.label}get hasSymbol(){return!(this.hasSublayers||(t=this.style,!t?.symbol&&!t?.symbolSvgContent));var t}get hasPattern(){return!(this.hasSublayers||this.hasSymbol||(t=this.style,!t.fillPattern&&!t.fillPatternSvgContent));var t}get hasFill(){return!this.hasSublayers&&!this.hasSymbol&&(this.hasPattern||this.style?.fill&&"transparent"!==this.style?.fill)}get hasStroke(){return!this.hasSublayers&&!this.hasSymbol&&Boolean(this.style?.stroke)}get tiles(){return this._datasetDefinition.tiles}get geojson(){return this._datasetDefinition.geojson}get idProperty(){return this._datasetDefinition.idProperty}get generateIds(){return this._datasetDefinition.generateIds}get parentId(){return this._datasetDefinition.parentId}get minZoom(){return this._datasetDefinition.minZoom||this.parent?.minZoom}get maxZoom(){return this._datasetDefinition.maxZoom||this.parent?.maxZoom}get type(){return this._datasetDefinition.type||this.parent?.type}get showInKey(){const t=this._datasetDefinition.showInKey;return void 0!==t?t:this.parent?.showInKey??!1}get visibleWhen(){return void 0===this._datasetDefinition.visibleWhen?this.parent?.visibleWhen:this._datasetDefinition.visibleWhen}get groupLabel(){return this._datasetDefinition.groupLabel||this.parent?.groupLabel||this.parent?.label}get groupId(){const t=this._datasetDefinition.groupId||this.parent?.groupId;return t||(this.groupLabel?this.groupLabel.toLowerCase().replace(/\s+/g,"-"):null)}get opacity(){const t=this.style?.opacity,e=this.parent?.style?.opacity;return j(this._datasetRegistry.globals,t,e)}get hasDynamicGeoJSON(){return Boolean(this._datasetDefinition.dynamicGeoJSON)}get dynamicGeoJSON(){return new W({...this._datasetDefinition.dynamicGeoJSON,id:this.id,minZoom:this.minZoom})}get hiddenFeatures(){return this._datasetDefinition.hiddenFeatures}get hasHiddenFeatures(){return Boolean(this.hiddenFeatures?.length>0||this.parent?.hasHiddenFeatures)}get filter(){return null}get isHiddenByInheritance(){return this.isSublayer?!this.parent?.visible:!this._datasetRegistry.globals.visible}get isLocallyVisible(){return!!this.isVisible||this._datasetDefinition.visible}get visible(){return this.isSublayer?this._datasetDefinition.visible&&this.parent?.visible:this._datasetDefinition.visible&&this._datasetRegistry.globals.visible}get esriStyleLayerId(){return this._datasetDefinition.esriStyleLayerId}get visibility(){const{visible:t,visibleWhen:e}=this;return t&&e?this._datasetRegistry.isVisibleWhen(e)?"visible":"none":t?"visible":"none"}get keyVisibility(){return this.showInKey&&"visible"===this.visibility}get symbolAnchor(){return this.style?.symbolAnchor?this.style.symbolAnchor:this.parent?.symbolAnchor}get sourceLayer(){return this.isSublayer?this.parent.sourceLayer:this.tiles?this._datasetDefinition.sourceLayer:void 0}get isSublayer(){return Boolean(this._datasetDefinition.parentId)}get hasSublayers(){return this._datasetDefinition.sublayerIds?.length>0}get sublayerIds(){return this._datasetDefinition.sublayerIds}get sublayers(){const{sublayerIds:t}=this;return t?t.map(t=>this._datasetRegistry.getDataset(t)):[]}get parent(){if(this._datasetDefinition.parentId)return this._datasetRegistry.getDataset(this._datasetDefinition.parentId)}get inheritedStyle(){const t=this._datasetDefinition.style||{},e=this.parent;return e?{...e.inheritedStyle,opacity:void 0,...t}:t}get style(){return{...p(this.inheritedStyle),symbolDescription:this.symbolDescription}}get hasCustomVisualStyle(){return u(this._datasetDefinition.style||{})}get symbolDescription(){return this._datasetDefinition.style?.symbolDescription?this._datasetDefinition.style.symbolDescription:this.hasCustomVisualStyle?void 0:this.parent?this.parent.symbolDescription:o.style.symbolDescription}get patternConfigs(){const t=this.hasPattern?[this.style]:[];return this.hasSublayers?[...t,...this.sublayers.flatMap(t=>t.patternConfigs)]:t}get symbolConfigs(){const t=this.hasSymbol?[this.style]:[];return this.hasSublayers?[...t,...this.sublayers.flatMap(t=>t.symbolConfigs)]:t}get keyDefinition(){return{id:this.id,type:"dataset",label:this.label,hasSymbol:this.hasSymbol,hasPattern:this.hasPattern,style:this.style,symbolDescription:this.symbolDescription}}}class K{constructor(){this.idToDefinitionMap=new Map,this.definitionToInstanceMap=new Map}add(t){this.idToDefinitionMap.set(t.id,t._datasetDefinition),this.definitionToInstanceMap.set(t._datasetDefinition,t)}invalidateDataset(t){const e=this.idToDefinitionMap.get(t.id);[e.id,...e?.sublayerIds||[]].forEach(t=>{const e=this.idToDefinitionMap.get(t);this.definitionToInstanceMap.delete(e),this.idToDefinitionMap.delete(t)})}invalidateChangedDatasets(t){t.forEach(t=>{const e=this.idToDefinitionMap.get(t.id);if(e&&e!==t){const t=this.definitionToInstanceMap.get(e);this.invalidateDataset(t.isSublayer&&t.parent?t.parent:t)}})}getByDefinition(t){return this.definitionToInstanceMap.get(t)}}const z=(t,e={})=>{for(const[a,s]of Object.entries(t)){const t=e[a];if(!s.includes(t))return!1}return!0},H=(t,e)=>(Array.isArray(t)?t:[t]).includes(e),J={attach(t,e,a){this._datasets=t,this._orderedDatasets=e,this.attachMapStyle(a),this._invalidateChangedDatasets()},_invalidateCache(){this._definitionCache=new K},_invalidateChangedDatasets(){this._datasets?this._definitionCache.invalidateChangedDatasets(Object.values(this._datasets)):this._invalidateCache()},attachCreateDataset(t){this._createDataset=t},_createDataset:(t,e)=>((t,e)=>new Z(t,e))(t,e),attachMapStyle(t){t&&(this._mapStyle=t)},get mapStyle(){return this._mapStyle},attachGlobals(t){t&&(this._globals=t)},get globals(){return this._globals},attachMenuStateRef(t){this._menuStateRef=t},isVisibleWhen(t){return((t,{mapStyleId:e,menuState:a}={})=>{if(null==t)return!0;if("boolean"==typeof t)return t;if("object"==typeof t){for(const[s,i]of Object.entries(t)){if("mapStyleId"===s&&!H(i,e))return!1;if("menu"===s&&!z(i,a))return!1}return!0}return!0})(t,{mapStyleId:this._mapStyle?.id,menuState:this._menuStateRef?.current?.menuState})},get datasets(){return this._datasets},getDataset(t){const e=this.datasets[t];if(!e)return;const a=this._definitionCache.getByDefinition(e);if(a)return a;const s=this._createDataset(e,this);return this._definitionCache.add(s),s.isSublayer&&this.getDataset(s.parentId),s},forEach(t){this._orderedDatasets.forEach(e=>t(this.getDataset(e)))},forEachDataset(t){Object.values(this.datasets).filter(t=>!t.parentId).forEach(e=>t(this.getDataset(e.id)))},topLevelDatasets(){return Object.values(this.datasets).filter(t=>!t.parentId).map(t=>this.getDataset(t.id))},getPatternAndSymbolConfigs(){return this.topLevelDatasets().reduce((t,e)=>({...t,patternConfigs:[...t.patternConfigs,...e.patternConfigs],symbolConfigs:[...t.symbolConfigs,...e.symbolConfigs]}),{patternConfigs:[],symbolConfigs:[]})},invalidateKeyItemsOnMenuStateChange(t){t!==this._lastMenuState&&(this._lastMenuState=t,this._lastKeyItemsDatasets=null)},keyItems(){if(this.datasets===this._lastKeyItemsDatasets)return this._lastKeyItems;this._lastKeyItemsDatasets=this.datasets;const t=[],e=new Map;this.forEach(a=>{if(!a.keyVisibility)return;if(!(a.hasSublayers||a.groupId||a.groupLabel))return void t.push({type:"flat",id:a.id,keyDefinition:a.keyDefinition});const s=a.groupId,i=((a,s)=>{if(e.has(s))return e.get(s);const i={type:"group",id:s,groupLabel:a,keyDefinitions:[]};return e.set(s,i),t.push(i),i})(a.groupLabel||s||a.label,s);a.hasSublayers||i.keyDefinitions.push(a.keyDefinition)});const a=t.filter(t=>"flat"===t.type||Boolean(t.keyDefinitions?.length)),s=a.some(t=>"group"===t.type);return this._lastKeyItems={items:a,hasGroups:s},this._lastKeyItems}},U={id:"datasetsLayers",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:({pluginState:t})=>{const{menu:e=[]}=t,i=e=>{const{value:a,checked:s}=e.target;L({pluginState:t},s,{datasetId:a})},r=e.some(t=>t.groupLabel);return a("div",{className:"im-c-datasets-layers"+(r?" im-c-datasets-layers--has-groups":""),children:e.map(e=>s(k,{menuGroup:e,children:[" ",e.items.map(e=>a(P,{menuGroupItem:e,datasetRegistry:t.datasetRegistry,onChange:i},e.id))]},e.id))})}},Y={id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",excludeWhen:t=>!M(t),iconId:"layers",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}};var q=Object.freeze({__proto__:null,createManifest:({hasMenu:t}={})=>({InitComponent:w,reducer:{initialState:{...g,datasetRegistry:Object.assign(Object.create(J),{_definitionCache:new K,_globals:{},_menuStateRef:{},_lastMenuState:{},_lastKeyItems:{}})},actions:D},panels:!1===t?[]:[U],buttons:!1===t?[]:[Y],icons:[{id:"layers",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addDataset:O,removeDataset:F,setDatasetVisibility:L,setFeatureVisibility:x,setStyle:G,getStyle:B,setOpacity:R,getOpacity:N,setData:$,setGlobals:V}})});export{Z as D,m as l,q as m};
1
+ import{useRef as t,useEffect as e}from"preact/compat";import{jsx as a,jsxs as s,Fragment as i}from"preact/jsx-runtime";const r=t=>{const{datasets:e=[]}=t,a=[],s=e.filter(t=>t.showInMenu||t.sublayers?.some(t=>t.showInMenu)),i=new Map;return s.forEach(t=>{if(t.sublayers?.length){const e=t.sublayers.filter(e=>t.showInMenu?!1!==e.showInMenu:e.showInMenu);if(!1===t.showInMenu&&!e.length)return;const s={id:t.id,groupLabel:t.label,visibleWhen:!0,type:"checkbox",items:e.map(e=>({id:`${t.id}-${e.id}`,label:e.label}))};0===s.items.length&&(delete s.groupLabel,s.items.push({id:t.id,label:t.label})),a.push(s)}else if(t.groupLabel){const e=i.has(t.groupLabel)?i.get(t.groupLabel):{id:t.groupLabel,groupLabel:t.groupLabel,visibleWhen:!0,type:"checkbox",items:[]};i.has(t.groupLabel)||(i.set(t.groupLabel,e),a.push(e)),e.items.push({id:t.id,label:t.label})}else a.push({visibleWhen:!0,type:"checkbox",id:t.id,items:[{id:t.id,label:t.label}]})}),a},n=(t,e)=>t.reduce((t,a)=>{const s=a.items.filter(t=>!e.includes(t.id));return s.length&&t.push({...a,items:s}),t},[]),o={minZoom:6,maxZoom:24,showInKey:!1,showInMenu:!1,visible:!0,style:{stroke:"#d4351c",strokeWidth:2,symbolDescription:"red outline"}},l=["stroke","strokeWidth","strokeDashArray","fill","fillPattern","fillPatternSvgContent","fillPatternForegroundColor","fillPatternBackgroundColor","opacity","symbolDescription","symbol","symbolSvgContent","symbolViewBox","symbolAnchor","symbolSize","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"],d=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"],u=t=>d.some(e=>e in t),p=(t={})=>u(t)?{strokeWidth:o.style.strokeWidth,...t}:{...o.style,...t},h=(t,e)=>{const{id:a}=e,s=(t=>{!0!==t.visible&&!1!==t.visible&&(t.visible="hidden"!==t.visibility);const e={...o,...t,style:{...t.style}};return l.forEach(t=>delete e[t]),e})(e);e.parentId&&("showInKey"in e||delete s.showInKey,"showInMenu"in e||delete s.showInMenu),t[a]=s;const{orderedDatasets:i}=t;i.push(a);const r=e.sublayers?.map(t=>((t,e)=>{const a=`${t}-${e.id}`,s=e.id;return"hidden"!==e.visibility&&(e.visibility="visible"),{...e,id:a,parentId:t,sublayerId:s}})(a,t));if(r?.length){const e=r?.map(t=>t.id),s=r?.reduce(h,{orderedDatasets:i});return t[a].sublayerIds=e,delete t[a].sublayers,{...t,...s,orderedDatasets:i}}return{...t,orderedDatasets:i}},c=t=>{const e=(t.datasets||[]).reduce(h,{orderedDatasets:[]}),{orderedDatasets:a}=e;return delete e.orderedDatasets,{...t,mappedDatasets:e,orderedDatasets:a}},y="[interactive-map]",m={warn:(...t)=>console.warn(y,...t),error:(...t)=>console.error(y,...t)},g={globals:{visible:!0,opacity:1,opacityMode:"dataset"},key:{items:[],hasGroups:!1},mappedDatasets:{},orderedDatasets:[],actionsArray:[],menu:[],menuInitialised:!1},b=(t,e,a,s="not found")=>!!t.mappedDatasets[e]||(m.error(`${a}: Dataset with id '${e}' ${s}`),!1),f=(t,e,a)=>({...a,actionsArray:[...a.actionsArray,{method:t,parameters:e}]}),D={SET_DATASETS:(t,e)=>{const{mappedDatasets:a,orderedDatasets:s}=e;return{...t,mappedDatasets:a,orderedDatasets:s}},ADD_DATASET:(t,e)=>{const{dataset:a,mapStyle:s}=e;if(t.mappedDatasets[a.id])return m.error(`addDataset: Dataset with id '${a.id}' already exists`),t;const{mappedDatasets:i,orderedDatasets:n}=c({datasets:[a]}),o=((t,e)=>{const a=[...t.menu],s=r({datasets:[e]}),i=a.find(t=>t.groupLabel===s[0].groupLabel);return i?i.items.push(...s[0].items):a.push(...s),a})(t,a);return f("addDataset",[a.id,s],{...t,mappedDatasets:{...t.mappedDatasets,...i},orderedDatasets:[...t.orderedDatasets,...n],menu:o})},REMOVE_DATASET:(t,e)=>{const{id:a}=e;if(!b(t,a,"removeDataset"))return t;const s={...t.mappedDatasets},i=[a,...s[a]?.sublayerIds||[]];i.forEach(t=>delete s[t]);const r=t.orderedDatasets.filter(t=>!i.includes(t));return{...t,mappedDatasets:s,orderedDatasets:r,menu:n(t.menu,i)}},SET_DATASET_VISIBILITY:(t,e)=>{const{datasetId:a,visible:s}=e;return b(t,a,"setDatasetVisibility")?t.mappedDatasets[a].visible===s?t:f("applyDatasetVisibility",[a,s],{...t,mappedDatasets:{...t.mappedDatasets,[a]:{...t.mappedDatasets[a],visible:s}}}):t},SET_GLOBAL_VISIBILITY:(t,e)=>{const{visible:a}=e;return f("applyGlobalVisibility",[a],{...t,globals:{...t.globals,visible:a}})},SET_DATASET_STYLE:(t,e)=>{const{datasetId:a,styleChanges:s,mapStyle:i}=e;if(!b(t,a,"setDatasetStyle"))return t;const r={...t.mappedDatasets[a].style,...s},n={...t.mappedDatasets[a],...s,style:r};return f("applyStyle",[a,i],{...t,mappedDatasets:{...t.mappedDatasets,[a]:n}})},SET_OPACITY:(t,e)=>{const{datasetId:a,opacity:s}=e;if(!b(t,a,"setOpacity"))return t;const i={...t.mappedDatasets[a].style,opacity:s},r={...t.mappedDatasets[a],style:i};return f("applyDatasetOpacity",[a],{...t,mappedDatasets:{...t.mappedDatasets,[a]:r}})},SET_GLOBAL_OPACITY:(t,e)=>{const{opacity:a}=e;return f("applyGlobalOpacity",[],{...t,globals:{...t.globals,opacity:a}})},HIDE_FEATURES:(t,e)=>{const{datasetId:a,featureIds:s}=e;if(!b(t,a,"setFeatureVisibility - hideFeatures"))return t;const i={...t.mappedDatasets[a]},r=i.hiddenFeatures||[],n=Array.from(new Set([...r,...s]));return i.hiddenFeatures=n,f("applyFeatureFilter",[a],{...t,mappedDatasets:{...t.mappedDatasets,[a]:i}})},SHOW_FEATURES:(t,e)=>{const{datasetId:a,featureIds:s}=e;if(!b(t,a,"setFeatureVisibility - showFeatures"))return t;const i={...t.mappedDatasets[a]},r=(i.hiddenFeatures||[]).filter(t=>!s.includes(t));return i.hiddenFeatures=r.length?r:[-1],f("applyFeatureFilter",[a],{...t,mappedDatasets:{...t.mappedDatasets,[a]:i}})},REMOVE_ADAPTER_ACTIONS:(t,e)=>e?.length?{...t,actionsArray:t.actionsArray.filter(t=>!e.includes(t))}:t,SET_GLOBAL_STATE:(t,e)=>f("applyGlobalOpacity",[],{...t,globals:{...t.globals,...e}}),SET_MENU:(t,e)=>{const{menu:a}=e;return{...t,menu:a,menuInitialised:!0}}},S={APP_HIDE_PANEL:"app:hidepanel",MAP_SIZE_CHANGE:"map:sizechange",MAP_DATA_CHANGE:"map:datachange"},_=(t,e)=>!(!t||!e)&&!(t[2]<e[0]||t[0]>e[2]||t[3]<e[1]||t[1]>e[3]),I=t=>{let e=1/0,a=1/0,s=-1/0,i=-1/0;const r=(t,n)=>{var o;0===n?(o=t,e=Math.min(e,o[0]),a=Math.min(a,o[1]),s=Math.max(s,o[0]),i=Math.max(i,o[1])):t.forEach(t=>r(t,n-1))};switch(t.type){case"Point":r(t.coordinates,0);break;case"LineString":case"MultiPoint":r(t.coordinates,1);break;case"Polygon":case"MultiLineString":r(t.coordinates,2);break;case"MultiPolygon":r(t.coordinates,3);break;case"GeometryCollection":t.geometries.forEach(t=>{const r=I(t);e=Math.min(e,r[0]),a=Math.min(a,r[1]),s=Math.max(s,r[2]),i=Math.max(i,r[3])});break;default:throw new Error(`Unsupported geometry type: ${t.type}`)}return[e,a,s,i]},v=t=>({type:"FeatureCollection",features:Array.from(t.values()).map(t=>t.feature)}),A=async(t,{mapProvider:e,dynamicGeoJSON:a,onUpdate:s})=>{const{url:i,idProperty:r,transformRequest:n,maxFeatures:o,minZoom:l=0}=a,d=e.getZoom();if(d<l)return;const u=(t=>t.getBounds())(e);if(!(t.fetchedBbox&&(p=t.fetchedBbox,h=u,p&&h&&h[0]>=p[0]&&h[1]>=p[1]&&h[2]<=p[2]&&h[3]<=p[3]))){var p,h,c,y;t.currentController&&t.currentController.abort(),t.currentController=new AbortController;try{const e={bbox:u,zoom:d},l=await(async(t,e,a,s)=>{const i=a(t,e),r="string"==typeof i?{url:i}:i,{url:n,headers:o={}}=r,l=await fetch(n,{headers:o,signal:s});if(!l.ok)throw new Error(`Failed to fetch GeoJSON: ${l.status} ${l.statusText}`);const d=await l.json();if("FeatureCollection"===d.type)return d;if("Feature"===d.type)return{type:"FeatureCollection",features:[d]};if(Array.isArray(d))return{type:"FeatureCollection",features:d};throw new Error("Invalid GeoJSON response")})(i,e,n,t.currentController.signal);((t,e,a)=>{const s=Date.now();e.features.forEach(e=>{const i=((t,e)=>e?t.properties?.[e]??t.id:t.id)(e,a);null!=i?t.set(i,{feature:e,bbox:I(e.geometry),lastSeenAt:s}):console.warn("Feature missing ID, skipping:",e)})})(t.features,l,r),t.fetchedBbox=(c=t.fetchedBbox,y=u,c?[Math.min(c[0],y[0]),Math.min(c[1],y[1]),Math.max(c[2],y[2]),Math.max(c[3],y[3])]:[...y]);const p=t.features.size;((t,e,a)=>{if(!a||t.size<=1.2*a)return;const s=a,i=[],r=[];for(const[a,s]of t)_(s.bbox,e)?i.push(a):r.push({id:a,lastSeenAt:s.lastSeenAt});r.sort((t,e)=>t.lastSeenAt-e.lastSeenAt);const n=t.size-s;for(let e=0;e<n&&e<r.length;e++)t.delete(r[e].id);if(t.size>s){const e=t.size-s,a=i.map(e=>({id:e,lastSeenAt:t.get(e).lastSeenAt})).sort((t,e)=>t.lastSeenAt-e.lastSeenAt);for(let s=0;s<e&&s<a.length;s++)t.delete(a[s].id)}})(t.features,u,o),t.features.size<p&&(t.fetchedBbox=u),s(a.id,v(t.features))}catch(t){if("AbortError"===t.name)return;console.error(`Failed to fetch dynamic GeoJSON for ${a.id}:`,t)}}},M=({dynamicGeoJSON:t,mapProvider:e,onUpdate:a})=>{const s={features:new Map,fetchedBbox:null,currentController:null},i=()=>A(s,{mapProvider:e,dynamicGeoJSON:t,onUpdate:a}),r=((t,e)=>{let a;const s=(...s)=>{clearTimeout(a),a=setTimeout(()=>t(...s),e)};return s.cancel=()=>{clearTimeout(a),a=null},s})(i,200),n=()=>{r()};return e.map.on("moveend",n),i(),{destroy(){var t,a;t=e.map,a=n,(t.off||t.un).call(t,"moveend",a),r.cancel(),s.currentController&&s.currentController.abort()},clear(){s.features.clear(),s.fetchedBbox=null,a(t.id,{type:"FeatureCollection",features:[]})},refresh(){s.features.clear(),s.fetchedBbox=null,i()},getFeatureCount:()=>s.features.size,reapply(){s.features.size>0&&a(t.id,v(s.features))}}},E=async(t,e,a,s)=>{const i=await(async t=>{switch(t.name){case"MapLibreProvider":{const{default:t}=await import(/* webpackChunkName: "im-datasets-ml-adapter" */ "./im-datasets-ml-adapter.js");return t}case"EsriProvider":{const{default:t}=await import(/* webpackChunkName: "im-datasets-esri-adapter" */ "./im-datasets-esri-adapter.js");return t}case"OpenLayersProvider":{const{default:t}=await import(/* webpackChunkName: "im-datasets-ol-adapter" */ "./im-datasets-ol-adapter.js");return t}default:throw new Error(`No layer adapter available for map provider ${t.name}. Please provide a compatible layer adapter.`)}})(t);return new i(t,e,a,s)},C=({pluginConfig:t,pluginState:e})=>!1!==t.hasMenu&&(e.menuInitialised?e.menu.length>0:(t.datasets||[]).some(t=>t.showInMenu||t.sublayers?.some(t=>t.showInMenu))),T="datasetsLayers";function w({appState:a,pluginConfig:s,pluginState:i,mapState:n,mapProvider:o,services:l}){const{dispatch:d,datasetRegistry:u}=i,{eventBus:p,symbolRegistry:h,patternRegistry:y}=l,m=Boolean(o?.isBaseMapReady());!function({appState:t,pluginConfig:a,pluginState:s,services:i}){const{eventBus:r}=i,n=C({pluginConfig:a,pluginState:s}),o=Boolean(t.openPanels[T]);e(()=>{!n&&o&&r.emit(S.APP_HIDE_PANEL,T)},[n,o])}({appState:a,pluginConfig:s,pluginState:i,services:l});const g=t(i);g.current=i;const b=t(null),f=t=>{const e=o?.datasets;t.length&&e&&(t.forEach(({method:t,parameters:a})=>e[t](...a)),d({type:"REMOVE_ADAPTER_ACTIONS",payload:t}))};return e(()=>{if(!m)return;if(b.current)return;(async()=>{const t=await E(o,h,y,u);b.current=(({adapter:t,datasetRegistry:e,pluginConfig:a,mapStyle:s,mapProvider:i,events:n,dispatch:o,eventBus:l})=>{const{datasets:d}=a,u=new Map;a.globals&&o({type:"SET_GLOBAL_STATE",payload:a.globals});const{mappedDatasets:p,orderedDatasets:h}=c({datasets:d});t.createDataset&&e.attachCreateDataset(t.createDataset),e.attach(p,h,s);const y=r({datasets:d});l.requestOnce("menu:state",t=>e.attachMenuStateRef(t)),o({type:"SET_MENU",payload:{menu:y}}),o({type:"SET_DATASETS",payload:{mappedDatasets:p,orderedDatasets:h}}),t.init().then(()=>{e.forEachDataset(e=>{if(!e.hasDynamicGeoJSON)return;const{dynamicGeoJSON:a}=e,s=M({dynamicGeoJSON:a,mapProvider:i,onUpdate:(e,a)=>t.setData(e,a)});u.set(e.id,s)}),t.attachDynamicSources(u),l.emit("datasets:ready")});const m=()=>{t.onMapSizeChange()};l.on(n.MAP_SIZE_CHANGE,m);const g=l.emitWhenRequested("datasets:registry",e);return l.on("menu:changed",a=>{e.invalidateKeyItemsOnMenuStateChange(a),t.applyGlobalVisibility()}),{remove(){l.off(n.MAP_SIZE_CHANGE,m),g(),u.forEach(t=>t.destroy()),u.clear(),t.destroy()},refreshDataset(t){u.get(t)?.refresh()},clearDatasetCache(t){u.get(t)?.clear()},getFeatureCount:t=>u.get(t)?.getFeatureCount()??null}})({adapter:t,datasetRegistry:u,pluginConfig:s,mapStyle:n.mapStyle,mapProvider:o,events:S,dispatch:d,eventBus:p}),o.datasets=t,f(g.current.actionsArray)})()},[m]),e(()=>{u.attach(i.mappedDatasets,i.orderedDatasets),p.emit("datasets:changed")},[i.mappedDatasets,i.orderedDatasets]),e(()=>{u.attachMapStyle(n.mapStyle);const t=o?.datasets;t?.onMapStyleChange&&Promise.resolve(t.onMapStyleChange()).then(()=>{p.emit(S.MAP_DATA_CHANGE)})},[n.mapStyle]),e(()=>u.attachGlobals(i.globals),[i.globals]),e(()=>f(i.actionsArray),[i.actionsArray]),e(()=>()=>{b.current&&(b.current.remove(),b.current=null,o.datasets=null)},[]),null}const L=({pluginState:{dispatch:t}},e,a={})=>{const{datasetId:s,sublayerId:i}=a,r=i?`${s}-${i}`:s;t(r?{type:"SET_DATASET_VISIBILITY",payload:{datasetId:r,visible:e}}:{type:"SET_GLOBAL_VISIBILITY",payload:{visible:e}})},P=({menuGroupItem:t,datasetRegistry:e,onChange:i})=>{const r=e.getDataset(t.id);if(!r)return null;const n=r.isSublayer?r.parentId:r.id,o=r.isSublayer?r.id:void 0,l="im-c-datasets-layers__item govuk-checkboxes govuk-checkboxes--small"+(r.visible?"":" im-c-datasets-layers__item--checked");return a("div",{className:l,"data-module":"govuk-checkboxes",children:s("div",{className:"govuk-checkboxes__item",children:[a("input",{className:"govuk-checkboxes__input",id:r.id,"data-dataset-id":n,"data-sublayer-id":o,name:"layers",type:"checkbox",value:r.id,checked:r.isLocallyVisible,onChange:i}),a("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:r.id,children:r.label})]})},r.id)},k=({menuGroup:t,children:e})=>{if(!t.groupLabel)return a(i,{children:e});return a("div",{className:"govuk-form-group im-c-datasets-layers-group",children:s("fieldset",{className:"im-c-datasets-layers-group__fieldset",children:[a("legend",{className:"im-c-datasets-layers-group__legend",children:a("h3",{children:t.groupLabel})}),e]})},t.id)},O=({pluginState:{dispatch:t},mapState:e},a)=>{t({type:"ADD_DATASET",payload:{dataset:a,mapStyle:e.mapStyle}})},x=({pluginState:{dispatch:t},mapProvider:e},a)=>{e.datasets?.removeDataset(a),t({type:"REMOVE_DATASET",payload:{id:a}})},F=({pluginState:{dispatch:t,datasetRegistry:e}},a,s,{datasetId:i=null}={})=>{if(i){const t=e.getDataset(i);!t||t.idProperty||t.generateIds||m.warn(`setFeatureVisibility: Dataset "${i}" has no idProperty or generateIds configured. Features may not be matched correctly. Add idProperty to match by a feature property, or add generateIds: true to use auto-generated IDs.`)}t({type:a?"SHOW_FEATURES":"HIDE_FEATURES",payload:{datasetId:i,featureIds:s}})},G=({pluginState:{dispatch:t},mapState:e},a,{datasetId:s,sublayerId:i}={})=>{t({type:"SET_DATASET_STYLE",payload:{datasetId:s=i?`${s}-${i}`:s,styleChanges:a,mapStyle:e.mapStyle}})},R=({pluginState:{datasetRegistry:t}},{datasetId:e,sublayerId:a}={})=>{e=a?`${e}-${a}`:e;const s=t.getDataset(e);return s?s.style:(m.warn(`getStyle: Dataset with id ${e} not found`),null)},B=({pluginState:{dispatch:t}},e,a={})=>{const{datasetId:s,sublayerId:i}=a,r=i?`${s}-${i}`:s;t(r?{type:"SET_OPACITY",payload:{datasetId:r,opacity:e}}:{type:"SET_GLOBAL_OPACITY",payload:{opacity:e}})},N=({pluginState:{globals:t,datasetRegistry:e}},a={})=>{const{datasetId:s,sublayerId:i}=a,r=i?`${s}-${i}`:s;if(r){const t=e.getDataset(r);return t?t.opacity??null:(m.warn(`getOpacity: Dataset with id ${r} not found`),null)}return t.opacity??null},$=({pluginState:{datasetRegistry:t},mapProvider:e},a,{datasetId:s})=>{const i=t.getDataset(s);i?i?.tiles?m.warn(`setData called on vector tile dataset "${s}" — has no effect`):e.datasets?.setData(s,a):m.warn(`setData: Dataset with id ${s} not found`)},V=({pluginState:{dispatch:t}},e)=>{const{opacityMode:a}=e,s={};let i=!1;a&&(["dataset","global","multiply"].includes(a)?(i=!0,s.opacityMode=a):m.warn(`Ignoring invalid opacityMode: ${a}. Must be one of 'dataset', 'global' or 'multiply'.`)),i?t({type:"SET_GLOBAL_STATE",payload:s}):m.warn("setGlobals: requires a valid value for opacityMode to be set")};class W{constructor(t){this.id=t.id,this.url=t.url,this.transformRequest=t.transformRequest,this.maxFeatures=t.maxFeatures,this.minZoom=t.minZoom,this.idProperty=t.idProperty,this.hiddenFeaturesIdExpression=["to-string",["get",this.idProperty]],this.sourceId=`geojson-dynamic-${this.id}`,this.source={type:"geojson",data:{type:"FeatureCollection",features:[]},...this.idProperty?{promoteId:this.idProperty}:{generateId:!0}}}}const j=(t,e,a)=>{switch(t.opacityMode){case"global":return t.opacity;case"multiply":return((t,e=1,a=1)=>Math.round(100*(e*a*t.opacity+Number.EPSILON))/100)(t,e,a);default:return((t,e,a)=>void 0===e?void 0===a?t.opacity:a:e)(t,e,a)}};class Z{constructor(t,e){this._datasetDefinition=t,this._datasetRegistry=e}get id(){return this._datasetDefinition.id}get label(){return this._datasetDefinition.label}get hasSymbol(){return!(this.hasSublayers||(t=this.style,!t?.symbol&&!t?.symbolSvgContent));var t}get hasPattern(){return!(this.hasSublayers||this.hasSymbol||(t=this.style,!t.fillPattern&&!t.fillPatternSvgContent));var t}get hasFill(){return!this.hasSublayers&&!this.hasSymbol&&(this.hasPattern||this.style?.fill&&"transparent"!==this.style?.fill)}get hasStroke(){return!this.hasSublayers&&!this.hasSymbol&&Boolean(this.style?.stroke)}get tiles(){return this._datasetDefinition.tiles}get geojson(){return this._datasetDefinition.geojson}get idProperty(){return this._datasetDefinition.idProperty}get generateIds(){return this._datasetDefinition.generateIds}get parentId(){return this._datasetDefinition.parentId}get minZoom(){return this._datasetDefinition.minZoom||this.parent?.minZoom}get maxZoom(){return this._datasetDefinition.maxZoom||this.parent?.maxZoom}get type(){return this._datasetDefinition.type||this.parent?.type}get showInKey(){const t=this._datasetDefinition.showInKey;return void 0!==t?t:this.parent?.showInKey??!1}get visibleWhen(){return void 0===this._datasetDefinition.visibleWhen?this.parent?.visibleWhen:this._datasetDefinition.visibleWhen}get groupLabel(){return this._datasetDefinition.groupLabel||this.parent?.groupLabel||this.parent?.label}get groupId(){const t=this._datasetDefinition.groupId||this.parent?.groupId;return t||(this.groupLabel?this.groupLabel.toLowerCase().replace(/\s+/g,"-"):null)}get opacity(){const t=this.style?.opacity,e=this.parent?.style?.opacity;return j(this._datasetRegistry.globals,t,e)}get hasDynamicGeoJSON(){return Boolean(this._datasetDefinition.dynamicGeoJSON)}get dynamicGeoJSON(){return new W({...this._datasetDefinition.dynamicGeoJSON,id:this.id,minZoom:this.minZoom})}get hiddenFeatures(){return this._datasetDefinition.hiddenFeatures}get hasHiddenFeatures(){return Boolean(this.hiddenFeatures?.length>0||this.parent?.hasHiddenFeatures)}get filter(){return null}get isHiddenByInheritance(){return this.isSublayer?!this.parent?.visible:!this._datasetRegistry.globals.visible}get isLocallyVisible(){return!!this.isVisible||this._datasetDefinition.visible}get visible(){return this.isSublayer?this._datasetDefinition.visible&&this.parent?.visible:this._datasetDefinition.visible&&this._datasetRegistry.globals.visible}get esriStyleLayerId(){return this._datasetDefinition.esriStyleLayerId}get visibility(){const{visible:t,visibleWhen:e}=this;return t&&e?this._datasetRegistry.isVisibleWhen(e)?"visible":"none":t?"visible":"none"}get keyVisibility(){return this.showInKey&&"visible"===this.visibility}get symbolAnchor(){return this.style?.symbolAnchor?this.style.symbolAnchor:this.parent?.symbolAnchor}get sourceLayer(){return this.isSublayer?this.parent.sourceLayer:this.tiles?this._datasetDefinition.sourceLayer:void 0}get isSublayer(){return Boolean(this._datasetDefinition.parentId)}get hasSublayers(){return this._datasetDefinition.sublayerIds?.length>0}get sublayerIds(){return this._datasetDefinition.sublayerIds}get sublayers(){const{sublayerIds:t}=this;return t?t.map(t=>this._datasetRegistry.getDataset(t)):[]}get parent(){if(this._datasetDefinition.parentId)return this._datasetRegistry.getDataset(this._datasetDefinition.parentId)}get inheritedStyle(){const t=this._datasetDefinition.style||{},e=this.parent;return e?{...e.inheritedStyle,opacity:void 0,...t}:t}get style(){return{...p(this.inheritedStyle),symbolDescription:this.symbolDescription}}get hasCustomVisualStyle(){return u(this._datasetDefinition.style||{})}get symbolDescription(){return this._datasetDefinition.style?.symbolDescription?this._datasetDefinition.style.symbolDescription:this.hasCustomVisualStyle?void 0:this.parent?this.parent.symbolDescription:o.style.symbolDescription}get patternConfigs(){const t=this.hasPattern?[this.style]:[];return this.hasSublayers?[...t,...this.sublayers.flatMap(t=>t.patternConfigs)]:t}get symbolConfigs(){const t=this.hasSymbol?[this.style]:[];return this.hasSublayers?[...t,...this.sublayers.flatMap(t=>t.symbolConfigs)]:t}get keyDefinition(){return{id:this.id,type:"dataset",label:this.label,hasSymbol:this.hasSymbol,hasPattern:this.hasPattern,style:this.style,symbolDescription:this.symbolDescription}}}class K{constructor(){this.idToDefinitionMap=new Map,this.definitionToInstanceMap=new Map}add(t){this.idToDefinitionMap.set(t.id,t._datasetDefinition),this.definitionToInstanceMap.set(t._datasetDefinition,t)}invalidateDataset(t){const e=this.idToDefinitionMap.get(t.id);[e.id,...e?.sublayerIds||[]].forEach(t=>{const e=this.idToDefinitionMap.get(t);this.definitionToInstanceMap.delete(e),this.idToDefinitionMap.delete(t)})}invalidateChangedDatasets(t){t.forEach(t=>{const e=this.idToDefinitionMap.get(t.id);if(e&&e!==t){const t=this.definitionToInstanceMap.get(e);this.invalidateDataset(t.isSublayer&&t.parent?t.parent:t)}})}getByDefinition(t){return this.definitionToInstanceMap.get(t)}}const H=(t,e={})=>{for(const[a,s]of Object.entries(t)){const t=e[a];if(!s.includes(t))return!1}return!0},z=(t,e)=>(Array.isArray(t)?t:[t]).includes(e),J={attach(t,e,a){this._datasets=t,this._orderedDatasets=e,this.attachMapStyle(a),this._invalidateChangedDatasets()},_invalidateCache(){this._definitionCache=new K},_invalidateChangedDatasets(){this._datasets?this._definitionCache.invalidateChangedDatasets(Object.values(this._datasets)):this._invalidateCache()},attachCreateDataset(t){this._createDataset=t},_createDataset:(t,e)=>((t,e)=>new Z(t,e))(t,e),attachMapStyle(t){t&&(this._mapStyle=t)},get mapStyle(){return this._mapStyle},attachGlobals(t){t&&(this._globals=t)},get globals(){return this._globals},attachMenuStateRef(t){this._menuStateRef=t},isVisibleWhen(t){return((t,{mapStyleId:e,menuState:a}={})=>{if(null==t)return!0;if("boolean"==typeof t)return t;if("object"==typeof t){for(const[s,i]of Object.entries(t)){if("mapStyleId"===s&&!z(i,e))return!1;if("menu"===s&&!H(i,a))return!1}return!0}return!0})(t,{mapStyleId:this._mapStyle?.id,menuState:this._menuStateRef?.current?.menuState})},get datasets(){return this._datasets},getDataset(t){const e=this.datasets[t];if(!e)return;const a=this._definitionCache.getByDefinition(e);if(a)return a;const s=this._createDataset(e,this);return this._definitionCache.add(s),s.isSublayer&&this.getDataset(s.parentId),s},forEach(t){this._orderedDatasets.forEach(e=>t(this.getDataset(e)))},forEachDataset(t){Object.values(this.datasets).filter(t=>!t.parentId).forEach(e=>t(this.getDataset(e.id)))},topLevelDatasets(){return Object.values(this.datasets).filter(t=>!t.parentId).map(t=>this.getDataset(t.id))},getPatternAndSymbolConfigs(){return this.topLevelDatasets().reduce((t,e)=>({...t,patternConfigs:[...t.patternConfigs,...e.patternConfigs],symbolConfigs:[...t.symbolConfigs,...e.symbolConfigs]}),{patternConfigs:[],symbolConfigs:[]})},invalidateKeyItemsOnMenuStateChange(t){t!==this._lastMenuState&&(this._lastMenuState=t,this._lastKeyItemsDatasets=null)},keyItems(){if(this.datasets===this._lastKeyItemsDatasets)return this._lastKeyItems;this._lastKeyItemsDatasets=this.datasets;const t=[],e=new Map;this.forEach(a=>{if(!a.keyVisibility)return;if(!(a.hasSublayers||a.groupId||a.groupLabel))return void t.push({type:"flat",id:a.id,keyDefinition:a.keyDefinition});const s=a.groupId,i=((a,s)=>{if(e.has(s))return e.get(s);const i={type:"group",id:s,groupLabel:a,keyDefinitions:[]};return e.set(s,i),t.push(i),i})(a.groupLabel||s||a.label,s);a.hasSublayers||i.keyDefinitions.push(a.keyDefinition)});const a=t.filter(t=>"flat"===t.type||Boolean(t.keyDefinitions?.length)),s=a.some(t=>"group"===t.type);return this._lastKeyItems={items:a,hasGroups:s},this._lastKeyItems}},U={id:"datasetsLayers",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:({pluginState:t})=>{const{menu:e=[]}=t,i=e=>{const{value:a,checked:s}=e.target;L({pluginState:t},s,{datasetId:a})},r=e.some(t=>t.groupLabel);return a("div",{className:"im-c-datasets-layers"+(r?" im-c-datasets-layers--has-groups":""),children:e.map(e=>s(k,{menuGroup:e,children:[" ",e.items.map(e=>a(P,{menuGroupItem:e,datasetRegistry:t.datasetRegistry,onChange:i},e.id))]},e.id))})}},Y={id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",excludeWhen:t=>!C(t),iconId:"layers",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}};var q=Object.freeze({__proto__:null,createManifest:({hasMenu:t}={})=>({InitComponent:w,reducer:{initialState:{...g,datasetRegistry:Object.assign(Object.create(J),{_definitionCache:new K,_globals:{},_menuStateRef:{},_lastMenuState:{},_lastKeyItems:{}})},actions:D},panels:!1===t?[]:[U],buttons:!1===t?[]:[Y],icons:[{id:"layers",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addDataset:O,removeDataset:x,setDatasetVisibility:L,setFeatureVisibility:F,setStyle:G,getStyle:R,setOpacity:B,getOpacity:N,setData:$,setGlobals:V}})});export{Z as D,m as l,q as m};
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see im-datasets-plugin.js.LICENSE.txt */
2
- "use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[447],{852:function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){i(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function i(t,e,r){return(e=function(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}r.d(e,{jE:function(){return d},Eg:function(){return y},V:function(){return l},p_:function(){return p}});var s,l={minZoom:6,maxZoom:24,showInKey:!1,showInMenu:!1,visible:!0,style:{stroke:"#d4351c",strokeWidth:2,symbolDescription:"red outline"}},c=["stroke","strokeWidth","strokeDashArray","fill","fillPattern","fillPatternSvgContent","fillPatternForegroundColor","fillPatternBackgroundColor","opacity","symbolDescription"].concat(function(t){if(Array.isArray(t))return u(t)}(s=["symbol","symbolSvgContent","symbolViewBox","symbolAnchor","symbolSize","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"])||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(s)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(s)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"],p=function(t){return f.some(function(e){return e in t})},y=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return p(t)?a({strokeWidth:l.style.strokeWidth},t):a(a({},l.style),t)},d=function(t){!0!==t.visible&&!1!==t.visible&&(t.visible="hidden"!==t.visibility);var e=a(a(a({},l),t),{},{style:a({},t.style)});return c.forEach(function(t){return delete e[t]}),e}},313:function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){i(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function i(t,e,r){return(e=function(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){return function(t){if(Array.isArray(t))return s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}r.r(e),r.d(e,{createManifest:function(){return zt}});var l=function(t){var e=t.datasets,r=[],n=(void 0===e?[]:e).filter(function(t){var e;return t.showInMenu||(null===(e=t.sublayers)||void 0===e?void 0:e.some(function(t){return t.showInMenu}))}),o=new Map;return n.forEach(function(t){var e;if(null!==(e=t.sublayers)&&void 0!==e&&e.length){var n=t.sublayers.filter(function(e){return t.showInMenu?!1!==e.showInMenu:e.showInMenu});if(!1===t.showInMenu&&!n.length)return;var a={id:t.id,groupLabel:t.label,visibleWhen:!0,type:"checkbox",items:n.map(function(e){return{id:"".concat(t.id,"-").concat(e.id),label:e.label}})};0===a.items.length&&(delete a.groupLabel,a.items.push({id:t.id,label:t.label})),r.push(a)}else if(t.groupLabel){var i=o.has(t.groupLabel)?o.get(t.groupLabel):{id:t.groupLabel,groupLabel:t.groupLabel,visibleWhen:!0,type:"checkbox",items:[]};o.has(t.groupLabel)||(o.set(t.groupLabel,i),r.push(i)),i.items.push({id:t.id,label:t.label})}else r.push({visibleWhen:!0,type:"checkbox",id:t.id,items:[{id:t.id,label:t.label}]})}),r},c=function(t,e){return t.reduce(function(t,r){var n=r.items.filter(function(t){return!e.includes(t.id)});return n.length&&t.push(a(a({},r),{},{items:n})),t},[])},f=r(852);function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function y(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function d(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?y(Object(r),!0).forEach(function(e){b(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function b(t,e,r){return(e=function(t){var e=function(t){if("object"!=p(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==p(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var v=function(t,e){var r,n=e.id,o=(0,f.jE)(e);e.parentId&&("showInKey"in e||delete o.showInKey,"showInMenu"in e||delete o.showInMenu),t[n]=o;var a=t.orderedDatasets;a.push(n);var i=null===(r=e.sublayers)||void 0===r?void 0:r.map(function(t){return function(t,e){var r="".concat(t,"-").concat(e.id),n=e.id;return"hidden"!==e.visibility&&(e.visibility="visible"),d(d({},e),{},{id:r,parentId:t,sublayerId:n})}(n,t)});if(null!=i&&i.length){var u=null==i?void 0:i.map(function(t){return t.id}),s=null==i?void 0:i.reduce(v,{orderedDatasets:a});return t[n].sublayerIds=u,delete t[n].sublayers,d(d(d({},t),s),{},{orderedDatasets:a})}return d(d({},t),{},{orderedDatasets:a})},h=function(t){var e=(t.datasets||[]).reduce(v,{orderedDatasets:[]}),r=e.orderedDatasets;return delete e.orderedDatasets,d(d({},t),{},{mappedDatasets:e,orderedDatasets:r})},m=r(619);function g(t){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g(t)}function S(t){return function(t){if(Array.isArray(t))return O(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return O(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?O(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function D(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function P(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?D(Object(r),!0).forEach(function(e){_(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _(t,e,r){return(e=function(t){var e=function(t){if("object"!=g(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=g(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==g(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var A={globals:{visible:!0,opacity:1,opacityMode:"dataset"},key:{items:[],hasGroups:!1},mappedDatasets:{},orderedDatasets:[],actionsArray:[],menu:[],menuInitialised:!1},w=function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"not found";return!!t.mappedDatasets[e]||(m.v.error("".concat(r,": Dataset with id '").concat(e,"' ").concat(n)),!1)},E=function(t,e,r){return P(P({},r),{},{actionsArray:[].concat(S(r.actionsArray),[{method:t,parameters:e}])})},j={SET_DATASETS:function(t,e){var r=e.mappedDatasets,n=e.orderedDatasets;return P(P({},t),{},{mappedDatasets:r,orderedDatasets:n})},ADD_DATASET:function(t,e){var r=e.dataset,n=e.mapStyle;if(t.mappedDatasets[r.id])return m.v.error("addDataset: Dataset with id '".concat(r.id,"' already exists")),t;var o=h({datasets:[r]}),a=o.mappedDatasets,i=o.orderedDatasets,s=function(t,e){var r,n=u(t.menu),o=l({datasets:[e]}),a=n.find(function(t){return t.groupLabel===o[0].groupLabel});return a?(r=a.items).push.apply(r,u(o[0].items)):n.push.apply(n,u(o)),n}(t,r);return E("addDataset",[r.id,n],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),a),orderedDatasets:[].concat(S(t.orderedDatasets),S(i)),menu:s}))},REMOVE_DATASET:function(t,e){var r,n=e.id;if(!w(t,n,"removeDataset"))return t;var o=P({},t.mappedDatasets),a=[n].concat(S((null===(r=o[n])||void 0===r?void 0:r.sublayerIds)||[]));a.forEach(function(t){return delete o[t]});var i=t.orderedDatasets.filter(function(t){return!a.includes(t)});return P(P({},t),{},{mappedDatasets:o,orderedDatasets:i,menu:c(t.menu,a)})},SET_DATASET_VISIBILITY:function(t,e){var r=e.datasetId,n=e.visible;return w(t,r,"setDatasetVisibility")?t.mappedDatasets[r].visible===n?t:E("applyDatasetVisibility",[r,n],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,P(P({},t.mappedDatasets[r]),{},{visible:n})))})):t},SET_GLOBAL_VISIBILITY:function(t,e){var r=e.visible;return E("applyGlobalVisibility",[r],P(P({},t),{},{globals:P(P({},t.globals),{},{visible:r})}))},SET_DATASET_STYLE:function(t,e){var r=e.datasetId,n=e.styleChanges,o=e.mapStyle;if(!w(t,r,"setDatasetStyle"))return t;var a=P(P({},t.mappedDatasets[r].style),n),i=P(P(P({},t.mappedDatasets[r]),n),{},{style:a});return E("applyStyle",[r,o],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,i))}))},SET_OPACITY:function(t,e){var r=e.datasetId,n=e.opacity;if(!w(t,r,"setOpacity"))return t;var o=P(P({},t.mappedDatasets[r].style),{},{opacity:n}),a=P(P({},t.mappedDatasets[r]),{},{style:o});return E("applyDatasetOpacity",[r],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,a))}))},SET_GLOBAL_OPACITY:function(t,e){var r=e.opacity;return E("applyGlobalOpacity",[],P(P({},t),{},{globals:P(P({},t.globals),{},{opacity:r})}))},HIDE_FEATURES:function(t,e){var r=e.datasetId,n=e.featureIds;if(!w(t,r,"setFeatureVisibility - hideFeatures"))return t;var o=P({},t.mappedDatasets[r]),a=o.hiddenFeatures||[],i=Array.from(new Set([].concat(S(a),S(n))));return o.hiddenFeatures=i,E("applyFeatureFilter",[r],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,o))}))},SHOW_FEATURES:function(t,e){var r=e.datasetId,n=e.featureIds;if(!w(t,r,"setFeatureVisibility - showFeatures"))return t;var o=P({},t.mappedDatasets[r]),a=(o.hiddenFeatures||[]).filter(function(t){return!n.includes(t)});return o.hiddenFeatures=a.length?a:[-1],E("applyFeatureFilter",[r],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,o))}))},REMOVE_ADAPTER_ACTIONS:function(t,e){return null!=e&&e.length?P(P({},t),{},{actionsArray:t.actionsArray.filter(function(t){return!e.includes(t)})}):t},SET_GLOBAL_STATE:function(t,e){return E("applyGlobalOpacity",[],P(P({},t),{},{globals:P(P({},t.globals),e)}))},SET_MENU:function(t,e){var r=e.menu;return P(P({},t),{},{menu:r,menuInitialised:!0})}},I=r(738),T={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SET_APPLICATION_MODE:"app:setapplicationmode",APP_CLEAR_APPLICATION_MODE:"app:clearapplicationmode",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_SPATIAL_LIST:"map:setspatiallist",MAP_SET_SPATIAL_LIST_SUPPRESSED:"map:setspatiallistsuppressed",MAP_SET_ACTIVE_ITEM:"map:setactiveitem",MAP_SELECT_ITEM:"map:selectitem",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"};function k(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,l=Object.create(s.prototype);return M(l,"_invoke",function(r,n,o){var a,u,s,l=0,c=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return a=e,u=0,s=t,p.n=r,i}};function y(r,n){for(u=r,s=n,e=0;!f&&l&&!o&&e<c.length;e++){var o,a=c[e],y=p.p,d=a[2];r>3?(o=d===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=t):a[0]<=y&&((o=r<2&&y<a[1])?(u=0,p.v=n,p.n=a[1]):y<d&&(o=r<3||a[0]>n||n>d)&&(a[4]=r,a[5]=n,p.n=d,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,c,d){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&y(c,d),u=c,s=d;(e=u<2?t:s)||!f;){a||(u?u<3?(u>1&&(p.n=-1),y(u,s)):p.n=s:p.v=s);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=t}else if((e=(f=p.n<0)?s:r.call(n,p))!==i)break}catch(e){a=t,u=1,s=e}finally{l=1}}return{value:e,done:f}}}(r,o,a),!0),l}var i={};function u(){}function s(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(M(e={},n,function(){return this}),e),f=l.prototype=u.prototype=Object.create(c);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,M(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return s.prototype=l,M(f,"constructor",l),M(l,"constructor",s),s.displayName="GeneratorFunction",M(l,o,"GeneratorFunction"),M(f),M(f,o,"Generator"),M(f,n,function(){return this}),M(f,"toString",function(){return"[object Generator]"}),(k=function(){return{w:a,m:p}})()}function M(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}M=function(t,e,r,n){function a(e,r){M(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},M(t,e,r,n)}function C(t,e,r,n,o,a,i){try{var u=t[a](i),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}var L=function(){var t,e=(t=k().m(function t(e,r,n,o){var a,i,u,s,l,c,f;return k().w(function(t){for(;;)switch(t.n){case 0:return a=n(e,r),u=(i="string"==typeof a?{url:a}:a).url,s=i.headers,l=void 0===s?{}:s,t.n=1,fetch(u,{headers:l,signal:o});case 1:if((c=t.v).ok){t.n=2;break}throw new Error("Failed to fetch GeoJSON: ".concat(c.status," ").concat(c.statusText));case 2:return t.n=3,c.json();case 3:if("FeatureCollection"!==(f=t.v).type){t.n=4;break}return t.a(2,f);case 4:if("Feature"!==f.type){t.n=5;break}return t.a(2,{type:"FeatureCollection",features:[f]});case 5:if(!Array.isArray(f)){t.n=6;break}return t.a(2,{type:"FeatureCollection",features:f});case 6:throw new Error("Invalid GeoJSON response");case 7:return t.a(2)}},t)}),function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(t){C(a,n,o,i,u,"next",t)}function u(t){C(a,n,o,i,u,"throw",t)}i(void 0)})});return function(t,r,n,o){return e.apply(this,arguments)}}();function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var G=function(t){return t.getBounds()},F=function(t,e){return!(!t||!e)&&e[0]>=t[0]&&e[1]>=t[1]&&e[2]<=t[2]&&e[3]<=t[3]},R=function(t,e){return t?[Math.min(t[0],e[0]),Math.min(t[1],e[1]),Math.max(t[2],e[2]),Math.max(t[3],e[3])]:function(t){if(Array.isArray(t))return x(t)}(r=e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return x(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var r},N=function(t,e){return!(!t||!e||t[2]<e[0]||t[0]>e[2]||t[3]<e[1]||t[1]>e[3])},B=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0,a=function(t,i){var u;0===i?(u=t,e=Math.min(e,u[0]),r=Math.min(r,u[1]),n=Math.max(n,u[0]),o=Math.max(o,u[1])):t.forEach(function(t){return a(t,i-1)})};switch(t.type){case"Point":a(t.coordinates,0);break;case"LineString":case"MultiPoint":a(t.coordinates,1);break;case"Polygon":case"MultiLineString":a(t.coordinates,2);break;case"MultiPolygon":a(t.coordinates,3);break;case"GeometryCollection":t.geometries.forEach(function(t){var a=B(t);e=Math.min(e,a[0]),r=Math.min(r,a[1]),n=Math.max(n,a[2]),o=Math.max(o,a[3])});break;default:throw new Error("Unsupported geometry type: ".concat(t.type))}return[e,r,n,o]};function V(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,l=Object.create(s.prototype);return U(l,"_invoke",function(r,n,o){var a,u,s,l=0,c=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return a=e,u=0,s=t,p.n=r,i}};function y(r,n){for(u=r,s=n,e=0;!f&&l&&!o&&e<c.length;e++){var o,a=c[e],y=p.p,d=a[2];r>3?(o=d===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=t):a[0]<=y&&((o=r<2&&y<a[1])?(u=0,p.v=n,p.n=a[1]):y<d&&(o=r<3||a[0]>n||n>d)&&(a[4]=r,a[5]=n,p.n=d,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,c,d){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&y(c,d),u=c,s=d;(e=u<2?t:s)||!f;){a||(u?u<3?(u>1&&(p.n=-1),y(u,s)):p.n=s:p.v=s);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=t}else if((e=(f=p.n<0)?s:r.call(n,p))!==i)break}catch(e){a=t,u=1,s=e}finally{l=1}}return{value:e,done:f}}}(r,o,a),!0),l}var i={};function u(){}function s(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(U(e={},n,function(){return this}),e),f=l.prototype=u.prototype=Object.create(c);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,U(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return s.prototype=l,U(f,"constructor",l),U(l,"constructor",s),s.displayName="GeneratorFunction",U(l,o,"GeneratorFunction"),U(f),U(f,o,"Generator"),U(f,n,function(){return this}),U(f,"toString",function(){return"[object Generator]"}),(V=function(){return{w:a,m:p}})()}function U(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}U=function(t,e,r,n){function a(e,r){U(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},U(t,e,r,n)}function W(t,e,r,n,o,a,i){try{var u=t[a](i),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}function H(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,u=[],s=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){l=!0,o=t}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(t,e)||K(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function K(t,e){if(t){if("string"==typeof t)return Z(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Z(t,e):void 0}}function Z(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Y=function(t){return{type:"FeatureCollection",features:Array.from(t.values()).map(function(t){return t.feature})}},z=function(t,e,r){if(r&&!(t.size<=1.2*r)){var n,o=r,a=[],i=[],u=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=K(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,i=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){i=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(i)throw o}}}}(t);try{for(u.s();!(n=u.n()).done;){var s=H(n.value,2),l=s[0],c=s[1];N(c.bbox,e)?a.push(l):i.push({id:l,lastSeenAt:c.lastSeenAt})}}catch(t){u.e(t)}finally{u.f()}i.sort(function(t,e){return t.lastSeenAt-e.lastSeenAt});for(var f=t.size-o,p=0;p<f&&p<i.length;p++)t.delete(i[p].id);if(t.size>o)for(var y=t.size-o,d=a.map(function(e){return{id:e,lastSeenAt:t.get(e).lastSeenAt}}).sort(function(t,e){return t.lastSeenAt-e.lastSeenAt}),b=0;b<y&&b<d.length;b++)t.delete(d[b].id)}},J=function(t,e,r){var n=Date.now();e.features.forEach(function(e){var o=function(t,e){var r,n;return e&&null!==(r=null===(n=t.properties)||void 0===n?void 0:n[e])&&void 0!==r?r:t.id}(e,r);null!=o?t.set(o,{feature:e,bbox:B(e.geometry),lastSeenAt:n}):console.warn("Feature missing ID, skipping:",e)})},$=function(){var t,e=(t=V().m(function t(e,r){var n,o,a,i,u,s,l,c,f,p,y,d,b,v,h;return V().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=r.mapProvider,o=r.dynamicGeoJSON,a=r.onUpdate,i=o.url,u=o.idProperty,s=o.transformRequest,l=o.maxFeatures,c=o.minZoom,f=void 0===c?0:c,!((p=n.getZoom())<f)){t.n=1;break}return t.a(2);case 1:if(y=G(n),!e.fetchedBbox||!F(e.fetchedBbox,y)){t.n=2;break}return t.a(2);case 2:return e.currentController&&e.currentController.abort(),e.currentController=new AbortController,t.p=3,d={bbox:y,zoom:p},t.n=4,L(i,d,s,e.currentController.signal);case 4:b=t.v,J(e.features,b,u),e.fetchedBbox=R(e.fetchedBbox,y),v=e.features.size,z(e.features,y,l),e.features.size<v&&(e.fetchedBbox=y),a(o.id,Y(e.features)),t.n=7;break;case 5:if(t.p=5,"AbortError"!==(h=t.v).name){t.n=6;break}return t.a(2);case 6:console.error("Failed to fetch dynamic GeoJSON for ".concat(o.id,":"),h);case 7:return t.a(2)}},t,null,[[3,5]])}),function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(t){W(a,n,o,i,u,"next",t)}function u(t){W(a,n,o,i,u,"throw",t)}i(void 0)})});return function(t,r){return e.apply(this,arguments)}}(),q=function(t){var e=t.adapter,r=t.datasetRegistry,n=t.pluginConfig,o=t.mapStyle,a=t.mapProvider,i=t.events,u=t.dispatch,s=t.eventBus,c=n.datasets,f=new Map;n.globals&&u({type:"SET_GLOBAL_STATE",payload:n.globals});var p=h({datasets:c}),y=p.mappedDatasets,d=p.orderedDatasets;e.createDataset&&r.attachCreateDataset(e.createDataset),r.attach(y,d,o);var b=l({datasets:c});s.requestOnce("menu:state",function(t){return r.attachMenuStateRef(t)}),u({type:"SET_MENU",payload:{menu:b}}),u({type:"SET_DATASETS",payload:{mappedDatasets:y,orderedDatasets:d}}),e.init().then(function(){r.forEachDataset(function(t){if(t.hasDynamicGeoJSON){var r=function(t){var e,r,n,o=t.dynamicGeoJSON,a=t.mapProvider,i=t.onUpdate,u={features:new Map,fetchedBbox:null,currentController:null},s=function(){return $(u,{mapProvider:a,dynamicGeoJSON:o,onUpdate:i})},l=(e=s,n=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(function(){return e.apply(void 0,n)},200)},n.cancel=function(){clearTimeout(r),r=null},n),c=function(){l()};return a.map.on("moveend",c),s(),{destroy:function(){var t,e;t=a.map,e=c,(t.off||t.un).call(t,"moveend",e),l.cancel(),u.currentController&&u.currentController.abort()},clear:function(){u.features.clear(),u.fetchedBbox=null,i(o.id,{type:"FeatureCollection",features:[]})},refresh:function(){u.features.clear(),u.fetchedBbox=null,s()},getFeatureCount:function(){return u.features.size},reapply:function(){u.features.size>0&&i(o.id,Y(u.features))}}}({dynamicGeoJSON:t.dynamicGeoJSON,mapProvider:a,onUpdate:function(t,r){return e.setData(t,r)}});f.set(t.id,r)}}),e.attachDynamicSources(f),s.emit("datasets:ready")});var v=function(){e.onMapSizeChange()};s.on(i.MAP_SIZE_CHANGE,v);var m=s.emitWhenRequested("datasets:registry",r);return s.on("menu:changed",function(t){r.invalidateKeyItemsOnMenuStateChange(t),e.applyGlobalVisibility()}),{remove:function(){s.off(i.MAP_SIZE_CHANGE,v),m(),f.forEach(function(t){return t.destroy()}),f.clear(),e.destroy()},refreshDataset:function(t){var e;null===(e=f.get(t))||void 0===e||e.refresh()},clearDatasetCache:function(t){var e;null===(e=f.get(t))||void 0===e||e.clear()},getFeatureCount:function(t){var e,r;return null!==(e=null===(r=f.get(t))||void 0===r?void 0:r.getFeatureCount())&&void 0!==e?e:null}}};function X(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,l=Object.create(s.prototype);return Q(l,"_invoke",function(r,n,o){var a,u,s,l=0,c=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return a=e,u=0,s=t,p.n=r,i}};function y(r,n){for(u=r,s=n,e=0;!f&&l&&!o&&e<c.length;e++){var o,a=c[e],y=p.p,d=a[2];r>3?(o=d===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=t):a[0]<=y&&((o=r<2&&y<a[1])?(u=0,p.v=n,p.n=a[1]):y<d&&(o=r<3||a[0]>n||n>d)&&(a[4]=r,a[5]=n,p.n=d,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,c,d){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&y(c,d),u=c,s=d;(e=u<2?t:s)||!f;){a||(u?u<3?(u>1&&(p.n=-1),y(u,s)):p.n=s:p.v=s);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=t}else if((e=(f=p.n<0)?s:r.call(n,p))!==i)break}catch(e){a=t,u=1,s=e}finally{l=1}}return{value:e,done:f}}}(r,o,a),!0),l}var i={};function u(){}function s(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Q(e={},n,function(){return this}),e),f=l.prototype=u.prototype=Object.create(c);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Q(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return s.prototype=l,Q(f,"constructor",l),Q(l,"constructor",s),s.displayName="GeneratorFunction",Q(l,o,"GeneratorFunction"),Q(f),Q(f,o,"Generator"),Q(f,n,function(){return this}),Q(f,"toString",function(){return"[object Generator]"}),(X=function(){return{w:a,m:p}})()}function Q(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Q=function(t,e,r,n){function a(e,r){Q(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},Q(t,e,r,n)}function tt(t,e,r,n,o,a,i){try{var u=t[a](i),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}function et(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(t){tt(a,n,o,i,u,"next",t)}function u(t){tt(a,n,o,i,u,"throw",t)}i(void 0)})}}var rt=function(){var t=et(X().m(function t(e){var n,o,a,i,u,s,l;return X().w(function(t){for(;;)switch(t.n){case 0:l=e.name,t.n="MapLibreProvider"===l?1:"EsriProvider"===l?3:"OpenLayersProvider"===l?5:7;break;case 1:return t.n=2,r.e(563).then(r.bind(r,291));case 2:return n=t.v,o=n.default,t.a(2,o);case 3:return t.n=4,Promise.resolve().then(function(){var t=new Error("Cannot find module './esri/esriLayerAdapter.js'");throw t.code="MODULE_NOT_FOUND",t});case 4:return a=t.v,i=a.default,t.a(2,i);case 5:return t.n=6,r.e(809).then(r.bind(r,382));case 6:return u=t.v,s=u.default,t.a(2,s);case 7:throw new Error("No layer adapter available for map provider ".concat(e.name,". Please provide a compatible layer adapter."));case 8:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),nt=function(){var t=et(X().m(function t(e,r,n,o){var a;return X().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,rt(e);case 1:return a=t.v,t.a(2,new a(e,r,n,o))}},t)}));return function(e,r,n,o){return t.apply(this,arguments)}}(),ot=function(t){var e=t.pluginConfig,r=t.pluginState;return!1!==e.hasMenu&&(r.menuInitialised?r.menu.length>0:(e.datasets||[]).some(function(t){var e;return t.showInMenu||(null===(e=t.sublayers)||void 0===e?void 0:e.some(function(t){return t.showInMenu}))}))};function at(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,l=Object.create(s.prototype);return it(l,"_invoke",function(r,n,o){var a,u,s,l=0,c=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return a=e,u=0,s=t,p.n=r,i}};function y(r,n){for(u=r,s=n,e=0;!f&&l&&!o&&e<c.length;e++){var o,a=c[e],y=p.p,d=a[2];r>3?(o=d===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=t):a[0]<=y&&((o=r<2&&y<a[1])?(u=0,p.v=n,p.n=a[1]):y<d&&(o=r<3||a[0]>n||n>d)&&(a[4]=r,a[5]=n,p.n=d,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,c,d){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&y(c,d),u=c,s=d;(e=u<2?t:s)||!f;){a||(u?u<3?(u>1&&(p.n=-1),y(u,s)):p.n=s:p.v=s);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=t}else if((e=(f=p.n<0)?s:r.call(n,p))!==i)break}catch(e){a=t,u=1,s=e}finally{l=1}}return{value:e,done:f}}}(r,o,a),!0),l}var i={};function u(){}function s(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(it(e={},n,function(){return this}),e),f=l.prototype=u.prototype=Object.create(c);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,it(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return s.prototype=l,it(f,"constructor",l),it(l,"constructor",s),s.displayName="GeneratorFunction",it(l,o,"GeneratorFunction"),it(f),it(f,o,"Generator"),it(f,n,function(){return this}),it(f,"toString",function(){return"[object Generator]"}),(at=function(){return{w:a,m:p}})()}function it(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}it=function(t,e,r,n){function a(e,r){it(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},it(t,e,r,n)}function ut(t,e,r,n,o,a,i){try{var u=t[a](i),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}function st(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var lt="datasetsLayers";function ct(t){var e=t.appConfig,r=t.appState,n=t.pluginConfig,o=t.pluginState,a=t.mapState,i=t.mapProvider,u=t.services,s=o.dispatch,l=o.datasetRegistry,c=u.eventBus,f=u.symbolRegistry,p=u.patternRegistry,y=Boolean(null==i?void 0:i.isBaseMapReady());!function(t){var e=t.appConfig,r=t.appState,n=t.pluginConfig,o=t.pluginState,a=t.services,i=a.eventBus,u=a.focusMap,s=ot({pluginConfig:n,pluginState:o}),l=Boolean(r.openPanels[lt]),c=(0,I.useRef)(null);(0,I.useEffect)(function(){if(!s&&l){var t,r,n,o=document.getElementById((t=e.id,r=lt,"".concat(t,"-panel-").concat(null==(n=r)?void 0:n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()))),a=Boolean(null==o?void 0:o.contains(document.activeElement));i.emit(T.APP_HIDE_PANEL,lt),a&&(c.current=requestAnimationFrame(function(){return u()}))}},[s,l]),(0,I.useEffect)(function(){return function(){return cancelAnimationFrame(c.current)}},[])}({appConfig:e,appState:r,pluginConfig:n,pluginState:o,services:u});var d=(0,I.useRef)(o);d.current=o;var b=(0,I.useRef)(null),v=function(t){var e=null==i?void 0:i.datasets;t.length&&e&&(t.forEach(function(t){var r,n=t.method,o=t.parameters;return e[n].apply(e,function(t){if(Array.isArray(t))return st(t)}(r=o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return st(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?st(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}),s({type:"REMOVE_ADAPTER_ACTIONS",payload:t}))};return(0,I.useEffect)(function(){if(y&&!b.current){var t=function(){var t,e=(t=at().m(function t(){var e;return at().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,nt(i,f,p,l);case 1:e=t.v,b.current=q({adapter:e,datasetRegistry:l,pluginConfig:n,pluginStateRef:d,mapStyle:a.mapStyle,mapProvider:i,events:T,dispatch:s,eventBus:c}),i.datasets=e,v(d.current.actionsArray);case 2:return t.a(2)}},t)}),function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(t){ut(a,n,o,i,u,"next",t)}function u(t){ut(a,n,o,i,u,"throw",t)}i(void 0)})});return function(){return e.apply(this,arguments)}}();t()}},[y]),(0,I.useEffect)(function(){l.attach(o.mappedDatasets,o.orderedDatasets),c.emit("datasets:changed")},[o.mappedDatasets,o.orderedDatasets]),(0,I.useEffect)(function(){l.attachMapStyle(a.mapStyle);var t=null==i?void 0:i.datasets;null!=t&&t.onMapStyleChange&&Promise.resolve(t.onMapStyleChange()).then(function(){c.emit(T.MAP_DATA_CHANGE)})},[a.mapStyle]),(0,I.useEffect)(function(){return l.attachGlobals(o.globals)},[o.globals]),(0,I.useEffect)(function(){return v(o.actionsArray)},[o.actionsArray]),(0,I.useEffect)(function(){return function(){b.current&&(b.current.remove(),b.current=null,i.datasets=null)}},[]),null}var ft=function(t,e){var r=t.pluginState.dispatch,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.datasetId,a=n.sublayerId,i=a?"".concat(o,"-").concat(a):o;r(i?{type:"SET_DATASET_VISIBILITY",payload:{datasetId:i,visible:e}}:{type:"SET_GLOBAL_VISIBILITY",payload:{visible:e}})},pt=r(287),yt=function(t){var e=t.menuGroupItem,r=t.datasetRegistry,n=t.onChange,o=r.getDataset(e.id);if(!o)return null;var a=o.isSublayer?o.parentId:o.id,i=o.isSublayer?o.id:void 0,u="im-c-datasets-layers__item govuk-checkboxes govuk-checkboxes--small".concat(o.visible?"":" im-c-datasets-layers__item--checked");return(0,pt.jsx)("div",{className:u,"data-module":"govuk-checkboxes",children:(0,pt.jsxs)("div",{className:"govuk-checkboxes__item",children:[(0,pt.jsx)("input",{className:"govuk-checkboxes__input",id:o.id,"data-dataset-id":a,"data-sublayer-id":i,name:"layers",type:"checkbox",value:o.id,checked:o.isLocallyVisible,onChange:n}),(0,pt.jsx)("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:o.id,children:o.label})]})},o.id)},dt=function(t){var e=t.menuGroup,r=t.children;return e.groupLabel?(0,pt.jsx)("div",{className:"govuk-form-group im-c-datasets-layers-group",children:(0,pt.jsxs)("fieldset",{className:"im-c-datasets-layers-group__fieldset",children:[(0,pt.jsx)("legend",{className:"im-c-datasets-layers-group__legend",children:(0,pt.jsx)("h3",{children:e.groupLabel})}),r]})},e.id):(0,pt.jsx)(pt.Fragment,{children:r})},bt=function(t,e){(0,t.pluginState.dispatch)({type:"ADD_DATASET",payload:{dataset:e,mapStyle:t.mapState.mapStyle}})},vt=function(t,e){var r,n=t.pluginState.dispatch;null===(r=t.mapProvider.datasets)||void 0===r||r.removeDataset(e),n({type:"REMOVE_DATASET",payload:{id:e}})},ht=function(t,e,r){var n=t.pluginState,o=n.dispatch,a=n.datasetRegistry,i=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).datasetId,u=void 0===i?null:i;if(u){var s=a.getDataset(u);!s||s.idProperty||s.generateIds||m.v.warn('setFeatureVisibility: Dataset "'.concat(u,'" has no idProperty or generateIds configured. Features may not be matched correctly. Add idProperty to match by a feature property, or add generateIds: true to use auto-generated IDs.'))}o({type:e?"SHOW_FEATURES":"HIDE_FEATURES",payload:{datasetId:u,featureIds:r}})},mt=function(t,e){var r=t.pluginState.dispatch,n=t.mapState,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=o.datasetId,i=o.sublayerId;r({type:"SET_DATASET_STYLE",payload:{datasetId:a=i?"".concat(a,"-").concat(i):a,styleChanges:e,mapStyle:n.mapStyle}})},gt=function(t){var e=t.pluginState.datasetRegistry,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.datasetId,o=r.sublayerId;n=o?"".concat(n,"-").concat(o):n;var a=e.getDataset(n);return a?a.style:(m.v.warn("getStyle: Dataset with id ".concat(n," not found")),null)},St=function(t,e){var r=t.pluginState.dispatch,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.datasetId,a=n.sublayerId,i=a?"".concat(o,"-").concat(a):o;r(i?{type:"SET_OPACITY",payload:{datasetId:i,opacity:e}}:{type:"SET_GLOBAL_OPACITY",payload:{opacity:e}})},Ot=function(t){var e,r=t.pluginState,n=r.globals,o=r.datasetRegistry,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=a.datasetId,u=a.sublayerId,s=u?"".concat(i,"-").concat(u):i;if(s){var l,c=o.getDataset(s);return c?null!==(l=c.opacity)&&void 0!==l?l:null:(m.v.warn("getOpacity: Dataset with id ".concat(s," not found")),null)}return null!==(e=n.opacity)&&void 0!==e?e:null},Dt=function(t,e,r){var n,o=t.pluginState.datasetRegistry,a=t.mapProvider,i=r.datasetId,u=o.getDataset(i);u?null!=u&&u.tiles?m.v.warn('setData called on vector tile dataset "'.concat(i,'" — has no effect')):null===(n=a.datasets)||void 0===n||n.setData(i,e):m.v.warn("setData: Dataset with id ".concat(i," not found"))},Pt=function(t,e){var r=t.pluginState.dispatch,n=e.opacityMode,o={},a=!1;n&&(["dataset","global","multiply"].includes(n)?(a=!0,o.opacityMode=n):m.v.warn("Ignoring invalid opacityMode: ".concat(n,". Must be one of 'dataset', 'global' or 'multiply'."))),a?r({type:"SET_GLOBAL_STATE",payload:o}):m.v.warn("setGlobals: requires a valid value for opacityMode to be set")},_t=r(428);function At(t){return At="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},At(t)}function wt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Et(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function jt(t){var e=function(t){if("object"!=At(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=At(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==At(e)?e:e+""}var It=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.idToDefinitionMap=new Map,this.definitionToInstanceMap=new Map},(e=[{key:"add",value:function(t){this.idToDefinitionMap.set(t.id,t._datasetDefinition),this.definitionToInstanceMap.set(t._datasetDefinition,t)}},{key:"invalidateDataset",value:function(t){var e=this,r=this.idToDefinitionMap.get(t.id);[r.id].concat(function(t){return function(t){if(Array.isArray(t))return wt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return wt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?wt(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((null==r?void 0:r.sublayerIds)||[])).forEach(function(t){var r=e.idToDefinitionMap.get(t);e.definitionToInstanceMap.delete(r),e.idToDefinitionMap.delete(t)})}},{key:"invalidateChangedDatasets",value:function(t){var e=this;t.forEach(function(t){var r=e.idToDefinitionMap.get(t.id);if(r&&r!==t){var n=e.definitionToInstanceMap.get(r);e.invalidateDataset(n.isSublayer&&n.parent?n.parent:n)}})}},{key:"getByDefinition",value:function(t){return this.definitionToInstanceMap.get(t)}}])&&Et(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Tt(t){return Tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tt(t)}function kt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,u=[],s=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){l=!0,o=t}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Mt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Mt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ct=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,n=Object.entries(t);r<n.length;r++){var o=kt(n[r],2),a=o[0],i=o[1],u=e[a];if(!i.includes(u))return!1}return!0},Lt=function(t,e){return(Array.isArray(t)?t:[t]).includes(e)};function xt(t){return xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xt(t)}function Gt(t){return function(t){if(Array.isArray(t))return Ft(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ft(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ft(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Rt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Nt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Rt(Object(r),!0).forEach(function(e){Bt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Rt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Bt(t,e,r){return(e=function(t){var e=function(t){if("object"!=xt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=xt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Vt={attach:function(t,e,r){this._datasets=t,this._orderedDatasets=e,this.attachMapStyle(r),this._invalidateChangedDatasets()},_invalidateCache:function(){this._definitionCache=new It},_invalidateChangedDatasets:function(){this._datasets?this._definitionCache.invalidateChangedDatasets(Object.values(this._datasets)):this._invalidateCache()},attachCreateDataset:function(t){this._createDataset=t},_createDataset:function(t,e){return function(t,e){return new _t.j(t,e)}(t,e)},attachMapStyle:function(t){t&&(this._mapStyle=t)},get mapStyle(){return this._mapStyle},attachGlobals:function(t){t&&(this._globals=t)},get globals(){return this._globals},attachMenuStateRef:function(t){this._menuStateRef=t},isVisibleWhen:function(t){var e,r;return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.mapStyleId,n=e.menuState;if(null==t)return!0;if("boolean"==typeof t)return t;if("object"===Tt(t)){for(var o=0,a=Object.entries(t);o<a.length;o++){var i=kt(a[o],2),u=i[0],s=i[1];if("mapStyleId"===u&&!Lt(s,r))return!1;if("menu"===u&&!Ct(s,n))return!1}return!0}return!0}(t,{mapStyleId:null===(e=this._mapStyle)||void 0===e?void 0:e.id,menuState:null===(r=this._menuStateRef)||void 0===r||null===(r=r.current)||void 0===r?void 0:r.menuState})},get datasets(){return this._datasets},getDataset:function(t){var e=this.datasets[t];if(e){var r=this._definitionCache.getByDefinition(e);if(r)return r;var n=this._createDataset(e,this);return this._definitionCache.add(n),n.isSublayer&&this.getDataset(n.parentId),n}},forEach:function(t){var e=this;this._orderedDatasets.forEach(function(r){return t(e.getDataset(r))})},forEachDataset:function(t){var e=this;Object.values(this.datasets).filter(function(t){return!t.parentId}).forEach(function(r){return t(e.getDataset(r.id))})},topLevelDatasets:function(){var t=this;return Object.values(this.datasets).filter(function(t){return!t.parentId}).map(function(e){return t.getDataset(e.id)})},getPatternAndSymbolConfigs:function(){return this.topLevelDatasets().reduce(function(t,e){return Nt(Nt({},t),{},{patternConfigs:[].concat(Gt(t.patternConfigs),Gt(e.patternConfigs)),symbolConfigs:[].concat(Gt(t.symbolConfigs),Gt(e.symbolConfigs))})},{patternConfigs:[],symbolConfigs:[]})},invalidateKeyItemsOnMenuStateChange:function(t){t!==this._lastMenuState&&(this._lastMenuState=t,this._lastKeyItemsDatasets=null)},keyItems:function(){if(this.datasets===this._lastKeyItemsDatasets)return this._lastKeyItems;this._lastKeyItemsDatasets=this.datasets;var t=[],e=new Map;this.forEach(function(r){if(r.keyVisibility)if(r.hasSublayers||r.groupId||r.groupLabel){var n=r.groupId,o=function(r,n){if(e.has(n))return e.get(n);var o={type:"group",id:n,groupLabel:r,keyDefinitions:[]};return e.set(n,o),t.push(o),o}(r.groupLabel||n||r.label,n);r.hasSublayers||o.keyDefinitions.push(r.keyDefinition)}else t.push({type:"flat",id:r.id,keyDefinition:r.keyDefinition})});var r=t.filter(function(t){var e;return"flat"===t.type||Boolean(null===(e=t.keyDefinitions)||void 0===e?void 0:e.length)}),n=r.some(function(t){return"group"===t.type});return this._lastKeyItems={items:r,hasGroups:n},this._lastKeyItems}};function Ut(t){return Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ut(t)}function Wt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Ht(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Wt(Object(r),!0).forEach(function(e){Kt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Wt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Kt(t,e,r){return(e=function(t){var e=function(t){if("object"!=Ut(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ut(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ut(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Zt={id:"datasetsLayers",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:function(t){var e=t.pluginState,r=e.menu,n=void 0===r?[]:r,o=function(t){var r=t.target,n=r.value,o=r.checked;ft({pluginState:e},o,{datasetId:n})},a=n.some(function(t){return t.groupLabel}),i="im-c-datasets-layers".concat(a?" im-c-datasets-layers--has-groups":"");return(0,pt.jsx)("div",{className:i,children:n.map(function(t){return(0,pt.jsxs)(dt,{menuGroup:t,children:[" ",t.items.map(function(t){return(0,pt.jsx)(yt,{menuGroupItem:t,datasetRegistry:e.datasetRegistry,onChange:o},t.id)})]},t.id)})})}},Yt={id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",excludeWhen:function(t){return!ot(t)},iconId:"layers",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}},zt=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).hasMenu;return{InitComponent:ct,reducer:{initialState:Ht(Ht({},A),{},{datasetRegistry:Object.assign(Object.create(Vt),{_definitionCache:new It,_globals:{},_menuStateRef:{},_lastMenuState:{},_lastKeyItems:{}})}),actions:j},panels:!1===t?[]:[Zt],buttons:!1===t?[]:[Yt],icons:[{id:"layers",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addDataset:bt,removeDataset:vt,setDatasetVisibility:ft,setFeatureVisibility:ht,setStyle:mt,getStyle:gt,setOpacity:St,getOpacity:Ot,setData:Dt,setGlobals:Pt}}}},428:function(t,e,r){r.d(e,{j:function(){return S}});var n=r(852),o=(new Set,new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),function(t){return!!(null!=t&&t.symbol||null!=t&&t.symbolSvgContent)});function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function u(t,e,r){return(e=c(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function l(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t){var e=function(t){if("object"!=a(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==a(e)?e:e+""}var f=l(function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.id=e.id,this.url=e.url,this.transformRequest=e.transformRequest,this.maxFeatures=e.maxFeatures,this.minZoom=e.minZoom,this.idProperty=e.idProperty,this.hiddenFeaturesIdExpression=["to-string",["get",this.idProperty]],this.sourceId="geojson-dynamic-".concat(this.id),this.source=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach(function(e){u(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({type:"geojson",data:{type:"FeatureCollection",features:[]}},this.idProperty?{promoteId:this.idProperty}:{generateId:!0})});function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function y(t){return function(t){if(Array.isArray(t))return d(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return d(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function v(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach(function(e){h(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function h(t,e,r){return(e=g(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,g(n.key),n)}}function g(t){var e=function(t){if("object"!=p(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==p(e)?e:e+""}var S=function(){return t=function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._datasetDefinition=e,this._datasetRegistry=r},(e=[{key:"id",get:function(){return this._datasetDefinition.id}},{key:"label",get:function(){return this._datasetDefinition.label}},{key:"hasSymbol",get:function(){return!this.hasSublayers&&o(this.style)}},{key:"hasPattern",get:function(){return!(this.hasSublayers||this.hasSymbol||(t=this.style,!t.fillPattern&&!t.fillPatternSvgContent));var t}},{key:"hasFill",get:function(){var t,e;return!this.hasSublayers&&!this.hasSymbol&&(this.hasPattern||(null===(t=this.style)||void 0===t?void 0:t.fill)&&"transparent"!==(null===(e=this.style)||void 0===e?void 0:e.fill))}},{key:"hasStroke",get:function(){var t;return!this.hasSublayers&&!this.hasSymbol&&Boolean(null===(t=this.style)||void 0===t?void 0:t.stroke)}},{key:"tiles",get:function(){return this._datasetDefinition.tiles}},{key:"geojson",get:function(){return this._datasetDefinition.geojson}},{key:"idProperty",get:function(){return this._datasetDefinition.idProperty}},{key:"generateIds",get:function(){return this._datasetDefinition.generateIds}},{key:"parentId",get:function(){return this._datasetDefinition.parentId}},{key:"minZoom",get:function(){var t;return this._datasetDefinition.minZoom||(null===(t=this.parent)||void 0===t?void 0:t.minZoom)}},{key:"maxZoom",get:function(){var t;return this._datasetDefinition.maxZoom||(null===(t=this.parent)||void 0===t?void 0:t.maxZoom)}},{key:"type",get:function(){var t;return this._datasetDefinition.type||(null===(t=this.parent)||void 0===t?void 0:t.type)}},{key:"showInKey",get:function(){var t,e,r=this._datasetDefinition.showInKey;return void 0!==r?r:null!==(t=null===(e=this.parent)||void 0===e?void 0:e.showInKey)&&void 0!==t&&t}},{key:"visibleWhen",get:function(){var t;return void 0===this._datasetDefinition.visibleWhen?null===(t=this.parent)||void 0===t?void 0:t.visibleWhen:this._datasetDefinition.visibleWhen}},{key:"groupLabel",get:function(){var t,e;return this._datasetDefinition.groupLabel||(null===(t=this.parent)||void 0===t?void 0:t.groupLabel)||(null===(e=this.parent)||void 0===e?void 0:e.label)}},{key:"groupId",get:function(){var t;return this._datasetDefinition.groupId||(null===(t=this.parent)||void 0===t?void 0:t.groupId)||(this.groupLabel?this.groupLabel.toLowerCase().replace(/\s+/g,"-"):null)}},{key:"opacity",get:function(){var t,e,r=null===(t=this.style)||void 0===t?void 0:t.opacity,n=null===(e=this.parent)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.opacity;return function(t,e,r){switch(t.opacityMode){case"global":return t.opacity;case"multiply":return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Math.round(100*(e*r*t.opacity+Number.EPSILON))/100}(t,e,r);default:return function(t,e,r){return void 0===e?void 0===r?t.opacity:r:e}(t,e,r)}}(this._datasetRegistry.globals,r,n)}},{key:"hasDynamicGeoJSON",get:function(){return Boolean(this._datasetDefinition.dynamicGeoJSON)}},{key:"dynamicGeoJSON",get:function(){return new f(v(v({},this._datasetDefinition.dynamicGeoJSON),{},{id:this.id,minZoom:this.minZoom}))}},{key:"hiddenFeatures",get:function(){return this._datasetDefinition.hiddenFeatures}},{key:"hasHiddenFeatures",get:function(){var t,e;return Boolean((null===(t=this.hiddenFeatures)||void 0===t?void 0:t.length)>0||(null===(e=this.parent)||void 0===e?void 0:e.hasHiddenFeatures))}},{key:"filter",get:function(){return null}},{key:"isHiddenByInheritance",get:function(){var t;return this.isSublayer?!(null!==(t=this.parent)&&void 0!==t&&t.visible):!this._datasetRegistry.globals.visible}},{key:"isLocallyVisible",get:function(){return!!this.isVisible||this._datasetDefinition.visible}},{key:"visible",get:function(){var t;return this.isSublayer?this._datasetDefinition.visible&&(null===(t=this.parent)||void 0===t?void 0:t.visible):this._datasetDefinition.visible&&this._datasetRegistry.globals.visible}},{key:"esriStyleLayerId",get:function(){return this._datasetDefinition.esriStyleLayerId}},{key:"visibility",get:function(){var t=this.visible,e=this.visibleWhen;return t&&e?this._datasetRegistry.isVisibleWhen(e)?"visible":"none":t?"visible":"none"}},{key:"keyVisibility",get:function(){return this.showInKey&&"visible"===this.visibility}},{key:"symbolAnchor",get:function(){var t,e;return null!==(t=this.style)&&void 0!==t&&t.symbolAnchor?this.style.symbolAnchor:null===(e=this.parent)||void 0===e?void 0:e.symbolAnchor}},{key:"sourceLayer",get:function(){return this.isSublayer?this.parent.sourceLayer:this.tiles?this._datasetDefinition.sourceLayer:void 0}},{key:"isSublayer",get:function(){return Boolean(this._datasetDefinition.parentId)}},{key:"hasSublayers",get:function(){var t;return(null===(t=this._datasetDefinition.sublayerIds)||void 0===t?void 0:t.length)>0}},{key:"sublayerIds",get:function(){return this._datasetDefinition.sublayerIds}},{key:"sublayers",get:function(){var t=this,e=this.sublayerIds;return e?e.map(function(e){return t._datasetRegistry.getDataset(e)}):[]}},{key:"parent",get:function(){if(this._datasetDefinition.parentId)return this._datasetRegistry.getDataset(this._datasetDefinition.parentId)}},{key:"inheritedStyle",get:function(){var t=this._datasetDefinition.style||{},e=this.parent;return e?v(v({},e.inheritedStyle),{},{opacity:void 0},t):t}},{key:"style",get:function(){return v(v({},(0,n.Eg)(this.inheritedStyle)),{},{symbolDescription:this.symbolDescription})}},{key:"hasCustomVisualStyle",get:function(){return(0,n.p_)(this._datasetDefinition.style||{})}},{key:"symbolDescription",get:function(){var t;return null!==(t=this._datasetDefinition.style)&&void 0!==t&&t.symbolDescription?this._datasetDefinition.style.symbolDescription:this.hasCustomVisualStyle?void 0:this.parent?this.parent.symbolDescription:n.V.style.symbolDescription}},{key:"patternConfigs",get:function(){var t=this.hasPattern?[this.style]:[];return this.hasSublayers?[].concat(t,y(this.sublayers.flatMap(function(t){return t.patternConfigs}))):t}},{key:"symbolConfigs",get:function(){var t=this.hasSymbol?[this.style]:[];return this.hasSublayers?[].concat(t,y(this.sublayers.flatMap(function(t){return t.symbolConfigs}))):t}},{key:"keyDefinition",get:function(){return{id:this.id,type:"dataset",label:this.label,hasSymbol:this.hasSymbol,hasPattern:this.hasPattern,style:this.style,symbolDescription:this.symbolDescription}}}])&&m(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()},619:function(t,e,r){r.d(e,{v:function(){return o}});var n="[interactive-map]",o={warn:function(){for(var t,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return(t=console).warn.apply(t,[n].concat(r))},error:function(){for(var t,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return(t=console).error.apply(t,[n].concat(r))}}}}]);
2
+ "use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[447],{852:function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){i(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function i(t,e,r){return(e=function(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}r.d(e,{jE:function(){return d},Eg:function(){return y},V:function(){return l},p_:function(){return p}});var s,l={minZoom:6,maxZoom:24,showInKey:!1,showInMenu:!1,visible:!0,style:{stroke:"#d4351c",strokeWidth:2,symbolDescription:"red outline"}},c=["stroke","strokeWidth","strokeDashArray","fill","fillPattern","fillPatternSvgContent","fillPatternForegroundColor","fillPatternBackgroundColor","opacity","symbolDescription"].concat(function(t){if(Array.isArray(t))return u(t)}(s=["symbol","symbolSvgContent","symbolViewBox","symbolAnchor","symbolSize","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"])||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(s)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(s)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"],p=function(t){return f.some(function(e){return e in t})},y=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return p(t)?a({strokeWidth:l.style.strokeWidth},t):a(a({},l.style),t)},d=function(t){!0!==t.visible&&!1!==t.visible&&(t.visible="hidden"!==t.visibility);var e=a(a(a({},l),t),{},{style:a({},t.style)});return c.forEach(function(t){return delete e[t]}),e}},634:function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){i(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function i(t,e,r){return(e=function(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){return function(t){if(Array.isArray(t))return s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}r.r(e),r.d(e,{createManifest:function(){return zt}});var l=function(t){var e=t.datasets,r=[],n=(void 0===e?[]:e).filter(function(t){var e;return t.showInMenu||(null===(e=t.sublayers)||void 0===e?void 0:e.some(function(t){return t.showInMenu}))}),o=new Map;return n.forEach(function(t){var e;if(null!==(e=t.sublayers)&&void 0!==e&&e.length){var n=t.sublayers.filter(function(e){return t.showInMenu?!1!==e.showInMenu:e.showInMenu});if(!1===t.showInMenu&&!n.length)return;var a={id:t.id,groupLabel:t.label,visibleWhen:!0,type:"checkbox",items:n.map(function(e){return{id:"".concat(t.id,"-").concat(e.id),label:e.label}})};0===a.items.length&&(delete a.groupLabel,a.items.push({id:t.id,label:t.label})),r.push(a)}else if(t.groupLabel){var i=o.has(t.groupLabel)?o.get(t.groupLabel):{id:t.groupLabel,groupLabel:t.groupLabel,visibleWhen:!0,type:"checkbox",items:[]};o.has(t.groupLabel)||(o.set(t.groupLabel,i),r.push(i)),i.items.push({id:t.id,label:t.label})}else r.push({visibleWhen:!0,type:"checkbox",id:t.id,items:[{id:t.id,label:t.label}]})}),r},c=function(t,e){return t.reduce(function(t,r){var n=r.items.filter(function(t){return!e.includes(t.id)});return n.length&&t.push(a(a({},r),{},{items:n})),t},[])},f=r(852);function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function y(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function d(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?y(Object(r),!0).forEach(function(e){b(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function b(t,e,r){return(e=function(t){var e=function(t){if("object"!=p(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==p(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var v=function(t,e){var r,n=e.id,o=(0,f.jE)(e);e.parentId&&("showInKey"in e||delete o.showInKey,"showInMenu"in e||delete o.showInMenu),t[n]=o;var a=t.orderedDatasets;a.push(n);var i=null===(r=e.sublayers)||void 0===r?void 0:r.map(function(t){return function(t,e){var r="".concat(t,"-").concat(e.id),n=e.id;return"hidden"!==e.visibility&&(e.visibility="visible"),d(d({},e),{},{id:r,parentId:t,sublayerId:n})}(n,t)});if(null!=i&&i.length){var u=null==i?void 0:i.map(function(t){return t.id}),s=null==i?void 0:i.reduce(v,{orderedDatasets:a});return t[n].sublayerIds=u,delete t[n].sublayers,d(d(d({},t),s),{},{orderedDatasets:a})}return d(d({},t),{},{orderedDatasets:a})},h=function(t){var e=(t.datasets||[]).reduce(v,{orderedDatasets:[]}),r=e.orderedDatasets;return delete e.orderedDatasets,d(d({},t),{},{mappedDatasets:e,orderedDatasets:r})},m=r(619);function g(t){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g(t)}function S(t){return function(t){if(Array.isArray(t))return O(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return O(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?O(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function D(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function P(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?D(Object(r),!0).forEach(function(e){_(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _(t,e,r){return(e=function(t){var e=function(t){if("object"!=g(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=g(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==g(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var A={globals:{visible:!0,opacity:1,opacityMode:"dataset"},key:{items:[],hasGroups:!1},mappedDatasets:{},orderedDatasets:[],actionsArray:[],menu:[],menuInitialised:!1},w=function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"not found";return!!t.mappedDatasets[e]||(m.v.error("".concat(r,": Dataset with id '").concat(e,"' ").concat(n)),!1)},E=function(t,e,r){return P(P({},r),{},{actionsArray:[].concat(S(r.actionsArray),[{method:t,parameters:e}])})},j={SET_DATASETS:function(t,e){var r=e.mappedDatasets,n=e.orderedDatasets;return P(P({},t),{},{mappedDatasets:r,orderedDatasets:n})},ADD_DATASET:function(t,e){var r=e.dataset,n=e.mapStyle;if(t.mappedDatasets[r.id])return m.v.error("addDataset: Dataset with id '".concat(r.id,"' already exists")),t;var o=h({datasets:[r]}),a=o.mappedDatasets,i=o.orderedDatasets,s=function(t,e){var r,n=u(t.menu),o=l({datasets:[e]}),a=n.find(function(t){return t.groupLabel===o[0].groupLabel});return a?(r=a.items).push.apply(r,u(o[0].items)):n.push.apply(n,u(o)),n}(t,r);return E("addDataset",[r.id,n],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),a),orderedDatasets:[].concat(S(t.orderedDatasets),S(i)),menu:s}))},REMOVE_DATASET:function(t,e){var r,n=e.id;if(!w(t,n,"removeDataset"))return t;var o=P({},t.mappedDatasets),a=[n].concat(S((null===(r=o[n])||void 0===r?void 0:r.sublayerIds)||[]));a.forEach(function(t){return delete o[t]});var i=t.orderedDatasets.filter(function(t){return!a.includes(t)});return P(P({},t),{},{mappedDatasets:o,orderedDatasets:i,menu:c(t.menu,a)})},SET_DATASET_VISIBILITY:function(t,e){var r=e.datasetId,n=e.visible;return w(t,r,"setDatasetVisibility")?t.mappedDatasets[r].visible===n?t:E("applyDatasetVisibility",[r,n],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,P(P({},t.mappedDatasets[r]),{},{visible:n})))})):t},SET_GLOBAL_VISIBILITY:function(t,e){var r=e.visible;return E("applyGlobalVisibility",[r],P(P({},t),{},{globals:P(P({},t.globals),{},{visible:r})}))},SET_DATASET_STYLE:function(t,e){var r=e.datasetId,n=e.styleChanges,o=e.mapStyle;if(!w(t,r,"setDatasetStyle"))return t;var a=P(P({},t.mappedDatasets[r].style),n),i=P(P(P({},t.mappedDatasets[r]),n),{},{style:a});return E("applyStyle",[r,o],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,i))}))},SET_OPACITY:function(t,e){var r=e.datasetId,n=e.opacity;if(!w(t,r,"setOpacity"))return t;var o=P(P({},t.mappedDatasets[r].style),{},{opacity:n}),a=P(P({},t.mappedDatasets[r]),{},{style:o});return E("applyDatasetOpacity",[r],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,a))}))},SET_GLOBAL_OPACITY:function(t,e){var r=e.opacity;return E("applyGlobalOpacity",[],P(P({},t),{},{globals:P(P({},t.globals),{},{opacity:r})}))},HIDE_FEATURES:function(t,e){var r=e.datasetId,n=e.featureIds;if(!w(t,r,"setFeatureVisibility - hideFeatures"))return t;var o=P({},t.mappedDatasets[r]),a=o.hiddenFeatures||[],i=Array.from(new Set([].concat(S(a),S(n))));return o.hiddenFeatures=i,E("applyFeatureFilter",[r],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,o))}))},SHOW_FEATURES:function(t,e){var r=e.datasetId,n=e.featureIds;if(!w(t,r,"setFeatureVisibility - showFeatures"))return t;var o=P({},t.mappedDatasets[r]),a=(o.hiddenFeatures||[]).filter(function(t){return!n.includes(t)});return o.hiddenFeatures=a.length?a:[-1],E("applyFeatureFilter",[r],P(P({},t),{},{mappedDatasets:P(P({},t.mappedDatasets),{},_({},r,o))}))},REMOVE_ADAPTER_ACTIONS:function(t,e){return null!=e&&e.length?P(P({},t),{},{actionsArray:t.actionsArray.filter(function(t){return!e.includes(t)})}):t},SET_GLOBAL_STATE:function(t,e){return E("applyGlobalOpacity",[],P(P({},t),{},{globals:P(P({},t.globals),e)}))},SET_MENU:function(t,e){var r=e.menu;return P(P({},t),{},{menu:r,menuInitialised:!0})}},I=r(738),T={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SET_APPLICATION_MODE:"app:setapplicationmode",APP_CLEAR_APPLICATION_MODE:"app:clearapplicationmode",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_SPATIAL_LIST:"map:setspatiallist",MAP_SET_SPATIAL_LIST_SUPPRESSED:"map:setspatiallistsuppressed",MAP_SET_ACTIVE_ITEM:"map:setactiveitem",MAP_SELECT_ITEM:"map:selectitem",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"};function k(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,l=Object.create(s.prototype);return M(l,"_invoke",function(r,n,o){var a,u,s,l=0,c=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return a=e,u=0,s=t,p.n=r,i}};function y(r,n){for(u=r,s=n,e=0;!f&&l&&!o&&e<c.length;e++){var o,a=c[e],y=p.p,d=a[2];r>3?(o=d===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=t):a[0]<=y&&((o=r<2&&y<a[1])?(u=0,p.v=n,p.n=a[1]):y<d&&(o=r<3||a[0]>n||n>d)&&(a[4]=r,a[5]=n,p.n=d,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,c,d){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&y(c,d),u=c,s=d;(e=u<2?t:s)||!f;){a||(u?u<3?(u>1&&(p.n=-1),y(u,s)):p.n=s:p.v=s);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=t}else if((e=(f=p.n<0)?s:r.call(n,p))!==i)break}catch(e){a=t,u=1,s=e}finally{l=1}}return{value:e,done:f}}}(r,o,a),!0),l}var i={};function u(){}function s(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(M(e={},n,function(){return this}),e),f=l.prototype=u.prototype=Object.create(c);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,M(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return s.prototype=l,M(f,"constructor",l),M(l,"constructor",s),s.displayName="GeneratorFunction",M(l,o,"GeneratorFunction"),M(f),M(f,o,"Generator"),M(f,n,function(){return this}),M(f,"toString",function(){return"[object Generator]"}),(k=function(){return{w:a,m:p}})()}function M(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}M=function(t,e,r,n){function a(e,r){M(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},M(t,e,r,n)}function C(t,e,r,n,o,a,i){try{var u=t[a](i),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}var L=function(){var t,e=(t=k().m(function t(e,r,n,o){var a,i,u,s,l,c,f;return k().w(function(t){for(;;)switch(t.n){case 0:return a=n(e,r),u=(i="string"==typeof a?{url:a}:a).url,s=i.headers,l=void 0===s?{}:s,t.n=1,fetch(u,{headers:l,signal:o});case 1:if((c=t.v).ok){t.n=2;break}throw new Error("Failed to fetch GeoJSON: ".concat(c.status," ").concat(c.statusText));case 2:return t.n=3,c.json();case 3:if("FeatureCollection"!==(f=t.v).type){t.n=4;break}return t.a(2,f);case 4:if("Feature"!==f.type){t.n=5;break}return t.a(2,{type:"FeatureCollection",features:[f]});case 5:if(!Array.isArray(f)){t.n=6;break}return t.a(2,{type:"FeatureCollection",features:f});case 6:throw new Error("Invalid GeoJSON response");case 7:return t.a(2)}},t)}),function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(t){C(a,n,o,i,u,"next",t)}function u(t){C(a,n,o,i,u,"throw",t)}i(void 0)})});return function(t,r,n,o){return e.apply(this,arguments)}}();function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var G=function(t){return t.getBounds()},F=function(t,e){return!(!t||!e)&&e[0]>=t[0]&&e[1]>=t[1]&&e[2]<=t[2]&&e[3]<=t[3]},R=function(t,e){return t?[Math.min(t[0],e[0]),Math.min(t[1],e[1]),Math.max(t[2],e[2]),Math.max(t[3],e[3])]:function(t){if(Array.isArray(t))return x(t)}(r=e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return x(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var r},N=function(t,e){return!(!t||!e||t[2]<e[0]||t[0]>e[2]||t[3]<e[1]||t[1]>e[3])},B=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0,a=function(t,i){var u;0===i?(u=t,e=Math.min(e,u[0]),r=Math.min(r,u[1]),n=Math.max(n,u[0]),o=Math.max(o,u[1])):t.forEach(function(t){return a(t,i-1)})};switch(t.type){case"Point":a(t.coordinates,0);break;case"LineString":case"MultiPoint":a(t.coordinates,1);break;case"Polygon":case"MultiLineString":a(t.coordinates,2);break;case"MultiPolygon":a(t.coordinates,3);break;case"GeometryCollection":t.geometries.forEach(function(t){var a=B(t);e=Math.min(e,a[0]),r=Math.min(r,a[1]),n=Math.max(n,a[2]),o=Math.max(o,a[3])});break;default:throw new Error("Unsupported geometry type: ".concat(t.type))}return[e,r,n,o]};function V(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,l=Object.create(s.prototype);return U(l,"_invoke",function(r,n,o){var a,u,s,l=0,c=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return a=e,u=0,s=t,p.n=r,i}};function y(r,n){for(u=r,s=n,e=0;!f&&l&&!o&&e<c.length;e++){var o,a=c[e],y=p.p,d=a[2];r>3?(o=d===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=t):a[0]<=y&&((o=r<2&&y<a[1])?(u=0,p.v=n,p.n=a[1]):y<d&&(o=r<3||a[0]>n||n>d)&&(a[4]=r,a[5]=n,p.n=d,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,c,d){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&y(c,d),u=c,s=d;(e=u<2?t:s)||!f;){a||(u?u<3?(u>1&&(p.n=-1),y(u,s)):p.n=s:p.v=s);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=t}else if((e=(f=p.n<0)?s:r.call(n,p))!==i)break}catch(e){a=t,u=1,s=e}finally{l=1}}return{value:e,done:f}}}(r,o,a),!0),l}var i={};function u(){}function s(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(U(e={},n,function(){return this}),e),f=l.prototype=u.prototype=Object.create(c);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,U(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return s.prototype=l,U(f,"constructor",l),U(l,"constructor",s),s.displayName="GeneratorFunction",U(l,o,"GeneratorFunction"),U(f),U(f,o,"Generator"),U(f,n,function(){return this}),U(f,"toString",function(){return"[object Generator]"}),(V=function(){return{w:a,m:p}})()}function U(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}U=function(t,e,r,n){function a(e,r){U(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},U(t,e,r,n)}function W(t,e,r,n,o,a,i){try{var u=t[a](i),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}function H(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,u=[],s=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){l=!0,o=t}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(t,e)||K(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function K(t,e){if(t){if("string"==typeof t)return Z(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Z(t,e):void 0}}function Z(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Y=function(t){return{type:"FeatureCollection",features:Array.from(t.values()).map(function(t){return t.feature})}},z=function(t,e,r){if(r&&!(t.size<=1.2*r)){var n,o=r,a=[],i=[],u=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=K(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,i=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){i=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(i)throw o}}}}(t);try{for(u.s();!(n=u.n()).done;){var s=H(n.value,2),l=s[0],c=s[1];N(c.bbox,e)?a.push(l):i.push({id:l,lastSeenAt:c.lastSeenAt})}}catch(t){u.e(t)}finally{u.f()}i.sort(function(t,e){return t.lastSeenAt-e.lastSeenAt});for(var f=t.size-o,p=0;p<f&&p<i.length;p++)t.delete(i[p].id);if(t.size>o)for(var y=t.size-o,d=a.map(function(e){return{id:e,lastSeenAt:t.get(e).lastSeenAt}}).sort(function(t,e){return t.lastSeenAt-e.lastSeenAt}),b=0;b<y&&b<d.length;b++)t.delete(d[b].id)}},J=function(t,e,r){var n=Date.now();e.features.forEach(function(e){var o=function(t,e){var r,n;return e&&null!==(r=null===(n=t.properties)||void 0===n?void 0:n[e])&&void 0!==r?r:t.id}(e,r);null!=o?t.set(o,{feature:e,bbox:B(e.geometry),lastSeenAt:n}):console.warn("Feature missing ID, skipping:",e)})},$=function(){var t,e=(t=V().m(function t(e,r){var n,o,a,i,u,s,l,c,f,p,y,d,b,v,h;return V().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=r.mapProvider,o=r.dynamicGeoJSON,a=r.onUpdate,i=o.url,u=o.idProperty,s=o.transformRequest,l=o.maxFeatures,c=o.minZoom,f=void 0===c?0:c,!((p=n.getZoom())<f)){t.n=1;break}return t.a(2);case 1:if(y=G(n),!e.fetchedBbox||!F(e.fetchedBbox,y)){t.n=2;break}return t.a(2);case 2:return e.currentController&&e.currentController.abort(),e.currentController=new AbortController,t.p=3,d={bbox:y,zoom:p},t.n=4,L(i,d,s,e.currentController.signal);case 4:b=t.v,J(e.features,b,u),e.fetchedBbox=R(e.fetchedBbox,y),v=e.features.size,z(e.features,y,l),e.features.size<v&&(e.fetchedBbox=y),a(o.id,Y(e.features)),t.n=7;break;case 5:if(t.p=5,"AbortError"!==(h=t.v).name){t.n=6;break}return t.a(2);case 6:console.error("Failed to fetch dynamic GeoJSON for ".concat(o.id,":"),h);case 7:return t.a(2)}},t,null,[[3,5]])}),function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(t){W(a,n,o,i,u,"next",t)}function u(t){W(a,n,o,i,u,"throw",t)}i(void 0)})});return function(t,r){return e.apply(this,arguments)}}(),q=function(t){var e=t.adapter,r=t.datasetRegistry,n=t.pluginConfig,o=t.mapStyle,a=t.mapProvider,i=t.events,u=t.dispatch,s=t.eventBus,c=n.datasets,f=new Map;n.globals&&u({type:"SET_GLOBAL_STATE",payload:n.globals});var p=h({datasets:c}),y=p.mappedDatasets,d=p.orderedDatasets;e.createDataset&&r.attachCreateDataset(e.createDataset),r.attach(y,d,o);var b=l({datasets:c});s.requestOnce("menu:state",function(t){return r.attachMenuStateRef(t)}),u({type:"SET_MENU",payload:{menu:b}}),u({type:"SET_DATASETS",payload:{mappedDatasets:y,orderedDatasets:d}}),e.init().then(function(){r.forEachDataset(function(t){if(t.hasDynamicGeoJSON){var r=function(t){var e,r,n,o=t.dynamicGeoJSON,a=t.mapProvider,i=t.onUpdate,u={features:new Map,fetchedBbox:null,currentController:null},s=function(){return $(u,{mapProvider:a,dynamicGeoJSON:o,onUpdate:i})},l=(e=s,n=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(function(){return e.apply(void 0,n)},200)},n.cancel=function(){clearTimeout(r),r=null},n),c=function(){l()};return a.map.on("moveend",c),s(),{destroy:function(){var t,e;t=a.map,e=c,(t.off||t.un).call(t,"moveend",e),l.cancel(),u.currentController&&u.currentController.abort()},clear:function(){u.features.clear(),u.fetchedBbox=null,i(o.id,{type:"FeatureCollection",features:[]})},refresh:function(){u.features.clear(),u.fetchedBbox=null,s()},getFeatureCount:function(){return u.features.size},reapply:function(){u.features.size>0&&i(o.id,Y(u.features))}}}({dynamicGeoJSON:t.dynamicGeoJSON,mapProvider:a,onUpdate:function(t,r){return e.setData(t,r)}});f.set(t.id,r)}}),e.attachDynamicSources(f),s.emit("datasets:ready")});var v=function(){e.onMapSizeChange()};s.on(i.MAP_SIZE_CHANGE,v);var m=s.emitWhenRequested("datasets:registry",r);return s.on("menu:changed",function(t){r.invalidateKeyItemsOnMenuStateChange(t),e.applyGlobalVisibility()}),{remove:function(){s.off(i.MAP_SIZE_CHANGE,v),m(),f.forEach(function(t){return t.destroy()}),f.clear(),e.destroy()},refreshDataset:function(t){var e;null===(e=f.get(t))||void 0===e||e.refresh()},clearDatasetCache:function(t){var e;null===(e=f.get(t))||void 0===e||e.clear()},getFeatureCount:function(t){var e,r;return null!==(e=null===(r=f.get(t))||void 0===r?void 0:r.getFeatureCount())&&void 0!==e?e:null}}};function X(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,l=Object.create(s.prototype);return Q(l,"_invoke",function(r,n,o){var a,u,s,l=0,c=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return a=e,u=0,s=t,p.n=r,i}};function y(r,n){for(u=r,s=n,e=0;!f&&l&&!o&&e<c.length;e++){var o,a=c[e],y=p.p,d=a[2];r>3?(o=d===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=t):a[0]<=y&&((o=r<2&&y<a[1])?(u=0,p.v=n,p.n=a[1]):y<d&&(o=r<3||a[0]>n||n>d)&&(a[4]=r,a[5]=n,p.n=d,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,c,d){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&y(c,d),u=c,s=d;(e=u<2?t:s)||!f;){a||(u?u<3?(u>1&&(p.n=-1),y(u,s)):p.n=s:p.v=s);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=t}else if((e=(f=p.n<0)?s:r.call(n,p))!==i)break}catch(e){a=t,u=1,s=e}finally{l=1}}return{value:e,done:f}}}(r,o,a),!0),l}var i={};function u(){}function s(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Q(e={},n,function(){return this}),e),f=l.prototype=u.prototype=Object.create(c);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Q(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return s.prototype=l,Q(f,"constructor",l),Q(l,"constructor",s),s.displayName="GeneratorFunction",Q(l,o,"GeneratorFunction"),Q(f),Q(f,o,"Generator"),Q(f,n,function(){return this}),Q(f,"toString",function(){return"[object Generator]"}),(X=function(){return{w:a,m:p}})()}function Q(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Q=function(t,e,r,n){function a(e,r){Q(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},Q(t,e,r,n)}function tt(t,e,r,n,o,a,i){try{var u=t[a](i),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}function et(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(t){tt(a,n,o,i,u,"next",t)}function u(t){tt(a,n,o,i,u,"throw",t)}i(void 0)})}}var rt=function(){var t=et(X().m(function t(e){var n,o,a,i,u,s,l;return X().w(function(t){for(;;)switch(t.n){case 0:l=e.name,t.n="MapLibreProvider"===l?1:"EsriProvider"===l?3:"OpenLayersProvider"===l?5:7;break;case 1:return t.n=2,r.e(563).then(r.bind(r,291));case 2:return n=t.v,o=n.default,t.a(2,o);case 3:return t.n=4,Promise.resolve().then(function(){var t=new Error("Cannot find module './esri/esriLayerAdapter.js'");throw t.code="MODULE_NOT_FOUND",t});case 4:return a=t.v,i=a.default,t.a(2,i);case 5:return t.n=6,r.e(809).then(r.bind(r,382));case 6:return u=t.v,s=u.default,t.a(2,s);case 7:throw new Error("No layer adapter available for map provider ".concat(e.name,". Please provide a compatible layer adapter."));case 8:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),nt=function(){var t=et(X().m(function t(e,r,n,o){var a;return X().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,rt(e);case 1:return a=t.v,t.a(2,new a(e,r,n,o))}},t)}));return function(e,r,n,o){return t.apply(this,arguments)}}(),ot=function(t){var e=t.pluginConfig,r=t.pluginState;return!1!==e.hasMenu&&(r.menuInitialised?r.menu.length>0:(e.datasets||[]).some(function(t){var e;return t.showInMenu||(null===(e=t.sublayers)||void 0===e?void 0:e.some(function(t){return t.showInMenu}))}))};function at(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,l=Object.create(s.prototype);return it(l,"_invoke",function(r,n,o){var a,u,s,l=0,c=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return a=e,u=0,s=t,p.n=r,i}};function y(r,n){for(u=r,s=n,e=0;!f&&l&&!o&&e<c.length;e++){var o,a=c[e],y=p.p,d=a[2];r>3?(o=d===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=t):a[0]<=y&&((o=r<2&&y<a[1])?(u=0,p.v=n,p.n=a[1]):y<d&&(o=r<3||a[0]>n||n>d)&&(a[4]=r,a[5]=n,p.n=d,u=0))}if(o||r>1)return i;throw f=!0,n}return function(o,c,d){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&y(c,d),u=c,s=d;(e=u<2?t:s)||!f;){a||(u?u<3?(u>1&&(p.n=-1),y(u,s)):p.n=s:p.v=s);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=t}else if((e=(f=p.n<0)?s:r.call(n,p))!==i)break}catch(e){a=t,u=1,s=e}finally{l=1}}return{value:e,done:f}}}(r,o,a),!0),l}var i={};function u(){}function s(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(it(e={},n,function(){return this}),e),f=l.prototype=u.prototype=Object.create(c);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,it(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return s.prototype=l,it(f,"constructor",l),it(l,"constructor",s),s.displayName="GeneratorFunction",it(l,o,"GeneratorFunction"),it(f),it(f,o,"Generator"),it(f,n,function(){return this}),it(f,"toString",function(){return"[object Generator]"}),(at=function(){return{w:a,m:p}})()}function it(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}it=function(t,e,r,n){function a(e,r){it(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},it(t,e,r,n)}function ut(t,e,r,n,o,a,i){try{var u=t[a](i),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}function st(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var lt="datasetsLayers";function ct(t){var e=t.appState,r=t.pluginConfig,n=t.pluginState,o=t.mapState,a=t.mapProvider,i=t.services,u=n.dispatch,s=n.datasetRegistry,l=i.eventBus,c=i.symbolRegistry,f=i.patternRegistry,p=Boolean(null==a?void 0:a.isBaseMapReady());!function(t){var e=t.appState,r=t.pluginConfig,n=t.pluginState,o=t.services.eventBus,a=ot({pluginConfig:r,pluginState:n}),i=Boolean(e.openPanels[lt]);(0,I.useEffect)(function(){!a&&i&&o.emit(T.APP_HIDE_PANEL,lt)},[a,i])}({appState:e,pluginConfig:r,pluginState:n,services:i});var y=(0,I.useRef)(n);y.current=n;var d=(0,I.useRef)(null),b=function(t){var e=null==a?void 0:a.datasets;t.length&&e&&(t.forEach(function(t){var r,n=t.method,o=t.parameters;return e[n].apply(e,function(t){if(Array.isArray(t))return st(t)}(r=o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return st(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?st(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}),u({type:"REMOVE_ADAPTER_ACTIONS",payload:t}))};return(0,I.useEffect)(function(){if(p&&!d.current){var t=function(){var t,e=(t=at().m(function t(){var e;return at().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,nt(a,c,f,s);case 1:e=t.v,d.current=q({adapter:e,datasetRegistry:s,pluginConfig:r,pluginStateRef:y,mapStyle:o.mapStyle,mapProvider:a,events:T,dispatch:u,eventBus:l}),a.datasets=e,b(y.current.actionsArray);case 2:return t.a(2)}},t)}),function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(t){ut(a,n,o,i,u,"next",t)}function u(t){ut(a,n,o,i,u,"throw",t)}i(void 0)})});return function(){return e.apply(this,arguments)}}();t()}},[p]),(0,I.useEffect)(function(){s.attach(n.mappedDatasets,n.orderedDatasets),l.emit("datasets:changed")},[n.mappedDatasets,n.orderedDatasets]),(0,I.useEffect)(function(){s.attachMapStyle(o.mapStyle);var t=null==a?void 0:a.datasets;null!=t&&t.onMapStyleChange&&Promise.resolve(t.onMapStyleChange()).then(function(){l.emit(T.MAP_DATA_CHANGE)})},[o.mapStyle]),(0,I.useEffect)(function(){return s.attachGlobals(n.globals)},[n.globals]),(0,I.useEffect)(function(){return b(n.actionsArray)},[n.actionsArray]),(0,I.useEffect)(function(){return function(){d.current&&(d.current.remove(),d.current=null,a.datasets=null)}},[]),null}var ft=function(t,e){var r=t.pluginState.dispatch,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.datasetId,a=n.sublayerId,i=a?"".concat(o,"-").concat(a):o;r(i?{type:"SET_DATASET_VISIBILITY",payload:{datasetId:i,visible:e}}:{type:"SET_GLOBAL_VISIBILITY",payload:{visible:e}})},pt=r(287),yt=function(t){var e=t.menuGroupItem,r=t.datasetRegistry,n=t.onChange,o=r.getDataset(e.id);if(!o)return null;var a=o.isSublayer?o.parentId:o.id,i=o.isSublayer?o.id:void 0,u="im-c-datasets-layers__item govuk-checkboxes govuk-checkboxes--small".concat(o.visible?"":" im-c-datasets-layers__item--checked");return(0,pt.jsx)("div",{className:u,"data-module":"govuk-checkboxes",children:(0,pt.jsxs)("div",{className:"govuk-checkboxes__item",children:[(0,pt.jsx)("input",{className:"govuk-checkboxes__input",id:o.id,"data-dataset-id":a,"data-sublayer-id":i,name:"layers",type:"checkbox",value:o.id,checked:o.isLocallyVisible,onChange:n}),(0,pt.jsx)("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:o.id,children:o.label})]})},o.id)},dt=function(t){var e=t.menuGroup,r=t.children;return e.groupLabel?(0,pt.jsx)("div",{className:"govuk-form-group im-c-datasets-layers-group",children:(0,pt.jsxs)("fieldset",{className:"im-c-datasets-layers-group__fieldset",children:[(0,pt.jsx)("legend",{className:"im-c-datasets-layers-group__legend",children:(0,pt.jsx)("h3",{children:e.groupLabel})}),r]})},e.id):(0,pt.jsx)(pt.Fragment,{children:r})},bt=function(t,e){(0,t.pluginState.dispatch)({type:"ADD_DATASET",payload:{dataset:e,mapStyle:t.mapState.mapStyle}})},vt=function(t,e){var r,n=t.pluginState.dispatch;null===(r=t.mapProvider.datasets)||void 0===r||r.removeDataset(e),n({type:"REMOVE_DATASET",payload:{id:e}})},ht=function(t,e,r){var n=t.pluginState,o=n.dispatch,a=n.datasetRegistry,i=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).datasetId,u=void 0===i?null:i;if(u){var s=a.getDataset(u);!s||s.idProperty||s.generateIds||m.v.warn('setFeatureVisibility: Dataset "'.concat(u,'" has no idProperty or generateIds configured. Features may not be matched correctly. Add idProperty to match by a feature property, or add generateIds: true to use auto-generated IDs.'))}o({type:e?"SHOW_FEATURES":"HIDE_FEATURES",payload:{datasetId:u,featureIds:r}})},mt=function(t,e){var r=t.pluginState.dispatch,n=t.mapState,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=o.datasetId,i=o.sublayerId;r({type:"SET_DATASET_STYLE",payload:{datasetId:a=i?"".concat(a,"-").concat(i):a,styleChanges:e,mapStyle:n.mapStyle}})},gt=function(t){var e=t.pluginState.datasetRegistry,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.datasetId,o=r.sublayerId;n=o?"".concat(n,"-").concat(o):n;var a=e.getDataset(n);return a?a.style:(m.v.warn("getStyle: Dataset with id ".concat(n," not found")),null)},St=function(t,e){var r=t.pluginState.dispatch,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.datasetId,a=n.sublayerId,i=a?"".concat(o,"-").concat(a):o;r(i?{type:"SET_OPACITY",payload:{datasetId:i,opacity:e}}:{type:"SET_GLOBAL_OPACITY",payload:{opacity:e}})},Ot=function(t){var e,r=t.pluginState,n=r.globals,o=r.datasetRegistry,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=a.datasetId,u=a.sublayerId,s=u?"".concat(i,"-").concat(u):i;if(s){var l,c=o.getDataset(s);return c?null!==(l=c.opacity)&&void 0!==l?l:null:(m.v.warn("getOpacity: Dataset with id ".concat(s," not found")),null)}return null!==(e=n.opacity)&&void 0!==e?e:null},Dt=function(t,e,r){var n,o=t.pluginState.datasetRegistry,a=t.mapProvider,i=r.datasetId,u=o.getDataset(i);u?null!=u&&u.tiles?m.v.warn('setData called on vector tile dataset "'.concat(i,'" — has no effect')):null===(n=a.datasets)||void 0===n||n.setData(i,e):m.v.warn("setData: Dataset with id ".concat(i," not found"))},Pt=function(t,e){var r=t.pluginState.dispatch,n=e.opacityMode,o={},a=!1;n&&(["dataset","global","multiply"].includes(n)?(a=!0,o.opacityMode=n):m.v.warn("Ignoring invalid opacityMode: ".concat(n,". Must be one of 'dataset', 'global' or 'multiply'."))),a?r({type:"SET_GLOBAL_STATE",payload:o}):m.v.warn("setGlobals: requires a valid value for opacityMode to be set")},_t=r(428);function At(t){return At="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},At(t)}function wt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Et(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function jt(t){var e=function(t){if("object"!=At(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=At(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==At(e)?e:e+""}var It=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.idToDefinitionMap=new Map,this.definitionToInstanceMap=new Map},(e=[{key:"add",value:function(t){this.idToDefinitionMap.set(t.id,t._datasetDefinition),this.definitionToInstanceMap.set(t._datasetDefinition,t)}},{key:"invalidateDataset",value:function(t){var e=this,r=this.idToDefinitionMap.get(t.id);[r.id].concat(function(t){return function(t){if(Array.isArray(t))return wt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return wt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?wt(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((null==r?void 0:r.sublayerIds)||[])).forEach(function(t){var r=e.idToDefinitionMap.get(t);e.definitionToInstanceMap.delete(r),e.idToDefinitionMap.delete(t)})}},{key:"invalidateChangedDatasets",value:function(t){var e=this;t.forEach(function(t){var r=e.idToDefinitionMap.get(t.id);if(r&&r!==t){var n=e.definitionToInstanceMap.get(r);e.invalidateDataset(n.isSublayer&&n.parent?n.parent:n)}})}},{key:"getByDefinition",value:function(t){return this.definitionToInstanceMap.get(t)}}])&&Et(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Tt(t){return Tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tt(t)}function kt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,u=[],s=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){l=!0,o=t}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Mt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Mt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ct=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,n=Object.entries(t);r<n.length;r++){var o=kt(n[r],2),a=o[0],i=o[1],u=e[a];if(!i.includes(u))return!1}return!0},Lt=function(t,e){return(Array.isArray(t)?t:[t]).includes(e)};function xt(t){return xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xt(t)}function Gt(t){return function(t){if(Array.isArray(t))return Ft(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ft(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ft(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Rt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Nt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Rt(Object(r),!0).forEach(function(e){Bt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Rt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Bt(t,e,r){return(e=function(t){var e=function(t){if("object"!=xt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=xt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Vt={attach:function(t,e,r){this._datasets=t,this._orderedDatasets=e,this.attachMapStyle(r),this._invalidateChangedDatasets()},_invalidateCache:function(){this._definitionCache=new It},_invalidateChangedDatasets:function(){this._datasets?this._definitionCache.invalidateChangedDatasets(Object.values(this._datasets)):this._invalidateCache()},attachCreateDataset:function(t){this._createDataset=t},_createDataset:function(t,e){return function(t,e){return new _t.j(t,e)}(t,e)},attachMapStyle:function(t){t&&(this._mapStyle=t)},get mapStyle(){return this._mapStyle},attachGlobals:function(t){t&&(this._globals=t)},get globals(){return this._globals},attachMenuStateRef:function(t){this._menuStateRef=t},isVisibleWhen:function(t){var e,r;return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.mapStyleId,n=e.menuState;if(null==t)return!0;if("boolean"==typeof t)return t;if("object"===Tt(t)){for(var o=0,a=Object.entries(t);o<a.length;o++){var i=kt(a[o],2),u=i[0],s=i[1];if("mapStyleId"===u&&!Lt(s,r))return!1;if("menu"===u&&!Ct(s,n))return!1}return!0}return!0}(t,{mapStyleId:null===(e=this._mapStyle)||void 0===e?void 0:e.id,menuState:null===(r=this._menuStateRef)||void 0===r||null===(r=r.current)||void 0===r?void 0:r.menuState})},get datasets(){return this._datasets},getDataset:function(t){var e=this.datasets[t];if(e){var r=this._definitionCache.getByDefinition(e);if(r)return r;var n=this._createDataset(e,this);return this._definitionCache.add(n),n.isSublayer&&this.getDataset(n.parentId),n}},forEach:function(t){var e=this;this._orderedDatasets.forEach(function(r){return t(e.getDataset(r))})},forEachDataset:function(t){var e=this;Object.values(this.datasets).filter(function(t){return!t.parentId}).forEach(function(r){return t(e.getDataset(r.id))})},topLevelDatasets:function(){var t=this;return Object.values(this.datasets).filter(function(t){return!t.parentId}).map(function(e){return t.getDataset(e.id)})},getPatternAndSymbolConfigs:function(){return this.topLevelDatasets().reduce(function(t,e){return Nt(Nt({},t),{},{patternConfigs:[].concat(Gt(t.patternConfigs),Gt(e.patternConfigs)),symbolConfigs:[].concat(Gt(t.symbolConfigs),Gt(e.symbolConfigs))})},{patternConfigs:[],symbolConfigs:[]})},invalidateKeyItemsOnMenuStateChange:function(t){t!==this._lastMenuState&&(this._lastMenuState=t,this._lastKeyItemsDatasets=null)},keyItems:function(){if(this.datasets===this._lastKeyItemsDatasets)return this._lastKeyItems;this._lastKeyItemsDatasets=this.datasets;var t=[],e=new Map;this.forEach(function(r){if(r.keyVisibility)if(r.hasSublayers||r.groupId||r.groupLabel){var n=r.groupId,o=function(r,n){if(e.has(n))return e.get(n);var o={type:"group",id:n,groupLabel:r,keyDefinitions:[]};return e.set(n,o),t.push(o),o}(r.groupLabel||n||r.label,n);r.hasSublayers||o.keyDefinitions.push(r.keyDefinition)}else t.push({type:"flat",id:r.id,keyDefinition:r.keyDefinition})});var r=t.filter(function(t){var e;return"flat"===t.type||Boolean(null===(e=t.keyDefinitions)||void 0===e?void 0:e.length)}),n=r.some(function(t){return"group"===t.type});return this._lastKeyItems={items:r,hasGroups:n},this._lastKeyItems}};function Ut(t){return Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ut(t)}function Wt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Ht(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Wt(Object(r),!0).forEach(function(e){Kt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Wt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Kt(t,e,r){return(e=function(t){var e=function(t){if("object"!=Ut(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ut(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ut(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Zt={id:"datasetsLayers",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:function(t){var e=t.pluginState,r=e.menu,n=void 0===r?[]:r,o=function(t){var r=t.target,n=r.value,o=r.checked;ft({pluginState:e},o,{datasetId:n})},a=n.some(function(t){return t.groupLabel}),i="im-c-datasets-layers".concat(a?" im-c-datasets-layers--has-groups":"");return(0,pt.jsx)("div",{className:i,children:n.map(function(t){return(0,pt.jsxs)(dt,{menuGroup:t,children:[" ",t.items.map(function(t){return(0,pt.jsx)(yt,{menuGroupItem:t,datasetRegistry:e.datasetRegistry,onChange:o},t.id)})]},t.id)})})}},Yt={id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",excludeWhen:function(t){return!ot(t)},iconId:"layers",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}},zt=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).hasMenu;return{InitComponent:ct,reducer:{initialState:Ht(Ht({},A),{},{datasetRegistry:Object.assign(Object.create(Vt),{_definitionCache:new It,_globals:{},_menuStateRef:{},_lastMenuState:{},_lastKeyItems:{}})}),actions:j},panels:!1===t?[]:[Zt],buttons:!1===t?[]:[Yt],icons:[{id:"layers",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addDataset:bt,removeDataset:vt,setDatasetVisibility:ft,setFeatureVisibility:ht,setStyle:mt,getStyle:gt,setOpacity:St,getOpacity:Ot,setData:Dt,setGlobals:Pt}}}},428:function(t,e,r){r.d(e,{j:function(){return S}});var n=r(852),o=(new Set,new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),function(t){return!!(null!=t&&t.symbol||null!=t&&t.symbolSvgContent)});function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function u(t,e,r){return(e=c(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function l(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t){var e=function(t){if("object"!=a(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==a(e)?e:e+""}var f=l(function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.id=e.id,this.url=e.url,this.transformRequest=e.transformRequest,this.maxFeatures=e.maxFeatures,this.minZoom=e.minZoom,this.idProperty=e.idProperty,this.hiddenFeaturesIdExpression=["to-string",["get",this.idProperty]],this.sourceId="geojson-dynamic-".concat(this.id),this.source=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach(function(e){u(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({type:"geojson",data:{type:"FeatureCollection",features:[]}},this.idProperty?{promoteId:this.idProperty}:{generateId:!0})});function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function y(t){return function(t){if(Array.isArray(t))return d(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return d(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function v(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach(function(e){h(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function h(t,e,r){return(e=g(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,g(n.key),n)}}function g(t){var e=function(t){if("object"!=p(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==p(e)?e:e+""}var S=function(){return t=function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._datasetDefinition=e,this._datasetRegistry=r},(e=[{key:"id",get:function(){return this._datasetDefinition.id}},{key:"label",get:function(){return this._datasetDefinition.label}},{key:"hasSymbol",get:function(){return!this.hasSublayers&&o(this.style)}},{key:"hasPattern",get:function(){return!(this.hasSublayers||this.hasSymbol||(t=this.style,!t.fillPattern&&!t.fillPatternSvgContent));var t}},{key:"hasFill",get:function(){var t,e;return!this.hasSublayers&&!this.hasSymbol&&(this.hasPattern||(null===(t=this.style)||void 0===t?void 0:t.fill)&&"transparent"!==(null===(e=this.style)||void 0===e?void 0:e.fill))}},{key:"hasStroke",get:function(){var t;return!this.hasSublayers&&!this.hasSymbol&&Boolean(null===(t=this.style)||void 0===t?void 0:t.stroke)}},{key:"tiles",get:function(){return this._datasetDefinition.tiles}},{key:"geojson",get:function(){return this._datasetDefinition.geojson}},{key:"idProperty",get:function(){return this._datasetDefinition.idProperty}},{key:"generateIds",get:function(){return this._datasetDefinition.generateIds}},{key:"parentId",get:function(){return this._datasetDefinition.parentId}},{key:"minZoom",get:function(){var t;return this._datasetDefinition.minZoom||(null===(t=this.parent)||void 0===t?void 0:t.minZoom)}},{key:"maxZoom",get:function(){var t;return this._datasetDefinition.maxZoom||(null===(t=this.parent)||void 0===t?void 0:t.maxZoom)}},{key:"type",get:function(){var t;return this._datasetDefinition.type||(null===(t=this.parent)||void 0===t?void 0:t.type)}},{key:"showInKey",get:function(){var t,e,r=this._datasetDefinition.showInKey;return void 0!==r?r:null!==(t=null===(e=this.parent)||void 0===e?void 0:e.showInKey)&&void 0!==t&&t}},{key:"visibleWhen",get:function(){var t;return void 0===this._datasetDefinition.visibleWhen?null===(t=this.parent)||void 0===t?void 0:t.visibleWhen:this._datasetDefinition.visibleWhen}},{key:"groupLabel",get:function(){var t,e;return this._datasetDefinition.groupLabel||(null===(t=this.parent)||void 0===t?void 0:t.groupLabel)||(null===(e=this.parent)||void 0===e?void 0:e.label)}},{key:"groupId",get:function(){var t;return this._datasetDefinition.groupId||(null===(t=this.parent)||void 0===t?void 0:t.groupId)||(this.groupLabel?this.groupLabel.toLowerCase().replace(/\s+/g,"-"):null)}},{key:"opacity",get:function(){var t,e,r=null===(t=this.style)||void 0===t?void 0:t.opacity,n=null===(e=this.parent)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.opacity;return function(t,e,r){switch(t.opacityMode){case"global":return t.opacity;case"multiply":return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Math.round(100*(e*r*t.opacity+Number.EPSILON))/100}(t,e,r);default:return function(t,e,r){return void 0===e?void 0===r?t.opacity:r:e}(t,e,r)}}(this._datasetRegistry.globals,r,n)}},{key:"hasDynamicGeoJSON",get:function(){return Boolean(this._datasetDefinition.dynamicGeoJSON)}},{key:"dynamicGeoJSON",get:function(){return new f(v(v({},this._datasetDefinition.dynamicGeoJSON),{},{id:this.id,minZoom:this.minZoom}))}},{key:"hiddenFeatures",get:function(){return this._datasetDefinition.hiddenFeatures}},{key:"hasHiddenFeatures",get:function(){var t,e;return Boolean((null===(t=this.hiddenFeatures)||void 0===t?void 0:t.length)>0||(null===(e=this.parent)||void 0===e?void 0:e.hasHiddenFeatures))}},{key:"filter",get:function(){return null}},{key:"isHiddenByInheritance",get:function(){var t;return this.isSublayer?!(null!==(t=this.parent)&&void 0!==t&&t.visible):!this._datasetRegistry.globals.visible}},{key:"isLocallyVisible",get:function(){return!!this.isVisible||this._datasetDefinition.visible}},{key:"visible",get:function(){var t;return this.isSublayer?this._datasetDefinition.visible&&(null===(t=this.parent)||void 0===t?void 0:t.visible):this._datasetDefinition.visible&&this._datasetRegistry.globals.visible}},{key:"esriStyleLayerId",get:function(){return this._datasetDefinition.esriStyleLayerId}},{key:"visibility",get:function(){var t=this.visible,e=this.visibleWhen;return t&&e?this._datasetRegistry.isVisibleWhen(e)?"visible":"none":t?"visible":"none"}},{key:"keyVisibility",get:function(){return this.showInKey&&"visible"===this.visibility}},{key:"symbolAnchor",get:function(){var t,e;return null!==(t=this.style)&&void 0!==t&&t.symbolAnchor?this.style.symbolAnchor:null===(e=this.parent)||void 0===e?void 0:e.symbolAnchor}},{key:"sourceLayer",get:function(){return this.isSublayer?this.parent.sourceLayer:this.tiles?this._datasetDefinition.sourceLayer:void 0}},{key:"isSublayer",get:function(){return Boolean(this._datasetDefinition.parentId)}},{key:"hasSublayers",get:function(){var t;return(null===(t=this._datasetDefinition.sublayerIds)||void 0===t?void 0:t.length)>0}},{key:"sublayerIds",get:function(){return this._datasetDefinition.sublayerIds}},{key:"sublayers",get:function(){var t=this,e=this.sublayerIds;return e?e.map(function(e){return t._datasetRegistry.getDataset(e)}):[]}},{key:"parent",get:function(){if(this._datasetDefinition.parentId)return this._datasetRegistry.getDataset(this._datasetDefinition.parentId)}},{key:"inheritedStyle",get:function(){var t=this._datasetDefinition.style||{},e=this.parent;return e?v(v({},e.inheritedStyle),{},{opacity:void 0},t):t}},{key:"style",get:function(){return v(v({},(0,n.Eg)(this.inheritedStyle)),{},{symbolDescription:this.symbolDescription})}},{key:"hasCustomVisualStyle",get:function(){return(0,n.p_)(this._datasetDefinition.style||{})}},{key:"symbolDescription",get:function(){var t;return null!==(t=this._datasetDefinition.style)&&void 0!==t&&t.symbolDescription?this._datasetDefinition.style.symbolDescription:this.hasCustomVisualStyle?void 0:this.parent?this.parent.symbolDescription:n.V.style.symbolDescription}},{key:"patternConfigs",get:function(){var t=this.hasPattern?[this.style]:[];return this.hasSublayers?[].concat(t,y(this.sublayers.flatMap(function(t){return t.patternConfigs}))):t}},{key:"symbolConfigs",get:function(){var t=this.hasSymbol?[this.style]:[];return this.hasSublayers?[].concat(t,y(this.sublayers.flatMap(function(t){return t.symbolConfigs}))):t}},{key:"keyDefinition",get:function(){return{id:this.id,type:"dataset",label:this.label,hasSymbol:this.hasSymbol,hasPattern:this.hasPattern,style:this.style,symbolDescription:this.symbolDescription}}}])&&m(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()},619:function(t,e,r){r.d(e,{v:function(){return o}});var n="[interactive-map]",o={warn:function(){for(var t,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return(t=console).warn.apply(t,[n].concat(r))},error:function(){for(var t,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return(t=console).error.apply(t,[n].concat(r))}}}}]);
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("defra",[],e):"object"==typeof exports?exports.defra=e():(t.defra=t.defra||{},t.defra.datasetsPlugin=e())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var t,e,r={738:function(t){t.exports=preactCompat},287:function(t){t.exports=preactJsxRuntime}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t](i,i.exports,o),i.exports}o.m=r,o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=function(t){return Promise.all(Object.keys(o.f).reduce(function(e,r){return o.f[r](t,e),e},[]))},o.u=function(t){return{447:"im-datasets-plugin",563:"im-datasets-ml-adapter",809:"im-datasets-ol-adapter"}[t]+".js"},o.miniCssF=function(t){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t={},e="defra.datasetsPlugin:",o.l=function(r,n,i,u){if(t[r])t[r].push(n);else{var a,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var s=f[p];if(s.getAttribute("src")==r||s.getAttribute("data-webpack")==e+i){a=s;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",e+i),a.src=r),t[r]=[n];var l=function(e,n){a.onerror=a.onload=null,clearTimeout(d);var o=t[r];if(delete t[r],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach(function(t){return t(n)}),e)return e(n)},d=setTimeout(l.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=l.bind(null,a.onerror),a.onload=l.bind(null,a.onload),c&&document.head.appendChild(a)}},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t}(),function(){var t={57:0};o.f.j=function(e,r){var n=o.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=t[e]=[r,o]});r.push(n[2]=i);var u=o.p+o.u(e),a=new Error;o.l(u,function(r){if(o.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+u+")",a.name="ChunkLoadError",a.type=i,a.request=u,n[1](a)}},"chunk-"+e,e)}};var e=function(e,r){var n,i,u=r[0],a=r[1],c=r[2],f=0;if(u.some(function(e){return 0!==t[e]})){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);c&&c(o)}for(e&&e(r);f<u.length;f++)i=u[f],o.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))}();var i={};function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function a(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var a=n&&n.prototype instanceof f?n:f,p=Object.create(a.prototype);return c(p,"_invoke",function(r,n,o){var i,a,c,f=0,p=o||[],s=!1,l={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,a=0,c=t,l.n=r,u}};function d(r,n){for(a=r,c=n,e=0;!s&&f&&!o&&e<p.length;e++){var o,i=p[e],d=l.p,b=i[2];r>3?(o=b===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(a=0,l.v=n,l.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,l.n=b,a=0))}if(o||r>1)return u;throw s=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(s&&1===p&&d(p,b),a=p,c=b;(e=a<2?t:c)||!s;){i||(a?a<3?(a>1&&(l.n=-1),d(a,c)):l.n=c:l.v=c);try{if(f=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(s=l.n<0)?c:r.call(n,l))!==u)break}catch(e){i=t,a=1,c=e}finally{f=1}}return{value:e,done:s}}}(r,o,i),!0),p}var u={};function f(){}function p(){}function s(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(c(e={},n,function(){return this}),e),d=s.prototype=f.prototype=Object.create(l);function b(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,c(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t}return p.prototype=s,c(d,"constructor",s),c(s,"constructor",p),p.displayName="GeneratorFunction",c(s,o,"GeneratorFunction"),c(d),c(d,o,"Generator"),c(d,n,function(){return this}),c(d,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:b}})()}function c(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}c=function(t,e,r,n){function i(e,r){c(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},c(t,e,r,n)}function f(t,e,r,n,o,i,u){try{var a=t[i](u),c=a.value}catch(t){return void r(t)}a.done?e(c):Promise.resolve(c).then(n,o)}function p(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?p(Object(r),!0).forEach(function(e){l(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function l(t,e,r){return(e=function(t){var e=function(t){if("object"!=u(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==u(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function d(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=s(s({noKeyItemText:"No features displayed"},r),{},{id:"datasets",load:(t=a().m(function t(){var e,n;return a().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o.e(447).then(o.bind(o,313));case 1:return e=t.v,n=e.createManifest,t.a(2,n(r))}},t)}),e=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function u(t){f(i,n,o,u,a,"next",t)}function a(t){f(i,n,o,u,a,"throw",t)}u(void 0)})},function(){return e.apply(this,arguments)})});return n}return o.d(i,{default:function(){return d}}),i.default}()});
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("defra",[],e):"object"==typeof exports?exports.defra=e():(t.defra=t.defra||{},t.defra.datasetsPlugin=e())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var t,e,r={738:function(t){t.exports=preactCompat},287:function(t){t.exports=preactJsxRuntime}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t](i,i.exports,o),i.exports}o.m=r,o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=function(t){return Promise.all(Object.keys(o.f).reduce(function(e,r){return o.f[r](t,e),e},[]))},o.u=function(t){return{447:"im-datasets-plugin",563:"im-datasets-ml-adapter",809:"im-datasets-ol-adapter"}[t]+".js"},o.miniCssF=function(t){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t={},e="defra.datasetsPlugin:",o.l=function(r,n,i,u){if(t[r])t[r].push(n);else{var a,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var s=f[p];if(s.getAttribute("src")==r||s.getAttribute("data-webpack")==e+i){a=s;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",e+i),a.src=r),t[r]=[n];var l=function(e,n){a.onerror=a.onload=null,clearTimeout(d);var o=t[r];if(delete t[r],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach(function(t){return t(n)}),e)return e(n)},d=setTimeout(l.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=l.bind(null,a.onerror),a.onload=l.bind(null,a.onload),c&&document.head.appendChild(a)}},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t}(),function(){var t={57:0};o.f.j=function(e,r){var n=o.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=t[e]=[r,o]});r.push(n[2]=i);var u=o.p+o.u(e),a=new Error;o.l(u,function(r){if(o.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+u+")",a.name="ChunkLoadError",a.type=i,a.request=u,n[1](a)}},"chunk-"+e,e)}};var e=function(e,r){var n,i,u=r[0],a=r[1],c=r[2],f=0;if(u.some(function(e){return 0!==t[e]})){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);c&&c(o)}for(e&&e(r);f<u.length;f++)i=u[f],o.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))}();var i={};function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function a(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var a=n&&n.prototype instanceof f?n:f,p=Object.create(a.prototype);return c(p,"_invoke",function(r,n,o){var i,a,c,f=0,p=o||[],s=!1,l={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,a=0,c=t,l.n=r,u}};function d(r,n){for(a=r,c=n,e=0;!s&&f&&!o&&e<p.length;e++){var o,i=p[e],d=l.p,b=i[2];r>3?(o=b===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(a=0,l.v=n,l.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,l.n=b,a=0))}if(o||r>1)return u;throw s=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(s&&1===p&&d(p,b),a=p,c=b;(e=a<2?t:c)||!s;){i||(a?a<3?(a>1&&(l.n=-1),d(a,c)):l.n=c:l.v=c);try{if(f=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(s=l.n<0)?c:r.call(n,l))!==u)break}catch(e){i=t,a=1,c=e}finally{f=1}}return{value:e,done:s}}}(r,o,i),!0),p}var u={};function f(){}function p(){}function s(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(c(e={},n,function(){return this}),e),d=s.prototype=f.prototype=Object.create(l);function b(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,c(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t}return p.prototype=s,c(d,"constructor",s),c(s,"constructor",p),p.displayName="GeneratorFunction",c(s,o,"GeneratorFunction"),c(d),c(d,o,"Generator"),c(d,n,function(){return this}),c(d,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:b}})()}function c(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}c=function(t,e,r,n){function i(e,r){c(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},c(t,e,r,n)}function f(t,e,r,n,o,i,u){try{var a=t[i](u),c=a.value}catch(t){return void r(t)}a.done?e(c):Promise.resolve(c).then(n,o)}function p(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?p(Object(r),!0).forEach(function(e){l(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function l(t,e,r){return(e=function(t){var e=function(t){if("object"!=u(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==u(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function d(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=s(s({noKeyItemText:"No features displayed"},r),{},{id:"datasets",load:(t=a().m(function t(){var e,n;return a().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o.e(447).then(o.bind(o,634));case 1:return e=t.v,n=e.createManifest,t.a(2,n(r))}},t)}),e=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function u(t){f(i,n,o,u,a,"next",t)}function a(t){f(i,n,o,u,a,"throw",t)}u(void 0)})},function(){return e.apply(this,arguments)})});return n}return o.d(i,{default:function(){return d}}),i.default}()});
@@ -4,39 +4,28 @@ import { EVENTS } from '../../../../src/config/events.js'
4
4
  import { initialiseDatasets } from './initialiseDatasets.js'
5
5
  import { loadLayerAdapter } from '../adapters/loadLayerAdapter.js'
6
6
  import { hasLayersMenu } from '../utils/hasLayersMenu.js'
7
- import { getPanelElementId } from '../../../../src/utils/getPanelElementId.js'
8
7
 
9
8
  const LAYERS_PANEL_ID = 'datasetsLayers'
10
9
 
11
10
  // Closes the Layers panel if its menu empties while it's open
12
- function useCloseEmptyLayersPanel ({ appConfig, appState, pluginConfig, pluginState, services }) {
13
- const { eventBus, focusMap } = services
11
+ function useCloseEmptyLayersPanel ({ appState, pluginConfig, pluginState, services }) {
12
+ const { eventBus } = services
14
13
  const hasMenu = hasLayersMenu({ pluginConfig, pluginState })
15
14
  const isLayersPanelOpen = Boolean(appState.openPanels[LAYERS_PANEL_ID])
16
- const focusFrameRef = useRef(null)
17
15
 
18
16
  useEffect(() => {
19
- if (hasMenu || !isLayersPanelOpen) {
20
- return
21
- }
22
- const panelEl = document.getElementById(getPanelElementId(appConfig.id, LAYERS_PANEL_ID))
23
- const hadFocus = Boolean(panelEl?.contains(document.activeElement))
24
- eventBus.emit(EVENTS.APP_HIDE_PANEL, LAYERS_PANEL_ID)
25
- if (hadFocus) {
26
- // Let the panel close and release modal focus/inert first, as Panel's handleClose does
27
- focusFrameRef.current = requestAnimationFrame(() => focusMap())
17
+ if (!hasMenu && isLayersPanelOpen) {
18
+ eventBus.emit(EVENTS.APP_HIDE_PANEL, LAYERS_PANEL_ID)
28
19
  }
29
20
  }, [hasMenu, isLayersPanelOpen])
30
-
31
- useEffect(() => () => cancelAnimationFrame(focusFrameRef.current), [])
32
21
  }
33
22
 
34
- export function DatasetsInit ({ appConfig, appState, pluginConfig, pluginState, mapState, mapProvider, services }) {
23
+ export function DatasetsInit ({ appState, pluginConfig, pluginState, mapState, mapProvider, services }) {
35
24
  const { dispatch, datasetRegistry } = pluginState
36
25
  const { eventBus, symbolRegistry, patternRegistry } = services
37
26
  const isBaseMapReady = Boolean(mapProvider?.isBaseMapReady())
38
27
 
39
- useCloseEmptyLayersPanel({ appConfig, appState, pluginConfig, pluginState, services })
28
+ useCloseEmptyLayersPanel({ appState, pluginConfig, pluginState, services })
40
29
 
41
30
  // Keep a ref to the latest pluginState so event handlers can access current data
42
31
  const pluginStateRef = useRef(pluginState)