var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
import { fE as e, fF as r, ac as o, fG as i, ec as t, f as n, e as a, ck as s, fH as c, v as l, fI as d, fJ as p, a9 as f, aa as h, fK as m, dM as u, fL as y, ey as b, fM as g } from "./index-f927b013.js";
import "./lodash-b5661970.js";
import { lz as x, lI as v, lJ as w } from "./ant-design-icons-6bfdc7d5.js";
import "./loglevel-b4003767.js";
import k, { useState as L, useContext as C, useEffect as I, Fragment as V } from "react";
import { u as q } from "./styled-components-7cfa37e6.js";
class j {
  constructor(e2, r2) {
    __publicField(this, "queryLibraryComp");
    __publicField(this, "setQueryLibraryState");
    this.queryLibraryComp = e2, this.setQueryLibraryState = r2;
  }
  changeStateFn(r2) {
    this.setQueryLibraryState((o2) => {
      const i2 = r2(o2);
      return e(o2, i2);
    });
  }
  setComp(e2) {
    this.changeStateFn((r2) => ({ queryLibraryComp: e2(r2.queryLibraryComp) }));
  }
  getNameGenerator() {
    const e2 = new t(), r2 = this.nameAndExposingInfo();
    return e2.init(Object.keys(r2)), e2;
  }
  nameAndExposingInfo() {
    return this.queryLibraryComp.nameAndExposingInfo();
  }
  checkRename(e2, i2) {
    const t2 = r(i2);
    return t2 || (i2 !== e2 && this.nameAndExposingInfo().hasOwnProperty(i2) ? o("query.nameExists", { name: i2 }) : "");
  }
  rename(e2, r2) {
    return !this.checkRename(e2, r2) && (r2 !== e2 && this.queryLibraryComp.dispatch(i(e2, r2)), true);
  }
}
const A = k.createContext(void 0), S = { name: c, description: l(""), value: d }, E = (e2) => {
  const [r2, i2] = L(e2.showPopover), t2 = C(A), n2 = e2.comp.children.name.getView();
  return v("div", { style: { position: "relative", width: "100%" }, children: [e2.comp.children.value.propertyView({ key: n2, label: x(p, { visible: r2, setVisible: i2, content: v(w, { children: [e2.comp.children.name.propertyView({ label: o("queryLibrary.inputName"), onValidate: (e3, r3) => t2.checkRename(e3, r3), onFinish: (e3, r3) => t2.rename(e3, r3) }), x(f, { label: o("queryLibrary.inputDesc"), children: x(h, { value: e2.comp.children.description.getView(), onChange: (r3) => {
    e2.comp.children.description.dispatchChangeValueAction(r3.target.value);
  } }) })] }), title: o("edit"), children: x("div", { style: { cursor: "pointer" }, children: n2 }) }), layout: "vertical", tooltip: e2.comp.children.description.getView() }), x(m, { items: [{ text: o("edit"), onClick: () => i2(true) }], del: e2.onDelete, children: x(O, { tabIndex: -1 }) })] });
}, F = g(class extends n(S) {
  propertyView(e2) {
    return x(E, { comp: this, ...e2 });
  }
}, {}, (e2) => e2.children.value.exposingNode()), N = q.div`
  padding: 0 16px;
`, O = q(y)`
  cursor: pointer;
  flex-shrink: 0;
  position: absolute;
  top: 0;
  right: 0;

  g {
    fill: #8b8fa3;
  }

  &:hover {
    background: #eef0f3;
    border-radius: 4px;
    cursor: pointer;

    g {
      fill: #3377ff;
    }
  }
`, P = q(b)`
  height: 28px;
  width: 70px;
  background-color: #fafbff;
  color: #4965f2;
  border-color: #c9d1fc;
  display: flex;
  align-items: center;
  box-shadow: none;

  &:hover {
    color: #315efb;
    background-color: #f5faff;
    border-color: #c2d6ff;
  }

  &:focus {
    color: #315efb;
    background-color: #f5faff;
    border-color: #c2d6ff;
  }

  &:disabled,
  &:disabled:hover {
    background: #f9fbff;
    border: 1px solid #dee9ff;
    border-radius: 4px;
  }
`, Q = q.div`
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
`, _ = a(s(F), (e2) => {
  const r2 = C(A), [i2, t2] = L(void 0);
  I(() => {
    t2(void 0);
  }, [e2]);
  const n2 = () => {
    e2.dispatch(e2.pushAction({ name: r2.getNameGenerator().genItemName("queryInput") })), t2(e2.getView().length);
  };
  return x(N, { children: e2.getView().length > 0 ? v(Q, { children: [e2.getView().map((r3, o2) => x(V, { children: r3.propertyView({ onDelete: () => e2.dispatch(e2.deleteAction(o2)), showPopover: o2 === i2 }) }, o2)), x(P, { onClick: n2, children: o("addItem") })] }) : x(u, { text: v(w, { children: [x("div", { children: o("queryLibrary.emptyInputs") }), x("span", { style: { color: "#4965f2", cursor: "pointer", margin: "0 4px" }, onClick: n2, children: o("queryLibrary.clickToAdd") })] }) }) });
}), D = Object.freeze(Object.defineProperty({ __proto__: null, InputListComp: _ }, Symbol.toStringTag, { value: "Module" }));
export {
  _ as I,
  A as Q,
  j as a,
  D as i
};
