```ts
export function matchSetting(rules: Record<string, string>, name: string): string | null {
  if (typeof rules !== 'object' || !rules || typeof name !== 'string' || !name) {
    throw new Error('Invalid arguments');
  }

  const isWildcard = (selector: string): boolean => selector === '*' || selector.endsWith('.*');

  const matchSelector = (selector: string, name: string): [boolean, string] | null => {
    const splitName = name.split('.');
    if (splitName.length < 2) return null;

    for (let i = 0; i <= splitName.length - 2; i++) {
      const prefix = splitName.slice(0, i + 1).join('.');
      const rulePrefix = selector.replace('*.*', '');

      if (rulePrefix === prefix || rulePrefix.startsWith(prefix) && rulePrefix.endsWith('.*')) {
        return [true, rules[prefix] || ''];
      }
    }

    return null;
  };

  for (const [selector, value] of Object.entries(rules)) {
    if (!isWildcard(selector) && matchSelector(selector, name)) {
      return rules[name];
    }
  }

  const wildcardMatch = matchSelector('*', name);
  if (wildcardMatch && wildcardMatch[0]) {
    return wildcardMatch[1];
  }

  return null;
}
```