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

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

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

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

import "lit";

import "lit/directives/when.js";

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

const mapTypesToComboboxItemModel = t => {
  if (!t || !Array.isArray(t)) {
    return [];
  }
  const e = [];
  t.forEach((t => {
    const s = {
      value: t.type,
      caption: t.type
    };
    e.push(s);
  }));
  return e;
};

const h = "button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;grid-template-rows:1fr max-content;overflow:auto}.section{display:contents}.main{grid-auto-rows:max-content}.source-container{display:grid;grid-template-columns:1fr max-content;gap:var(--spacing-gap-m)}.footer{margin-block-start:16px}";

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

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

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

const C = [ "resets/box-sizing", "utils/form--full", "utils/layout", "utils/typography", "utils/spacing", "chameleon/scrollbar" ];

const E = c({
  category: "gemini-tools",
  name: "show-more-horizontal",
  colorType: "on-surface"
});

const _ = class {
  constructor(o) {
    t(this, o);
    this.componentDidRenderFirstTime = e(this, "componentDidRenderFirstTime", 7);
    f.set(this, void 0);
    p.set(this, false);
    u.set(this, []);
    m.set(this, s(`./gx-ide-assets/edit-module-server/shortcuts.json`));
    w.set(this, void 0);
    b.set(this, void 0);
    y.set(this, void 0);
    v.set(this, void 0);
    g.set(this, void 0);
    k.set(this, void 0);
    W.set(this, (async () => {
      await this.cancelCallback();
    }));
    M.set(this, (async () => {
      if (this.confirmCallback) {
        const t = this.types.find((({type: t}) => t === this.selectedType));
        let e = {};
        if (t.type === "remote") {
          e = {
            id: t.id,
            name: l(this, b, "f").value,
            type: l(this, v, "f").value,
            authenticated: t.authenticated,
            source: l(this, g, "f").value,
            user: l(this, k, "f").value,
            password: l(this, y, "f").value
          };
        } else {
          e = {
            id: t.id,
            name: l(this, b, "f").value,
            type: l(this, v, "f").value,
            authenticated: t.authenticated,
            source: l(this, g, "f").value
          };
        }
        await this.confirmCallback(e);
      }
    }));
    x.set(this, (t => {
      this.selectedType = t.detail;
    }));
    j.set(this, (() => i("footer", {
      class: "footer dialog-footer dialog-footer-with-border spacing-body-block-end spacing-body-inline"
    }, i("div", {
      class: "buttons-spacer"
    }, i("button", {
      class: "button-secondary",
      id: "button-cancel",
      onClick: l(this, W, "f"),
      part: "button-cancel"
    }, l(this, f, "f").footer.btnCancel), i("button", {
      class: "button-primary",
      id: "button-create",
      onClick: l(this, M, "f"),
      part: "button-create"
    }, l(this, f, "f").footer.btnConfirm)))));
    F.set(this, (() => i(a, null, i("label", {
      class: "label",
      htmlFor: "user"
    }, l(this, f, "f").user), i("ch-edit", {
      id: "user",
      part: "user",
      class: "input",
      placeholder: l(this, f, "f").user,
      ref: t => d(this, k, t, "f")
    }), i("label", {
      class: "label",
      htmlFor: "password"
    }, l(this, f, "f").password), i("ch-edit", {
      id: "password",
      part: "password",
      class: "input",
      placeholder: l(this, f, "f").password,
      ref: t => d(this, y, t, "f")
    }))));
    T.set(this, (async () => {
      if (this.selectSourceCallback) {
        const t = await this.selectSourceCallback();
        if (t) {
          l(this, g, "f").value = t;
        }
      }
    }));
    this.selectedType = "local";
    this.cancelCallback = undefined;
    this.confirmCallback = undefined;
    this.name = undefined;
    this.selectSourceCallback = undefined;
    this.source = undefined;
    this.type = undefined;
    this.types = undefined;
  }
  async componentWillLoad() {
    d(this, f, await n.getComponentStrings(this.el), "f");
    d(this, u, mapTypesToComboboxItemModel(this.types), "f");
    if (this.types && this.types.length > 0) {
      this.selectedType = this.types[0].type;
    }
  }
  componentDidRender() {
    if (!l(this, p, "f")) {
      this.componentDidRenderFirstTime.emit(l(this, f, "f").componentName);
      d(this, p, true, "f");
    }
  }
  /**
     * Suspends or reactivates the shortcuts
     */  async suspendShortcuts(t) {
    if (t) {
      l(this, w, "f").suspend = true;
    } else {
      l(this, w, "f").suspend = false;
    }
  }
  render() {
    const t = this.selectedType === "local";
    const e = i("ch-edit", {
      placeholder: l(this, f, "f").source,
      ref: t => d(this, g, t, "f"),
      value: this.source,
      class: "input",
      part: "source",
      id: "source"
    });
    const s = i("button", {
      class: "button-tertiary button-icon-only",
      "aria-label": "caption",
      onClick: l(this, T, "f")
    }, i("ch-image", {
      class: "icon-m",
      src: E
    }));
    return i(o, {
      class: "widget"
    }, i("ch-theme", {
      model: C
    }), i("ch-shortcuts", {
      src: l(this, m, "f"),
      ref: t => d(this, w, t, "f")
    }), i("section", {
      class: "section"
    }, i("main", {
      class: "main field-group-justified-start"
    }, i("label", {
      class: "label",
      htmlFor: "server-type"
    }, l(this, f, "f").type), i("ch-combo-box-render", {
      accessibleName: "server types",
      id: "server-type",
      part: "server-type",
      class: "combo-box",
      model: l(this, u, "f"),
      value: this.selectedType,
      onChange: l(this, x, "f"),
      ref: t => d(this, v, t, "f")
    }), i("label", {
      class: "label",
      htmlFor: "name"
    }, l(this, f, "f").name), i("ch-edit", {
      placeholder: l(this, f, "f").name,
      ref: t => d(this, b, t, "f"),
      value: this.name,
      part: "name",
      class: "input",
      id: "name"
    }), i("label", {
      class: "label",
      htmlFor: "source"
    }, l(this, f, "f").source), t ? i("div", {
      class: "source-container"
    }, [ e, s ]) : e, this.selectedType === "remote" && l(this, F, "f").call(this)), l(this, j, "f").call(this)));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/edit-module-server" ];
  }
  get el() {
    return r(this);
  }
};

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

_.style = h;

export { _ as gx_ide_edit_module_server };
//# sourceMappingURL=p-0be24413.entry.js.map