{"version":3,"file":"/Users/anthonygubler/development/dojo-org/parade/src/theme.block.ts","sourceRoot":"","sources":["../node_modules/@dojo/webpack-contrib/css-module-dts-loader/index.js?type=ts&instanceName=0_custom-elements!/Users/anthonygubler/development/dojo-org/parade/src/theme.block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMnC,MAAM,CAAC,OAAO,WAAU,MAAmC;IAC1D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;QAC3B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC;KAC3D,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE;QAC5D,MAAM,SAAS,GAAG,EAAS,CAAC;QAC5B,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,UAAU,EAAE;YACf,MAAM,OAAO,GAAG,UAAW,CAAC,qBAAqB,EAAE,CAAC;YACpD,OAAO,CAAC,OAAO,CAAC,CAAC,iBAAiB,EAAE,EAAE;gBACrC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,uBAAuB,EAAE,CAAC;gBACzE,MAAM,KAAK,GAAG,oBAAoB,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;gBACrE,IAAI,KAAK,EAAE;oBACV,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CACzB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAC3E,CAAC;oBACF,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;wBAClB,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;4BAC5B,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;yBACpB;6BAAM,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;4BAC9D,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;4BACvD,IAAI,QAAQ,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;gCACxC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;6BACjC;4BACD,OAAO,GAAG,EAAE,CAAC;yBACb;6BAAM;4BACN,OAAO,GAAG,EAAE,CAAC;yBACb;oBACF,CAAC,CAAC,CAAC;iBACH;YACF,CAAC,CAAC,CAAC;SACH;QACD,yBAAY,UAAU,IAAE,CAAC,UAAU,CAAC,EAAE,SAAS,IAAG;IACnD,CAAC,EAAE,EAAE,CAAC,CAAC;AACR,CAAC","sourcesContent":["import * as postcss from 'postcss';\nimport * as fs from 'fs';\nimport * as path from 'canonical-path';\nimport { Project } from 'ts-morph';\n\ninterface ThemeInterface {\n\t[index: string]: { [index: string]: string };\n}\n\nexport default function(config: { [index: string]: string }): ThemeInterface {\n\tconst project = new Project({\n\t\ttsConfigFilePath: path.join(process.cwd(), 'tsconfig.json')\n\t});\n\treturn Object.keys(config).reduce((properties, widgetName) => {\n\t\tconst classHash = {} as any;\n\t\tlet comment = '';\n\t\tconst filename = config[widgetName];\n\t\tconst sourceFile = project.getSourceFile(filename);\n\t\tif (sourceFile) {\n\t\t\tconst imports = sourceFile!.getImportDeclarations();\n\t\t\timports.forEach((importDeclaration) => {\n\t\t\t\tconst moduleSpecifierValue = importDeclaration.getModuleSpecifierValue();\n\t\t\t\tconst match = moduleSpecifierValue.match(/.*\\/theme\\/(.*\\.m\\.css)$/);\n\t\t\t\tif (match) {\n\t\t\t\t\tconst root = postcss.parse(\n\t\t\t\t\t\tfs.readFileSync(path.resolve(path.dirname(filename), moduleSpecifierValue))\n\t\t\t\t\t);\n\t\t\t\t\troot.walk((node) => {\n\t\t\t\t\t\tif (node.type === 'comment') {\n\t\t\t\t\t\t\tcomment = node.text;\n\t\t\t\t\t\t} else if (node.type === 'rule' && node.selector.match(/^\\./)) {\n\t\t\t\t\t\t\tconst selector = /^\\.[a-zA-Z0-9]*/.exec(node.selector);\n\t\t\t\t\t\t\tif (selector && !classHash[selector[0]]) {\n\t\t\t\t\t\t\t\tclassHash[selector[0]] = comment;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcomment = '';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcomment = '';\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\treturn { ...properties, [widgetName]: classHash };\n\t}, {});\n}\n"]}