ol 8.1.1-dev.1694608919656 → 8.1.1-dev.1694687206621

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 (50) hide show
  1. package/Feature.d.ts +2 -2
  2. package/Feature.d.ts.map +1 -1
  3. package/Feature.js +1 -1
  4. package/color.d.ts +1 -1
  5. package/color.d.ts.map +1 -1
  6. package/color.js +12 -11
  7. package/dist/ol.js +2 -2
  8. package/dist/ol.js.map +1 -1
  9. package/format/EsriJSON.d.ts +8 -0
  10. package/format/EsriJSON.d.ts.map +1 -1
  11. package/format/Feature.d.ts +79 -5
  12. package/format/Feature.d.ts.map +1 -1
  13. package/format/Feature.js +151 -11
  14. package/format/GeoJSON.d.ts +11 -0
  15. package/format/GeoJSON.d.ts.map +1 -1
  16. package/format/GeoJSON.js +144 -52
  17. package/format/JSONFeature.d.ts +4 -24
  18. package/format/JSONFeature.d.ts.map +1 -1
  19. package/format/JSONFeature.js +4 -4
  20. package/format/MVT.d.ts.map +1 -1
  21. package/format/MVT.js +3 -2
  22. package/format/TopoJSON.d.ts +8 -0
  23. package/format/TopoJSON.d.ts.map +1 -1
  24. package/geom/SimpleGeometry.d.ts +5 -0
  25. package/geom/SimpleGeometry.d.ts.map +1 -1
  26. package/geom/SimpleGeometry.js +1 -1
  27. package/interaction/DragAndDrop.d.ts +1 -1
  28. package/interaction/Draw.d.ts +2 -2
  29. package/interaction/Modify.d.ts +1 -1
  30. package/interaction/Snap.d.ts +1 -1
  31. package/layer/BaseVector.d.ts +2 -2
  32. package/layer/Graticule.d.ts +2 -1
  33. package/layer/Graticule.d.ts.map +1 -1
  34. package/layer/Heatmap.d.ts +2 -2
  35. package/layer/Heatmap.js +1 -1
  36. package/layer/Vector.d.ts +1 -1
  37. package/layer/VectorImage.d.ts +2 -2
  38. package/layer/WebGLPoints.d.ts +4 -4
  39. package/layer/WebGLPoints.js +2 -2
  40. package/package.json +2 -1
  41. package/render/Feature.d.ts +33 -11
  42. package/render/Feature.d.ts.map +1 -1
  43. package/render/Feature.js +115 -21
  44. package/render/webgl/MixedGeometryBatch.d.ts.map +1 -1
  45. package/render/webgl/MixedGeometryBatch.js +1 -3
  46. package/source/Cluster.d.ts +2 -2
  47. package/source/Vector.d.ts +74 -66
  48. package/source/Vector.d.ts.map +1 -1
  49. package/source/Vector.js +98 -67
  50. package/util.js +1 -1
@@ -62,6 +62,13 @@ declare class EsriJSON extends JSONFeature {
62
62
  * @return {import("../Feature.js").default} Feature.
63
63
  */
64
64
  protected readFeatureFromObject(object: any, options?: import("./Feature.js").ReadOptions | undefined, idField?: string | undefined): import("../Feature.js").default;
65
+ /**
66
+ * @param {Object} object Object.
67
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
68
+ * @protected
69
+ * @return {Array<Feature>} Features.
70
+ */
71
+ protected readFeaturesFromObject(object: any, options?: import("./Feature.js").ReadOptions | undefined): Array<Feature>;
65
72
  /**
66
73
  * @param {EsriJSONGeometry} object Object.
67
74
  * @param {import("./Feature.js").ReadOptions} [options] Read options.
@@ -89,4 +96,5 @@ declare class EsriJSON extends JSONFeature {
89
96
  writeFeaturesObject(features: Array<import("../Feature.js").default>, options?: import("./Feature.js").WriteOptions | undefined): EsriJSONFeatureSet;
90
97
  }
91
98
  import JSONFeature from './JSONFeature.js';
99
+ import Feature from '../Feature.js';
92
100
  //# sourceMappingURL=EsriJSON.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EsriJSON.d.ts","sourceRoot":"","sources":["EsriJSON.js"],"names":[],"mappings":";8BAoBa,OAAO,iBAAiB,EAAE,OAAO;iCACjC,OAAO,iBAAiB,EAAE,UAAU;+BACpC,OAAO,iBAAiB,EAAE,QAAQ;4BAClC,OAAO,iBAAiB,EAAE,KAAK;+BAC/B,OAAO,iBAAiB,EAAE,QAAQ;8BAClC,OAAO,iBAAiB,EAAE,OAAO;iCACjC,OAAO,iBAAiB,EAAE,UAAU;4BACpC,OAAO,iBAAiB,EAAE,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Ae,EAAE,OAAO,CAkB1C;IAED;;;;;OAKG;IACH,yGAFY,MAAM,OAAO,CAAC,CAqBzB;IAED;;;;;OAKG;IACH,yCALW,gBAAgB,6DAGf,OAAO,qBAAqB,EAAE,OAAO,CAIhD;IAqBD;;;;;;;OAOG;IACH,8BALW,OAAO,qBAAqB,EAAE,OAAO,8DAEpC,gBAAgB,CAK3B;IAuCD;;;;;;;OAOG;IACH,8BALW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,8DAErC,kBAAkB,CAY7B;CACF;wBA9OuB,kBAAkB;oBADtB,eAAe"}
@@ -1,16 +1,29 @@
1
1
  /**
2
- * @param {import("../geom/Geometry.js").default} geometry Geometry.
2
+ * @template {import("../geom/Geometry.js").default|RenderFeature} T
3
+ * @param {T} geometry Geometry.
3
4
  * @param {boolean} write Set to true for writing, false for reading.
4
5
  * @param {WriteOptions|ReadOptions} [options] Options.
5
- * @return {import("../geom/Geometry.js").default} Transformed geometry.
6
+ * @return {T} Transformed geometry.
6
7
  */
7
- export function transformGeometryWithOptions(geometry: import("../geom/Geometry.js").default, write: boolean, options?: ReadOptions | WriteOptions | undefined): import("../geom/Geometry.js").default;
8
+ export function transformGeometryWithOptions<T extends import("../geom/Geometry.js").default | RenderFeature>(geometry: T, write: boolean, options?: ReadOptions | WriteOptions | undefined): T;
8
9
  /**
9
10
  * @param {import("../extent.js").Extent} extent Extent.
10
11
  * @param {ReadOptions} [options] Read options.
11
12
  * @return {import("../extent.js").Extent} Transformed extent.
12
13
  */
13
14
  export function transformExtentWithOptions(extent: import("../extent.js").Extent, options?: ReadOptions | undefined): import("../extent.js").Extent;
15
+ /**
16
+ * @param {FeatureObject} object Feature object.
17
+ * @param {WriteOptions|ReadOptions} [options] Options.
18
+ * @return {RenderFeature|Array<RenderFeature>} Render feature.
19
+ */
20
+ export function createRenderFeature(object: FeatureObject, options?: ReadOptions | WriteOptions | undefined): RenderFeature | Array<RenderFeature>;
21
+ /**
22
+ * @param {GeometryObject|null} object Geometry object.
23
+ * @param {WriteOptions|ReadOptions} [options] Options.
24
+ * @return {import("../geom/Geometry.js").default} Geometry.
25
+ */
26
+ export function createGeometry(object: GeometryObject | null, options?: ReadOptions | WriteOptions | undefined): import("../geom/Geometry.js").default;
14
27
  export default FeatureFormat;
15
28
  export type ReadOptions = {
16
29
  /**
@@ -71,6 +84,43 @@ export type WriteOptions = {
71
84
  decimals?: number | undefined;
72
85
  };
73
86
  export type Type = 'arraybuffer' | 'json' | 'text' | 'xml';
87
+ export type SimpleGeometryObject = {
88
+ /**
89
+ * Type.
90
+ */
91
+ type: import('../geom/Geometry.js').Type;
92
+ /**
93
+ * Flat coordinates.
94
+ */
95
+ flatCoordinates: Array<number>;
96
+ /**
97
+ * Ends or endss.
98
+ */
99
+ ends?: number[] | number[][] | undefined;
100
+ /**
101
+ * Layout.
102
+ */
103
+ layout?: import("../geom/Geometry.js").GeometryLayout | undefined;
104
+ };
105
+ export type GeometryCollectionObject = Array<GeometryObject>;
106
+ export type GeometryObject = SimpleGeometryObject | GeometryObject[];
107
+ export type FeatureObject = {
108
+ /**
109
+ * Id.
110
+ */
111
+ id?: string | number | undefined;
112
+ /**
113
+ * Geometry.
114
+ */
115
+ geometry?: GeometryObject | undefined;
116
+ /**
117
+ * Properties.
118
+ */
119
+ properties?: {
120
+ [x: string]: any;
121
+ } | undefined;
122
+ };
123
+ import RenderFeature from '../render/Feature.js';
74
124
  /**
75
125
  * @typedef {Object} ReadOptions
76
126
  * @property {import("../proj.js").ProjectionLike} [dataProjection] Projection of the data we are reading.
@@ -113,6 +163,25 @@ export type Type = 'arraybuffer' | 'json' | 'text' | 'xml';
113
163
  /**
114
164
  * @typedef {'arraybuffer' | 'json' | 'text' | 'xml'} Type
115
165
  */
166
+ /**
167
+ * @typedef {Object} SimpleGeometryObject
168
+ * @property {import('../geom/Geometry.js').Type} type Type.
169
+ * @property {Array<number>} flatCoordinates Flat coordinates.
170
+ * @property {Array<number>|Array<Array<number>>} [ends] Ends or endss.
171
+ * @property {import('../geom/Geometry.js').GeometryLayout} [layout] Layout.
172
+ */
173
+ /**
174
+ * @typedef {Array<GeometryObject>} GeometryCollectionObject
175
+ */
176
+ /**
177
+ * @typedef {SimpleGeometryObject|GeometryCollectionObject} GeometryObject
178
+ */
179
+ /**
180
+ * @typedef {Object} FeatureObject
181
+ * @property {string|number} [id] Id.
182
+ * @property {GeometryObject} [geometry] Geometry.
183
+ * @property {Object<string, *>} [properties] Properties.
184
+ */
116
185
  /**
117
186
  * @classdesc
118
187
  * Abstract base class; normally only used for creating subclasses and not
@@ -136,6 +205,11 @@ declare class FeatureFormat {
136
205
  * @type {import("../proj/Projection.js").default|undefined}
137
206
  */
138
207
  protected defaultFeatureProjection: import("../proj/Projection.js").default | undefined;
208
+ /**
209
+ * @protected
210
+ * @type {import("../Feature.js").FeatureClass}
211
+ */
212
+ protected featureClass: import("../Feature.js").FeatureClass;
139
213
  /**
140
214
  * A list media types supported by the format in descending order of preference.
141
215
  * @type {Array<string>}
@@ -170,9 +244,9 @@ declare class FeatureFormat {
170
244
  * @abstract
171
245
  * @param {Document|Element|Object|string} source Source.
172
246
  * @param {ReadOptions} [options] Read options.
173
- * @return {import("../Feature.js").FeatureLike} Feature.
247
+ * @return {import("../Feature.js").FeatureLike|Array<import("../render/Feature.js").default>} Feature.
174
248
  */
175
- readFeature(source: Document | Element | any | string, options?: ReadOptions | undefined): import("../Feature.js").FeatureLike;
249
+ readFeature(source: Document | Element | any | string, options?: ReadOptions | undefined): import("../Feature.js").FeatureLike | Array<import("../render/Feature.js").default>;
176
250
  /**
177
251
  * Read all features from a source.
178
252
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Feature.d.ts","sourceRoot":"","sources":["Feature.js"],"names":[],"mappings":"AAqOA;;;;;GAKG;AACH,uDALW,OAAO,qBAAqB,EAAE,OAAO,SACrC,OAAO,qDAEN,OAAO,qBAAqB,EAAE,OAAO,CA4ChD;AAED;;;;GAIG;AACH,mDAJW,OAAO,cAAc,EAA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,CAI7B;IAED;;;;;;;OAOG;IACH,wBAJW,OAAO,qBAAqB,EAAE,OAAO,uCAEpC,MAAM,GAAC,WAAW,CAI7B;CACF"}
package/format/Feature.js CHANGED
@@ -1,12 +1,30 @@
1
1
  /**
2
2
  * @module ol/format/Feature
3
3
  */
4
+ import Feature from '../Feature.js';
5
+ import RenderFeature from '../render/Feature.js';
6
+ import {
7
+ GeometryCollection,
8
+ LineString,
9
+ MultiLineString,
10
+ MultiPoint,
11
+ MultiPolygon,
12
+ Point,
13
+ Polygon,
14
+ } from '../geom.js';
4
15
  import {abstract} from '../util.js';
5
16
  import {
6
17
  equivalent as equivalentProjection,
7
18
  get as getProjection,
19
+ getTransform,
8
20
  transformExtent,
9
21
  } from '../proj.js';
22
+ import {
23
+ linearRingsAreOriented,
24
+ linearRingssAreOriented,
25
+ orientLinearRings,
26
+ orientLinearRingsArray,
27
+ } from '../geom/flat/orient.js';
10
28
 
11
29
  /**
12
30
  * @typedef {Object} ReadOptions
@@ -53,6 +71,29 @@ import {
53
71
  * @typedef {'arraybuffer' | 'json' | 'text' | 'xml'} Type
54
72
  */
55
73
 
74
+ /**
75
+ * @typedef {Object} SimpleGeometryObject
76
+ * @property {import('../geom/Geometry.js').Type} type Type.
77
+ * @property {Array<number>} flatCoordinates Flat coordinates.
78
+ * @property {Array<number>|Array<Array<number>>} [ends] Ends or endss.
79
+ * @property {import('../geom/Geometry.js').GeometryLayout} [layout] Layout.
80
+ */
81
+
82
+ /**
83
+ * @typedef {Array<GeometryObject>} GeometryCollectionObject
84
+ */
85
+
86
+ /**
87
+ * @typedef {SimpleGeometryObject|GeometryCollectionObject} GeometryObject
88
+ */
89
+
90
+ /**
91
+ * @typedef {Object} FeatureObject
92
+ * @property {string|number} [id] Id.
93
+ * @property {GeometryObject} [geometry] Geometry.
94
+ * @property {Object<string, *>} [properties] Properties.
95
+ */
96
+
56
97
  /**
57
98
  * @classdesc
58
99
  * Abstract base class; normally only used for creating subclasses and not
@@ -79,6 +120,12 @@ class FeatureFormat {
79
120
  */
80
121
  this.defaultFeatureProjection = undefined;
81
122
 
123
+ /**
124
+ * @protected
125
+ * @type {import("../Feature.js").FeatureClass}
126
+ */
127
+ this.featureClass = Feature;
128
+
82
129
  /**
83
130
  * A list media types supported by the format in descending order of preference.
84
131
  * @type {Array<string>}
@@ -128,6 +175,7 @@ class FeatureFormat {
128
175
  {
129
176
  dataProjection: this.dataProjection,
130
177
  featureProjection: this.defaultFeatureProjection,
178
+ featureClass: this.featureClass,
131
179
  },
132
180
  options
133
181
  );
@@ -147,7 +195,7 @@ class FeatureFormat {
147
195
  * @abstract
148
196
  * @param {Document|Element|Object|string} source Source.
149
197
  * @param {ReadOptions} [options] Read options.
150
- * @return {import("../Feature.js").FeatureLike} Feature.
198
+ * @return {import("../Feature.js").FeatureLike|Array<import("../render/Feature.js").default>} Feature.
151
199
  */
152
200
  readFeature(source, options) {
153
201
  return abstract();
@@ -228,10 +276,11 @@ class FeatureFormat {
228
276
  export default FeatureFormat;
229
277
 
230
278
  /**
231
- * @param {import("../geom/Geometry.js").default} geometry Geometry.
279
+ * @template {import("../geom/Geometry.js").default|RenderFeature} T
280
+ * @param {T} geometry Geometry.
232
281
  * @param {boolean} write Set to true for writing, false for reading.
233
282
  * @param {WriteOptions|ReadOptions} [options] Options.
234
- * @return {import("../geom/Geometry.js").default} Transformed geometry.
283
+ * @return {T} Transformed geometry.
235
284
  */
236
285
  export function transformGeometryWithOptions(geometry, write, options) {
237
286
  const featureProjection = options
@@ -239,18 +288,22 @@ export function transformGeometryWithOptions(geometry, write, options) {
239
288
  : null;
240
289
  const dataProjection = options ? getProjection(options.dataProjection) : null;
241
290
 
242
- let transformed;
291
+ let transformed = geometry;
243
292
  if (
244
293
  featureProjection &&
245
294
  dataProjection &&
246
295
  !equivalentProjection(featureProjection, dataProjection)
247
296
  ) {
248
- transformed = (write ? geometry.clone() : geometry).transform(
249
- write ? featureProjection : dataProjection,
250
- write ? dataProjection : featureProjection
251
- );
252
- } else {
253
- transformed = geometry;
297
+ if (write) {
298
+ transformed = /** @type {T} */ (geometry.clone());
299
+ }
300
+ const fromProjection = write ? featureProjection : dataProjection;
301
+ const toProjection = write ? dataProjection : featureProjection;
302
+ if (fromProjection.getUnits() === 'tile-pixels') {
303
+ transformed.transform(fromProjection, toProjection);
304
+ } else {
305
+ transformed.applyTransform(getTransform(fromProjection, toProjection));
306
+ }
254
307
  }
255
308
  if (
256
309
  write &&
@@ -270,7 +323,7 @@ export function transformGeometryWithOptions(geometry, write, options) {
270
323
  return coordinates;
271
324
  };
272
325
  if (transformed === geometry) {
273
- transformed = geometry.clone();
326
+ transformed = /** @type {T} */ (geometry.clone());
274
327
  }
275
328
  transformed.applyTransform(transform);
276
329
  }
@@ -297,3 +350,90 @@ export function transformExtentWithOptions(extent, options) {
297
350
  }
298
351
  return extent;
299
352
  }
353
+
354
+ const GeometryConstructor = {
355
+ Point: Point,
356
+ LineString: LineString,
357
+ Polygon: Polygon,
358
+ MultiPoint: MultiPoint,
359
+ MultiLineString: MultiLineString,
360
+ MultiPolygon: MultiPolygon,
361
+ };
362
+
363
+ function orientFlatCoordinates(flatCoordinates, ends, stride) {
364
+ if (Array.isArray(ends[0])) {
365
+ // MultiPolagon
366
+ if (!linearRingssAreOriented(flatCoordinates, 0, ends, stride)) {
367
+ flatCoordinates = flatCoordinates.slice();
368
+ orientLinearRingsArray(flatCoordinates, 0, ends, stride);
369
+ }
370
+ return flatCoordinates;
371
+ }
372
+ if (!linearRingsAreOriented(flatCoordinates, 0, ends, stride)) {
373
+ flatCoordinates = flatCoordinates.slice();
374
+ orientLinearRings(flatCoordinates, 0, ends, stride);
375
+ }
376
+ return flatCoordinates;
377
+ }
378
+
379
+ /**
380
+ * @param {FeatureObject} object Feature object.
381
+ * @param {WriteOptions|ReadOptions} [options] Options.
382
+ * @return {RenderFeature|Array<RenderFeature>} Render feature.
383
+ */
384
+ export function createRenderFeature(object, options) {
385
+ const geometry = object.geometry;
386
+ if (!geometry) {
387
+ return [];
388
+ }
389
+ if (Array.isArray(geometry)) {
390
+ return geometry
391
+ .map((geometry) => createRenderFeature({...object, geometry}))
392
+ .flat();
393
+ }
394
+
395
+ const geometryType =
396
+ geometry.type === 'MultiPolygon' ? 'Polygon' : geometry.type;
397
+ if (geometryType === 'GeometryCollection' || geometryType === 'Circle') {
398
+ throw new Error('Unsupported geometry type: ' + geometryType);
399
+ }
400
+
401
+ const stride = geometry.layout.length;
402
+ return transformGeometryWithOptions(
403
+ new RenderFeature(
404
+ geometryType,
405
+ geometryType === 'Polygon'
406
+ ? orientFlatCoordinates(geometry.flatCoordinates, geometry.ends, stride)
407
+ : geometry.flatCoordinates,
408
+ geometry.ends?.flat(),
409
+ stride,
410
+ object.properties || {},
411
+ object.id
412
+ ).enableSimplifyTransformed(),
413
+ false,
414
+ options
415
+ );
416
+ }
417
+
418
+ /**
419
+ * @param {GeometryObject|null} object Geometry object.
420
+ * @param {WriteOptions|ReadOptions} [options] Options.
421
+ * @return {import("../geom/Geometry.js").default} Geometry.
422
+ */
423
+ export function createGeometry(object, options) {
424
+ if (!object) {
425
+ return null;
426
+ }
427
+ if (Array.isArray(object)) {
428
+ const geometries = object.map((geometry) =>
429
+ createGeometry(geometry, options)
430
+ );
431
+ return new GeometryCollection(geometries);
432
+ }
433
+ const Geometry = GeometryConstructor[object.type];
434
+ return transformGeometryWithOptions(
435
+ new Geometry(object.flatCoordinates, object.layout, object.ends),
436
+ false,
437
+ options
438
+ );
439
+ }
@@ -31,6 +31,13 @@ export type Options = {
31
31
  * and a `geometryName` is provided, the `geometryName` will take precedence.
32
32
  */
33
33
  extractGeometryName?: boolean | undefined;
34
+ /**
35
+ * Feature class
36
+ * to be used when reading features. The default is {@link module :ol/Feature~Feature}. If performance is
37
+ * the primary concern, and features are not going to be modified or round-tripped through the format,
38
+ * consider using {@link module :ol/render/Feature~RenderFeature}
39
+ */
40
+ featureClass?: import("../Feature.js").FeatureClass | undefined;
34
41
  };
35
42
  /**
36
43
  * @typedef {import("geojson").GeoJSON} GeoJSONObject
@@ -55,6 +62,10 @@ export type Options = {
55
62
  * the geometry_name field in the feature GeoJSON. If set to `true` the GeoJSON reader
56
63
  * will look for that field to set the geometry name. If both this field is set to `true`
57
64
  * and a `geometryName` is provided, the `geometryName` will take precedence.
65
+ * @property {import("../Feature.js").FeatureClass} [featureClass] Feature class
66
+ * to be used when reading features. The default is {@link module:ol/Feature~Feature}. If performance is
67
+ * the primary concern, and features are not going to be modified or round-tripped through the format,
68
+ * consider using {@link module:ol/render/Feature~RenderFeature}
58
69
  */
59
70
  /**
60
71
  * @classdesc
@@ -1 +1 @@
1
- {"version":3,"file":"GeoJSON.d.ts","sourceRoot":"","sources":["GeoJSON.js"],"names":[],"mappings":";4BAkBa,OAAO,SAAS,EAAE,OAAO;6BACzB,OAAO,SAAS,EAAE,OAAO;uCACzB,OAAO,SAAS,EAAE,iBAAiB;8BACnC,OAAO,SAAS,EAAE,QAAQ;2BAC1B,OAAO,SAAS,EAAE,KAAK;gCACvB,OAAO,SAAS,EAAE,UAAU;6BAC5B,OAAO,SAAS,EAAE,OAAO;gCACzB,OAAO,SAAS,EAAE,UAAU;qCAC5B,OAAO,SAAS,EAAE,eAAe;kCACjC,OAAO,SAAS,EAAE,YAAY;wCAC9B,OAAO,SAAS,EAAE,kBAAkB;;;;;qBAKnC,OAAO,YAAY,EAAE,cAAc;;;;;wBACnC,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;AAjBjD;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH;IACE;;OAEG;IACH,2CAqCC;IAlBC;;;;OAIG;IACH,sBAAyC;IAEzC;;;;OAIG;IACH,6BAAuD;IA4EzD;;;;;OAKG;IACH,yCALW,eAAe,6DAGd,OAAO,qBAAqB,EAAE,OAAO,CAIhD;IAwBD;;;;;;;OAOG;IACH,4BALW,OAAO,eAAe,EAAE,OAAO,8DAE9B,cAAc,CAmCzB;IAED;;;;;;;OA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