";
}
}
function validateMatchingNode(node, nodeType, tagName, lView, tNode, isViewContainerAnchor = false) {
if (!node || node.nodeType !== nodeType || node.nodeType === Node.ELEMENT_NODE && node.tagName.toLowerCase() !== tagName?.toLowerCase()) {
const expectedNode = shortRNodeDescription(nodeType, tagName, null);
let header = `During hydration Angular expected ${expectedNode} but `;
const hostComponentDef = getDeclarationComponentDef(lView);
const componentClassName = hostComponentDef?.type?.name;
const expectedDom = describeExpectedDom(lView, tNode, isViewContainerAnchor);
const expected = `Angular expected this DOM:
${expectedDom}
`;
let actual = "";
const componentHostElement = unwrapRNode(lView[HOST]);
if (!node) {
header += `the node was not found.
`;
markRNodeAsHavingHydrationMismatch(componentHostElement, expectedDom);
} else {
const actualNode = shortRNodeDescription(node.nodeType, node.tagName ?? null, node.textContent ?? null);
header += `found ${actualNode}.
`;
const actualDom = describeDomFromNode(node);
actual = `Actual DOM is:
${actualDom}
`;
markRNodeAsHavingHydrationMismatch(componentHostElement, expectedDom, actualDom);
}
const footer = getHydrationErrorFooter(componentClassName);
const message = header + expected + actual + getHydrationAttributeNote() + footer;
throw new RuntimeError(-500, message);
}
}
function validateSiblingNodeExists(node) {
validateNodeExists(node);
if (!node.nextSibling) {
const header = "During hydration Angular expected more sibling nodes to be present.\n\n";
const actual = `Actual DOM is:
${describeDomFromNode(node)}
`;
const footer = getHydrationErrorFooter();
const message = header + actual + footer;
markRNodeAsHavingHydrationMismatch(node, "", actual);
throw new RuntimeError(-501, message);
}
}
function validateNodeExists(node, lView = null, tNode = null) {
if (!node) {
const header = "During hydration, Angular expected an element to be present at this location.\n\n";
let expected = "";
let footer = "";
if (lView !== null && tNode !== null) {
expected = describeExpectedDom(lView, tNode, false);
footer = getHydrationErrorFooter();
markRNodeAsHavingHydrationMismatch(unwrapRNode(lView[HOST]), expected, "");
}
throw new RuntimeError(-502, `${header}${expected}
${footer}`);
}
}
function nodeNotFoundError(lView, tNode) {
const header = "During serialization, Angular was unable to find an element in the DOM:\n\n";
const expected = `${describeExpectedDom(lView, tNode, false)}
`;
const footer = getHydrationErrorFooter();
throw new RuntimeError(-502, header + expected + footer);
}
function nodeNotFoundAtPathError(host, path) {
const header = `During hydration Angular was unable to locate a node using the "${path}" path, starting from the ${describeRNode(host)} node.
`;
const footer = getHydrationErrorFooter();
markRNodeAsHavingHydrationMismatch(host);
throw new RuntimeError(-502, header + footer);
}
function unsupportedProjectionOfDomNodes(rNode) {
const header = "During serialization, Angular detected DOM nodes that were created outside of Angular context and provided as projectable nodes (likely via `ViewContainerRef.createComponent` or `createComponent` APIs). Hydration is not supported for such cases, consider refactoring the code to avoid this pattern or using `ngSkipHydration` on the host element of the component.\n\n";
const actual = `${describeDomFromNode(rNode)}
`;
const message = header + actual + getHydrationAttributeNote();
return new RuntimeError(-503, message);
}
function invalidSkipHydrationHost(rNode) {
const header = "The `ngSkipHydration` flag is applied on a node that doesn't act as a component host. Hydration can be skipped only on per-component basis.\n\n";
const actual = `${describeDomFromNode(rNode)}
`;
const footer = "Please move the `ngSkipHydration` attribute to the component host element.\n\n";
const message = header + actual + footer;
return new RuntimeError(-504, message);
}
function stringifyTNodeAttrs(tNode) {
const results = [];
if (tNode.attrs) {
for (let i = 0; i < tNode.attrs.length; ) {
const attrName = tNode.attrs[i++];
if (typeof attrName == "number") {
break;
}
const attrValue = tNode.attrs[i++];
results.push(`${attrName}="${shorten(attrValue)}"`);
}
}
return results.join(" ");
}
var internalAttrs = /* @__PURE__ */ new Set(["ngh", "ng-version", "ng-server-context"]);
function stringifyRNodeAttrs(rNode) {
const results = [];
for (let i = 0; i < rNode.attributes.length; i++) {
const attr = rNode.attributes[i];
if (internalAttrs.has(attr.name))
continue;
results.push(`${attr.name}="${shorten(attr.value)}"`);
}
return results.join(" ");
}
function describeTNode(tNode, innerContent = "…") {
switch (tNode.type) {
case 1:
const content = tNode.value ? `(${tNode.value})` : "";
return `#text${content}`;
case 2:
const attrs = stringifyTNodeAttrs(tNode);
const tag = tNode.value.toLowerCase();
return `<${tag}${attrs ? " " + attrs : ""}>${innerContent}${tag}>`;
case 8:
return "";
case 4:
return "";
default:
const typeAsString = getFriendlyStringFromTNodeType(tNode.type);
return `#node(${typeAsString})`;
}
}
function describeRNode(rNode, innerContent = "…") {
const node = rNode;
switch (node.nodeType) {
case Node.ELEMENT_NODE:
const tag = node.tagName.toLowerCase();
const attrs = stringifyRNodeAttrs(node);
return `<${tag}${attrs ? " " + attrs : ""}>${innerContent}${tag}>`;
case Node.TEXT_NODE:
const content = node.textContent ? shorten(node.textContent) : "";
return `#text${content ? `(${content})` : ""}`;
case Node.COMMENT_NODE:
return ``;
default:
return `#node(${node.nodeType})`;
}
}
function describeExpectedDom(lView, tNode, isViewContainerAnchor) {
const spacer = " ";
let content = "";
if (tNode.prev) {
content += spacer + "…\n";
content += spacer + describeTNode(tNode.prev) + "\n";
} else if (tNode.type && tNode.type & 12) {
content += spacer + "…\n";
}
if (isViewContainerAnchor) {
content += spacer + describeTNode(tNode) + "\n";
content += spacer + ` ${AT_THIS_LOCATION}
`;
} else {
content += spacer + describeTNode(tNode) + ` ${AT_THIS_LOCATION}
`;
}
content += spacer + "…\n";
const parentRNode = tNode.type ? getParentRElement(lView[TVIEW], tNode, lView) : null;
if (parentRNode) {
content = describeRNode(parentRNode, "\n" + content);
}
return content;
}
function describeDomFromNode(node) {
const spacer = " ";
let content = "";
const currentNode = node;
if (currentNode.previousSibling) {
content += spacer + "…\n";
content += spacer + describeRNode(currentNode.previousSibling) + "\n";
}
content += spacer + describeRNode(currentNode) + ` ${AT_THIS_LOCATION}
`;
if (node.nextSibling) {
content += spacer + "…\n";
}
if (node.parentNode) {
content = describeRNode(currentNode.parentNode, "\n" + content);
}
return content;
}
function shortRNodeDescription(nodeType, tagName, textContent) {
switch (nodeType) {
case Node.ELEMENT_NODE:
return `<${tagName.toLowerCase()}>`;
case Node.TEXT_NODE:
const content = textContent ? ` (with the "${shorten(textContent)}" content)` : "";
return `a text node${content}`;
case Node.COMMENT_NODE:
return "a comment node";
default:
return `#node(nodeType=${nodeType})`;
}
}
function getHydrationErrorFooter(componentClassName) {
const componentInfo = componentClassName ? `the "${componentClassName}"` : "corresponding";
return `To fix this problem:
* check ${componentInfo} component for hydration-related issues
* check to see if your template has valid HTML structure
* or skip hydration by adding the \`ngSkipHydration\` attribute to its host node in a template
`;
}
function getHydrationAttributeNote() {
return "Note: attributes are only displayed to better represent the DOM but have no effect on hydration mismatches.\n\n";
}
function stripNewlines(input2) {
return input2.replace(/\s+/gm, "");
}
function shorten(input2, maxLength = 50) {
if (!input2) {
return "";
}
input2 = stripNewlines(input2);
return input2.length > maxLength ? `${input2.substring(0, maxLength - 1)}…` : input2;
}
function getInsertInFrontOfRNodeWithI18n(parentTNode, currentTNode, lView) {
const tNodeInsertBeforeIndex = currentTNode.insertBeforeIndex;
const insertBeforeIndex = Array.isArray(tNodeInsertBeforeIndex) ? tNodeInsertBeforeIndex[0] : tNodeInsertBeforeIndex;
if (insertBeforeIndex === null) {
return getInsertInFrontOfRNodeWithNoI18n(parentTNode, currentTNode, lView);
} else {
ngDevMode && assertIndexInRange(lView, insertBeforeIndex);
return unwrapRNode(lView[insertBeforeIndex]);
}
}
function processI18nInsertBefore(renderer, childTNode, lView, childRNode, parentRElement) {
const tNodeInsertBeforeIndex = childTNode.insertBeforeIndex;
if (Array.isArray(tNodeInsertBeforeIndex)) {
ngDevMode && assertDomNode(childRNode);
let i18nParent = childRNode;
let anchorRNode = null;
if (!(childTNode.type & 3)) {
anchorRNode = i18nParent;
i18nParent = parentRElement;
}
if (i18nParent !== null && childTNode.componentOffset === -1) {
for (let i = 1; i < tNodeInsertBeforeIndex.length; i++) {
const i18nChild = lView[tNodeInsertBeforeIndex[i]];
nativeInsertBefore(renderer, i18nParent, i18nChild, anchorRNode, false);
}
}
}
}
function getOrCreateTNode(tView, index, type, name, attrs) {
ngDevMode && index !== 0 && // 0 are bogus nodes and they are OK. See `createContainerRef` in
// `view_engine_compatibility` for additional context.
assertGreaterThanOrEqual(index, HEADER_OFFSET, "TNodes can't be in the LView header.");
ngDevMode && assertPureTNodeType(type);
let tNode = tView.data[index];
if (tNode === null) {
tNode = createTNodeAtIndex(tView, index, type, name, attrs);
if (isInI18nBlock()) {
tNode.flags |= 32;
}
} else if (tNode.type & 64) {
tNode.type = type;
tNode.value = name;
tNode.attrs = attrs;
const parent = getCurrentParentTNode();
tNode.injectorIndex = parent === null ? -1 : parent.injectorIndex;
ngDevMode && assertTNodeForTView(tNode, tView);
ngDevMode && assertEqual(index, tNode.index, "Expecting same index");
}
setCurrentTNode(tNode, true);
return tNode;
}
function createTNodeAtIndex(tView, index, type, name, attrs) {
const currentTNode = getCurrentTNodePlaceholderOk();
const isParent = isCurrentTNodeParent();
const parent = isParent ? currentTNode : currentTNode && currentTNode.parent;
const tNode = tView.data[index] = createTNode(tView, parent, type, index, name, attrs);
linkTNodeInTView(tView, tNode, currentTNode, isParent);
return tNode;
}
function linkTNodeInTView(tView, tNode, currentTNode, isParent) {
if (tView.firstChild === null) {
tView.firstChild = tNode;
}
if (currentTNode !== null) {
if (isParent) {
if (currentTNode.child == null && tNode.parent !== null) {
currentTNode.child = tNode;
}
} else {
if (currentTNode.next === null) {
currentTNode.next = tNode;
tNode.prev = currentTNode;
}
}
}
}
function createTNode(tView, tParent, type, index, value, attrs) {
ngDevMode && index !== 0 && // 0 are bogus nodes and they are OK. See `createContainerRef` in
// `view_engine_compatibility` for additional context.
assertGreaterThanOrEqual(index, HEADER_OFFSET, "TNodes can't be in the LView header.");
ngDevMode && assertNotSame(attrs, void 0, "'undefined' is not valid value for 'attrs'");
ngDevMode && tParent && assertTNodeForTView(tParent, tView);
let injectorIndex = tParent ? tParent.injectorIndex : -1;
let flags = 0;
if (isInSkipHydrationBlock()) {
flags |= 128;
}
const tNode = {
type,
index,
insertBeforeIndex: null,
injectorIndex,
directiveStart: -1,
directiveEnd: -1,
directiveStylingLast: -1,
componentOffset: -1,
propertyBindings: null,
flags,
providerIndexes: 0,
value,
attrs,
mergedAttrs: null,
localNames: null,
initialInputs: null,
inputs: null,
hostDirectiveInputs: null,
outputs: null,
hostDirectiveOutputs: null,
directiveToIndex: null,
tView: null,
next: null,
prev: null,
projectionNext: null,
child: null,
parent: tParent,
projection: null,
styles: null,
stylesWithoutHost: null,
residualStyles: void 0,
classes: null,
classesWithoutHost: null,
residualClasses: void 0,
classBindings: 0,
styleBindings: 0
};
if (ngDevMode) {
Object.seal(tNode);
}
return tNode;
}
function addTNodeAndUpdateInsertBeforeIndex(previousTNodes, newTNode) {
ngDevMode && assertEqual(newTNode.insertBeforeIndex, null, "We expect that insertBeforeIndex is not set");
previousTNodes.push(newTNode);
if (previousTNodes.length > 1) {
for (let i = previousTNodes.length - 2; i >= 0; i--) {
const existingTNode = previousTNodes[i];
if (!isI18nText(existingTNode)) {
if (isNewTNodeCreatedBefore(existingTNode, newTNode) && getInsertBeforeIndex(existingTNode) === null) {
setInsertBeforeIndex(existingTNode, newTNode.index);
}
}
}
}
}
function isI18nText(tNode) {
return !(tNode.type & 64);
}
function isNewTNodeCreatedBefore(existingTNode, newTNode) {
return isI18nText(newTNode) || existingTNode.index > newTNode.index;
}
function getInsertBeforeIndex(tNode) {
const index = tNode.insertBeforeIndex;
return Array.isArray(index) ? index[0] : index;
}
function setInsertBeforeIndex(tNode, value) {
const index = tNode.insertBeforeIndex;
if (Array.isArray(index)) {
index[0] = value;
} else {
setI18nHandling(getInsertInFrontOfRNodeWithI18n, processI18nInsertBefore);
tNode.insertBeforeIndex = value;
}
}
function getTIcu(tView, index) {
const value = tView.data[index];
if (value === null || typeof value === "string")
return null;
if (ngDevMode && !(value.hasOwnProperty("tView") || value.hasOwnProperty("currentCaseLViewIndex"))) {
throwError("We expect to get 'null'|'TIcu'|'TIcuContainer', but got: " + value);
}
const tIcu = value.hasOwnProperty("currentCaseLViewIndex") ? value : value.value;
ngDevMode && assertTIcu(tIcu);
return tIcu;
}
function setTIcu(tView, index, tIcu) {
const tNode = tView.data[index];
ngDevMode && assertEqual(tNode === null || tNode.hasOwnProperty("tView"), true, "We expect to get 'null'|'TIcuContainer'");
if (tNode === null) {
tView.data[index] = tIcu;
} else {
ngDevMode && assertTNodeType(
tNode,
32
/* TNodeType.Icu */
);
tNode.value = tIcu;
}
}
function setTNodeInsertBeforeIndex(tNode, index) {
ngDevMode && assertTNode(tNode);
let insertBeforeIndex = tNode.insertBeforeIndex;
if (insertBeforeIndex === null) {
setI18nHandling(getInsertInFrontOfRNodeWithI18n, processI18nInsertBefore);
insertBeforeIndex = tNode.insertBeforeIndex = [
null,
index
];
} else {
assertEqual(Array.isArray(insertBeforeIndex), true, "Expecting array here");
insertBeforeIndex.push(index);
}
}
function createTNodePlaceholder(tView, previousTNodes, index) {
const tNode = createTNodeAtIndex(tView, index, 64, null, null);
addTNodeAndUpdateInsertBeforeIndex(previousTNodes, tNode);
return tNode;
}
function getCurrentICUCaseIndex(tIcu, lView) {
const currentCase = lView[tIcu.currentCaseLViewIndex];
return currentCase === null ? currentCase : currentCase < 0 ? ~currentCase : currentCase;
}
function getParentFromIcuCreateOpCode(mergedCode) {
return mergedCode >>> 17;
}
function getRefFromIcuCreateOpCode(mergedCode) {
return (mergedCode & 131070) >>> 1;
}
function getInstructionFromIcuCreateOpCode(mergedCode) {
return mergedCode & 1;
}
function icuCreateOpCode(opCode, parentIdx, refIdx) {
ngDevMode && assertGreaterThanOrEqual(parentIdx, 0, "Missing parent index");
ngDevMode && assertGreaterThan(refIdx, 0, "Missing ref index");
return opCode | parentIdx << 17 | refIdx << 1;
}
function isRootTemplateMessage(subTemplateIndex) {
return subTemplateIndex === -1;
}
function enterIcu(state, tIcu, lView) {
state.index = 0;
const currentCase = getCurrentICUCaseIndex(tIcu, lView);
if (currentCase !== null) {
ngDevMode && assertNumberInRange(currentCase, 0, tIcu.cases.length - 1);
state.removes = tIcu.remove[currentCase];
} else {
state.removes = EMPTY_ARRAY;
}
}
function icuContainerIteratorNext(state) {
if (state.index < state.removes.length) {
const removeOpCode = state.removes[state.index++];
ngDevMode && assertNumber(removeOpCode, "Expecting OpCode number");
if (removeOpCode > 0) {
const rNode = state.lView[removeOpCode];
ngDevMode && assertDomNode(rNode);
return rNode;
} else {
state.stack.push(state.index, state.removes);
const tIcuIndex = ~removeOpCode;
const tIcu = state.lView[TVIEW].data[tIcuIndex];
ngDevMode && assertTIcu(tIcu);
enterIcu(state, tIcu, state.lView);
return icuContainerIteratorNext(state);
}
} else {
if (state.stack.length === 0) {
return null;
} else {
state.removes = state.stack.pop();
state.index = state.stack.pop();
return icuContainerIteratorNext(state);
}
}
}
function loadIcuContainerVisitor() {
const _state = {
stack: [],
index: -1
};
function icuContainerIteratorStart(tIcuContainerNode, lView) {
_state.lView = lView;
while (_state.stack.length)
_state.stack.pop();
ngDevMode && assertTNodeForLView(tIcuContainerNode, lView);
enterIcu(_state, tIcuContainerNode.value, lView);
return icuContainerIteratorNext.bind(null, _state);
}
return icuContainerIteratorStart;
}
function createIcuIterator(tIcu, lView) {
const state = {
stack: [],
index: -1,
lView
};
ngDevMode && assertTIcu(tIcu);
enterIcu(state, tIcu, lView);
return icuContainerIteratorNext.bind(null, state);
}
var REF_EXTRACTOR_REGEXP = new RegExp(`^(\\d+)*(${REFERENCE_NODE_BODY}|${REFERENCE_NODE_HOST})*(.*)`);
function compressNodeLocation(referenceNode, path) {
const result = [referenceNode];
for (const segment of path) {
const lastIdx = result.length - 1;
if (lastIdx > 0 && result[lastIdx - 1] === segment) {
const value = result[lastIdx] || 1;
result[lastIdx] = value + 1;
} else {
result.push(segment, "");
}
}
return result.join("");
}
function decompressNodeLocation(path) {
const matches = path.match(REF_EXTRACTOR_REGEXP);
const [_, refNodeId, refNodeName, rest] = matches;
const ref = refNodeId ? parseInt(refNodeId, 10) : refNodeName;
const steps = [];
for (const [_2, step, count] of rest.matchAll(/(f|n)(\d*)/g)) {
const repeat = parseInt(count, 10) || 1;
steps.push(step, repeat);
}
return [ref, ...steps];
}
function isFirstElementInNgContainer(tNode) {
return !tNode.prev && tNode.parent?.type === 8;
}
function getNoOffsetIndex(tNode) {
return tNode.index - HEADER_OFFSET;
}
function isDisconnectedNode(tNode, lView) {
return !(tNode.type & (16 | 128)) && !!lView[tNode.index] && isDisconnectedRNode(unwrapRNode(lView[tNode.index]));
}
function isDisconnectedRNode(rNode) {
return !!rNode && !rNode.isConnected;
}
function locateI18nRNodeByIndex(hydrationInfo, noOffsetIndex) {
const i18nNodes = hydrationInfo.i18nNodes;
if (i18nNodes) {
return i18nNodes.get(noOffsetIndex);
}
return void 0;
}
function tryLocateRNodeByPath(hydrationInfo, lView, noOffsetIndex) {
const nodes = hydrationInfo.data[NODES];
const path = nodes?.[noOffsetIndex];
return path ? locateRNodeByPath(path, lView) : null;
}
function locateNextRNode(hydrationInfo, tView, lView, tNode) {
const noOffsetIndex = getNoOffsetIndex(tNode);
let native = locateI18nRNodeByIndex(hydrationInfo, noOffsetIndex);
if (native === void 0) {
const nodes = hydrationInfo.data[NODES];
if (nodes?.[noOffsetIndex]) {
native = locateRNodeByPath(nodes[noOffsetIndex], lView);
} else if (tView.firstChild === tNode) {
native = hydrationInfo.firstChild;
} else {
const previousTNodeParent = tNode.prev === null;
const previousTNode = tNode.prev ?? tNode.parent;
ngDevMode && assertDefined(previousTNode, "Unexpected state: current TNode does not have a connection to the previous node or a parent node.");
if (isFirstElementInNgContainer(tNode)) {
const noOffsetParentIndex = getNoOffsetIndex(tNode.parent);
native = getSegmentHead(hydrationInfo, noOffsetParentIndex);
} else {
let previousRElement = getNativeByTNode(previousTNode, lView);
if (previousTNodeParent) {
native = previousRElement.firstChild;
} else {
const noOffsetPrevSiblingIndex = getNoOffsetIndex(previousTNode);
const segmentHead = getSegmentHead(hydrationInfo, noOffsetPrevSiblingIndex);
if (previousTNode.type === 2 && segmentHead) {
const numRootNodesToSkip = calcSerializedContainerSize(hydrationInfo, noOffsetPrevSiblingIndex);
const nodesToSkip = numRootNodesToSkip + 1;
native = siblingAfter(nodesToSkip, segmentHead);
} else {
native = previousRElement.nextSibling;
}
}
}
}
}
return native;
}
function siblingAfter(skip, from) {
let currentNode = from;
for (let i = 0; i < skip; i++) {
ngDevMode && validateSiblingNodeExists(currentNode);
currentNode = currentNode.nextSibling;
}
return currentNode;
}
function stringifyNavigationInstructions(instructions) {
const container = [];
for (let i = 0; i < instructions.length; i += 2) {
const step = instructions[i];
const repeat = instructions[i + 1];
for (let r = 0; r < repeat; r++) {
container.push(step === NODE_NAVIGATION_STEP_FIRST_CHILD ? "firstChild" : "nextSibling");
}
}
return container.join(".");
}
function navigateToNode(from, instructions) {
let node = from;
for (let i = 0; i < instructions.length; i += 2) {
const step = instructions[i];
const repeat = instructions[i + 1];
for (let r = 0; r < repeat; r++) {
if (ngDevMode && !node) {
throw nodeNotFoundAtPathError(from, stringifyNavigationInstructions(instructions));
}
switch (step) {
case NODE_NAVIGATION_STEP_FIRST_CHILD:
node = node.firstChild;
break;
case NODE_NAVIGATION_STEP_NEXT_SIBLING:
node = node.nextSibling;
break;
}
}
}
if (ngDevMode && !node) {
throw nodeNotFoundAtPathError(from, stringifyNavigationInstructions(instructions));
}
return node;
}
function locateRNodeByPath(path, lView) {
const [referenceNode, ...navigationInstructions] = decompressNodeLocation(path);
let ref;
if (referenceNode === REFERENCE_NODE_HOST) {
ref = lView[DECLARATION_COMPONENT_VIEW][HOST];
} else if (referenceNode === REFERENCE_NODE_BODY) {
ref = ɵɵresolveBody(lView[DECLARATION_COMPONENT_VIEW][HOST]);
} else {
const parentElementId = Number(referenceNode);
ref = unwrapRNode(lView[parentElementId + HEADER_OFFSET]);
}
return navigateToNode(ref, navigationInstructions);
}
function navigateBetween(start, finish) {
if (start === finish) {
return [];
} else if (start.parentElement == null || finish.parentElement == null) {
return null;
} else if (start.parentElement === finish.parentElement) {
return navigateBetweenSiblings(start, finish);
} else {
const parent = finish.parentElement;
const parentPath = navigateBetween(start, parent);
const childPath = navigateBetween(parent.firstChild, finish);
if (!parentPath || !childPath)
return null;
return [
// First navigate to `finish`'s parent
...parentPath,
// Then to its first child.
NODE_NAVIGATION_STEP_FIRST_CHILD,
// And finally from that node to `finish` (maybe a no-op if we're already there).
...childPath
];
}
}
function navigateBetweenSiblings(start, finish) {
const nav = [];
let node = null;
for (node = start; node != null && node !== finish; node = node.nextSibling) {
nav.push(NODE_NAVIGATION_STEP_NEXT_SIBLING);
}
return node == null ? null : nav;
}
function calcPathBetween(from, to, fromNodeName) {
const path = navigateBetween(from, to);
return path === null ? null : compressNodeLocation(fromNodeName, path);
}
function calcPathForNode(tNode, lView, excludedParentNodes) {
let parentTNode = tNode.parent;
let parentIndex;
let parentRNode;
let referenceNodeName;
while (parentTNode !== null && (isDisconnectedNode(parentTNode, lView) || excludedParentNodes?.has(parentTNode.index))) {
parentTNode = parentTNode.parent;
}
if (parentTNode === null || !(parentTNode.type & 3)) {
parentIndex = referenceNodeName = REFERENCE_NODE_HOST;
parentRNode = lView[DECLARATION_COMPONENT_VIEW][HOST];
} else {
parentIndex = parentTNode.index;
parentRNode = unwrapRNode(lView[parentIndex]);
referenceNodeName = renderStringify(parentIndex - HEADER_OFFSET);
}
let rNode = unwrapRNode(lView[tNode.index]);
if (tNode.type & (12 | 32)) {
const firstRNode = getFirstNativeNode(lView, tNode);
if (firstRNode) {
rNode = firstRNode;
}
}
let path = calcPathBetween(parentRNode, rNode, referenceNodeName);
if (path === null && parentRNode !== rNode) {
const body = parentRNode.ownerDocument.body;
path = calcPathBetween(body, rNode, REFERENCE_NODE_BODY);
if (path === null) {
throw nodeNotFoundError(lView, tNode);
}
}
return path;
}
function gatherDeferBlocksCommentNodes(doc, node) {
const commentNodesIterator = doc.createNodeIterator(node, NodeFilter.SHOW_COMMENT, { acceptNode });
let currentNode;
const nodesByBlockId = /* @__PURE__ */ new Map();
while (currentNode = commentNodesIterator.nextNode()) {
const nghPattern = "ngh=";
const content = currentNode?.textContent;
const nghIdx = content?.indexOf(nghPattern) ?? -1;
if (nghIdx > -1) {
const nghValue = content.substring(nghIdx + nghPattern.length).trim();
ngDevMode && assertEqual(nghValue.startsWith("d"), true, "Invalid defer block id found in a comment node.");
nodesByBlockId.set(nghValue, currentNode);
}
}
return nodesByBlockId;
}
function acceptNode(node) {
return node.textContent?.trimStart().startsWith("ngh=") ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
}
var _isI18nHydrationSupportEnabled = false;
var _prepareI18nBlockForHydrationImpl = () => {
};
function setIsI18nHydrationSupportEnabled(enabled) {
_isI18nHydrationSupportEnabled = enabled;
}
function isI18nHydrationSupportEnabled() {
return _isI18nHydrationSupportEnabled;
}
function prepareI18nBlockForHydration(lView, index, parentTNode, subTemplateIndex) {
_prepareI18nBlockForHydrationImpl(lView, index, parentTNode, subTemplateIndex);
}
function enablePrepareI18nBlockForHydrationImpl() {
_prepareI18nBlockForHydrationImpl = prepareI18nBlockForHydrationImpl;
}
function isI18nHydrationEnabled(injector) {
injector = injector ?? inject(Injector);
return injector.get(IS_I18N_HYDRATION_ENABLED, false);
}
function getOrComputeI18nChildren(tView, context) {
let i18nChildren = context.i18nChildren.get(tView);
if (i18nChildren === void 0) {
i18nChildren = collectI18nChildren(tView);
context.i18nChildren.set(tView, i18nChildren);
}
return i18nChildren;
}
function collectI18nChildren(tView) {
const children = /* @__PURE__ */ new Set();
function collectI18nViews(node) {
children.add(node.index);
switch (node.kind) {
case 1:
case 2: {
for (const childNode of node.children) {
collectI18nViews(childNode);
}
break;
}
case 3: {
for (const caseNodes of node.cases) {
for (const caseNode of caseNodes) {
collectI18nViews(caseNode);
}
}
break;
}
}
}
for (let i = HEADER_OFFSET; i < tView.bindingStartIndex; i++) {
const tI18n = tView.data[i];
if (!tI18n || !tI18n.ast) {
continue;
}
for (const node of tI18n.ast) {
collectI18nViews(node);
}
}
return children.size === 0 ? null : children;
}
function trySerializeI18nBlock(lView, index, context) {
if (!context.isI18nHydrationEnabled) {
return null;
}
const tView = lView[TVIEW];
const tI18n = tView.data[index];
if (!tI18n || !tI18n.ast) {
return null;
}
const parentTNode = tView.data[tI18n.parentTNodeIndex];
if (parentTNode && isI18nInSkipHydrationBlock(parentTNode)) {
return null;
}
const serializedI18nBlock = {
caseQueue: [],
disconnectedNodes: /* @__PURE__ */ new Set(),
disjointNodes: /* @__PURE__ */ new Set()
};
serializeI18nBlock(lView, serializedI18nBlock, context, tI18n.ast);
return serializedI18nBlock.caseQueue.length === 0 && serializedI18nBlock.disconnectedNodes.size === 0 && serializedI18nBlock.disjointNodes.size === 0 ? null : serializedI18nBlock;
}
function serializeI18nBlock(lView, serializedI18nBlock, context, nodes) {
let prevRNode = null;
for (const node of nodes) {
const nextRNode = serializeI18nNode(lView, serializedI18nBlock, context, node);
if (nextRNode) {
if (isDisjointNode(prevRNode, nextRNode)) {
serializedI18nBlock.disjointNodes.add(node.index - HEADER_OFFSET);
}
prevRNode = nextRNode;
}
}
return prevRNode;
}
function isDisjointNode(prevNode, nextNode) {
return prevNode && prevNode.nextSibling !== nextNode;
}
function serializeI18nNode(lView, serializedI18nBlock, context, node) {
const maybeRNode = unwrapRNode(lView[node.index]);
if (!maybeRNode || isDisconnectedRNode(maybeRNode)) {
serializedI18nBlock.disconnectedNodes.add(node.index - HEADER_OFFSET);
return null;
}
const rNode = maybeRNode;
switch (node.kind) {
case 0: {
processTextNodeBeforeSerialization(context, rNode);
break;
}
case 1:
case 2: {
serializeI18nBlock(lView, serializedI18nBlock, context, node.children);
break;
}
case 3: {
const currentCase = lView[node.currentCaseLViewIndex];
if (currentCase != null) {
const caseIdx = currentCase < 0 ? ~currentCase : currentCase;
serializedI18nBlock.caseQueue.push(caseIdx);
serializeI18nBlock(lView, serializedI18nBlock, context, node.cases[caseIdx]);
}
break;
}
}
return getFirstNativeNodeForI18nNode(lView, node);
}
function getFirstNativeNodeForI18nNode(lView, node) {
const tView = lView[TVIEW];
const maybeTNode = tView.data[node.index];
if (isTNodeShape(maybeTNode)) {
return getFirstNativeNode(lView, maybeTNode);
} else if (node.kind === 3) {
const icuIterator = createIcuIterator(maybeTNode, lView);
let rNode = icuIterator();
return rNode ?? unwrapRNode(lView[node.index]);
} else {
return unwrapRNode(lView[node.index]) ?? null;
}
}
function setCurrentNode(state, node) {
state.currentNode = node;
}
function appendI18nNodeToCollection(context, state, astNode) {
const noOffsetIndex = astNode.index - HEADER_OFFSET;
const { disconnectedNodes } = context;
const currentNode = state.currentNode;
if (state.isConnected) {
context.i18nNodes.set(noOffsetIndex, currentNode);
disconnectedNodes.delete(noOffsetIndex);
} else {
disconnectedNodes.add(noOffsetIndex);
}
return currentNode;
}
function skipSiblingNodes(state, skip) {
let currentNode = state.currentNode;
for (let i = 0; i < skip; i++) {
if (!currentNode) {
break;
}
currentNode = currentNode?.nextSibling ?? null;
}
return currentNode;
}
function forkHydrationState(state, nextNode) {
return { currentNode: nextNode, isConnected: state.isConnected };
}
function prepareI18nBlockForHydrationImpl(lView, index, parentTNode, subTemplateIndex) {
const hydrationInfo = lView[HYDRATION];
if (!hydrationInfo) {
return;
}
if (!isI18nHydrationSupportEnabled() || parentTNode && (isI18nInSkipHydrationBlock(parentTNode) || isDisconnectedNode$1(hydrationInfo, parentTNode.index - HEADER_OFFSET))) {
return;
}
const tView = lView[TVIEW];
const tI18n = tView.data[index];
ngDevMode && assertDefined(tI18n, "Expected i18n data to be present in a given TView slot during hydration");
function findHydrationRoot() {
if (isRootTemplateMessage(subTemplateIndex)) {
ngDevMode && assertDefined(parentTNode, "Expected parent TNode while hydrating i18n root");
const rootNode = locateNextRNode(hydrationInfo, tView, lView, parentTNode);
return parentTNode.type & 8 ? rootNode : rootNode.firstChild;
}
return hydrationInfo?.firstChild;
}
const currentNode = findHydrationRoot();
ngDevMode && assertDefined(currentNode, "Expected root i18n node during hydration");
const disconnectedNodes = initDisconnectedNodes(hydrationInfo) ?? /* @__PURE__ */ new Set();
const i18nNodes = hydrationInfo.i18nNodes ??= /* @__PURE__ */ new Map();
const caseQueue = hydrationInfo.data[I18N_DATA]?.[index - HEADER_OFFSET] ?? [];
const dehydratedIcuData = hydrationInfo.dehydratedIcuData ??= /* @__PURE__ */ new Map();
collectI18nNodesFromDom({ hydrationInfo, lView, i18nNodes, disconnectedNodes, caseQueue, dehydratedIcuData }, { currentNode, isConnected: true }, tI18n.ast);
hydrationInfo.disconnectedNodes = disconnectedNodes.size === 0 ? null : disconnectedNodes;
}
function collectI18nNodesFromDom(context, state, nodeOrNodes) {
if (Array.isArray(nodeOrNodes)) {
let nextState = state;
for (const node of nodeOrNodes) {
const targetNode = tryLocateRNodeByPath(context.hydrationInfo, context.lView, node.index - HEADER_OFFSET);
if (targetNode) {
nextState = forkHydrationState(state, targetNode);
}
collectI18nNodesFromDom(context, nextState, node);
}
} else {
if (context.disconnectedNodes.has(nodeOrNodes.index - HEADER_OFFSET)) {
return;
}
switch (nodeOrNodes.kind) {
case 0: {
const currentNode = appendI18nNodeToCollection(context, state, nodeOrNodes);
setCurrentNode(state, currentNode?.nextSibling ?? null);
break;
}
case 1: {
collectI18nNodesFromDom(context, forkHydrationState(state, state.currentNode?.firstChild ?? null), nodeOrNodes.children);
const currentNode = appendI18nNodeToCollection(context, state, nodeOrNodes);
setCurrentNode(state, currentNode?.nextSibling ?? null);
break;
}
case 2: {
const noOffsetIndex = nodeOrNodes.index - HEADER_OFFSET;
const { hydrationInfo } = context;
const containerSize = getNgContainerSize(hydrationInfo, noOffsetIndex);
switch (nodeOrNodes.type) {
case 0: {
const currentNode = appendI18nNodeToCollection(context, state, nodeOrNodes);
if (isSerializedElementContainer(hydrationInfo, noOffsetIndex)) {
collectI18nNodesFromDom(context, state, nodeOrNodes.children);
const nextNode = skipSiblingNodes(state, 1);
setCurrentNode(state, nextNode);
} else {
collectI18nNodesFromDom(context, forkHydrationState(state, state.currentNode?.firstChild ?? null), nodeOrNodes.children);
setCurrentNode(state, currentNode?.nextSibling ?? null);
if (containerSize !== null) {
const nextNode = skipSiblingNodes(state, containerSize + 1);
setCurrentNode(state, nextNode);
}
}
break;
}
case 1: {
ngDevMode && assertNotEqual(containerSize, null, "Expected a container size while hydrating i18n subtemplate");
appendI18nNodeToCollection(context, state, nodeOrNodes);
const nextNode = skipSiblingNodes(state, containerSize + 1);
setCurrentNode(state, nextNode);
break;
}
}
break;
}
case 3: {
const selectedCase = state.isConnected ? context.caseQueue.shift() : null;
const childState = { currentNode: null, isConnected: false };
for (let i = 0; i < nodeOrNodes.cases.length; i++) {
collectI18nNodesFromDom(context, i === selectedCase ? state : childState, nodeOrNodes.cases[i]);
}
if (selectedCase !== null) {
context.dehydratedIcuData.set(nodeOrNodes.index, { case: selectedCase, node: nodeOrNodes });
}
const currentNode = appendI18nNodeToCollection(context, state, nodeOrNodes);
setCurrentNode(state, currentNode?.nextSibling ?? null);
break;
}
}
}
}
var _claimDehydratedIcuCaseImpl = () => {
};
function claimDehydratedIcuCase(lView, icuIndex, caseIndex) {
_claimDehydratedIcuCaseImpl(lView, icuIndex, caseIndex);
}
function enableClaimDehydratedIcuCaseImpl() {
_claimDehydratedIcuCaseImpl = claimDehydratedIcuCaseImpl;
}
function claimDehydratedIcuCaseImpl(lView, icuIndex, caseIndex) {
const dehydratedIcuDataMap = lView[HYDRATION]?.dehydratedIcuData;
if (dehydratedIcuDataMap) {
const dehydratedIcuData = dehydratedIcuDataMap.get(icuIndex);
if (dehydratedIcuData?.case === caseIndex) {
dehydratedIcuDataMap.delete(icuIndex);
}
}
}
function cleanupI18nHydrationData(lView) {
const hydrationInfo = lView[HYDRATION];
if (hydrationInfo) {
const { i18nNodes, dehydratedIcuData: dehydratedIcuDataMap } = hydrationInfo;
if (i18nNodes && dehydratedIcuDataMap) {
const renderer = lView[RENDERER];
for (const dehydratedIcuData of dehydratedIcuDataMap.values()) {
cleanupDehydratedIcuData(renderer, i18nNodes, dehydratedIcuData);
}
}
hydrationInfo.i18nNodes = void 0;
hydrationInfo.dehydratedIcuData = void 0;
}
}
function cleanupDehydratedIcuData(renderer, i18nNodes, dehydratedIcuData) {
for (const node of dehydratedIcuData.node.cases[dehydratedIcuData.case]) {
const rNode = i18nNodes.get(node.index - HEADER_OFFSET);
if (rNode) {
nativeRemoveNode(renderer, rNode, false);
}
}
}
function removeDehydratedViews(lContainer) {
const views = lContainer[DEHYDRATED_VIEWS] ?? [];
const parentLView = lContainer[PARENT];
const renderer = parentLView[RENDERER];
const retainedViews = [];
for (const view of views) {
if (view.data[DEFER_BLOCK_ID] !== void 0) {
retainedViews.push(view);
} else {
removeDehydratedView(view, renderer);
ngDevMode && ngDevMode.dehydratedViewsRemoved++;
}
}
lContainer[DEHYDRATED_VIEWS] = retainedViews;
}
function removeDehydratedViewList(deferBlock) {
const { lContainer } = deferBlock;
const dehydratedViews = lContainer[DEHYDRATED_VIEWS];
if (dehydratedViews === null)
return;
const parentLView = lContainer[PARENT];
const renderer = parentLView[RENDERER];
for (const view of dehydratedViews) {
removeDehydratedView(view, renderer);
ngDevMode && ngDevMode.dehydratedViewsRemoved++;
}
}
function removeDehydratedView(dehydratedView, renderer) {
let nodesRemoved = 0;
let currentRNode = dehydratedView.firstChild;
if (currentRNode) {
const numNodes = dehydratedView.data[NUM_ROOT_NODES];
while (nodesRemoved < numNodes) {
ngDevMode && validateSiblingNodeExists(currentRNode);
const nextSibling = currentRNode.nextSibling;
nativeRemoveNode(renderer, currentRNode, false);
currentRNode = nextSibling;
nodesRemoved++;
}
}
}
function cleanupLContainer(lContainer) {
removeDehydratedViews(lContainer);
const hostLView = lContainer[HOST];
if (isLView(hostLView)) {
cleanupLView(hostLView);
}
for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) {
cleanupLView(lContainer[i]);
}
}
function cleanupLView(lView) {
cleanupI18nHydrationData(lView);
const tView = lView[TVIEW];
for (let i = HEADER_OFFSET; i < tView.bindingStartIndex; i++) {
if (isLContainer(lView[i])) {
const lContainer = lView[i];
cleanupLContainer(lContainer);
} else if (isLView(lView[i])) {
cleanupLView(lView[i]);
}
}
}
function cleanupDehydratedViews(appRef) {
const viewRefs = appRef._views;
for (const viewRef of viewRefs) {
const lNode = getLNodeForHydration(viewRef);
if (lNode !== null && lNode[HOST] !== null) {
if (isLView(lNode)) {
cleanupLView(lNode);
} else {
cleanupLContainer(lNode);
}
ngDevMode && ngDevMode.dehydratedViewsCleanupRuns++;
}
}
}
function cleanupHydratedDeferBlocks(deferBlock, hydratedBlocks, registry, appRef) {
if (deferBlock !== null) {
registry.cleanup(hydratedBlocks);
cleanupLContainer(deferBlock.lContainer);
cleanupDehydratedViews(appRef);
}
}
function locateDehydratedViewsInContainer(currentRNode, serializedViews) {
const dehydratedViews = [];
for (const serializedView of serializedViews) {
for (let i = 0; i < (serializedView[MULTIPLIER] ?? 1); i++) {
const view = {
data: serializedView,
firstChild: null
};
if (serializedView[NUM_ROOT_NODES] > 0) {
view.firstChild = currentRNode;
currentRNode = siblingAfter(serializedView[NUM_ROOT_NODES], currentRNode);
}
dehydratedViews.push(view);
}
}
return [currentRNode, dehydratedViews];
}
var _findMatchingDehydratedViewImpl = () => null;
var _findAndReconcileMatchingDehydratedViewsImpl = () => null;
function enableFindMatchingDehydratedViewImpl() {
_findMatchingDehydratedViewImpl = findMatchingDehydratedViewImpl;
_findAndReconcileMatchingDehydratedViewsImpl = findAndReconcileMatchingDehydratedViewsImpl;
}
function findMatchingDehydratedViewImpl(lContainer, template) {
if (hasMatchingDehydratedView(lContainer, template)) {
return lContainer[DEHYDRATED_VIEWS].shift();
} else {
removeDehydratedViews(lContainer);
return null;
}
}
function findMatchingDehydratedView(lContainer, template) {
return _findMatchingDehydratedViewImpl(lContainer, template);
}
function findAndReconcileMatchingDehydratedViewsImpl(lContainer, templateTNode, hostLView) {
if (templateTNode.tView.ssrId === null)
return null;
const dehydratedView = findMatchingDehydratedView(lContainer, templateTNode.tView.ssrId);
if (hostLView[TVIEW].firstUpdatePass && dehydratedView === null) {
removeStaleDehydratedBranch(hostLView, templateTNode);
}
return dehydratedView;
}
function findAndReconcileMatchingDehydratedViews(lContainer, templateTNode, hostLView) {
return _findAndReconcileMatchingDehydratedViewsImpl(lContainer, templateTNode, hostLView);
}
function removeStaleDehydratedBranch(hostLView, tNode) {
let currentTNode = tNode;
while (currentTNode) {
if (cleanupMatchingDehydratedViews(hostLView, currentTNode))
return;
if ((currentTNode.flags & 256) === 256) {
break;
}
currentTNode = currentTNode.prev;
}
currentTNode = tNode.next;
while (currentTNode) {
if ((currentTNode.flags & 512) !== 512) {
break;
}
if (cleanupMatchingDehydratedViews(hostLView, currentTNode))
return;
currentTNode = currentTNode.next;
}
}
function hasMatchingDehydratedView(lContainer, template) {
const views = lContainer[DEHYDRATED_VIEWS];
if (!template || views === null || views.length === 0) {
return false;
}
return views[0].data[TEMPLATE_ID] === template;
}
function cleanupMatchingDehydratedViews(hostLView, currentTNode) {
const ssrId = currentTNode.tView?.ssrId;
if (ssrId == null)
return false;
const container = hostLView[currentTNode.index];
if (isLContainer(container) && hasMatchingDehydratedView(container, ssrId)) {
removeDehydratedViews(container);
return true;
}
return false;
}
var ComponentRef$1 = class ComponentRef {
};
var ComponentFactory$1 = class ComponentFactory {
};
var _NullComponentFactoryResolver = class {
resolveComponentFactory(component) {
throw new RuntimeError(917, typeof ngDevMode !== "undefined" && ngDevMode && `No component factory found for ${stringify(component)}.`);
}
};
var ComponentFactoryResolver$1 = class ComponentFactoryResolver {
static NULL = new _NullComponentFactoryResolver();
};
var RendererFactory2 = class {
};
var Renderer2 = class {
/**
* If null or undefined, the view engine won't call it.
* This is used as a performance optimization for production mode.
*/
destroyNode = null;
/**
* @internal
* @nocollapse
*/
static __NG_ELEMENT_ID__ = () => injectRenderer2();
};
function injectRenderer2() {
const lView = getLView();
const tNode = getCurrentTNode();
const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER];
}
var Sanitizer = class _Sanitizer {
/** @nocollapse */
static ɵprov = (
/** @pureOrBreakMyCode */
ɵɵdefineInjectable({
token: _Sanitizer,
providedIn: "root",
factory: () => null
})
);
};
function isModuleWithProviders(value) {
return value.ngModule !== void 0;
}
function isNgModule(value) {
return !!getNgModuleDef(value);
}
function isPipe(value) {
return !!getPipeDef(value);
}
function isDirective(value) {
return !!getDirectiveDef(value);
}
function isComponent(value) {
return !!getComponentDef(value);
}
function getDependencyTypeForError(type) {
if (getComponentDef(type))
return "component";
if (getDirectiveDef(type))
return "directive";
if (getPipeDef(type))
return "pipe";
return "type";
}
function verifyStandaloneImport(depType, importingType) {
if (isForwardRef(depType)) {
depType = resolveForwardRef(depType);
if (!depType) {
throw new Error(`Expected forwardRef function, imported from "${stringifyForError(importingType)}", to return a standalone entity or NgModule but got "${stringifyForError(depType) || depType}".`);
}
}
if (getNgModuleDef(depType) == null) {
const def = getComponentDef(depType) || getDirectiveDef(depType) || getPipeDef(depType);
if (def != null) {
if (!def.standalone) {
throw new Error(`The "${stringifyForError(depType)}" ${getDependencyTypeForError(depType)}, imported from "${stringifyForError(importingType)}", is not standalone. Did you forget to add the standalone: true flag?`);
}
} else {
if (isModuleWithProviders(depType)) {
throw new Error(`A module with providers was imported from "${stringifyForError(importingType)}". Modules with providers are not supported in standalone components imports.`);
} else {
throw new Error(`The "${stringifyForError(depType)}" type, imported from "${stringifyForError(importingType)}", must be a standalone component / directive / pipe or an NgModule. Did you forget to add the required @Component / @Directive / @Pipe or @NgModule annotation?`);
}
}
}
}
var DepsTracker = class {
ownerNgModule = /* @__PURE__ */ new Map();
ngModulesWithSomeUnresolvedDecls = /* @__PURE__ */ new Set();
ngModulesScopeCache = /* @__PURE__ */ new Map();
standaloneComponentsScopeCache = /* @__PURE__ */ new Map();
/**
* Attempts to resolve ng module's forward ref declarations as much as possible and add them to
* the `ownerNgModule` map. This method normally should be called after the initial parsing when
* all the forward refs are resolved (e.g., when trying to render a component)
*/
resolveNgModulesDecls() {
if (this.ngModulesWithSomeUnresolvedDecls.size === 0) {
return;
}
for (const moduleType of this.ngModulesWithSomeUnresolvedDecls) {
const def = getNgModuleDef(moduleType);
if (def?.declarations) {
for (const decl of maybeUnwrapFn(def.declarations)) {
if (isComponent(decl)) {
this.ownerNgModule.set(decl, moduleType);
}
}
}
}
this.ngModulesWithSomeUnresolvedDecls.clear();
}
/** @override */
getComponentDependencies(type, rawImports) {
this.resolveNgModulesDecls();
const def = getComponentDef(type);
if (def === null) {
throw new Error(`Attempting to get component dependencies for a type that is not a component: ${type}`);
}
if (def.standalone) {
const scope = this.getStandaloneComponentScope(type, rawImports);
if (scope.compilation.isPoisoned) {
return { dependencies: [] };
}
return {
dependencies: [
...scope.compilation.directives,
...scope.compilation.pipes,
...scope.compilation.ngModules
]
};
} else {
if (!this.ownerNgModule.has(type)) {
return { dependencies: [] };
}
const scope = this.getNgModuleScope(this.ownerNgModule.get(type));
if (scope.compilation.isPoisoned) {
return { dependencies: [] };
}
return {
dependencies: [...scope.compilation.directives, ...scope.compilation.pipes]
};
}
}
/**
* @override
* This implementation does not make use of param scopeInfo since it assumes the scope info is
* already added to the type itself through methods like {@link ɵɵsetNgModuleScope}
*/
registerNgModule(type, scopeInfo) {
if (!isNgModule(type)) {
throw new Error(`Attempting to register a Type which is not NgModule as NgModule: ${type}`);
}
this.ngModulesWithSomeUnresolvedDecls.add(type);
}
/** @override */
clearScopeCacheFor(type) {
this.ngModulesScopeCache.delete(type);
this.standaloneComponentsScopeCache.delete(type);
}
/** @override */
getNgModuleScope(type) {
if (this.ngModulesScopeCache.has(type)) {
return this.ngModulesScopeCache.get(type);
}
const scope = this.computeNgModuleScope(type);
this.ngModulesScopeCache.set(type, scope);
return scope;
}
/** Compute NgModule scope afresh. */
computeNgModuleScope(type) {
const def = getNgModuleDefOrThrow(type);
const scope = {
exported: { directives: /* @__PURE__ */ new Set(), pipes: /* @__PURE__ */ new Set() },
compilation: { directives: /* @__PURE__ */ new Set(), pipes: /* @__PURE__ */ new Set() }
};
for (const imported of maybeUnwrapFn(def.imports)) {
if (isNgModule(imported)) {
const importedScope = this.getNgModuleScope(imported);
addSet(importedScope.exported.directives, scope.compilation.directives);
addSet(importedScope.exported.pipes, scope.compilation.pipes);
} else if (isStandalone(imported)) {
if (isDirective(imported) || isComponent(imported)) {
scope.compilation.directives.add(imported);
} else if (isPipe(imported)) {
scope.compilation.pipes.add(imported);
} else {
throw new RuntimeError(980, "The standalone imported type is neither a component nor a directive nor a pipe");
}
} else {
scope.compilation.isPoisoned = true;
break;
}
}
if (!scope.compilation.isPoisoned) {
for (const decl of maybeUnwrapFn(def.declarations)) {
if (isNgModule(decl) || isStandalone(decl)) {
scope.compilation.isPoisoned = true;
break;
}
if (isPipe(decl)) {
scope.compilation.pipes.add(decl);
} else {
scope.compilation.directives.add(decl);
}
}
}
for (const exported of maybeUnwrapFn(def.exports)) {
if (isNgModule(exported)) {
const exportedScope = this.getNgModuleScope(exported);
addSet(exportedScope.exported.directives, scope.exported.directives);
addSet(exportedScope.exported.pipes, scope.exported.pipes);
addSet(exportedScope.exported.directives, scope.compilation.directives);
addSet(exportedScope.exported.pipes, scope.compilation.pipes);
} else if (isPipe(exported)) {
scope.exported.pipes.add(exported);
} else {
scope.exported.directives.add(exported);
}
}
return scope;
}
/** @override */
getStandaloneComponentScope(type, rawImports) {
if (this.standaloneComponentsScopeCache.has(type)) {
return this.standaloneComponentsScopeCache.get(type);
}
const ans = this.computeStandaloneComponentScope(type, rawImports);
this.standaloneComponentsScopeCache.set(type, ans);
return ans;
}
computeStandaloneComponentScope(type, rawImports) {
const ans = {
compilation: {
// Standalone components are always able to self-reference.
directives: /* @__PURE__ */ new Set([type]),
pipes: /* @__PURE__ */ new Set(),
ngModules: /* @__PURE__ */ new Set()
}
};
for (const rawImport of flatten(rawImports ?? [])) {
const imported = resolveForwardRef(rawImport);
try {
verifyStandaloneImport(imported, type);
} catch (e) {
ans.compilation.isPoisoned = true;
return ans;
}
if (isNgModule(imported)) {
ans.compilation.ngModules.add(imported);
const importedScope = this.getNgModuleScope(imported);
if (importedScope.exported.isPoisoned) {
ans.compilation.isPoisoned = true;
return ans;
}
addSet(importedScope.exported.directives, ans.compilation.directives);
addSet(importedScope.exported.pipes, ans.compilation.pipes);
} else if (isPipe(imported)) {
ans.compilation.pipes.add(imported);
} else if (isDirective(imported) || isComponent(imported)) {
ans.compilation.directives.add(imported);
} else {
ans.compilation.isPoisoned = true;
return ans;
}
}
return ans;
}
/** @override */
isOrphanComponent(cmp) {
const def = getComponentDef(cmp);
if (!def || def.standalone) {
return false;
}
this.resolveNgModulesDecls();
return !this.ownerNgModule.has(cmp);
}
};
function addSet(sourceSet, targetSet) {
for (const m of sourceSet) {
targetSet.add(m);
}
}
var depsTracker = new DepsTracker();
var NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
var ChainedInjector = class {
injector;
parentInjector;
constructor(injector, parentInjector) {
this.injector = injector;
this.parentInjector = parentInjector;
}
get(token, notFoundValue, options) {
const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, options);
if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR || notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
return value;
}
return this.parentInjector.get(token, notFoundValue, options);
}
};
function computeStaticStyling(tNode, attrs, writeToHost) {
ngDevMode && assertFirstCreatePass(getTView(), "Expecting to be called in first template pass only");
let styles = writeToHost ? tNode.styles : null;
let classes = writeToHost ? tNode.classes : null;
let mode = 0;
if (attrs !== null) {
for (let i = 0; i < attrs.length; i++) {
const value = attrs[i];
if (typeof value === "number") {
mode = value;
} else if (mode == 1) {
classes = concatStringsWithSpace(classes, value);
} else if (mode == 2) {
const style = value;
const styleValue = attrs[++i];
styles = concatStringsWithSpace(styles, style + ": " + styleValue + ";");
}
}
}
writeToHost ? tNode.styles = styles : tNode.stylesWithoutHost = styles;
writeToHost ? tNode.classes = classes : tNode.classesWithoutHost = classes;
}
function ɵɵdirectiveInject(token, flags = 0) {
const lView = getLView();
if (lView === null) {
ngDevMode && assertInjectImplementationNotEqual(ɵɵdirectiveInject);
return ɵɵinject(token, flags);
}
const tNode = getCurrentTNode();
const value = getOrCreateInjectable(tNode, lView, resolveForwardRef(token), flags);
ngDevMode && emitInjectEvent(token, value, flags);
return value;
}
function ɵɵinvalidFactory() {
const msg = ngDevMode ? `This constructor was not compatible with Dependency Injection.` : "invalid";
throw new Error(msg);
}
function resolveDirectives(tView, lView, tNode, localRefs, directiveMatcher) {
ngDevMode && assertFirstCreatePass(tView);
const exportsMap = localRefs === null ? null : { "": -1 };
const matchedDirectiveDefs = directiveMatcher(tView, tNode);
if (matchedDirectiveDefs !== null) {
let directiveDefs = matchedDirectiveDefs;
let hostDirectiveDefs = null;
let hostDirectiveRanges = null;
for (const def of matchedDirectiveDefs) {
if (def.resolveHostDirectives !== null) {
[directiveDefs, hostDirectiveDefs, hostDirectiveRanges] = def.resolveHostDirectives(matchedDirectiveDefs);
break;
}
}
ngDevMode && assertNoDuplicateDirectives(directiveDefs);
initializeDirectives(tView, lView, tNode, directiveDefs, exportsMap, hostDirectiveDefs, hostDirectiveRanges);
}
if (exportsMap !== null && localRefs !== null) {
cacheMatchingLocalNames(tNode, localRefs, exportsMap);
}
}
function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
const localNames = tNode.localNames = [];
for (let i = 0; i < localRefs.length; i += 2) {
const index = exportsMap[localRefs[i + 1]];
if (index == null)
throw new RuntimeError(-301, ngDevMode && `Export of name '${localRefs[i + 1]}' not found!`);
localNames.push(localRefs[i], index);
}
}
function markAsComponentHost(tView, hostTNode, componentOffset) {
ngDevMode && assertFirstCreatePass(tView);
ngDevMode && assertGreaterThan(componentOffset, -1, "componentOffset must be great than -1");
hostTNode.componentOffset = componentOffset;
(tView.components ??= []).push(hostTNode.index);
}
function initializeDirectives(tView, lView, tNode, directives, exportsMap, hostDirectiveDefs, hostDirectiveRanges) {
ngDevMode && assertFirstCreatePass(tView);
const directivesLength = directives.length;
let hasSeenComponent = false;
for (let i = 0; i < directivesLength; i++) {
const def = directives[i];
if (!hasSeenComponent && isComponentDef(def)) {
hasSeenComponent = true;
markAsComponentHost(tView, tNode, i);
}
diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, lView), tView, def.type);
}
initTNodeFlags(tNode, tView.data.length, directivesLength);
for (let i = 0; i < directivesLength; i++) {
const def = directives[i];
if (def.providersResolver)
def.providersResolver(def);
}
let preOrderHooksFound = false;
let preOrderCheckHooksFound = false;
let directiveIdx = allocExpando(tView, lView, directivesLength, null);
ngDevMode && assertSame(directiveIdx, tNode.directiveStart, "TNode.directiveStart should point to just allocated space");
if (directivesLength > 0) {
tNode.directiveToIndex = /* @__PURE__ */ new Map();
}
for (let i = 0; i < directivesLength; i++) {
const def = directives[i];
tNode.mergedAttrs = mergeHostAttrs(tNode.mergedAttrs, def.hostAttrs);
configureViewWithDirective(tView, tNode, lView, directiveIdx, def);
saveNameToExportMap(directiveIdx, def, exportsMap);
if (hostDirectiveRanges !== null && hostDirectiveRanges.has(def)) {
const [start, end] = hostDirectiveRanges.get(def);
tNode.directiveToIndex.set(def.type, [
directiveIdx,
start + tNode.directiveStart,
end + tNode.directiveStart
]);
} else if (hostDirectiveDefs === null || !hostDirectiveDefs.has(def)) {
tNode.directiveToIndex.set(def.type, directiveIdx);
}
if (def.contentQueries !== null)
tNode.flags |= 4;
if (def.hostBindings !== null || def.hostAttrs !== null || def.hostVars !== 0)
tNode.flags |= 64;
const lifeCycleHooks = def.type.prototype;
if (!preOrderHooksFound && (lifeCycleHooks.ngOnChanges || lifeCycleHooks.ngOnInit || lifeCycleHooks.ngDoCheck)) {
(tView.preOrderHooks ??= []).push(tNode.index);
preOrderHooksFound = true;
}
if (!preOrderCheckHooksFound && (lifeCycleHooks.ngOnChanges || lifeCycleHooks.ngDoCheck)) {
(tView.preOrderCheckHooks ??= []).push(tNode.index);
preOrderCheckHooksFound = true;
}
directiveIdx++;
}
initializeInputAndOutputAliases(tView, tNode, hostDirectiveDefs);
}
function initializeInputAndOutputAliases(tView, tNode, hostDirectiveDefs) {
ngDevMode && assertFirstCreatePass(tView);
for (let index = tNode.directiveStart; index < tNode.directiveEnd; index++) {
const directiveDef = tView.data[index];
if (hostDirectiveDefs === null || !hostDirectiveDefs.has(directiveDef)) {
setupSelectorMatchedInputsOrOutputs(0, tNode, directiveDef, index);
setupSelectorMatchedInputsOrOutputs(1, tNode, directiveDef, index);
setupInitialInputs(tNode, index, false);
} else {
const hostDirectiveDef = hostDirectiveDefs.get(directiveDef);
setupHostDirectiveInputsOrOutputs(0, tNode, hostDirectiveDef, index);
setupHostDirectiveInputsOrOutputs(1, tNode, hostDirectiveDef, index);
setupInitialInputs(tNode, index, true);
}
}
}
function setupSelectorMatchedInputsOrOutputs(mode, tNode, def, directiveIndex) {
const aliasMap = mode === 0 ? def.inputs : def.outputs;
for (const publicName in aliasMap) {
if (aliasMap.hasOwnProperty(publicName)) {
let bindings;
if (mode === 0) {
bindings = tNode.inputs ??= {};
} else {
bindings = tNode.outputs ??= {};
}
bindings[publicName] ??= [];
bindings[publicName].push(directiveIndex);
setShadowStylingInputFlags(tNode, publicName);
}
}
}
function setupHostDirectiveInputsOrOutputs(mode, tNode, config, directiveIndex) {
const aliasMap = mode === 0 ? config.inputs : config.outputs;
for (const initialName in aliasMap) {
if (aliasMap.hasOwnProperty(initialName)) {
const publicName = aliasMap[initialName];
let bindings;
if (mode === 0) {
bindings = tNode.hostDirectiveInputs ??= {};
} else {
bindings = tNode.hostDirectiveOutputs ??= {};
}
bindings[publicName] ??= [];
bindings[publicName].push(directiveIndex, initialName);
setShadowStylingInputFlags(tNode, publicName);
}
}
}
function setShadowStylingInputFlags(tNode, publicName) {
if (publicName === "class") {
tNode.flags |= 8;
} else if (publicName === "style") {
tNode.flags |= 16;
}
}
function setupInitialInputs(tNode, directiveIndex, isHostDirective) {
const { attrs, inputs, hostDirectiveInputs } = tNode;
if (attrs === null || !isHostDirective && inputs === null || isHostDirective && hostDirectiveInputs === null || // Do not use unbound attributes as inputs to structural directives, since structural
// directive inputs can only be set using microsyntax (e.g. ``).
isInlineTemplate(tNode)) {
tNode.initialInputs ??= [];
tNode.initialInputs.push(null);
return;
}
let inputsToStore = null;
let i = 0;
while (i < attrs.length) {
const attrName = attrs[i];
if (attrName === 0) {
i += 4;
continue;
} else if (attrName === 5) {
i += 2;
continue;
} else if (typeof attrName === "number") {
break;
}
if (!isHostDirective && inputs.hasOwnProperty(attrName)) {
const inputConfig = inputs[attrName];
for (const index of inputConfig) {
if (index === directiveIndex) {
inputsToStore ??= [];
inputsToStore.push(attrName, attrs[i + 1]);
break;
}
}
} else if (isHostDirective && hostDirectiveInputs.hasOwnProperty(attrName)) {
const config = hostDirectiveInputs[attrName];
for (let j = 0; j < config.length; j += 2) {
if (config[j] === directiveIndex) {
inputsToStore ??= [];
inputsToStore.push(config[j + 1], attrs[i + 1]);
break;
}
}
}
i += 2;
}
tNode.initialInputs ??= [];
tNode.initialInputs.push(inputsToStore);
}
function configureViewWithDirective(tView, tNode, lView, directiveIndex, def) {
ngDevMode && assertGreaterThanOrEqual(directiveIndex, HEADER_OFFSET, "Must be in Expando section");
tView.data[directiveIndex] = def;
const directiveFactory = def.factory || (def.factory = getFactoryDef(def.type, true));
const nodeInjectorFactory = new NodeInjectorFactory(directiveFactory, isComponentDef(def), ɵɵdirectiveInject, ngDevMode ? def.type.name : null);
tView.blueprint[directiveIndex] = nodeInjectorFactory;
lView[directiveIndex] = nodeInjectorFactory;
registerHostBindingOpCodes(tView, tNode, directiveIndex, allocExpando(tView, lView, def.hostVars, NO_CHANGE), def);
}
function registerHostBindingOpCodes(tView, tNode, directiveIdx, directiveVarsIdx, def) {
ngDevMode && assertFirstCreatePass(tView);
const hostBindings = def.hostBindings;
if (hostBindings) {
let hostBindingOpCodes = tView.hostBindingOpCodes;
if (hostBindingOpCodes === null) {
hostBindingOpCodes = tView.hostBindingOpCodes = [];
}
const elementIndx = ~tNode.index;
if (lastSelectedElementIdx(hostBindingOpCodes) != elementIndx) {
hostBindingOpCodes.push(elementIndx);
}
hostBindingOpCodes.push(directiveIdx, directiveVarsIdx, hostBindings);
}
}
function lastSelectedElementIdx(hostBindingOpCodes) {
let i = hostBindingOpCodes.length;
while (i > 0) {
const value = hostBindingOpCodes[--i];
if (typeof value === "number" && value < 0) {
return value;
}
}
return 0;
}
function saveNameToExportMap(directiveIdx, def, exportsMap) {
if (exportsMap) {
if (def.exportAs) {
for (let i = 0; i < def.exportAs.length; i++) {
exportsMap[def.exportAs[i]] = directiveIdx;
}
}
if (isComponentDef(def))
exportsMap[""] = directiveIdx;
}
}
function initTNodeFlags(tNode, index, numberOfDirectives) {
ngDevMode && assertNotEqual(numberOfDirectives, tNode.directiveEnd - tNode.directiveStart, "Reached the max number of directives");
tNode.flags |= 1;
tNode.directiveStart = index;
tNode.directiveEnd = index + numberOfDirectives;
tNode.providerIndexes = index;
}
function assertNoDuplicateDirectives(directives) {
if (directives.length < 2) {
return;
}
const seenDirectives = /* @__PURE__ */ new Set();
for (const current of directives) {
if (seenDirectives.has(current)) {
throw new RuntimeError(309, `Directive ${current.type.name} matches multiple times on the same element. Directives can only match an element once.`);
}
seenDirectives.add(current);
}
}
function directiveHostFirstCreatePass(index, lView, type, name, directiveMatcher, bindingsEnabled, attrsIndex, localRefsIndex) {
const tView = lView[TVIEW];
ngDevMode && assertFirstCreatePass(tView);
const tViewConsts = tView.consts;
const attrs = getConstant(tViewConsts, attrsIndex);
const tNode = getOrCreateTNode(tView, index, type, name, attrs);
if (bindingsEnabled) {
resolveDirectives(tView, lView, tNode, getConstant(tViewConsts, localRefsIndex), directiveMatcher);
}
tNode.mergedAttrs = mergeHostAttrs(tNode.mergedAttrs, tNode.attrs);
if (tNode.attrs !== null) {
computeStaticStyling(tNode, tNode.attrs, false);
}
if (tNode.mergedAttrs !== null) {
computeStaticStyling(tNode, tNode.mergedAttrs, true);
}
if (tView.queries !== null) {
tView.queries.elementStart(tView, tNode);
}
return tNode;
}
function directiveHostEndFirstCreatePass(tView, tNode) {
ngDevMode && assertFirstCreatePass(tView);
registerPostOrderHooks(tView, tNode);
if (isContentQueryHost(tNode)) {
tView.queries.elementEnd(tNode);
}
}
function domOnlyFirstCreatePass(index, tView, type, name, attrsIndex, localRefsIndex) {
ngDevMode && assertFirstCreatePass(tView);
const tViewConsts = tView.consts;
const attrs = getConstant(tViewConsts, attrsIndex);
const tNode = getOrCreateTNode(tView, index, type, name, attrs);
tNode.mergedAttrs = mergeHostAttrs(tNode.mergedAttrs, tNode.attrs);
if (localRefsIndex != null) {
const refs = getConstant(tViewConsts, localRefsIndex);
tNode.localNames = [];
for (let i = 0; i < refs.length; i += 2) {
tNode.localNames.push(refs[i], -1);
}
}
if (tNode.attrs !== null) {
computeStaticStyling(tNode, tNode.attrs, false);
}
if (tNode.mergedAttrs !== null) {
computeStaticStyling(tNode, tNode.mergedAttrs, true);
}
if (tView.queries !== null) {
tView.queries.elementStart(tView, tNode);
}
return tNode;
}
function isListLikeIterable(obj) {
if (!isJsObject(obj))
return false;
return Array.isArray(obj) || !(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
Symbol.iterator in obj;
}
function areIterablesEqual(a, b, comparator) {
const iterator1 = a[Symbol.iterator]();
const iterator2 = b[Symbol.iterator]();
while (true) {
const item1 = iterator1.next();
const item2 = iterator2.next();
if (item1.done && item2.done)
return true;
if (item1.done || item2.done)
return false;
if (!comparator(item1.value, item2.value))
return false;
}
}
function iterateListLike(obj, fn) {
if (Array.isArray(obj)) {
for (let i = 0; i < obj.length; i++) {
fn(obj[i]);
}
} else {
const iterator = obj[Symbol.iterator]();
let item;
while (!(item = iterator.next()).done) {
fn(item.value);
}
}
}
function isJsObject(o) {
return o !== null && (typeof o === "function" || typeof o === "object");
}
function devModeEqual(a, b) {
const isListLikeIterableA = isListLikeIterable(a);
const isListLikeIterableB = isListLikeIterable(b);
if (isListLikeIterableA && isListLikeIterableB) {
return areIterablesEqual(a, b, devModeEqual);
} else {
const isAObject = a && (typeof a === "object" || typeof a === "function");
const isBObject = b && (typeof b === "object" || typeof b === "function");
if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
return true;
} else {
return Object.is(a, b);
}
}
}
function updateBinding(lView, bindingIndex, value) {
return lView[bindingIndex] = value;
}
function getBinding(lView, bindingIndex) {
ngDevMode && assertIndexInRange(lView, bindingIndex);
ngDevMode && assertNotSame(lView[bindingIndex], NO_CHANGE, "Stored value should never be NO_CHANGE.");
return lView[bindingIndex];
}
function bindingUpdated(lView, bindingIndex, value) {
ngDevMode && assertLessThan(bindingIndex, lView.length, `Slot should have been initialized to NO_CHANGE`);
if (value === NO_CHANGE) {
return false;
}
const oldValue = lView[bindingIndex];
if (Object.is(oldValue, value)) {
return false;
} else {
if (ngDevMode && isInCheckNoChangesMode()) {
const oldValueToCompare = oldValue !== NO_CHANGE ? oldValue : void 0;
if (!devModeEqual(oldValueToCompare, value)) {
const details = getExpressionChangedErrorDetails(lView, bindingIndex, oldValueToCompare, value);
throwErrorIfNoChangesMode(oldValue === NO_CHANGE, details.oldValue, details.newValue, details.propName, lView);
}
return false;
}
lView[bindingIndex] = value;
return true;
}
}
function bindingUpdated2(lView, bindingIndex, exp1, exp2) {
const different = bindingUpdated(lView, bindingIndex, exp1);
return bindingUpdated(lView, bindingIndex + 1, exp2) || different;
}
function bindingUpdated3(lView, bindingIndex, exp1, exp2, exp3) {
const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
return bindingUpdated(lView, bindingIndex + 2, exp3) || different;
}
function bindingUpdated4(lView, bindingIndex, exp1, exp2, exp3, exp4) {
const different = bindingUpdated2(lView, bindingIndex, exp1, exp2);
return bindingUpdated2(lView, bindingIndex + 2, exp3, exp4) || different;
}
function wrapListener(tNode, lView, listenerFn) {
return function wrapListenerIn_markDirtyAndPreventDefault(event) {
const startView = isComponentHost(tNode) ? getComponentLViewByIndex(tNode.index, lView) : lView;
markViewDirty(
startView,
5
/* NotificationSource.Listener */
);
const context = lView[CONTEXT];
let result = executeListenerWithErrorHandling(lView, context, listenerFn, event);
let nextListenerFn = wrapListenerIn_markDirtyAndPreventDefault.__ngNextListenerFn__;
while (nextListenerFn) {
result = executeListenerWithErrorHandling(lView, context, nextListenerFn, event) && result;
nextListenerFn = nextListenerFn.__ngNextListenerFn__;
}
return result;
};
}
function executeListenerWithErrorHandling(lView, context, listenerFn, e) {
const prevConsumer = setActiveConsumer(null);
try {
profiler(6, context, listenerFn);
return listenerFn(e) !== false;
} catch (error) {
handleUncaughtError(lView, error);
return false;
} finally {
profiler(7, context, listenerFn);
setActiveConsumer(prevConsumer);
}
}
function listenToDomEvent(tNode, tView, lView, eventTargetResolver, renderer, eventName, originalListener, wrappedListener) {
ngDevMode && assertNotSame(wrappedListener, originalListener, "Expected wrapped and original listeners to be different.");
const isTNodeDirectiveHost = isDirectiveHost(tNode);
let hasCoalesced = false;
let existingListener = null;
if (!eventTargetResolver && isTNodeDirectiveHost) {
existingListener = findExistingListener(tView, lView, eventName, tNode.index);
}
if (existingListener !== null) {
const lastListenerFn = existingListener.__ngLastListenerFn__ || existingListener;
lastListenerFn.__ngNextListenerFn__ = originalListener;
existingListener.__ngLastListenerFn__ = originalListener;
hasCoalesced = true;
} else {
const native = getNativeByTNode(tNode, lView);
const target = eventTargetResolver ? eventTargetResolver(native) : native;
stashEventListenerImpl(lView, target, eventName, wrappedListener);
const cleanupFn = renderer.listen(target, eventName, wrappedListener);
const idxOrTargetGetter = eventTargetResolver ? (_lView) => eventTargetResolver(unwrapRNode(_lView[tNode.index])) : tNode.index;
storeListenerCleanup(idxOrTargetGetter, tView, lView, eventName, wrappedListener, cleanupFn, false);
}
return hasCoalesced;
}
function findExistingListener(tView, lView, eventName, tNodeIndex) {
const tCleanup = tView.cleanup;
if (tCleanup != null) {
for (let i = 0; i < tCleanup.length - 1; i += 2) {
const cleanupEventName = tCleanup[i];
if (cleanupEventName === eventName && tCleanup[i + 1] === tNodeIndex) {
const lCleanup = lView[CLEANUP];
const listenerIdxInLCleanup = tCleanup[i + 2];
return lCleanup && lCleanup.length > listenerIdxInLCleanup ? lCleanup[listenerIdxInLCleanup] : null;
}
if (typeof cleanupEventName === "string") {
i += 2;
}
}
}
return null;
}
function storeListenerCleanup(indexOrTargetGetter, tView, lView, eventName, listenerFn, cleanup, isOutput) {
const tCleanup = tView.firstCreatePass ? getOrCreateTViewCleanup(tView) : null;
const lCleanup = getOrCreateLViewCleanup(lView);
const index = lCleanup.length;
lCleanup.push(listenerFn, cleanup);
tCleanup && tCleanup.push(eventName, indexOrTargetGetter, index, (index + 1) * (isOutput ? -1 : 1));
}
function createOutputListener(tNode, lView, listenerFn, targetDef, eventName) {
const wrappedListener = wrapListener(tNode, lView, listenerFn);
const hasBound = listenToDirectiveOutput(tNode, lView, targetDef, eventName, wrappedListener);
if (!hasBound && ngDevMode) {
throw new RuntimeError(316, `${stringifyForError(targetDef.type)} does not have an output with a public name of "${eventName}".`);
}
}
function listenToDirectiveOutput(tNode, lView, target, eventName, listenerFn) {
let hostIndex = null;
let hostDirectivesStart = null;
let hostDirectivesEnd = null;
let hasOutput = false;
if (ngDevMode && !tNode.directiveToIndex?.has(target.type)) {
throw new Error(`Node does not have a directive with type ${target.type.name}`);
}
const data = tNode.directiveToIndex.get(target.type);
if (typeof data === "number") {
hostIndex = data;
} else {
[hostIndex, hostDirectivesStart, hostDirectivesEnd] = data;
}
if (hostDirectivesStart !== null && hostDirectivesEnd !== null && tNode.hostDirectiveOutputs?.hasOwnProperty(eventName)) {
const hostDirectiveOutputs = tNode.hostDirectiveOutputs[eventName];
for (let i = 0; i < hostDirectiveOutputs.length; i += 2) {
const index = hostDirectiveOutputs[i];
if (index >= hostDirectivesStart && index <= hostDirectivesEnd) {
ngDevMode && assertIndexInRange(lView, index);
hasOutput = true;
listenToOutput(tNode, lView, index, hostDirectiveOutputs[i + 1], eventName, listenerFn);
} else if (index > hostDirectivesEnd) {
break;
}
}
}
if (target.outputs.hasOwnProperty(eventName)) {
ngDevMode && assertIndexInRange(lView, hostIndex);
hasOutput = true;
listenToOutput(tNode, lView, hostIndex, eventName, eventName, listenerFn);
}
return hasOutput;
}
function listenToOutput(tNode, lView, directiveIndex, lookupName, eventName, listenerFn) {
ngDevMode && assertIndexInRange(lView, directiveIndex);
const instance = lView[directiveIndex];
const tView = lView[TVIEW];
const def = tView.data[directiveIndex];
const propertyName = def.outputs[lookupName];
const output2 = instance[propertyName];
if (ngDevMode && !isOutputSubscribable(output2)) {
throw new Error(`@Output ${propertyName} not initialized in '${instance.constructor.name}'.`);
}
const subscription = output2.subscribe(listenerFn);
storeListenerCleanup(tNode.index, tView, lView, eventName, listenerFn, subscription, true);
}
function isOutputSubscribable(value) {
return value != null && typeof value.subscribe === "function";
}
var BINDING = Symbol("BINDING");
var INPUT_BINDING_METADATA = { kind: "input", requiredVars: 1 };
var OUTPUT_BINDING_METADATA = { kind: "output", requiredVars: 0 };
function inputBindingUpdate(targetDirectiveIdx, publicName, value) {
const lView = getLView();
const bindingIndex = nextBindingIndex();
if (bindingUpdated(lView, bindingIndex, value)) {
const tView = lView[TVIEW];
const tNode = getSelectedTNode();
const componentLView = getComponentLViewByIndex(tNode.index, lView);
markViewDirty(
componentLView,
1
/* NotificationSource.SetInput */
);
const targetDef = tView.directiveRegistry[targetDirectiveIdx];
if (ngDevMode && !targetDef) {
throw new RuntimeError(315, `Input binding to property "${publicName}" does not have a target.`);
}
const hasSet = setDirectiveInput(tNode, tView, lView, targetDef, publicName, value);
if (ngDevMode) {
if (!hasSet) {
throw new RuntimeError(315, `${stringifyForError(targetDef.type)} does not have an input with a public name of "${publicName}".`);
}
storePropertyBindingMetadata(tView.data, tNode, publicName, bindingIndex);
}
}
}
function inputBinding(publicName, value) {
const binding = {
[BINDING]: INPUT_BINDING_METADATA,
update: () => inputBindingUpdate(binding.targetIdx, publicName, value())
};
return binding;
}
function outputBinding(eventName, listener) {
const binding = {
[BINDING]: OUTPUT_BINDING_METADATA,
create: () => {
const lView = getLView();
const tNode = getCurrentTNode();
const tView = lView[TVIEW];
const targetDef = tView.directiveRegistry[binding.targetIdx];
createOutputListener(tNode, lView, listener, targetDef, eventName);
}
};
return binding;
}
function twoWayBinding(publicName, value) {
const input2 = inputBinding(publicName, value);
const output2 = outputBinding(publicName + "Change", (eventValue) => value.set(eventValue));
ngDevMode && assertNotDefined(input2.create, "Unexpected `create` callback in inputBinding");
ngDevMode && assertNotDefined(output2.update, "Unexpected `update` callback in outputBinding");
const binding = {
[BINDING]: {
kind: "twoWay",
requiredVars: input2[BINDING].requiredVars + output2[BINDING].requiredVars
},
set targetIdx(idx) {
input2.targetIdx = idx;
output2.targetIdx = idx;
},
create: output2.create,
update: input2.update
};
return binding;
}
var ComponentFactoryResolver2 = class extends ComponentFactoryResolver$1 {
ngModule;
/**
* @param ngModule The NgModuleRef to which all resolved factories are bound.
*/
constructor(ngModule) {
super();
this.ngModule = ngModule;
}
resolveComponentFactory(component) {
ngDevMode && assertComponentType(component);
const componentDef = getComponentDef(component);
return new ComponentFactory2(componentDef, this.ngModule);
}
};
function toInputRefArray(map2) {
return Object.keys(map2).map((name) => {
const [propName, flags, transform] = map2[name];
const inputData = {
propName,
templateName: name,
isSignal: (flags & InputFlags.SignalBased) !== 0
};
if (transform) {
inputData.transform = transform;
}
return inputData;
});
}
function toOutputRefArray(map2) {
return Object.keys(map2).map((name) => ({ propName: map2[name], templateName: name }));
}
function verifyNotAnOrphanComponent(componentDef) {
if (false) {
if (depsTracker.isOrphanComponent(componentDef.type)) {
throw new RuntimeError(981, `Orphan component found! Trying to render the component ${debugStringifyTypeForError(componentDef.type)} without first loading the NgModule that declares it. It is recommended to make this component standalone in order to avoid this error. If this is not possible now, import the component's NgModule in the appropriate NgModule, or the standalone component in which you are trying to render this component. If this is a lazy import, load the NgModule lazily as well and use its module injector.`);
}
}
}
function createRootViewInjector(componentDef, environmentInjector, injector) {
let realEnvironmentInjector = environmentInjector instanceof EnvironmentInjector ? environmentInjector : environmentInjector?.injector;
if (realEnvironmentInjector && componentDef.getStandaloneInjector !== null) {
realEnvironmentInjector = componentDef.getStandaloneInjector(realEnvironmentInjector) || realEnvironmentInjector;
}
const rootViewInjector = realEnvironmentInjector ? new ChainedInjector(injector, realEnvironmentInjector) : injector;
return rootViewInjector;
}
function createRootLViewEnvironment(rootLViewInjector) {
const rendererFactory = rootLViewInjector.get(RendererFactory2, null);
if (rendererFactory === null) {
throw new RuntimeError(407, ngDevMode && "Angular was not able to inject a renderer (RendererFactory2). Likely this is due to a broken DI hierarchy. Make sure that any injector used to create this component has a correct parent.");
}
const sanitizer = rootLViewInjector.get(Sanitizer, null);
const changeDetectionScheduler = rootLViewInjector.get(ChangeDetectionScheduler, null);
let ngReflect = false;
if (typeof ngDevMode === "undefined" || ngDevMode) {
ngReflect = rootLViewInjector.get(NG_REFLECT_ATTRS_FLAG, NG_REFLECT_ATTRS_FLAG_DEFAULT);
}
return {
rendererFactory,
sanitizer,
changeDetectionScheduler,
ngReflect
};
}
function createHostElement(componentDef, renderer) {
const tagName = inferTagNameFromDefinition(componentDef);
const namespace = tagName === "svg" ? SVG_NAMESPACE : tagName === "math" ? MATH_ML_NAMESPACE : null;
return createElementNode(renderer, tagName, namespace);
}
function inferTagNameFromDefinition(componentDef) {
return (componentDef.selectors[0][0] || "div").toLowerCase();
}
var ComponentFactory2 = class extends ComponentFactory$1 {
componentDef;
ngModule;
selector;
componentType;
ngContentSelectors;
isBoundToModule;
cachedInputs = null;
cachedOutputs = null;
get inputs() {
this.cachedInputs ??= toInputRefArray(this.componentDef.inputs);
return this.cachedInputs;
}
get outputs() {
this.cachedOutputs ??= toOutputRefArray(this.componentDef.outputs);
return this.cachedOutputs;
}
/**
* @param componentDef The component definition.
* @param ngModule The NgModuleRef to which the factory is bound.
*/
constructor(componentDef, ngModule) {
super();
this.componentDef = componentDef;
this.ngModule = ngModule;
this.componentType = componentDef.type;
this.selector = stringifyCSSSelectorList(componentDef.selectors);
this.ngContentSelectors = componentDef.ngContentSelectors ?? [];
this.isBoundToModule = !!ngModule;
}
create(injector, projectableNodes, rootSelectorOrNode, environmentInjector, directives, componentBindings) {
profiler(
22
/* ProfilerEvent.DynamicComponentStart */
);
const prevConsumer = setActiveConsumer(null);
try {
const cmpDef = this.componentDef;
ngDevMode && verifyNotAnOrphanComponent(cmpDef);
const rootTView = createRootTView(rootSelectorOrNode, cmpDef, componentBindings, directives);
const rootViewInjector = createRootViewInjector(cmpDef, environmentInjector || this.ngModule, injector);
const environment = createRootLViewEnvironment(rootViewInjector);
const hostRenderer = environment.rendererFactory.createRenderer(null, cmpDef);
const hostElement = rootSelectorOrNode ? locateHostElement(hostRenderer, rootSelectorOrNode, cmpDef.encapsulation, rootViewInjector) : createHostElement(cmpDef, hostRenderer);
const hasInputBindings = componentBindings?.some(isInputBinding) || directives?.some((d) => typeof d !== "function" && d.bindings.some(isInputBinding));
const rootLView = createLView(null, rootTView, null, 512 | getInitialLViewFlagsFromDef(cmpDef), null, null, environment, hostRenderer, rootViewInjector, null, retrieveHydrationInfo(
hostElement,
rootViewInjector,
true
/* isRootView */
));
rootLView[HEADER_OFFSET] = hostElement;
enterView(rootLView);
let componentView = null;
try {
const hostTNode = directiveHostFirstCreatePass(HEADER_OFFSET, rootLView, 2, "#host", () => rootTView.directiveRegistry, true, 0);
if (hostElement) {
setupStaticAttributes(hostRenderer, hostElement, hostTNode);
attachPatchData(hostElement, rootLView);
}
createDirectivesInstances(rootTView, rootLView, hostTNode);
executeContentQueries(rootTView, hostTNode, rootLView);
directiveHostEndFirstCreatePass(rootTView, hostTNode);
if (projectableNodes !== void 0) {
projectNodes(hostTNode, this.ngContentSelectors, projectableNodes);
}
componentView = getComponentLViewByIndex(hostTNode.index, rootLView);
rootLView[CONTEXT] = componentView[CONTEXT];
renderView(rootTView, rootLView, null);
} catch (e) {
if (componentView !== null) {
unregisterLView(componentView);
}
unregisterLView(rootLView);
throw e;
} finally {
profiler(
23
/* ProfilerEvent.DynamicComponentEnd */
);
leaveView();
}
return new ComponentRef2(this.componentType, rootLView, !!hasInputBindings);
} finally {
setActiveConsumer(prevConsumer);
}
}
};
function createRootTView(rootSelectorOrNode, componentDef, componentBindings, directives) {
const tAttributes = rootSelectorOrNode ? ["ng-version", "20.2.4"] : (
// Extract attributes and classes from the first selector only to match VE behavior.
extractAttrsAndClassesFromSelector(componentDef.selectors[0])
);
let creationBindings = null;
let updateBindings = null;
let varsToAllocate = 0;
if (componentBindings) {
for (const binding of componentBindings) {
varsToAllocate += binding[BINDING].requiredVars;
if (binding.create) {
binding.targetIdx = 0;
(creationBindings ??= []).push(binding);
}
if (binding.update) {
binding.targetIdx = 0;
(updateBindings ??= []).push(binding);
}
}
}
if (directives) {
for (let i = 0; i < directives.length; i++) {
const directive = directives[i];
if (typeof directive !== "function") {
for (const binding of directive.bindings) {
varsToAllocate += binding[BINDING].requiredVars;
const targetDirectiveIdx = i + 1;
if (binding.create) {
binding.targetIdx = targetDirectiveIdx;
(creationBindings ??= []).push(binding);
}
if (binding.update) {
binding.targetIdx = targetDirectiveIdx;
(updateBindings ??= []).push(binding);
}
}
}
}
}
const directivesToApply = [componentDef];
if (directives) {
for (const directive of directives) {
const directiveType = typeof directive === "function" ? directive : directive.type;
const directiveDef = ngDevMode ? getDirectiveDefOrThrow(directiveType) : getDirectiveDef(directiveType);
if (ngDevMode && !directiveDef.standalone) {
throw new RuntimeError(907, `The ${stringifyForError(directiveType)} directive must be standalone in order to be applied to a dynamically-created component.`);
}
directivesToApply.push(directiveDef);
}
}
const rootTView = createTView(0, null, getRootTViewTemplate(creationBindings, updateBindings), 1, varsToAllocate, directivesToApply, null, null, null, [tAttributes], null);
return rootTView;
}
function getRootTViewTemplate(creationBindings, updateBindings) {
if (!creationBindings && !updateBindings) {
return null;
}
return (flags) => {
if (flags & 1 && creationBindings) {
for (const binding of creationBindings) {
binding.create();
}
}
if (flags & 2 && updateBindings) {
for (const binding of updateBindings) {
binding.update();
}
}
};
}
function isInputBinding(binding) {
const kind = binding[BINDING].kind;
return kind === "input" || kind === "twoWay";
}
var ComponentRef2 = class extends ComponentRef$1 {
_rootLView;
_hasInputBindings;
instance;
hostView;
changeDetectorRef;
componentType;
location;
previousInputValues = null;
_tNode;
constructor(componentType, _rootLView, _hasInputBindings) {
super();
this._rootLView = _rootLView;
this._hasInputBindings = _hasInputBindings;
this._tNode = getTNode(_rootLView[TVIEW], HEADER_OFFSET);
this.location = createElementRef(this._tNode, _rootLView);
this.instance = getComponentLViewByIndex(this._tNode.index, _rootLView)[CONTEXT];
this.hostView = this.changeDetectorRef = new ViewRef(
_rootLView,
void 0
/* _cdRefInjectingView */
);
this.componentType = componentType;
}
setInput(name, value) {
if (this._hasInputBindings && ngDevMode) {
throw new RuntimeError(317, "Cannot call `setInput` on a component that is using the `inputBinding` or `twoWayBinding` functions.");
}
const tNode = this._tNode;
this.previousInputValues ??= /* @__PURE__ */ new Map();
if (this.previousInputValues.has(name) && Object.is(this.previousInputValues.get(name), value)) {
return;
}
const lView = this._rootLView;
const hasSetInput = setAllInputsForProperty(tNode, lView[TVIEW], lView, name, value);
this.previousInputValues.set(name, value);
const childComponentLView = getComponentLViewByIndex(tNode.index, lView);
markViewDirty(
childComponentLView,
1
/* NotificationSource.SetInput */
);
if (ngDevMode && !hasSetInput) {
const cmpNameForError = stringifyForError(this.componentType);
let message = `Can't set value of the '${name}' input on the '${cmpNameForError}' component. `;
message += `Make sure that the '${name}' property is declared as an input using the input() or model() function or the @Input() decorator.`;
reportUnknownPropertyError(message);
}
}
get injector() {
return new NodeInjector(this._tNode, this._rootLView);
}
destroy() {
this.hostView.destroy();
}
onDestroy(callback) {
this.hostView.onDestroy(callback);
}
};
function projectNodes(tNode, ngContentSelectors, projectableNodes) {
const projection = tNode.projection = [];
for (let i = 0; i < ngContentSelectors.length; i++) {
const nodesforSlot = projectableNodes[i];
projection.push(nodesforSlot != null && nodesforSlot.length ? Array.from(nodesforSlot) : null);
}
}
var ViewContainerRef = class {
/**
* @internal
* @nocollapse
*/
static __NG_ELEMENT_ID__ = injectViewContainerRef;
};
function injectViewContainerRef() {
const previousTNode = getCurrentTNode();
return createContainerRef(previousTNode, getLView());
}
var VE_ViewContainerRef = ViewContainerRef;
var R3ViewContainerRef = class ViewContainerRef2 extends VE_ViewContainerRef {
_lContainer;
_hostTNode;
_hostLView;
constructor(_lContainer, _hostTNode, _hostLView) {
super();
this._lContainer = _lContainer;
this._hostTNode = _hostTNode;
this._hostLView = _hostLView;
}
get element() {
return createElementRef(this._hostTNode, this._hostLView);
}
get injector() {
return new NodeInjector(this._hostTNode, this._hostLView);
}
/** @deprecated No replacement */
get parentInjector() {
const parentLocation = getParentInjectorLocation(this._hostTNode, this._hostLView);
if (hasParentInjector(parentLocation)) {
const parentView = getParentInjectorView(parentLocation, this._hostLView);
const injectorIndex = getParentInjectorIndex(parentLocation);
ngDevMode && assertNodeInjector(parentView, injectorIndex);
const parentTNode = parentView[TVIEW].data[
injectorIndex + 8
/* NodeInjectorOffset.TNODE */
];
return new NodeInjector(parentTNode, parentView);
} else {
return new NodeInjector(null, this._hostLView);
}
}
clear() {
while (this.length > 0) {
this.remove(this.length - 1);
}
}
get(index) {
const viewRefs = getViewRefs(this._lContainer);
return viewRefs !== null && viewRefs[index] || null;
}
get length() {
return this._lContainer.length - CONTAINER_HEADER_OFFSET;
}
createEmbeddedView(templateRef, context, indexOrOptions) {
let index;
let injector;
if (typeof indexOrOptions === "number") {
index = indexOrOptions;
} else if (indexOrOptions != null) {
index = indexOrOptions.index;
injector = indexOrOptions.injector;
}
const dehydratedView = findMatchingDehydratedView(this._lContainer, templateRef.ssrId);
const viewRef = templateRef.createEmbeddedViewImpl(context || {}, injector, dehydratedView);
this.insertImpl(viewRef, index, shouldAddViewToDom(this._hostTNode, dehydratedView));
return viewRef;
}
createComponent(componentFactoryOrType, indexOrOptions, injector, projectableNodes, environmentInjector, directives, bindings) {
const isComponentFactory = componentFactoryOrType && !isType(componentFactoryOrType);
let index;
if (isComponentFactory) {
if (ngDevMode) {
assertEqual(typeof indexOrOptions !== "object", true, "It looks like Component factory was provided as the first argument and an options object as the second argument. This combination of arguments is incompatible. You can either change the first argument to provide Component type or change the second argument to be a number (representing an index at which to insert the new component's host view into this container)");
}
index = indexOrOptions;
} else {
if (ngDevMode) {
assertDefined(getComponentDef(componentFactoryOrType), `Provided Component class doesn't contain Component definition. Please check whether provided class has @Component decorator.`);
assertEqual(typeof indexOrOptions !== "number", true, "It looks like Component type was provided as the first argument and a number (representing an index at which to insert the new component's host view into this container as the second argument. This combination of arguments is incompatible. Please use an object as the second argument instead.");
}
const options = indexOrOptions || {};
if (ngDevMode && options.environmentInjector && options.ngModuleRef) {
throwError(`Cannot pass both environmentInjector and ngModuleRef options to createComponent().`);
}
index = options.index;
injector = options.injector;
projectableNodes = options.projectableNodes;
environmentInjector = options.environmentInjector || options.ngModuleRef;
directives = options.directives;
bindings = options.bindings;
}
const componentFactory = isComponentFactory ? componentFactoryOrType : new ComponentFactory2(getComponentDef(componentFactoryOrType));
const contextInjector = injector || this.parentInjector;
if (!environmentInjector && componentFactory.ngModule == null) {
const _injector = isComponentFactory ? contextInjector : this.parentInjector;
const result = _injector.get(EnvironmentInjector, null);
if (result) {
environmentInjector = result;
}
}
const componentDef = getComponentDef(componentFactory.componentType ?? {});
const dehydratedView = findMatchingDehydratedView(this._lContainer, componentDef?.id ?? null);
const rNode = dehydratedView?.firstChild ?? null;
const componentRef = componentFactory.create(contextInjector, projectableNodes, rNode, environmentInjector, directives, bindings);
this.insertImpl(componentRef.hostView, index, shouldAddViewToDom(this._hostTNode, dehydratedView));
return componentRef;
}
insert(viewRef, index) {
return this.insertImpl(viewRef, index, true);
}
insertImpl(viewRef, index, addToDOM) {
const lView = viewRef._lView;
if (ngDevMode && viewRef.destroyed) {
throw new Error("Cannot insert a destroyed View in a ViewContainer!");
}
if (viewAttachedToContainer(lView)) {
const prevIdx = this.indexOf(viewRef);
if (prevIdx !== -1) {
this.detach(prevIdx);
} else {
const prevLContainer = lView[PARENT];
ngDevMode && assertEqual(isLContainer(prevLContainer), true, "An attached view should have its PARENT point to a container.");
const prevVCRef = new R3ViewContainerRef(prevLContainer, prevLContainer[T_HOST], prevLContainer[PARENT]);
prevVCRef.detach(prevVCRef.indexOf(viewRef));
}
}
const adjustedIdx = this._adjustIndex(index);
const lContainer = this._lContainer;
addLViewToLContainer(lContainer, lView, adjustedIdx, addToDOM);
viewRef.attachToViewContainerRef();
addToArray(getOrCreateViewRefs(lContainer), adjustedIdx, viewRef);
return viewRef;
}
move(viewRef, newIndex) {
if (ngDevMode && viewRef.destroyed) {
throw new Error("Cannot move a destroyed View in a ViewContainer!");
}
return this.insert(viewRef, newIndex);
}
indexOf(viewRef) {
const viewRefsArr = getViewRefs(this._lContainer);
return viewRefsArr !== null ? viewRefsArr.indexOf(viewRef) : -1;
}
remove(index) {
const adjustedIdx = this._adjustIndex(index, -1);
const detachedView = detachView(this._lContainer, adjustedIdx);
if (detachedView) {
removeFromArray(getOrCreateViewRefs(this._lContainer), adjustedIdx);
destroyLView(detachedView[TVIEW], detachedView);
}
}
detach(index) {
const adjustedIdx = this._adjustIndex(index, -1);
const view = detachView(this._lContainer, adjustedIdx);
const wasDetached = view && removeFromArray(getOrCreateViewRefs(this._lContainer), adjustedIdx) != null;
return wasDetached ? new ViewRef(view) : null;
}
_adjustIndex(index, shift = 0) {
if (index == null) {
return this.length + shift;
}
if (ngDevMode) {
assertGreaterThan(index, -1, `ViewRef index must be positive, got ${index}`);
assertLessThan(index, this.length + 1 + shift, "index");
}
return index;
}
};
function getViewRefs(lContainer) {
return lContainer[VIEW_REFS];
}
function getOrCreateViewRefs(lContainer) {
return lContainer[VIEW_REFS] || (lContainer[VIEW_REFS] = []);
}
function createContainerRef(hostTNode, hostLView) {
ngDevMode && assertTNodeType(
hostTNode,
12 | 3
/* TNodeType.AnyRNode */
);
let lContainer;
const slotValue = hostLView[hostTNode.index];
if (isLContainer(slotValue)) {
lContainer = slotValue;
} else {
lContainer = createLContainer(slotValue, hostLView, null, hostTNode);
hostLView[hostTNode.index] = lContainer;
addToEndOfViewTree(hostLView, lContainer);
}
_locateOrCreateAnchorNode(lContainer, hostLView, hostTNode, slotValue);
return new R3ViewContainerRef(lContainer, hostTNode, hostLView);
}
function insertAnchorNode(hostLView, hostTNode) {
const renderer = hostLView[RENDERER];
const commentNode = renderer.createComment(ngDevMode ? "container" : "");
const hostNative = getNativeByTNode(hostTNode, hostLView);
const parentOfHostNative = renderer.parentNode(hostNative);
nativeInsertBefore(renderer, parentOfHostNative, commentNode, renderer.nextSibling(hostNative), false);
return commentNode;
}
var _locateOrCreateAnchorNode = createAnchorNode;
var _populateDehydratedViewsInLContainer = () => false;
function populateDehydratedViewsInLContainer(lContainer, tNode, hostLView) {
return _populateDehydratedViewsInLContainer(lContainer, tNode, hostLView);
}
function createAnchorNode(lContainer, hostLView, hostTNode, slotValue) {
if (lContainer[NATIVE])
return;
let commentNode;
if (hostTNode.type & 8) {
commentNode = unwrapRNode(slotValue);
} else {
commentNode = insertAnchorNode(hostLView, hostTNode);
}
lContainer[NATIVE] = commentNode;
}
function populateDehydratedViewsInLContainerImpl(lContainer, tNode, hostLView) {
if (lContainer[NATIVE] && lContainer[DEHYDRATED_VIEWS]) {
return true;
}
const hydrationInfo = hostLView[HYDRATION];
const noOffsetIndex = tNode.index - HEADER_OFFSET;
const isNodeCreationMode = !hydrationInfo || isInSkipHydrationBlock2(tNode) || isDisconnectedNode$1(hydrationInfo, noOffsetIndex);
if (isNodeCreationMode) {
return false;
}
const currentRNode = getSegmentHead(hydrationInfo, noOffsetIndex);
const serializedViews = hydrationInfo.data[CONTAINERS]?.[noOffsetIndex];
ngDevMode && assertDefined(serializedViews, "Unexpected state: no hydration info available for a given TNode, which represents a view container.");
const [commentNode, dehydratedViews] = locateDehydratedViewsInContainer(currentRNode, serializedViews);
if (ngDevMode) {
validateMatchingNode(commentNode, Node.COMMENT_NODE, null, hostLView, tNode, true);
markRNodeAsClaimedByHydration(commentNode, false);
}
lContainer[NATIVE] = commentNode;
lContainer[DEHYDRATED_VIEWS] = dehydratedViews;
return true;
}
function locateOrCreateAnchorNode(lContainer, hostLView, hostTNode, slotValue) {
if (!_populateDehydratedViewsInLContainer(lContainer, hostTNode, hostLView)) {
createAnchorNode(lContainer, hostLView, hostTNode, slotValue);
}
}
function enableLocateOrCreateContainerRefImpl() {
_locateOrCreateAnchorNode = locateOrCreateAnchorNode;
_populateDehydratedViewsInLContainer = populateDehydratedViewsInLContainerImpl;
}
var LQuery_ = class _LQuery_ {
queryList;
matches = null;
constructor(queryList) {
this.queryList = queryList;
}
clone() {
return new _LQuery_(this.queryList);
}
setDirty() {
this.queryList.setDirty();
}
};
var LQueries_ = class _LQueries_ {
queries;
constructor(queries = []) {
this.queries = queries;
}
createEmbeddedView(tView) {
const tQueries = tView.queries;
if (tQueries !== null) {
const noOfInheritedQueries = tView.contentQueries !== null ? tView.contentQueries[0] : tQueries.length;
const viewLQueries = [];
for (let i = 0; i < noOfInheritedQueries; i++) {
const tQuery = tQueries.getByIndex(i);
const parentLQuery = this.queries[tQuery.indexInDeclarationView];
viewLQueries.push(parentLQuery.clone());
}
return new _LQueries_(viewLQueries);
}
return null;
}
insertView(tView) {
this.dirtyQueriesWithMatches(tView);
}
detachView(tView) {
this.dirtyQueriesWithMatches(tView);
}
finishViewCreation(tView) {
this.dirtyQueriesWithMatches(tView);
}
dirtyQueriesWithMatches(tView) {
for (let i = 0; i < this.queries.length; i++) {
if (getTQuery(tView, i).matches !== null) {
this.queries[i].setDirty();
}
}
}
};
var TQueryMetadata_ = class {
flags;
read;
predicate;
constructor(predicate, flags, read = null) {
this.flags = flags;
this.read = read;
if (typeof predicate === "string") {
this.predicate = splitQueryMultiSelectors(predicate);
} else {
this.predicate = predicate;
}
}
};
var TQueries_ = class _TQueries_ {
queries;
constructor(queries = []) {
this.queries = queries;
}
elementStart(tView, tNode) {
ngDevMode && assertFirstCreatePass(tView, "Queries should collect results on the first template pass only");
for (let i = 0; i < this.queries.length; i++) {
this.queries[i].elementStart(tView, tNode);
}
}
elementEnd(tNode) {
for (let i = 0; i < this.queries.length; i++) {
this.queries[i].elementEnd(tNode);
}
}
embeddedTView(tNode) {
let queriesForTemplateRef = null;
for (let i = 0; i < this.length; i++) {
const childQueryIndex = queriesForTemplateRef !== null ? queriesForTemplateRef.length : 0;
const tqueryClone = this.getByIndex(i).embeddedTView(tNode, childQueryIndex);
if (tqueryClone) {
tqueryClone.indexInDeclarationView = i;
if (queriesForTemplateRef !== null) {
queriesForTemplateRef.push(tqueryClone);
} else {
queriesForTemplateRef = [tqueryClone];
}
}
}
return queriesForTemplateRef !== null ? new _TQueries_(queriesForTemplateRef) : null;
}
template(tView, tNode) {
ngDevMode && assertFirstCreatePass(tView, "Queries should collect results on the first template pass only");
for (let i = 0; i < this.queries.length; i++) {
this.queries[i].template(tView, tNode);
}
}
getByIndex(index) {
ngDevMode && assertIndexInRange(this.queries, index);
return this.queries[index];
}
get length() {
return this.queries.length;
}
track(tquery) {
this.queries.push(tquery);
}
};
var TQuery_ = class _TQuery_ {
metadata;
matches = null;
indexInDeclarationView = -1;
crossesNgTemplate = false;
/**
* A node index on which a query was declared (-1 for view queries and ones inherited from the
* declaration template). We use this index (alongside with _appliesToNextNode flag) to know
* when to apply content queries to elements in a template.
*/
_declarationNodeIndex;
/**
* A flag indicating if a given query still applies to nodes it is crossing. We use this flag
* (alongside with _declarationNodeIndex) to know when to stop applying content queries to
* elements in a template.
*/
_appliesToNextNode = true;
constructor(metadata, nodeIndex = -1) {
this.metadata = metadata;
this._declarationNodeIndex = nodeIndex;
}
elementStart(tView, tNode) {
if (this.isApplyingToNode(tNode)) {
this.matchTNode(tView, tNode);
}
}
elementEnd(tNode) {
if (this._declarationNodeIndex === tNode.index) {
this._appliesToNextNode = false;
}
}
template(tView, tNode) {
this.elementStart(tView, tNode);
}
embeddedTView(tNode, childQueryIndex) {
if (this.isApplyingToNode(tNode)) {
this.crossesNgTemplate = true;
this.addMatch(-tNode.index, childQueryIndex);
return new _TQuery_(this.metadata);
}
return null;
}
isApplyingToNode(tNode) {
if (this._appliesToNextNode && (this.metadata.flags & 1) !== 1) {
const declarationNodeIdx = this._declarationNodeIndex;
let parent = tNode.parent;
while (parent !== null && parent.type & 8 && parent.index !== declarationNodeIdx) {
parent = parent.parent;
}
return declarationNodeIdx === (parent !== null ? parent.index : -1);
}
return this._appliesToNextNode;
}
matchTNode(tView, tNode) {
const predicate = this.metadata.predicate;
if (Array.isArray(predicate)) {
for (let i = 0; i < predicate.length; i++) {
const name = predicate[i];
this.matchTNodeWithReadOption(tView, tNode, getIdxOfMatchingSelector(tNode, name));
this.matchTNodeWithReadOption(tView, tNode, locateDirectiveOrProvider(tNode, tView, name, false, false));
}
} else {
if (predicate === TemplateRef) {
if (tNode.type & 4) {
this.matchTNodeWithReadOption(tView, tNode, -1);
}
} else {
this.matchTNodeWithReadOption(tView, tNode, locateDirectiveOrProvider(tNode, tView, predicate, false, false));
}
}
}
matchTNodeWithReadOption(tView, tNode, nodeMatchIdx) {
if (nodeMatchIdx !== null) {
const read = this.metadata.read;
if (read !== null) {
if (read === ElementRef || read === ViewContainerRef || read === TemplateRef && tNode.type & 4) {
this.addMatch(tNode.index, -2);
} else {
const directiveOrProviderIdx = locateDirectiveOrProvider(tNode, tView, read, false, false);
if (directiveOrProviderIdx !== null) {
this.addMatch(tNode.index, directiveOrProviderIdx);
}
}
} else {
this.addMatch(tNode.index, nodeMatchIdx);
}
}
}
addMatch(tNodeIdx, matchIdx) {
if (this.matches === null) {
this.matches = [tNodeIdx, matchIdx];
} else {
this.matches.push(tNodeIdx, matchIdx);
}
}
};
function getIdxOfMatchingSelector(tNode, selector) {
const localNames = tNode.localNames;
if (localNames !== null) {
for (let i = 0; i < localNames.length; i += 2) {
if (localNames[i] === selector) {
return localNames[i + 1];
}
}
}
return null;
}
function createResultByTNodeType(tNode, currentView) {
if (tNode.type & (3 | 8)) {
return createElementRef(tNode, currentView);
} else if (tNode.type & 4) {
return createTemplateRef(tNode, currentView);
}
return null;
}
function createResultForNode(lView, tNode, matchingIdx, read) {
if (matchingIdx === -1) {
return createResultByTNodeType(tNode, lView);
} else if (matchingIdx === -2) {
return createSpecialToken(lView, tNode, read);
} else {
return getNodeInjectable(lView, lView[TVIEW], matchingIdx, tNode);
}
}
function createSpecialToken(lView, tNode, read) {
if (read === ElementRef) {
return createElementRef(tNode, lView);
} else if (read === TemplateRef) {
return createTemplateRef(tNode, lView);
} else if (read === ViewContainerRef) {
ngDevMode && assertTNodeType(
tNode,
3 | 12
/* TNodeType.AnyContainer */
);
return createContainerRef(tNode, lView);
} else {
ngDevMode && throwError(`Special token to read should be one of ElementRef, TemplateRef or ViewContainerRef but got ${stringify(read)}.`);
}
}
function materializeViewResults(tView, lView, tQuery, queryIndex) {
const lQuery = lView[QUERIES].queries[queryIndex];
if (lQuery.matches === null) {
const tViewData = tView.data;
const tQueryMatches = tQuery.matches;
const result = [];
for (let i = 0; tQueryMatches !== null && i < tQueryMatches.length; i += 2) {
const matchedNodeIdx = tQueryMatches[i];
if (matchedNodeIdx < 0) {
result.push(null);
} else {
ngDevMode && assertIndexInRange(tViewData, matchedNodeIdx);
const tNode = tViewData[matchedNodeIdx];
result.push(createResultForNode(lView, tNode, tQueryMatches[i + 1], tQuery.metadata.read));
}
}
lQuery.matches = result;
}
return lQuery.matches;
}
function collectQueryResults(tView, lView, queryIndex, result) {
const tQuery = tView.queries.getByIndex(queryIndex);
const tQueryMatches = tQuery.matches;
if (tQueryMatches !== null) {
const lViewResults = materializeViewResults(tView, lView, tQuery, queryIndex);
for (let i = 0; i < tQueryMatches.length; i += 2) {
const tNodeIdx = tQueryMatches[i];
if (tNodeIdx > 0) {
result.push(lViewResults[i / 2]);
} else {
const childQueryIndex = tQueryMatches[i + 1];
const declarationLContainer = lView[-tNodeIdx];
ngDevMode && assertLContainer(declarationLContainer);
for (let i2 = CONTAINER_HEADER_OFFSET; i2 < declarationLContainer.length; i2++) {
const embeddedLView = declarationLContainer[i2];
if (embeddedLView[DECLARATION_LCONTAINER] === embeddedLView[PARENT]) {
collectQueryResults(embeddedLView[TVIEW], embeddedLView, childQueryIndex, result);
}
}
if (declarationLContainer[MOVED_VIEWS] !== null) {
const embeddedLViews = declarationLContainer[MOVED_VIEWS];
for (let i2 = 0; i2 < embeddedLViews.length; i2++) {
const embeddedLView = embeddedLViews[i2];
collectQueryResults(embeddedLView[TVIEW], embeddedLView, childQueryIndex, result);
}
}
}
}
}
return result;
}
function loadQueryInternal(lView, queryIndex) {
ngDevMode && assertDefined(lView[QUERIES], "LQueries should be defined when trying to load a query");
ngDevMode && assertIndexInRange(lView[QUERIES].queries, queryIndex);
return lView[QUERIES].queries[queryIndex].queryList;
}
function createLQuery(tView, lView, flags) {
const queryList = new QueryList(
(flags & 4) === 4
/* QueryFlags.emitDistinctChangesOnly */
);
storeCleanupWithContext(tView, lView, queryList, queryList.destroy);
const lQueries = (lView[QUERIES] ??= new LQueries_()).queries;
return lQueries.push(new LQuery_(queryList)) - 1;
}
function createViewQuery(predicate, flags, read) {
ngDevMode && assertNumber(flags, "Expecting flags");
const tView = getTView();
if (tView.firstCreatePass) {
createTQuery(tView, new TQueryMetadata_(predicate, flags, read), -1);
if ((flags & 2) === 2) {
tView.staticViewQueries = true;
}
}
return createLQuery(tView, getLView(), flags);
}
function createContentQuery(directiveIndex, predicate, flags, read) {
ngDevMode && assertNumber(flags, "Expecting flags");
const tView = getTView();
if (tView.firstCreatePass) {
const tNode = getCurrentTNode();
createTQuery(tView, new TQueryMetadata_(predicate, flags, read), tNode.index);
saveContentQueryAndDirectiveIndex(tView, directiveIndex);
if ((flags & 2) === 2) {
tView.staticContentQueries = true;
}
}
return createLQuery(tView, getLView(), flags);
}
function splitQueryMultiSelectors(locator) {
return locator.split(",").map((s) => s.trim());
}
function createTQuery(tView, metadata, nodeIndex) {
if (tView.queries === null)
tView.queries = new TQueries_();
tView.queries.track(new TQuery_(metadata, nodeIndex));
}
function saveContentQueryAndDirectiveIndex(tView, directiveIndex) {
const tViewContentQueries = tView.contentQueries || (tView.contentQueries = []);
const lastSavedDirectiveIndex = tViewContentQueries.length ? tViewContentQueries[tViewContentQueries.length - 1] : -1;
if (directiveIndex !== lastSavedDirectiveIndex) {
tViewContentQueries.push(tView.queries.length - 1, directiveIndex);
}
}
function getTQuery(tView, index) {
ngDevMode && assertDefined(tView.queries, "TQueries must be defined to retrieve a TQuery");
return tView.queries.getByIndex(index);
}
function getQueryResults(lView, queryIndex) {
const tView = lView[TVIEW];
const tQuery = getTQuery(tView, queryIndex);
return tQuery.crossesNgTemplate ? collectQueryResults(tView, lView, queryIndex, []) : materializeViewResults(tView, lView, tQuery, queryIndex);
}
function createQuerySignalFn(firstOnly, required, opts) {
let node;
const signalFn = createComputed(() => {
node._dirtyCounter();
const value = refreshSignalQuery(node, firstOnly);
if (required && value === void 0) {
throw new RuntimeError(-951, ngDevMode && "Child query result is required but no value is available.");
}
return value;
});
node = signalFn[SIGNAL];
node._dirtyCounter = signal(0);
node._flatValue = void 0;
if (ngDevMode) {
signalFn.toString = () => `[Query Signal]`;
node.debugName = opts?.debugName;
}
return signalFn;
}
function createSingleResultOptionalQuerySignalFn(opts) {
return createQuerySignalFn(
/* firstOnly */
true,
/* required */
false,
opts
);
}
function createSingleResultRequiredQuerySignalFn(opts) {
return createQuerySignalFn(
/* firstOnly */
true,
/* required */
true,
opts
);
}
function createMultiResultQuerySignalFn(opts) {
return createQuerySignalFn(
/* firstOnly */
false,
/* required */
false,
opts
);
}
function bindQueryToSignal(target, queryIndex) {
const node = target[SIGNAL];
node._lView = getLView();
node._queryIndex = queryIndex;
node._queryList = loadQueryInternal(node._lView, queryIndex);
node._queryList.onDirty(() => node._dirtyCounter.update((v) => v + 1));
}
function refreshSignalQuery(node, firstOnly) {
const lView = node._lView;
const queryIndex = node._queryIndex;
if (lView === void 0 || queryIndex === void 0 || lView[FLAGS] & 4) {
return firstOnly ? void 0 : EMPTY_ARRAY;
}
const queryList = loadQueryInternal(lView, queryIndex);
const results = getQueryResults(lView, queryIndex);
queryList.reset(results, unwrapElementRef);
if (firstOnly) {
return queryList.first;
} else {
const resultChanged = queryList._changesDetected;
if (resultChanged || node._flatValue === void 0) {
return node._flatValue = queryList.toArray();
}
return node._flatValue;
}
}
function resolveComponentResources(resourceResolver) {
const componentResolved = [];
const urlMap = /* @__PURE__ */ new Map();
function cachedResourceResolve(url) {
let promise = urlMap.get(url);
if (!promise) {
const resp = resourceResolver(url);
urlMap.set(url, promise = resp.then((res) => unwrapResponse(url, res)));
}
return promise;
}
componentResourceResolutionQueue.forEach((component, type) => {
const promises = [];
if (component.templateUrl) {
promises.push(cachedResourceResolve(component.templateUrl).then((template) => {
component.template = template;
}));
}
const styles = typeof component.styles === "string" ? [component.styles] : component.styles || [];
component.styles = styles;
if (component.styleUrl && component.styleUrls?.length) {
throw new Error("@Component cannot define both `styleUrl` and `styleUrls`. Use `styleUrl` if the component has one stylesheet, or `styleUrls` if it has multiple");
} else if (component.styleUrls?.length) {
const styleOffset = component.styles.length;
const styleUrls = component.styleUrls;
component.styleUrls.forEach((styleUrl, index) => {
styles.push("");
promises.push(cachedResourceResolve(styleUrl).then((style) => {
styles[styleOffset + index] = style;
styleUrls.splice(styleUrls.indexOf(styleUrl), 1);
if (styleUrls.length == 0) {
component.styleUrls = void 0;
}
}));
});
} else if (component.styleUrl) {
promises.push(cachedResourceResolve(component.styleUrl).then((style) => {
styles.push(style);
component.styleUrl = void 0;
}));
}
const fullyResolved = Promise.all(promises).then(() => componentDefResolved(type));
componentResolved.push(fullyResolved);
});
clearResolutionOfComponentResourcesQueue();
return Promise.all(componentResolved).then(() => void 0);
}
var componentResourceResolutionQueue = /* @__PURE__ */ new Map();
var componentDefPendingResolution = /* @__PURE__ */ new Set();
function maybeQueueResolutionOfComponentResources(type, metadata) {
if (componentNeedsResolution(metadata)) {
componentResourceResolutionQueue.set(type, metadata);
componentDefPendingResolution.add(type);
}
}
function isComponentDefPendingResolution(type) {
return componentDefPendingResolution.has(type);
}
function componentNeedsResolution(component) {
return !!(component.templateUrl && !component.hasOwnProperty("template") || component.styleUrls && component.styleUrls.length || component.styleUrl);
}
function clearResolutionOfComponentResourcesQueue() {
const old = componentResourceResolutionQueue;
componentResourceResolutionQueue = /* @__PURE__ */ new Map();
return old;
}
function restoreComponentResolutionQueue(queue) {
componentDefPendingResolution.clear();
queue.forEach((_, type) => componentDefPendingResolution.add(type));
componentResourceResolutionQueue = queue;
}
function isComponentResourceResolutionQueueEmpty() {
return componentResourceResolutionQueue.size === 0;
}
function unwrapResponse(url, response) {
if (typeof response === "string") {
return response;
}
if (response.status !== void 0 && response.status !== 200) {
return Promise.reject(new RuntimeError(918, ngDevMode && `Could not load resource: ${url}. Response status: ${response.status}`));
}
return response.text();
}
function componentDefResolved(type) {
componentDefPendingResolution.delete(type);
}
var modules = /* @__PURE__ */ new Map();
var checkForDuplicateNgModules = true;
function assertSameOrNotExisting(id, type, incoming) {
if (type && type !== incoming && checkForDuplicateNgModules) {
throw new Error(`Duplicate module registered for ${id} - ${stringify(type)} vs ${stringify(type.name)}`);
}
}
function registerNgModuleType(ngModuleType, id) {
const existing = modules.get(id) || null;
assertSameOrNotExisting(id, existing, ngModuleType);
modules.set(id, ngModuleType);
}
function getRegisteredNgModuleType(id) {
return modules.get(id);
}
function setAllowDuplicateNgModuleIdsForTest(allowDuplicates) {
checkForDuplicateNgModules = !allowDuplicates;
}
function ɵɵvalidateIframeAttribute(attrValue, tagName, attrName) {
const lView = getLView();
const tNode = getSelectedTNode();
const element = getNativeByTNode(tNode, lView);
if (tNode.type === 2 && tagName.toLowerCase() === "iframe") {
const iframe = element;
iframe.src = "";
iframe.srcdoc = trustedHTMLFromString("");
nativeRemoveNode(lView[RENDERER], iframe);
const errorMessage = ngDevMode && `Angular has detected that the \`${attrName}\` was applied as a binding to an