export function disposiciones(init = {}) {
  return {
    rows: Array.isArray(init.items) ? init.items : [],
    addRow() {
      this.rows.push({ item: '', ponderado: '0,0', cumple: '', observaciones: '' });
      this.$nextTick(() => {
        const last = this.$refs?.lastObs; if (last) last.focus();
      });
    },
    removeRow(i) { this.rows.splice(i,1); },
    sumPonderado() {
      return this.rows.reduce((acc, r) => {
        const n = parseFloat(String(r.ponderado || '0').replace(',', '.'));
        return acc + (isNaN(n) ? 0 : n);
      }, 0).toFixed(1);
    },
  };
}
