// #region Imports
// #endregion
// #region Constants
/**
 * A collection of common local/system fonts.
 */
const LOCAL_FONTS = [
    {
        id: 'arial',
        family: 'Arial',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'arial-black',
        family: 'Arial Black',
        category: 'sans-serif',
        source: 'local',
        variants: ['900'],
        subsets: ['latin']
    },
    {
        id: 'book-antiqua',
        family: 'Book Antiqua',
        category: 'serif',
        source: 'local',
        variants: ['regular', 'italic'],
        subsets: ['latin']
    },
    {
        id: 'calibri',
        family: 'Calibri',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'cambria',
        family: 'Cambria',
        category: 'serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'candara',
        family: 'Candara',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'century-gothic',
        family: 'Century Gothic',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'comic-sans-ms',
        family: 'Comic Sans MS',
        category: 'handwriting',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'consolas',
        family: 'Consolas',
        category: 'monospace',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'constantia',
        family: 'Constantia',
        category: 'serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'corbel',
        family: 'Corbel',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'courier-new',
        family: 'Courier New',
        category: 'monospace',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'dejavu-sans',
        family: 'DejaVu Sans',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'dejavu-serif',
        family: 'DejaVu Serif',
        category: 'serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'franklin-gothic',
        family: 'Franklin Gothic',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'futura',
        family: 'Futura',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'garamond',
        family: 'Garamond',
        category: 'serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'geneva',
        family: 'Geneva',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular'],
        subsets: ['latin']
    },
    {
        id: 'georgia',
        family: 'Georgia',
        category: 'serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'gill-sans',
        family: 'Gill Sans',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'helvetica',
        family: 'Helvetica',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'helvetica-neue',
        family: 'Helvetica Neue',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'impact',
        family: 'Impact',
        category: 'display',
        source: 'local',
        variants: ['regular'],
        subsets: ['latin']
    },
    {
        id: 'lucida-console',
        family: 'Lucida Console',
        category: 'monospace',
        source: 'local',
        variants: ['regular'],
        subsets: ['latin']
    },
    {
        id: 'lucida-grande',
        family: 'Lucida Grande',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'lucida-sans',
        family: 'Lucida Sans',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', 'italic'],
        subsets: ['latin']
    },
    {
        id: 'menlo',
        family: 'Menlo',
        category: 'monospace',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'monaco',
        family: 'Monaco',
        category: 'monospace',
        source: 'local',
        variants: ['regular'],
        subsets: ['latin']
    },
    {
        id: 'optima',
        family: 'Optima',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'palatino',
        family: 'Palatino',
        category: 'serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'palatino-linotype',
        family: 'Palatino Linotype',
        category: 'serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'rockwell',
        family: 'Rockwell',
        category: 'serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'san-francisco',
        family: 'San Francisco',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'segoe-ui',
        family: 'Segoe UI',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'system-ui',
        family: 'system-ui',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'tahoma',
        family: 'Tahoma',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'times-new-roman',
        family: 'Times New Roman',
        category: 'serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'trebuchet-ms',
        family: 'Trebuchet MS',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    },
    {
        id: 'ubuntu',
        family: 'Ubuntu',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'ubuntu-mono',
        family: 'Ubuntu Mono',
        category: 'monospace',
        source: 'local',
        variants: ['regular', '700'],
        subsets: ['latin']
    },
    {
        id: 'verdana',
        family: 'Verdana',
        category: 'sans-serif',
        source: 'local',
        variants: ['regular', 'italic', '700'],
        subsets: ['latin']
    }
].toSorted((a, b) => a.family.localeCompare(b.family));
// #endregion
/**
 * A font provider that serves local/system fonts.
 *
 * @public
 */
export class LocalFontProvider {
    // #region Fields
    _name = 'local';
    _displayName = 'Local Fonts';
    // #endregion
    // #region Properties
    /**
     * @inheritdoc
     */
    get name() {
        return this._name;
    }
    /**
     * Returns the provider ID. Alias for `name` for compatibility.
     */
    get id() {
        return this._name;
    }
    /**
     * @inheritdoc
     */
    get displayName() {
        return this._displayName;
    }
    // #endregion
    // #region Methods
    /**
     * @inheritdoc
     */
    async fetchFonts(request) {
        let filtered = LOCAL_FONTS;
        // Apply search filter
        if (request.searchText) {
            const normalizedQuery = request.searchText.toLowerCase().trim();
            filtered = filtered.filter((font) => font.family.toLowerCase().includes(normalizedQuery));
        }
        // Apply category filter
        if (request.category) {
            filtered = filtered.filter((font) => font.category === request.category);
        }
        // Apply starting letter filter
        if (request.startingLetter) {
            const normalizedLetter = request.startingLetter.toLowerCase();
            filtered = filtered.filter((font) => font.family.toLowerCase().startsWith(normalizedLetter));
        }
        // Apply pagination if specified
        const pageIndex = request.pageIndex ?? 0;
        const pageSize = request.pageSize ?? filtered.length;
        const start = pageIndex * pageSize;
        const paginated = filtered.slice(start, start + pageSize);
        return {
            fonts: paginated,
            totalCount: filtered.length
        };
    }
    /**
     * @inheritdoc
     */
    loadFont(font) {
        // Local fonts are already available on the system,
        // so we don't need to load them dynamically.
        // Return a no-op disposable.
        return {
            dispose: () => {
                // No-op for local fonts
            }
        };
    }
    /**
     * @inheritdoc
     */
    async isAvailable() {
        // Local fonts are always available
        return true;
    }
    /**
     * @inheritdoc
     */
    dispose() {
        // No resources to clean up for local font provider
    }
}
//# sourceMappingURL=LocalFontProvider.js.map