@everymatrix/user-actions 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cjs/index-46c0a1de.js +791 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/user-actions.cjs.entry.js +61 -0
  5. package/dist/cjs/user-actions.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/user-actions/user-actions.css +3 -0
  8. package/dist/collection/components/user-actions/user-actions.js +90 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/utils.js +14 -0
  11. package/dist/components/index.d.ts +26 -0
  12. package/dist/components/index.js +1 -0
  13. package/dist/components/user-actions.d.ts +11 -0
  14. package/dist/components/user-actions.js +79 -0
  15. package/dist/esm/index-6c13c021.js +767 -0
  16. package/dist/esm/index.js +1 -0
  17. package/dist/esm/loader.js +17 -0
  18. package/dist/esm/polyfills/core-js.js +11 -0
  19. package/dist/esm/polyfills/css-shim.js +1 -0
  20. package/dist/esm/polyfills/dom.js +79 -0
  21. package/dist/esm/polyfills/es5-html-element.js +1 -0
  22. package/dist/esm/polyfills/index.js +34 -0
  23. package/dist/esm/polyfills/system.js +6 -0
  24. package/dist/esm/user-actions.entry.js +57 -0
  25. package/dist/esm/user-actions.js +17 -0
  26. package/dist/index.cjs.js +1 -0
  27. package/dist/index.js +1 -0
  28. package/dist/stencil.config.js +22 -0
  29. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/user-actions/.stencil/packages/user-actions/stencil.config.d.ts +2 -0
  30. package/dist/types/components/user-actions/user-actions.d.ts +11 -0
  31. package/dist/types/components.d.ts +41 -0
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  34. package/dist/types/utils/utils.d.ts +14 -0
  35. package/dist/user-actions/index.esm.js +0 -0
  36. package/dist/user-actions/p-02573b9e.entry.js +1 -0
  37. package/dist/user-actions/p-d8d5dc61.js +1 -0
  38. package/dist/user-actions/user-actions.esm.js +1 -0
  39. package/loader/cdn.js +3 -0
  40. package/loader/index.cjs.js +3 -0
  41. package/loader/index.d.ts +12 -0
  42. package/loader/index.es2017.js +3 -0
  43. package/loader/index.js +4 -0
  44. package/loader/package.json +10 -0
  45. package/package.json +19 -0
@@ -0,0 +1,767 @@
1
+ const NAMESPACE = 'user-actions';
2
+
3
+ let queuePending = false;
4
+ const win = typeof window !== 'undefined' ? window : {};
5
+ const doc = win.document || { head: {} };
6
+ const plt = {
7
+ $flags$: 0,
8
+ $resourcesUrl$: '',
9
+ jmp: (h) => h(),
10
+ raf: (h) => requestAnimationFrame(h),
11
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
12
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
13
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
14
+ };
15
+ const promiseResolve = (v) => Promise.resolve(v);
16
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
17
+ try {
18
+ new CSSStyleSheet();
19
+ return typeof new CSSStyleSheet().replace === 'function';
20
+ }
21
+ catch (e) { }
22
+ return false;
23
+ })()
24
+ ;
25
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
26
+ if (listeners) {
27
+ listeners.map(([flags, name, method]) => {
28
+ const target = getHostListenerTarget(elm, flags) ;
29
+ const handler = hostListenerProxy(hostRef, method);
30
+ const opts = hostListenerOpts(flags);
31
+ plt.ael(target, name, handler, opts);
32
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
33
+ });
34
+ }
35
+ };
36
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
37
+ try {
38
+ {
39
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
40
+ // instance is ready, let's call it's member method for this event
41
+ hostRef.$lazyInstance$[methodName](ev);
42
+ }
43
+ else {
44
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
45
+ }
46
+ }
47
+ }
48
+ catch (e) {
49
+ consoleError(e);
50
+ }
51
+ };
52
+ const getHostListenerTarget = (elm, flags) => {
53
+ if (flags & 8 /* TargetWindow */)
54
+ return win;
55
+ return elm;
56
+ };
57
+ // prettier-ignore
58
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
59
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
60
+ const createTime = (fnName, tagName = '') => {
61
+ {
62
+ return () => {
63
+ return;
64
+ };
65
+ }
66
+ };
67
+ const uniqueTime = (key, measureText) => {
68
+ {
69
+ return () => {
70
+ return;
71
+ };
72
+ }
73
+ };
74
+ const rootAppliedStyles = new WeakMap();
75
+ const registerStyle = (scopeId, cssText, allowCS) => {
76
+ let style = styles.get(scopeId);
77
+ if (supportsConstructibleStylesheets && allowCS) {
78
+ style = (style || new CSSStyleSheet());
79
+ style.replace(cssText);
80
+ }
81
+ else {
82
+ style = cssText;
83
+ }
84
+ styles.set(scopeId, style);
85
+ };
86
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
87
+ let scopeId = getScopeId(cmpMeta);
88
+ let style = styles.get(scopeId);
89
+ // if an element is NOT connected then getRootNode() will return the wrong root node
90
+ // so the fallback is to always use the document for the root node in those cases
91
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
92
+ if (style) {
93
+ if (typeof style === 'string') {
94
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
95
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
96
+ let styleElm;
97
+ if (!appliedStyles) {
98
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
99
+ }
100
+ if (!appliedStyles.has(scopeId)) {
101
+ {
102
+ {
103
+ styleElm = doc.createElement('style');
104
+ styleElm.innerHTML = style;
105
+ }
106
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
107
+ }
108
+ if (appliedStyles) {
109
+ appliedStyles.add(scopeId);
110
+ }
111
+ }
112
+ }
113
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
114
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
115
+ }
116
+ }
117
+ return scopeId;
118
+ };
119
+ const attachStyles = (hostRef) => {
120
+ const cmpMeta = hostRef.$cmpMeta$;
121
+ const elm = hostRef.$hostElement$;
122
+ const flags = cmpMeta.$flags$;
123
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
124
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
125
+ if (flags & 10 /* needsScopedEncapsulation */) {
126
+ // only required when we're NOT using native shadow dom (slot)
127
+ // or this browser doesn't support native shadow dom
128
+ // and this host element was NOT created with SSR
129
+ // let's pick out the inner content for slot projection
130
+ // create a node to represent where the original
131
+ // content was first placed, which is useful later on
132
+ // DOM WRITE!!
133
+ elm['s-sc'] = scopeId;
134
+ elm.classList.add(scopeId + '-h');
135
+ }
136
+ endAttachStyles();
137
+ };
138
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
139
+ const isComplexType = (o) => {
140
+ // https://jsperf.com/typeof-fn-object/5
141
+ o = typeof o;
142
+ return o === 'object' || o === 'function';
143
+ };
144
+ /**
145
+ * Helper function to create & dispatch a custom Event on a provided target
146
+ * @param elm the target of the Event
147
+ * @param name the name to give the custom Event
148
+ * @param opts options for configuring a custom Event
149
+ * @returns the custom Event
150
+ */
151
+ const emitEvent = (elm, name, opts) => {
152
+ const ev = plt.ce(name, opts);
153
+ elm.dispatchEvent(ev);
154
+ return ev;
155
+ };
156
+ const attachToAncestor = (hostRef, ancestorComponent) => {
157
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
158
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
159
+ }
160
+ };
161
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
162
+ {
163
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
164
+ }
165
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
166
+ hostRef.$flags$ |= 512 /* needsRerender */;
167
+ return;
168
+ }
169
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
170
+ // there is no ancestor component or the ancestor component
171
+ // has already fired off its lifecycle update then
172
+ // fire off the initial update
173
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
174
+ return writeTask(dispatch) ;
175
+ };
176
+ const dispatchHooks = (hostRef, isInitialLoad) => {
177
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
178
+ const instance = hostRef.$lazyInstance$ ;
179
+ let promise;
180
+ if (isInitialLoad) {
181
+ {
182
+ hostRef.$flags$ |= 256 /* isListenReady */;
183
+ if (hostRef.$queuedListeners$) {
184
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
185
+ hostRef.$queuedListeners$ = null;
186
+ }
187
+ }
188
+ {
189
+ promise = safeCall(instance, 'componentWillLoad');
190
+ }
191
+ }
192
+ endSchedule();
193
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
194
+ };
195
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
196
+ // updateComponent
197
+ const elm = hostRef.$hostElement$;
198
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
199
+ const rc = elm['s-rc'];
200
+ if (isInitialLoad) {
201
+ // DOM WRITE!
202
+ attachStyles(hostRef);
203
+ }
204
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
205
+ {
206
+ callRender(hostRef, instance, elm);
207
+ }
208
+ if (rc) {
209
+ // ok, so turns out there are some child host elements
210
+ // waiting on this parent element to load
211
+ // let's fire off all update callbacks waiting
212
+ rc.map((cb) => cb());
213
+ elm['s-rc'] = undefined;
214
+ }
215
+ endRender();
216
+ endUpdate();
217
+ {
218
+ const childrenPromises = elm['s-p'];
219
+ const postUpdate = () => postUpdateComponent(hostRef);
220
+ if (childrenPromises.length === 0) {
221
+ postUpdate();
222
+ }
223
+ else {
224
+ Promise.all(childrenPromises).then(postUpdate);
225
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
226
+ childrenPromises.length = 0;
227
+ }
228
+ }
229
+ };
230
+ const callRender = (hostRef, instance, elm) => {
231
+ try {
232
+ instance = instance.render() ;
233
+ {
234
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
235
+ }
236
+ {
237
+ hostRef.$flags$ |= 2 /* hasRendered */;
238
+ }
239
+ {
240
+ {
241
+ elm.textContent = instance;
242
+ }
243
+ }
244
+ }
245
+ catch (e) {
246
+ consoleError(e, hostRef.$hostElement$);
247
+ }
248
+ return null;
249
+ };
250
+ const postUpdateComponent = (hostRef) => {
251
+ const tagName = hostRef.$cmpMeta$.$tagName$;
252
+ const elm = hostRef.$hostElement$;
253
+ const endPostUpdate = createTime('postUpdate', tagName);
254
+ const ancestorComponent = hostRef.$ancestorComponent$;
255
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
256
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
257
+ {
258
+ // DOM WRITE!
259
+ addHydratedFlag(elm);
260
+ }
261
+ endPostUpdate();
262
+ {
263
+ hostRef.$onReadyResolve$(elm);
264
+ if (!ancestorComponent) {
265
+ appDidLoad();
266
+ }
267
+ }
268
+ }
269
+ else {
270
+ endPostUpdate();
271
+ }
272
+ // load events fire from bottom to top
273
+ // the deepest elements load first then bubbles up
274
+ {
275
+ if (hostRef.$onRenderResolve$) {
276
+ hostRef.$onRenderResolve$();
277
+ hostRef.$onRenderResolve$ = undefined;
278
+ }
279
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
280
+ nextTick(() => scheduleUpdate(hostRef, false));
281
+ }
282
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
283
+ }
284
+ // ( •_•)
285
+ // ( •_•)>⌐■-■
286
+ // (⌐■_■)
287
+ };
288
+ const appDidLoad = (who) => {
289
+ // on appload
290
+ // we have finish the first big initial render
291
+ {
292
+ addHydratedFlag(doc.documentElement);
293
+ }
294
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
295
+ };
296
+ const safeCall = (instance, method, arg) => {
297
+ if (instance && instance[method]) {
298
+ try {
299
+ return instance[method](arg);
300
+ }
301
+ catch (e) {
302
+ consoleError(e);
303
+ }
304
+ }
305
+ return undefined;
306
+ };
307
+ const then = (promise, thenFn) => {
308
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
309
+ };
310
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
311
+ ;
312
+ /**
313
+ * Parse a new property value for a given property type.
314
+ *
315
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
316
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
317
+ * 1. `any`, the type given to `propValue` in the function signature
318
+ * 2. the type stored from `propType`.
319
+ *
320
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
321
+ *
322
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
323
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
324
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
325
+ * ```tsx
326
+ * <my-cmp prop-val={0}></my-cmp>
327
+ * ```
328
+ *
329
+ * HTML prop values on the other hand, will always a string
330
+ *
331
+ * @param propValue the new value to coerce to some type
332
+ * @param propType the type of the prop, expressed as a binary number
333
+ * @returns the parsed/coerced value
334
+ */
335
+ const parsePropertyValue = (propValue, propType) => {
336
+ // ensure this value is of the correct prop type
337
+ if (propValue != null && !isComplexType(propValue)) {
338
+ if (propType & 1 /* String */) {
339
+ // could have been passed as a number or boolean
340
+ // but we still want it as a string
341
+ return String(propValue);
342
+ }
343
+ // redundant return here for better minification
344
+ return propValue;
345
+ }
346
+ // not sure exactly what type we want
347
+ // so no need to change to a different type
348
+ return propValue;
349
+ };
350
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
351
+ const setValue = (ref, propName, newVal, cmpMeta) => {
352
+ // check our new property value against our internal value
353
+ const hostRef = getHostRef(ref);
354
+ const oldVal = hostRef.$instanceValues$.get(propName);
355
+ const flags = hostRef.$flags$;
356
+ const instance = hostRef.$lazyInstance$ ;
357
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
358
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
359
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
360
+ const didValueChange = newVal !== oldVal && !areBothNaN;
361
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
362
+ // gadzooks! the property's value has changed!!
363
+ // set our new value!
364
+ hostRef.$instanceValues$.set(propName, newVal);
365
+ if (instance) {
366
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
367
+ // looks like this value actually changed, so we've got work to do!
368
+ // but only if we've already rendered, otherwise just chill out
369
+ // queue that we need to do an update, but don't worry about queuing
370
+ // up millions cuz this function ensures it only runs once
371
+ scheduleUpdate(hostRef, false);
372
+ }
373
+ }
374
+ }
375
+ };
376
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
377
+ if (cmpMeta.$members$) {
378
+ // It's better to have a const than two Object.entries()
379
+ const members = Object.entries(cmpMeta.$members$);
380
+ const prototype = Cstr.prototype;
381
+ members.map(([memberName, [memberFlags]]) => {
382
+ if ((memberFlags & 31 /* Prop */ ||
383
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
384
+ // proxyComponent - prop
385
+ Object.defineProperty(prototype, memberName, {
386
+ get() {
387
+ // proxyComponent, get value
388
+ return getValue(this, memberName);
389
+ },
390
+ set(newValue) {
391
+ // proxyComponent, set value
392
+ setValue(this, memberName, newValue, cmpMeta);
393
+ },
394
+ configurable: true,
395
+ enumerable: true,
396
+ });
397
+ }
398
+ });
399
+ if ((flags & 1 /* isElementConstructor */)) {
400
+ const attrNameToPropName = new Map();
401
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
402
+ plt.jmp(() => {
403
+ const propName = attrNameToPropName.get(attrName);
404
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
405
+ // in the case where an attribute was set inline.
406
+ // ```html
407
+ // <my-component some-attribute="some-value"></my-component>
408
+ // ```
409
+ //
410
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
411
+ // programmatically changes it before it has been upgraded as shown below:
412
+ //
413
+ // ```html
414
+ // <!-- this component has _not_ been upgraded yet -->
415
+ // <my-component id="test" some-attribute="some-value"></my-component>
416
+ // <script>
417
+ // // grab non-upgraded component
418
+ // el = document.querySelector("#test");
419
+ // el.someAttribute = "another-value";
420
+ // // upgrade component
421
+ // customElements.define('my-component', MyComponent);
422
+ // </script>
423
+ // ```
424
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
425
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
426
+ // to the value that was set inline i.e. "some-value" from above example. When
427
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
428
+ //
429
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
430
+ // by connectedCallback as this attributeChangedCallback will not fire.
431
+ //
432
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
433
+ //
434
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
435
+ // properties here given that this goes against best practices outlined here
436
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
437
+ if (this.hasOwnProperty(propName)) {
438
+ newValue = this[propName];
439
+ delete this[propName];
440
+ }
441
+ else if (prototype.hasOwnProperty(propName) &&
442
+ typeof this[propName] === 'number' &&
443
+ this[propName] == newValue) {
444
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
445
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
446
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
447
+ return;
448
+ }
449
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
450
+ });
451
+ };
452
+ // create an array of attributes to observe
453
+ // and also create a map of html attribute name to js property name
454
+ Cstr.observedAttributes = members
455
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
456
+ .map(([propName, m]) => {
457
+ const attrName = m[1] || propName;
458
+ attrNameToPropName.set(attrName, propName);
459
+ return attrName;
460
+ });
461
+ }
462
+ }
463
+ return Cstr;
464
+ };
465
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
466
+ // initializeComponent
467
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
468
+ {
469
+ // we haven't initialized this element yet
470
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
471
+ // lazy loaded components
472
+ // request the component's implementation to be
473
+ // wired up with the host element
474
+ Cstr = loadModule(cmpMeta);
475
+ if (Cstr.then) {
476
+ // Await creates a micro-task avoid if possible
477
+ const endLoad = uniqueTime();
478
+ Cstr = await Cstr;
479
+ endLoad();
480
+ }
481
+ if (!Cstr.isProxied) {
482
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
483
+ Cstr.isProxied = true;
484
+ }
485
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
486
+ // ok, time to construct the instance
487
+ // but let's keep track of when we start and stop
488
+ // so that the getters/setters don't incorrectly step on data
489
+ {
490
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
491
+ }
492
+ // construct the lazy-loaded component implementation
493
+ // passing the hostRef is very important during
494
+ // construction in order to directly wire together the
495
+ // host element and the lazy-loaded instance
496
+ try {
497
+ new Cstr(hostRef);
498
+ }
499
+ catch (e) {
500
+ consoleError(e);
501
+ }
502
+ {
503
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
504
+ }
505
+ endNewInstance();
506
+ }
507
+ if (Cstr.style) {
508
+ // this component has styles but we haven't registered them yet
509
+ let style = Cstr.style;
510
+ const scopeId = getScopeId(cmpMeta);
511
+ if (!styles.has(scopeId)) {
512
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
513
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
514
+ endRegisterStyles();
515
+ }
516
+ }
517
+ }
518
+ // we've successfully created a lazy instance
519
+ const ancestorComponent = hostRef.$ancestorComponent$;
520
+ const schedule = () => scheduleUpdate(hostRef, true);
521
+ if (ancestorComponent && ancestorComponent['s-rc']) {
522
+ // this is the initial load and this component it has an ancestor component
523
+ // but the ancestor component has NOT fired its will update lifecycle yet
524
+ // so let's just cool our jets and wait for the ancestor to continue first
525
+ // this will get fired off when the ancestor component
526
+ // finally gets around to rendering its lazy self
527
+ // fire off the initial update
528
+ ancestorComponent['s-rc'].push(schedule);
529
+ }
530
+ else {
531
+ schedule();
532
+ }
533
+ };
534
+ const connectedCallback = (elm) => {
535
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
536
+ const hostRef = getHostRef(elm);
537
+ const cmpMeta = hostRef.$cmpMeta$;
538
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
539
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
540
+ // first time this component has connected
541
+ hostRef.$flags$ |= 1 /* hasConnected */;
542
+ {
543
+ // find the first ancestor component (if there is one) and register
544
+ // this component as one of the actively loading child components for its ancestor
545
+ let ancestorComponent = elm;
546
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
547
+ // climb up the ancestors looking for the first
548
+ // component that hasn't finished its lifecycle update yet
549
+ if (ancestorComponent['s-p']) {
550
+ // we found this components first ancestor component
551
+ // keep a reference to this component's ancestor component
552
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
553
+ break;
554
+ }
555
+ }
556
+ }
557
+ // Lazy properties
558
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
559
+ if (cmpMeta.$members$) {
560
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
561
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
562
+ const value = elm[memberName];
563
+ delete elm[memberName];
564
+ elm[memberName] = value;
565
+ }
566
+ });
567
+ }
568
+ {
569
+ initializeComponent(elm, hostRef, cmpMeta);
570
+ }
571
+ }
572
+ else {
573
+ // not the first time this has connected
574
+ // reattach any event listeners to the host
575
+ // since they would have been removed when disconnected
576
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
577
+ }
578
+ endConnected();
579
+ }
580
+ };
581
+ const disconnectedCallback = (elm) => {
582
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
583
+ const hostRef = getHostRef(elm);
584
+ {
585
+ if (hostRef.$rmListeners$) {
586
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
587
+ hostRef.$rmListeners$ = undefined;
588
+ }
589
+ }
590
+ }
591
+ };
592
+ const bootstrapLazy = (lazyBundles, options = {}) => {
593
+ const endBootstrap = createTime();
594
+ const cmpTags = [];
595
+ const exclude = options.exclude || [];
596
+ const customElements = win.customElements;
597
+ const head = doc.head;
598
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
599
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
600
+ const deferredConnectedCallbacks = [];
601
+ let appLoadFallback;
602
+ let isBootstrapping = true;
603
+ Object.assign(plt, options);
604
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
605
+ lazyBundles.map((lazyBundle) => {
606
+ lazyBundle[1].map((compactMeta) => {
607
+ const cmpMeta = {
608
+ $flags$: compactMeta[0],
609
+ $tagName$: compactMeta[1],
610
+ $members$: compactMeta[2],
611
+ $listeners$: compactMeta[3],
612
+ };
613
+ {
614
+ cmpMeta.$members$ = compactMeta[2];
615
+ }
616
+ {
617
+ cmpMeta.$listeners$ = compactMeta[3];
618
+ }
619
+ const tagName = cmpMeta.$tagName$;
620
+ const HostElement = class extends HTMLElement {
621
+ // StencilLazyHost
622
+ constructor(self) {
623
+ // @ts-ignore
624
+ super(self);
625
+ self = this;
626
+ registerHost(self, cmpMeta);
627
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
628
+ // this component is using shadow dom
629
+ // and this browser supports shadow dom
630
+ // add the read-only property "shadowRoot" to the host element
631
+ // adding the shadow root build conditionals to minimize runtime
632
+ {
633
+ {
634
+ self.attachShadow({ mode: 'open' });
635
+ }
636
+ }
637
+ }
638
+ }
639
+ connectedCallback() {
640
+ if (appLoadFallback) {
641
+ clearTimeout(appLoadFallback);
642
+ appLoadFallback = null;
643
+ }
644
+ if (isBootstrapping) {
645
+ // connectedCallback will be processed once all components have been registered
646
+ deferredConnectedCallbacks.push(this);
647
+ }
648
+ else {
649
+ plt.jmp(() => connectedCallback(this));
650
+ }
651
+ }
652
+ disconnectedCallback() {
653
+ plt.jmp(() => disconnectedCallback(this));
654
+ }
655
+ componentOnReady() {
656
+ return getHostRef(this).$onReadyPromise$;
657
+ }
658
+ };
659
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
660
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
661
+ cmpTags.push(tagName);
662
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
663
+ }
664
+ });
665
+ });
666
+ {
667
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
668
+ visibilityStyle.setAttribute('data-styles', '');
669
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
670
+ }
671
+ // Process deferred connectedCallbacks now all components have been registered
672
+ isBootstrapping = false;
673
+ if (deferredConnectedCallbacks.length) {
674
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
675
+ }
676
+ else {
677
+ {
678
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
679
+ }
680
+ }
681
+ // Fallback appLoad event
682
+ endBootstrap();
683
+ };
684
+ const hostRefs = new WeakMap();
685
+ const getHostRef = (ref) => hostRefs.get(ref);
686
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
687
+ const registerHost = (elm, cmpMeta) => {
688
+ const hostRef = {
689
+ $flags$: 0,
690
+ $hostElement$: elm,
691
+ $cmpMeta$: cmpMeta,
692
+ $instanceValues$: new Map(),
693
+ };
694
+ {
695
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
696
+ elm['s-p'] = [];
697
+ elm['s-rc'] = [];
698
+ }
699
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
700
+ return hostRefs.set(elm, hostRef);
701
+ };
702
+ const consoleError = (e, el) => (0, console.error)(e, el);
703
+ const cmpModules = /*@__PURE__*/ new Map();
704
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
705
+ // loadModuleImport
706
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
707
+ const bundleId = cmpMeta.$lazyBundleId$;
708
+ const module = cmpModules.get(bundleId) ;
709
+ if (module) {
710
+ return module[exportName];
711
+ }
712
+ return import(
713
+ /* webpackInclude: /\.entry\.js$/ */
714
+ /* webpackExclude: /\.system\.entry\.js$/ */
715
+ /* webpackMode: "lazy" */
716
+ `./${bundleId}.entry.js${''}`).then((importedModule) => {
717
+ {
718
+ cmpModules.set(bundleId, importedModule);
719
+ }
720
+ return importedModule[exportName];
721
+ }, consoleError);
722
+ };
723
+ const styles = new Map();
724
+ const queueDomReads = [];
725
+ const queueDomWrites = [];
726
+ const queueTask = (queue, write) => (cb) => {
727
+ queue.push(cb);
728
+ if (!queuePending) {
729
+ queuePending = true;
730
+ if (write && plt.$flags$ & 4 /* queueSync */) {
731
+ nextTick(flush);
732
+ }
733
+ else {
734
+ plt.raf(flush);
735
+ }
736
+ }
737
+ };
738
+ const consume = (queue) => {
739
+ for (let i = 0; i < queue.length; i++) {
740
+ try {
741
+ queue[i](performance.now());
742
+ }
743
+ catch (e) {
744
+ consoleError(e);
745
+ }
746
+ }
747
+ queue.length = 0;
748
+ };
749
+ const flush = () => {
750
+ // always force a bunch of medium callbacks to run, but still have
751
+ // a throttle on how many can run in a certain time
752
+ // DOM READS!!!
753
+ consume(queueDomReads);
754
+ // DOM WRITES!!!
755
+ {
756
+ consume(queueDomWrites);
757
+ if ((queuePending = queueDomReads.length > 0)) {
758
+ // still more to do yet, but we've run out of time
759
+ // let's let this thing cool off and try again in the next tick
760
+ plt.raf(flush);
761
+ }
762
+ }
763
+ };
764
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
765
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
766
+
767
+ export { bootstrapLazy as b, promiseResolve as p, registerInstance as r };