/* eslint-disable no-console */

const fs = require('node:fs');
const path = require('node:path');

const postcss = require('postcss');

const root = postcss.parse(fs.readFileSync(path.join(__dirname, '../dist/css/neptune.css')));

/** @type {Set<string>} */
const selectors = new Set();

/**
 * @param {postcss.ChildNode} node
 */
function visitNode(node) {
  switch (node.type) {
    case 'rule': {
      for (const selector of node.selectors) {
        selectors.add(selector);
      }
      break;
    }
    case 'atrule': {
      for (const childNode of node.nodes) {
        visitNode(childNode);
      }
      break;
    }
    default:
  }
}

for (const node of root.nodes) {
  visitNode(node);
}

const sortedClassNameSelectors = [...selectors].filter((selector) => selector.includes('.')).sort();
console.log(JSON.stringify(sortedClassNameSelectors, null, 2));
