//
//  ESCCustomDescription.swift
//  PrinterDemo
//
//  Created by ldc on 2025/9/7.
//  Copyright © 2025 XiamenHY. All rights reserved.
//

import Foundation
import PrinterSDK

extension PTESCPrinterAutoStatus: @retroactive CustomStringConvertible {
    
    var descItems: [String] {
        var items = [String]()
        
        if contains(.offline) {
            items.append("offline")
        }
        
        if contains(.cutterError) {
            items.append("cutterError")
        }
        
        if contains(.coverOpen) {
            items.append("coverOpen")
        }
        
        if contains(.outOfPaper) {
            items.append("outOfPaper")
        }
        return items
    }
    
    public var description: String {
        
        return descItems.joined(separator: "|")
    }
    
}

extension S1ESCAutoReportPrinterStatus: @retroactive CustomStringConvertible {
    
    public var description: String {
        
        if isEmpty {
            return "打印机正常".localized
        }
        var items = [String]()
        if contains(.offline) {
            items.append("offline")
        }
        if contains(.cutterError) {
            items.append("cutterError")
        }
        
        if contains(.coverOpen) {
            items.append("coverOpen")
        }
        
        if contains(.outOfPaper) {
            items.append("outOfPaper")
        }
        return items.joined(separator: "|")
    }
}

extension ESCBeeperPattern: @retroactive CustomStringConvertible,@retroactive CaseIterable {
    public static var allCases: [ESCBeeperPattern] = [
        .A, .B, .C, .D, .E
    ]
    
    public var description: String {
        switch self {
        case .A: return "a"
        case .B: return "b"
        case .C: return "c"
        case .D: return "d"
        case .E: return "e"
        default: return String(self.rawValue)
        }
    }
}
