"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.shouldSearchElementFileHints = void 0;
const GENERIC_SVG_TAGS = new Set([
    'circle',
    'ellipse',
    'g',
    'line',
    'path',
    'polygon',
    'polyline',
    'rect',
    'svg',
]);
const IDENTIFYING_ATTRS = ['href', 'data-testid', 'aria-label', 'name'];
const UTILITY_CLASS_PATTERN = /^(flex|grid|block|inline|hidden|p-\d+|px-\d+|py-\d+|m-\d+|mx-\d+|my-\d+|text-|bg-|w-\d+|h-\d+|rounded|border|shadow|hover:|focus:|active:|disabled:|opacity-|z-\d+|gap-\d+|space-|justify-|items-|cursor-|overflow-|relative|absolute|fixed|top-|left-|right-|bottom-)/;
const hasUsefulClassName = (className) => className
    .trim()
    .split(/\s+/)
    .some((token) => token.length > 2 && !UTILITY_CLASS_PATTERN.test(token));
/**
 * Decide whether a selected element has enough identity to safely search source files.
 * Generic SVG primitives like <rect> are too broad unless the client also sends
 * component, text, id, class, Rivet id, or identifying attributes.
 */
const shouldSearchElementFileHints = (element) => {
    const tagName = element.tagName.toLowerCase();
    const hasSpecificSignal = Boolean(element.rivetId?.trim()) ||
        Boolean(element.id?.trim()) ||
        hasUsefulClassName(element.className) ||
        Boolean(element.textContent?.trim()) ||
        Boolean(element.componentTree?.length) ||
        IDENTIFYING_ATTRS.some((attr) => Boolean(element.attributes?.[attr]));
    if (GENERIC_SVG_TAGS.has(tagName)) {
        return hasSpecificSignal;
    }
    return true;
};
exports.shouldSearchElementFileHints = shouldSearchElementFileHints;
//# sourceMappingURL=elementFileHintSignals.js.map