```typescript
/** Prune a file listing with ordered drop and keep rules. */

function segmentFits(pattern: string, text: string): boolean {
  let p = 0;
  let t = 0;
  let star = -1;
  let mark = 0;
  while (t < text.length) {
    if (p < pattern.length && pattern[p] === "*") {
      star = p;
      mark = t;
      p += 1;
    } else if (pattern[p] === text[t]) {
      p += 1;
      t += 1;
    } else if (star >= 0) {
      p = star + 1;
      mark += 1;
      t = mark;
    } else {
      return false;
    }
  }
  while (p < pattern.length && pattern[p] === "*") {
    p += 1;
  }
  return p === pattern.length;
}

function splitStrict(text: string, what: string): string[] {
  if (typeof text !== "string" || text === "") {
    throw new Error(`${what} must be a non-empty string`);
  }
  const segments = text.split("/");
  if (segments.some((segment) => segment === "")) {
    throw new Error(`${what} has an empty segment: ${text}`);
  }
  return segments;
}

export function pruneListing(listing: string[], rules: string[]): string[] {
  // Validate every rule and path with splitStrict
  const validatedRules = rules.map((rule) => {
    if (typeof rule !== "string" || rule === "") {
      throw new Error("Rule must be a non-empty string");
    }
    return splitStrict(rule, "rule");
  });

  const validatedListing = listing.map((path) => {
    if (typeof path !== "string" || path === "" || path[0] === "!") {
      throw new Error("Path must be a non-empty string and not start with !");
    }
    return splitStrict(path, "path");
  });

  // Prune the listing based on the rules
  return validatedListing.flatMap((path) => {
    for (const rule of validatedRules) {
      if (rule.length <= path.length && segmentFits(rule.join("/"), path.join("/"))) {
        return [path];
      }
    }
    return [];
  });
}
```