{type:"func", params:[{name:"equipRef"}, {name:"debugMode", def:{type:"literal", val:true}}], body:{type:"block", exprs:[{type:"if", cond:{type:"not", operand:{type:"dotCall", target:{type:"var", name:"isRef"}, args:[{type:"var", name:"equipRef"}]}}, ifExpr:{type:"block", exprs:[{type:"throw", expr:{type:"literal", val:"'equipRef' is not a Ref"}}]}}, {type:"def", name:"recordsToDelete", val:{type:"list", vals:[]}}, {type:"def", name:"equip", val:{type:"call", target:{type:"var", name:"readById"}, args:[{type:"var", name:"equipRef"}]}}, {type:"assign", lhs:{type:"var", name:"recordsToDelete"}, rhs:{type:"dotCall", target:{type:"var", name:"add"}, args:[{type:"var", name:"recordsToDelete"}, {type:"var", name:"equip"}]}}, {type:"def", name:"points", val:{type:"call", target:{type:"var", name:"readAll"}, args:[{type:"and", lhs:{type:"var", name:"point"}, rhs:{type:"eq", lhs:{type:"var", name:"equipRef"}, rhs:{type:"trapCall", target:{type:"var", name:"trap"}, args:[{type:"var", name:"equip"}, {type:"literal", val:"id"}]}}}]}}, {type:"if", cond:{type:"dotCall", target:{type:"var", name:"isEmpty"}, args:[{type:"var", name:"points"}]}, ifExpr:{type:"block", exprs:[{type:"assign", lhs:{type:"var", name:"points"}, rhs:{type:"list", vals:[]}}]}, elseExpr:{type:"block", exprs:[{type:"assign", lhs:{type:"var", name:"points"}, rhs:{type:"dotCall", target:{type:"var", name:"toRecList"}, args:[{type:"var", name:"points"}]}}]}}, {type:"assign", lhs:{type:"var", name:"recordsToDelete"}, rhs:{type:"dotCall", target:{type:"var", name:"addAll"}, args:[{type:"var", name:"recordsToDelete"}, {type:"var", name:"points"}]}}, {type:"def", name:"refsToDelete", val:{type:"dotCall", target:{type:"var", name:"map"}, args:[{type:"var", name:"recordsToDelete"}, {type:"func", params:[{name:"r"}], body:{type:"trapCall", target:{type:"var", name:"trap"}, args:[{type:"var", name:"r"}, {type:"literal", val:"id"}]}}]}}, {type:"def", name:"refColNames", val:{type:"dotCall", target:{type:"var", name:"findAll"}, args:[{type:"dotCall", target:{type:"var", name:"colNames"}, args:[{type:"call", target:{type:"var", name:"readAll"}, args:[{type:"var", name:"id"}]}]}, {type:"func", params:[{name:"colName"}], body:{type:"dotCall", target:{type:"var", name:"endsWith"}, args:[{type:"var", name:"colName"}, {type:"literal", val:"Ref"}]}}]}}, {type:"def", name:"extraRecordsToDelete", val:{type:"list", vals:[]}}, {type:"dotCall", target:{type:"var", name:"each"}, args:[{type:"var", name:"refColNames"}, {type:"func", params:[{name:"refColName"}], body:{type:"block", exprs:[{type:"def", name:"records", val:{type:"call", target:{type:"var", name:"readAll"}, args:[{type:"call", target:{type:"var", name:"parseFilter"}, args:[{type:"var", name:"refColName"}]}]}}, {type:"def", name:"matchingRecords", val:{type:"dotCall", target:{type:"var", name:"findAll"}, args:[{type:"var", name:"records"}, {type:"func", params:[{name:"record"}], body:{type:"block", exprs:[{type:"def", name:"ref", val:{type:"dotCall", target:{type:"var", name:"get"}, args:[{type:"var", name:"record"}, {type:"var", name:"refColName"}]}}, {type:"call", target:{type:"var", name:"utilsAssert"}, args:[{type:"dotCall", target:{type:"var", name:"isRef"}, args:[{type:"var", name:"ref"}]}, {type:"add", lhs:{type:"add", lhs:{type:"add", lhs:{type:"literal", val:"Invalid ref '"}, rhs:{type:"var", name:"refColName"}}, rhs:{type:"literal", val:"' on record "}}, rhs:{type:"dotCall", target:{type:"var", name:"toAxonCode"}, args:[{type:"trapCall", target:{type:"var", name:"trap"}, args:[{type:"var", name:"record"}, {type:"literal", val:"id"}]}]}}]}, {type:"dotCall", target:{type:"var", name:"contains"}, args:[{type:"var", name:"refsToDelete"}, {type:"var", name:"ref"}]}]}}]}}, {type:"if", cond:{type:"not", operand:{type:"dotCall", target:{type:"var", name:"isEmpty"}, args:[{type:"var", name:"matchingRecords"}]}}, ifExpr:{type:"block", exprs:[{type:"assign", lhs:{type:"var", name:"extraRecordsToDelete"}, rhs:{type:"dotCall", target:{type:"var", name:"addAll"}, args:[{type:"var", name:"extraRecordsToDelete"}, {type:"dotCall", target:{type:"var", name:"toRecList"}, args:[{type:"var", name:"matchingRecords"}]}]}}]}}]}}]}, {type:"def", name:"allRecordsToDelete", val:{type:"dotCall", target:{type:"var", name:"readByIds"}, args:[{type:"dotCall", target:{type:"var", name:"unique"}, args:[{type:"dotCall", target:{type:"var", name:"map"}, args:[{type:"dotCall", target:{type:"var", name:"addAll"}, args:[{type:"var", name:"recordsToDelete"}, {type:"var", name:"extraRecordsToDelete"}]}, {type:"func", params:[{name:"r"}], body:{type:"trapCall", target:{type:"var", name:"trap"}, args:[{type:"var", name:"r"}, {type:"literal", val:"id"}]}}]}]}]}}, {type:"if", cond:{type:"var", name:"debugMode"}, ifExpr:{type:"block", exprs:[{type:"return", expr:{type:"dotCall", target:{type:"var", name:"removeEmptyColumns"}, args:[{type:"var", name:"allRecordsToDelete"}]}}]}, elseExpr:{type:"block", exprs:[{type:"return", expr:{type:"call", target:{type:"var", name:"commit"}, args:[{type:"dotCall", target:{type:"var", name:"map"}, args:[{type:"var", name:"allRecordsToDelete"}, {type:"func", params:[{name:"r"}], body:{type:"call", target:{type:"var", name:"diff"}, args:[{type:"var", name:"r"}, {type:"dict", names:["trash"], vals:[{type:"literal", val}]}]}}]}]}}]}}]}}