@datagouv/components-next 0.2.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +1 -1
  2. package/assets/main.css +56 -1
  3. package/dist/Control-BNCDn-8E.js +148 -0
  4. package/dist/{Datafair.client-x39O4yfF.js → Datafair.client-Dls5AHTE.js} +1 -1
  5. package/dist/Event-BOgJUhNR.js +738 -0
  6. package/dist/Image-BN-4XkIn.js +247 -0
  7. package/dist/{JsonPreview.client-BMsC5JcY.js → JsonPreview.client-DPDTs433.js} +14 -14
  8. package/dist/Map-BdT3i2C4.js +7609 -0
  9. package/dist/MapContainer.client-BdAzd7bj.js +105 -0
  10. package/dist/OSM-CamriM9b.js +71 -0
  11. package/dist/{PdfPreview.client-COOkEkRA.js → PdfPreview.client-CopqSDyt.js} +3 -3
  12. package/dist/{Pmtiles.client-BaiIo4VZ.js → Pmtiles.client-mF6xaOO_.js} +2 -2
  13. package/dist/ScaleLine-BiesrgOv.js +165 -0
  14. package/dist/Swagger.client-eJ7gpfZA.js +4 -0
  15. package/dist/Tile-DCuqwNOI.js +1206 -0
  16. package/dist/TileImage-CmZf8EdU.js +1067 -0
  17. package/dist/View-DcDc7N2K.js +2858 -0
  18. package/dist/{XmlPreview.client-CAdN0w_Y.js → XmlPreview.client-C0OgBkSq.js} +7 -7
  19. package/dist/common-C4rDcQpp.js +243 -0
  20. package/dist/components-next.css +1 -1
  21. package/dist/components-next.js +153 -117
  22. package/dist/components.css +1 -1
  23. package/dist/{MapContainer.client-DeSo8EvG.js → index-BRGqW8aQ.js} +4975 -21416
  24. package/dist/leaflet-src-7m1mB8LI.js +6338 -0
  25. package/dist/{main-Dgri3TQL.js → main-CNHxAJ8J.js} +56758 -51450
  26. package/dist/proj-CKwYjU38.js +1569 -0
  27. package/dist/tilecoord-YW3qEH_j.js +884 -0
  28. package/dist/{vue3-xml-viewer.common-D6skc_Ai.js → vue3-xml-viewer.common-CmAdQfIy.js} +1 -1
  29. package/package.json +5 -1
  30. package/src/components/ActivityList/ActivityList.vue +6 -2
  31. package/src/components/AppLink.vue +4 -1
  32. package/src/components/Avatar.vue +2 -2
  33. package/src/components/AvatarWithName.vue +8 -4
  34. package/src/components/BouncingDots.vue +21 -0
  35. package/src/components/BrandedButton.vue +2 -0
  36. package/src/components/CopyButton.vue +19 -7
  37. package/src/components/DataserviceCard.vue +83 -118
  38. package/src/components/DatasetCard.vue +110 -171
  39. package/src/components/DatasetInformation/DatasetEmbedSection.vue +43 -0
  40. package/src/components/DatasetInformation/DatasetInformationSection.vue +73 -0
  41. package/src/components/DatasetInformation/DatasetSchemaSection.vue +74 -0
  42. package/src/components/DatasetInformation/DatasetSpatialSection.vue +59 -0
  43. package/src/components/DatasetInformation/DatasetTemporalitySection.vue +45 -0
  44. package/src/components/DatasetInformation/index.ts +5 -0
  45. package/src/components/DatasetQualityTooltipContent.vue +3 -3
  46. package/src/components/DescriptionList.vue +1 -4
  47. package/src/components/DescriptionListDetails.vue +5 -0
  48. package/src/components/DescriptionListTerm.vue +5 -0
  49. package/src/components/DiscussionMessageCard.vue +63 -0
  50. package/src/components/ExtraAccordion.vue +4 -4
  51. package/src/components/Form/BadgeSelect.vue +35 -0
  52. package/src/components/Form/FormatSelect.vue +28 -0
  53. package/src/components/Form/GeozoneSelect.vue +52 -0
  54. package/src/components/Form/GranularitySelect.vue +29 -0
  55. package/src/components/Form/LicenseSelect.vue +30 -0
  56. package/src/components/Form/OrganizationSelect.vue +62 -0
  57. package/src/components/Form/OrganizationTypeSelect.vue +34 -0
  58. package/src/components/Form/ReuseTopicSelect.vue +29 -0
  59. package/src/components/Form/SchemaSelect.vue +30 -0
  60. package/src/components/Form/SearchableSelect.vue +334 -0
  61. package/src/components/Form/SelectGroup.vue +132 -0
  62. package/src/components/Form/TagSelect.vue +38 -0
  63. package/src/components/LeafletMap.vue +31 -0
  64. package/src/components/LicenseBadge.vue +24 -0
  65. package/src/components/LoadingBlock.vue +23 -2
  66. package/src/components/MarkdownViewer.vue +3 -1
  67. package/src/components/ObjectCard.vue +42 -0
  68. package/src/components/ObjectCardBadge.vue +22 -0
  69. package/src/components/ObjectCardHeader.vue +35 -0
  70. package/src/components/ObjectCardOwner.vue +43 -0
  71. package/src/components/ObjectCardShortDescription.vue +28 -0
  72. package/src/components/OrganizationCard.vue +35 -20
  73. package/src/components/OrganizationLogo.vue +1 -1
  74. package/src/components/OrganizationNameWithCertificate.vue +13 -7
  75. package/src/components/OwnerTypeIcon.vue +1 -0
  76. package/src/components/Pagination.vue +1 -1
  77. package/src/components/Placeholder.vue +5 -2
  78. package/src/components/PostCard.vue +62 -0
  79. package/src/components/RadioGroup.vue +32 -0
  80. package/src/components/RadioInput.vue +64 -0
  81. package/src/components/ResourceAccordion/EditButton.vue +2 -3
  82. package/src/components/ResourceAccordion/MapContainer.client.vue +20 -16
  83. package/src/components/ResourceAccordion/Metadata.vue +11 -24
  84. package/src/components/ResourceAccordion/Pmtiles.client.vue +1 -1
  85. package/src/components/ResourceAccordion/Preview.vue +1 -1
  86. package/src/components/ResourceAccordion/ResourceAccordion.vue +30 -20
  87. package/src/components/ResourceAccordion/ResourceIcon.vue +1 -0
  88. package/src/components/ResourceAccordion/SchemaBadge.vue +2 -2
  89. package/src/components/ResourceExplorer/ResourceExplorer.vue +243 -0
  90. package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +116 -0
  91. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +361 -0
  92. package/src/components/ReuseCard.vue +8 -28
  93. package/src/components/ReuseHorizontalCard.vue +80 -0
  94. package/src/components/Search/BasicAndAdvancedFilters.vue +49 -0
  95. package/src/components/Search/Filter/AccessTypeFilter.vue +37 -0
  96. package/src/components/Search/Filter/DatasetBadgeFilter.vue +40 -0
  97. package/src/components/Search/Filter/FilterButtonGroup.vue +78 -0
  98. package/src/components/Search/Filter/FormatFamilyFilter.vue +39 -0
  99. package/src/components/Search/Filter/LastUpdateRangeFilter.vue +37 -0
  100. package/src/components/Search/Filter/ProducerTypeFilter.vue +39 -0
  101. package/src/components/Search/Filter/ReuseTypeFilter.vue +42 -0
  102. package/src/components/Search/GlobalSearch.vue +611 -0
  103. package/src/components/Search/SearchInput.vue +63 -0
  104. package/src/components/Search/Sidemenu.vue +38 -0
  105. package/src/components/StatBox.vue +5 -5
  106. package/src/components/Tag.vue +30 -0
  107. package/src/components/Toggletip.vue +6 -2
  108. package/src/components/Tooltip.vue +2 -3
  109. package/src/components/TopicCard.vue +134 -0
  110. package/src/components/radioGroupContext.ts +9 -0
  111. package/src/composables/useDebouncedRef.ts +31 -0
  112. package/src/composables/useMetrics.ts +4 -3
  113. package/src/composables/useResourceCapabilities.ts +118 -0
  114. package/src/composables/useRouteQueryBoolean.ts +10 -0
  115. package/src/composables/useSelectModelSync.ts +89 -0
  116. package/src/composables/useStableQueryParams.ts +84 -0
  117. package/src/config.ts +4 -0
  118. package/src/functions/api.ts +17 -6
  119. package/src/functions/api.types.ts +4 -2
  120. package/src/functions/datasets.ts +1 -29
  121. package/src/functions/description.ts +33 -0
  122. package/src/functions/helpers.ts +11 -0
  123. package/src/functions/markdown.ts +60 -16
  124. package/src/functions/metrics.ts +33 -0
  125. package/src/functions/organizations.ts +5 -5
  126. package/src/main.ts +89 -7
  127. package/src/types/dataservices.ts +14 -12
  128. package/src/types/datasets.ts +20 -7
  129. package/src/types/discussions.ts +20 -0
  130. package/src/types/licenses.ts +3 -3
  131. package/src/types/organizations.ts +13 -1
  132. package/src/types/owned.ts +4 -2
  133. package/src/types/pages.ts +70 -0
  134. package/src/types/posts.ts +27 -0
  135. package/src/types/resources.ts +6 -0
  136. package/src/types/reuses.ts +14 -5
  137. package/src/types/search.ts +379 -0
  138. package/src/types/users.ts +12 -3
  139. package/dist/Swagger.client-CpLgaLg6.js +0 -4
  140. package/src/components/DatasetInformationPanel.vue +0 -211
@@ -0,0 +1,1206 @@
1
+ import { T as De, b as Oe, d as ye, I as Ke, R as Pe, g as Me } from "./tilecoord-YW3qEH_j.js";
2
+ import { T, g as Te, d as j, c as Ee, t as ze } from "./Image-BN-4XkIn.js";
3
+ import { aF as be, aH as Ae, ak as ee, E as ke, _ as je, an as Ce, aI as Fe, az as Ze, aJ as Ne, K as Ue, D as Ge, m as Be, W as qe, a as z, aK as He, j as re, d as oe, a1 as Ve, i as We, G as Xe } from "./proj-CKwYjU38.js";
4
+ import { a as te, e as ne, o as Ye, g as v, d as ae, n as $e, p as Qe } from "./common-C4rDcQpp.js";
5
+ import { a as xe, R as Je, E as X, L as et } from "./Event-BOgJUhNR.js";
6
+ function le(d) {
7
+ return d instanceof Image || d instanceof HTMLCanvasElement || d instanceof HTMLVideoElement || d instanceof ImageBitmap ? d : null;
8
+ }
9
+ const tt = new Error("disposed"), nt = [256, 256];
10
+ class Re extends De {
11
+ /**
12
+ * @param {Options} options Tile options.
13
+ */
14
+ constructor(e) {
15
+ const t = T.IDLE;
16
+ super(e.tileCoord, t, {
17
+ transition: e.transition,
18
+ interpolate: e.interpolate
19
+ }), this.loader_ = e.loader, this.data_ = null, this.error_ = null, this.size_ = e.size || null, this.controller_ = e.controller || null;
20
+ }
21
+ /**
22
+ * Get the tile size.
23
+ * @return {import('./size.js').Size} Tile size.
24
+ */
25
+ getSize() {
26
+ if (this.size_)
27
+ return this.size_;
28
+ const e = le(this.data_);
29
+ return e ? [e.width, e.height] : nt;
30
+ }
31
+ /**
32
+ * Get the data for the tile.
33
+ * @return {Data} Tile data.
34
+ * @api
35
+ */
36
+ getData() {
37
+ return this.data_;
38
+ }
39
+ /**
40
+ * Get any loading error.
41
+ * @return {Error} Loading error.
42
+ * @api
43
+ */
44
+ getError() {
45
+ return this.error_;
46
+ }
47
+ /**
48
+ * Load the tile data.
49
+ * @api
50
+ * @override
51
+ */
52
+ load() {
53
+ if (this.state !== T.IDLE && this.state !== T.ERROR)
54
+ return;
55
+ this.state = T.LOADING, this.changed();
56
+ const e = this;
57
+ this.loader_().then(function(t) {
58
+ e.data_ = t, e.state = T.LOADED, e.changed();
59
+ }).catch(function(t) {
60
+ e.error_ = t, e.state = T.ERROR, e.changed();
61
+ });
62
+ }
63
+ /**
64
+ * Clean up.
65
+ * @override
66
+ */
67
+ disposeInternal() {
68
+ this.controller_ && (this.controller_.abort(tt), this.controller_ = null), super.disposeInternal();
69
+ }
70
+ }
71
+ class it {
72
+ /**
73
+ * @param {number} [highWaterMark] High water mark.
74
+ */
75
+ constructor(e) {
76
+ this.highWaterMark = e !== void 0 ? e : 2048, this.count_ = 0, this.entries_ = {}, this.oldest_ = null, this.newest_ = null;
77
+ }
78
+ deleteOldest() {
79
+ const e = this.pop();
80
+ e instanceof be && e.dispose();
81
+ }
82
+ /**
83
+ * @return {boolean} Can expire cache.
84
+ */
85
+ canExpireCache() {
86
+ return this.highWaterMark > 0 && this.getCount() > this.highWaterMark;
87
+ }
88
+ /**
89
+ * Expire the cache. When the cache entry is a {@link module:ol/Disposable~Disposable},
90
+ * the entry will be disposed.
91
+ * @param {!Object<string, boolean>} [keep] Keys to keep. To be implemented by subclasses.
92
+ */
93
+ expireCache(e) {
94
+ for (; this.canExpireCache(); )
95
+ this.deleteOldest();
96
+ }
97
+ /**
98
+ * FIXME empty description for jsdoc
99
+ */
100
+ clear() {
101
+ for (; this.oldest_; )
102
+ this.deleteOldest();
103
+ }
104
+ /**
105
+ * @param {string} key Key.
106
+ * @return {boolean} Contains key.
107
+ */
108
+ containsKey(e) {
109
+ return this.entries_.hasOwnProperty(e);
110
+ }
111
+ /**
112
+ * @param {function(T, string, LRUCache<T>): ?} f The function
113
+ * to call for every entry from the oldest to the newer. This function takes
114
+ * 3 arguments (the entry value, the entry key and the LRUCache object).
115
+ * The return value is ignored.
116
+ */
117
+ forEach(e) {
118
+ let t = this.oldest_;
119
+ for (; t; )
120
+ e(t.value_, t.key_, this), t = t.newer;
121
+ }
122
+ /**
123
+ * @param {string} key Key.
124
+ * @param {*} [options] Options (reserved for subclasses).
125
+ * @return {T} Value.
126
+ */
127
+ get(e, t) {
128
+ const n = this.entries_[e];
129
+ return te(
130
+ n !== void 0,
131
+ "Tried to get a value for a key that does not exist in the cache"
132
+ ), n === this.newest_ || (n === this.oldest_ ? (this.oldest_ = /** @type {Entry} */
133
+ this.oldest_.newer, this.oldest_.older = null) : (n.newer.older = n.older, n.older.newer = n.newer), n.newer = null, n.older = this.newest_, this.newest_.newer = n, this.newest_ = n), n.value_;
134
+ }
135
+ /**
136
+ * Remove an entry from the cache.
137
+ * @param {string} key The entry key.
138
+ * @return {T} The removed entry.
139
+ */
140
+ remove(e) {
141
+ const t = this.entries_[e];
142
+ return te(
143
+ t !== void 0,
144
+ "Tried to get a value for a key that does not exist in the cache"
145
+ ), t === this.newest_ ? (this.newest_ = /** @type {Entry} */
146
+ t.older, this.newest_ && (this.newest_.newer = null)) : t === this.oldest_ ? (this.oldest_ = /** @type {Entry} */
147
+ t.newer, this.oldest_ && (this.oldest_.older = null)) : (t.newer.older = t.older, t.older.newer = t.newer), delete this.entries_[e], --this.count_, t.value_;
148
+ }
149
+ /**
150
+ * @return {number} Count.
151
+ */
152
+ getCount() {
153
+ return this.count_;
154
+ }
155
+ /**
156
+ * @return {Array<string>} Keys.
157
+ */
158
+ getKeys() {
159
+ const e = new Array(this.count_);
160
+ let t = 0, n;
161
+ for (n = this.newest_; n; n = n.older)
162
+ e[t++] = n.key_;
163
+ return e;
164
+ }
165
+ /**
166
+ * @return {Array<T>} Values.
167
+ */
168
+ getValues() {
169
+ const e = new Array(this.count_);
170
+ let t = 0, n;
171
+ for (n = this.newest_; n; n = n.older)
172
+ e[t++] = n.value_;
173
+ return e;
174
+ }
175
+ /**
176
+ * @return {T} Last value.
177
+ */
178
+ peekLast() {
179
+ return this.oldest_.value_;
180
+ }
181
+ /**
182
+ * @return {string} Last key.
183
+ */
184
+ peekLastKey() {
185
+ return this.oldest_.key_;
186
+ }
187
+ /**
188
+ * Get the key of the newest item in the cache. Throws if the cache is empty.
189
+ * @return {string} The newest key.
190
+ */
191
+ peekFirstKey() {
192
+ return this.newest_.key_;
193
+ }
194
+ /**
195
+ * Return an entry without updating least recently used time.
196
+ * @param {string} key Key.
197
+ * @return {T|undefined} Value.
198
+ */
199
+ peek(e) {
200
+ return this.entries_[e]?.value_;
201
+ }
202
+ /**
203
+ * @return {T} value Value.
204
+ */
205
+ pop() {
206
+ const e = this.oldest_;
207
+ return delete this.entries_[e.key_], e.newer && (e.newer.older = null), this.oldest_ = /** @type {Entry} */
208
+ e.newer, this.oldest_ || (this.newest_ = null), --this.count_, e.value_;
209
+ }
210
+ /**
211
+ * @param {string} key Key.
212
+ * @param {T} value Value.
213
+ */
214
+ replace(e, t) {
215
+ this.get(e), this.entries_[e].value_ = t;
216
+ }
217
+ /**
218
+ * @param {string} key Key.
219
+ * @param {T} value Value.
220
+ */
221
+ set(e, t) {
222
+ te(
223
+ !(e in this.entries_),
224
+ "Tried to set a value for a key that is used already"
225
+ );
226
+ const n = {
227
+ key_: e,
228
+ newer: null,
229
+ older: this.newest_,
230
+ value_: t
231
+ };
232
+ this.newest_ ? this.newest_.newer = n : this.oldest_ = n, this.newest_ = n, this.entries_[e] = n, ++this.count_;
233
+ }
234
+ /**
235
+ * Set a maximum number of entries for the cache.
236
+ * @param {number} size Cache size.
237
+ * @api
238
+ */
239
+ setSize(e) {
240
+ this.highWaterMark = e;
241
+ }
242
+ }
243
+ class st {
244
+ constructor() {
245
+ this.instructions_ = [], this.zIndex = 0, this.offset_ = 0, this.context_ = /** @type {ZIndexContextProxy} */
246
+ new Proxy(Te(), {
247
+ get: (e, t) => {
248
+ if (typeof /** @type {*} */
249
+ Te()[t] == "function")
250
+ return this.push_(t), this.pushMethodArgs_;
251
+ },
252
+ set: (e, t, n) => (this.push_(t, n), !0)
253
+ });
254
+ }
255
+ /**
256
+ * @param {...*} args Arguments to push to the instructions array.
257
+ * @private
258
+ */
259
+ push_(...e) {
260
+ const t = this.instructions_, n = this.zIndex + this.offset_;
261
+ t[n] || (t[n] = []), t[n].push(...e);
262
+ }
263
+ /**
264
+ * @private
265
+ * @param {...*} args Args.
266
+ * @return {ZIndexContext} This.
267
+ */
268
+ pushMethodArgs_ = (...e) => (this.push_(e), this);
269
+ /**
270
+ * Push a function that renders to the context directly.
271
+ * @param {function(CanvasRenderingContext2D): void} render Function.
272
+ */
273
+ pushFunction(e) {
274
+ this.push_(e);
275
+ }
276
+ /**
277
+ * Get a proxy for CanvasRenderingContext2D which does not support getting state
278
+ * (e.g. `context.globalAlpha`, which will return `undefined`). To set state, if it relies on a
279
+ * previous state (e.g. `context.globalAlpha = context.globalAlpha / 2`), set a function,
280
+ * e.g. `context.globalAlpha = (context) => context.globalAlpha / 2`.
281
+ * @return {ZIndexContextProxy} Context.
282
+ */
283
+ getContext() {
284
+ return this.context_;
285
+ }
286
+ /**
287
+ * @param {CanvasRenderingContext2D} context Context.
288
+ */
289
+ draw(e) {
290
+ this.instructions_.forEach((t) => {
291
+ for (let n = 0, i = t.length; n < i; ++n) {
292
+ const r = t[n];
293
+ if (typeof r == "function") {
294
+ r(e);
295
+ continue;
296
+ }
297
+ const a = t[++n];
298
+ if (typeof /** @type {*} */
299
+ e[r] == "function")
300
+ e[r](...a);
301
+ else {
302
+ if (typeof a == "function") {
303
+ e[r] = a(e);
304
+ continue;
305
+ }
306
+ e[r] = a;
307
+ }
308
+ }
309
+ });
310
+ }
311
+ clear() {
312
+ this.instructions_.length = 0, this.zIndex = 0, this.offset_ = 0;
313
+ }
314
+ /**
315
+ * Offsets the zIndex by the highest current zIndex. Useful for rendering multiple worlds or tiles, to
316
+ * avoid conflicting context.clip() or context.save()/restore() calls.
317
+ */
318
+ offset() {
319
+ this.offset_ = this.instructions_.length, this.zIndex = 0;
320
+ }
321
+ }
322
+ const rt = 5;
323
+ class ot extends Ae {
324
+ /**
325
+ * @param {LayerType} layer Layer.
326
+ */
327
+ constructor(e) {
328
+ super(), this.ready = !0, this.boundHandleImageChange_ = this.handleImageChange_.bind(this), this.layer_ = e, this.staleKeys_ = new Array(), this.maxStaleKeys = rt;
329
+ }
330
+ /**
331
+ * @return {Array<string>} Get the list of stale keys.
332
+ */
333
+ getStaleKeys() {
334
+ return this.staleKeys_;
335
+ }
336
+ /**
337
+ * @param {string} key The new stale key.
338
+ */
339
+ prependStaleKey(e) {
340
+ this.staleKeys_.unshift(e), this.staleKeys_.length > this.maxStaleKeys && (this.staleKeys_.length = this.maxStaleKeys);
341
+ }
342
+ /**
343
+ * Asynchronous layer level hit detection.
344
+ * @param {import("../pixel.js").Pixel} pixel Pixel.
345
+ * @return {Promise<Array<import("../Feature").FeatureLike>>} Promise that resolves with
346
+ * an array of features.
347
+ */
348
+ getFeatures(e) {
349
+ return ee();
350
+ }
351
+ /**
352
+ * @param {import("../pixel.js").Pixel} pixel Pixel.
353
+ * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
354
+ */
355
+ getData(e) {
356
+ return null;
357
+ }
358
+ /**
359
+ * Determine whether render should be called.
360
+ * @abstract
361
+ * @param {import("../Map.js").FrameState} frameState Frame state.
362
+ * @return {boolean} Layer is ready to be rendered.
363
+ */
364
+ prepareFrame(e) {
365
+ return ee();
366
+ }
367
+ /**
368
+ * Render the layer.
369
+ * @abstract
370
+ * @param {import("../Map.js").FrameState} frameState Frame state.
371
+ * @param {HTMLElement|null} target Target that may be used to render content to.
372
+ * @return {HTMLElement} The rendered element.
373
+ */
374
+ renderFrame(e, t) {
375
+ return ee();
376
+ }
377
+ /**
378
+ * @abstract
379
+ * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
380
+ * @param {import("../Map.js").FrameState} frameState Frame state.
381
+ * @param {number} hitTolerance Hit tolerance in pixels.
382
+ * @param {import("./vector.js").FeatureCallback<T>} callback Feature callback.
383
+ * @param {Array<import("./Map.js").HitMatch<T>>} matches The hit detected matches with tolerance.
384
+ * @return {T|undefined} Callback result.
385
+ * @template T
386
+ */
387
+ forEachFeatureAtCoordinate(e, t, n, i, r) {
388
+ }
389
+ /**
390
+ * @return {LayerType} Layer.
391
+ */
392
+ getLayer() {
393
+ return this.layer_;
394
+ }
395
+ /**
396
+ * Perform action necessary to get the layer rendered after new fonts have loaded
397
+ * @abstract
398
+ */
399
+ handleFontsChanged() {
400
+ }
401
+ /**
402
+ * Handle changes in image state.
403
+ * @param {import("../events/Event.js").default} event Image change event.
404
+ * @private
405
+ */
406
+ handleImageChange_(e) {
407
+ const t = (
408
+ /** @type {import("../Image.js").default} */
409
+ e.target
410
+ );
411
+ (t.getState() === j.LOADED || t.getState() === j.ERROR) && this.renderIfReadyAndVisible();
412
+ }
413
+ /**
414
+ * Load the image if not already loaded, and register the image change
415
+ * listener if needed.
416
+ * @param {import("../Image.js").default} image Image.
417
+ * @return {boolean} `true` if the image is already loaded, `false` otherwise.
418
+ * @protected
419
+ */
420
+ loadImage(e) {
421
+ let t = e.getState();
422
+ return t != j.LOADED && t != j.ERROR && e.addEventListener(ke.CHANGE, this.boundHandleImageChange_), t == j.IDLE && (e.load(), t = e.getState()), t == j.LOADED;
423
+ }
424
+ /**
425
+ * @protected
426
+ */
427
+ renderIfReadyAndVisible() {
428
+ const e = this.getLayer();
429
+ e && e.getVisible() && e.getSourceState() === "ready" && e.changed();
430
+ }
431
+ /**
432
+ * @param {import("../Map.js").FrameState} frameState Frame state.
433
+ */
434
+ renderDeferred(e) {
435
+ }
436
+ /**
437
+ * Clean up.
438
+ * @override
439
+ */
440
+ disposeInternal() {
441
+ delete this.layer_, super.disposeInternal();
442
+ }
443
+ }
444
+ const Tt = [];
445
+ let F = null;
446
+ function at() {
447
+ F = Ee(1, 1, void 0, {
448
+ willReadFrequently: !0
449
+ });
450
+ }
451
+ class lt extends ot {
452
+ /**
453
+ * @param {LayerType} layer Layer.
454
+ */
455
+ constructor(e) {
456
+ super(e), this.container = null, this.renderedResolution, this.tempTransform = ne(), this.pixelTransform = ne(), this.inversePixelTransform = ne(), this.context = null, this.deferredContext_ = null, this.containerReused = !1, this.frameState = null;
457
+ }
458
+ /**
459
+ * @param {import('../../DataTile.js').ImageLike} image Image.
460
+ * @param {number} col The column index.
461
+ * @param {number} row The row index.
462
+ * @return {Uint8ClampedArray|null} The image data.
463
+ */
464
+ getImageData(e, t, n) {
465
+ F || at(), F.clearRect(0, 0, 1, 1);
466
+ let i;
467
+ try {
468
+ F.drawImage(e, t, n, 1, 1, 0, 0, 1, 1), i = F.getImageData(0, 0, 1, 1).data;
469
+ } catch {
470
+ return F = null, null;
471
+ }
472
+ return i;
473
+ }
474
+ /**
475
+ * @param {import('../../Map.js').FrameState} frameState Frame state.
476
+ * @return {string} Background color.
477
+ */
478
+ getBackground(e) {
479
+ let n = this.getLayer().getBackground();
480
+ return typeof n == "function" && (n = n(e.viewState.resolution)), n || void 0;
481
+ }
482
+ /**
483
+ * Get a rendering container from an existing target, if compatible.
484
+ * @param {HTMLElement} target Potential render target.
485
+ * @param {string} transform CSS transform matrix.
486
+ * @param {string} [backgroundColor] Background color.
487
+ */
488
+ useContainer(e, t, n) {
489
+ const i = this.getLayer().getClassName();
490
+ let r, a;
491
+ if (e && e.className === i && (!n || e && e.style.backgroundColor && je(
492
+ xe(e.style.backgroundColor),
493
+ xe(n)
494
+ ))) {
495
+ const s = e.firstElementChild;
496
+ s instanceof HTMLCanvasElement && (a = s.getContext("2d"));
497
+ }
498
+ if (a && Ye(a.canvas.style.transform, t) ? (this.container = e, this.context = a, this.containerReused = !0) : this.containerReused ? (this.container = null, this.context = null, this.containerReused = !1) : this.container && (this.container.style.backgroundColor = null), !this.container) {
499
+ r = document.createElement("div"), r.className = i;
500
+ let s = r.style;
501
+ s.position = "absolute", s.width = "100%", s.height = "100%", a = Ee();
502
+ const l = a.canvas;
503
+ r.appendChild(l), s = l.style, s.position = "absolute", s.left = "0", s.transformOrigin = "top left", this.container = r, this.context = a;
504
+ }
505
+ !this.containerReused && n && !this.container.style.backgroundColor && (this.container.style.backgroundColor = n);
506
+ }
507
+ /**
508
+ * @param {CanvasRenderingContext2D} context Context.
509
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
510
+ * @param {import("../../extent.js").Extent} extent Clip extent.
511
+ * @protected
512
+ */
513
+ clipUnrotated(e, t, n) {
514
+ const i = Ce(n), r = Fe(n), a = Ze(n), s = Ne(n);
515
+ v(t.coordinateToPixelTransform, i), v(t.coordinateToPixelTransform, r), v(t.coordinateToPixelTransform, a), v(t.coordinateToPixelTransform, s);
516
+ const l = this.inversePixelTransform;
517
+ v(l, i), v(l, r), v(l, a), v(l, s), e.save(), e.beginPath(), e.moveTo(Math.round(i[0]), Math.round(i[1])), e.lineTo(Math.round(r[0]), Math.round(r[1])), e.lineTo(Math.round(a[0]), Math.round(a[1])), e.lineTo(Math.round(s[0]), Math.round(s[1])), e.clip();
518
+ }
519
+ /**
520
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
521
+ * @param {HTMLElement} target Target that may be used to render content to.
522
+ * @protected
523
+ */
524
+ prepareContainer(e, t) {
525
+ const n = e.extent, i = e.viewState.resolution, r = e.viewState.rotation, a = e.pixelRatio, s = Math.round(Ue(n) / i * a), l = Math.round(Ge(n) / i * a);
526
+ ae(
527
+ this.pixelTransform,
528
+ e.size[0] / 2,
529
+ e.size[1] / 2,
530
+ 1 / a,
531
+ 1 / a,
532
+ r,
533
+ -s / 2,
534
+ -l / 2
535
+ ), $e(this.inversePixelTransform, this.pixelTransform);
536
+ const c = Qe(this.pixelTransform);
537
+ if (this.useContainer(t, c, this.getBackground(e)), !this.containerReused) {
538
+ const o = this.context.canvas;
539
+ o.width != s || o.height != l ? (o.width = s, o.height = l) : this.context.clearRect(0, 0, s, l), c !== o.style.transform && (o.style.transform = c);
540
+ }
541
+ }
542
+ /**
543
+ * @param {import("../../render/EventType.js").default} type Event type.
544
+ * @param {CanvasRenderingContext2D} context Context.
545
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
546
+ * @private
547
+ */
548
+ dispatchRenderEvent_(e, t, n) {
549
+ const i = this.getLayer();
550
+ if (i.hasListener(e)) {
551
+ const r = new Je(
552
+ e,
553
+ this.inversePixelTransform,
554
+ n,
555
+ t
556
+ );
557
+ i.dispatchEvent(r);
558
+ }
559
+ }
560
+ /**
561
+ * @param {CanvasRenderingContext2D} context Context.
562
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
563
+ * @protected
564
+ */
565
+ preRender(e, t) {
566
+ this.frameState = t, !t.declutter && this.dispatchRenderEvent_(X.PRERENDER, e, t);
567
+ }
568
+ /**
569
+ * @param {CanvasRenderingContext2D} context Context.
570
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
571
+ * @protected
572
+ */
573
+ postRender(e, t) {
574
+ t.declutter || this.dispatchRenderEvent_(X.POSTRENDER, e, t);
575
+ }
576
+ /**
577
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
578
+ */
579
+ renderDeferredInternal(e) {
580
+ }
581
+ /**
582
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
583
+ * @return {import('../../render/canvas/ZIndexContext.js').ZIndexContextProxy} Context.
584
+ */
585
+ getRenderContext(e) {
586
+ return e.declutter && !this.deferredContext_ && (this.deferredContext_ = new st()), e.declutter ? this.deferredContext_.getContext() : this.context;
587
+ }
588
+ /**
589
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
590
+ * @override
591
+ */
592
+ renderDeferred(e) {
593
+ e.declutter && (this.dispatchRenderEvent_(
594
+ X.PRERENDER,
595
+ this.context,
596
+ e
597
+ ), e.declutter && this.deferredContext_ && (this.deferredContext_.draw(this.context), this.deferredContext_.clear()), this.renderDeferredInternal(e), this.dispatchRenderEvent_(
598
+ X.POSTRENDER,
599
+ this.context,
600
+ e
601
+ ));
602
+ }
603
+ /**
604
+ * Creates a transform for rendering to an element that will be rotated after rendering.
605
+ * @param {import("../../coordinate.js").Coordinate} center Center.
606
+ * @param {number} resolution Resolution.
607
+ * @param {number} rotation Rotation.
608
+ * @param {number} pixelRatio Pixel ratio.
609
+ * @param {number} width Width of the rendered element (in pixels).
610
+ * @param {number} height Height of the rendered element (in pixels).
611
+ * @param {number} offsetX Offset on the x-axis in view coordinates.
612
+ * @protected
613
+ * @return {!import("../../transform.js").Transform} Transform.
614
+ */
615
+ getRenderTransform(e, t, n, i, r, a, s) {
616
+ const l = r / 2, c = a / 2, o = i / t, u = -o, h = -e[0] + s, g = -e[1];
617
+ return ae(
618
+ this.tempTransform,
619
+ l,
620
+ c,
621
+ o,
622
+ u,
623
+ -n,
624
+ h,
625
+ g
626
+ );
627
+ }
628
+ /**
629
+ * Clean up.
630
+ * @override
631
+ */
632
+ disposeInternal() {
633
+ delete this.frameState, super.disposeInternal();
634
+ }
635
+ }
636
+ function ie(d, e, t, n, i) {
637
+ return `${z(d)},${e},${Me(t, n, i)}`;
638
+ }
639
+ function se(d, e, t) {
640
+ if (!(t in d))
641
+ return d[t] = /* @__PURE__ */ new Set([e]), !0;
642
+ const n = d[t], i = n.has(e);
643
+ return i || n.add(e), !i;
644
+ }
645
+ function ct(d, e, t) {
646
+ const n = d[t];
647
+ return n ? n.delete(e) : !1;
648
+ }
649
+ function me(d, e) {
650
+ const t = d.layerStatesArray[d.layerIndex];
651
+ t.extent && (e = oe(
652
+ e,
653
+ re(t.extent, d.viewState.projection)
654
+ ));
655
+ const n = (
656
+ /** @type {import("../../source/Tile.js").default} */
657
+ t.layer.getRenderSource()
658
+ );
659
+ if (!n.getWrapX()) {
660
+ const i = n.getTileGridForProjection(d.viewState.projection).getExtent();
661
+ i && (e = oe(e, i));
662
+ }
663
+ return e;
664
+ }
665
+ class ht extends lt {
666
+ /**
667
+ * @param {LayerType} tileLayer Tile layer.
668
+ * @param {Options} [options] Options.
669
+ */
670
+ constructor(e, t) {
671
+ super(e), t = t || {}, this.extentChanged = !0, this.renderComplete = !1, this.renderedExtent_ = null, this.renderedPixelRatio, this.renderedProjection = null, this.renderedTiles = [], this.renderedSourceKey_, this.renderedSourceRevision_, this.tempExtent = Be(), this.tempTileRange_ = new Oe(0, 0, 0, 0), this.tempTileCoord_ = ye(0, 0, 0);
672
+ const n = t.cacheSize !== void 0 ? t.cacheSize : 512;
673
+ this.tileCache_ = new it(n), this.maxStaleKeys = n * 0.5;
674
+ }
675
+ /**
676
+ * @return {LRUCache} Tile cache.
677
+ */
678
+ getTileCache() {
679
+ return this.tileCache_;
680
+ }
681
+ /**
682
+ * Get a tile from the cache or create one if needed.
683
+ *
684
+ * @param {number} z Tile coordinate z.
685
+ * @param {number} x Tile coordinate x.
686
+ * @param {number} y Tile coordinate y.
687
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
688
+ * @return {import("../../Tile.js").default|null} Tile (or null if outside source extent).
689
+ * @protected
690
+ */
691
+ getOrCreateTile(e, t, n, i) {
692
+ const r = this.tileCache_, s = this.getLayer().getSource(), l = ie(s, s.getKey(), e, t, n);
693
+ let c;
694
+ if (r.containsKey(l))
695
+ c = r.get(l);
696
+ else {
697
+ if (c = s.getTile(
698
+ e,
699
+ t,
700
+ n,
701
+ i.pixelRatio,
702
+ i.viewState.projection
703
+ ), !c)
704
+ return null;
705
+ r.set(l, c);
706
+ }
707
+ return c;
708
+ }
709
+ /**
710
+ * @param {number} z Tile coordinate z.
711
+ * @param {number} x Tile coordinate x.
712
+ * @param {number} y Tile coordinate y.
713
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
714
+ * @return {import("../../Tile.js").default|null} Tile (or null if outside source extent).
715
+ * @protected
716
+ */
717
+ getTile(e, t, n, i) {
718
+ const r = this.getOrCreateTile(e, t, n, i);
719
+ return r || null;
720
+ }
721
+ /**
722
+ * @param {import("../../pixel.js").Pixel} pixel Pixel.
723
+ * @return {Uint8ClampedArray} Data at the pixel location.
724
+ * @override
725
+ */
726
+ getData(e) {
727
+ const t = this.frameState;
728
+ if (!t)
729
+ return null;
730
+ const n = this.getLayer(), i = v(
731
+ t.pixelToCoordinateTransform,
732
+ e.slice()
733
+ ), r = n.getExtent();
734
+ if (r && !qe(r, i))
735
+ return null;
736
+ const a = t.viewState, s = n.getRenderSource(), l = s.getTileGridForProjection(a.projection), c = s.getTilePixelRatio(t.pixelRatio);
737
+ for (let o = l.getZForResolution(a.resolution); o >= l.getMinZoom(); --o) {
738
+ const u = l.getTileCoordForCoordAndZ(i, o), h = this.getTile(o, u[1], u[2], t);
739
+ if (!h || h.getState() !== T.LOADED)
740
+ continue;
741
+ const g = l.getOrigin(o), p = ze(l.getTileSize(o)), S = l.getResolution(o);
742
+ let f;
743
+ if (h instanceof Ke || h instanceof Pe)
744
+ f = h.getImage();
745
+ else if (h instanceof Re) {
746
+ if (f = le(h.getData()), !f)
747
+ continue;
748
+ } else
749
+ continue;
750
+ const C = Math.floor(
751
+ c * ((i[0] - g[0]) / S - u[1] * p[0])
752
+ ), P = Math.floor(
753
+ c * ((g[1] - i[1]) / S - u[2] * p[1])
754
+ ), E = Math.round(
755
+ c * s.getGutterForProjection(a.projection)
756
+ );
757
+ return this.getImageData(f, C + E, P + E);
758
+ }
759
+ return null;
760
+ }
761
+ /**
762
+ * Determine whether render should be called.
763
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
764
+ * @return {boolean} Layer is ready to be rendered.
765
+ * @override
766
+ */
767
+ prepareFrame(e) {
768
+ this.renderedProjection ? e.viewState.projection !== this.renderedProjection && (this.tileCache_.clear(), this.renderedProjection = e.viewState.projection) : this.renderedProjection = e.viewState.projection;
769
+ const t = this.getLayer().getSource();
770
+ if (!t)
771
+ return !1;
772
+ const n = t.getRevision();
773
+ return this.renderedSourceRevision_ ? this.renderedSourceRevision_ !== n && (this.renderedSourceRevision_ = n, this.renderedSourceKey_ === t.getKey() && this.tileCache_.clear()) : this.renderedSourceRevision_ = n, !0;
774
+ }
775
+ /**
776
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
777
+ * @param {import("../../extent.js").Extent} extent The extent to be rendered.
778
+ * @param {number} initialZ The zoom level.
779
+ * @param {TileLookup} tilesByZ Lookup of tiles by zoom level.
780
+ * @param {number} preload Number of additional levels to load.
781
+ */
782
+ enqueueTiles(e, t, n, i, r) {
783
+ const a = e.viewState, s = this.getLayer(), l = s.getRenderSource(), c = l.getTileGridForProjection(a.projection), o = z(l);
784
+ o in e.wantedTiles || (e.wantedTiles[o] = {});
785
+ const u = e.wantedTiles[o], h = s.getMapInternal(), g = Math.max(
786
+ n - r,
787
+ c.getMinZoom(),
788
+ c.getZForResolution(
789
+ Math.min(
790
+ s.getMaxResolution(),
791
+ h ? h.getView().getResolutionForZoom(Math.max(s.getMinZoom(), 0)) : c.getResolution(0)
792
+ ),
793
+ l.zDirection
794
+ )
795
+ ), p = a.rotation, S = p ? He(
796
+ a.center,
797
+ a.resolution,
798
+ p,
799
+ e.size
800
+ ) : void 0;
801
+ for (let f = n; f >= g; --f) {
802
+ const C = c.getTileRangeForExtentAndZ(
803
+ t,
804
+ f,
805
+ this.tempTileRange_
806
+ ), P = c.getResolution(f);
807
+ for (let E = C.minX; E <= C.maxX; ++E)
808
+ for (let I = C.minY; I <= C.maxY; ++I) {
809
+ if (p && !c.tileCoordIntersectsViewport([f, E, I], S))
810
+ continue;
811
+ const L = this.getTile(f, E, I, e);
812
+ if (!L || !se(i, L, f))
813
+ continue;
814
+ const y = L.getKey();
815
+ if (u[y] = !0, L.getState() === T.IDLE && !e.tileQueue.isKeyQueued(y)) {
816
+ const Z = ye(f, E, I, this.tempTileCoord_);
817
+ e.tileQueue.enqueue([
818
+ L,
819
+ o,
820
+ c.getTileCoordCenter(Z),
821
+ P
822
+ ]);
823
+ }
824
+ }
825
+ }
826
+ }
827
+ /**
828
+ * Look for tiles covering the provided tile coordinate at an alternate
829
+ * zoom level. Loaded tiles will be added to the provided tile texture lookup.
830
+ * @param {import("../../tilecoord.js").TileCoord} tileCoord The target tile coordinate.
831
+ * @param {TileLookup} tilesByZ Lookup of tiles by zoom level.
832
+ * @return {boolean} The tile coordinate is covered by loaded tiles at the alternate zoom level.
833
+ * @private
834
+ */
835
+ findStaleTile_(e, t) {
836
+ const n = this.tileCache_, i = e[0], r = e[1], a = e[2], s = this.getStaleKeys();
837
+ for (let l = 0; l < s.length; ++l) {
838
+ const c = ie(
839
+ this.getLayer().getSource(),
840
+ s[l],
841
+ i,
842
+ r,
843
+ a
844
+ );
845
+ if (n.containsKey(c)) {
846
+ const o = n.peek(c);
847
+ if (o.getState() === T.LOADED)
848
+ return o.endTransition(z(this)), se(t, o, i), !0;
849
+ }
850
+ }
851
+ return !1;
852
+ }
853
+ /**
854
+ * Look for tiles covering the provided tile coordinate at an alternate
855
+ * zoom level. Loaded tiles will be added to the provided tile texture lookup.
856
+ * @param {import("../../tilegrid/TileGrid.js").default} tileGrid The tile grid.
857
+ * @param {import("../../tilecoord.js").TileCoord} tileCoord The target tile coordinate.
858
+ * @param {number} altZ The alternate zoom level.
859
+ * @param {TileLookup} tilesByZ Lookup of tiles by zoom level.
860
+ * @return {boolean} The tile coordinate is covered by loaded tiles at the alternate zoom level.
861
+ * @private
862
+ */
863
+ findAltTiles_(e, t, n, i) {
864
+ const r = e.getTileRangeForTileCoordAndZ(
865
+ t,
866
+ n,
867
+ this.tempTileRange_
868
+ );
869
+ if (!r)
870
+ return !1;
871
+ let a = !0;
872
+ const s = this.tileCache_, l = this.getLayer().getRenderSource(), c = l.getKey();
873
+ for (let o = r.minX; o <= r.maxX; ++o)
874
+ for (let u = r.minY; u <= r.maxY; ++u) {
875
+ const h = ie(l, c, n, o, u);
876
+ let g = !1;
877
+ if (s.containsKey(h)) {
878
+ const p = s.peek(h);
879
+ p.getState() === T.LOADED && (se(i, p, n), g = !0);
880
+ }
881
+ g || (a = !1);
882
+ }
883
+ return a;
884
+ }
885
+ /**
886
+ * Render the layer.
887
+ *
888
+ * The frame rendering logic has three parts:
889
+ *
890
+ * 1. Enqueue tiles
891
+ * 2. Find alt tiles for those that are not yet loaded
892
+ * 3. Render loaded tiles
893
+ *
894
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
895
+ * @param {HTMLElement} target Target that may be used to render content to.
896
+ * @return {HTMLElement} The rendered element.
897
+ * @override
898
+ */
899
+ renderFrame(e, t) {
900
+ this.renderComplete = !0;
901
+ const n = e.layerStatesArray[e.layerIndex], i = e.viewState, r = i.projection, a = i.resolution, s = i.center, l = e.pixelRatio, c = this.getLayer(), o = c.getSource(), u = o.getTileGridForProjection(r), h = u.getZForResolution(a, o.zDirection), g = u.getResolution(h), p = o.getKey();
902
+ this.renderedSourceKey_ ? this.renderedSourceKey_ !== p && (this.prependStaleKey(this.renderedSourceKey_), this.renderedSourceKey_ = p) : this.renderedSourceKey_ = p;
903
+ let S = e.extent;
904
+ const f = o.getTilePixelRatio(l);
905
+ this.prepareContainer(e, t);
906
+ const C = this.context.canvas.width, P = this.context.canvas.height, E = n.extent && re(n.extent);
907
+ E && (S = oe(
908
+ S,
909
+ re(n.extent)
910
+ ));
911
+ const I = g * C / 2 / f, L = g * P / 2 / f, b = [
912
+ s[0] - I,
913
+ s[1] - L,
914
+ s[0] + I,
915
+ s[1] + L
916
+ ], y = {};
917
+ this.renderedTiles.length = 0;
918
+ const Z = c.getPreload();
919
+ if (e.nextExtent) {
920
+ const x = u.getZForResolution(
921
+ i.nextResolution,
922
+ o.zDirection
923
+ ), R = me(e, e.nextExtent);
924
+ this.enqueueTiles(e, R, x, y, Z);
925
+ }
926
+ const ce = me(e, S);
927
+ if (this.enqueueTiles(e, ce, h, y, 0), Z > 0 && setTimeout(() => {
928
+ this.enqueueTiles(
929
+ e,
930
+ ce,
931
+ h - 1,
932
+ y,
933
+ Z - 1
934
+ );
935
+ }, 0), !(h in y))
936
+ return this.container;
937
+ const he = z(this), we = e.time;
938
+ for (const x of y[h]) {
939
+ const R = x.getState();
940
+ if (R === T.EMPTY)
941
+ continue;
942
+ const D = x.tileCoord;
943
+ if (R === T.LOADED && x.getAlpha(he, we) === 1) {
944
+ x.endTransition(he);
945
+ continue;
946
+ }
947
+ if (R !== T.ERROR && (this.renderComplete = !1), this.findStaleTile_(D, y)) {
948
+ ct(y, x, h), e.animate = !0;
949
+ continue;
950
+ }
951
+ if (this.findAltTiles_(
952
+ u,
953
+ D,
954
+ h + 1,
955
+ y
956
+ ))
957
+ continue;
958
+ const k = u.getMinZoom();
959
+ for (let M = h - 1; M >= k && !this.findAltTiles_(
960
+ u,
961
+ D,
962
+ M,
963
+ y
964
+ ); --M)
965
+ ;
966
+ }
967
+ const U = g / a * l / f, _ = this.getRenderContext(e);
968
+ ae(
969
+ this.tempTransform,
970
+ C / 2,
971
+ P / 2,
972
+ U,
973
+ U,
974
+ 0,
975
+ -C / 2,
976
+ -P / 2
977
+ ), n.extent && this.clipUnrotated(_, e, E), o.getInterpolate() || (_.imageSmoothingEnabled = !1), this.preRender(_, e);
978
+ const G = Object.keys(y).map(Number);
979
+ G.sort(Ve);
980
+ let w;
981
+ const $ = [], de = [];
982
+ for (let x = G.length - 1; x >= 0; --x) {
983
+ const R = G[x], D = o.getTilePixelSize(
984
+ R,
985
+ l,
986
+ r
987
+ ), A = u.getResolution(R) / g, k = D[0] * A * U, M = D[1] * A * U, B = u.getTileCoordForCoordAndZ(
988
+ Ce(b),
989
+ R
990
+ ), ue = u.getTileCoordExtent(B), q = v(this.tempTransform, [
991
+ f * (ue[0] - b[0]) / g,
992
+ f * (b[3] - ue[3]) / g
993
+ ]), ve = f * o.getGutterForProjection(r);
994
+ for (const N of y[R]) {
995
+ if (N.getState() !== T.LOADED)
996
+ continue;
997
+ const ge = N.tileCoord, fe = B[1] - ge[1], Se = Math.round(q[0] - (fe - 1) * k), _e = B[2] - ge[2], Ie = Math.round(q[1] - (_e - 1) * M), O = Math.round(q[0] - fe * k), K = Math.round(q[1] - _e * M), H = Se - O, V = Ie - K, pe = G.length === 1;
998
+ let J = !1;
999
+ w = [O, K, O + H, K, O + H, K + V, O, K + V];
1000
+ for (let W = 0, Le = $.length; W < Le; ++W)
1001
+ if (!pe && R < de[W]) {
1002
+ const m = $[W];
1003
+ We(
1004
+ [O, K, O + H, K + V],
1005
+ [m[0], m[3], m[4], m[7]]
1006
+ ) && (J || (_.save(), J = !0), _.beginPath(), _.moveTo(w[0], w[1]), _.lineTo(w[2], w[3]), _.lineTo(w[4], w[5]), _.lineTo(w[6], w[7]), _.moveTo(m[6], m[7]), _.lineTo(m[4], m[5]), _.lineTo(m[2], m[3]), _.lineTo(m[0], m[1]), _.clip());
1007
+ }
1008
+ $.push(w), de.push(R), this.drawTile(N, e, O, K, H, V, ve, pe), J && _.restore(), this.renderedTiles.unshift(N), this.updateUsedTiles(e.usedTiles, o, N);
1009
+ }
1010
+ }
1011
+ if (this.renderedResolution = g, this.extentChanged = !this.renderedExtent_ || !Xe(this.renderedExtent_, b), this.renderedExtent_ = b, this.renderedPixelRatio = l, this.postRender(this.context, e), n.extent && _.restore(), _.imageSmoothingEnabled = !0, this.renderComplete) {
1012
+ const x = (R, D) => {
1013
+ const Q = z(o), A = D.wantedTiles[Q], k = A ? Object.keys(A).length : 0;
1014
+ this.updateCacheSize(k), this.tileCache_.expireCache();
1015
+ };
1016
+ e.postRenderFunctions.push(x);
1017
+ }
1018
+ return this.container;
1019
+ }
1020
+ /**
1021
+ * Increases the cache size if needed
1022
+ * @param {number} tileCount Minimum number of tiles needed.
1023
+ */
1024
+ updateCacheSize(e) {
1025
+ this.tileCache_.highWaterMark = Math.max(
1026
+ this.tileCache_.highWaterMark,
1027
+ e * 2
1028
+ );
1029
+ }
1030
+ /**
1031
+ * @param {import("../../Tile.js").default} tile Tile.
1032
+ * @param {import("../../Map.js").FrameState} frameState Frame state.
1033
+ * @param {number} x Left of the tile.
1034
+ * @param {number} y Top of the tile.
1035
+ * @param {number} w Width of the tile.
1036
+ * @param {number} h Height of the tile.
1037
+ * @param {number} gutter Tile gutter.
1038
+ * @param {boolean} transition Apply an alpha transition.
1039
+ * @protected
1040
+ */
1041
+ drawTile(e, t, n, i, r, a, s, l) {
1042
+ let c;
1043
+ if (e instanceof Re) {
1044
+ if (c = le(e.getData()), !c)
1045
+ throw new Error("Rendering array data is not yet supported");
1046
+ } else
1047
+ c = this.getTileImage(
1048
+ /** @type {import("../../ImageTile.js").default} */
1049
+ e
1050
+ );
1051
+ if (!c)
1052
+ return;
1053
+ const o = this.getRenderContext(t), u = z(this), h = t.layerStatesArray[t.layerIndex], g = h.opacity * (l ? e.getAlpha(u, t.time) : 1), p = g !== o.globalAlpha;
1054
+ p && (o.save(), o.globalAlpha = g), o.drawImage(
1055
+ c,
1056
+ s,
1057
+ s,
1058
+ c.width - 2 * s,
1059
+ c.height - 2 * s,
1060
+ n,
1061
+ i,
1062
+ r,
1063
+ a
1064
+ ), p && o.restore(), g !== h.opacity ? t.animate = !0 : l && e.endTransition(u);
1065
+ }
1066
+ /**
1067
+ * @return {HTMLCanvasElement} Image
1068
+ */
1069
+ getImage() {
1070
+ const e = this.context;
1071
+ return e ? e.canvas : null;
1072
+ }
1073
+ /**
1074
+ * Get the image from a tile.
1075
+ * @param {import("../../ImageTile.js").default} tile Tile.
1076
+ * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
1077
+ * @protected
1078
+ */
1079
+ getTileImage(e) {
1080
+ return e.getImage();
1081
+ }
1082
+ /**
1083
+ * @param {!Object<string, !Object<string, boolean>>} usedTiles Used tiles.
1084
+ * @param {import("../../source/Tile.js").default} tileSource Tile source.
1085
+ * @param {import('../../Tile.js').default} tile Tile.
1086
+ * @protected
1087
+ */
1088
+ updateUsedTiles(e, t, n) {
1089
+ const i = z(t);
1090
+ i in e || (e[i] = {}), e[i][n.getKey()] = !0;
1091
+ }
1092
+ }
1093
+ const Y = {
1094
+ PRELOAD: "preload",
1095
+ USE_INTERIM_TILES_ON_ERROR: "useInterimTilesOnError"
1096
+ };
1097
+ class dt extends et {
1098
+ /**
1099
+ * @param {Options<TileSourceType>} [options] Tile layer options.
1100
+ */
1101
+ constructor(e) {
1102
+ e = e || {};
1103
+ const t = Object.assign({}, e), n = e.cacheSize;
1104
+ delete e.cacheSize, delete t.preload, delete t.useInterimTilesOnError, super(t), this.on, this.once, this.un, this.cacheSize_ = n, this.setPreload(e.preload !== void 0 ? e.preload : 0), this.setUseInterimTilesOnError(
1105
+ e.useInterimTilesOnError !== void 0 ? e.useInterimTilesOnError : !0
1106
+ );
1107
+ }
1108
+ /**
1109
+ * @return {number|undefined} The suggested cache size
1110
+ * @protected
1111
+ */
1112
+ getCacheSize() {
1113
+ return this.cacheSize_;
1114
+ }
1115
+ /**
1116
+ * Return the level as number to which we will preload tiles up to.
1117
+ * @return {number} The level to preload tiles up to.
1118
+ * @observable
1119
+ * @api
1120
+ */
1121
+ getPreload() {
1122
+ return (
1123
+ /** @type {number} */
1124
+ this.get(Y.PRELOAD)
1125
+ );
1126
+ }
1127
+ /**
1128
+ * Set the level as number to which we will preload tiles up to.
1129
+ * @param {number} preload The level to preload tiles up to.
1130
+ * @observable
1131
+ * @api
1132
+ */
1133
+ setPreload(e) {
1134
+ this.set(Y.PRELOAD, e);
1135
+ }
1136
+ /**
1137
+ * Deprecated. Whether we use interim tiles on error.
1138
+ * @return {boolean} Use interim tiles on error.
1139
+ * @observable
1140
+ * @api
1141
+ */
1142
+ getUseInterimTilesOnError() {
1143
+ return (
1144
+ /** @type {boolean} */
1145
+ this.get(Y.USE_INTERIM_TILES_ON_ERROR)
1146
+ );
1147
+ }
1148
+ /**
1149
+ * Deprecated. Set whether we use interim tiles on error.
1150
+ * @param {boolean} useInterimTilesOnError Use interim tiles on error.
1151
+ * @observable
1152
+ * @api
1153
+ */
1154
+ setUseInterimTilesOnError(e) {
1155
+ this.set(Y.USE_INTERIM_TILES_ON_ERROR, e);
1156
+ }
1157
+ /**
1158
+ * Get data for a pixel location. The return type depends on the source data. For image tiles,
1159
+ * a four element RGBA array will be returned. For data tiles, the array length will match the
1160
+ * number of bands in the dataset. For requests outside the layer extent, `null` will be returned.
1161
+ * Data for a image tiles can only be retrieved if the source's `crossOrigin` property is set.
1162
+ *
1163
+ * ```js
1164
+ * // display layer data on every pointer move
1165
+ * map.on('pointermove', (event) => {
1166
+ * console.log(layer.getData(event.pixel));
1167
+ * });
1168
+ * ```
1169
+ * @param {import("../pixel").Pixel} pixel Pixel.
1170
+ * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
1171
+ * @api
1172
+ * @override
1173
+ */
1174
+ getData(e) {
1175
+ return super.getData(e);
1176
+ }
1177
+ }
1178
+ class ut extends dt {
1179
+ /**
1180
+ * @param {import("./BaseTile.js").Options<TileSourceType>} [options] Tile layer options.
1181
+ */
1182
+ constructor(e) {
1183
+ super(e);
1184
+ }
1185
+ /**
1186
+ * @override
1187
+ */
1188
+ createRenderer() {
1189
+ return new ht(this, {
1190
+ cacheSize: this.getCacheSize()
1191
+ });
1192
+ }
1193
+ }
1194
+ const xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1195
+ __proto__: null,
1196
+ default: ut
1197
+ }, Symbol.toStringTag, { value: "Module" }));
1198
+ export {
1199
+ lt as C,
1200
+ ut as T,
1201
+ st as Z,
1202
+ ht as a,
1203
+ Y as b,
1204
+ Tt as c,
1205
+ xt as d
1206
+ };