@opengeoweb/sigmet-airmet 5.2.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { createContext, version, useContext, useRef, useCallback, useDebugValue, forwardRef, createElement, Fragment } from 'react';
3
- import { Box as Box$2, Button, FormControlLabel, Radio, Grid, Typography, Checkbox, MenuItem, FormHelperText, useTheme as useTheme$2, Dialog, DialogTitle, DialogContent, Card, LinearProgress, List, ListItemButton, Backdrop, CircularProgress } from '@mui/material';
3
+ import { FormControlLabel, Radio, Grid, Typography, Box as Box$2, Button, Checkbox, MenuItem, FormHelperText, useTheme as useTheme$2, Dialog, DialogTitle, DialogContent, Card, LinearProgress, List, ListItemButton, Backdrop, CircularProgress } from '@mui/material';
4
4
  import { useFormContext } from 'react-hook-form';
5
5
  import { useDraftFormHelpers, ReactHookFormRadioGroup, ReactHookFormSelect, ReactHookFormNumberField, isInteger, isValidMax, isValidMin, isEmpty, ReactHookFormDateTime, isValidDate, isBefore, isBetween, hasMaxFeaturePoints, hasMulitpleIntersections, ReactHookFormHiddenInput, isMaximumOneDrawing, hasIntersectionWithFIR, isValidGeoJsonCoordinates, isXHoursBefore, isAfter, isXHoursAfter, ReactHookFormTextField, isLatitude, isNonOrBothCoordinates, isLongitude, ReactHookFormFormControl, isGeometryDirty, ReactHookFormProvider, defaultFormOptions } from '@opengeoweb/form-fields';
6
6
  import { useApiContext, useApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider } from '@opengeoweb/api';
7
- import * as turf from '@turf/turf';
8
- import { polygonToLineString, booleanClockwise, rewind } from '@turf/turf';
7
+ import { defaultStyleProperties, defaultIntersectionStyleProperties, defaultPoint, defaultBox, defaultPolygon, DRAWMODE, addFeatureProperties, defaultDelete, MapControls, LayerManagerMapButtonConnect, LegendMapButtonConnect, MultiDimensionSelectMapButtonsConnect, MapViewConnect, MapViewLayer, TimeSliderConnect, LegendConnect, LayerManagerConnect, useMapDrawTool } from '@opengeoweb/core';
8
+ import { CustomTooltip, ToggleMenu, useIsMounted, StatusTag, AlertBanner, ConfirmationServiceProvider, usePreventBrowserClose, useConfirmationDialog, isAxiosError, getAxiosErrorMessage, usePoller, ErrorBoundary } from '@opengeoweb/shared';
9
9
  import moment from 'moment';
10
- import { ToggleMenu, CustomTooltip, useIsMounted, StatusTag, AlertBanner, ConfirmationServiceProvider, usePreventBrowserClose, useConfirmationDialog, isAxiosError, getAxiosErrorMessage, usePoller, ErrorBoundary } from '@opengeoweb/shared';
11
- import { layerTypes, mapSelectors, generateMapId, generateTimesliderId, SyncGroups, generateLayerId, mapActions, publicLayers, MapControls, LayerManagerMapButtonConnect, LegendMapButtonConnect, MultiDimensionSelectMapButtonsConnect, MapViewConnect, MapViewLayer, TimeSliderConnect, LegendConnect, LayerManagerConnect } from '@opengeoweb/core';
12
- import { Location, DrawRegion, DrawPolygon, DrawFIRLand, Delete, ChevronLeft, Edit, Success, Clock } from '@opengeoweb/theme';
10
+ import { polygonToLineString, booleanClockwise, rewind } from '@turf/turf';
11
+ import { layerTypes, mapSelectors, mapStoreUtils, syncGroupsActions, mapStoreActions, defaultLayers, syncConstants } from '@opengeoweb/store';
12
+ import { DrawFIRLand, ChevronLeft, Edit, Success, Clock } from '@opengeoweb/theme';
13
13
  import { debounce } from 'lodash';
14
14
  import 'react-dom';
15
15
  import { jsx } from 'react/jsx-runtime';
@@ -414,8 +414,6 @@ function _toPropertyKey(arg) {
414
414
  return typeof key === "symbol" ? key : String(key);
415
415
  }
416
416
 
417
- function n$5(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r$5(n){return !!n&&!!n[Q]}function t$5(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v$4(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v$4(n)?3:0}function u$3(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f$3(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c$3(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v$4(n){return q$5&&n instanceof Set}function p$5(n){return n.o||n.t}function l$4(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d$3(n,e){return void 0===e&&(e=!1),y$2(n)||r$5(n)||!t$5(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h$5),Object.freeze(n),e&&i(n,(function(n,r){return d$3(r,!0)}),!0)),n}function h$5(){n$5(2);}function y$2(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b$3(r){var t=tn[r];return t||n$5(18,r),t}function _(){return "production"===process.env.NODE_ENV||U||n$5(0),U}function j(n,r){r&&(b$3("Patches"),n.u=[],n.s=[],n.v=r);}function g$3(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w$3(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b$3("ES5").S(e,r,o),o?(i[Q].P&&(g$3(e),n$5(4)),t$5(r)&&(r=M(e,r),e.l||x$2(e,r)),e.u&&b$3("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g$3(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y$2(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A$2(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x$2(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l$4(e.k):e.o,u=o,a=!1;3===e.i&&(u=new Set(o),o.clear(),a=!0),i(u,(function(r,i){return A$2(n,e,o,r,i,t,a)})),x$2(n,o,!1),t&&n.u&&b$3("Patches").N(e,t,n.u,n.s);}return e.o}function A$2(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n$5(5),r$5(c)){var p=M(e,c,s&&i&&3!==i.i&&!u$3(i.R,a)?s.concat(a):void 0);if(f$3(o,a,p),!r$5(p))return;e.m=!1;}else v&&o.add(c);if(t$5(c)&&!y$2(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x$2(e,c);}}function x$2(n,r,t){void 0===t&&(t=!1),!n.l&&n.h.D&&n.m&&d$3(r,t);}function z$2(n,r){var t=n[Q];return (t?p$5(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k$4(n){n.P||(n.P=!0,n.l&&k$4(n.l));}function E(n){n.o||(n.o=l$4(n.t));}function N(n,r,t){var e=s(r)?b$3("MapSet").F(r,t):v$4(r)?b$3("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b$3("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r$5(e)||n$5(22,e),function n(r){if(!t$5(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b$3("ES5").K(u)))return u.t;u.I=!0,e=D(r,c),u.I=!1;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f$3(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l$4(n)}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q$5="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p$5(n);if(!u$3(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t$5(i)?i:i===z$2(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p$5(n)},ownKeys:function(n){return Reflect.ownKeys(p$5(n))},set:function(n,r,t){var e=I(p$5(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z$2(p$5(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=!1,!0;if(c$3(t,i)&&(void 0!==t||u$3(n.t,r)))return !0;E(n),k$4(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=!0),!0},deleteProperty:function(n,r){return void 0!==z$2(n.t,r)||r in n.t?(n.R[r]=!1,E(n),k$4(n)):delete n.R[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p$5(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n$5(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n$5(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n$5(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n$5(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n$5(6),void 0!==o&&"function"!=typeof o&&n$5(7),t$5(r)){var c=w$3(e),s=N(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?g$3(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g$3(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d$3(f,!0),o){var p=[],l=[];b$3("Patches").M(r,f,p,l),o(p,l);}return f}n$5(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t$5(e)||n$5(8),r$5(e)&&(e=R(e));var i=w$3(this),o=N(this,e,void 0);return o[Q].C=!0,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n$5(9),e.I&&n$5(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n$5(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b$3("Patches").$;return r$5(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);
418
-
419
417
  /**
420
418
  * The possible phenomena for the sigmet
421
419
  */
@@ -551,224 +549,384 @@ var isInstanceOfSigmetOrAirmet = function isInstanceOfSigmetOrAirmet(obj) {
551
549
  var isInstanceOfCancelSigmetOrAirmet = function isInstanceOfCancelSigmetOrAirmet(obj) {
552
550
  return 'cancelsSigmetSequenceId' in obj || 'cancelsAirmetSequenceId' in obj;
553
551
  };
554
- var MapDrawMode;
555
- (function (MapDrawMode) {
556
- MapDrawMode["POINT"] = "POINT";
557
- MapDrawMode["BOX"] = "BOX";
558
- MapDrawMode["POLYGON"] = "POLYGON";
559
- MapDrawMode["FIR"] = "FIR";
560
- MapDrawMode["DELETE"] = "DELETE";
561
- })(MapDrawMode || (MapDrawMode = {}));
562
552
  var StartOrEndDrawing;
563
553
  (function (StartOrEndDrawing) {
564
554
  StartOrEndDrawing["start"] = "start";
565
555
  StartOrEndDrawing["end"] = "end";
566
556
  })(StartOrEndDrawing || (StartOrEndDrawing = {}));
567
557
 
568
- var srsAndBboxDefault = {
569
- bbox: {
570
- left: -911501,
571
- right: 3738819,
572
- top: 11688874,
573
- bottom: 5930186
558
+ /* *
559
+ * Licensed under the Apache License, Version 2.0 (the "License");
560
+ * you may not use this file except in compliance with the License.
561
+ * You may obtain a copy of the License at
562
+ *
563
+ * http://www.apache.org/licenses/LICENSE-2.0
564
+ *
565
+ * Unless required by applicable law or agreed to in writing, software
566
+ * distributed under the License is distributed on an "AS IS" BASIS,
567
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
568
+ * See the License for the specific language governing permissions and
569
+ * limitations under the License.
570
+ *
571
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
572
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
573
+ * */
574
+ var styles$2 = {
575
+ label: {
576
+ fontSize: '0.875rem',
577
+ marginTop: 2,
578
+ textAlign: 'right'
574
579
  },
575
- srs: 'EPSG:3857'
576
- };
577
- var featurePropsStart = {
578
- stroke: '#f24a00',
579
- 'stroke-width': 1.5,
580
- 'stroke-opacity': 1,
581
- fill: '#f24a00',
582
- 'fill-opacity': 0.25
583
- };
584
- var featurePropsEnd = {
585
- stroke: '#6e1e91',
586
- 'stroke-width': 1.5,
587
- 'stroke-opacity': 1,
588
- fill: '#6e1e91',
589
- 'fill-opacity': 0.25
590
- };
591
- var featurePropsIntersectionStart = {
592
- stroke: '#f24a00',
593
- 'stroke-width': 1.5,
594
- 'stroke-opacity': 1,
595
- fill: '#f24a00',
596
- 'fill-opacity': 0.5
597
- };
598
- var featurePropsIntersectionEnd = {
599
- stroke: '#6e1e91',
600
- 'stroke-width': 1.5,
601
- 'stroke-opacity': 1,
602
- fill: '#6e1e91',
603
- 'fill-opacity': 0.5
604
- };
605
- var featurePropsFIR = {
606
- stroke: '#0075a9',
607
- 'stroke-width': 1.5,
608
- 'stroke-opacity': 1,
609
- fill: '#0075a9',
610
- 'fill-opacity': 0.0
611
- };
612
- var featurePropsUnStyled = {
613
- stroke: '#FF0000',
614
- 'stroke-width': 10.0,
615
- 'stroke-opacity': 1,
616
- fill: '#0000FF',
617
- 'fill-opacity': 1.0
618
- };
619
- var emptyPolygonGeoJSONStart = {
620
- type: 'FeatureCollection',
621
- features: [{
622
- type: 'Feature',
623
- properties: Object.assign(Object.assign({}, featurePropsUnStyled), {
624
- selectionType: 'poly'
625
- }),
626
- geometry: {
627
- type: 'Polygon',
628
- coordinates: [[]]
629
- }
630
- }]
631
- };
632
- var emptyPolygonGeoJSONEnd = {
633
- type: 'FeatureCollection',
634
- features: [{
635
- type: 'Feature',
636
- properties: Object.assign(Object.assign({}, featurePropsUnStyled), {
637
- selectionType: 'poly'
638
- }),
639
- geometry: {
640
- type: 'Polygon',
641
- coordinates: [[]]
642
- }
643
- }]
644
- };
645
- var emptyBoxGeoJSONStart = {
646
- type: 'FeatureCollection',
647
- features: [{
648
- type: 'Feature',
649
- properties: Object.assign({
650
- _adaguctype: 'box',
651
- selectionType: 'box'
652
- }, featurePropsUnStyled),
653
- geometry: {
654
- type: 'Polygon',
655
- coordinates: [[]]
656
- }
657
- }]
658
- };
659
- var emptyBoxGeoJSONEnd = {
660
- type: 'FeatureCollection',
661
- features: [{
662
- type: 'Feature',
663
- properties: Object.assign({
664
- _adaguctype: 'box',
665
- selectionType: 'box'
666
- }, featurePropsUnStyled),
667
- geometry: {
668
- type: 'Polygon',
669
- coordinates: [[]]
670
- }
671
- }]
672
- };
673
- var emptyPointsGeojsonStart = {
674
- type: 'FeatureCollection',
675
- features: [{
676
- type: 'Feature',
677
- properties: Object.assign(Object.assign({}, featurePropsUnStyled), {
678
- selectionType: 'point'
679
- }),
680
- geometry: {
681
- type: 'Point',
682
- coordinates: []
683
- }
684
- }]
685
- };
686
- var emptyPointsGeojsonEnd = {
687
- type: 'FeatureCollection',
688
- features: [{
689
- type: 'Feature',
690
- properties: Object.assign(Object.assign({}, featurePropsUnStyled), {
691
- selectionType: 'point'
692
- }),
693
- geometry: {
694
- type: 'Point',
695
- coordinates: []
580
+ body: {
581
+ paddingTop: '17px'
582
+ },
583
+ containerItem: {
584
+ ' .MuiTypography-subtitle1': {
585
+ marginTop: 1
696
586
  }
697
- }]
698
- };
699
- var geoJSONTemplate = {
700
- POINT: {
701
- start: emptyPointsGeojsonStart,
702
- end: emptyPointsGeojsonEnd
703
587
  },
704
- BOX: {
705
- start: emptyBoxGeoJSONStart,
706
- end: emptyBoxGeoJSONEnd
588
+ volcanicField: {
589
+ marginBottom: 2
590
+ },
591
+ surfaceVisibility: {
592
+ marginBottom: 2
593
+ },
594
+ surfaceWind: {
595
+ marginBottom: 2
596
+ },
597
+ levelField: {
598
+ marginBottom: 2
599
+ },
600
+ movement: {
601
+ marginBottom: 2
602
+ },
603
+ latitude: {
604
+ width: '97%'
605
+ },
606
+ unit: {
607
+ width: '95%'
707
608
  },
708
- POLYGON: {
709
- start: emptyPolygonGeoJSONStart,
710
- end: emptyPolygonGeoJSONEnd
609
+ quitDrawModeMessage: {
610
+ paddingBottom: '10px',
611
+ opacity: '1'
612
+ },
613
+ drawSection: {
614
+ '+ .MuiGrid-item': {
615
+ paddingTop: 5
616
+ },
617
+ ' .MuiTypography-subtitle1': {
618
+ marginTop: 1
619
+ }
711
620
  },
712
- FIR: {
713
- start: null,
714
- end: null
621
+ helperText: {
622
+ ' .MuiFormHelperText-root': {
623
+ position: 'absolute',
624
+ top: 56,
625
+ '&.Mui-error': {
626
+ top: 'auto',
627
+ position: 'relative'
628
+ }
629
+ }
715
630
  }
716
631
  };
717
632
 
718
- var getHoursBeforeValidity = function getHoursBeforeValidity(phenomenon, fir, config) {
719
- if (!fir) {
720
- return 4;
721
- }
722
- var _config$fir_areas$fir = config.fir_areas[fir],
723
- hours_before_validity = _config$fir_areas$fir.hours_before_validity,
724
- va_hours_before_validity = _config$fir_areas$fir.va_hours_before_validity,
725
- tc_hours_before_validity = _config$fir_areas$fir.tc_hours_before_validity;
726
- switch (phenomenon) {
727
- // Tropical Cyclone
728
- case 'TC':
729
- return tc_hours_before_validity;
730
- // Volcanic ash cloud
731
- case 'VA_CLD':
732
- return va_hours_before_validity;
733
- default:
734
- return hours_before_validity;
735
- }
736
- };
737
- var getMaxHoursOfValidity = function getMaxHoursOfValidity(phenomenon, fir, config) {
738
- if (!fir) {
739
- return 4;
740
- }
741
- var _config$fir_areas$fir2 = config.fir_areas[fir],
742
- max_hours_of_validity = _config$fir_areas$fir2.max_hours_of_validity,
743
- va_max_hours_of_validity = _config$fir_areas$fir2.va_max_hours_of_validity,
744
- tc_max_hours_of_validity = _config$fir_areas$fir2.tc_max_hours_of_validity;
745
- switch (phenomenon) {
746
- // Tropical Cyclone
747
- case 'TC':
748
- return tc_max_hours_of_validity;
749
- // Volcanic ash cloud
750
- case 'VA_CLD':
751
- return va_max_hours_of_validity;
752
- default:
753
- return max_hours_of_validity;
754
- }
755
- };
756
- var getValidFromDelayTimeMinutesFromConfig = function getValidFromDelayTimeMinutesFromConfig(config) {
757
- return config.valid_from_delay_minutes;
758
- };
759
- var getDefaultValidityMinutesFromConfig = function getDefaultValidityMinutesFromConfig(config) {
760
- return config.default_validity_minutes;
761
- };
762
- var getFirArea = function getFirArea(selectedFIR, productConfig) {
763
- // If no FIR selected or FIR doesn't exist in list, select first FIR
764
- return selectedFIR && productConfig.fir_areas[selectedFIR] !== undefined ? selectedFIR : productConfig.active_firs[0];
633
+ /******************************************************************************
634
+ Copyright (c) Microsoft Corporation.
635
+
636
+ Permission to use, copy, modify, and/or distribute this software for any
637
+ purpose with or without fee is hereby granted.
638
+
639
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
640
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
641
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
642
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
643
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
644
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
645
+ PERFORMANCE OF THIS SOFTWARE.
646
+ ***************************************************************************** */
647
+
648
+ function __rest(s, e) {
649
+ var t = {};
650
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
651
+ t[p] = s[p];
652
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
653
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
654
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
655
+ t[p[i]] = s[p[i]];
656
+ }
657
+ return t;
658
+ }
659
+
660
+ function __awaiter(thisArg, _arguments, P, generator) {
661
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
662
+ return new (P || (P = Promise))(function (resolve, reject) {
663
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
664
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
665
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
666
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
667
+ });
668
+ }
669
+
670
+ // A version of a radio button with label where the label and surrounding white space is not clickable
671
+ var RadioButtonAndLabel = function RadioButtonAndLabel(props) {
672
+ var value = props.value,
673
+ label = props.label,
674
+ _props$disabled = props.disabled,
675
+ disabled = _props$disabled === void 0 ? true : _props$disabled,
676
+ restProps = __rest(props, ["value", "label", "disabled"]);
677
+ return /*#__PURE__*/React__default.createElement(FormControlLabel, Object.assign({
678
+ style: {
679
+ pointerEvents: 'none'
680
+ },
681
+ value: value,
682
+ control: /*#__PURE__*/React__default.createElement(Radio, {
683
+ style: {
684
+ pointerEvents: 'auto'
685
+ }
686
+ }),
687
+ label: label,
688
+ disabled: disabled
689
+ }, restProps));
765
690
  };
766
- var getActiveFIRArea = function getActiveFIRArea(selectedFIR, productConfig) {
767
- var FIR = getFirArea(selectedFIR, productConfig);
768
- return productConfig.fir_areas[FIR];
691
+
692
+ var ProductFormFieldLayout = function ProductFormFieldLayout(_a) {
693
+ var title = _a.title,
694
+ children = _a.children,
695
+ props = __rest(_a, ["title", "children"]);
696
+ return /*#__PURE__*/React__default.createElement(Grid, Object.assign({
697
+ item: true,
698
+ container: true,
699
+ spacing: 3
700
+ }, props), /*#__PURE__*/React__default.createElement(Grid, {
701
+ item: true,
702
+ xs: 4,
703
+ container: true,
704
+ justifyContent: "flex-end"
705
+ }, title && /*#__PURE__*/React__default.createElement(Typography, {
706
+ variant: "subtitle1",
707
+ sx: styles$2.label
708
+ }, title)), /*#__PURE__*/React__default.createElement(Grid, {
709
+ item: true,
710
+ xs: 8,
711
+ container: true,
712
+ justifyContent: "flex-start"
713
+ }, children));
769
714
  };
770
- var DEFAULT_MINIMUM_SURFACE_LEVEL = 0;
771
- var getMinCloudLevelValue = function getMinCloudLevelValue(unit, selectedFIR, productConfig) {
715
+
716
+ /* *
717
+ * Licensed under the Apache License, Version 2.0 (the "License");
718
+ * you may not use this file except in compliance with the License.
719
+ * You may obtain a copy of the License at
720
+ *
721
+ * http://www.apache.org/licenses/LICENSE-2.0
722
+ *
723
+ * Unless required by applicable law or agreed to in writing, software
724
+ * distributed under the License is distributed on an "AS IS" BASIS,
725
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
726
+ * See the License for the specific language governing permissions and
727
+ * limitations under the License.
728
+ *
729
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
730
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
731
+ * */
732
+ var Change = function Change(_ref) {
733
+ var isDisabled = _ref.isDisabled,
734
+ isReadOnly = _ref.isReadOnly;
735
+ var _useDraftFormHelpers = useDraftFormHelpers(),
736
+ isRequired = _useDraftFormHelpers.isRequired;
737
+ return /*#__PURE__*/React__default.createElement(ProductFormFieldLayout, {
738
+ title: "Change",
739
+ sx: styles$2.containerItem
740
+ }, /*#__PURE__*/React__default.createElement(Grid, {
741
+ item: true,
742
+ xs: 12
743
+ }, /*#__PURE__*/React__default.createElement(ReactHookFormRadioGroup, {
744
+ name: "change",
745
+ rules: {
746
+ validate: {
747
+ isRequired: isRequired
748
+ }
749
+ },
750
+ disabled: isDisabled,
751
+ isReadOnly: isReadOnly
752
+ }, /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
753
+ value: "WKN",
754
+ label: "Weakening",
755
+ disabled: isDisabled,
756
+ "data-testid": "change-WKN"
757
+ }), /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
758
+ value: "NC",
759
+ label: "No change",
760
+ disabled: isDisabled,
761
+ "data-testid": "change-NC"
762
+ }), /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
763
+ value: "INTSF",
764
+ label: "Intensifying",
765
+ disabled: isDisabled,
766
+ "data-testid": "change-INTSF"
767
+ }))));
768
+ };
769
+
770
+ /* *
771
+ * Licensed under the Apache License, Version 2.0 (the "License");
772
+ * you may not use this file except in compliance with the License.
773
+ * You may obtain a copy of the License at
774
+ *
775
+ * http://www.apache.org/licenses/LICENSE-2.0
776
+ *
777
+ * Unless required by applicable law or agreed to in writing, software
778
+ * distributed under the License is distributed on an "AS IS" BASIS,
779
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
780
+ * See the License for the specific language governing permissions and
781
+ * limitations under the License.
782
+ *
783
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
784
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
785
+ * */
786
+ var styles$1 = {
787
+ radioInput: {
788
+ padding: 1,
789
+ borderRadius: '5px',
790
+ backgroundColor: 'geowebColors.buttons.tool.default.fill',
791
+ color: 'geowebColors.buttons.tool.default.color',
792
+ '&.Mui-checked': {
793
+ backgroundColor: 'geowebColors.buttons.primary.default.fill',
794
+ color: 'geowebColors.buttons.primary.default.color'
795
+ }
796
+ }
797
+ };
798
+ var DrawTools = function DrawTools(_ref) {
799
+ var activeTool = _ref.activeTool,
800
+ tools = _ref.tools,
801
+ onChangeTool = _ref.onChangeTool;
802
+ return /*#__PURE__*/React__default.createElement(Grid, {
803
+ item: true,
804
+ xs: 12,
805
+ container: true,
806
+ justifyContent: "space-between",
807
+ "data-testid": "drawtools",
808
+ spacing: 1
809
+ }, tools.map(function (tool) {
810
+ return /*#__PURE__*/React__default.createElement(Grid, {
811
+ key: tool.id,
812
+ item: true
813
+ }, /*#__PURE__*/React__default.createElement(CustomTooltip, {
814
+ title: tool.title
815
+ }, /*#__PURE__*/React__default.createElement(Radio, {
816
+ icon: tool.icon,
817
+ value: true,
818
+ checkedIcon: tool.icon,
819
+ checked: tool.isSelectable && activeTool === tool.id,
820
+ onChange: function onChange() {
821
+ onChangeTool(tool);
822
+ },
823
+ "data-testid": tool.id,
824
+ sx: styles$1.radioInput
825
+ })));
826
+ }));
827
+ };
828
+
829
+ function n$5(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r$5(n){return !!n&&!!n[Q]}function t$5(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v$4(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v$4(n)?3:0}function u$3(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f$3(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c$3(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v$4(n){return q$5&&n instanceof Set}function p$5(n){return n.o||n.t}function l$4(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d$3(n,e){return void 0===e&&(e=!1),y$2(n)||r$5(n)||!t$5(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h$5),Object.freeze(n),e&&i(n,(function(n,r){return d$3(r,!0)}),!0)),n}function h$5(){n$5(2);}function y$2(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b$3(r){var t=tn[r];return t||n$5(18,r),t}function _(){return "production"===process.env.NODE_ENV||U||n$5(0),U}function j(n,r){r&&(b$3("Patches"),n.u=[],n.s=[],n.v=r);}function g$3(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w$3(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b$3("ES5").S(e,r,o),o?(i[Q].P&&(g$3(e),n$5(4)),t$5(r)&&(r=M(e,r),e.l||x$2(e,r)),e.u&&b$3("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g$3(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y$2(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A$2(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x$2(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l$4(e.k):e.o,u=o,a=!1;3===e.i&&(u=new Set(o),o.clear(),a=!0),i(u,(function(r,i){return A$2(n,e,o,r,i,t,a)})),x$2(n,o,!1),t&&n.u&&b$3("Patches").N(e,t,n.u,n.s);}return e.o}function A$2(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n$5(5),r$5(c)){var p=M(e,c,s&&i&&3!==i.i&&!u$3(i.R,a)?s.concat(a):void 0);if(f$3(o,a,p),!r$5(p))return;e.m=!1;}else v&&o.add(c);if(t$5(c)&&!y$2(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x$2(e,c);}}function x$2(n,r,t){void 0===t&&(t=!1),!n.l&&n.h.D&&n.m&&d$3(r,t);}function z$2(n,r){var t=n[Q];return (t?p$5(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k$4(n){n.P||(n.P=!0,n.l&&k$4(n.l));}function E(n){n.o||(n.o=l$4(n.t));}function N(n,r,t){var e=s(r)?b$3("MapSet").F(r,t):v$4(r)?b$3("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b$3("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r$5(e)||n$5(22,e),function n(r){if(!t$5(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b$3("ES5").K(u)))return u.t;u.I=!0,e=D(r,c),u.I=!1;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f$3(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l$4(n)}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q$5="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p$5(n);if(!u$3(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t$5(i)?i:i===z$2(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p$5(n)},ownKeys:function(n){return Reflect.ownKeys(p$5(n))},set:function(n,r,t){var e=I(p$5(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z$2(p$5(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=!1,!0;if(c$3(t,i)&&(void 0!==t||u$3(n.t,r)))return !0;E(n),k$4(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=!0),!0},deleteProperty:function(n,r){return void 0!==z$2(n.t,r)||r in n.t?(n.R[r]=!1,E(n),k$4(n)):delete n.R[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p$5(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n$5(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n$5(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n$5(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n$5(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n$5(6),void 0!==o&&"function"!=typeof o&&n$5(7),t$5(r)){var c=w$3(e),s=N(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?g$3(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g$3(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d$3(f,!0),o){var p=[],l=[];b$3("Patches").M(r,f,p,l),o(p,l);}return f}n$5(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t$5(e)||n$5(8),r$5(e)&&(e=R(e));var i=w$3(this),o=N(this,e,void 0);return o[Q].C=!0,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n$5(9),e.I&&n$5(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n$5(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b$3("Patches").$;return r$5(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);
830
+
831
+ /* *
832
+ * Licensed under the Apache License, Version 2.0 (the "License");
833
+ * you may not use this file except in compliance with the License.
834
+ * You may obtain a copy of the License at
835
+ *
836
+ * http://www.apache.org/licenses/LICENSE-2.0
837
+ *
838
+ * Unless required by applicable law or agreed to in writing, software
839
+ * distributed under the License is distributed on an "AS IS" BASIS,
840
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
841
+ * See the License for the specific language governing permissions and
842
+ * limitations under the License.
843
+ *
844
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
845
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
846
+ * */
847
+ var srsAndBboxDefault = {
848
+ bbox: {
849
+ left: -911501,
850
+ right: 3738819,
851
+ top: 11688874,
852
+ bottom: 5930186
853
+ },
854
+ srs: 'EPSG:3857'
855
+ };
856
+ var featurePropsStart = defaultStyleProperties;
857
+ var featurePropsEnd = {
858
+ stroke: '#6e1e91',
859
+ 'stroke-width': 1.5,
860
+ 'stroke-opacity': 1,
861
+ fill: '#6e1e91',
862
+ 'fill-opacity': 0.25
863
+ };
864
+ var featurePropsIntersectionStart = defaultIntersectionStyleProperties;
865
+ var featurePropsIntersectionEnd = Object.assign(Object.assign({}, featurePropsEnd), {
866
+ 'fill-opacity': 0.5
867
+ });
868
+ var featurePropsFIR = {
869
+ stroke: '#0075a9',
870
+ 'stroke-width': 1.5,
871
+ 'stroke-opacity': 1,
872
+ fill: '#0075a9',
873
+ 'fill-opacity': 0.0
874
+ };
875
+
876
+ var getHoursBeforeValidity = function getHoursBeforeValidity(phenomenon, fir, config) {
877
+ if (!fir) {
878
+ return 4;
879
+ }
880
+ var _config$fir_areas$fir = config.fir_areas[fir],
881
+ hours_before_validity = _config$fir_areas$fir.hours_before_validity,
882
+ va_hours_before_validity = _config$fir_areas$fir.va_hours_before_validity,
883
+ tc_hours_before_validity = _config$fir_areas$fir.tc_hours_before_validity;
884
+ switch (phenomenon) {
885
+ // Tropical Cyclone
886
+ case 'TC':
887
+ return tc_hours_before_validity;
888
+ // Volcanic ash cloud
889
+ case 'VA_CLD':
890
+ return va_hours_before_validity;
891
+ default:
892
+ return hours_before_validity;
893
+ }
894
+ };
895
+ var getMaxHoursOfValidity = function getMaxHoursOfValidity(phenomenon, fir, config) {
896
+ if (!fir) {
897
+ return 4;
898
+ }
899
+ var _config$fir_areas$fir2 = config.fir_areas[fir],
900
+ max_hours_of_validity = _config$fir_areas$fir2.max_hours_of_validity,
901
+ va_max_hours_of_validity = _config$fir_areas$fir2.va_max_hours_of_validity,
902
+ tc_max_hours_of_validity = _config$fir_areas$fir2.tc_max_hours_of_validity;
903
+ switch (phenomenon) {
904
+ // Tropical Cyclone
905
+ case 'TC':
906
+ return tc_max_hours_of_validity;
907
+ // Volcanic ash cloud
908
+ case 'VA_CLD':
909
+ return va_max_hours_of_validity;
910
+ default:
911
+ return max_hours_of_validity;
912
+ }
913
+ };
914
+ var getValidFromDelayTimeMinutesFromConfig = function getValidFromDelayTimeMinutesFromConfig(config) {
915
+ return config.valid_from_delay_minutes;
916
+ };
917
+ var getDefaultValidityMinutesFromConfig = function getDefaultValidityMinutesFromConfig(config) {
918
+ return config.default_validity_minutes;
919
+ };
920
+ var getFirArea = function getFirArea(selectedFIR, productConfig) {
921
+ // If no FIR selected or FIR doesn't exist in list, select first FIR
922
+ return selectedFIR && productConfig.fir_areas[selectedFIR] !== undefined ? selectedFIR : productConfig.active_firs[0];
923
+ };
924
+ var getActiveFIRArea = function getActiveFIRArea(selectedFIR, productConfig) {
925
+ var FIR = getFirArea(selectedFIR, productConfig);
926
+ return productConfig.fir_areas[FIR];
927
+ };
928
+ var DEFAULT_MINIMUM_SURFACE_LEVEL = 0;
929
+ var getMinCloudLevelValue = function getMinCloudLevelValue(unit, selectedFIR, productConfig) {
772
930
  // Use first FIR in list if no FIR selected
773
931
  var _getActiveFIRArea = getActiveFIRArea(selectedFIR, productConfig),
774
932
  cloud_level_min = _getActiveFIRArea.cloud_level_min;
@@ -982,10 +1140,10 @@ var prepareFormValues = function prepareFormValues(product) {
982
1140
  }
983
1141
  // remove geometry if empty coordinates
984
1142
  if (key === 'endGeometry' || key === 'endGeometryIntersect' || key === 'startGeometry' || key === 'startGeometryIntersect') {
985
- if ((value === null || value === void 0 ? void 0 : value.features[0].geometry.type) === 'Polygon' && (value === null || value === void 0 ? void 0 : value.features[0].geometry.coordinates[0].length)) {
1143
+ if ((value === null || value === void 0 ? void 0 : value.features.length) > 0 && (value === null || value === void 0 ? void 0 : value.features[0].geometry.type) === 'Polygon' && (value === null || value === void 0 ? void 0 : value.features[0].geometry.coordinates[0].length)) {
986
1144
  return Object.assign(Object.assign({}, list), _defineProperty({}, key, value));
987
1145
  }
988
- if ((value === null || value === void 0 ? void 0 : value.features[0].geometry.type) === 'Point' && (value === null || value === void 0 ? void 0 : value.features[0].geometry.coordinates.length)) {
1146
+ if ((value === null || value === void 0 ? void 0 : value.features.length) > 0 && (value === null || value === void 0 ? void 0 : value.features[0].geometry.type) === 'Point' && (value === null || value === void 0 ? void 0 : value.features[0].geometry.coordinates.length)) {
989
1147
  return Object.assign(Object.assign({}, list), _defineProperty({}, key, value));
990
1148
  }
991
1149
  return list;
@@ -1105,604 +1263,99 @@ var getAllowedUnits = function getAllowedUnits(selectedFIR, productConfig, confi
1105
1263
  */
1106
1264
  var getFir = function getFir(productConfig, firName) {
1107
1265
  var currentFIRName = firName || productConfig.active_firs[0];
1108
- return productConfig.fir_areas[currentFIRName].fir_location;
1109
- };
1110
- /**
1111
- * Function to check if the given geojson object has 'fir' selectionType property
1112
- */
1113
- var isFir = function isFir(geojson) {
1114
- return geojson && geojson.features && geojson.features[0].properties['selectionType'] === 'fir';
1115
- };
1116
- var rewindGeometry = function rewindGeometry(geoJSON) {
1117
- return fn(geoJSON, function (geoJSONDraft) {
1118
- if (geoJSONDraft && geoJSONDraft.features[0].geometry.type === 'Polygon' && geoJSONDraft.features[0].geometry.coordinates[0].length > 1) {
1119
- var geometry = geoJSON.features[0].geometry;
1120
- var lineString = polygonToLineString(geometry);
1121
- if (booleanClockwise(lineString.geometry.coordinates)) {
1122
- // eslint-disable-next-line no-param-reassign
1123
- geoJSONDraft.features[0].geometry = rewind(geoJSONDraft.features[0].geometry);
1124
- }
1125
- }
1126
- });
1127
- };
1128
- var getFieldLabel = function getFieldLabel(title, isDisabled) {
1129
- var action = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Select';
1130
- return isDisabled ? title : "".concat(action, " ").concat(title.toLowerCase());
1131
- };
1132
- var getBaseLayers = function getBaseLayers(productConfig) {
1133
- var _a, _b;
1134
- return ((_b = (_a = productConfig.mapPreset) === null || _a === void 0 ? void 0 : _a.layers) === null || _b === void 0 ? void 0 : _b.filter(function (layer) {
1135
- return layer.layerType === layerTypes.LayerType.baseLayer || layer.layerType === layerTypes.LayerType.overLayer;
1136
- })) || [];
1137
- };
1138
- var getMaxMovementSpeedValue = function getMaxMovementSpeedValue(unit, selectedFIR, productConfig) {
1139
- var _getActiveFIRArea11 = getActiveFIRArea(selectedFIR, productConfig),
1140
- movement_max = _getActiveFIRArea11.movement_max;
1141
- // Return max value for selected unit - if not present in list, return null
1142
- return movement_max !== undefined && movement_max[unit] ? movement_max[unit] : null;
1143
- };
1144
- var DEFAULT_MIN_MOVEMENT_SPEED = 0;
1145
- var getMinMovementSpeedValue = function getMinMovementSpeedValue(unit, selectedFIR, productConfig) {
1146
- var _getActiveFIRArea12 = getActiveFIRArea(selectedFIR, productConfig),
1147
- movement_min = _getActiveFIRArea12.movement_min;
1148
- // Return min value for selected unit - if not present in list, return DEFAULT_MIN_MOVEMENT_SPEED (zero, no negative speeds)
1149
- return movement_min !== undefined && movement_min[unit] ? movement_min[unit] : DEFAULT_MIN_MOVEMENT_SPEED;
1150
- };
1151
- /** Trigger form validations for given list of field names if field has a value */
1152
- var triggerValidations = function triggerValidations(fieldNames, getValues, trigger) {
1153
- fieldNames.forEach(function (field) {
1154
- var value = getValues(field);
1155
- if (value || value === 0) {
1156
- trigger(field);
1157
- }
1158
- });
1159
- };
1160
- var getProjection = function getProjection(productConfig) {
1161
- var _a;
1162
- return ((_a = productConfig.mapPreset) === null || _a === void 0 ? void 0 : _a.proj) || undefined;
1163
- };
1164
-
1165
- var getDrawModeFromSelectionType = function getDrawModeFromSelectionType(selectionType) {
1166
- switch (selectionType) {
1167
- case 'point':
1168
- return MapDrawMode.POINT;
1169
- case 'box':
1170
- return MapDrawMode.BOX;
1171
- case 'fir':
1172
- return MapDrawMode.FIR;
1173
- case 'poly':
1174
- default:
1175
- return MapDrawMode.POLYGON;
1176
- }
1177
- };
1178
- /**
1179
- * Adds properties to the first geojson feature based on the given property object.
1180
- * It only extends or changes the properties which are defined in styleConfig,
1181
- * all other properties in the geojson are left unchanged.
1182
- * @param geojson
1183
- * @param featureProperties
1184
- */
1185
- var addFeatureProperties = function addFeatureProperties(geojson, featureProperties) {
1186
- if (!geojson) {
1187
- return null;
1188
- }
1189
- return fn(geojson, function (draft) {
1190
- if (draft.features && draft.features.length > 0 && draft.features[0].properties) {
1191
- Object.keys(featureProperties).forEach(function (key) {
1192
- draft.features[0].properties[key] = featureProperties[key];
1193
- });
1194
- }
1195
- });
1196
- };
1197
- var getInitialGeoJSONState = function getInitialGeoJSONState(productConfig, currentSelectedFIR, initialGeometry) {
1198
- var startGeometry = initialGeometry && initialGeometry.start ? initialGeometry.start : geoJSONTemplate['BOX']['start'];
1199
- var endGeometry = initialGeometry && initialGeometry.end ? initialGeometry.end : geoJSONTemplate['BOX']['end'];
1200
- return {
1201
- start: addFeatureProperties(startGeometry, featurePropsStart),
1202
- end: addFeatureProperties(endGeometry, featurePropsEnd),
1203
- intersectionStart: addFeatureProperties(initialGeometry === null || initialGeometry === void 0 ? void 0 : initialGeometry.intersectionStart, featurePropsIntersectionStart),
1204
- intersectionEnd: addFeatureProperties(initialGeometry === null || initialGeometry === void 0 ? void 0 : initialGeometry.intersectionEnd, featurePropsIntersectionEnd),
1205
- fir: addFeatureProperties(getFir(productConfig, currentSelectedFIR), featurePropsFIR)
1206
- };
1207
- };
1208
- var useDrawMode = function useDrawMode(productConfig, initialGeometry, currentSelectedFIR) {
1209
- var getInitialLayerDrawModes = function getInitialLayerDrawModes(startorEnd) {
1210
- return initialGeometry && initialGeometry[startorEnd] ? getDrawModeFromSelectionType(initialGeometry[startorEnd].features[0].properties.selectionType) : null;
1211
- };
1212
- /* For the radio buttons */
1213
- var _React$useState = React.useState({
1214
- start: null,
1215
- end: null
1216
- }),
1217
- _React$useState2 = _slicedToArray(_React$useState, 2),
1218
- drawMode = _React$useState2[0],
1219
- setDrawMode = _React$useState2[1];
1220
- /* Drawmode for the layers */
1221
- var _React$useState3 = React.useState({
1222
- start: getInitialLayerDrawModes('start'),
1223
- end: getInitialLayerDrawModes('end')
1224
- }),
1225
- _React$useState4 = _slicedToArray(_React$useState3, 2),
1226
- layerDrawModes = _React$useState4[0],
1227
- setLayersDrawModes = _React$useState4[1];
1228
- /* GeoJSONs for the layers */
1229
- var _React$useState5 = React.useState(function () {
1230
- return getInitialGeoJSONState(productConfig, currentSelectedFIR, initialGeometry);
1231
- }),
1232
- _React$useState6 = _slicedToArray(_React$useState5, 2),
1233
- geoJSONs = _React$useState6[0],
1234
- setLayerGeoJSONs = _React$useState6[1];
1235
- /**
1236
- *
1237
- * @param mapDrawMode Can be 'POINT' | 'BOX' | 'POLYGON' | 'FIR' | 'DELETE'
1238
- * @param startOrEnd Can be 'start' | 'end'
1239
- */
1240
- var setDrawModeType = function setDrawModeType(mapDrawMode, startOrEnd, updateCallback) {
1241
- var newGeoJSONDrawMode = Object.assign({}, layerDrawModes);
1242
- var featureStyleProperties = startOrEnd === StartOrEndDrawing.start ? featurePropsStart : featurePropsEnd;
1243
- /* Switch on the mapdrawmode type for either start or end */
1244
- switch (mapDrawMode) {
1245
- /* Set draw modes point, box, polygon for either start or end layer */
1246
- case MapDrawMode.POINT:
1247
- case MapDrawMode.BOX:
1248
- case MapDrawMode.POLYGON:
1249
- {
1250
- if (newGeoJSONDrawMode[startOrEnd] !== mapDrawMode) {
1251
- /* Set for either start or end GeoJSON; key is the same as in the MapDrawMode ENUM */
1252
- var cleanGeoJSON = fn(geoJSONs, function (draft) {
1253
- draft[startOrEnd] = addFeatureProperties(geoJSONTemplate[mapDrawMode][startOrEnd], featureStyleProperties);
1254
- });
1255
- setLayerGeoJSONs(createInterSections(cleanGeoJSON));
1256
- }
1257
- newGeoJSONDrawMode[startOrEnd] = mapDrawMode;
1258
- setLayersDrawModes(newGeoJSONDrawMode);
1259
- setDrawMode(startOrEnd === StartOrEndDrawing.start ? {
1260
- start: mapDrawMode,
1261
- end: null
1262
- } : {
1263
- start: null,
1264
- end: mapDrawMode
1265
- });
1266
- break;
1267
- }
1268
- /* Set complete fir for either start or end layer */
1269
- case MapDrawMode.FIR:
1270
- {
1271
- newGeoJSONDrawMode[startOrEnd] = mapDrawMode;
1272
- var _cleanGeoJSON = fn(geoJSONs, function (draft) {
1273
- draft[startOrEnd] = addFeatureProperties(getFir(productConfig, currentSelectedFIR), Object.assign(Object.assign({}, featureStyleProperties), {
1274
- selectionType: 'fir'
1275
- }));
1276
- });
1277
- setDrawMode({
1278
- start: null,
1279
- end: null
1280
- });
1281
- setLayersDrawModes(newGeoJSONDrawMode);
1282
- var intersections = createInterSections(_cleanGeoJSON);
1283
- setLayerGeoJSONs(intersections);
1284
- if (updateCallback) {
1285
- updateCallback(intersections);
1286
- }
1287
- break;
1288
- }
1289
- /* Clear the map for either start or end layer */
1290
- case MapDrawMode.DELETE:
1291
- {
1292
- var newDrawMode = Object.assign({}, drawMode);
1293
- newDrawMode[startOrEnd] = null;
1294
- setDrawMode(newDrawMode);
1295
- switch (newGeoJSONDrawMode[startOrEnd]) {
1296
- case MapDrawMode.POINT:
1297
- case MapDrawMode.BOX:
1298
- {
1299
- var _cleanGeoJSON2 = fn(geoJSONs, function (draft) {
1300
- draft[startOrEnd] = addFeatureProperties(geoJSONTemplate[newGeoJSONDrawMode[startOrEnd]][startOrEnd], featureStyleProperties);
1301
- });
1302
- var _intersections = createInterSections(_cleanGeoJSON2);
1303
- setLayerGeoJSONs(_intersections);
1304
- if (updateCallback) {
1305
- updateCallback(_intersections);
1306
- }
1307
- break;
1308
- }
1309
- default:
1310
- {
1311
- var _cleanGeoJSON3 = fn(geoJSONs, function (draft) {
1312
- draft[startOrEnd] = addFeatureProperties(geoJSONTemplate['POLYGON'][startOrEnd], featureStyleProperties);
1313
- });
1314
- var _intersections2 = createInterSections(_cleanGeoJSON3);
1315
- setLayerGeoJSONs(_intersections2);
1316
- if (updateCallback) {
1317
- updateCallback(_intersections2);
1318
- }
1319
- break;
1320
- }
1321
- }
1322
- break;
1323
- }
1324
- }
1325
- };
1326
- return {
1327
- drawMode: drawMode,
1328
- setDrawMode: setDrawMode,
1329
- layerDrawModes: layerDrawModes,
1330
- setLayersDrawModes: setLayersDrawModes,
1331
- geoJSONs: geoJSONs,
1332
- setLayerGeoJSONs: setLayerGeoJSONs,
1333
- setDrawModeType: setDrawModeType
1334
- };
1335
- };
1336
- /**
1337
- * Returns the intersection of two features. In case of a polygon, only the first feature is used.
1338
- * @param a Feature A
1339
- * @param b Feature B
1340
- * @returns The intersection of the two features.
1341
- */
1342
- var intersectGeoJSONS = function intersectGeoJSONS(a, b) {
1343
- var featureA = turf.feature(a.features[0].geometry);
1344
- var featureB = turf.feature(b.features[0].geometry);
1345
- var options = {
1346
- tolerance: 0.001,
1347
- highQuality: true
1348
- };
1349
- var simplifiedA = turf.simplify(featureA, options);
1350
- var simplifiedB = turf.simplify(featureB, options);
1351
- var intersection = turf.intersect(simplifiedA, simplifiedB);
1352
- return addFeatureProperties({
1353
- type: 'FeatureCollection',
1354
- features: intersection === null ? [{
1355
- type: 'Feature',
1356
- properties: {
1357
- selectionType: 'poly'
1358
- },
1359
- geometry: {
1360
- type: 'Polygon',
1361
- coordinates: [[]]
1362
- }
1363
- }] : [intersection]
1364
- }, featurePropsUnStyled);
1365
- };
1366
- /**
1367
- * Adds the intersectionStart and intersectionEnd properties to the GeoJSONS structure
1368
- * @param geoJSONs
1369
- * @returns GeoJSONS extend with intersections
1370
- */
1371
- var createInterSections = function createInterSections(geoJSONs) {
1372
- var intersections = fn(geoJSONs, function (draft) {
1373
- try {
1374
- draft.intersectionStart = addFeatureProperties(intersectGeoJSONS(geoJSONs.start, geoJSONs.fir), featurePropsIntersectionStart);
1375
- } catch (e) {
1376
- draft.intersectionStart = addFeatureProperties(geoJSONs.start, featurePropsIntersectionStart);
1377
- }
1378
- try {
1379
- draft.intersectionEnd = addFeatureProperties(intersectGeoJSONS(geoJSONs.end, geoJSONs.fir), featurePropsIntersectionEnd);
1380
- } catch (e) {
1381
- draft.intersectionEnd = addFeatureProperties(geoJSONs.end, featurePropsIntersectionEnd);
1382
- }
1383
- });
1384
- return intersections;
1385
- };
1386
-
1387
- /* *
1388
- * Licensed under the Apache License, Version 2.0 (the "License");
1389
- * you may not use this file except in compliance with the License.
1390
- * You may obtain a copy of the License at
1391
- *
1392
- * http://www.apache.org/licenses/LICENSE-2.0
1393
- *
1394
- * Unless required by applicable law or agreed to in writing, software
1395
- * distributed under the License is distributed on an "AS IS" BASIS,
1396
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1397
- * See the License for the specific language governing permissions and
1398
- * limitations under the License.
1399
- *
1400
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1401
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1402
- * */
1403
- var styles$2 = {
1404
- label: {
1405
- fontSize: '0.875rem',
1406
- marginTop: 2,
1407
- textAlign: 'right'
1408
- },
1409
- body: {
1410
- paddingTop: '17px'
1411
- },
1412
- containerItem: {
1413
- ' .MuiTypography-subtitle1': {
1414
- marginTop: 1
1415
- }
1416
- },
1417
- volcanicField: {
1418
- marginBottom: 2
1419
- },
1420
- surfaceVisibility: {
1421
- marginBottom: 2
1422
- },
1423
- surfaceWind: {
1424
- marginBottom: 2
1425
- },
1426
- levelField: {
1427
- marginBottom: 2
1428
- },
1429
- movement: {
1430
- marginBottom: 2
1431
- },
1432
- latitude: {
1433
- width: '97%'
1434
- },
1435
- unit: {
1436
- width: '95%'
1437
- },
1438
- quitDrawModeMessage: {
1439
- paddingBottom: '10px',
1440
- opacity: '1'
1441
- },
1442
- drawSection: {
1443
- '+ .MuiGrid-item': {
1444
- paddingTop: 5
1445
- },
1446
- ' .MuiTypography-subtitle1': {
1447
- marginTop: 1
1448
- }
1449
- },
1450
- helperText: {
1451
- ' .MuiFormHelperText-root': {
1452
- position: 'absolute',
1453
- top: 56,
1454
- '&.Mui-error': {
1455
- top: 'auto',
1456
- position: 'relative'
1457
- }
1458
- }
1459
- }
1460
- };
1461
-
1462
- /******************************************************************************
1463
- Copyright (c) Microsoft Corporation.
1464
-
1465
- Permission to use, copy, modify, and/or distribute this software for any
1466
- purpose with or without fee is hereby granted.
1467
-
1468
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1469
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1470
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1471
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1472
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1473
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1474
- PERFORMANCE OF THIS SOFTWARE.
1475
- ***************************************************************************** */
1476
-
1477
- function __rest(s, e) {
1478
- var t = {};
1479
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1480
- t[p] = s[p];
1481
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1482
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1483
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1484
- t[p[i]] = s[p[i]];
1485
- }
1486
- return t;
1487
- }
1488
-
1489
- function __awaiter(thisArg, _arguments, P, generator) {
1490
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1491
- return new (P || (P = Promise))(function (resolve, reject) {
1492
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1493
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1494
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1495
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1496
- });
1497
- }
1498
-
1499
- // A version of a radio button with label where the label and surrounding white space is not clickable
1500
- var RadioButtonAndLabel = function RadioButtonAndLabel(props) {
1501
- var value = props.value,
1502
- label = props.label,
1503
- _props$disabled = props.disabled,
1504
- disabled = _props$disabled === void 0 ? true : _props$disabled,
1505
- restProps = __rest(props, ["value", "label", "disabled"]);
1506
- return /*#__PURE__*/React__default.createElement(FormControlLabel, Object.assign({
1507
- style: {
1508
- pointerEvents: 'none'
1509
- },
1510
- value: value,
1511
- control: /*#__PURE__*/React__default.createElement(Radio, {
1512
- style: {
1513
- pointerEvents: 'auto'
1514
- }
1515
- }),
1516
- label: label,
1517
- disabled: disabled
1518
- }, restProps));
1519
- };
1520
-
1521
- var ProductFormFieldLayout = function ProductFormFieldLayout(_a) {
1522
- var title = _a.title,
1523
- children = _a.children,
1524
- props = __rest(_a, ["title", "children"]);
1525
- return /*#__PURE__*/React__default.createElement(Grid, Object.assign({
1526
- item: true,
1527
- container: true,
1528
- spacing: 3
1529
- }, props), /*#__PURE__*/React__default.createElement(Grid, {
1530
- item: true,
1531
- xs: 4,
1532
- container: true,
1533
- justifyContent: "flex-end"
1534
- }, title && /*#__PURE__*/React__default.createElement(Typography, {
1535
- variant: "subtitle1",
1536
- sx: styles$2.label
1537
- }, title)), /*#__PURE__*/React__default.createElement(Grid, {
1538
- item: true,
1539
- xs: 8,
1540
- container: true,
1541
- justifyContent: "flex-start"
1542
- }, children));
1266
+ return productConfig.fir_areas[currentFIRName].fir_location;
1543
1267
  };
1544
-
1545
- /* *
1546
- * Licensed under the Apache License, Version 2.0 (the "License");
1547
- * you may not use this file except in compliance with the License.
1548
- * You may obtain a copy of the License at
1549
- *
1550
- * http://www.apache.org/licenses/LICENSE-2.0
1551
- *
1552
- * Unless required by applicable law or agreed to in writing, software
1553
- * distributed under the License is distributed on an "AS IS" BASIS,
1554
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1555
- * See the License for the specific language governing permissions and
1556
- * limitations under the License.
1557
- *
1558
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1559
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1560
- * */
1561
- var Change = function Change(_ref) {
1562
- var isDisabled = _ref.isDisabled,
1563
- isReadOnly = _ref.isReadOnly;
1564
- var _useDraftFormHelpers = useDraftFormHelpers(),
1565
- isRequired = _useDraftFormHelpers.isRequired;
1566
- return /*#__PURE__*/React__default.createElement(ProductFormFieldLayout, {
1567
- title: "Change",
1568
- sx: styles$2.containerItem
1569
- }, /*#__PURE__*/React__default.createElement(Grid, {
1570
- item: true,
1571
- xs: 12
1572
- }, /*#__PURE__*/React__default.createElement(ReactHookFormRadioGroup, {
1573
- name: "change",
1574
- rules: {
1575
- validate: {
1576
- isRequired: isRequired
1268
+ /**
1269
+ * Function to check if the given geojson object has 'fir' selectionType property
1270
+ */
1271
+ var isFir = function isFir(geojson) {
1272
+ return geojson && geojson.features && geojson.features.length > 0 && geojson.features[0].properties['selectionType'] === 'fir';
1273
+ };
1274
+ var rewindGeometry = function rewindGeometry(geoJSON) {
1275
+ return fn(geoJSON, function (geoJSONDraft) {
1276
+ if (geoJSONDraft && geoJSONDraft.features.length > 0 && geoJSONDraft.features[0].geometry.type === 'Polygon' && geoJSONDraft.features[0].geometry.coordinates[0].length > 1) {
1277
+ var geometry = geoJSON.features[0].geometry;
1278
+ var lineString = polygonToLineString(geometry);
1279
+ if (booleanClockwise(lineString.geometry.coordinates)) {
1280
+ // eslint-disable-next-line no-param-reassign
1281
+ geoJSONDraft.features[0].geometry = rewind(geoJSONDraft.features[0].geometry);
1577
1282
  }
1578
- },
1579
- disabled: isDisabled,
1580
- isReadOnly: isReadOnly
1581
- }, /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
1582
- value: "WKN",
1583
- label: "Weakening",
1584
- disabled: isDisabled,
1585
- "data-testid": "change-WKN"
1586
- }), /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
1587
- value: "NC",
1588
- label: "No change",
1589
- disabled: isDisabled,
1590
- "data-testid": "change-NC"
1591
- }), /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
1592
- value: "INTSF",
1593
- label: "Intensifying",
1594
- disabled: isDisabled,
1595
- "data-testid": "change-INTSF"
1596
- }))));
1283
+ }
1284
+ });
1597
1285
  };
1598
-
1599
- /* *
1600
- * Licensed under the Apache License, Version 2.0 (the "License");
1601
- * you may not use this file except in compliance with the License.
1602
- * You may obtain a copy of the License at
1603
- *
1604
- * http://www.apache.org/licenses/LICENSE-2.0
1605
- *
1606
- * Unless required by applicable law or agreed to in writing, software
1607
- * distributed under the License is distributed on an "AS IS" BASIS,
1608
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1609
- * See the License for the specific language governing permissions and
1610
- * limitations under the License.
1611
- *
1612
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1613
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1614
- * */
1615
- var styles$1 = {
1616
- radioInput: {
1617
- padding: 1,
1618
- borderRadius: '5px',
1619
- backgroundColor: 'geowebColors.buttons.tool.default.fill',
1620
- color: 'geowebColors.buttons.tool.default.color',
1621
- '&.Mui-checked': {
1622
- backgroundColor: 'geowebColors.buttons.primary.default.fill',
1623
- color: 'geowebColors.buttons.primary.default.color'
1286
+ var getFieldLabel = function getFieldLabel(title, isDisabled) {
1287
+ var action = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Select';
1288
+ return isDisabled ? title : "".concat(action, " ").concat(title.toLowerCase());
1289
+ };
1290
+ var getBaseLayers = function getBaseLayers(productConfig) {
1291
+ var _a, _b;
1292
+ return ((_b = (_a = productConfig.mapPreset) === null || _a === void 0 ? void 0 : _a.layers) === null || _b === void 0 ? void 0 : _b.filter(function (layer) {
1293
+ return layer.layerType === layerTypes.LayerType.baseLayer || layer.layerType === layerTypes.LayerType.overLayer;
1294
+ })) || [];
1295
+ };
1296
+ var getMaxMovementSpeedValue = function getMaxMovementSpeedValue(unit, selectedFIR, productConfig) {
1297
+ var _getActiveFIRArea11 = getActiveFIRArea(selectedFIR, productConfig),
1298
+ movement_max = _getActiveFIRArea11.movement_max;
1299
+ // Return max value for selected unit - if not present in list, return null
1300
+ return movement_max !== undefined && movement_max[unit] ? movement_max[unit] : null;
1301
+ };
1302
+ var DEFAULT_MIN_MOVEMENT_SPEED = 0;
1303
+ var getMinMovementSpeedValue = function getMinMovementSpeedValue(unit, selectedFIR, productConfig) {
1304
+ var _getActiveFIRArea12 = getActiveFIRArea(selectedFIR, productConfig),
1305
+ movement_min = _getActiveFIRArea12.movement_min;
1306
+ // Return min value for selected unit - if not present in list, return DEFAULT_MIN_MOVEMENT_SPEED (zero, no negative speeds)
1307
+ return movement_min !== undefined && movement_min[unit] ? movement_min[unit] : DEFAULT_MIN_MOVEMENT_SPEED;
1308
+ };
1309
+ /** Trigger form validations for given list of field names if field has a value */
1310
+ var triggerValidations = function triggerValidations(fieldNames, getValues, trigger) {
1311
+ fieldNames.forEach(function (field) {
1312
+ var value = getValues(field);
1313
+ if (value || value === 0) {
1314
+ trigger(field);
1624
1315
  }
1625
- }
1316
+ });
1626
1317
  };
1627
- var DrawTools = function DrawTools(_ref) {
1628
- var _ref$type = _ref.type,
1629
- type = _ref$type === void 0 ? '' : _ref$type,
1630
- drawMode = _ref.drawMode,
1631
- setDrawMode = _ref.setDrawMode;
1632
- return /*#__PURE__*/React__default.createElement(Grid, {
1633
- item: true,
1634
- xs: 12,
1635
- container: true,
1636
- justifyContent: "space-between",
1637
- "data-testid": "drawtools",
1638
- spacing: 1
1639
- }, /*#__PURE__*/React__default.createElement(Grid, {
1640
- item: true
1641
- }, /*#__PURE__*/React__default.createElement(CustomTooltip, {
1642
- title: "Drop a point as ".concat(type, " position")
1643
- }, /*#__PURE__*/React__default.createElement(Radio, {
1644
- icon: /*#__PURE__*/React__default.createElement(Location, null),
1645
- value: true,
1646
- checkedIcon: /*#__PURE__*/React__default.createElement(Location, null),
1647
- checked: drawMode === MapDrawMode.POINT,
1648
- onChange: function onChange() {
1649
- setDrawMode(MapDrawMode.POINT);
1650
- },
1651
- "data-testid": "drawtools-point",
1652
- sx: styles$1.radioInput
1653
- }))), /*#__PURE__*/React__default.createElement(Grid, {
1654
- item: true
1655
- }, /*#__PURE__*/React__default.createElement(CustomTooltip, {
1656
- title: "Draw a box as ".concat(type, " position")
1657
- }, /*#__PURE__*/React__default.createElement(Radio, {
1658
- icon: /*#__PURE__*/React__default.createElement(DrawRegion, null),
1659
- checkedIcon: /*#__PURE__*/React__default.createElement(DrawRegion, null),
1660
- checked: drawMode === MapDrawMode.BOX,
1661
- onChange: function onChange() {
1662
- setDrawMode(MapDrawMode.BOX);
1663
- },
1664
- "data-testid": "drawtools-box",
1665
- sx: styles$1.radioInput
1666
- }))), /*#__PURE__*/React__default.createElement(Grid, {
1667
- item: true
1668
- }, /*#__PURE__*/React__default.createElement(CustomTooltip, {
1669
- title: "Draw a shape as ".concat(type, " position")
1670
- }, /*#__PURE__*/React__default.createElement(Radio, {
1671
- icon: /*#__PURE__*/React__default.createElement(DrawPolygon, null),
1672
- checkedIcon: /*#__PURE__*/React__default.createElement(DrawPolygon, null),
1673
- checked: drawMode === MapDrawMode.POLYGON,
1674
- onChange: function onChange() {
1675
- setDrawMode(MapDrawMode.POLYGON);
1676
- },
1677
- "data-testid": "drawtools-polygon",
1678
- sx: styles$1.radioInput
1679
- }))), /*#__PURE__*/React__default.createElement(Grid, {
1680
- item: true
1681
- }, /*#__PURE__*/React__default.createElement(CustomTooltip, {
1682
- title: "Set FIR as ".concat(type, " position")
1683
- }, /*#__PURE__*/React__default.createElement(Radio, {
1684
- icon: /*#__PURE__*/React__default.createElement(DrawFIRLand, null),
1685
- checkedIcon: /*#__PURE__*/React__default.createElement(DrawFIRLand, null),
1686
- checked: drawMode === MapDrawMode.FIR,
1687
- onChange: function onChange() {
1688
- setDrawMode(MapDrawMode.FIR);
1689
- },
1690
- "data-testid": "drawtools-fir",
1691
- sx: styles$1.radioInput
1692
- }))), /*#__PURE__*/React__default.createElement(Grid, {
1693
- item: true
1694
- }, /*#__PURE__*/React__default.createElement(CustomTooltip, {
1695
- title: "Remove geometry"
1696
- }, /*#__PURE__*/React__default.createElement(Radio, {
1697
- icon: /*#__PURE__*/React__default.createElement(Delete, null),
1698
- checkedIcon: /*#__PURE__*/React__default.createElement(Delete, null),
1699
- checked: drawMode === MapDrawMode.DELETE,
1700
- onChange: function onChange() {
1701
- setDrawMode(MapDrawMode.DELETE);
1702
- },
1703
- "data-testid": "drawtools-delete",
1704
- sx: styles$1.radioInput
1705
- }))));
1318
+ var getProjection = function getProjection(productConfig) {
1319
+ var _a;
1320
+ return ((_a = productConfig.mapPreset) === null || _a === void 0 ? void 0 : _a.proj) || undefined;
1321
+ };
1322
+ var getShapeWithProperties = function getShapeWithProperties(shape, properties) {
1323
+ return Object.assign(Object.assign({}, shape), {
1324
+ properties: Object.assign(Object.assign({}, shape.properties), properties)
1325
+ });
1326
+ };
1327
+ var firID = 'drawtools-fir';
1328
+ var getDrawTools = function getDrawTools(type, firShape) {
1329
+ var defaultStyleProperties = type === StartOrEndDrawing.start ? featurePropsStart : featurePropsEnd;
1330
+ return [Object.assign(Object.assign({}, defaultPoint), {
1331
+ title: "Drop a point as ".concat(type, " position"),
1332
+ shape: getShapeWithProperties(defaultPoint.shape, defaultStyleProperties)
1333
+ }), Object.assign(Object.assign({}, defaultBox), {
1334
+ title: "Draw a box as ".concat(type, " position"),
1335
+ shape: getShapeWithProperties(defaultBox.shape, defaultStyleProperties)
1336
+ }), Object.assign(Object.assign({}, defaultPolygon), {
1337
+ title: "Draw a shape as ".concat(type, " position"),
1338
+ shape: getShapeWithProperties(defaultPolygon.shape, defaultStyleProperties)
1339
+ }), {
1340
+ id: firID,
1341
+ title: "Set FIR as ".concat(type, " position"),
1342
+ isSelectable: false,
1343
+ value: DRAWMODE.POLYGON,
1344
+ icon: /*#__PURE__*/React.createElement(DrawFIRLand, null),
1345
+ shape: addFeatureProperties(firShape, defaultStyleProperties)
1346
+ }, Object.assign(Object.assign({}, defaultDelete), {
1347
+ title: 'Remove geometry'
1348
+ })];
1349
+ };
1350
+ var updateDrawToolsWithFir = function updateDrawToolsWithFir(drawTools, newFirShape) {
1351
+ return drawTools.map(function (mode) {
1352
+ if (mode.id === firID) {
1353
+ return Object.assign(Object.assign({}, mode), {
1354
+ shape: newFirShape
1355
+ });
1356
+ }
1357
+ return mode;
1358
+ });
1706
1359
  };
1707
1360
 
1708
1361
  /* *
@@ -2370,9 +2023,11 @@ var multiIntersectionsMessage = 'The drawn polygon has multiple intersections wi
2370
2023
  var StartGeometry = function StartGeometry(_ref) {
2371
2024
  var _ref$isReadOnly = _ref.isReadOnly,
2372
2025
  isReadOnly = _ref$isReadOnly === void 0 ? false : _ref$isReadOnly,
2373
- drawMode = _ref.drawMode,
2374
- geoJSONs = _ref.geoJSONs,
2375
- setDrawModeType = _ref.setDrawModeType;
2026
+ activeTool = _ref.activeTool,
2027
+ tools = _ref.tools,
2028
+ onChangeTool = _ref.onChangeTool,
2029
+ geoJSON = _ref.geoJSON,
2030
+ geoJSONIntersection = _ref.geoJSONIntersection;
2376
2031
  var _useFormContext = useFormContext(),
2377
2032
  errors = _useFormContext.formState.errors,
2378
2033
  watch = _useFormContext.watch;
@@ -2383,21 +2038,19 @@ var StartGeometry = function StartGeometry(_ref) {
2383
2038
  sx: styles$2.drawSection,
2384
2039
  "data-testid": "startGeometry"
2385
2040
  }, /*#__PURE__*/React__default.createElement(DrawTools, {
2386
- type: StartOrEndDrawing.start,
2387
- drawMode: drawMode[StartOrEndDrawing.start],
2388
- setDrawMode: function setDrawMode(mapDrawMode) {
2389
- setDrawModeType(mapDrawMode, StartOrEndDrawing.start);
2390
- }
2391
- }), drawMode[StartOrEndDrawing.start] && /*#__PURE__*/React__default.createElement(FormHelperText, {
2041
+ activeTool: activeTool,
2042
+ tools: tools,
2043
+ onChangeTool: onChangeTool
2044
+ }), activeTool && /*#__PURE__*/React__default.createElement(FormHelperText, {
2392
2045
  variant: "filled",
2393
2046
  sx: styles$2.quitDrawModeMessage
2394
2047
  }, exitDrawModeMessage), !!errors.startGeometry && /*#__PURE__*/React__default.createElement(FormHelperText, {
2395
2048
  error: true,
2396
2049
  variant: "filled"
2397
2050
  }, errors.startGeometry.message), /* non-blocking warnings */
2398
- hasMaxFeaturePoints(geoJSONs.intersectionStart) && !drawMode[StartOrEndDrawing.start] && !errors.startGeometry && !isFir(geoJSONs.start) && /*#__PURE__*/React__default.createElement(FormHelperText, {
2051
+ hasMaxFeaturePoints(geoJSONIntersection) && !activeTool && !errors.startGeometry && !isFir(geoJSON) && /*#__PURE__*/React__default.createElement(FormHelperText, {
2399
2052
  variant: "filled"
2400
- }, maxFeaturePointsMessage), hasMulitpleIntersections(geoJSONs.intersectionStart) && !drawMode[StartOrEndDrawing.start] && !errors.startGeometry && !isFir(geoJSONs.start) && /*#__PURE__*/React__default.createElement(FormHelperText, {
2053
+ }, maxFeaturePointsMessage), hasMulitpleIntersections(geoJSONIntersection) && !activeTool && !errors.startGeometry && !isFir(geoJSON) && /*#__PURE__*/React__default.createElement(FormHelperText, {
2401
2054
  variant: "filled"
2402
2055
  }, multiIntersectionsMessage), /*#__PURE__*/React__default.createElement(ReactHookFormHiddenInput, {
2403
2056
  name: "startGeometry",
@@ -2473,15 +2126,19 @@ var _validateMovementSteps = function validateMovementSteps(value, unit, product
2473
2126
  var Progress = function Progress(_ref) {
2474
2127
  var productType = _ref.productType,
2475
2128
  productConfig = _ref.productConfig,
2476
- drawMode = _ref.drawMode,
2477
2129
  _ref$isDisabled = _ref.isDisabled,
2478
2130
  isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
2479
2131
  _ref$isReadOnly = _ref.isReadOnly,
2480
2132
  isReadOnly = _ref$isReadOnly === void 0 ? false : _ref$isReadOnly,
2481
- geoJSONs = _ref.geoJSONs,
2482
- setDrawModeType = _ref.setDrawModeType,
2483
2133
  _ref$onChange = _ref.onChange,
2484
- _onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
2134
+ _onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
2135
+ _ref$tools = _ref.tools,
2136
+ tools = _ref$tools === void 0 ? [] : _ref$tools,
2137
+ activeTool = _ref.activeTool,
2138
+ _ref$onChangeTool = _ref.onChangeTool,
2139
+ onChangeTool = _ref$onChangeTool === void 0 ? function () {} : _ref$onChangeTool,
2140
+ geoJSON = _ref.geoJSON,
2141
+ geoJSONIntersection = _ref.geoJSONIntersection;
2485
2142
  var _useFormContext = useFormContext(),
2486
2143
  watch = _useFormContext.watch,
2487
2144
  getValues = _useFormContext.getValues,
@@ -2522,10 +2179,15 @@ var Progress = function Progress(_ref) {
2522
2179
  isRequired: isRequired
2523
2180
  }
2524
2181
  },
2182
+ isReadOnly: isReadOnly,
2525
2183
  onChange: function onChange() {
2526
- return setDrawModeType ? setDrawModeType(MapDrawMode.DELETE, StartOrEndDrawing.end) : null;
2527
- },
2528
- isReadOnly: isReadOnly
2184
+ var deleteTool = tools === null || tools === void 0 ? void 0 : tools.find(function (tool) {
2185
+ return tool.value === 'DELETE';
2186
+ });
2187
+ if (deleteTool) {
2188
+ onChangeTool(deleteTool);
2189
+ }
2190
+ }
2529
2191
  }, watch('phenomenon') === 'VA_CLD' && /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
2530
2192
  value: "NO_VA_EXP",
2531
2193
  label: "No volcanic ash expected",
@@ -2640,21 +2302,19 @@ var Progress = function Progress(_ref) {
2640
2302
  sx: styles$2.drawSection
2641
2303
  }, !isReadOnly && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(DrawTools, {
2642
2304
  "data-testid": "endGeometry-drawTools",
2643
- type: StartOrEndDrawing.end,
2644
- drawMode: drawMode[StartOrEndDrawing.end],
2645
- setDrawMode: function setDrawMode(mapDrawMode) {
2646
- setDrawModeType(mapDrawMode, StartOrEndDrawing.end);
2647
- }
2648
- }), drawMode[StartOrEndDrawing.end] && /*#__PURE__*/React__default.createElement(FormHelperText, {
2305
+ tools: tools,
2306
+ activeTool: activeTool,
2307
+ onChangeTool: onChangeTool
2308
+ }), activeTool && /*#__PURE__*/React__default.createElement(FormHelperText, {
2649
2309
  variant: "filled",
2650
2310
  sx: styles$2.quitDrawModeMessage
2651
2311
  }, exitDrawModeMessage), !!errors.endGeometry && /*#__PURE__*/React__default.createElement(FormHelperText, {
2652
2312
  error: true,
2653
2313
  variant: "filled"
2654
2314
  }, errors.endGeometry.message), /* non-blocking warnings */
2655
- hasMaxFeaturePoints(geoJSONs.intersectionEnd) && !drawMode[StartOrEndDrawing.end] && !errors.endGeometry && !isFir(geoJSONs.end) && /*#__PURE__*/React__default.createElement(FormHelperText, {
2315
+ hasMaxFeaturePoints(geoJSONIntersection) && !activeTool && !errors.endGeometry && !isFir(geoJSON) && /*#__PURE__*/React__default.createElement(FormHelperText, {
2656
2316
  variant: "filled"
2657
- }, maxFeaturePointsMessage), hasMulitpleIntersections(geoJSONs.intersectionEnd) && !drawMode[StartOrEndDrawing.end] && !errors.endGeometry && !isFir(geoJSONs.end) && /*#__PURE__*/React__default.createElement(FormHelperText, {
2317
+ }, maxFeaturePointsMessage), hasMulitpleIntersections(geoJSONIntersection) && !activeTool && !errors.endGeometry && !isFir(geoJSON) && /*#__PURE__*/React__default.createElement(FormHelperText, {
2658
2318
  variant: "filled"
2659
2319
  }, multiIntersectionsMessage)), /*#__PURE__*/React__default.createElement(ReactHookFormHiddenInput, {
2660
2320
  name: "endGeometry",
@@ -5071,39 +4731,11 @@ initializeUseSelector(withSelector.exports.useSyncExternalStoreWithSelector);
5071
4731
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5072
4732
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
5073
4733
  * */
5074
- var allowOneGeoJSONFeature = function allowOneGeoJSONFeature(mode, geojson) {
5075
- switch (mode) {
5076
- case MapDrawMode.BOX:
5077
- case MapDrawMode.POLYGON:
5078
- return geojson.features[0].geometry.coordinates.length > 1 ? fn(geojson, function (draft) {
5079
- draft.features[0].geometry.coordinates = [draft.features[0].geometry.coordinates[1]];
5080
- }) : geojson;
5081
- default:
5082
- return geojson;
5083
- }
5084
- };
5085
4734
  var MapViewGeoJson = function MapViewGeoJson(_ref) {
5086
- var geoJSONs = _ref.geoJSONs,
5087
- initialBaseLayers = _ref.baseLayers,
4735
+ var initialBaseLayers = _ref.baseLayers,
5088
4736
  initialProjection = _ref.projection,
5089
- _ref$setLayerGeoJSONs = _ref.setLayerGeoJSONs,
5090
- setLayerGeoJSONs = _ref$setLayerGeoJSONs === void 0 ? function () {} : _ref$setLayerGeoJSONs,
5091
- _ref$layerDrawModes = _ref.layerDrawModes,
5092
- layerDrawModes = _ref$layerDrawModes === void 0 ? {
5093
- start: null,
5094
- end: null
5095
- } : _ref$layerDrawModes,
5096
- _ref$drawMode = _ref.drawMode,
5097
- drawMode = _ref$drawMode === void 0 ? {
5098
- start: null,
5099
- end: null
5100
- } : _ref$drawMode,
5101
- _ref$setDrawMode = _ref.setDrawMode,
5102
- setDrawMode = _ref$setDrawMode === void 0 ? function () {} : _ref$setDrawMode,
5103
- _ref$exitDrawModeCall = _ref.exitDrawModeCallbackStart,
5104
- exitDrawModeCallbackStart = _ref$exitDrawModeCall === void 0 ? function () {} : _ref$exitDrawModeCall,
5105
- _ref$exitDrawModeCall2 = _ref.exitDrawModeCallbackEnd,
5106
- exitDrawModeCallbackEnd = _ref$exitDrawModeCall2 === void 0 ? function () {} : _ref$exitDrawModeCall2;
4737
+ _ref$geoJSONLayers = _ref.geoJSONLayers,
4738
+ geoJSONLayers = _ref$geoJSONLayers === void 0 ? [] : _ref$geoJSONLayers;
5107
4739
  var dispatch = useDispatch();
5108
4740
  var firstMap = useSelector(function (store) {
5109
4741
  return mapSelectors.getFirstMap(store);
@@ -5115,44 +4747,44 @@ var MapViewGeoJson = function MapViewGeoJson(_ref) {
5115
4747
  var mapDimensions = useSelector(function (store) {
5116
4748
  return mapSelectors.getMapDimensions(store, firstMapId);
5117
4749
  }, shallowEqual);
5118
- var mapId = React.useRef("sigmet-".concat(generateMapId())).current;
5119
- var timesliderId = React.useRef("sigmet-".concat(generateTimesliderId())).current;
4750
+ var mapId = React.useRef("sigmet-".concat(mapStoreUtils.generateMapId())).current;
4751
+ var timesliderId = React.useRef("sigmet-".concat(mapStoreUtils.generateTimesliderId())).current;
5120
4752
  var syncGroupAddGroup = React.useCallback(function (payload) {
5121
- dispatch(SyncGroups.actions.syncGroupAddGroup(payload));
4753
+ dispatch(syncGroupsActions.syncGroupAddGroup(payload));
5122
4754
  }, [dispatch]);
5123
4755
  var syncGroupAddTarget = React.useCallback(function (payload) {
5124
- dispatch(SyncGroups.actions.syncGroupAddTarget(payload));
4756
+ dispatch(syncGroupsActions.syncGroupAddTarget(payload));
5125
4757
  }, [dispatch]);
5126
4758
  React.useEffect(function () {
5127
4759
  if (mapLayers && mapLayers.length) {
5128
4760
  // use maplayers, but change layerId and current mapId
5129
4761
  var layers = mapLayers.map(function (layer) {
5130
4762
  return Object.assign(Object.assign({}, layer), {
5131
- id: generateLayerId(),
4763
+ id: mapStoreUtils.generateLayerId(),
5132
4764
  mapId: mapId
5133
4765
  });
5134
4766
  });
5135
- dispatch(mapActions.setLayers({
4767
+ dispatch(mapStoreActions.setLayers({
5136
4768
  mapId: mapId,
5137
4769
  layers: layers
5138
4770
  }));
5139
4771
  }
5140
4772
  if (mapDimensions && mapDimensions.length) {
5141
- dispatch(mapActions.mapChangeDimension({
4773
+ dispatch(mapStoreActions.mapChangeDimension({
5142
4774
  mapId: mapId,
5143
4775
  dimension: mapDimensions[0],
5144
4776
  origin: 'MapViewGeoJson'
5145
4777
  }));
5146
4778
  }
5147
- var baseLayers = initialBaseLayers || [Object.assign(Object.assign({}, publicLayers.overLayer), {
4779
+ var baseLayers = initialBaseLayers || [Object.assign(Object.assign({}, defaultLayers.overLayer), {
5148
4780
  id: "countryborders-".concat(mapId)
5149
4781
  })];
5150
- dispatch(mapActions.setBaseLayers({
4782
+ dispatch(mapStoreActions.setBaseLayers({
5151
4783
  mapId: mapId,
5152
4784
  layers: baseLayers
5153
4785
  }));
5154
4786
  var projection = initialProjection || srsAndBboxDefault;
5155
- dispatch(mapActions.setBbox({
4787
+ dispatch(mapStoreActions.setBbox({
5156
4788
  mapId: mapId,
5157
4789
  bbox: projection.bbox,
5158
4790
  srs: projection.srs
@@ -5160,7 +4792,7 @@ var MapViewGeoJson = function MapViewGeoJson(_ref) {
5160
4792
  syncGroupAddGroup({
5161
4793
  groupId: 'Time_SigmetAirmet',
5162
4794
  title: 'Group 1 for sigmet/airmet map',
5163
- type: SyncGroups.constants.SYNCGROUPS_TYPE_SETTIME
4795
+ type: syncConstants.SYNCGROUPS_TYPE_SETTIME
5164
4796
  });
5165
4797
  syncGroupAddTarget({
5166
4798
  groupId: 'Time_SigmetAirmet',
@@ -5189,56 +4821,10 @@ var MapViewGeoJson = function MapViewGeoJson(_ref) {
5189
4821
  mapId: mapId
5190
4822
  })), /*#__PURE__*/React.createElement(MapViewConnect, {
5191
4823
  mapId: mapId
5192
- }, /*#__PURE__*/React.createElement(MapViewLayer, {
5193
- id: "geojsonlayer-fir-".concat(mapId),
5194
- isInEditMode: false,
5195
- geojson: geoJSONs.fir
5196
- }), /*#__PURE__*/React.createElement(MapViewLayer, {
5197
- id: "geojsonlayer-end-".concat(mapId),
5198
- isInEditMode: drawMode.end !== null && layerDrawModes.end !== null,
5199
- geojson: geoJSONs.end,
5200
- drawMode: layerDrawModes.end,
5201
- updateGeojson: function updateGeojson(geojson) {
5202
- var end = allowOneGeoJSONFeature(layerDrawModes.end, geojson);
5203
- setLayerGeoJSONs(Object.assign(Object.assign({}, geoJSONs), {
5204
- end: end
5205
- }));
5206
- },
5207
- exitDrawModeCallback: function exitDrawModeCallback() {
5208
- setDrawMode({
5209
- start: null,
5210
- end: null
5211
- });
5212
- exitDrawModeCallbackEnd();
5213
- },
5214
- featureNrToEdit: 0
5215
- }), /*#__PURE__*/React.createElement(MapViewLayer, {
5216
- id: "geojsonlayer-start-".concat(mapId),
5217
- isInEditMode: drawMode.start !== null && layerDrawModes.start !== null,
5218
- geojson: geoJSONs.start,
5219
- drawMode: layerDrawModes.start,
5220
- updateGeojson: function updateGeojson(geojson) {
5221
- var start = allowOneGeoJSONFeature(layerDrawModes.start, geojson);
5222
- setLayerGeoJSONs(Object.assign(Object.assign({}, geoJSONs), {
5223
- start: start
5224
- }));
5225
- },
5226
- exitDrawModeCallback: function exitDrawModeCallback() {
5227
- setDrawMode({
5228
- start: null,
5229
- end: null
5230
- });
5231
- exitDrawModeCallbackStart();
5232
- },
5233
- featureNrToEdit: 0
5234
- }), /*#__PURE__*/React.createElement(MapViewLayer, {
5235
- id: "geojsonlayer-intersection-end-".concat(mapId),
5236
- isInEditMode: false,
5237
- geojson: geoJSONs.intersectionEnd
5238
- }), /*#__PURE__*/React.createElement(MapViewLayer, {
5239
- id: "geojsonlayer-intersection-start-".concat(mapId),
5240
- isInEditMode: false,
5241
- geojson: geoJSONs.intersectionStart
4824
+ }, geoJSONLayers.map(function (layer) {
4825
+ return /*#__PURE__*/React.createElement(MapViewLayer, Object.assign({
4826
+ key: layer.id
4827
+ }, layer));
5242
4828
  })), /*#__PURE__*/React.createElement("div", {
5243
4829
  style: {
5244
4830
  position: 'absolute',
@@ -5261,10 +4847,11 @@ var MapViewGeoJson = function MapViewGeoJson(_ref) {
5261
4847
  }));
5262
4848
  };
5263
4849
 
5264
- var ProductFormLayout = function ProductFormLayout(_a) {
5265
- var children = _a.children,
5266
- productConfig = _a.productConfig,
5267
- geojsonProps = __rest(_a, ["children", "productConfig"]);
4850
+ var ProductFormLayout = function ProductFormLayout(_ref) {
4851
+ var children = _ref.children,
4852
+ productConfig = _ref.productConfig,
4853
+ _ref$geoJSONLayers = _ref.geoJSONLayers,
4854
+ geoJSONLayers = _ref$geoJSONLayers === void 0 ? [] : _ref$geoJSONLayers;
5268
4855
  var theme = useTheme$2();
5269
4856
  var baseLayers = getBaseLayers(productConfig);
5270
4857
  var projection = getProjection(productConfig);
@@ -5288,10 +4875,11 @@ var ProductFormLayout = function ProductFormLayout(_a) {
5288
4875
  height: '100%',
5289
4876
  padding: 0
5290
4877
  })
5291
- }, /*#__PURE__*/React__default.createElement(MapViewGeoJson, Object.assign({
4878
+ }, /*#__PURE__*/React__default.createElement(MapViewGeoJson, {
5292
4879
  baseLayers: baseLayers,
5293
- projection: projection
5294
- }, geojsonProps))), /*#__PURE__*/React__default.createElement(Grid, {
4880
+ projection: projection,
4881
+ geoJSONLayers: geoJSONLayers
4882
+ })), /*#__PURE__*/React__default.createElement(Grid, {
5295
4883
  item: true,
5296
4884
  xs: 12,
5297
4885
  sm: 6,
@@ -8453,11 +8041,96 @@ var SigmetForm = function SigmetForm(_ref) {
8453
8041
  productConfig = _ref$productConfig === void 0 ? sigmetConfig : _ref$productConfig;
8454
8042
  var _useApiContext = useApiContext(),
8455
8043
  api = _useApiContext.api;
8044
+ var _useMapDrawTool = useMapDrawTool({
8045
+ defaultEditModes: getDrawTools(StartOrEndDrawing.start, getFir(productConfig)),
8046
+ defaultGeoJSON: !isCancelSigmet && initialSigmet ? addFeatureProperties(initialSigmet.startGeometry, featurePropsStart) : undefined,
8047
+ defaultGeoJSONIntersection: !isCancelSigmet && initialSigmet ? addFeatureProperties(initialSigmet.startGeometryIntersect, featurePropsIntersectionStart) : undefined,
8048
+ defaultGeoJSONIntersectionBounds: addFeatureProperties(getFir(productConfig), featurePropsFIR)
8049
+ }),
8050
+ startGeoJSON = _useMapDrawTool.geoJSON,
8051
+ startGeoJSONIntersection = _useMapDrawTool.geoJSONIntersection,
8052
+ getStartLayer = _useMapDrawTool.getLayer,
8053
+ startEditModes = _useMapDrawTool.editModes,
8054
+ activeStartTool = _useMapDrawTool.activeTool,
8055
+ changeActiveStartTool = _useMapDrawTool.changeActiveTool,
8056
+ deactivateStartTool = _useMapDrawTool.deactivateTool,
8057
+ setStartGeoJSONIntersectionBounds = _useMapDrawTool.setGeoJSONIntersectionBounds,
8058
+ setStartEditModes = _useMapDrawTool.setEditModes;
8059
+ var _useMapDrawTool2 = useMapDrawTool({
8060
+ defaultEditModes: getDrawTools(StartOrEndDrawing.end, getFir(productConfig)),
8061
+ defaultGeoJSON: !isCancelSigmet && initialSigmet ? addFeatureProperties(initialSigmet.endGeometry, featurePropsEnd) : undefined,
8062
+ defaultGeoJSONIntersection: !isCancelSigmet && initialSigmet ? addFeatureProperties(initialSigmet.endGeometryIntersect, featurePropsIntersectionEnd) : undefined,
8063
+ defaultGeoJSONIntersectionBounds: addFeatureProperties(getFir(productConfig), featurePropsFIR),
8064
+ defaultGeoJSONIntersectionProperties: featurePropsIntersectionEnd
8065
+ }),
8066
+ endGeoJSON = _useMapDrawTool2.geoJSON,
8067
+ endGeoJSONIntersection = _useMapDrawTool2.geoJSONIntersection,
8068
+ getEndLayer = _useMapDrawTool2.getLayer,
8069
+ endEditModes = _useMapDrawTool2.editModes,
8070
+ activeEndTool = _useMapDrawTool2.activeTool,
8071
+ changeActiveEndTool = _useMapDrawTool2.changeActiveTool,
8072
+ deactivateEndTool = _useMapDrawTool2.deactivateTool,
8073
+ setEndGeoJSONIntersectionBounds = _useMapDrawTool2.setGeoJSONIntersectionBounds,
8074
+ setEndEditModes = _useMapDrawTool2.setEditModes;
8075
+ var onUpdateStartgeoJSON = function onUpdateStartgeoJSON(updatedStartGeoJSON, updateStartGeoJSONIntersection) {
8076
+ setValue('startGeometry', updatedStartGeoJSON, {
8077
+ shouldValidate: true,
8078
+ shouldDirty: isGeometryDirty(watch('startGeometry'), updatedStartGeoJSON)
8079
+ });
8080
+ setValue('startGeometryIntersect', updateStartGeoJSONIntersection, {
8081
+ shouldValidate: true,
8082
+ shouldDirty: isGeometryDirty(watch('startGeometryIntersect'), updateStartGeoJSONIntersection)
8083
+ });
8084
+ onChangeForm();
8085
+ };
8086
+ var onUpdateEndGeoJson = function onUpdateEndGeoJson(updatedEndGeoJSON, updateEndGeoJSONIntersection) {
8087
+ setValue('endGeometry', updatedEndGeoJSON, {
8088
+ shouldValidate: true,
8089
+ shouldDirty: isGeometryDirty(watch('endGeometry'), updatedEndGeoJSON)
8090
+ });
8091
+ setValue('endGeometryIntersect', updateEndGeoJSONIntersection, {
8092
+ shouldValidate: true,
8093
+ shouldDirty: isGeometryDirty(watch('endGeometryIntersect'), updateEndGeoJSONIntersection)
8094
+ });
8095
+ onChangeForm();
8096
+ };
8097
+ var onChangeStartTool = function onChangeStartTool(newTool) {
8098
+ deactivateEndTool();
8099
+ changeActiveStartTool(newTool);
8100
+ if (!newTool.isSelectable) {
8101
+ deactivateStartTool();
8102
+ onUpdateStartgeoJSON(newTool.shape, newTool.shape);
8103
+ }
8104
+ };
8105
+ var onChangeEndTool = function onChangeEndTool(newTool) {
8106
+ deactivateStartTool();
8107
+ changeActiveEndTool(newTool);
8108
+ if (!newTool.isSelectable) {
8109
+ deactivateEndTool();
8110
+ onUpdateEndGeoJson(newTool.shape, newTool.shape);
8111
+ }
8112
+ };
8113
+ var onExitDrawMode = function onExitDrawMode() {
8114
+ deactivateStartTool();
8115
+ var newGeoStart = rewindGeometry(startGeoJSON);
8116
+ var newGeoStartIntersect = rewindGeometry(startGeoJSONIntersection);
8117
+ onUpdateStartgeoJSON(newGeoStart, newGeoStartIntersect);
8118
+ };
8119
+ var onExitDrawModeEnd = function onExitDrawModeEnd() {
8120
+ deactivateEndTool();
8121
+ var newGeoEnd = rewindGeometry(endGeoJSON);
8122
+ var newGeoEndIntersect = rewindGeometry(endGeoJSONIntersection);
8123
+ onUpdateEndGeoJson(newGeoEnd, newGeoEndIntersect);
8124
+ };
8125
+ var layers = [getStartLayer('geoJSONIntersectionBounds', 'geojsonlayer-fir'), Object.assign(Object.assign({}, getEndLayer('geoJSON', 'geojsonlayer-end')), {
8126
+ exitDrawModeCallback: onExitDrawModeEnd
8127
+ }), Object.assign(Object.assign({}, getStartLayer('geoJSON', 'geojsonlayer-start')), {
8128
+ exitDrawModeCallback: onExitDrawMode
8129
+ }), getEndLayer('geoJSONIntersection', 'geojsonlayer-intersection-end'), getStartLayer('geoJSONIntersection', 'geojsonlayer-intersection-start')];
8456
8130
  var _useFormContext2 = useFormContext(),
8457
8131
  watch = _useFormContext2.watch,
8458
8132
  setValue = _useFormContext2.setValue,
8459
- handleSubmit = _useFormContext2.handleSubmit,
8460
- getValues = _useFormContext2.getValues;
8133
+ handleSubmit = _useFormContext2.handleSubmit;
8461
8134
  var _React$useState = React__default.useState(mode === 'view'),
8462
8135
  _React$useState2 = _slicedToArray(_React$useState, 2),
8463
8136
  isDisabled = _React$useState2[0],
@@ -8471,65 +8144,31 @@ var SigmetForm = function SigmetForm(_ref) {
8471
8144
  var onChangeForm = function onChangeForm() {
8472
8145
  updateTac(watch);
8473
8146
  };
8474
- // TODO: [Loes Cornelis]: fix this whole mess of if statements for isCancelSigmet and hidden fields if disabled throughout the form
8475
- var initialGeometry = initialSigmet && !isCancelSigmet ? {
8476
- start: initialSigmet.startGeometry,
8477
- end: initialSigmet.endGeometry,
8478
- intersectionStart: initialSigmet.startGeometryIntersect,
8479
- intersectionEnd: initialSigmet.endGeometryIntersect
8480
- } : undefined;
8481
- var currentSelectedFIR = getValues('locationIndicatorATSR');
8482
- var _useDrawMode = useDrawMode(productConfig, initialGeometry, currentSelectedFIR),
8483
- drawMode = _useDrawMode.drawMode,
8484
- setDrawMode = _useDrawMode.setDrawMode,
8485
- layerDrawModes = _useDrawMode.layerDrawModes,
8486
- geoJSONs = _useDrawMode.geoJSONs,
8487
- _setLayerGeoJSONs = _useDrawMode.setLayerGeoJSONs,
8488
- _setDrawModeType = _useDrawMode.setDrawModeType;
8489
- var updateStartDrawing = function updateStartDrawing(mapGeoJSONS) {
8490
- var baseGeoJSON = mapGeoJSONS || geoJSONs;
8491
- var newGeoJSON = fn(baseGeoJSON, function (draftGeoJSON) {
8492
- // eslint-disable-next-line no-param-reassign
8493
- draftGeoJSON.start = rewindGeometry(baseGeoJSON.start);
8494
- // eslint-disable-next-line no-param-reassign
8495
- draftGeoJSON.intersectionStart = rewindGeometry(baseGeoJSON.intersectionStart);
8496
- });
8497
- setValue('startGeometry', newGeoJSON.start, {
8498
- shouldValidate: true,
8499
- shouldDirty: isGeometryDirty(watch('startGeometry'), newGeoJSON.start)
8500
- });
8501
- setValue('startGeometryIntersect', newGeoJSON.intersectionStart, {
8502
- shouldValidate: true,
8503
- shouldDirty: isGeometryDirty(watch('startGeometryIntersect'), newGeoJSON.intersectionStart)
8504
- });
8505
- onChangeForm();
8506
- };
8507
- var updateEndDrawing = function updateEndDrawing(mapGeoJSONS) {
8508
- var baseGeoJSON = mapGeoJSONS || geoJSONs;
8509
- var newGeoJSON = fn(baseGeoJSON, function (draftGeoJSON) {
8510
- // eslint-disable-next-line no-param-reassign
8511
- draftGeoJSON.end = rewindGeometry(baseGeoJSON.end);
8512
- // eslint-disable-next-line no-param-reassign
8513
- draftGeoJSON.intersectionEnd = rewindGeometry(baseGeoJSON.intersectionEnd);
8514
- });
8515
- setValue('endGeometry', newGeoJSON.end, {
8516
- shouldValidate: true,
8517
- shouldDirty: isGeometryDirty(watch('endGeometry'), newGeoJSON.end)
8518
- });
8519
- setValue('endGeometryIntersect', newGeoJSON.intersectionEnd, {
8520
- shouldValidate: true,
8521
- shouldDirty: isGeometryDirty(watch('endGeometryIntersect'), newGeoJSON.intersectionEnd)
8522
- });
8523
- onChangeForm();
8524
- };
8525
8147
  React__default.useEffect(function () {
8526
- var isInDrawMode = drawMode.start !== null || drawMode.end !== null;
8148
+ var isInDrawMode = activeStartTool !== '' || activeEndTool !== '';
8527
8149
  if (!isReadOnly && isInDrawMode !== isDisabled) {
8528
8150
  setIsDisabled(isInDrawMode);
8529
8151
  }
8530
- }, [drawMode.start, drawMode.end, isReadOnly, isDisabled]);
8152
+ }, [activeStartTool, activeEndTool, isReadOnly, isDisabled]);
8531
8153
  var _useConditionalFields = useConditionalFields$1(),
8532
8154
  hasVolcanicAshes = _useConditionalFields.hasVolcanicAshes;
8155
+ var onChangeFir = function onChangeFir(event) {
8156
+ var newFIRValue = event === null || event === void 0 ? void 0 : event.target.value;
8157
+ var newFirGeoJSON = addFeatureProperties(getFir(productConfig, newFIRValue), featurePropsFIR);
8158
+ // delete shape
8159
+ onChangeStartTool(startEditModes.find(function (mode) {
8160
+ return mode.value === 'DELETE';
8161
+ }));
8162
+ onChangeEndTool(endEditModes.find(function (mode) {
8163
+ return mode.value === 'DELETE';
8164
+ }));
8165
+ // update instersection bounds
8166
+ setStartGeoJSONIntersectionBounds(newFirGeoJSON);
8167
+ setEndGeoJSONIntersectionBounds(newFirGeoJSON);
8168
+ // update tool buttons with new fir geoJSON
8169
+ setStartEditModes(updateDrawToolsWithFir(startEditModes, newFirGeoJSON));
8170
+ setEndEditModes(updateDrawToolsWithFir(endEditModes, newFirGeoJSON));
8171
+ };
8533
8172
  var renderForm = function renderForm() {
8534
8173
  return /*#__PURE__*/React__default.createElement(Grid, {
8535
8174
  container: true,
@@ -8566,24 +8205,14 @@ var SigmetForm = function SigmetForm(_ref) {
8566
8205
  productConfig: productConfig,
8567
8206
  isDisabled: isDisabled,
8568
8207
  isReadOnly: isReadOnly,
8569
- onChange: function onChange(event) {
8570
- var newFIRValue = event === null || event === void 0 ? void 0 : event.target.value;
8571
- var updatedGeoJson = getInitialGeoJSONState(productConfig, newFIRValue);
8572
- _setDrawModeType(MapDrawMode.DELETE, StartOrEndDrawing.start, function () {
8573
- return updateStartDrawing(updatedGeoJson);
8574
- });
8575
- _setDrawModeType(MapDrawMode.DELETE, StartOrEndDrawing.end, function () {
8576
- return updateEndDrawing(updatedGeoJson);
8577
- });
8578
- _setLayerGeoJSONs(updatedGeoJson);
8579
- }
8208
+ onChange: onChangeFir
8580
8209
  }), /*#__PURE__*/React__default.createElement(StartGeometry, {
8581
8210
  isReadOnly: isReadOnly,
8582
- drawMode: drawMode,
8583
- geoJSONs: geoJSONs,
8584
- setDrawModeType: function setDrawModeType(mapDrawMode, StartOrEndDrawing) {
8585
- _setDrawModeType(mapDrawMode, StartOrEndDrawing, updateStartDrawing);
8586
- }
8211
+ geoJSON: startGeoJSON,
8212
+ geoJSONIntersection: startGeoJSONIntersection,
8213
+ tools: startEditModes,
8214
+ onChangeTool: onChangeStartTool,
8215
+ activeTool: activeStartTool
8587
8216
  }), !isCancelSigmet && /*#__PURE__*/React__default.createElement(Levels, {
8588
8217
  isDisabled: isDisabled,
8589
8218
  isReadOnly: isReadOnly,
@@ -8595,12 +8224,12 @@ var SigmetForm = function SigmetForm(_ref) {
8595
8224
  productConfig: productConfig,
8596
8225
  isDisabled: isDisabled,
8597
8226
  isReadOnly: isReadOnly,
8598
- drawMode: drawMode,
8599
- geoJSONs: geoJSONs,
8600
- setDrawModeType: function setDrawModeType(mapDrawMode, StartOrEndDrawing) {
8601
- _setDrawModeType(mapDrawMode, StartOrEndDrawing, updateEndDrawing);
8602
- },
8603
- onChange: onChangeForm
8227
+ onChange: onChangeForm,
8228
+ geoJSON: endGeoJSON,
8229
+ geoJSONIntersection: endGeoJSONIntersection,
8230
+ tools: endEditModes,
8231
+ onChangeTool: onChangeEndTool,
8232
+ activeTool: activeEndTool
8604
8233
  }), !isCancelSigmet && /*#__PURE__*/React__default.createElement(Change, {
8605
8234
  isDisabled: isDisabled,
8606
8235
  isReadOnly: isReadOnly
@@ -8644,15 +8273,7 @@ var SigmetForm = function SigmetForm(_ref) {
8644
8273
  }
8645
8274
  }, /*#__PURE__*/React__default.createElement(ProductFormLayout, {
8646
8275
  productConfig: productConfig,
8647
- geoJSONs: geoJSONs,
8648
- setLayerGeoJSONs: function setLayerGeoJSONs(geoJSONs) {
8649
- return _setLayerGeoJSONs(createInterSections(geoJSONs));
8650
- },
8651
- layerDrawModes: layerDrawModes,
8652
- drawMode: drawMode,
8653
- setDrawMode: setDrawMode,
8654
- exitDrawModeCallbackStart: updateStartDrawing,
8655
- exitDrawModeCallbackEnd: updateEndDrawing
8276
+ geoJSONLayers: layers
8656
8277
  }, renderForm()));
8657
8278
  };
8658
8279
 
@@ -8710,6 +8331,48 @@ var AirmetForm = function AirmetForm(_ref) {
8710
8331
  productConfig = _ref$productConfig === void 0 ? airmetConfig : _ref$productConfig;
8711
8332
  var _useApiContext = useApiContext(),
8712
8333
  api = _useApiContext.api;
8334
+ var _useMapDrawTool = useMapDrawTool({
8335
+ defaultEditModes: getDrawTools(StartOrEndDrawing.start, getFir(productConfig)),
8336
+ defaultGeoJSON: !isCancelAirmet && initialAirmet ? addFeatureProperties(initialAirmet.startGeometry, featurePropsStart) : undefined,
8337
+ defaultGeoJSONIntersection: !isCancelAirmet && initialAirmet ? addFeatureProperties(initialAirmet.startGeometryIntersect, featurePropsIntersectionStart) : undefined,
8338
+ defaultGeoJSONIntersectionBounds: addFeatureProperties(getFir(productConfig), featurePropsFIR)
8339
+ }),
8340
+ startGeoJSON = _useMapDrawTool.geoJSON,
8341
+ startGeoJSONIntersection = _useMapDrawTool.geoJSONIntersection,
8342
+ getStartLayer = _useMapDrawTool.getLayer,
8343
+ startEditModes = _useMapDrawTool.editModes,
8344
+ activeStartTool = _useMapDrawTool.activeTool,
8345
+ changeActiveStartTool = _useMapDrawTool.changeActiveTool,
8346
+ deactivateStartTool = _useMapDrawTool.deactivateTool,
8347
+ setStartGeoJSONIntersectionBounds = _useMapDrawTool.setGeoJSONIntersectionBounds,
8348
+ setStartEditModes = _useMapDrawTool.setEditModes;
8349
+ var onUpdateStartgeoJSON = function onUpdateStartgeoJSON(updatedStartGeoJSON, updateStartGeoJSONIntersection) {
8350
+ setValue('startGeometry', updatedStartGeoJSON, {
8351
+ shouldValidate: true,
8352
+ shouldDirty: isGeometryDirty(watch('startGeometry'), updatedStartGeoJSON)
8353
+ });
8354
+ setValue('startGeometryIntersect', updateStartGeoJSONIntersection, {
8355
+ shouldValidate: true,
8356
+ shouldDirty: isGeometryDirty(watch('startGeometryIntersect'), updateStartGeoJSONIntersection)
8357
+ });
8358
+ onChangeForm();
8359
+ };
8360
+ var onChangeStartTool = function onChangeStartTool(newTool) {
8361
+ changeActiveStartTool(newTool);
8362
+ if (!newTool.isSelectable) {
8363
+ deactivateStartTool();
8364
+ onUpdateStartgeoJSON(newTool.shape, newTool.shape);
8365
+ }
8366
+ };
8367
+ var onExitDrawMode = function onExitDrawMode() {
8368
+ deactivateStartTool();
8369
+ var newGeoStart = rewindGeometry(startGeoJSON);
8370
+ var newGeoStartIntersect = rewindGeometry(startGeoJSONIntersection);
8371
+ onUpdateStartgeoJSON(newGeoStart, newGeoStartIntersect);
8372
+ };
8373
+ var layers = [getStartLayer('geoJSONIntersectionBounds', 'geojsonlayer-fir'), Object.assign(Object.assign({}, getStartLayer('geoJSON', 'geojsonlayer-start')), {
8374
+ exitDrawModeCallback: onExitDrawMode
8375
+ }), getStartLayer('geoJSONIntersection', 'geojsonlayer-intersection-start')];
8713
8376
  var _useFormContext2 = useFormContext(),
8714
8377
  watch = _useFormContext2.watch,
8715
8378
  setValue = _useFormContext2.setValue,
@@ -8729,47 +8392,32 @@ var AirmetForm = function AirmetForm(_ref) {
8729
8392
  var onChangeForm = function onChangeForm() {
8730
8393
  updateTac(watch);
8731
8394
  };
8732
- var initialGeometry = initialAirmet && !isCancelAirmet ? {
8733
- start: initialAirmet.startGeometry,
8734
- intersectionStart: initialAirmet.startGeometryIntersect
8735
- } : undefined;
8736
- var currentSelectedFIR = getValues('locationIndicatorATSR');
8737
- var _useDrawMode = useDrawMode(productConfig, initialGeometry, currentSelectedFIR),
8738
- drawMode = _useDrawMode.drawMode,
8739
- setDrawMode = _useDrawMode.setDrawMode,
8740
- layerDrawModes = _useDrawMode.layerDrawModes,
8741
- geoJSONs = _useDrawMode.geoJSONs,
8742
- _setLayerGeoJSONs = _useDrawMode.setLayerGeoJSONs,
8743
- _setDrawModeType = _useDrawMode.setDrawModeType;
8744
- var updateStartDrawing = function updateStartDrawing(mapGeoJSONS) {
8745
- var baseGeoJSON = mapGeoJSONS || geoJSONs;
8746
- var newGeoJSON = fn(baseGeoJSON, function (draftGeoJSON) {
8747
- // eslint-disable-next-line no-param-reassign
8748
- draftGeoJSON.start = rewindGeometry(baseGeoJSON.start);
8749
- // eslint-disable-next-line no-param-reassign
8750
- draftGeoJSON.intersectionStart = rewindGeometry(baseGeoJSON.intersectionStart);
8751
- });
8752
- setValue('startGeometry', newGeoJSON.start, {
8753
- shouldValidate: true,
8754
- shouldDirty: isGeometryDirty(watch('startGeometry'), newGeoJSON.start)
8755
- });
8756
- setValue('startGeometryIntersect', newGeoJSON.intersectionStart, {
8757
- shouldValidate: true,
8758
- shouldDirty: isGeometryDirty(watch('startGeometryIntersect'), newGeoJSON.intersectionStart)
8759
- });
8760
- onChangeForm();
8761
- };
8762
8395
  React__default.useEffect(function () {
8763
- var isInDrawMode = drawMode.start !== null;
8396
+ var isInDrawMode = activeStartTool !== '';
8764
8397
  if (!isReadOnly && isInDrawMode !== isDisabled) {
8765
8398
  setIsDisabled(isInDrawMode);
8766
8399
  }
8767
- }, [drawMode.start, isReadOnly, isDisabled]);
8400
+ }, [activeStartTool, isReadOnly, isDisabled]);
8768
8401
  var _useConditionalFields = useConditionalFields(),
8769
8402
  hasSurfaceVisiblity = _useConditionalFields.hasSurfaceVisiblity,
8770
8403
  hasSurfaceWind = _useConditionalFields.hasSurfaceWind,
8771
8404
  hasLevels = _useConditionalFields.hasLevels,
8772
8405
  hasCloudLevels = _useConditionalFields.hasCloudLevels;
8406
+ var onChangeFir = function onChangeFir(event) {
8407
+ var newFIRValue = event === null || event === void 0 ? void 0 : event.target.value;
8408
+ var newFirGeoJSON = addFeatureProperties(getFir(productConfig, newFIRValue), featurePropsFIR);
8409
+ // delete shape
8410
+ onChangeStartTool(startEditModes.find(function (mode) {
8411
+ return mode.value === 'DELETE';
8412
+ }));
8413
+ // update instersection bounds
8414
+ setStartGeoJSONIntersectionBounds(newFirGeoJSON);
8415
+ // update tool buttons with new fir geoJSON
8416
+ setStartEditModes(updateDrawToolsWithFir(startEditModes, newFirGeoJSON));
8417
+ // trigger validation for airmet specific fields that depend on FIR config
8418
+ var fieldnames = ['windDirection', 'windSpeed', 'visibilityValue', 'cloudLevel.value', 'cloudLowerLevel.value'];
8419
+ triggerValidations(fieldnames, getValues, trigger);
8420
+ };
8773
8421
  var renderForm = function renderForm() {
8774
8422
  return /*#__PURE__*/React__default.createElement(Grid, {
8775
8423
  container: true,
@@ -8812,24 +8460,14 @@ var AirmetForm = function AirmetForm(_ref) {
8812
8460
  isReadOnly: isReadOnly,
8813
8461
  isDisabled: isDisabled,
8814
8462
  productConfig: productConfig,
8815
- onChange: function onChange(event) {
8816
- var newFIRValue = event === null || event === void 0 ? void 0 : event.target.value;
8817
- var updatedGeoJson = getInitialGeoJSONState(productConfig, newFIRValue);
8818
- _setDrawModeType(MapDrawMode.DELETE, StartOrEndDrawing.start, function () {
8819
- return updateStartDrawing(updatedGeoJson);
8820
- });
8821
- _setLayerGeoJSONs(updatedGeoJson);
8822
- // trigger validation for airmet specific fields that depend on FIR config
8823
- var fieldnames = ['windDirection', 'windSpeed', 'visibilityValue', 'cloudLevel.value', 'cloudLowerLevel.value'];
8824
- triggerValidations(fieldnames, getValues, trigger);
8825
- }
8463
+ onChange: onChangeFir
8826
8464
  }), /*#__PURE__*/React__default.createElement(StartGeometry, {
8827
8465
  isReadOnly: isReadOnly,
8828
- drawMode: drawMode,
8829
- geoJSONs: geoJSONs,
8830
- setDrawModeType: function setDrawModeType(mapDrawMode, StartOrEndDrawing) {
8831
- _setDrawModeType(mapDrawMode, StartOrEndDrawing, updateStartDrawing);
8832
- }
8466
+ geoJSON: startGeoJSON,
8467
+ geoJSONIntersection: startGeoJSONIntersection,
8468
+ tools: startEditModes,
8469
+ onChangeTool: onChangeStartTool,
8470
+ activeTool: activeStartTool
8833
8471
  }), !isCancelAirmet && hasLevels && /*#__PURE__*/React__default.createElement(Levels, {
8834
8472
  isDisabled: isDisabled,
8835
8473
  isReadOnly: isReadOnly,
@@ -8883,14 +8521,7 @@ var AirmetForm = function AirmetForm(_ref) {
8883
8521
  }
8884
8522
  }, /*#__PURE__*/React__default.createElement(ProductFormLayout, {
8885
8523
  productConfig: productConfig,
8886
- geoJSONs: geoJSONs,
8887
- setLayerGeoJSONs: function setLayerGeoJSONs(geoJSONs) {
8888
- return _setLayerGeoJSONs(createInterSections(geoJSONs));
8889
- },
8890
- layerDrawModes: layerDrawModes,
8891
- drawMode: drawMode,
8892
- setDrawMode: setDrawMode,
8893
- exitDrawModeCallbackStart: updateStartDrawing
8524
+ geoJSONLayers: layers
8894
8525
  }, renderForm()));
8895
8526
  };
8896
8527
 
@@ -17007,4 +16638,4 @@ var AirmetComponentsLookUp = function AirmetComponentsLookUp(payload, _ref) {
17007
16638
  }
17008
16639
  };
17009
16640
 
17010
- export { AirmetComponentsLookUp, AirmetForm, AirmetPhenomena, CloudLevelUnits, ContentDialog, Direction, DownloadSigmetAirmetConfigWrapper, LevelUnits, MapDrawMode, MapViewGeoJson, MetInfoWrapper, MovementUnit, ProductList, ProductListRow, ProductStatusDescription, SigmetComponentsLookUp, SigmetForm, SigmetPhenomena, StartOrEndDrawing, VisibilityCause, WindUnit, airmetConfig, createApi$1 as createApi, createApi as createFakeApi, isInstanceOfAirmet, isInstanceOfCancelAirmet, isInstanceOfCancelSigmet, isInstanceOfCancelSigmetOrAirmet, isInstanceOfSigmet, isInstanceOfSigmetOrAirmet, sigmetConfig };
16641
+ export { AirmetComponentsLookUp, AirmetForm, AirmetPhenomena, CloudLevelUnits, ContentDialog, Direction, DownloadSigmetAirmetConfigWrapper, LevelUnits, MapViewGeoJson, MetInfoWrapper, MovementUnit, ProductList, ProductListRow, ProductStatusDescription, SigmetComponentsLookUp, SigmetForm, SigmetPhenomena, StartOrEndDrawing, VisibilityCause, WindUnit, airmetConfig, createApi$1 as createApi, createApi as createFakeApi, isInstanceOfAirmet, isInstanceOfCancelAirmet, isInstanceOfCancelSigmet, isInstanceOfCancelSigmetOrAirmet, isInstanceOfSigmet, isInstanceOfSigmetOrAirmet, sigmetConfig };