"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var fallback_exports = {};
__export(fallback_exports, {
  resourceRuleFallback: () => resourceRuleFallback
});
module.exports = __toCommonJS(fallback_exports);
var import_constants = require("./constants");
const resourceRuleFallback = (rules = []) => {
  const innerRules = [];
  const outerRules = [];
  for (const rule of rules) {
    if (!rule) {
      continue;
    }
    if (
      // "..." refers to the webpack defaults
      rule === "..." || // this is a special case, put the mjs fullySpecified rule in the outside
      rule.resolve && "fullySpecified" in rule.resolve && !rule.mimetype
    ) {
      outerRules.push(rule);
    } else if (rule.oneOf && !(rule.test || rule.exclude || rule.resource || rule.issuer || rule.mimetype)) {
      rule.oneOf.forEach((item) => {
        if (item) {
          innerRules.push(item);
        }
      });
    } else {
      innerRules.push(rule);
    }
  }
  const fileLoader = {
    exclude: [
      import_constants.JS_REGEX,
      import_constants.TS_REGEX,
      // exclude `html` and `json`, they get processed by webpack internal loaders.
      import_constants.HTML_REGEX,
      import_constants.JSON_REGEX
    ],
    type: "asset/resource"
  };
  return [...outerRules, { oneOf: [...innerRules, fileLoader] }];
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  resourceRuleFallback
});
