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cAAc,IAAU,EAAO,OAAQ,CACzC,CAEA,SAAS,UAAU,GACjB,MAAqB,kBAAV,EACF,EAAQ,CAAC,OAAI,EAEf,CACT,CAEA,SAAS,gBAAgB,GACvB,MAAM,EAAmB,UAAU,EAAQ,kBACrC,EAAU,UAAU,EAAQ,SAE9B,GAAgD,iBAArB,IAC7B,EAAQ,iBAAmB,KAAK,UAAU,IAGxC,GAA8B,iBAAZ,IACpB,EAAQ,QAAU,KAAK,UAAU,GAErC,CAjFA,QAAQ,SAAW,SAEnB,QAAQ,OAAS,SAAU,EAAU,EAAM,GACzC,OAAO,OAAO,KAAK,UAAU,GAAM,EAAU,EAC/C,EAEA,QAAQ,WAAa,SAAU,EAAU,EAAM,GAC7C,OAAO,WAAW,KAAK,UAAU,GAAM,EAAU,EACnD","file":"/npm/@modern-js/swc-plugins@0.6.11/binding.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@modern-js/swc-plugins@0.6.11/binding.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","let binding;\ntry {\n  binding = require(\"./index\");\n} catch (e) {\n  console.error(\n    \"Can't find SWC binary, you can try following ways to solve this:\\n1. Upgrade your Node.js version to 14.19, and reinstall dependencies.\\n2. Make sure your Node.js matches your computer OS and CPU architecture, you can check that by printing `process.arch` and `process.platform`.\\n\"\n  );\n  throw e;\n}\n\nexports.minifyCss = binding.minifyCss;\nexports.minifyCssSync = binding.minifyCssSync;\n\nconst { minify, minifySync, Compiler: RawCompiler } = binding;\n\nclass Compiler extends RawCompiler {\n  // Do not mutate on rawConfig\n  constructor(rawConfig) {\n    const config = { ...rawConfig };\n    const extensions = { ...config.extensions } || {};\n\n    if (extensions.pluginImport) {\n      extensions.pluginImport = transformPluginImport(extensions.pluginImport);\n    }\n\n    /**\n     * Convert some options to string, let rust to deserialize it to real config,\n     */\n    optionsToString(extensions);\n\n    delete config.extensions;\n\n    // SWC will crash if use jsc.target and env.targets together after bump\n    if (config.jsc?.target && config.env?.targets) {\n      console.warn(\n        \"[SWC] Do not use jsc.target and env.targets together, when used together only env.targets works\"\n      );\n      delete config.jsc.target;\n    }\n\n    try {\n      super({\n        swc: JSON.stringify(config),\n        extensions: extensions,\n      });\n    } catch (e) {\n      console.error(\"[@modern-js/swc-plugins] Failed to initialize config\");\n      throw e;\n    }\n  }\n}\n\nexports.Compiler = Compiler;\n\nexports.minify = function (filename, code, opt) {\n  return minify(JSON.stringify(opt), filename, code);\n};\n\nexports.minifySync = function (filename, code, opt) {\n  return minifySync(JSON.stringify(opt), filename, code);\n};\n\n/**\n *\n@type {(pluginImports: import('./types').ImportItem) => import('./types').ImportItemNapi}\n */\nfunction transformPluginImport(pluginImports) {\n  return pluginImports.map((pluginImport) => {\n    const {\n      libraryName,\n      libraryDirectory,\n      customName,\n      customStyleName,\n      style,\n      styleLibraryDirectory,\n      camelToDashComponentName,\n      camel2DashComponentName,\n      transformToDefaultImport,\n      ignoreEsComponent,\n      ignoreStyleComponent,\n    } = pluginImport;\n\n    const res = {\n      libraryName,\n      libraryDirectory,\n\n      customNameFn: maybe(\"function\", customName),\n      customNameTpl: maybe(\"string\", customName),\n      customStyleNameFn: maybe(\"function\", customStyleName),\n      customStyleNameTpl: maybe(\"string\", customStyleName),\n\n      style: {\n        styleLibraryDirectory: styleLibraryDirectory,\n        customFn: maybe(\"function\", style),\n        customTpl: style !== \"css\" ? maybe(\"string\", style) : undefined,\n        css: style === \"css\" ? style : undefined,\n        bool: maybe(\"boolean\", style),\n      },\n\n      camelToDashComponentName:\n        camelToDashComponentName ?? camel2DashComponentName, // default to true\n      transformToDefaultImport,\n\n      ignoreEsComponent,\n      ignoreStyleComponent,\n    };\n\n    return res;\n  });\n}\n\nfunction maybe(type, input) {\n  return typeof input === type ? input : undefined;\n}\n\nfunction boolToObj(input) {\n  if (typeof input === \"boolean\") {\n    return input ? {} : undefined;\n  }\n  return input;\n}\n\nfunction optionsToString(options) {\n  const styledComponents = boolToObj(options.styledComponents);\n  const emotion = boolToObj(options.emotion);\n\n  if (styledComponents && typeof styledComponents !== \"string\") {\n    options.styledComponents = JSON.stringify(styledComponents);\n  }\n\n  if (emotion && typeof emotion !== \"string\") {\n    options.emotion = JSON.stringify(emotion);\n  }\n}\n"]}