//
//  LKFMetaDataItem.swift
//  LKF
//
//  Created by Alexander Holzer on 02.05.25.
//  Copyright © 2025 Alexander Holzer. All rights reserved.
//

import Foundation

open class LKFMetaDataItem {
    open var itemKey: String { return "" }
    open var itemDescription: String { return "" }
    
    open func getLowercasedSearchTexts() -> [String] {
        return []
    }
    
    var _lowercasedSearchTexts : [String]?
    var _itemKey: String?
    
    open func itemMatches (lowercasedSearchString: String) -> Bool {
        if _lowercasedSearchTexts == nil {
            _lowercasedSearchTexts = getLowercasedSearchTexts()
        }
        return _lowercasedSearchTexts!.first(where: { $0.contains(lowercasedSearchString) }) != nil
    }
    
    open func starts(with prefix: String) -> Bool {
        if (_itemKey == nil) {
            _itemKey = self.itemKey.lowercased()
        }
        return _itemKey!.starts(with: prefix)
    }
    
    public init() {
        
    }
}
