 void 0 : locationHref.split("?");
                if (!splitUrl || splitUrl.length <= 1) {
                    return;
                }
                const afterSlashBeforeQuestionText = splitUrl[0].substring(splitUrl[0].lastIndexOf("/") + 1);
                const urlAfterLastSlashWithDhpRemoved = splitUrl[1]
                    .split("&")
                    .filter((param) => param != "startpage=1")
                    .join("&");
                const newUrlAfterLastSlash = urlAfterLastSlashWithDhpRemoved.length > 0
                    ? afterSlashBeforeQuestionText + "?" + urlAfterLastSlashWithDhpRemoved
                    : afterSlashBeforeQuestionText;
                window.history.replaceState({}, document.title, newUrlAfterLastSlash);
                // Update above telemetry properties, dont update msnocid if in enterprise
                if (!isEnterpriseAudience()) {
                    telemetryProperties.msnocid = "msedgntp";
                }
                telemetryProperties.pageType = "ntp";
                telemetryProperties.pageUrl = window.document.URL;
                // Update telemetry contract, dont update ocid if in enterprise
                let updatedPageTelemetryContract;
                if (isEnterpriseAudience()) {
                    updatedPageTelemetryContract = {
                        page: {
                            url: window.document.URL,
                            type: "ntp"
                        }
                    };
                }
                else {
                    updatedPageTelemetryContract = {
                        page: {
                            url: window.document.URL,
                            type: "ntp",
                            ocid: "msedgntp"
                        }
                    };
                }
                Telemetry.updatePageMetadata(updatedPageTelemetryContract);
            });
        }
        waitForPageSettingsTrackUpdate(telemetryProperties.waitForPageSettingsToUpdateTrack);
        return telemetryProperties;
    }
    /**
     * Creates telemetry contract for page
     * @param {any} telemetryProperties
     * @param (boolean) isStaticPage
     * @param (boolean) isMobile
     * @param (number) signedInStatus
     * @param (string) locationHref - The window.location.href passed from requestContext
     */
    static getPageTelemetryContract(telemetryProperties, isStaticPage, isMobile, isMsaUser, isAadUser, locationHref) {
        const isDefaultSearchBing = currentSearchParams().get("dsp") !== "0";
        const pageTelemetryContract = {
            page: {
                appType: appEnvironment.AppType,
                name: telemetryProperties.pageName,
                config: telemetryProperties.pageConfiguration,
                product: telemetryProperties.pageProduct,
                type: telemetryProperties.pageType,
                canvas: telemetryProperties.canvas,
                has3PSearch: !isDefaultSearchBing,
                isSearchAB: false,
                isAdEnabled: false,
                isAutoRefresh: false,
                isJSEnabled: true,
                isStatic: isStaticPage,
                ocid: telemetryProperties.msnocid || telemetryProperties.storeocid,
                url: locationHref,
                content: {
                    author: "",
                    brand: "",
                    brandId: "",
                    domainId: telemetryProperties.domainId,
                    id: "",
                    parentId: "",
                    partnerName: "",
                    source: "",
                    subcategory: telemetryProperties.department,
                    title: window.document.title,
                    topic: "",
                    vertical: telemetryProperties.vertical
                },
                viewType: viewTypeForEdgeNext()
            },
            feed: {
                id: ""
            },
            flight: {
                id: appEnvironment.CurrentRequestTargetScope &&
                    appEnvironment.CurrentRequestTargetScope.pageExperiments &&
                    appEnvironment.CurrentRequestTargetScope.pageExperiments.join(","),
                tmpl: []
            },
            locale: {
                mkt: appEnvironment.CurrentMarket
            },
            browser: {
                isMobile: isMobile,
                deviceGroup: "unknown"
            },
            user: {
                isSignedIn: isMsaUser,
                isSso: false,
                aadState: isAadUser ? AadAccountType.AadAccount : AadAccountType.NonAadAccount
            }
        };
        return pageTelemetryContract;
    }
}
/**
 * This code block is used for preload scenarios
 */
let pageRevealed = false;
let trackValuesUpdated = true;
// Check and add an event listener if page has been pre-loaded but not yet revealed.
if (headData.IsPrerender && document.visibilityState !== "visible") {
    waitForReveal().then(() => {
        pageRevealed = true;
        if (trackValuesUpdated) {
            Telemetry.flush();
        }
    });
}
else {
    pageRevealed = true;
}
/** Event handler to run once track values have been updated by respective entities */
function onTrackValuesUpdated() {
    document.removeEventListener(CustomEventNames.trackValuesUpdated, onTrackValuesUpdated);
    trackValuesUpdated = true;
    if (pageRevealed) {
        Telemetry.flush();
    }
}
/** Returns true if we are in enterprise mode */
function isEnterpriseAudience() {
    return appEnvironment.CurrentRequestTargetScope && appEnvironment.CurrentRequestTargetScope.audienceMode === AudienceModeType.Enterprise;
}
/** If config dictates to wait for page settings to update track values, set trackValuesUpdated to false and add an event listener for trackvaluesupdated. */
export function waitForPageSettingsTrackUpdate(waitForPageSettingsToUpdateTrack) {
    if (!waitForPageSettingsToUpdateTrack) {
        return;
    }
    trackValuesUpdated = false;
    // Add an event listener to listen for a signal indicating track values have been updated.
    document.addEventListener(CustomEventNames.trackValuesUpdated, onTrackValuesUpdated);
}
//# sourceMappingURL=EdgeNextTelemetry.js.mapA
Eo