@postnord/web-components
Version:
PostNord Web Components
1,427 lines (1,412 loc) • 88.9 kB
JavaScript
/*!
* Built with Stencil
* By PostNord.
*/
const NAMESPACE = 'postnord-web-components';
const BUILD = /* postnord-web-components */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: true, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: true, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: true, cmpWillUpdate: false, connectedCallback: true, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: true, hostListenerTarget: true, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: true, hotModuleReplacement: false, hydrateClientSide: true, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, modernPropertyDecls: true, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, slot: true, slotChildNodesFix: true, slotRelocation: true, state: true, style: true, svg: true, taskQueue: true, transformTagName: true, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
/*
Stencil Client Platform v4.25.1 | MIT Licensed | https://stenciljs.com
*/
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
// src/utils/constants.ts
var SVG_NS = "http://www.w3.org/2000/svg";
var HTML_NS = "http://www.w3.org/1999/xhtml";
// src/utils/es2022-rewire-class-members.ts
var reWireGetterSetter = (instance, hostRef) => {
var _a;
const cmpMeta = hostRef.$cmpMeta$;
const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
members.map(([memberName, [memberFlags]]) => {
if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
const ogValue = instance[memberName];
const ogDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(instance), memberName);
Object.defineProperty(instance, memberName, {
get() {
return ogDescriptor.get.call(this);
},
set(newValue) {
ogDescriptor.set.call(this, newValue);
},
configurable: true,
enumerable: true
});
instance[memberName] = hostRef.$instanceValues$.has(memberName) ? hostRef.$instanceValues$.get(memberName) : ogValue;
}
});
};
// src/client/client-host-ref.ts
var hostRefs = /* @__PURE__ */ new WeakMap();
var getHostRef = (ref) => hostRefs.get(ref);
var registerInstance = (lazyInstance, hostRef) => {
hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
{
reWireGetterSetter(lazyInstance, hostRef);
}
};
var registerHost = (hostElement, cmpMeta) => {
const hostRef = {
$flags$: 0,
$hostElement$: hostElement,
$cmpMeta$: cmpMeta,
$instanceValues$: /* @__PURE__ */ new Map()
};
{
hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
}
{
hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
hostElement["s-p"] = [];
hostElement["s-rc"] = [];
}
const ref = hostRefs.set(hostElement, hostRef);
return ref;
};
var isMemberInElement = (elm, memberName) => memberName in elm;
var consoleError = (e, el) => (0, console.error)(e, el);
// src/client/client-load-module.ts
var cmpModules = /* @__PURE__ */ new Map();
var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
const bundleId = cmpMeta.$lazyBundleId$;
if (!bundleId) {
return void 0;
}
const module = cmpModules.get(bundleId) ;
if (module) {
return module[exportName];
}
if (!hmrVersionId || !BUILD.hotModuleReplacement) {
const processMod = importedModule => {
cmpModules.set(bundleId, importedModule);
return importedModule[exportName];
}
switch(bundleId) {
case 'pn-accordion_2':
return import(
/* webpackMode: "lazy" */
'./pn-accordion_2.entry.js').then(processMod, consoleError);
case 'pn-tab_2':
return import(
/* webpackMode: "lazy" */
'./pn-tab_2.entry.js').then(processMod, consoleError);
case 'pn-button-dropdown':
return import(
/* webpackMode: "lazy" */
'./pn-button-dropdown.entry.js').then(processMod, consoleError);
case 'pn-checkbox':
return import(
/* webpackMode: "lazy" */
'./pn-checkbox.entry.js').then(processMod, consoleError);
case 'pn-choice-chip':
return import(
/* webpackMode: "lazy" */
'./pn-choice-chip.entry.js').then(processMod, consoleError);
case 'pn-counter':
return import(
/* webpackMode: "lazy" */
'./pn-counter.entry.js').then(processMod, consoleError);
case 'pn-date-picker':
return import(
/* webpackMode: "lazy" */
'./pn-date-picker.entry.js').then(processMod, consoleError);
case 'pn-fieldset':
return import(
/* webpackMode: "lazy" */
'./pn-fieldset.entry.js').then(processMod, consoleError);
case 'pn-file-upload':
return import(
/* webpackMode: "lazy" */
'./pn-file-upload.entry.js').then(processMod, consoleError);
case 'pn-footer':
return import(
/* webpackMode: "lazy" */
'./pn-footer.entry.js').then(processMod, consoleError);
case 'pn-header':
return import(
/* webpackMode: "lazy" */
'./pn-header.entry.js').then(processMod, consoleError);
case 'pn-input':
return import(
/* webpackMode: "lazy" */
'./pn-input.entry.js').then(processMod, consoleError);
case 'pn-modal':
return import(
/* webpackMode: "lazy" */
'./pn-modal.entry.js').then(processMod, consoleError);
case 'pn-multiselect':
return import(
/* webpackMode: "lazy" */
'./pn-multiselect.entry.js').then(processMod, consoleError);
case 'pn-ocr-search':
return import(
/* webpackMode: "lazy" */
'./pn-ocr-search.entry.js').then(processMod, consoleError);
case 'pn-page-nav':
return import(
/* webpackMode: "lazy" */
'./pn-page-nav.entry.js').then(processMod, consoleError);
case 'pn-page-nav-dropdown-item':
return import(
/* webpackMode: "lazy" */
'./pn-page-nav-dropdown-item.entry.js').then(processMod, consoleError);
case 'pn-page-nav-item':
return import(
/* webpackMode: "lazy" */
'./pn-page-nav-item.entry.js').then(processMod, consoleError);
case 'pn-progress-indicator':
return import(
/* webpackMode: "lazy" */
'./pn-progress-indicator.entry.js').then(processMod, consoleError);
case 'pn-progress-indicator-step':
return import(
/* webpackMode: "lazy" */
'./pn-progress-indicator-step.entry.js').then(processMod, consoleError);
case 'pn-progress-stepper':
return import(
/* webpackMode: "lazy" */
'./pn-progress-stepper.entry.js').then(processMod, consoleError);
case 'pn-radio-button':
return import(
/* webpackMode: "lazy" */
'./pn-radio-button.entry.js').then(processMod, consoleError);
case 'pn-read-only-button':
return import(
/* webpackMode: "lazy" */
'./pn-read-only-button.entry.js').then(processMod, consoleError);
case 'pn-segment':
return import(
/* webpackMode: "lazy" */
'./pn-segment.entry.js').then(processMod, consoleError);
case 'pn-segmented-control':
return import(
/* webpackMode: "lazy" */
'./pn-segmented-control.entry.js').then(processMod, consoleError);
case 'pn-select':
return import(
/* webpackMode: "lazy" */
'./pn-select.entry.js').then(processMod, consoleError);
case 'pn-table':
return import(
/* webpackMode: "lazy" */
'./pn-table.entry.js').then(processMod, consoleError);
case 'pn-tag':
return import(
/* webpackMode: "lazy" */
'./pn-tag.entry.js').then(processMod, consoleError);
case 'pn-textarea':
return import(
/* webpackMode: "lazy" */
'./pn-textarea.entry.js').then(processMod, consoleError);
case 'pn-tile':
return import(
/* webpackMode: "lazy" */
'./pn-tile.entry.js').then(processMod, consoleError);
case 'pn-toast':
return import(
/* webpackMode: "lazy" */
'./pn-toast.entry.js').then(processMod, consoleError);
case 'pn-toggle-switch':
return import(
/* webpackMode: "lazy" */
'./pn-toggle-switch.entry.js').then(processMod, consoleError);
case 'pn-tooltip':
return import(
/* webpackMode: "lazy" */
'./pn-tooltip.entry.js').then(processMod, consoleError);
case 'pn-zipcode-search':
return import(
/* webpackMode: "lazy" */
'./pn-zipcode-search.entry.js').then(processMod, consoleError);
case 'pn-illustration':
return import(
/* webpackMode: "lazy" */
'./pn-illustration.entry.js').then(processMod, consoleError);
case 'pn-progress-bar':
return import(
/* webpackMode: "lazy" */
'./pn-progress-bar.entry.js').then(processMod, consoleError);
case 'pn-search-field':
return import(
/* webpackMode: "lazy" */
'./pn-search-field.entry.js').then(processMod, consoleError);
case 'pn-text-link':
return import(
/* webpackMode: "lazy" */
'./pn-text-link.entry.js').then(processMod, consoleError);
case 'pn-button_2':
return import(
/* webpackMode: "lazy" */
'./pn-button_2.entry.js').then(processMod, consoleError);
case 'pn-icon':
return import(
/* webpackMode: "lazy" */
'./pn-icon.entry.js').then(processMod, consoleError);
}
}
return import(
/* @vite-ignore */
/* webpackInclude: /\.entry\.js$/ */
/* webpackExclude: /\.system\.entry\.js$/ */
/* webpackMode: "lazy" */
`./${bundleId}.entry.js${""}`
).then(
(importedModule) => {
{
cmpModules.set(bundleId, importedModule);
}
return importedModule[exportName];
},
(e) => {
consoleError(e, hostRef.$hostElement$);
}
);
};
// src/client/client-style.ts
var styles = /* @__PURE__ */ new Map();
// src/runtime/runtime-constants.ts
var CONTENT_REF_ID = "r";
var ORG_LOCATION_ID = "o";
var SLOT_NODE_ID = "s";
var TEXT_NODE_ID = "t";
var COMMENT_NODE_ID = "c";
var HYDRATE_ID = "s-id";
var HYDRATED_STYLE_ID = "sty-id";
var HYDRATE_CHILD_ID = "c-id";
var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
var XLINK_NS = "http://www.w3.org/1999/xlink";
var win = typeof window !== "undefined" ? window : {};
var doc = win.document || { head: {} };
var H = win.HTMLElement || class {
};
var plt = {
$flags$: 0,
$resourcesUrl$: "",
jmp: (h2) => h2(),
raf: (h2) => requestAnimationFrame(h2),
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
ce: (eventName, opts) => new CustomEvent(eventName, opts)
};
var supportsShadow = BUILD.shadowDom;
var supportsListenerOptions = /* @__PURE__ */ (() => {
let supportsListenerOptions2 = false;
try {
doc.addEventListener(
"e",
null,
Object.defineProperty({}, "passive", {
get() {
supportsListenerOptions2 = true;
}
})
);
} catch (e) {
}
return supportsListenerOptions2;
})();
var promiseResolve = (v) => Promise.resolve(v);
var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
try {
new CSSStyleSheet();
return typeof new CSSStyleSheet().replaceSync === "function";
} catch (e) {
}
return false;
})() ;
var queuePending = false;
var queueDomReads = [];
var queueDomWrites = [];
var queueTask = (queue, write) => (cb) => {
queue.push(cb);
if (!queuePending) {
queuePending = true;
if (write && plt.$flags$ & 4 /* queueSync */) {
nextTick(flush);
} else {
plt.raf(flush);
}
}
};
var consume = (queue) => {
for (let i2 = 0; i2 < queue.length; i2++) {
try {
queue[i2](performance.now());
} catch (e) {
consoleError(e);
}
}
queue.length = 0;
};
var flush = () => {
consume(queueDomReads);
{
consume(queueDomWrites);
if (queuePending = queueDomReads.length > 0) {
plt.raf(flush);
}
}
};
var nextTick = (cb) => promiseResolve().then(cb);
var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
var isComplexType = (o) => {
o = typeof o;
return o === "object" || o === "function";
};
// src/utils/query-nonce-meta-tag-content.ts
function queryNonceMetaTagContent(doc2) {
var _a, _b, _c;
return (_c = (_b = (_a = doc2.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
}
// src/utils/result.ts
var result_exports = {};
__export(result_exports, {
err: () => err,
map: () => map,
ok: () => ok,
unwrap: () => unwrap,
unwrapErr: () => unwrapErr
});
var ok = (value) => ({
isOk: true,
isErr: false,
value
});
var err = (value) => ({
isOk: false,
isErr: true,
value
});
function map(result, fn) {
if (result.isOk) {
const val = fn(result.value);
if (val instanceof Promise) {
return val.then((newVal) => ok(newVal));
} else {
return ok(val);
}
}
if (result.isErr) {
const value = result.value;
return err(value);
}
throw "should never get here";
}
var unwrap = (result) => {
if (result.isOk) {
return result.value;
} else {
throw result.value;
}
};
var unwrapErr = (result) => {
if (result.isErr) {
return result.value;
} else {
throw result.value;
}
};
var updateFallbackSlotVisibility = (elm) => {
const childNodes = elm.__childNodes || elm.childNodes;
if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
var _a;
if (slotNode.nodeType === 1 /* ElementNode */ && slotNode.tagName === "SLOT-FB") {
if ((_a = getHostSlotChildNodes(slotNode, slotNode["s-sn"], false)) == null ? void 0 : _a.length) {
slotNode.hidden = true;
} else {
slotNode.hidden = false;
}
}
});
}
for (const childNode of childNodes) {
if (childNode.nodeType === 1 /* ElementNode */ && (childNode.__childNodes || childNode.childNodes).length) {
updateFallbackSlotVisibility(childNode);
}
}
};
var getSlottedChildNodes = (childNodes) => {
const result = [];
for (let i2 = 0; i2 < childNodes.length; i2++) {
const slottedNode = childNodes[i2]["s-nr"] || void 0;
if (slottedNode && slottedNode.isConnected) {
result.push(slottedNode);
}
}
return result;
};
function getHostSlotNodes(childNodes, hostName, slotName) {
let i2 = 0;
let slottedNodes = [];
let childNode;
for (; i2 < childNodes.length; i2++) {
childNode = childNodes[i2];
if (childNode["s-sr"] && childNode["s-hn"] === hostName && (slotName === void 0 || childNode["s-sn"] === slotName)) {
slottedNodes.push(childNode);
if (typeof slotName !== "undefined") return slottedNodes;
}
slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
}
return slottedNodes;
}
var getHostSlotChildNodes = (node, slotName, includeSlot = true) => {
const childNodes = [];
if (includeSlot && node["s-sr"] || !node["s-sr"]) childNodes.push(node);
while ((node = node.nextSibling) && node["s-sn"] === slotName) {
childNodes.push(node);
}
return childNodes;
};
var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
if (nodeToRelocate.getAttribute("slot") === null && slotName === "") {
return true;
}
if (nodeToRelocate.getAttribute("slot") === slotName) {
return true;
}
return false;
}
if (nodeToRelocate["s-sn"] === slotName) {
return true;
}
return slotName === "";
};
var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
let slottedNodeLocation;
if (newChild["s-ol"] && newChild["s-ol"].isConnected) {
slottedNodeLocation = newChild["s-ol"];
} else {
slottedNodeLocation = document.createTextNode("");
slottedNodeLocation["s-nr"] = newChild;
}
if (!slotNode["s-cr"] || !slotNode["s-cr"].parentNode) return;
const parent = slotNode["s-cr"].parentNode;
const appendMethod = prepend ? parent.__prepend || parent.prepend : parent.__appendChild || parent.appendChild;
if (typeof position !== "undefined") {
{
slottedNodeLocation["s-oo"] = position;
const childNodes = parent.__childNodes || parent.childNodes;
const slotRelocateNodes = [slottedNodeLocation];
childNodes.forEach((n) => {
if (n["s-nr"]) slotRelocateNodes.push(n);
});
slotRelocateNodes.sort((a, b) => {
if (!a["s-oo"] || a["s-oo"] < b["s-oo"]) return -1;
else if (!b["s-oo"] || b["s-oo"] < a["s-oo"]) return 1;
return 0;
});
slotRelocateNodes.forEach((n) => appendMethod.call(parent, n));
}
} else {
appendMethod.call(parent, slottedNodeLocation);
}
newChild["s-ol"] = slottedNodeLocation;
newChild["s-sh"] = slotNode["s-hn"];
};
var patchCloneNode = (HostElementPrototype) => {
const orgCloneNode = HostElementPrototype.cloneNode;
HostElementPrototype.cloneNode = function(deep) {
const srcNode = this;
const clonedNode = orgCloneNode.call(srcNode, false);
if (deep) {
let i2 = 0;
let slotted, nonStencilNode;
const stencilPrivates = [
"s-id",
"s-cr",
"s-lr",
"s-rc",
"s-sc",
"s-p",
"s-cn",
"s-sr",
"s-sn",
"s-hn",
"s-ol",
"s-nr",
"s-si",
"s-rf",
"s-scs"
];
const childNodes = this.__childNodes || this.childNodes;
for (; i2 < childNodes.length; i2++) {
slotted = childNodes[i2]["s-nr"];
nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i2][privateField]);
if (slotted) {
{
clonedNode.appendChild(slotted.cloneNode(true));
}
}
if (nonStencilNode) {
clonedNode.appendChild(childNodes[i2].cloneNode(true));
}
}
}
return clonedNode;
};
};
var patchChildSlotNodes = (elm) => {
class FakeNodeList extends Array {
item(n) {
return this[n];
}
}
patchHostOriginalAccessor("children", elm);
Object.defineProperty(elm, "children", {
get() {
return this.childNodes.filter((n) => n.nodeType === 1);
}
});
Object.defineProperty(elm, "childElementCount", {
get() {
return this.children.length;
}
});
patchHostOriginalAccessor("firstChild", elm);
Object.defineProperty(elm, "firstChild", {
get() {
return this.childNodes[0];
}
});
patchHostOriginalAccessor("lastChild", elm);
Object.defineProperty(elm, "lastChild", {
get() {
return this.childNodes[this.childNodes.length - 1];
}
});
patchHostOriginalAccessor("childNodes", elm);
Object.defineProperty(elm, "childNodes", {
get() {
const result = new FakeNodeList();
result.push(...getSlottedChildNodes(this.__childNodes));
return result;
}
});
};
var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
var validNodesPatches = [
"childNodes",
"firstChild",
"lastChild",
"nextSibling",
"previousSibling",
"textContent",
"parentNode"
];
function patchHostOriginalAccessor(accessorName, node) {
let accessor;
if (validElementPatches.includes(accessorName)) {
accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
} else if (validNodesPatches.includes(accessorName)) {
accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
}
if (!accessor) {
accessor = Object.getOwnPropertyDescriptor(node, accessorName);
}
if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
}
var createTime = (fnName, tagName = "") => {
{
return () => {
return;
};
}
};
var uniqueTime = (key, measureText) => {
{
return () => {
return;
};
}
};
var h = (nodeName, vnodeData, ...children) => {
let child = null;
let key = null;
let slotName = null;
let simple = false;
let lastSimple = false;
const vNodeChildren = [];
const walk = (c) => {
for (let i2 = 0; i2 < c.length; i2++) {
child = c[i2];
if (Array.isArray(child)) {
walk(child);
} else if (child != null && typeof child !== "boolean") {
if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
child = String(child);
}
if (simple && lastSimple) {
vNodeChildren[vNodeChildren.length - 1].$text$ += child;
} else {
vNodeChildren.push(simple ? newVNode(null, child) : child);
}
lastSimple = simple;
}
}
};
walk(children);
if (vnodeData) {
if (vnodeData.key) {
key = vnodeData.key;
}
if (vnodeData.name) {
slotName = vnodeData.name;
}
{
const classData = vnodeData.className || vnodeData.class;
if (classData) {
vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
}
}
}
if (typeof nodeName === "function") {
return nodeName(
vnodeData === null ? {} : vnodeData,
vNodeChildren,
vdomFnUtils
);
}
const vnode = newVNode(nodeName, null);
vnode.$attrs$ = vnodeData;
if (vNodeChildren.length > 0) {
vnode.$children$ = vNodeChildren;
}
{
vnode.$key$ = key;
}
{
vnode.$name$ = slotName;
}
return vnode;
};
var newVNode = (tag, text) => {
const vnode = {
$flags$: 0,
$tag$: tag,
$text$: text,
$elm$: null,
$children$: null
};
{
vnode.$attrs$ = null;
}
{
vnode.$key$ = null;
}
{
vnode.$name$ = null;
}
return vnode;
};
var Host = {};
var isHost = (node) => node && node.$tag$ === Host;
var vdomFnUtils = {
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
};
var convertToPublic = (node) => ({
vattrs: node.$attrs$,
vchildren: node.$children$,
vkey: node.$key$,
vname: node.$name$,
vtag: node.$tag$,
vtext: node.$text$
});
var convertToPrivate = (node) => {
if (typeof node.vtag === "function") {
const vnodeData = { ...node.vattrs };
if (node.vkey) {
vnodeData.key = node.vkey;
}
if (node.vname) {
vnodeData.name = node.vname;
}
return h(node.vtag, vnodeData, ...node.vchildren || []);
}
const vnode = newVNode(node.vtag, node.vtext);
vnode.$attrs$ = node.vattrs;
vnode.$children$ = node.vchildren;
vnode.$key$ = node.vkey;
vnode.$name$ = node.vname;
return vnode;
};
// src/runtime/client-hydrate.ts
var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
const endHydrate = createTime("hydrateClient", tagName);
const shadowRoot = hostElm.shadowRoot;
const childRenderNodes = [];
const slotNodes = [];
const slottedNodes = [];
const shadowRootNodes = null;
const vnode = newVNode(tagName, null);
vnode.$elm$ = hostElm;
if (!plt.$orgLocNodes$) {
initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
}
hostElm[HYDRATE_ID] = hostId;
hostElm.removeAttribute(HYDRATE_ID);
hostRef.$vnode$ = clientHydrate(
vnode,
childRenderNodes,
slotNodes,
shadowRootNodes,
hostElm,
hostElm,
hostId,
slottedNodes
);
let crIndex = 0;
const crLength = childRenderNodes.length;
let childRenderNode;
for (crIndex; crIndex < crLength; crIndex++) {
childRenderNode = childRenderNodes[crIndex];
const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
const node = childRenderNode.$elm$;
if (!shadowRoot) {
node["s-hn"] = tagName.toUpperCase();
if (childRenderNode.$tag$ === "slot") {
node["s-cr"] = hostElm["s-cr"];
}
}
if (childRenderNode.$tag$ === "slot") {
if (childRenderNode.$children$) {
childRenderNode.$flags$ |= 2 /* isSlotFallback */;
if (!childRenderNode.$elm$.childNodes.length) {
childRenderNode.$children$.forEach((c) => {
childRenderNode.$elm$.appendChild(c.$elm$);
});
}
} else {
childRenderNode.$flags$ |= 1 /* isSlotReference */;
}
}
if (orgLocationNode && orgLocationNode.isConnected) {
if (shadowRoot && orgLocationNode["s-en"] === "") {
orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
}
orgLocationNode.parentNode.removeChild(orgLocationNode);
if (!shadowRoot) {
node["s-oo"] = parseInt(childRenderNode.$nodeId$);
}
}
plt.$orgLocNodes$.delete(orgLocationId);
}
const hosts = [];
const snLen = slottedNodes.length;
let snIndex = 0;
let slotGroup;
let snGroupIdx;
let snGroupLen;
let slottedItem;
for (snIndex; snIndex < snLen; snIndex++) {
slotGroup = slottedNodes[snIndex];
if (!slotGroup || !slotGroup.length) continue;
snGroupLen = slotGroup.length;
snGroupIdx = 0;
for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
slottedItem = slotGroup[snGroupIdx];
if (!hosts[slottedItem.hostId]) {
hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
}
if (!hosts[slottedItem.hostId]) continue;
const hostEle = hosts[slottedItem.hostId];
if (!hostEle.shadowRoot || !shadowRoot) {
slottedItem.slot["s-cr"] = hostEle["s-cr"];
if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
slottedItem.slot["s-cr"] = hostEle;
} else {
slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
}
addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
}
if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
hostEle.appendChild(slottedItem.node);
}
}
}
hostRef.$hostElement$ = hostElm;
endHydrate();
};
var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
let childNodeType;
let childIdSplt;
let childVNode;
let i2;
if (node.nodeType === 1 /* ElementNode */) {
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
if (childNodeType) {
childIdSplt = childNodeType.split(".");
if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
childVNode = createSimpleVNode({
$flags$: 0,
$hostId$: childIdSplt[0],
$nodeId$: childIdSplt[1],
$depth$: childIdSplt[2],
$index$: childIdSplt[3],
$tag$: node.tagName.toLowerCase(),
$elm$: node,
// If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
// won't try to reconcile them. Classes set on the node will be blown away.
$attrs$: { class: node.className || "" }
});
childRenderNodes.push(childVNode);
node.removeAttribute(HYDRATE_CHILD_ID);
if (!parentVNode.$children$) {
parentVNode.$children$ = [];
}
const slotName = childVNode.$elm$.getAttribute("s-sn");
if (typeof slotName === "string") {
if (childVNode.$tag$ === "slot-fb") {
addSlot(
slotName,
childIdSplt[2],
childVNode,
node,
parentVNode,
childRenderNodes,
slotNodes,
shadowRootNodes,
slottedNodes
);
}
childVNode.$elm$["s-sn"] = slotName;
childVNode.$elm$.removeAttribute("s-sn");
}
if (childVNode.$index$ !== void 0) {
parentVNode.$children$[childVNode.$index$] = childVNode;
}
parentVNode = childVNode;
if (shadowRootNodes && childVNode.$depth$ === "0") {
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
}
}
}
if (node.shadowRoot) {
for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
clientHydrate(
parentVNode,
childRenderNodes,
slotNodes,
shadowRootNodes,
hostElm,
node.shadowRoot.childNodes[i2],
hostId,
slottedNodes
);
}
}
const nonShadowNodes = node.__childNodes || node.childNodes;
for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
clientHydrate(
parentVNode,
childRenderNodes,
slotNodes,
shadowRootNodes,
hostElm,
nonShadowNodes[i2],
hostId,
slottedNodes
);
}
} else if (node.nodeType === 8 /* CommentNode */) {
childIdSplt = node.nodeValue.split(".");
if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
childNodeType = childIdSplt[0];
childVNode = createSimpleVNode({
$hostId$: childIdSplt[1],
$nodeId$: childIdSplt[2],
$depth$: childIdSplt[3],
$index$: childIdSplt[4] || "0",
$elm$: node,
$attrs$: null,
$children$: null,
$key$: null,
$name$: null,
$tag$: null,
$text$: null
});
if (childNodeType === TEXT_NODE_ID) {
childVNode.$elm$ = node.nextSibling;
if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
childVNode.$text$ = childVNode.$elm$.textContent;
childRenderNodes.push(childVNode);
node.remove();
if (hostId === childVNode.$hostId$) {
if (!parentVNode.$children$) {
parentVNode.$children$ = [];
}
parentVNode.$children$[childVNode.$index$] = childVNode;
}
if (shadowRootNodes && childVNode.$depth$ === "0") {
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
}
}
} else if (childNodeType === COMMENT_NODE_ID) {
childVNode.$elm$ = node.nextSibling;
if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
childRenderNodes.push(childVNode);
node.remove();
}
} else if (childVNode.$hostId$ === hostId) {
if (childNodeType === SLOT_NODE_ID) {
const slotName = node["s-sn"] = childIdSplt[5] || "";
addSlot(
slotName,
childIdSplt[2],
childVNode,
node,
parentVNode,
childRenderNodes,
slotNodes,
shadowRootNodes,
slottedNodes
);
} else if (childNodeType === CONTENT_REF_ID) {
{
hostElm["s-cr"] = node;
node["s-cn"] = true;
}
}
}
}
} else if (parentVNode && parentVNode.$tag$ === "style") {
const vnode = newVNode(null, node.textContent);
vnode.$elm$ = node;
vnode.$index$ = "0";
parentVNode.$children$ = [vnode];
}
return parentVNode;
};
var initializeDocumentHydrate = (node, orgLocNodes) => {
if (node.nodeType === 1 /* ElementNode */) {
const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
if (componentId) {
orgLocNodes.set(componentId, node);
}
let i2 = 0;
if (node.shadowRoot) {
for (; i2 < node.shadowRoot.childNodes.length; i2++) {
initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
}
}
const nonShadowNodes = node.__childNodes || node.childNodes;
for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
}
} else if (node.nodeType === 8 /* CommentNode */) {
const childIdSplt = node.nodeValue.split(".");
if (childIdSplt[0] === ORG_LOCATION_ID) {
orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
node.nodeValue = "";
node["s-en"] = childIdSplt[3];
}
}
};
var createSimpleVNode = (vnode) => {
const defaultVNode = {
$flags$: 0,
$hostId$: null,
$nodeId$: null,
$depth$: null,
$index$: "0",
$elm$: null,
$attrs$: null,
$children$: null,
$key$: null,
$name$: null,
$tag$: null,
$text$: null
};
return { ...defaultVNode, ...vnode };
};
function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
node["s-sr"] = true;
childVNode.$name$ = slotName || null;
childVNode.$tag$ = "slot";
const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
{
const slot = childVNode.$elm$;
const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
if (shouldMove) {
parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
}
childRenderNodes.push(childVNode);
}
slotNodes.push(childVNode);
if (!parentVNode.$children$) {
parentVNode.$children$ = [];
}
parentVNode.$children$[childVNode.$index$] = childVNode;
}
var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
let slottedNode = slotNode.nextSibling;
slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
while (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (slottedNode.nodeType === 8 /* CommentNode */ && slottedNode.nodeValue.indexOf(".") !== 1 || slottedNode.nodeType === 3 /* TextNode */))) {
slottedNode["s-sn"] = slotName;
slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
slottedNode = slottedNode.nextSibling;
}
};
var parsePropertyValue = (propValue, propType) => {
if (propValue != null && !isComplexType(propValue)) {
if (propType & 4 /* Boolean */) {
return propValue === "false" ? false : propValue === "" || !!propValue;
}
if (propType & 2 /* Number */) {
return parseFloat(propValue);
}
if (propType & 1 /* String */) {
return String(propValue);
}
return propValue;
}
return propValue;
};
var getElement = (ref) => getHostRef(ref).$hostElement$ ;
// src/runtime/event-emitter.ts
var createEvent = (ref, name, flags) => {
const elm = getElement(ref);
return {
emit: (detail) => {
return emitEvent(elm, name, {
bubbles: !!(flags & 4 /* Bubbles */),
composed: !!(flags & 2 /* Composed */),
cancelable: !!(flags & 1 /* Cancellable */),
detail
});
}
};
};
var emitEvent = (elm, name, opts) => {
const ev = plt.ce(name, opts);
elm.dispatchEvent(ev);
return ev;
};
var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
var registerStyle = (scopeId2, cssText, allowCS) => {
let style = styles.get(scopeId2);
if (supportsConstructableStylesheets && allowCS) {
style = style || new CSSStyleSheet();
if (typeof style === "string") {
style = cssText;
} else {
style.replaceSync(cssText);
}
} else {
style = cssText;
}
styles.set(scopeId2, style);
};
var addStyle = (styleContainerNode, cmpMeta, mode) => {
var _a;
const scopeId2 = getScopeId(cmpMeta);
const style = styles.get(scopeId2);
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
if (style) {
if (typeof style === "string") {
styleContainerNode = styleContainerNode.head || styleContainerNode;
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
let styleElm;
if (!appliedStyles) {
rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
}
if (!appliedStyles.has(scopeId2)) {
if (styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
styleElm.innerHTML = style;
} else {
styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
styleElm.innerHTML = style;
const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
if (nonce != null) {
styleElm.setAttribute("nonce", nonce);
}
if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
if (styleContainerNode.nodeName === "HEAD") {
const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
styleContainerNode.insertBefore(
styleElm,
(referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
);
} else if ("host" in styleContainerNode) {
if (supportsConstructableStylesheets) {
const stylesheet = new CSSStyleSheet();
stylesheet.replaceSync(style);
styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
} else {
const existingStyleContainer = styleContainerNode.querySelector("style");
if (existingStyleContainer) {
existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
} else {
styleContainerNode.prepend(styleElm);
}
}
} else {
styleContainerNode.append(styleElm);
}
}
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
styleContainerNode.insertBefore(styleElm, null);
}
}
if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
styleElm.innerHTML += SLOT_FB_CSS;
}
if (appliedStyles) {
appliedStyles.add(scopeId2);
}
}
} else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
}
}
return scopeId2;
};
var attachStyles = (hostRef) => {
const cmpMeta = hostRef.$cmpMeta$;
const elm = hostRef.$hostElement$;
const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
addStyle(
elm.getRootNode(),
cmpMeta);
endAttachStyles();
};
var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
if (oldValue !== newValue) {
let isProp = isMemberInElement(elm, memberName);
let ln = memberName.toLowerCase();
if (memberName === "class") {
const classList = elm.classList;
const oldClasses = parseClassList(oldValue);
let newClasses = parseClassList(newValue);
if (elm["s-si"] && initialRender) {
newClasses.push(elm["s-si"]);
oldClasses.forEach((c) => {
if (c.startsWith(elm["s-si"])) newClasses.push(c);
});
newClasses = [...new Set(newClasses)];
classList.add(...newClasses);
} else {
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
}
} else if (memberName === "style") {
{
for (const prop in oldValue) {
if (!newValue || newValue[prop] == null) {
if (prop.includes("-")) {
elm.style.removeProperty(prop);
} else {
elm.style[prop] = "";
}
}
}
}
for (const prop in newValue) {
if (!oldValue || newValue[prop] !== oldValue[prop]) {
if (prop.includes("-")) {
elm.style.setProperty(prop, newValue[prop]);
} else {
elm.style[prop] = newValue[prop];
}
}
}
} else if (memberName === "key") ; else if (memberName === "ref") {
if (newValue) {
newValue(elm);
}
} else if ((!isProp ) && memberName[0] === "o" && memberName[1] === "n") {
if (memberName[2] === "-") {
memberName = memberName.slice(3);
} else if (isMemberInElement(win, ln)) {
memberName = ln.slice(2);
} else {
memberName = ln[2] + memberName.slice(3);
}
if (oldValue || newValue) {
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
if (oldValue) {
plt.rel(elm, memberName, oldValue, capture);
}
if (newValue) {
plt.ael(elm, memberName, newValue, capture);
}
}
} else {
const isComplex = isComplexType(newValue);
if ((isProp || isComplex && newValue !== null) && !isSvg) {
try {
if (!elm.tagName.includes("-")) {
const n = newValue == null ? "" : newValue;
if (memberName === "list") {
isProp = false;
} else if (oldValue == null || elm[memberName] != n) {
if (typeof elm.__lookupSetter__(memberName) === "function") {
elm[memberName] = n;
} else {
elm.setAttribute(memberName, n);
}
}
} else if (elm[memberName] !== newValue) {
elm[memberName] = newValue;
}
} catch (e) {
}
}
let xlink = false;
{
if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
memberName = ln;
xlink = true;
}
}
if (newValue == null || newValue === false) {
if (newValue !== false || elm.getAttribute(memberName) === "") {
if (xlink) {
elm.removeAttributeNS(XLINK_NS, memberName);
} else {
elm.removeAttribute(memberName);
}
}
} else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
newValue = newValue === true ? "" : newValue;
if (xlink) {
elm.setAttributeNS(XLINK_NS, memberName, newValue);
} else {
elm.setAttribute(memberName, newValue);
}
}
}
}
};
var parseClassListRegex = /\s/;
var parseClassList = (value) => {
if (typeof value === "object" && value && "baseVal" in value) {
value = value.baseVal;
}
if (!value || typeof value !== "string") {
return [];
}
return value.split(parseClassListRegex);
};
var CAPTURE_EVENT_SUFFIX = "Capture";
var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
// src/runtime/vdom/update-element.ts
var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
const newVnodeAttrs = newVnode.$attrs$ || {};
{
for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
if (!(memberName in newVnodeAttrs)) {
setAccessor(
elm,
memberName,
oldVnodeAttrs[memberName],
void 0,
isSvgMode2,
newVnode.$flags$,
isInitialRender
);
}
}
}
for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
setAccessor(
elm,
memberName,
oldVnodeAttrs[memberName],
newVnodeAttrs[memberName],
isSvgMode2,
newVnode.$flags$,
isInitialRender
);
}
};
function sortedAttrNames(attrNames) {
return attrNames.includes("ref") ? (
// we need to sort these to ensure that `'ref'` is the last attr
[...attrNames.filter((attr) => attr !== "ref"), "ref"]
) : (
// no need to sort, return the original array
attrNames
);
}
var contentRef;
var hostTagName;
var useNativeShadowDom = false;
var checkSlotFallbackVisibility = false;
var checkSlotRelocate = false;
var isSvgMode = false;
var createElm = (oldParentVNode, newParentVNode, childIndex) => {
var _a;
const newVNode2 = newParentVNode.$children$[childIndex];
let i2 = 0;
let elm;
let childNode;
let oldVNode;
if (!useNativeShadowDom) {
checkSlotRelocate = true;
if (newVNode2.$tag$ === "slot") {
newVNode2.$flags$ |= newVNode2.$children$ ? (
// slot element has fallback content
// still create an element that "mocks" the slot element
2 /* isSlotFallback */
) : (
// slot element does not have fallback content
// create an html comment we'll use to always reference
// where actual slot content should sit next to
1 /* isSlotReference */
);
}
}
if (newVNode2.$text$ !== null) {
elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
} else if (newVNode2.$flags$ & 1 /* isSlotReference */) {
elm = newVNode2.$elm$ = doc.createTextNode("");
} else {
if (!isSvgMode) {
isSvgMode = newVNode2.$tag$ === "svg";
}
elm = newVNode2.$elm$ = doc.createElementNS(
isSvgMode ? SVG_NS : HTML_NS,
!useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
) ;
if (isSvgMode && newVNode2.$tag$ === "foreignObject") {
isSvgMode = false;
}
{
updateElement(null, newVNode2, isSvgMode);
}
if (newVNode2.$children$) {
for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
childNode = createElm(oldParentVNode, newVNode2, i2);
if (childNode) {
elm.appendChild(childNode);
}
}
}
{
if (newVNode2.$tag$ === "svg") {
isSvgMode = false;
} else if (elm.tagName === "foreignObject") {
isSvgMode = true;
}
}
}
elm["s-hn"] = hostTagName;
{
if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
elm["s-sr"] = true;
elm["s-cr"] = contentRef;
elm["s-sn"] = newVNode2.$name$ || "";