import{Puppeteer}from"../common/Puppeteer.js";import{PUPPETEER_REVISIONS}from"../revisions.js";import{BrowserFetcher}from"./BrowserFetcher.js";import Launcher from"./Launcher.js";export class PuppeteerNode extends Puppeteer{constructor(e){const{projectRoot:r,preferredRevision:t,productName:o,...c}=e;super(c),this._projectRoot=r,this.__productName=o,this._preferredRevision=t}connect(e){return e.product&&(this._productName=e.product),super.connect(e)}get _productName(){return this.__productName}set _productName(e){this.__productName!==e&&(this._changedProduct=!0),this.__productName=e}launch(e={}){return e.product&&(this._productName=e.product),this._launcher.launch(e)}executablePath(){return this._launcher.executablePath()}get _launcher(){if(!this._lazyLauncher||this._lazyLauncher.product!==this._productName||this._changedProduct){switch(this._productName){case"firefox":this._preferredRevision=PUPPETEER_REVISIONS.firefox;break;case"chrome":default:this._preferredRevision=PUPPETEER_REVISIONS.chromium}this._changedProduct=!1,this._lazyLauncher=Launcher(this._projectRoot,this._preferredRevision,this._isPuppeteerCore,this._productName)}return this._lazyLauncher}get product(){return this._launcher.product}defaultArgs(e={}){return this._launcher.defaultArgs(e)}createBrowserFetcher(e){return new BrowserFetcher(this._projectRoot,e)}}