@arcgis/lumina 4.31.0-next.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,805 @@
1
+ import {
2
+ defaultEventBubbles,
3
+ defaultEventCancelable,
4
+ defaultEventComposed,
5
+ lazyMetaGroupJoiner,
6
+ lazyMetaItemJoiner,
7
+ lazyMetaSubItemJoiner
8
+ } from "./chunk-CH52Q2MB.js";
9
+
10
+ // src/createEvent.ts
11
+ import { retrieveComponent, trackPropertyKey } from "@arcgis/components-controllers";
12
+ var createEventFactory = (eventName = "", options = {}, component = retrieveComponent()) => {
13
+ const emitter = {
14
+ emit: (payload) => {
15
+ if (process.env.NODE_ENV !== "production") {
16
+ if (eventName === "") {
17
+ throw new Error("Unable to resolve event name from property name");
18
+ }
19
+ if (!component.el.isConnected) {
20
+ console.warn(
21
+ `Trying to emit an ${eventName} event on a disconnected element ${component.el.tagName.toLowerCase()}`
22
+ );
23
+ }
24
+ }
25
+ const event = new CustomEvent(eventName, {
26
+ detail: payload,
27
+ cancelable: defaultEventCancelable,
28
+ bubbles: defaultEventBubbles,
29
+ composed: defaultEventComposed,
30
+ ...options
31
+ });
32
+ component.el.dispatchEvent(event);
33
+ return event;
34
+ }
35
+ };
36
+ if (eventName === "") {
37
+ trackPropertyKey(
38
+ component,
39
+ (key) => {
40
+ if (process.env.NODE_ENV !== "production" && key === void 0) {
41
+ throw new Error(`createEvent must be called in property default value only`);
42
+ }
43
+ eventName = key;
44
+ },
45
+ emitter
46
+ );
47
+ }
48
+ return emitter;
49
+ };
50
+ var createEvent = createEventFactory.bind(null, "");
51
+
52
+ // src/decorators.ts
53
+ import { state } from "@lit/reactive-element/decorators/state.js";
54
+ import { property as litProperty } from "@lit/reactive-element/decorators/property.js";
55
+ var property = litProperty;
56
+ var method = void 0;
57
+
58
+ // src/lazyLoad.ts
59
+ import { Deferred, camelToKebab } from "@arcgis/components-utils";
60
+
61
+ // src/devOnlyDetectIncorrectLazyUsages.ts
62
+ function devOnlyDetectIncorrectLazyUsages(LitClass) {
63
+ const genericPrototype = LitClass.prototype;
64
+ const allowList = /* @__PURE__ */ new Set([
65
+ // We shouldn't be overwriting this property
66
+ "constructor",
67
+ // Called by Lit - we proxy it to this.el in ProxyComponent
68
+ "setAttribute"
69
+ ]);
70
+ const customErrorMessages = {
71
+ addEventListener: "use this.listen() or this.el.addEventListener()"
72
+ };
73
+ Object.entries({
74
+ ...Object.getOwnPropertyDescriptors(HTMLElement.prototype),
75
+ ...Object.getOwnPropertyDescriptors(Element.prototype),
76
+ ...Object.getOwnPropertyDescriptors(Node.prototype),
77
+ ...Object.getOwnPropertyDescriptors(EventTarget.prototype)
78
+ }).filter(([key, { value }]) => typeof value === "function" && !allowList.has(key)).forEach(([key]) => {
79
+ genericPrototype[key] = (...args) => {
80
+ if (key === "hasAttribute" && args[0] === "defer-hydration") {
81
+ return false;
82
+ }
83
+ throw new Error(
84
+ `You should not be calling this.${key}() directly as it won't work correctly in lazy-builds. Instead, ${customErrorMessages[key] ?? `use this.el.${key}()`}`
85
+ );
86
+ };
87
+ });
88
+ }
89
+
90
+ // src/lifecycleSupport.ts
91
+ function attachToAncestor(child, el) {
92
+ let ancestor = el;
93
+ while (ancestor = ancestor.parentNode ?? ancestor.host) {
94
+ if (ancestor?.constructor?.lumina) {
95
+ const litParent = ancestor;
96
+ if (!litParent.manager?.loadedCalled) {
97
+ litParent._offspring.push(child);
98
+ }
99
+ return litParent._postLoad?.promise;
100
+ }
101
+ }
102
+ return false;
103
+ }
104
+
105
+ // src/utils.ts
106
+ var noShadowRoot = {};
107
+
108
+ // src/lazyLoad.ts
109
+ var makeDefineCustomElements = (runtime, structure) => function defineCustomElements(windowOrOptions, options) {
110
+ if (!globalThis.customElements) {
111
+ return;
112
+ }
113
+ const resolvedOptions = options ?? windowOrOptions ?? {};
114
+ const resourcesUrl = resolvedOptions.resourcesUrl;
115
+ if (resourcesUrl) {
116
+ runtime.setAssetPath(resourcesUrl);
117
+ }
118
+ Object.entries(structure).forEach(createLazyElement);
119
+ };
120
+ function createLazyElement([tagName, [load, compactMeta = ""]]) {
121
+ if (customElements.get(tagName)) {
122
+ return;
123
+ }
124
+ const [compactObservedProps, compactAsyncMethods, compactSyncMethods] = compactMeta.split(lazyMetaGroupJoiner);
125
+ const observedProps = compactObservedProps ? compactObservedProps?.split(lazyMetaItemJoiner).map(parseCondensedProp) : void 0;
126
+ const observedProperties = observedProps?.map(([property2]) => property2);
127
+ const ProxyClass = class extends ProxyComponent {
128
+ static {
129
+ this.observedAttributes = observedProps?.map(([, attribute]) => attribute).filter((attribute) => attribute !== "");
130
+ }
131
+ static {
132
+ this._properties = observedProperties;
133
+ }
134
+ static {
135
+ this._asyncMethods = compactAsyncMethods ? compactAsyncMethods?.split(lazyMetaItemJoiner) : void 0;
136
+ }
137
+ static {
138
+ this._syncMethods = compactSyncMethods?.split(lazyMetaItemJoiner);
139
+ }
140
+ static {
141
+ this._name = tagName;
142
+ }
143
+ constructor() {
144
+ const isFirstInstanceOfType = !ProxyClass._loadPromise;
145
+ if (isFirstInstanceOfType) {
146
+ ProxyClass._loadPromise = load();
147
+ ProxyClass._initializePrototype();
148
+ }
149
+ super();
150
+ }
151
+ };
152
+ customElements.define(tagName, ProxyClass);
153
+ }
154
+ function parseCondensedProp(propAndAttribute) {
155
+ const name = propAndAttribute.split(lazyMetaSubItemJoiner);
156
+ return name.length === 1 ? [name[0], camelToKebab(name[0])] : name;
157
+ }
158
+ var HtmlElement = globalThis.HTMLElement ?? parseCondensedProp;
159
+ var ProxyComponent = class extends HtmlElement {
160
+ constructor() {
161
+ super();
162
+ /**
163
+ * On HMR, preserve the values of all properties that at least once were set
164
+ * by someone other than component itself.
165
+ *
166
+ * @internal
167
+ */
168
+ this._hmrSetProps = /* @__PURE__ */ new Set();
169
+ /** @internal */
170
+ this._hmrSetAttributes = /* @__PURE__ */ new Set();
171
+ /** @internal */
172
+ this._store = {};
173
+ /**
174
+ * If attributeChangedCallback() is called before the LitElement is loaded,
175
+ * store the attributes here, and replay later
176
+ */
177
+ this._pendingAttributes = [];
178
+ /**
179
+ * Resolved once LitElement's load() is complete.
180
+ * Not read inside of this class, but needed for LitElement to determine if
181
+ * it's closest ancestor finished load()
182
+ */
183
+ this._postLoad = new Deferred();
184
+ /**
185
+ * Resolved once LitElement's loaded() is complete
186
+ */
187
+ this._postLoaded = new Deferred();
188
+ /**
189
+ * Direct offspring that should be awaited before loaded() is emitted
190
+ */
191
+ this._offspring = [];
192
+ this._saveInstanceProperties();
193
+ const ProxyClass = this.constructor;
194
+ if (ProxyClass._LitConstructor) {
195
+ this._initializeComponent({ a: ProxyClass._LitConstructor });
196
+ } else {
197
+ void ProxyClass._loadPromise.then(this._initializeComponent.bind(this)).catch(this._postLoaded.reject);
198
+ }
199
+ if (process.env.NODE_ENV !== "production") {
200
+ ProxyClass._hmrInstances ??= [];
201
+ ProxyClass._hmrInstances.push(new WeakRef(this));
202
+ }
203
+ }
204
+ static {
205
+ this.lumina = true;
206
+ }
207
+ /** @internal */
208
+ static _initializePrototype() {
209
+ this._properties?.forEach(this._bindProp, this);
210
+ this._asyncMethods?.forEach(this._bindAsync, this);
211
+ this._syncMethods?.forEach(this._bindSync, this);
212
+ }
213
+ static _bindProp(propName) {
214
+ Object.defineProperty(this.prototype, propName, {
215
+ configurable: true,
216
+ enumerable: true,
217
+ get() {
218
+ return this._store[propName];
219
+ },
220
+ set(value) {
221
+ this._store[propName] = value;
222
+ if (process.env.NODE_ENV !== "production") {
223
+ this._hmrSetProps.add(propName);
224
+ }
225
+ }
226
+ });
227
+ }
228
+ static _bindAsync(methodName) {
229
+ Object.defineProperty(this.prototype, methodName, {
230
+ async value(...args) {
231
+ if (!this._litElement) {
232
+ await this._postLoaded.promise;
233
+ }
234
+ const genericLitElement = this._litElement;
235
+ return await genericLitElement[methodName](...args);
236
+ },
237
+ configurable: true,
238
+ writable: true,
239
+ enumerable: true
240
+ });
241
+ }
242
+ static _bindSync(methodName) {
243
+ Object.defineProperty(this.prototype, methodName, {
244
+ value(...args) {
245
+ if (process.env.NODE_ENV === "development" && !this._litElement) {
246
+ const ProxyClass = this.constructor;
247
+ throw new Error(
248
+ `Tried to call method ${methodName}() on <${ProxyClass._name}> component before it's fully loaded. Please do 'await component.componentOnReady();' before calling this method.`
249
+ );
250
+ }
251
+ const genericLitElement = this._litElement;
252
+ return genericLitElement[methodName](...args);
253
+ },
254
+ configurable: true,
255
+ enumerable: true
256
+ });
257
+ }
258
+ get manager() {
259
+ return this._litElement?.manager;
260
+ }
261
+ /**
262
+ * Until the custom element is registered on the page, an instance of that
263
+ * element can be constructed and some properties on that instance set.
264
+ *
265
+ * These properties are set before the element prototype is set to this proxy
266
+ * class and thus none of our getters/setters are yet registered - such
267
+ * properties will be set by JavaScript on the instance directly.
268
+ *
269
+ * Once element is registered, the properties set in the meanwhile will shadow
270
+ * the getter/setters, and thus break reactivity. The fix is to delete these
271
+ * properties from the instance, and re-apply them once accessors are set.
272
+ *
273
+ * @example
274
+ * ```ts
275
+ * import { defineCustomElements } from '@arcgis/map-components';
276
+ * const map = document.createElement('arcgis-map');
277
+ * // This will shadow the getter/setters
278
+ * map.itemId = '...';
279
+ * // This finally defines the custom elements and sets the property accessors
280
+ * defineCustomElements();
281
+ * ```
282
+ *
283
+ * @remarks
284
+ * This is an equivalent of the __saveInstanceProperties method in Lit's
285
+ * ReactiveElement. Lit takes care of this on LitElement, but we have to take
286
+ * care of this on the lazy proxy
287
+ */
288
+ _saveInstanceProperties() {
289
+ const ProxyClass = this.constructor;
290
+ const genericThis = this;
291
+ ProxyClass._properties?.forEach((propName) => {
292
+ if (Object.hasOwn(this, propName)) {
293
+ this._store[propName] = genericThis[propName];
294
+ delete genericThis[propName];
295
+ }
296
+ });
297
+ }
298
+ /*
299
+ * This method must be statically present rather than added later, or else,
300
+ * browsers won't call it. Same for connected and disconnected callbacks.
301
+ */
302
+ attributeChangedCallback(name, oldValue, newValue) {
303
+ this._litElement?.attributeChangedCallback(name, oldValue, newValue);
304
+ if (!this._litElement) {
305
+ this._pendingAttributes.push(name);
306
+ }
307
+ if (process.env.NODE_ENV !== "production") {
308
+ this._hmrSetAttributes.add(name);
309
+ }
310
+ }
311
+ connectedCallback() {
312
+ if (this._litElement) {
313
+ this._litElement?.connectedCallback();
314
+ } else {
315
+ queueMicrotask(() => {
316
+ this._ancestorLoad = attachToAncestor(this, this);
317
+ });
318
+ }
319
+ }
320
+ disconnectedCallback() {
321
+ this._litElement?.disconnectedCallback();
322
+ }
323
+ /**
324
+ * Create a promise that resolves once component is fully loaded
325
+ */
326
+ async componentOnReady() {
327
+ await this._postLoaded.promise;
328
+ return this._litElement;
329
+ }
330
+ /** @internal */
331
+ _initializeComponent(module) {
332
+ const ProxyClass = this.constructor;
333
+ const tagName = ProxyClass._name;
334
+ if (process.env.NODE_ENV !== "production") {
335
+ Object.entries(module).forEach(([name, LitConstructor2]) => {
336
+ if (name !== "exportsForTests" && typeof LitConstructor2 !== "function" || typeof LitConstructor2.tagName !== "string") {
337
+ console.warn(
338
+ `Found non-component export "${name}" in the file for the "${tagName}" component. This will interfere with hot module replacement. Please move "${name}" into a separate file.`
339
+ );
340
+ }
341
+ });
342
+ }
343
+ const LitConstructor = Object.values(module).find(
344
+ (LitConstructor2) => LitConstructor2.tagName === tagName
345
+ );
346
+ if (process.env.NODE_ENV !== "production" && !LitConstructor) {
347
+ throw new Error(
348
+ `Unable to find the LitElement class for the "${tagName}" custom element in the lazy-loaded module`
349
+ );
350
+ }
351
+ const lazyTagName = process.env.NODE_ENV === "production" ? `${tagName}--lazy` : (ProxyClass._hmrIndex ?? 0) === 0 ? `${tagName}--lazy` : `${tagName}--lazy-${ProxyClass._hmrIndex}`;
352
+ const isFirstInitialization = !ProxyClass._LitConstructor;
353
+ if (isFirstInitialization) {
354
+ ProxyClass._LitConstructor = LitConstructor;
355
+ LitConstructor.prototype.removeAttribute = removeAttribute;
356
+ LitConstructor.prototype.setAttribute = setAttribute;
357
+ if (process.env.NODE_ENV !== "production" && LitConstructor.shadowRootOptions !== noShadowRoot) {
358
+ devOnlyDetectIncorrectLazyUsages(Object.getPrototypeOf(LitConstructor));
359
+ }
360
+ customElements.define(lazyTagName, LitConstructor);
361
+ }
362
+ LitConstructor.lazy = this;
363
+ const litElement = document.createElement(lazyTagName);
364
+ LitConstructor.lazy = void 0;
365
+ this._litElement = litElement;
366
+ this._pendingAttributes.forEach((name) => {
367
+ const value = this.getAttribute(name);
368
+ litElement.attributeChangedCallback(
369
+ name,
370
+ // Lit doesn't look at this value, thus even if attribute already exists, that's ok
371
+ null,
372
+ value
373
+ );
374
+ });
375
+ Object.entries(this._store).forEach(syncLitElement, litElement);
376
+ this._store = litElement;
377
+ if (process.env.NODE_ENV !== "production") {
378
+ const litObserved = LitConstructor.observedAttributes ?? [];
379
+ const lazyObserved = ProxyClass.observedAttributes ?? [];
380
+ const missingFromLazy = litObserved.filter((attribute) => !lazyObserved.includes(attribute));
381
+ const missingFromLit = lazyObserved.filter((attribute) => !litObserved.includes(attribute));
382
+ if (missingFromLazy.length > 0) {
383
+ console.warn(
384
+ `The following attributes on <${ProxyClass._name}> are present on the Lit element, but are missing from the lazy proxy component: ${missingFromLazy.join(", ")}. This either indicates a bug in Lumina, or you are creating the attribute dynamically in a way that compiler can not infer statically. For these attributes, lazy-loading version of your component won't work correctly, thus this must be resolved`
385
+ );
386
+ }
387
+ if (missingFromLit.length > 0) {
388
+ console.warn(
389
+ `The following attributes on <${ProxyClass._name}> are defined on the lazy proxy component, but not on the actual Lit element: ${missingFromLit.join(", ")}. This either indicates a bug in Lumina, or you are creating the attribute dynamically in a way that compiler can not infer statically. This is a non-critical issue, but does indicate that something is going wrong and should be fixed`
390
+ );
391
+ }
392
+ }
393
+ if (this.isConnected) {
394
+ litElement.connectedCallback();
395
+ }
396
+ }
397
+ };
398
+ function removeAttribute(qualifiedName) {
399
+ HTMLElement.prototype.removeAttribute.call(this.el, qualifiedName);
400
+ }
401
+ function setAttribute(qualifiedName, value) {
402
+ HTMLElement.prototype.setAttribute.call(this.el, qualifiedName, value);
403
+ }
404
+ function syncLitElement([key, value]) {
405
+ this[key] = value;
406
+ }
407
+
408
+ // src/hmrSupport.ts
409
+ import { camelToKebab as camelToKebab2 } from "@arcgis/components-utils";
410
+ function handleHmrUpdate(newModules) {
411
+ newModules.forEach((newModule) => {
412
+ if (newModule === void 0) {
413
+ return;
414
+ }
415
+ Object.values(newModule).forEach((exported) => {
416
+ if (typeof exported !== "function" || typeof exported.tagName !== "string") {
417
+ return;
418
+ }
419
+ const LitConstructor = exported;
420
+ const ProxyClass = customElements.get(LitConstructor.tagName);
421
+ if (ProxyClass === void 0) {
422
+ throw new Error(`Failed to find custom element proxy for tag name: ${LitConstructor.tagName}`);
423
+ }
424
+ ProxyClass._LitConstructor = void 0;
425
+ ProxyClass._loadPromise = void 0;
426
+ ProxyClass._hmrIndex ??= 0;
427
+ ProxyClass._hmrIndex += 1;
428
+ ProxyClass._initializePrototype();
429
+ ProxyClass._hmrInstances?.forEach((instanceWeakRef) => {
430
+ const instance = instanceWeakRef.deref();
431
+ if (instance === void 0) {
432
+ return;
433
+ }
434
+ if (instance._litElement === void 0) {
435
+ void ProxyClass._loadPromise.then(() => reInitialize(instance, newModule));
436
+ } else {
437
+ reInitialize(instance, newModule);
438
+ }
439
+ });
440
+ return;
441
+ });
442
+ });
443
+ }
444
+ function reInitialize(instance, newModule) {
445
+ const PreviousLitConstructor = instance._litElement.constructor;
446
+ const properties = PreviousLitConstructor.elementProperties;
447
+ const preservedProperties = Array.from(properties.entries()).filter(
448
+ ([propertyName, descriptor]) => typeof propertyName === "string" && (instance._hmrSetProps.has(propertyName) || typeof descriptor.attribute === "string" && instance._hmrSetAttributes.has(descriptor.attribute))
449
+ ).map(([key]) => [key, instance[key]]);
450
+ instance._store = Object.fromEntries(preservedProperties);
451
+ const isConnected = instance.isConnected;
452
+ if (isConnected) {
453
+ instance._litElement.disconnectedCallback();
454
+ }
455
+ instance._initializeComponent(newModule);
456
+ }
457
+ function handleComponentMetaUpdate(meta) {
458
+ const ProxyClass = customElements.get(meta.tagName);
459
+ if (ProxyClass === void 0) {
460
+ return;
461
+ }
462
+ const attributes = meta.properties.map(([property2, attribute]) => attribute ?? camelToKebab2(property2)).filter(Boolean);
463
+ observedAttributes[meta.tagName] ??= {};
464
+ observedAttributes[meta.tagName].original ??= new Set(ProxyClass.observedAttributes);
465
+ const originallyObserved = observedAttributes[meta.tagName].original;
466
+ observedAttributes[meta.tagName].manuallyObserved ??= new Set(
467
+ /**
468
+ * Never manually observe attributes that were in the original
469
+ * observedAttributes as those would be observed by the browser
470
+ */
471
+ attributes.filter((attribute) => !originallyObserved.has(attribute))
472
+ );
473
+ ProxyClass._asyncMethods = meta.asyncMethods;
474
+ ProxyClass._syncMethods = meta.syncMethods;
475
+ ProxyClass._properties = meta.properties.map(([name]) => name);
476
+ ProxyClass.observedAttributes = attributes;
477
+ }
478
+ var observedAttributesSymbol = Symbol.for("@arcgis/lumina:observedAttributes");
479
+ var globalThisWithObservedAttributes = globalThis;
480
+ var alreadyHadObservers = observedAttributesSymbol in globalThisWithObservedAttributes;
481
+ globalThisWithObservedAttributes[observedAttributesSymbol] ??= {};
482
+ var observedAttributes = globalThisWithObservedAttributes[observedAttributesSymbol];
483
+ if (!alreadyHadObservers) {
484
+ const makeObserver = (original) => function observeAttributes(qualifiedName, ...rest) {
485
+ const observed = observedAttributes[this.tagName.toLowerCase()]?.manuallyObserved;
486
+ if (observed?.has(qualifiedName)) {
487
+ const oldValue = this.getAttribute(qualifiedName);
488
+ const returns = original.call(this, qualifiedName, ...rest);
489
+ const newValue = this.getAttribute(qualifiedName);
490
+ this.attributeChangedCallback(qualifiedName, oldValue, newValue);
491
+ return returns;
492
+ } else {
493
+ return original.call(this, qualifiedName, ...rest);
494
+ }
495
+ };
496
+ ProxyComponent.prototype.setAttribute = makeObserver(ProxyComponent.prototype.setAttribute);
497
+ ProxyComponent.prototype.toggleAttribute = makeObserver(ProxyComponent.prototype.toggleAttribute);
498
+ ProxyComponent.prototype.removeAttribute = makeObserver(ProxyComponent.prototype.removeAttribute);
499
+ }
500
+
501
+ // src/LitElement.ts
502
+ import { Deferred as Deferred2, camelToKebab as camelToKebab3 } from "@arcgis/components-utils";
503
+ import { LitElement as OriginalLitElement, isServer } from "lit";
504
+ import { useControllerManager } from "@arcgis/components-controllers";
505
+ var emptyFunction = () => void 0;
506
+ var LitElement = class _LitElement extends OriginalLitElement {
507
+ constructor() {
508
+ super();
509
+ /**
510
+ * In lazy build, the actual DOM element differs from the class instance:
511
+ * - "this.el" is a proxy custom element - it's physically present in the DOM
512
+ * even before the Lit component is loaded.
513
+ * - "this" is the actual Lit component - in case of Lazy builds, it's
514
+ * never directly attached to the DOM. Instead, all interactions with the
515
+ * proxy are forwarded to the actual Lit component. And, when Lit wants to
516
+ * render, it renders into the shadow root of the proxy.
517
+ *
518
+ * "this.el" should be used instead of "this" for all things involving the
519
+ * DOM (addEventListener, querySelector, children, setAttribute,
520
+ * MutationObserver, etc...)
521
+ *
522
+ * @example
523
+ * ```ts
524
+ * // Generally, you shouldn't have to write logic specific to lazy or non-lazy
525
+ * // build, but if you have to, you can detect if you are in a lazy build like so:
526
+ * const isLazy = this.el !== this;
527
+ * ```
528
+ */
529
+ this.el = this.constructor.lazy ?? this;
530
+ /**
531
+ * Controller Manager orchestrates all components used by this component,
532
+ * connecting their lifecycle hooks and providing context information.
533
+ */
534
+ this.manager = useControllerManager(this);
535
+ /** @internal */
536
+ this._postLoad = this.constructor.lazy?._postLoad ?? new Deferred2();
537
+ /**
538
+ * Direct offspring that should be awaited before loaded() is emitted.
539
+ *
540
+ * `attachToAncestor()` will add elements to this array
541
+ *
542
+ * @internal
543
+ */
544
+ this._offspring = this.constructor.lazy?._offspring ?? [];
545
+ /**
546
+ * Promise that resolves once parent's load() completed. False if there is no
547
+ * parent
548
+ *
549
+ * @internal
550
+ */
551
+ this._ancestorLoad = this.constructor.lazy?._ancestorLoad;
552
+ this._postLoaded = this.constructor.lazy?._postLoaded ?? new Deferred2();
553
+ this._enableUpdating = this.enableUpdating;
554
+ this.enableUpdating = emptyFunction;
555
+ const ourShouldUpdate = _LitElement.prototype.shouldUpdate;
556
+ if (this.shouldUpdate !== ourShouldUpdate) {
557
+ this._originalShouldUpdate = this.shouldUpdate;
558
+ this.shouldUpdate = ourShouldUpdate;
559
+ }
560
+ if (process.env.NODE_ENV !== "production") {
561
+ globalThis.devOnly$luminaComponentRefCallback?.(this);
562
+ }
563
+ if (isServer) {
564
+ this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
565
+ }
566
+ }
567
+ static finalizeStyles(styles) {
568
+ if (process.env.NODE_ENV === "test" && Array.isArray(styles)) {
569
+ styles = styles.filter(Boolean);
570
+ }
571
+ const finalizedStyles = super.finalizeStyles(styles);
572
+ const options = this.constructor.shadowRootOptions;
573
+ const useLightDom = options === noShadowRoot;
574
+ return this.runtime?.commonStyles === void 0 || useLightDom ? finalizedStyles : [this.runtime.commonStyles, ...finalizedStyles];
575
+ }
576
+ static createProperty(name, options) {
577
+ const flags = typeof options === "number" ? options : Array.isArray(options) ? options[0] : 0;
578
+ const rest = Array.isArray(options) ? options[1] : void 0;
579
+ super.createProperty(name, {
580
+ /**
581
+ * By default to infer attribute name from property name, Lit just
582
+ * converts property name to lowercase. That is consistent with
583
+ * native DOM attributes.
584
+ *
585
+ * However, that is not consistent with Stencil and would be a
586
+ * breaking change for us. Also, kebab-case is more common among the
587
+ * web components. But the most important reason is that we have
588
+ * some pretty long attribute names, which would be utterly
589
+ * unreadable in lowercase.
590
+ *
591
+ * Also, if browsers add new attributes, that may cause a conflict
592
+ * with our attributes.
593
+ *
594
+ * Thus, overwriting Lit's default behavior to use kebab-case:
595
+ */
596
+ attribute: !!(flags & 1 /* ATTRIBUTE */) && typeof name === "string" ? camelToKebab3(name) : false,
597
+ reflect: !!(flags & 2 /* REFLECT */),
598
+ type: flags & 4 /* BOOLEAN */ ? Boolean : flags & 8 /* NUMBER */ ? Number : void 0,
599
+ /**
600
+ * At the moment in Lit, state:true just means attribute:false, so this
601
+ * line is technically redundant, but let's keep it here just in case Lit
602
+ * will add more meaning to state:true in the future.
603
+ */
604
+ state: !!(flags & 16 /* STATE */),
605
+ // Controllers add this option to Lit
606
+ readOnly: !!(flags & 32 /* READ_ONLY */),
607
+ noAccessor: !!(flags & 64 /* NO_ACCESSOR */),
608
+ ...rest
609
+ });
610
+ }
611
+ static {
612
+ this.lumina = true;
613
+ }
614
+ connectedCallback() {
615
+ if (this.el.hasAttribute("defer-hydration")) {
616
+ return;
617
+ }
618
+ const isFirstCall = !this.manager.connectedCalled;
619
+ super.connectedCallback();
620
+ if (isFirstCall) {
621
+ queueMicrotask(() => void this._load().catch(this._postLoaded.reject));
622
+ }
623
+ }
624
+ /**
625
+ * Overwrite Lit's default behavior of attaching shadow root to the lit
626
+ * element, and instead use this.el to support lazy builds.
627
+ *
628
+ * Also, support the case when component asked to not use shadow root
629
+ */
630
+ createRenderRoot() {
631
+ const existingShadowRoot = this.el.shadowRoot;
632
+ const Class = this.constructor;
633
+ const options = Class.shadowRootOptions;
634
+ const useLightDom = options === noShadowRoot;
635
+ const renderRoot = existingShadowRoot ?? (useLightDom ? this.el : this.el.attachShadow(options));
636
+ Object.defineProperty(this, "shadowRoot", {
637
+ // Create shadow root on the proxy instance, to make Lit render content there
638
+ value: renderRoot
639
+ });
640
+ if (existingShadowRoot) {
641
+ if (process.env.NODE_ENV === "production") {
642
+ OriginalLitElement.prototype.createRenderRoot.call(this);
643
+ }
644
+ return existingShadowRoot;
645
+ }
646
+ const domRoot = renderRoot.getRootNode();
647
+ domRoot.adoptedStyleSheets = [
648
+ ...domRoot.adoptedStyleSheets,
649
+ ...Class.elementStyles.map((stylesheet) => "styleSheet" in stylesheet ? stylesheet.styleSheet : stylesheet)
650
+ ];
651
+ return renderRoot;
652
+ }
653
+ /** Do asynchronous component load */
654
+ async _load() {
655
+ const parentLoadPromise = this._ancestorLoad ?? attachToAncestor(this, this);
656
+ if (parentLoadPromise) {
657
+ await parentLoadPromise;
658
+ }
659
+ await this.manager._load();
660
+ this._enableUpdating(true);
661
+ this.performUpdate();
662
+ this._postLoad.resolve();
663
+ await Promise.resolve();
664
+ const pendingChildren = this._offspring.filter((loaded) => !loaded.manager?.loadedCalled);
665
+ if (pendingChildren.length) {
666
+ await Promise.allSettled(pendingChildren.map(async (child) => await child.componentOnReady()));
667
+ }
668
+ this._offspring.length = 0;
669
+ this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
670
+ this.manager._loaded();
671
+ this._postLoaded.resolve();
672
+ }
673
+ /**
674
+ * Overwriting default shouldUpdate simply to get access to
675
+ * "changedProperties" so that we can later provide it to ControllerManager
676
+ */
677
+ shouldUpdate(_changedProperties) {
678
+ this.$changes = _changedProperties;
679
+ return this._originalShouldUpdate?.(_changedProperties) ?? true;
680
+ }
681
+ listen(name, listener, options) {
682
+ const boundListener = listener?.bind(this) ?? listener;
683
+ this.manager.onLifecycle(() => {
684
+ this.el.addEventListener(name, boundListener, options);
685
+ return () => this.el.removeEventListener(name, boundListener, options);
686
+ });
687
+ }
688
+ listenOn(target, name, listener, options) {
689
+ const boundListener = listener?.bind(this) ?? listener;
690
+ this.manager.onLifecycle(() => {
691
+ target.addEventListener(name, boundListener, options);
692
+ return () => target.removeEventListener(name, boundListener, options);
693
+ });
694
+ }
695
+ /**
696
+ * Create a promise that resolves once component is fully loaded.
697
+ *
698
+ * @example
699
+ * const map = document.createElement('arcgis-map');
700
+ * document.body.append(map);
701
+ * map.componentOnReady().then(() => {
702
+ * console.log('Map is ready to go!');
703
+ * });
704
+ */
705
+ async componentOnReady() {
706
+ await this._postLoaded.promise;
707
+ return this;
708
+ }
709
+ };
710
+ LitElement.$createEvent = createEventFactory;
711
+ if (process.env.NODE_ENV !== "production") {
712
+ const globalWithLit = globalThis;
713
+ globalWithLit.litIssuedWarnings ??= /* @__PURE__ */ new Set();
714
+ globalWithLit.litIssuedWarnings.add(
715
+ "Overriding ReactiveElement.createProperty() is deprecated. The override will not be called with standard decorators See https://lit.dev/msg/no-override-create-property for more information."
716
+ );
717
+ }
718
+
719
+ // src/runtime.ts
720
+ function makeRuntime(options) {
721
+ let assetPath;
722
+ const setAssetPath = (path) => {
723
+ assetPath = new URL(path, globalThis.location?.href).href;
724
+ };
725
+ const runtime = {
726
+ ...options,
727
+ // FEATURE: research https://vitejs.dev/guide/build.html#advanced-base-options
728
+ getAssetPath(suffix) {
729
+ const assetUrl = new URL(suffix, assetPath);
730
+ return assetUrl.origin !== globalThis.location?.origin ? assetUrl.href : assetUrl.pathname;
731
+ },
732
+ setAssetPath,
733
+ customElement(tagName, component) {
734
+ component.runtime = runtime;
735
+ component.tagName = tagName;
736
+ if (!customElements.get(tagName)) {
737
+ customElements.define(tagName, component);
738
+ }
739
+ }
740
+ };
741
+ setAssetPath(options.defaultAssetPath);
742
+ if (process.env.NODE_ENV !== "production") {
743
+ globalThis.devOnly$luminaRuntime = runtime;
744
+ }
745
+ return runtime;
746
+ }
747
+
748
+ // src/jsx/jsx.ts
749
+ import { directive as litDirective } from "lit-html/directive.js";
750
+ import { noChange as litNoChange, nothing as litNothing } from "lit-html";
751
+ var bindAttribute = void 0;
752
+ var bindBooleanAttribute = void 0;
753
+ var bindProperty = void 0;
754
+ var bindEvent = void 0;
755
+ var nothing = litNothing;
756
+ var noChange = litNoChange;
757
+ var directive = litDirective;
758
+
759
+ // src/jsx/directives.ts
760
+ import { classMap } from "lit-html/directives/class-map.js";
761
+ import { styleMap } from "lit/directives/style-map.js";
762
+ var safeClassMap = (parameters) => typeof parameters === "object" && parameters != null ? classMap(parameters) : parameters;
763
+ var safeStyleMap = (parameters) => typeof parameters === "object" && parameters != null ? styleMap(parameters) : parameters;
764
+
765
+ // src/wrappersUtils.ts
766
+ function createPrototypeProxy(tagName) {
767
+ const customElement = {
768
+ name: tagName,
769
+ get prototype() {
770
+ const customElementPrototype = customElements.get(tagName)?.prototype;
771
+ if (!customElementPrototype) {
772
+ if (process.env.NODE_ENV === "production") {
773
+ throw new Error(`Custom element "${tagName}" not found`);
774
+ } else {
775
+ return Object.create(HTMLElement.prototype);
776
+ }
777
+ }
778
+ Object.defineProperty(customElement, "prototype", customElementPrototype);
779
+ return customElementPrototype;
780
+ }
781
+ };
782
+ return customElement;
783
+ }
784
+ export {
785
+ LitElement,
786
+ bindAttribute,
787
+ bindBooleanAttribute,
788
+ bindEvent,
789
+ bindProperty,
790
+ createEvent,
791
+ createPrototypeProxy,
792
+ directive,
793
+ handleComponentMetaUpdate,
794
+ handleHmrUpdate,
795
+ makeDefineCustomElements,
796
+ makeRuntime,
797
+ method,
798
+ noChange,
799
+ noShadowRoot,
800
+ nothing,
801
+ property,
802
+ safeClassMap,
803
+ safeStyleMap,
804
+ state
805
+ };