import { RuleCategory } from "../ruleCategory" ; /**
 * CategorizedChange data in a format more easily consumed by Handlebars templates
 */ export type CategorizedChangeTemplateData = { ruleName : string ; category : RuleCategory ; change : { single ? : unknown ; multiple ? : [ unknown , unknown ] ; } ; } ; /**
 * Holds node change that is categorized by rules
 */ export class CategorizedChange { param ruleName param ruleEvent param category param change constructor ( public ruleName , public ruleEvent , public category , public change ? ) { if ( category !== RuleCategory . IGNORED && ! change ) { throw new Error ( "Changed values are required" ) ; } } /**
     * Returns data in a format more easily consumed by Handlebars templates
     */ getTemplateData ( ) { const change = { } ; if ( this . change ) { const values = this . change . filter ( ( v ) => v !== undefined ) ; if ( values . length === 2 ) { change . multiple = values as [ unknown , unknown ] ; } else if ( values . length === 1 ) { change . single = values [ 0 ] ; } } return { change , category : this . category , ruleName : this . ruleName , } ; } }