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MAAK,KACJ,iBAAiB,EAAa,IAE/B,MAAK,WACJ,OAAO,KACL,EACA,EACA,KAAK,KAAK,EAxGI,cAyGd,EACA,GACA,KAAK,aAAa,GACtB,GACJ,GACF,GACF","file":"/npm/css-in-elm@2.1.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/css-in-elm@2.1.0/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","//@flow\n\nconst _ = require(\"lodash\"),\n  path = require(\"path\"),\n  glob = require(\"glob\"),\n  mkdirp = require(\"mkdirp\").mkdirp,\n  findExposedValues = require(\"./js/find-exposed-values\").findExposedValues,\n  writeGeneratedElmPackage = require(\"./js/generate-elm-package\"),\n  writeMain = require(\"./js/generate-main\").writeMain,\n  writeFile = require(\"./js/generate-class-modules\").writeFile,\n  findElmFiles = require(\"./js/find-elm-files\"),\n  compileAll = require(\"./js/compile-all\"),\n  fs = require(\"fs-extra\"),\n  compile = require(\"node-elm-compiler\").compile,\n  extractCssResults = require(\"./js/extract-css-results.js\"),\n  hackMain = require(\"./js/hack-main.js\");\n\nconst jsEmitterFilename = \"emitter.js\";\n\nmodule.exports = function (\n  projectDir /*: string*/,\n  outputDir /*: string */,\n  pathToMake /*: ?string */\n) {\n  const cssSourceDir = path.join(projectDir, \"css\");\n  const cssElmPackageJson = path.join(cssSourceDir, \"elm.json\");\n\n  if (!fs.existsSync(cssElmPackageJson)) {\n    mkdirp.sync(cssSourceDir);\n\n    // TODO do an init here\n  }\n\n  const elmFilePaths = findElmFiles(cssSourceDir);\n  const generatedDir = path.join(\n    projectDir,\n    \"elm-stuff\",\n    \"generated-code\",\n    \"ThinkAlexandria\",\n    \"css-in-elm\"\n  );\n\n  // Symlink our existing elm-stuff into the generated code,\n  // to avoid re-downloading and recompiling things we already\n  // just downloaded and compiled.\n  var generatedElmStuff = path.join(generatedDir, \"elm-stuff\");\n\n  mkdirp.sync(generatedDir);\n  // ensure the elm-stuff directory in the css/ folder exists so we can symlink\n  // it. If it does not exist `elm` has probably not downloaded the required\n  // packages yet and will do so automatically.\n  var cssSourceDirElmStuff = path.join(cssSourceDir, \"elm-stuff\");\n  mkdirp.sync(cssSourceDirElmStuff);\n\n  try {\n    // Check if the symlink itself exists (not following it)\n    const stats = fs.lstatSync(generatedElmStuff);\n\n    if (!stats.isSymbolicLink()) {\n      console.log(\n        \"Path exists but is not a symlink. Removing it and creating symlink.\"\n      );\n      fs.rmSync(generatedElmStuff, { recursive: true, force: true });\n      return;\n    } else {\n      // console.error(\"symlink exists\");\n    }\n  } catch (error) {\n    if (error.code === \"ENOENT\") {\n      fs.symlinkSync(\n        path.join(cssSourceDir, \"elm-stuff\"),\n        generatedElmStuff,\n        \"junction\" // Only affects Windows, but necessary for this to work there. See https://github.com/gulpjs/vinyl-fs/issues/210\n      );\n    } else {\n      console.error(\"An error occurred:\", error);\n      return;\n    }\n  }\n\n  const generatedSrc = path.join(generatedDir, \"src\");\n  const mainFilename = path.join(generatedSrc, \"Main.elm\");\n\n  const makeGeneratedSrcDir = new Promise(function (resolve, reject) {\n    mkdirp(generatedSrc).then(resolve).catch(reject);\n  });\n\n  return Promise.all([\n    writeGeneratedElmPackage(generatedDir, generatedSrc, cssSourceDir),\n    makeGeneratedSrcDir,\n    compileAll(pathToMake, cssSourceDir, elmFilePaths),\n  ]).then(function (promiseOutputs) {\n    const repository /*: string */ = promiseOutputs[0];\n\n    // This part below is not used because we are using the Stylesheets.elm input format\n    // instead of generating our own Main.elm file\n    //\n    // Not quite sure what findExposedValues is doing, the format of the elmi\n    // files has changed in 0.19, so it will never return results right now\n    // anyway\n    return findExposedValues(\n      [\"Css.File.UniqueClass\", \"Css.Snippet\"],\n      generatedDir,\n      elmFilePaths,\n      [cssSourceDir],\n      true\n    ).then(function (modules) {\n      return Promise.all(\n        [writeMain(mainFilename, modules)].concat(\n          modules.map(function (modul) {\n            return writeFile(path.join(generatedDir, \"styles\"), modul);\n          })\n        )\n      )\n        .then(() => {\n          writePackageJson(generatedDir);\n        })\n        .then(function () {\n          return emit(\n            mainFilename,\n            repository,\n            path.join(generatedDir, jsEmitterFilename),\n            generatedDir,\n            pathToMake\n          ).then(writeResults(outputDir));\n        });\n    });\n  });\n};\n\nfunction writePackageJson(directory) {\n  const packageJsonPath = path.join(directory, \"package.json\");\n  const packageJsonContent = JSON.stringify(\n    {\n      type: \"commonjs\",\n    },\n    null,\n    2\n  );\n  console.log(\"Writing package.json to\", packageJsonPath);\n\n  return fs.writeFile(packageJsonPath, packageJsonContent);\n}\n\nfunction emit(\n  src /*: string */,\n  repository /*: string */,\n  dest /*: string */,\n  cwd /*: string */,\n  pathToMake /*: ?string */\n) {\n  // Compile the js file.\n  return (\n    compileEmitter(src, {\n      output: dest,\n      cwd: cwd,\n      // Because we upgraded the version of node-elm-compiler, it only supports\n      // Elm 0.19 now. So if we want to still support Elm 0.18 we would might need to\n      // vendor node-elm-compiler\n      pathToElm: pathToMake,\n    })\n      //.then(function() {\n      //  return hackMain(repository, dest);\n      //})\n      .then(function () {\n        return extractCssResults(dest);\n      })\n  );\n}\n\nfunction writeResults(outputDir) {\n  return function (results) {\n    return Promise.all(results.map(writeResult(outputDir)));\n  };\n}\n\nfunction writeResult(outputDir) {\n  return function (result) {\n    return new Promise(function (resolve, reject) {\n      const filename = path.join(outputDir, result.filename);\n      // It's important to call path.dirname explicitly,\n      // because result.filename can have directories in it!\n      const directory = path.dirname(filename);\n\n      mkdirp(directory)\n        .catch(reject)\n        .then(function () {\n          fs.writeFile(\n            filename,\n            result.content + \"\\n\",\n            function (fileError, file) {\n              if (fileError) return reject(fileError);\n\n              resolve(result);\n            }\n          );\n        });\n    });\n  };\n}\n\nfunction reportFailures(failures) {\n  return (\n    \"The following errors occurred during compilation:\\n\\n\" +\n    failures\n      .map(function (result) {\n        return result.filename + \": \" + result.content;\n      })\n      .join(\"\\n\\n\")\n  );\n}\n\nfunction compileEmitter(src, options) {\n  return new Promise(function (resolve, reject) {\n    compile(src, options).on(\"close\", function (exitCode) {\n      if (exitCode === 0) {\n        resolve();\n      } else {\n        reject(\"Errored with exit code \" + exitCode);\n      }\n    });\n  });\n}\n"]}