import { t as React, az as GetAddressUseKladr, aA as handleParameters, aB as getParamsObject, j as jsxRuntimeExports, G as Grid, aC as AddressParams, aD as getModalSectionID, B as Button, ab as formEdit } from "./index-D15x63tD.js";
function DialogAddress({ props }) {
  const [data, setData] = React.useState();
  const [useKladr, setUseKladr] = React.useState();
  const [objRef, setObjRef] = React.useState(props.ObjRef);
  React.useEffect(() => {
    getParams();
  }, []);
  async function getParams() {
    const json = await GetAddressUseKladr();
    json.service === "1" ? setUseKladr(true) : setUseKladr(false);
    const items = await handleParameters("address", { Token: "GetAddressInfo" }, void 0, props.ObjRef);
    if (items && items.Values) {
      setData(getParamsObject(items, "0", items.Caption));
    }
  }
  async function onSelect() {
    if (props.onEdit) {
      props.onEdit({
        tag: objRef,
        name: props.Name,
        record: props.record,
        textchanged: "0",
        setValue: props.setValue,
        setInputValue: props.setInputValue,
        type: props.Module,
        requestId: props.RequestID,
        addInfo: props.addInfo
      });
    }
    if (props.RequestID) {
      await formEdit("1", props.func, { Name: "ObjRef", Value: objRef }, props.RequestID, props.from);
    }
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { height: "100%", width: "100%" }, children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(
      Grid,
      {
        item: true,
        style: {
          height: "calc(100% - 50px)",
          width: "100%",
          border: "1px solid #cccccc"
        },
        children: /* @__PURE__ */ jsxRuntimeExports.jsx(
          AddressParams,
          {
            Module: "address",
            SectionID: getModalSectionID(),
            data,
            useKladr,
            setObjRef
          }
        )
      }
    ),
    /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, style: { height: "40px", width: "100%", marginTop: "10px" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Grid, { container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(
        Button,
        {
          size: "small",
          variant: "outlined",
          style: { textTransform: "none", marginRight: "10px" },
          value: "1",
          className: "button_Modal_Select",
          onClick: onSelect,
          children: "Выбрать"
        }
      ),
      /* @__PURE__ */ jsxRuntimeExports.jsx(
        Button,
        {
          size: "small",
          variant: "outlined",
          value: "2",
          style: { textTransform: "none", width: 75 },
          className: "button_Modal_Close",
          children: "Отмена"
        }
      )
    ] }) })
  ] }) });
}
export {
  DialogAddress as default
};
//# sourceMappingURL=DialogAddress-CN21lwvZ.js.map
