@metoceanapi/wxtiles-leaflet 2.2.0 → 2.4.0-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/GPLv3.txt +674 -0
  3. package/LICENSE.txt +12 -9
  4. package/README.md +16 -3
  5. package/dep.dot +33 -0
  6. package/dep.svg +233 -0
  7. package/dist/es/customlayer/customlayer.d.ts +3 -0
  8. package/dist/es/index.d.ts +19 -13
  9. package/dist/es/index.js +6 -2
  10. package/dist/es/wxAPI/WxAPI.d.ts +3 -61
  11. package/dist/es/wxAPI/WxDataSetManager.d.ts +35 -123
  12. package/dist/es/wxsource/wxsource.d.ts +118 -51
  13. package/dist/es/wxsource/wxsourcetypes.d.ts +70 -10
  14. package/dist/web/index.js +6 -2
  15. package/docs/docs/assets/highlight.css +7 -0
  16. package/docs/docs/assets/search.js +1 -1
  17. package/docs/docs/classes/CustomWxTilesLayer.html +4 -1
  18. package/docs/docs/classes/DataIntegral.html +9 -9
  19. package/docs/docs/classes/QTree.html +41 -14
  20. package/docs/docs/classes/RawCLUT.html +9 -9
  21. package/docs/docs/classes/TilesCache.html +5 -5
  22. package/docs/docs/classes/WxAPI.html +109 -79
  23. package/docs/docs/classes/WxAPIControl.html +242 -0
  24. package/docs/docs/classes/WxDataSetManager.html +166 -118
  25. package/docs/docs/classes/WxInfoControl.html +172 -0
  26. package/docs/docs/classes/WxLegendControl.html +166 -0
  27. package/docs/docs/classes/WxStyleEditorControl.html +462 -0
  28. package/docs/docs/classes/WxTileSource.html +204 -108
  29. package/docs/docs/classes/WxTimeControl.html +219 -0
  30. package/docs/docs/enums/TileType.html +4 -4
  31. package/docs/docs/functions/WXLOG.html +10 -5
  32. package/docs/docs/functions/WxCreateLegend.html +14 -9
  33. package/docs/docs/functions/WxGetColorSchemes.html +10 -5
  34. package/docs/docs/functions/WxGetColorStyles.html +10 -5
  35. package/docs/docs/functions/WxTilesLogging.html +13 -5
  36. package/docs/docs/index.html +27 -7
  37. package/docs/docs/interfaces/CachedUriLoaderPromiseFunc.html +7 -5
  38. package/docs/docs/interfaces/ColorStylesIncomplete.html +10 -5
  39. package/docs/docs/interfaces/Converter.html +3 -5
  40. package/docs/docs/interfaces/DataPicture.html +5 -5
  41. package/docs/docs/interfaces/FrameworkOptions.html +12 -6
  42. package/docs/docs/interfaces/IntegralPare.html +3 -3
  43. package/docs/docs/interfaces/SLinePoint.html +4 -4
  44. package/docs/docs/interfaces/Tree.html +11 -7
  45. package/docs/docs/interfaces/WxAPIOptions.html +33 -24
  46. package/docs/docs/interfaces/WxAllBoundariesMeta.html +14 -9
  47. package/docs/docs/interfaces/WxAllDatasetsShortMetas.html +11 -6
  48. package/docs/docs/interfaces/WxBoundaryMeta.html +18 -10
  49. package/docs/docs/interfaces/WxColorSchemes.html +10 -5
  50. package/docs/docs/interfaces/WxColorStyleStrict.html +44 -26
  51. package/docs/docs/interfaces/WxColorStyleWeak.html +46 -26
  52. package/docs/docs/interfaces/WxColorStylesStrict.html +2 -2
  53. package/docs/docs/interfaces/WxColorStylesWeakMixed.html +10 -5
  54. package/docs/docs/interfaces/WxData.html +10 -6
  55. package/docs/docs/interfaces/WxDataSetManagerOptions.html +15 -15
  56. package/docs/docs/interfaces/WxDatasetMeta.html +20 -20
  57. package/docs/docs/interfaces/WxDatasetShortMeta.html +9 -8
  58. package/docs/docs/interfaces/WxLayerAPI.html +24 -28
  59. package/docs/docs/interfaces/WxLayerBaseAPI.html +18 -22
  60. package/docs/docs/interfaces/WxLayerOptions.html +18 -13
  61. package/docs/docs/interfaces/WxLegend.html +16 -15
  62. package/docs/docs/interfaces/WxLngLat.html +3 -3
  63. package/docs/docs/interfaces/WxRasterData.html +11 -8
  64. package/docs/docs/interfaces/WxRequestInit.html +2 -2
  65. package/docs/docs/interfaces/WxSourceLayerOptions.html +14 -12
  66. package/docs/docs/interfaces/WxTick.html +8 -7
  67. package/docs/docs/interfaces/WxTileInfo.html +10 -10
  68. package/docs/docs/interfaces/WxUnits.html +10 -5
  69. package/docs/docs/interfaces/WxVariableMeta.html +13 -12
  70. package/docs/docs/interfaces/WxVariablesMetas.html +11 -6
  71. package/docs/docs/interfaces/XYZ.html +4 -4
  72. package/docs/docs/modules.html +21 -8
  73. package/docs/docs/types/DataIntegrals.html +10 -5
  74. package/docs/docs/types/DataPictures.html +10 -5
  75. package/docs/docs/types/ListenerMethod.html +10 -5
  76. package/docs/docs/types/Loader.html +116 -0
  77. package/docs/docs/types/Painter.html +116 -0
  78. package/docs/docs/types/SLine.html +11 -6
  79. package/docs/docs/types/SubTrees.html +10 -5
  80. package/docs/docs/types/SubTreesN.html +12 -7
  81. package/docs/docs/types/TreeN.html +12 -7
  82. package/docs/docs/types/WxDate.html +10 -5
  83. package/docs/docs/types/WxEventType.html +10 -5
  84. package/docs/docs/types/WxInstances.html +13 -6
  85. package/docs/docs/types/WxLayer.html +116 -0
  86. package/docs/docs/types/WxLayerVarsNames.html +11 -6
  87. package/docs/docs/types/WxURIs.html +10 -5
  88. package/docs/docs/types/WxUnitTuple.html +10 -5
  89. package/docs/docs/variables/WxLayerBaseImplementation.html +116 -0
  90. package/docs/script/script.js +6 -6
  91. package/hooks/pre-commit +29 -0
  92. package/package.json +9 -2
  93. package/src_example/frwrkdeps.ts +57 -18
  94. package/src_example/index.ts +2 -2
  95. package/src_example/start.ts +101 -47
  96. package/watch-public.mjs +16 -12
  97. package/dist/es/controls/WxAPIControl.d.ts +0 -19
  98. package/dist/es/controls/WxInfoControl.d.ts +0 -16
  99. package/dist/es/controls/WxLegendControl.d.ts +0 -14
  100. package/dist/es/controls/WxStyleEditorControl.d.ts +0 -52
  101. package/dist/es/controls/WxTimeControl .d.ts +0 -18
  102. package/dist/es/defaults/colorschemes.d.ts +0 -2
  103. package/dist/es/defaults/styles.d.ts +0 -2
  104. package/dist/es/defaults/uconv.d.ts +0 -2
  105. package/dist/es/utils/RawCLUT.d.ts +0 -57
  106. package/dist/es/utils/mercator.d.ts +0 -4
  107. package/dist/es/utils/qtree.d.ts +0 -27
  108. package/dist/es/utils/tests_wxtools.d.ts +0 -1
  109. package/dist/es/utils/wxtools.d.ts +0 -357
  110. package/dist/es/wxAPI/WxAPItypes.d.ts +0 -152
  111. package/dist/es/wxlayer/WxImplementation.d.ts +0 -189
  112. package/dist/es/wxlayer/loader.d.ts +0 -54
  113. package/dist/es/wxlayer/loadertools.d.ts +0 -50
  114. package/dist/es/wxlayer/painter.d.ts +0 -58
  115. package/dist/es/wxlayer/wxlayer.d.ts +0 -186
  116. package/docs/docs/classes/Loader.html +0 -165
  117. package/docs/docs/classes/Painter.html +0 -161
  118. package/docs/docs/classes/WxLayer.html +0 -419
  119. package/docs/docs/classes/WxLayerBaseImplementation.html +0 -427
  120. package/docs/examples/interactive.html +0 -84
  121. package/docs/examples/res/icon.png +0 -0
  122. package/docs/examples/res/wxtiles-logo.png +0 -0
  123. package/docs/examples/seaMaskAndAnimatedBlur.html +0 -76
  124. package/docs/examples/simpleDemo.html +0 -70
@@ -1,87 +1,154 @@
1
- import L from 'leaflet';
2
- import { type XYZ } from '../utils/wxtools';
3
- import { type WxRequestInit, type WxTileInfo, type WxLngLat, WxLayerOptions } from '../wxlayer/wxlayer';
4
- import { type WxRasterData } from '../wxlayer/painter';
5
- import { WxLayerBaseImplementation, type WxLayerAPI } from '../wxlayer/WxImplementation';
6
- import { FrameworkOptions } from './wxsourcetypes';
1
+ import type L from "leaflet";
2
+ import { type XYZ } from "@metoceanapi/wxtiles-common/utils/wxtools";
3
+ import { WxLayer as InnerWxLayer } from "@metoceanapi/wxtiles-common/wxlayer/wxlayer";
4
+ import type { WxRequestInit, WxLngLat, WxTileInfo, WxRasterData, WxLayerOptions } from "@metoceanapi/wxtiles-common/types";
5
+ import type { WxDataSetManager } from "../wxAPI/WxDataSetManager";
6
+ import { FrameworkParentClass, type FrameworkOptions } from "./wxsourcetypes";
7
+ export type WxLayer = InnerWxLayer<WxDataSetManager>;
8
+ export declare const WxLayerBaseImplementation: {
9
+ new (...args: any[]): {
10
+ _animation: boolean;
11
+ _animationSeed: number;
12
+ _redrawRequested?: Promise<void> | undefined;
13
+ readonly wxdatasetManager: import("@metoceanapi/wxtiles-common/managers/BaseDatasetManager").BaseDatasetManager;
14
+ getCurrentVariableMeta(): import("@metoceanapi/wxtiles-common/types").WxVariableMeta;
15
+ getDatasetMeta(): import("@metoceanapi/wxtiles-common/types").WxDatasetMeta;
16
+ getMetadata(): import("@metoceanapi/wxtiles-common/types").WxVariableMeta;
17
+ getVariablesNames(): import("@metoceanapi/wxtiles-common/types").WxLayerVarsNames;
18
+ clearCache(): void;
19
+ getCache(): import("@metoceanapi/wxtiles-common/types").WxRasterDataCache;
20
+ getCurrentStyleObjectCopy(): import("@metoceanapi/wxtiles-common/utils/wxtools").WxColorStyleStrict;
21
+ getTime(): string;
22
+ getAllTimes(): string[];
23
+ setTime(time?: import("@metoceanapi/wxtiles-common/types").WxDate | undefined, requestInit?: WxRequestInit | undefined, redraw?: boolean | undefined): Promise<string>;
24
+ preloadTime(time: import("@metoceanapi/wxtiles-common/types").WxDate, requestInit?: WxRequestInit | undefined): Promise<void>;
25
+ startAnimation(): void;
26
+ stopAnimation(): Promise<void>;
27
+ setCoarseLevel(level?: number): Promise<void>;
28
+ unsetCoarseLevel(): Promise<void>;
29
+ setStyleByName(wxstyleName: string, reload?: boolean): Promise<void>;
30
+ updateCurrentStyleObject(style?: import("@metoceanapi/wxtiles-common/utils/wxtools").WxColorStyleWeak | undefined, reload?: boolean, requestInit?: WxRequestInit | undefined): Promise<void>;
31
+ _redrawTiles(): Promise<void>;
32
+ _reloadVisible(requestInit?: WxRequestInit | undefined, redraw?: boolean | undefined): Promise<void>;
33
+ coveringTiles(): XYZ[];
34
+ update(): void;
35
+ _needUpdateDSManager: boolean;
36
+ _loadTileHelper(coords: XYZ, requestInit?: WxRequestInit | undefined): Promise<WxRasterData | null>;
37
+ id: string;
38
+ _layer: InnerWxLayer<import("@metoceanapi/wxtiles-common/managers/BaseDatasetManager").BaseDatasetManager>;
39
+ fire<T extends "changed">(type: T, data: import("@metoceanapi/wxtiles-common/types").WxEventType[T]): void;
40
+ };
41
+ } & {
42
+ new (options: FrameworkOptions, wxLayerOptions: WxLayerOptions<WxDataSetManager>): FrameworkParentClass<WxDataSetManager>;
43
+ extend(props: any): (new (...args: any[]) => any) & typeof L.Class; /**
44
+ * Creates a WxTile instance.
45
+ * @param {XYZ} coords - The tile's XYZ coordinates.
46
+ * @param {CanvasRenderingContext2D} ctx - The 2D canvas rendering context for the tile.
47
+ * @param {WxRasterData | null} raster_data - Raster data for the tile. Can be null if no data is available.
48
+ */
49
+ include(props: any): any;
50
+ mergeOptions(props: any): any;
51
+ addInitHook(initHookFn: () => void): any;
52
+ addInitHook(methodName: string, ...args: any[]): any;
53
+ callInitHooks(): void;
54
+ };
7
55
  /**
8
56
  * @ignore
9
- * A class to represent a tile
57
+ * A class to represent a single tile in the WxTileSource layer.
58
+ * Each tile contains its coordinates, a drawing context, and optional raster data.
10
59
  **/
11
60
  declare class WxTile {
12
61
  coords: XYZ;
13
62
  ctx: CanvasRenderingContext2D;
14
63
  raster_data: WxRasterData | null;
64
+ /**
65
+ * Creates a WxTile instance.
66
+ * @param {XYZ} coords - The tile's XYZ coordinates.
67
+ * @param {CanvasRenderingContext2D} ctx - The 2D canvas rendering context for the tile.
68
+ * @param {WxRasterData | null} raster_data - Raster data for the tile. Can be null if no data is available.
69
+ */
15
70
  constructor(coords: XYZ, ctx: CanvasRenderingContext2D, raster_data: WxRasterData | null);
71
+ /**
72
+ * Draws the tile content on its canvas.
73
+ * @param {HTMLCanvasElement | null} [canvas] - The canvas containing pre-rendered content to be drawn.
74
+ */
16
75
  draw(canvas?: HTMLCanvasElement | null): void;
17
76
  }
18
77
  /**
19
- * A custom layer source implementation
20
- * It is used to load and display weather data from the WxTiles server.
78
+ * A custom layer source implementation for displaying weather data tiles.
79
+ * This class integrates with Leaflet and the WxTiles API to fetch, display, and manage tiles
80
+ * representing weather data such as temperature, wind speed, or other meteorological variables.
81
+ *
21
82
  * @example
22
83
  * ```ts
23
- const wxapi = new WxAPI({ 'http://dataserver.com' });
24
-
25
- const datasetName = 'gfs.global';
26
- const variable = 'air.temperature.at-2m'; // Scalar example
27
-
28
- // Create a dataset manager (may be used for many layers from this dataset)
29
- const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
30
-
31
- // get proper representation of the variable
32
- const variables = wxdatasetManager.checkCombineVariableIfVector(variable);
33
-
34
- // create a layer source
35
- const wxsource = new WxTileSource({ wxdatasetManager, variables }, { id: 'wxsource', attribution: 'WxTiles' });
84
+ * const wxapi = new WxAPI({ dataServerURL: 'http://dataserver.com' });
85
+ * const datasetName = 'gfs.global';
86
+ * const variable = 'air.temperature.at-2m';
87
+ *
88
+ * // Create a dataset manager
89
+ * const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
90
+ *
91
+ * // Get variables (for scalar/vector representation)
92
+ * const variables = wxdatasetManager.checkCombineVariableIfVector(variable);
93
+ *
94
+ * // Create a layer source
95
+ * const wxsource = new WxTileSource({ wxdatasetManager, variables }, { id: 'wxsource', attribution: 'WxTiles' });
36
96
  * ```
37
- * Or use the {@link WxDataSetManager.createSourceLayer} method to create a layer/source in one step.
97
+ *
98
+ * Alternatively, use {@link WxDataSetManager.createSourceLayer} to simplify the creation process.
38
99
  */
39
- export declare class WxTileSource extends WxLayerBaseImplementation implements WxLayerAPI {
100
+ export declare class WxTileSource extends WxLayerBaseImplementation {
40
101
  /**
102
+ * Initializes a new WxTileSource instance.
41
103
  *
42
- * @param {WxLayerOptions} wxlayeroptions - The options for the {@link WxLayerBaseImplementation}.
43
- * @param {FrameworkOptions} frameworkOptions - The options for the framework.
104
+ * @param {WxLayerOptions} wxlayeroptions - Configuration options for the WxLayerBaseImplementation.
105
+ * @param {FrameworkOptions} frameworkOptions - Framework-specific options.
44
106
  */
45
- constructor(wxlayeroptions: WxLayerOptions, frameworkOptions: FrameworkOptions);
107
+ constructor(wxlayeroptions: WxLayerOptions<WxDataSetManager>, frameworkOptions: FrameworkOptions);
46
108
  /**
47
- * Get comprehensive information about the current point on map.
48
- * @param {WxLngLat} lnglat - Coordinates of the point.
49
- * @param map - map instance.
50
- * @returns {WxTileInfo | undefined }
51
- * */
109
+ * Retrieves information about a specific point on the map.
110
+ *
111
+ * @param {WxLngLat} lnglat - The longitude and latitude of the point.
112
+ * @param {any} anymap - The map instance. This is kept generic to allow flexibility.
113
+ * @returns {WxTileInfo | undefined} Information about the tile at the specified point, or undefined if unavailable.
114
+ */
52
115
  getLayerInfoAtLatLon(lnglat: WxLngLat, anymap: any): WxTileInfo | undefined;
53
116
  /**
54
- * @ignore
55
- * Reloads the tiles that are currently visible on the map. Used for time/particles animation.
56
- **/
117
+ * Reloads the visible tiles on the map.
118
+ * This method is typically used during animations or time-based updates.
119
+ *
120
+ * @param {WxRequestInit} [requestInit] - Request options such as signals for aborting requests.
121
+ */
57
122
  _reloadVisible(requestInit?: WxRequestInit): Promise<void>;
58
123
  /**
59
- * @ignore
60
- * Get the tiles that are currently visible on the map.
61
- * <MBOX API> get assigned by map.addSource *
62
- * */
124
+ * Retrieves the coordinates of tiles currently visible on the map.
125
+ * @returns {XYZ[]} An array of tile coordinates.
126
+ */
63
127
  coveringTiles(): XYZ[];
64
128
  /**
65
- * @ignore
66
- * @description reload tiles that are currently visible on the map.
67
- * <MBOX API> get assigned by map.addSource
129
+ * Redraws the tiles currently visible on the map.
130
+ * This ensures that updated raster data or animations are displayed.
68
131
  */
69
132
  update(): void;
70
- /** @ignore */
133
+ /**
134
+ * Iterates over all tiles and applies a callback function.
135
+ * @param {(wxtile: WxTile) => T} func - The callback function to execute for each tile.
136
+ * @param {string} name - A name for logging purposes.
137
+ * @returns {T[]} An array of results from the callback function.
138
+ */
71
139
  protected _ForEachWxTile<T>(func: (wxtile: WxTile) => T, name: string): T[];
72
140
  /**
73
- * @internal
74
- * Used by framework. Creates a representation of a tile for the framework.
75
- * @param tile - The tile coordinates to be loaded.
76
- * @param requestInit - The request options.
77
- * @returns {Promise<Picture>} - A picture of the tile.
141
+ * Creates a new tile element and loads its data.
142
+ *
143
+ * @param {L.Coords} coords - The coordinates of the tile to load.
144
+ * @param {L.DoneCallback} done - A callback function to signal completion.
145
+ * @returns {HTMLElement} The created canvas element representing the tile.
78
146
  */
79
147
  protected createTile(coords: L.Coords, done: L.DoneCallback): HTMLElement;
80
148
  /**
81
- * @internal
82
- * @description Called when the layer is removed from a map.
149
+ * Cleans up the layer when it is removed from a map.
83
150
  * @param {L.Map} map - The map instance.
84
- * @returns {this} - The WxTileSource instance.
151
+ * @returns {this} The current WxTileSource instance.
85
152
  */
86
153
  onRemove(map: L.Map): this;
87
154
  }
@@ -1,22 +1,82 @@
1
- import L from 'leaflet';
1
+ import L from "leaflet";
2
+ import { WxLayer as InnerWxLayer } from "@metoceanapi/wxtiles-common/wxlayer/wxlayer";
3
+ import type { BaseDatasetManager } from "@metoceanapi/wxtiles-common/managers/BaseDatasetManager";
4
+ import type { WxLayerOptions } from "@metoceanapi/wxtiles-common/types";
2
5
  /**
3
- * Framework dependent source type to be inherited by the framework dependent custom source type.
4
- * Mapbox does not provide a parent type for the custom source.
5
- * Leaflet provides a parent type for the custom layer to inherit from L.GridLayer.
6
- * Used as universal type for the custom source parent class. see {@link WxTileSource}
6
+ * **FrameworkParentClass**
7
+ *
8
+ * A framework-specific base class for custom layer sources.
9
+ *
10
+ * - In **Leaflet**, this class extends `L.GridLayer`, which serves as a parent type for tile-based layers.
11
+ * - In **Mapbox**, a similar universal parent type does not exist, so this class provides a unified interface
12
+ * for creating custom sources that integrate seamlessly across frameworks.
13
+ *
14
+ * This class acts as a foundation for the {@link WxTileSource} implementation and can be extended
15
+ * to include framework-specific behavior where required.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const layerOptions: FrameworkOptions = {
20
+ * id: 'weatherLayer',
21
+ * opacity: 0.8,
22
+ * attribution: 'WxTiles',
23
+ * };
24
+ * const customLayer = new FrameworkParentClass(layerOptions);
25
+ * customLayer.addTo(map);
26
+ * ```
7
27
  */
8
- export declare class FrameworkParentClass extends L.GridLayer {
28
+ export declare class FrameworkParentClass<WxDatasetManagerT extends BaseDatasetManager> extends L.GridLayer {
29
+ /**
30
+ * **Unique Layer Identifier**
31
+ *
32
+ * A required unique identifier for the layer. Useful for managing multiple layers
33
+ * and tracking them within a map instance.
34
+ */
9
35
  id: string;
10
- constructor(options: FrameworkOptions);
36
+ /**
37
+ * @ignore
38
+ * An instance of the layer
39
+ * */
40
+ readonly _layer: InnerWxLayer<WxDatasetManagerT>;
41
+ /**
42
+ * Creates an instance of the **FrameworkParentClass**.
43
+ *
44
+ * @param {FrameworkOptions} options - The framework-specific options for creating a grid-based layer.
45
+ * @param {string} options.id - A unique identifier for the layer.
46
+ * @param {number} [options.opacity] - Opacity of the layer (0 - fully transparent, 1 - fully opaque).
47
+ * @param {string} [options.attribution] - Attribution text for this layer (shown on the map).
48
+ * @param {boolean} [options.interactive] - Whether the layer responds to mouse events.
49
+ */
50
+ constructor(options: FrameworkOptions, wxLayerOptions: WxLayerOptions<WxDatasetManagerT>);
11
51
  }
12
52
  /**
13
- * Framework dependent options for constructing a layer.
14
- * Inherits from *L.GridLayerOptions*.
53
+ * **FrameworkOptions**
54
+ *
55
+ * Options for creating a custom weather layer in Leaflet.
56
+ *
57
+ * This interface extends the **L.GridLayerOptions** interface provided by Leaflet,
58
+ * adding a mandatory `id` field to uniquely identify the layer.
59
+ *
60
+ * @extends {L.GridLayerOptions}
61
+ *
15
62
  * @example
16
63
  * ```ts
17
- * const leafletOptions: FrameworkOptions = { opacity: 1, attribution: 'WxTiles' };
64
+ * const options: FrameworkOptions = {
65
+ * id: 'customWeatherLayer',
66
+ * opacity: 0.7,
67
+ * attribution: 'Weather Tiles © 2024',
68
+ * interactive: true,
69
+ * };
70
+ * const weatherLayer = new FrameworkParentClass(options);
71
+ * map.addLayer(weatherLayer);
18
72
  * ```
19
73
  */
20
74
  export interface FrameworkOptions extends L.GridLayerOptions {
75
+ /**
76
+ * **Layer Identifier**
77
+ *
78
+ * A unique string used to identify the layer instance. Required for distinguishing
79
+ * between multiple layers, especially when managing or removing them from the map.
80
+ */
21
81
  id: string;
22
82
  }
package/dist/web/index.js CHANGED
@@ -1,6 +1,10 @@
1
- var wxtilesleaflet=(()=>{var Ne=Object.create;var X=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var Be=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Fe=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),Xe=(a,e)=>{for(var t in e)X(a,t,{get:e[t],enumerable:!0})},ue=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ze(e))!Ve.call(a,n)&&n!==t&&X(a,n,{get:()=>e[n],enumerable:!(r=$e(e,n))||r.enumerable});return a};var qe=(a,e,t)=>(t=a!=null?Ne(Be(a)):{},ue(e||!a||!a.__esModule?X(t,"default",{value:a,enumerable:!0}):t,a)),Oe=a=>ue(X({},"__esModule",{value:!0}),a);var Re=Fe((qt,ke)=>{ke.exports=window.L});var mt={};Xe(mt,{CustomWxTilesLayer:()=>te,DataIntegral:()=>F,Loader:()=>R,Painter:()=>U,QTree:()=>k,TilesCache:()=>N,WXLOG:()=>m,WxAPI:()=>ee,WxCreateLegend:()=>ce,WxDataSetManager:()=>V,WxGetColorSchemes:()=>O,WxGetColorStyles:()=>P,WxLayer:()=>$,WxLayerBaseImplementation:()=>Z,WxTileSource:()=>B,WxTilesLogging:()=>We});var me={comment1:["'degC': ['K', 1, 273.15] -> degC = K * 1 + 273.15",0],comment2:["'hPa': ['Pa', 1000]' -> hPa = Pa * 1000 + 0 (0 - could be ommited)",0],K:["K",1],kelvin:["K",1],F:["K",.5555555555,255.372222222],C:["K",1,273.15],degC:["K",1,273.15],"kg/m^2/s":["kg/m^2/s",1],"Kg/m^2/s":["kg/m^2/s",1],"Kg m**-2 s**-1":["kg/m^2/s",1],"Kg m^-2 s^-1":["kg/m^2/s",1],"Kg m^{-2} s^-1":["kg/m^2/s",1],"mm/h":["kg/m^2/s",.00027777777],"mm/hr":["kg/m^2/s",.00027777777],"W/m^2":["W/m^2",1],"W m^-2":["W/m^2",1],"W m^{-2}":["W/m^2",1],"W/m**2":["W/m^2",1],"W m**-2":["W/m^2",1],"m/s":["m/s",1],"m s**-1":["m/s",1],"m s^-1":["m/s",1],"m.s^{-1}":["m/s",1],knot:["m/s",.514444],knots:["m/s",.514444],"km/h":["m/s",.27777777777],"km h^-1":["m/s",.27777777777],"km h**-1":["m/s",.27777777777],mph:["m/s",.44704],"miles/h":["m/s",.44704],s:["s",1],sec:["s",1],h:["s",3600],min:["s",60],m:["m",1],cm:["m",.01],km:["m",1e3],mile:["m",1609.344],miles:["m",1609.344],inch:["m",.0254],Pa:["Pa",1],hPa:["Pa",100],degree:["degree",1],radian:["degree",57.3],"mg/m^3":["mg/m^3",1],"mg m^-3":["mg/m^3",1],"mg.m^-3":["mg/m^3",1],"%":["%",1],"(0 - 1)":["%",100]};var de={none:["#00000000","#00000000"],divergingbluered:["#2166acff","#92c5deff","#f7f7f7ff","#f4a582ff","#b2182bff"],rainbow:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbowzerro:["#ff000000","#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbow2:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff","#ff0000ff"],bluebird:["#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bluebirdzerro:["#0000ff00","#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bw:["#000000ff","#ffffffff"],wb:["#ffffffff","#000000ff"],redish:["#ff00ffff","#ff0000ff","#ffff00ff"],greenish:["#ffff00ff","#00ff00ff","#00ffffff"],blueish:["#ff00ffff","#0000ffff","#00ffffff"],hspastel:["#AC6EA4FF","#8E92BDFF","#ACD4DEFF","#E9DC8EFF","#E7A97DFF","#E59074FF","#BE7E68FF","#A88F86FF"]};var q={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"none",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"none",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"divergingbluered",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none",gl:{animationSpeed:1,noiseTexturePow:5,vectorFieldFactor:1,animationIntensity:5,wavesCount:4}},custom:{parent:void 0,name:"custom",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"}};var fe,xe,pe;function he({colorStyles:a={},units:e={},colorSchemes:t={}}={}){m("WxTile lib setup: start"),fe=Object.assign({},me,e),xe=Object.assign({},t,de);let r=Object.assign({},a,q);pe=Ee(r),m("WxTile lib setup: styles unrolled"),(async()=>{try{await document.fonts.load("32px barbs"),await document.fonts.load("32px arrows")}catch{m("WxTile lib setup: fonts not loaded")}})(),m("WxTile lib setup is done.")}function P(){return pe}function O(){return xe}function E(a,e,t){m("makeConverter: From=",a," To=",e);let r=g=>g;if(r.trivial=!0,a===e)return m("Trivial converter"),r;let n=Object.assign({},fe,t),s=n[a],o=n[e];if(!s||!o)return m("Inconvertible units. Trivial converter"),r;let[i,u,c]=s,[l,d,x]=o;if(i!==l||!u||!d)return m("Inconvertible units. Trivial converter"),r;let p=u/d,h=((c||0)-(x||0))/d;return h?g=>p*g+h:g=>p*g}function Ee(a){let e=Object.assign({},q);for(let s in a){let o=a[s];if(Array.isArray(o))for(let i=0;i<o.length;++i)e[s+"["+i+"]"]=Object.assign({},o[i]);else e[s]=Object.assign({},o)}let t=Object.assign({},q.base),r=(s,o)=>{if(o==="base")return t;let i=s[o];if(!i)return t;(!i.parent||!(i.parent in s))&&(i.parent="base");let u=r(s,i.parent);return Object.assign(i,Object.assign({},u,i,{parent:"base"}))},n={base:t};for(let s in e)n[s]=r(e,s);return n}function Y(a){let e=new Map,t=(r,...n)=>{let s=e.get(r);if(s)return s;let o=a(r,...n);return e.set(r,o),o.catch(i=>i.name==="AbortError"&&e.delete(r)),o};return t.clearCache=()=>e.clear(),t}async function Ye(a,e){let t=await fetch(a,e);if(t.status!==200&&t.status!==304)throw{name:"Tile loading failed",reason:t.headers.get("x-reason"),status:t.status};return await createImageBitmap(await t.blob(),{premultiplyAlpha:"none"})}var F=class{constructor(e,t,r,n){this.raw=e;this.dmin=t;this.dmax=r;this.dmul=n;this.radius=0}get integral(){return this.integral_||(this.integral_=ze(this.raw))}};function A(a,e,t=!0){let r=Object.assign(document.createElement("canvas"),{width:a,height:e,imageSmoothingEnabled:!1}).getContext("2d",{willReadFrequently:t});if(!r)throw new Error("Cannot get canvas context");return r}function je(a){let{width:e,height:t}=a,r=A(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}async function ae(a,e){return je(await Ye(a,e))}function Ge(a){a.data[34]<1&&m("Warning: image is in too old format. Check the version of the Splitter.");let e=new Uint16Array(a.data.buffer),t=new Uint16Array(e.length/2);for(let u=0;u<t.length;u++)t[u]=e[u*2];let r=new Uint8Array(8);for(let u=0;u<8;++u)r[u]=a.data[u*4+2];let n=new DataView(r.buffer),s=n.getFloat32(0,!0),o=n.getFloat32(4,!0),i=(o-s)/65535;return new F(t,s,o,i)}async function ge(a,e){return Ge(await ae(a,e))}function ze(a){let e=new Uint32Array(66564),t=new Uint32Array(258*258);e[0]=a[0],t[0]=a[0]?1:0;for(let r=1;r<258;++r){e[r]=a[r]+e[r-1],t[r]=(a[r]?1:0)+t[r-1];let n=258*r;e[n]=a[n]+e[n-258],t[n]=(a[n]?1:0)+t[n-258]}for(let r=1;r<258;++r)for(let n=1;n<258;++n){let s=258*r+n;e[s]=a[s]+e[s-258]+e[s-1]-e[s-259],t[s]=(a[s]?1:0)+t[s-258]+t[s-1]-t[s-259]}return{integral:e,integralNZ:t[66563]===66564?null:t}}function He(a){let{integral:e}=a.integral;a.raw[0]=e[0];for(let t=1;t<258;t++){a.raw[t]=e[t]-e[t-1],a.raw[258*t]=e[258*t]-e[258*(t-1)];for(let r=1;r<258;r++){let n=258*t+r;a.raw[n]=e[n-259]+e[n]-e[n-258]-e[n-1]}}return a}function ye(a,e){if(e<0&&(e=0),e===a.radius)return a;if(a.radius=e,!e)return He(a);let{integral:t,integralNZ:r}=a.integral;for(let n=2;n<256;n++)for(let s=2;s<256;s++){let o=258*n+s;if(!a.raw[o])continue;let i=Math.min(e,s-1,256-s),u=Math.min(e,n-1,256-n),c=258*(n-u-1)+s,l=258*(n+u)+s,d;if(r){let y=r[c-i-1],b=r[c+i],W=r[l-i-1],S=r[l+i];d=y+S-b-W}else d=(2*i+1)*(2*u+1);let x=t[c-i-1],p=t[c+i],h=t[l-i-1],g=t[l+i],f=x+g-p-h;a.raw[o]=f/d}for(let n=2;n<256;n++){let s=258+n;if(a.raw[s]){let c=n,l=Math.min(e,c-1,256-c),d=258+c,x;if(r){let M=r[d-l-1];x=0+r[d+l]-0-M}else x=(2*l+1)*2;let p=0,h=0,g=t[d-l-1],f=t[d+l],b=(p+f-h-g)/x;a.raw[s-258]=b,a.raw[s]=b}let o=258*256+n;if(a.raw[o]){let c=n,l=Math.min(e,c-1,256-c),d=258*255+c,x=258*257+c,p=t[d-l-1],h=t[d+l],g=t[x-l-1],f=t[x+l],y=p+f-h-g,b;if(r){let S=r[d-l-1],M=r[d+l],w=r[x-l-1],D=r[x+l];b=S+D-M-w}else b=(2*l+1)*2;let W=y/b;a.raw[o]=W,a.raw[o+258]=W}let i=258*n+1;if(a.raw[i]){let c=n,l=Math.min(e,c-1,256-c),d=258*(c-l-1)+1,x=258*(c+l)+1,p;if(r){let M=r[d],w=0;p=0+r[x]-M-w}else p=(2*l+1)*2;let h=0,g=t[d],f=0,y=t[x],W=(h+y-g-f)/p;a.raw[i-1]=W,a.raw[i]=W}let u=258*n+256;if(a.raw[u]){let c=n,l=Math.min(e,c-1,256-c),d=258*(c-l-1)+256,x=258*(c+l)+256,p;if(r){let S=r[d-1],M=r[d+1],w=r[x-1],D=r[x+1];p=S+D-M-w}else p=2*(2*l+1);let h=t[d-1],g=t[d+1],f=t[x-1],y=t[x+1],W=(h+y-g-f)/p;a.raw[u]=W,a.raw[u+1]=W}}return a}function T(a){let e=a>>0&255,t=a>>8&255,r=a>>16&255,n=e.toString(16),s=t.toString(16),o=r.toString(16);return n=n.length===2?n:"0"+n,s=s.length===2?s:"0"+s,o=o.length===2?o:"0"+o,"#"+n+s+o}function C(a){if(a[0]==="#"){if(a.length===4)return+("0xff"+a[3]+a[3]+a[2]+a[2]+a[1]+a[1]);if(a.length===7)return+("0xff"+a[5]+a[6]+a[3]+a[4]+a[1]+a[2]);if(a.length===9)return+("0x"+a[7]+a[8]+a[5]+a[6]+a[3]+a[4]+a[1]+a[2])}return m("wrong color format",a),0}async function v(a,e){let t=await fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()}function ne(a,e,t){let r=a>>0&255,n=a>>8&255,s=a>>16&255,o=a>>>24,i=e>>0&255,u=e>>8&255,c=e>>16&255,l=e>>>24,d=r+t*(i-r),x=n+t*(u-n),p=s+t*(c-s),h=o+t*(l-o);return d|x<<8|p<<16|h<<24}function be(a,e,t){let r=[];for(let n=0;n<t;++n)r.push(n*(e-a)/(t-1)+a);return r}var re=!1,m=(...a)=>{};function We(a){re=!!a,console.log("WXLOGing",re),m=typeof a=="function"?a:re?console.log:()=>{}}function se(a){return a[0]==="#"&&a.length===4?"#"+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]:a}function j(a,{x:e,y:t,z:r}){return a.replace("{x}",`${e}`).replace("{y}",`${t}`).replace("{z}",`${r}`)}function G({x:a,y:e,z:t}){return`${t}-${a}-${e}`}var Ke="A".charCodeAt(0);var k=class{constructor(e,t){this._qtree={nodes:null};this._qtreedepth=0;m("QTree.constructor"),this._ready=this._load(e,t)}get ready(){return this._ready}async _load(e,t){if(e!="none"){try{let r=await v(e,t);this._qtree=we(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this._qtreedepth=Se(this._qtree),m(`QTree.load: qtreedepth=${this._qtreedepth}`)}}check(e){let t=e.z-this._qtreedepth,r=t>=0,n=r?{x:e.x>>t,y:e.y>>t,z:this._qtreedepth}:{...e};return Me(this._qtree,n,r)}};function we(a,e){let t=a.charCodeAt(e.pos)-Ke;e.pos++;let r=[1,2,4,8].map(n=>t&n?we(a,e):null);return{nodes:r.some(n=>n)?r:null}}function Se(a){return a?.nodes?1+Math.max(...a.nodes.map(Se)):0}function Me(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,Me(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}var Je=2*Math.PI*6378137/256,z=2*Math.PI*6378137/2;function Qe(a,e){let t=a/z*180,r=e/z*180;return r=180/Math.PI*(2*Math.atan(Math.exp(r*Math.PI/180))-Math.PI/2),[r,t]}function et(a,e,t){let r=tt(t),n=a*r-z,s=e*r-z;return[n,s]}function tt(a){return Je/2**a}function oe(a,e,t){let[r,n]=Qe(...et(a,e,t));return[n,-r]}function De(a,e){return[a*256,e*256]}function ie(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function rt(a,e,t,r,n,s,o,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 0:return 0;case 1:return a;case 2:return e;case 3:t=a,r=e;break;case 4:return t;case 5:e=a,r=t;break;case 6:r=e+t>>1,a=r;break;case 7:r=e+t>>1;break;case 8:return r;case 9:e=a+r>>1,t=e;break;case 10:a=e,t=r;break;case 11:t=a+r>>1;break;case 12:a=t,e=r;break;case 13:e=a+r>>1;break;case 14:a=e+t>>1;break}a=o+i*a,e=o+i*e,t=o+i*t,r=o+i*r;let c=ie(a,e,n),l=ie(t,r,n),d=(ie(c,l,s)-o)/i;return d<1?1:d}function Te(a,e,t,r,n,s,o,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 7:return n+s<1?n*(e-a)+s*(t-a)+a:0;case 14:return n+s<1?0:n*(r-t)+s*(r-e)+e+t-r;case 11:return s<n?(1-n)*(a-e)+s*(r-e)+e:0;case 13:return s<n?0:(1-n)*(t-r)+s*(t-a)+a+r-t;case 15:return n+s<1?n*(e-a)+s*(t-a)+a:n*(r-t)+s*(r-e)+e+t-r;default:return 0}}function Ce(a,e,t){let r=1/2**t.z,n=t.x*256*r-.5,s=t.y*256*r-.5,{raw:o,dmin:i,dmax:u,dmul:c}=e,l={raw:new Uint16Array(258*258),dmin:i,dmax:u,dmul:c},{raw:d}=l;for(let x=-1,p=0,h=s-r+1;x<=256;x++,h+=r){let g=Math.floor(h),f=h-g,y=g*258;for(let b=-1,W=n-r+1;b<=256;b++,p++,W+=r){let S=Math.floor(W),M=W-S,w=S+y,D=o[w],I=o[w+1],_=o[w+258],L=o[w+258+1];d[p]=a(D,I,_,L,M,f,i,c)}}return l}function Ie(a,e,t){if(!e)return a;let r=l=>l<0?0:l>254?254:l,n=1/2**e.z,s=e.x*256*n-.5,o=e.y*256*n-.5,{data:i}=a,u=new ImageData(256,256),{data:c}=u;for(let l=0,d=t,x=o;l<256;l++,x+=n){let p=~~r(x),h=x-p,g=p*256;for(let f=0,y=s;f<256;f++,d+=4,y+=n){let b=~~r(y),W=y-b,S=(b+g)*4+t,M=i[S],w=i[S+4],D=i[S+4*256],I=i[S+4*256+4],_=Te(M,w,D,I,W,h,0,0);c[d]=_>127?255:0}}return u}function _e(a,e){return e?Ce(Te,a,e):a}function Le(a,e){return e?Ce(rt,a,e):a}function ve(a,{data:e},t,r){let n=r==="sea",{raw:s}=a;for(let o=t,i=259,u=0;u<256;i+=2,u++)for(let c=0;c<256;c++,i++,o+=4)n===!e[o]&&(s[i]=0);return a}function Pe(a){let[e,t]=De(a.x,a.y),[r,n]=oe(e,t,a.z),[s,o]=oe(e+256,t+256,a.z);return{west:r,north:n,east:s,south:o}}function le(a,e){let t=a.z-e;if(t<=0)return{upCoords:a};let r={x:a.x>>>t,y:a.y>>>t,z:e},n={x:a.x&(1<<t)-1,y:a.y&(1<<t)-1,z:t};return{upCoords:r,subCoords:n}}var R=class{constructor(e){this._loadDataFunc=Y(ge);this._layer=e}async load(e,t){let r=await this.cacheLoad(e,this._layer.tilesURIs,t);if(!r)return null;let{rawdata:n,subCoords:s,tileType:o}=r,{units:i}=this._layer.currentVariableMeta,u=i==="degree"?Le:_e,c=d=>u(ye(d,this._layer.style.blurRadius),s),l=n.map(c);return this._vectorMagnitudesPrepare(l),await this._applyMask(l,e,o,!s&&n.length===1),{data:l,slines:this._createStreamLines(l)}}async cacheLoad(e,t,r){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:s,subCoords:o}=le(e,this._layer.getCoarseMaxZoom()),i=t.map(l=>j(l,s)),u=Object.assign({},this._layer.wxdatasetManager.wxAPI.requestInit,{signal:r?.signal});return{rawdata:await Promise.all(i.map(l=>this._loadDataFunc(l,u))),subCoords:o,tileType:n}}clearCache(){this._loadDataFunc.clearCache()}async _applyMask(e,t,r,n){let{style:s}=this._layer;if((s.mask==="land"||s.mask==="sea")&&r==="mixed"){if(n){let{raw:u,dmin:c,dmax:l,dmul:d}=e[0];e[0]={raw:new Uint16Array(u),dmin:c,dmax:l,dmul:d}}let o,{wxAPI:i}=this._layer.wxdatasetManager;try{let{upCoords:u,subCoords:c}=le(t,i.maskDepth);o=await i.loadMaskFunc(u),o=Ie(o,c,i.maskChannel)}catch{s.mask=void 0,m("Can't load Mask. Masking is disabled");return}ve(e[0],o,i.maskChannel,s.mask)}}_vectorMagnitudesPrepare(e){if(e.length===1)return;e.unshift({raw:new Uint16Array(258*258),dmin:0,dmax:0,dmul:0});let[t,r,n]=e;t.dmax=1.42*Math.max(-r.dmin,r.dmax,-n.dmin,n.dmax),t.dmul=(t.dmax-t.dmin)/65535;for(let s=0;s<258*258;++s){if(!r.raw[s]||!n.raw[s])continue;let o=r.dmin+r.dmul*r.raw[s],i=n.dmin+n.dmul*n.raw[s];t.raw[s]=Math.sqrt(i*i+o*o)/t.dmul}}_checkTypeAndMask(e){let{mask:t}=this._layer.style;if(t==="land"||t==="sea"){let r=this._layer.wxdatasetManager.wxAPI.qtree.check(e);return t===r?void 0:r}return"mixed"}_checkInsideBoundaries(e){let t=this._layer.getBoundaries();if(t?.boundaries180){let r=Pe(e),n=s=>!(r.west>s.east||s.west>r.east||r.south>s.north||s.south>r.north);if(!t.boundaries180.some(n))return!1}return!0}_createStreamLines(e){if(e.length!==3)return[];let{style:t}=this._layer;if(t.streamLineColor==="none")return[];let r=[],[n,s,o]=e,i=(t.streamLineSpeedFactor||1)/n.dmax,u=t.addDegrees?.017453292519943*t.addDegrees:0,c=t.streamLineGridStep||64,l=t.streamLineSteps||300;for(let d=0;d<=256;d+=c)for(let x=0;x<=256;x+=c){if(!n.raw[1+x+(1+d)*258])continue;let p=[],h=x,g=d,f=-1,y=0,b=0;for(let M=0;M<=l&&h>=0&&h<=256&&g>=0&&g<=256;M++){M%(l/10)||p.push({x:~~h,y:~~g});let w=~~h+1+(~~g+1)*258;if(w!==f){if(!n.raw[w])break;f=w;let D=n.dmin+n.raw[w]*n.dmul,I=s.dmin+s.raw[w]*s.dmul,_=o.dmin+o.raw[w]*o.dmul,L=Math.atan2(I,_)+u;y=i*D*Math.sin(L),b=i*D*Math.cos(L)}h+=y,g-=b}let W=x,S=d;f=-1;for(let M=1;M<=l&&W>=0&&W<=256&&S>=0&&S<=256;M++){M%(l/10)||p.unshift({x:~~W,y:~~S});let w=~~W+1+(~~S+1)*258;if(w!==f){if(!n.raw[w])break;f=w;let D=n.dmin+n.raw[w]*n.dmul,I=s.dmin+s.raw[w]*s.dmul,_=o.dmin+o.raw[w]*o.dmul,L=Math.atan2(I,_)+u;y=i*D*Math.sin(L),b=i*D*Math.cos(L)}W-=y,S+=b}p.length>2&&r.push(p)}return r}};var U=class{constructor(e){this._layer=e}paint({data:e,ctxFill:t,ctxText:r,ctxStreamLines:n}){let{_layer:s}=this,{units:o}=s.currentVariableMeta,i=new ImageData(256,256),u=new Uint32Array(i.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),at(e.data[0],u,s);let c=nt(u,e.data[0],s);t.putImageData(i,0,0),st(c,r,s),ot(e.data,r,s),it(e.data[0],r,o,s),lt(e,r,s)}getPaintedCanvas(e,t,r){return t?(this.imprintVectorAnimationLinesStep(e,r),e.ctxStreamLines.canvas):e.ctxFill.canvas}imprintVectorAnimationLinesStep({data:e,ctxFill:t,ctxStreamLines:r},n){let{_layer:s}=this;r.clearRect(0,0,256,256),r.drawImage(t.canvas,0,0),!(e.slines.length===0||s.style.streamLineStatic||s.style.streamLineColor==="none")&&ct(e,r,s,n)}};function at(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:s}=t;if(r.fill!=="none")for(let o=0,i=0,u=259;o<256;++o,u+=2)for(let c=0;c<256;++c,++i,++u)e[i]=s[n[u]];else e.fill(0)}function nt(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:s,colorsI:o}=t,i=[];if(r.isolineColor!=="none"){let u=r.isolineColor[0]==="#"?C(r.isolineColor):0;for(let c=0,l=0;c<256;c+=1)for(let d=0;d<256;d+=1){let x=(c+1)*258+(d+1),p=n[x],h=n[x+1],g=n[x+258];if(!p||!h||!g)continue;let f=s[p],y=s[h],b=s[g];if(f!==y||f!==b){let W=Math.max(f,y,b),S=Math.max(p,h,g),M=c*256+d;switch(r.isolineColor){case"inverted":a[M]=~o[S]|4278190080;break;case"fill":a[M]=o[S]|4278190080;break;default:a[M]=u;break}r.isolineText&&!(++l%255)&&d>20&&d<235&&c>20&&c<235&&i.push({x:d,y:c,d:p,dr:h,db:g,mli:W})}}}return i}function st(a,e,{CLUT:t}){if(a.length){e.font="1.1em Sans-serif",e.lineWidth=2,e.strokeStyle="white",e.fillStyle="black",e.textAlign="center",e.textBaseline="middle";for(let{x:r,y:n,d:s,dr:o,db:i,mli:u}of a){let c=t.ticks[u].dataString,l=Math.atan2(s-o,i-s);e.save(),e.translate(r,n),e.rotate(l<-1.57||l>1.57?l+3.14:l),e.strokeText(c,0,0),e.fillText(c,0,0),e.restore()}}}function ot(a,e,{CLUT:t,style:r}){if(!t.DataToKnots||r.vectorColor==="none"||r.vectorType==="none")return;if(a.length!==3)throw new Error("data.length !== 3");let[n,s,o]=a;switch(r.vectorType){case"barbs":e.font="40px barbs";break;case"arrows":e.font="50px arrows";break;default:e.font=r.vectorType}e.textAlign="center",e.textBaseline="middle",e.fillStyle=r.vectorColor;let i=r.addDegrees?.017453292519943*r.addDegrees:0,u=32;for(let c=u/2;c<256;c+=u)for(let l=u/2;l<256;l+=u){let d=l+1+(c+1)*258;if(!n.raw[d])continue;let x=Math.atan2(s.dmin+s.raw[d]*s.dmul,o.dmin+o.raw[d]*o.dmul),p=n.dmin+n.raw[d]*n.dmul,h=r.vectorType!=="barbs"?r.vectorFactor*.5:.2,g=Math.min(~~(t.DataToKnots(p)*h),25)+65,f=String.fromCharCode(g);switch(r.vectorColor){case"inverted":e.fillStyle=T(~t.colorsI[n.raw[d]]);break;case"fill":e.fillStyle=T(t.colorsI[n.raw[d]]);break}e.save(),e.translate(l,c),e.rotate(x+i),e.fillText(f,0,0),e.restore()}}function it(a,e,t,{CLUT:r,style:n}){if(t!=="degree")return;let s=.017453292519943*n.addDegrees;e.font="50px arrows",e.textAlign="center",e.textBaseline="middle",e.fillStyle=n.vectorColor;let o="L",i=32;for(let u=i/2;u<256;u+=i)for(let c=i/2;c<256;c+=i){let l=c+1+(u+1)*258;if(!a.raw[l])continue;let x=(a.dmin+a.raw[l]*a.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=T(~r.colorsI[a.raw[l]]);break;case"fill":e.fillStyle=T(r.colorsI[a.raw[l]]);break}e.save(),e.translate(c,u),e.rotate(x+s),e.fillText(o,0,0),e.restore()}}function lt(a,e,{CLUT:t,style:r}){let{data:n,slines:s}=a;if(!s.length||!r.streamLineStatic||r.streamLineColor==="none")return;let o=n[0];e.lineWidth=1,r.streamLineColor[0]==="#"&&(e.strokeStyle=se(r.streamLineColor));for(let i=s.length;i--;){let u=s[i];for(let c=0;c<u.length-1;++c){let l=u[c],d=u[c+1],x=l.x+1+(l.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=T(~t.colorsI[o.raw[x]]);break;case"fill":e.strokeStyle=T(t.colorsI[o.raw[x]]);break}e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(d.x,d.y),e.stroke()}}}function ct(a,e,{CLUT:t,style:r},n){let{data:s,slines:o}=a,i=s[0],u=r.streamLineColor[0]==="#"?se(r.streamLineColor).substring(0,7):"#000000";n=n>>5;for(let c=0;c<o.length;++c){let l=o[c],d=l.length-1,x=(n+(1+l[0].x)*(1+l[0].y))%30;for(let p=0;p<d;++p){let h=l[p],g=l[p+1],f=1-(x-p)/d;(f<0||f>1)&&(f=0);let y=(~~(f*255)).toString(16).padStart(2,"0"),b=1+~~((1.2-f)*5);e.lineWidth=b;let W=h.x+1+(h.y+1)*258;switch(r.streamLineColor){case"inverted":u=T(~t.colorsI[i.raw[W]]);break;case"fill":u=T(t.colorsI[i.raw[W]]);break}e.strokeStyle=u+y,e.beginPath(),e.moveTo(h.x,h.y),e.lineTo(g.x,g.y),e.stroke()}}}function ut(a,e,t){return a>t?t:a<e?e:a}var H=class{constructor(e,t,[r,n],s){m("RawCLUT.constructor"),this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let o;this.DataToStyle=E(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),s&&(this.DataToKnots=E(t,"knot"));let i=E(e.units,t,e.extraUnits),u=f=>~~(65535*ut((i(f)-r)/(n-r),0,1));if(e.colorMap?.length)o=e.colorMap.sort((f,y)=>f[0]-y[0]).map(([f])=>u(f));else{e.levels||(e.levels=be(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((y,b)=>y-b);let f=O();e.colors||(e.colors=f[e.colorScheme&&e.colorScheme in f&&e.colorScheme||"wb"]),o=e.levels.map(u)}let c=n-r,l=ce(65536,e);this.ticks=l.ticks;let d=l.ticks[0].data,p=l.ticks[l.ticks.length-1].data-d,h=e.showBelowMin?l.colors[0]:0,g=e.showAboveMax?l.colors[65535]:0;this.colorsI[0]=0;for(let f=1;f<65536;++f){let y=this.DataToStyle(c*f/65535+r),b=Math.round(65535*(y-d)/p);this.colorsI[f]=b<=0?h:b>65535?g:l.colors[b]}for(let f=0;f<o[0];++f)this.levelIndex[f]=0;for(let f=0;f<o.length-1;f++)for(let y=o[f];y<o[f+1]+1;++y)this.levelIndex[y]=f;for(let f=o[o.length-1];f<65536;++f)this.levelIndex[f]=o.length-1}};function Ae(a){if(a!==0&&-.1<a&&a<.1)return a.toExponential(2);let e=a.toString();return e.split(".")[1]?.length>2?a.toFixed(2):e}function ce(a,e){let t={size:a,showBelowMin:e.showBelowMin,showAboveMax:e.showAboveMax,units:e.units,colors:new Uint32Array(a),ticks:[]},{colorMap:r,levels:n,colors:s}=e,o=e.fill!=="solid";if(r){let x=r[0][0],p=(a-1)/(r[r.length-1][0]-x);t.ticks=r.map(([h,g])=>({data:h,dataString:Ae(h),color:g,pos:~~((h-x)*p)}));for(let h=0;h<r.length-1;h++){let g=t.ticks[h].pos,f=t.ticks[h+1].pos,y=C(r[h][1]),b=o?C(r[h+1][1]):0;for(let W=g;W<f;++W)t.colors[W]=o?ne(y,b,(W-g)/(f-g)):y}return t.colors[a-1]=C(r[r.length-1][1]),t}if(!s||!n)return t;let i=0,u=0,c=-1;for(let x=0;x<a;++x){let p=x*(s.length-1)/a;c!==~~p&&(c=~~p,i=C(s[c]),u=s.length>c+1?C(s[c+1]):i),t.colors[x]=o?ne(i,u,p-c):i}t.colors[a-1]=C(s[s.length-1]);let l=n[0],d=(a-1)/(n[n.length-1]-l);return t.ticks=n.map(x=>{let p=~~((x-l)*d);return{data:x,dataString:Ae(x),pos:p,color:T(t.colors[p])}}),t}var N=class extends Map{clear(){m("TilesCache.clear()"),this.forEach(e=>{e.rd&&(e.rd.gl.deleteTexture(e.rd.vectorTextureU),e.rd.gl.deleteTexture(e.rd.vectorTextureV))}),super.clear()}},$=class{constructor(e){this.tilesRasterCache=new N;this.coarseLevel=0;this._painter=new U(this);this._loader=new R(this);if(m(`WxLayer.constructor:
1
+ var wxtilesleaflet=(()=>{var Oe=Object.create;var Z=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Ye=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),je=(r,e)=>{for(var t in e)Z(r,t,{get:e[t],enumerable:!0})},We=(r,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of He(e))!Xe.call(r,n)&&n!==t&&Z(r,n,{get:()=>e[n],enumerable:!(a=Ze(e,n))||a.enumerable});return r};var Ge=(r,e,t)=>(t=r!=null?Oe(qe(r)):{},We(e||!r||!r.__esModule?Z(t,"default",{value:r,enumerable:!0}):t,r)),ze=r=>We(Z({},"__esModule",{value:!0}),r);var ke=Ye((Ht,_e)=>{_e.exports=window.L});var vt={};je(vt,{CustomWxTilesLayer:()=>se,DataIntegral:()=>F,QTree:()=>$,WXLOG:()=>m,WxAPI:()=>ne,WxAPIControl:()=>ie,WxCreateLegend:()=>V,WxDataSetManager:()=>N,WxGetColorSchemes:()=>E,WxGetColorStyles:()=>k,WxInfoControl:()=>oe,WxLayerBaseImplementation:()=>be,WxLegendControl:()=>le,WxStyleEditorControl:()=>ce,WxTileSource:()=>B,WxTilesLogging:()=>we,WxTimeControl:()=>ue});var de={none:["#00000000","#00000000"],diverging_blue_red:["#2166acff","#92c5deff","#f7f7f7ff","#f4a582ff","#b2182bff"],rainbow:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbow_zero:["#ff000000","#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbow_wrap:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff","#ff0000ff"],rainbow_backwards:["#0000ffff","#00ffffff","#00ff00ff","#ffff00ff","#ff0000ff","#ff00ffff"],rainbow_backwards_zero:["#0000ff00","#0000ffff","#00ffffff","#00ff00ff","#ffff00ff","#ff0000ff","#ff00ffff"],bluebird:["#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bluebird_zero:["#0000ff00","#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],black_white:["#000000ff","#ffffffff"],white_black:["#ffffffff","#000000ff"],reddish:["#ff00ffff","#ff0000ff","#ffff00ff"],greenish:["#ffff00ff","#00ff00ff","#00ffffff"],blueish:["#ff00ffff","#0000ffff","#00ffffff"],hspastel:["#AC6EA4FF","#8E92BDFF","#ACD4DEFF","#E9DC8EFF","#E7A97DFF","#E59074FF","#BE7E68FF","#A88F86FF"],black:["#000000ff","#000000ff"],white:["#ffffffff","#ffffffff"],transparent:["#ffffff00"],peach_red_zero:["#fdd49f00","#fdd49fff","#d7301fff"]};var U={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"none",isolineText:!0,isolineTextSizeEm:1.1,isolineTextBackground:!1,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"none",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"diverging_blue_red",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none",gl:{animationIntensity:5,animationSpeed:1,noiseTexturePow:5,vectorFieldFactor:1,wavesCount:4}},custom:{parent:void 0,name:"custom",fill:"gradient",isolineColor:"inverted",isolineText:!0,isolineTextSizeEm:1.1,isolineTextBackground:!1,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"}};var me={comment1:["'degC': ['K', 1, 273.15] -> degC = K * 1 + 273.15",0],comment2:["'hPa': ['Pa', 1000]' -> hPa = Pa * 1000 + 0 (0 - could be ommited)",0],K:["K",1],kelvin:["K",1],F:["K",.5555555555,255.372222222],C:["K",1,273.15],degC:["K",1,273.15],"kg/m^2/s":["kg/m^2/s",1],"Kg/m^2/s":["kg/m^2/s",1],"Kg m**-2 s**-1":["kg/m^2/s",1],"Kg m^-2 s^-1":["kg/m^2/s",1],"Kg m^{-2} s^-1":["kg/m^2/s",1],"mm/h":["kg/m^2/s",.00027777777],"mm/hr":["kg/m^2/s",.00027777777],"W/m^2":["W/m^2",1],"W m^-2":["W/m^2",1],"W m^{-2}":["W/m^2",1],"W/m**2":["W/m^2",1],"W m**-2":["W/m^2",1],"m/s":["m/s",1],"m s**-1":["m/s",1],"m s^-1":["m/s",1],"m.s^{-1}":["m/s",1],knot:["m/s",.514444],knots:["m/s",.514444],"km/h":["m/s",.27777777777],"km h^-1":["m/s",.27777777777],"km h**-1":["m/s",.27777777777],mph:["m/s",.44704],"miles/h":["m/s",.44704],s:["s",1],sec:["s",1],h:["s",3600],min:["s",60],m:["m",1],cm:["m",.01],km:["m",1e3],mile:["m",1609.344],miles:["m",1609.344],inch:["m",.0254],Pa:["Pa",1],hPa:["Pa",100],degree:["degree",1],radian:["degree",57.3],"mg/m^3":["mg/m^3",1],"mg m^-3":["mg/m^3",1],"mg.m^-3":["mg/m^3",1],"%":["%",1],"(0 - 1)":["%",100]};var C={_units:me,_colorSchemes:de,_colorStylesUnrolled:U,wxlogging:!1};function Me({colorStyles:r={},units:e={},colorSchemes:t={}}={}){m("WxTile lib setup: start"),C._units=Object.assign({},me,e),C._colorSchemes=Object.assign({},t,de);let a=Object.assign({},r,U);C._colorStylesUnrolled=Ke(a),m("WxTile lib setup: styles unrolled"),(async()=>{try{await document.fonts.load("32px barbs"),await document.fonts.load("32px arrows")}catch{m("WxTile lib setup: fonts not loaded")}})(),m("WxTile lib setup is done.")}function k(){return C._colorStylesUnrolled}function E(){return C._colorSchemes}function H(r,e,t){m("makeConverter: From=",r," To=",e);let a=g=>g;if(a.trivial=!0,r===e)return m("Trivial converter"),a;let n=Object.assign({},C._units,t),s=n[r],i=n[e];if(!s||!i)return m("Inconvertible units. Trivial converter"),a;let[o,u,c]=s,[l,d,p]=i;if(o!==l||!u||!d)return m("Inconvertible units. Trivial converter"),a;let f=u/d,x=((c||0)-(p||0))/d;return x?g=>f*g+x:g=>f*g}function Ke(r){let e=Object.assign({},U);for(let s in r){let i=r[s];if(Array.isArray(i))for(let o=0;o<i.length;++o)e[`${s}[${o}]`]=Object.assign({},i[o]);else e[s]=Object.assign({},i)}let t=Object.assign({},U.base),a=(s,i)=>{if(i==="base")return t;let o=s[i];if(!o)return t;(!o.parent||!(o.parent in s))&&(o.parent="base");let u=a(s,o.parent);return Object.assign(o,Object.assign({},u,o,{parent:"base"}))},n={base:t};for(let s in e)n[s]=a(e,s);return n}function q(r){let e=new Map,t=(a,...n)=>{let s=e.get(a);if(s)return s;let i=r(a,...n);return e.set(a,i),i.catch(o=>o.name==="AbortError"&&e.delete(a)),i};return t.clearCache=()=>e.clear(),t}async function Je(r,e){let t=await fetch(r,e);if(t.status!==200&&t.status!==304)throw{name:"Tile loading failed",reason:t.headers.get("x-reason"),status:t.status};return await createImageBitmap(await t.blob(),{premultiplyAlpha:"none"})}var F=class{constructor(e,t,a,n){this.raw=e;this.dmin=t;this.dmax=a;this.dmul=n;this.radius=0}get integral(){return this.integral_||(this.integral_=tt(this.raw)),this.integral_}};function R(r,e,t=!0){let a=Object.assign(document.createElement("canvas"),{width:r,height:e,imageSmoothingEnabled:!1}).getContext("2d",{willReadFrequently:t});if(!a)throw new Error("Cannot get canvas context");return a}function Qe(r){let{width:e,height:t}=r,a=R(e,t);return a.drawImage(r,0,0),a.getImageData(0,0,e,t)}async function pe(r,e){return Qe(await Je(r,e))}function et(r){r.data[34]<1&&m("Warning: image is in too old format. Check the version of the Splitter.");let e=new Uint16Array(r.data.buffer),t=new Uint16Array(e.length/2);for(let u=0;u<t.length;u++)t[u]=e[u*2];let a=new Uint8Array(8);for(let u=0;u<8;++u)a[u]=r.data[u*4+2];let n=new DataView(a.buffer),s=n.getFloat32(0,!0),i=n.getFloat32(4,!0),o=(i-s)/65535;return new F(t,s,i,o)}async function Se(r,e){return et(await pe(r,e))}function tt(r){let e=new Uint32Array(66564),t=new Uint32Array(258*258);e[0]=r[0],t[0]=r[0]?1:0;for(let a=1;a<258;++a){e[a]=r[a]+e[a-1],t[a]=(r[a]?1:0)+t[a-1];let n=258*a;e[n]=r[n]+e[n-258],t[n]=(r[n]?1:0)+t[n-258]}for(let a=1;a<258;++a)for(let n=1;n<258;++n){let s=258*a+n;e[s]=r[s]+e[s-258]+e[s-1]-e[s-259],t[s]=(r[s]?1:0)+t[s-258]+t[s-1]-t[s-259]}return{integral:e,integralNZ:t[66563]===66564?null:t}}function at(r){let{integral:e}=r.integral;r.raw[0]=e[0];for(let t=1;t<258;t++){r.raw[t]=e[t]-e[t-1],r.raw[258*t]=e[258*t]-e[258*(t-1)];for(let a=1;a<258;a++){let n=258*t+a;r.raw[n]=e[n-259]+e[n]-e[n-258]-e[n-1]}}return r}function Te(r,e){let t=e<0?0:e;if(t===r.radius)return r;if(r.radius=t,!t)return at(r);let{integral:a,integralNZ:n}=r.integral;for(let s=2;s<256;s++)for(let i=2;i<256;i++){let o=258*s+i;if(!r.raw[o])continue;let u=Math.min(t,i-1,256-i),c=Math.min(t,s-1,256-s),l=258*(s-c-1)+i,d=258*(s+c)+i,p;if(n){let v=n[l-u-1],b=n[l+u],W=n[d-u-1],S=n[d+u];p=v+S-b-W}else p=(2*u+1)*(2*c+1);let f=a[l-u-1],x=a[l+u],g=a[d-u-1],h=a[d+u],y=f+h-x-g;r.raw[o]=y/p}for(let s=2;s<256;s++){let i=258+s;if(r.raw[i]){let l=s,d=Math.min(t,l-1,256-l),p=258+l,f;if(n){let M=n[p-d-1];f=0+n[p+d]-0-M}else f=(2*d+1)*2;let x=0,g=0,h=a[p-d-1],y=a[p+d],b=(x+y-g-h)/f;r.raw[i-258]=b,r.raw[i]=b}let o=258*256+s;if(r.raw[o]){let l=s,d=Math.min(t,l-1,256-l),p=258*255+l,f=258*257+l,x=a[p-d-1],g=a[p+d],h=a[f-d-1],y=a[f+d],v=x+y-g-h,b;if(n){let S=n[p-d-1],M=n[p+d],T=n[f-d-1],w=n[f+d];b=S+w-M-T}else b=(2*d+1)*2;let W=v/b;r.raw[o]=W,r.raw[o+258]=W}let u=258*s+1;if(r.raw[u]){let l=s,d=Math.min(t,l-1,256-l),p=258*(l-d-1)+1,f=258*(l+d)+1,x;if(n){let M=n[p],T=0;x=0+n[f]-M-T}else x=(2*d+1)*2;let g=0,h=a[p],y=0,v=a[f],W=(g+v-h-y)/x;r.raw[u-1]=W,r.raw[u]=W}let c=258*s+256;if(r.raw[c]){let l=s,d=Math.min(t,l-1,256-l),p=258*(l-d-1)+256,f=258*(l+d)+256,x;if(n){let S=n[p-1],M=n[p+1],T=n[f-1],w=n[f+1];x=S+w-M-T}else x=2*(2*d+1);let g=a[p-1],h=a[p+1],y=a[f-1],v=a[f+1],W=(g+v-h-y)/x;r.raw[c]=W,r.raw[c+1]=W}}return r}function D(r){let e=r>>0&255,t=r>>8&255,a=r>>16&255,n=e.toString(16),s=t.toString(16),i=a.toString(16);return n=n.length===2?n:`0${n}`,s=s.length===2?s:`0${s}`,i=i.length===2?i:`0${i}`,`#${n}${s}${i}`}function L(r){if(r[0]==="#"){if(r.length===4)return+`0xff${r[3]}${r[3]}${r[2]}${r[2]}${r[1]}${r[1]}`;if(r.length===7)return+`0xff${r[5]}${r[6]}${r[3]}${r[4]}${r[1]}${r[2]}`;if(r.length===9)return+`0x${r[7]}${r[8]}${r[5]}${r[6]}${r[3]}${r[4]}${r[1]}${r[2]}`}return m("wrong color format",r),0}async function _(r,e){let t=await fetch(r,e);if(!t.ok)throw new Error(`error:${r} - ${t.statusText}`);return t.json()}function fe(r,e,t){let a=r>>0&255,n=r>>8&255,s=r>>16&255,i=r>>>24,o=e>>0&255,u=e>>8&255,c=e>>16&255,l=e>>>24,d=a+t*(o-a),p=n+t*(u-n),f=s+t*(c-s),x=i+t*(l-i);return d|p<<8|f<<16|x<<24}function De(r,e,t){let a=[];for(let n=0;n<t;++n)a.push(n*(e-r)/(t-1)+r);return a}var m=(...r)=>{};function we(r){C.wxlogging=!!r,console.log("WXLOGing",C.wxlogging),m=typeof r=="function"?r:C.wxlogging?console.log:()=>{}}function xe(r){return r[0]==="#"&&r.length===4?`#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`:r}function X(r,{x:e,y:t,z:a}){return r.replace("{x}",`${e}`).replace("{y}",`${t}`).replace("{z}",`${a}`)}function Y({x:r,y:e,z:t}){return`${t}-${r}-${e}`}var rt="A".charCodeAt(0);var $=class{constructor(e,t){this._qtree={};this._qtreedepth=0;m("QTree.constructor"),this._ready=this._load(e,t)}get ready(){return this._ready}async _load(e,t){if(e!=="none"){try{let a=await _(e,t);this._qtree=Ie(a,{pos:0})}catch(a){throw new Error(`Failed to load QTree: ${a.message}`)}this._qtreedepth=Ce(this._qtree),m(`QTree.load: qtreedepth=${this._qtreedepth}`)}}check(e){let t=e.z-this._qtreedepth,a=t>=0,n=a?{x:e.x>>t,y:e.y>>t,z:this._qtreedepth}:{...e};return nt(this._qtree,n,a)}};function Ie(r,e){let t=r.charCodeAt(e.pos)-rt;e.pos++;let a=[1,2,4,8].map(n=>t&n?Ie(r,e):void 0);return a.some(n=>n)?{nodes:a}:{}}function Ce(r){return r?.nodes?1+Math.max(...r.nodes.map(Ce)):0}function nt(r,e,t){let a=r;for(;a;){if(t&&e.z===0)return"mixed";if(!a.nodes)return"sea";if(e.z===0)return"mixed";e.z--,a=a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1]}return"land"}var j=class{constructor(e){this.wxAPI=e;this.allDatasetsShortMetas={};this.ready=this.updateAll()}updateAll(){return this.ready=_(`${this.wxAPI.dataServerURL}meta.json`,this.wxAPI.requestInit),this.ready.then(e=>{this.allDatasetsShortMetas=e}),this.ready}async updateOne(e){try{let t=`${this.wxAPI.dataServerURL+e}/meta.json`,a=await _(t,this.wxAPI.requestInit);return Object.assign(this.allDatasetsShortMetas,a)}catch{return this.updateAll()}}};var G=class{constructor({dataServerURL:e,ext:t="webp",maskURL:a="none",maskChannel:n="R",maskDepth:s=11,qtreeURL:i="none",requestInit:o,colorStyles:u,units:c,colorSchemes:l}){if(m("WxAPI.constructor",e),Me({colorStyles:u,units:c,colorSchemes:l}),i==="auto"&&(i=`${e}masks/11+1.seamask.qtree`),a==="auto"&&(a=`${e}masks/{z}/{x}/{y}.${t}`),this.dataServerURL=e,this.ext=t,this.requestInit=o,this.maskURL=a,this.maskChannel=n==="R"?0:n==="G"?1:n==="B"?2:n==="A"?3:0,this.maskDepth=s,this.maskURL!=="none"){let d=q(pe);this.loadMaskFunc=p=>d(X(this.maskURL,p),o)}else this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));this._allDatasetsManager=new j(this),this.qtree=new $(i,o),this.initDone=Promise.all([this._allDatasetsManager.ready,this.qtree.ready]).then(()=>m("WxAPI.constructor initDone"))}async createDatasetManagerOptions(e){await this.initDone,await this._allDatasetsManager.updateOne(e),m("WxAPI.createDatasetManager",e);let t=this._allDatasetsManager.allDatasetsShortMetas[e],a=t?.instance;if(!a)throw new Error(`Dataset/instance not found:${e}`);let n=t.instanced,s,i=`${this.dataServerURL+e}/`;try{s=await _(`${i}metafull.json`,this.requestInit)}catch{m("Can't load metafull.json. Trying old infrastructure with NGINX");let l=await _(`${i}instances.json`,this.requestInit);if(!Array.isArray(l)||!l.length)throw new Error("instances.json is not an array or empty");s=await Promise.all(l.reverse().map(async d=>Object.assign(await _(`${i+d}/meta.json`,this.requestInit),{instance:d})))}let o=s[0],u=n&&new Map(s.map(c=>[c.instance,c]));return{datasetName:e,datasetCurrentInstance:a,datasetCurrentMeta:o,instanced:n,metas:u,wxAPI:this}}async getDatasetAllVariables(e){return await this.initDone,m("WxAPI.getDatasetVariables",e),this._allDatasetsManager.allDatasetsShortMetas[e]?.variables}async filterDatasetsByVariableName(e){await this.initDone,m("WxAPI.filterDatasetsByVariableName:",e);let{allDatasetsShortMetas:t}=this._allDatasetsManager;return Object.keys(t).filter(a=>t[a]?.variables.includes(e))}async getAllDatasetsNames(){return await this.initDone,m("WxAPI.getAllDatasetsNames"),Object.keys(this._allDatasetsManager.allDatasetsShortMetas)}};function Le(r){return class extends r{constructor(){super(...arguments);this._animation=!1;this._animationSeed=0;this._needUpdateDSManager=!1}get wxdatasetManager(){return m(`WxLayerBaseImplementation.wxdatasetManager (${this.id})`),this._layer.wxdatasetManager}getCurrentVariableMeta(){return m(`WxLayerBaseImplementation.getCurrentVariableMeta (${this.id})`),{...this._layer.currentVariableMeta}}getDatasetMeta(){return this._layer.wxdatasetManager.getInstanceMeta(this.getTime())}getMetadata(){return m(`WxLayerBaseImplementation.getMetadata (${this.id})`),{...this._layer.currentVariableMeta}}getVariablesNames(){return m(`WxLayerBaseImplementation.getVariables (${this.id})`),[...this._layer.variables]}clearCache(){m(`WxLayerBaseImplementation.clearCache (${this.id})`),this._layer.clearCache()}getCache(){return this._layer.tilesRasterCache}getCurrentStyleObjectCopy(){return m(`WxLayerBaseImplementation.getCurrentStyleObjectCopy (${this.id})`),this._layer.getCurrentStyleObjectCopy()}getTime(){return m(`WxLayerBaseImplementation.getTime (${this.id})`),this._layer.getTime()}getAllTimes(){return m(`WxLayerBaseImplementation.getTimes (${this.id})`),this._layer.wxdatasetManager.getAllTimes()}async setTime(t,a,n){m(`WxLayerBaseImplementation.setTime (${this.id}) time=${t}`);let s=this.getTime();return this._layer.setURLsAndTime(t),await this._reloadVisible(a,n),a?.signal?.aborted&&this._layer.setURLsAndTime(s),this.getTime()}async preloadTime(t,a){return m(`WxLayerBaseImplementation.preloadTime (${this.id}) time=${t}`),this._layer.preloadTime(t,this.coveringTiles(),a)}startAnimation(){if(this._animation){m(`WxLayerBaseImplementation.startAnimation (${this.id}) already started`);return}if(this._layer.nonanimatable){m(`WxLayerBaseImplementation.startAnimation (${this.id}) nonanimatable`);return}m(`WxLayerBaseImplementation.startAnimation (${this.id})`),this._animation=!0;let t=async a=>{if(m(`WxLayerBaseImplementation.startAnimation (${this.id}) animationStep`),!this._animation||this._layer.nonanimatable){this._animation=!1;return}this._animationSeed=a,await this._redrawTiles(),requestAnimationFrame(t)};requestAnimationFrame(t)}async stopAnimation(){return m(`WxLayerBaseImplementation.stopAnimation (${this.id})`),this._animation=!1,this._redrawTiles()}async setCoarseLevel(t=2){this._layer.coarseLevel=Math.max(0,Math.min(t,this.wxdatasetManager.getMaxZoom()))}async unsetCoarseLevel(){return this._layer.coarseLevel=0,this._reloadVisible()}async setStyleByName(t,a=!0){return m(`WxLayerBaseImplementation.setStyleByName (${this.id}) wxstyleName=${t} reload=${a}`),this.updateCurrentStyleObject(k()[t],a)}async updateCurrentStyleObject(t,a=!0,n){if(m(`WxLayerBaseImplementation.updateCurrentStyleObject (${this.id}) style=${t} reload=${a}`),this._layer.updateCurrentStyleObject(t),this.startAnimation(),a)return this._reloadVisible(n)}_redrawTiles(){return this._redrawRequested?this._redrawRequested:(this._redrawRequested=new Promise(t=>{requestAnimationFrame(()=>{m(`WxTileSource _redrawTiles (${this.id})`),this.update(),t(),this._redrawRequested=void 0})}),this._redrawRequested)}async _reloadVisible(t,a){}coveringTiles(){return[]}update(){}async _loadTileHelper(t,a){if(!this._needUpdateDSManager)try{return await this._layer.loadTile(t,a)}catch(n){if(n.name==="AbortError")throw n;n.reason==="instance-not-found"&&!this._needUpdateDSManager&&(this._needUpdateDSManager=!0,m(`WxTileSource.loadTile (${this.id}) instance-not-found. Trying to update wxdatasetManager and load again.`),this.wxdatasetManager.update().then(()=>{this._needUpdateDSManager=!1,this.setTime(this.getTime()).then(()=>this.fire("changed",this))}).catch(s=>{m(`WxTileSource.loadTile (${this.id}) instance-not-found. wxdatasetManager update failed.`,s)}))}return null}}}var Ve=Ge(ke());function st(r,e,t){return r>t?t:r<e?e:r}var z=class{constructor(e,t,[a,n],s){m("RawCLUT.constructor"),this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let i;this.DataToStyle=H(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),s&&(this.DataToKnots=H(t,"knot"));let o=H(e.units,t,e.extraUnits),u=h=>~~(65535*st((o(h)-a)/(n-a),0,1));if(e.colorMap?.length)i=e.colorMap.sort((h,y)=>h[0]-y[0]).map(([h])=>u(h));else{e.levels||=De(this.DataToStyle(a),this.DataToStyle(n),10),e.levels.sort((y,v)=>y-v);let h=E();e.colors||=h[e.colorScheme]||["#ffffffff","#000000ff"],i=e.levels.map(u)}let c=n-a,l=V(65536,e);this.ticks=l.ticks;let d=l.ticks[0].data,f=l.ticks[l.ticks.length-1].data-d,x=e.showBelowMin?l.colors[0]:0,g=e.showAboveMax?l.colors[65535]:0;this.colorsI[0]=0;for(let h=1;h<65536;++h){let y=this.DataToStyle(c*h/65535+a),v=Math.round(65535*(y-d)/f);this.colorsI[h]=v<=0?x:v>65535?g:l.colors[v]}for(let h=0;h<i[0];++h)this.levelIndex[h]=0;for(let h=0;h<i.length-1;h++)for(let y=i[h];y<i[h+1]+1;++y)this.levelIndex[y]=h;for(let h=i[i.length-1];h<65536;++h)this.levelIndex[h]=i.length-1}};function Pe(r){if(r!==0&&-.1<r&&r<.1)return r.toExponential(2);let e=r.toString();return e.split(".")[1]?.length>2?r.toFixed(2):e}function V(r,e){let t={size:r,showBelowMin:e.showBelowMin,showAboveMax:e.showAboveMax,units:e.units,colors:new Uint32Array(r),ticks:[]},{colorMap:a,levels:n,colors:s}=e,i=e.fill!=="solid";if(a){let p=a[0][0],f=(r-1)/(a[a.length-1][0]-p);t.ticks=a.map(([x,g])=>({data:x,dataString:Pe(x),color:g,pos:~~((x-p)*f)}));for(let x=0;x<a.length-1;x++){let g=t.ticks[x].pos,h=t.ticks[x+1].pos,y=L(a[x][1]),v=i?L(a[x+1][1]):0;for(let b=g;b<h;++b)t.colors[b]=i?fe(y,v,(b-g)/(h-g)):y}return t.colors[r-1]=L(a[a.length-1][1]),t}if(!s||!n)return t;let o=0,u=0,c=-1;for(let p=0;p<r;++p){let f=p*(s.length-1)/r;c!==~~f&&(c=~~f,o=L(s[c]),u=s.length>c+1?L(s[c+1]):o),t.colors[p]=i?fe(o,u,f-c):o}t.colors[r-1]=L(s[s.length-1]);let l=n[0],d=(r-1)/(n[n.length-1]-l);return t.ticks=n.map(p=>{let f=~~((p-l)*d);return{data:p,dataString:Pe(p),pos:f,color:D(t.colors[f])}}),t}var O=class extends Map{clear(){m("TilesCache.clear()");for(let e of this.values()){if(!e.rd)return;e.rd.gl.deleteTexture(e.rd.vectorTextureU),e.rd.gl.deleteTexture(e.rd.vectorTextureV)}super.clear()}};var it=2*Math.PI*6378137/256,K=2*Math.PI*6378137/2;function ot(r,e){let t=r/K*180,a=e/K*180;return a=180/Math.PI*(2*Math.atan(Math.exp(a*Math.PI/180))-Math.PI/2),[a,t]}function lt(r,e,t){let a=ct(t),n=r*a-K,s=e*a-K;return[n,s]}function ct(r){return it/2**r}function he(r,e,t){let[a,n]=ot(...lt(r,e,t));return[n,-a]}function Ae(r,e){return[r*256,e*256]}function ge(r,e,t){let a=((e-r)%360+540)%360-180;return(r+a*t+360)%360}function ut(r,e,t,a,n,s,i,o){let u=r,c=e,l=t,d=a;switch((u?1:0)|(c?2:0)|(l?4:0)|(d?8:0)){case 0:return 0;case 1:return u;case 2:return c;case 3:l=u,d=c;break;case 4:return l;case 5:c=u,d=l;break;case 6:d=c+l>>1,u=d;break;case 7:d=c+l>>1;break;case 8:return d;case 9:c=u+d>>1,l=c;break;case 10:u=c,l=d;break;case 11:l=u+d>>1;break;case 12:u=l,c=d;break;case 13:c=u+d>>1;break;case 14:u=c+l>>1;break}u=i+o*u,c=i+o*c,l=i+o*l,d=i+o*d;let f=ge(u,c,n),x=ge(l,d,n),g=(ge(f,x,s)-i)/o;return g<1?1:g}function Ee(r,e,t,a,n,s,i,o){switch((r?1:0)|(e?2:0)|(t?4:0)|(a?8:0)){case 7:return n+s<1?n*(e-r)+s*(t-r)+r:0;case 14:return n+s<1?0:n*(a-t)+s*(a-e)+e+t-a;case 11:return s<n?(1-n)*(r-e)+s*(a-e)+e:0;case 13:return s<n?0:(1-n)*(t-a)+s*(t-r)+r+a-t;case 15:return n+s<1?n*(e-r)+s*(t-r)+r:n*(a-t)+s*(a-e)+e+t-a;default:return 0}}function Re(r,e,t){let a=1/2**t.z,n=t.x*256*a-.5,s=t.y*256*a-.5,{raw:i,dmin:o,dmax:u,dmul:c}=e,l={raw:new Uint16Array(258*258),dmin:o,dmax:u,dmul:c},{raw:d}=l;for(let p=-1,f=0,x=s-a+1;p<=256;p++,x+=a){let g=Math.floor(x),h=x-g,y=g*258;for(let v=-1,b=n-a+1;v<=256;v++,f++,b+=a){let W=Math.floor(b),S=b-W,M=W+y,T=i[M],w=i[M+1],P=i[M+258],A=i[M+258+1];d[f]=r(T,w,P,A,S,h,o,c)}}return l}function $e(r,e,t){if(!e)return r;let a=l=>l<0?0:l>254?254:l,n=1/2**e.z,s=e.x*256*n-.5,i=e.y*256*n-.5,{data:o}=r,u=new ImageData(256,256),{data:c}=u;for(let l=0,d=t,p=i;l<256;l++,p+=n){let f=~~a(p),x=p-f,g=f*256;for(let h=0,y=s;h<256;h++,d+=4,y+=n){let v=~~a(y),b=y-v,W=(v+g)*4+t,S=o[W],M=o[W+4],T=o[W+4*256],w=o[W+4*256+4],P=Ee(S,M,T,w,b,x,0,0);c[d]=P>127?255:0}}return u}function Be(r,e){return e?Re(Ee,r,e):r}function Ne(r,e){return e?Re(ut,r,e):r}function Ue(r,{data:e},t,a){let n=a==="sea",{raw:s}=r;for(let i=t,o=259,u=0;u<256;o+=2,u++)for(let c=0;c<256;c++,o++,i+=4)n===!e[i]&&(s[o]=0);return r}function Fe(r){let[e,t]=Ae(r.x,r.y),[a,n]=he(e,t,r.z),[s,i]=he(e+256,t+256,r.z);return{west:a,north:n,east:s,south:i}}function ye(r,e){let t=r.z-e;if(t<=0)return{upCoords:r};let a={x:r.x>>>t,y:r.y>>>t,z:e},n={x:r.x&(1<<t)-1,y:r.y&(1<<t)-1,z:t};return{upCoords:a,subCoords:n}}var J=class{constructor(e){this._loadDataFunc=q(Se);this._layer=e}async load(e,t){let a=await this.cacheLoad(e,this._layer.tilesURIs,t);if(!a)return null;let{rawdata:n,subCoords:s,tileType:i}=a,{units:o}=this._layer.currentVariableMeta,u=o==="degree"?Ne:Be,c=d=>u(Te(d,this._layer.style.blurRadius),s),l=n.map(c);return this._vectorMagnitudesPrepare(l),await this._applyMask(l,e,i,!s&&n.length===1),{data:l,slines:this._createStreamLines(l)}}async cacheLoad(e,t,a){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:s,subCoords:i}=ye(e,this._layer.getCoarseMaxZoom()),o=t.map(l=>X(l,s)),u=Object.assign({},this._layer.wxdatasetManager.wxAPI.requestInit,{signal:a?.signal});return{rawdata:await Promise.all(o.map(l=>this._loadDataFunc(l,u))),subCoords:i,tileType:n}}clearCache(){this._loadDataFunc.clearCache()}async _applyMask(e,t,a,n){let{style:s}=this._layer;if((s.mask==="land"||s.mask==="sea")&&a==="mixed"){if(n){let{raw:u,dmin:c,dmax:l,dmul:d}=e[0];e[0]={raw:new Uint16Array(u),dmin:c,dmax:l,dmul:d}}let i,{wxAPI:o}=this._layer.wxdatasetManager;try{let{upCoords:u,subCoords:c}=ye(t,o.maskDepth);i=await o.loadMaskFunc(u),i=$e(i,c,o.maskChannel)}catch{s.mask=void 0,m("Can't load Mask. Masking is disabled");return}Ue(e[0],i,o.maskChannel,s.mask)}}_vectorMagnitudesPrepare(e){if(e.length===1)return;e.unshift({raw:new Uint16Array(258*258),dmin:0,dmax:0,dmul:0});let[t,a,n]=e;t.dmax=1.42*Math.max(-a.dmin,a.dmax,-n.dmin,n.dmax),t.dmul=(t.dmax-t.dmin)/65535;for(let s=0;s<258*258;++s){if(!a.raw[s]||!n.raw[s])continue;let i=a.dmin+a.dmul*a.raw[s],o=n.dmin+n.dmul*n.raw[s];t.raw[s]=Math.sqrt(o*o+i*i)/t.dmul}}_checkTypeAndMask(e){let{mask:t}=this._layer.style;if(t==="land"||t==="sea"){let a=this._layer.wxdatasetManager.wxAPI.qtree.check(e);return t===a?void 0:a}return"mixed"}_checkInsideBoundaries(e){let t=this._layer.getBoundaries();if(t?.boundaries180){let a=Fe(e),n=s=>!(a.west>s.east||s.west>a.east||a.south>s.north||s.south>a.north);if(!t.boundaries180.some(n))return!1}return!0}_createStreamLines(e){if(e.length!==3)return[];let{style:t}=this._layer;if(t.streamLineColor==="none")return[];let a=[],[n,s,i]=e,o=(t.streamLineSpeedFactor||1)/n.dmax,u=t.addDegrees?.017453292519943*t.addDegrees:0,c=t.streamLineGridStep||64,l=t.streamLineSteps||300;for(let d=0;d<=256;d+=c)for(let p=0;p<=256;p+=c){if(!n.raw[1+p+(1+d)*258])continue;let f=[],x=p,g=d,h=-1,y=0,v=0;for(let S=0;S<=l&&x>=0&&x<=256&&g>=0&&g<=256;S++){S%(l/10)||f.push({x:~~x,y:~~g});let M=~~x+1+(~~g+1)*258;if(M!==h){if(!n.raw[M])break;h=M;let T=n.dmin+n.raw[M]*n.dmul,w=s.dmin+s.raw[M]*s.dmul,P=i.dmin+i.raw[M]*i.dmul,A=Math.atan2(w,P)+u;y=o*T*Math.sin(A),v=o*T*Math.cos(A)}x+=y,g-=v}let b=p,W=d;h=-1;for(let S=1;S<=l&&b>=0&&b<=256&&W>=0&&W<=256;S++){S%(l/10)||f.unshift({x:~~b,y:~~W});let M=~~b+1+(~~W+1)*258;if(M!==h){if(!n.raw[M])break;h=M;let T=n.dmin+n.raw[M]*n.dmul,w=s.dmin+s.raw[M]*s.dmul,P=i.dmin+i.raw[M]*i.dmul,A=Math.atan2(w,P)+u;y=o*T*Math.sin(A),v=o*T*Math.cos(A)}b-=y,W+=v}f.length>2&&a.push(f)}return a}};var Q=class{constructor(e){this._layer=e}paint({data:e,ctxFill:t,ctxText:a,ctxStreamLines:n}){let{_layer:s}=this,{units:i}=s.currentVariableMeta,o=new ImageData(256,256),u=new Uint32Array(o.data.buffer);t.clearRect(0,0,256,256),a.clearRect(0,0,256,256),n.clearRect(0,0,256,256),dt(e.data[0],u,s);let c=mt(u,e.data[0],s);t.putImageData(o,0,0),pt(c,a,s),ht(e.data,a,s),gt(e.data[0],a,i,s),yt(e,a,s)}getPaintedCanvas(e,t,a){return t?(this.imprintVectorAnimationLinesStep(e,a),e.ctxStreamLines.canvas):e.ctxFill.canvas}imprintVectorAnimationLinesStep({data:e,ctxFill:t,ctxStreamLines:a},n){let{_layer:s}=this;a.clearRect(0,0,256,256),a.drawImage(t.canvas,0,0),!(e.slines.length===0||s.style.streamLineStatic||s.style.streamLineColor==="none")&&bt(e,a,s,n)}};function dt(r,e,{CLUT:t,style:a}){let{raw:n}=r,{colorsI:s}=t;if(a.fill!=="none")for(let i=0,o=0,u=259;i<256;++i,u+=2)for(let c=0;c<256;++c,++o,++u)e[o]=s[n[u]];else e.fill(0)}function mt(r,e,{CLUT:t,style:a}){let{raw:n}=e,{levelIndex:s,colorsI:i}=t,o=[];if(a.isolineColor!=="none"){let u=a.isolineColor[0]==="#"?L(a.isolineColor):0;for(let c=0,l=0;c<256;c+=1)for(let d=0;d<256;d+=1){let p=(c+1)*258+(d+1),f=n[p],x=n[p+1],g=n[p+258];if(!f||!x||!g)continue;let h=s[f],y=s[x],v=s[g];if(h!==y||h!==v){let b=Math.max(h,y,v),W=Math.max(f,x,g),S=c*256+d;switch(a.isolineColor){case"inverted":r[S]=~i[W]|4278190080;break;case"fill":r[S]=i[W]|4278190080;break;default:r[S]=u;break}a.isolineText&&!(++l%255)&&d>20&&d<235&&c>20&&c<235&&o.push({x:d,y:c,d:f,dr:x,db:g,mli:b})}}}return o}function pt(r,e,{CLUT:t,style:a}){if(r.length){let n=a.isolineTextSizeEm||1.1;e.font=`${n.toString()}em Sans-serif`,e.lineWidth=2,e.strokeStyle="white",e.fillStyle="black",e.textAlign="center",e.textBaseline="middle";let s=e.measureText("-.0123456789"),i=s.actualBoundingBoxAscent+s.actualBoundingBoxDescent,u=1.5*i,c=s.actualBoundingBoxAscent+(u-i)/2,l=1.1,d=n*2.5,p=a.isolineTextBackground?ft:xt;for(let{x:f,y:x,d:g,dr:h,db:y,mli:v}of r){let b=Math.atan2(g-h,y-g);e.save(),e.translate(f,x),e.rotate(b<-1.57||b>1.57?b+3.14:b);let W=t.ticks[v].dataString;p(W,e,{height:u,hOffset:c,wScale:l,radii:d}),e.fillText(W,0,0),e.restore()}}}function ft(r,e,t){e.strokeText(r,0,0)}function xt(r,e,{height:t,hOffset:a,wScale:n,radii:s}){let i=e.fillStyle;e.fillStyle=e.strokeStyle;let o=n*e.measureText(r).width;e.beginPath(),e.roundRect(-o/2,-a,o,t,s),e.closePath(),e.fill(),e.fillStyle=i}function ht(r,e,{CLUT:t,style:a}){if(!t.DataToKnots||a.vectorColor==="none"||a.vectorType==="none")return;if(r.length!==3)throw new Error("data.length !== 3");let[n,s,i]=r;switch(a.vectorType){case"barbs":e.font="40px barbs";break;case"arrows":e.font="50px arrows";break;default:e.font=a.vectorType}e.textAlign="center",e.textBaseline="middle",e.fillStyle=a.vectorColor;let o=a.addDegrees?.017453292519943*a.addDegrees:0,u=32;for(let c=u/2;c<256;c+=u)for(let l=u/2;l<256;l+=u){let d=l+1+(c+1)*258;if(!n.raw[d])continue;let p=Math.atan2(s.dmin+s.raw[d]*s.dmul,i.dmin+i.raw[d]*i.dmul),f=n.dmin+n.raw[d]*n.dmul,x=a.vectorType!=="barbs"?a.vectorFactor*.5:.2,g=Math.min(~~(t.DataToKnots(f)*x),25)+65,h=String.fromCharCode(g);switch(a.vectorColor){case"inverted":e.fillStyle=D(~t.colorsI[n.raw[d]]);break;case"fill":e.fillStyle=D(t.colorsI[n.raw[d]]);break}e.save(),e.translate(l,c),e.rotate(p+o),e.fillText(h,0,0),e.restore()}}function gt(r,e,t,{CLUT:a,style:n}){if(t!=="degree")return;let s=.017453292519943*n.addDegrees;e.font="50px arrows",e.textAlign="center",e.textBaseline="middle",e.fillStyle=n.vectorColor;let i="L",o=32;for(let u=o/2;u<256;u+=o)for(let c=o/2;c<256;c+=o){let l=c+1+(u+1)*258;if(!r.raw[l])continue;let p=(r.dmin+r.raw[l]*r.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=D(~a.colorsI[r.raw[l]]);break;case"fill":e.fillStyle=D(a.colorsI[r.raw[l]]);break}e.save(),e.translate(c,u),e.rotate(p+s),e.fillText(i,0,0),e.restore()}}function yt(r,e,{CLUT:t,style:a}){let{data:n,slines:s}=r;if(!s.length||!a.streamLineStatic||a.streamLineColor==="none")return;let i=n[0];e.lineWidth=1,a.streamLineColor[0]==="#"&&(e.strokeStyle=xe(a.streamLineColor));for(let o=s.length;o--;){let u=s[o];for(let c=0;c<u.length-1;++c){let l=u[c],d=u[c+1],p=l.x+1+(l.y+1)*258;switch(a.streamLineColor){case"inverted":e.strokeStyle=D(~t.colorsI[i.raw[p]]);break;case"fill":e.strokeStyle=D(t.colorsI[i.raw[p]]);break}e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(d.x,d.y),e.stroke()}}}function bt(r,e,{CLUT:t,style:a},n){let{data:s,slines:i}=r,o=s[0],u=a.streamLineColor[0]==="#"?xe(a.streamLineColor).substring(0,7):"#000000",c=n>>5;for(let l=0;l<i.length;++l){let d=i[l],p=d.length-1,f=(c+(1+d[0].x)*(1+d[0].y))%30;for(let x=0;x<p;++x){let g=d[x],h=d[x+1],y=1-(f-x)/p;(y<0||y>1)&&(y=0);let v=(~~(y*255)).toString(16).padStart(2,"0"),b=1+~~((1.2-y)*5);e.lineWidth=b;let W=g.x+1+(g.y+1)*258;switch(a.streamLineColor){case"inverted":u=D(~t.colorsI[o.raw[W]]);break;case"fill":u=D(t.colorsI[o.raw[W]]);break}e.strokeStyle=u+v,e.beginPath(),e.moveTo(g.x,g.y),e.lineTo(h.x,h.y),e.stroke()}}}var ee=class{constructor(e){this.tilesRasterCache=new O;this.coarseLevel=0;this._painter=new Q(this);this._loader=new J(this);if(m(`WxLayer.constructor:
2
2
  datasetName: ${e.wxdatasetManager.datasetName},
3
3
  variables: ${e.variables.join(", ")},
4
4
  wxstyleName: ${e.wxstyleName},
5
5
  wxstyle: ${JSON.stringify(e.wxstyle)},
6
- time: ${e.time}`),!e.variables?.length||e.variables.length>2)throw new Error(`datasetName: ${e.wxdatasetManager.datasetName}: only 1 or 2 variables are supported but ${e.variables} was given`);e.variables.forEach(s=>{if(!e.wxdatasetManager.isVariableValid(s))throw new Error(`datasetName: ${e.wxdatasetManager.datasetName}: variable ${s} is not valid`)}),this.variables=e.variables,this.wxdatasetManager=e.wxdatasetManager,[this.tilesURIs,this._time]=this._createURLsAndTime(e.time);let t=P(),r=t.base,n=e.wxstyleName&&t[e.wxstyleName];this.currentVariableMeta=this._getCurrentVariableMeta(),[this.style,this.CLUT]=this._createStyleAndCLUT({...r,...n,...e.wxstyle})}get nonanimatable(){return m("WxLayer.nonanimatabl()"),this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getMaxZoom(){return m("WxLayer.getMaxZoom"),this.wxdatasetManager.isInstanced()?this.wxdatasetManager.getInstanceMeta(this.getTime()).maxZoom:this.wxdatasetManager.getMaxZoom()}getCoarseMaxZoom(){return m("WxLayer.getCoarseMaxZoom"),this.getMaxZoom()-this.coarseLevel}getBoundaries(){return this.wxdatasetManager.isInstanced()?this.wxdatasetManager.getInstanceMeta(this.getTime()).boundaries:this.wxdatasetManager.getBoundaries()}getTime(){return m("WxLayer.getTime"),this._time}clearCache(){m("WxLayer.clearCache"),this.tilesRasterCache.clear(),this._loader.clearCache()}getCurrentStyleObjectCopy(){return m("WxLayer.getCurrentStyleObjectCopy"),Object.assign({},this.style)}updateCurrentStyleObject(e){m(`WxLayer.updateCurrentStyleObject ${JSON.stringify(e)}`),[this.style,this.CLUT]=this._createStyleAndCLUT(e)}getTileData(e,t){let r=this.tilesRasterCache.get(G(e));if(!r)return;let n=this._getPixelInfo(t,r.data.data);if(!n)return;let{raw:s,data:o}=n,i=s.map(l=>this.CLUT.colorsI[l]),u=i.map(T),c=o.map(l=>this.CLUT.DataToStyle(l));return{data:o,raw:s,rgba:i,hexColor:u,inStyleUnits:c,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentVariableMeta.units}}setURLsAndTime(e){m(`WxLayer.setURLsAndTime time=${e}`),[this.tilesURIs,this._time]=this._createURLsAndTime(e),this.wxdatasetManager.isInstanced()&&(this.currentVariableMeta=this._getCurrentVariableMeta(),[this.style,this.CLUT]=this._createStyleAndCLUT())}getPaintedCanvas(e,t,r){return this._painter.getPaintedCanvas(e,t,r)}async loadTile(e,t){return this._loadCacheDrawTile(e,this.tilesRasterCache,t)}async preloadTime(e,t,r){m(`WxLayer.preloadTime time=${e}`);let[n]=this._createURLsAndTime(e);await Promise.allSettled(t.map(s=>this._loader.cacheLoad(s,n,r)))}async reloadTiles(e,t){m("WxLayer.reloadTiles");let r=new N;await Promise.allSettled(e.map(n=>this._loadCacheDrawTile(n,r,t))),t?.signal?.aborted?r.clear():(this.tilesRasterCache.clear(),this.tilesRasterCache=r)}async _loadCacheDrawTile(e,t,r){let n=t.get(G(e));if(n)return n;let s=await this._loader.load(e,r);if(!s)return null;let o=A(256,256),i=o,u=this.variables.length===2?A(256,256):o,c={ctxFill:o,ctxText:i,ctxStreamLines:u,data:s};return this._painter.paint(c),t.set(G(e),c),c}_getCurrentVariableMeta(){let e=this.variables.map(o=>{let i=this.wxdatasetManager.getInstanceVariableMeta(o,this._time);if(!i)throw new Error(`datasetName ${this.wxdatasetManager.datasetName}: variable ${o} is not valid`);return i}),{min:t,max:r,units:n,vector:s}=e[0];return this.variables.length>1&&(t=0,r=1.42*Math.max(-e[0].min,e[0].max,-e[1].min,e[1].max)),{min:t,max:r,units:n,vector:s}}_getPixelInfo({x:e,y:t},r){m(`WxLayer._getPixelInfo x=${e} y=${t}`);let n=(t+1)*258+(e+1);if(r?.[0]?.raw?.[n])return{raw:r.map(s=>s.raw[n]),data:r.map(s=>s.raw[n]*s.dmul+s.dmin)}}_createStyleAndCLUT(e){let t=Object.assign({},this.style,e),r=this._prepareCLUT(t);return[t,r]}_prepareCLUT(e){let{min:t,max:r,units:n}=this.currentVariableMeta;return new H(e,n,[t,r],this.variables.length===2)}_createURLsAndTime(e){let t=this.wxdatasetManager.getNearestValidTime(e);return[this.variables.map(n=>this.wxdatasetManager.createURI(n,t)),t]}};var Ue=qe(Re()),K=class extends Ue.default.GridLayer{constructor(t){super(t);this.id=t.id}};var Z=class extends K{constructor(t,r){m(`WxLayerBaseImplementation.constructor (${r.id})`);super(r);this._animation=!1;this._animationSeed=0;this._needUpdateDSManager=!1;this._layer=new $(t)}get wxdatasetManager(){return m(`WxLayerBaseImplementation.wxdatasetManager (${this.id})`),this._layer.wxdatasetManager}getCurrentVariableMeta(){return m(`WxLayerBaseImplementation.getCurrentVariableMeta (${this.id})`),{...this._layer.currentVariableMeta}}getDatasetMeta(){return this._layer.wxdatasetManager.getInstanceMeta(this.getTime())}getMetadata(){return m(`WxLayerBaseImplementation.getMetadata (${this.id})`),{...this._layer.currentVariableMeta}}getVariablesNames(){return m(`WxLayerBaseImplementation.getVariables (${this.id})`),[...this._layer.variables]}clearCache(){m(`WxLayerBaseImplementation.clearCache (${this.id})`),this._layer.clearCache()}getCache(){return this._layer.tilesRasterCache}getCurrentStyleObjectCopy(){return m(`WxLayerBaseImplementation.getCurrentStyleObjectCopy (${this.id})`),this._layer.getCurrentStyleObjectCopy()}getTime(){return m(`WxLayerBaseImplementation.getTime (${this.id})`),this._layer.getTime()}getAllTimes(){return m(`WxLayerBaseImplementation.getTimes (${this.id})`),this._layer.wxdatasetManager.getAllTimes()}async setTime(t,r){m(`WxLayerBaseImplementation.setTime (${this.id}) time=${t}`);let n=this.getTime();return this._layer.setURLsAndTime(t),await this._reloadVisible(r),r?.signal?.aborted&&this._layer.setURLsAndTime(n),this.getTime()}async preloadTime(t,r){return m(`WxLayerBaseImplementation.preloadTime (${this.id}) time=${t}`),this._layer.preloadTime(t,this.coveringTiles(),r)}startAnimation(){if(this._animation){m(`WxLayerBaseImplementation.startAnimation (${this.id}) already started`);return}if(this._layer.nonanimatable){m(`WxLayerBaseImplementation.startAnimation (${this.id}) nonanimatable`);return}m(`WxLayerBaseImplementation.startAnimation (${this.id})`),this._animation=!0;let t=async r=>{if(m(`WxLayerBaseImplementation.startAnimation (${this.id}) animationStep`),!this._animation||this._layer.nonanimatable){this._animation=!1;return}this._animationSeed=r,await this._redrawTiles(),requestAnimationFrame(t)};requestAnimationFrame(t)}async stopAnimation(){return m(`WxLayerBaseImplementation.stopAnimation (${this.id})`),this._animation=!1,this._redrawTiles()}async setCoarseLevel(t=2){this._layer.coarseLevel=Math.max(0,Math.min(t,this.wxdatasetManager.getMaxZoom()))}async unsetCoarseLevel(){return this._layer.coarseLevel=0,this._reloadVisible()}async setStyleByName(t,r=!0){return m(`WxLayerBaseImplementation.setStyleByName (${this.id}) wxstyleName=${t} reload=${r}`),this.updateCurrentStyleObject(P()[t],r)}async updateCurrentStyleObject(t,r=!0,n){if(m(`WxLayerBaseImplementation.updateCurrentStyleObject (${this.id}) style=${t} reload=${r}`),this._layer.updateCurrentStyleObject(t),this.startAnimation(),r)return this._reloadVisible(n)}_redrawTiles(){return this._redrawRequested?this._redrawRequested:(this._redrawRequested=new Promise(t=>{requestAnimationFrame(()=>{m(`WxTileSource _redrawTiles (${this.id})`),this.update(),t(),this._redrawRequested=void 0})}),this._redrawRequested)}async _reloadVisible(t){}coveringTiles(){return[]}update(){}async _loadTileHelper(t,r){let n=null;if(!this._needUpdateDSManager)try{n=await this._layer.loadTile(t,r)}catch(s){if(s.name==="AbortError")throw s;s.reason==="instance-not-found"&&!this._needUpdateDSManager&&(this._needUpdateDSManager=!0,m(`WxTileSource.loadTile (${this.id}) instance-not-found. Trying to update wxdatasetManager and load again.`),this.wxdatasetManager.update().then(()=>{this._needUpdateDSManager=!1,this.setTime(this.getTime()).then(()=>this.fire("changed",this))}).catch(o=>{m(`WxTileSource.loadTile (${this.id}) instance-not-found. wxdatasetManager update failed.`,o)}))}return n}};var J=class{constructor(e,t,r){this.coords=e;this.ctx=t;this.raster_data=r;this.draw(r?.ctxFill.canvas)}draw(e){this.ctx.clearRect(0,0,256,256),e&&this.ctx.drawImage(e,0,0)}},B=class extends Z{constructor(e,t){super(e,t),m("WxTileSource constructor: ",e)}getLayerInfoAtLatLon(e,t){if(m(`WxTileSource getLayerInfoAtLatLon (${this._layer.wxdatasetManager.datasetName})`,e),!this._map)return;let r=this._map.getZoom(),n=this._map.project(e,r),s=n.divideBy(256).floor(),o=n.subtract(s.multiplyBy(256)).floor();return this._layer.getTileData({x:s.x,y:s.y,z:r},o)}async _reloadVisible(e){if(m(`WxTileSource _reloadVisible (${this._layer.wxdatasetManager.datasetName})`),await this._layer.reloadTiles(this.coveringTiles(),e),e?.signal?.aborted){m(`WxTileSource _reloadVisible (${this._layer.wxdatasetManager.datasetName}) aborted`);return}return await Promise.allSettled(this._ForEachWxTile(async t=>{t.raster_data=null,t.raster_data=await this._layer.loadTile(t.coords)},"_reloadVisible")),this._redrawTiles()}coveringTiles(){m(`WxTileSource coveringTiles (${this._layer.wxdatasetManager.datasetName})`);let e=[];for(let t in this._tiles){let r=this._tiles[t].el?.wxtile;r&&e.push(r.coords)}return e}update(){m(`WxTileSource update (${this._layer.wxdatasetManager.datasetName})`),this._ForEachWxTile(e=>{e.draw(e.raster_data&&this._layer.getPaintedCanvas(e.raster_data,this._animation,this._animationSeed))},"_redrawTiles")}_ForEachWxTile(e,t){m(`WxTileSource _ForEachWxTile (${this._layer.wxdatasetManager.datasetName}) func=${t}`);let r=[];for(let n in this._tiles){let s=this._tiles[n].el?.wxtile;s&&r.push(e(s))}return r}createTile(e,t){let r=A(256,256),n=r.canvas;return this._loadTileHelper(e).then(s=>{n.wxtile=new J(e,r,s)}).catch(()=>{n.wxtile=new J(e,r,null)}).finally(t),n}onRemove(e){return super.onRemove(e),m(`WxTileSource onRemove (${this._layer.wxdatasetManager.datasetName})`),this._animation=!1,this}};var V=class{constructor({datasetName:e,datasetCurrentInstance:t,instanced:r,datasetCurrentMeta:n,metas:s,wxAPI:o}){this.datasetName=e,this._instanced=r,this._datasetCurrentInstance=t,this._datasetCurrentMeta=n,this._metas=s,this.wxAPI=o,m(`WxDataSetManager.constructor: ${this.datasetName}`)}createSourceLayer(e,t){m(`WxDataSetManager.createSourceLayer: ${this.datasetName}`);let r={...e,variables:this._checkCombineVariableIfVector(e.variable),wxdatasetManager:this};return new B(r,t)}getNearestValidTime(e=Date()){m(`WxDataSetManager.getValidTime: ${this.datasetName}, ${e}`);let t=this.getAllTimes();if(e==="")return t[t.length-1];if(typeof e=="string"){let s=t.indexOf(e);if(s!==-1)return t[s]}if(typeof e=="number"){if(e<=0)return t[0];if(e<t.length)return t[e]}let r=new Date(e).getTime();return isNaN(r)?t[t.length-1]:t.find(s=>new Date(s).getTime()>=r)||t[t.length-1]}getAllTimes(){return m(`WxDataSetManager.getTimes: ${this.datasetName}`),this._instanced||this._datasetCurrentMeta.times}getAllVariables(){return m(`WxDataSetManager.getVariables: ${this.datasetName}`),this._datasetCurrentMeta.variables}getVariableCurrentMeta(e){return m(`WxDataSetManager.getVariableCurrentMeta: ${this.datasetName}, ${e}`),this._datasetCurrentMeta.variablesMeta[e]}getInstanceVariableMeta(e,t){return m(`WxDataSetManager.getInstanceVariableMeta: ${this.datasetName}, ${e}, ${t}`),this.getInstanceMeta(t).variablesMeta[e]}getMaxZoom(){return m(`WxDataSetManager.getMaxZoom: ${this.datasetName}`),this._datasetCurrentMeta.maxZoom}getBoundaries(){return m(`WxDataSetManager.getBoundaries: ${this.datasetName}`),this._datasetCurrentMeta.boundaries}getInstanceMeta(e){return m(`WxDataSetManager.getInstanceMeta: ${this.datasetName}, ${e}`),e&&this._metas?.get(e)||this._datasetCurrentMeta}createURI(e,t,r="png"){if(m(`WxDataSetManager.createURI: ${this.datasetName}, ${e}, ${t}`),!this.isVariableValid(e))throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);let n=this._instanced?t:this._datasetCurrentInstance;return`${this.wxAPI.dataServerURL+this.datasetName}/${n}/${e}/${t}/{z}/{x}/{y}.${r}`}isVariableValid(e){return m(`WxDataSetManager.checkVariableValid: ${this.datasetName}, ${e}`),this._datasetCurrentMeta.variablesMeta[e]!==void 0}async update(){let e=await this.wxAPI.createDatasetManager(this.datasetName);this._datasetCurrentInstance=e._datasetCurrentInstance,this._instanced=e._instanced,this._datasetCurrentMeta=e._datasetCurrentMeta,this._metas=e._metas}isInstanced(){return this._instanced!==void 0}_checkCombineVariableIfVector(e){m(`WxDataSetManager.checkCombineVariableIfVector: ${this.datasetName}, ${e}`);let t=this._datasetCurrentMeta.variablesMeta[e];if(!t)throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);return t.vector||[e]}},Q=class{constructor(e){this.wxAPI=e;this.allDatasetsShortMetas={};this.ready=this.updateAll()}updateAll(){return this.ready=v(this.wxAPI.dataServerURL+"meta.json",this.wxAPI.requestInit),this.ready.then(e=>this.allDatasetsShortMetas=e),this.ready}async updateOne(e){try{let t=this.wxAPI.dataServerURL+e+"/meta.json",r=await v(t,this.wxAPI.requestInit);return Object.assign(this.allDatasetsShortMetas,r)}catch{return this.updateAll()}}};var ee=class{constructor({dataServerURL:e,maskURL:t="none",maskChannel:r="R",maskDepth:n=11,qtreeURL:s="none",requestInit:o,colorStyles:i,units:u,colorSchemes:c}){if(m("WxAPI.constructor",e),he({colorStyles:i,units:u,colorSchemes:c}),s==="auto"&&(s=e+"masks/11+1.seamask.qtree"),t==="auto"&&(t=e+"masks/{z}/{x}/{y}.png"),this.dataServerURL=e,this.requestInit=o,this.maskURL=t,this.maskChannel=r==="R"?0:r==="G"?1:r==="B"?2:r==="A"?3:0,this.maskDepth=n,this.maskURL!=="none"){let l=Y(ae);this.loadMaskFunc=d=>l(j(this.maskURL,d),o)}else this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));this._allDatasetsManager=new Q(this),this.qtree=new k(s,o),this.initDone=Promise.all([this._allDatasetsManager.ready,this.qtree.ready]).then(()=>m("WxAPI.constructor initDone"))}async createDatasetManager(e){await this.initDone,await this._allDatasetsManager.updateOne(e),m("WxAPI.createDatasetManager",e);let t=this._allDatasetsManager.allDatasetsShortMetas[e],r=t?.instance;if(!r)throw new Error("Dataset/instance not found:"+e);let n=t.instanced,s=await v(this.dataServerURL+e+"/metafull.json"),o=s[0],i=n&&new Map(s.map(u=>[u.instance,u]));return new V({datasetName:e,datasetCurrentInstance:r,datasetCurrentMeta:o,instanced:n,metas:i,wxAPI:this})}async getDatasetAllVariables(e){return await this.initDone,m("WxAPI.getDatasetVariables",e),this._allDatasetsManager.allDatasetsShortMetas[e]?.variables}async filterDatasetsByVariableName(e){await this.initDone,m("WxAPI.filterDatasetsByVariableName:",e);let{allDatasetsShortMetas:t}=this._allDatasetsManager;return Object.keys(t).filter(r=>t[r].variables.includes(e))}async getAllDatasetsNames(){return await this.initDone,m("WxAPI.getAllDatasetsNames"),Object.keys(this._allDatasetsManager.allDatasetsShortMetas)}};var te=class{};return Oe(mt);})();
6
+ time: ${e.time}`),!e.variables?.length||e.variables.length>2)throw new Error(`datasetName: ${e.wxdatasetManager.datasetName}: only 1 or 2 variables are supported but ${e.variables} was given`);for(let s of e.variables)if(!e.wxdatasetManager.isVariableValid(s))throw new Error(`datasetName: ${e.wxdatasetManager.datasetName}: variable ${s} is not valid`);this.variables=e.variables,this.wxdatasetManager=e.wxdatasetManager,[this.tilesURIs,this._time]=this._createURLsAndTime(e.time);let t=k(),a=t.base,n=e.wxstyleName&&t[e.wxstyleName];this.currentVariableMeta=this._getCurrentVariableMeta(),[this.style,this.CLUT]=this._createStyleAndCLUT({...a,...n,...e.wxstyle})}get nonanimatable(){return m("WxLayer.nonanimatabl()"),this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getMaxZoom(){return m("WxLayer.getMaxZoom"),this.wxdatasetManager.isInstanced()?this.wxdatasetManager.getInstanceMeta(this.getTime()).maxZoom:this.wxdatasetManager.getMaxZoom()}getCoarseMaxZoom(){return m("WxLayer.getCoarseMaxZoom"),this.getMaxZoom()-this.coarseLevel}getBoundaries(){return this.wxdatasetManager.isInstanced()?this.wxdatasetManager.getInstanceMeta(this.getTime()).boundaries:this.wxdatasetManager.getBoundaries()}getTime(){return m("WxLayer.getTime"),this._time}clearCache(){m("WxLayer.clearCache"),this.tilesRasterCache.clear(),this._loader.clearCache()}getCurrentStyleObjectCopy(){return m("WxLayer.getCurrentStyleObjectCopy"),Object.assign({},this.style)}updateCurrentStyleObject(e){m(`WxLayer.updateCurrentStyleObject ${JSON.stringify(e)}`),[this.style,this.CLUT]=this._createStyleAndCLUT(e)}getTileData(e,t){let a=this.tilesRasterCache.get(Y(e));if(!a)return;let n=this._getPixelInfo(t,a.data.data);if(!n)return;let{raw:s,data:i}=n,o=s.map(l=>this.CLUT.colorsI[l]),u=o.map(D),c=i.map(l=>this.CLUT.DataToStyle(l));return{data:i,raw:s,rgba:o,hexColor:u,inStyleUnits:c,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentVariableMeta.units}}setURLsAndTime(e){m(`WxLayer.setURLsAndTime time=${e}`),[this.tilesURIs,this._time]=this._createURLsAndTime(e),this.wxdatasetManager.isInstanced()&&(this.currentVariableMeta=this._getCurrentVariableMeta(),[this.style,this.CLUT]=this._createStyleAndCLUT())}getPaintedCanvas(e,t,a){return this._painter.getPaintedCanvas(e,t,a)}async loadTile(e,t){return this._loadCacheDrawTile(e,this.tilesRasterCache,t)}async preloadTime(e,t,a){m(`WxLayer.preloadTime time=${e}`);let[n]=this._createURLsAndTime(e);await Promise.allSettled(t.map(s=>this._loader.cacheLoad(s,n,a)))}async reloadTiles(e,t){m("WxLayer.reloadTiles");let a=new O;await Promise.allSettled(e.map(n=>this._loadCacheDrawTile(n,a,t))),t?.signal?.aborted?a.clear():(this.tilesRasterCache.clear(),this.tilesRasterCache=a)}async _loadCacheDrawTile(e,t,a){let n=t.get(Y(e));if(n)return n;let s=await this._loader.load(e,a);if(!s)return null;let i=R(256,256),o=i,u=this.variables.length===2?R(256,256):i,c={ctxFill:i,ctxText:o,ctxStreamLines:u,data:s};return this._painter.paint(c),t.set(Y(e),c),c}_getCurrentVariableMeta(){let e=this.variables.map(i=>{let o=this.wxdatasetManager.getInstanceVariableMeta(i,this._time);if(!o)throw new Error(`datasetName ${this.wxdatasetManager.datasetName}: variable ${i} is not valid`);return o}),{min:t,max:a,units:n,vector:s}=e[0];return this.variables.length>1&&(t=0,a=1.42*Math.max(-e[0].min,e[0].max,-e[1].min,e[1].max)),{min:t,max:a,units:n,vector:s}}_getPixelInfo({x:e,y:t},a){m(`WxLayer._getPixelInfo x=${e} y=${t}`);let n=(t+1)*258+(e+1);if(a?.[0]?.raw?.[n])return{raw:a.map(s=>s.raw[n]),data:a.map(s=>s.raw[n]*s.dmul+s.dmin)}}_createStyleAndCLUT(e){let t=Object.assign({},this.style,e),a=this._prepareCLUT(t);return[t,a]}_prepareCLUT(e){let{min:t,max:a,units:n}=this.currentVariableMeta;return new z(e,n,[t,a],this.variables.length===2)}_createURLsAndTime(e){let t=this.wxdatasetManager.getNearestValidTime(e);return[this.variables.map(n=>this.wxdatasetManager.createURI(n,t)),t]}};var te=class extends Ve.default.GridLayer{constructor(t,a){super(t);this.id=t.id,this._layer=new ee(a)}};var be=Le(te),ae=class{constructor(e,t,a){this.coords=e;this.ctx=t;this.raster_data=a;this.draw(a?.ctxFill.canvas)}draw(e){this.ctx.clearRect(0,0,256,256),e&&this.ctx.drawImage(e,0,0)}},B=class extends be{constructor(e,t){super(t,e),m("WxTileSource constructor: ",e)}getLayerInfoAtLatLon(e,t){if(m(`WxTileSource getLayerInfoAtLatLon (${this._layer.wxdatasetManager.datasetName})`,e),!this._map)return;let a=this._map.getZoom(),n=this._map.project(e,a),s=n.divideBy(256).floor(),i=n.subtract(s.multiplyBy(256)).floor();return this._layer.getTileData({x:s.x,y:s.y,z:a},i)}async _reloadVisible(e){if(m(`WxTileSource _reloadVisible (${this._layer.wxdatasetManager.datasetName})`),await this._layer.reloadTiles(this.coveringTiles(),e),e?.signal?.aborted){m(`WxTileSource _reloadVisible (${this._layer.wxdatasetManager.datasetName}) aborted`);return}return await Promise.allSettled(this._ForEachWxTile(async t=>{t.raster_data=null,t.raster_data=await this._layer.loadTile(t.coords)},"_reloadVisible")),this._redrawTiles()}coveringTiles(){m(`WxTileSource coveringTiles (${this._layer.wxdatasetManager.datasetName})`);let e=[];for(let t in this._tiles){let a=this._tiles[t].el?.wxtile;a&&e.push(a.coords)}return e}update(){m(`WxTileSource update (${this._layer.wxdatasetManager.datasetName})`),this._ForEachWxTile(e=>{e.draw(e.raster_data&&this._layer.getPaintedCanvas(e.raster_data,this._animation,this._animationSeed))},"_redrawTiles")}_ForEachWxTile(e,t){m(`WxTileSource _ForEachWxTile (${this._layer.wxdatasetManager.datasetName}) func=${t}`);let a=[];for(let n in this._tiles){let s=this._tiles[n].el?.wxtile;s&&a.push(e(s))}return a}createTile(e,t){let a=R(256,256),n=a.canvas;return this._loadTileHelper(e).then(s=>{n.wxtile=new ae(e,a,s)}).catch(()=>{n.wxtile=new ae(e,a,null)}).finally(t),n}onRemove(e){return super.onRemove(e),m(`WxTileSource onRemove (${this._layer.wxdatasetManager.datasetName})`),this._animation=!1,this}};var re=class{constructor({datasetName:e,datasetCurrentInstance:t,instanced:a,datasetCurrentMeta:n,metas:s,wxAPI:i}){this.datasetName=e,this._instanced=a,this._datasetCurrentInstance=t,this._datasetCurrentMeta=n,this._metas=s,this.wxAPI=i,m(`WxDataSetManager.constructor: ${this.datasetName}`)}getNearestValidTime(e=Date()){m(`WxDataSetManager.getValidTime: ${this.datasetName}, ${e}`);let t=this.getAllTimes();if(e==="")return t[t.length-1];if(typeof e=="string"){let s=t.indexOf(e);if(s!==-1)return t[s]}if(typeof e=="number"){if(e<=0)return t[0];if(e<t.length)return t[e]}let a=new Date(e).getTime();return Number.isNaN(a)?t[t.length-1]:t.find(s=>new Date(s).getTime()>=a)||t[t.length-1]}getAllTimes(){return m(`WxDataSetManager.getTimes: ${this.datasetName}`),this._instanced||this._datasetCurrentMeta.times}getAllVariables(){return m(`WxDataSetManager.getVariables: ${this.datasetName}`),this._datasetCurrentMeta.variables}getVariableCurrentMeta(e){return m(`WxDataSetManager.getVariableCurrentMeta: ${this.datasetName}, ${e}`),this._datasetCurrentMeta.variablesMeta[e]}getInstanceVariableMeta(e,t){return m(`WxDataSetManager.getInstanceVariableMeta: ${this.datasetName}, ${e}, ${t}`),this.getInstanceMeta(t).variablesMeta[e]}getMaxZoom(){return m(`WxDataSetManager.getMaxZoom: ${this.datasetName}`),this._datasetCurrentMeta.maxZoom}getBoundaries(){return m(`WxDataSetManager.getBoundaries: ${this.datasetName}`),this._datasetCurrentMeta.boundaries}getInstanceMeta(e){return m(`WxDataSetManager.getInstanceMeta: ${this.datasetName}, ${e}`),e&&this._metas?.get(e)||this._datasetCurrentMeta}createURI(e,t,a="webp"){if(m(`WxDataSetManager.createURI: ${this.datasetName}, ${e}, ${t}`),!this.isVariableValid(e))throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);let n=this._instanced?t:this._datasetCurrentInstance;return`${this.wxAPI.dataServerURL+this.datasetName}/${n}/${e}/${t}/{z}/{x}/{y}.${a}`}isVariableValid(e){return m(`WxDataSetManager.checkVariableValid: ${this.datasetName}, ${e}`),this._datasetCurrentMeta.variablesMeta[e]!==void 0}async update(){let e=await this.wxAPI.createDatasetManagerOptions(this.datasetName);this._datasetCurrentInstance=e.datasetCurrentInstance,this._instanced=e.instanced,this._datasetCurrentMeta=e.datasetCurrentMeta,this._metas=e.metas}isInstanced(){return this._instanced!==void 0}_checkCombineVariableIfVector(e){m(`WxDataSetManager.checkCombineVariableIfVector: ${this.datasetName}, ${e}`);let t=this._datasetCurrentMeta.variablesMeta[e];if(!t)throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);return t.vector||[e]}};var N=class extends re{createSourceLayer(e,t){m(`WxDataSetManager.createSourceLayer: ${this.datasetName}`);let a={...e,variables:this._checkCombineVariableIfVector(e.variable),wxdatasetManager:this};return new B(a,t)}};var ne=class extends G{async createDatasetManager(e){let t=await this.createDatasetManagerOptions(e);return new N(t)}};var se=class{};var ie=class{constructor(e,t,a){this.wxapi=e;this._busy=!1;let n=document.createElement("div");n.className="mapboxgl-ctrl leaflet-control",n.style.borderStyle="solid",n.style.borderColor="#000",n.style.backgroundColor="#aaaaaaaa",n.style.padding="5px",n.style.display="flex",n.style.flexDirection="column",this._div=n;let s=document.createElement("label");s.innerText="Dataset",n.appendChild(s),this.datasets=document.createElement("select"),n.appendChild(this.datasets),this.fillDatasets(t,a),this.datasets.addEventListener("change",async()=>{if(this._busy)return;this.setBusy(!0);let o=this.datasets.value;await this.fillVariables();let u=this.variables.value;await this.onchange?.(this.datasets.value,this.variables.value),this.datasets.value=o,this.variables.value=u,this.setBusy(!1)});let i=document.createElement("label");i.innerText="Variable",n.appendChild(i),this.variables=document.createElement("select"),n.appendChild(this.variables),this.variables.addEventListener("change",async()=>{if(this._busy)return;this.setBusy(!0);let o=this.variables.value;await this.onchange?.(this.datasets.value,this.variables.value),this.variables.value=o,this.setBusy(!1)}),this.datasets.value=t||"",this.variables.value=a||""}setBusy(e){this._busy=e,this._div.style.backgroundColor=e?"yellow":"lightgray"}async fillDatasets(e,t){this.datasets.options.length=0;let a=await this.wxapi.getAllDatasetsNames();for(let n of a){let s=document.createElement("option");s.value=n,s.text=n,this.datasets.appendChild(s)}e&&(this.datasets.value=e),await this.fillVariables(t)}async fillVariables(e){this.variables.options.length=0;let t=this.datasets.value,a=await this.wxapi.getDatasetAllVariables(t);if(a)for(let n of a){let s=document.createElement("option");s.value=n,s.text=n,this.variables.appendChild(s)}e&&this.variables.options.length&&(this.variables.value=e)}onAdd(){return this._div}onRemove(){this._div.parentNode?.removeChild(this._div)}extender(){return{onAdd:()=>this.onAdd(),onRemove:()=>this.onRemove()}}};var oe=class{constructor(){this.pos={lng:0,lat:0};let e=document.createElement("div");e.className="mapboxgl-ctrl leaflet-control",e.style.borderStyle="solid",e.style.borderColor="#000",e.style.backgroundColor="#aaaaaaaa",e.style.padding="5px",this.div=e}onAdd(){return this.div}onRemove(){this.div.parentNode?.removeChild(this.div)}update(e,t,a){if(a&&(this.pos=a),!e){this.div.innerHTML="";return}let{min:n,max:s,units:i}=e.getCurrentVariableMeta(),{datasetName:o}=e.wxdatasetManager,u=e.wxdatasetManager.getInstanceMeta(e.getTime()),{sourceID:c,baseAtmosphericModel:l,model:d}=u;this.div.innerHTML=`lnglat=(${this.pos.lng.toFixed(2)}, ${this.pos.lat.toFixed(2)})<br>`,this.div.innerHTML+=c&&`sourceID=${c}<br>`||"",this.div.innerHTML+=l&&`baseAtmosphericModel=${l}<br>`||"",this.div.innerHTML+=d&&`model=${d}<br>`||"",this.div.innerHTML+=`dataset=${o}<br>
7
+ variables=${e.getVariablesNames()}<br>
8
+ time=${e.getTime()}<br>
9
+ min=${n.toFixed(2)} ${i}, max=${s.toFixed(2)} ${i}<br>`;let p=e.getLayerInfoAtLatLon(this.pos,t);p?this.div.innerHTML+=`style=${p.inStyleUnits.map(f=>f.toFixed(2))} ${p.styleUnits}<br>
10
+ source=${p.data.map(f=>f.toFixed(2))} ${p.dataUnits}<br>`:this.div.innerHTML+="style=outside<br>source=outside<br>"}extender(){return{onAdd:()=>this.onAdd(),onRemove:()=>this.onRemove()}}};var le=class{constructor(){let e=document.createElement("div");e.className="mapboxgl-ctrl leaflet-control",e.style.borderStyle="solid",e.style.borderColor="#000",e.style.backgroundColor="#aaaaaaaa",e.style.padding="5px",this._div=e,this._canvas=document.createElement("canvas"),this._canvas.width=600,this._canvas.height=40,e.appendChild(this._canvas)}onAdd(){return this._div}onRemove(){this._div.parentNode?.removeChild(this._div)}drawLegend(e){let{_canvas:t}=this,{width:a,height:n}=t,s=16+n>>2,i=V(a-50,e),o=t.getContext("2d");if(!o)throw new Error("Failed to get 2D context from canvas");let u=o.createImageData(a,n),c=new Uint32Array(u.data.buffer);c.fill(-1);let l=2,d=2,p=l+a*d,f=s>>1;if(i.showBelowMin){let x=i.colors[0];if(x)for(let g=0;g<f;++g)for(let h=f;h<f+g;++h)c[p+g+h*a]=x,c[p+g+(f*2-h)*a]=x}for(let x=0;x<i.size;++x)for(let g=0;g<s;++g)i.colors[0]&&(c[l+x+f+(g+d+1)*a]=i.colors[x]);if(i.showAboveMax){let x=i.colors[i.colors.length-1];if(x)for(let g=0;g<=f;++g)for(let h=f;h<f+g;++h)c[p+f*2+i.size-g+h*a]=x,c[p+f*2+i.size-g+(f*2-h)*a]=x}o.putImageData(u,0,0),o.font="8px sans-serif",o.beginPath();for(let x of i.ticks)o.strokeStyle="#000",o.moveTo(x.pos+f+l+1,d+3),o.lineTo(x.pos+f+l+1,s),o.fillText(x.dataString,x.pos+f+l+1,s+11);o.font="12px sans-serif",o.fillText(`(${i.units})`,13,n-5),o.stroke(),o.strokeStyle="#888",o.strokeRect(1,1,a-3,n-2)}clear(){let{_canvas:e}=this,{width:t,height:a}=e,n=e.getContext("2d");if(!n)throw new Error("Failed to get 2D context from canvas");n.clearRect(0,0,t,a)}extender(){return{onAdd:()=>this.onAdd(),onRemove:()=>this.onRemove()}}};var ce=class{constructor(){this.parent=document.createElement("div"),this.parent.className="mapboxgl-ctrl leaflet-control",this.parent.style.borderStyle="solid",this.parent.style.borderColor="#000",this.parent.style.backgroundColor="#aaaaaaaa",this.parent.style.padding="5px",this.parent.onmousemove=this.parent.ondblclick=this.parent.onclick=c=>c.stopPropagation?.();let{base:e}=k();this.styleBase=e;let t=I(this.parent,"div",{onclick:onwheel,ondblclick:onwheel,onwheel,onmousedown,onmouseup}),a=I(t,"button",{id:"customStyleButton",style:"height: 1.5em; background-color: gray",innerText:"Custom Style"}),n=I(t,"div",{id:"customStyleDiv",style:"display: none; border-color: black; border-style: solid; border-width: 2px; background-color: rgba(135, 206, 250, 0.8)"});a.addEventListener("click",()=>{n.style.display!=="none"?(n.style.display="none",a.innerHTML="show Custom Style Editor"):(n.style.display="flex",a.innerHTML="update Custom Style & Hide")}),this.editorTextAreaEl=I(n,"textarea",{id:"customStyleTextArea",style:"width: 20vw;"}),this.editorTextAreaEl.readOnly=!0,this.editorDivEl=I(n,"div");let s=(c,l=!0)=>{I(this.editorDivEl,"label",{htmlFor:c,id:`${c}Label`,className:`${c}LabelClass`,textContent:c.replace(/Input|Select$/i,"")}),l&&I(this.editorDivEl,"br",{})},i=({id:c,type:l,min:d,max:p,step:f,onEvent:x="change",br:g=!0})=>{let h=I(this.editorDivEl,"input",{id:c,className:`${c}Class`,type:l,min:d,max:p,step:f});return x!=="none"&&h.addEventListener(x,()=>this._onDivChange()),s(c,g),h},o=({id:c,opts:l,onEvent:d="change",br:p=!0})=>{let f=I(this.editorDivEl,"select",{id:c,className:`${c}Class`});d!=="none"&&f.addEventListener(d,()=>this._onDivChange());for(let x of l)f.options.add(I(f,"option",{value:x,text:x}));return s(c,p),f.selectedIndex=0,f},u=c=>{let l=o({id:`${c}Select`,br:!1,opts:["inverted","fill","none","custom"]}),d=i({id:`${c}Input`,type:"color",onEvent:"none"});return d.addEventListener("change",()=>{l.value="custom",this._onDivChange()}),[l,d]};this.parentInput=i({id:"parentInput",type:"text"}),this.nameInput=i({id:"nameInput",type:"text"}),this.fillSelect=o({id:"fillSelect",opts:["gradient","solid","none"]}),[this.isolineColorSelect,this.isolineColorInput]=u("isolineColor"),this.isolineTextInput=i({id:"isolineTextInput",type:"checkbox"}),this.vectorFactorInput=i({id:"vectorFactorInput",type:"number",min:"0.1",max:"10",step:"0.1"}),this.vectorTypeSelect=o({id:"vectorTypeSelect",opts:["arrows","barbs","none"]}),[this.vectorColorSelect,this.vectorColorInput]=u("vectorColor"),[this.streamLineColorSelect,this.streamLineColorInput]=u("streamLineColor"),this.streamLineSpeedFactorInput=i({id:"streamLineSpeedFactorInput",type:"range",onEvent:"input",min:"0.1",max:"10",step:"0.1"}),this.streamLineStaticInput=i({id:"streamLineStaticInput",type:"checkbox"}),this.showBelowMinInput=i({id:"showBelowMinInput",type:"checkbox"}),this.showAboveMaxInput=i({id:"showAboveMaxInput",type:"checkbox"}),this.colorSchemeSelect=o({id:"colorSchemeSelect",opts:Object.keys(E()),onEvent:"none"}),this.colorSchemeSelect.addEventListener("change",()=>{let{colors:c,...l}=this.getStyle(),d=l;this._setStyleToTextArea(d),this.colorsInput.value="",this._onDivChange()}),this.colorsInput=i({id:"colorsInput",type:"text"}),this.colorMapInput=i({id:"colorMapInput",type:"text"}),this.levelsInput=i({id:"levelsInput",type:"text"}),this.blurRadiusInput=i({id:"blurRadiusInput",type:"range",onEvent:"input",min:"0",max:"10",step:"1"}),this.addDegreesInput=i({id:"addDegreesInput",type:"number",min:"0",max:"360",step:"1"}),this.unitsInput=i({id:"unitsInput",type:"text"}),this.extraUnitsInput=i({id:"extraUnitsInput",type:"text"}),this.maskSelect=o({id:"maskSelect",opts:["none","sea","land"]}),this.animationSpeed=i({id:"animationSpeed",type:"range",onEvent:"input",min:"0.1",max:"10",step:"0.1"}),this.noiseTexturePow=i({id:"noiseTexturePow",type:"range",onEvent:"input",min:"5",max:"8",step:"1"}),this.vectorFieldFactor=i({id:"vectorFieldFactor",type:"range",onEvent:"input",min:"0.1",max:"3",step:"0.1"}),this.animationIntensity=i({id:"animationIntensity",type:"range",onEvent:"input",min:"0.1",max:"10",step:"0.1"}),this.wavesCount=i({id:"wavesCount",type:"range",onEvent:"input",min:"2",max:"10",step:"1"})}extender(){return{onAdd:()=>this.onAdd(),onRemove:()=>this.onRemove()}}onAdd(){return this.parent}onRemove(){this.parent.parentNode?.removeChild(this.parent)}getStyle(){return this._getStyleFromDiv()}setStyle(e){if(e.colorMap){let{colors:t,levels:a,...n}=e;this._setStyleToDiv(n)}else this._setStyleToDiv(e);this._setStyleToTextArea(this._getStyleFromDiv())}_getStyleFromDiv(){let e=n=>{try{return this[n].value?JSON.parse(this[n].value):void 0}catch(s){console.log(n," : parsing error: ",s);return}},t=(n,s)=>n.value==="custom"?s.value:n.value||void 0;return{parent:this.parentInput.value||void 0,name:this.nameInput.value||void 0,fill:this.fillSelect.value||void 0,isolineColor:t(this.isolineColorSelect,this.isolineColorInput),isolineText:this.isolineTextInput.checked,vectorType:this.vectorTypeSelect.value||void 0,vectorColor:t(this.vectorColorSelect,this.vectorColorInput),vectorFactor:+this.vectorFactorInput.value,streamLineColor:t(this.streamLineColorSelect,this.streamLineColorInput),streamLineSpeedFactor:+this.streamLineSpeedFactorInput.value,streamLineStatic:this.streamLineStaticInput.checked,showBelowMin:this.showBelowMinInput.checked,showAboveMax:this.showAboveMaxInput.checked,colorScheme:this.colorSchemeSelect.value||void 0,colors:e("colorsInput"),colorMap:e("colorMapInput"),levels:e("levelsInput"),blurRadius:+this.blurRadiusInput.value,addDegrees:+this.addDegreesInput.value,units:this.unitsInput.value||void 0,extraUnits:e("extraUnitsInput"),mask:this.maskSelect.value||void 0,gl:{animationSpeed:+this.animationSpeed.value||void 0,noiseTexturePow:+this.noiseTexturePow.value||void 0,vectorFieldFactor:+this.vectorFieldFactor.value||void 0,animationIntensity:+this.animationIntensity.value||void 0,wavesCount:+this.wavesCount.value||void 0}}}_setStyleToTextArea(e){this.editorTextAreaEl.value=JSON.stringify(ve(e),null,2)}_setStyleToDiv(e){this.parentInput.value=e.parent||"",this.nameInput.value=e.name||"",this.fillSelect.value=e.fill||"",this.isolineColorSelect.value=e.isolineColor?.[0]==="#"?"custom":e.isolineColor||"",this.isolineColorInput.value=e.isolineColor?.[0]==="#"?e.isolineColor:"#000000",this.isolineTextInput.checked=e.isolineText||!1,this.vectorTypeSelect.value=e.vectorType||"",this.vectorColorSelect.value=e.vectorColor?.[0]==="#"?"custom":e.vectorColor||"",this.vectorColorInput.value=e.vectorColor?.[0]==="#"?e.vectorColor:"#000000",this.vectorFactorInput.value=e.vectorFactor?.toString()||"1",this.streamLineColorSelect.value=e.streamLineColor?.[0]==="#"?"custom":e.streamLineColor||"",this.streamLineColorInput.value=e.streamLineColor?.[0]==="#"?e.streamLineColor:"#000000",this.streamLineSpeedFactorInput.value=e.streamLineSpeedFactor?.toString()||"1",this.streamLineStaticInput.checked=e.streamLineStatic||!1,this.showBelowMinInput.checked=e.showBelowMin||!1,this.showAboveMaxInput.checked=e.showAboveMax||!1,this.colorSchemeSelect.value=e.colorScheme||"",this.colorsInput.value=e.colors?.length?JSON.stringify(e.colors):"",this.colorMapInput.value=e.colorMap?.length?JSON.stringify(e.colorMap):"",this.levelsInput.value=e.levels?.length?JSON.stringify(e.levels.map(t=>+t.toFixed(2))):"",this.blurRadiusInput.value=e.blurRadius?.toString()||"",this.addDegreesInput.value=e.addDegrees?.toString()||"",this.unitsInput.value=e.units||"",this.extraUnitsInput.value=e.extraUnits?JSON.stringify(e.extraUnits):"",this.maskSelect.value=e.mask||"",e.gl?.animationSpeed&&(this.animationSpeed.value=e.gl.animationSpeed.toString()),e.gl?.noiseTexturePow&&(this.noiseTexturePow.value=e.gl.noiseTexturePow.toString()),e.gl?.vectorFieldFactor&&(this.vectorFieldFactor.value=e.gl.vectorFieldFactor.toString()),e.gl?.animationIntensity&&(this.animationIntensity.value=e.gl.animationIntensity.toString()),e.gl?.wavesCount&&(this.wavesCount.value=e.gl.wavesCount.toString())}_onDivChange(){let e=this._getStyleFromDiv();for(let t of Object.keys(e))(e[t]===void 0||e[t]===""||e[t].length===0)&&delete e[t];this._setStyleToTextArea(e),this.onchange?.(this.getStyle())}};function I(r,e,t){let a=document.createElement(e);return Object.assign(a,t),r?.appendChild(a),a}function ve(r){return Array.isArray(r)?r.map(ve):typeof r=="object"&&r!==null?Object.keys(r).sort((t,a)=>{let n=t.toUpperCase(),s=a.toUpperCase();return n===s?0:n>s?1:-1}).reduce((t,a)=>(t[a]=ve(r[a]),t),{}):r}var ue=class{constructor(e,t){this.delay=e;this.wxsource=t;this.onchange=()=>{};let a=document.createElement("div");a.className="mapboxgl-ctrl leaflet-control",a.style.borderStyle="solid",a.style.borderColor="#000",a.style.backgroundColor="#aaaaaaaa",a.style.padding="5px",a.style.display="flex",a.style.flexDirection="column",this._div=a,a.innerText="Time animation",this.buttonPlayStop=document.createElement("button"),a.appendChild(this.buttonPlayStop),this.timesEl=document.createElement("select"),a.appendChild(this.timesEl),this.timesEl.onchange=async()=>{this.timesEl.style.backgroundColor!=="yellow"&&(this.timesEl.style.backgroundColor="yellow",this.timesEl.value=await this.wxsource?.setTime(this.timesEl.value)||"",this.onchange(this.timesEl.value),this.timesEl.style.backgroundColor="white")},this.wxsource&&this.updateSource(this.wxsource),this.buttonPlayStop.innerHTML="Start";let n=0,s={abortController:new AbortController};this.buttonPlayStop.onclick=async()=>{if(this.buttonPlayStop.innerHTML==="Start"){this.buttonPlayStop.innerHTML="Stop";let i=async()=>{if(this.wxsource){if(this.timesEl.style.backgroundColor="yellow",this.buttonPlayStop.innerHTML==="Stop"){let o=n++%this.wxsource.getAllTimes().length;await this.wxsource.setTime(o,s.abortController),setTimeout(i,this.delay)}else await this.wxsource.unsetCoarseLevel();this.timesEl.value=this.wxsource.getTime()||"",this.onchange(this.timesEl.value),this.timesEl.style.backgroundColor="white"}};await this.wxsource?.setCoarseLevel(2),i()}else s.abortController.abort(),s.abortController=new AbortController,this.buttonPlayStop.innerHTML="Start"}}setTimes(e){this.timesEl.options.length=0;for(let t=0;t<e.length;t++){let a=document.createElement("option");a.value=e[t],a.text=e[t],this.timesEl.appendChild(a)}this.onchange(this.timesEl.value)}updateSource(e){this.buttonPlayStop.innerHTML="Start",this.wxsource=e;let t=this.wxsource?.getAllTimes()||[];this.setTimes(t),this.timesEl.value=this.wxsource?.getTime()||"",this.onchange(this.timesEl.value),e?.on("changed",()=>this.updateSource(e))}onAdd(){return this._div}onRemove(){this._div.parentNode?.removeChild(this._div)}extender(){return{onAdd:()=>this.onAdd(),onRemove:()=>this.onRemove()}}};return ze(vt);})();
@@ -19,6 +19,8 @@
19
19
  --dark-hl-8: #4EC9B0;
20
20
  --light-hl-9: #098658;
21
21
  --dark-hl-9: #B5CEA8;
22
+ --light-hl-10: #EE0000;
23
+ --dark-hl-10: #D7BA7D;
22
24
  --light-code-background: #FFFFFF;
23
25
  --dark-code-background: #1E1E1E;
24
26
  }
@@ -34,6 +36,7 @@
34
36
  --hl-7: var(--light-hl-7);
35
37
  --hl-8: var(--light-hl-8);
36
38
  --hl-9: var(--light-hl-9);
39
+ --hl-10: var(--light-hl-10);
37
40
  --code-background: var(--light-code-background);
38
41
  } }
39
42
 
@@ -48,6 +51,7 @@
48
51
  --hl-7: var(--dark-hl-7);
49
52
  --hl-8: var(--dark-hl-8);
50
53
  --hl-9: var(--dark-hl-9);
54
+ --hl-10: var(--dark-hl-10);
51
55
  --code-background: var(--dark-code-background);
52
56
  } }
53
57
 
@@ -62,6 +66,7 @@
62
66
  --hl-7: var(--light-hl-7);
63
67
  --hl-8: var(--light-hl-8);
64
68
  --hl-9: var(--light-hl-9);
69
+ --hl-10: var(--light-hl-10);
65
70
  --code-background: var(--light-code-background);
66
71
  }
67
72
 
@@ -76,6 +81,7 @@
76
81
  --hl-7: var(--dark-hl-7);
77
82
  --hl-8: var(--dark-hl-8);
78
83
  --hl-9: var(--dark-hl-9);
84
+ --hl-10: var(--dark-hl-10);
79
85
  --code-background: var(--dark-code-background);
80
86
  }
81
87
 
@@ -89,4 +95,5 @@
89
95
  .hl-7 { color: var(--hl-7); }
90
96
  .hl-8 { color: var(--hl-8); }
91
97
  .hl-9 { color: var(--hl-9); }
98
+ .hl-10 { color: var(--hl-10); }
92
99
  pre, code { background: var(--code-background); }