import { h as l } from "./p-9b9ccd0c.js";

import { C as e, r as a, I as r } from "./p-2eae8843.js";

import { f as t } from "./p-4d330836.js";

import { h as s } from "./p-9663f418.js";

import { c } from "./p-c5196b3b.js";

// stencil
const o = "button-action-custom-selector";

const n = {
  action: "action",
  description: "description",
  lastSynchronized: "lastSynchronized",
  localState: "localState",
  modifiedOn: "modifiedOn",
  module: "module",
  name: "name",
  status: "status",
  type: "type"
};

const renderStateCellContent = (e, a) => {
  let t;
  let s;
  let c;
  if (e === "deleted") {
    t = r.substract;
    s = a.states.deleted;
    c = "--color-icon-error-default";
  } else if (e === "inserted") {
    t = r.add;
    s = a.states.inserted;
    c = "--color-icon-success-default";
  } else if (e === "modified") {
    t = r.edit;
    s = a.states.modified;
    c = "--color-icon-warning-default";
  } else if (e === "conflicted") {
    t = r.warning;
    s = a.states.conflicted;
    c = "--color-icon-warning-default";
  } else if (!e) {
    // proably is "ignored"
    return null;
  }
  return l("span", {
    class: "custom-icon-text-wrapper"
  }, l("ch-image", {
    type: "mask",
    class: "icon-s",
    src: t,
    style: {
      backgroundColor: `var(${c})`
    }
  }), `${s}`);
};

const renderObjectStatus = (e, a, r, t, s) => {
  const c = a.get(e);
  const n = c === "pending" && r ? s.status.commit : s.status[c];
  if (c === "committing") {
    return l("span", {
      class: "spinner-caption"
    }, n);
  }
  const i = `pill pill--${c}`;
  if (r && c === "pending") {
    return l("button", {
      class: {
        "button-secondary": true,
        "button-icon-and-text": true,
        pill: true,
        "pill--update": true,
        [o]: true
      },
      onClick: t(e)
    }, n);
  } else {
    return l("span", {
      class: i
    }, n);
  }
};

const renderTabularGridRows = (c, o, n, i, u, d, m, g, b, f, p) => {
  let h;
  if (c === "pending") {
    h = o;
  } else if (c === "ignored") {
    h = n;
  }
  f = f.toLowerCase();
  const C = h.map((o => {
    const n = i.has(o.id);
    const h = n || c === "ignored";
    const C = u.has(o.id);
    const S = d.get(o.id);
    return l("ch-tabular-grid-row", {
      class: "tabular-grid-row",
      key: o.id,
      rowid: o.id,
      ref: l => C && (l === null || l === void 0 ? void 0 : l.setAttribute("marked", "true"))
    }, l("ch-tabular-grid-cell", {
      "cell-type": "rich",
      "row-selector": "true",
      class: {
        "tabular-grid-cell": true,
        "no-checkbox-custom-selector": h
      },
      size: "max-content"
    }, l("div", null, s(o.name, f))), l("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, a(o.type)), l("ch-tabular-grid-cell", {
      class: {
        "tabular-grid-cell": true,
        [e.GRID_CELL_DESCRIPTION]: true
      }
    }, l("div", null, s(o.description, f))), l("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, t(o.modifiedOn)), l("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, o.module), l("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, renderStateCellContent(o.state, p)), l("ch-tabular-grid-cell", {
      class: "tabular-grid-cell"
    }, t(o.lastSynchronized)), l("ch-tabular-grid-cell", {
      class: "tabular-grid-cell tabular-grid-cell--for-pill"
    }, renderObjectStatus(o.id, b, m, g, p)), (S === null || S === void 0 ? void 0 : S.length) && l("ch-tabular-grid-rowset", {
      class: "tabular-grid-rowset"
    }, l("ch-tabular-grid-rowset-empty", {
      class: {
        "tabular-grid-rowset-empty": true
      }
    }, l("ul", {
      class: "messages-list"
    }, S.map((e => {
      let a;
      if (e.type === "error") {
        a = r.error;
      } else if (e.type === "warning") {
        a = r.warning;
      } else if (e.type === "success") {
        a = r.success;
      } else {
        // info
        a = r.info;
      }
      return l("li", {
        class: "message-description"
      }, l("ch-image", {
        class: "icon-s message-icon",
        src: a
      }), e.text);
    }))))));
  }));
  return C;
};

const renderTabularGridColumns = (e, a = false, r, t, s, o) => {
  const i = a ? c.tabularGrid.colSize.auto : c.tabularGrid.colSize.maxContent;
  return l("ch-tabular-grid-columnset", {
    class: "tabular-grid-column-set"
  }, !e.includes("name") && l("ch-tabular-grid-column", {
    class: "tabular-grid-column",
    columnId: n.name,
    columnName: s.objects.name,
    columnType: "rich",
    richRowSelector: o,
    richRowSelectorMode: "mark",
    settingable: false,
    sortable: true,
    onColumnSortChanged: r,
    onColumnSelectorClicked: t,
    size: i
  }), !e.includes("type") && l("ch-tabular-grid-column", {
    class: "tabular-grid-column",
    columnId: n.type,
    columnName: s.objects.type,
    settingable: false,
    sortable: true,
    onColumnSortChanged: r,
    size: i
  }), !e.includes("description") && l("ch-tabular-grid-column", {
    class: "tabular-grid-column",
    columnId: n.description,
    columnName: s.objects.description,
    settingable: false,
    sortable: true,
    onColumnSortChanged: r,
    size: c.tabularGrid.colSize.description
  }), !e.includes("modifiedOn") && l("ch-tabular-grid-column", {
    class: "tabular-grid-column",
    columnId: n.modifiedOn,
    columnName: s.objects.modifiedOn,
    sortable: true,
    onColumnSortChanged: r,
    settingable: false,
    size: i
  }), !e.includes("module") && l("ch-tabular-grid-column", {
    class: "tabular-grid-column",
    columnId: n.module,
    columnName: s.objects.module,
    sortable: true,
    onColumnSortChanged: r,
    settingable: false,
    size: i
  }), !e.includes("localState") && l("ch-tabular-grid-column", {
    class: "tabular-grid-column",
    columnId: n.localState,
    columnName: s.objects.localState,
    sortable: false,
    settingable: false,
    size: i
  }), !e.includes("lastSynchronized") && l("ch-tabular-grid-column", {
    class: "tabular-grid-column",
    columnId: n.lastSynchronized,
    columnName: s.objects.lastSynchronized,
    settingable: false,
    sortable: true,
    onColumnSortChanged: r,
    size: i
  }), !e.includes("action") && l("ch-tabular-grid-column", {
    class: "tabular-grid-column",
    columnId: n.action,
    columnName: s.objects.action,
    sortable: false,
    settingable: false,
    size: i
  }), !e.includes("status") && l("ch-tabular-grid-column", {
    class: "tabular-grid-column",
    columnId: n.status,
    columnName: s.objects.status,
    sortable: false,
    settingable: false,
    size: a ? "auto" : "100px"
  }));
};

export { n as C, renderTabularGridRows as a, renderTabularGridColumns as r };
//# sourceMappingURL=p-e2b6d62b.js.map