import e, { useContext as t, useRef as r, useEffect as o, useCallback as s } from "react";
import { cr as a, fk as i, fu as m, gx as n, gy as p, gz as c, dG as l, gA as d, fL as u, gB as j, gC as g, gD as h } from "./index-f50c05c4.js";
import { g as f } from "./shortcutConfigs-d5478626.js";
import { lA as C } from "./ant-design-icons-b1480d8d.js";
import "./axios-84bb1c75.js";
import "./redux-devtools-d38e5b33.js";
import "./alasql-0ff6dabf.js";
import "./react-router-a1807b5b.js";
import "./antd-04a23d13.js";
import "react-dom";
import "./dayjs-844325ae.js";
import "./lodash-f1e42446.js";
import "./fontawesome-2445f580.js";
import "./dnd-kit-56a2f36f.js";
import "./styled-components-1e696d6b.js";
import "./numbro-c1edb412.js";
import "./papaparse-1bac8e5f.js";
import "./uuid-82f303b2.js";
import "./supabase-c27c62e3.js";
import "./fetch-a3c8ad94.js";
import "./react-draggable-60f59f09.js";
import "./remark-gfm-f2973785.js";
import "./buffer-d3713d77.js";
import "./rehype-raw-41b6145f.js";
import "./parse5-6476676e.js";
import "./rehype-sanitize-deb53e9a.js";
import "./simplebar-react-e1b123a3.js";
import "./react-best-gradient-color-picker-4dd60dac.js";
import "./ua-parser-js-094f59ba.js";
import "./clsx-469c2c43.js";
import "./loglevel-6fb66d22.js";
import "./crypto-js-d5eac8ba.js";
import "./codemirror-73d8c217.js";
import "./really-relaxed-json-49b6a70d.js";
import "./immer-c0428a8d.js";
import "./redux-saga-5514e228.js";
import "./hotkeys-js-0dddb21a.js";
import "./cnchar-5678e6bc.js";
import "./react-documents-eb6de859.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-5125aafe.js";
import "./react-json-view-9403d8a1.js";
import "./qrcode-react-cb73d2b6.js";
import "./katex-a34f0265.js";
import "./ecogis-maps-bb0d63f9.js";
import "./devextreme-2fa5bb9a.js";
function b(e2, t2) {
  e2.setForceShowGrid(!!t2 && j(t2)), e2.setDisableInteract(!!t2 && g(t2));
}
const y = e.memo((e2) => {
  const c2 = t(a), { history: g2 } = t(i), { togglePanel: y2, panelStatus: v2, toggleShortcutList: w2 } = e2, S = m(), k = r(true);
  o(() => () => {
    k.current = false;
  }, []);
  const x = s((e3) => {
    k.current && (b(c2, e3), function(e4, t2, r2, o2, s2, a2) {
      switch (f(e4, "global")) {
        case "toggleLeftPanel":
          o2("left");
          break;
        case "toggleBottomPanel":
          o2("bottom");
          break;
        case "toggleRightPanel":
          o2("right");
          break;
        case "toggleAllPanels":
          o2();
          break;
        case "preview":
          u(a2);
          break;
        case "undo":
          r2 == null ? void 0 : r2.undo();
          break;
        case "redo":
          r2 == null ? void 0 : r2.redo();
          break;
        case "deleteComps":
          return void d.deleteComp(t2, t2.selectedComps());
        case "toggleShortcutList":
          return void s2();
        case "executeQuery": {
          const e5 = t2.selectedQueryComp();
          e5 == null ? void 0 : e5.dispatch(l({ afterExecFunc: () => t2.setShowResultCompName(e5.children.name.getView()) }));
          break;
        }
        default:
          return;
      }
      e4.stopPropagation(), e4.preventDefault();
    }(e3, c2, g2, y2, w2, S), c2.getAppSettingsComp().children.customShortcuts.handleKeyEvent(e3));
  }, [c2, g2, y2, w2, S]), D = s((e3) => {
    k.current && b(c2, e3);
  }, [c2]), N = s((e3) => {
    k.current && (b(c2, e3), function(e4, t2, r2) {
      if (!j(e4))
        return;
      const o2 = e4.target || e4.srcElement;
      if (!o2)
        return;
      if (o2.className !== h) {
        const e5 = o2.parentElement;
        if (!e5 || e5.className !== h)
          return;
      }
      r2();
      const s2 = o2.innerText;
      if (t2.getUICompByName(s2))
        return void t2.setSelectedCompNames(/* @__PURE__ */ new Set([s2]));
      const a2 = t2.getBottomResComp(s2);
      a2 && t2.setSelectedBottomRes(s2, a2.type());
    }(e3, c2, () => !v2.left && y2("left")));
  }, [c2, v2, y2]);
  return n(() => {
    k.current = false;
  }), C(p, { disabled: e2.disabled, onKeyDownCapture: x, onKeyUpCapture: D, onMouseMoveCapture: D, onMouseDownCapture: N, children: e2.children });
});
const v = e.memo((e2) => {
  const i2 = t(a), m2 = r(true);
  o(() => () => {
    m2.current = false;
  }, []);
  const p2 = s((e3) => {
    m2.current && function(e4, t2) {
      switch (f(e4, "editor")) {
        case "selectAllComps":
          return t2.setSelectedCompNames(new Set(Object.values(t2.getUIComp().getTopCompItems()).map((e5) => e5.children.name.getView()))), e4.preventDefault(), void e4.stopPropagation();
        case "copyComps":
          return void d.copyComp(t2, t2.selectedComps());
        case "pasteComps":
          return void d.pasteComp(t2);
        case "cutComps":
          return void d.cutComp(t2, t2.selectedComps());
        case "deselectComps":
          t2.setSelectedCompNames(/* @__PURE__ */ new Set());
      }
    }(e3, i2);
  }, [i2]);
  return n(() => {
    m2.current = false;
  }), C(c, { disabled: e2.disabled, onKeyDown: p2, style: { width: "100%", height: "100%" }, children: e2.children });
}), w = e.memo((e2) => {
  const i2 = t(a), m2 = r(true);
  o(() => () => {
    m2.current = false;
  }, []);
  const c2 = s((e3) => {
    m2.current && i2.getAppSettingsComp().children.customShortcuts.handleKeyEvent(e3);
  }, [i2]);
  return n(() => {
    m2.current = false;
  }), C(p, { onKeyDownCapture: c2, children: e2.children });
});
export {
  w as CustomShortcutWrapper,
  y as EditorGlobalHotKeys,
  v as EditorHotKeys
};
