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,yBAmB9E,MAjBoB,CAEhB,QAAS,YAAY,QAAS,GAC9B,OAAQ,YAAY,OAAQ,GAC5B,WAAY,YAAY,WAAY,GACpC,mBAAoB,YAAY,mBAAoB,GACpD,eAAgB,YAAY,eAAgB,GAC5C,SAAU,YAAY,SAAU,GAChC,aAAc,YAAY,aAAc,GAExC,gBAAiB,EAAS,YAAY,gBAAiB,QAAY,EAEnE,IAAK,CACD,mBAAoB,YAAY,sBAAuB,GACvD,eAAgB,YAAY,kBAAmB,IAGrC,EAIhB,gBAAmB,IAErB,GAAI,yBAAyB,GAAS,CAClC,MAAM,EAAW,gBAAgB,GAC3B,EAAe,WAAW,GAChC,MAAO,IACA,KACA,EACH,IAAK,IACE,EAAa,OACb,EAAS,KAGxB,CAEA,OAAO,WAAW,EAAO,EAE7B,OAAO,KAAK,YAAY,SAAS,IAE7B,gBAAgB,GAAQ,WAAW,EAAK,SAGf,IAAlB,OAAO,SAAwB,OAAO,OAAS,iBAE1D,QAAQ,OAAS,gBACjB,QAAQ,kBAAoB,kBAC5B,QAAQ,kBAAoB","file":"/npm/expect-puppeteer@11.0.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/expect-puppeteer@11.0.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nconst checkIsPuppeteerInstance = (instance)=>{\n    return Boolean(instance?.constructor?.name && typeof instance === \"object\" && \"$\" in instance);\n};\nconst checkIsPage = (instance)=>{\n    return checkIsPuppeteerInstance(instance) && (instance?.constructor?.name === \"CDPPage\" || instance?.constructor?.name === \"CdpPage\");\n};\nconst checkIsFrame = (instance)=>{\n    return checkIsPuppeteerInstance(instance) && (instance?.constructor?.name === \"CDPFrame\" || instance?.constructor?.name === \"CdpFrame\" || instance?.constructor?.name === \"Frame\");\n};\nconst checkIsElementHandle = (instance)=>{\n    return checkIsPuppeteerInstance(instance) && (instance?.constructor?.name === \"CDPElementHandle\" || instance?.constructor?.name === \"CdpElementHandle\");\n};\nconst getContext = async (instance, pageFunction)=>{\n    if (checkIsFrame(instance) || checkIsPage(instance)) {\n        return {\n            page: instance,\n            handle: await instance.evaluateHandle(pageFunction)\n        };\n    }\n    if (checkIsElementHandle(instance)) {\n        return {\n            page: instance.frame,\n            handle: instance\n        };\n    }\n    throw new Error(`instance is not a valid Puppeteer instance`);\n};\nconst enhanceError = (error, message)=>{\n    error.message = `${message}\\n${error.message}`;\n    return error;\n};\nconst checkIsRegexp = (input)=>Object.prototype.toString.call(input) === \"[object RegExp]\";\nconst serializeRegexp = (regexp)=>{\n    return regexp.toString();\n};\nconst serializeSearchExpression = (expr)=>{\n    if (checkIsRegexp(expr)) {\n        return {\n            text: null,\n            regexp: serializeRegexp(expr)\n        };\n    }\n    if (typeof expr === \"string\") {\n        return {\n            text: expr,\n            regexp: null\n        };\n    }\n    return {\n        text: null,\n        regexp: null\n    };\n};\nconst resolveSelector = (selector)=>{\n    return typeof selector === \"string\" ? {\n        type: \"css\",\n        value: selector\n    } : selector;\n};\nconst getSelectorMessage = (selector, text)=>{\n    return `Element ${selector.value}${text ? ` (text: \"${text}\")` : \"\"}`;\n};\nconst evaluateParseSearchExpression = (page)=>{\n    return page.evaluateHandle(()=>(expr)=>{\n            const sanitizeForSearch = (text)=>{\n                return text.replace(/\\s+/g, \" \").trim();\n            };\n            const parseRegexp = (regexp)=>{\n                const match = regexp.match(/^\\/(.*)\\/([gimuy]*)$/);\n                if (!match) {\n                    throw new Error(`Invalid regexp: ${regexp}`);\n                }\n                return new RegExp(match[1], match[2]);\n            };\n            const { text, regexp } = expr;\n            if (text) {\n                return (value)=>sanitizeForSearch(value).includes(text);\n            }\n            if (regexp) {\n                const regexpInstance = parseRegexp(regexp);\n                return (value)=>regexpInstance.test(sanitizeForSearch(value));\n            }\n            return null;\n        });\n};\n\nlet defaultOptionsValue = {\n    timeout: 500\n};\nconst setDefaultOptions = (options)=>{\n    defaultOptionsValue = options;\n};\nconst globalWithPuppeteerConfig = global;\nconst getDefaultOptions = ()=>{\n    const slowMo = globalWithPuppeteerConfig.puppeteerConfig?.launch?.slowMo || globalWithPuppeteerConfig.puppeteerConfig?.connect?.slowMo || 0;\n    const defaultTimeout = defaultOptionsValue.timeout || 0;\n    if (slowMo || defaultOptionsValue.timeout) {\n        return {\n            ...defaultOptionsValue,\n            // Multiplying slowMo by 10 is just arbitrary\n            // slowMo is applied on all Puppeteer internal methods, so it is just a \"slow\" indicator\n            // we can't use it as a real value\n            timeout: defaultTimeout + slowMo * 10\n        };\n    }\n    return defaultOptionsValue;\n};\nconst defaultOptions = (options)=>({\n        ...getDefaultOptions(),\n        ...options\n    });\n\nasync function matchTextContent(instance, matcher, options, type) {\n    const { traverseShadowRoots = false, ...otherOptions } = options;\n    const frameOptions = defaultOptions(otherOptions);\n    const ctx = await getContext(instance, ()=>document.body);\n    const { text, regexp } = serializeSearchExpression(matcher);\n    const parseSearchExpressionHandle = await evaluateParseSearchExpression(ctx.page);\n    await ctx.page.waitForFunction((handle, text, regexp, traverseShadowRoots, parseSearchExpression, type)=>{\n        const checkNodeIsElement = (node)=>{\n            return node.nodeType === Node.ELEMENT_NODE;\n        };\n        const checkNodeIsText = (node)=>{\n            return node.nodeType === Node.TEXT_NODE;\n        };\n        const checkIsHtmlSlotElement = (node)=>{\n            return node.nodeType === Node.ELEMENT_NODE && node.nodeName === \"SLOT\";\n        };\n        function getShadowTextContent(node) {\n            const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT);\n            let result = \"\";\n            let currentNode = walker.nextNode();\n            while(currentNode){\n                if (checkNodeIsText(currentNode)) {\n                    result += currentNode.textContent;\n                } else if (checkNodeIsElement(currentNode)) {\n                    if (currentNode.assignedSlot) {\n                        // Skip everything within this subtree, since it's assigned to a slot in the shadow DOM.\n                        const nodeWithAssignedSlot = currentNode;\n                        while(currentNode === nodeWithAssignedSlot || nodeWithAssignedSlot.contains(currentNode)){\n                            currentNode = walker.nextNode();\n                        }\n                        continue;\n                    } else if (currentNode.shadowRoot) {\n                        result += getShadowTextContent(currentNode.shadowRoot);\n                    } else if (checkIsHtmlSlotElement(currentNode)) {\n                        const assignedNodes = currentNode.assignedNodes();\n                        assignedNodes.forEach((node)=>{\n                            result += getShadowTextContent(node);\n                        });\n                    }\n                }\n                currentNode = walker.nextNode();\n            }\n            return result;\n        }\n        if (!handle) return false;\n        const textContent = traverseShadowRoots ? getShadowTextContent(handle) : handle.textContent;\n        const matcher = parseSearchExpression({\n            text,\n            regexp\n        });\n        if (!matcher) {\n            throw new Error(`Invalid ${type} matcher: \"${text}\" or \"${regexp}\".`);\n        }\n        switch(type){\n            case \"positive\":\n                return Boolean(textContent && matcher(textContent));\n            case \"negative\":\n                return Boolean(!textContent || !matcher(textContent));\n            default:\n                throw new Error(`Invalid type: \"${type}\".`);\n        }\n    }, frameOptions, ctx.handle, text, regexp, traverseShadowRoots, parseSearchExpressionHandle, type);\n}\n\nasync function notToMatchTextContent(instance, matcher, options = {}) {\n    try {\n        await matchTextContent(instance, matcher, options, \"negative\");\n    } catch (error) {\n        throw enhanceError(error, `Text found \"${matcher}\"`);\n    }\n}\n\nasync function getElementFactory(instance, selector, options) {\n    const { text: searchExpr, visible = false } = options;\n    const ctx = await getContext(instance, ()=>document);\n    const { text, regexp } = serializeSearchExpression(searchExpr);\n    const parseSearchExpressionHandle = await evaluateParseSearchExpression(ctx.page);\n    const getElementArgs = [\n        ctx.handle,\n        selector,\n        text,\n        regexp,\n        visible,\n        parseSearchExpressionHandle\n    ];\n    const getElement = (handle, selector, text, regexp, visible, parseSearchExpression, type)=>{\n        const hasVisibleBoundingBox = (element)=>{\n            const rect = element.getBoundingClientRect();\n            return !!(rect.top || rect.bottom || rect.width || rect.height);\n        };\n        const checkNodeIsElement = (node)=>{\n            return node.nodeType === Node.ELEMENT_NODE;\n        };\n        const checkIsElementVisible = (element)=>{\n            const style = window.getComputedStyle(element);\n            return style?.visibility !== \"hidden\" && hasVisibleBoundingBox(element);\n        };\n        let elements = [];\n        switch(selector.type){\n            case \"xpath\":\n                {\n                    const results = document.evaluate(selector.value, handle);\n                    let node = results.iterateNext();\n                    while(node){\n                        if (checkNodeIsElement(node)) {\n                            elements.push(node);\n                        }\n                        node = results.iterateNext();\n                    }\n                    break;\n                }\n            case \"css\":\n                elements = Array.from(handle.querySelectorAll(selector.value));\n                break;\n            default:\n                throw new Error(`${selector.type} is not implemented`);\n        }\n        elements = visible ? elements.filter(checkIsElementVisible) : elements;\n        const matcher = parseSearchExpression({\n            text,\n            regexp\n        });\n        const element = matcher ? elements.find(({ textContent })=>textContent && matcher(textContent)) : elements[0];\n        switch(type){\n            case \"element\":\n                return element;\n            case \"positive\":\n                return !!element;\n            case \"negative\":\n                return !element;\n            default:\n                throw new Error(`Unknown type: ${type}`);\n        }\n    };\n    return [\n        getElement,\n        getElementArgs,\n        ctx\n    ];\n}\n\n// import {\n//   getContext,\n//   enhanceError,\n//   PuppeteerInstance,\n//   Selector,\n// } from \"../utils\";\n// import { defaultOptions, Options } from \"../options\";\nasync function notToMatchElement(instance, selector, options = {}) {\n    const { text, visible, ...otherOptions } = options;\n    const frameOptions = defaultOptions(otherOptions);\n    const rSelector = resolveSelector(selector);\n    const [getElement, getElementArgs, ctx] = await getElementFactory(instance, rSelector, {\n        text,\n        visible\n    });\n    try {\n        await ctx.page.waitForFunction(getElement, frameOptions, ...getElementArgs, \"negative\");\n    } catch (error) {\n        throw enhanceError(error, `${getSelectorMessage(rSelector, text)} found`);\n    }\n}\n\nasync function toMatchElement(instance, selector, options = {}) {\n    const { text, visible, ...otherOptions } = options;\n    const frameOptions = defaultOptions(otherOptions);\n    const rSelector = resolveSelector(selector);\n    const [getElement, getElementArgs, ctx] = await getElementFactory(instance, rSelector, {\n        text,\n        visible\n    });\n    try {\n        await ctx.page.waitForFunction(getElement, frameOptions, ...getElementArgs, \"positive\");\n    } catch (error) {\n        throw enhanceError(error, `${getSelectorMessage(rSelector, text)} not found`);\n    }\n    const jsHandle = await ctx.page.evaluateHandle(getElement, ...getElementArgs, \"element\");\n    return jsHandle.asElement();\n}\n\nasync function toClick(instance, selector, options = {}) {\n    const { delay, button, count, offset, ...otherOptions } = options;\n    const element = await toMatchElement(instance, selector, otherOptions);\n    await element.click({\n        delay,\n        button,\n        count,\n        offset\n    });\n}\n\nasync function toDisplayDialog(page, block) {\n    return new Promise((resolve, reject)=>{\n        const handleDialog = (dialog)=>{\n            page.off(\"dialog\", handleDialog);\n            resolve(dialog);\n        };\n        page.on(\"dialog\", handleDialog);\n        block().catch(reject);\n    });\n}\n\nasync function selectAll(element) {\n    // modified from https://github.com/microsoft/playwright/issues/849#issuecomment-587983363\n    await element.evaluate((element)=>{\n        if (!(element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement)) {\n            throw new Error(`Element is not an <input> element.`);\n        }\n        if (element.setSelectionRange) {\n            try {\n                element.setSelectionRange(0, element.value.length);\n            } catch  {\n                // setSelectionRange throws an error for inputs: number/date/time/etc\n                // we can just focus them and the content will be selected\n                element.focus();\n                element.select();\n            }\n        } else if (window.getSelection && document.createRange) {\n            const range = document.createRange();\n            range.selectNodeContents(element);\n            const selection = window.getSelection();\n            if (selection) {\n                selection.removeAllRanges();\n                selection.addRange(range);\n            }\n        }\n    });\n}\nasync function toFill(instance, selector, value, options = {}) {\n    const { delay, ...toMatchElementOptions } = options;\n    const element = await toMatchElement(instance, selector, toMatchElementOptions);\n    await selectAll(element);\n    await element.press(\"Delete\");\n    await element.type(value, delay ? {\n        delay\n    } : undefined);\n}\n\nasync function toFillForm(instance, selector, values, options = {}) {\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    const { delay, ...otherOptions } = options;\n    const form = await toMatchElement(instance, selector, otherOptions);\n    for (const name of Object.keys(values)){\n        await toFill(form, `[name=\"${name}\"]`, values[name], options);\n    }\n}\n\nasync function toMatchTextContent(instance, matcher, options = {}) {\n    try {\n        await matchTextContent(instance, matcher, options, \"positive\");\n    } catch (error) {\n        throw enhanceError(error, `Text not found \"${matcher}\"`);\n    }\n}\n\nconst checkIsSelectElement = (element)=>{\n    return typeof element.select === \"function\";\n};\nasync function toSelect(instance, selector, valueOrText, options = {}) {\n    const element = await toMatchElement(instance, selector, options);\n    if (!checkIsSelectElement(element)) {\n        throw new Error(`Element is not a <select> element.`);\n    }\n    const optionElements = await element.$$(\"option\");\n    const optionsAttributes = await Promise.all(optionElements.map(async (option)=>{\n        const textContentProperty = await option.getProperty(\"textContent\");\n        const valueProperty = await option.getProperty(\"value\");\n        return {\n            value: await valueProperty.jsonValue(),\n            textContent: await textContentProperty.jsonValue()\n        };\n    }));\n    const option = optionsAttributes.find(({ value, textContent })=>value === valueOrText || textContent === valueOrText);\n    if (!option) {\n        throw new Error(`Option not found \"${resolveSelector(selector).value}\" (\"${valueOrText}\")`);\n    }\n    await element.select(option.value);\n}\n\nconst checkIsInputElement = (element)=>{\n    return typeof element.uploadFile === \"function\";\n};\nasync function toUploadFile(instance, selector, filePaths, options = {}) {\n    const element = await toMatchElement(instance, selector, options);\n    if (!checkIsInputElement(element)) {\n        throw new Error(`Element is not an input element`);\n    }\n    const resolvedFilePaths = Array.isArray(filePaths) ? filePaths : [\n        filePaths\n    ];\n    return element.uploadFile(...resolvedFilePaths);\n}\n\n// import modules\n// ---------------------------\n// @ts-expect-error global node object w/ initial jest expect prop attached\nconst jestExpect = global.expect;\n// ---------------------------\n// wrapper executing the matcher and capturing the stack trace on error before rethrowing\nconst wrapMatcher = (matcher, instance)=>async function throwingMatcher(...args) {\n        // update the assertions counter\n        jestExpect.getState().assertionCalls += 1;\n        try {\n            // run async matcher\n            const result = await matcher(instance, ...args);\n            // resolve\n            return result;\n        } catch (err) {\n            if (err instanceof Error) Error.captureStackTrace(err, throwingMatcher);\n            // reject\n            throw err;\n        }\n    };\n// ---------------------------\n// create the generic expect object and bind wrapped matchers to it\nconst puppeteerExpect = (instance)=>{\n    // read instance type\n    const [isPage, isFrame, isHandle] = [\n        checkIsPage(instance),\n        checkIsFrame(instance),\n        checkIsElementHandle(instance)\n    ];\n    if (!isPage && !isFrame && !isHandle) throw new Error(`${instance.constructor.name} is not supported`);\n    // retrieve matchers\n    const expectation = {\n        // common\n        toClick: wrapMatcher(toClick, instance),\n        toFill: wrapMatcher(toFill, instance),\n        toFillForm: wrapMatcher(toFillForm, instance),\n        toMatchTextContent: wrapMatcher(toMatchTextContent, instance),\n        toMatchElement: wrapMatcher(toMatchElement, instance),\n        toSelect: wrapMatcher(toSelect, instance),\n        toUploadFile: wrapMatcher(toUploadFile, instance),\n        // page\n        toDisplayDialog: isPage ? wrapMatcher(toDisplayDialog, instance) : undefined,\n        // inverse matchers\n        not: {\n            toMatchTextContent: wrapMatcher(notToMatchTextContent, instance),\n            toMatchElement: wrapMatcher(notToMatchElement, instance)\n        }\n    };\n    return expectation;\n};\n// ---------------------------\n// merge puppeteer matchers w/ jest matchers and return a new object\nconst expectPuppeteer = (actual)=>{\n    // puppeteer\n    if (checkIsPuppeteerInstance(actual)) {\n        const matchers = puppeteerExpect(actual);\n        const jestMatchers = jestExpect(actual);\n        return {\n            ...jestMatchers,\n            ...matchers,\n            not: {\n                ...jestMatchers.not,\n                ...matchers.not\n            }\n        };\n    }\n    // not puppeteer (fall back to jest defaults, puppeteer matchers not available)\n    return jestExpect(actual);\n};\nObject.keys(jestExpect).forEach((prop)=>{\n    // @ts-expect-error add jest expect properties to expect-puppeteer implementation\n    expectPuppeteer[prop] = jestExpect[prop];\n});\n// replace jest expect by expect-puppeteer ...\nif (typeof global.expect !== `undefined`) global.expect = expectPuppeteer;\n\nexports.expect = expectPuppeteer;\nexports.getDefaultOptions = getDefaultOptions;\nexports.setDefaultOptions = setDefaultOptions;\n"]}