{"version":3,"file":"msf-1.50.kbl70o08.js","sources":["../../../../src/js/components/perf.ts","../../../../src/js/client/apiPage/cache/geomCache.ts","../../../../src/js/client/apiPage/sfApi.ts","../../../../src/js/client/apiPage/cache/numberCache.ts","../../../../src/js/components/metrics/latency-metric-type.ts","../../../../../../../node_modules/@amzn/creative-rendering-monitor/src/btr.ts","../../../../../../../node_modules/@amzn/creative-rendering-monitor/src/creativeBTREvaluatorSync.ts","../../../../src/js/components/aax/aax.ts","../../../../src/js/components/counters/AD_LOAD_CSM_COUNTERS.ts","../../../../src/js/components/counters/BTR_COUNTERS.ts","../../../../src/js/components/counters/COD_COUNTERS.ts","../../../../src/js/components/counters/IMPRESSION_COUNTERS.ts","../../../../src/js/components/events/AD_LOAD_CSA_EVENTS.ts","../../../../../../../node_modules/@amzn/apejs-instrumentation/src/metrics/logging.ts","../../../../src/js/components/metrics/metric-tagger.ts","../../../../src/js/components/pixel.ts","../../../../src/js/components/urlQueryParams/addJSONQueryParamToURL.ts","../../../../src/js/client/MEASUREMENT_METHODS.ts","../../../../src/js/client/clientReporter.ts","../../../../src/js/client/commonSf.ts","../../../../src/js/client/CommonApiImplementation.ts","../../../../src/js/client/clientMessageReceiver.ts","../../../../src/js/client/clientMessageSender.ts","../../../../src/js/components/metrics/awsMetricLoggerApiKey.ts","../../../../src/js/components/metrics/awsMetricBatcher.ts","../../../../src/js/components/weblabs.ts","../../../../src/js/components/metrics/logMetricOnce.ts","../../../../src/js/components/metrics/awsMetricLogger.ts","../../../../src/js/components/viewRateExperimentUtil.ts","../../../../src/js/client/checkAndResizeImageOnlyCreative.ts","../../../../src/js/client/render.util.ts","../../../../src/js/client/validateCreativeRendering.ts","../../../../src/js/client/render.ts","../../../../src/js/client/service/documentWrite.ts","../../../../src/js/components/clickTracking/replace.ts","../../../../src/js/client/percolateClickTracker.ts","../../../../src/js/components/util.ts","../../../../src/js/client/service/get-creative.ts","../../../../src/js/client/CommonSFSetup.ts","../../../../src/js/client/Mash.ts","../../../../src/js/client/service/Mash.ts","../../../../src/js/client/MobileSFClientAPIImplementation.ts","../../../../src/js/client/application/safeframeClientFactory.ts","../../../../src/js/client/components/adDetails.ts","../../../../src/js/components/messaging/bootstrap.ts","../../../../src/js/client/components/notifyParent.ts","../../../../src/js/client/errorHandling/handleErrors.ts","../../../../src/js/components/messageChannel/common/sendMessage.ts","../../../../src/js/client/messageChannel/clientEventsChannel.ts","../../../../src/js/components/messageChannel/csm/csmChannelClient.ts","../../../../src/js/client/disable/disableCookieAccess.ts","../../../../src/js/client/disable/disableGeolocationApi.ts","../../../../src/js/client/disable/disableUserAgent.ts","../../../../src/js/client/disable/workAroundIOBugtt0156195085.ts","../../../../src/js/client/disable/disableAll.ts","../../../../src/js/client/security/referrers.ts","../../../../src/js/client/service/dcm.ts","../../../../src/js/client/service/setupReportingObserver.ts","../../../../src/js/client/initSafeframeClient.ts","../../../../src/js/client/entrypoints/msf.ts"],"sourcesContent":["import type { AdDetails } from '@amzn/safeframe-model';\n\nexport const getMarkName = (scope: string, message: string, adDetails?: AdDetails): string =>\n    `${scope}${adDetails ? `:${adDetails.placementName}` : ''} - ${message}`;\n\nexport const mark = (scope: string, message: string, adDetails?: AdDetails): string => {\n    const markString = getMarkName(scope, message, adDetails);\n\n    performance?.mark?.(markString);\n\n    return markString;\n};\n","import type { GeometricInformation } from '@amzn/safe-frame-client';\n\nimport type { Cache } from '@/client/apiPage/cache/cache.js';\n\nexport const defaultGeom: GeometricInformation = {\n    win: {\n        t: 0,\n        b: 0,\n        l: 0,\n        r: 0,\n        w: 0,\n        h: 0,\n    },\n    self: {\n        t: 0,\n        l: 0,\n        r: 0,\n        b: 0,\n        xiv: 0,\n        yiv: 0,\n        iv: 0,\n        z: 0,\n        w: 0,\n        h: 0,\n    },\n    exp: {\n        t: 0,\n        l: 0,\n        r: 0,\n        b: 0,\n        xs: 0,\n        yx: 0,\n    },\n};\n\nexport const createGeomCache = (initial: GeometricInformation = defaultGeom): Cache<GeometricInformation> => {\n    const cachedGeom: GeometricInformation = initial;\n\n    return {\n        set(newGeom: GeometricInformation): void {\n            cachedGeom.self = {\n                ...cachedGeom.self,\n                ...newGeom.self,\n            };\n        },\n        get(): GeometricInformation {\n            return cachedGeom;\n        },\n    };\n};\n","/**\n * @desc IAB safeframe API for some limited functionality\n * {@link http://www.iab.net/media/file/SafeFrames_v1.1_final.pdf}\n */\nimport type { ExternalParty, GeometricInformation } from '@amzn/safe-frame-client';\n\nimport { createGeomCache } from '@/client/apiPage/cache/geomCache.js';\nimport { createNumberCache } from '@/client/apiPage/cache/numberCache.js';\n\ndeclare global {\n    interface Window {\n        $sf?: SafeFrame;\n    }\n}\n\nexport interface SafeFrame {\n    ext: ExternalParty;\n}\n\nexport const inViewPercentageCache = createNumberCache();\nexport const geomCache = createGeomCache();\n\nexport const create$sf = (): SafeFrame => {\n    return {\n        ext: {\n            /**\n             * @desc Gives the inViewPercentage of the SafeFrame container as a whole number in [0, 100]\n             * @returns {Number} returns the inView percentage of the SafeFrame container\n             */\n            inViewPercentage: (): number => inViewPercentageCache.get(),\n\n            /**\n             * @desc Gives the geometric dimension and location of SafeFrame container\n             */\n            geom: (): GeometricInformation => geomCache.get(),\n        },\n    };\n};\n","import type { Cache } from '@/client/apiPage/cache/cache.js';\n\nexport const createNumberCache = (defaultNumber: number = -1): Cache<number> => {\n    let cachedNumber = defaultNumber;\n\n    return {\n        set(value: number): void {\n            cachedNumber = value;\n        },\n        get(): number {\n            return cachedNumber;\n        },\n    };\n};\n","type CsaKey =\n    | 'bodyBegin'\n    | 'bodyEnd'\n    | 'clickToATF'\n    | 'criticalFeature'\n    | 'loaded'\n    | 'viewablelatency:bodyBegin'\n    | 'viewablelatency:loaded';\n\ntype CsmKey = 'af' | 'bb' | 'be' | 'cf' | 'ld';\n\nconst HOST_SCOPE = 'sfImpression' as const;\nconst LIGHTAD_SCOPE = 'LightAdImpression' as const;\nconst VIEWABLE_LATENCY = 'viewablelatency' as const;\n\ntype CsmMessage = typeof HOST_SCOPE | typeof LIGHTAD_SCOPE | typeof VIEWABLE_LATENCY;\n\nexport interface LatencyMetricType {\n    readonly csaKey: CsaKey;\n    readonly csmKey: CsmKey;\n    readonly csmMessage?: CsmMessage;\n}\n\nconst create = (csaKey: CsaKey, csmKey: CsmKey, csmMessage?: CsmMessage): LatencyMetricType => {\n    return { csaKey, csmKey, csmMessage };\n};\n\nexport const BODY_BEGIN = create('bodyBegin', 'bb');\nexport const BODY_BEGIN_HOST_SCOPE = create('bodyBegin', 'bb', HOST_SCOPE);\nexport const BODY_BEGIN_LIGHTAD_SCOPE = create('bodyBegin', 'bb', LIGHTAD_SCOPE);\n\nexport const BODY_END = create('bodyEnd', 'be');\n\nexport const CLICK_TO_ATF = create('clickToATF', 'af');\n\nexport const CRITICAL_FEATURE = create('criticalFeature', 'cf');\nexport const CRITICAL_FEATURE_HOST_SCOPE = create('criticalFeature', 'cf', HOST_SCOPE);\nexport const CRITICAL_FEATURE_LIGHTAD_SCOPE = create('criticalFeature', 'cf', LIGHTAD_SCOPE);\n\nexport const LOADED = create('loaded', 'ld');\nexport const LOADED_HOST_SCOPE = create('loaded', 'ld', HOST_SCOPE);\nexport const LOADED_LIGHTAD_SCOPE = create('loaded', 'ld', LIGHTAD_SCOPE);\n\nexport const VIEWABLE_LATENCY_BODY_BEGIN = create('viewablelatency:bodyBegin', 'bb', VIEWABLE_LATENCY);\nexport const VIEWABLE_LATENCY_LOADED = create('viewablelatency:loaded', 'ld', VIEWABLE_LATENCY);\n","export const btr = {\n    set: (element: HTMLElement, value: boolean): void => {\n        element.dataset.isBtr = String(value);\n    },\n    get: (element: HTMLElement): boolean => {\n        return element.dataset.isBtr === String(true);\n    },\n};\n","/**\n * Possible status codes indicating the evaluation result of a creative's rendering.\n */\nimport { btr } from './btr.js';\n\nexport type Code = 'BEGIN_TO_RENDER' | 'ERROR' | 'NO_CREATIVE';\n\n/**\n * Represents the response structure for evaluating whether a creative has begun to render.\n */\nexport interface CreativeBeginToRenderResponse {\n    /** Indicates whether the creative has begun to render successfully. */\n    success: boolean;\n\n    /** The status code indicating the result of the evaluation. */\n    code: Code;\n}\n\n/**\n * Evaluates whether a creative inside the provided container has begun to render.\n * This is determined by checking the BTR dataset flag or if any visible images within the container have loaded.\n *\n * @param creativeContainer - The HTML element containing the creative.\n * @returns A response indicating whether rendering has begun.\n */\nexport const evaluateCreativeBeginToRender = (creativeContainer: HTMLElement): CreativeBeginToRenderResponse => {\n    if (btr.get(creativeContainer)) {\n        return { success: true, code: 'BEGIN_TO_RENDER' };\n    }\n\n    const images = Array.from(creativeContainer.querySelectorAll('img')).filter(\n        (x) => getComputedStyle(x).display !== 'none',\n    );\n    return evaluateAnyImageLoaded(images);\n};\n\n/**\n * Evaluates whether any image in the provided list has successfully loaded.\n *\n * The function checks if at least one image is fully loaded (i.e., it is marked as complete\n * and has non-zero dimensions). If no images are present, it returns `NO_CREATIVE`.\n * If at least one image loads successfully, it returns `BEGIN_TO_RENDER`.\n * If all images fail to load, it returns `ERROR`.\n *\n * @param images - An array of HTML image elements to evaluate.\n * @returns A response indicating whether rendering has begun, no creative was found, or an error occurred.\n */\nconst evaluateAnyImageLoaded = (images: HTMLImageElement[]): CreativeBeginToRenderResponse => {\n    if (images.length === 0) {\n        return { success: false, code: 'NO_CREATIVE' };\n    }\n\n    return images.some((img) => img.complete && img.naturalWidth > 0 && img.naturalHeight > 0)\n        ? { success: true, code: 'BEGIN_TO_RENDER' }\n        : { success: false, code: 'ERROR' };\n};\n","export const ATF_URL_KEY = 'atf' as const;\nexport const VIEW_PIXEL_URL_KEY = 'v' as const;\nexport const PUBLISHER_JSON_KEY = 'pj' as const;\nexport const BTR_JSON_KEY = 'c' as const;\nexport const aaxTypeMacro = /\\${AAX_TYPE}/;\nexport const aaxPayloadMacro = /\\${AAX_PAYLOAD}/;\n","// List of Pre-Defined CSM Counters to be used inside the safeframe.\nexport const IFRAME_INIT = 'adload:iframeinitialized';\nexport const RENDER_START = 'adload:renderstart';\nexport const RENDER_END = 'adload:renderend';\nexport const CREATIVE_WRITTEN = 'adload:creativewritten';\nexport const IMP = 'adload:impression';\nexport const BTR = 'adload:btr';\nexport const UNSERVED_IMP = 'adload:unservedimpression';\nexport const VIEWABILITY = 'adload:viewability';\nexport const UNSERVED_VIEWABILITY = 'adload:unservedviewability';\nexport const MEASURABILITY = 'adload:measurability';\n\n// These ones are used inside the host\nexport const START = 'adload:start';\nexport const CALLBACK = 'adload:delayloadcallback';\nexport const IFRAME_CREATED = 'adload:iframecreated';\n\nexport type AD_LOAD_COUNTERS =\n    | typeof IFRAME_INIT\n    | typeof RENDER_START\n    | typeof RENDER_END\n    | typeof CREATIVE_WRITTEN\n    | typeof IMP\n    | typeof BTR\n    | typeof UNSERVED_IMP\n    | typeof VIEWABILITY\n    | typeof UNSERVED_VIEWABILITY\n    | typeof MEASURABILITY\n    | typeof START\n    | typeof CALLBACK\n    | typeof IFRAME_CREATED;\n","export const LOADED = 'btr:loaded';\nexport const ERROR = 'btr:error';\nexport const IMPRESSION = 'btr:impression';\nexport const NO_IMAGES = 'btr:noimages';\nexport const NO_URL = 'btr:nourl';\nexport const TAGGED = 'btr:taggedcreative';\n\nexport type BTR_COUNTERS =\n    | typeof LOADED\n    | typeof ERROR\n    | typeof IMPRESSION\n    | typeof NO_IMAGES\n    | typeof NO_URL\n    | typeof TAGGED;\n","export const LOADED = 'cod:loaded';\nexport const ERROR = 'cod:error';\nexport const IMPRESSION = 'cod:impression';\nexport const NO_IMAGES = 'cod:noimages';\nexport const TAGGED = 'cod:taggedcreative';\n\nexport type COD_COUNTERS = typeof LOADED | typeof ERROR | typeof IMPRESSION | typeof NO_IMAGES | typeof TAGGED;\n","export const GLOBAL_IMPRESSION_FIRED_COUNTER = 'impressionFired';\n\nexport type IMPRESSION_COUNTERS = typeof GLOBAL_IMPRESSION_FIRED_COUNTER;\n","// List of Pre-Defined CSA Counters to be used inside the safeframe.\nexport const IFRAME_INIT = 'adload_iframeinitialized';\nexport const RENDER_START = 'adload_renderstart';\nexport const RENDER_END = 'adload_renderend';\nexport const CREATIVE_WRITTEN = 'adload_creativewritten';\nexport const IMP = 'impression';\nexport const BTR = 'btr';\nexport const UNSERVED_IMP = 'unservedimpression';\nexport const VIEWABILITY = 'viewability';\nexport const UNSERVED_VIEWABILITY = 'unservedviewability';\nexport const MEASURABILITY = 'measurability';\n\n// Host side\nexport const START = 'adload_start';\nexport const CALLBACK = 'adload_delayload';\n\nexport type AD_LOAD_EVENTS =\n    | typeof IFRAME_INIT\n    | typeof RENDER_START\n    | typeof RENDER_END\n    | typeof CREATIVE_WRITTEN\n    | typeof IMP\n    | typeof UNSERVED_IMP\n    | typeof VIEWABILITY\n    | typeof UNSERVED_VIEWABILITY\n    | typeof MEASURABILITY\n    | typeof START\n    | typeof CALLBACK;\n","import { LogLevel } from './csmGlobal';\n\n/*\n * All Error logging should go through these 2 functions.\n * Issues which degrade customer experience should call {@link logFatal}\n * Log level descriptions: https://w.amazon.com/bin/view/ClientSideMetrics/UserDocs/JavascriptErrors/#Error_levels\n * This will send messages/errors to RTLA, which can be analyzed to provide more information.\n */\n\n/**\n * Logs a message to the console, with console.debug(message)\n * @param message text send to console\n */\nexport const logDebug = (message: string): void => {\n    console.debug(message);\n};\n\n/**\n * Sends a warn message to RTLA.\n * @param message the text string of the warn\n * @param err the error object to log, if omitted, an error object will be created using message\n */\nexport const logWarn = (message: string, err?: Error | any): void => {\n    console.warn(message, JSON.stringify(err));\n    emitToRTLA('WARN', message, toError(message, err));\n};\n\n/**\n * Send an error message to RTLA. Use {@link logFatal} instead for issues which degrade customer experience.\n * @param message the text string of the error\n * @param err the error object to log, if omitted, an error object will be created using message\n */\nexport const logError = (message: string, err?: Error | any): void => {\n    console.error(message, JSON.stringify(err));\n    emitToRTLA('ERROR', message, toError(message, err));\n};\n\n/**\n * Send a fatal error message to RTLA. Use {@link logError} instead for non-critical errors.\n * @param message the text string of the error\n * @param err the error object to log, if omitted, an error object will be created using message\n */\nexport const logFatal = (message: string, err?: Error | any): void => {\n    console.error(message, JSON.stringify(err));\n    emitToRTLA('FATAL', message, toError(message, err));\n};\n\nconst emitToRTLA = (level: LogLevel, message: string, err: Error): void => {\n    window.ueLogError?.(err, {\n        logLevel: level,\n        attribution: 'APE-safeframe',\n        message: message + ' | '\n    });\n};\n\nconst toError = (message: string, err: any): Error =>\n    err instanceof Error ? err : err ? new Error(err) : new Error(message);\n","import { setCsaEntity } from '@amzn/apejs-instrumentation/src/metrics/csa/events.js';\nimport { addCsmPlacementTag, addCsmTag } from '@amzn/apejs-instrumentation/src/metrics/csm/tag.js';\nimport type { AdDetails } from '@amzn/safeframe-model';\nimport type { LightAdDetails } from '@amzn/safeframe-model';\n\nimport type { Placement } from '../../light-ad/domain/model/placement.js';\n\nexport const addLightAdTags = (placement: Placement, lightAdDetails: LightAdDetails) => {\n    addCsmPlacementTag('adrender', placement);\n    addCsmPlacementTag('adrender:lightad', placement);\n    if (lightAdDetails.adCreativeMetaData.adCreativeId) {\n        addCsmPlacementTag('adrender', placement, `creativeid:${lightAdDetails.adCreativeMetaData.adCreativeId}`);\n        setCsaEntity({ creativeId: lightAdDetails.adCreativeMetaData.adCreativeId.toString() });\n    }\n    if (lightAdDetails.adCreativeMetaData.adProgramId) {\n        addCsmPlacementTag('adrender', placement, `programid:${lightAdDetails.adCreativeMetaData.adProgramId}`);\n        setCsaEntity({ programId: lightAdDetails.adCreativeMetaData.adProgramId.toString() });\n    }\n    if (typeof lightAdDetails.isCardsFlow !== 'undefined') {\n        setCsaEntity({ isCardsFlow: lightAdDetails.isCardsFlow.toString() });\n    }\n    const creativeTemplateName = getCreativeTemplateNameForTagging(lightAdDetails);\n    addCsmPlacementTag('adrender', placement, `creativetemplatename:${creativeTemplateName}`);\n    setCsaEntity({\n        adrender: 'true',\n        creativeTemplateName: creativeTemplateName,\n        isLightAds: 'true',\n    });\n};\n\nexport const addSafeframeTags = (adDetails: AdDetails) => {\n    if (!adDetails?.adCreativeMetaData || !Object.keys(adDetails.adCreativeMetaData).length) {\n        addCsmTag('noadrender');\n        setCsaEntity({ adrender: 'false' });\n        return;\n    }\n\n    addCsmTag('adrender');\n    addCsmTag('adrender:safeframe');\n\n    tagTemplate(adDetails);\n    tagCreativeId(adDetails);\n    tagProgramId(adDetails);\n    tagIsCardsFlow(adDetails);\n};\n\nconst tagTemplate = (adDetails: AdDetails): void => {\n    const creativeTemplateName = getCreativeTemplateNameForTagging(adDetails);\n    addCsmTag('adrender', 'creativetemplatename:' + creativeTemplateName);\n    setCsaEntity({\n        adrender: 'true',\n        creativeTemplateName: creativeTemplateName,\n        isLightAds: 'false',\n    });\n};\n\n/*\n * Helper function to prepare creative template name for tagging\n * 1. Change to lower case\n * 2. Remove all non-alphanumeric characters\n * 3. Use 'unknown' if it does not exist\n */\nexport const getCreativeTemplateNameForTagging = (adDetails: AdDetails | LightAdDetails): string => {\n    if (adDetails.adCreativeMetaData.adCreativeTemplateName) {\n        return adDetails.adCreativeMetaData.adCreativeTemplateName.toLowerCase().replace(/[^0-9a-z]/g, '');\n    }\n\n    return 'unknown';\n};\n\nconst tagCreativeId = (adDetails: AdDetails): void => {\n    if (adDetails.adCreativeMetaData.adCreativeId) {\n        addCsmTag('adrender', 'creativeid:' + adDetails.adCreativeMetaData.adCreativeId);\n        setCsaEntity({\n            creativeId: adDetails.adCreativeMetaData.adCreativeId,\n        });\n    }\n};\n\nconst tagProgramId = (adDetails: AdDetails): void => {\n    if (adDetails.adCreativeMetaData.adProgramId) {\n        addCsmTag('adrender', 'programid:' + adDetails.adCreativeMetaData.adProgramId);\n        setCsaEntity({\n            adProgramId: adDetails.adCreativeMetaData.adProgramId,\n        });\n    }\n};\n\nconst tagIsCardsFlow = (adDetails: AdDetails): void => {\n    if (adDetails.isCardsFlow !== undefined) {\n        setCsaEntity({\n            isCardsFlow: adDetails.isCardsFlow.toString(),\n        });\n    }\n};\n","import type { CommonApiImplementation } from '@/client/CommonApiImplementation.js';\n\n/*\n * We no longer trigger pixel tracking URLs by appending the img to the DOM.\n * We use a made up attribute 'pixel-url' to store the URL for testing/debugging.\n * We will directly call the pixel URL with the fetch API.\n */\nexport const createPixel = (id: string, pixelUrl: string): HTMLImageElement => {\n    const pixel = document.createElement('img');\n    pixel.id = id;\n    pixel.style.display = 'none';\n    pixel.setAttribute('pixel-url', pixelUrl);\n    return pixel;\n};\n\nexport const formFullCounterName = (baseCounterName: string, eventName: string, extension: string | undefined) => {\n    let finalCounter = baseCounterName + eventName;\n    if (extension) {\n        finalCounter += '_' + extension;\n    }\n    return finalCounter;\n};\n\nexport const isPixelFired = (id: string): boolean => !!document.getElementById(id);\n\nexport type PixelData = {\n    id: string;\n    pixelUrl: string;\n    baseCounterName: string;\n    baseMetricName: string;\n    counterExtension?: string;\n    logId: string;\n    aaxProgramId?: string;\n};\n\n/**\n * Fires pixel via initiating an image request\n * @param {Object} messengerClient - safeframe messenger client\n * @param {string} pixelUrl - url of pixel to be fired\n * @param {string} id - pixel id in DOM\n * @param {string} baseCounterName - base CSM counter name\n * @param {string} baseMetricName - base CSA metric name\n * @param {string} counterExtension - extension to CSM counters that are fired\n * @param {Object} additionalTrace - for adBar logging\n * @returns {boolean} indicates if pixel was fired.  Will be false if already fired\n */\nexport const firePixel = async (\n    c: CommonApiImplementation,\n    { pixelUrl, id, baseCounterName, baseMetricName, counterExtension, logId, aaxProgramId }: PixelData,\n): Promise<boolean> => {\n    try {\n        if (isPixelFired(id)) return false;\n\n        c.logCsaEvent(formFullCounterName(baseMetricName, 'fired', counterExtension));\n        c.countMetric(formFullCounterName(baseCounterName, 'fired', counterExtension), 1);\n\n        await fetch(pixelUrl, { keepalive: true, mode: 'no-cors', priority: 'low' } as RequestInit);\n        document.getElementsByTagName('body')[0].appendChild(createPixel(id, pixelUrl));\n\n        c.countMetric(formFullCounterName(baseCounterName, 'loaded', counterExtension), 1);\n        c.logCsaEvent(formFullCounterName(baseMetricName, 'loaded', counterExtension));\n\n        c.countMetric(`pixel:${logId}`, 1, true);\n        aaxProgramId && c.countMetric(`pixel:${logId}:${aaxProgramId}`, 1, true);\n\n        return true;\n    } catch (ex) {\n        c.countMetric(formFullCounterName(baseCounterName, 'error', counterExtension), 1);\n        c.logCsaEvent(formFullCounterName(baseMetricName, 'error', counterExtension));\n        c.logError(`Error firing pixels: ${pixelUrl}`, ex as Error);\n        throw ex;\n    }\n};\n","const EMPTY_OBJECT_STRINGIFIED = '{}' as const;\nconst EMPTY_STRING = '' as const;\n\n/**\n * This function adds a query parameter to the given URL where the value is a JSON.\n * The most common use-case is addition of `publisherJSON` to AAX URLs. eg: https://evergreen.corp.amazon.com/aax-hub/apis/bid-api/xsp/#impression\n * If the existing URL already contains this parameter key, the two JSONs are merged based on the top-level keys.\n * In case of a conflict, priority is given to the new JSON.\n *\n * eg:\n * 1. If url contains json {\"key1\": \"value1\"}, and queryParamValueObject contains {\"key1\":\"value2\"}, priority is given to queryParamValueObject.\n *    Final json is {\"key1\":\"value2\"}\n * 2. If url contains json {\"key1\": \"value1\"}, and queryParamValueObject contains {\"key2\":\"value2\"}, JSONs are merged.\n *    Final json is {\"key1\":\"value1\", \"key2\":\"value2\"}\n *\n * @param {string} url - URL where query param needs to be added.\n * @param {string} queryParamKey - key of query param that needs to be added.\n * @param {Object} queryParamValueObject - value of query param that needs to be added.\n * @returns {string} URL with query param added.\n * @throws Error if invalid inputs are provided.\n **/\nexport const addJSONQueryParamToURL = (\n    url: string,\n    queryParamKey: string,\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    queryParamValueObject: { [key: string]: any },\n): string => {\n    if (queryParamKey === EMPTY_STRING) {\n        throw new Error(\n            'Invalid queryParamKey input to addJSONQueryParamToURL: ' +\n                JSON.stringify({ queryParamKey: queryParamKey }),\n        );\n    }\n    const urlObject = new URL(url);\n    const pk = urlObject.searchParams.get(queryParamKey);\n    const existingJSONString = pk ? pk : EMPTY_OBJECT_STRINGIFIED;\n    const existingJSONObject = JSON.parse(existingJSONString);\n    const mergedJSONObject = Object.assign(existingJSONObject, queryParamValueObject);\n    urlObject.searchParams.set(queryParamKey, JSON.stringify(mergedJSONObject));\n    return urlObject.toString();\n};\n","/**\n * measurementMethod will be an enum used for reporting purposes with following possible values\n *  * btr_client\n *  * btr_server\n *  * cod_client\n *  * cod_server\n *  * coi_client\n *  * coi_server\n *  * unknown (default option)\n * cod = Count on download: Creative html/script/tag/assets are requested by the client device.\n * coi = Count on Insertion: Represents counting at time of won bid / ad serve prior to download request by client.\n * btr = Begin to render: Creative assets are loaded and begin to render\n *\n */\nexport const BEGIN_TO_RENDER_CLIENT = 'btr_client' as const;\nexport const COUNT_ON_DOWNLOAD_CLIENT = 'cod_client' as const;\n\nexport type MEASUREMENT_METHODS = typeof BEGIN_TO_RENDER_CLIENT | typeof COUNT_ON_DOWNLOAD_CLIENT;\n","import { evaluateCreativeBeginToRender } from '@amzn/creative-rendering-monitor/src/creativeBTREvaluatorSync.js';\nimport type { AdDetails } from '@amzn/safeframe-model';\n\nimport type { CommonApiImplementation } from '@/client/CommonApiImplementation.js';\n\nimport { PUBLISHER_JSON_KEY } from '../components/aax/aax.js';\nimport { IMP } from '../components/counters/AD_LOAD_CSM_COUNTERS.js';\nimport { IMPRESSION as BTRIMPRESSION } from '../components/counters/BTR_COUNTERS.js';\nimport { IMPRESSION as CODIMPRESSION } from '../components/counters/COD_COUNTERS.js';\nimport { GLOBAL_IMPRESSION_FIRED_COUNTER } from '../components/counters/IMPRESSION_COUNTERS.js';\nimport * as AD_LOAD_EVENTS from '../components/events/AD_LOAD_CSA_EVENTS.js';\nimport { getCreativeTemplateNameForTagging } from '../components/metrics/metric-tagger.js';\nimport { firePixel } from '../components/pixel.js';\nimport { addJSONQueryParamToURL } from '../components/urlQueryParams/addJSONQueryParamToURL.js';\nimport type { MEASUREMENT_METHODS } from './MEASUREMENT_METHODS.js';\nimport { BEGIN_TO_RENDER_CLIENT, COUNT_ON_DOWNLOAD_CLIENT } from './MEASUREMENT_METHODS.js';\n\nexport class ClientReporter {\n    constructor(\n        readonly c: CommonApiImplementation,\n        readonly o: AdDetails,\n    ) {}\n\n    fireCodImpressionPixel = async () => {\n        let isPixelFired = false;\n        isPixelFired = await firePixel(this.c, {\n            id: 'ape_impression',\n            pixelUrl: createPixelUrl(this.o.aaxImpPixelUrl, PUBLISHER_JSON_KEY, COUNT_ON_DOWNLOAD_CLIENT),\n            baseCounterName: IMP,\n            baseMetricName: AD_LOAD_EVENTS.IMP,\n            logId: 'imp:cod',\n            aaxProgramId: this.o.adCreativeMetaData.adProgramId,\n        });\n\n        if (isPixelFired) {\n            // TODO: Migrate these metrics to the new pixel standard\n            // https://code.amazon.com/packages/D16GSafeFrame/blobs/544913ede51c527b81aff887c5744915092be10e/--/packages/@amzn/d16gsafeframe/src/js/components/pixels/btrPixel.ts#L9\n            this.emitImpressionPixelMetrics(false);\n        }\n    };\n\n    private emitImpressionPixelMetrics(isBtrPixel: boolean) {\n        const adProgramId = this.o.adCreativeMetaData.adProgramId ? this.o.adCreativeMetaData.adProgramId : 'unknown';\n        const creativeTemplateNameForMetrics = getCreativeTemplateNameForTagging(this.o);\n        this.c.countMetric(GLOBAL_IMPRESSION_FIRED_COUNTER, 1, true);\n        this.c.countMetric(GLOBAL_IMPRESSION_FIRED_COUNTER + ':program:' + adProgramId, 1, true);\n        this.c.countMetric(GLOBAL_IMPRESSION_FIRED_COUNTER + ':template:' + creativeTemplateNameForMetrics, 1, true);\n        const impressionMetric = isBtrPixel ? BTRIMPRESSION : CODIMPRESSION;\n        this.c.countMetric(impressionMetric, 1, false);\n        this.c.countMetric(impressionMetric, 1, true);\n        this.c.countMetric(impressionMetric + ':program:' + adProgramId, 1, true);\n        this.c.countMetric(impressionMetric + ':template:' + creativeTemplateNameForMetrics, 1, true);\n    }\n}\n\n// Creates the filled out impression tracking URL\nexport const createPixelUrl = (\n    aaxImpPixelUrl: string,\n    queryParamKey: string,\n    measurementMethod: MEASUREMENT_METHODS,\n) => {\n    const paets = aaxImpPixelUrl.includes('.paets.');\n    const legacyAnswer = addJSONQueryParamToURL(aaxImpPixelUrl, queryParamKey, {\n        measurementMethod: measurementMethod,\n    });\n    return paets ? aaxImpPixelUrl : legacyAnswer;\n};\n\nexport const tryWaitForBTR = async (element: HTMLElement = document.body): Promise<MEASUREMENT_METHODS> => {\n    const btrEvaluationWaitTime = 75;\n    let elapsedTime = 0;\n    const intervalMs = 5;\n\n    return new Promise<MEASUREMENT_METHODS>((resolve) => {\n        const intervalId = setInterval(() => {\n            elapsedTime += intervalMs;\n\n            const response = evaluateCreativeBeginToRender(element);\n            if (response.success) {\n                clearInterval(intervalId);\n                resolve(BEGIN_TO_RENDER_CLIENT);\n            } else if (elapsedTime >= btrEvaluationWaitTime) {\n                clearInterval(intervalId);\n                resolve(COUNT_ON_DOWNLOAD_CLIENT);\n            }\n        }, intervalMs);\n    });\n};\n","import { CRITICAL_FEATURE, LOADED } from '../components/metrics/latency-metric-type.js';\nimport type { CommonApiImplementation } from './CommonApiImplementation.js';\n\n/*\n * Use for cases where safeframe is not supported and\n * error message could not possibly propagate to parent\n * window for proper RTLA logging.\n */\n\n/**\n * @deprecated Use logError\n */\nexport const errorLog = (msg: string, ex?: Error | string) => {\n    /* eslint-disable no-console */\n    console.error(msg, ex);\n    /* eslint-enable no-console */\n};\n\nexport const sendCriticalFeatureAndLoaded = (c: CommonApiImplementation) => {\n    c.sendLatencyMetric(LOADED);\n    c.sendLatencyMetric(CRITICAL_FEATURE);\n};\n","import type { SFClientAPI, SFClientVideoAPI } from '@amzn/safe-frame-client-amzn';\nimport type { AdDetails } from '@amzn/safeframe-model';\n\nimport { geomCache, inViewPercentageCache } from '@/client/apiPage/sfApi.js';\nimport type { GeomMessage, SafeFrameExtMessage } from '@/host/api-client/handlers/sendSafeFrameExt.js';\n\nimport type { ComputedAdDetailsData, PixelOptionsData } from '../components/commands.js';\nimport type { LatencyMetricType } from '../components/metrics/latency-metric-type.js';\nimport { LOADED_HOST_SCOPE } from '../components/metrics/latency-metric-type.js';\nimport type { CommonSupportedCommands } from '../host/api-client/CommonSupportedCommands.js';\nimport type { ClientMessageListeners } from './clientMessageReceiver.js';\nimport type { ClientMessageSender } from './clientMessageSender.js';\nimport { ClientReporter } from './clientReporter.js';\nimport { sendCriticalFeatureAndLoaded } from './commonSf.js';\nimport type { InternalSFClientAPI } from './InternalSFClientAPI.js';\n\ndeclare global {\n    interface Window {\n        aPageStart?: number | undefined;\n        adStartTime?: number | undefined;\n    }\n}\n\n/**\n * @desc Contains safeframe client APIs that are common to desktop and mobile safeframe.\n */\nexport class CommonApiImplementation implements SFClientVideoAPI, SFClientAPI, InternalSFClientAPI {\n    public readonly cr: ClientReporter;\n\n    constructor(\n        private readonly cms: ClientMessageSender,\n        private readonly o: AdDetails,\n        private readonly mL: ClientMessageListeners,\n    ) {\n        this.cr = new ClientReporter(this, o);\n    }\n\n    fireImpression = async (_data: PixelOptionsData) => {\n        this.sendLatencyMetric(LOADED_HOST_SCOPE);\n        await this.cr.fireCodImpressionPixel();\n    };\n\n    changeSize = (width: string, height: string) => {\n        this.cms.sendMessage<CommonSupportedCommands['changeSize']>('changeSize', { width: width, height: height });\n    };\n    logCsaEvent = (metricName: string) => {\n        this.cms.sendMessage<CommonSupportedCommands['logCsaEvent']>('logCsaEvent', { metricName: metricName });\n    };\n    registerCustomMessageListener = (msgKey: string, callback: any) => {\n        this.mL[msgKey] = callback;\n        this.countMetric('sf:commonmain:registerCustomMessageListener', 1, true);\n    };\n    sendLatencyMetric = (latencyMetricType: LatencyMetricType) => {\n        this.cms.sendMessage<CommonSupportedCommands['sendLatencyMetric']>('sendLatencyMetric', {\n            latencyMetricType: latencyMetricType,\n            timestamp: new Date(),\n        });\n    };\n    countMetric = (msg: string, num: number = 1, isGlobal: boolean = false) => {\n        this.cms.sendMessage<CommonSupportedCommands['countMetric']>('countMetric', {\n            metricMsg: msg,\n            value: num,\n            isGlobal: isGlobal,\n        });\n    };\n\n    /**\n     * @desc Used by Creative template owners to trigger metric for 'Sponsored Label' rendered.\n     */\n    feedbackLabelRendered = () => {\n        this.cms.sendMessage<CommonSupportedCommands['feedbackLabelRendered']>('feedbackLabelRendered');\n    };\n    /**\n     * @desc Used by Creative template owners to open feedback Modal.\n     */\n    feedbackOpenModal = () => {\n        this.cms.sendMessage<CommonSupportedCommands['feedbackOpenModal']>('feedbackOpenModal');\n    };\n\n    /**\n     * Viewability pixels for video are fired from a combination of time spent in the view port and time spent playing.\n     * For ad templates which implement their own video player (ie Sponsored Display's PERC), they need to tell SF how much\n     * time has been spent playing. SF will combine this with its knowledge of in view time to determine when to fire a\n     * viewability pixel.\n     *\n     * @param continuousPlaybackSeconds - This is the maximum amount of continuous playback time the videoplayer has observed (in seconds)\n     */\n    updatePlayingTimeForVideo = (continuousPlaybackSeconds: number) => {\n        // Send message from iframe to host on the updated continuousPlaybackSeconds\n        this.cms.sendMessage<CommonSupportedCommands['sendSfVideoContinuousPlaytimeSeconds']>(\n            'sendSfVideoContinuousPlaytimeSeconds',\n            {\n                sfVideoContinuousPlaytimeSeconds: continuousPlaybackSeconds,\n            },\n        );\n    };\n    requestVideoAutoplay = () => {\n        this.cms.sendMessage<CommonSupportedCommands['requestVideoAutoplay']>('requestVideoAutoplay');\n    };\n    releaseVideoAutoplay = () => {\n        this.cms.sendMessage<CommonSupportedCommands['releaseVideoAutoplay']>('releaseVideoAutoplay');\n    };\n    haveVideoAutoplayPermission = () => {\n        this.cms.sendMessage<CommonSupportedCommands['haveVideoAutoplayPermission']>('haveVideoAutoplayPermission');\n    };\n\n    isOnAmazon = (): boolean => {\n        return true;\n    };\n    logError = (message: string, error?: Error, level?: number) => {\n        this.cms.sendMessage<CommonSupportedCommands['logError']>('logError', { message, error, level });\n    };\n    logFatal = (message: string, error?: Error, level?: number) => {\n        this.cms.sendMessage<CommonSupportedCommands['logFatal']>('logFatal', { message, error, level });\n    };\n\n    collapseSlot = () => {\n        this.cms.sendMessage<CommonSupportedCommands['collapseSlot']>('collapseSlot', 'CREATIVE');\n    };\n\n    resizeCreativeWrapper = (data: { height: string; width: string }) => {\n        const creativeWrapper = window.document.getElementById(`ape_${this.o.scope}_creativeWrapper`);\n        if (creativeWrapper === null) {\n            return;\n        }\n\n        creativeWrapper.style.height = data.height;\n        creativeWrapper.style.width = data.width;\n    };\n\n    /**\n     * Used to emit a custom event to the ad notifying that an event occurred outside the safeframe.\n     * @param data object containing the name of the event which is being propagated to the ad\n     */\n    triggerEventInIframe = (data: { eventType: string }) => {\n        window.dispatchEvent(new Event('outerpage' + data.eventType));\n    };\n\n    setupComputedAdDetails = (data: ComputedAdDetailsData) => {\n        window.aPageStart = data.aPageStart;\n        window.adStartTime = data.adStartTime;\n    };\n\n    signalAdLoadedAndInteractive = () => {\n        sendCriticalFeatureAndLoaded(this);\n    };\n\n    /**\n     *\n     * Client sends domain event to host to fire the\n     * COD impression pixel using the Light Ads logic\n     */\n    sendEventAddedCreative = () => {\n        this.cms.sendMessage<CommonSupportedCommands['sendEventAddedCreative']>('sendEventAddedCreative');\n    };\n\n    populateGeom = (message: GeomMessage): void => geomCache.set(message.geom);\n\n    populateSafeFrameExt = (message: SafeFrameExtMessage): void => {\n        inViewPercentageCache.set(message.inViewPercentage);\n        geomCache.set(message.geom);\n    };\n}\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport type { HostMessageToClient } from '../components/messaging/types.js';\nimport type { ClientApis } from './types/types.js';\n\nexport type ClientMessageListeners = { [key: string]: (data: any) => void };\n\nexport class ClientMessageReceiver {\n    constructor(\n        readonly c: ClientApis,\n        readonly o: AdDetails,\n        private readonly mL: ClientMessageListeners,\n    ) {}\n    private readonly pendingMessages = new Map<string, () => void>();\n    // TODO Convert this to a more generalized mechanism\n    // For now it just waits for the next message of the key to be processed\n    // Main usecase is for dynamic compuated details to get the non-Promised APIS to work as in\n    // https://code.amazon.com/packages/SafeFrameClient/blobs/e6d7afa4b0c567ab7ba245a07efd974cd8f3a6b6/--/packages/safe-frame-client-mobilesfclient/src/MobileSFClientAPI.ts#L187\n    /**\n     * This does not support more than one wait per message time and promise will only be resolved once\n     * @deprecated\n     * @param key The commadn to for wait for\n     * @returns A promise that will be fired.\n     */\n    waitForMessageProcessed = async (key: string): Promise<void> => {\n        return new Promise((resolve) => this.pendingMessages.set(key, resolve));\n    };\n\n    receiveMessage = (event: MessageEvent) => {\n        try {\n            const msg: HostMessageToClient = event.data;\n            // msgObj is expected to have a command\n            const cmdPath = msg.command ? msg.command.split('.') : [];\n            type ActionPath = { [key: string]: ActionPath } | ((...args: any) => void);\n            let action: ActionPath = this.c[cmdPath[0] as keyof ClientApis];\n            for (let i = 1; i < cmdPath.length; i++) {\n                if (action) {\n                    action = (action as unknown as { [key: string]: ActionPath })[cmdPath[i]];\n                } else {\n                    break;\n                }\n            }\n            if (msg.command === 'customMessage') {\n                // treat custom message specially\n                const msgKey = msg.data.key;\n                const body = msg.data.data;\n                if (typeof this.mL[msgKey] === 'function') {\n                    try {\n                        this.mL[msgKey](body);\n                    } catch (ex) {\n                        this.c.logError('Custom Message Listener Error', ex as Error);\n                    }\n                }\n            } else if (action) {\n                (action as (...args: any) => void)(msg.data);\n                resolveMessagePromise(msg.command, this.pendingMessages);\n            }\n        } catch (ex) {\n            //Log the error metrics for debugging purposes.\n            this.c.logError('Error with ' + event.data.command, ex as Error);\n            return;\n        }\n    };\n}\n\nconst resolveMessagePromise = (command: string, pendingMessages: Map<string, () => void>) => {\n    const resolve = pendingMessages?.get(command);\n    resolve?.();\n    pendingMessages?.delete(command);\n};\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport type { MessageCommand } from '@/components/messageChannel/common/sendMessage.js';\n\nimport type { ClientMessageToHost } from '../components/messenger.js';\nimport type { CommonSupportedCommands } from '../host/api-client/CommonSupportedCommands.js';\nimport type { MobileSupportedCommands } from '../host/api-client/MobileSupportedCommands.js';\nimport { errorLog } from './commonSf.js';\n\nexport type ToHostCommandType = keyof CommonSupportedCommands | keyof MobileSupportedCommands | MessageCommand;\n\nexport class ClientMessageSender {\n    constructor(\n        private o: AdDetails,\n        private messagePort: MessagePort,\n    ) {}\n\n    sendMessage = <T extends (...args: any) => any>(command: ToHostCommandType, data?: Parameters<T>[1]) => {\n        const msg: ClientMessageToHost = {\n            command: command,\n            adDetails: this.o,\n            payload: data || {},\n        };\n\n        try {\n            this.messagePort.postMessage(msg);\n        } catch (ex) {\n            errorLog('Post Message error', ex as Error);\n        }\n    };\n}\n","export const API_KEY: string = 'aUAZqFtiIp6VxqpW3coqZ2JdZnV3RN9S8yKMRIdJ';\n","import { API_KEY } from '@/components/metrics/awsMetricLoggerApiKey.js';\n\nexport const METRICS_ENDPOINT = 'https://qdbx3pbnx6veby23pzgaowu3q40tmmrr.lambda-url.us-east-1.on.aws';\nexport const STORAGE_KEY = 'APE_CW_METRICS';\nexport const BATCH_SIZE = 10;\n\nexport type PostMetricDTO = {\n    metrics: Metric[];\n    xApiKey: string;\n};\n\nexport type Metric = {\n    metricName: string;\n    timestamp: number;\n    value: number;\n    dimensions: Record<string, string>;\n};\n\nlet unloadHookRegistered = false;\n\n// Used for testing\nexport const resetUnloadHook = (): void => {\n    unloadHookRegistered = false;\n};\n\nexport const logMetric = (metric: Metric): void => {\n    if (!unloadHookRegistered) {\n        window.addEventListener('beforeunload', () => flushAndClear());\n        unloadHookRegistered = true;\n    }\n\n    const cache = getCache();\n    cache.push(metric);\n\n    if (cache.length >= BATCH_SIZE) {\n        flushCache(cache);\n    } else {\n        updateCache(cache);\n    }\n};\n\nconst getCache = (): Metric[] => {\n    const data = localStorage.getItem(STORAGE_KEY);\n    if (!data) return [];\n    try {\n        return JSON.parse(data) as Metric[];\n    } catch {\n        return [];\n    }\n};\n\nconst flushCache = (metrics: Metric[]): void => {\n    navigator.sendBeacon(METRICS_ENDPOINT, JSON.stringify(toPostMetricDTO(metrics)));\n    localStorage.removeItem(STORAGE_KEY);\n};\n\nconst toPostMetricDTO = (metrics: Metric[]): PostMetricDTO => ({\n    metrics: metrics,\n    xApiKey: API_KEY,\n});\n\nconst updateCache = (metrics: Metric[]): void => {\n    localStorage.setItem(STORAGE_KEY, JSON.stringify(metrics));\n};\n\nconst flushAndClear = (): void => {\n    const cache = getCache();\n    if (cache.length > 0) {\n        flushCache(cache);\n    }\n};\n","declare global {\n    // eslint-disable-next-line\n    interface Window extends WeblabsWindow {}\n}\n\nexport type WeblabTreatment = `t${number}`;\n\nexport type AllWeblabTreatment = WeblabTreatment | 'c';\n\nexport interface WeblabsWindow {\n    renderingWeblabs?: { [key: string]: string };\n}\n\nexport interface Weblab {\n    is(treatment: WeblabTreatment): boolean;\n    isInTreatment(): boolean;\n    getTreatment(): AllWeblabTreatment;\n}\n\nexport const createWeblab = (weblabsWindow: WeblabsWindow, prefix: string): Weblab => {\n    const weblabTreatment = (): AllWeblabTreatment =>\n        weblabsWindow?.renderingWeblabs?.[prefix]?.toLowerCase() as AllWeblabTreatment;\n\n    return {\n        is(treatment: WeblabTreatment): boolean {\n            return weblabTreatment() === treatment;\n        },\n        isInTreatment(): boolean {\n            return !!weblabTreatment() && weblabTreatment() !== 'c';\n        },\n        getTreatment(): AllWeblabTreatment {\n            return weblabTreatment() ?? 'c';\n        },\n    };\n};\n\n/*\n * Used for gating IN art event styling\n * @link https://weblab.amazon.com/wl/ADPT_SF_HOMEPAGE_ART_THEMING_1298909\n */\nexport const ADPT_SF_HOMEPAGE_ART_THEMING = () => createWeblab(window, 'ADPT_SF_HOMEPAGE_ART_THEMING_1298909');\n\n/*\n * Used for sampling metrics logging at a low rate\n * @link https://weblab.amazon.com/wl/ADPT_SF_LOW_RATE_METRIC_LOGGING_1256362\n */\nexport const ADPT_SF_LOW_RATE_METRIC_LOGGING = () => createWeblab(window, 'ADPT_SF_LOW_RATE_METRIC_LOGGING_1256362');\n\n/*\n * Use Light Ads pixel firing logic in Safeframe for COD pixel\n * @link https://weblab.amazon.com/wl/ADPT_SF_PIXEL_FIRING_1151992\n */\nexport const ADPT_SF_PIXEL_FIRING_1151992 = () => createWeblab(window, 'ADPT_SF_PIXEL_FIRING_1151992');\n\n/**\n * Used to enable new retail tracking with the JRS test painter.\n * @link https://weblab.amazon.com/wl/APM_STORES_JPS_JRS_SAFEFRAME_CLICK_TRACKING_PAINTER_TEST_1259727\n */\nexport const CLICK_TRACKING_PAINTER_TEST = () =>\n    createWeblab(window, 'APM_STORES_JPS_JRS_SAFEFRAME_CLICK_TRACKING_PAINTER_TEST_1259727');\n\n/**\n * Used to enable viewability-based impression pixel firing for CA, JP, and UK marketplaces.\n * @link https://weblab.amazon.com/wl/APM_STORES_JPS_JRS_SAFEFRAME_VIEW_RATE_EXPERIMENT_1289633\n */\nexport const VIEW_RATE_EXPERIMENT = () =>\n    createWeblab(window, 'APM_STORES_JPS_JRS_SAFEFRAME_VIEW_RATE_EXPERIMENT_1289633');\n\n/**\n * Used to control timeout for placement viewability of Stores View Rate experiment in ES and FR marketplaces.\n * @link https://weblab.amazon.com/wl/APM_STORES_JPS_JRS_SAFEFRAME_VIEW_RATE_EXPERIMENT_TIMEOUT_1373183\n */\nexport const VIEW_RATE_EXPERIMENT_TIMEOUT = () =>\n    createWeblab(window, 'APM_STORES_JPS_JRS_SAFEFRAME_VIEW_RATE_EXPERIMENT_TIMEOUT_1373183');\n\n/**\n * Used to disable user agent access for creatives\n * @link https://shepherd.a2z.com/issues/e4e8cd86-419a-4e1a-96ff-b20a6615b8b5\n */\nexport const DISABLE_USER_AGENT_WEBLAB = () =>\n    createWeblab(window, 'APM_STORES_JPS_JRS_SAFEFRAME_DISABLE_USER_AGENT_1326744');\n\n/**\n * Used to enable new viewability tracker implementation\n * @link https://weblab.amazon.com/wl/APM_STORES_JPS_JRS_SAFEFRAME_NEW_VIEWABILITY_TRACKER_1354300\n */\nexport const NEW_VIEWABILITY_TRACKER_WEBLAB = () =>\n    createWeblab(window, 'APM_STORES_JPS_JRS_SAFEFRAME_NEW_VIEWABILITY_TRACKER_1354300');\n\n/**\n * Used to enable LightFrames on all eligible placement\n * @link https://weblab.amazon.com/wl/APM_STORES_JPS_JRS_SAFEFRAME_LIGHT_ADS_EVERYWHERE_1362485\n */\nexport const LIGHT_ADS_EVERYWHERE_WEBLAB = () =>\n    createWeblab(window, 'APM_STORES_JPS_JRS_SAFEFRAME_LIGHT_ADS_EVERYWHERE_1362485');\n\n/**\n * Used to enable iframe ready retry mechanism for host message receiver\n * @link https://weblab.amazon.com/wl/APM_STORES_JPS_JRS_SAFEFRAME_IFRAME_READY_RETRY_1374491\n */\nexport const IFRAME_READY_RETRY_WEBLAB = () =>\n    createWeblab(window, 'APM_STORES_JPS_JRS_SAFEFRAME_IFRAME_READY_RETRY_1374491');\n\n/**\n * Used to disable window.top\n * @link https://weblab.amazon.com/wl/APM_STORES_JPS_JRS_SAFEFRAME_DISABLE_POSTMESSAGE_1327371\n */\nexport const DISABLE_POSTMESSAGE_WEBLAB = () =>\n    createWeblab(window, 'APM_STORES_JPS_JRS_SAFEFRAME_DISABLE_POSTMESSAGE_1327371');\n","import type { Metric } from '@/components/metrics/awsMetricBatcher.js';\nimport { logMetric } from '@/components/metrics/awsMetricBatcher.js';\n\n/**\n * logMetric(), but ensure that the same metricName is only logged once per page load.\n */\nexport const logMetricOnce = (metric: Metric): void => {\n    if (!window.APE_SF) {\n        return;\n    }\n\n    // Initlialize the store if it doesn't exist\n    const store = (window.APE_SF.loggedMetricNames ??= new Set<string>());\n\n    if (store.has(metric.metricName)) {\n        return;\n    }\n\n    store.add(metric.metricName);\n\n    logMetric(metric);\n};\n","import type { AdDetails } from '@amzn/safeframe-model';\nimport type { LightAdDetails } from '@amzn/safeframe-model';\n\nimport type { Metric } from '@/components/metrics/awsMetricBatcher.js';\nimport { logMetric } from '@/components/metrics/awsMetricBatcher.js';\nimport { ADPT_SF_LOW_RATE_METRIC_LOGGING } from '@/components/weblabs.js';\n\nimport { logMetricOnce } from './logMetricOnce.js';\n\ntype MetricInputBase = {\n    /**\n     * The name of the metric to log. Use colon (:) to separate metric components. E.g., \"asset:load:timing\"\n     */\n    metricName: string;\n    /**\n     * Number of occurrences to log. Defaults to 1.\n     */\n    count?: number;\n    /**\n     * Additional dimensions to add to the metric. These will be merged with the default dimensions.\n     */\n    additionalDimensions?: Record<string, string>;\n    /**\n     * Whether the metric should only be logged once per page load\n     */\n    once?: boolean;\n};\n\ntype MetricInputSF = MetricInputBase & {\n    adDetails: AdDetails;\n};\n\ntype MetricInputLA = MetricInputBase & {\n    lightAdDetails: LightAdDetails;\n};\n\n/**\n * @deprecated This is not live yet. Don't use.\n * SIM: https://sim.amazon.com/issues/CPP-39529\n */\nexport const logLowRateMetricSF = ({\n    metricName,\n    adDetails,\n    count = 1,\n    additionalDimensions = {},\n    once = false,\n}: MetricInputSF): void => {\n    if (ADPT_SF_LOW_RATE_METRIC_LOGGING().is('t1')) {\n        const logFn = once ? logMetricOnce : logMetric;\n        logFn(toMetric(metricName, count, toSFDimensions(adDetails, additionalDimensions)));\n    }\n};\n\n/**\n * @deprecated This is not live yet. Don't use.\n * SIM: https://sim.amazon.com/issues/CPP-39529\n */\nexport const logLowRateMetricLA = ({\n    metricName,\n    lightAdDetails,\n    count = 1,\n    additionalDimensions = {},\n}: MetricInputLA): void => {\n    if (ADPT_SF_LOW_RATE_METRIC_LOGGING().is('t1')) {\n        logMetric(toMetric(metricName, count, toLADimensions(lightAdDetails, additionalDimensions)));\n    }\n};\n\nconst toMetric = (metricName: string, count: number, dimensions: Record<string, string>): Metric => ({\n    metricName: metricName,\n    timestamp: new Date().getTime(),\n    value: count,\n    dimensions: dimensions,\n});\n\nconst toSFDimensions = (adDetails: AdDetails, additionalDimensions: Record<string, string>): Record<string, string> => {\n    return {\n        app: 'SF',\n        siteName: adDetails.siteName,\n        slotName: adDetails.slotName,\n        pageType: adDetails.pageType,\n        placementId: adDetails.placementId,\n        mediaType: adDetails.mediaType,\n        programId: adDetails.adCreativeMetaData?.adProgramId,\n        creativeTemplateName: adDetails.adCreativeMetaData?.adCreativeTemplateName,\n        deviceType: adDetails.deviceType,\n        ...additionalDimensions,\n    };\n};\n\nconst toLADimensions = (\n    adDetails: LightAdDetails,\n    additionalDimensions: Record<string, string> | undefined,\n): Record<string, string> => {\n    return {\n        app: 'LA',\n        siteName: adDetails.siteName,\n        slotName: adDetails.slotName,\n        pageType: adDetails.pageType,\n        placementId: adDetails.placementId,\n        mediaType: adDetails.videoCreative ? 'V' : 'D',\n        programId: adDetails.adCreativeMetaData?.adProgramId,\n        creativeTemplateName: adDetails.adCreativeMetaData?.adCreativeTemplateName,\n        deviceType: adDetails.deviceType,\n        ...additionalDimensions,\n    };\n};\n","import type { Pixel } from '@/components/pixels/pixel.js';\nimport type { Placement } from '@/components/pixels/pixel.js';\nimport { btr } from '@/components/pixels/placementData.js';\nimport type { FirePixelValidator } from '@/components/pixels/services/firePixelValidator.js';\nimport type { ViewabilityService } from '@/components/pixels/services/viewabilityService.js';\nimport { createViewabilityTracker } from '@/components/pixels/viewabilityTrackerImpl.js';\nimport { VIEW_RATE_EXPERIMENT, VIEW_RATE_EXPERIMENT_TIMEOUT } from '@/components/weblabs.js';\n\n/**\n * TODO: Clean up View Rate Experiment\n * https://sim.amazon.com/issues/ASPEN-9994\n */\nexport interface ViewRateExperimentPixels {\n    impressionPixel: Pixel;\n    btrPixel?: Pixel;\n    measurabilityPixel: Pixel;\n}\n\nconst weblabTreatmentToThreshold: Record<string, number> = {\n    c: 0,\n    t1: 0.1,\n    t2: 0.2,\n    t3: 0.3,\n    t4: 0.4,\n    t5: 0.5,\n};\n\nconst weblabTreatmentToTimeout: Record<string, number> = {\n    c: 0,\n    t1: 100,\n    t2: 200,\n    t3: 300,\n    t4: 400,\n    t5: 500,\n    t6: 600,\n    t7: 700,\n    t8: 800,\n    t9: 900,\n};\n\nexport const isViewRateExperimentEnabled = (aaxProgramId: number): boolean => {\n    return aaxProgramId !== 1004 && VIEW_RATE_EXPERIMENT().isInTreatment();\n};\n\nconst btrFirePixelValidator = (placement: Placement): FirePixelValidator => {\n    return {\n        shouldFirePixel(): boolean {\n            return btr.get(placement);\n        },\n    };\n};\n\nexport const trackViewRateExperiment = (\n    placement: Placement,\n    pixels: ViewRateExperimentPixels,\n    viewabilityService: ViewabilityService,\n): void => {\n    const viewabilityStandard = {\n        definition: '',\n        thresholdPercentage: weblabTreatmentToThreshold[VIEW_RATE_EXPERIMENT().getTreatment()],\n        thresholdTimeVisibleMs: weblabTreatmentToTimeout[VIEW_RATE_EXPERIMENT_TIMEOUT().getTreatment()],\n    };\n    // ViewabilityTracker for impression and measurability pixels\n    const impViewabilityTracker = createViewabilityTracker(\n        [pixels.impressionPixel, pixels.measurabilityPixel],\n        viewabilityStandard,\n        viewabilityService,\n        [],\n    );\n    impViewabilityTracker.track(placement);\n\n    // ViewabilityTracker for btrPixel\n    if (pixels.btrPixel) {\n        const btrViewabilityTracker = createViewabilityTracker(\n            [pixels.btrPixel],\n            viewabilityStandard,\n            viewabilityService,\n            [btrFirePixelValidator(placement)],\n        );\n        btrViewabilityTracker.track(placement);\n    }\n};\n","import type { CommonSupportedCommands } from '@/host/api-client/CommonSupportedCommands.js';\n\nimport type { ClientMessageSender } from './clientMessageSender.js';\n\n// Threshold for considering an image to be spanning the viewport (95%)\nconst VIEWPORT_COVERAGE_THRESHOLD = 0.95;\n\n// Threshold for considering text to be significant (num chars)\nconst SIGNIFICANT_TEXT_THRESHOLD = 75;\n\n// 1P image template ads generally have this class name\nconst AD_BACKGROUND_IMAGE_CLASS = 'ad-background-image';\n\n/**\n * Checks if an image has the 'ad-background-image' class\n */\nexport const hasBackgroundImageClass = (imgElement: HTMLImageElement): boolean =>\n    imgElement.classList.contains(AD_BACKGROUND_IMAGE_CLASS);\n\n/**\n * Checks if an image covers a significant portion of the viewport width\n */\nexport const isImageCoveringViewportWidth = (imgWidth: number): boolean =>\n    imgWidth / window.innerWidth >= VIEWPORT_COVERAGE_THRESHOLD;\n\n/**\n * Checks if the document has significant text content\n */\nexport const hasSignificantText = (): boolean => {\n    // get innerText and strip whitespace\n    const text = (document.documentElement.innerText ?? '').replace(/\\s/g, '');\n    return text.length > SIGNIFICANT_TEXT_THRESHOLD;\n};\n\n/**\n * Checks an array of images for one with the target className\n * @param images\n * @returns\n */\nexport const hasAnyImageWithAdBackgroundClass = (images: HTMLImageElement[]) =>\n    images.some((image) => image.classList.contains(AD_BACKGROUND_IMAGE_CLASS));\n\n/**\n * Returns the largest image based on area.\n */\nexport const hasLargeImage = (images: HTMLImageElement[]): boolean => {\n    for (const image of images) {\n        const rect = image.getBoundingClientRect();\n\n        // check to see if this image covers all/most of the viewport width\n        if (isImageCoveringViewportWidth(rect.width)) {\n            return true;\n        }\n    }\n\n    return false;\n};\n\n/**\n * Determines if the ad is an image template ad and sends appropriate message if needed\n */\nexport const isImageTemplateAd = (): boolean => {\n    // Find all images in the creative\n    const images = Array.from(document.querySelectorAll('img'));\n\n    // no images in the ad means it is not an image template\n    if (!images.length) return false;\n\n    // if any image has .ad-background-class, it is an image template\n    if (hasAnyImageWithAdBackgroundClass(images)) return true;\n\n    // if no large images (spans viewport width), it is not an image template\n    if (!hasLargeImage(images)) return false;\n\n    // if the ad has a full width image, but has a lot of text, likely not an image template\n    if (hasSignificantText()) return false;\n\n    // all conditions met, this is likely an image-only ad\n    return true;\n};\n\n/**\n * Checks to see if the creative consists primarily of an image that spans (or nearly spans)\n * the entire viewport. If so, sends a message to the host to indicate this is an image-only creative.\n */\nexport const checkAndResizeImageOnlyCreative = (cms: ClientMessageSender): void => {\n    // Check if the creative is an image-only creative\n    if (isImageTemplateAd()) {\n        // If we found a large image and no significant text\n        cms.sendMessage<CommonSupportedCommands['resizeForImageOnlyTemplate']>('resizeForImageOnlyTemplate');\n    }\n};\n","import { creativeReplayId } from './render.js';\n\ntype FiredAttributes = 'iscomplete' | 'creativeLoad' | 'creativedomcontentloaded';\n\n// This is so we can tell from the DOM if the creative has triggered\n//  This is useful for UI testing and also interactive debugging\nexport const markScriptAsFired = (attr: FiredAttributes) =>\n    document.getElementById(creativeReplayId)?.setAttribute(attr, 'true');\n","import type { CreativeRenderingValidators } from '@amzn/creative-rendering-validation/src/api/blankAdDetection.js';\nimport type { AdDetails } from '@amzn/safeframe-model';\n\nimport { logLowRateMetricSF } from '@/components/metrics/awsMetricLogger.js';\n\nimport type { InternalSFClientAPI } from './InternalSFClientAPI.js';\n\ndeclare global {\n    interface Window {\n        crv: CreativeRenderingValidators;\n    }\n}\n\nexport const validateCreativeRendering = (adDetails: AdDetails, clientApi: InternalSFClientAPI): void => {\n    const callBlankAdValidation = async () => {\n        if (typeof window?.crv?.detectAndReportBlankAd === 'function') {\n            clearInterval(intervalId);\n            try {\n                const result = await window.crv.detectAndReportBlankAd(document.body);\n                if (result) {\n                    clientApi.countMetric('blankadvalidation:failure', 1, true);\n                    logLowRateMetricSF({\n                        metricName: 'blank:ad',\n                        adDetails: adDetails,\n                        additionalDimensions: {\n                            creativeId: adDetails.adCreativeMetaData.adCreativeId,\n                        },\n                    });\n                } else {\n                    clientApi.countMetric('blankadvalidation:success', 1, true);\n                }\n            } catch (err) {\n                clientApi.countMetric('blankadvalidation:error', 1, true);\n            }\n        }\n    };\n\n    const intervalId = setInterval(callBlankAdValidation, 1000);\n};\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport type { EventsChannel } from '@/components/messageChannel/eventsChannel.js';\nimport { isViewRateExperimentEnabled } from '@/components/viewRateExperimentUtil.js';\nimport { ADPT_SF_PIXEL_FIRING_1151992 } from '@/components/weblabs.js';\n\nimport type { CommonSupportedCommands } from '../host/api-client/CommonSupportedCommands.js';\nimport { checkAndResizeImageOnlyCreative } from './checkAndResizeImageOnlyCreative.js';\nimport type { ClientMessageSender } from './clientMessageSender.js';\nimport type { ClientReporter } from './clientReporter.js';\nimport { tryWaitForBTR } from './clientReporter.js';\nimport { generateSyntheticLoadEvent } from './CommonSFSetup.js';\nimport type { InternalSFClientAPI } from './InternalSFClientAPI.js';\nimport type { MEASUREMENT_METHODS } from './MEASUREMENT_METHODS.js';\nimport { BEGIN_TO_RENDER_CLIENT, COUNT_ON_DOWNLOAD_CLIENT } from './MEASUREMENT_METHODS.js';\nimport { markScriptAsFired } from './render.util.js';\nimport { validateCreativeRendering } from './validateCreativeRendering.js';\n\nexport const creativeReplayId = 'creativeReplayStatus';\nexport const creativeReplayCompleteEventName = 'creativeReplayComplete';\nconst fireEvent = `document.dispatchEvent(new CustomEvent(\"${creativeReplayCompleteEventName}\"));`;\n\nexport const getFinishProcessingEvent = (): string => `<script id=\"${creativeReplayId}\">${fireEvent}</script>`;\n\nexport const replayScriptTag = (adScript: HTMLScriptElement): void => {\n    const range = document.createRange();\n    range.selectNode(adScript);\n    const adScriptCopyDoc = range.createContextualFragment(adScript.outerHTML);\n    const adScriptCopy = adScriptCopyDoc.firstElementChild as HTMLScriptElement;\n    if (adScriptCopy.getAttribute('src')) {\n        // https://html.spec.whatwg.org/multipage/scripting.html#attr-script-async\n        // Need to explicity force async to false to skip https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model\n        // https://hsivonen.fi/script-execution/\n        adScriptCopy.async = false;\n    } else {\n        const scriptText = adScript.innerHTML;\n        adScriptCopy.async = false;\n        adScriptCopy.setAttribute('src', `data:text/javascript;charset=UTF-8,${encodeURIComponent(scriptText)}`);\n    }\n    adScript.parentNode?.insertBefore(adScriptCopy, adScript.nextSibling);\n    adScript.parentNode?.removeChild(adScript);\n};\n\n/**\n * Replaces the contents of the document with the passed HTML string\n * @param htmlContent string of HTML to add\n */\nexport const writeHtmlToDocumentRoot = (htmlContent: string): void => {\n    // setting innerHtml drops the host element's attributes, ie <html lang=\"en\">\n    // setting the outerHtml solves this, but setting outerHtml on document.documentElement is forbidden by the spec\n    // supporting a target of document.documentElement is a must\n\n    // Funciton fails with strict equality\n    // eslint-disable-next-line eqeqeq\n    if (document.documentElement == undefined) {\n        const html = document.createElement('html');\n        document.appendChild(html);\n    }\n    document.documentElement.innerHTML = htmlContent;\n\n    // options for getting attributes from the html string include DOMParser or regex, but performance is a concern\n    // https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes#enumerating_elements_attributes\n};\n\n/**\n * Executes all of the descendant inline scripts of the passed element in the order in which they appear\n * via depth first, pre-order DOM tree traversal\n */\nexport const replayAllDescendantScriptsSerially = (containerElement: HTMLElement): void => {\n    // https://html.spec.whatwg.org/multipage/scripting.html#list-of-scripts-that-will-execute-in-order-as-soon-as-possible\n    // We cannot use createFragment because it is required to import in the body so we lose the HEAD/BODY/etc. tags\n    // So we use InnerHTML which will not execute the scripts but then dynamically recreate the script tags\n    // so that they will be executed (as they are not with innerHTML imported tags)\n    const adScripts = containerElement.querySelectorAll('script');\n    for (const adScript of adScripts) {\n        replayScriptTag(adScript);\n    }\n};\n\nexport const preCreativeWrite = (\n    cms: ClientMessageSender,\n    cr: ClientReporter,\n    o: AdDetails,\n    eventsChannel: EventsChannel,\n): void => {\n    eventsChannel.onPreCreativeWrite(o);\n\n    if (isViewRateExperimentEnabled(Number(o.adCreativeMetaData.adProgramId))) {\n        // Do nothing: delay firing of the COD Impression Pixel for Stores view rate experiment\n        return;\n    }\n\n    const fireImpressionInHost =\n        // Hard code skyscraper-2 slots to fire impression in the host (avoiding firing when display:none)\n        // Remove this when ADPT_SF_PIXEL_FIRING_1151992 is launched\n        // Cleanup SIM: https://taskei.amazon.dev/tasks/CPP-46601\n        o.slotName === 'auto-left-advertising-2' ||\n        o.slotName.endsWith('-ad-left-2') ||\n        // weblab control to fire in host\n        ADPT_SF_PIXEL_FIRING_1151992().is('t1');\n\n    if (fireImpressionInHost) {\n        cms.sendMessage<CommonSupportedCommands['sendEventAddedCreative']>('sendEventAddedCreative');\n    } else if (o.firePixelsAfter) {\n        cms.sendMessage<CommonSupportedCommands['fireImpressionWithDelay']>('fireImpressionWithDelay');\n    } else {\n        cr.fireCodImpressionPixel();\n    }\n};\n\nexport const postCreativeWrite = async (\n    o: AdDetails,\n    cms: ClientMessageSender,\n    cr: ClientReporter,\n    c: InternalSFClientAPI,\n    eventsChannel: EventsChannel,\n) => {\n    // Since the initial loading event was fired when loading the messageport we need to simulate them\n    // for the creative\n    // TODO(https://sim.amazon.com/issues/CPP-38246) Wait for creative image resource loads in corner case\n    fireDOMContentLoadedEventForCreative();\n    // TODO(https://sim.amazon.com/issues/CPP-38245) Check if this can be moved earlier\n    fireLoadEventForCreativeSinceItWasAlreadyFiredUpon();\n\n    // isNoInventory is always false at this point\n    const measurementMethod: MEASUREMENT_METHODS = o.btrPixelUrl ? await tryWaitForBTR() : COUNT_ON_DOWNLOAD_CLIENT;\n    eventsChannel.onCreativeBeginToRender(o);\n\n    const isBtr = measurementMethod === BEGIN_TO_RENDER_CLIENT;\n    if (isBtr) {\n        cms.sendMessage<CommonSupportedCommands['sendEventCreativeBeginToRender']>('sendEventCreativeBeginToRender');\n    }\n\n    cms.sendMessage<CommonSupportedCommands['sendEventCreativeLoaded']>('sendEventCreativeLoaded', {\n        isBtr: isBtr,\n    });\n    validateCreativeRendering(o, c);\n\n    if (isMobile(o)) {\n        checkAndResizeImageOnlyCreative(cms);\n    }\n};\n\nconst fireLoadEventForCreativeSinceItWasAlreadyFiredUpon = () => {\n    markScriptAsFired('creativeLoad');\n    generateSyntheticLoadEvent();\n};\nconst fireDOMContentLoadedEventForCreative = () => {\n    markScriptAsFired('creativedomcontentloaded');\n    document.dispatchEvent(new Event('DOMContentLoaded'));\n};\n\nconst isMobile = (adDetails: AdDetails): boolean => ['mweb', 'mshop'].includes(adDetails.deviceType?.toLowerCase());\n","import {\n    creativeReplayCompleteEventName,\n    getFinishProcessingEvent,\n    replayAllDescendantScriptsSerially,\n    replayScriptTag,\n    writeHtmlToDocumentRoot,\n} from '@/client/render.js';\n\nexport const writeCreativeToDOM = async (htmlContent: string): Promise<void> => {\n    const eventFired = waitForCreativeReplayComplete();\n    documentWriteImpl(htmlContent, getFinishProcessingEvent());\n    await eventFired;\n};\n\nconst waitForCreativeReplayComplete = (): Promise<void> =>\n    new Promise((resolve) => {\n        document.addEventListener(creativeReplayCompleteEventName, () => resolve(), { once: true });\n    });\n\n/**\n * Called by\n * 1. The SF render script to add the creative to the DOM\n * 2. The creative for further mutations to the DOM\n */\nexport const documentWriteImpl = (...text: string[]): void => {\n    const htmlContent = text\n        .filter((x) => !!x)\n        .map(String)\n        .join('');\n\n    // The below conditional checks if an inline script is running AND that document has not\n    // finished painting. In this case, document.write should append to the document immediately\n    // below that script, as described here: https://www.oreilly.com/library/view/javascript-the-definitive/0596000480/re204.html\n    // In all other cases we will replace the contents of the document with the string passed to document.write.\n    if (document.currentScript !== null) {\n        let currentElement: Element | null = document.currentScript;\n        currentElement.insertAdjacentHTML('afterend', htmlContent);\n\n        // Scripts do not execute when added via html string. Need to replay each script after the\n        // insertion point (via next sibling). If we used replayAll on the body, it would infinitely\n        // loop by replaying the script which called renderHTML in the first place.\n        currentElement = currentElement.nextElementSibling;\n        while (currentElement !== null) {\n            if (currentElement.tagName === 'SCRIPT') {\n                replayScriptTag(currentElement as HTMLScriptElement);\n            } else {\n                replayAllDescendantScriptsSerially(currentElement as HTMLElement);\n            }\n            currentElement = currentElement.nextElementSibling;\n        }\n    } else {\n        writeHtmlToDocumentRoot(htmlContent);\n        replayAllDescendantScriptsSerially(document.documentElement);\n    }\n};\n","const PLACEHOLDER_DEFAULT = '&pd_rd_plhdr=t';\n\n/**\n *  HTML entity examples:\n *      Symbols\n *          shortest: &lt;\n *          longest: &Omicron;\n *\n *      Numbers\n *          (0-31 are control characters)\n *          shortest: &#32;\n *          longest: &#8721;\n *\n *  Regular Expressions\n *      Entity Numbers: (&#(0-){2};)|(&#(a-z){3};)|(&#(a-z){4};)\n *      Entity Symbols: (&(a-z){2};)|(&(a-z){3};)|(&(a-z){4};)|(&(a-z){5};)|(&(a-z){6};)|(&(a-z){7};)\n */\nconst REGEX_MATCH = new RegExp(\n    /((&#\\d{2,4};)|(&[a-z]{2};)|(&[a-z]{3,7};)|(%[a-fA-F0-9]{2})|(\\W))pd_rd_plhdr(=|%3D)t((&#\\d{2,4};)|(&[a-z]{2,7};)|(%[a-fA-F0-9]{2})|(\\W))/,\n);\n\n/**\n * Indices must be updated if RegEx groups are modified.\n * Each left and right group has 10 subgroups.\n * String.prototype.match() call will return the results of 22 groups.\n * Main result of the left matching group will be at index 1, while\n * the primary result of the right group is stored at index 12.\n */\nconst LEFT_GROUP_INDEX = 1;\nconst MIDDLE_GROUP_INDEX = 7;\nconst RIGHT_GROUP_INDEX = 8;\nconst LEFT_GROUP_VALUE = '$' + LEFT_GROUP_INDEX;\nconst RIGHT_GROUP_VALUE = '$' + RIGHT_GROUP_INDEX;\n\n/**\n * Replaces placeholders in HTML content with a specified click tracker value.\n *\n * This function substitutes the placeholder `PLACEHOLDER_DEFAULT` (`&pd_rd_plhdr=t`) in the provided\n * HTML content with the given click tracker value. It handles cases where the placeholder is surrounded\n * by HTML entities or URL encoding, ensuring that the replacement respects the format of the surrounding content.\n *\n * @param {string} clickTracker - The replacement value for the placeholder.\n *   - If the value matches the default placeholder or is empty/whitespace, no replacement is performed.\n *   - HTML entities in the value are escaped (e.g., `&` becomes `&amp;`) when appropriate.\n * @param {string} htmlContent - The HTML content where the placeholder should be replaced.\n * @returns {string} The updated HTML content with placeholders replaced.\n */\nexport const replaceForHtml = (clickTracker: string, htmlContent: string): string => {\n    let content = htmlContent,\n        replacement = clickTracker;\n\n    if (clickTracker === PLACEHOLDER_DEFAULT || clickTracker.trim() === '') {\n        return content;\n    }\n\n    replacement = replacement.replace(/&amp;/g, '&');\n    if (replacement.startsWith('&')) {\n        replacement = replacement.replace(/^&+/, '');\n    }\n    if (replacement.endsWith('&')) {\n        replacement = replacement.replace(/&+$/, '');\n    }\n\n    try {\n        let match;\n        let executions = 0;\n        do {\n            executions++;\n            match = content.match(REGEX_MATCH);\n\n            if (!match) {\n                break;\n            }\n\n            const left = match[LEFT_GROUP_INDEX]; // Match of main left group - not subgroups\n            const right = match[RIGHT_GROUP_INDEX]; // Match of main right group - not subgroups\n            const middle = match[MIDDLE_GROUP_INDEX]; // Match middle group (equals sign)\n\n            const hasHtmlEntity =\n                (left.startsWith('&') && left.endsWith(';')) || (right.startsWith('&') && right.endsWith(';'));\n            const hasUrlEncoding = left.startsWith('%') && right.startsWith('%') && middle === '%3D';\n\n            if (hasHtmlEntity) {\n                content = content.replace(\n                    REGEX_MATCH,\n                    LEFT_GROUP_VALUE + replacement.replace(/&/g, '&amp;') + RIGHT_GROUP_VALUE,\n                );\n            } else if (hasUrlEncoding) {\n                content = content.replace(\n                    REGEX_MATCH,\n                    LEFT_GROUP_VALUE + encodeURIComponent(replacement) + RIGHT_GROUP_VALUE,\n                );\n            } else {\n                content = content.replace(REGEX_MATCH, LEFT_GROUP_VALUE + replacement + RIGHT_GROUP_VALUE);\n            }\n        } while (match && executions < 10);\n        // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    } catch (ex) {\n        return htmlContent;\n    }\n\n    return content;\n};\n\n/**\n * Replaces placeholders in a URL with a specified click tracker value.\n *\n * This function searches for occurrences of the placeholder `pd_rd_plhdr=t` in the given URL\n * and replaces them with the specified click tracker value. It also trims leading or trailing\n * ampersands (`&` or `&amp;`) from the replacement value to avoid introducing malformed URLs.\n *\n * @param {string} clickTracker - The replacement value for the placeholder.\n *   - If the value matches the default placeholder or is empty/whitespace, no replacement is performed.\n * @param {string} url - The URL where the placeholder should be replaced.\n * @returns {string} The updated URL with placeholders replaced.\n */\nexport const replaceForUrl = (clickTracker: string, url: string): string => {\n    if (clickTracker === PLACEHOLDER_DEFAULT || clickTracker.trim() === '') {\n        return url;\n    }\n\n    const URL_PLACEHOLDER_REGEX = /pd_rd_plhdr=t/g;\n    const trimAmpersands = (clickTracker: string): string => {\n        return clickTracker.trim().replace(/^(&amp;|&)+|(&amp;|&)+$/g, '');\n    };\n\n    return url.replace(URL_PLACEHOLDER_REGEX, trimAmpersands(clickTracker));\n};\n","import { logDebug } from '@amzn/apejs-instrumentation/src/metrics/logging.js';\n\nimport type { HostMessageToClient } from '../components/messaging/types.js';\n\nexport const DEFAULT_PERCOLATE_TIMEOUT = 500;\n\n/**\n *\n * @deprecated Migrate the logic to the GPAT side so we don't need to ask the wrapper.ts\n */\nexport const waitForPercolateClickTrackingFromHost = async (\n    mp: MessagePort,\n    timeout = DEFAULT_PERCOLATE_TIMEOUT,\n): Promise<string> => {\n    // Can't use race here because we need to remove the event listener\n    return new Promise<string>((resolve) => {\n        let timeoutId = -1;\n        const listener = (e: MessageEvent) => {\n            const command = e.data as HostMessageToClient;\n            const expectedCommand = 'percolateClickTracking';\n            if (command.command !== expectedCommand)\n                throw new Error(`Unexpected command ${command}, Expected ${expectedCommand}`);\n            window.clearTimeout(timeoutId); // We don't want to fire the trigger now\n            resolve(command.data);\n        };\n        // TODO Remove this after we have made sure it works\n        timeoutId = window.setTimeout(() => {\n            mp.removeEventListener('message', listener); // Don't want to process the next message as it won't be what we expect!\n            resolve('');\n            logDebug(`Did not receive percolateClickTracking within ${timeout}ms`);\n        }, timeout);\n        mp.addEventListener('message', listener, { once: true });\n        mp.start();\n    });\n};\n","// Utility Functions used by both Client and Server\nimport {} from '@amzn/amazon-ui-page-ts';\n\nexport const safeFunctionWrapper = (\n    handler: (...safeArgs: any[]) => void,\n    errorHandler?: (msg: string, ex?: any) => void,\n    errorMessage?: string,\n): any => {\n    return (...args: any[]) => {\n        try {\n            handler(...args);\n        } catch (ex) {\n            errorHandler?.(errorMessage ? errorMessage : 'Error in handler', ex);\n        }\n    };\n};\n\n/**\n * Check if the given mediaType is video\n * @param {String} mediaType - mediaType value from AAX\n * @returns {Boolean} isVideo - True if mediaType is V\n */\nexport const isVideo = (mediaType: string): boolean => mediaType === 'V';\n\n// Below code is for utf_8 compliant versions of atob/btoa\n//M DN https://developer.mozilla.org/en-US/docs/Glossary/Base64#solution_2_%E2%80%93_rewriting_atob_and_btoa_using_typedarrays_and_utf-8\n\nexport const utf_8_atob = (base64: string): string => b64_to_utf8(base64);\nexport const utf_8_btoa = (js_text: string): string => utf8_to_b64(js_text);\n\nconst base64TestRegexp = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/;\n/**\n * @deprecated Remove once GPAT changes that only send text have been rolled out\n */\nconst isBase64 = (stringToTest: string) => base64TestRegexp.test(stringToTest);\n/**\n * @deprecated Remove once GPAT changes that only send text have been rolled out\n */\nexport const convertToStringIfBase64 = (stringToTest: string) =>\n    isBase64(stringToTest) ? utf_8_atob(stringToTest) : stringToTest;\n\nexport const convertToBase64IfString = (stringToTest: string) =>\n    isBase64(stringToTest) ? stringToTest : utf8_to_b64(stringToTest);\n\n// We use unescape even though not recommended due to performance and code size\nconst utf8_to_b64 = (utf8: string): string => {\n    return btoa(unescape(encodeURIComponent(utf8)));\n};\n\nconst b64_to_utf8 = (base64: string): string => {\n    return decodeURIComponent(escape(atob(base64)));\n};\n\nexport const isEmptyObject = (obj?: object) => {\n    return obj && Object.keys(obj).length === 0 && obj.constructor === Object;\n};\n\n// Remove when https://issues.amazon.com/issues/V1533734779 is resolved.\nexport const removeAAXPayloadFromUrl = (url: string): string => {\n    if (!url) {\n        return url;\n    }\n    // eslint-disable-next-line no-template-curly-in-string\n    return url.split('&c=${AAX_PAYLOAD}').join('');\n};\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport { utf_8_atob } from '../../components/util.js';\n\nexport const getCreative = (adDetails: AdDetails): string => {\n    if (!adDetails.htmlContentEncoded || adDetails.htmlContentEncoded.trim().length === 0)\n        throw new Error('No html content found on a server side fetch');\n    const htmlContent = adDetails.htmlContentEncodedLength\n        ? adDetails.htmlContentEncoded\n        : utf_8_atob(adDetails.htmlContentEncoded);\n    logIfError(htmlContent, adDetails.htmlContentEncodedLength);\n    return htmlContent;\n};\n\nconst logIfError = (htmlContent: string, htmlContentEncodedLength: number | undefined): void => {\n    if (htmlContentEncodedLength && htmlContent.length !== htmlContentEncodedLength) {\n        console.debug(\n            `Mismatched expected htmlContentEncoded size. Expected ${htmlContentEncodedLength} but got ${htmlContent.length}`,\n        );\n    }\n};\n","import { evaluateCreativeBeginToRender } from '@amzn/creative-rendering-monitor/src/creativeBTREvaluatorSync.js';\nimport type { AdDetails } from '@amzn/safeframe-model';\n\nimport { writeCreativeToDOM } from '@/client/service/documentWrite.js';\nimport type { EventsChannel } from '@/components/messageChannel/eventsChannel.js';\nimport { CLICK_TRACKING_PAINTER_TEST } from '@/components/weblabs.js';\n\nimport { replaceForHtml } from '../components/clickTracking/replace.js';\nimport { IFRAME_INIT } from '../components/counters/AD_LOAD_CSM_COUNTERS.js';\nimport * as AD_LOAD_EVENTS from '../components/events/AD_LOAD_CSA_EVENTS.js';\nimport { BODY_END } from '../components/metrics/latency-metric-type.js';\nimport type { ClientMessageReceiver } from './clientMessageReceiver.js';\nimport type { ClientMessageSender } from './clientMessageSender.js';\nimport type { CommonApiImplementation } from './CommonApiImplementation.js';\nimport { sendCriticalFeatureAndLoaded } from './commonSf.js';\nimport { waitForPercolateClickTrackingFromHost } from './percolateClickTracker.js';\nimport { postCreativeWrite, preCreativeWrite } from './render.js';\nimport { getCreative } from './service/get-creative.js';\n\nexport interface SafeFrameClient {\n    initSFClient: () => void;\n}\n\nexport class SafeframeClientImpl implements SafeFrameClient {\n    private clickTrackingParam = ''; // Containers the clickTrackingParam passed from the host\n    constructor(\n        private readonly o: AdDetails,\n        private readonly mp: MessagePort,\n        private readonly cms: ClientMessageSender,\n        private readonly cmr: ClientMessageReceiver,\n        private readonly c: CommonApiImplementation,\n        private readonly eventsChannel: EventsChannel,\n    ) {}\n\n    initSFClient = async () => {\n        // Send clientBodyEnd after setting up the safeframe APIs\n        this.c.sendLatencyMetric(BODY_END);\n        this.eventsChannel.onSafeFrameReady(this.o);\n        // Wait for the Percolate Click Tracking To Come Back\n        if (!CLICK_TRACKING_PAINTER_TEST().is('t1')) {\n            this.clickTrackingParam = await waitForPercolateClickTrackingFromHost(this.mp);\n        }\n        // We don't want to start processing messages in the host message receiver until we have gotten the\n        // percolate click tracking param\n        this.mp.onmessage = this.cmr.receiveMessage;\n\n        this.c.countMetric(IFRAME_INIT, 1);\n        this.c.logCsaEvent(AD_LOAD_EVENTS.IFRAME_INIT);\n\n        await this.writeCreativeToDocument();\n    };\n\n    /**\n     * This should only be called once per iframe. Inserts the creative html into the iframe document's DOM.\n     * Currently, we assume all video ad creatives which use the safeframe have a built-in video player.\n     * VAST ads should be rendered through LightAds.\n     * We expect the synthetic load event to be fired during this code path\n     */\n    private readonly writeCreativeToDocument = async (): Promise<void> => {\n        addSyntheticOnLoadListeners(this.c, this.o);\n\n        try {\n            const htmlContent = replaceForHtml(this.clickTrackingParam, getCreative(this.o));\n            preCreativeWrite(this.cms, this.c.cr, this.o, this.eventsChannel);\n\n            await writeCreativeToDOM(htmlContent);\n\n            this.eventsChannel.onPostCreativeWrite(this.o);\n            await postCreativeWrite(this.o, this.cms, this.c.cr, this.c, this.eventsChannel);\n            this.eventsChannel.onCreativeLoad(this.o);\n            if (CLICK_TRACKING_PAINTER_TEST().is('t1')) {\n                document.body.addEventListener('click', () => this.eventsChannel.onClick(this.o), { once: true });\n            }\n        } catch (err) {\n            this.eventsChannel.onError(this.o, {\n                code: 'CLIENT_SETUP',\n                isBTR: evaluateCreativeBeginToRender(document.body).success,\n                error: err instanceof Error ? err : new Error(String(err)),\n            });\n        }\n    };\n}\n\n// We generate our own synthetic load event for the creative to hook (since the initial sf script and html already fired it)\n// we expect a matching call to generateSyntheticLoadEvent to be generated\nconst addSyntheticOnLoadListeners = (commonApiImplementation: CommonApiImplementation, adDetails: AdDetails) => {\n    if (adDetails.creativeSupportsTTIMeasurement) return;\n    window.addEventListener('load', () => sendCriticalFeatureAndLoaded(commonApiImplementation), { once: true });\n};\nexport const generateSyntheticLoadEvent = () => {\n    window.dispatchEvent(new Event('load'));\n};\n","import type {\n    LaunchIntentURLParameters,\n    MashAPI,\n    MashError,\n    OpenInApp3pBrowserParameters,\n    OpenInExternalBrowserParameters,\n    SFOpenInApp3pBrowser,\n    SFOpenInExternalBrowser,\n    SFShowEmbeddedBrowser,\n    ShowEmbeddedBrowserParameters,\n} from '@amzn/safe-frame-client-mobilesfclient';\n\nimport type { ClientMessageSender, ToHostCommandType } from './clientMessageSender.js';\n\nexport interface MessageCallback<ExecuteType, CallbackType> {\n    execute: (data: ExecuteType) => void;\n    update: (data: CallbackType) => void;\n}\n\ninterface MashCallbackFunction {\n    successCallback?: () => void;\n    failCallback?: (error: MashError) => void;\n}\ninterface MashCallbackData {\n    value?: object | string | number;\n    errorMsg?: string;\n}\n\nclass MessageCallbackImpl<ExecuteType extends MashCallbackFunction, CallbackType extends MashCallbackData>\n    implements MessageCallback<ExecuteType, CallbackType>\n{\n    private _successCallback?: () => void;\n    private _failCallback?: (error: MashError) => void;\n    constructor(\n        protected readonly messageName: ToHostCommandType,\n        protected readonly cms: ClientMessageSender,\n    ) {}\n\n    execute = (data: ExecuteType) => {\n        this._successCallback = data.successCallback;\n        this._failCallback = data.failCallback;\n        this.cms.sendMessage(this.messageName, data);\n    };\n\n    update = (data: CallbackType) => {\n        if (typeof data.value === 'undefined') {\n            if (this._successCallback) {\n                this._successCallback();\n            }\n        } else {\n            if (this._failCallback) {\n                // TODO Fix this type override\n                this._failCallback(data.value || (data.errorMsg as any));\n            }\n        }\n    };\n}\nexport class OpenInExternalBrowser\n    extends MessageCallbackImpl<OpenInExternalBrowserParameters, { value?: string }>\n    implements SFOpenInExternalBrowser\n{\n    constructor(cms: ClientMessageSender) {\n        super('openInExternalBrowser', cms);\n    }\n}\n\nexport class ShowEmbeddedBrowser\n    extends MessageCallbackImpl<ShowEmbeddedBrowserParameters, { value?: string }>\n    implements SFShowEmbeddedBrowser\n{\n    constructor(cms: ClientMessageSender) {\n        super('showEmbeddedBrowser', cms);\n    }\n}\n\nexport class LaunchIntentURL\n    extends MessageCallbackImpl<LaunchIntentURLParameters, { value?: string }>\n    implements LaunchIntentURL\n{\n    constructor(cms: ClientMessageSender) {\n        super('launchIntentURL', cms);\n    }\n}\n\nexport class OpenInApp3pBrowser\n    extends MessageCallbackImpl<OpenInApp3pBrowserParameters, { value?: string }>\n    implements SFOpenInApp3pBrowser\n{\n    constructor(cms: ClientMessageSender) {\n        super('openInApp3pBrowser', cms);\n    }\n}\n\nexport class MashAPIImpl implements MashAPI {\n    readonly openInExternalBrowser: OpenInExternalBrowser;\n    readonly showEmbeddedBrowser: ShowEmbeddedBrowser;\n    readonly launchIntentURL: LaunchIntentURL;\n    readonly openInApp3pBrowser: OpenInApp3pBrowser;\n\n    constructor(cms: ClientMessageSender) {\n        this.openInExternalBrowser = new OpenInExternalBrowser(cms);\n        this.showEmbeddedBrowser = new ShowEmbeddedBrowser(cms);\n        this.launchIntentURL = new LaunchIntentURL(cms);\n        this.openInApp3pBrowser = new OpenInApp3pBrowser(cms);\n    }\n\n    /**\n     * TODO Remove this\n     * @deprecated This is always true and also irrelevant since the client has no direct access to the AUI anyways\n     */\n    isAUIAvailable = (): boolean => {\n        return true;\n    };\n}\n","import type { UserConnectionInfo } from '@amzn/safe-frame-client-mobilesfclient';\n\nconst CONNECTION_TYPE_UNKNOWN = 'unknown';\nconst MOBILE_CONNECTION_TYPE_UNKNOWN = 0;\n\nconst getConnectionInfo = () => {\n    const navigatorObject: Navigator = window.navigator;\n    const connection = navigatorObject?.connection;\n    return connection?.type || connection?.effectiveType || CONNECTION_TYPE_UNKNOWN;\n};\n\nexport const getUserNetworkConnectionInfo = (amznAppContextCookie?: string): UserConnectionInfo => {\n    const mobileConnectionType = amznAppContextCookie\n        ? getAmznAppContextFromCookie(amznAppContextCookie)?.di?.ct\n        : MOBILE_CONNECTION_TYPE_UNKNOWN;\n    console.error(mobileConnectionType);\n    // User context is the data received from MASH application context\n    return {\n        connectionType: getConnectionInfo(),\n        mobileConnectionType: mobileConnectionType || MOBILE_CONNECTION_TYPE_UNKNOWN,\n    };\n};\n\n// https://w.amazon.com/bin/view/MASH/Application_Context_Protocol/1.5\ntype AmznAppContext = {\n    di: {\n        ct: number;\n    };\n};\n\n/**\n * From https://w.amazon.com/bin/view/MASH/Application_Context_Protocol\n */\nconst getAmznAppContextFromCookie = (mashCookieValue: string): AmznAppContext => {\n    const MASH_COOKIE_REGEX = /^([.\\d]*\\s*)({.*})$/;\n    const cookieSplitArray = MASH_COOKIE_REGEX.exec(mashCookieValue) as RegExpExecArray;\n    return JSON.parse(cookieSplitArray[2]);\n};\n","import type { MobileAdsInfo, MobileSFClientAPI } from '@amzn/safe-frame-client-mobilesfclient';\nimport type { AdDetails } from '@amzn/safeframe-model';\n\nimport { DISABLE_USER_AGENT_WEBLAB } from '@/components/weblabs.js';\n\nimport type { MobileSupportedCommands } from '../host/api-client/MobileSupportedCommands.js';\nimport type { ClientMessageSender } from './clientMessageSender.js';\nimport { MashAPIImpl } from './Mash.js';\nimport { getUserNetworkConnectionInfo } from './service/Mash.js';\n\nexport class MobileSFClientAPIImplementation implements MobileSFClientAPI {\n    readonly mash: MashAPIImpl;\n\n    constructor(\n        private readonly cms: ClientMessageSender,\n        private readonly o: AdDetails,\n    ) {\n        this.mash = new MashAPIImpl(this.cms);\n    }\n\n    onPageEvent = {\n        callback: () => {\n            /**/\n        },\n        execute: (eventName: string, callback: () => void) => {\n            this.onPageEvent.callback = callback;\n            this.cms.sendMessage<MobileSupportedCommands['onPageEvent']>('onPageEvent', { eventName: eventName });\n        },\n        update: () => {\n            if (typeof this.onPageEvent.callback === 'function') {\n                this.onPageEvent.callback();\n            }\n        },\n    };\n\n    /**\n     * @func renderClickThroughAppAds\n     * @desc Renders click-through app ads for SKAdNetwork attribution on iOS.\n     *  * This handles the SKAN click-through attribution when a user clicks on an app ad.\n     *  * It uses the MASH API to communicate with the native iOS layer for proper SKAdNetwork attribution.\n     *\n     * @see https://developer.apple.com/documentation/storekit/skadnetwork\n     * @param url {URL} The fallback url used to pass to MASH API\n     *\n     * @example\n     *  const url = new URL(\"https://apps.apple.com/us/app/tapier/id6476941533?aref=0LAPHaEBAS\");\n     *  renderClickThroughAppAds(url);\n     *\n     * Note, adDetails object is passed by default in sendMessage which includes SKAdNetwork object to call SKAN API.\n     */\n    renderClickThroughAppAds = (url: URL) => {\n        this.cms.sendMessage<MobileSupportedCommands['renderClickThroughAppAds']>('renderClickThroughAppAds', url.href);\n    };\n\n    /**\n     * @func sendAdInfo\n     * @desc [Internal & External] Sends information about creative ID / program ID to page, to send to AdFeedback team\n     * @param {*} mobileAdsInfo - Information passed in by the creatives\n     */\n    sendAdInfo = (mobileAdsInfo: MobileAdsInfo) => {\n        if (mobileAdsInfo) {\n            this.cms.sendMessage<MobileSupportedCommands['getAdInfo']>('getAdInfo', { mobileAdsInfo: mobileAdsInfo });\n        }\n    };\n    getPlacementInfo = () => {\n        const placementInfo = {\n            pageType: this.o.pageType,\n            slotName: this.o.slotName,\n            subPageType: this.o.subPageType,\n        };\n        return placementInfo;\n    };\n    // TODO Move this to public API\n    getUserAgentInfo = (): string => {\n        if (DISABLE_USER_AGENT_WEBLAB().is('t1')) {\n            return '';\n        }\n\n        // TODO Eliminate the override here\n        return window.navigator.userAgent;\n    };\n    /**\n     * @deprecated Do not use this anymore.  Use direct APIs\n\n     * @desc Returns the amzn-app-ctxt cookie if it exists\n     * @returns {String} cookie - amzn-app-ctxt\n     */\n    getDocumentCookie = () => {\n        const amaznAppContextCookieValue = this.o.amznAppContext ? `amzn-app-ctxt=${this.o.amznAppContext}` : undefined;\n        return amaznAppContextCookieValue ?? '';\n    };\n\n    /**\n     * TODO: deprecate this and replace it with shouldHaveAutoplayPermissionFromDevice\n     * https://sim.amazon.com/issues/CPP-30396\n     */\n    getUserConnectionInfo = () => {\n        return getUserNetworkConnectionInfo(this.o.amznAppContext);\n    };\n}\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport { CommonApiImplementation } from '@/client/CommonApiImplementation.js';\nimport type { EventsChannel } from '@/components/messageChannel/eventsChannel.js';\n\nimport { ClientMessageReceiver } from '../clientMessageReceiver.js';\nimport { ClientMessageSender } from '../clientMessageSender.js';\nimport { SafeframeClientImpl } from '../CommonSFSetup.js';\nimport { DesktopSFClientAPIImplementation } from '../DesktopSFClientAPIImplementation.js';\nimport { MobileSFClientAPIImplementation } from '../MobileSFClientAPIImplementation.js';\n\nexport const createMobileSafeframeClient = (\n    messagePort: MessagePort,\n    adDetails: AdDetails,\n    eventsChannel: EventsChannel,\n): SafeframeClientImpl => {\n    const cms = new ClientMessageSender(adDetails, messagePort);\n    const mL = {};\n    const commonApiImplementation = new CommonApiImplementation(cms, adDetails, mL);\n    const mobileSFClientAPIImplementation = new MobileSFClientAPIImplementation(cms, adDetails);\n\n    window.MSFClient = {\n        ...commonApiImplementation,\n        ...mobileSFClientAPIImplementation,\n    };\n\n    const cmr = new ClientMessageReceiver(window.MSFClient, adDetails, mL);\n\n    return new SafeframeClientImpl(adDetails, messagePort, cms, cmr, commonApiImplementation, eventsChannel);\n};\n\nexport const createDesktopSafeframeClient = (\n    messagePort: MessagePort,\n    adDetails: AdDetails,\n    eventsChannel: EventsChannel,\n): SafeframeClientImpl => {\n    const cms = new ClientMessageSender(adDetails, messagePort);\n    const mL = {};\n    const commonApiImplementation = new CommonApiImplementation(cms, adDetails, mL);\n    const desktopSFClientAPIImplementation = new DesktopSFClientAPIImplementation(adDetails);\n\n    window.SFClient = {\n        ...commonApiImplementation,\n        ...desktopSFClientAPIImplementation,\n    };\n\n    const cmr = new ClientMessageReceiver(window.SFClient, adDetails, mL);\n\n    return new SafeframeClientImpl(adDetails, messagePort, cms, cmr, commonApiImplementation, eventsChannel);\n};\n","import type { AdDetails } from '@amzn/safeframe-model';\n\n/**\n * Retrieves and parses {@link AdDetails} from the iframe's `window.name`.\n * @throws {Error} If `window.name` is empty or contains invalid JSON.\n */\nexport const getAdDetails = (): AdDetails => {\n    if (!window.name) {\n        throw new Error('Ad Details not found in name!');\n    }\n\n    try {\n        return JSON.parse(window.name);\n    } catch {\n        throw new Error(`Failed to parse Ad Details from name: ${window.name}`);\n    }\n};\n","export const readyMessage = 'sf iframe ready';\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport { readyMessage } from '@/components/messaging/bootstrap.js';\nimport { mark } from '@/components/perf.js';\n\n/**\n * Sends a {@link MessagePort} to the SafeFrame host page to establish a communication channel.\n * Uses `postMessage` instead of `onload` as the latter is unreliable for hidden iframes.\n * @see https://stackoverflow.com/questions/12410606/hidden-iframe-onload-event\n * @param mp - The {@link MessagePort} to transfer to the parent.\n * @param adDetails - The {@link AdDetails} used for performance marking.\n */\nexport const sendMessagePortToParent = (mp: MessagePort, adDetails: AdDetails): void => {\n    mark('sf:perf:client', `Start Send Ready ${mp}`, adDetails);\n    window.parent.postMessage(readyMessage, '*', [mp]);\n};\n","import { evaluateCreativeBeginToRender } from '@amzn/creative-rendering-monitor/src/creativeBTREvaluatorSync.js';\nimport type { AdDetails } from '@amzn/safeframe-model';\n\nimport type { EventsChannel } from '@/components/messageChannel/eventsChannel.js';\n\nconst isExtensionError = (source?: string): boolean =>\n    (source?.startsWith('chrome-extension://') || source?.startsWith('moz-extension://')) ?? false;\n\n/**\n * Creates a handler for window.onerror to catch any unexpected errors\n * coming from the creative code. We will log the error and attempt to\n * show a different ad or collapse the slot.\n */\nexport const createHandleErrors =\n    (eventsChannel: EventsChannel, adDetails: AdDetails): OnErrorEventHandler =>\n    (message: Event | string, source?: string, _line?: number, _col?: number, error?: Error): boolean => {\n        eventsChannel.onError(adDetails, {\n            code: isExtensionError(source) ? 'BROWSER_EXTENSION' : 'CLIENT_ERROR',\n            isBTR: evaluateCreativeBeginToRender(document.body).success,\n            error: error ?? new Error(typeof message === 'string' ? message : 'Unknown error'),\n        });\n\n        // Returning true suppresses the default browser behavior\n        return true;\n    };\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport { errorLog } from '@/client/commonSf.js';\nimport type { CsmChannelCommand, CsmPayload } from '@/components/messageChannel/csm/csmChannel.js';\nimport type { EventsChannel, EventsPayload, OnErrorPayload } from '@/components/messageChannel/eventsChannel.js';\nimport type { ClientMessageToHost } from '@/components/messenger.js';\n\ntype MessagePayload = CsmPayload | EventsPayload | OnErrorPayload;\nexport type MessageCommand = CsmChannelCommand | keyof EventsChannel;\n\nexport const sendMessage = (\n    messagePort: MessagePort,\n    adDetails: AdDetails,\n    command: MessageCommand,\n    payload: MessagePayload,\n): void => {\n    const msg: ClientMessageToHost = {\n        command,\n        adDetails,\n        payload,\n    };\n\n    try {\n        messagePort.postMessage(msg);\n    } catch (ex) {\n        errorLog('Post Message error', ex as Error);\n    }\n};\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport { sendMessage } from '@/components/messageChannel/common/sendMessage.js';\nimport type { EventsChannel, OnErrorPayload } from '@/components/messageChannel/eventsChannel.js';\n\nexport const createClientEventsChannel = (mp: MessagePort): EventsChannel => {\n    return {\n        onSafeFrameReady: (adDetails: AdDetails) => sendMessage(mp, adDetails, 'onSafeFrameReady', {}),\n        onPreCreativeWrite: (adDetails: AdDetails) => sendMessage(mp, adDetails, 'onPreCreativeWrite', {}),\n        onPostCreativeWrite: (adDetails: AdDetails) => sendMessage(mp, adDetails, 'onPostCreativeWrite', {}),\n        onCreativeBeginToRender: (adDetails: AdDetails) => sendMessage(mp, adDetails, 'onCreativeBeginToRender', {}),\n        onCreativeLoad: (adDetails: AdDetails) => sendMessage(mp, adDetails, 'onCreativeLoad', {}),\n        onError: (adDetails: AdDetails, payload: OnErrorPayload) => sendMessage(mp, adDetails, 'onError', payload),\n        onClick: (adDetails: AdDetails) => sendMessage(mp, adDetails, 'onClick', {}),\n    };\n};\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport { sendMessage } from '@/components/messageChannel/common/sendMessage.js';\nimport type { AdditionalInfo, CsmChannel } from '@/components/messageChannel/csm/csmChannel.js';\n\nexport const createClientCsmChannel = (mp: MessagePort, adDetails: AdDetails): CsmChannel => {\n    return {\n        ueLogError: (error: Error, additionalInfo: AdditionalInfo) =>\n            sendMessage(mp, adDetails, 'ueLogError', { error, additionalInfo }),\n        ue: {\n            count: (metric: string, count?: number) => sendMessage(mp, adDetails, 'ue.count', { metric, count }),\n        },\n    };\n};\n","/**\n * Disables creative access to set and get cookies.\n * @see https://issues.amazon.com/issues/APEX-4377\n */\nexport const disableCookieAccess = () => {\n    Object.defineProperty(Document.prototype, 'cookie', {\n        get: () => '',\n        set: () => {\n            // Empty\n        },\n    });\n};\n","/**\n * Disables geolocation API access for creatives.\n * @see https://issues.amazon.com/issues/CPP-24902\n */\nconst permissionDeniedError: GeolocationPositionError = {\n    code: 1, // PERMISSION_DENIED\n    message: 'Geolocation access disabled',\n    PERMISSION_DENIED: 1,\n    POSITION_UNAVAILABLE: 2,\n    TIMEOUT: 3,\n};\n\nexport const disableGeolocationApi = () => {\n    if (window?.navigator?.geolocation) {\n        window.navigator.geolocation.watchPosition = (\n            _successCallback: PositionCallback,\n            _errorCallback?: PositionErrorCallback | null,\n            _options?: PositionOptions,\n        ): number => {\n            _errorCallback?.(permissionDeniedError);\n            return 0;\n        };\n\n        window.navigator.geolocation.getCurrentPosition = (\n            _successCallback: PositionCallback,\n            _errorCallback?: PositionErrorCallback | null,\n            _options?: PositionOptions,\n        ) => {\n            _errorCallback?.(permissionDeniedError);\n        };\n    }\n};\n","/**\n * Disables user agent access for creatives.\n * @see https://shepherd.a2z.com/issues/e4e8cd86-419a-4e1a-96ff-b20a6615b8b5\n */\nexport const disableUserAgent = () => {\n    Object.defineProperty(Navigator.prototype, 'userAgent', {\n        get: () => '',\n        set: () => {\n            // Empty\n        },\n    });\n};\n","/**\n * Workaround for iOS bug: allows clicks to propagate in iframe.\n * @see https://tt.amazon.com/0156195085\n * TODO Verify this is still needed.\n */\nexport const workAroundIOBugtt0156195085 = () => {\n    document.addEventListener(\n        'touchstart',\n        {\n            handleEvent: () => {\n                //do nothing\n            },\n        },\n        false,\n    );\n};\n","import { DISABLE_USER_AGENT_WEBLAB } from '@/components/weblabs.js';\n\nimport { disableCookieAccess } from './disableCookieAccess.js';\nimport { disableGeolocationApi } from './disableGeolocationApi.js';\nimport { disableUserAgent } from './disableUserAgent.js';\nimport { workAroundIOBugtt0156195085 } from './workAroundIOBugtt0156195085.js';\n\nexport { disableCookieAccess, disableGeolocationApi, disableUserAgent, workAroundIOBugtt0156195085 };\n\nexport const disableAll = () => {\n    disableCookieAccess();\n    disableGeolocationApi();\n    workAroundIOBugtt0156195085();\n    if (DISABLE_USER_AGENT_WEBLAB().is('t1')) {\n        disableUserAgent();\n    }\n};\n","// Must be kept in sync with https://tiny.amazon.com/2xu3ne6j/SafeframeCSP\nexport const allowedReferrers: string[] = [\n    'amazon.com',\n    'amazon.in',\n    'amazon.de',\n    'amazon.co.jp',\n    'amazon.co.uk',\n    'amazon.ca',\n    'amazon.com.au',\n    'amazon.com.be',\n    'amazon.com.br',\n    'amazon.com.mx',\n    'amazon.com.tr',\n    'amazon.eg',\n    'amazon.es',\n    'amazon.fr',\n    'amazon.it',\n    'amazon.nl',\n    'amazon.pl',\n    'amazon.sa',\n    'amazon.se',\n    'amazon.sg',\n    'amazon.ae',\n    'amazon.co.za',\n    'amazon.cn',\n    'amazon.dev',\n    'boxofficemojo.com',\n    'a2z.com',\n    'console.harmony.a2z.com',\n    'depot.advertising.amazon.dev',\n    'harmony.a2z.com',\n    'd116tmsy8qpy37.cloudfront.net',\n    'd1u3onhraow3iz.cloudfront.net',\n    'd1ubtmbgqm1jlf.cloudfront.net',\n    'd2dk40qqpfbxei.cloudfront.net',\n    'd2jbcalcdp0p85.cloudfront.net',\n    'd2y0vsnh7zmbrq.cloudfront.net',\n    'd345aeerog89iv.cloudfront.net',\n    'imdb.com',\n];\n\nif (process.env.NODE_ENV !== 'production') {\n    // This is stripped from production builds. It is required for local browser testing since SF runs a check for\n    // document.referrer\n    allowedReferrers.push('localhost');\n}\n\nconst isMatched = (referrerHostName: string, allowedList: string[]): boolean => {\n    return allowedList.some((domain) => {\n        return referrerHostName === domain || referrerHostName.endsWith('.' + domain);\n    });\n};\n\nconst isReferrerAllowed = (): boolean => {\n    const referrer = document.referrer;\n\n    if (!referrer) {\n        return false; // No referrer means it's not allowed\n    }\n\n    try {\n        const url = new URL(referrer);\n        return isMatched(url.hostname, allowedReferrers);\n    } catch {\n        return false;\n    }\n};\n\n/**\n * Validates that the current document referrer is in the list of allowed referrers.\n * Skips the check when `window.origin` is `'null'` (e.g. sandboxed iframes).\n * @throws {Error} If the referrer is present but not in the allowed list.\n * @todo Clean up referrer check once https://sim.amazon.com/issues/CPP-41009 is solved.\n */\nexport const validateReferrerAllowed = (): void => {\n    if (window.origin !== 'null' && !isReferrerAllowed()) {\n        throw new Error(`Referrer not allowed: ${document.referrer}`);\n    }\n};\n","const DCM_EIDS = '4|40004007';\n\ntype Dcmads = { eids?: string };\n\ndeclare global {\n    interface Window {\n        dcmads: Dcmads | undefined;\n    }\n}\n\n/**\n * Sets a flag on `window.dcmads.eids` that dcmads.js reads to decide whether to append\n * creative content using document.write or HTMLElement.appendChild.\n * @see https://t.corp.amazon.com/HEDWIGTT-300\n */\nexport const setDcmAdsEids = () => {\n    window.dcmads = window.dcmads || {};\n    window.dcmads.eids = DCM_EIDS;\n};\n","import type { AdDetails } from '@amzn/safeframe-model';\n\nimport { logLowRateMetricSF } from '@/components/metrics/awsMetricLogger.js';\n\n/**\n * Sets up a {@link ReportingObserver} to detect and log heavy ad interventions.\n * Observes intervention reports and flushes pending reports on page hide.\n * No-op if {@link ReportingObserver} is unavailable.\n * @see https://developer.chrome.com/blog/heavy-ad-interventions\n */\nexport const setupReportingObserver = (adDetails: AdDetails) => {\n    if (typeof window.ReportingObserver === 'undefined') return;\n\n    const reportingObserver = new ReportingObserver((reports) => checkReports(reports, adDetails), { buffered: true });\n\n    reportingObserver.observe();\n\n    document.addEventListener('pagehide', () => checkReports(reportingObserver.takeRecords(), adDetails));\n};\n\nconst checkReports = (reports: Report[] = [], adDetails: AdDetails): void =>\n    reports\n        .filter((report) => report.type === 'intervention')\n        .forEach(() => {\n            logLowRateMetricSF({\n                metricName: 'reporting-observer:heavy-ad-intervention',\n                adDetails,\n                additionalDimensions: {\n                    creativeId: adDetails.adCreativeMetaData.adCreativeId,\n                },\n            });\n        });\n","import { logError } from '@amzn/apejs-instrumentation/src/metrics/logging.js';\nimport type { AdDetails } from '@amzn/safeframe-model';\n\nimport { create$sf } from '@/client/apiPage/sfApi.js';\nimport type { SafeFrameClient } from '@/client/CommonSFSetup.js';\nimport { getAdDetails } from '@/client/components/adDetails.js';\nimport { sendMessagePortToParent } from '@/client/components/notifyParent.js';\nimport { createHandleErrors } from '@/client/errorHandling/handleErrors.js';\nimport { createClientEventsChannel } from '@/client/messageChannel/clientEventsChannel.js';\nimport { documentWriteImpl } from '@/client/service/documentWrite.js';\nimport { createClientCsmChannel } from '@/components/messageChannel/csm/csmChannelClient.js';\nimport type { EventsChannel } from '@/components/messageChannel/eventsChannel.js';\nimport { mark } from '@/components/perf.js';\n\nimport { disableAll } from './disable/disableAll.js';\nimport { validateReferrerAllowed } from './security/referrers.js';\nimport { setDcmAdsEids } from './service/dcm.js';\nimport { setupReportingObserver } from './service/setupReportingObserver.js';\n\n/**\n * Bootstraps the SafeFrame client by creating a {@link MessageChannel} and sending a {@link MessagePort} to the SafeFrame host page.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API\n */\nexport const bootstrapSafeFrameClient = (safeFrameClientFactory: SafeFrameClientFactory): void => {\n    validateReferrerAllowed();\n    const adDetails = getAdDetails();\n    const { port1: clientPort, port2: hostPort } = new MessageChannel();\n    setupSafeFrameClient(safeFrameClientFactory, clientPort, adDetails);\n    sendMessagePortToParent(hostPort, adDetails);\n};\n\nconst setupSafeFrameClient = async (\n    safeFrameClientFactory: SafeFrameClientFactory,\n    messagePort: MessagePort,\n    adDetails: AdDetails,\n): Promise<void> => {\n    try {\n        setDcmAdsEids();\n        disableAll();\n        setupReportingObserver(adDetails);\n        // FIX ME: we should not have a stringified obj inside the stringified AdDetails. Fix this upstream\n        window.renderingWeblabs = JSON.parse(adDetails.weblabTreatments ?? '');\n        mark('sf:perf:client', 'SF received ad details', adDetails);\n\n        const eventsChannel = createClientEventsChannel(messagePort);\n\n        window.$sf = create$sf();\n        document.write = documentWriteImpl;\n        window.onerror = createHandleErrors(eventsChannel, adDetails);\n        Object.assign(window, createClientCsmChannel(messagePort, adDetails));\n\n        safeFrameClientFactory(messagePort, adDetails, eventsChannel).initSFClient();\n    } catch (ex) {\n        logError('Could not init SafeFrame Client', ex);\n    }\n};\n\nexport type SafeFrameClientFactory = (\n    messagePort: MessagePort,\n    adDetails: AdDetails,\n    eventsChannel: EventsChannel,\n) => SafeFrameClient;\n","import { mark } from '@/components/perf.js';\n\nimport { createMobileSafeframeClient } from '../application/safeframeClientFactory.js';\nimport { bootstrapSafeFrameClient } from '../initSafeframeClient.js';\nimport type {} from '../InternalClientWindow.js';\n\nmark('perf:sf:client', 'Enter msf.ts');\n\nif (!window.MSFClient) {\n    bootstrapSafeFrameClient(createMobileSafeframeClient);\n}\n"],"names":["getMarkName","scope","message","adDetails","mark","markString","_a","defaultGeom","createGeomCache","initial","cachedGeom","newGeom","inViewPercentageCache","defaultNumber","cachedNumber","value","geomCache","create$sf","HOST_SCOPE","create","csaKey","csmKey","csmMessage","BODY_END","CRITICAL_FEATURE","LOADED","LOADED_HOST_SCOPE","btr","element","evaluateCreativeBeginToRender","creativeContainer","images","x","evaluateAnyImageLoaded","img","PUBLISHER_JSON_KEY","IFRAME_INIT","IMP","IMPRESSION","GLOBAL_IMPRESSION_FIRED_COUNTER","logDebug","logError","err","emitToRTLA","toError","level","getCreativeTemplateNameForTagging","createPixel","id","pixelUrl","pixel","formFullCounterName","baseCounterName","eventName","extension","finalCounter","isPixelFired","firePixel","c","baseMetricName","counterExtension","logId","aaxProgramId","ex","EMPTY_OBJECT_STRINGIFIED","addJSONQueryParamToURL","url","queryParamKey","queryParamValueObject","urlObject","pk","existingJSONObject","mergedJSONObject","BEGIN_TO_RENDER_CLIENT","COUNT_ON_DOWNLOAD_CLIENT","ClientReporter","o","createPixelUrl","AD_LOAD_EVENTS.IMP","isBtrPixel","adProgramId","creativeTemplateNameForMetrics","impressionMetric","BTRIMPRESSION","CODIMPRESSION","aaxImpPixelUrl","measurementMethod","paets","legacyAnswer","tryWaitForBTR","elapsedTime","intervalMs","resolve","intervalId","errorLog","msg","sendCriticalFeatureAndLoaded","CommonApiImplementation","cms","mL","_data","width","height","metricName","msgKey","callback","latencyMetricType","num","isGlobal","continuousPlaybackSeconds","error","data","creativeWrapper","ClientMessageReceiver","key","event","cmdPath","action","i","body","resolveMessagePromise","command","pendingMessages","ClientMessageSender","messagePort","API_KEY","METRICS_ENDPOINT","STORAGE_KEY","BATCH_SIZE","unloadHookRegistered","logMetric","metric","flushAndClear","cache","getCache","flushCache","updateCache","e","metrics","toPostMetricDTO","createWeblab","weblabsWindow","prefix","weblabTreatment","_b","treatment","ADPT_SF_LOW_RATE_METRIC_LOGGING","ADPT_SF_PIXEL_FIRING_1151992","CLICK_TRACKING_PAINTER_TEST","VIEW_RATE_EXPERIMENT","DISABLE_USER_AGENT_WEBLAB","logMetricOnce","store","logLowRateMetricSF","count","additionalDimensions","once","toMetric","toSFDimensions","dimensions","isViewRateExperimentEnabled","VIEWPORT_COVERAGE_THRESHOLD","SIGNIFICANT_TEXT_THRESHOLD","AD_BACKGROUND_IMAGE_CLASS","isImageCoveringViewportWidth","imgWidth","hasSignificantText","hasAnyImageWithAdBackgroundClass","image","hasLargeImage","rect","isImageTemplateAd","checkAndResizeImageOnlyCreative","markScriptAsFired","attr","creativeReplayId","validateCreativeRendering","clientApi","creativeReplayCompleteEventName","fireEvent","getFinishProcessingEvent","replayScriptTag","adScript","range","adScriptCopy","scriptText","writeHtmlToDocumentRoot","htmlContent","html","replayAllDescendantScriptsSerially","containerElement","adScripts","preCreativeWrite","cr","eventsChannel","postCreativeWrite","fireDOMContentLoadedEventForCreative","fireLoadEventForCreativeSinceItWasAlreadyFiredUpon","isBtr","isMobile","generateSyntheticLoadEvent","writeCreativeToDOM","eventFired","waitForCreativeReplayComplete","documentWriteImpl","text","currentElement","PLACEHOLDER_DEFAULT","REGEX_MATCH","LEFT_GROUP_INDEX","MIDDLE_GROUP_INDEX","RIGHT_GROUP_INDEX","LEFT_GROUP_VALUE","RIGHT_GROUP_VALUE","replaceForHtml","clickTracker","content","replacement","match","executions","left","right","middle","hasHtmlEntity","hasUrlEncoding","DEFAULT_PERCOLATE_TIMEOUT","waitForPercolateClickTrackingFromHost","mp","timeout","timeoutId","listener","expectedCommand","utf_8_atob","base64","b64_to_utf8","getCreative","logIfError","htmlContentEncodedLength","SafeframeClientImpl","cmr","AD_LOAD_EVENTS.IFRAME_INIT","addSyntheticOnLoadListeners","commonApiImplementation","MessageCallbackImpl","messageName","OpenInExternalBrowser","ShowEmbeddedBrowser","LaunchIntentURL","OpenInApp3pBrowser","MashAPIImpl","CONNECTION_TYPE_UNKNOWN","MOBILE_CONNECTION_TYPE_UNKNOWN","getConnectionInfo","navigatorObject","connection","getUserNetworkConnectionInfo","amznAppContextCookie","mobileConnectionType","getAmznAppContextFromCookie","mashCookieValue","cookieSplitArray","MobileSFClientAPIImplementation","mobileAdsInfo","amaznAppContextCookieValue","createMobileSafeframeClient","mobileSFClientAPIImplementation","getAdDetails","readyMessage","sendMessagePortToParent","isExtensionError","source","createHandleErrors","_line","_col","sendMessage","payload","createClientEventsChannel","createClientCsmChannel","additionalInfo","disableCookieAccess","permissionDeniedError","disableGeolocationApi","_successCallback","_errorCallback","_options","disableUserAgent","workAroundIOBugtt0156195085","disableAll","allowedReferrers","isMatched","referrerHostName","allowedList","domain","isReferrerAllowed","referrer","validateReferrerAllowed","DCM_EIDS","setDcmAdsEids","setupReportingObserver","reportingObserver","reports","checkReports","report","bootstrapSafeFrameClient","safeFrameClientFactory","clientPort","hostPort","setupSafeFrameClient"],"mappings":"yBAEO,MAAMA,EAAc,CAACC,EAAeC,EAAiBC,IACxD,GAAG,OAAAF,GAAQ,OAAAE,EAAY,IAAI,OAAAA,EAAU,eAAkB,GAAE,OAAM,OAAAD,GAEtDE,EAAO,CAACH,EAAeC,EAAiBC,IAAkC,OACnF,MAAME,EAAaL,EAAYC,EAAOC,EAASC,CAAS,EAExD,OAAAG,EAAA,qCAAa,OAAb,MAAAA,EAAA,iBAAoBD,GAEbA,CACX,EC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