import { r as t, c as i, g as a, h as e, H as s, a as n } from "./p-9b9ccd0c.js";

import { g as o } from "./p-d42e842b.js";

import "./p-6534555e.js";

import "lit";

import "lit/directives/when.js";

import "lit/directives/if-defined.js";

import { L as r } from "./p-311eedf3.js";

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

const c = ":host{display:grid;block-size:100%}.opacity-0{opacity:0}.gxi-hidden{display:none !important}.align-center{display:flex;align-items:center}.align-end{display:flex;align-items:end}.overflow-auto{overflow:auto}:host(.gx-ide-component){height:100% !important;display:flex !important;flex-direction:column !important}.gx-ide-main-wrapper{color:var(--gx-ide-component-text-color);font-weight:var(--font-style-regular);font-size:var(--font-size-body-m);font-family:var(--font-family-body);height:100%;display:flex;flex-direction:column;flex-grow:1;box-sizing:border-box}.buttons-container{display:flex;gap:var(--spacing-gap-m)}.giu-static-pill-icon-and-text,.giu-static-pill{background-color:var(--elevation-background-color, var(--color-accent-surface-elevation-1));padding-inline:var(--spacing-padding-m);color:var(--color-text-neutral-default);font-size:var(--font-size-body-s);line-height:var(--line-height-relaxed);font-weight:var(--font-style-regular);border-radius:4px;min-block-size:25px;display:inline-grid;align-items:center;pointer-events:none;inline-size:max-content}.giu-static-pill-icon-and-text{display:inline-grid;grid-auto-flow:column;grid-auto-columns:max-content;gap:var(--spacing-gap-m)}.tab-full-width-buttons::part(tab-list block-start),.tab-full-width-buttons::part(tab-list block-end){grid-auto-columns:1fr}.tab-full-width-buttons::part(tab block-start){justify-content:center}.tree-view::part(item__header){--icon__system_warning_warning--disabled:var(\n    --icon__system_warning_warning--enabled\n  )}.tabular-grid{--focus-outline-width:1px}button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;block-size:100%;grid-template-rows:max-content 1fr max-content;overflow:auto}.section{display:contents}.header{display:grid;grid-template-columns:1fr max-content}.data-mapping-grid-container,.data-mapping-grid-container .field{overflow:auto;block-size:100%}.tabular-grid-application-declaration{overflow:auto}ch-tabular-grid.empty-result::part(main){overflow:hidden}.pill-tag{min-inline-size:40px;margin-inline-end:8px;padding-block:1px;padding-inline:4px;border-radius:2px;text-align:center;font-size:var(--font-size-body-xs)}.tabular-grid-application-declaration ch-tabular-grid-cell:is(:nth-child(2)){--control-border-width:0;--control-border-color:transparent;--control-border-radius:0;padding-block:0;padding-inline:0;--control-padding-inline:var(--spacing-padding-l);--control-padding-block:6.5px;display:grid;align-items:stretch;justify-content:stretch;min-inline-size:0}.tabular-grid-application-declaration ch-tabular-grid-cell:is(:nth-child(2)):hover{outline:1px solid var(--color-border-primary-focused);outline-offset:calc(var(--size-2) * -1)}.tabular-grid-cell:nth-child(2){padding:0 !important;display:grid;align-items:stretch;justify-content:stretch;--ds-focus-border-width:none}.tabular-grid-cell:nth-child(3){padding:0 !important;align-items:center !important;justify-content:center !important}.tabular-grid{overflow:auto}";

var d = undefined && undefined.__classPrivateFieldGet || function(t, i, a, e) {
  if (a === "a" && !e) throw new TypeError("Private accessor was defined without a getter");
  if (typeof i === "function" ? t !== i || !e : !i.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return a === "m" ? e : a === "a" ? e.call(t) : e ? e.value : i.get(t);
};

var h = undefined && undefined.__classPrivateFieldSet || function(t, i, a, e, s) {
  if (e === "m") throw new TypeError("Private method is not writable");
  if (e === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
  if (typeof i === "function" ? t !== i || !s : !i.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return e === "a" ? s.call(t, a) : s ? s.value = a : i.set(t, a), a;
};

var p, u, f, g, b, m, w, y, v, x, k, M, z, W, j, _, C, T;

const I = [ "resets/box-sizing", "components/button", "components/combo-box", "components/icon", "components/tabular-grid", "utils/elevation", "utils/form", "utils/layout", "utils/spacing" ];

const E = o({
  category: "system",
  name: "add",
  colorType: "interactive"
});

const $ = o({
  category: "window-tools",
  name: "filter",
  colorType: "on-surface"
});

const D = o({
  category: "system",
  name: "more-horizontal",
  colorType: "primary"
});

const P = {
  alreadyProcessed: true,
  autoExpand: false,
  hideMatchesAndShowNonMatches: false,
  highlightMatchedItems: false,
  matchCase: false,
  regularExpression: false,
  strict: false,
  renderActiveItemIconOnExpand: true
};

const A = class {
  constructor(s) {
    t(this, s);
    this.componentDidRenderFirstTime = i(this, "componentDidRenderFirstTime", 7);
    /**
         * The component hard-coded strings translations.
         */
    // eslint-disable-next-line @stencil-community/own-props-must-be-private
        p.set(this, void 0);
    u.set(this, true);
    f.set(this, a(`./gx-ide-assets/bpm-app-declaration/shortcuts.json`));
    g.set(this, {
      // To be defined on componentWillLoad
      in: undefined,
      out: undefined,
      inout: undefined
    });
    b.set(this, (() => {
      d(this, g, "f").in = d(this, p, "f").dataMappings.access.in;
      d(this, g, "f").out = d(this, p, "f").dataMappings.access.out;
      d(this, g, "f").inout = d(this, p, "f").dataMappings.access.inout;
    }));
    m.set(this, (async t => {
      const i = t.detail;
      this.application.mappings = await this.getDataMappingCallback(i);
    }));
    w.set(this, (() => {
      this.cancelCallback();
    }));
    y.set(this, (() => {
      this.application = {
        application: {
          name: "",
          typeIcon: ""
        },
        mappings: []
      };
    }));
    v.set(this, (() => {
      this.confirmCallback(this.application);
    }));
    x.set(this, (t => t.map((t => ({
      caption: t,
      value: t
    })))));
    k.set(this, (t => t.map((t => ({
      caption: t,
      value: t
    })))));
    M.set(this, (t => async i => {
      const a = i.detail;
      this.application.mappings[t].relevantData = a;
    }));
    z.set(this, (async () => {
      const t = await this.selectApplicationCallback();
      if (t) {
        d(this, j, "f").call(this, t.application);
        this.application.mappings = t.mappings;
      }
    }));
    W.set(this, ((t, i) => async () => {
      const a = await this.selectMappingCallback(t);
      if (a) {
        const t = this.application.mappings[i].relevantDataOptions;
        const e = t.indexOf(a);
        if (e === -1) {
          // returnedRelevantData is a new option. Add to combo-box.
          t.push(a);
        }
        // Set as selected
                this.application.mappings[i].relevantData = a;
        d(this, C, "f").call(this);
      }
    }));
    j.set(this, (t => {
      if (t) {
        const i = t.name;
        this.application.application.name = i;
        this.applicationComboBoxModel = [ {
          caption: i,
          value: i,
          startImgSrc: t.typeIcon
        } ];
      }
    }));
    _.set(this, (async t => {
      const i = t.detail;
      this.application.application.name = i;
      const a = await this.suggestApplicationsCallback(i);
      this.applicationComboBoxModel = d(this, k, "f").call(this, a);
    }));
    C.set(this, (() => {
      this.application = Object.assign({}, this.application);
    }));
    // Renders
        T.set(this, (() => {
      var t;
      const i = this.application.mappings.length;
      if (i) {
        // Set as animated for the next time.
        h(this, u, true, "f");
      }
      return e("div", {
        class: "field-group data-mapping-grid-container"
      }, e("div", {
        class: "field field-block"
      }, e("label", {
        class: "spacing-body-inline-start label"
      }, d(this, p, "f").dataMappings.title), e("ch-tabular-grid", {
        class: {
          "tabular-grid": true,
          "tabular-grid-application-declaration": true,
          scrollable: true,
          "empty-result": !i
        },
        part: "ch-grid-data-mappings"
      }, e("ch-tabular-grid-columnset", {
        class: "tabular-grid-column-set"
      }, e("ch-tabular-grid-column", {
        class: "tabular-grid-column",
        columnName: ((t = this.application.application) === null || t === void 0 ? void 0 : t.typeIcon) === "objects/transaction" ? d(this, p, "f").dataMappings.firstColName : d(this, p, "f").dataMappings.firstColNameParameter,
        settingable: false,
        sortable: false,
        size: l.tabularGrid.colSize.common
      }), e("ch-tabular-grid-column", {
        class: "tabular-grid-column",
        columnName: d(this, p, "f").dataMappings.secondColName,
        settingable: false,
        sortable: false,
        size: l.tabularGrid.colSize.common
      }), e("ch-tabular-grid-column", {
        class: "tabular-grid-column",
        settingable: false,
        sortable: false,
        size: l.tabularGrid.colSize.auto
      })), this.application.mappings.length ? e("ch-tabular-grid-rowset", {
        class: "tabular-grid-rowset"
      }, this.application.mappings.map(((t, i) => e("ch-tabular-grid-row", {
        class: "tabular-grid-row",
        rowId: `${i}-${t.parameter}`,
        key: `${i}-${t.parameter}-grid-row`
      }, e("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, e("span", {
        class: "pill-tag elevation-3"
      }, d(this, g, "f")[t.access]), t.parameter), e("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, e("ch-combo-box-render", {
        class: "combo-box",
        model: d(this, x, "f").call(this, t.relevantDataOptions),
        value: t.relevantData,
        key: `${i}-${t.parameter}-combo-box`,
        onInput: d(this, M, "f").call(this, i)
      })), e("ch-tabular-grid-cell", {
        class: "tabular-grid-cell"
      }, e("button", {
        "data-index": i,
        onClick: d(this, W, "f").call(this, t.parameter, i),
        class: "button-tertiary button-icon-only",
        "aria-label": d(this, p, "f").buttons.selectMapping,
        title: d(this, p, "f").buttons.selectMapping
      }, e("ch-image", {
        class: "icon-m",
        src: E
      }))))))) : e("ch-tabular-grid-rowset", {
        class: "tabular-grid-rowset"
      }, e("ch-tabular-grid-rowset-empty", null, e("gx-ide-empty-state", {
        isAnimated: d(this, u, "f"),
        stateIconSrc: $,
        stateTitle: d(this, p, "f").emptyState.title,
        stateDescription: d(this, p, "f").emptyState.description
      }))))));
    }));
    this.applicationComboBoxModel = [];
    this.application = undefined;
    this.cancelCallback = undefined;
    this.confirmCallback = undefined;
    this.getDataMappingCallback = undefined;
    this.selectApplicationCallback = undefined;
    this.selectMappingCallback = undefined;
    this.suggestApplicationsCallback = undefined;
  }
  async componentWillLoad() {
    h(this, p, await r.getComponentStrings(this.el), "f");
    d(this, j, "f").call(this, this.application.application);
    if (this.application.mappings.length === 0) {
      h(this, u, false, "f");
    }
    d(this, b, "f").call(this);
  }
  render() {
    return e(s, {
      class: "widget"
    }, e("ch-theme", {
      model: I
    }), e("section", {
      class: "section"
    }, e("header", {
      slot: "header",
      class: "header spacing-body"
    }, e("ch-combo-box-render", {
      class: "combo-box",
      value: this.application.application.name,
      model: this.applicationComboBoxModel,
      suggestDebounce: l.inputDebounce,
      suggest: true,
      suggestOptions: P,
      onInput: d(this, _, "f"),
      onChange: d(this, m, "f")
    }), e("div", {
      class: "buttons-spacer"
    }, e("button", {
      onClick: d(this, z, "f"),
      class: "button-tertiary button-icon-only",
      "aria-label": d(this, p, "f").buttons.selectApplication,
      title: d(this, p, "f").buttons.selectApplication
    }, e("ch-image", {
      class: "icon-m",
      src: D
    })), e("button", {
      onClick: d(this, y, "f"),
      class: "button-secondary"
    }, "Clear"))), d(this, T, "f").call(this), e("footer", {
      class: "dialog-footer spacing-body-block-end spacing-body-inline"
    }, e("div", {
      class: "buttons-spacer"
    }, e("button", {
      class: "button-secondary",
      onClick: d(this, w, "f")
    }, d(this, p, "f").buttons.cancelButton), e("button", {
      class: "button-primary",
      onClick: d(this, v, "f")
    }, d(this, p, "f").buttons.confirmButton)))), e("ch-shortcuts", {
      src: d(this, f, "f")
    }));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/bpm-app-declaration" ];
  }
  get el() {
    return n(this);
  }
};

p = new WeakMap, u = new WeakMap, f = new WeakMap, g = new WeakMap, b = new WeakMap, 
m = new WeakMap, w = new WeakMap, y = new WeakMap, v = new WeakMap, x = new WeakMap, 
k = new WeakMap, M = new WeakMap, z = new WeakMap, W = new WeakMap, j = new WeakMap, 
_ = new WeakMap, C = new WeakMap, T = new WeakMap;

A.style = c;

export { A as gx_ide_bpm_app_declaration };
//# sourceMappingURL=p-4d7433e0.entry.js.map