UNPKG

122 kBJavaScriptView Raw
1'use strict';
2
3function _interopNamespace(e) {
4 if (e && e.__esModule) { return e; } else {
5 var n = {};
6 if (e) {
7 Object.keys(e).forEach(function (k) {
8 var d = Object.getOwnPropertyDescriptor(e, k);
9 Object.defineProperty(n, k, d.get ? d : {
10 enumerable: true,
11 get: function () {
12 return e[k];
13 }
14 });
15 });
16 }
17 n['default'] = e;
18 return n;
19 }
20}
21
22const NAMESPACE = 'bulmil';
23const BUILD = /* bulmil */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: true, attachStyles: true, cloneNodeFix: false, cmpDidLoad: false, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: false, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, cssVarShim: true, devTools: false, disconnectedCallback: false, dynamicImportShim: true, element: false, event: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: true, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: true, isDebug: false, isDev: true, isTesting: true, lazyLoad: true, lifecycle: false, lifecycleDOMEvents: true, member: true, method: false, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: true, scoped: false, scriptDataOpts: true, shadowDelegatesFocus: false, shadowDom: false, shadowDomShim: true, slot: true, slotChildNodesFix: false, slotRelocation: true, state: false, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: false, vdomListener: true, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: false };
24
25let scopeId;
26let contentRef;
27let hostTagName;
28let i = 0;
29let useNativeShadowDom = false;
30let checkSlotFallbackVisibility = false;
31let checkSlotRelocate = false;
32let isSvgMode = false;
33let renderingRef = null;
34let queueCongestion = 0;
35let queuePending = false;
36const win = typeof window !== 'undefined' ? window : {};
37const CSS = BUILD.cssVarShim ? win.CSS : null;
38const doc = win.document || { head: {} };
39const H = (win.HTMLElement || class {
40});
41const plt = {
42 $flags$: 0,
43 $resourcesUrl$: '',
44 jmp: h => h(),
45 raf: h => requestAnimationFrame(h),
46 ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
47 rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
48 ce: (eventName, opts) => new CustomEvent(eventName, opts),
49};
50const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)() : true;
51const supportsListenerOptions = /*@__PURE__*/ (() => {
52 let supportsListenerOptions = false;
53 try {
54 doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
55 get() {
56 supportsListenerOptions = true;
57 },
58 }));
59 }
60 catch (e) { }
61 return supportsListenerOptions;
62})();
63const promiseResolve = (v) => Promise.resolve(v);
64const supportsConstructibleStylesheets = BUILD.constructableCSS
65 ? /*@__PURE__*/ (() => {
66 try {
67 new CSSStyleSheet();
68 return true;
69 }
70 catch (e) { }
71 return false;
72 })()
73 : false;
74const Context = {};
75const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
76 if (BUILD.hostListener && listeners) {
77 // this is called immediately within the element's constructor
78 // initialize our event listeners on the host element
79 // we do this now so that we can listen to events that may
80 // have fired even before the instance is ready
81 if (BUILD.hostListenerTargetParent) {
82 // this component may have event listeners that should be attached to the parent
83 if (attachParentListeners) {
84 // this is being ran from within the connectedCallback
85 // which is important so that we know the host element actually has a parent element
86 // filter out the listeners to only have the ones that ARE being attached to the parent
87 listeners = listeners.filter(([flags]) => flags & 16 /* TargetParent */);
88 }
89 else {
90 // this is being ran from within the component constructor
91 // everything BUT the parent element listeners should be attached at this time
92 // filter out the listeners that are NOT being attached to the parent
93 listeners = listeners.filter(([flags]) => !(flags & 16 /* TargetParent */));
94 }
95 }
96 listeners.map(([flags, name, method]) => {
97 const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
98 const handler = hostListenerProxy(hostRef, method);
99 const opts = hostListenerOpts(flags);
100 plt.ael(target, name, handler, opts);
101 (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
102 });
103 }
104};
105const hostListenerProxy = (hostRef, methodName) => (ev) => {
106 if (BUILD.lazyLoad) {
107 if (hostRef.$flags$ & 256 /* isListenReady */) {
108 // instance is ready, let's call it's member method for this event
109 hostRef.$lazyInstance$[methodName](ev);
110 }
111 else {
112 (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
113 }
114 }
115 else {
116 hostRef.$hostElement$[methodName](ev);
117 }
118};
119const getHostListenerTarget = (elm, flags) => {
120 if (BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
121 return doc;
122 if (BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
123 return win;
124 if (BUILD.hostListenerTargetBody && flags & 32 /* TargetBody */)
125 return doc.body;
126 if (BUILD.hostListenerTargetParent && flags & 16 /* TargetParent */)
127 return elm.parentElement;
128 return elm;
129};
130// prettier-ignore
131const hostListenerOpts = (flags) => supportsListenerOptions
132 ? ({
133 passive: (flags & 1 /* Passive */) !== 0,
134 capture: (flags & 2 /* Capture */) !== 0,
135 })
136 : (flags & 2 /* Capture */) !== 0;
137const CONTENT_REF_ID = 'r';
138const ORG_LOCATION_ID = 'o';
139const SLOT_NODE_ID = 's';
140const TEXT_NODE_ID = 't';
141const HYDRATE_ID = 's-id';
142const HYDRATED_STYLE_ID = 'sty-id';
143const HYDRATE_CHILD_ID = 'c-id';
144const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
145const XLINK_NS = 'http://www.w3.org/1999/xlink';
146const createTime = (fnName, tagName = '') => {
147 if (BUILD.profile && performance.mark) {
148 const key = `st:${fnName}:${tagName}:${i++}`;
149 // Start
150 performance.mark(key);
151 // End
152 return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
153 }
154 else {
155 return () => {
156 return;
157 };
158 }
159};
160const uniqueTime = (key, measureText) => {
161 if (BUILD.profile && performance.mark) {
162 if (performance.getEntriesByName(key).length === 0) {
163 performance.mark(key);
164 }
165 return () => {
166 if (performance.getEntriesByName(measureText).length === 0) {
167 performance.measure(measureText, key);
168 }
169 };
170 }
171 else {
172 return () => {
173 return;
174 };
175 }
176};
177const inspect = (ref) => {
178 const hostRef = getHostRef(ref);
179 if (!hostRef) {
180 return undefined;
181 }
182 const flags = hostRef.$flags$;
183 const hostElement = hostRef.$hostElement$;
184 return {
185 renderCount: hostRef.$renderCount$,
186 flags: {
187 hasRendered: !!(flags & 2 /* hasRendered */),
188 hasConnected: !!(flags & 1 /* hasConnected */),
189 isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
190 isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
191 isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
192 hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
193 hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
194 isWatchReady: !!(flags & 128 /* isWatchReady */),
195 isListenReady: !!(flags & 256 /* isListenReady */),
196 needsRerender: !!(flags & 512 /* needsRerender */),
197 },
198 instanceValues: hostRef.$instanceValues$,
199 ancestorComponent: hostRef.$ancestorComponent$,
200 hostElement,
201 lazyInstance: hostRef.$lazyInstance$,
202 vnode: hostRef.$vnode$,
203 modeName: hostRef.$modeName$,
204 onReadyPromise: hostRef.$onReadyPromise$,
205 onReadyResolve: hostRef.$onReadyResolve$,
206 onInstancePromise: hostRef.$onInstancePromise$,
207 onInstanceResolve: hostRef.$onInstanceResolve$,
208 onRenderResolve: hostRef.$onRenderResolve$,
209 queuedListeners: hostRef.$queuedListeners$,
210 rmListeners: hostRef.$rmListeners$,
211 ['s-id']: hostElement['s-id'],
212 ['s-cr']: hostElement['s-cr'],
213 ['s-lr']: hostElement['s-lr'],
214 ['s-p']: hostElement['s-p'],
215 ['s-rc']: hostElement['s-rc'],
216 ['s-sc']: hostElement['s-sc'],
217 };
218};
219const installDevTools = () => {
220 if (BUILD.devTools) {
221 const stencil = (win.stencil = win.stencil || {});
222 const originalInspect = stencil.inspect;
223 stencil.inspect = (ref) => {
224 let result = inspect(ref);
225 if (!result && typeof originalInspect === 'function') {
226 result = originalInspect(ref);
227 }
228 return result;
229 };
230 }
231};
232const rootAppliedStyles = new WeakMap();
233const registerStyle = (scopeId, cssText, allowCS) => {
234 let style = styles.get(scopeId);
235 if (supportsConstructibleStylesheets && allowCS) {
236 style = (style || new CSSStyleSheet());
237 style.replace(cssText);
238 }
239 else {
240 style = cssText;
241 }
242 styles.set(scopeId, style);
243};
244const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
245 let scopeId = getScopeId(cmpMeta, mode);
246 let style = styles.get(scopeId);
247 if (!BUILD.attachStyles) {
248 return scopeId;
249 }
250 // if an element is NOT connected then getRootNode() will return the wrong root node
251 // so the fallback is to always use the document for the root node in those cases
252 styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
253 if (style) {
254 if (typeof style === 'string') {
255 styleContainerNode = styleContainerNode.head || styleContainerNode;
256 let appliedStyles = rootAppliedStyles.get(styleContainerNode);
257 let styleElm;
258 if (!appliedStyles) {
259 rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
260 }
261 if (!appliedStyles.has(scopeId)) {
262 if (BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
263 // This is only happening on native shadow-dom, do not needs CSS var shim
264 styleElm.innerHTML = style;
265 }
266 else {
267 if (BUILD.cssVarShim && plt.$cssShim$) {
268 styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
269 const newScopeId = styleElm['s-sc'];
270 if (newScopeId) {
271 scopeId = newScopeId;
272 // we don't want to add this styleID to the appliedStyles Set
273 // since the cssVarShim might need to apply several different
274 // stylesheets for the same component
275 appliedStyles = null;
276 }
277 }
278 else {
279 styleElm = doc.createElement('style');
280 styleElm.innerHTML = style;
281 }
282 if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
283 styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
284 }
285 styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
286 }
287 if (appliedStyles) {
288 appliedStyles.add(scopeId);
289 }
290 }
291 }
292 else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
293 styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
294 }
295 }
296 return scopeId;
297};
298const attachStyles = (hostRef) => {
299 const cmpMeta = hostRef.$cmpMeta$;
300 const elm = hostRef.$hostElement$;
301 const flags = cmpMeta.$flags$;
302 const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
303 const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
304 if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */) {
305 // only required when we're NOT using native shadow dom (slot)
306 // or this browser doesn't support native shadow dom
307 // and this host element was NOT created with SSR
308 // let's pick out the inner content for slot projection
309 // create a node to represent where the original
310 // content was first placed, which is useful later on
311 // DOM WRITE!!
312 elm['s-sc'] = scopeId;
313 elm.classList.add(scopeId + '-h');
314 if (BUILD.scoped && flags & 2 /* scopedCssEncapsulation */) {
315 elm.classList.add(scopeId + '-s');
316 }
317 }
318 endAttachStyles();
319};
320const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
321const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
322// Private
323const computeMode = (elm) => modeResolutionChain.map(h => h(elm)).find(m => !!m);
324// Public
325const setMode = (handler) => modeResolutionChain.push(handler);
326const getMode = (ref) => getHostRef(ref).$modeName$;
327/**
328 * Default style mode id
329 */
330/**
331 * Reusable empty obj/array
332 * Don't add values to these!!
333 */
334const EMPTY_OBJ = {};
335/**
336 * Namespaces
337 */
338const SVG_NS = 'http://www.w3.org/2000/svg';
339const HTML_NS = 'http://www.w3.org/1999/xhtml';
340const isDef = (v) => v != null;
341const noop = () => {
342 /* noop*/
343};
344const isComplexType = (o) => {
345 // https://jsperf.com/typeof-fn-object/5
346 o = typeof o;
347 return o === 'object' || o === 'function';
348};
349const IS_DENO_ENV = typeof Deno !== 'undefined';
350const IS_NODE_ENV = !IS_DENO_ENV &&
351 typeof global !== 'undefined' &&
352 typeof require === 'function' &&
353 !!global.process &&
354 typeof __filename === 'string' &&
355 (!global.origin || typeof global.origin !== 'string');
356const IS_DENO_WINDOWS_ENV = IS_DENO_ENV && Deno.build.os === 'windows';
357const getCurrentDirectory = IS_NODE_ENV ? process.cwd : IS_DENO_ENV ? Deno.cwd : () => '/';
358const exit = IS_NODE_ENV ? process.exit : IS_DENO_ENV ? Deno.exit : noop;
359/**
360 * Production h() function based on Preact by
361 * Jason Miller (@developit)
362 * Licensed under the MIT License
363 * https://github.com/developit/preact/blob/master/LICENSE
364 *
365 * Modified for Stencil's compiler and vdom
366 */
367// const stack: any[] = [];
368// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
369// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
370const h = (nodeName, vnodeData, ...children) => {
371 let child = null;
372 let key = null;
373 let slotName = null;
374 let simple = false;
375 let lastSimple = false;
376 let vNodeChildren = [];
377 const walk = (c) => {
378 for (let i = 0; i < c.length; i++) {
379 child = c[i];
380 if (Array.isArray(child)) {
381 walk(child);
382 }
383 else if (child != null && typeof child !== 'boolean') {
384 if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
385 child = String(child);
386 }
387 else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
388 consoleDevError(`vNode passed as children has unexpected type.
389Make sure it's using the correct h() function.
390Empty objects can also be the cause, look for JSX comments that became objects.`);
391 }
392 if (simple && lastSimple) {
393 // If the previous child was simple (string), we merge both
394 vNodeChildren[vNodeChildren.length - 1].$text$ += child;
395 }
396 else {
397 // Append a new vNode, if it's text, we create a text vNode
398 vNodeChildren.push(simple ? newVNode(null, child) : child);
399 }
400 lastSimple = simple;
401 }
402 }
403 };
404 walk(children);
405 if (vnodeData) {
406 if (BUILD.isDev && nodeName === 'input') {
407 validateInputProperties(vnodeData);
408 }
409 // normalize class / classname attributes
410 if (BUILD.vdomKey && vnodeData.key) {
411 key = vnodeData.key;
412 }
413 if (BUILD.slotRelocation && vnodeData.name) {
414 slotName = vnodeData.name;
415 }
416 if (BUILD.vdomClass) {
417 const classData = vnodeData.className || vnodeData.class;
418 if (classData) {
419 vnodeData.class =
420 typeof classData !== 'object'
421 ? classData
422 : Object.keys(classData)
423 .filter(k => classData[k])
424 .join(' ');
425 }
426 }
427 }
428 if (BUILD.isDev && vNodeChildren.some(isHost)) {
429 consoleDevError(`The <Host> must be the single root component. Make sure:
430- You are NOT using hostData() and <Host> in the same component.
431- <Host> is used once, and it's the single root component of the render() function.`);
432 }
433 if (BUILD.vdomFunctional && typeof nodeName === 'function') {
434 // nodeName is a functional component
435 return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
436 }
437 const vnode = newVNode(nodeName, null);
438 vnode.$attrs$ = vnodeData;
439 if (vNodeChildren.length > 0) {
440 vnode.$children$ = vNodeChildren;
441 }
442 if (BUILD.vdomKey) {
443 vnode.$key$ = key;
444 }
445 if (BUILD.slotRelocation) {
446 vnode.$name$ = slotName;
447 }
448 return vnode;
449};
450const newVNode = (tag, text) => {
451 const vnode = {
452 $flags$: 0,
453 $tag$: tag,
454 $text$: text,
455 $elm$: null,
456 $children$: null,
457 };
458 if (BUILD.vdomAttribute) {
459 vnode.$attrs$ = null;
460 }
461 if (BUILD.vdomKey) {
462 vnode.$key$ = null;
463 }
464 if (BUILD.slotRelocation) {
465 vnode.$name$ = null;
466 }
467 return vnode;
468};
469const Host = {};
470const isHost = (node) => node && node.$tag$ === Host;
471const vdomFnUtils = {
472 forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
473 map: (children, cb) => children
474 .map(convertToPublic)
475 .map(cb)
476 .map(convertToPrivate),
477};
478const convertToPublic = (node) => ({
479 vattrs: node.$attrs$,
480 vchildren: node.$children$,
481 vkey: node.$key$,
482 vname: node.$name$,
483 vtag: node.$tag$,
484 vtext: node.$text$,
485});
486const convertToPrivate = (node) => {
487 if (typeof node.vtag === 'function') {
488 const vnodeData = Object.assign({}, node.vattrs);
489 if (node.vkey) {
490 vnodeData.key = node.vkey;
491 }
492 if (node.vname) {
493 vnodeData.name = node.vname;
494 }
495 return h(node.vtag, vnodeData, ...node.vchildren || []);
496 }
497 const vnode = newVNode(node.vtag, node.vtext);
498 vnode.$attrs$ = node.vattrs;
499 vnode.$children$ = node.vchildren;
500 vnode.$key$ = node.vkey;
501 vnode.$name$ = node.vname;
502 return vnode;
503};
504const validateInputProperties = (vnodeData) => {
505 const props = Object.keys(vnodeData);
506 const typeIndex = props.indexOf('type');
507 const minIndex = props.indexOf('min');
508 const maxIndex = props.indexOf('max');
509 const stepIndex = props.indexOf('min');
510 const value = props.indexOf('value');
511 if (value === -1) {
512 return;
513 }
514 if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
515 consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
516 }
517};
518/**
519 * Production setAccessor() function based on Preact by
520 * Jason Miller (@developit)
521 * Licensed under the MIT License
522 * https://github.com/developit/preact/blob/master/LICENSE
523 *
524 * Modified for Stencil's compiler and vdom
525 */
526const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
527 if (oldValue !== newValue) {
528 let isProp = isMemberInElement(elm, memberName);
529 let ln = memberName.toLowerCase();
530 if (BUILD.vdomClass && memberName === 'class') {
531 const classList = elm.classList;
532 const oldClasses = parseClassList(oldValue);
533 const newClasses = parseClassList(newValue);
534 classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
535 classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
536 }
537 else if (BUILD.vdomStyle && memberName === 'style') {
538 // update style attribute, css properties and values
539 if (BUILD.updatable) {
540 for (const prop in oldValue) {
541 if (!newValue || newValue[prop] == null) {
542 if (!BUILD.hydrateServerSide && prop.includes('-')) {
543 elm.style.removeProperty(prop);
544 }
545 else {
546 elm.style[prop] = '';
547 }
548 }
549 }
550 }
551 for (const prop in newValue) {
552 if (!oldValue || newValue[prop] !== oldValue[prop]) {
553 if (!BUILD.hydrateServerSide && prop.includes('-')) {
554 elm.style.setProperty(prop, newValue[prop]);
555 }
556 else {
557 elm.style[prop] = newValue[prop];
558 }
559 }
560 }
561 }
562 else if (BUILD.vdomKey && memberName === 'key')
563 ;
564 else if (BUILD.vdomRef && memberName === 'ref') {
565 // minifier will clean this up
566 if (newValue) {
567 newValue(elm);
568 }
569 }
570 else if (BUILD.vdomListener && (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === 'o' && memberName[1] === 'n') {
571 // Event Handlers
572 // so if the member name starts with "on" and the 3rd characters is
573 // a capital letter, and it's not already a member on the element,
574 // then we're assuming it's an event listener
575 if (memberName[2] === '-') {
576 // on- prefixed events
577 // allows to be explicit about the dom event to listen without any magic
578 // under the hood:
579 // <my-cmp on-click> // listens for "click"
580 // <my-cmp on-Click> // listens for "Click"
581 // <my-cmp on-ionChange> // listens for "ionChange"
582 // <my-cmp on-EVENTS> // listens for "EVENTS"
583 memberName = memberName.slice(3);
584 }
585 else if (isMemberInElement(win, ln)) {
586 // standard event
587 // the JSX attribute could have been "onMouseOver" and the
588 // member name "onmouseover" is on the window's prototype
589 // so let's add the listener "mouseover", which is all lowercased
590 memberName = ln.slice(2);
591 }
592 else {
593 // custom event
594 // the JSX attribute could have been "onMyCustomEvent"
595 // so let's trim off the "on" prefix and lowercase the first character
596 // and add the listener "myCustomEvent"
597 // except for the first character, we keep the event name case
598 memberName = ln[2] + memberName.slice(3);
599 }
600 if (oldValue) {
601 plt.rel(elm, memberName, oldValue, false);
602 }
603 if (newValue) {
604 plt.ael(elm, memberName, newValue, false);
605 }
606 }
607 else if (BUILD.vdomPropOrAttr) {
608 // Set property if it exists and it's not a SVG
609 const isComplex = isComplexType(newValue);
610 if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
611 try {
612 if (!elm.tagName.includes('-')) {
613 let n = newValue == null ? '' : newValue;
614 // Workaround for Safari, moving the <input> caret when re-assigning the same valued
615 if (memberName === 'list') {
616 isProp = false;
617 // tslint:disable-next-line: triple-equals
618 }
619 else if (oldValue == null || elm[memberName] != n) {
620 elm[memberName] = n;
621 }
622 }
623 else {
624 elm[memberName] = newValue;
625 }
626 }
627 catch (e) { }
628 }
629 /**
630 * Need to manually update attribute if:
631 * - memberName is not an attribute
632 * - if we are rendering the host element in order to reflect attribute
633 * - if it's a SVG, since properties might not work in <svg>
634 * - if the newValue is null/undefined or 'false'.
635 */
636 let xlink = false;
637 if (BUILD.vdomXlink) {
638 if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
639 memberName = ln;
640 xlink = true;
641 }
642 }
643 if (newValue == null || newValue === false) {
644 if (newValue !== false || elm.getAttribute(memberName) === '') {
645 if (BUILD.vdomXlink && xlink) {
646 elm.removeAttributeNS(XLINK_NS, memberName);
647 }
648 else {
649 elm.removeAttribute(memberName);
650 }
651 }
652 }
653 else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
654 newValue = newValue === true ? '' : newValue;
655 if (BUILD.vdomXlink && xlink) {
656 elm.setAttributeNS(XLINK_NS, memberName, newValue);
657 }
658 else {
659 elm.setAttribute(memberName, newValue);
660 }
661 }
662 }
663 }
664};
665const parseClassListRegex = /\s/;
666const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
667const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
668 // if the element passed in is a shadow root, which is a document fragment
669 // then we want to be adding attrs/props to the shadow root's "host" element
670 // if it's not a shadow root, then we add attrs/props to the same element
671 const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
672 const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
673 const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
674 if (BUILD.updatable) {
675 // remove attributes no longer present on the vnode by setting them to undefined
676 for (memberName in oldVnodeAttrs) {
677 if (!(memberName in newVnodeAttrs)) {
678 setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
679 }
680 }
681 }
682 // add new & update changed attributes
683 for (memberName in newVnodeAttrs) {
684 setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
685 }
686};
687const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
688 // tslint:disable-next-line: prefer-const
689 let newVNode = newParentVNode.$children$[childIndex];
690 let i = 0;
691 let elm;
692 let childNode;
693 let oldVNode;
694 if (BUILD.slotRelocation && !useNativeShadowDom) {
695 // remember for later we need to check to relocate nodes
696 checkSlotRelocate = true;
697 if (newVNode.$tag$ === 'slot') {
698 if (scopeId) {
699 // scoped css needs to add its scoped id to the parent element
700 parentElm.classList.add(scopeId + '-s');
701 }
702 newVNode.$flags$ |= newVNode.$children$
703 ? // slot element has fallback content
704 2 /* isSlotFallback */
705 : // slot element does not have fallback content
706 1 /* isSlotReference */;
707 }
708 }
709 if (BUILD.isDev && newVNode.$elm$) {
710 consoleError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
711 }
712 if (BUILD.vdomText && newVNode.$text$ !== null) {
713 // create text node
714 elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
715 }
716 else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* isSlotReference */) {
717 // create a slot reference node
718 elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
719 }
720 else {
721 if (BUILD.svg && !isSvgMode) {
722 isSvgMode = newVNode.$tag$ === 'svg';
723 }
724 // create element
725 elm = newVNode.$elm$ = (BUILD.svg
726 ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$)
727 : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$));
728 if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
729 isSvgMode = false;
730 }
731 // add css classes, attrs, props, listeners, etc.
732 if (BUILD.vdomAttribute) {
733 updateElement(null, newVNode, isSvgMode);
734 }
735 if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
736 // if there is a scopeId and this is the initial render
737 // then let's add the scopeId as a css class
738 elm.classList.add((elm['s-si'] = scopeId));
739 }
740 if (newVNode.$children$) {
741 for (i = 0; i < newVNode.$children$.length; ++i) {
742 // create the node
743 childNode = createElm(oldParentVNode, newVNode, i, elm);
744 // return node could have been null
745 if (childNode) {
746 // append our new node
747 elm.appendChild(childNode);
748 }
749 }
750 }
751 if (BUILD.svg) {
752 if (newVNode.$tag$ === 'svg') {
753 // Only reset the SVG context when we're exiting <svg> element
754 isSvgMode = false;
755 }
756 else if (elm.tagName === 'foreignObject') {
757 // Reenter SVG context when we're exiting <foreignObject> element
758 isSvgMode = true;
759 }
760 }
761 }
762 if (BUILD.slotRelocation) {
763 elm['s-hn'] = hostTagName;
764 if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
765 // remember the content reference comment
766 elm['s-sr'] = true;
767 // remember the content reference comment
768 elm['s-cr'] = contentRef;
769 // remember the slot name, or empty string for default slot
770 elm['s-sn'] = newVNode.$name$ || '';
771 // check if we've got an old vnode for this slot
772 oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
773 if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
774 // we've got an old slot vnode and the wrapper is being replaced
775 // so let's move the old slot content back to it's original location
776 putBackInOriginalLocation(oldParentVNode.$elm$, false);
777 }
778 }
779 }
780 return elm;
781};
782const putBackInOriginalLocation = (parentElm, recursive) => {
783 plt.$flags$ |= 1 /* isTmpDisconnected */;
784 const oldSlotChildNodes = parentElm.childNodes;
785 for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
786 const childNode = oldSlotChildNodes[i];
787 if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
788 // // this child node in the old element is from another component
789 // // remove this node from the old slot's parent
790 // childNode.remove();
791 // and relocate it back to it's original location
792 parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
793 // remove the old original location comment entirely
794 // later on the patch function will know what to do
795 // and move this to the correct spot in need be
796 childNode['s-ol'].remove();
797 childNode['s-ol'] = undefined;
798 checkSlotRelocate = true;
799 }
800 if (recursive) {
801 putBackInOriginalLocation(childNode, recursive);
802 }
803 }
804 plt.$flags$ &= ~1 /* isTmpDisconnected */;
805};
806const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
807 let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
808 let childNode;
809 if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
810 containerElm = containerElm.shadowRoot;
811 }
812 for (; startIdx <= endIdx; ++startIdx) {
813 if (vnodes[startIdx]) {
814 childNode = createElm(null, parentVNode, startIdx, parentElm);
815 if (childNode) {
816 vnodes[startIdx].$elm$ = childNode;
817 containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
818 }
819 }
820 }
821};
822const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
823 for (; startIdx <= endIdx; ++startIdx) {
824 if ((vnode = vnodes[startIdx])) {
825 elm = vnode.$elm$;
826 callNodeRefs(vnode);
827 if (BUILD.slotRelocation) {
828 // we're removing this element
829 // so it's possible we need to show slot fallback content now
830 checkSlotFallbackVisibility = true;
831 if (elm['s-ol']) {
832 // remove the original location comment
833 elm['s-ol'].remove();
834 }
835 else {
836 // it's possible that child nodes of the node
837 // that's being removed are slot nodes
838 putBackInOriginalLocation(elm, true);
839 }
840 }
841 // remove the vnode's element from the dom
842 elm.remove();
843 }
844 }
845};
846const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
847 let oldStartIdx = 0;
848 let newStartIdx = 0;
849 let idxInOld = 0;
850 let i = 0;
851 let oldEndIdx = oldCh.length - 1;
852 let oldStartVnode = oldCh[0];
853 let oldEndVnode = oldCh[oldEndIdx];
854 let newEndIdx = newCh.length - 1;
855 let newStartVnode = newCh[0];
856 let newEndVnode = newCh[newEndIdx];
857 let node;
858 let elmToMove;
859 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
860 if (oldStartVnode == null) {
861 // Vnode might have been moved left
862 oldStartVnode = oldCh[++oldStartIdx];
863 }
864 else if (oldEndVnode == null) {
865 oldEndVnode = oldCh[--oldEndIdx];
866 }
867 else if (newStartVnode == null) {
868 newStartVnode = newCh[++newStartIdx];
869 }
870 else if (newEndVnode == null) {
871 newEndVnode = newCh[--newEndIdx];
872 }
873 else if (isSameVnode(oldStartVnode, newStartVnode)) {
874 patch(oldStartVnode, newStartVnode);
875 oldStartVnode = oldCh[++oldStartIdx];
876 newStartVnode = newCh[++newStartIdx];
877 }
878 else if (isSameVnode(oldEndVnode, newEndVnode)) {
879 patch(oldEndVnode, newEndVnode);
880 oldEndVnode = oldCh[--oldEndIdx];
881 newEndVnode = newCh[--newEndIdx];
882 }
883 else if (isSameVnode(oldStartVnode, newEndVnode)) {
884 // Vnode moved right
885 if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
886 putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
887 }
888 patch(oldStartVnode, newEndVnode);
889 parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
890 oldStartVnode = oldCh[++oldStartIdx];
891 newEndVnode = newCh[--newEndIdx];
892 }
893 else if (isSameVnode(oldEndVnode, newStartVnode)) {
894 // Vnode moved left
895 if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
896 putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
897 }
898 patch(oldEndVnode, newStartVnode);
899 parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
900 oldEndVnode = oldCh[--oldEndIdx];
901 newStartVnode = newCh[++newStartIdx];
902 }
903 else {
904 // createKeyToOldIdx
905 idxInOld = -1;
906 if (BUILD.vdomKey) {
907 for (i = oldStartIdx; i <= oldEndIdx; ++i) {
908 if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
909 idxInOld = i;
910 break;
911 }
912 }
913 }
914 if (BUILD.vdomKey && idxInOld >= 0) {
915 elmToMove = oldCh[idxInOld];
916 if (elmToMove.$tag$ !== newStartVnode.$tag$) {
917 node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
918 }
919 else {
920 patch(elmToMove, newStartVnode);
921 oldCh[idxInOld] = undefined;
922 node = elmToMove.$elm$;
923 }
924 newStartVnode = newCh[++newStartIdx];
925 }
926 else {
927 // new element
928 node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
929 newStartVnode = newCh[++newStartIdx];
930 }
931 if (node) {
932 if (BUILD.slotRelocation) {
933 parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
934 }
935 else {
936 oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
937 }
938 }
939 }
940 }
941 if (oldStartIdx > oldEndIdx) {
942 addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
943 }
944 else if (BUILD.updatable && newStartIdx > newEndIdx) {
945 removeVnodes(oldCh, oldStartIdx, oldEndIdx);
946 }
947};
948const isSameVnode = (vnode1, vnode2) => {
949 // compare if two vnode to see if they're "technically" the same
950 // need to have the same element tag, and same key to be the same
951 if (vnode1.$tag$ === vnode2.$tag$) {
952 if (BUILD.slotRelocation && vnode1.$tag$ === 'slot') {
953 return vnode1.$name$ === vnode2.$name$;
954 }
955 if (BUILD.vdomKey) {
956 return vnode1.$key$ === vnode2.$key$;
957 }
958 return true;
959 }
960 return false;
961};
962const referenceNode = (node) => {
963 // this node was relocated to a new location in the dom
964 // because of some other component's slot
965 // but we still have an html comment in place of where
966 // it's original location was according to it's original vdom
967 return (node && node['s-ol']) || node;
968};
969const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
970const patch = (oldVNode, newVNode) => {
971 const elm = (newVNode.$elm$ = oldVNode.$elm$);
972 const oldChildren = oldVNode.$children$;
973 const newChildren = newVNode.$children$;
974 const tag = newVNode.$tag$;
975 const text = newVNode.$text$;
976 let defaultHolder;
977 if (!BUILD.vdomText || text === null) {
978 if (BUILD.svg) {
979 // test if we're rendering an svg element, or still rendering nodes inside of one
980 // only add this to the when the compiler sees we're using an svg somewhere
981 isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
982 }
983 // element node
984 if (BUILD.vdomAttribute || BUILD.reflect) {
985 if (BUILD.slot && tag === 'slot')
986 ;
987 else {
988 // either this is the first render of an element OR it's an update
989 // AND we already know it's possible it could have changed
990 // this updates the element's css classes, attrs, props, listeners, etc.
991 updateElement(oldVNode, newVNode, isSvgMode);
992 }
993 }
994 if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
995 // looks like there's child vnodes for both the old and new vnodes
996 updateChildren(elm, oldChildren, newVNode, newChildren);
997 }
998 else if (newChildren !== null) {
999 // no old child vnodes, but there are new child vnodes to add
1000 if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1001 // the old vnode was text, so be sure to clear it out
1002 elm.textContent = '';
1003 }
1004 // add the new vnode children
1005 addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1006 }
1007 else if (BUILD.updatable && oldChildren !== null) {
1008 // no new child vnodes, but there are old child vnodes to remove
1009 removeVnodes(oldChildren, 0, oldChildren.length - 1);
1010 }
1011 if (BUILD.svg && isSvgMode && tag === 'svg') {
1012 isSvgMode = false;
1013 }
1014 }
1015 else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1016 // this element has slotted content
1017 defaultHolder.parentNode.textContent = text;
1018 }
1019 else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1020 // update the text content for the text only vnode
1021 // and also only if the text is different than before
1022 elm.data = text;
1023 }
1024};
1025const updateFallbackSlotVisibility = (elm) => {
1026 // tslint:disable-next-line: prefer-const
1027 let childNodes = elm.childNodes;
1028 let childNode;
1029 let i;
1030 let ilen;
1031 let j;
1032 let slotNameAttr;
1033 let nodeType;
1034 for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1035 childNode = childNodes[i];
1036 if (childNode.nodeType === 1 /* ElementNode */) {
1037 if (childNode['s-sr']) {
1038 // this is a slot fallback node
1039 // get the slot name for this slot reference node
1040 slotNameAttr = childNode['s-sn'];
1041 // by default always show a fallback slot node
1042 // then hide it if there are other slots in the light dom
1043 childNode.hidden = false;
1044 for (j = 0; j < ilen; j++) {
1045 if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
1046 // this sibling node is from a different component
1047 nodeType = childNodes[j].nodeType;
1048 if (slotNameAttr !== '') {
1049 // this is a named fallback slot node
1050 if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1051 childNode.hidden = true;
1052 break;
1053 }
1054 }
1055 else {
1056 // this is a default fallback slot node
1057 // any element or text node (with content)
1058 // should hide the default fallback slot node
1059 if (nodeType === 1 /* ElementNode */ || (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
1060 childNode.hidden = true;
1061 break;
1062 }
1063 }
1064 }
1065 }
1066 }
1067 // keep drilling down
1068 updateFallbackSlotVisibility(childNode);
1069 }
1070 }
1071};
1072const relocateNodes = [];
1073const relocateSlotContent = (elm) => {
1074 // tslint:disable-next-line: prefer-const
1075 let childNode;
1076 let node;
1077 let hostContentNodes;
1078 let slotNameAttr;
1079 let relocateNodeData;
1080 let j;
1081 let i = 0;
1082 let childNodes = elm.childNodes;
1083 let ilen = childNodes.length;
1084 for (; i < ilen; i++) {
1085 childNode = childNodes[i];
1086 if (childNode['s-sr'] && (node = childNode['s-cr'])) {
1087 // first got the content reference comment node
1088 // then we got it's parent, which is where all the host content is in now
1089 hostContentNodes = node.parentNode.childNodes;
1090 slotNameAttr = childNode['s-sn'];
1091 for (j = hostContentNodes.length - 1; j >= 0; j--) {
1092 node = hostContentNodes[j];
1093 if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1094 // let's do some relocating to its new home
1095 // but never relocate a content reference node
1096 // that is suppose to always represent the original content location
1097 if (isNodeLocatedInSlot(node, slotNameAttr)) {
1098 // it's possible we've already decided to relocate this node
1099 relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
1100 // made some changes to slots
1101 // let's make sure we also double check
1102 // fallbacks are correctly hidden or shown
1103 checkSlotFallbackVisibility = true;
1104 node['s-sn'] = node['s-sn'] || slotNameAttr;
1105 if (relocateNodeData) {
1106 // previously we never found a slot home for this node
1107 // but turns out we did, so let's remember it now
1108 relocateNodeData.$slotRefNode$ = childNode;
1109 }
1110 else {
1111 // add to our list of nodes to relocate
1112 relocateNodes.push({
1113 $slotRefNode$: childNode,
1114 $nodeToRelocate$: node,
1115 });
1116 }
1117 if (node['s-sr']) {
1118 relocateNodes.map(relocateNode => {
1119 if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1120 relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
1121 if (relocateNodeData && !relocateNode.$slotRefNode$) {
1122 relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1123 }
1124 }
1125 });
1126 }
1127 }
1128 else if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
1129 // so far this element does not have a slot home, not setting slotRefNode on purpose
1130 // if we never find a home for this element then we'll need to hide it
1131 relocateNodes.push({
1132 $nodeToRelocate$: node,
1133 });
1134 }
1135 }
1136 }
1137 }
1138 if (childNode.nodeType === 1 /* ElementNode */) {
1139 relocateSlotContent(childNode);
1140 }
1141 }
1142};
1143const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1144 if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1145 if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1146 return true;
1147 }
1148 if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1149 return true;
1150 }
1151 return false;
1152 }
1153 if (nodeToRelocate['s-sn'] === slotNameAttr) {
1154 return true;
1155 }
1156 return slotNameAttr === '';
1157};
1158const callNodeRefs = (vNode) => {
1159 if (BUILD.vdomRef) {
1160 vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1161 vNode.$children$ && vNode.$children$.map(callNodeRefs);
1162 }
1163};
1164const renderVdom = (hostRef, renderFnResults) => {
1165 const hostElm = hostRef.$hostElement$;
1166 const cmpMeta = hostRef.$cmpMeta$;
1167 const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1168 const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1169 hostTagName = hostElm.tagName;
1170 // <Host> runtime check
1171 if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1172 throw new Error(`The <Host> must be the single root component.
1173Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1174
1175The render() function should look like this instead:
1176
1177render() {
1178 // Do not return an array
1179 return (
1180 <Host>{content}</Host>
1181 );
1182}
1183 `);
1184 }
1185 if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1186 rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1187 cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1188 }
1189 rootVnode.$tag$ = null;
1190 rootVnode.$flags$ |= 4 /* isHost */;
1191 hostRef.$vnode$ = rootVnode;
1192 rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1193 if (BUILD.scoped || BUILD.shadowDom) {
1194 scopeId = hostElm['s-sc'];
1195 }
1196 if (BUILD.slotRelocation) {
1197 contentRef = hostElm['s-cr'];
1198 useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1199 // always reset
1200 checkSlotFallbackVisibility = false;
1201 }
1202 // synchronous patch
1203 patch(oldVNode, rootVnode);
1204 if (BUILD.slotRelocation) {
1205 // while we're moving nodes around existing nodes, temporarily disable
1206 // the disconnectCallback from working
1207 plt.$flags$ |= 1 /* isTmpDisconnected */;
1208 if (checkSlotRelocate) {
1209 relocateSlotContent(rootVnode.$elm$);
1210 let relocateData;
1211 let nodeToRelocate;
1212 let orgLocationNode;
1213 let parentNodeRef;
1214 let insertBeforeNode;
1215 let refNode;
1216 let i = 0;
1217 for (; i < relocateNodes.length; i++) {
1218 relocateData = relocateNodes[i];
1219 nodeToRelocate = relocateData.$nodeToRelocate$;
1220 if (!nodeToRelocate['s-ol']) {
1221 // add a reference node marking this node's original location
1222 // keep a reference to this node for later lookups
1223 orgLocationNode = BUILD.isDebug || BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode('');
1224 orgLocationNode['s-nr'] = nodeToRelocate;
1225 nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1226 }
1227 }
1228 for (i = 0; i < relocateNodes.length; i++) {
1229 relocateData = relocateNodes[i];
1230 nodeToRelocate = relocateData.$nodeToRelocate$;
1231 if (relocateData.$slotRefNode$) {
1232 // by default we're just going to insert it directly
1233 // after the slot reference node
1234 parentNodeRef = relocateData.$slotRefNode$.parentNode;
1235 insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1236 orgLocationNode = nodeToRelocate['s-ol'];
1237 while ((orgLocationNode = orgLocationNode.previousSibling)) {
1238 refNode = orgLocationNode['s-nr'];
1239 if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1240 refNode = refNode.nextSibling;
1241 if (!refNode || !refNode['s-nr']) {
1242 insertBeforeNode = refNode;
1243 break;
1244 }
1245 }
1246 }
1247 if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
1248 // we've checked that it's worth while to relocate
1249 // since that the node to relocate
1250 // has a different next sibling or parent relocated
1251 if (nodeToRelocate !== insertBeforeNode) {
1252 if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1253 // probably a component in the index.html that doesn't have it's hostname set
1254 nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1255 }
1256 // add it back to the dom but in its new home
1257 parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1258 }
1259 }
1260 }
1261 else {
1262 // this node doesn't have a slot home to go to, so let's hide it
1263 if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1264 nodeToRelocate.hidden = true;
1265 }
1266 }
1267 }
1268 }
1269 if (checkSlotFallbackVisibility) {
1270 updateFallbackSlotVisibility(rootVnode.$elm$);
1271 }
1272 // done moving nodes around
1273 // allow the disconnect callback to work again
1274 plt.$flags$ &= ~1 /* isTmpDisconnected */;
1275 // always reset
1276 relocateNodes.length = 0;
1277 }
1278};
1279// slot comment debug nodes only created with the `--debug` flag
1280// otherwise these nodes are text nodes w/out content
1281const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1282const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})` : `[${nodeToRelocate.textContent}]`));
1283const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
1284const createEvent = (ref, name, flags) => {
1285 const elm = getElement(ref);
1286 return {
1287 emit: (detail) => {
1288 if (BUILD.isDev && !elm.isConnected) {
1289 consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1290 }
1291 return emitEvent(elm, name, {
1292 bubbles: !!(flags & 4 /* Bubbles */),
1293 composed: !!(flags & 2 /* Composed */),
1294 cancelable: !!(flags & 1 /* Cancellable */),
1295 detail,
1296 });
1297 },
1298 };
1299};
1300const emitEvent = (elm, name, opts) => {
1301 const ev = plt.ce(name, opts);
1302 elm.dispatchEvent(ev);
1303 return ev;
1304};
1305const attachToAncestor = (hostRef, ancestorComponent) => {
1306 if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1307 ancestorComponent['s-p'].push(new Promise(r => (hostRef.$onRenderResolve$ = r)));
1308 }
1309};
1310const scheduleUpdate = (hostRef, isInitialLoad) => {
1311 if (BUILD.taskQueue && BUILD.updatable) {
1312 hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1313 }
1314 if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1315 hostRef.$flags$ |= 512 /* needsRerender */;
1316 return;
1317 }
1318 attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1319 // there is no ancestorc omponent or the ancestor component
1320 // has already fired off its lifecycle update then
1321 // fire off the initial update
1322 const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1323 return BUILD.taskQueue ? writeTask(dispatch) : dispatch;
1324};
1325const dispatchHooks = (hostRef, isInitialLoad) => {
1326 const elm = hostRef.$hostElement$;
1327 const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1328 const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1329 let promise;
1330 if (isInitialLoad) {
1331 if (BUILD.lazyLoad && BUILD.hostListener) {
1332 hostRef.$flags$ |= 256 /* isListenReady */;
1333 if (hostRef.$queuedListeners$) {
1334 hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1335 hostRef.$queuedListeners$ = null;
1336 }
1337 }
1338 emitLifecycleEvent(elm, 'componentWillLoad');
1339 if (BUILD.cmpWillLoad) {
1340 promise = safeCall(instance, 'componentWillLoad');
1341 }
1342 }
1343 else {
1344 emitLifecycleEvent(elm, 'componentWillUpdate');
1345 if (BUILD.cmpWillUpdate) {
1346 promise = safeCall(instance, 'componentWillUpdate');
1347 }
1348 }
1349 emitLifecycleEvent(elm, 'componentWillRender');
1350 if (BUILD.cmpWillRender) {
1351 promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1352 }
1353 endSchedule();
1354 return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1355};
1356const updateComponent = (hostRef, instance, isInitialLoad) => {
1357 // updateComponent
1358 const elm = hostRef.$hostElement$;
1359 const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1360 const rc = elm['s-rc'];
1361 if (BUILD.style && isInitialLoad) {
1362 // DOM WRITE!
1363 attachStyles(hostRef);
1364 }
1365 const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1366 if (BUILD.isDev) {
1367 hostRef.$flags$ |= 1024 /* devOnRender */;
1368 }
1369 if (BUILD.hasRenderFn || BUILD.reflect) {
1370 if (BUILD.vdomRender || BUILD.reflect) {
1371 // looks like we've got child nodes to render into this host element
1372 // or we need to update the css class/attrs on the host element
1373 // DOM WRITE!
1374 renderVdom(hostRef, callRender(hostRef, instance));
1375 }
1376 else {
1377 elm.textContent = callRender(hostRef, instance);
1378 }
1379 }
1380 if (BUILD.cssVarShim && plt.$cssShim$) {
1381 plt.$cssShim$.updateHost(elm);
1382 }
1383 if (BUILD.isDev) {
1384 hostRef.$renderCount$++;
1385 hostRef.$flags$ &= ~1024 /* devOnRender */;
1386 }
1387 if (BUILD.hydrateServerSide) {
1388 try {
1389 // manually connected child components during server-side hydrate
1390 serverSideConnected(elm);
1391 if (isInitialLoad) {
1392 // using only during server-side hydrate
1393 if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
1394 elm['s-en'] = '';
1395 }
1396 else if (hostRef.$cmpMeta$.$flags$ & 2 /* scopedCssEncapsulation */) {
1397 elm['s-en'] = 'c';
1398 }
1399 }
1400 }
1401 catch (e) {
1402 consoleError(e);
1403 }
1404 }
1405 if (BUILD.asyncLoading && rc) {
1406 // ok, so turns out there are some child host elements
1407 // waiting on this parent element to load
1408 // let's fire off all update callbacks waiting
1409 rc.map(cb => cb());
1410 elm['s-rc'] = undefined;
1411 }
1412 endRender();
1413 endUpdate();
1414 if (BUILD.asyncLoading) {
1415 const childrenPromises = elm['s-p'];
1416 const postUpdate = () => postUpdateComponent(hostRef);
1417 if (childrenPromises.length === 0) {
1418 postUpdate();
1419 }
1420 else {
1421 Promise.all(childrenPromises).then(postUpdate);
1422 hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1423 childrenPromises.length = 0;
1424 }
1425 }
1426 else {
1427 postUpdateComponent(hostRef);
1428 }
1429};
1430const callRender = (hostRef, instance) => {
1431 // in order for bundlers to correctly treeshake the BUILD object
1432 // we need to ensure BUILD is not deoptimized within a try/catch
1433 // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1434 const allRenderFn = BUILD.allRenderFn ? true : false;
1435 const lazyLoad = BUILD.lazyLoad ? true : false;
1436 const taskQueue = BUILD.taskQueue ? true : false;
1437 const updatable = BUILD.updatable ? true : false;
1438 try {
1439 renderingRef = instance;
1440 instance = allRenderFn ? instance.render() : instance.render && instance.render();
1441 if (updatable && taskQueue) {
1442 hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1443 }
1444 if (updatable || lazyLoad) {
1445 hostRef.$flags$ |= 2 /* hasRendered */;
1446 }
1447 }
1448 catch (e) {
1449 consoleError(e);
1450 }
1451 renderingRef = null;
1452 return instance;
1453};
1454const getRenderingRef = () => renderingRef;
1455const postUpdateComponent = (hostRef) => {
1456 const tagName = hostRef.$cmpMeta$.$tagName$;
1457 const elm = hostRef.$hostElement$;
1458 const endPostUpdate = createTime('postUpdate', tagName);
1459 const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1460 const ancestorComponent = hostRef.$ancestorComponent$;
1461 if (BUILD.cmpDidRender) {
1462 if (BUILD.isDev) {
1463 hostRef.$flags$ |= 1024 /* devOnRender */;
1464 }
1465 safeCall(instance, 'componentDidRender');
1466 if (BUILD.isDev) {
1467 hostRef.$flags$ &= ~1024 /* devOnRender */;
1468 }
1469 }
1470 emitLifecycleEvent(elm, 'componentDidRender');
1471 if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1472 hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1473 if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1474 // DOM WRITE!
1475 addHydratedFlag(elm);
1476 }
1477 if (BUILD.cmpDidLoad) {
1478 if (BUILD.isDev) {
1479 hostRef.$flags$ |= 2048 /* devOnDidLoad */;
1480 }
1481 safeCall(instance, 'componentDidLoad');
1482 if (BUILD.isDev) {
1483 hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
1484 }
1485 }
1486 emitLifecycleEvent(elm, 'componentDidLoad');
1487 endPostUpdate();
1488 if (BUILD.asyncLoading) {
1489 hostRef.$onReadyResolve$(elm);
1490 if (!ancestorComponent) {
1491 appDidLoad(tagName);
1492 }
1493 }
1494 }
1495 else {
1496 if (BUILD.cmpDidUpdate) {
1497 // we've already loaded this component
1498 // fire off the user's componentDidUpdate method (if one was provided)
1499 // componentDidUpdate runs AFTER render() has been called
1500 // and all child components have finished updating
1501 if (BUILD.isDev) {
1502 hostRef.$flags$ |= 1024 /* devOnRender */;
1503 }
1504 safeCall(instance, 'componentDidUpdate');
1505 if (BUILD.isDev) {
1506 hostRef.$flags$ &= ~1024 /* devOnRender */;
1507 }
1508 }
1509 emitLifecycleEvent(elm, 'componentDidUpdate');
1510 endPostUpdate();
1511 }
1512 if (BUILD.hotModuleReplacement) {
1513 elm['s-hmr-load'] && elm['s-hmr-load']();
1514 }
1515 if (BUILD.method && BUILD.lazyLoad) {
1516 hostRef.$onInstanceResolve$(elm);
1517 }
1518 // load events fire from bottom to top
1519 // the deepest elements load first then bubbles up
1520 if (BUILD.asyncLoading) {
1521 if (hostRef.$onRenderResolve$) {
1522 hostRef.$onRenderResolve$();
1523 hostRef.$onRenderResolve$ = undefined;
1524 }
1525 if (hostRef.$flags$ & 512 /* needsRerender */) {
1526 nextTick(() => scheduleUpdate(hostRef, false));
1527 }
1528 hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1529 }
1530 // ( •_•)
1531 // ( •_•)>⌐■-■
1532 // (⌐■_■)
1533};
1534const forceUpdate = (ref) => {
1535 if (BUILD.updatable) {
1536 const hostRef = getHostRef(ref);
1537 const isConnected = hostRef.$hostElement$.isConnected;
1538 if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1539 scheduleUpdate(hostRef, false);
1540 }
1541 // Returns "true" when the forced update was successfully scheduled
1542 return isConnected;
1543 }
1544 return false;
1545};
1546const appDidLoad = (who) => {
1547 // on appload
1548 // we have finish the first big initial render
1549 if (BUILD.cssAnnotations) {
1550 addHydratedFlag(doc.documentElement);
1551 }
1552 if (BUILD.asyncQueue) {
1553 plt.$flags$ |= 2 /* appLoaded */;
1554 }
1555 nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1556 if (BUILD.profile && performance.measure) {
1557 performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1558 }
1559};
1560const safeCall = (instance, method, arg) => {
1561 if (instance && instance[method]) {
1562 try {
1563 return instance[method](arg);
1564 }
1565 catch (e) {
1566 consoleError(e);
1567 }
1568 }
1569 return undefined;
1570};
1571const then = (promise, thenFn) => {
1572 return promise && promise.then ? promise.then(thenFn) : thenFn();
1573};
1574const emitLifecycleEvent = (elm, lifecycleName) => {
1575 if (BUILD.lifecycleDOMEvents) {
1576 emitEvent(elm, 'stencil_' + lifecycleName, {
1577 bubbles: true,
1578 composed: true,
1579 detail: {
1580 namespace: NAMESPACE,
1581 },
1582 });
1583 }
1584};
1585const addHydratedFlag = (elm) => (BUILD.hydratedClass ? elm.classList.add('hydrated') : BUILD.hydratedAttribute ? elm.setAttribute('hydrated', '') : undefined);
1586const serverSideConnected = (elm) => {
1587 const children = elm.children;
1588 if (children != null) {
1589 for (let i = 0, ii = children.length; i < ii; i++) {
1590 const childElm = children[i];
1591 if (typeof childElm.connectedCallback === 'function') {
1592 childElm.connectedCallback();
1593 }
1594 serverSideConnected(childElm);
1595 }
1596 }
1597};
1598const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1599 const endHydrate = createTime('hydrateClient', tagName);
1600 const shadowRoot = hostElm.shadowRoot;
1601 const childRenderNodes = [];
1602 const slotNodes = [];
1603 const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
1604 const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
1605 if (!plt.$orgLocNodes$) {
1606 initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
1607 }
1608 hostElm[HYDRATE_ID] = hostId;
1609 hostElm.removeAttribute(HYDRATE_ID);
1610 clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
1611 childRenderNodes.map(c => {
1612 const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
1613 const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1614 const node = c.$elm$;
1615 if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
1616 orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1617 }
1618 if (!shadowRoot) {
1619 node['s-hn'] = tagName;
1620 if (orgLocationNode) {
1621 node['s-ol'] = orgLocationNode;
1622 node['s-ol']['s-nr'] = node;
1623 }
1624 }
1625 plt.$orgLocNodes$.delete(orgLocationId);
1626 });
1627 if (BUILD.shadowDom && shadowRoot) {
1628 shadowRootNodes.map(shadowRootNode => {
1629 if (shadowRootNode) {
1630 shadowRoot.appendChild(shadowRootNode);
1631 }
1632 });
1633 }
1634 endHydrate();
1635};
1636const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
1637 let childNodeType;
1638 let childIdSplt;
1639 let childVNode;
1640 let i;
1641 if (node.nodeType === 1 /* ElementNode */) {
1642 childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1643 if (childNodeType) {
1644 // got the node data from the element's attribute
1645 // `${hostId}.${nodeId}.${depth}.${index}`
1646 childIdSplt = childNodeType.split('.');
1647 if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
1648 childVNode = {
1649 $flags$: 0,
1650 $hostId$: childIdSplt[0],
1651 $nodeId$: childIdSplt[1],
1652 $depth$: childIdSplt[2],
1653 $index$: childIdSplt[3],
1654 $tag$: node.tagName.toLowerCase(),
1655 $elm$: node,
1656 $attrs$: null,
1657 $children$: null,
1658 $key$: null,
1659 $name$: null,
1660 $text$: null,
1661 };
1662 childRenderNodes.push(childVNode);
1663 node.removeAttribute(HYDRATE_CHILD_ID);
1664 // this is a new child vnode
1665 // so ensure its parent vnode has the vchildren array
1666 if (!parentVNode.$children$) {
1667 parentVNode.$children$ = [];
1668 }
1669 // add our child vnode to a specific index of the vnode's children
1670 parentVNode.$children$[childVNode.$index$] = childVNode;
1671 // this is now the new parent vnode for all the next child checks
1672 parentVNode = childVNode;
1673 if (shadowRootNodes && childVNode.$depth$ === '0') {
1674 shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1675 }
1676 }
1677 }
1678 // recursively drill down, end to start so we can remove nodes
1679 for (i = node.childNodes.length - 1; i >= 0; i--) {
1680 clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
1681 }
1682 if (node.shadowRoot) {
1683 // keep drilling down through the shadow root nodes
1684 for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
1685 clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
1686 }
1687 }
1688 }
1689 else if (node.nodeType === 8 /* CommentNode */) {
1690 // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
1691 childIdSplt = node.nodeValue.split('.');
1692 if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
1693 // comment node for either the host id or a 0 host id
1694 childNodeType = childIdSplt[0];
1695 childVNode = {
1696 $flags$: 0,
1697 $hostId$: childIdSplt[1],
1698 $nodeId$: childIdSplt[2],
1699 $depth$: childIdSplt[3],
1700 $index$: childIdSplt[4],
1701 $elm$: node,
1702 $attrs$: null,
1703 $children$: null,
1704 $key$: null,
1705 $name$: null,
1706 $tag$: null,
1707 $text$: null,
1708 };
1709 if (childNodeType === TEXT_NODE_ID) {
1710 childVNode.$elm$ = node.nextSibling;
1711 if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1712 childVNode.$text$ = childVNode.$elm$.textContent;
1713 childRenderNodes.push(childVNode);
1714 // remove the text comment since it's no longer needed
1715 node.remove();
1716 if (!parentVNode.$children$) {
1717 parentVNode.$children$ = [];
1718 }
1719 parentVNode.$children$[childVNode.$index$] = childVNode;
1720 if (shadowRootNodes && childVNode.$depth$ === '0') {
1721 shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1722 }
1723 }
1724 }
1725 else if (childVNode.$hostId$ === hostId) {
1726 // this comment node is specifcally for this host id
1727 if (childNodeType === SLOT_NODE_ID) {
1728 // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
1729 childVNode.$tag$ = 'slot';
1730 if (childIdSplt[5]) {
1731 node['s-sn'] = childVNode.$name$ = childIdSplt[5];
1732 }
1733 else {
1734 node['s-sn'] = '';
1735 }
1736 node['s-sr'] = true;
1737 if (BUILD.shadowDom && shadowRootNodes) {
1738 // browser support shadowRoot and this is a shadow dom component
1739 // create an actual slot element
1740 childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1741 if (childVNode.$name$) {
1742 // add the slot name attribute
1743 childVNode.$elm$.setAttribute('name', childVNode.$name$);
1744 }
1745 // insert the new slot element before the slot comment
1746 node.parentNode.insertBefore(childVNode.$elm$, node);
1747 // remove the slot comment since it's not needed for shadow
1748 node.remove();
1749 if (childVNode.$depth$ === '0') {
1750 shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1751 }
1752 }
1753 slotNodes.push(childVNode);
1754 if (!parentVNode.$children$) {
1755 parentVNode.$children$ = [];
1756 }
1757 parentVNode.$children$[childVNode.$index$] = childVNode;
1758 }
1759 else if (childNodeType === CONTENT_REF_ID) {
1760 // `${CONTENT_REF_ID}.${hostId}`;
1761 if (BUILD.shadowDom && shadowRootNodes) {
1762 // remove the content ref comment since it's not needed for shadow
1763 node.remove();
1764 }
1765 else if (BUILD.slotRelocation) {
1766 hostElm['s-cr'] = node;
1767 node['s-cn'] = true;
1768 }
1769 }
1770 }
1771 }
1772 }
1773 else if (parentVNode && parentVNode.$tag$ === 'style') {
1774 const vnode = newVNode(null, node.textContent);
1775 vnode.$elm$ = node;
1776 vnode.$index$ = '0';
1777 parentVNode.$children$ = [vnode];
1778 }
1779};
1780const initializeDocumentHydrate = (node, orgLocNodes) => {
1781 if (node.nodeType === 1 /* ElementNode */) {
1782 let i = 0;
1783 for (; i < node.childNodes.length; i++) {
1784 initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
1785 }
1786 if (node.shadowRoot) {
1787 for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
1788 initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
1789 }
1790 }
1791 }
1792 else if (node.nodeType === 8 /* CommentNode */) {
1793 const childIdSplt = node.nodeValue.split('.');
1794 if (childIdSplt[0] === ORG_LOCATION_ID) {
1795 orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
1796 node.nodeValue = '';
1797 // useful to know if the original location is
1798 // the root light-dom of a shadow dom component
1799 node['s-en'] = childIdSplt[3];
1800 }
1801 }
1802};
1803const parsePropertyValue = (propValue, propType) => {
1804 // ensure this value is of the correct prop type
1805 if (propValue != null && !isComplexType(propValue)) {
1806 if (BUILD.propBoolean && propType & 4 /* Boolean */) {
1807 // per the HTML spec, any string value means it is a boolean true value
1808 // but we'll cheat here and say that the string "false" is the boolean false
1809 return propValue === 'false' ? false : propValue === '' || !!propValue;
1810 }
1811 if (BUILD.propNumber && propType & 2 /* Number */) {
1812 // force it to be a number
1813 return parseFloat(propValue);
1814 }
1815 if (BUILD.propString && propType & 1 /* String */) {
1816 // could have been passed as a number or boolean
1817 // but we still want it as a string
1818 return String(propValue);
1819 }
1820 // redundant return here for better minification
1821 return propValue;
1822 }
1823 // not sure exactly what type we want
1824 // so no need to change to a different type
1825 return propValue;
1826};
1827const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1828const setValue = (ref, propName, newVal, cmpMeta) => {
1829 // check our new property value against our internal value
1830 const hostRef = getHostRef(ref);
1831 const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1832 const oldVal = hostRef.$instanceValues$.get(propName);
1833 const flags = hostRef.$flags$;
1834 const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1835 newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1836 if ((!BUILD.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1837 // gadzooks! the property's value has changed!!
1838 // set our new value!
1839 hostRef.$instanceValues$.set(propName, newVal);
1840 if (BUILD.isDev) {
1841 if (hostRef.$flags$ & 1024 /* devOnRender */) {
1842 consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
1843 }
1844 else if (hostRef.$flags$ & 2048 /* devOnDidLoad */) {
1845 consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
1846 }
1847 }
1848 if (!BUILD.lazyLoad || instance) {
1849 // get an array of method names of watch functions to call
1850 if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1851 const watchMethods = cmpMeta.$watchers$[propName];
1852 if (watchMethods) {
1853 // this instance is watching for when this property changed
1854 watchMethods.map(watchMethodName => {
1855 try {
1856 // fire off each of the watch methods that are watching this property
1857 instance[watchMethodName](newVal, oldVal, propName);
1858 }
1859 catch (e) {
1860 consoleError(e);
1861 }
1862 });
1863 }
1864 }
1865 if (BUILD.updatable && (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1866 if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1867 if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1868 return;
1869 }
1870 }
1871 // looks like this value actually changed, so we've got work to do!
1872 // but only if we've already rendered, otherwise just chill out
1873 // queue that we need to do an update, but don't worry about queuing
1874 // up millions cuz this function ensures it only runs once
1875 scheduleUpdate(hostRef, false);
1876 }
1877 }
1878 }
1879};
1880const proxyComponent = (Cstr, cmpMeta, flags) => {
1881 if (BUILD.member && cmpMeta.$members$) {
1882 if (BUILD.watchCallback && Cstr.watchers) {
1883 cmpMeta.$watchers$ = Cstr.watchers;
1884 }
1885 // It's better to have a const than two Object.entries()
1886 const members = Object.entries(cmpMeta.$members$);
1887 const prototype = Cstr.prototype;
1888 members.map(([memberName, [memberFlags]]) => {
1889 if ((BUILD.prop || BUILD.state) && (memberFlags & 31 /* Prop */ || ((!BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1890 // proxyComponent - prop
1891 Object.defineProperty(prototype, memberName, {
1892 get() {
1893 // proxyComponent, get value
1894 return getValue(this, memberName);
1895 },
1896 set(newValue) {
1897 if (
1898 // only during dev time
1899 BUILD.isDev &&
1900 // we are proxing the instance (not element)
1901 (flags & 1 /* isElementConstructor */) === 0 &&
1902 // the member is a non-mutable prop
1903 (memberFlags & (31 /* Prop */ | 1024 /* Mutable */)) === 31 /* Prop */) {
1904 consoleDevWarn(`@Prop() "${memberName}" on "${cmpMeta.$tagName$}" cannot be modified.\nFurther information: https://stenciljs.com/docs/properties#prop-mutability`);
1905 }
1906 // proxyComponent, set value
1907 setValue(this, memberName, newValue, cmpMeta);
1908 },
1909 configurable: true,
1910 enumerable: true,
1911 });
1912 }
1913 else if (BUILD.lazyLoad && BUILD.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
1914 // proxyComponent - method
1915 Object.defineProperty(prototype, memberName, {
1916 value(...args) {
1917 const ref = getHostRef(this);
1918 return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1919 },
1920 });
1921 }
1922 });
1923 if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* isElementConstructor */)) {
1924 const attrNameToPropName = new Map();
1925 prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1926 plt.jmp(() => {
1927 const propName = attrNameToPropName.get(attrName);
1928 this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1929 });
1930 };
1931 // create an array of attributes to observe
1932 // and also create a map of html attribute name to js property name
1933 Cstr.observedAttributes = members
1934 .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1935 .map(([propName, m]) => {
1936 const attrName = m[1] || propName;
1937 attrNameToPropName.set(attrName, propName);
1938 if (BUILD.reflect && m[0] & 512 /* ReflectAttr */) {
1939 cmpMeta.$attrsToReflect$.push([propName, attrName]);
1940 }
1941 return attrName;
1942 });
1943 }
1944 }
1945 return Cstr;
1946};
1947const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1948 // initializeComponent
1949 if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) && (hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1950 if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
1951 // we haven't initialized this element yet
1952 hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1953 // lazy loaded components
1954 // request the component's implementation to be
1955 // wired up with the host element
1956 Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
1957 if (Cstr.then) {
1958 // Await creates a micro-task avoid if possible
1959 const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
1960 Cstr = await Cstr;
1961 endLoad();
1962 }
1963 if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
1964 throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
1965 }
1966 if (BUILD.member && !Cstr.isProxied) {
1967 // we'eve never proxied this Constructor before
1968 // let's add the getters/setters to its prototype before
1969 // the first time we create an instance of the implementation
1970 if (BUILD.watchCallback) {
1971 cmpMeta.$watchers$ = Cstr.watchers;
1972 }
1973 proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1974 Cstr.isProxied = true;
1975 }
1976 const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1977 // ok, time to construct the instance
1978 // but let's keep track of when we start and stop
1979 // so that the getters/setters don't incorrectly step on data
1980 if (BUILD.member) {
1981 hostRef.$flags$ |= 8 /* isConstructingInstance */;
1982 }
1983 // construct the lazy-loaded component implementation
1984 // passing the hostRef is very important during
1985 // construction in order to directly wire together the
1986 // host element and the lazy-loaded instance
1987 try {
1988 new Cstr(hostRef);
1989 }
1990 catch (e) {
1991 consoleError(e);
1992 }
1993 if (BUILD.member) {
1994 hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1995 }
1996 if (BUILD.watchCallback) {
1997 hostRef.$flags$ |= 128 /* isWatchReady */;
1998 }
1999 endNewInstance();
2000 fireConnectedCallback(hostRef.$lazyInstance$);
2001 }
2002 else {
2003 // sync constructor component
2004 Cstr = elm.constructor;
2005 hostRef.$flags$ |= 128 /* isWatchReady */ | 32 /* hasInitializedComponent */;
2006 }
2007 if (BUILD.style && Cstr.style) {
2008 // this component has styles but we haven't registered them yet
2009 let style = Cstr.style;
2010 if (BUILD.mode && typeof style !== 'string') {
2011 style = style[(hostRef.$modeName$ = computeMode(elm))];
2012 if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2013 elm.setAttribute('s-mode', hostRef.$modeName$);
2014 }
2015 }
2016 const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
2017 if (!styles.has(scopeId)) {
2018 const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2019 if (!BUILD.hydrateServerSide && BUILD.shadowDom && BUILD.shadowDomShim && cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2020 style = await Promise.resolve().then(function () { return require('./shadow-css-7d1bc869.js'); }).then(m => m.scopeCss(style, scopeId, false));
2021 }
2022 registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
2023 endRegisterStyles();
2024 }
2025 }
2026 }
2027 // we've successfully created a lazy instance
2028 const ancestorComponent = hostRef.$ancestorComponent$;
2029 const schedule = () => scheduleUpdate(hostRef, true);
2030 if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
2031 // this is the intial load and this component it has an ancestor component
2032 // but the ancestor component has NOT fired its will update lifecycle yet
2033 // so let's just cool our jets and wait for the ancestor to continue first
2034 // this will get fired off when the ancestor component
2035 // finally gets around to rendering its lazy self
2036 // fire off the initial update
2037 ancestorComponent['s-rc'].push(schedule);
2038 }
2039 else {
2040 schedule();
2041 }
2042};
2043const fireConnectedCallback = (instance) => {
2044 if (BUILD.lazyLoad && BUILD.connectedCallback) {
2045 safeCall(instance, 'connectedCallback');
2046 }
2047};
2048const connectedCallback = (elm) => {
2049 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2050 const hostRef = getHostRef(elm);
2051 const cmpMeta = hostRef.$cmpMeta$;
2052 const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2053 if (BUILD.hostListenerTargetParent) {
2054 // only run if we have listeners being attached to a parent
2055 addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2056 }
2057 if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
2058 // first time this component has connected
2059 hostRef.$flags$ |= 1 /* hasConnected */;
2060 let hostId;
2061 if (BUILD.hydrateClientSide) {
2062 hostId = elm.getAttribute(HYDRATE_ID);
2063 if (hostId) {
2064 if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2065 const scopeId = BUILD.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode')) : addStyle(elm.shadowRoot, cmpMeta);
2066 elm.classList.remove(scopeId + '-h', scopeId + '-s');
2067 }
2068 initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2069 }
2070 }
2071 if (BUILD.slotRelocation && !hostId) {
2072 // initUpdate
2073 // if the slot polyfill is required we'll need to put some nodes
2074 // in here to act as original content anchors as we move nodes around
2075 // host element has been connected to the DOM
2076 if (BUILD.hydrateServerSide || ((BUILD.slot || BUILD.shadowDom) && cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
2077 setContentReference(elm);
2078 }
2079 }
2080 if (BUILD.asyncLoading) {
2081 // find the first ancestor component (if there is one) and register
2082 // this component as one of the actively loading child components for its ancestor
2083 let ancestorComponent = elm;
2084 while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2085 // climb up the ancestors looking for the first
2086 // component that hasn't finished its lifecycle update yet
2087 if ((BUILD.hydrateClientSide && ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute('s-id') && ancestorComponent['s-p']) ||
2088 ancestorComponent['s-p']) {
2089 // we found this components first ancestor component
2090 // keep a reference to this component's ancestor component
2091 attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2092 break;
2093 }
2094 }
2095 }
2096 // Lazy properties
2097 // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2098 if (BUILD.prop && BUILD.lazyLoad && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2099 Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2100 if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
2101 const value = elm[memberName];
2102 delete elm[memberName];
2103 elm[memberName] = value;
2104 }
2105 });
2106 }
2107 if (BUILD.initializeNextTick) {
2108 // connectedCallback, taskQueue, initialLoad
2109 // angular sets attribute AFTER connectCallback
2110 // https://github.com/angular/angular/issues/18909
2111 // https://github.com/angular/angular/issues/19940
2112 nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2113 }
2114 else {
2115 initializeComponent(elm, hostRef, cmpMeta);
2116 }
2117 }
2118 else {
2119 // not the first time this has connected
2120 // reattach any event listeners to the host
2121 // since they would have been removed when disconnected
2122 addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2123 // fire off connectedCallback() on component instance
2124 fireConnectedCallback(hostRef.$lazyInstance$);
2125 }
2126 endConnected();
2127 }
2128};
2129const setContentReference = (elm) => {
2130 // only required when we're NOT using native shadow dom (slot)
2131 // or this browser doesn't support native shadow dom
2132 // and this host element was NOT created with SSR
2133 // let's pick out the inner content for slot projection
2134 // create a node to represent where the original
2135 // content was first placed, which is useful later on
2136 const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
2137 contentRefElm['s-cn'] = true;
2138 elm.insertBefore(contentRefElm, elm.firstChild);
2139};
2140const disconnectedCallback = (elm) => {
2141 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2142 const hostRef = getHostRef(elm);
2143 const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2144 if (BUILD.hostListener) {
2145 if (hostRef.$rmListeners$) {
2146 hostRef.$rmListeners$.map(rmListener => rmListener());
2147 hostRef.$rmListeners$ = undefined;
2148 }
2149 }
2150 // clear CSS var-shim tracking
2151 if (BUILD.cssVarShim && plt.$cssShim$) {
2152 plt.$cssShim$.removeHost(elm);
2153 }
2154 if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2155 safeCall(instance, 'disconnectedCallback');
2156 }
2157 if (BUILD.cmpDidUnload) {
2158 safeCall(instance, 'componentDidUnload');
2159 }
2160 }
2161};
2162const defineCustomElement = (Cstr, compactMeta) => {
2163 customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2164};
2165const proxyCustomElement = (Cstr, compactMeta) => {
2166 const cmpMeta = {
2167 $flags$: compactMeta[0],
2168 $tagName$: compactMeta[1],
2169 };
2170 if (BUILD.member) {
2171 cmpMeta.$members$ = compactMeta[2];
2172 }
2173 if (BUILD.hostListener) {
2174 cmpMeta.$listeners$ = compactMeta[3];
2175 }
2176 if (BUILD.watchCallback) {
2177 cmpMeta.$watchers$ = Cstr.$watchers$;
2178 }
2179 if (BUILD.reflect) {
2180 cmpMeta.$attrsToReflect$ = [];
2181 }
2182 if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2183 cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2184 }
2185 const originalConnectedCallback = Cstr.prototype.connectedCallback;
2186 const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2187 Object.assign(Cstr.prototype, {
2188 __registerHost() {
2189 registerHost(this, cmpMeta);
2190 },
2191 connectedCallback() {
2192 connectedCallback(this);
2193 if (BUILD.connectedCallback && originalConnectedCallback) {
2194 originalConnectedCallback.call(this);
2195 }
2196 },
2197 disconnectedCallback() {
2198 disconnectedCallback(this);
2199 if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2200 originalDisconnectedCallback.call(this);
2201 }
2202 },
2203 });
2204 Cstr.is = cmpMeta.$tagName$;
2205 return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2206};
2207const forceModeUpdate = (elm) => {
2208 if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2209 const mode = computeMode(elm);
2210 const hostRef = getHostRef(elm);
2211 if (hostRef.$modeName$ !== mode) {
2212 const cmpMeta = hostRef.$cmpMeta$;
2213 const oldScopeId = elm['s-sc'];
2214 const scopeId = getScopeId(cmpMeta, mode);
2215 const style = elm.constructor.style[mode];
2216 const flags = cmpMeta.$flags$;
2217 if (style) {
2218 if (!styles.has(scopeId)) {
2219 registerStyle(scopeId, style, !!(flags & 1 /* shadowDomEncapsulation */));
2220 }
2221 hostRef.$modeName$ = mode;
2222 elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2223 attachStyles(hostRef);
2224 forceUpdate(elm);
2225 }
2226 }
2227 }
2228};
2229const attachShadow = (el) => {
2230 if (supportsShadow) {
2231 el.attachShadow({ mode: 'open' });
2232 }
2233 else {
2234 el.shadowRoot = el;
2235 }
2236};
2237const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2238 // ¯\_(ツ)_/¯
2239 const hostRef = getHostRef(elm);
2240 // reset state flags to only have been connected
2241 hostRef.$flags$ = 1 /* hasConnected */;
2242 // TODO
2243 // detatch any event listeners that may have been added
2244 // because we're not passing an exact event name it'll
2245 // remove all of this element's event, which is good
2246 // create a callback for when this component finishes hmr
2247 elm['s-hmr-load'] = () => {
2248 // finished hmr for this element
2249 delete elm['s-hmr-load'];
2250 };
2251 // re-initialize the component
2252 initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2253};
2254const patchCloneNode = (HostElementPrototype) => {
2255 const orgCloneNode = HostElementPrototype.cloneNode;
2256 HostElementPrototype.cloneNode = function (deep) {
2257 const srcNode = this;
2258 const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2259 const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2260 if (BUILD.slot && !isShadowDom && deep) {
2261 let i = 0;
2262 let slotted;
2263 for (; i < srcNode.childNodes.length; i++) {
2264 slotted = srcNode.childNodes[i]['s-nr'];
2265 if (slotted) {
2266 if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2267 clonedNode.__appendChild(slotted.cloneNode(true));
2268 }
2269 else {
2270 clonedNode.appendChild(slotted.cloneNode(true));
2271 }
2272 }
2273 }
2274 }
2275 return clonedNode;
2276 };
2277};
2278const patchSlotAppendChild = (HostElementPrototype) => {
2279 HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2280 HostElementPrototype.appendChild = function (newChild) {
2281 const slotName = (newChild['s-sn'] = getSlotName(newChild));
2282 const slotNode = getHostSlotNode(this.childNodes, slotName);
2283 if (slotNode) {
2284 const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2285 const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2286 return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2287 }
2288 return this.__appendChild(newChild);
2289 };
2290};
2291const patchChildSlotNodes = (elm, cmpMeta) => {
2292 class FakeNodeList extends Array {
2293 item(n) {
2294 return this[n];
2295 }
2296 }
2297 if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2298 const childNodesFn = elm.__lookupGetter__('childNodes');
2299 Object.defineProperty(elm, 'children', {
2300 get() {
2301 return this.childNodes.map((n) => n.nodeType === 1);
2302 },
2303 });
2304 Object.defineProperty(elm, 'childElementCount', {
2305 get() {
2306 return elm.children.length;
2307 },
2308 });
2309 Object.defineProperty(elm, 'childNodes', {
2310 get() {
2311 const childNodes = childNodesFn.call(this);
2312 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 && getHostRef(this).$flags$ & 2 /* hasRendered */) {
2313 const result = new FakeNodeList();
2314 for (let i = 0; i < childNodes.length; i++) {
2315 const slot = childNodes[i]['s-nr'];
2316 if (slot) {
2317 result.push(slot);
2318 }
2319 }
2320 return result;
2321 }
2322 return FakeNodeList.from(childNodes);
2323 },
2324 });
2325 }
2326};
2327const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2328const getHostSlotNode = (childNodes, slotName) => {
2329 let i = 0;
2330 let childNode;
2331 for (; i < childNodes.length; i++) {
2332 childNode = childNodes[i];
2333 if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2334 return childNode;
2335 }
2336 childNode = getHostSlotNode(childNode.childNodes, slotName);
2337 if (childNode) {
2338 return childNode;
2339 }
2340 }
2341 return null;
2342};
2343const getHostSlotChildNodes = (n, slotName) => {
2344 const childNodes = [n];
2345 while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2346 childNodes.push(n);
2347 }
2348 return childNodes;
2349};
2350const bootstrapLazy = (lazyBundles, options = {}) => {
2351 if (BUILD.profile && performance.mark) {
2352 performance.mark('st:app:start');
2353 }
2354 installDevTools();
2355 const endBootstrap = createTime('bootstrapLazy');
2356 const cmpTags = [];
2357 const exclude = options.exclude || [];
2358 const customElements = win.customElements;
2359 const head = doc.head;
2360 const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2361 const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
2362 const deferredConnectedCallbacks = [];
2363 const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2364 let appLoadFallback;
2365 let isBootstrapping = true;
2366 let i = 0;
2367 Object.assign(plt, options);
2368 plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2369 if (BUILD.asyncQueue) {
2370 if (options.syncQueue) {
2371 plt.$flags$ |= 4 /* queueSync */;
2372 }
2373 }
2374 if (BUILD.hydrateClientSide) {
2375 // If the app is already hydrated there is not point to disable the
2376 // async queue. This will improve the first input delay
2377 plt.$flags$ |= 2 /* appLoaded */;
2378 }
2379 if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2380 for (; i < styles.length; i++) {
2381 registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2382 }
2383 }
2384 lazyBundles.map(lazyBundle => lazyBundle[1].map(compactMeta => {
2385 const cmpMeta = {
2386 $flags$: compactMeta[0],
2387 $tagName$: compactMeta[1],
2388 $members$: compactMeta[2],
2389 $listeners$: compactMeta[3],
2390 };
2391 if (BUILD.member) {
2392 cmpMeta.$members$ = compactMeta[2];
2393 }
2394 if (BUILD.hostListener) {
2395 cmpMeta.$listeners$ = compactMeta[3];
2396 }
2397 if (BUILD.reflect) {
2398 cmpMeta.$attrsToReflect$ = [];
2399 }
2400 if (BUILD.watchCallback) {
2401 cmpMeta.$watchers$ = {};
2402 }
2403 if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2404 cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2405 }
2406 const tagName = BUILD.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : cmpMeta.$tagName$;
2407 const HostElement = class extends HTMLElement {
2408 // StencilLazyHost
2409 constructor(self) {
2410 // @ts-ignore
2411 super(self);
2412 self = this;
2413 registerHost(self, cmpMeta);
2414 if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2415 // this component is using shadow dom
2416 // and this browser supports shadow dom
2417 // add the read-only property "shadowRoot" to the host element
2418 // adding the shadow root build conditionals to minimize runtime
2419 if (supportsShadow) {
2420 if (BUILD.shadowDelegatesFocus) {
2421 self.attachShadow({
2422 mode: 'open',
2423 delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2424 });
2425 }
2426 else {
2427 self.attachShadow({ mode: 'open' });
2428 }
2429 }
2430 else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2431 self.shadowRoot = self;
2432 }
2433 }
2434 if (BUILD.slotChildNodesFix) {
2435 patchChildSlotNodes(self, cmpMeta);
2436 }
2437 }
2438 connectedCallback() {
2439 if (appLoadFallback) {
2440 clearTimeout(appLoadFallback);
2441 appLoadFallback = null;
2442 }
2443 if (isBootstrapping) {
2444 // connectedCallback will be processed once all components have been registered
2445 deferredConnectedCallbacks.push(this);
2446 }
2447 else {
2448 plt.jmp(() => connectedCallback(this));
2449 }
2450 }
2451 disconnectedCallback() {
2452 plt.jmp(() => disconnectedCallback(this));
2453 }
2454 forceUpdate() {
2455 if (BUILD.isDev) {
2456 consoleDevWarn(`element.forceUpdate() is deprecated, use the "forceUpdate" function from "@stencil/core" instead:
2457
2458 import { forceUpdate } from ‘@stencil/core’;
2459
2460 forceUpdate(this);
2461 forceUpdate(element);`);
2462 }
2463 forceUpdate(this);
2464 }
2465 componentOnReady() {
2466 return getHostRef(this).$onReadyPromise$;
2467 }
2468 };
2469 if (BUILD.cloneNodeFix) {
2470 patchCloneNode(HostElement.prototype);
2471 }
2472 if (BUILD.appendChildSlotFix) {
2473 patchSlotAppendChild(HostElement.prototype);
2474 }
2475 if (BUILD.hotModuleReplacement) {
2476 HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2477 hmrStart(this, cmpMeta, hmrVersionId);
2478 };
2479 }
2480 cmpMeta.$lazyBundleId$ = lazyBundle[0];
2481 if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2482 cmpTags.push(tagName);
2483 customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
2484 }
2485 }));
2486 if (BUILD.hydratedClass || BUILD.hydratedAttribute) {
2487 visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2488 visibilityStyle.setAttribute('data-styles', '');
2489 head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2490 }
2491 // Process deferred connectedCallbacks now all components have been registered
2492 isBootstrapping = false;
2493 if (deferredConnectedCallbacks.length) {
2494 deferredConnectedCallbacks.map(host => host.connectedCallback());
2495 }
2496 else {
2497 if (BUILD.profile) {
2498 plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2499 }
2500 else {
2501 plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2502 }
2503 }
2504 // Fallback appLoad event
2505 endBootstrap();
2506};
2507const getAssetPath = (path) => {
2508 const assetUrl = new URL(path, plt.$resourcesUrl$);
2509 return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
2510};
2511const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
2512const getConnect = (_ref, tagName) => {
2513 const componentOnReady = () => {
2514 let elm = doc.querySelector(tagName);
2515 if (!elm) {
2516 elm = doc.createElement(tagName);
2517 doc.body.appendChild(elm);
2518 }
2519 return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2520 };
2521 const create = (...args) => {
2522 return componentOnReady().then(el => el.create(...args));
2523 };
2524 return {
2525 create,
2526 componentOnReady,
2527 };
2528};
2529const getContext = (_elm, context) => {
2530 if (context in Context) {
2531 return Context[context];
2532 }
2533 else if (context === 'window') {
2534 return win;
2535 }
2536 else if (context === 'document') {
2537 return doc;
2538 }
2539 else if (context === 'isServer' || context === 'isPrerender') {
2540 return BUILD.hydrateServerSide ? true : false;
2541 }
2542 else if (context === 'isClient') {
2543 return BUILD.hydrateServerSide ? false : true;
2544 }
2545 else if (context === 'resourcesUrl' || context === 'publicPath') {
2546 return getAssetPath('.');
2547 }
2548 else if (context === 'queue') {
2549 return {
2550 write: writeTask,
2551 read: readTask,
2552 tick: {
2553 then(cb) {
2554 return nextTick(cb);
2555 },
2556 },
2557 };
2558 }
2559 return undefined;
2560};
2561const insertVdomAnnotations = (doc, staticComponents) => {
2562 if (doc != null) {
2563 const docData = {
2564 hostIds: 0,
2565 rootLevelIds: 0,
2566 staticComponents: new Set(staticComponents),
2567 };
2568 const orgLocationNodes = [];
2569 parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
2570 orgLocationNodes.forEach(orgLocationNode => {
2571 if (orgLocationNode != null) {
2572 const nodeRef = orgLocationNode['s-nr'];
2573 let hostId = nodeRef['s-host-id'];
2574 let nodeId = nodeRef['s-node-id'];
2575 let childId = `${hostId}.${nodeId}`;
2576 if (hostId == null) {
2577 hostId = 0;
2578 docData.rootLevelIds++;
2579 nodeId = docData.rootLevelIds;
2580 childId = `${hostId}.${nodeId}`;
2581 if (nodeRef.nodeType === 1 /* ElementNode */) {
2582 nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2583 }
2584 else if (nodeRef.nodeType === 3 /* TextNode */) {
2585 if (hostId === 0) {
2586 const textContent = nodeRef.nodeValue.trim();
2587 if (textContent === '') {
2588 // useless whitespace node at the document root
2589 orgLocationNode.remove();
2590 return;
2591 }
2592 }
2593 const commentBeforeTextNode = doc.createComment(childId);
2594 commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2595 nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
2596 }
2597 }
2598 let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
2599 const orgLocationParentNode = orgLocationNode.parentElement;
2600 if (orgLocationParentNode) {
2601 if (orgLocationParentNode['s-en'] === '') {
2602 // ending with a "." means that the parent element
2603 // of this node's original location is a SHADOW dom element
2604 // and this node is apart of the root level light dom
2605 orgLocationNodeId += `.`;
2606 }
2607 else if (orgLocationParentNode['s-en'] === 'c') {
2608 // ending with a ".c" means that the parent element
2609 // of this node's original location is a SCOPED element
2610 // and this node is apart of the root level light dom
2611 orgLocationNodeId += `.c`;
2612 }
2613 }
2614 orgLocationNode.nodeValue = orgLocationNodeId;
2615 }
2616 });
2617 }
2618};
2619const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
2620 if (node == null) {
2621 return;
2622 }
2623 if (node['s-nr'] != null) {
2624 orgLocationNodes.push(node);
2625 }
2626 if (node.nodeType === 1 /* ElementNode */) {
2627 node.childNodes.forEach(childNode => {
2628 const hostRef = getHostRef(childNode);
2629 if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
2630 const cmpData = {
2631 nodeIds: 0,
2632 };
2633 insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
2634 }
2635 parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
2636 });
2637 }
2638};
2639const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
2640 if (vnode != null) {
2641 const hostId = ++docData.hostIds;
2642 hostElm.setAttribute(HYDRATE_ID, hostId);
2643 if (hostElm['s-cr'] != null) {
2644 hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
2645 }
2646 if (vnode.$children$ != null) {
2647 const depth = 0;
2648 vnode.$children$.forEach((vnodeChild, index) => {
2649 insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
2650 });
2651 }
2652 if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
2653 const parent = hostElm.parentElement;
2654 if (parent && parent.childNodes) {
2655 const parentChildNodes = Array.from(parent.childNodes);
2656 const comment = parentChildNodes.find(node => node.nodeType === 8 /* CommentNode */ && node['s-sr']);
2657 if (comment) {
2658 const index = parentChildNodes.indexOf(hostElm) - 1;
2659 vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
2660 }
2661 }
2662 }
2663 }
2664};
2665const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
2666 const childElm = vnodeChild.$elm$;
2667 if (childElm == null) {
2668 return;
2669 }
2670 const nodeId = cmpData.nodeIds++;
2671 const childId = `${hostId}.${nodeId}.${depth}.${index}`;
2672 childElm['s-host-id'] = hostId;
2673 childElm['s-node-id'] = nodeId;
2674 if (childElm.nodeType === 1 /* ElementNode */) {
2675 childElm.setAttribute(HYDRATE_CHILD_ID, childId);
2676 }
2677 else if (childElm.nodeType === 3 /* TextNode */) {
2678 const parentNode = childElm.parentNode;
2679 if (parentNode.nodeName !== 'STYLE') {
2680 const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2681 const commentBeforeTextNode = doc.createComment(textNodeId);
2682 parentNode.insertBefore(commentBeforeTextNode, childElm);
2683 }
2684 }
2685 else if (childElm.nodeType === 8 /* CommentNode */) {
2686 if (childElm['s-sr']) {
2687 const slotName = childElm['s-sn'] || '';
2688 const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
2689 childElm.nodeValue = slotNodeId;
2690 }
2691 }
2692 if (vnodeChild.$children$ != null) {
2693 const childDepth = depth + 1;
2694 vnodeChild.$children$.forEach((vnode, index) => {
2695 insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
2696 });
2697 }
2698};
2699const hostRefs = new WeakMap();
2700const getHostRef = (ref) => hostRefs.get(ref);
2701const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2702const registerHost = (elm, cmpMeta) => {
2703 const hostRef = {
2704 $flags$: 0,
2705 $hostElement$: elm,
2706 $cmpMeta$: cmpMeta,
2707 $instanceValues$: new Map(),
2708 };
2709 if (BUILD.isDev) {
2710 hostRef.$renderCount$ = 0;
2711 }
2712 if (BUILD.method && BUILD.lazyLoad) {
2713 hostRef.$onInstancePromise$ = new Promise(r => (hostRef.$onInstanceResolve$ = r));
2714 }
2715 if (BUILD.asyncLoading) {
2716 hostRef.$onReadyPromise$ = new Promise(r => (hostRef.$onReadyResolve$ = r));
2717 elm['s-p'] = [];
2718 elm['s-rc'] = [];
2719 }
2720 addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2721 return hostRefs.set(elm, hostRef);
2722};
2723const isMemberInElement = (elm, memberName) => memberName in elm;
2724const STENCIL_DEV_MODE = BUILD.isTesting
2725 ? ['STENCIL:'] // E2E testing
2726 : ['%cstencil', 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px'];
2727const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
2728const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
2729const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
2730const consoleError = (e) => console.error(e);
2731const cmpModules = /*@__PURE__*/ new Map();
2732const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2733 // loadModuleImport
2734 const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2735 const bundleId = cmpMeta.$lazyBundleId$;
2736 if (BUILD.isDev && typeof bundleId !== 'string') {
2737 consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
2738 return undefined;
2739 }
2740 const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
2741 if (module) {
2742 return module[exportName];
2743 }
2744 return Promise.resolve().then(function () { return _interopNamespace(require(
2745 /* webpackInclude: /\.entry\.js$/ */
2746 /* webpackExclude: /\.system\.entry\.js$/ */
2747 /* webpackMode: "lazy" */
2748 `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`)); }).then(importedModule => {
2749 if (!BUILD.hotModuleReplacement) {
2750 cmpModules.set(bundleId, importedModule);
2751 }
2752 return importedModule[exportName];
2753 }, consoleError);
2754};
2755const styles = new Map();
2756const modeResolutionChain = [];
2757const queueDomReads = [];
2758const queueDomWrites = [];
2759const queueDomWritesLow = [];
2760const queueTask = (queue, write) => (cb) => {
2761 queue.push(cb);
2762 if (!queuePending) {
2763 queuePending = true;
2764 if (write && plt.$flags$ & 4 /* queueSync */) {
2765 nextTick(flush);
2766 }
2767 else {
2768 plt.raf(flush);
2769 }
2770 }
2771};
2772const consume = (queue) => {
2773 for (let i = 0; i < queue.length; i++) {
2774 try {
2775 queue[i](performance.now());
2776 }
2777 catch (e) {
2778 consoleError(e);
2779 }
2780 }
2781 queue.length = 0;
2782};
2783const consumeTimeout = (queue, timeout) => {
2784 let i = 0;
2785 let ts = 0;
2786 while (i < queue.length && (ts = performance.now()) < timeout) {
2787 try {
2788 queue[i++](ts);
2789 }
2790 catch (e) {
2791 consoleError(e);
2792 }
2793 }
2794 if (i === queue.length) {
2795 queue.length = 0;
2796 }
2797 else if (i !== 0) {
2798 queue.splice(0, i);
2799 }
2800};
2801const flush = () => {
2802 if (BUILD.asyncQueue) {
2803 queueCongestion++;
2804 }
2805 // always force a bunch of medium callbacks to run, but still have
2806 // a throttle on how many can run in a certain time
2807 // DOM READS!!!
2808 consume(queueDomReads);
2809 // DOM WRITES!!!
2810 if (BUILD.asyncQueue) {
2811 const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0)) : Infinity;
2812 consumeTimeout(queueDomWrites, timeout);
2813 consumeTimeout(queueDomWritesLow, timeout);
2814 if (queueDomWrites.length > 0) {
2815 queueDomWritesLow.push(...queueDomWrites);
2816 queueDomWrites.length = 0;
2817 }
2818 if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
2819 // still more to do yet, but we've run out of time
2820 // let's let this thing cool off and try again in the next tick
2821 plt.raf(flush);
2822 }
2823 else {
2824 queueCongestion = 0;
2825 }
2826 }
2827 else {
2828 consume(queueDomWrites);
2829 if ((queuePending = queueDomReads.length > 0)) {
2830 // still more to do yet, but we've run out of time
2831 // let's let this thing cool off and try again in the next tick
2832 plt.raf(flush);
2833 }
2834 }
2835};
2836const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
2837const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
2838const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2839const Build = {
2840 isDev: BUILD.isDev ? true : false,
2841 isBrowser: true,
2842 isServer: false,
2843 isTesting: BUILD.isTesting ? true : false,
2844};
2845
2846exports.BUILD = BUILD;
2847exports.CSS = CSS;
2848exports.H = H;
2849exports.Host = Host;
2850exports.NAMESPACE = NAMESPACE;
2851exports.bootstrapLazy = bootstrapLazy;
2852exports.consoleDevInfo = consoleDevInfo;
2853exports.doc = doc;
2854exports.h = h;
2855exports.plt = plt;
2856exports.promiseResolve = promiseResolve;
2857exports.registerInstance = registerInstance;
2858exports.win = win;