{"version":3,"file":"index.cjs","sources":["../src/utils/string-utils.ts","../src/create-es-modules-components-file.ts","../src/create-stencil-react-components.ts","../src/create-tag-transformer.ts","../src/create-component-wrappers.ts","../src/index.ts"],"sourcesContent":["export const kebabToPascalCase = (str: string) =>\n  str\n    .toLowerCase()\n    .split('-')\n    .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))\n    .join('');\n\nexport const kebabToCamelCase = (str: string) => str.replace(/-([_a-z])/g, (_, letter) => letter.toUpperCase());\n\nconst slashesToCamelCase = (str: string) => str.replace(/\\/([a-z])/g, (_, letter) => letter.toUpperCase());\n\nexport const eventListenerName = (eventName: string) => {\n  const slashesConverted = slashesToCamelCase(eventName);\n  return kebabToCamelCase(`on-${slashesConverted}`);\n};\n\n/**\n * Normalizes a type string by removing single-line comments and collapsing whitespace.\n * This is necessary because multiline types with comments would break when collapsed to a single line.\n */\nexport const normalizeTypeString = (type: string) =>\n  type\n    .replace(/\\/\\/.*$/gm, '') // Remove single-line comments\n    .replace(/\\n/g, ' ') // Replace newlines with spaces\n    .replace(/\\s{2,}/g, ' ') // Collapse multiple spaces\n    .trim();\n","import type { ComponentCompilerMeta } from '@stencil/core/internal';\nimport path from 'node:path';\nimport { Project } from 'ts-morph';\nimport { kebabToPascalCase } from './utils/string-utils.js';\n\nexport const createEsModulesComponentsFile = async ({\n  components,\n  project,\n  outDir,\n}: {\n  components: ComponentCompilerMeta[];\n  project?: Project;\n  outDir?: string;\n}) => {\n  const tsProject = project || new Project({ useInMemoryFileSystem: true });\n  const disableEslint = `/* eslint-disable */\\n`;\n  const autogeneratedComment = `/**\n * This file was automatically generated by the Stencil React Output Target.\n * Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.\n */\\n\\n`;\n  const outFile = path.join(outDir || '', 'components.ts');\n  const sourceFile = tsProject.createSourceFile(outFile, autogeneratedComment + disableEslint, {\n    overwrite: true,\n  });\n\n  for (const component of components) {\n    const tagName = component.tagName;\n    const reactTagName = kebabToPascalCase(tagName);\n    const fileName = component.tagName;\n    sourceFile.addExportDeclaration({\n      moduleSpecifier: `./${fileName}.js`,\n      namedExports: [reactTagName],\n    });\n  }\n\n  sourceFile.organizeImports();\n  sourceFile.formatText();\n  await sourceFile.save();\n\n  return sourceFile;\n};\n","import type { ComponentCompilerMeta } from '@stencil/core/internal';\nimport { Project, VariableDeclarationKind } from 'ts-morph';\nimport { eventListenerName, kebabToPascalCase, normalizeTypeString } from './utils/string-utils.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\ninterface ReactEvent {\n  originalName: string;\n  name: string;\n  type: string;\n}\n\nexport const createStencilReactComponents = ({\n  components,\n  stencilPackageName,\n  customElementsDir,\n  hydrateModule,\n  clientModule,\n  serializeShadowRoot,\n  transformTag,\n}: {\n  components: ComponentCompilerMeta[];\n  stencilPackageName: string;\n  customElementsDir: string;\n  hydrateModule?: string;\n  clientModule?: string;\n  serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n  transformTag?: boolean;\n}) => {\n  const project = new Project({ useInMemoryFileSystem: true });\n\n  /**\n   * automatically attach the `use client` directive if we are not generating\n   * server side rendering components.\n   */\n  const useClientDirective = `'use client';\\n\\n`;\n  const autogeneratedComment = `/**\n * This file was automatically generated by the Stencil React Output Target.\n * Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.\n */\\n\\n`;\n\n  const disableEslint = `/* eslint-disable */\\n`;\n  const getTagTransformerImport = transformTag ? `import { getTagTransformer } from './tag-transformer.js';\\n` : '';\n  const createComponentImport = hydrateModule\n    ? [\n        getTagTransformerImport,\n        `import { createComponent, type SerializeShadowRootOptions, type HydrateModule, type ReactWebComponent } from '@stencil/react-output-target/ssr';`,\n      ]\n        .filter(Boolean)\n        .join('\\n')\n    : `import { createComponent } from '@stencil/react-output-target/runtime';`;\n  // transformTag should be imported from tag-transformer for both client and server\n  const transformTagImport = transformTag ? `import { transformTag } from './tag-transformer.js';\\n` : '';\n  const sourceFile = project.createSourceFile(\n    'component.ts',\n    `${useClientDirective}${autogeneratedComment}${disableEslint}\nimport React from 'react';\n${createComponentImport}\nimport type { EventName, StencilReactComponent } from '@stencil/react-output-target/runtime';\n${transformTagImport}\nimport type { Components } from \"${stencilPackageName}/${customElementsDir}\";\n  `\n  );\n\n  /**\n   * Add the `clientComponents` import if hydrateModule is provided.\n   * This import needs a @ts-ignore comment, which will be added after organizeImports().\n   */\n  if (hydrateModule && clientModule) {\n    sourceFile.addImportDeclaration({\n      moduleSpecifier: clientModule,\n      namespaceImport: 'clientComponents',\n    });\n  }\n\n  /**\n   * Add the `serializeShadowRoot` variable to the file if the hydrateModule is provided.\n   */\n  if (hydrateModule) {\n    sourceFile.addVariableStatement({\n      isExported: true,\n      declarationKind: VariableDeclarationKind.Const,\n      declarations: [\n        {\n          name: 'serializeShadowRoot',\n          type: 'SerializeShadowRootOptions',\n          initializer: serializeShadowRoot\n            ? JSON.stringify(serializeShadowRoot)\n            : '{ default: \"declarative-shadow-dom\" }',\n        },\n      ],\n    });\n  }\n\n  for (const component of components) {\n    const tagName = component.tagName;\n    const reactTagName = kebabToPascalCase(tagName);\n    const componentElement = `${reactTagName}Element`;\n    const componentCustomEvent = `${reactTagName}CustomEvent`;\n\n    sourceFile.addImportDeclaration({\n      moduleSpecifier: `${stencilPackageName}/${customElementsDir}/${tagName}.js`,\n      namedImports: [\n        {\n          name: reactTagName,\n          alias: componentElement,\n        },\n        {\n          name: 'defineCustomElement',\n          alias: `define${reactTagName}`,\n        },\n      ],\n    });\n\n    const publicEvents = (component.events || []).filter((e) => e.internal === false);\n    const events: ReactEvent[] = [];\n    const importedEventDetailTypes = new Set<string>();\n    let importedComponentCustomEvent = false;\n\n    for (const event of publicEvents) {\n      /**\n       * Import the referenced types from the component library.\n       * Stencil will automatically re-export type definitions from the components,\n       * if they are used in the component's property or event types.\n       */\n      if (Object.keys(event.complexType.references).length > 0) {\n        for (const referenceKey of Object.keys(event.complexType.references)) {\n          const reference = event.complexType.references[referenceKey];\n          const isGlobalType = reference.location === 'global';\n\n          /**\n           * Global type references should not have an explicit import.\n           * The type should be available globally.\n           */\n          if (!isGlobalType && !importedEventDetailTypes.has(referenceKey)) {\n            importedEventDetailTypes.add(referenceKey);\n            sourceFile.addImportDeclaration({\n              moduleSpecifier: stencilPackageName,\n              namedImports: [\n                {\n                  name: referenceKey,\n                  isTypeOnly: true,\n                },\n              ],\n            });\n          }\n        }\n      }\n\n      /**\n       * Import the CustomEvent type for the web component from the Stencil package.\n       *\n       * For example:\n       * ```\n       * import type { ComponentCustomEvent } from 'my-component-library';\n       * ```\n       */\n      if (!importedComponentCustomEvent) {\n        importedComponentCustomEvent = true;\n        sourceFile.addImportDeclaration({\n          moduleSpecifier: stencilPackageName,\n          namedImports: [\n            {\n              name: componentCustomEvent,\n              isTypeOnly: true,\n            },\n          ],\n        });\n      }\n\n      // Always type events using the Stencil per-component CustomEvent type.\n      events.push({\n        originalName: event.name,\n        name: eventListenerName(event.name),\n        type: `EventName<${componentCustomEvent}<${normalizeTypeString(event.complexType.original)}>>`,\n      });\n    }\n\n    const componentEventNamesType = `${reactTagName}Events`;\n\n    sourceFile.addTypeAlias({\n      isExported: true,\n      name: componentEventNamesType,\n      type: events.length > 0 ? `{ ${events.map((e) => `${e.name}: ${e.type}`).join(',\\n')} }` : 'NonNullable<unknown>',\n    });\n\n    const transformTagParam = transformTag ? ',\\n    transformTag' : '';\n    const clientComponentCall = `/*@__PURE__*/ createComponent<${componentElement}, ${componentEventNamesType}, Components.${reactTagName}>({\n    tagName: '${tagName}',\n    elementClass: ${componentElement},\n    // @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.\n    react: React,\n    events: {${events.map((e) => `${e.name}: '${e.originalName}'`).join(',\\n')}} as ${componentEventNamesType},\n    defineCustomElement: define${reactTagName}${transformTagParam}\n  })`;\n\n    const getTagTransformerParam = transformTag ? ',\\n    getTagTransformer' : '';\n    const serverComponentCall = `/*@__PURE__*/ createComponent<${componentElement}, ${componentEventNamesType}, Components.${reactTagName}>({\n    tagName: '${tagName}',\n    properties: {${component.properties\n      /**\n       * Filter out properties that don't have an attribute.\n       * These are properties with complex types and can't be serialized.\n       */\n      .filter((prop) => Boolean(prop.attribute))\n      .map((e) => `${e.name}: '${e.attribute}'`)\n      .join(',\\n')}},\n    hydrateModule: import('${hydrateModule}') as Promise<HydrateModule>,\n    clientModule: clientComponents.${reactTagName} as StencilReactComponent<${componentElement}, ${componentEventNamesType}, Components.${reactTagName}>,\n    serializeShadowRoot${getTagTransformerParam}\n  })`;\n\n    sourceFile.addVariableStatement({\n      isExported: true,\n      declarationKind: VariableDeclarationKind.Const,\n      declarations: [\n        {\n          name: reactTagName,\n          type: `StencilReactComponent<${componentElement}, ${componentEventNamesType}, Components.${reactTagName}>`,\n          initializer: hydrateModule ? serverComponentCall : clientComponentCall,\n        },\n      ],\n    });\n  }\n\n  sourceFile.organizeImports();\n\n  /**\n   * Add the @ts-ignore comment to the clientComponents import after organizeImports()\n   * to ensure the comment stays attached to the correct import.\n   */\n  if (hydrateModule && clientModule) {\n    const clientComponentsImport = sourceFile\n      .getImportDeclarations()\n      .find((imp) => imp.getNamespaceImport()?.getText() === 'clientComponents');\n\n    if (clientComponentsImport) {\n      sourceFile.insertText(\n        clientComponentsImport.getStart(),\n        '// @ts-ignore - ignore potential type issues as the project is importing itself\\n'\n      );\n    }\n  }\n\n  sourceFile.formatText();\n\n  return sourceFile.getFullText();\n};\n","export const createTagTransformer = ({\n  stencilPackageName,\n  customElementsDir,\n}: {\n  stencilPackageName: string;\n  customElementsDir: string;\n}) => {\n  return `/* eslint-disable */\n/* tslint:disable */\nimport { setTagTransformer as clientSetTagTransformer } from '${stencilPackageName}/${customElementsDir}/index.js';\n\nlet tagTransformer: ((tagName: string) => string) | undefined;\n\nexport const setTagTransformer = (transformer: (tagName: string) => string) => {\n  clientSetTagTransformer(transformer);\n  tagTransformer = transformer;\n};\n\nexport const transformTag = (tag: string): string => {\n  return tagTransformer ? tagTransformer(tag) : tag;\n};\n\nexport const getTagTransformer = () => tagTransformer;\n`;\n};\n","import type { ComponentCompilerMeta } from '@stencil/core/internal';\nimport path from 'node:path';\nimport { Project, SourceFile } from 'ts-morph';\nimport { createEsModulesComponentsFile } from './create-es-modules-components-file.js';\nimport { createStencilReactComponents } from './create-stencil-react-components.js';\nimport { createTagTransformer } from './create-tag-transformer.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\nexport const createComponentWrappers = async ({\n  stencilPackageName,\n  components,\n  outDir,\n  esModules,\n  customElementsDir,\n  excludeComponents,\n  project,\n  hydrateModule,\n  clientModule,\n  excludeServerSideRenderingFor,\n  serializeShadowRoot,\n  transformTag,\n}: {\n  stencilPackageName: string;\n  components: ComponentCompilerMeta[];\n  customElementsDir: string;\n  outDir: string;\n  esModules?: boolean;\n  excludeComponents?: string[];\n  project: Project;\n  hydrateModule?: string;\n  clientModule?: string;\n  excludeServerSideRenderingFor?: string[];\n  serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n  transformTag?: boolean;\n}) => {\n  const sourceFiles: SourceFile[] = [];\n\n  const filteredComponents = components.filter((c) => {\n    if (c.internal === true) {\n      /**\n       * Skip internal components\n       */\n      return false;\n    }\n    if (excludeComponents?.includes(c.tagName)) {\n      /**\n       * Skip excluded components\n       */\n      return false;\n    }\n\n    return true;\n  });\n\n  if (filteredComponents.length === 0) {\n    return [];\n  }\n\n  const fileContents: Record<string, string> = {};\n\n  /**\n   * create a single file with all components or a separate file for each component\n   * @param components - the components to create the file for\n   * @param filename - the filename of the file to create\n   */\n  function createComponentFile(components: ComponentCompilerMeta[], filename = 'components') {\n    /**\n     * create a single file with all components\n     */\n    const outputPath = path.join(outDir, `${filename}.ts`);\n\n    /**\n     * create a client side component\n     */\n    const stencilReactComponent = createStencilReactComponents({\n      components,\n      stencilPackageName,\n      customElementsDir,\n      transformTag,\n    });\n    fileContents[outputPath] = stencilReactComponent;\n\n    /**\n     * create tag-transformer file (for both client and server)\n     */\n    if (transformTag) {\n      const tagTransformerPath = path.join(outDir, 'tag-transformer.ts');\n      fileContents[tagTransformerPath] = createTagTransformer({ stencilPackageName, customElementsDir });\n    }\n\n    /**\n     * create a server side component\n     */\n    if (hydrateModule) {\n      const outputPath = path.join(outDir, `${filename}.server.ts`);\n      const stencilReactComponent = createStencilReactComponents({\n        components: components.filter(\n          (c) => !excludeServerSideRenderingFor || !excludeServerSideRenderingFor.includes(c.tagName)\n        ),\n        stencilPackageName,\n        customElementsDir,\n        hydrateModule,\n        clientModule,\n        serializeShadowRoot,\n        transformTag,\n      });\n      fileContents[outputPath] = stencilReactComponent;\n    }\n  }\n\n  if (esModules) {\n    /**\n     * create a separate file for each component\n     */\n    for (const component of filteredComponents) {\n      createComponentFile([component], component.tagName);\n    }\n    const componentsSource = await createEsModulesComponentsFile({ components: filteredComponents, project, outDir });\n    sourceFiles.push(componentsSource);\n  } else {\n    createComponentFile(filteredComponents);\n  }\n\n  await Promise.all(\n    Object.entries(fileContents).map(async ([outputPath, content]) => {\n      const sourceFile = project.createSourceFile(outputPath, content, { overwrite: true });\n      await sourceFile.save();\n      sourceFiles.push(sourceFile);\n    })\n  );\n\n  return sourceFiles;\n};\n","import type { BuildCtx, OutputTargetCustom, OutputTargetDistCustomElements } from '@stencil/core/internal';\nimport { Project } from 'ts-morph';\nimport { createComponentWrappers } from './create-component-wrappers.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\nexport interface ReactOutputTargetOptions {\n  /**\n   * Specify the output directory or path where the generated React components will be saved.\n   */\n  outDir: string;\n  /**\n   * Specify the components that should be excluded from the React output target.\n   */\n  excludeComponents?: string[];\n  /**\n   * The package name of the Stencil project.\n   *\n   * This value is automatically detected from the package.json file of the Stencil project.\n   * If the validation fails, you can manually assign the package name.\n   */\n  stencilPackageName?: string;\n  /**\n   * The directory where the custom elements are saved.\n   *\n   * This value is automatically detected from the Stencil configuration file for the dist-custom-elements output target.\n   * If you are working in an environment that uses absolute paths, consider setting this value manually.\n   */\n  customElementsDir?: string;\n  /**\n   * To enable server side rendering, provide the path to the hydrate module, e.g. `my-component/hydrate`.\n   * By default this value is undefined and server side rendering is disabled.\n   */\n  hydrateModule?: string;\n  /**\n   * The name of the package that exports all React wrapped Stencil components for client side rendering.\n   * This options is required when `hydrateModule` is set for server side rendering to work.\n   */\n  clientModule?: string;\n  /**\n   * Specify the components that should be excluded from server side rendering.\n   */\n  excludeServerSideRenderingFor?: string[];\n  /**\n   * If `true`, the output target will generate a separate ES module for each React component wrapper (better for tree-shaking).\n   * @default false\n   */\n  esModules?: boolean;\n  /**\n   * Configure how Stencil serializes the components shadow root.\n   * - If set to `declarative-shadow-dom` the component will be rendered within a Declarative Shadow DOM.\n   * - If set to `scoped` Stencil will render the contents of the shadow root as a `scoped: true` component\n   *   and the shadow DOM will be created during client-side hydration.\n   * - Alternatively you can mix and match the two by providing an object with `declarative-shadow-dom` and `scoped` keys,\n   * the value arrays containing the tag names of the components that should be rendered in that mode.\n   *\n   * Examples:\n   * - `{ 'declarative-shadow-dom': ['my-component-1', 'another-component'], default: 'scoped' }`\n   * Render all components as `scoped` apart from `my-component-1` and `another-component`\n   * -  `{ 'scoped': ['an-option-component'], default: 'declarative-shadow-dom' }`\n   * Render all components within `declarative-shadow-dom` apart from `an-option-component`\n   * - `'scoped'` Render all components as `scoped`\n   * - `false` disables shadow root serialization\n   *\n   * *NOTE* `true` has been deprecated in favor of `declarative-shadow-dom` and `scoped`\n   * @default 'declarative-shadow-dom'\n   */\n  serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n  /**\n   * Use `transformTag` to enable runtime tag name transformation for your components.\n   * When enabled, the output target will import `transformTag` from your component library\n   * and apply it when rendering components.\n   *\n   * You must export `transformTag` from the root entry of your component library:\n   * ```ts\n   * // src/index.ts\n   * export { transformTag } from '@stencil/core';\n   * ```\n   *\n   * @default false\n   */\n  transformTag?: boolean;\n}\n\nconst PLUGIN_NAME = 'react-output-target';\n\nconst DIST_CUSTOM_ELEMENTS_DEFAULT_DIR = 'dist/components';\nconst DIST_CUSTOM_ELEMENTS = 'dist-custom-elements';\nconst HYDRATE_OUTPUT_TARGET = 'dist-hydrate-script';\n\ninterface ReactOutputTarget extends OutputTargetCustom {\n  __internal_getCustomElementsDir: () => string;\n}\n\n/**\n * Creates an output target for binding Stencil components to be used in a React context\n * @public\n * @param outputTarget the user-defined output target defined in a Stencil configuration file\n * @returns an output target that can be used by the Stencil compiler\n */\nexport const reactOutputTarget = ({\n  outDir,\n  esModules,\n  stencilPackageName,\n  excludeComponents,\n  customElementsDir: customElementsDirOverride,\n  hydrateModule,\n  clientModule,\n  excludeServerSideRenderingFor,\n  serializeShadowRoot,\n  transformTag,\n}: ReactOutputTargetOptions): ReactOutputTarget => {\n  let customElementsDir = DIST_CUSTOM_ELEMENTS_DEFAULT_DIR;\n  return {\n    type: 'custom',\n    name: PLUGIN_NAME,\n    validate(config) {\n      /**\n       * Validate the configuration to ensure that the dist-custom-elements\n       * output target is defined in the Stencil configuration.\n       *\n       * This context is used to detect a customized output path.\n       */\n      if (customElementsDirOverride) {\n        customElementsDir = customElementsDirOverride;\n      } else {\n        const customElementsOutputTarget = (config.outputTargets || []).find(\n          (o) => o.type === DIST_CUSTOM_ELEMENTS\n        ) as OutputTargetDistCustomElements;\n        if (customElementsOutputTarget == null) {\n          throw new Error(\n            `The '${PLUGIN_NAME}' requires '${DIST_CUSTOM_ELEMENTS}' output target. Add { type: '${DIST_CUSTOM_ELEMENTS}' }, to the outputTargets config.`\n          );\n        }\n        if (customElementsOutputTarget.dir !== undefined) {\n          /**\n           * If the developer has configured a custom output path for the Stencil components,\n           * we need to use that path when importing the components in the React components.\n           */\n          customElementsDir = customElementsOutputTarget.dir;\n        }\n\n        /**\n         * Validate the configuration for `dist-custom-elements` output target to ensure that\n         * the bundle generates its own runtime. This is important because we need to ensure that\n         * the Stencil runtime has hydration flags set which the default Stencil runtime does not have.\n         */\n        if (customElementsOutputTarget.externalRuntime !== false) {\n          throw new Error(\n            `The '${PLUGIN_NAME}' requires the '${DIST_CUSTOM_ELEMENTS}' output target to have 'externalRuntime: false' set in its configuration.`\n          );\n        }\n      }\n\n      /**\n       * Validate the configuration to ensure that the dist-hydrate-script\n       * output target is defined in the Stencil configuration if the hydrateModule is provided.\n       */\n      if (hydrateModule) {\n        const hydrateOutputTarget = (config.outputTargets || []).find((o) => o.type === HYDRATE_OUTPUT_TARGET);\n        if (hydrateOutputTarget == null) {\n          throw new Error(\n            `The '${PLUGIN_NAME}' requires '${HYDRATE_OUTPUT_TARGET}' output target when the 'hydrateModule' option is set. Add { type: '${HYDRATE_OUTPUT_TARGET}' }, to the outputTargets config.`\n          );\n        }\n\n        if (clientModule == null) {\n          throw new Error(\n            `The '${PLUGIN_NAME}' requires the 'clientModule' option when the 'hydrateModule' option is set. Please provide the clientModule manually to the ${PLUGIN_NAME} output target.`\n          );\n        }\n      }\n\n      /**\n       * Validate the configuration to detect the package name of the Stencil project.\n       */\n      if (stencilPackageName === undefined) {\n        if (config.sys && config.packageJsonFilePath) {\n          const { name: packageName } = JSON.parse(config.sys.readFileSync(config.packageJsonFilePath, 'utf8'));\n          stencilPackageName = packageName;\n        }\n\n        if (!stencilPackageName) {\n          throw new Error(\n            `Unable to find the package name in the package.json file: ${config.packageJsonFilePath}. Please provide the stencilPackageName manually to the ${PLUGIN_NAME} output target.`\n          );\n        }\n      }\n    },\n    async generator(_config, compilerCtx, buildCtx: BuildCtx) {\n      const timespan = buildCtx.createTimeSpan(`generate ${PLUGIN_NAME} started`, true);\n\n      const components = buildCtx.components;\n      const project = new Project();\n\n      const sourceFiles = await createComponentWrappers({\n        outDir,\n        components,\n        stencilPackageName: stencilPackageName!,\n        customElementsDir,\n        excludeComponents,\n        esModules: esModules === true,\n        project,\n        hydrateModule,\n        clientModule,\n        excludeServerSideRenderingFor,\n        serializeShadowRoot,\n        transformTag,\n      });\n\n      await Promise.all(\n        sourceFiles.map((sourceFile) => compilerCtx.fs.writeFile(sourceFile.getFilePath(), sourceFile.getFullText()))\n      );\n\n      timespan.finish(`generate ${PLUGIN_NAME} finished`);\n    },\n    __internal_getCustomElementsDir() {\n      return customElementsDir;\n    },\n  };\n};\n"],"names":["kebabToPascalCase","str","segment","kebabToCamelCase","_","letter","slashesToCamelCase","eventListenerName","eventName","slashesConverted","normalizeTypeString","type","createEsModulesComponentsFile","components","project","outDir","tsProject","Project","disableEslint","autogeneratedComment","outFile","path","sourceFile","component","tagName","reactTagName","fileName","createStencilReactComponents","stencilPackageName","customElementsDir","hydrateModule","clientModule","serializeShadowRoot","transformTag","useClientDirective","createComponentImport","transformTagImport","VariableDeclarationKind","componentElement","componentCustomEvent","publicEvents","e","events","importedEventDetailTypes","importedComponentCustomEvent","event","referenceKey","componentEventNamesType","transformTagParam","clientComponentCall","getTagTransformerParam","serverComponentCall","prop","clientComponentsImport","imp","_a","createTagTransformer","createComponentWrappers","esModules","excludeComponents","excludeServerSideRenderingFor","sourceFiles","filteredComponents","c","fileContents","createComponentFile","filename","outputPath","stencilReactComponent","tagTransformerPath","componentsSource","content","PLUGIN_NAME","DIST_CUSTOM_ELEMENTS_DEFAULT_DIR","DIST_CUSTOM_ELEMENTS","HYDRATE_OUTPUT_TARGET","reactOutputTarget","customElementsDirOverride","config","customElementsOutputTarget","o","packageName","_config","compilerCtx","buildCtx","timespan"],"mappings":"mIAAaA,EAAqBC,GAChCA,EACG,YAAA,EACA,MAAM,GAAG,EACT,IAAKC,GAAYA,EAAQ,OAAO,CAAC,EAAE,cAAgBA,EAAQ,MAAM,CAAC,CAAC,EACnE,KAAK,EAAE,EAECC,EAAoBF,GAAgBA,EAAI,QAAQ,aAAc,CAACG,EAAGC,IAAWA,EAAO,aAAa,EAExGC,EAAsBL,GAAgBA,EAAI,QAAQ,aAAc,CAACG,EAAGC,IAAWA,EAAO,aAAa,EAE5FE,EAAqBC,GAAsB,CAChD,MAAAC,EAAmBH,EAAmBE,CAAS,EAC9C,OAAAL,EAAiB,MAAMM,CAAgB,EAAE,CAClD,EAMaC,EAAuBC,GAClCA,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