import { filterValidOperandsArraySelectAsync as l } from "../subcomponents/FieldTypes/SelectAsyncFilter/helpers.js";
import { filterValidOperandsArraySelect as n } from "../subcomponents/FieldTypes/SelectFilter/helpers.js";
function a(d) {
  return d.map((e) => {
    let i, t = e.operand1, o = e.operand2;
    if (e.fieldType === "datetime")
      t = e.operand1.toISOString(), o = e.operator === "b" ? e.operand2.toISOString() : void 0;
    else if (e.fieldType === "selectAsync" && e.field.type === "selectAsync") {
      if (e.field.selectAsyncOptions.multiple) {
        const r = l(
          e.operandsArray,
          e.field
        );
        r && r?.length > 0 && (i = r);
      }
    } else if (e.fieldType === "select") {
      const r = n(
        e.operandsArray,
        e.field
      );
      r && r?.length > 0 && (i = r);
    }
    return {
      name: e.field.name,
      operator: e.operator,
      ...t !== void 0 ? { operand1: t } : {},
      ...o !== void 0 ? { operand2: o } : {},
      ...i !== void 0 ? { operandsArray: i } : {}
    };
  });
}
export {
  a as formatToInitialFilters
};
