import { jsx as f, jsxs as _, Fragment as dr } from "react/jsx-runtime";
import Co, { createContext as Ph, useContext as Eo, forwardRef as Lh, createElement as ko, useState as U, useRef as xe, useMemo as _e, useEffect as le, useCallback as ce } from "react";
import tp, { useReactFlow as Ao, Handle as rc, Position as Er, useNodesState as np, useEdgesState as ap, MarkerType as at, addEdge as ip, ConnectionMode as sp, Background as op, Controls as cp } from "reactflow";
var de = /* @__PURE__ */ ((e) => (e.Single = "Single", e.Collection = "Collection", e.Fixed = "Fixed", e))(de || {}), pe = /* @__PURE__ */ ((e) => (e[e.BottomUp = 0] = "BottomUp", e[e.TopDown = 1] = "TopDown", e))(pe || {}), ir = /* @__PURE__ */ ((e) => (e.Room = "Room", e.Area = "Area", e.Global = "Global", e))(ir || {});
const tc = [
  { name: "Standard", color: "slate" },
  { name: "Emergency", color: "red", icon: "AlertTriangle" },
  { name: "VIP", color: "purple", icon: "Crown" },
  { name: "Temporary", color: "amber", icon: "Clock" },
  { name: "Night Shift", color: "indigo", icon: "Moon" },
  { name: "Restricted", color: "orange", icon: "ShieldAlert" },
  { name: "Maintenance", color: "blue", icon: "Wrench" }
], jh = Ph({
  groups: [],
  addGroup: () => {
  },
  updateGroup: () => {
  }
}), up = ({
  children: e,
  groups: r,
  onAddGroup: t,
  onUpdateGroup: n
}) => /* @__PURE__ */ f(jh.Provider, { value: { groups: r, addGroup: t, updateGroup: n }, children: e }), Dh = () => Eo(jh), To = Ph(null), Ty = ({
  children: e,
  repositories: r
}) => /* @__PURE__ */ f(To.Provider, { value: r, children: e }), lp = () => {
  const e = Eo(To);
  if (!e)
    throw new Error("useRepositories must be used within RepositoryProvider");
  return e;
}, dp = () => Eo(To);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const fp = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), hp = (e) => e.replace(
  /^([A-Z])|[\s-_]+(\w)/g,
  (r, t, n) => n ? n.toUpperCase() : t.toLowerCase()
), nc = (e) => {
  const r = hp(e);
  return r.charAt(0).toUpperCase() + r.slice(1);
}, Fh = (...e) => e.filter((r, t, n) => !!r && r.trim() !== "" && n.indexOf(r) === t).join(" ").trim(), pp = (e) => {
  for (const r in e)
    if (r.startsWith("aria-") || r === "role" || r === "title")
      return !0;
};
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
var mp = {
  xmlns: "http://www.w3.org/2000/svg",
  width: 24,
  height: 24,
  viewBox: "0 0 24 24",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 2,
  strokeLinecap: "round",
  strokeLinejoin: "round"
};
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const vp = Lh(
  ({
    color: e = "currentColor",
    size: r = 24,
    strokeWidth: t = 2,
    absoluteStrokeWidth: n,
    className: a = "",
    children: i,
    iconNode: o,
    ...s
  }, u) => ko(
    "svg",
    {
      ref: u,
      ...mp,
      width: r,
      height: r,
      stroke: e,
      strokeWidth: n ? Number(t) * 24 / Number(r) : t,
      className: Fh("lucide", a),
      ...!i && !pp(s) && { "aria-hidden": "true" },
      ...s
    },
    [
      ...o.map(([l, c]) => ko(l, c)),
      ...Array.isArray(i) ? i : [i]
    ]
  )
);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const $ = (e, r) => {
  const t = Lh(
    ({ className: n, ...a }, i) => ko(vp, {
      ref: i,
      iconNode: r,
      className: Fh(
        `lucide-${fp(nc(e))}`,
        `lucide-${e}`,
        n
      ),
      ...a
    })
  );
  return t.displayName = nc(e), t;
};
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const gp = [
  ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
  ["path", { d: "M19 12H5", key: "x3x0zl" }]
], bp = $("arrow-left", gp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const yp = [
  ["path", { d: "M5 12h14", key: "1ays0h" }],
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
], xp = $("arrow-right", yp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const _p = [
  [
    "path",
    {
      d: "M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",
      key: "hh9hay"
    }
  ],
  ["path", { d: "m3.3 7 8.7 5 8.7-5", key: "g66t2b" }],
  ["path", { d: "M12 22V12", key: "d0xqtd" }]
], fr = $("box", _p);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const wp = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], Ar = $("check", wp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Np = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], Ip = $("chevron-down", Np);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const qp = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], kp = $("chevron-right", qp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Sp = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]], Gh = $("chevron-left", Sp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Rp = [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
], Cp = $("circle-alert", Rp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Ep = [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
  ["path", { d: "M12 8v8", key: "napkw2" }],
  ["path", { d: "m8 12 4 4 4-4", key: "k98ssh" }]
], zh = $("circle-arrow-down", Ep);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Ap = [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
  ["path", { d: "m16 12-4-4-4 4", key: "177agl" }],
  ["path", { d: "M12 16V8", key: "1sbj14" }]
], Bh = $("circle-arrow-up", Ap);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Tp = [
  ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
  ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
], Mp = $("circle-check-big", Tp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Op = [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
], Pp = $("circle-check", Op);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Lp = [
  ["path", { d: "M12 6v6l4 2", key: "mmk7yg" }],
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
], vr = $("clock", Lp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const jp = [
  [
    "path",
    {
      d: "M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",
      key: "1vdc57"
    }
  ],
  ["path", { d: "M5 21h14", key: "11awu3" }]
], Uh = $("crown", jp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Dp = [
  ["path", { d: "M12 15V3", key: "m9g1x1" }],
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
  ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
], Fp = $("download", Dp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Gp = [
  [
    "path",
    {
      d: "M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6",
      key: "g5mvt7"
    }
  ],
  ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
  ["path", { d: "m14 20 2 2 4-4", key: "15kota" }]
], Mo = $("file-check-corner", Gp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const zp = [
  [
    "path",
    {
      d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
      key: "1oefj6"
    }
  ],
  ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
  ["path", { d: "M10 9H8", key: "b1mrlr" }],
  ["path", { d: "M16 13H8", key: "t4e002" }],
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
], Oo = $("file-text", zp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Bp = [
  [
    "path",
    {
      d: "M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",
      key: "sc7q7i"
    }
  ]
], Po = $("funnel", Bp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Up = [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
  ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
], $p = $("globe", Up);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Vp = [
  [
    "path",
    {
      d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
      key: "zw3jo"
    }
  ],
  [
    "path",
    {
      d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
      key: "1wduqc"
    }
  ],
  [
    "path",
    {
      d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
      key: "kqbvx6"
    }
  ]
], Hp = $("layers", Vp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Kp = [
  ["rect", { width: "7", height: "9", x: "3", y: "3", rx: "1", key: "10lvy0" }],
  ["rect", { width: "7", height: "5", x: "14", y: "3", rx: "1", key: "16une8" }],
  ["rect", { width: "7", height: "9", x: "14", y: "12", rx: "1", key: "1hutg5" }],
  ["rect", { width: "7", height: "5", x: "3", y: "16", rx: "1", key: "ldoo1y" }]
], Wp = $("layout-dashboard", Kp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Yp = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], $h = $("loader-circle", Yp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Jp = [
  ["path", { d: "m16 17 5-5-5-5", key: "1bji2h" }],
  ["path", { d: "M21 12H9", key: "dn1m92" }],
  ["path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4", key: "1uf3rs" }]
], Zp = $("log-out", Jp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Xp = [
  [
    "path",
    {
      d: "M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",
      key: "1r0f0z"
    }
  ],
  ["circle", { cx: "12", cy: "10", r: "3", key: "ilqhr7" }]
], Qp = $("map-pin", Xp);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const em = [
  [
    "path",
    {
      d: "M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",
      key: "kfwtm"
    }
  ]
], Vh = $("moon", em);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const rm = [
  ["rect", { x: "16", y: "16", width: "6", height: "6", rx: "1", key: "4q2zg0" }],
  ["rect", { x: "2", y: "16", width: "6", height: "6", rx: "1", key: "8cvhb9" }],
  ["rect", { x: "9", y: "2", width: "6", height: "6", rx: "1", key: "1egb70" }],
  ["path", { d: "M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3", key: "1jsf9p" }],
  ["path", { d: "M12 12V8", key: "2874zd" }]
], tm = $("network", rm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const nm = [
  ["path", { d: "M5 12h14", key: "1ays0h" }],
  ["path", { d: "M12 5v14", key: "s699le" }]
], gr = $("plus", nm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const am = [
  ["path", { d: "m15 14 5-5-5-5", key: "12vg1m" }],
  ["path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13", key: "6uklza" }]
], im = $("redo-2", am);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const sm = [
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
], om = $("refresh-cw", sm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const cm = [
  [
    "path",
    {
      d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
      key: "1c8476"
    }
  ],
  ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
  ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
], Hh = $("save", cm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const um = [
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
], Ye = $("search", um);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const lm = [
  [
    "path",
    {
      d: "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",
      key: "1i5ecw"
    }
  ],
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
], Lr = $("settings", lm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const dm = [
  ["circle", { cx: "18", cy: "5", r: "3", key: "gq8acd" }],
  ["circle", { cx: "6", cy: "12", r: "3", key: "w7nqdw" }],
  ["circle", { cx: "18", cy: "19", r: "3", key: "1xt0gg" }],
  ["line", { x1: "8.59", x2: "15.42", y1: "13.51", y2: "17.49", key: "47mynk" }],
  ["line", { x1: "15.41", x2: "8.59", y1: "6.51", y2: "10.49", key: "1n3mei" }]
], Kh = $("share-2", dm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const fm = [
  [
    "path",
    {
      d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
      key: "oel41y"
    }
  ],
  ["path", { d: "M12 8v4", key: "1got3b" }],
  ["path", { d: "M12 16h.01", key: "1drbdi" }]
], Wh = $("shield-alert", fm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const hm = [
  [
    "path",
    {
      d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
      key: "oel41y"
    }
  ],
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
], pm = $("shield-check", hm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const mm = [
  [
    "path",
    {
      d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
      key: "oel41y"
    }
  ]
], vm = $("shield", mm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const gm = [
  ["line", { x1: "10", x2: "14", y1: "2", y2: "2", key: "14vaq8" }],
  ["line", { x1: "12", x2: "15", y1: "14", y2: "11", key: "17fdiu" }],
  ["circle", { cx: "12", cy: "14", r: "8", key: "1e1u0o" }]
], bm = $("timer", gm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const ym = [
  ["path", { d: "M10 11v6", key: "nco0om" }],
  ["path", { d: "M14 11v6", key: "outv1u" }],
  ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
  ["path", { d: "M3 6h18", key: "d0wm0j" }],
  ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
], Je = $("trash-2", ym);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const xm = [
  [
    "path",
    {
      d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
      key: "wmoenq"
    }
  ],
  ["path", { d: "M12 9v4", key: "juzpu7" }],
  ["path", { d: "M12 17h.01", key: "p32p05" }]
], Ze = $("triangle-alert", xm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const _m = [
  ["path", { d: "M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978", key: "1n3hpd" }],
  ["path", { d: "M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978", key: "rfe1zi" }],
  ["path", { d: "M18 9h1.5a1 1 0 0 0 0-5H18", key: "7xy6bh" }],
  ["path", { d: "M4 22h16", key: "57wxv0" }],
  ["path", { d: "M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z", key: "1mhfuq" }],
  ["path", { d: "M6 9H4.5a1 1 0 0 1 0-5H6", key: "tex48p" }]
], wm = $("trophy", _m);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Nm = [
  ["path", { d: "M9 14 4 9l5-5", key: "102s5s" }],
  ["path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11", key: "f3b9sd" }]
], Im = $("undo-2", Nm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const qm = [
  ["path", { d: "M12 3v12", key: "1x0j5s" }],
  ["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
], km = $("upload", qm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Sm = [
  [
    "path",
    {
      d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",
      key: "1ngwbx"
    }
  ]
], Yh = $("wrench", Sm);
/**
 * @license lucide-react v0.555.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
const Rm = [
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
], Pe = $("x", Rm), Jh = {
  slate: { bg: "bg-slate-50", border: "border-slate-100", text: "text-slate-500" },
  red: { bg: "bg-red-50", border: "border-red-100", text: "text-red-700" },
  purple: { bg: "bg-purple-50", border: "border-purple-100", text: "text-purple-700" },
  amber: { bg: "bg-amber-50", border: "border-amber-100", text: "text-amber-700" },
  indigo: { bg: "bg-indigo-50", border: "border-indigo-100", text: "text-indigo-700" },
  orange: { bg: "bg-orange-50", border: "border-orange-100", text: "text-orange-700" },
  blue: { bg: "bg-blue-50", border: "border-blue-100", text: "text-blue-700" },
  emerald: { bg: "bg-emerald-50", border: "border-emerald-100", text: "text-emerald-700" },
  teal: { bg: "bg-teal-50", border: "border-teal-100", text: "text-teal-700" },
  pink: { bg: "bg-pink-50", border: "border-pink-100", text: "text-pink-700" }
}, Cm = Jh.slate, Em = {
  AlertTriangle: Ze,
  Crown: Uh,
  Clock: vr,
  Moon: Vh,
  ShieldAlert: Wh,
  Wrench: Yh
}, Am = ({ id: e, data: r, selected: t }) => {
  var y, w;
  const { setNodes: n } = Ao(), { groups: a } = Dh(), [i, o] = U(!1), [s, u] = U(r.name), l = xe(null), c = r.isActive, d = _e(
    () => a.find((I) => I.name === r.group),
    [a, r.group]
  ), h = (d == null ? void 0 : d.color) && Jh[d.color] || Cm, p = d != null && d.icon ? Em[d.icon] : void 0;
  le(() => {
    u(r.name);
  }, [r.name]);
  const x = (I) => {
    I == null || I.stopPropagation(), o(!0), u(r.name);
  }, v = () => {
    o(!1), u(r.name);
  }, m = () => {
    s.trim() && s !== r.name && n((I) => I.map((q) => q.id === e ? { ...q, data: { ...q.data, name: s } } : q)), o(!1);
  }, b = (I) => {
    I.key === "Enter" && (I.preventDefault(), I.stopPropagation(), m()), I.key === "Escape" && (I.preventDefault(), I.stopPropagation(), v());
  };
  le(() => {
    i && l.current && (l.current.focus(), l.current.select());
  }, [i]), le(() => {
    if (!t) return;
    const I = (q) => {
      (q.ctrlKey || q.metaKey) && q.key === "r" && (q.preventDefault(), x());
    };
    return window.addEventListener("keydown", I), () => window.removeEventListener("keydown", I);
  }, [t]);
  const g = _e(() => {
    const I = r._inheritedResources || [], q = r.resources, N = /* @__PURE__ */ new Map();
    return q.forEach((R) => {
      N.set(R.resourceId, r.priority);
    }), I.forEach((R) => {
      const k = N.get(R.resourceId);
      (k === void 0 || R.sourceNodePriority > k) && N.set(R.resourceId, R.sourceNodePriority);
    }), N.size;
  }, [r.resources, r._inheritedResources, r.priority]);
  return /* @__PURE__ */ _(
    "div",
    {
      className: `relative w-[280px] shadow-sm rounded-xl border-2 transition-all duration-200 bg-white
      ${t ? "border-teal-500 ring-2 ring-teal-100" : "border-slate-200"}
      ${c ? "" : "opacity-70 grayscale"}
      `,
      children: [
        /* @__PURE__ */ f(rc, { type: "target", position: Er.Top, className: "!bg-slate-400 !w-3 !h-3" }),
        /* @__PURE__ */ _("div", { className: `px-4 py-2 rounded-t-xl flex items-center justify-between border-b ${h.bg} ${h.border}`, children: [
          /* @__PURE__ */ _("span", { className: `text-xs font-bold uppercase tracking-wider flex items-center gap-1 ${h.text}`, children: [
            p && /* @__PURE__ */ f(p, { size: 12 }),
            r.group
          ] }),
          /* @__PURE__ */ _("div", { className: "flex gap-2 items-center", children: [
            r.direction === pe.BottomUp && /* @__PURE__ */ f("span", { title: "Inherits from Parents", className: "flex items-center", children: /* @__PURE__ */ f(Bh, { size: 14, className: "text-slate-400" }) }),
            r.direction === pe.TopDown && /* @__PURE__ */ f("span", { title: "Inherits from Children", className: "flex items-center", children: /* @__PURE__ */ f(zh, { size: 14, className: "text-slate-400" }) }),
            /* @__PURE__ */ _("span", { className: "text-xs bg-white border border-slate-200 px-2 py-0.5 rounded-full text-slate-600 font-mono", children: [
              "P",
              r.priority
            ] })
          ] })
        ] }),
        /* @__PURE__ */ _("div", { className: "p-4", children: [
          i ? /* @__PURE__ */ f("div", { className: "mb-3", children: /* @__PURE__ */ f(
            "input",
            {
              ref: l,
              type: "text",
              value: s,
              onChange: (I) => u(I.target.value),
              onKeyDown: b,
              onBlur: m,
              className: "w-full text-sm font-semibold text-slate-800 border-2 border-teal-500 rounded p-1 focus:outline-none",
              onClick: (I) => I.stopPropagation()
            }
          ) }) : /* @__PURE__ */ _(
            "div",
            {
              className: "font-semibold text-slate-800 text-sm mb-3 truncate flex items-center gap-2 cursor-text hover:bg-slate-50 rounded -ml-1 pl-1 py-0.5",
              title: `${r.name} (Double-click to edit)`,
              onDoubleClick: x,
              children: [
                /* @__PURE__ */ f(vm, { size: 16, className: "text-teal-600 flex-shrink-0" }),
                r.name
              ]
            }
          ),
          /* @__PURE__ */ _("div", { className: "space-y-2", children: [
            /* @__PURE__ */ _("div", { className: "flex items-center text-xs text-slate-600 gap-2", children: [
              /* @__PURE__ */ f(vr, { size: 14, className: "text-slate-400" }),
              /* @__PURE__ */ f("span", { className: "bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 font-mono", children: r.time })
            ] }),
            /* @__PURE__ */ _("div", { className: "flex items-center text-xs text-slate-600 gap-2", title: "Purpose", children: [
              /* @__PURE__ */ f(Oo, { size: 14, className: "text-slate-400" }),
              /* @__PURE__ */ f("span", { className: "truncate max-w-[180px]", children: r.purpose })
            ] }),
            /* @__PURE__ */ _("div", { className: "flex items-center justify-between pt-2 border-t border-slate-100 mt-2", children: [
              /* @__PURE__ */ _("div", { className: "flex items-center text-xs text-slate-500 gap-1.5", title: "Effective Resources (After Priority Resolution)", children: [
                /* @__PURE__ */ f(fr, { size: 14, className: "text-teal-600" }),
                /* @__PURE__ */ f("span", { className: "font-bold text-slate-700 font-mono", children: g }),
                /* @__PURE__ */ f("span", { className: "text-[10px] text-slate-400 font-normal", children: "effective" })
              ] }),
              ((w = (y = r.configuration) == null ? void 0 : y.workflow) == null ? void 0 : w.type) && /* @__PURE__ */ _("div", { className: "flex items-center text-xs text-slate-400 gap-1", title: "Workflow Type", children: [
                /* @__PURE__ */ f(Hp, { size: 14 }),
                /* @__PURE__ */ _("span", { children: [
                  "Type ",
                  r.configuration.workflow.type
                ] })
              ] })
            ] })
          ] })
        ] }),
        /* @__PURE__ */ f(rc, { type: "source", position: Er.Bottom, className: "!bg-slate-400 !w-3 !h-3" })
      ]
    }
  );
}, Tm = Co.memo(Am), So = ({ tags: e, onChange: r, placeholder: t = "Add tag...", colorClass: n = "bg-slate-100 text-slate-700 border-slate-200", id: a }) => {
  const [i, o] = U(""), s = (l) => {
    l.key === "Enter" && i.trim() && (l.preventDefault(), e.includes(i.trim()) || r([...e, i.trim()]), o(""));
  }, u = (l) => {
    r(e.filter((c) => c !== l));
  };
  return /* @__PURE__ */ _("div", { className: "space-y-2", children: [
    /* @__PURE__ */ f("div", { className: "flex flex-wrap gap-2 mb-2", children: e.map((l) => /* @__PURE__ */ _(
      "span",
      {
        className: `inline-flex items-center px-2 py-1 rounded text-xs font-medium border ${n}`,
        children: [
          l,
          /* @__PURE__ */ f(
            "button",
            {
              onClick: () => u(l),
              className: "ml-1.5 p-0.5 hover:bg-black/10 rounded-full transition-colors",
              children: /* @__PURE__ */ f(Pe, { size: 10 })
            }
          )
        ]
      },
      l
    )) }),
    /* @__PURE__ */ _("div", { className: "relative", children: [
      /* @__PURE__ */ f(
        "input",
        {
          id: a,
          type: "text",
          value: i,
          onChange: (l) => o(l.target.value),
          onKeyDown: s,
          placeholder: t,
          className: "w-full pl-3 pr-8 py-2 bg-white text-slate-900 border border-slate-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-teal-500/20 focus:border-teal-500 transition-all placeholder:text-slate-400"
        }
      ),
      /* @__PURE__ */ f(
        "button",
        {
          onClick: () => {
            i.trim() && (e.includes(i.trim()) || r([...e, i.trim()]), o(""));
          },
          className: "absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-teal-600",
          children: /* @__PURE__ */ f(gr, { size: 16 })
        }
      )
    ] })
  ] });
};
function Tr({
  items: e,
  height: r,
  itemHeight: t,
  renderItem: n,
  className: a = "",
  overscan: i = 5
}) {
  const [o, s] = U(0), u = xe(null), l = e.length * t, { startIndex: c, endIndex: d } = _e(() => {
    var g;
    let v = 0;
    typeof r == "number" ? v = r : v = ((g = u.current) == null ? void 0 : g.clientHeight) || 500;
    const m = Math.floor(o / t), b = Math.ceil((o + v) / t);
    return {
      startIndex: Math.max(0, m - i),
      endIndex: Math.min(e.length, b + i)
    };
  }, [o, e.length, t, r, i]), h = e.slice(c, d), p = c * t, x = (v) => {
    s(v.currentTarget.scrollTop);
  };
  return le(() => {
    const v = () => {
      u.current;
    };
    return window.addEventListener("resize", v), () => window.removeEventListener("resize", v);
  }, []), /* @__PURE__ */ f(
    "div",
    {
      ref: u,
      className: `overflow-y-auto relative ${a}`,
      style: { height: r },
      onScroll: x,
      children: /* @__PURE__ */ f("div", { style: { height: l, position: "relative" }, children: /* @__PURE__ */ f(
        "div",
        {
          style: {
            position: "absolute",
            top: 0,
            left: 0,
            width: "100%",
            transform: `translateY(${p}px)`
          },
          children: h.map((v, m) => n(v, c + m))
        }
      ) })
    }
  );
}
const ac = (e) => e.isOpen ? /* @__PURE__ */ f(Mm, { ...e }) : null, Mm = ({
  onClose: e,
  onSelect: r,
  schedules: t,
  title: n = "Select Schedule",
  excludeId: a
}) => {
  const [i, o] = U(""), s = _e(() => {
    const u = i.toLowerCase();
    return t.filter((l) => !a || l.scheduleId !== a).filter(
      (l) => l.name.toLowerCase().includes(u) || l.scheduleId.toLowerCase().includes(u) || l.group.toLowerCase().includes(u)
    );
  }, [t, i, a]);
  return /* @__PURE__ */ f("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/50 backdrop-blur-sm p-4 animate-in fade-in duration-200", children: /* @__PURE__ */ _("div", { className: "bg-white rounded-xl shadow-2xl w-full max-w-2xl h-[70vh] flex flex-col overflow-hidden border border-slate-200", children: [
    /* @__PURE__ */ _("div", { className: "px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50", children: [
      /* @__PURE__ */ f("h2", { className: "text-lg font-bold text-slate-900", children: n }),
      /* @__PURE__ */ f("button", { onClick: e, className: "p-2 hover:bg-slate-200 rounded-full text-slate-400 transition-colors", children: /* @__PURE__ */ f(Pe, { size: 20 }) })
    ] }),
    /* @__PURE__ */ _("div", { className: "p-4 border-b border-slate-100 flex gap-4 bg-white flex-shrink-0", children: [
      /* @__PURE__ */ _("div", { className: "relative flex-1", children: [
        /* @__PURE__ */ f(Ye, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", size: 18 }),
        /* @__PURE__ */ f(
          "input",
          {
            type: "text",
            placeholder: "Search by name, ID or group...",
            className: "w-full pl-10 pr-4 py-2 bg-white text-slate-900 border border-slate-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-teal-500/20 focus:border-teal-500 transition-all placeholder:text-slate-400",
            value: i,
            onChange: (u) => o(u.target.value)
          }
        )
      ] }),
      /* @__PURE__ */ _("div", { className: "flex items-center gap-2 px-3 py-2 bg-slate-50 rounded-lg border border-slate-200 text-slate-600 text-sm", children: [
        /* @__PURE__ */ f(Po, { size: 16 }),
        /* @__PURE__ */ f("span", { className: "font-medium", children: s.length })
      ] })
    ] }),
    /* @__PURE__ */ f("div", { className: "flex-1 overflow-hidden bg-slate-50 p-2 relative", children: s.length === 0 ? /* @__PURE__ */ f("div", { className: "p-8 text-center text-slate-400", children: "No schedules found." }) : /* @__PURE__ */ f(
      Tr,
      {
        items: s,
        height: "100%",
        itemHeight: 64,
        renderItem: (u) => /* @__PURE__ */ f("div", { className: "pb-1", children: /* @__PURE__ */ _(
          "button",
          {
            onClick: () => {
              r(u.scheduleId), e();
            },
            className: "w-full text-left p-3 rounded-lg border border-transparent hover:border-teal-200 hover:bg-teal-50 hover:shadow-sm bg-white transition-all group flex items-center justify-between h-[60px]",
            children: [
              /* @__PURE__ */ _("div", { children: [
                /* @__PURE__ */ f("div", { className: "font-semibold text-slate-800 text-sm truncate", children: u.name }),
                /* @__PURE__ */ _("div", { className: "flex items-center gap-2 mt-1", children: [
                  /* @__PURE__ */ f("span", { className: "text-[10px] bg-slate-100 text-slate-500 px-1.5 py-0.5 rounded border border-slate-200 uppercase font-bold", children: u.group }),
                  /* @__PURE__ */ f("span", { className: "text-[10px] font-mono text-slate-400 truncate max-w-[150px]", children: u.scheduleId })
                ] })
              ] }),
              /* @__PURE__ */ f("div", { className: "opacity-0 group-hover:opacity-100 text-teal-600 transition-opacity", children: /* @__PURE__ */ f(Ar, { size: 18 }) })
            ]
          }
        ) }, u.scheduleId)
      }
    ) })
  ] }) });
}, Om = ["slate", "red", "purple", "amber", "indigo", "orange", "blue", "emerald", "teal", "pink"], Pm = [
  { name: "", label: "None" },
  { name: "AlertTriangle", label: "Alert" },
  { name: "Crown", label: "Crown" },
  { name: "Clock", label: "Clock" },
  { name: "Moon", label: "Moon" },
  { name: "ShieldAlert", label: "Shield" },
  { name: "Wrench", label: "Wrench" }
], it = {
  slate: "bg-slate-400",
  red: "bg-red-500",
  purple: "bg-purple-500",
  amber: "bg-amber-500",
  indigo: "bg-indigo-500",
  orange: "bg-orange-500",
  blue: "bg-blue-500",
  emerald: "bg-emerald-500",
  teal: "bg-teal-500",
  pink: "bg-pink-500"
}, ic = {
  AlertTriangle: Ze,
  Crown: Uh,
  Clock: vr,
  Moon: Vh,
  ShieldAlert: Wh,
  Wrench: Yh
}, Lm = ({ node: e, handleUpdate: r, allNodes: t, getScheduleName: n }) => {
  const [a, i] = U(!1), [o, s] = U(!1), { groups: u, addGroup: l, updateGroup: c } = Dh(), [d, h] = U(!1), [p, x] = U(""), v = xe(null), [m, b] = U(null);
  le(() => {
    const k = (S) => {
      v.current && !v.current.contains(S.target) && h(!1);
    };
    return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
  }, []);
  const g = _e(
    () => u.filter((k) => k.name.toLowerCase().includes(p.toLowerCase())),
    [u, p]
  ), y = (k) => {
    r("group", k), x(""), h(!1);
  }, w = (k) => {
    x(k), r("group", k), d || h(!0);
  }, I = () => {
    e.group && !u.some((k) => k.name === e.group) && l(e.group);
  }, q = (k) => {
    k ? r("followUp", "") : r("followUp", null);
  }, N = (k, S) => {
    !e.phaseOut && S ? r("phaseOut", { scheduleId: S, duration: "30d" }) : e.phaseOut && r("phaseOut", { ...e.phaseOut, [k]: S });
  }, R = (k) => {
    k ? r("phaseOut", { scheduleId: "", duration: "30d" }) : r("phaseOut", null);
  };
  return /* @__PURE__ */ _("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ _("div", { className: "flex items-center justify-between bg-slate-50 p-3 rounded-lg border border-slate-200", children: [
      /* @__PURE__ */ _("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ f("div", { className: `p-2 rounded-full ${e.isActive ? "bg-emerald-100 text-emerald-600" : "bg-slate-200 text-slate-500"}`, children: e.isActive ? /* @__PURE__ */ f(Mp, { size: 20 }) : /* @__PURE__ */ f(Ze, { size: 20 }) }),
        /* @__PURE__ */ _("div", { children: [
          /* @__PURE__ */ f("div", { className: "font-semibold text-sm text-slate-900", children: "Schedule Status" }),
          /* @__PURE__ */ f("div", { className: "text-xs text-slate-500", children: e.isActive ? "Active & Enforced" : "Inactive & Ignored" })
        ] })
      ] }),
      /* @__PURE__ */ _("label", { "aria-label": "Toggle schedule status", className: "relative inline-flex items-center cursor-pointer", children: [
        /* @__PURE__ */ f("input", { type: "checkbox", className: "sr-only peer", checked: e.isActive, onChange: (k) => r("isActive", k.target.checked) }),
        /* @__PURE__ */ f("div", { className: "w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-teal-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-teal-600" })
      ] })
    ] }),
    /* @__PURE__ */ _("div", { className: "space-y-4", children: [
      /* @__PURE__ */ f("h3", { className: "text-xs font-bold text-slate-900 uppercase tracking-wider border-b border-slate-100 pb-2", children: "Basic Information" }),
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ f("label", { htmlFor: "gen-name", className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Name" }),
        /* @__PURE__ */ f(
          "input",
          {
            id: "gen-name",
            type: "text",
            value: e.name,
            onChange: (k) => r("name", k.target.value),
            className: "w-full p-2 bg-white text-slate-900 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-teal-500 focus:ring-2 focus:ring-teal-500/20 transition-all"
          }
        )
      ] }),
      /* @__PURE__ */ _("div", { className: "grid grid-cols-2 gap-4", children: [
        /* @__PURE__ */ _("div", { ref: v, className: "relative", children: [
          /* @__PURE__ */ f("label", { htmlFor: "gen-group", className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Group" }),
          /* @__PURE__ */ _("div", { className: "relative", children: [
            /* @__PURE__ */ f(
              "input",
              {
                id: "gen-group",
                type: "text",
                value: d && p || e.group,
                onChange: (k) => w(k.target.value),
                onFocus: () => {
                  h(!0), x("");
                },
                onBlur: I,
                className: "w-full p-2 pr-8 bg-white text-slate-900 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-teal-500",
                placeholder: "Select or type..."
              }
            ),
            /* @__PURE__ */ f(
              "button",
              {
                type: "button",
                tabIndex: -1,
                onClick: () => h(!d),
                className: "absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",
                children: /* @__PURE__ */ f(Ip, { size: 14 })
              }
            )
          ] }),
          d && /* @__PURE__ */ _("div", { className: "absolute z-50 mt-1 w-full bg-white border border-slate-200 rounded-lg shadow-lg max-h-48 overflow-y-auto", children: [
            g.map((k) => {
              const S = k.icon ? ic[k.icon] : void 0, E = it[k.color || "slate"] || it.slate;
              return /* @__PURE__ */ _(
                "div",
                {
                  className: `flex items-center hover:bg-slate-50 transition-colors ${e.group === k.name ? "bg-teal-50 text-teal-700" : "text-slate-700"}`,
                  children: [
                    /* @__PURE__ */ _(
                      "button",
                      {
                        type: "button",
                        onMouseDown: (A) => {
                          A.preventDefault(), y(k.name);
                        },
                        className: "flex-1 flex items-center gap-2 px-3 py-2 text-sm text-left",
                        children: [
                          /* @__PURE__ */ f("span", { className: `w-2.5 h-2.5 rounded-full flex-shrink-0 ${E}` }),
                          S && /* @__PURE__ */ f(S, { size: 13, className: "text-slate-400 flex-shrink-0" }),
                          /* @__PURE__ */ f("span", { children: k.name })
                        ]
                      }
                    ),
                    /* @__PURE__ */ f(
                      "button",
                      {
                        type: "button",
                        onMouseDown: (A) => {
                          A.preventDefault(), A.stopPropagation(), b(k.name), h(!1);
                        },
                        className: "px-2 py-2 text-slate-300 hover:text-slate-600 transition-colors",
                        title: `Edit ${k.name} group`,
                        children: /* @__PURE__ */ f(Lr, { size: 12 })
                      }
                    )
                  ]
                },
                k.name
              );
            }),
            g.length === 0 && p && /* @__PURE__ */ _("div", { className: "px-3 py-2 text-xs text-slate-400 italic", children: [
              'Press Tab to add "',
              p,
              '" as custom group'
            ] })
          ] })
        ] }),
        /* @__PURE__ */ _("div", { children: [
          /* @__PURE__ */ f("label", { htmlFor: "gen-purpose", className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Purpose" }),
          /* @__PURE__ */ f(
            "input",
            {
              id: "gen-purpose",
              type: "text",
              value: e.purpose,
              onChange: (k) => r("purpose", k.target.value),
              className: "w-full p-2 bg-white text-slate-900 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-teal-500"
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ _("label", { htmlFor: "gen-tags", className: "text-xs font-semibold text-slate-500 mb-1 block", children: [
          "Tags ",
          /* @__PURE__ */ f("span", { className: "text-[10px] font-normal text-slate-400 opacity-80", children: "(Search)" })
        ] }),
        /* @__PURE__ */ f(
          So,
          {
            id: "gen-tags",
            tags: e.tags || [],
            onChange: (k) => r("tags", k)
          }
        )
      ] }),
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ _("label", { htmlFor: "gen-attributes", className: "text-xs font-semibold text-slate-500 mb-1 block", children: [
          "Attributes ",
          /* @__PURE__ */ f("span", { className: "text-[10px] font-normal text-slate-400 opacity-80", children: "(Workflow Logic)" })
        ] }),
        /* @__PURE__ */ f(
          So,
          {
            id: "gen-attributes",
            tags: e.attributes || [],
            onChange: (k) => r("attributes", k),
            placeholder: "Add attribute...",
            colorClass: "bg-indigo-50 text-indigo-700 border-indigo-200"
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ _("div", { className: "space-y-4", children: [
      /* @__PURE__ */ f("h3", { className: "text-xs font-bold text-slate-900 uppercase tracking-wider border-b border-slate-100 pb-2", children: "Lifecycle" }),
      /* @__PURE__ */ _("div", { className: `p-3 border rounded-lg transition-colors ${e.followUp !== null ? "bg-indigo-50 border-indigo-200" : "bg-slate-50 border-slate-200"}`, children: [
        /* @__PURE__ */ _("div", { className: "flex items-center justify-between mb-2", children: [
          /* @__PURE__ */ _("div", { className: "flex items-center gap-3", children: [
            /* @__PURE__ */ f(Kh, { size: 16, className: e.followUp !== null ? "text-indigo-500" : "text-slate-400" }),
            /* @__PURE__ */ f("div", { children: /* @__PURE__ */ f("div", { className: "text-sm font-medium text-slate-900", children: "Follow Up Schedule" }) })
          ] }),
          /* @__PURE__ */ _("label", { "aria-label": "Toggle follow up schedule", className: "relative inline-flex items-center cursor-pointer", children: [
            /* @__PURE__ */ f(
              "input",
              {
                type: "checkbox",
                className: "sr-only peer",
                checked: e.followUp !== null,
                onChange: (k) => q(k.target.checked)
              }
            ),
            /* @__PURE__ */ f("div", { className: "w-9 h-5 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-indigo-500" })
          ] })
        ] }),
        e.followUp !== null && /* @__PURE__ */ f("div", { className: "mt-3 space-y-3 pl-2 border-l-2 border-indigo-200", children: /* @__PURE__ */ _("div", { children: [
          /* @__PURE__ */ f("span", { className: "text-xs text-slate-500 mb-1 block", children: "Target Schedule" }),
          /* @__PURE__ */ _("div", { className: "flex gap-2", children: [
            /* @__PURE__ */ f("div", { className: "flex-1 text-sm p-2 bg-white border border-indigo-200 rounded text-slate-700 flex items-center justify-between", children: /* @__PURE__ */ f("span", { className: e.followUp ? "" : "text-slate-400 italic", children: e.followUp ? n(e.followUp) : "None configured" }) }),
            /* @__PURE__ */ f(
              "button",
              {
                onClick: () => i(!0),
                className: "px-3 py-1 bg-white border border-indigo-200 text-indigo-700 text-xs rounded hover:bg-indigo-100 transition-colors",
                children: "Select"
              }
            ),
            e.followUp && /* @__PURE__ */ f(
              "button",
              {
                onClick: () => r("followUp", ""),
                className: "p-2 bg-white border border-indigo-200 text-indigo-700 rounded hover:bg-red-50 hover:text-red-600 hover:border-red-200 transition-colors",
                title: "Remove Follow Up",
                children: /* @__PURE__ */ f(Je, { size: 14 })
              }
            )
          ] })
        ] }) })
      ] }),
      /* @__PURE__ */ _("div", { className: `p-3 border rounded-lg transition-colors ${e.phaseOut ? "bg-amber-50 border-amber-200" : "bg-slate-50 border-slate-200"}`, children: [
        /* @__PURE__ */ _("div", { className: "flex items-center justify-between mb-2", children: [
          /* @__PURE__ */ _("div", { className: "flex items-center gap-3", children: [
            /* @__PURE__ */ f(bm, { size: 16, className: e.phaseOut ? "text-amber-500" : "text-slate-400" }),
            /* @__PURE__ */ f("div", { children: /* @__PURE__ */ f("div", { className: "text-sm font-medium text-slate-900", children: "Phase Out Logic" }) })
          ] }),
          /* @__PURE__ */ _("label", { "aria-label": "Toggle phase out logic", className: "relative inline-flex items-center cursor-pointer", children: [
            /* @__PURE__ */ f(
              "input",
              {
                type: "checkbox",
                className: "sr-only peer",
                checked: !!e.phaseOut,
                onChange: (k) => R(k.target.checked)
              }
            ),
            /* @__PURE__ */ f("div", { className: "w-9 h-5 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-amber-500" })
          ] })
        ] }),
        e.phaseOut && /* @__PURE__ */ _("div", { className: "mt-3 space-y-3 pl-2 border-l-2 border-amber-200", children: [
          /* @__PURE__ */ _("div", { children: [
            /* @__PURE__ */ f("span", { className: "text-xs text-slate-500 mb-1 block", children: "Replacement Schedule" }),
            /* @__PURE__ */ _("div", { className: "flex gap-2", children: [
              /* @__PURE__ */ f("div", { className: "flex-1 text-sm p-2 bg-white border border-amber-200 rounded text-slate-700 flex items-center justify-between", children: /* @__PURE__ */ f("span", { className: e.phaseOut.scheduleId ? "" : "text-slate-400 italic", children: n(e.phaseOut.scheduleId) || "None configured" }) }),
              /* @__PURE__ */ f(
                "button",
                {
                  onClick: () => s(!0),
                  className: "px-3 py-1 bg-white border border-amber-200 text-amber-700 text-xs rounded hover:bg-amber-100 transition-colors",
                  children: "Select"
                }
              ),
              e.phaseOut.scheduleId && /* @__PURE__ */ f(
                "button",
                {
                  onClick: () => N("scheduleId", ""),
                  className: "p-2 bg-white border border-amber-200 text-amber-700 rounded hover:bg-red-50 hover:text-red-600 hover:border-red-200 transition-colors",
                  title: "Remove Replacement",
                  children: /* @__PURE__ */ f(Je, { size: 14 })
                }
              )
            ] })
          ] }),
          /* @__PURE__ */ _("div", { children: [
            /* @__PURE__ */ f("label", { htmlFor: "gen-phaseout-duration", className: "text-xs text-slate-500 mb-1 block", children: "Duration" }),
            /* @__PURE__ */ f(
              "input",
              {
                id: "gen-phaseout-duration",
                type: "text",
                value: e.phaseOut.duration,
                onChange: (k) => N("duration", k.target.value),
                className: "w-full p-2 bg-white text-slate-900 border border-amber-200 rounded text-sm focus:outline-none focus:border-amber-400"
              }
            )
          ] })
        ] })
      ] })
    ] }),
    /* @__PURE__ */ f(
      ac,
      {
        isOpen: a,
        onClose: () => i(!1),
        schedules: t,
        onSelect: (k) => r("followUp", k),
        title: "Select Follow Up Schedule",
        excludeId: e.scheduleId
      }
    ),
    /* @__PURE__ */ f(
      ac,
      {
        isOpen: o,
        onClose: () => s(!1),
        schedules: t,
        onSelect: (k) => N("scheduleId", k),
        title: "Select Replacement Schedule",
        excludeId: e.scheduleId
      }
    ),
    m && (() => {
      const k = u.find((S) => S.name === m);
      return k ? /* @__PURE__ */ f("div", { role: "presentation", className: "fixed inset-0 z-[100] flex items-center justify-center bg-black/30", onMouseDown: () => b(null), children: /* @__PURE__ */ _("div", { role: "dialog", "aria-label": `Edit Group: ${k.name}`, className: "bg-white rounded-xl shadow-xl w-80 p-5", onMouseDown: (S) => S.stopPropagation(), children: [
        /* @__PURE__ */ _("div", { className: "flex items-center justify-between mb-4", children: [
          /* @__PURE__ */ _("h3", { className: "text-sm font-bold text-slate-900", children: [
            "Edit Group: ",
            k.name
          ] }),
          /* @__PURE__ */ f("button", { onClick: () => b(null), className: "text-slate-400 hover:text-slate-600", children: /* @__PURE__ */ f(Pe, { size: 16 }) })
        ] }),
        /* @__PURE__ */ _("div", { className: "space-y-4", children: [
          /* @__PURE__ */ _("div", { children: [
            /* @__PURE__ */ f("span", { className: "text-xs font-semibold text-slate-500 mb-2 block", children: "Color" }),
            /* @__PURE__ */ f("div", { className: "flex flex-wrap gap-2", children: Om.map((S) => /* @__PURE__ */ f(
              "button",
              {
                type: "button",
                onClick: () => c(k.name, { color: S }),
                className: `w-7 h-7 rounded-full border-2 transition-all ${it[S]} ${(k.color || "slate") === S ? "border-slate-800 scale-110" : "border-transparent hover:border-slate-300"}`,
                title: S
              },
              S
            )) })
          ] }),
          /* @__PURE__ */ _("div", { children: [
            /* @__PURE__ */ f("span", { className: "text-xs font-semibold text-slate-500 mb-2 block", children: "Icon" }),
            /* @__PURE__ */ f("div", { className: "flex flex-wrap gap-1.5", children: Pm.map((S) => {
              const E = S.name ? ic[S.name] : void 0, A = (k.icon || "") === S.name;
              return /* @__PURE__ */ _(
                "button",
                {
                  type: "button",
                  onClick: () => c(k.name, { icon: S.name || void 0 }),
                  className: `flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border text-xs transition-all ${A ? "border-teal-500 bg-teal-50 text-teal-700" : "border-slate-200 text-slate-600 hover:border-slate-300"}`,
                  children: [
                    E ? /* @__PURE__ */ f(E, { size: 13 }) : /* @__PURE__ */ f("span", { className: "text-slate-400", children: "--" }),
                    /* @__PURE__ */ f("span", { children: S.label })
                  ]
                },
                S.name
              );
            }) })
          ] })
        ] }),
        /* @__PURE__ */ f(
          "button",
          {
            onClick: () => b(null),
            className: "mt-4 w-full py-2 bg-teal-600 hover:bg-teal-700 text-white text-sm font-medium rounded-lg transition-colors",
            children: "Done"
          }
        )
      ] }) }) : null;
    })()
  ] });
}, jm = ({ node: e, handleUpdate: r, availableLocations: t, availableApprovalGroups: n }) => {
  const a = (u) => {
    const [l, c] = u.split("|");
    l && c && r("locationGroup", { groupId: l, nodeId: c });
  }, i = () => {
    const u = n[0], l = {
      groupId: u ? u.groupId : "",
      nodeId: u ? u.id : "",
      type: ir.Room
    };
    r("approvalGroups", [...e.approvalGroups || [], l]);
  }, o = (u) => {
    const l = (e.approvalGroups || []).filter((c, d) => d !== u);
    r("approvalGroups", l);
  }, s = (u, l, c) => {
    const d = [...e.approvalGroups || []];
    if (l === "combined") {
      const [h, p] = c.split("|");
      d[u] = { ...d[u], groupId: h, nodeId: p };
    } else
      d[u] = { ...d[u], [l]: c };
    r("approvalGroups", d);
  };
  return /* @__PURE__ */ _("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ _("div", { children: [
      /* @__PURE__ */ f("h3", { className: "text-xs font-bold text-slate-900 uppercase tracking-wider border-b border-slate-100 pb-2 mb-4", children: "Evaluation Logic" }),
      /* @__PURE__ */ _("div", { className: "flex items-center justify-between p-4 bg-white border border-slate-200 rounded-xl shadow-sm", children: [
        /* @__PURE__ */ _("div", { children: [
          /* @__PURE__ */ f("div", { className: "text-xs text-slate-500 font-bold uppercase tracking-wider mb-1", children: "Priority Level" }),
          /* @__PURE__ */ _("div", { className: "text-3xl font-mono font-bold text-slate-900", children: [
            "P",
            e.priority
          ] })
        ] }),
        /* @__PURE__ */ _("div", { className: "flex gap-1", children: [
          /* @__PURE__ */ f(
            "button",
            {
              onClick: () => r("priority", Math.max(0, e.priority - 1)),
              className: "w-8 h-8 rounded bg-slate-100 hover:bg-slate-200 border border-slate-200 text-slate-600 flex items-center justify-center transition-colors",
              children: "-"
            }
          ),
          /* @__PURE__ */ f(
            "button",
            {
              onClick: () => r("priority", e.priority + 1),
              className: "w-8 h-8 rounded bg-slate-100 hover:bg-slate-200 border border-slate-200 text-slate-600 flex items-center justify-center transition-colors",
              children: "+"
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ f("p", { className: "text-xs text-slate-500 mt-2", children: "Higher priority schedules override conflicting resources from lower priority schedules (inherited or direct)." })
    ] }),
    /* @__PURE__ */ _("div", { className: "grid grid-cols-2 gap-4", children: [
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ f("label", { htmlFor: "logic-time", className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Time Schedule" }),
        /* @__PURE__ */ _("div", { className: "relative", children: [
          /* @__PURE__ */ f(vr, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", size: 14 }),
          /* @__PURE__ */ f(
            "input",
            {
              id: "logic-time",
              type: "text",
              value: e.time,
              onChange: (u) => r("time", u.target.value),
              className: "w-full pl-9 pr-3 py-2 bg-white text-slate-900 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-teal-500"
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ f("span", { className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Inheritance Direction" }),
        /* @__PURE__ */ _("div", { className: "flex bg-slate-100 p-1 rounded-lg", children: [
          /* @__PURE__ */ _(
            "button",
            {
              onClick: () => r("direction", pe.BottomUp),
              className: `flex-1 text-xs py-1.5 rounded-md flex items-center justify-center gap-1 transition-all ${e.direction === pe.BottomUp ? "bg-white text-teal-700 shadow-sm font-medium" : "text-slate-500 hover:text-slate-700"}`,
              children: [
                /* @__PURE__ */ f(Bh, { size: 12 }),
                " Bottom Up"
              ]
            }
          ),
          /* @__PURE__ */ _(
            "button",
            {
              onClick: () => r("direction", pe.TopDown),
              className: `flex-1 text-xs py-1.5 rounded-md flex items-center justify-center gap-1 transition-all ${e.direction === pe.TopDown ? "bg-white text-teal-700 shadow-sm font-medium" : "text-slate-500 hover:text-slate-700"}`,
              children: [
                /* @__PURE__ */ f(zh, { size: 12 }),
                " Top Down"
              ]
            }
          )
        ] })
      ] })
    ] }),
    /* @__PURE__ */ _("div", { children: [
      /* @__PURE__ */ f("label", { htmlFor: "logic-location", className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Location Context" }),
      /* @__PURE__ */ _("div", { className: "relative", children: [
        /* @__PURE__ */ f(Qp, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", size: 14 }),
        /* @__PURE__ */ _(
          "select",
          {
            id: "logic-location",
            value: `${e.locationGroup.groupId}|${e.locationGroup.nodeId}`,
            onChange: (u) => a(u.target.value),
            className: "w-full pl-9 pr-8 py-2 bg-white text-slate-900 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-teal-500 appearance-none",
            children: [
              /* @__PURE__ */ f("option", { value: "", children: "Select Location..." }),
              t.map((u) => /* @__PURE__ */ f("option", { value: `${u.groupId}|${u.id}`, children: u.name }, u.id))
            ]
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ _("div", { children: [
      /* @__PURE__ */ _("div", { className: "flex items-center justify-between mb-2", children: [
        /* @__PURE__ */ f("span", { className: "text-xs font-semibold text-slate-500 block", children: "Approval Groups" }),
        /* @__PURE__ */ _(
          "button",
          {
            onClick: i,
            className: "text-xs text-teal-600 hover:text-teal-700 font-medium flex items-center gap-1",
            children: [
              /* @__PURE__ */ f(gr, { size: 12 }),
              " Add"
            ]
          }
        )
      ] }),
      /* @__PURE__ */ _("div", { className: "space-y-2", children: [
        (e.approvalGroups || []).map((u, l) => /* @__PURE__ */ _("div", { className: "flex gap-2 items-start", children: [
          /* @__PURE__ */ f(
            "select",
            {
              value: `${u.groupId}|${u.nodeId}`,
              onChange: (c) => s(l, "combined", c.target.value),
              className: "flex-1 p-2 text-xs bg-white text-slate-900 border border-slate-300 rounded-lg focus:outline-none focus:border-teal-500",
              children: n.map((c) => /* @__PURE__ */ f("option", { value: `${c.groupId}|${c.id}`, children: c.name }, c.id))
            }
          ),
          /* @__PURE__ */ _(
            "select",
            {
              value: u.type,
              onChange: (c) => s(l, "type", c.target.value),
              className: "w-24 p-2 text-xs bg-white text-slate-900 border border-slate-300 rounded-lg focus:outline-none focus:border-teal-500",
              children: [
                /* @__PURE__ */ f("option", { value: ir.Room, children: "Room" }),
                /* @__PURE__ */ f("option", { value: ir.Area, children: "Area" }),
                /* @__PURE__ */ f("option", { value: ir.Global, children: "Global" })
              ]
            }
          ),
          /* @__PURE__ */ f(
            "button",
            {
              onClick: () => o(l),
              className: "p-2 text-slate-400 hover:text-red-500 transition-colors",
              children: /* @__PURE__ */ f(Pe, { size: 14 })
            }
          )
        ] }, `${u.groupId}-${u.nodeId}-${u.type}`)),
        (!e.approvalGroups || e.approvalGroups.length === 0) && /* @__PURE__ */ f("div", { className: "text-center py-4 bg-slate-50 border border-dashed border-slate-200 rounded-lg text-xs text-slate-400", children: "No approval groups defined" })
      ] })
    ] })
  ] });
}, Dm = ({
  node: e,
  handleUpdate: r,
  inheritedResources: t,
  resourceStatusMap: n,
  resourceMap: a,
  systemMap: i,
  planMap: o,
  loading: s,
  onAddResourceRequest: u
}) => {
  const l = (p) => {
    const x = e.resources.filter((v, m) => m !== p);
    r("resources", x);
  }, c = (p) => a.get(p), d = (p) => i.get(p), h = (p) => p ? o.get(p) : void 0;
  return /* @__PURE__ */ _("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ _("div", { className: "grid grid-cols-2 gap-3", children: [
      /* @__PURE__ */ _("div", { className: "p-3 bg-teal-50 border border-teal-100 rounded-xl", children: [
        /* @__PURE__ */ f("div", { className: "text-2xl font-bold text-teal-700", children: e.resources.length }),
        /* @__PURE__ */ f("div", { className: "text-xs text-teal-600 font-medium", children: "Direct Resources" })
      ] }),
      /* @__PURE__ */ _("div", { className: "p-3 bg-indigo-50 border border-indigo-100 rounded-xl", children: [
        /* @__PURE__ */ f("div", { className: "text-2xl font-bold text-indigo-700", children: t.length }),
        /* @__PURE__ */ f("div", { className: "text-xs text-indigo-600 font-medium", children: "Inherited" })
      ] })
    ] }),
    /* @__PURE__ */ _("div", { children: [
      /* @__PURE__ */ _("div", { className: "flex items-center justify-between mb-3", children: [
        /* @__PURE__ */ f("h3", { className: "text-xs font-bold text-slate-900 uppercase tracking-wider", children: "Direct Resources" }),
        /* @__PURE__ */ _(
          "button",
          {
            onClick: u,
            className: "text-xs bg-teal-600 hover:bg-teal-700 text-white px-3 py-1.5 rounded-lg flex items-center gap-2 transition-colors",
            children: [
              /* @__PURE__ */ f(gr, { size: 12 }),
              " Add Resource"
            ]
          }
        )
      ] }),
      /* @__PURE__ */ _("div", { className: "space-y-2", children: [
        e.resources.map((p, x) => {
          const v = n.get(p.resourceId), m = (v == null ? void 0 : v.priority) === e.priority, b = c(p.resourceId), g = d(p.systemId), y = h(p.resourcePlanId);
          return /* @__PURE__ */ _("div", { className: `p-3 rounded-lg border flex flex-col group transition-all ${m ? "bg-white border-slate-200 shadow-sm" : "bg-slate-50 border-slate-100 opacity-60"}`, children: [
            /* @__PURE__ */ _("div", { className: "flex items-center justify-between mb-1", children: [
              /* @__PURE__ */ _("div", { className: "flex items-center gap-2", children: [
                /* @__PURE__ */ f("span", { className: "font-semibold text-sm text-slate-900 truncate", title: p.resourceId, children: s ? "Loading..." : (b == null ? void 0 : b.name) || p.resourceId }),
                b && /* @__PURE__ */ f("span", { className: "text-[10px] bg-slate-100 text-slate-500 px-1 rounded border border-slate-200", children: b.resourceKind }),
                m && /* @__PURE__ */ f("span", { title: "Active (Winning Priority)", children: /* @__PURE__ */ f(pm, { size: 14, className: "text-teal-500" }) })
              ] }),
              /* @__PURE__ */ f(
                "button",
                {
                  onClick: () => l(x),
                  className: "opacity-0 group-hover:opacity-100 p-1.5 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded transition-all",
                  children: /* @__PURE__ */ f(Je, { size: 14 })
                }
              )
            ] }),
            (b == null ? void 0 : b.description) && /* @__PURE__ */ f("div", { className: "text-xs text-slate-500 mb-2 italic", children: b.description }),
            /* @__PURE__ */ _("div", { className: "grid grid-cols-2 gap-2 mt-1", children: [
              /* @__PURE__ */ _("div", { className: "flex items-center gap-1.5 text-[10px] text-slate-500 p-1.5 bg-slate-50 rounded border border-slate-100", children: [
                /* @__PURE__ */ f(fr, { size: 10, className: "text-slate-400" }),
                /* @__PURE__ */ f("span", { className: "truncate", children: s ? "..." : (g == null ? void 0 : g.name) || p.systemId })
              ] }),
              /* @__PURE__ */ _("div", { className: "flex items-center gap-1.5 text-[10px] text-slate-500 p-1.5 bg-slate-50 rounded border border-slate-100", children: [
                /* @__PURE__ */ f(vr, { size: 10, className: "text-slate-400" }),
                /* @__PURE__ */ f("span", { className: "truncate", children: p.resourcePlanId ? s ? "..." : (y == null ? void 0 : y.name) || p.resourcePlanId : /* @__PURE__ */ f("span", { className: "italic text-slate-400", children: "Fixed / No Plan" }) })
              ] })
            ] })
          ] }, p.resourceId);
        }),
        e.resources.length === 0 && /* @__PURE__ */ f("div", { className: "text-center py-8 bg-slate-50 border border-dashed border-slate-200 rounded-xl text-slate-400 text-sm", children: "No direct resources assigned." })
      ] })
    ] }),
    t.length > 0 && /* @__PURE__ */ _("div", { children: [
      /* @__PURE__ */ _("h3", { className: "text-xs font-bold text-slate-900 uppercase tracking-wider mb-3 flex items-center gap-2", children: [
        "Inherited Resources",
        /* @__PURE__ */ f("span", { className: "bg-slate-100 text-slate-600 px-1.5 py-0.5 rounded text-[10px]", children: t.length })
      ] }),
      /* @__PURE__ */ f("div", { className: "space-y-2 opacity-80", children: t.map((p, x) => {
        const v = n.get(p.resourceId), m = (v == null ? void 0 : v.priority) === p.sourceNodePriority, b = c(p.resourceId);
        return /* @__PURE__ */ f("div", { className: `p-3 rounded-lg border border-slate-100 flex items-center justify-between ${m ? "bg-indigo-50/50" : "bg-slate-50 opacity-60"}`, children: /* @__PURE__ */ _("div", { className: "flex-1 min-w-0", children: [
          /* @__PURE__ */ _("div", { className: "flex items-center gap-2 mb-0.5", children: [
            /* @__PURE__ */ f("span", { className: "font-medium text-sm text-slate-700 truncate", children: s ? "Loading..." : (b == null ? void 0 : b.name) || p.resourceId }),
            m ? /* @__PURE__ */ f("span", { title: "Winning Inherited Resource", children: /* @__PURE__ */ f(wm, { size: 12, className: "text-indigo-500" }) }) : /* @__PURE__ */ f("span", { title: "Overridden by higher priority", children: /* @__PURE__ */ f(Cp, { size: 12, className: "text-slate-300" }) })
          ] }),
          /* @__PURE__ */ _("div", { className: "text-xs text-indigo-400 flex items-center gap-1", children: [
            /* @__PURE__ */ f(Kh, { size: 10 }),
            "Inherited from: ",
            /* @__PURE__ */ f("span", { className: "font-semibold", children: p.sourceNodeName }),
            " (P",
            p.sourceNodePriority,
            ")"
          ] })
        ] }) }, `inh-${p.resourceId}`);
      }) })
    ] })
  ] });
}, Fm = ({
  node: e,
  handleUpdate: r,
  testamentTypeMap: t,
  loading: n,
  repositoryAvailable: a,
  onAddRequirementRequest: i
}) => {
  const o = e.requirements || [], s = (u) => {
    r("requirements", o.filter((l, c) => c !== u));
  };
  return /* @__PURE__ */ _("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ _("div", { className: "grid grid-cols-2 gap-3", children: [
      /* @__PURE__ */ _("div", { className: "p-3 bg-teal-50 border border-teal-100 rounded-xl", children: [
        /* @__PURE__ */ f("div", { className: "text-2xl font-bold text-teal-700", children: o.length }),
        /* @__PURE__ */ f("div", { className: "text-xs text-teal-600 font-medium", children: "Required Testaments" })
      ] }),
      /* @__PURE__ */ _("div", { className: "p-3 bg-slate-50 border border-slate-100 rounded-xl", children: [
        /* @__PURE__ */ f("div", { className: "text-2xl font-bold text-slate-700", children: t.size }),
        /* @__PURE__ */ f("div", { className: "text-xs text-slate-500 font-medium", children: "Resolved Names" })
      ] })
    ] }),
    /* @__PURE__ */ _("div", { children: [
      /* @__PURE__ */ _("div", { className: "flex items-center justify-between mb-3", children: [
        /* @__PURE__ */ f("h3", { className: "text-xs font-bold text-slate-900 uppercase tracking-wider", children: "Requirements" }),
        /* @__PURE__ */ _(
          "button",
          {
            onClick: i,
            disabled: !a,
            className: "text-xs bg-teal-600 hover:bg-teal-700 disabled:bg-slate-200 disabled:text-slate-400 text-white px-3 py-1.5 rounded-lg flex items-center gap-2 transition-colors",
            children: [
              /* @__PURE__ */ f(gr, { size: 12 }),
              " Add Requirement"
            ]
          }
        )
      ] }),
      !a && /* @__PURE__ */ _("div", { className: "mb-3 p-3 bg-amber-50 border border-amber-200 rounded-lg flex gap-2 text-xs text-amber-800", children: [
        /* @__PURE__ */ f(Ze, { size: 14, className: "mt-0.5 flex-shrink-0" }),
        /* @__PURE__ */ f("span", { children: "Testament type repository is not configured." })
      ] }),
      /* @__PURE__ */ _("div", { className: "space-y-2", children: [
        o.map((u, l) => {
          const c = t.get(u.testamentTypeId);
          return /* @__PURE__ */ f("div", { className: "p-3 rounded-lg border border-slate-200 bg-white shadow-sm group transition-all", children: /* @__PURE__ */ _("div", { className: "flex items-start justify-between gap-3", children: [
            /* @__PURE__ */ _("div", { className: "flex items-start gap-2 min-w-0", children: [
              /* @__PURE__ */ f(Mo, { size: 16, className: "text-teal-600 mt-0.5 flex-shrink-0" }),
              /* @__PURE__ */ _("div", { className: "min-w-0", children: [
                /* @__PURE__ */ _("div", { className: "flex items-center gap-2", children: [
                  /* @__PURE__ */ f("span", { className: "font-semibold text-sm text-slate-900 truncate", title: u.testamentTypeId, children: n ? "Loading..." : (c == null ? void 0 : c.name) || u.testamentTypeId }),
                  (c == null ? void 0 : c.isDeprecated) && /* @__PURE__ */ f("span", { className: "text-[10px] bg-amber-50 text-amber-700 px-1.5 rounded border border-amber-200", children: "Deprecated" })
                ] }),
                (c == null ? void 0 : c.description) && /* @__PURE__ */ f("div", { className: "text-xs text-slate-500 mt-1 line-clamp-2", children: c.description }),
                /* @__PURE__ */ _("div", { className: "flex flex-wrap gap-1.5 mt-2 text-[10px] text-slate-500", children: [
                  (c == null ? void 0 : c.category) && /* @__PURE__ */ f("span", { className: "bg-slate-100 px-1.5 py-0.5 rounded border border-slate-200", children: c.category }),
                  (c == null ? void 0 : c.requiresDocument) && /* @__PURE__ */ f("span", { className: "bg-indigo-50 text-indigo-700 px-1.5 py-0.5 rounded border border-indigo-100", children: "Document" }),
                  (c == null ? void 0 : c.isRenewable) && /* @__PURE__ */ _("span", { className: "bg-emerald-50 text-emerald-700 px-1.5 py-0.5 rounded border border-emerald-100 flex items-center gap-1", children: [
                    /* @__PURE__ */ f(om, { size: 9 }),
                    " Renewable"
                  ] })
                ] })
              ] })
            ] }),
            /* @__PURE__ */ f(
              "button",
              {
                onClick: () => s(l),
                className: "opacity-0 group-hover:opacity-100 p-1.5 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded transition-all",
                title: "Remove requirement",
                children: /* @__PURE__ */ f(Je, { size: 14 })
              }
            )
          ] }) }, `${u.testamentTypeId}-${l}`);
        }),
        o.length === 0 && /* @__PURE__ */ f("div", { className: "text-center py-8 bg-slate-50 border border-dashed border-slate-200 rounded-xl text-slate-400 text-sm", children: "No testament requirements configured." })
      ] })
    ] })
  ] });
}, Gm = ({ node: e, handleUpdate: r }) => {
  const [t, n] = U(null), [a, i] = U("");
  le(() => {
    i(JSON.stringify(e.configuration, null, 2)), n(null);
  }, [e.configuration]);
  const o = (s) => {
    i(s);
    try {
      const u = JSON.parse(s);
      r("configuration", u), n(null);
    } catch {
      n("Invalid JSON");
    }
  };
  return /* @__PURE__ */ _("div", { className: "h-full flex flex-col animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ _("div", { className: "mb-4", children: [
      /* @__PURE__ */ f("h3", { className: "text-xs font-bold text-slate-900 uppercase tracking-wider mb-2", children: "Raw JSON Configuration" }),
      /* @__PURE__ */ f("p", { className: "text-xs text-slate-500", children: "Edit the advanced configuration object for this schedule directly." })
    ] }),
    /* @__PURE__ */ _("div", { className: "flex-1 relative", children: [
      /* @__PURE__ */ f(
        "textarea",
        {
          value: a,
          onChange: (s) => o(s.target.value),
          className: `w-full h-96 p-4 font-mono text-xs border rounded-xl focus:outline-none focus:ring-2 focus:ring-teal-500/20 resize-none text-slate-900 ${t ? "border-red-500 focus:border-red-500 bg-red-50" : "border-slate-300 focus:border-teal-500 bg-slate-50"}`
        }
      ),
      t && /* @__PURE__ */ _("div", { className: "absolute bottom-4 right-4 bg-red-100 text-red-700 px-3 py-1.5 rounded-lg text-xs font-medium border border-red-200 shadow-sm flex items-center gap-2", children: [
        /* @__PURE__ */ f(Ze, { size: 14 }),
        t
      ] })
    ] })
  ] });
}, kr = ({ id: e, label: r, icon: t, activeTab: n, onSelect: a }) => /* @__PURE__ */ _(
  "button",
  {
    onClick: () => a(e),
    className: `flex items-center gap-1.5 py-3 px-1 border-b-2 transition-colors text-xs font-medium whitespace-nowrap flex-shrink-0 ${n === e ? "border-teal-600 text-teal-700" : "border-transparent text-slate-500 hover:text-slate-700 hover:border-slate-300"}`,
    children: [
      t,
      r
    ]
  }
), zm = ({ node: e, allNodes: r, onClose: t, onUpdate: n, onAddResourceRequest: a, onAddRequirementRequest: i }) => {
  const o = lp(), [s, u] = U("general"), l = !!o.testamentTypes, [c, d] = U([]), [h, p] = U([]), [x, v] = U({
    resourceMap: /* @__PURE__ */ new Map(),
    systemMap: /* @__PURE__ */ new Map(),
    planMap: /* @__PURE__ */ new Map(),
    testamentTypeMap: /* @__PURE__ */ new Map(),
    loading: !1,
    requirementsLoading: !1
  });
  le(() => {
    (async () => {
      try {
        const [w, I] = await Promise.all([
          o.getLocations({ pageSize: 100 }),
          o.getApprovalGroups({ pageSize: 100 })
        ]);
        d(w.items), p(I.items);
      } catch (w) {
        console.error("Failed to load options", w);
      }
    })();
  }, [o]), le(() => {
    e && (async () => {
      v((N) => ({ ...N, loading: !0 }));
      const w = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ new Set();
      if ([...e.resources, ...e._inheritedResources || []].forEach((N) => {
        w.add(N.resourceId), N.systemId && I.add(N.systemId), N.resourcePlanId && q.add(N.resourcePlanId);
      }), w.size > 0 || I.size > 0 || q.size > 0) {
        const [N, R, k] = await Promise.all([
          o.resolveResources(Array.from(w)),
          o.resolveSystems(Array.from(I)),
          o.resolvePlans(Array.from(q))
        ]);
        v((S) => ({ ...S, resourceMap: N, systemMap: R, planMap: k, loading: !1 }));
      } else
        v((N) => ({ ...N, loading: !1 }));
    })();
  }, [e == null ? void 0 : e.scheduleId, e == null ? void 0 : e.resources, e == null ? void 0 : e._inheritedResources, o]), le(() => {
    if (!e || !o.testamentTypes) return;
    (async () => {
      const w = Array.from(new Set((e.requirements || []).map((I) => I.testamentTypeId).filter(Boolean)));
      if (w.length === 0) {
        v((I) => ({ ...I, testamentTypeMap: /* @__PURE__ */ new Map(), requirementsLoading: !1 }));
        return;
      }
      v((I) => ({ ...I, requirementsLoading: !0 }));
      try {
        const I = await o.testamentTypes.resolve(w);
        v((q) => ({
          ...q,
          testamentTypeMap: new Map(I.map((N) => [N.testamentTypeId, N])),
          requirementsLoading: !1
        }));
      } catch (I) {
        console.error("Failed to resolve testament types", I), v((q) => ({ ...q, requirementsLoading: !1 }));
      }
    })();
  }, [e == null ? void 0 : e.scheduleId, e == null ? void 0 : e.requirements, o]), le(() => {
    !l && s === "requirements" && u("general");
  }, [s, l]);
  const m = _e(() => {
    if (!e) return /* @__PURE__ */ new Map();
    const y = /* @__PURE__ */ new Map();
    return e.resources.forEach((w) => {
      y.set(w.resourceId, {
        priority: e.priority,
        sourceName: "This Schedule",
        isDirect: !0
      });
    }), (e._inheritedResources || []).forEach((w) => {
      const I = y.get(w.resourceId);
      (!I || w.sourceNodePriority > I.priority) && y.set(w.resourceId, {
        priority: w.sourceNodePriority,
        sourceName: w.sourceNodeName,
        isDirect: !1
      });
    }), y;
  }, [e == null ? void 0 : e.resources, e == null ? void 0 : e._inheritedResources, e == null ? void 0 : e.priority]);
  if (!e) return null;
  const b = (y, w) => {
    n(e.scheduleId, y, w);
  }, g = (y) => {
    if (!y) return "";
    const w = r.find((I) => I.scheduleId === y);
    return w ? w.name : y;
  };
  return /* @__PURE__ */ f(dr, { children: /* @__PURE__ */ _("div", { className: "absolute top-0 right-0 h-full w-[500px] bg-white shadow-2xl border-l border-slate-200 transform transition-transform duration-300 ease-in-out z-50 flex flex-col", children: [
    /* @__PURE__ */ _("div", { className: "p-6 pb-0 flex-none", children: [
      /* @__PURE__ */ _("div", { className: "flex items-center justify-between mb-4", children: [
        /* @__PURE__ */ _("div", { children: [
          /* @__PURE__ */ f("h2", { className: "text-xl font-bold text-slate-900", children: "Edit Schedule" }),
          /* @__PURE__ */ _("div", { className: "flex items-center gap-2 text-xs text-slate-400 font-mono mt-1", children: [
            /* @__PURE__ */ f("span", { children: "ID:" }),
            /* @__PURE__ */ f("span", { className: "truncate max-w-[200px]", children: e.scheduleId })
          ] })
        ] }),
        /* @__PURE__ */ _("div", { className: "flex items-center gap-1", children: [
          /* @__PURE__ */ f(
            "button",
            {
              onClick: () => u("config"),
              className: `p-2 rounded-full transition-colors ${s === "config" ? "bg-teal-50 text-teal-700" : "text-slate-500 hover:text-teal-600 hover:bg-slate-100"}`,
              title: "Config",
              children: /* @__PURE__ */ f(Lr, { size: 18 })
            }
          ),
          /* @__PURE__ */ f("button", { onClick: t, className: "p-2 hover:bg-slate-100 rounded-full text-slate-500 hover:text-teal-600 transition-colors", children: /* @__PURE__ */ f(Pe, { size: 20 }) })
        ] })
      ] }),
      /* @__PURE__ */ _("div", { className: "flex gap-3 border-b border-slate-200 overflow-x-auto", children: [
        /* @__PURE__ */ f(kr, { id: "general", label: "General", icon: /* @__PURE__ */ f(Oo, { size: 14 }), activeTab: s, onSelect: u }),
        /* @__PURE__ */ f(kr, { id: "logic", label: "Logic", icon: /* @__PURE__ */ f(tm, { size: 14 }), activeTab: s, onSelect: u }),
        /* @__PURE__ */ f(kr, { id: "resources", label: "Resources", icon: /* @__PURE__ */ f(fr, { size: 14 }), activeTab: s, onSelect: u }),
        l && /* @__PURE__ */ f(kr, { id: "requirements", label: "Requirements", icon: /* @__PURE__ */ f(Mo, { size: 14 }), activeTab: s, onSelect: u })
      ] })
    ] }),
    /* @__PURE__ */ _("div", { className: "flex-1 overflow-y-auto p-6 space-y-8", children: [
      s === "general" && /* @__PURE__ */ f(
        Lm,
        {
          node: e,
          handleUpdate: b,
          allNodes: r,
          getScheduleName: g
        }
      ),
      s === "logic" && /* @__PURE__ */ f(
        jm,
        {
          node: e,
          handleUpdate: b,
          availableLocations: c,
          availableApprovalGroups: h
        }
      ),
      s === "resources" && /* @__PURE__ */ f(
        Dm,
        {
          node: e,
          handleUpdate: b,
          inheritedResources: e._inheritedResources || [],
          resourceStatusMap: m,
          resourceMap: x.resourceMap,
          systemMap: x.systemMap,
          planMap: x.planMap,
          loading: x.loading,
          onAddResourceRequest: a
        }
      ),
      s === "requirements" && /* @__PURE__ */ f(
        Fm,
        {
          node: e,
          handleUpdate: b,
          testamentTypeMap: x.testamentTypeMap,
          loading: x.requirementsLoading,
          repositoryAvailable: l,
          onAddRequirementRequest: i
        }
      ),
      s === "config" && /* @__PURE__ */ f(
        Gm,
        {
          node: e,
          handleUpdate: b
        }
      )
    ] })
  ] }) });
}, Bm = ({ isOpen: e, onClose: r, onConfirm: t, count: n }) => e ? /* @__PURE__ */ f("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/50 backdrop-blur-sm p-4 animate-in fade-in duration-200", children: /* @__PURE__ */ f("div", { className: "bg-white rounded-xl shadow-2xl w-full max-w-md overflow-hidden border border-slate-200 transform scale-100", children: /* @__PURE__ */ _("div", { className: "p-6 text-center", children: [
  /* @__PURE__ */ f("div", { className: "w-12 h-12 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4 text-red-600", children: /* @__PURE__ */ f(Ze, { size: 24 }) }),
  /* @__PURE__ */ _("h3", { className: "text-lg font-bold text-slate-900 mb-2", children: [
    "Delete ",
    n,
    " Selected Node",
    n !== 1 ? "s" : "",
    "?"
  ] }),
  /* @__PURE__ */ _("p", { className: "text-sm text-slate-500 mb-6", children: [
    "This action cannot be undone. Any connections to ",
    n !== 1 ? "these nodes" : "this node",
    " will also be removed."
  ] }),
  /* @__PURE__ */ _("div", { className: "flex gap-3 justify-center", children: [
    /* @__PURE__ */ f(
      "button",
      {
        onClick: r,
        className: "px-4 py-2 bg-white border border-slate-300 rounded-lg text-slate-700 text-sm font-medium hover:bg-slate-50 transition-colors",
        children: "Cancel"
      }
    ),
    /* @__PURE__ */ _(
      "button",
      {
        onClick: t,
        className: "px-4 py-2 bg-red-600 rounded-lg text-white text-sm font-medium hover:bg-red-700 transition-colors flex items-center gap-2 shadow-sm shadow-red-600/20",
        children: [
          /* @__PURE__ */ f(Je, { size: 16 }),
          " Delete"
        ]
      }
    )
  ] })
] }) }) }) : null, Um = (e) => e.isOpen ? /* @__PURE__ */ f($m, { ...e }) : null, $m = ({ onClose: e, data: r, onSave: t }) => {
  const [n, a] = U(() => ({ ...r })), [i, o] = U(null), [s, u] = U(() => JSON.stringify(r.configuration, null, 2)), l = (d) => {
    u(d);
    try {
      const h = JSON.parse(d);
      a((p) => ({ ...p, configuration: h })), o(null);
    } catch {
      o("Invalid JSON format");
    }
  }, c = () => {
    i || (t(n), e());
  };
  return /* @__PURE__ */ f("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/50 backdrop-blur-sm p-4 animate-in fade-in duration-200", children: /* @__PURE__ */ _("div", { className: "bg-white rounded-xl shadow-2xl w-full max-w-lg overflow-hidden border border-slate-200", children: [
    /* @__PURE__ */ _("div", { className: "flex items-center justify-between px-6 py-4 border-b border-slate-100 bg-slate-50", children: [
      /* @__PURE__ */ _("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ f("div", { className: "bg-teal-100 p-1.5 rounded-lg text-teal-700", children: /* @__PURE__ */ f($p, { size: 18 }) }),
        /* @__PURE__ */ f("h2", { className: "text-lg font-bold text-slate-900", children: "Global Settings" })
      ] }),
      /* @__PURE__ */ f("button", { onClick: e, className: "p-2 hover:bg-slate-200 rounded-full text-slate-400 transition-colors", children: /* @__PURE__ */ f(Pe, { size: 20 }) })
    ] }),
    /* @__PURE__ */ _("div", { className: "p-6 space-y-5 max-h-[70vh] overflow-y-auto", children: [
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ f("label", { htmlFor: "gs-name", className: "block text-xs font-bold text-slate-500 uppercase tracking-wider mb-1.5", children: "Entitlement Name" }),
        /* @__PURE__ */ f(
          "input",
          {
            id: "gs-name",
            type: "text",
            value: n.name,
            onChange: (d) => a({ ...n, name: d.target.value }),
            className: "w-full p-2 bg-white text-slate-900 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-teal-500 focus:ring-2 focus:ring-teal-500/20"
          }
        )
      ] }),
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ f("label", { htmlFor: "gs-tags", className: "block text-xs font-bold text-slate-500 uppercase tracking-wider mb-1.5", children: "Global Tags" }),
        /* @__PURE__ */ f(
          So,
          {
            id: "gs-tags",
            tags: n.tags,
            onChange: (d) => a({ ...n, tags: d }),
            colorClass: "bg-teal-50 text-teal-700 border-teal-200"
          }
        )
      ] }),
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ f("label", { htmlFor: "gs-config", className: "block text-xs font-bold text-slate-500 uppercase tracking-wider mb-1.5", children: "Configuration (JSON)" }),
        /* @__PURE__ */ f(
          "textarea",
          {
            id: "gs-config",
            value: s,
            onChange: (d) => l(d.target.value),
            className: `w-full h-40 p-3 font-mono text-xs border rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500/20 bg-white text-slate-900 ${i ? "border-red-500 focus:border-red-500" : "border-slate-300 focus:border-teal-500"}`
          }
        ),
        i && /* @__PURE__ */ f("p", { className: "text-red-500 text-xs mt-1", children: i })
      ] })
    ] }),
    /* @__PURE__ */ _("div", { className: "px-6 py-4 border-t border-slate-100 bg-slate-50 flex justify-end gap-3", children: [
      /* @__PURE__ */ f("button", { onClick: e, className: "px-4 py-2 text-slate-600 font-medium text-sm hover:bg-slate-100 rounded-lg", children: "Cancel" }),
      /* @__PURE__ */ _(
        "button",
        {
          onClick: c,
          disabled: !!i,
          className: "px-4 py-2 bg-teal-600 text-white font-medium text-sm rounded-lg hover:bg-teal-700 disabled:opacity-50 flex items-center gap-2",
          children: [
            /* @__PURE__ */ f(Hh, { size: 16 }),
            " Save Changes"
          ]
        }
      )
    ] })
  ] }) });
}, Vm = (e) => e.isOpen ? /* @__PURE__ */ f(Hm, { ...e }) : null, Hm = ({ onClose: e, onConfirm: r, repositories: t }) => {
  const [n, a] = U(1), [i, o] = U(/* @__PURE__ */ new Set()), [s, u] = U(""), [l, c] = U({}), [d, h] = U(""), [p, x] = U([]), [v, m] = U([]), [b, g] = U(/* @__PURE__ */ new Map()), [y, w] = U(!1), I = xe(null);
  le(() => {
    q(), N("");
  }, []);
  const q = async () => {
    try {
      const O = await t.getPlans({ pageSize: 100 });
      m(O.items);
    } catch (O) {
      console.error("Failed to fetch plans", O);
    }
  }, N = async (O) => {
    w(!0);
    try {
      const z = await t.getResources({
        filter: O,
        pageSize: 1e3
        // Increase page size now that we have virtualization
      });
      x(z.items);
      const j = /* @__PURE__ */ new Set();
      if (z.items.forEach((F) => {
        F.systemId && j.add(F.systemId);
      }), j.size > 0) {
        const F = await t.resolveSystems(Array.from(j));
        g((te) => new Map([...te, ...F]));
      }
    } catch (z) {
      console.error("Failed to fetch resources", z);
    } finally {
      w(!1);
    }
  }, R = (O) => {
    const z = O.target.value;
    u(z), I.current && clearTimeout(I.current), I.current = setTimeout(() => {
      N(z);
    }, 300);
  }, k = (O) => {
    const z = new Set(i);
    if (z.has(O)) {
      z.delete(O);
      const j = { ...l };
      delete j[O], c(j);
    } else
      z.add(O), c((j) => ({
        ...j,
        [O]: { planId: "" }
        // Initialize empty config
      }));
    o(z);
  }, S = (O, z, j) => {
    c((F) => ({
      ...F,
      [O]: {
        ...F[O],
        [z]: j
      }
    }));
  }, E = (O) => {
    if (h(O), !O) return;
    const z = v.find((j) => j.id === O);
    z && c((j) => {
      const F = { ...j };
      return i.forEach((te) => {
        const ne = p.find((ie) => ie.id === te);
        ne && ne.systemId === z.systemId && ne.resourceKind !== de.Fixed && F[te] && (F[te] = { ...F[te], planId: O });
      }), F;
    });
  }, A = (O) => {
    const z = new Set(i);
    z.delete(O), o(z);
    const j = { ...l };
    delete j[O], c(j), z.size === 0 && a(1);
  }, P = () => {
    const O = [];
    i.forEach((z) => {
      const j = l[z], F = p.find((te) => te.id === z);
      F && F.systemId && (F.resourceKind === de.Fixed ? O.push({
        systemId: F.systemId,
        resourceId: z,
        resourcePlanId: null
        // Fixed resources do not need a plan
      }) : j && j.planId && O.push({
        systemId: F.systemId,
        resourceId: z,
        resourcePlanId: j.planId
      }));
    }), r(O), e();
  }, G = () => Array.from(i).every((O) => {
    const z = p.find((F) => F.id === O);
    if ((z == null ? void 0 : z.resourceKind) === de.Fixed) return !0;
    const j = l[O];
    return j && j.planId;
  }), H = (O) => {
    if (!O) return "Unknown";
    const z = b.get(O);
    return z ? z.name : O;
  }, ee = _e(() => {
    const O = /* @__PURE__ */ new Map();
    return v.forEach((z) => {
      var F;
      const j = z.systemId;
      O.has(j) || O.set(j, []), (F = O.get(j)) == null || F.push(z);
    }), O;
  }, [v]);
  return /* @__PURE__ */ f("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/50 backdrop-blur-sm p-4 animate-in fade-in duration-200", children: /* @__PURE__ */ _("div", { className: "bg-white rounded-xl shadow-2xl w-full max-w-5xl h-[85vh] flex flex-col overflow-hidden border border-slate-200", children: [
    /* @__PURE__ */ _("div", { className: "px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50", children: [
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ f("h2", { className: "text-lg font-bold text-slate-900", children: "Add Resources" }),
        /* @__PURE__ */ _("div", { className: "flex items-center gap-2 text-xs text-slate-500 mt-1", children: [
          /* @__PURE__ */ f("span", { className: n === 1 ? "text-teal-600 font-semibold" : "", children: "1. Select Resources" }),
          /* @__PURE__ */ f("span", { className: "text-slate-300", children: "/" }),
          /* @__PURE__ */ f("span", { className: n === 2 ? "text-teal-600 font-semibold" : "", children: "2. Assign Plans" })
        ] })
      ] }),
      /* @__PURE__ */ f("button", { onClick: e, className: "p-2 hover:bg-slate-200 rounded-full text-slate-400 transition-colors", children: /* @__PURE__ */ f(Pe, { size: 20 }) })
    ] }),
    /* @__PURE__ */ _("div", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
      n === 1 && /* @__PURE__ */ _(dr, { children: [
        /* @__PURE__ */ _("div", { className: "p-4 border-b border-slate-100 flex gap-4 bg-white flex-shrink-0", children: [
          /* @__PURE__ */ _("div", { className: "relative flex-1", children: [
            /* @__PURE__ */ f(Ye, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", size: 18 }),
            /* @__PURE__ */ f(
              "input",
              {
                type: "text",
                placeholder: "Search resources by name, ID or description...",
                className: "w-full pl-10 pr-4 py-2 bg-slate-50 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-teal-500/20 focus:border-teal-500 transition-all",
                value: s,
                onChange: R
              }
            )
          ] }),
          /* @__PURE__ */ f("div", { className: "flex items-center gap-2 px-3 py-2 bg-slate-50 rounded-lg border border-slate-200 text-slate-600 text-sm min-w-[100px] justify-center", children: y ? /* @__PURE__ */ f($h, { size: 16, className: "animate-spin text-teal-600" }) : /* @__PURE__ */ _(dr, { children: [
            /* @__PURE__ */ f(Po, { size: 16 }),
            /* @__PURE__ */ _("span", { className: "font-medium", children: [
              p.length,
              " Found"
            ] })
          ] }) })
        ] }),
        /* @__PURE__ */ f("div", { className: "bg-white border-b border-slate-200 shadow-sm z-10 flex-shrink-0", children: /* @__PURE__ */ _("div", { className: "flex text-left text-sm", children: [
          /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[60px] text-center", children: /* @__PURE__ */ f("div", { className: "w-4 h-4 mx-auto border-2 border-slate-300 rounded" }) }),
          /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider flex-1", children: "Resource" }),
          /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[25%] hidden md:block", children: "Description" }),
          /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[15%]", children: "Type" }),
          /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[20%]", children: "System" })
        ] }) }),
        /* @__PURE__ */ _("div", { className: "flex-1 overflow-hidden bg-slate-50 relative", children: [
          p.length === 0 && !y && /* @__PURE__ */ _("div", { className: "absolute inset-0 flex flex-col items-center justify-center text-slate-400", children: [
            /* @__PURE__ */ f(Ye, { size: 32, className: "mx-auto mb-2 opacity-20" }),
            'No resources found matching "',
            s,
            '"'
          ] }),
          /* @__PURE__ */ f(
            Tr,
            {
              items: p,
              height: "100%",
              itemHeight: 64,
              renderItem: (O, z) => {
                const j = i.has(O.id);
                return /* @__PURE__ */ _(
                  "div",
                  {
                    role: "button",
                    tabIndex: 0,
                    onClick: () => k(O.id),
                    onKeyDown: (F) => {
                      (F.key === "Enter" || F.key === " ") && (F.preventDefault(), k(O.id));
                    },
                    className: `
                                            flex items-center text-sm border-b border-slate-100 cursor-pointer transition-colors h-[64px]
                                            ${j ? "bg-teal-50 hover:bg-teal-100" : "bg-white hover:bg-slate-50"}
                                        `,
                    children: [
                      /* @__PURE__ */ f("div", { className: "px-4 w-[60px] text-center flex-shrink-0", children: /* @__PURE__ */ f("div", { className: `
                                                w-4 h-4 mx-auto rounded border flex items-center justify-center transition-all
                                                ${j ? "bg-teal-500 border-teal-500 text-white" : "border-slate-300 bg-white"}
                                            `, children: j && /* @__PURE__ */ f(Ar, { size: 10, strokeWidth: 4 }) }) }),
                      /* @__PURE__ */ _("div", { className: "px-4 flex-1 min-w-0", children: [
                        /* @__PURE__ */ f("div", { className: `font-medium truncate ${j ? "text-teal-900" : "text-slate-900"}`, children: O.name }),
                        /* @__PURE__ */ _("div", { className: "flex gap-2 text-[10px] mt-1", children: [
                          /* @__PURE__ */ f("span", { className: "font-mono text-slate-400", children: O.id }),
                          /* @__PURE__ */ f("span", { className: "bg-slate-100 px-1 rounded text-slate-500 border border-slate-200", children: O.resourceKind })
                        ] })
                      ] }),
                      /* @__PURE__ */ f("div", { className: "px-4 w-[25%] hidden md:block text-slate-500 truncate", children: O.description || /* @__PURE__ */ f("span", { className: "text-slate-300 italic", children: "No description" }) }),
                      /* @__PURE__ */ f("div", { className: "px-4 w-[15%] text-slate-500 truncate", children: O.resourceType }),
                      /* @__PURE__ */ _("div", { className: "px-4 w-[20%] flex items-center gap-1.5 text-slate-600 truncate", children: [
                        /* @__PURE__ */ f(fr, { size: 14, className: "text-slate-400 flex-shrink-0" }),
                        /* @__PURE__ */ f("span", { className: "truncate", children: H(O.systemId) })
                      ] })
                    ]
                  },
                  O.id
                );
              }
            }
          )
        ] })
      ] }),
      n === 2 && /* @__PURE__ */ _("div", { className: "h-full flex flex-col bg-slate-50", children: [
        /* @__PURE__ */ f("div", { className: "p-4 bg-white border-b border-slate-200 shadow-sm z-10 flex-shrink-0", children: /* @__PURE__ */ _("div", { className: "flex items-center gap-4", children: [
          /* @__PURE__ */ _("div", { className: "text-xs font-bold text-slate-500 uppercase tracking-wider whitespace-nowrap", children: [
            "Apply to all ",
            i.size,
            " items:"
          ] }),
          /* @__PURE__ */ f("div", { className: "flex-1 max-w-md", children: /* @__PURE__ */ _("div", { className: "relative", children: [
            /* @__PURE__ */ f(Lr, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", size: 14 }),
            /* @__PURE__ */ _(
              "select",
              {
                className: "w-full pl-9 pr-3 py-1.5 text-xs border border-slate-300 rounded-lg focus:outline-none focus:border-teal-500 bg-slate-50",
                value: d,
                onChange: (O) => E(O.target.value),
                children: [
                  /* @__PURE__ */ f("option", { value: "", children: "Select Plan..." }),
                  Array.from(ee.keys()).map((O) => {
                    const z = H(O), j = ee.get(O) || [];
                    return /* @__PURE__ */ f("optgroup", { label: z, children: j.map((F) => /* @__PURE__ */ f("option", { value: F.id, children: F.name }, F.id)) }, O);
                  })
                ]
              }
            )
          ] }) })
        ] }) }),
        /* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto p-4 relative", children: /* @__PURE__ */ _("div", { className: "bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden h-full flex flex-col", children: [
          /* @__PURE__ */ _("div", { className: "flex text-left text-sm bg-slate-50 border-b border-slate-200 flex-shrink-0", children: [
            /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[40%]", children: "Resource" }),
            /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[25%]", children: "System" }),
            /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[30%]", children: "Plan" }),
            /* @__PURE__ */ f("div", { className: "px-4 py-3 w-10" })
          ] }),
          /* @__PURE__ */ f("div", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ f(
            Tr,
            {
              items: Array.from(i),
              height: "100%",
              itemHeight: 64,
              renderItem: (O, z) => {
                const j = p.find((ie) => ie.id === O), F = l[O] || { planId: "" }, te = (j == null ? void 0 : j.resourceKind) === de.Fixed, ne = v.filter((ie) => ie.systemId === (j == null ? void 0 : j.systemId));
                return /* @__PURE__ */ _("div", { className: "flex items-center text-sm border-b border-slate-100 h-[64px] bg-white group hover:bg-slate-50", children: [
                  /* @__PURE__ */ _("div", { className: "px-4 w-[40%]", children: [
                    /* @__PURE__ */ f("div", { className: "font-medium text-slate-900 truncate", children: (j == null ? void 0 : j.name) || O }),
                    /* @__PURE__ */ _("div", { className: "flex gap-2 text-[10px] mt-0.5", children: [
                      /* @__PURE__ */ f("span", { className: "text-slate-400 font-mono", children: O }),
                      /* @__PURE__ */ f("span", { className: "bg-slate-100 px-1 rounded text-slate-500 border border-slate-200", children: j == null ? void 0 : j.resourceKind })
                    ] })
                  ] }),
                  /* @__PURE__ */ f("div", { className: "px-4 w-[25%]", children: /* @__PURE__ */ _("div", { className: "flex items-center gap-1.5 text-slate-500 text-xs truncate", children: [
                    /* @__PURE__ */ f(fr, { size: 12, className: "text-slate-400 flex-shrink-0" }),
                    /* @__PURE__ */ f("span", { className: "truncate", children: H(j == null ? void 0 : j.systemId) })
                  ] }) }),
                  /* @__PURE__ */ f("div", { className: "px-4 w-[30%]", children: te ? /* @__PURE__ */ _("div", { className: "flex items-center gap-2 text-slate-400 text-xs italic bg-slate-100 px-2 py-1.5 rounded border border-slate-200 w-fit", children: [
                    /* @__PURE__ */ f("div", { className: "w-1.5 h-1.5 rounded-full bg-slate-400" }),
                    "Included in Resource"
                  ] }) : /* @__PURE__ */ _(
                    "select",
                    {
                      className: `w-full p-2 border rounded-lg text-xs focus:outline-none focus:border-teal-500 transition-colors ${F.planId ? "border-slate-200" : "border-red-200 bg-red-50 text-red-800"}`,
                      value: F.planId,
                      onChange: (ie) => S(O, "planId", ie.target.value),
                      disabled: ne.length === 0,
                      children: [
                        /* @__PURE__ */ f("option", { value: "", children: ne.length === 0 ? "No plans" : "Select Plan..." }),
                        ne.map((ie) => /* @__PURE__ */ _("option", { value: ie.id, children: [
                          ie.name,
                          " (P",
                          ie.priority,
                          ")"
                        ] }, ie.id))
                      ]
                    }
                  ) }),
                  /* @__PURE__ */ f("div", { className: "px-4 flex-1 text-right", children: /* @__PURE__ */ f(
                    "button",
                    {
                      onClick: () => A(O),
                      className: "p-2 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors",
                      title: "Remove",
                      children: /* @__PURE__ */ f(Je, { size: 16 })
                    }
                  ) })
                ] }, O);
              }
            }
          ) })
        ] }) })
      ] })
    ] }),
    /* @__PURE__ */ _("div", { className: "px-6 py-4 border-t border-slate-200 bg-white flex justify-between items-center flex-shrink-0", children: [
      /* @__PURE__ */ f("div", { className: "text-sm text-slate-500", children: i.size > 0 && /* @__PURE__ */ _("span", { className: "font-medium text-slate-900", children: [
        i.size,
        " resources selected"
      ] }) }),
      /* @__PURE__ */ _("div", { className: "flex gap-3", children: [
        n === 2 && /* @__PURE__ */ _(
          "button",
          {
            onClick: () => a(1),
            className: "px-4 py-2 text-slate-600 font-medium text-sm hover:bg-slate-100 rounded-lg flex items-center gap-2",
            children: [
              /* @__PURE__ */ f(Gh, { size: 16 }),
              " Back"
            ]
          }
        ),
        n === 1 ? /* @__PURE__ */ _(
          "button",
          {
            onClick: () => a(2),
            disabled: i.size === 0,
            className: "bg-slate-900 hover:bg-slate-800 disabled:bg-slate-200 disabled:text-slate-400 text-white px-5 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-colors shadow-sm",
            children: [
              "Next: Configuration ",
              /* @__PURE__ */ f(xp, { size: 16 })
            ]
          }
        ) : /* @__PURE__ */ _(
          "button",
          {
            onClick: P,
            disabled: !G(),
            className: "bg-teal-600 hover:bg-teal-700 disabled:bg-slate-200 disabled:text-slate-400 text-white px-6 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-colors shadow-sm shadow-teal-600/20",
            children: [
              /* @__PURE__ */ f(Pp, { size: 18 }),
              " Confirm & Add Resources"
            ]
          }
        )
      ] })
    ] })
  ] }) });
}, Km = (e) => e.isOpen ? /* @__PURE__ */ f(Wm, { ...e }) : null, Wm = ({
  onClose: e,
  onConfirm: r,
  repository: t,
  excludedIds: n
}) => {
  const [a, i] = U(""), [o, s] = U([]), [u, l] = U(/* @__PURE__ */ new Set()), [c, d] = U(!1), h = xe(null), p = new Set(n);
  le(() => (x(""), () => {
    h.current && clearTimeout(h.current);
  }), []);
  const x = async (g) => {
    if (t) {
      d(!0);
      try {
        const y = await t.search(g);
        s(y);
      } catch (y) {
        console.error("Failed to fetch testament types", y);
      } finally {
        d(!1);
      }
    }
  }, v = (g) => {
    const y = g.target.value;
    i(y), h.current && clearTimeout(h.current), h.current = setTimeout(() => {
      x(y);
    }, 300);
  }, m = (g) => {
    if (p.has(g)) return;
    const y = new Set(u);
    y.has(g) ? y.delete(g) : y.add(g), l(y);
  }, b = () => {
    r(o.filter((g) => u.has(g.testamentTypeId))), e();
  };
  return /* @__PURE__ */ f("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/50 backdrop-blur-sm p-4 animate-in fade-in duration-200", children: /* @__PURE__ */ _("div", { className: "bg-white rounded-xl shadow-2xl w-full max-w-4xl h-[75vh] flex flex-col overflow-hidden border border-slate-200", children: [
    /* @__PURE__ */ _("div", { className: "px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50", children: [
      /* @__PURE__ */ _("div", { children: [
        /* @__PURE__ */ f("h2", { className: "text-lg font-bold text-slate-900", children: "Add Requirements" }),
        /* @__PURE__ */ _("div", { className: "text-xs text-slate-500 mt-1", children: [
          u.size,
          " testament types selected"
        ] })
      ] }),
      /* @__PURE__ */ f("button", { onClick: e, className: "p-2 hover:bg-slate-200 rounded-full text-slate-400 transition-colors", children: /* @__PURE__ */ f(Pe, { size: 20 }) })
    ] }),
    /* @__PURE__ */ _("div", { className: "p-4 border-b border-slate-100 flex gap-4 bg-white flex-shrink-0", children: [
      /* @__PURE__ */ _("div", { className: "relative flex-1", children: [
        /* @__PURE__ */ f(Ye, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", size: 18 }),
        /* @__PURE__ */ f(
          "input",
          {
            type: "text",
            placeholder: "Search testament types by name...",
            className: "w-full pl-10 pr-4 py-2 bg-slate-50 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-teal-500/20 focus:border-teal-500 transition-all",
            value: a,
            onChange: v
          }
        )
      ] }),
      /* @__PURE__ */ f("div", { className: "flex items-center gap-2 px-3 py-2 bg-slate-50 rounded-lg border border-slate-200 text-slate-600 text-sm min-w-[100px] justify-center", children: c ? /* @__PURE__ */ f($h, { size: 16, className: "animate-spin text-teal-600" }) : /* @__PURE__ */ _(dr, { children: [
        /* @__PURE__ */ f(Po, { size: 16 }),
        /* @__PURE__ */ _("span", { className: "font-medium", children: [
          o.length,
          " Found"
        ] })
      ] }) })
    ] }),
    /* @__PURE__ */ f("div", { className: "bg-white border-b border-slate-200 shadow-sm z-10 flex-shrink-0", children: /* @__PURE__ */ _("div", { className: "flex text-left text-sm", children: [
      /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[60px] text-center", children: /* @__PURE__ */ f("div", { className: "w-4 h-4 mx-auto border-2 border-slate-300 rounded" }) }),
      /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider flex-1", children: "Testament Type" }),
      /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[25%] hidden md:block", children: "Category" }),
      /* @__PURE__ */ f("div", { className: "px-4 py-3 font-semibold text-slate-600 text-xs uppercase tracking-wider w-[25%]", children: "Properties" })
    ] }) }),
    /* @__PURE__ */ _("div", { className: "flex-1 overflow-hidden bg-slate-50 relative", children: [
      o.length === 0 && !c && /* @__PURE__ */ _("div", { className: "absolute inset-0 flex flex-col items-center justify-center text-slate-400", children: [
        /* @__PURE__ */ f(Ye, { size: 32, className: "mx-auto mb-2 opacity-20" }),
        'No testament types found matching "',
        a,
        '"'
      ] }),
      /* @__PURE__ */ f(
        Tr,
        {
          items: o,
          height: "100%",
          itemHeight: 72,
          renderItem: (g) => {
            const y = g.testamentTypeId, w = u.has(y), I = p.has(y);
            return /* @__PURE__ */ _(
              "div",
              {
                role: "button",
                tabIndex: I ? -1 : 0,
                onClick: () => m(y),
                onKeyDown: (q) => {
                  (q.key === "Enter" || q.key === " ") && (q.preventDefault(), m(y));
                },
                className: `
                    flex items-center text-sm border-b border-slate-100 h-[72px] transition-colors
                    ${I ? "bg-slate-100 cursor-not-allowed opacity-60" : "cursor-pointer"}
                    ${w ? "bg-teal-50 hover:bg-teal-100" : "bg-white hover:bg-slate-50"}
                  `,
                children: [
                  /* @__PURE__ */ f("div", { className: "px-4 w-[60px] text-center flex-shrink-0", children: /* @__PURE__ */ f("div", { className: `
                      w-4 h-4 mx-auto rounded border flex items-center justify-center transition-all
                      ${w ? "bg-teal-500 border-teal-500 text-white" : "border-slate-300 bg-white"}
                    `, children: w && /* @__PURE__ */ f(Ar, { size: 10, strokeWidth: 4 }) }) }),
                  /* @__PURE__ */ _("div", { className: "px-4 flex-1 min-w-0", children: [
                    /* @__PURE__ */ f("div", { className: `font-medium truncate ${w ? "text-teal-900" : "text-slate-900"}`, children: g.name }),
                    /* @__PURE__ */ _("div", { className: "flex gap-2 text-[10px] mt-1", children: [
                      /* @__PURE__ */ f("span", { className: "font-mono text-slate-400", children: y }),
                      I && /* @__PURE__ */ f("span", { className: "bg-slate-200 px-1 rounded text-slate-500 border border-slate-300", children: "Already added" }),
                      g.isDeprecated && /* @__PURE__ */ f("span", { className: "bg-amber-50 text-amber-700 px-1 rounded border border-amber-200", children: "Deprecated" })
                    ] })
                  ] }),
                  /* @__PURE__ */ f("div", { className: "px-4 w-[25%] hidden md:block text-slate-500 truncate", children: g.category || /* @__PURE__ */ f("span", { className: "text-slate-300 italic", children: "Uncategorized" }) }),
                  /* @__PURE__ */ _("div", { className: "px-4 w-[25%] flex flex-wrap gap-1.5 text-[10px] text-slate-500", children: [
                    g.requiresDocument && /* @__PURE__ */ _("span", { className: "bg-indigo-50 text-indigo-700 px-1.5 py-0.5 rounded border border-indigo-100 flex items-center gap-1", children: [
                      /* @__PURE__ */ f(Mo, { size: 9 }),
                      " Document"
                    ] }),
                    g.isRenewable && /* @__PURE__ */ f("span", { className: "bg-emerald-50 text-emerald-700 px-1.5 py-0.5 rounded border border-emerald-100", children: "Renewable" })
                  ] })
                ]
              },
              y
            );
          }
        }
      )
    ] }),
    /* @__PURE__ */ _("div", { className: "px-6 py-4 border-t border-slate-200 bg-white flex justify-between items-center flex-shrink-0", children: [
      /* @__PURE__ */ f("div", { className: "text-sm text-slate-500", children: u.size > 0 && /* @__PURE__ */ _("span", { className: "font-medium text-slate-900", children: [
        u.size,
        " requirements selected"
      ] }) }),
      /* @__PURE__ */ _("div", { className: "flex gap-3", children: [
        /* @__PURE__ */ f(
          "button",
          {
            onClick: e,
            className: "px-4 py-2 text-slate-600 font-medium text-sm hover:bg-slate-100 rounded-lg",
            children: "Cancel"
          }
        ),
        /* @__PURE__ */ _(
          "button",
          {
            onClick: b,
            disabled: u.size === 0,
            className: "bg-teal-600 hover:bg-teal-700 disabled:bg-slate-200 disabled:text-slate-400 text-white px-6 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-colors shadow-sm shadow-teal-600/20",
            children: [
              /* @__PURE__ */ f(Ar, { size: 18 }),
              " Add Requirements"
            ]
          }
        )
      ] })
    ] })
  ] }) });
}, Ym = ({ x: e, y: r, items: t, onClose: n }) => {
  const a = xe(null);
  return le(() => {
    const i = (o) => {
      a.current && !a.current.contains(o.target) && n();
    };
    return document.addEventListener("mousedown", i), () => document.removeEventListener("mousedown", i);
  }, [n]), /* @__PURE__ */ f(
    "div",
    {
      ref: a,
      className: "fixed z-[1000] bg-white rounded-lg shadow-xl border border-slate-200 min-w-[180px] py-1.5 animate-in fade-in zoom-in-95 duration-100",
      style: { top: r, left: e },
      children: t.map((i) => /* @__PURE__ */ f(Co.Fragment, { children: /* @__PURE__ */ _(
        "button",
        {
          onClick: () => {
            i.disabled || (i.onClick(), n());
          },
          disabled: i.disabled,
          className: `w-full text-left px-3 py-2 text-xs font-medium flex items-center gap-2 transition-colors
              ${i.danger ? "text-red-600 hover:bg-red-50" : "text-slate-700 hover:bg-slate-100"}
              ${i.disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
            `,
          children: [
            i.icon && /* @__PURE__ */ f("span", { className: "w-4 h-4 flex items-center justify-center", children: i.icon }),
            i.label
          ]
        }
      ) }, i.label))
    }
  );
}, Jm = ({ nodes: e, onSelectNode: r }) => {
  const [t, n] = U(""), [a, i] = U(0), [o, s] = U(!0), u = xe(null), { setCenter: l, setNodes: c } = Ao(), d = _e(() => {
    if (!t.trim()) return [];
    const b = t.toLowerCase();
    return e.filter((g) => {
      const y = g.data;
      return y.name.toLowerCase().includes(b) || y.purpose.toLowerCase().includes(b) || y.group.toLowerCase().includes(b);
    });
  }, [e, t]);
  le(() => {
    const b = (g) => {
      var y;
      (g.ctrlKey || g.metaKey) && g.key === "f" && (g.preventDefault(), s(!0), (y = u.current) == null || y.focus());
    };
    return window.addEventListener("keydown", b), () => window.removeEventListener("keydown", b);
  }, []);
  const h = (b, g = !1) => {
    const y = d[b];
    if (!y) return;
    r(y.data), c(
      (q) => q.map((N) => ({
        ...N,
        selected: N.id === y.id
      }))
    );
    const w = y.position.x + 140, I = y.position.y + 60;
    l(w, I, {
      zoom: 1.2,
      duration: g ? 800 : 600
    });
  }, p = (b) => {
    const g = b.target.value;
    n(g), i(0);
  };
  le(() => {
    d.length > 0 && t && h(a, !0);
  }, [t]);
  const x = (b) => {
    if (b == null || b.preventDefault(), d.length === 0) return;
    const g = (a + 1) % d.length;
    i(g), h(g, !1);
  }, v = (b) => {
    if (b == null || b.preventDefault(), d.length === 0) return;
    const g = (a - 1 + d.length) % d.length;
    i(g), h(g, !1);
  }, m = (b) => {
    var g;
    b.key === "Enter" && x(), b.key === "Escape" && (n(""), (g = u.current) == null || g.blur());
  };
  return o ? /* @__PURE__ */ f("div", { className: "absolute top-4 left-4 z-[60] w-full px-4 md:px-0 md:w-80 animate-in fade-in slide-in-from-top-2 duration-300", children: /* @__PURE__ */ _("div", { className: "bg-white/95 backdrop-blur shadow-xl rounded-xl border border-slate-200/50 flex items-center p-1.5 focus-within:ring-2 focus-within:ring-teal-500/30 transition-all", children: [
    /* @__PURE__ */ f("div", { className: "pl-2 text-slate-400", children: /* @__PURE__ */ f(Ye, { size: 18 }) }),
    /* @__PURE__ */ f(
      "input",
      {
        ref: u,
        type: "text",
        value: t,
        onChange: p,
        onKeyDown: m,
        placeholder: "Search schedules (Cmd+F)...",
        className: "flex-1 bg-transparent border-none outline-none px-2 py-1.5 text-sm text-slate-900 placeholder:text-slate-400"
      }
    ),
    t && /* @__PURE__ */ _("div", { className: "flex items-center gap-1 pr-1 border-l border-slate-100 ml-1 pl-2", children: [
      /* @__PURE__ */ f("span", { className: "text-[10px] font-bold text-slate-500 min-w-[32px] text-center", children: d.length > 0 ? `${a + 1}/${d.length}` : "0/0" }),
      /* @__PURE__ */ _("div", { className: "flex", children: [
        /* @__PURE__ */ f(
          "button",
          {
            onClick: v,
            disabled: d.length <= 1,
            className: "p-1 text-slate-400 hover:text-teal-600 disabled:opacity-30 rounded transition-colors",
            children: /* @__PURE__ */ f(Gh, { size: 14 })
          }
        ),
        /* @__PURE__ */ f(
          "button",
          {
            onClick: x,
            disabled: d.length <= 1,
            className: "p-1 text-slate-400 hover:text-teal-600 disabled:opacity-30 rounded transition-colors",
            children: /* @__PURE__ */ f(kp, { size: 14 })
          }
        )
      ] }),
      /* @__PURE__ */ f(
        "button",
        {
          onClick: () => n(""),
          className: "p-1 text-slate-400 hover:text-red-500 rounded transition-colors",
          children: /* @__PURE__ */ f(Pe, { size: 14 })
        }
      )
    ] })
  ] }) }) : null;
};
var Sr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Zm(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function Lo(e) {
  throw new Error('Could not dynamically require "' + e + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var st, sc;
function Xm() {
  if (sc) return st;
  sc = 1;
  function e() {
    this.__data__ = [], this.size = 0;
  }
  return st = e, st;
}
var ot, oc;
function Xe() {
  if (oc) return ot;
  oc = 1;
  function e(r, t) {
    return r === t || r !== r && t !== t;
  }
  return ot = e, ot;
}
var ct, cc;
function jr() {
  if (cc) return ct;
  cc = 1;
  var e = Xe();
  function r(t, n) {
    for (var a = t.length; a--; )
      if (e(t[a][0], n))
        return a;
    return -1;
  }
  return ct = r, ct;
}
var ut, uc;
function Qm() {
  if (uc) return ut;
  uc = 1;
  var e = jr(), r = Array.prototype, t = r.splice;
  function n(a) {
    var i = this.__data__, o = e(i, a);
    if (o < 0)
      return !1;
    var s = i.length - 1;
    return o == s ? i.pop() : t.call(i, o, 1), --this.size, !0;
  }
  return ut = n, ut;
}
var lt, lc;
function ev() {
  if (lc) return lt;
  lc = 1;
  var e = jr();
  function r(t) {
    var n = this.__data__, a = e(n, t);
    return a < 0 ? void 0 : n[a][1];
  }
  return lt = r, lt;
}
var dt, dc;
function rv() {
  if (dc) return dt;
  dc = 1;
  var e = jr();
  function r(t) {
    return e(this.__data__, t) > -1;
  }
  return dt = r, dt;
}
var ft, fc;
function tv() {
  if (fc) return ft;
  fc = 1;
  var e = jr();
  function r(t, n) {
    var a = this.__data__, i = e(a, t);
    return i < 0 ? (++this.size, a.push([t, n])) : a[i][1] = n, this;
  }
  return ft = r, ft;
}
var ht, hc;
function Dr() {
  if (hc) return ht;
  hc = 1;
  var e = Xm(), r = Qm(), t = ev(), n = rv(), a = tv();
  function i(o) {
    var s = -1, u = o == null ? 0 : o.length;
    for (this.clear(); ++s < u; ) {
      var l = o[s];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = e, i.prototype.delete = r, i.prototype.get = t, i.prototype.has = n, i.prototype.set = a, ht = i, ht;
}
var pt, pc;
function nv() {
  if (pc) return pt;
  pc = 1;
  var e = Dr();
  function r() {
    this.__data__ = new e(), this.size = 0;
  }
  return pt = r, pt;
}
var mt, mc;
function av() {
  if (mc) return mt;
  mc = 1;
  function e(r) {
    var t = this.__data__, n = t.delete(r);
    return this.size = t.size, n;
  }
  return mt = e, mt;
}
var vt, vc;
function iv() {
  if (vc) return vt;
  vc = 1;
  function e(r) {
    return this.__data__.get(r);
  }
  return vt = e, vt;
}
var gt, gc;
function sv() {
  if (gc) return gt;
  gc = 1;
  function e(r) {
    return this.__data__.has(r);
  }
  return gt = e, gt;
}
var bt, bc;
function Zh() {
  if (bc) return bt;
  bc = 1;
  var e = typeof Sr == "object" && Sr && Sr.Object === Object && Sr;
  return bt = e, bt;
}
var yt, yc;
function Se() {
  if (yc) return yt;
  yc = 1;
  var e = Zh(), r = typeof self == "object" && self && self.Object === Object && self, t = e || r || Function("return this")();
  return yt = t, yt;
}
var xt, xc;
function Qe() {
  if (xc) return xt;
  xc = 1;
  var e = Se(), r = e.Symbol;
  return xt = r, xt;
}
var _t, _c;
function ov() {
  if (_c) return _t;
  _c = 1;
  var e = Qe(), r = Object.prototype, t = r.hasOwnProperty, n = r.toString, a = e ? e.toStringTag : void 0;
  function i(o) {
    var s = t.call(o, a), u = o[a];
    try {
      o[a] = void 0;
      var l = !0;
    } catch {
    }
    var c = n.call(o);
    return l && (s ? o[a] = u : delete o[a]), c;
  }
  return _t = i, _t;
}
var wt, wc;
function cv() {
  if (wc) return wt;
  wc = 1;
  var e = Object.prototype, r = e.toString;
  function t(n) {
    return r.call(n);
  }
  return wt = t, wt;
}
var Nt, Nc;
function ze() {
  if (Nc) return Nt;
  Nc = 1;
  var e = Qe(), r = ov(), t = cv(), n = "[object Null]", a = "[object Undefined]", i = e ? e.toStringTag : void 0;
  function o(s) {
    return s == null ? s === void 0 ? a : n : i && i in Object(s) ? r(s) : t(s);
  }
  return Nt = o, Nt;
}
var It, Ic;
function we() {
  if (Ic) return It;
  Ic = 1;
  function e(r) {
    var t = typeof r;
    return r != null && (t == "object" || t == "function");
  }
  return It = e, It;
}
var qt, qc;
function br() {
  if (qc) return qt;
  qc = 1;
  var e = ze(), r = we(), t = "[object AsyncFunction]", n = "[object Function]", a = "[object GeneratorFunction]", i = "[object Proxy]";
  function o(s) {
    if (!r(s))
      return !1;
    var u = e(s);
    return u == n || u == a || u == t || u == i;
  }
  return qt = o, qt;
}
var kt, kc;
function uv() {
  if (kc) return kt;
  kc = 1;
  var e = Se(), r = e["__core-js_shared__"];
  return kt = r, kt;
}
var St, Sc;
function lv() {
  if (Sc) return St;
  Sc = 1;
  var e = uv(), r = (function() {
    var n = /[^.]+$/.exec(e && e.keys && e.keys.IE_PROTO || "");
    return n ? "Symbol(src)_1." + n : "";
  })();
  function t(n) {
    return !!r && r in n;
  }
  return St = t, St;
}
var Rt, Rc;
function Xh() {
  if (Rc) return Rt;
  Rc = 1;
  var e = Function.prototype, r = e.toString;
  function t(n) {
    if (n != null) {
      try {
        return r.call(n);
      } catch {
      }
      try {
        return n + "";
      } catch {
      }
    }
    return "";
  }
  return Rt = t, Rt;
}
var Ct, Cc;
function dv() {
  if (Cc) return Ct;
  Cc = 1;
  var e = br(), r = lv(), t = we(), n = Xh(), a = /[\\^$.*+?()[\]{}|]/g, i = /^\[object .+?Constructor\]$/, o = Function.prototype, s = Object.prototype, u = o.toString, l = s.hasOwnProperty, c = RegExp(
    "^" + u.call(l).replace(a, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
  );
  function d(h) {
    if (!t(h) || r(h))
      return !1;
    var p = e(h) ? c : i;
    return p.test(n(h));
  }
  return Ct = d, Ct;
}
var Et, Ec;
function fv() {
  if (Ec) return Et;
  Ec = 1;
  function e(r, t) {
    return r == null ? void 0 : r[t];
  }
  return Et = e, Et;
}
var At, Ac;
function Be() {
  if (Ac) return At;
  Ac = 1;
  var e = dv(), r = fv();
  function t(n, a) {
    var i = r(n, a);
    return e(i) ? i : void 0;
  }
  return At = t, At;
}
var Tt, Tc;
function jo() {
  if (Tc) return Tt;
  Tc = 1;
  var e = Be(), r = Se(), t = e(r, "Map");
  return Tt = t, Tt;
}
var Mt, Mc;
function Fr() {
  if (Mc) return Mt;
  Mc = 1;
  var e = Be(), r = e(Object, "create");
  return Mt = r, Mt;
}
var Ot, Oc;
function hv() {
  if (Oc) return Ot;
  Oc = 1;
  var e = Fr();
  function r() {
    this.__data__ = e ? e(null) : {}, this.size = 0;
  }
  return Ot = r, Ot;
}
var Pt, Pc;
function pv() {
  if (Pc) return Pt;
  Pc = 1;
  function e(r) {
    var t = this.has(r) && delete this.__data__[r];
    return this.size -= t ? 1 : 0, t;
  }
  return Pt = e, Pt;
}
var Lt, Lc;
function mv() {
  if (Lc) return Lt;
  Lc = 1;
  var e = Fr(), r = "__lodash_hash_undefined__", t = Object.prototype, n = t.hasOwnProperty;
  function a(i) {
    var o = this.__data__;
    if (e) {
      var s = o[i];
      return s === r ? void 0 : s;
    }
    return n.call(o, i) ? o[i] : void 0;
  }
  return Lt = a, Lt;
}
var jt, jc;
function vv() {
  if (jc) return jt;
  jc = 1;
  var e = Fr(), r = Object.prototype, t = r.hasOwnProperty;
  function n(a) {
    var i = this.__data__;
    return e ? i[a] !== void 0 : t.call(i, a);
  }
  return jt = n, jt;
}
var Dt, Dc;
function gv() {
  if (Dc) return Dt;
  Dc = 1;
  var e = Fr(), r = "__lodash_hash_undefined__";
  function t(n, a) {
    var i = this.__data__;
    return this.size += this.has(n) ? 0 : 1, i[n] = e && a === void 0 ? r : a, this;
  }
  return Dt = t, Dt;
}
var Ft, Fc;
function bv() {
  if (Fc) return Ft;
  Fc = 1;
  var e = hv(), r = pv(), t = mv(), n = vv(), a = gv();
  function i(o) {
    var s = -1, u = o == null ? 0 : o.length;
    for (this.clear(); ++s < u; ) {
      var l = o[s];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = e, i.prototype.delete = r, i.prototype.get = t, i.prototype.has = n, i.prototype.set = a, Ft = i, Ft;
}
var Gt, Gc;
function yv() {
  if (Gc) return Gt;
  Gc = 1;
  var e = bv(), r = Dr(), t = jo();
  function n() {
    this.size = 0, this.__data__ = {
      hash: new e(),
      map: new (t || r)(),
      string: new e()
    };
  }
  return Gt = n, Gt;
}
var zt, zc;
function xv() {
  if (zc) return zt;
  zc = 1;
  function e(r) {
    var t = typeof r;
    return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? r !== "__proto__" : r === null;
  }
  return zt = e, zt;
}
var Bt, Bc;
function Gr() {
  if (Bc) return Bt;
  Bc = 1;
  var e = xv();
  function r(t, n) {
    var a = t.__data__;
    return e(n) ? a[typeof n == "string" ? "string" : "hash"] : a.map;
  }
  return Bt = r, Bt;
}
var Ut, Uc;
function _v() {
  if (Uc) return Ut;
  Uc = 1;
  var e = Gr();
  function r(t) {
    var n = e(this, t).delete(t);
    return this.size -= n ? 1 : 0, n;
  }
  return Ut = r, Ut;
}
var $t, $c;
function wv() {
  if ($c) return $t;
  $c = 1;
  var e = Gr();
  function r(t) {
    return e(this, t).get(t);
  }
  return $t = r, $t;
}
var Vt, Vc;
function Nv() {
  if (Vc) return Vt;
  Vc = 1;
  var e = Gr();
  function r(t) {
    return e(this, t).has(t);
  }
  return Vt = r, Vt;
}
var Ht, Hc;
function Iv() {
  if (Hc) return Ht;
  Hc = 1;
  var e = Gr();
  function r(t, n) {
    var a = e(this, t), i = a.size;
    return a.set(t, n), this.size += a.size == i ? 0 : 1, this;
  }
  return Ht = r, Ht;
}
var Kt, Kc;
function Do() {
  if (Kc) return Kt;
  Kc = 1;
  var e = yv(), r = _v(), t = wv(), n = Nv(), a = Iv();
  function i(o) {
    var s = -1, u = o == null ? 0 : o.length;
    for (this.clear(); ++s < u; ) {
      var l = o[s];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = e, i.prototype.delete = r, i.prototype.get = t, i.prototype.has = n, i.prototype.set = a, Kt = i, Kt;
}
var Wt, Wc;
function qv() {
  if (Wc) return Wt;
  Wc = 1;
  var e = Dr(), r = jo(), t = Do(), n = 200;
  function a(i, o) {
    var s = this.__data__;
    if (s instanceof e) {
      var u = s.__data__;
      if (!r || u.length < n - 1)
        return u.push([i, o]), this.size = ++s.size, this;
      s = this.__data__ = new t(u);
    }
    return s.set(i, o), this.size = s.size, this;
  }
  return Wt = a, Wt;
}
var Yt, Yc;
function zr() {
  if (Yc) return Yt;
  Yc = 1;
  var e = Dr(), r = nv(), t = av(), n = iv(), a = sv(), i = qv();
  function o(s) {
    var u = this.__data__ = new e(s);
    this.size = u.size;
  }
  return o.prototype.clear = r, o.prototype.delete = t, o.prototype.get = n, o.prototype.has = a, o.prototype.set = i, Yt = o, Yt;
}
var Jt, Jc;
function Fo() {
  if (Jc) return Jt;
  Jc = 1;
  function e(r, t) {
    for (var n = -1, a = r == null ? 0 : r.length; ++n < a && t(r[n], n, r) !== !1; )
      ;
    return r;
  }
  return Jt = e, Jt;
}
var Zt, Zc;
function Qh() {
  if (Zc) return Zt;
  Zc = 1;
  var e = Be(), r = (function() {
    try {
      var t = e(Object, "defineProperty");
      return t({}, "", {}), t;
    } catch {
    }
  })();
  return Zt = r, Zt;
}
var Xt, Xc;
function Br() {
  if (Xc) return Xt;
  Xc = 1;
  var e = Qh();
  function r(t, n, a) {
    n == "__proto__" && e ? e(t, n, {
      configurable: !0,
      enumerable: !0,
      value: a,
      writable: !0
    }) : t[n] = a;
  }
  return Xt = r, Xt;
}
var Qt, Qc;
function Ur() {
  if (Qc) return Qt;
  Qc = 1;
  var e = Br(), r = Xe(), t = Object.prototype, n = t.hasOwnProperty;
  function a(i, o, s) {
    var u = i[o];
    (!(n.call(i, o) && r(u, s)) || s === void 0 && !(o in i)) && e(i, o, s);
  }
  return Qt = a, Qt;
}
var en, eu;
function yr() {
  if (eu) return en;
  eu = 1;
  var e = Ur(), r = Br();
  function t(n, a, i, o) {
    var s = !i;
    i || (i = {});
    for (var u = -1, l = a.length; ++u < l; ) {
      var c = a[u], d = o ? o(i[c], n[c], c, i, n) : void 0;
      d === void 0 && (d = n[c]), s ? r(i, c, d) : e(i, c, d);
    }
    return i;
  }
  return en = t, en;
}
var rn, ru;
function kv() {
  if (ru) return rn;
  ru = 1;
  function e(r, t) {
    for (var n = -1, a = Array(r); ++n < r; )
      a[n] = t(n);
    return a;
  }
  return rn = e, rn;
}
var tn, tu;
function Ae() {
  if (tu) return tn;
  tu = 1;
  function e(r) {
    return r != null && typeof r == "object";
  }
  return tn = e, tn;
}
var nn, nu;
function Sv() {
  if (nu) return nn;
  nu = 1;
  var e = ze(), r = Ae(), t = "[object Arguments]";
  function n(a) {
    return r(a) && e(a) == t;
  }
  return nn = n, nn;
}
var an, au;
function xr() {
  if (au) return an;
  au = 1;
  var e = Sv(), r = Ae(), t = Object.prototype, n = t.hasOwnProperty, a = t.propertyIsEnumerable, i = e(/* @__PURE__ */ (function() {
    return arguments;
  })()) ? e : function(o) {
    return r(o) && n.call(o, "callee") && !a.call(o, "callee");
  };
  return an = i, an;
}
var sn, iu;
function se() {
  if (iu) return sn;
  iu = 1;
  var e = Array.isArray;
  return sn = e, sn;
}
var sr = { exports: {} }, on, su;
function Rv() {
  if (su) return on;
  su = 1;
  function e() {
    return !1;
  }
  return on = e, on;
}
sr.exports;
var ou;
function er() {
  return ou || (ou = 1, (function(e, r) {
    var t = Se(), n = Rv(), a = r && !r.nodeType && r, i = a && !0 && e && !e.nodeType && e, o = i && i.exports === a, s = o ? t.Buffer : void 0, u = s ? s.isBuffer : void 0, l = u || n;
    e.exports = l;
  })(sr, sr.exports)), sr.exports;
}
var cn, cu;
function $r() {
  if (cu) return cn;
  cu = 1;
  var e = 9007199254740991, r = /^(?:0|[1-9]\d*)$/;
  function t(n, a) {
    var i = typeof n;
    return a = a ?? e, !!a && (i == "number" || i != "symbol" && r.test(n)) && n > -1 && n % 1 == 0 && n < a;
  }
  return cn = t, cn;
}
var un, uu;
function Go() {
  if (uu) return un;
  uu = 1;
  var e = 9007199254740991;
  function r(t) {
    return typeof t == "number" && t > -1 && t % 1 == 0 && t <= e;
  }
  return un = r, un;
}
var ln, lu;
function Cv() {
  if (lu) return ln;
  lu = 1;
  var e = ze(), r = Go(), t = Ae(), n = "[object Arguments]", a = "[object Array]", i = "[object Boolean]", o = "[object Date]", s = "[object Error]", u = "[object Function]", l = "[object Map]", c = "[object Number]", d = "[object Object]", h = "[object RegExp]", p = "[object Set]", x = "[object String]", v = "[object WeakMap]", m = "[object ArrayBuffer]", b = "[object DataView]", g = "[object Float32Array]", y = "[object Float64Array]", w = "[object Int8Array]", I = "[object Int16Array]", q = "[object Int32Array]", N = "[object Uint8Array]", R = "[object Uint8ClampedArray]", k = "[object Uint16Array]", S = "[object Uint32Array]", E = {};
  E[g] = E[y] = E[w] = E[I] = E[q] = E[N] = E[R] = E[k] = E[S] = !0, E[n] = E[a] = E[m] = E[i] = E[b] = E[o] = E[s] = E[u] = E[l] = E[c] = E[d] = E[h] = E[p] = E[x] = E[v] = !1;
  function A(P) {
    return t(P) && r(P.length) && !!E[e(P)];
  }
  return ln = A, ln;
}
var dn, du;
function Vr() {
  if (du) return dn;
  du = 1;
  function e(r) {
    return function(t) {
      return r(t);
    };
  }
  return dn = e, dn;
}
var or = { exports: {} };
or.exports;
var fu;
function zo() {
  return fu || (fu = 1, (function(e, r) {
    var t = Zh(), n = r && !r.nodeType && r, a = n && !0 && e && !e.nodeType && e, i = a && a.exports === n, o = i && t.process, s = (function() {
      try {
        var u = a && a.require && a.require("util").types;
        return u || o && o.binding && o.binding("util");
      } catch {
      }
    })();
    e.exports = s;
  })(or, or.exports)), or.exports;
}
var fn, hu;
function _r() {
  if (hu) return fn;
  hu = 1;
  var e = Cv(), r = Vr(), t = zo(), n = t && t.isTypedArray, a = n ? r(n) : e;
  return fn = a, fn;
}
var hn, pu;
function e0() {
  if (pu) return hn;
  pu = 1;
  var e = kv(), r = xr(), t = se(), n = er(), a = $r(), i = _r(), o = Object.prototype, s = o.hasOwnProperty;
  function u(l, c) {
    var d = t(l), h = !d && r(l), p = !d && !h && n(l), x = !d && !h && !p && i(l), v = d || h || p || x, m = v ? e(l.length, String) : [], b = m.length;
    for (var g in l)
      (c || s.call(l, g)) && !(v && // Safari 9 has enumerable `arguments.length` in strict mode.
      (g == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
      p && (g == "offset" || g == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
      x && (g == "buffer" || g == "byteLength" || g == "byteOffset") || // Skip index properties.
      a(g, b))) && m.push(g);
    return m;
  }
  return hn = u, hn;
}
var pn, mu;
function Hr() {
  if (mu) return pn;
  mu = 1;
  var e = Object.prototype;
  function r(t) {
    var n = t && t.constructor, a = typeof n == "function" && n.prototype || e;
    return t === a;
  }
  return pn = r, pn;
}
var mn, vu;
function r0() {
  if (vu) return mn;
  vu = 1;
  function e(r, t) {
    return function(n) {
      return r(t(n));
    };
  }
  return mn = e, mn;
}
var vn, gu;
function Ev() {
  if (gu) return vn;
  gu = 1;
  var e = r0(), r = e(Object.keys, Object);
  return vn = r, vn;
}
var gn, bu;
function Bo() {
  if (bu) return gn;
  bu = 1;
  var e = Hr(), r = Ev(), t = Object.prototype, n = t.hasOwnProperty;
  function a(i) {
    if (!e(i))
      return r(i);
    var o = [];
    for (var s in Object(i))
      n.call(i, s) && s != "constructor" && o.push(s);
    return o;
  }
  return gn = a, gn;
}
var bn, yu;
function Le() {
  if (yu) return bn;
  yu = 1;
  var e = br(), r = Go();
  function t(n) {
    return n != null && r(n.length) && !e(n);
  }
  return bn = t, bn;
}
var yn, xu;
function Ge() {
  if (xu) return yn;
  xu = 1;
  var e = e0(), r = Bo(), t = Le();
  function n(a) {
    return t(a) ? e(a) : r(a);
  }
  return yn = n, yn;
}
var xn, _u;
function Av() {
  if (_u) return xn;
  _u = 1;
  var e = yr(), r = Ge();
  function t(n, a) {
    return n && e(a, r(a), n);
  }
  return xn = t, xn;
}
var _n, wu;
function Tv() {
  if (wu) return _n;
  wu = 1;
  function e(r) {
    var t = [];
    if (r != null)
      for (var n in Object(r))
        t.push(n);
    return t;
  }
  return _n = e, _n;
}
var wn, Nu;
function Mv() {
  if (Nu) return wn;
  Nu = 1;
  var e = we(), r = Hr(), t = Tv(), n = Object.prototype, a = n.hasOwnProperty;
  function i(o) {
    if (!e(o))
      return t(o);
    var s = r(o), u = [];
    for (var l in o)
      l == "constructor" && (s || !a.call(o, l)) || u.push(l);
    return u;
  }
  return wn = i, wn;
}
var Nn, Iu;
function Ue() {
  if (Iu) return Nn;
  Iu = 1;
  var e = e0(), r = Mv(), t = Le();
  function n(a) {
    return t(a) ? e(a, !0) : r(a);
  }
  return Nn = n, Nn;
}
var In, qu;
function Ov() {
  if (qu) return In;
  qu = 1;
  var e = yr(), r = Ue();
  function t(n, a) {
    return n && e(a, r(a), n);
  }
  return In = t, In;
}
var cr = { exports: {} };
cr.exports;
var ku;
function t0() {
  return ku || (ku = 1, (function(e, r) {
    var t = Se(), n = r && !r.nodeType && r, a = n && !0 && e && !e.nodeType && e, i = a && a.exports === n, o = i ? t.Buffer : void 0, s = o ? o.allocUnsafe : void 0;
    function u(l, c) {
      if (c)
        return l.slice();
      var d = l.length, h = s ? s(d) : new l.constructor(d);
      return l.copy(h), h;
    }
    e.exports = u;
  })(cr, cr.exports)), cr.exports;
}
var qn, Su;
function n0() {
  if (Su) return qn;
  Su = 1;
  function e(r, t) {
    var n = -1, a = r.length;
    for (t || (t = Array(a)); ++n < a; )
      t[n] = r[n];
    return t;
  }
  return qn = e, qn;
}
var kn, Ru;
function a0() {
  if (Ru) return kn;
  Ru = 1;
  function e(r, t) {
    for (var n = -1, a = r == null ? 0 : r.length, i = 0, o = []; ++n < a; ) {
      var s = r[n];
      t(s, n, r) && (o[i++] = s);
    }
    return o;
  }
  return kn = e, kn;
}
var Sn, Cu;
function i0() {
  if (Cu) return Sn;
  Cu = 1;
  function e() {
    return [];
  }
  return Sn = e, Sn;
}
var Rn, Eu;
function Uo() {
  if (Eu) return Rn;
  Eu = 1;
  var e = a0(), r = i0(), t = Object.prototype, n = t.propertyIsEnumerable, a = Object.getOwnPropertySymbols, i = a ? function(o) {
    return o == null ? [] : (o = Object(o), e(a(o), function(s) {
      return n.call(o, s);
    }));
  } : r;
  return Rn = i, Rn;
}
var Cn, Au;
function Pv() {
  if (Au) return Cn;
  Au = 1;
  var e = yr(), r = Uo();
  function t(n, a) {
    return e(n, r(n), a);
  }
  return Cn = t, Cn;
}
var En, Tu;
function $o() {
  if (Tu) return En;
  Tu = 1;
  function e(r, t) {
    for (var n = -1, a = t.length, i = r.length; ++n < a; )
      r[i + n] = t[n];
    return r;
  }
  return En = e, En;
}
var An, Mu;
function Kr() {
  if (Mu) return An;
  Mu = 1;
  var e = r0(), r = e(Object.getPrototypeOf, Object);
  return An = r, An;
}
var Tn, Ou;
function s0() {
  if (Ou) return Tn;
  Ou = 1;
  var e = $o(), r = Kr(), t = Uo(), n = i0(), a = Object.getOwnPropertySymbols, i = a ? function(o) {
    for (var s = []; o; )
      e(s, t(o)), o = r(o);
    return s;
  } : n;
  return Tn = i, Tn;
}
var Mn, Pu;
function Lv() {
  if (Pu) return Mn;
  Pu = 1;
  var e = yr(), r = s0();
  function t(n, a) {
    return e(n, r(n), a);
  }
  return Mn = t, Mn;
}
var On, Lu;
function o0() {
  if (Lu) return On;
  Lu = 1;
  var e = $o(), r = se();
  function t(n, a, i) {
    var o = a(n);
    return r(n) ? o : e(o, i(n));
  }
  return On = t, On;
}
var Pn, ju;
function c0() {
  if (ju) return Pn;
  ju = 1;
  var e = o0(), r = Uo(), t = Ge();
  function n(a) {
    return e(a, t, r);
  }
  return Pn = n, Pn;
}
var Ln, Du;
function jv() {
  if (Du) return Ln;
  Du = 1;
  var e = o0(), r = s0(), t = Ue();
  function n(a) {
    return e(a, t, r);
  }
  return Ln = n, Ln;
}
var jn, Fu;
function Dv() {
  if (Fu) return jn;
  Fu = 1;
  var e = Be(), r = Se(), t = e(r, "DataView");
  return jn = t, jn;
}
var Dn, Gu;
function Fv() {
  if (Gu) return Dn;
  Gu = 1;
  var e = Be(), r = Se(), t = e(r, "Promise");
  return Dn = t, Dn;
}
var Fn, zu;
function u0() {
  if (zu) return Fn;
  zu = 1;
  var e = Be(), r = Se(), t = e(r, "Set");
  return Fn = t, Fn;
}
var Gn, Bu;
function Gv() {
  if (Bu) return Gn;
  Bu = 1;
  var e = Be(), r = Se(), t = e(r, "WeakMap");
  return Gn = t, Gn;
}
var zn, Uu;
function rr() {
  if (Uu) return zn;
  Uu = 1;
  var e = Dv(), r = jo(), t = Fv(), n = u0(), a = Gv(), i = ze(), o = Xh(), s = "[object Map]", u = "[object Object]", l = "[object Promise]", c = "[object Set]", d = "[object WeakMap]", h = "[object DataView]", p = o(e), x = o(r), v = o(t), m = o(n), b = o(a), g = i;
  return (e && g(new e(new ArrayBuffer(1))) != h || r && g(new r()) != s || t && g(t.resolve()) != l || n && g(new n()) != c || a && g(new a()) != d) && (g = function(y) {
    var w = i(y), I = w == u ? y.constructor : void 0, q = I ? o(I) : "";
    if (q)
      switch (q) {
        case p:
          return h;
        case x:
          return s;
        case v:
          return l;
        case m:
          return c;
        case b:
          return d;
      }
    return w;
  }), zn = g, zn;
}
var Bn, $u;
function zv() {
  if ($u) return Bn;
  $u = 1;
  var e = Object.prototype, r = e.hasOwnProperty;
  function t(n) {
    var a = n.length, i = new n.constructor(a);
    return a && typeof n[0] == "string" && r.call(n, "index") && (i.index = n.index, i.input = n.input), i;
  }
  return Bn = t, Bn;
}
var Un, Vu;
function l0() {
  if (Vu) return Un;
  Vu = 1;
  var e = Se(), r = e.Uint8Array;
  return Un = r, Un;
}
var $n, Hu;
function Vo() {
  if (Hu) return $n;
  Hu = 1;
  var e = l0();
  function r(t) {
    var n = new t.constructor(t.byteLength);
    return new e(n).set(new e(t)), n;
  }
  return $n = r, $n;
}
var Vn, Ku;
function Bv() {
  if (Ku) return Vn;
  Ku = 1;
  var e = Vo();
  function r(t, n) {
    var a = n ? e(t.buffer) : t.buffer;
    return new t.constructor(a, t.byteOffset, t.byteLength);
  }
  return Vn = r, Vn;
}
var Hn, Wu;
function Uv() {
  if (Wu) return Hn;
  Wu = 1;
  var e = /\w*$/;
  function r(t) {
    var n = new t.constructor(t.source, e.exec(t));
    return n.lastIndex = t.lastIndex, n;
  }
  return Hn = r, Hn;
}
var Kn, Yu;
function $v() {
  if (Yu) return Kn;
  Yu = 1;
  var e = Qe(), r = e ? e.prototype : void 0, t = r ? r.valueOf : void 0;
  function n(a) {
    return t ? Object(t.call(a)) : {};
  }
  return Kn = n, Kn;
}
var Wn, Ju;
function d0() {
  if (Ju) return Wn;
  Ju = 1;
  var e = Vo();
  function r(t, n) {
    var a = n ? e(t.buffer) : t.buffer;
    return new t.constructor(a, t.byteOffset, t.length);
  }
  return Wn = r, Wn;
}
var Yn, Zu;
function Vv() {
  if (Zu) return Yn;
  Zu = 1;
  var e = Vo(), r = Bv(), t = Uv(), n = $v(), a = d0(), i = "[object Boolean]", o = "[object Date]", s = "[object Map]", u = "[object Number]", l = "[object RegExp]", c = "[object Set]", d = "[object String]", h = "[object Symbol]", p = "[object ArrayBuffer]", x = "[object DataView]", v = "[object Float32Array]", m = "[object Float64Array]", b = "[object Int8Array]", g = "[object Int16Array]", y = "[object Int32Array]", w = "[object Uint8Array]", I = "[object Uint8ClampedArray]", q = "[object Uint16Array]", N = "[object Uint32Array]";
  function R(k, S, E) {
    var A = k.constructor;
    switch (S) {
      case p:
        return e(k);
      case i:
      case o:
        return new A(+k);
      case x:
        return r(k, E);
      case v:
      case m:
      case b:
      case g:
      case y:
      case w:
      case I:
      case q:
      case N:
        return a(k, E);
      case s:
        return new A();
      case u:
      case d:
        return new A(k);
      case l:
        return t(k);
      case c:
        return new A();
      case h:
        return n(k);
    }
  }
  return Yn = R, Yn;
}
var Jn, Xu;
function f0() {
  if (Xu) return Jn;
  Xu = 1;
  var e = we(), r = Object.create, t = /* @__PURE__ */ (function() {
    function n() {
    }
    return function(a) {
      if (!e(a))
        return {};
      if (r)
        return r(a);
      n.prototype = a;
      var i = new n();
      return n.prototype = void 0, i;
    };
  })();
  return Jn = t, Jn;
}
var Zn, Qu;
function h0() {
  if (Qu) return Zn;
  Qu = 1;
  var e = f0(), r = Kr(), t = Hr();
  function n(a) {
    return typeof a.constructor == "function" && !t(a) ? e(r(a)) : {};
  }
  return Zn = n, Zn;
}
var Xn, el;
function Hv() {
  if (el) return Xn;
  el = 1;
  var e = rr(), r = Ae(), t = "[object Map]";
  function n(a) {
    return r(a) && e(a) == t;
  }
  return Xn = n, Xn;
}
var Qn, rl;
function Kv() {
  if (rl) return Qn;
  rl = 1;
  var e = Hv(), r = Vr(), t = zo(), n = t && t.isMap, a = n ? r(n) : e;
  return Qn = a, Qn;
}
var ea, tl;
function Wv() {
  if (tl) return ea;
  tl = 1;
  var e = rr(), r = Ae(), t = "[object Set]";
  function n(a) {
    return r(a) && e(a) == t;
  }
  return ea = n, ea;
}
var ra, nl;
function Yv() {
  if (nl) return ra;
  nl = 1;
  var e = Wv(), r = Vr(), t = zo(), n = t && t.isSet, a = n ? r(n) : e;
  return ra = a, ra;
}
var ta, al;
function p0() {
  if (al) return ta;
  al = 1;
  var e = zr(), r = Fo(), t = Ur(), n = Av(), a = Ov(), i = t0(), o = n0(), s = Pv(), u = Lv(), l = c0(), c = jv(), d = rr(), h = zv(), p = Vv(), x = h0(), v = se(), m = er(), b = Kv(), g = we(), y = Yv(), w = Ge(), I = Ue(), q = 1, N = 2, R = 4, k = "[object Arguments]", S = "[object Array]", E = "[object Boolean]", A = "[object Date]", P = "[object Error]", G = "[object Function]", H = "[object GeneratorFunction]", ee = "[object Map]", O = "[object Number]", z = "[object Object]", j = "[object RegExp]", F = "[object Set]", te = "[object String]", ne = "[object Symbol]", ie = "[object WeakMap]", C = "[object ArrayBuffer]", T = "[object DataView]", M = "[object Float32Array]", L = "[object Float64Array]", K = "[object Int8Array]", Q = "[object Int16Array]", ae = "[object Int32Array]", fe = "[object Uint8Array]", Te = "[object Uint8ClampedArray]", oe = "[object Uint16Array]", ue = "[object Uint32Array]", Y = {};
  Y[k] = Y[S] = Y[C] = Y[T] = Y[E] = Y[A] = Y[M] = Y[L] = Y[K] = Y[Q] = Y[ae] = Y[ee] = Y[O] = Y[z] = Y[j] = Y[F] = Y[te] = Y[ne] = Y[fe] = Y[Te] = Y[oe] = Y[ue] = !0, Y[P] = Y[G] = Y[ie] = !1;
  function me(W, Me, Re, et, Ve, Ie) {
    var he, He = Me & q, Ke = Me & N, rt = Me & R;
    if (Re && (he = Ve ? Re(W, et, Ve, Ie) : Re(W)), he !== void 0)
      return he;
    if (!g(W))
      return W;
    var Nr = v(W);
    if (Nr) {
      if (he = h(W), !He)
        return o(W, he);
    } else {
      var De = d(W), Ir = De == G || De == H;
      if (m(W))
        return i(W, He);
      if (De == z || De == k || Ir && !Ve) {
        if (he = Ke || Ir ? {} : x(W), !He)
          return Ke ? u(W, a(he, W)) : s(W, n(he, W));
      } else {
        if (!Y[De])
          return Ve ? W : {};
        he = p(W, De, He);
      }
    }
    Ie || (Ie = new e());
    var We = Ie.get(W);
    if (We)
      return We;
    Ie.set(W, he), y(W) ? W.forEach(function(Ce) {
      he.add(me(Ce, Me, Re, Ce, W, Ie));
    }) : b(W) && W.forEach(function(Ce, Oe) {
      he.set(Oe, me(Ce, Me, Re, Oe, W, Ie));
    });
    var tt = rt ? Ke ? c : l : Ke ? I : w, qr = Nr ? void 0 : tt(W);
    return r(qr || W, function(Ce, Oe) {
      qr && (Oe = Ce, Ce = W[Oe]), t(he, Oe, me(Ce, Me, Re, Oe, W, Ie));
    }), he;
  }
  return ta = me, ta;
}
var na, il;
function Jv() {
  if (il) return na;
  il = 1;
  var e = p0(), r = 4;
  function t(n) {
    return e(n, r);
  }
  return na = t, na;
}
var aa, sl;
function Ho() {
  if (sl) return aa;
  sl = 1;
  function e(r) {
    return function() {
      return r;
    };
  }
  return aa = e, aa;
}
var ia, ol;
function Zv() {
  if (ol) return ia;
  ol = 1;
  function e(r) {
    return function(t, n, a) {
      for (var i = -1, o = Object(t), s = a(t), u = s.length; u--; ) {
        var l = s[r ? u : ++i];
        if (n(o[l], l, o) === !1)
          break;
      }
      return t;
    };
  }
  return ia = e, ia;
}
var sa, cl;
function Ko() {
  if (cl) return sa;
  cl = 1;
  var e = Zv(), r = e();
  return sa = r, sa;
}
var oa, ul;
function Wo() {
  if (ul) return oa;
  ul = 1;
  var e = Ko(), r = Ge();
  function t(n, a) {
    return n && e(n, a, r);
  }
  return oa = t, oa;
}
var ca, ll;
function Xv() {
  if (ll) return ca;
  ll = 1;
  var e = Le();
  function r(t, n) {
    return function(a, i) {
      if (a == null)
        return a;
      if (!e(a))
        return t(a, i);
      for (var o = a.length, s = n ? o : -1, u = Object(a); (n ? s-- : ++s < o) && i(u[s], s, u) !== !1; )
        ;
      return a;
    };
  }
  return ca = r, ca;
}
var ua, dl;
function Wr() {
  if (dl) return ua;
  dl = 1;
  var e = Wo(), r = Xv(), t = r(e);
  return ua = t, ua;
}
var la, fl;
function $e() {
  if (fl) return la;
  fl = 1;
  function e(r) {
    return r;
  }
  return la = e, la;
}
var da, hl;
function m0() {
  if (hl) return da;
  hl = 1;
  var e = $e();
  function r(t) {
    return typeof t == "function" ? t : e;
  }
  return da = r, da;
}
var fa, pl;
function v0() {
  if (pl) return fa;
  pl = 1;
  var e = Fo(), r = Wr(), t = m0(), n = se();
  function a(i, o) {
    var s = n(i) ? e : r;
    return s(i, t(o));
  }
  return fa = a, fa;
}
var ha, ml;
function g0() {
  return ml || (ml = 1, ha = v0()), ha;
}
var pa, vl;
function Qv() {
  if (vl) return pa;
  vl = 1;
  var e = Wr();
  function r(t, n) {
    var a = [];
    return e(t, function(i, o, s) {
      n(i, o, s) && a.push(i);
    }), a;
  }
  return pa = r, pa;
}
var ma, gl;
function eg() {
  if (gl) return ma;
  gl = 1;
  var e = "__lodash_hash_undefined__";
  function r(t) {
    return this.__data__.set(t, e), this;
  }
  return ma = r, ma;
}
var va, bl;
function rg() {
  if (bl) return va;
  bl = 1;
  function e(r) {
    return this.__data__.has(r);
  }
  return va = e, va;
}
var ga, yl;
function b0() {
  if (yl) return ga;
  yl = 1;
  var e = Do(), r = eg(), t = rg();
  function n(a) {
    var i = -1, o = a == null ? 0 : a.length;
    for (this.__data__ = new e(); ++i < o; )
      this.add(a[i]);
  }
  return n.prototype.add = n.prototype.push = r, n.prototype.has = t, ga = n, ga;
}
var ba, xl;
function tg() {
  if (xl) return ba;
  xl = 1;
  function e(r, t) {
    for (var n = -1, a = r == null ? 0 : r.length; ++n < a; )
      if (t(r[n], n, r))
        return !0;
    return !1;
  }
  return ba = e, ba;
}
var ya, _l;
function y0() {
  if (_l) return ya;
  _l = 1;
  function e(r, t) {
    return r.has(t);
  }
  return ya = e, ya;
}
var xa, wl;
function x0() {
  if (wl) return xa;
  wl = 1;
  var e = b0(), r = tg(), t = y0(), n = 1, a = 2;
  function i(o, s, u, l, c, d) {
    var h = u & n, p = o.length, x = s.length;
    if (p != x && !(h && x > p))
      return !1;
    var v = d.get(o), m = d.get(s);
    if (v && m)
      return v == s && m == o;
    var b = -1, g = !0, y = u & a ? new e() : void 0;
    for (d.set(o, s), d.set(s, o); ++b < p; ) {
      var w = o[b], I = s[b];
      if (l)
        var q = h ? l(I, w, b, s, o, d) : l(w, I, b, o, s, d);
      if (q !== void 0) {
        if (q)
          continue;
        g = !1;
        break;
      }
      if (y) {
        if (!r(s, function(N, R) {
          if (!t(y, R) && (w === N || c(w, N, u, l, d)))
            return y.push(R);
        })) {
          g = !1;
          break;
        }
      } else if (!(w === I || c(w, I, u, l, d))) {
        g = !1;
        break;
      }
    }
    return d.delete(o), d.delete(s), g;
  }
  return xa = i, xa;
}
var _a, Nl;
function ng() {
  if (Nl) return _a;
  Nl = 1;
  function e(r) {
    var t = -1, n = Array(r.size);
    return r.forEach(function(a, i) {
      n[++t] = [i, a];
    }), n;
  }
  return _a = e, _a;
}
var wa, Il;
function Yo() {
  if (Il) return wa;
  Il = 1;
  function e(r) {
    var t = -1, n = Array(r.size);
    return r.forEach(function(a) {
      n[++t] = a;
    }), n;
  }
  return wa = e, wa;
}
var Na, ql;
function ag() {
  if (ql) return Na;
  ql = 1;
  var e = Qe(), r = l0(), t = Xe(), n = x0(), a = ng(), i = Yo(), o = 1, s = 2, u = "[object Boolean]", l = "[object Date]", c = "[object Error]", d = "[object Map]", h = "[object Number]", p = "[object RegExp]", x = "[object Set]", v = "[object String]", m = "[object Symbol]", b = "[object ArrayBuffer]", g = "[object DataView]", y = e ? e.prototype : void 0, w = y ? y.valueOf : void 0;
  function I(q, N, R, k, S, E, A) {
    switch (R) {
      case g:
        if (q.byteLength != N.byteLength || q.byteOffset != N.byteOffset)
          return !1;
        q = q.buffer, N = N.buffer;
      case b:
        return !(q.byteLength != N.byteLength || !E(new r(q), new r(N)));
      case u:
      case l:
      case h:
        return t(+q, +N);
      case c:
        return q.name == N.name && q.message == N.message;
      case p:
      case v:
        return q == N + "";
      case d:
        var P = a;
      case x:
        var G = k & o;
        if (P || (P = i), q.size != N.size && !G)
          return !1;
        var H = A.get(q);
        if (H)
          return H == N;
        k |= s, A.set(q, N);
        var ee = n(P(q), P(N), k, S, E, A);
        return A.delete(q), ee;
      case m:
        if (w)
          return w.call(q) == w.call(N);
    }
    return !1;
  }
  return Na = I, Na;
}
var Ia, kl;
function ig() {
  if (kl) return Ia;
  kl = 1;
  var e = c0(), r = 1, t = Object.prototype, n = t.hasOwnProperty;
  function a(i, o, s, u, l, c) {
    var d = s & r, h = e(i), p = h.length, x = e(o), v = x.length;
    if (p != v && !d)
      return !1;
    for (var m = p; m--; ) {
      var b = h[m];
      if (!(d ? b in o : n.call(o, b)))
        return !1;
    }
    var g = c.get(i), y = c.get(o);
    if (g && y)
      return g == o && y == i;
    var w = !0;
    c.set(i, o), c.set(o, i);
    for (var I = d; ++m < p; ) {
      b = h[m];
      var q = i[b], N = o[b];
      if (u)
        var R = d ? u(N, q, b, o, i, c) : u(q, N, b, i, o, c);
      if (!(R === void 0 ? q === N || l(q, N, s, u, c) : R)) {
        w = !1;
        break;
      }
      I || (I = b == "constructor");
    }
    if (w && !I) {
      var k = i.constructor, S = o.constructor;
      k != S && "constructor" in i && "constructor" in o && !(typeof k == "function" && k instanceof k && typeof S == "function" && S instanceof S) && (w = !1);
    }
    return c.delete(i), c.delete(o), w;
  }
  return Ia = a, Ia;
}
var qa, Sl;
function sg() {
  if (Sl) return qa;
  Sl = 1;
  var e = zr(), r = x0(), t = ag(), n = ig(), a = rr(), i = se(), o = er(), s = _r(), u = 1, l = "[object Arguments]", c = "[object Array]", d = "[object Object]", h = Object.prototype, p = h.hasOwnProperty;
  function x(v, m, b, g, y, w) {
    var I = i(v), q = i(m), N = I ? c : a(v), R = q ? c : a(m);
    N = N == l ? d : N, R = R == l ? d : R;
    var k = N == d, S = R == d, E = N == R;
    if (E && o(v)) {
      if (!o(m))
        return !1;
      I = !0, k = !1;
    }
    if (E && !k)
      return w || (w = new e()), I || s(v) ? r(v, m, b, g, y, w) : t(v, m, N, b, g, y, w);
    if (!(b & u)) {
      var A = k && p.call(v, "__wrapped__"), P = S && p.call(m, "__wrapped__");
      if (A || P) {
        var G = A ? v.value() : v, H = P ? m.value() : m;
        return w || (w = new e()), y(G, H, b, g, w);
      }
    }
    return E ? (w || (w = new e()), n(v, m, b, g, y, w)) : !1;
  }
  return qa = x, qa;
}
var ka, Rl;
function _0() {
  if (Rl) return ka;
  Rl = 1;
  var e = sg(), r = Ae();
  function t(n, a, i, o, s) {
    return n === a ? !0 : n == null || a == null || !r(n) && !r(a) ? n !== n && a !== a : e(n, a, i, o, t, s);
  }
  return ka = t, ka;
}
var Sa, Cl;
function og() {
  if (Cl) return Sa;
  Cl = 1;
  var e = zr(), r = _0(), t = 1, n = 2;
  function a(i, o, s, u) {
    var l = s.length, c = l, d = !u;
    if (i == null)
      return !c;
    for (i = Object(i); l--; ) {
      var h = s[l];
      if (d && h[2] ? h[1] !== i[h[0]] : !(h[0] in i))
        return !1;
    }
    for (; ++l < c; ) {
      h = s[l];
      var p = h[0], x = i[p], v = h[1];
      if (d && h[2]) {
        if (x === void 0 && !(p in i))
          return !1;
      } else {
        var m = new e();
        if (u)
          var b = u(x, v, p, i, o, m);
        if (!(b === void 0 ? r(v, x, t | n, u, m) : b))
          return !1;
      }
    }
    return !0;
  }
  return Sa = a, Sa;
}
var Ra, El;
function w0() {
  if (El) return Ra;
  El = 1;
  var e = we();
  function r(t) {
    return t === t && !e(t);
  }
  return Ra = r, Ra;
}
var Ca, Al;
function cg() {
  if (Al) return Ca;
  Al = 1;
  var e = w0(), r = Ge();
  function t(n) {
    for (var a = r(n), i = a.length; i--; ) {
      var o = a[i], s = n[o];
      a[i] = [o, s, e(s)];
    }
    return a;
  }
  return Ca = t, Ca;
}
var Ea, Tl;
function N0() {
  if (Tl) return Ea;
  Tl = 1;
  function e(r, t) {
    return function(n) {
      return n == null ? !1 : n[r] === t && (t !== void 0 || r in Object(n));
    };
  }
  return Ea = e, Ea;
}
var Aa, Ml;
function ug() {
  if (Ml) return Aa;
  Ml = 1;
  var e = og(), r = cg(), t = N0();
  function n(a) {
    var i = r(a);
    return i.length == 1 && i[0][2] ? t(i[0][0], i[0][1]) : function(o) {
      return o === a || e(o, a, i);
    };
  }
  return Aa = n, Aa;
}
var Ta, Ol;
function tr() {
  if (Ol) return Ta;
  Ol = 1;
  var e = ze(), r = Ae(), t = "[object Symbol]";
  function n(a) {
    return typeof a == "symbol" || r(a) && e(a) == t;
  }
  return Ta = n, Ta;
}
var Ma, Pl;
function Jo() {
  if (Pl) return Ma;
  Pl = 1;
  var e = se(), r = tr(), t = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, n = /^\w*$/;
  function a(i, o) {
    if (e(i))
      return !1;
    var s = typeof i;
    return s == "number" || s == "symbol" || s == "boolean" || i == null || r(i) ? !0 : n.test(i) || !t.test(i) || o != null && i in Object(o);
  }
  return Ma = a, Ma;
}
var Oa, Ll;
function lg() {
  if (Ll) return Oa;
  Ll = 1;
  var e = Do(), r = "Expected a function";
  function t(n, a) {
    if (typeof n != "function" || a != null && typeof a != "function")
      throw new TypeError(r);
    var i = function() {
      var o = arguments, s = a ? a.apply(this, o) : o[0], u = i.cache;
      if (u.has(s))
        return u.get(s);
      var l = n.apply(this, o);
      return i.cache = u.set(s, l) || u, l;
    };
    return i.cache = new (t.Cache || e)(), i;
  }
  return t.Cache = e, Oa = t, Oa;
}
var Pa, jl;
function dg() {
  if (jl) return Pa;
  jl = 1;
  var e = lg(), r = 500;
  function t(n) {
    var a = e(n, function(o) {
      return i.size === r && i.clear(), o;
    }), i = a.cache;
    return a;
  }
  return Pa = t, Pa;
}
var La, Dl;
function fg() {
  if (Dl) return La;
  Dl = 1;
  var e = dg(), r = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, t = /\\(\\)?/g, n = e(function(a) {
    var i = [];
    return a.charCodeAt(0) === 46 && i.push(""), a.replace(r, function(o, s, u, l) {
      i.push(u ? l.replace(t, "$1") : s || o);
    }), i;
  });
  return La = n, La;
}
var ja, Fl;
function Yr() {
  if (Fl) return ja;
  Fl = 1;
  function e(r, t) {
    for (var n = -1, a = r == null ? 0 : r.length, i = Array(a); ++n < a; )
      i[n] = t(r[n], n, r);
    return i;
  }
  return ja = e, ja;
}
var Da, Gl;
function hg() {
  if (Gl) return Da;
  Gl = 1;
  var e = Qe(), r = Yr(), t = se(), n = tr(), a = e ? e.prototype : void 0, i = a ? a.toString : void 0;
  function o(s) {
    if (typeof s == "string")
      return s;
    if (t(s))
      return r(s, o) + "";
    if (n(s))
      return i ? i.call(s) : "";
    var u = s + "";
    return u == "0" && 1 / s == -1 / 0 ? "-0" : u;
  }
  return Da = o, Da;
}
var Fa, zl;
function I0() {
  if (zl) return Fa;
  zl = 1;
  var e = hg();
  function r(t) {
    return t == null ? "" : e(t);
  }
  return Fa = r, Fa;
}
var Ga, Bl;
function Jr() {
  if (Bl) return Ga;
  Bl = 1;
  var e = se(), r = Jo(), t = fg(), n = I0();
  function a(i, o) {
    return e(i) ? i : r(i, o) ? [i] : t(n(i));
  }
  return Ga = a, Ga;
}
var za, Ul;
function wr() {
  if (Ul) return za;
  Ul = 1;
  var e = tr();
  function r(t) {
    if (typeof t == "string" || e(t))
      return t;
    var n = t + "";
    return n == "0" && 1 / t == -1 / 0 ? "-0" : n;
  }
  return za = r, za;
}
var Ba, $l;
function Zr() {
  if ($l) return Ba;
  $l = 1;
  var e = Jr(), r = wr();
  function t(n, a) {
    a = e(a, n);
    for (var i = 0, o = a.length; n != null && i < o; )
      n = n[r(a[i++])];
    return i && i == o ? n : void 0;
  }
  return Ba = t, Ba;
}
var Ua, Vl;
function pg() {
  if (Vl) return Ua;
  Vl = 1;
  var e = Zr();
  function r(t, n, a) {
    var i = t == null ? void 0 : e(t, n);
    return i === void 0 ? a : i;
  }
  return Ua = r, Ua;
}
var $a, Hl;
function mg() {
  if (Hl) return $a;
  Hl = 1;
  function e(r, t) {
    return r != null && t in Object(r);
  }
  return $a = e, $a;
}
var Va, Kl;
function q0() {
  if (Kl) return Va;
  Kl = 1;
  var e = Jr(), r = xr(), t = se(), n = $r(), a = Go(), i = wr();
  function o(s, u, l) {
    u = e(u, s);
    for (var c = -1, d = u.length, h = !1; ++c < d; ) {
      var p = i(u[c]);
      if (!(h = s != null && l(s, p)))
        break;
      s = s[p];
    }
    return h || ++c != d ? h : (d = s == null ? 0 : s.length, !!d && a(d) && n(p, d) && (t(s) || r(s)));
  }
  return Va = o, Va;
}
var Ha, Wl;
function k0() {
  if (Wl) return Ha;
  Wl = 1;
  var e = mg(), r = q0();
  function t(n, a) {
    return n != null && r(n, a, e);
  }
  return Ha = t, Ha;
}
var Ka, Yl;
function vg() {
  if (Yl) return Ka;
  Yl = 1;
  var e = _0(), r = pg(), t = k0(), n = Jo(), a = w0(), i = N0(), o = wr(), s = 1, u = 2;
  function l(c, d) {
    return n(c) && a(d) ? i(o(c), d) : function(h) {
      var p = r(h, c);
      return p === void 0 && p === d ? t(h, c) : e(d, p, s | u);
    };
  }
  return Ka = l, Ka;
}
var Wa, Jl;
function S0() {
  if (Jl) return Wa;
  Jl = 1;
  function e(r) {
    return function(t) {
      return t == null ? void 0 : t[r];
    };
  }
  return Wa = e, Wa;
}
var Ya, Zl;
function gg() {
  if (Zl) return Ya;
  Zl = 1;
  var e = Zr();
  function r(t) {
    return function(n) {
      return e(n, t);
    };
  }
  return Ya = r, Ya;
}
var Ja, Xl;
function bg() {
  if (Xl) return Ja;
  Xl = 1;
  var e = S0(), r = gg(), t = Jo(), n = wr();
  function a(i) {
    return t(i) ? e(n(i)) : r(i);
  }
  return Ja = a, Ja;
}
var Za, Ql;
function je() {
  if (Ql) return Za;
  Ql = 1;
  var e = ug(), r = vg(), t = $e(), n = se(), a = bg();
  function i(o) {
    return typeof o == "function" ? o : o == null ? t : typeof o == "object" ? n(o) ? r(o[0], o[1]) : e(o) : a(o);
  }
  return Za = i, Za;
}
var Xa, ed;
function R0() {
  if (ed) return Xa;
  ed = 1;
  var e = a0(), r = Qv(), t = je(), n = se();
  function a(i, o) {
    var s = n(i) ? e : r;
    return s(i, t(o, 3));
  }
  return Xa = a, Xa;
}
var Qa, rd;
function yg() {
  if (rd) return Qa;
  rd = 1;
  var e = Object.prototype, r = e.hasOwnProperty;
  function t(n, a) {
    return n != null && r.call(n, a);
  }
  return Qa = t, Qa;
}
var ei, td;
function C0() {
  if (td) return ei;
  td = 1;
  var e = yg(), r = q0();
  function t(n, a) {
    return n != null && r(n, a, e);
  }
  return ei = t, ei;
}
var ri, nd;
function xg() {
  if (nd) return ri;
  nd = 1;
  var e = Bo(), r = rr(), t = xr(), n = se(), a = Le(), i = er(), o = Hr(), s = _r(), u = "[object Map]", l = "[object Set]", c = Object.prototype, d = c.hasOwnProperty;
  function h(p) {
    if (p == null)
      return !0;
    if (a(p) && (n(p) || typeof p == "string" || typeof p.splice == "function" || i(p) || s(p) || t(p)))
      return !p.length;
    var x = r(p);
    if (x == u || x == l)
      return !p.size;
    if (o(p))
      return !e(p).length;
    for (var v in p)
      if (d.call(p, v))
        return !1;
    return !0;
  }
  return ri = h, ri;
}
var ti, ad;
function E0() {
  if (ad) return ti;
  ad = 1;
  function e(r) {
    return r === void 0;
  }
  return ti = e, ti;
}
var ni, id;
function A0() {
  if (id) return ni;
  id = 1;
  var e = Wr(), r = Le();
  function t(n, a) {
    var i = -1, o = r(n) ? Array(n.length) : [];
    return e(n, function(s, u, l) {
      o[++i] = a(s, u, l);
    }), o;
  }
  return ni = t, ni;
}
var ai, sd;
function T0() {
  if (sd) return ai;
  sd = 1;
  var e = Yr(), r = je(), t = A0(), n = se();
  function a(i, o) {
    var s = n(i) ? e : t;
    return s(i, r(o, 3));
  }
  return ai = a, ai;
}
var ii, od;
function _g() {
  if (od) return ii;
  od = 1;
  function e(r, t, n, a) {
    var i = -1, o = r == null ? 0 : r.length;
    for (a && o && (n = r[++i]); ++i < o; )
      n = t(n, r[i], i, r);
    return n;
  }
  return ii = e, ii;
}
var si, cd;
function wg() {
  if (cd) return si;
  cd = 1;
  function e(r, t, n, a, i) {
    return i(r, function(o, s, u) {
      n = a ? (a = !1, o) : t(n, o, s, u);
    }), n;
  }
  return si = e, si;
}
var oi, ud;
function M0() {
  if (ud) return oi;
  ud = 1;
  var e = _g(), r = Wr(), t = je(), n = wg(), a = se();
  function i(o, s, u) {
    var l = a(o) ? e : n, c = arguments.length < 3;
    return l(o, t(s, 4), u, c, r);
  }
  return oi = i, oi;
}
var ci, ld;
function Ng() {
  if (ld) return ci;
  ld = 1;
  var e = ze(), r = se(), t = Ae(), n = "[object String]";
  function a(i) {
    return typeof i == "string" || !r(i) && t(i) && e(i) == n;
  }
  return ci = a, ci;
}
var ui, dd;
function Ig() {
  if (dd) return ui;
  dd = 1;
  var e = S0(), r = e("length");
  return ui = r, ui;
}
var li, fd;
function qg() {
  if (fd) return li;
  fd = 1;
  var e = "\\ud800-\\udfff", r = "\\u0300-\\u036f", t = "\\ufe20-\\ufe2f", n = "\\u20d0-\\u20ff", a = r + t + n, i = "\\ufe0e\\ufe0f", o = "\\u200d", s = RegExp("[" + o + e + a + i + "]");
  function u(l) {
    return s.test(l);
  }
  return li = u, li;
}
var di, hd;
function kg() {
  if (hd) return di;
  hd = 1;
  var e = "\\ud800-\\udfff", r = "\\u0300-\\u036f", t = "\\ufe20-\\ufe2f", n = "\\u20d0-\\u20ff", a = r + t + n, i = "\\ufe0e\\ufe0f", o = "[" + e + "]", s = "[" + a + "]", u = "\\ud83c[\\udffb-\\udfff]", l = "(?:" + s + "|" + u + ")", c = "[^" + e + "]", d = "(?:\\ud83c[\\udde6-\\uddff]){2}", h = "[\\ud800-\\udbff][\\udc00-\\udfff]", p = "\\u200d", x = l + "?", v = "[" + i + "]?", m = "(?:" + p + "(?:" + [c, d, h].join("|") + ")" + v + x + ")*", b = v + x + m, g = "(?:" + [c + s + "?", s, d, h, o].join("|") + ")", y = RegExp(u + "(?=" + u + ")|" + g + b, "g");
  function w(I) {
    for (var q = y.lastIndex = 0; y.test(I); )
      ++q;
    return q;
  }
  return di = w, di;
}
var fi, pd;
function Sg() {
  if (pd) return fi;
  pd = 1;
  var e = Ig(), r = qg(), t = kg();
  function n(a) {
    return r(a) ? t(a) : e(a);
  }
  return fi = n, fi;
}
var hi, md;
function Rg() {
  if (md) return hi;
  md = 1;
  var e = Bo(), r = rr(), t = Le(), n = Ng(), a = Sg(), i = "[object Map]", o = "[object Set]";
  function s(u) {
    if (u == null)
      return 0;
    if (t(u))
      return n(u) ? a(u) : u.length;
    var l = r(u);
    return l == i || l == o ? u.size : e(u).length;
  }
  return hi = s, hi;
}
var pi, vd;
function Cg() {
  if (vd) return pi;
  vd = 1;
  var e = Fo(), r = f0(), t = Wo(), n = je(), a = Kr(), i = se(), o = er(), s = br(), u = we(), l = _r();
  function c(d, h, p) {
    var x = i(d), v = x || o(d) || l(d);
    if (h = n(h, 4), p == null) {
      var m = d && d.constructor;
      v ? p = x ? new m() : [] : u(d) ? p = s(m) ? r(a(d)) : {} : p = {};
    }
    return (v ? e : t)(d, function(b, g, y) {
      return h(p, b, g, y);
    }), p;
  }
  return pi = c, pi;
}
var mi, gd;
function Eg() {
  if (gd) return mi;
  gd = 1;
  var e = Qe(), r = xr(), t = se(), n = e ? e.isConcatSpreadable : void 0;
  function a(i) {
    return t(i) || r(i) || !!(n && i && i[n]);
  }
  return mi = a, mi;
}
var vi, bd;
function Zo() {
  if (bd) return vi;
  bd = 1;
  var e = $o(), r = Eg();
  function t(n, a, i, o, s) {
    var u = -1, l = n.length;
    for (i || (i = r), s || (s = []); ++u < l; ) {
      var c = n[u];
      a > 0 && i(c) ? a > 1 ? t(c, a - 1, i, o, s) : e(s, c) : o || (s[s.length] = c);
    }
    return s;
  }
  return vi = t, vi;
}
var gi, yd;
function Ag() {
  if (yd) return gi;
  yd = 1;
  function e(r, t, n) {
    switch (n.length) {
      case 0:
        return r.call(t);
      case 1:
        return r.call(t, n[0]);
      case 2:
        return r.call(t, n[0], n[1]);
      case 3:
        return r.call(t, n[0], n[1], n[2]);
    }
    return r.apply(t, n);
  }
  return gi = e, gi;
}
var bi, xd;
function O0() {
  if (xd) return bi;
  xd = 1;
  var e = Ag(), r = Math.max;
  function t(n, a, i) {
    return a = r(a === void 0 ? n.length - 1 : a, 0), function() {
      for (var o = arguments, s = -1, u = r(o.length - a, 0), l = Array(u); ++s < u; )
        l[s] = o[a + s];
      s = -1;
      for (var c = Array(a + 1); ++s < a; )
        c[s] = o[s];
      return c[a] = i(l), e(n, this, c);
    };
  }
  return bi = t, bi;
}
var yi, _d;
function Tg() {
  if (_d) return yi;
  _d = 1;
  var e = Ho(), r = Qh(), t = $e(), n = r ? function(a, i) {
    return r(a, "toString", {
      configurable: !0,
      enumerable: !1,
      value: e(i),
      writable: !0
    });
  } : t;
  return yi = n, yi;
}
var xi, wd;
function Mg() {
  if (wd) return xi;
  wd = 1;
  var e = 800, r = 16, t = Date.now;
  function n(a) {
    var i = 0, o = 0;
    return function() {
      var s = t(), u = r - (s - o);
      if (o = s, u > 0) {
        if (++i >= e)
          return arguments[0];
      } else
        i = 0;
      return a.apply(void 0, arguments);
    };
  }
  return xi = n, xi;
}
var _i, Nd;
function P0() {
  if (Nd) return _i;
  Nd = 1;
  var e = Tg(), r = Mg(), t = r(e);
  return _i = t, _i;
}
var wi, Id;
function Xr() {
  if (Id) return wi;
  Id = 1;
  var e = $e(), r = O0(), t = P0();
  function n(a, i) {
    return t(r(a, i, e), a + "");
  }
  return wi = n, wi;
}
var Ni, qd;
function L0() {
  if (qd) return Ni;
  qd = 1;
  function e(r, t, n, a) {
    for (var i = r.length, o = n + (a ? 1 : -1); a ? o-- : ++o < i; )
      if (t(r[o], o, r))
        return o;
    return -1;
  }
  return Ni = e, Ni;
}
var Ii, kd;
function Og() {
  if (kd) return Ii;
  kd = 1;
  function e(r) {
    return r !== r;
  }
  return Ii = e, Ii;
}
var qi, Sd;
function Pg() {
  if (Sd) return qi;
  Sd = 1;
  function e(r, t, n) {
    for (var a = n - 1, i = r.length; ++a < i; )
      if (r[a] === t)
        return a;
    return -1;
  }
  return qi = e, qi;
}
var ki, Rd;
function Lg() {
  if (Rd) return ki;
  Rd = 1;
  var e = L0(), r = Og(), t = Pg();
  function n(a, i, o) {
    return i === i ? t(a, i, o) : e(a, r, o);
  }
  return ki = n, ki;
}
var Si, Cd;
function jg() {
  if (Cd) return Si;
  Cd = 1;
  var e = Lg();
  function r(t, n) {
    var a = t == null ? 0 : t.length;
    return !!a && e(t, n, 0) > -1;
  }
  return Si = r, Si;
}
var Ri, Ed;
function Dg() {
  if (Ed) return Ri;
  Ed = 1;
  function e(r, t, n) {
    for (var a = -1, i = r == null ? 0 : r.length; ++a < i; )
      if (n(t, r[a]))
        return !0;
    return !1;
  }
  return Ri = e, Ri;
}
var Ci, Ad;
function Fg() {
  if (Ad) return Ci;
  Ad = 1;
  function e() {
  }
  return Ci = e, Ci;
}
var Ei, Td;
function Gg() {
  if (Td) return Ei;
  Td = 1;
  var e = u0(), r = Fg(), t = Yo(), n = 1 / 0, a = e && 1 / t(new e([, -0]))[1] == n ? function(i) {
    return new e(i);
  } : r;
  return Ei = a, Ei;
}
var Ai, Md;
function zg() {
  if (Md) return Ai;
  Md = 1;
  var e = b0(), r = jg(), t = Dg(), n = y0(), a = Gg(), i = Yo(), o = 200;
  function s(u, l, c) {
    var d = -1, h = r, p = u.length, x = !0, v = [], m = v;
    if (c)
      x = !1, h = t;
    else if (p >= o) {
      var b = l ? null : a(u);
      if (b)
        return i(b);
      x = !1, h = n, m = new e();
    } else
      m = l ? [] : v;
    e:
      for (; ++d < p; ) {
        var g = u[d], y = l ? l(g) : g;
        if (g = c || g !== 0 ? g : 0, x && y === y) {
          for (var w = m.length; w--; )
            if (m[w] === y)
              continue e;
          l && m.push(y), v.push(g);
        } else h(m, y, c) || (m !== v && m.push(y), v.push(g));
      }
    return v;
  }
  return Ai = s, Ai;
}
var Ti, Od;
function j0() {
  if (Od) return Ti;
  Od = 1;
  var e = Le(), r = Ae();
  function t(n) {
    return r(n) && e(n);
  }
  return Ti = t, Ti;
}
var Mi, Pd;
function Bg() {
  if (Pd) return Mi;
  Pd = 1;
  var e = Zo(), r = Xr(), t = zg(), n = j0(), a = r(function(i) {
    return t(e(i, 1, n, !0));
  });
  return Mi = a, Mi;
}
var Oi, Ld;
function Ug() {
  if (Ld) return Oi;
  Ld = 1;
  var e = Yr();
  function r(t, n) {
    return e(n, function(a) {
      return t[a];
    });
  }
  return Oi = r, Oi;
}
var Pi, jd;
function D0() {
  if (jd) return Pi;
  jd = 1;
  var e = Ug(), r = Ge();
  function t(n) {
    return n == null ? [] : e(n, r(n));
  }
  return Pi = t, Pi;
}
var Li, Dd;
function Ne() {
  if (Dd) return Li;
  Dd = 1;
  var e;
  if (typeof Lo == "function")
    try {
      e = {
        clone: Jv(),
        constant: Ho(),
        each: g0(),
        filter: R0(),
        has: C0(),
        isArray: se(),
        isEmpty: xg(),
        isFunction: br(),
        isUndefined: E0(),
        keys: Ge(),
        map: T0(),
        reduce: M0(),
        size: Rg(),
        transform: Cg(),
        union: Bg(),
        values: D0()
      };
    } catch {
    }
  return e || (e = window._), Li = e, Li;
}
var ji, Fd;
function Xo() {
  if (Fd) return ji;
  Fd = 1;
  var e = Ne();
  ji = a;
  var r = "\0", t = "\0", n = "";
  function a(c) {
    this._isDirected = e.has(c, "directed") ? c.directed : !0, this._isMultigraph = e.has(c, "multigraph") ? c.multigraph : !1, this._isCompound = e.has(c, "compound") ? c.compound : !1, this._label = void 0, this._defaultNodeLabelFn = e.constant(void 0), this._defaultEdgeLabelFn = e.constant(void 0), this._nodes = {}, this._isCompound && (this._parent = {}, this._children = {}, this._children[t] = {}), this._in = {}, this._preds = {}, this._out = {}, this._sucs = {}, this._edgeObjs = {}, this._edgeLabels = {};
  }
  a.prototype._nodeCount = 0, a.prototype._edgeCount = 0, a.prototype.isDirected = function() {
    return this._isDirected;
  }, a.prototype.isMultigraph = function() {
    return this._isMultigraph;
  }, a.prototype.isCompound = function() {
    return this._isCompound;
  }, a.prototype.setGraph = function(c) {
    return this._label = c, this;
  }, a.prototype.graph = function() {
    return this._label;
  }, a.prototype.setDefaultNodeLabel = function(c) {
    return e.isFunction(c) || (c = e.constant(c)), this._defaultNodeLabelFn = c, this;
  }, a.prototype.nodeCount = function() {
    return this._nodeCount;
  }, a.prototype.nodes = function() {
    return e.keys(this._nodes);
  }, a.prototype.sources = function() {
    var c = this;
    return e.filter(this.nodes(), function(d) {
      return e.isEmpty(c._in[d]);
    });
  }, a.prototype.sinks = function() {
    var c = this;
    return e.filter(this.nodes(), function(d) {
      return e.isEmpty(c._out[d]);
    });
  }, a.prototype.setNodes = function(c, d) {
    var h = arguments, p = this;
    return e.each(c, function(x) {
      h.length > 1 ? p.setNode(x, d) : p.setNode(x);
    }), this;
  }, a.prototype.setNode = function(c, d) {
    return e.has(this._nodes, c) ? (arguments.length > 1 && (this._nodes[c] = d), this) : (this._nodes[c] = arguments.length > 1 ? d : this._defaultNodeLabelFn(c), this._isCompound && (this._parent[c] = t, this._children[c] = {}, this._children[t][c] = !0), this._in[c] = {}, this._preds[c] = {}, this._out[c] = {}, this._sucs[c] = {}, ++this._nodeCount, this);
  }, a.prototype.node = function(c) {
    return this._nodes[c];
  }, a.prototype.hasNode = function(c) {
    return e.has(this._nodes, c);
  }, a.prototype.removeNode = function(c) {
    var d = this;
    if (e.has(this._nodes, c)) {
      var h = function(p) {
        d.removeEdge(d._edgeObjs[p]);
      };
      delete this._nodes[c], this._isCompound && (this._removeFromParentsChildList(c), delete this._parent[c], e.each(this.children(c), function(p) {
        d.setParent(p);
      }), delete this._children[c]), e.each(e.keys(this._in[c]), h), delete this._in[c], delete this._preds[c], e.each(e.keys(this._out[c]), h), delete this._out[c], delete this._sucs[c], --this._nodeCount;
    }
    return this;
  }, a.prototype.setParent = function(c, d) {
    if (!this._isCompound)
      throw new Error("Cannot set parent in a non-compound graph");
    if (e.isUndefined(d))
      d = t;
    else {
      d += "";
      for (var h = d; !e.isUndefined(h); h = this.parent(h))
        if (h === c)
          throw new Error("Setting " + d + " as parent of " + c + " would create a cycle");
      this.setNode(d);
    }
    return this.setNode(c), this._removeFromParentsChildList(c), this._parent[c] = d, this._children[d][c] = !0, this;
  }, a.prototype._removeFromParentsChildList = function(c) {
    delete this._children[this._parent[c]][c];
  }, a.prototype.parent = function(c) {
    if (this._isCompound) {
      var d = this._parent[c];
      if (d !== t)
        return d;
    }
  }, a.prototype.children = function(c) {
    if (e.isUndefined(c) && (c = t), this._isCompound) {
      var d = this._children[c];
      if (d)
        return e.keys(d);
    } else {
      if (c === t)
        return this.nodes();
      if (this.hasNode(c))
        return [];
    }
  }, a.prototype.predecessors = function(c) {
    var d = this._preds[c];
    if (d)
      return e.keys(d);
  }, a.prototype.successors = function(c) {
    var d = this._sucs[c];
    if (d)
      return e.keys(d);
  }, a.prototype.neighbors = function(c) {
    var d = this.predecessors(c);
    if (d)
      return e.union(d, this.successors(c));
  }, a.prototype.isLeaf = function(c) {
    var d;
    return this.isDirected() ? d = this.successors(c) : d = this.neighbors(c), d.length === 0;
  }, a.prototype.filterNodes = function(c) {
    var d = new this.constructor({
      directed: this._isDirected,
      multigraph: this._isMultigraph,
      compound: this._isCompound
    });
    d.setGraph(this.graph());
    var h = this;
    e.each(this._nodes, function(v, m) {
      c(m) && d.setNode(m, v);
    }), e.each(this._edgeObjs, function(v) {
      d.hasNode(v.v) && d.hasNode(v.w) && d.setEdge(v, h.edge(v));
    });
    var p = {};
    function x(v) {
      var m = h.parent(v);
      return m === void 0 || d.hasNode(m) ? (p[v] = m, m) : m in p ? p[m] : x(m);
    }
    return this._isCompound && e.each(d.nodes(), function(v) {
      d.setParent(v, x(v));
    }), d;
  }, a.prototype.setDefaultEdgeLabel = function(c) {
    return e.isFunction(c) || (c = e.constant(c)), this._defaultEdgeLabelFn = c, this;
  }, a.prototype.edgeCount = function() {
    return this._edgeCount;
  }, a.prototype.edges = function() {
    return e.values(this._edgeObjs);
  }, a.prototype.setPath = function(c, d) {
    var h = this, p = arguments;
    return e.reduce(c, function(x, v) {
      return p.length > 1 ? h.setEdge(x, v, d) : h.setEdge(x, v), v;
    }), this;
  }, a.prototype.setEdge = function() {
    var c, d, h, p, x = !1, v = arguments[0];
    typeof v == "object" && v !== null && "v" in v ? (c = v.v, d = v.w, h = v.name, arguments.length === 2 && (p = arguments[1], x = !0)) : (c = v, d = arguments[1], h = arguments[3], arguments.length > 2 && (p = arguments[2], x = !0)), c = "" + c, d = "" + d, e.isUndefined(h) || (h = "" + h);
    var m = s(this._isDirected, c, d, h);
    if (e.has(this._edgeLabels, m))
      return x && (this._edgeLabels[m] = p), this;
    if (!e.isUndefined(h) && !this._isMultigraph)
      throw new Error("Cannot set a named edge when isMultigraph = false");
    this.setNode(c), this.setNode(d), this._edgeLabels[m] = x ? p : this._defaultEdgeLabelFn(c, d, h);
    var b = u(this._isDirected, c, d, h);
    return c = b.v, d = b.w, Object.freeze(b), this._edgeObjs[m] = b, i(this._preds[d], c), i(this._sucs[c], d), this._in[d][m] = b, this._out[c][m] = b, this._edgeCount++, this;
  }, a.prototype.edge = function(c, d, h) {
    var p = arguments.length === 1 ? l(this._isDirected, arguments[0]) : s(this._isDirected, c, d, h);
    return this._edgeLabels[p];
  }, a.prototype.hasEdge = function(c, d, h) {
    var p = arguments.length === 1 ? l(this._isDirected, arguments[0]) : s(this._isDirected, c, d, h);
    return e.has(this._edgeLabels, p);
  }, a.prototype.removeEdge = function(c, d, h) {
    var p = arguments.length === 1 ? l(this._isDirected, arguments[0]) : s(this._isDirected, c, d, h), x = this._edgeObjs[p];
    return x && (c = x.v, d = x.w, delete this._edgeLabels[p], delete this._edgeObjs[p], o(this._preds[d], c), o(this._sucs[c], d), delete this._in[d][p], delete this._out[c][p], this._edgeCount--), this;
  }, a.prototype.inEdges = function(c, d) {
    var h = this._in[c];
    if (h) {
      var p = e.values(h);
      return d ? e.filter(p, function(x) {
        return x.v === d;
      }) : p;
    }
  }, a.prototype.outEdges = function(c, d) {
    var h = this._out[c];
    if (h) {
      var p = e.values(h);
      return d ? e.filter(p, function(x) {
        return x.w === d;
      }) : p;
    }
  }, a.prototype.nodeEdges = function(c, d) {
    var h = this.inEdges(c, d);
    if (h)
      return h.concat(this.outEdges(c, d));
  };
  function i(c, d) {
    c[d] ? c[d]++ : c[d] = 1;
  }
  function o(c, d) {
    --c[d] || delete c[d];
  }
  function s(c, d, h, p) {
    var x = "" + d, v = "" + h;
    if (!c && x > v) {
      var m = x;
      x = v, v = m;
    }
    return x + n + v + n + (e.isUndefined(p) ? r : p);
  }
  function u(c, d, h, p) {
    var x = "" + d, v = "" + h;
    if (!c && x > v) {
      var m = x;
      x = v, v = m;
    }
    var b = { v: x, w: v };
    return p && (b.name = p), b;
  }
  function l(c, d) {
    return s(c, d.v, d.w, d.name);
  }
  return ji;
}
var Di, Gd;
function $g() {
  return Gd || (Gd = 1, Di = "2.1.8"), Di;
}
var Fi, zd;
function Vg() {
  return zd || (zd = 1, Fi = {
    Graph: Xo(),
    version: $g()
  }), Fi;
}
var Gi, Bd;
function Hg() {
  if (Bd) return Gi;
  Bd = 1;
  var e = Ne(), r = Xo();
  Gi = {
    write: t,
    read: i
  };
  function t(o) {
    var s = {
      options: {
        directed: o.isDirected(),
        multigraph: o.isMultigraph(),
        compound: o.isCompound()
      },
      nodes: n(o),
      edges: a(o)
    };
    return e.isUndefined(o.graph()) || (s.value = e.clone(o.graph())), s;
  }
  function n(o) {
    return e.map(o.nodes(), function(s) {
      var u = o.node(s), l = o.parent(s), c = { v: s };
      return e.isUndefined(u) || (c.value = u), e.isUndefined(l) || (c.parent = l), c;
    });
  }
  function a(o) {
    return e.map(o.edges(), function(s) {
      var u = o.edge(s), l = { v: s.v, w: s.w };
      return e.isUndefined(s.name) || (l.name = s.name), e.isUndefined(u) || (l.value = u), l;
    });
  }
  function i(o) {
    var s = new r(o.options).setGraph(o.value);
    return e.each(o.nodes, function(u) {
      s.setNode(u.v, u.value), u.parent && s.setParent(u.v, u.parent);
    }), e.each(o.edges, function(u) {
      s.setEdge({ v: u.v, w: u.w, name: u.name }, u.value);
    }), s;
  }
  return Gi;
}
var zi, Ud;
function Kg() {
  if (Ud) return zi;
  Ud = 1;
  var e = Ne();
  zi = r;
  function r(t) {
    var n = {}, a = [], i;
    function o(s) {
      e.has(n, s) || (n[s] = !0, i.push(s), e.each(t.successors(s), o), e.each(t.predecessors(s), o));
    }
    return e.each(t.nodes(), function(s) {
      i = [], o(s), i.length && a.push(i);
    }), a;
  }
  return zi;
}
var Bi, $d;
function F0() {
  if ($d) return Bi;
  $d = 1;
  var e = Ne();
  Bi = r;
  function r() {
    this._arr = [], this._keyIndices = {};
  }
  return r.prototype.size = function() {
    return this._arr.length;
  }, r.prototype.keys = function() {
    return this._arr.map(function(t) {
      return t.key;
    });
  }, r.prototype.has = function(t) {
    return e.has(this._keyIndices, t);
  }, r.prototype.priority = function(t) {
    var n = this._keyIndices[t];
    if (n !== void 0)
      return this._arr[n].priority;
  }, r.prototype.min = function() {
    if (this.size() === 0)
      throw new Error("Queue underflow");
    return this._arr[0].key;
  }, r.prototype.add = function(t, n) {
    var a = this._keyIndices;
    if (t = String(t), !e.has(a, t)) {
      var i = this._arr, o = i.length;
      return a[t] = o, i.push({ key: t, priority: n }), this._decrease(o), !0;
    }
    return !1;
  }, r.prototype.removeMin = function() {
    this._swap(0, this._arr.length - 1);
    var t = this._arr.pop();
    return delete this._keyIndices[t.key], this._heapify(0), t.key;
  }, r.prototype.decrease = function(t, n) {
    var a = this._keyIndices[t];
    if (n > this._arr[a].priority)
      throw new Error("New priority is greater than current priority. Key: " + t + " Old: " + this._arr[a].priority + " New: " + n);
    this._arr[a].priority = n, this._decrease(a);
  }, r.prototype._heapify = function(t) {
    var n = this._arr, a = 2 * t, i = a + 1, o = t;
    a < n.length && (o = n[a].priority < n[o].priority ? a : o, i < n.length && (o = n[i].priority < n[o].priority ? i : o), o !== t && (this._swap(t, o), this._heapify(o)));
  }, r.prototype._decrease = function(t) {
    for (var n = this._arr, a = n[t].priority, i; t !== 0 && (i = t >> 1, !(n[i].priority < a)); )
      this._swap(t, i), t = i;
  }, r.prototype._swap = function(t, n) {
    var a = this._arr, i = this._keyIndices, o = a[t], s = a[n];
    a[t] = s, a[n] = o, i[s.key] = t, i[o.key] = n;
  }, Bi;
}
var Ui, Vd;
function G0() {
  if (Vd) return Ui;
  Vd = 1;
  var e = Ne(), r = F0();
  Ui = n;
  var t = e.constant(1);
  function n(i, o, s, u) {
    return a(
      i,
      String(o),
      s || t,
      u || function(l) {
        return i.outEdges(l);
      }
    );
  }
  function a(i, o, s, u) {
    var l = {}, c = new r(), d, h, p = function(x) {
      var v = x.v !== d ? x.v : x.w, m = l[v], b = s(x), g = h.distance + b;
      if (b < 0)
        throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + x + " Weight: " + b);
      g < m.distance && (m.distance = g, m.predecessor = d, c.decrease(v, g));
    };
    for (i.nodes().forEach(function(x) {
      var v = x === o ? 0 : Number.POSITIVE_INFINITY;
      l[x] = { distance: v }, c.add(x, v);
    }); c.size() > 0 && (d = c.removeMin(), h = l[d], h.distance !== Number.POSITIVE_INFINITY); )
      u(d).forEach(p);
    return l;
  }
  return Ui;
}
var $i, Hd;
function Wg() {
  if (Hd) return $i;
  Hd = 1;
  var e = G0(), r = Ne();
  $i = t;
  function t(n, a, i) {
    return r.transform(n.nodes(), function(o, s) {
      o[s] = e(n, s, a, i);
    }, {});
  }
  return $i;
}
var Vi, Kd;
function z0() {
  if (Kd) return Vi;
  Kd = 1;
  var e = Ne();
  Vi = r;
  function r(t) {
    var n = 0, a = [], i = {}, o = [];
    function s(u) {
      var l = i[u] = {
        onStack: !0,
        lowlink: n,
        index: n++
      };
      if (a.push(u), t.successors(u).forEach(function(h) {
        e.has(i, h) ? i[h].onStack && (l.lowlink = Math.min(l.lowlink, i[h].index)) : (s(h), l.lowlink = Math.min(l.lowlink, i[h].lowlink));
      }), l.lowlink === l.index) {
        var c = [], d;
        do
          d = a.pop(), i[d].onStack = !1, c.push(d);
        while (u !== d);
        o.push(c);
      }
    }
    return t.nodes().forEach(function(u) {
      e.has(i, u) || s(u);
    }), o;
  }
  return Vi;
}
var Hi, Wd;
function Yg() {
  if (Wd) return Hi;
  Wd = 1;
  var e = Ne(), r = z0();
  Hi = t;
  function t(n) {
    return e.filter(r(n), function(a) {
      return a.length > 1 || a.length === 1 && n.hasEdge(a[0], a[0]);
    });
  }
  return Hi;
}
var Ki, Yd;
function Jg() {
  if (Yd) return Ki;
  Yd = 1;
  var e = Ne();
  Ki = t;
  var r = e.constant(1);
  function t(a, i, o) {
    return n(
      a,
      i || r,
      o || function(s) {
        return a.outEdges(s);
      }
    );
  }
  function n(a, i, o) {
    var s = {}, u = a.nodes();
    return u.forEach(function(l) {
      s[l] = {}, s[l][l] = { distance: 0 }, u.forEach(function(c) {
        l !== c && (s[l][c] = { distance: Number.POSITIVE_INFINITY });
      }), o(l).forEach(function(c) {
        var d = c.v === l ? c.w : c.v, h = i(c);
        s[l][d] = { distance: h, predecessor: l };
      });
    }), u.forEach(function(l) {
      var c = s[l];
      u.forEach(function(d) {
        var h = s[d];
        u.forEach(function(p) {
          var x = h[l], v = c[p], m = h[p], b = x.distance + v.distance;
          b < m.distance && (m.distance = b, m.predecessor = v.predecessor);
        });
      });
    }), s;
  }
  return Ki;
}
var Wi, Jd;
function B0() {
  if (Jd) return Wi;
  Jd = 1;
  var e = Ne();
  Wi = r, r.CycleException = t;
  function r(n) {
    var a = {}, i = {}, o = [];
    function s(u) {
      if (e.has(i, u))
        throw new t();
      e.has(a, u) || (i[u] = !0, a[u] = !0, e.each(n.predecessors(u), s), delete i[u], o.push(u));
    }
    if (e.each(n.sinks(), s), e.size(a) !== n.nodeCount())
      throw new t();
    return o;
  }
  function t() {
  }
  return t.prototype = new Error(), Wi;
}
var Yi, Zd;
function Zg() {
  if (Zd) return Yi;
  Zd = 1;
  var e = B0();
  Yi = r;
  function r(t) {
    try {
      e(t);
    } catch (n) {
      if (n instanceof e.CycleException)
        return !1;
      throw n;
    }
    return !0;
  }
  return Yi;
}
var Ji, Xd;
function U0() {
  if (Xd) return Ji;
  Xd = 1;
  var e = Ne();
  Ji = r;
  function r(n, a, i) {
    e.isArray(a) || (a = [a]);
    var o = (n.isDirected() ? n.successors : n.neighbors).bind(n), s = [], u = {};
    return e.each(a, function(l) {
      if (!n.hasNode(l))
        throw new Error("Graph does not have node: " + l);
      t(n, l, i === "post", u, o, s);
    }), s;
  }
  function t(n, a, i, o, s, u) {
    e.has(o, a) || (o[a] = !0, i || u.push(a), e.each(s(a), function(l) {
      t(n, l, i, o, s, u);
    }), i && u.push(a));
  }
  return Ji;
}
var Zi, Qd;
function Xg() {
  if (Qd) return Zi;
  Qd = 1;
  var e = U0();
  Zi = r;
  function r(t, n) {
    return e(t, n, "post");
  }
  return Zi;
}
var Xi, ef;
function Qg() {
  if (ef) return Xi;
  ef = 1;
  var e = U0();
  Xi = r;
  function r(t, n) {
    return e(t, n, "pre");
  }
  return Xi;
}
var Qi, rf;
function eb() {
  if (rf) return Qi;
  rf = 1;
  var e = Ne(), r = Xo(), t = F0();
  Qi = n;
  function n(a, i) {
    var o = new r(), s = {}, u = new t(), l;
    function c(h) {
      var p = h.v === l ? h.w : h.v, x = u.priority(p);
      if (x !== void 0) {
        var v = i(h);
        v < x && (s[p] = l, u.decrease(p, v));
      }
    }
    if (a.nodeCount() === 0)
      return o;
    e.each(a.nodes(), function(h) {
      u.add(h, Number.POSITIVE_INFINITY), o.setNode(h);
    }), u.decrease(a.nodes()[0], 0);
    for (var d = !1; u.size() > 0; ) {
      if (l = u.removeMin(), e.has(s, l))
        o.setEdge(l, s[l]);
      else {
        if (d)
          throw new Error("Input graph is not connected: " + a);
        d = !0;
      }
      a.nodeEdges(l).forEach(c);
    }
    return o;
  }
  return Qi;
}
var es, tf;
function rb() {
  return tf || (tf = 1, es = {
    components: Kg(),
    dijkstra: G0(),
    dijkstraAll: Wg(),
    findCycles: Yg(),
    floydWarshall: Jg(),
    isAcyclic: Zg(),
    postorder: Xg(),
    preorder: Qg(),
    prim: eb(),
    tarjan: z0(),
    topsort: B0()
  }), es;
}
var rs, nf;
function tb() {
  if (nf) return rs;
  nf = 1;
  var e = Vg();
  return rs = {
    Graph: e.Graph,
    json: Hg(),
    alg: rb(),
    version: e.version
  }, rs;
}
var ts, af;
function ke() {
  if (af) return ts;
  af = 1;
  var e;
  if (typeof Lo == "function")
    try {
      e = tb();
    } catch {
    }
  return e || (e = window.graphlib), ts = e, ts;
}
var ns, sf;
function nb() {
  if (sf) return ns;
  sf = 1;
  var e = p0(), r = 1, t = 4;
  function n(a) {
    return e(a, r | t);
  }
  return ns = n, ns;
}
var as, of;
function Qr() {
  if (of) return as;
  of = 1;
  var e = Xe(), r = Le(), t = $r(), n = we();
  function a(i, o, s) {
    if (!n(s))
      return !1;
    var u = typeof o;
    return (u == "number" ? r(s) && t(o, s.length) : u == "string" && o in s) ? e(s[o], i) : !1;
  }
  return as = a, as;
}
var is, cf;
function ab() {
  if (cf) return is;
  cf = 1;
  var e = Xr(), r = Xe(), t = Qr(), n = Ue(), a = Object.prototype, i = a.hasOwnProperty, o = e(function(s, u) {
    s = Object(s);
    var l = -1, c = u.length, d = c > 2 ? u[2] : void 0;
    for (d && t(u[0], u[1], d) && (c = 1); ++l < c; )
      for (var h = u[l], p = n(h), x = -1, v = p.length; ++x < v; ) {
        var m = p[x], b = s[m];
        (b === void 0 || r(b, a[m]) && !i.call(s, m)) && (s[m] = h[m]);
      }
    return s;
  });
  return is = o, is;
}
var ss, uf;
function ib() {
  if (uf) return ss;
  uf = 1;
  var e = je(), r = Le(), t = Ge();
  function n(a) {
    return function(i, o, s) {
      var u = Object(i);
      if (!r(i)) {
        var l = e(o, 3);
        i = t(i), o = function(d) {
          return l(u[d], d, u);
        };
      }
      var c = a(i, o, s);
      return c > -1 ? u[l ? i[c] : c] : void 0;
    };
  }
  return ss = n, ss;
}
var os, lf;
function sb() {
  if (lf) return os;
  lf = 1;
  var e = /\s/;
  function r(t) {
    for (var n = t.length; n-- && e.test(t.charAt(n)); )
      ;
    return n;
  }
  return os = r, os;
}
var cs, df;
function ob() {
  if (df) return cs;
  df = 1;
  var e = sb(), r = /^\s+/;
  function t(n) {
    return n && n.slice(0, e(n) + 1).replace(r, "");
  }
  return cs = t, cs;
}
var us, ff;
function cb() {
  if (ff) return us;
  ff = 1;
  var e = ob(), r = we(), t = tr(), n = NaN, a = /^[-+]0x[0-9a-f]+$/i, i = /^0b[01]+$/i, o = /^0o[0-7]+$/i, s = parseInt;
  function u(l) {
    if (typeof l == "number")
      return l;
    if (t(l))
      return n;
    if (r(l)) {
      var c = typeof l.valueOf == "function" ? l.valueOf() : l;
      l = r(c) ? c + "" : c;
    }
    if (typeof l != "string")
      return l === 0 ? l : +l;
    l = e(l);
    var d = i.test(l);
    return d || o.test(l) ? s(l.slice(2), d ? 2 : 8) : a.test(l) ? n : +l;
  }
  return us = u, us;
}
var ls, hf;
function $0() {
  if (hf) return ls;
  hf = 1;
  var e = cb(), r = 1 / 0, t = 17976931348623157e292;
  function n(a) {
    if (!a)
      return a === 0 ? a : 0;
    if (a = e(a), a === r || a === -r) {
      var i = a < 0 ? -1 : 1;
      return i * t;
    }
    return a === a ? a : 0;
  }
  return ls = n, ls;
}
var ds, pf;
function ub() {
  if (pf) return ds;
  pf = 1;
  var e = $0();
  function r(t) {
    var n = e(t), a = n % 1;
    return n === n ? a ? n - a : n : 0;
  }
  return ds = r, ds;
}
var fs, mf;
function lb() {
  if (mf) return fs;
  mf = 1;
  var e = L0(), r = je(), t = ub(), n = Math.max;
  function a(i, o, s) {
    var u = i == null ? 0 : i.length;
    if (!u)
      return -1;
    var l = s == null ? 0 : t(s);
    return l < 0 && (l = n(u + l, 0)), e(i, r(o, 3), l);
  }
  return fs = a, fs;
}
var hs, vf;
function db() {
  if (vf) return hs;
  vf = 1;
  var e = ib(), r = lb(), t = e(r);
  return hs = t, hs;
}
var ps, gf;
function V0() {
  if (gf) return ps;
  gf = 1;
  var e = Zo();
  function r(t) {
    var n = t == null ? 0 : t.length;
    return n ? e(t, 1) : [];
  }
  return ps = r, ps;
}
var ms, bf;
function fb() {
  if (bf) return ms;
  bf = 1;
  var e = Ko(), r = m0(), t = Ue();
  function n(a, i) {
    return a == null ? a : e(a, r(i), t);
  }
  return ms = n, ms;
}
var vs, yf;
function hb() {
  if (yf) return vs;
  yf = 1;
  function e(r) {
    var t = r == null ? 0 : r.length;
    return t ? r[t - 1] : void 0;
  }
  return vs = e, vs;
}
var gs, xf;
function pb() {
  if (xf) return gs;
  xf = 1;
  var e = Br(), r = Wo(), t = je();
  function n(a, i) {
    var o = {};
    return i = t(i, 3), r(a, function(s, u, l) {
      e(o, u, i(s, u, l));
    }), o;
  }
  return gs = n, gs;
}
var bs, _f;
function Qo() {
  if (_f) return bs;
  _f = 1;
  var e = tr();
  function r(t, n, a) {
    for (var i = -1, o = t.length; ++i < o; ) {
      var s = t[i], u = n(s);
      if (u != null && (l === void 0 ? u === u && !e(u) : a(u, l)))
        var l = u, c = s;
    }
    return c;
  }
  return bs = r, bs;
}
var ys, wf;
function mb() {
  if (wf) return ys;
  wf = 1;
  function e(r, t) {
    return r > t;
  }
  return ys = e, ys;
}
var xs, Nf;
function vb() {
  if (Nf) return xs;
  Nf = 1;
  var e = Qo(), r = mb(), t = $e();
  function n(a) {
    return a && a.length ? e(a, t, r) : void 0;
  }
  return xs = n, xs;
}
var _s, If;
function H0() {
  if (If) return _s;
  If = 1;
  var e = Br(), r = Xe();
  function t(n, a, i) {
    (i !== void 0 && !r(n[a], i) || i === void 0 && !(a in n)) && e(n, a, i);
  }
  return _s = t, _s;
}
var ws, qf;
function gb() {
  if (qf) return ws;
  qf = 1;
  var e = ze(), r = Kr(), t = Ae(), n = "[object Object]", a = Function.prototype, i = Object.prototype, o = a.toString, s = i.hasOwnProperty, u = o.call(Object);
  function l(c) {
    if (!t(c) || e(c) != n)
      return !1;
    var d = r(c);
    if (d === null)
      return !0;
    var h = s.call(d, "constructor") && d.constructor;
    return typeof h == "function" && h instanceof h && o.call(h) == u;
  }
  return ws = l, ws;
}
var Ns, kf;
function K0() {
  if (kf) return Ns;
  kf = 1;
  function e(r, t) {
    if (!(t === "constructor" && typeof r[t] == "function") && t != "__proto__")
      return r[t];
  }
  return Ns = e, Ns;
}
var Is, Sf;
function bb() {
  if (Sf) return Is;
  Sf = 1;
  var e = yr(), r = Ue();
  function t(n) {
    return e(n, r(n));
  }
  return Is = t, Is;
}
var qs, Rf;
function yb() {
  if (Rf) return qs;
  Rf = 1;
  var e = H0(), r = t0(), t = d0(), n = n0(), a = h0(), i = xr(), o = se(), s = j0(), u = er(), l = br(), c = we(), d = gb(), h = _r(), p = K0(), x = bb();
  function v(m, b, g, y, w, I, q) {
    var N = p(m, g), R = p(b, g), k = q.get(R);
    if (k) {
      e(m, g, k);
      return;
    }
    var S = I ? I(N, R, g + "", m, b, q) : void 0, E = S === void 0;
    if (E) {
      var A = o(R), P = !A && u(R), G = !A && !P && h(R);
      S = R, A || P || G ? o(N) ? S = N : s(N) ? S = n(N) : P ? (E = !1, S = r(R, !0)) : G ? (E = !1, S = t(R, !0)) : S = [] : d(R) || i(R) ? (S = N, i(N) ? S = x(N) : (!c(N) || l(N)) && (S = a(R))) : E = !1;
    }
    E && (q.set(R, S), w(S, R, y, I, q), q.delete(R)), e(m, g, S);
  }
  return qs = v, qs;
}
var ks, Cf;
function xb() {
  if (Cf) return ks;
  Cf = 1;
  var e = zr(), r = H0(), t = Ko(), n = yb(), a = we(), i = Ue(), o = K0();
  function s(u, l, c, d, h) {
    u !== l && t(l, function(p, x) {
      if (h || (h = new e()), a(p))
        n(u, l, x, c, s, d, h);
      else {
        var v = d ? d(o(u, x), p, x + "", u, l, h) : void 0;
        v === void 0 && (v = p), r(u, x, v);
      }
    }, i);
  }
  return ks = s, ks;
}
var Ss, Ef;
function _b() {
  if (Ef) return Ss;
  Ef = 1;
  var e = Xr(), r = Qr();
  function t(n) {
    return e(function(a, i) {
      var o = -1, s = i.length, u = s > 1 ? i[s - 1] : void 0, l = s > 2 ? i[2] : void 0;
      for (u = n.length > 3 && typeof u == "function" ? (s--, u) : void 0, l && r(i[0], i[1], l) && (u = s < 3 ? void 0 : u, s = 1), a = Object(a); ++o < s; ) {
        var c = i[o];
        c && n(a, c, o, u);
      }
      return a;
    });
  }
  return Ss = t, Ss;
}
var Rs, Af;
function wb() {
  if (Af) return Rs;
  Af = 1;
  var e = xb(), r = _b(), t = r(function(n, a, i) {
    e(n, a, i);
  });
  return Rs = t, Rs;
}
var Cs, Tf;
function W0() {
  if (Tf) return Cs;
  Tf = 1;
  function e(r, t) {
    return r < t;
  }
  return Cs = e, Cs;
}
var Es, Mf;
function Nb() {
  if (Mf) return Es;
  Mf = 1;
  var e = Qo(), r = W0(), t = $e();
  function n(a) {
    return a && a.length ? e(a, t, r) : void 0;
  }
  return Es = n, Es;
}
var As, Of;
function Ib() {
  if (Of) return As;
  Of = 1;
  var e = Qo(), r = je(), t = W0();
  function n(a, i) {
    return a && a.length ? e(a, r(i, 2), t) : void 0;
  }
  return As = n, As;
}
var Ts, Pf;
function qb() {
  if (Pf) return Ts;
  Pf = 1;
  var e = Se(), r = function() {
    return e.Date.now();
  };
  return Ts = r, Ts;
}
var Ms, Lf;
function kb() {
  if (Lf) return Ms;
  Lf = 1;
  var e = Ur(), r = Jr(), t = $r(), n = we(), a = wr();
  function i(o, s, u, l) {
    if (!n(o))
      return o;
    s = r(s, o);
    for (var c = -1, d = s.length, h = d - 1, p = o; p != null && ++c < d; ) {
      var x = a(s[c]), v = u;
      if (x === "__proto__" || x === "constructor" || x === "prototype")
        return o;
      if (c != h) {
        var m = p[x];
        v = l ? l(m, x, p) : void 0, v === void 0 && (v = n(m) ? m : t(s[c + 1]) ? [] : {});
      }
      e(p, x, v), p = p[x];
    }
    return o;
  }
  return Ms = i, Ms;
}
var Os, jf;
function Sb() {
  if (jf) return Os;
  jf = 1;
  var e = Zr(), r = kb(), t = Jr();
  function n(a, i, o) {
    for (var s = -1, u = i.length, l = {}; ++s < u; ) {
      var c = i[s], d = e(a, c);
      o(d, c) && r(l, t(c, a), d);
    }
    return l;
  }
  return Os = n, Os;
}
var Ps, Df;
function Rb() {
  if (Df) return Ps;
  Df = 1;
  var e = Sb(), r = k0();
  function t(n, a) {
    return e(n, a, function(i, o) {
      return r(n, o);
    });
  }
  return Ps = t, Ps;
}
var Ls, Ff;
function Cb() {
  if (Ff) return Ls;
  Ff = 1;
  var e = V0(), r = O0(), t = P0();
  function n(a) {
    return t(r(a, void 0, e), a + "");
  }
  return Ls = n, Ls;
}
var js, Gf;
function Eb() {
  if (Gf) return js;
  Gf = 1;
  var e = Rb(), r = Cb(), t = r(function(n, a) {
    return n == null ? {} : e(n, a);
  });
  return js = t, js;
}
var Ds, zf;
function Ab() {
  if (zf) return Ds;
  zf = 1;
  var e = Math.ceil, r = Math.max;
  function t(n, a, i, o) {
    for (var s = -1, u = r(e((a - n) / (i || 1)), 0), l = Array(u); u--; )
      l[o ? u : ++s] = n, n += i;
    return l;
  }
  return Ds = t, Ds;
}
var Fs, Bf;
function Tb() {
  if (Bf) return Fs;
  Bf = 1;
  var e = Ab(), r = Qr(), t = $0();
  function n(a) {
    return function(i, o, s) {
      return s && typeof s != "number" && r(i, o, s) && (o = s = void 0), i = t(i), o === void 0 ? (o = i, i = 0) : o = t(o), s = s === void 0 ? i < o ? 1 : -1 : t(s), e(i, o, s, a);
    };
  }
  return Fs = n, Fs;
}
var Gs, Uf;
function Mb() {
  if (Uf) return Gs;
  Uf = 1;
  var e = Tb(), r = e();
  return Gs = r, Gs;
}
var zs, $f;
function Ob() {
  if ($f) return zs;
  $f = 1;
  function e(r, t) {
    var n = r.length;
    for (r.sort(t); n--; )
      r[n] = r[n].value;
    return r;
  }
  return zs = e, zs;
}
var Bs, Vf;
function Pb() {
  if (Vf) return Bs;
  Vf = 1;
  var e = tr();
  function r(t, n) {
    if (t !== n) {
      var a = t !== void 0, i = t === null, o = t === t, s = e(t), u = n !== void 0, l = n === null, c = n === n, d = e(n);
      if (!l && !d && !s && t > n || s && u && c && !l && !d || i && u && c || !a && c || !o)
        return 1;
      if (!i && !s && !d && t < n || d && a && o && !i && !s || l && a && o || !u && o || !c)
        return -1;
    }
    return 0;
  }
  return Bs = r, Bs;
}
var Us, Hf;
function Lb() {
  if (Hf) return Us;
  Hf = 1;
  var e = Pb();
  function r(t, n, a) {
    for (var i = -1, o = t.criteria, s = n.criteria, u = o.length, l = a.length; ++i < u; ) {
      var c = e(o[i], s[i]);
      if (c) {
        if (i >= l)
          return c;
        var d = a[i];
        return c * (d == "desc" ? -1 : 1);
      }
    }
    return t.index - n.index;
  }
  return Us = r, Us;
}
var $s, Kf;
function jb() {
  if (Kf) return $s;
  Kf = 1;
  var e = Yr(), r = Zr(), t = je(), n = A0(), a = Ob(), i = Vr(), o = Lb(), s = $e(), u = se();
  function l(c, d, h) {
    d.length ? d = e(d, function(v) {
      return u(v) ? function(m) {
        return r(m, v.length === 1 ? v[0] : v);
      } : v;
    }) : d = [s];
    var p = -1;
    d = e(d, i(t));
    var x = n(c, function(v, m, b) {
      var g = e(d, function(y) {
        return y(v);
      });
      return { criteria: g, index: ++p, value: v };
    });
    return a(x, function(v, m) {
      return o(v, m, h);
    });
  }
  return $s = l, $s;
}
var Vs, Wf;
function Db() {
  if (Wf) return Vs;
  Wf = 1;
  var e = Zo(), r = jb(), t = Xr(), n = Qr(), a = t(function(i, o) {
    if (i == null)
      return [];
    var s = o.length;
    return s > 1 && n(i, o[0], o[1]) ? o = [] : s > 2 && n(o[0], o[1], o[2]) && (o = [o[0]]), r(i, e(o, 1), []);
  });
  return Vs = a, Vs;
}
var Hs, Yf;
function Fb() {
  if (Yf) return Hs;
  Yf = 1;
  var e = I0(), r = 0;
  function t(n) {
    var a = ++r;
    return e(n) + a;
  }
  return Hs = t, Hs;
}
var Ks, Jf;
function Gb() {
  if (Jf) return Ks;
  Jf = 1;
  function e(r, t, n) {
    for (var a = -1, i = r.length, o = t.length, s = {}; ++a < i; ) {
      var u = a < o ? t[a] : void 0;
      n(s, r[a], u);
    }
    return s;
  }
  return Ks = e, Ks;
}
var Ws, Zf;
function zb() {
  if (Zf) return Ws;
  Zf = 1;
  var e = Ur(), r = Gb();
  function t(n, a) {
    return r(n || [], a || [], e);
  }
  return Ws = t, Ws;
}
var Ys, Xf;
function re() {
  if (Xf) return Ys;
  Xf = 1;
  var e;
  if (typeof Lo == "function")
    try {
      e = {
        cloneDeep: nb(),
        constant: Ho(),
        defaults: ab(),
        each: g0(),
        filter: R0(),
        find: db(),
        flatten: V0(),
        forEach: v0(),
        forIn: fb(),
        has: C0(),
        isUndefined: E0(),
        last: hb(),
        map: T0(),
        mapValues: pb(),
        max: vb(),
        merge: wb(),
        min: Nb(),
        minBy: Ib(),
        now: qb(),
        pick: Eb(),
        range: Mb(),
        reduce: M0(),
        sortBy: Db(),
        uniqueId: Fb(),
        values: D0(),
        zipObject: zb()
      };
    } catch {
    }
  return e || (e = window._), Ys = e, Ys;
}
var Js, Qf;
function Bb() {
  if (Qf) return Js;
  Qf = 1, Js = e;
  function e() {
    var n = {};
    n._next = n._prev = n, this._sentinel = n;
  }
  e.prototype.dequeue = function() {
    var n = this._sentinel, a = n._prev;
    if (a !== n)
      return r(a), a;
  }, e.prototype.enqueue = function(n) {
    var a = this._sentinel;
    n._prev && n._next && r(n), n._next = a._next, a._next._prev = n, a._next = n, n._prev = a;
  }, e.prototype.toString = function() {
    for (var n = [], a = this._sentinel, i = a._prev; i !== a; )
      n.push(JSON.stringify(i, t)), i = i._prev;
    return "[" + n.join(", ") + "]";
  };
  function r(n) {
    n._prev._next = n._next, n._next._prev = n._prev, delete n._next, delete n._prev;
  }
  function t(n, a) {
    if (n !== "_next" && n !== "_prev")
      return a;
  }
  return Js;
}
var Zs, eh;
function Ub() {
  if (eh) return Zs;
  eh = 1;
  var e = re(), r = ke().Graph, t = Bb();
  Zs = a;
  var n = e.constant(1);
  function a(l, c) {
    if (l.nodeCount() <= 1)
      return [];
    var d = s(l, c || n), h = i(d.graph, d.buckets, d.zeroIdx);
    return e.flatten(e.map(h, function(p) {
      return l.outEdges(p.v, p.w);
    }), !0);
  }
  function i(l, c, d) {
    for (var h = [], p = c[c.length - 1], x = c[0], v; l.nodeCount(); ) {
      for (; v = x.dequeue(); )
        o(l, c, d, v);
      for (; v = p.dequeue(); )
        o(l, c, d, v);
      if (l.nodeCount()) {
        for (var m = c.length - 2; m > 0; --m)
          if (v = c[m].dequeue(), v) {
            h = h.concat(o(l, c, d, v, !0));
            break;
          }
      }
    }
    return h;
  }
  function o(l, c, d, h, p) {
    var x = p ? [] : void 0;
    return e.forEach(l.inEdges(h.v), function(v) {
      var m = l.edge(v), b = l.node(v.v);
      p && x.push({ v: v.v, w: v.w }), b.out -= m, u(c, d, b);
    }), e.forEach(l.outEdges(h.v), function(v) {
      var m = l.edge(v), b = v.w, g = l.node(b);
      g.in -= m, u(c, d, g);
    }), l.removeNode(h.v), x;
  }
  function s(l, c) {
    var d = new r(), h = 0, p = 0;
    e.forEach(l.nodes(), function(m) {
      d.setNode(m, { v: m, in: 0, out: 0 });
    }), e.forEach(l.edges(), function(m) {
      var b = d.edge(m.v, m.w) || 0, g = c(m), y = b + g;
      d.setEdge(m.v, m.w, y), p = Math.max(p, d.node(m.v).out += g), h = Math.max(h, d.node(m.w).in += g);
    });
    var x = e.range(p + h + 3).map(function() {
      return new t();
    }), v = h + 1;
    return e.forEach(d.nodes(), function(m) {
      u(x, v, d.node(m));
    }), { graph: d, buckets: x, zeroIdx: v };
  }
  function u(l, c, d) {
    d.out ? d.in ? l[d.out - d.in + c].enqueue(d) : l[l.length - 1].enqueue(d) : l[0].enqueue(d);
  }
  return Zs;
}
var Xs, rh;
function $b() {
  if (rh) return Xs;
  rh = 1;
  var e = re(), r = Ub();
  Xs = {
    run: t,
    undo: a
  };
  function t(i) {
    var o = i.graph().acyclicer === "greedy" ? r(i, s(i)) : n(i);
    e.forEach(o, function(u) {
      var l = i.edge(u);
      i.removeEdge(u), l.forwardName = u.name, l.reversed = !0, i.setEdge(u.w, u.v, l, e.uniqueId("rev"));
    });
    function s(u) {
      return function(l) {
        return u.edge(l).weight;
      };
    }
  }
  function n(i) {
    var o = [], s = {}, u = {};
    function l(c) {
      e.has(u, c) || (u[c] = !0, s[c] = !0, e.forEach(i.outEdges(c), function(d) {
        e.has(s, d.w) ? o.push(d) : l(d.w);
      }), delete s[c]);
    }
    return e.forEach(i.nodes(), l), o;
  }
  function a(i) {
    e.forEach(i.edges(), function(o) {
      var s = i.edge(o);
      if (s.reversed) {
        i.removeEdge(o);
        var u = s.forwardName;
        delete s.reversed, delete s.forwardName, i.setEdge(o.w, o.v, s, u);
      }
    });
  }
  return Xs;
}
var Qs, th;
function ye() {
  if (th) return Qs;
  th = 1;
  var e = re(), r = ke().Graph;
  Qs = {
    addDummyNode: t,
    simplify: n,
    asNonCompoundGraph: a,
    successorWeights: i,
    predecessorWeights: o,
    intersectRect: s,
    buildLayerMatrix: u,
    normalizeRanks: l,
    removeEmptyRanks: c,
    addBorderNode: d,
    maxRank: h,
    partition: p,
    time: x,
    notime: v
  };
  function t(m, b, g, y) {
    var w;
    do
      w = e.uniqueId(y);
    while (m.hasNode(w));
    return g.dummy = b, m.setNode(w, g), w;
  }
  function n(m) {
    var b = new r().setGraph(m.graph());
    return e.forEach(m.nodes(), function(g) {
      b.setNode(g, m.node(g));
    }), e.forEach(m.edges(), function(g) {
      var y = b.edge(g.v, g.w) || { weight: 0, minlen: 1 }, w = m.edge(g);
      b.setEdge(g.v, g.w, {
        weight: y.weight + w.weight,
        minlen: Math.max(y.minlen, w.minlen)
      });
    }), b;
  }
  function a(m) {
    var b = new r({ multigraph: m.isMultigraph() }).setGraph(m.graph());
    return e.forEach(m.nodes(), function(g) {
      m.children(g).length || b.setNode(g, m.node(g));
    }), e.forEach(m.edges(), function(g) {
      b.setEdge(g, m.edge(g));
    }), b;
  }
  function i(m) {
    var b = e.map(m.nodes(), function(g) {
      var y = {};
      return e.forEach(m.outEdges(g), function(w) {
        y[w.w] = (y[w.w] || 0) + m.edge(w).weight;
      }), y;
    });
    return e.zipObject(m.nodes(), b);
  }
  function o(m) {
    var b = e.map(m.nodes(), function(g) {
      var y = {};
      return e.forEach(m.inEdges(g), function(w) {
        y[w.v] = (y[w.v] || 0) + m.edge(w).weight;
      }), y;
    });
    return e.zipObject(m.nodes(), b);
  }
  function s(m, b) {
    var g = m.x, y = m.y, w = b.x - g, I = b.y - y, q = m.width / 2, N = m.height / 2;
    if (!w && !I)
      throw new Error("Not possible to find intersection inside of the rectangle");
    var R, k;
    return Math.abs(I) * q > Math.abs(w) * N ? (I < 0 && (N = -N), R = N * w / I, k = N) : (w < 0 && (q = -q), R = q, k = q * I / w), { x: g + R, y: y + k };
  }
  function u(m) {
    var b = e.map(e.range(h(m) + 1), function() {
      return [];
    });
    return e.forEach(m.nodes(), function(g) {
      var y = m.node(g), w = y.rank;
      e.isUndefined(w) || (b[w][y.order] = g);
    }), b;
  }
  function l(m) {
    var b = e.min(e.map(m.nodes(), function(g) {
      return m.node(g).rank;
    }));
    e.forEach(m.nodes(), function(g) {
      var y = m.node(g);
      e.has(y, "rank") && (y.rank -= b);
    });
  }
  function c(m) {
    var b = e.min(e.map(m.nodes(), function(I) {
      return m.node(I).rank;
    })), g = [];
    e.forEach(m.nodes(), function(I) {
      var q = m.node(I).rank - b;
      g[q] || (g[q] = []), g[q].push(I);
    });
    var y = 0, w = m.graph().nodeRankFactor;
    e.forEach(g, function(I, q) {
      e.isUndefined(I) && q % w !== 0 ? --y : y && e.forEach(I, function(N) {
        m.node(N).rank += y;
      });
    });
  }
  function d(m, b, g, y) {
    var w = {
      width: 0,
      height: 0
    };
    return arguments.length >= 4 && (w.rank = g, w.order = y), t(m, "border", w, b);
  }
  function h(m) {
    return e.max(e.map(m.nodes(), function(b) {
      var g = m.node(b).rank;
      if (!e.isUndefined(g))
        return g;
    }));
  }
  function p(m, b) {
    var g = { lhs: [], rhs: [] };
    return e.forEach(m, function(y) {
      b(y) ? g.lhs.push(y) : g.rhs.push(y);
    }), g;
  }
  function x(m, b) {
    var g = e.now();
    try {
      return b();
    } finally {
      console.log(m + " time: " + (e.now() - g) + "ms");
    }
  }
  function v(m, b) {
    return b();
  }
  return Qs;
}
var eo, nh;
function Vb() {
  if (nh) return eo;
  nh = 1;
  var e = re(), r = ye();
  eo = {
    run: t,
    undo: a
  };
  function t(i) {
    i.graph().dummyChains = [], e.forEach(i.edges(), function(o) {
      n(i, o);
    });
  }
  function n(i, o) {
    var s = o.v, u = i.node(s).rank, l = o.w, c = i.node(l).rank, d = o.name, h = i.edge(o), p = h.labelRank;
    if (c !== u + 1) {
      i.removeEdge(o);
      var x, v, m;
      for (m = 0, ++u; u < c; ++m, ++u)
        h.points = [], v = {
          width: 0,
          height: 0,
          edgeLabel: h,
          edgeObj: o,
          rank: u
        }, x = r.addDummyNode(i, "edge", v, "_d"), u === p && (v.width = h.width, v.height = h.height, v.dummy = "edge-label", v.labelpos = h.labelpos), i.setEdge(s, x, { weight: h.weight }, d), m === 0 && i.graph().dummyChains.push(x), s = x;
      i.setEdge(s, l, { weight: h.weight }, d);
    }
  }
  function a(i) {
    e.forEach(i.graph().dummyChains, function(o) {
      var s = i.node(o), u = s.edgeLabel, l;
      for (i.setEdge(s.edgeObj, u); s.dummy; )
        l = i.successors(o)[0], i.removeNode(o), u.points.push({ x: s.x, y: s.y }), s.dummy === "edge-label" && (u.x = s.x, u.y = s.y, u.width = s.width, u.height = s.height), o = l, s = i.node(o);
    });
  }
  return eo;
}
var ro, ah;
function Mr() {
  if (ah) return ro;
  ah = 1;
  var e = re();
  ro = {
    longestPath: r,
    slack: t
  };
  function r(n) {
    var a = {};
    function i(o) {
      var s = n.node(o);
      if (e.has(a, o))
        return s.rank;
      a[o] = !0;
      var u = e.min(e.map(n.outEdges(o), function(l) {
        return i(l.w) - n.edge(l).minlen;
      }));
      return (u === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3
      u === void 0 || // return value of _.map([]) for Lodash 4
      u === null) && (u = 0), s.rank = u;
    }
    e.forEach(n.sources(), i);
  }
  function t(n, a) {
    return n.node(a.w).rank - n.node(a.v).rank - n.edge(a).minlen;
  }
  return ro;
}
var to, ih;
function Y0() {
  if (ih) return to;
  ih = 1;
  var e = re(), r = ke().Graph, t = Mr().slack;
  to = n;
  function n(s) {
    var u = new r({ directed: !1 }), l = s.nodes()[0], c = s.nodeCount();
    u.setNode(l, {});
    for (var d, h; a(u, s) < c; )
      d = i(u, s), h = u.hasNode(d.v) ? t(s, d) : -t(s, d), o(u, s, h);
    return u;
  }
  function a(s, u) {
    function l(c) {
      e.forEach(u.nodeEdges(c), function(d) {
        var h = d.v, p = c === h ? d.w : h;
        !s.hasNode(p) && !t(u, d) && (s.setNode(p, {}), s.setEdge(c, p, {}), l(p));
      });
    }
    return e.forEach(s.nodes(), l), s.nodeCount();
  }
  function i(s, u) {
    return e.minBy(u.edges(), function(l) {
      if (s.hasNode(l.v) !== s.hasNode(l.w))
        return t(u, l);
    });
  }
  function o(s, u, l) {
    e.forEach(s.nodes(), function(c) {
      u.node(c).rank += l;
    });
  }
  return to;
}
var no, sh;
function Hb() {
  if (sh) return no;
  sh = 1;
  var e = re(), r = Y0(), t = Mr().slack, n = Mr().longestPath, a = ke().alg.preorder, i = ke().alg.postorder, o = ye().simplify;
  no = s, s.initLowLimValues = d, s.initCutValues = u, s.calcCutValue = c, s.leaveEdge = p, s.enterEdge = x, s.exchangeEdges = v;
  function s(y) {
    y = o(y), n(y);
    var w = r(y);
    d(w), u(w, y);
    for (var I, q; I = p(w); )
      q = x(w, y, I), v(w, y, I, q);
  }
  function u(y, w) {
    var I = i(y, y.nodes());
    I = I.slice(0, I.length - 1), e.forEach(I, function(q) {
      l(y, w, q);
    });
  }
  function l(y, w, I) {
    var q = y.node(I), N = q.parent;
    y.edge(I, N).cutvalue = c(y, w, I);
  }
  function c(y, w, I) {
    var q = y.node(I), N = q.parent, R = !0, k = w.edge(I, N), S = 0;
    return k || (R = !1, k = w.edge(N, I)), S = k.weight, e.forEach(w.nodeEdges(I), function(E) {
      var A = E.v === I, P = A ? E.w : E.v;
      if (P !== N) {
        var G = A === R, H = w.edge(E).weight;
        if (S += G ? H : -H, b(y, I, P)) {
          var ee = y.edge(I, P).cutvalue;
          S += G ? -ee : ee;
        }
      }
    }), S;
  }
  function d(y, w) {
    arguments.length < 2 && (w = y.nodes()[0]), h(y, {}, 1, w);
  }
  function h(y, w, I, q, N) {
    var R = I, k = y.node(q);
    return w[q] = !0, e.forEach(y.neighbors(q), function(S) {
      e.has(w, S) || (I = h(y, w, I, S, q));
    }), k.low = R, k.lim = I++, N ? k.parent = N : delete k.parent, I;
  }
  function p(y) {
    return e.find(y.edges(), function(w) {
      return y.edge(w).cutvalue < 0;
    });
  }
  function x(y, w, I) {
    var q = I.v, N = I.w;
    w.hasEdge(q, N) || (q = I.w, N = I.v);
    var R = y.node(q), k = y.node(N), S = R, E = !1;
    R.lim > k.lim && (S = k, E = !0);
    var A = e.filter(w.edges(), function(P) {
      return E === g(y, y.node(P.v), S) && E !== g(y, y.node(P.w), S);
    });
    return e.minBy(A, function(P) {
      return t(w, P);
    });
  }
  function v(y, w, I, q) {
    var N = I.v, R = I.w;
    y.removeEdge(N, R), y.setEdge(q.v, q.w, {}), d(y), u(y, w), m(y, w);
  }
  function m(y, w) {
    var I = e.find(y.nodes(), function(N) {
      return !w.node(N).parent;
    }), q = a(y, I);
    q = q.slice(1), e.forEach(q, function(N) {
      var R = y.node(N).parent, k = w.edge(N, R), S = !1;
      k || (k = w.edge(R, N), S = !0), w.node(N).rank = w.node(R).rank + (S ? k.minlen : -k.minlen);
    });
  }
  function b(y, w, I) {
    return y.hasEdge(w, I);
  }
  function g(y, w, I) {
    return I.low <= w.lim && w.lim <= I.lim;
  }
  return no;
}
var ao, oh;
function Kb() {
  if (oh) return ao;
  oh = 1;
  var e = Mr(), r = e.longestPath, t = Y0(), n = Hb();
  ao = a;
  function a(u) {
    switch (u.graph().ranker) {
      case "network-simplex":
        s(u);
        break;
      case "tight-tree":
        o(u);
        break;
      case "longest-path":
        i(u);
        break;
      default:
        s(u);
    }
  }
  var i = r;
  function o(u) {
    r(u), t(u);
  }
  function s(u) {
    n(u);
  }
  return ao;
}
var io, ch;
function Wb() {
  if (ch) return io;
  ch = 1;
  var e = re();
  io = r;
  function r(a) {
    var i = n(a);
    e.forEach(a.graph().dummyChains, function(o) {
      for (var s = a.node(o), u = s.edgeObj, l = t(a, i, u.v, u.w), c = l.path, d = l.lca, h = 0, p = c[h], x = !0; o !== u.w; ) {
        if (s = a.node(o), x) {
          for (; (p = c[h]) !== d && a.node(p).maxRank < s.rank; )
            h++;
          p === d && (x = !1);
        }
        if (!x) {
          for (; h < c.length - 1 && a.node(p = c[h + 1]).minRank <= s.rank; )
            h++;
          p = c[h];
        }
        a.setParent(o, p), o = a.successors(o)[0];
      }
    });
  }
  function t(a, i, o, s) {
    var u = [], l = [], c = Math.min(i[o].low, i[s].low), d = Math.max(i[o].lim, i[s].lim), h, p;
    h = o;
    do
      h = a.parent(h), u.push(h);
    while (h && (i[h].low > c || d > i[h].lim));
    for (p = h, h = s; (h = a.parent(h)) !== p; )
      l.push(h);
    return { path: u.concat(l.reverse()), lca: p };
  }
  function n(a) {
    var i = {}, o = 0;
    function s(u) {
      var l = o;
      e.forEach(a.children(u), s), i[u] = { low: l, lim: o++ };
    }
    return e.forEach(a.children(), s), i;
  }
  return io;
}
var so, uh;
function Yb() {
  if (uh) return so;
  uh = 1;
  var e = re(), r = ye();
  so = {
    run: t,
    cleanup: o
  };
  function t(s) {
    var u = r.addDummyNode(s, "root", {}, "_root"), l = a(s), c = e.max(e.values(l)) - 1, d = 2 * c + 1;
    s.graph().nestingRoot = u, e.forEach(s.edges(), function(p) {
      s.edge(p).minlen *= d;
    });
    var h = i(s) + 1;
    e.forEach(s.children(), function(p) {
      n(s, u, d, h, c, l, p);
    }), s.graph().nodeRankFactor = d;
  }
  function n(s, u, l, c, d, h, p) {
    var x = s.children(p);
    if (!x.length) {
      p !== u && s.setEdge(u, p, { weight: 0, minlen: l });
      return;
    }
    var v = r.addBorderNode(s, "_bt"), m = r.addBorderNode(s, "_bb"), b = s.node(p);
    s.setParent(v, p), b.borderTop = v, s.setParent(m, p), b.borderBottom = m, e.forEach(x, function(g) {
      n(s, u, l, c, d, h, g);
      var y = s.node(g), w = y.borderTop ? y.borderTop : g, I = y.borderBottom ? y.borderBottom : g, q = y.borderTop ? c : 2 * c, N = w !== I ? 1 : d - h[p] + 1;
      s.setEdge(v, w, {
        weight: q,
        minlen: N,
        nestingEdge: !0
      }), s.setEdge(I, m, {
        weight: q,
        minlen: N,
        nestingEdge: !0
      });
    }), s.parent(p) || s.setEdge(u, v, { weight: 0, minlen: d + h[p] });
  }
  function a(s) {
    var u = {};
    function l(c, d) {
      var h = s.children(c);
      h && h.length && e.forEach(h, function(p) {
        l(p, d + 1);
      }), u[c] = d;
    }
    return e.forEach(s.children(), function(c) {
      l(c, 1);
    }), u;
  }
  function i(s) {
    return e.reduce(s.edges(), function(u, l) {
      return u + s.edge(l).weight;
    }, 0);
  }
  function o(s) {
    var u = s.graph();
    s.removeNode(u.nestingRoot), delete u.nestingRoot, e.forEach(s.edges(), function(l) {
      var c = s.edge(l);
      c.nestingEdge && s.removeEdge(l);
    });
  }
  return so;
}
var oo, lh;
function Jb() {
  if (lh) return oo;
  lh = 1;
  var e = re(), r = ye();
  oo = t;
  function t(a) {
    function i(o) {
      var s = a.children(o), u = a.node(o);
      if (s.length && e.forEach(s, i), e.has(u, "minRank")) {
        u.borderLeft = [], u.borderRight = [];
        for (var l = u.minRank, c = u.maxRank + 1; l < c; ++l)
          n(a, "borderLeft", "_bl", o, u, l), n(a, "borderRight", "_br", o, u, l);
      }
    }
    e.forEach(a.children(), i);
  }
  function n(a, i, o, s, u, l) {
    var c = { width: 0, height: 0, rank: l, borderType: i }, d = u[i][l - 1], h = r.addDummyNode(a, "border", c, o);
    u[i][l] = h, a.setParent(h, s), d && a.setEdge(d, h, { weight: 1 });
  }
  return oo;
}
var co, dh;
function Zb() {
  if (dh) return co;
  dh = 1;
  var e = re();
  co = {
    adjust: r,
    undo: t
  };
  function r(l) {
    var c = l.graph().rankdir.toLowerCase();
    (c === "lr" || c === "rl") && n(l);
  }
  function t(l) {
    var c = l.graph().rankdir.toLowerCase();
    (c === "bt" || c === "rl") && i(l), (c === "lr" || c === "rl") && (s(l), n(l));
  }
  function n(l) {
    e.forEach(l.nodes(), function(c) {
      a(l.node(c));
    }), e.forEach(l.edges(), function(c) {
      a(l.edge(c));
    });
  }
  function a(l) {
    var c = l.width;
    l.width = l.height, l.height = c;
  }
  function i(l) {
    e.forEach(l.nodes(), function(c) {
      o(l.node(c));
    }), e.forEach(l.edges(), function(c) {
      var d = l.edge(c);
      e.forEach(d.points, o), e.has(d, "y") && o(d);
    });
  }
  function o(l) {
    l.y = -l.y;
  }
  function s(l) {
    e.forEach(l.nodes(), function(c) {
      u(l.node(c));
    }), e.forEach(l.edges(), function(c) {
      var d = l.edge(c);
      e.forEach(d.points, u), e.has(d, "x") && u(d);
    });
  }
  function u(l) {
    var c = l.x;
    l.x = l.y, l.y = c;
  }
  return co;
}
var uo, fh;
function Xb() {
  if (fh) return uo;
  fh = 1;
  var e = re();
  uo = r;
  function r(t) {
    var n = {}, a = e.filter(t.nodes(), function(l) {
      return !t.children(l).length;
    }), i = e.max(e.map(a, function(l) {
      return t.node(l).rank;
    })), o = e.map(e.range(i + 1), function() {
      return [];
    });
    function s(l) {
      if (!e.has(n, l)) {
        n[l] = !0;
        var c = t.node(l);
        o[c.rank].push(l), e.forEach(t.successors(l), s);
      }
    }
    var u = e.sortBy(a, function(l) {
      return t.node(l).rank;
    });
    return e.forEach(u, s), o;
  }
  return uo;
}
var lo, hh;
function Qb() {
  if (hh) return lo;
  hh = 1;
  var e = re();
  lo = r;
  function r(n, a) {
    for (var i = 0, o = 1; o < a.length; ++o)
      i += t(n, a[o - 1], a[o]);
    return i;
  }
  function t(n, a, i) {
    for (var o = e.zipObject(
      i,
      e.map(i, function(h, p) {
        return p;
      })
    ), s = e.flatten(e.map(a, function(h) {
      return e.sortBy(e.map(n.outEdges(h), function(p) {
        return { pos: o[p.w], weight: n.edge(p).weight };
      }), "pos");
    }), !0), u = 1; u < i.length; ) u <<= 1;
    var l = 2 * u - 1;
    u -= 1;
    var c = e.map(new Array(l), function() {
      return 0;
    }), d = 0;
    return e.forEach(s.forEach(function(h) {
      var p = h.pos + u;
      c[p] += h.weight;
      for (var x = 0; p > 0; )
        p % 2 && (x += c[p + 1]), p = p - 1 >> 1, c[p] += h.weight;
      d += h.weight * x;
    })), d;
  }
  return lo;
}
var fo, ph;
function ey() {
  if (ph) return fo;
  ph = 1;
  var e = re();
  fo = r;
  function r(t, n) {
    return e.map(n, function(a) {
      var i = t.inEdges(a);
      if (i.length) {
        var o = e.reduce(i, function(s, u) {
          var l = t.edge(u), c = t.node(u.v);
          return {
            sum: s.sum + l.weight * c.order,
            weight: s.weight + l.weight
          };
        }, { sum: 0, weight: 0 });
        return {
          v: a,
          barycenter: o.sum / o.weight,
          weight: o.weight
        };
      } else
        return { v: a };
    });
  }
  return fo;
}
var ho, mh;
function ry() {
  if (mh) return ho;
  mh = 1;
  var e = re();
  ho = r;
  function r(a, i) {
    var o = {};
    e.forEach(a, function(u, l) {
      var c = o[u.v] = {
        indegree: 0,
        in: [],
        out: [],
        vs: [u.v],
        i: l
      };
      e.isUndefined(u.barycenter) || (c.barycenter = u.barycenter, c.weight = u.weight);
    }), e.forEach(i.edges(), function(u) {
      var l = o[u.v], c = o[u.w];
      !e.isUndefined(l) && !e.isUndefined(c) && (c.indegree++, l.out.push(o[u.w]));
    });
    var s = e.filter(o, function(u) {
      return !u.indegree;
    });
    return t(s);
  }
  function t(a) {
    var i = [];
    function o(l) {
      return function(c) {
        c.merged || (e.isUndefined(c.barycenter) || e.isUndefined(l.barycenter) || c.barycenter >= l.barycenter) && n(l, c);
      };
    }
    function s(l) {
      return function(c) {
        c.in.push(l), --c.indegree === 0 && a.push(c);
      };
    }
    for (; a.length; ) {
      var u = a.pop();
      i.push(u), e.forEach(u.in.reverse(), o(u)), e.forEach(u.out, s(u));
    }
    return e.map(
      e.filter(i, function(l) {
        return !l.merged;
      }),
      function(l) {
        return e.pick(l, ["vs", "i", "barycenter", "weight"]);
      }
    );
  }
  function n(a, i) {
    var o = 0, s = 0;
    a.weight && (o += a.barycenter * a.weight, s += a.weight), i.weight && (o += i.barycenter * i.weight, s += i.weight), a.vs = i.vs.concat(a.vs), a.barycenter = o / s, a.weight = s, a.i = Math.min(i.i, a.i), i.merged = !0;
  }
  return ho;
}
var po, vh;
function ty() {
  if (vh) return po;
  vh = 1;
  var e = re(), r = ye();
  po = t;
  function t(i, o) {
    var s = r.partition(i, function(v) {
      return e.has(v, "barycenter");
    }), u = s.lhs, l = e.sortBy(s.rhs, function(v) {
      return -v.i;
    }), c = [], d = 0, h = 0, p = 0;
    u.sort(a(!!o)), p = n(c, l, p), e.forEach(u, function(v) {
      p += v.vs.length, c.push(v.vs), d += v.barycenter * v.weight, h += v.weight, p = n(c, l, p);
    });
    var x = { vs: e.flatten(c, !0) };
    return h && (x.barycenter = d / h, x.weight = h), x;
  }
  function n(i, o, s) {
    for (var u; o.length && (u = e.last(o)).i <= s; )
      o.pop(), i.push(u.vs), s++;
    return s;
  }
  function a(i) {
    return function(o, s) {
      return o.barycenter < s.barycenter ? -1 : o.barycenter > s.barycenter ? 1 : i ? s.i - o.i : o.i - s.i;
    };
  }
  return po;
}
var mo, gh;
function ny() {
  if (gh) return mo;
  gh = 1;
  var e = re(), r = ey(), t = ry(), n = ty();
  mo = a;
  function a(s, u, l, c) {
    var d = s.children(u), h = s.node(u), p = h ? h.borderLeft : void 0, x = h ? h.borderRight : void 0, v = {};
    p && (d = e.filter(d, function(I) {
      return I !== p && I !== x;
    }));
    var m = r(s, d);
    e.forEach(m, function(I) {
      if (s.children(I.v).length) {
        var q = a(s, I.v, l, c);
        v[I.v] = q, e.has(q, "barycenter") && o(I, q);
      }
    });
    var b = t(m, l);
    i(b, v);
    var g = n(b, c);
    if (p && (g.vs = e.flatten([p, g.vs, x], !0), s.predecessors(p).length)) {
      var y = s.node(s.predecessors(p)[0]), w = s.node(s.predecessors(x)[0]);
      e.has(g, "barycenter") || (g.barycenter = 0, g.weight = 0), g.barycenter = (g.barycenter * g.weight + y.order + w.order) / (g.weight + 2), g.weight += 2;
    }
    return g;
  }
  function i(s, u) {
    e.forEach(s, function(l) {
      l.vs = e.flatten(l.vs.map(function(c) {
        return u[c] ? u[c].vs : c;
      }), !0);
    });
  }
  function o(s, u) {
    e.isUndefined(s.barycenter) ? (s.barycenter = u.barycenter, s.weight = u.weight) : (s.barycenter = (s.barycenter * s.weight + u.barycenter * u.weight) / (s.weight + u.weight), s.weight += u.weight);
  }
  return mo;
}
var vo, bh;
function ay() {
  if (bh) return vo;
  bh = 1;
  var e = re(), r = ke().Graph;
  vo = t;
  function t(a, i, o) {
    var s = n(a), u = new r({ compound: !0 }).setGraph({ root: s }).setDefaultNodeLabel(function(l) {
      return a.node(l);
    });
    return e.forEach(a.nodes(), function(l) {
      var c = a.node(l), d = a.parent(l);
      (c.rank === i || c.minRank <= i && i <= c.maxRank) && (u.setNode(l), u.setParent(l, d || s), e.forEach(a[o](l), function(h) {
        var p = h.v === l ? h.w : h.v, x = u.edge(p, l), v = e.isUndefined(x) ? 0 : x.weight;
        u.setEdge(p, l, { weight: a.edge(h).weight + v });
      }), e.has(c, "minRank") && u.setNode(l, {
        borderLeft: c.borderLeft[i],
        borderRight: c.borderRight[i]
      }));
    }), u;
  }
  function n(a) {
    for (var i; a.hasNode(i = e.uniqueId("_root")); ) ;
    return i;
  }
  return vo;
}
var go, yh;
function iy() {
  if (yh) return go;
  yh = 1;
  var e = re();
  go = r;
  function r(t, n, a) {
    var i = {}, o;
    e.forEach(a, function(s) {
      for (var u = t.parent(s), l, c; u; ) {
        if (l = t.parent(u), l ? (c = i[l], i[l] = u) : (c = o, o = u), c && c !== u) {
          n.setEdge(c, u);
          return;
        }
        u = l;
      }
    });
  }
  return go;
}
var bo, xh;
function sy() {
  if (xh) return bo;
  xh = 1;
  var e = re(), r = Xb(), t = Qb(), n = ny(), a = ay(), i = iy(), o = ke().Graph, s = ye();
  bo = u;
  function u(h) {
    var p = s.maxRank(h), x = l(h, e.range(1, p + 1), "inEdges"), v = l(h, e.range(p - 1, -1, -1), "outEdges"), m = r(h);
    d(h, m);
    for (var b = Number.POSITIVE_INFINITY, g, y = 0, w = 0; w < 4; ++y, ++w) {
      c(y % 2 ? x : v, y % 4 >= 2), m = s.buildLayerMatrix(h);
      var I = t(h, m);
      I < b && (w = 0, g = e.cloneDeep(m), b = I);
    }
    d(h, g);
  }
  function l(h, p, x) {
    return e.map(p, function(v) {
      return a(h, v, x);
    });
  }
  function c(h, p) {
    var x = new o();
    e.forEach(h, function(v) {
      var m = v.graph().root, b = n(v, m, x, p);
      e.forEach(b.vs, function(g, y) {
        v.node(g).order = y;
      }), i(v, x, b.vs);
    });
  }
  function d(h, p) {
    e.forEach(p, function(x) {
      e.forEach(x, function(v, m) {
        h.node(v).order = m;
      });
    });
  }
  return bo;
}
var yo, _h;
function oy() {
  if (_h) return yo;
  _h = 1;
  var e = re(), r = ke().Graph, t = ye();
  yo = {
    positionX: x,
    findType1Conflicts: n,
    findType2Conflicts: a,
    addConflict: o,
    hasConflict: s,
    verticalAlignment: u,
    horizontalCompaction: l,
    alignCoordinates: h,
    findSmallestWidthAlignment: d,
    balance: p
  };
  function n(b, g) {
    var y = {};
    function w(I, q) {
      var N = 0, R = 0, k = I.length, S = e.last(q);
      return e.forEach(q, function(E, A) {
        var P = i(b, E), G = P ? b.node(P).order : k;
        (P || E === S) && (e.forEach(q.slice(R, A + 1), function(H) {
          e.forEach(b.predecessors(H), function(ee) {
            var O = b.node(ee), z = O.order;
            (z < N || G < z) && !(O.dummy && b.node(H).dummy) && o(y, ee, H);
          });
        }), R = A + 1, N = G);
      }), q;
    }
    return e.reduce(g, w), y;
  }
  function a(b, g) {
    var y = {};
    function w(q, N, R, k, S) {
      var E;
      e.forEach(e.range(N, R), function(A) {
        E = q[A], b.node(E).dummy && e.forEach(b.predecessors(E), function(P) {
          var G = b.node(P);
          G.dummy && (G.order < k || G.order > S) && o(y, P, E);
        });
      });
    }
    function I(q, N) {
      var R = -1, k, S = 0;
      return e.forEach(N, function(E, A) {
        if (b.node(E).dummy === "border") {
          var P = b.predecessors(E);
          P.length && (k = b.node(P[0]).order, w(N, S, A, R, k), S = A, R = k);
        }
        w(N, S, N.length, k, q.length);
      }), N;
    }
    return e.reduce(g, I), y;
  }
  function i(b, g) {
    if (b.node(g).dummy)
      return e.find(b.predecessors(g), function(y) {
        return b.node(y).dummy;
      });
  }
  function o(b, g, y) {
    if (g > y) {
      var w = g;
      g = y, y = w;
    }
    var I = b[g];
    I || (b[g] = I = {}), I[y] = !0;
  }
  function s(b, g, y) {
    if (g > y) {
      var w = g;
      g = y, y = w;
    }
    return e.has(b[g], y);
  }
  function u(b, g, y, w) {
    var I = {}, q = {}, N = {};
    return e.forEach(g, function(R) {
      e.forEach(R, function(k, S) {
        I[k] = k, q[k] = k, N[k] = S;
      });
    }), e.forEach(g, function(R) {
      var k = -1;
      e.forEach(R, function(S) {
        var E = w(S);
        if (E.length) {
          E = e.sortBy(E, function(ee) {
            return N[ee];
          });
          for (var A = (E.length - 1) / 2, P = Math.floor(A), G = Math.ceil(A); P <= G; ++P) {
            var H = E[P];
            q[S] === S && k < N[H] && !s(y, S, H) && (q[H] = S, q[S] = I[S] = I[H], k = N[H]);
          }
        }
      });
    }), { root: I, align: q };
  }
  function l(b, g, y, w, I) {
    var q = {}, N = c(b, g, y, I), R = I ? "borderLeft" : "borderRight";
    function k(A, P) {
      for (var G = N.nodes(), H = G.pop(), ee = {}; H; )
        ee[H] ? A(H) : (ee[H] = !0, G.push(H), G = G.concat(P(H))), H = G.pop();
    }
    function S(A) {
      q[A] = N.inEdges(A).reduce(function(P, G) {
        return Math.max(P, q[G.v] + N.edge(G));
      }, 0);
    }
    function E(A) {
      var P = N.outEdges(A).reduce(function(H, ee) {
        return Math.min(H, q[ee.w] - N.edge(ee));
      }, Number.POSITIVE_INFINITY), G = b.node(A);
      P !== Number.POSITIVE_INFINITY && G.borderType !== R && (q[A] = Math.max(q[A], P));
    }
    return k(S, N.predecessors.bind(N)), k(E, N.successors.bind(N)), e.forEach(w, function(A) {
      q[A] = q[y[A]];
    }), q;
  }
  function c(b, g, y, w) {
    var I = new r(), q = b.graph(), N = v(q.nodesep, q.edgesep, w);
    return e.forEach(g, function(R) {
      var k;
      e.forEach(R, function(S) {
        var E = y[S];
        if (I.setNode(E), k) {
          var A = y[k], P = I.edge(A, E);
          I.setEdge(A, E, Math.max(N(b, S, k), P || 0));
        }
        k = S;
      });
    }), I;
  }
  function d(b, g) {
    return e.minBy(e.values(g), function(y) {
      var w = Number.NEGATIVE_INFINITY, I = Number.POSITIVE_INFINITY;
      return e.forIn(y, function(q, N) {
        var R = m(b, N) / 2;
        w = Math.max(q + R, w), I = Math.min(q - R, I);
      }), w - I;
    });
  }
  function h(b, g) {
    var y = e.values(g), w = e.min(y), I = e.max(y);
    e.forEach(["u", "d"], function(q) {
      e.forEach(["l", "r"], function(N) {
        var R = q + N, k = b[R], S;
        if (k !== g) {
          var E = e.values(k);
          S = N === "l" ? w - e.min(E) : I - e.max(E), S && (b[R] = e.mapValues(k, function(A) {
            return A + S;
          }));
        }
      });
    });
  }
  function p(b, g) {
    return e.mapValues(b.ul, function(y, w) {
      if (g)
        return b[g.toLowerCase()][w];
      var I = e.sortBy(e.map(b, w));
      return (I[1] + I[2]) / 2;
    });
  }
  function x(b) {
    var g = t.buildLayerMatrix(b), y = e.merge(
      n(b, g),
      a(b, g)
    ), w = {}, I;
    e.forEach(["u", "d"], function(N) {
      I = N === "u" ? g : e.values(g).reverse(), e.forEach(["l", "r"], function(R) {
        R === "r" && (I = e.map(I, function(A) {
          return e.values(A).reverse();
        }));
        var k = (N === "u" ? b.predecessors : b.successors).bind(b), S = u(b, I, y, k), E = l(
          b,
          I,
          S.root,
          S.align,
          R === "r"
        );
        R === "r" && (E = e.mapValues(E, function(A) {
          return -A;
        })), w[N + R] = E;
      });
    });
    var q = d(b, w);
    return h(w, q), p(w, b.graph().align);
  }
  function v(b, g, y) {
    return function(w, I, q) {
      var N = w.node(I), R = w.node(q), k = 0, S;
      if (k += N.width / 2, e.has(N, "labelpos"))
        switch (N.labelpos.toLowerCase()) {
          case "l":
            S = -N.width / 2;
            break;
          case "r":
            S = N.width / 2;
            break;
        }
      if (S && (k += y ? S : -S), S = 0, k += (N.dummy ? g : b) / 2, k += (R.dummy ? g : b) / 2, k += R.width / 2, e.has(R, "labelpos"))
        switch (R.labelpos.toLowerCase()) {
          case "l":
            S = R.width / 2;
            break;
          case "r":
            S = -R.width / 2;
            break;
        }
      return S && (k += y ? S : -S), S = 0, k;
    };
  }
  function m(b, g) {
    return b.node(g).width;
  }
  return yo;
}
var xo, wh;
function cy() {
  if (wh) return xo;
  wh = 1;
  var e = re(), r = ye(), t = oy().positionX;
  xo = n;
  function n(i) {
    i = r.asNonCompoundGraph(i), a(i), e.forEach(t(i), function(o, s) {
      i.node(s).x = o;
    });
  }
  function a(i) {
    var o = r.buildLayerMatrix(i), s = i.graph().ranksep, u = 0;
    e.forEach(o, function(l) {
      var c = e.max(e.map(l, function(d) {
        return i.node(d).height;
      }));
      e.forEach(l, function(d) {
        i.node(d).y = u + c / 2;
      }), u += c + s;
    });
  }
  return xo;
}
var _o, Nh;
function uy() {
  if (Nh) return _o;
  Nh = 1;
  var e = re(), r = $b(), t = Vb(), n = Kb(), a = ye().normalizeRanks, i = Wb(), o = ye().removeEmptyRanks, s = Yb(), u = Jb(), l = Zb(), c = sy(), d = cy(), h = ye(), p = ke().Graph;
  _o = x;
  function x(C, T) {
    var M = T && T.debugTiming ? h.time : h.notime;
    M("layout", function() {
      var L = M("  buildLayoutGraph", function() {
        return k(C);
      });
      M("  runLayout", function() {
        v(L, M);
      }), M("  updateInputGraph", function() {
        m(C, L);
      });
    });
  }
  function v(C, T) {
    T("    makeSpaceForEdgeLabels", function() {
      S(C);
    }), T("    removeSelfEdges", function() {
      j(C);
    }), T("    acyclic", function() {
      r.run(C);
    }), T("    nestingGraph.run", function() {
      s.run(C);
    }), T("    rank", function() {
      n(h.asNonCompoundGraph(C));
    }), T("    injectEdgeLabelProxies", function() {
      E(C);
    }), T("    removeEmptyRanks", function() {
      o(C);
    }), T("    nestingGraph.cleanup", function() {
      s.cleanup(C);
    }), T("    normalizeRanks", function() {
      a(C);
    }), T("    assignRankMinMax", function() {
      A(C);
    }), T("    removeEdgeLabelProxies", function() {
      P(C);
    }), T("    normalize.run", function() {
      t.run(C);
    }), T("    parentDummyChains", function() {
      i(C);
    }), T("    addBorderSegments", function() {
      u(C);
    }), T("    order", function() {
      c(C);
    }), T("    insertSelfEdges", function() {
      F(C);
    }), T("    adjustCoordinateSystem", function() {
      l.adjust(C);
    }), T("    position", function() {
      d(C);
    }), T("    positionSelfEdges", function() {
      te(C);
    }), T("    removeBorderNodes", function() {
      z(C);
    }), T("    normalize.undo", function() {
      t.undo(C);
    }), T("    fixupEdgeLabelCoords", function() {
      ee(C);
    }), T("    undoCoordinateSystem", function() {
      l.undo(C);
    }), T("    translateGraph", function() {
      G(C);
    }), T("    assignNodeIntersects", function() {
      H(C);
    }), T("    reversePoints", function() {
      O(C);
    }), T("    acyclic.undo", function() {
      r.undo(C);
    });
  }
  function m(C, T) {
    e.forEach(C.nodes(), function(M) {
      var L = C.node(M), K = T.node(M);
      L && (L.x = K.x, L.y = K.y, T.children(M).length && (L.width = K.width, L.height = K.height));
    }), e.forEach(C.edges(), function(M) {
      var L = C.edge(M), K = T.edge(M);
      L.points = K.points, e.has(K, "x") && (L.x = K.x, L.y = K.y);
    }), C.graph().width = T.graph().width, C.graph().height = T.graph().height;
  }
  var b = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"], g = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" }, y = ["acyclicer", "ranker", "rankdir", "align"], w = ["width", "height"], I = { width: 0, height: 0 }, q = ["minlen", "weight", "width", "height", "labeloffset"], N = {
    minlen: 1,
    weight: 1,
    width: 0,
    height: 0,
    labeloffset: 10,
    labelpos: "r"
  }, R = ["labelpos"];
  function k(C) {
    var T = new p({ multigraph: !0, compound: !0 }), M = ie(C.graph());
    return T.setGraph(e.merge(
      {},
      g,
      ne(M, b),
      e.pick(M, y)
    )), e.forEach(C.nodes(), function(L) {
      var K = ie(C.node(L));
      T.setNode(L, e.defaults(ne(K, w), I)), T.setParent(L, C.parent(L));
    }), e.forEach(C.edges(), function(L) {
      var K = ie(C.edge(L));
      T.setEdge(L, e.merge(
        {},
        N,
        ne(K, q),
        e.pick(K, R)
      ));
    }), T;
  }
  function S(C) {
    var T = C.graph();
    T.ranksep /= 2, e.forEach(C.edges(), function(M) {
      var L = C.edge(M);
      L.minlen *= 2, L.labelpos.toLowerCase() !== "c" && (T.rankdir === "TB" || T.rankdir === "BT" ? L.width += L.labeloffset : L.height += L.labeloffset);
    });
  }
  function E(C) {
    e.forEach(C.edges(), function(T) {
      var M = C.edge(T);
      if (M.width && M.height) {
        var L = C.node(T.v), K = C.node(T.w), Q = { rank: (K.rank - L.rank) / 2 + L.rank, e: T };
        h.addDummyNode(C, "edge-proxy", Q, "_ep");
      }
    });
  }
  function A(C) {
    var T = 0;
    e.forEach(C.nodes(), function(M) {
      var L = C.node(M);
      L.borderTop && (L.minRank = C.node(L.borderTop).rank, L.maxRank = C.node(L.borderBottom).rank, T = e.max(T, L.maxRank));
    }), C.graph().maxRank = T;
  }
  function P(C) {
    e.forEach(C.nodes(), function(T) {
      var M = C.node(T);
      M.dummy === "edge-proxy" && (C.edge(M.e).labelRank = M.rank, C.removeNode(T));
    });
  }
  function G(C) {
    var T = Number.POSITIVE_INFINITY, M = 0, L = Number.POSITIVE_INFINITY, K = 0, Q = C.graph(), ae = Q.marginx || 0, fe = Q.marginy || 0;
    function Te(oe) {
      var ue = oe.x, Y = oe.y, me = oe.width, W = oe.height;
      T = Math.min(T, ue - me / 2), M = Math.max(M, ue + me / 2), L = Math.min(L, Y - W / 2), K = Math.max(K, Y + W / 2);
    }
    e.forEach(C.nodes(), function(oe) {
      Te(C.node(oe));
    }), e.forEach(C.edges(), function(oe) {
      var ue = C.edge(oe);
      e.has(ue, "x") && Te(ue);
    }), T -= ae, L -= fe, e.forEach(C.nodes(), function(oe) {
      var ue = C.node(oe);
      ue.x -= T, ue.y -= L;
    }), e.forEach(C.edges(), function(oe) {
      var ue = C.edge(oe);
      e.forEach(ue.points, function(Y) {
        Y.x -= T, Y.y -= L;
      }), e.has(ue, "x") && (ue.x -= T), e.has(ue, "y") && (ue.y -= L);
    }), Q.width = M - T + ae, Q.height = K - L + fe;
  }
  function H(C) {
    e.forEach(C.edges(), function(T) {
      var M = C.edge(T), L = C.node(T.v), K = C.node(T.w), Q, ae;
      M.points ? (Q = M.points[0], ae = M.points[M.points.length - 1]) : (M.points = [], Q = K, ae = L), M.points.unshift(h.intersectRect(L, Q)), M.points.push(h.intersectRect(K, ae));
    });
  }
  function ee(C) {
    e.forEach(C.edges(), function(T) {
      var M = C.edge(T);
      if (e.has(M, "x"))
        switch ((M.labelpos === "l" || M.labelpos === "r") && (M.width -= M.labeloffset), M.labelpos) {
          case "l":
            M.x -= M.width / 2 + M.labeloffset;
            break;
          case "r":
            M.x += M.width / 2 + M.labeloffset;
            break;
        }
    });
  }
  function O(C) {
    e.forEach(C.edges(), function(T) {
      var M = C.edge(T);
      M.reversed && M.points.reverse();
    });
  }
  function z(C) {
    e.forEach(C.nodes(), function(T) {
      if (C.children(T).length) {
        var M = C.node(T), L = C.node(M.borderTop), K = C.node(M.borderBottom), Q = C.node(e.last(M.borderLeft)), ae = C.node(e.last(M.borderRight));
        M.width = Math.abs(ae.x - Q.x), M.height = Math.abs(K.y - L.y), M.x = Q.x + M.width / 2, M.y = L.y + M.height / 2;
      }
    }), e.forEach(C.nodes(), function(T) {
      C.node(T).dummy === "border" && C.removeNode(T);
    });
  }
  function j(C) {
    e.forEach(C.edges(), function(T) {
      if (T.v === T.w) {
        var M = C.node(T.v);
        M.selfEdges || (M.selfEdges = []), M.selfEdges.push({ e: T, label: C.edge(T) }), C.removeEdge(T);
      }
    });
  }
  function F(C) {
    var T = h.buildLayerMatrix(C);
    e.forEach(T, function(M) {
      var L = 0;
      e.forEach(M, function(K, Q) {
        var ae = C.node(K);
        ae.order = Q + L, e.forEach(ae.selfEdges, function(fe) {
          h.addDummyNode(C, "selfedge", {
            width: fe.label.width,
            height: fe.label.height,
            rank: ae.rank,
            order: Q + ++L,
            e: fe.e,
            label: fe.label
          }, "_se");
        }), delete ae.selfEdges;
      });
    });
  }
  function te(C) {
    e.forEach(C.nodes(), function(T) {
      var M = C.node(T);
      if (M.dummy === "selfedge") {
        var L = C.node(M.e.v), K = L.x + L.width / 2, Q = L.y, ae = M.x - K, fe = L.height / 2;
        C.setEdge(M.e, M.label), C.removeNode(T), M.label.points = [
          { x: K + 2 * ae / 3, y: Q - fe },
          { x: K + 5 * ae / 6, y: Q - fe },
          { x: K + ae, y: Q },
          { x: K + 5 * ae / 6, y: Q + fe },
          { x: K + 2 * ae / 3, y: Q + fe }
        ], M.label.x = M.x, M.label.y = M.y;
      }
    });
  }
  function ne(C, T) {
    return e.mapValues(e.pick(C, T), Number);
  }
  function ie(C) {
    var T = {};
    return e.forEach(C, function(M, L) {
      T[L.toLowerCase()] = M;
    }), T;
  }
  return _o;
}
var wo, Ih;
function ly() {
  if (Ih) return wo;
  Ih = 1;
  var e = re(), r = ye(), t = ke().Graph;
  wo = {
    debugOrdering: n
  };
  function n(a) {
    var i = r.buildLayerMatrix(a), o = new t({ compound: !0, multigraph: !0 }).setGraph({});
    return e.forEach(a.nodes(), function(s) {
      o.setNode(s, { label: s }), o.setParent(s, "layer" + a.node(s).rank);
    }), e.forEach(a.edges(), function(s) {
      o.setEdge(s.v, s.w, {}, s.name);
    }), e.forEach(i, function(s, u) {
      var l = "layer" + u;
      o.setNode(l, { rank: "same" }), e.reduce(s, function(c, d) {
        return o.setEdge(c, d, { style: "invis" }), d;
      });
    }), o;
  }
  return wo;
}
var No, qh;
function dy() {
  return qh || (qh = 1, No = "0.8.5"), No;
}
var Io, kh;
function fy() {
  return kh || (kh = 1, Io = {
    graphlib: ke(),
    layout: uy(),
    debug: ly(),
    util: {
      time: ye().time,
      notime: ye().notime
    },
    version: dy()
  }), Io;
}
var hy = fy();
const Sh = /* @__PURE__ */ Zm(hy), Rh = 280, Ch = 120, Eh = (e, r, t = "TB") => {
  const n = new Sh.graphlib.Graph();
  return n.setDefaultEdgeLabel(() => ({})), n.setGraph({
    rankdir: t,
    ranksep: 140,
    // Increased vertical spacing (was default ~50, prev 100)
    nodesep: 140
    // Increased horizontal spacing (was default ~50, prev 80)
  }), e.forEach((i) => {
    n.setNode(i.id, { width: Rh, height: Ch });
  }), r.forEach((i) => {
    n.setEdge(i.source, i.target);
  }), Sh.layout(n), { nodes: e.map((i) => {
    const o = n.node(i.id);
    return {
      ...i,
      targetPosition: Er.Top,
      sourcePosition: Er.Bottom,
      position: {
        x: o.x - Rh / 2,
        y: o.y - Ch / 2
      }
    };
  }), edges: r };
}, Ah = (e) => {
  const r = new Map(e.map((n) => [n.scheduleId, n])), t = /* @__PURE__ */ new Map();
  return e.forEach((n) => {
    const a = [], i = /* @__PURE__ */ new Set();
    i.add(n.scheduleId);
    const o = n.direction === pe.TopDown ? [...n.children] : [...n.parents];
    for (; o.length > 0; ) {
      const s = o.shift();
      if (i.has(s)) continue;
      i.add(s);
      const u = r.get(s);
      u && (u.resources.forEach((l) => {
        a.push({
          ...l,
          sourceNodeId: u.scheduleId,
          sourceNodeName: u.name,
          sourceNodePriority: u.priority,
          isInherited: !0
        });
      }), n.direction === pe.TopDown ? o.push(...u.children) : o.push(...u.parents));
    }
    t.set(n.scheduleId, a);
  }), t;
}, J0 = (e, r) => {
  const t = r.target, n = r.source;
  if (!t || !n || t === n) return !0;
  const a = /* @__PURE__ */ new Map();
  e.forEach((s) => {
    var u;
    a.has(s.source) || a.set(s.source, []), (u = a.get(s.source)) == null || u.push(s.target);
  });
  const i = /* @__PURE__ */ new Set(), o = [t];
  for (; o.length > 0; ) {
    const s = o.pop();
    if (s === n) return !0;
    if (!i.has(s)) {
      i.add(s);
      const u = a.get(s) || [];
      for (const l of u)
        i.has(l) || o.push(l);
    }
  }
  return !1;
};
function Th() {
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
    return crypto.randomUUID();
  if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") {
    const e = new Uint8Array(16);
    crypto.getRandomValues(e), e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
    const r = [];
    for (let t = 0; t < 256; t++)
      r.push((t + 256).toString(16).slice(1));
    return r[e[0]] + r[e[1]] + r[e[2]] + r[e[3]] + "-" + r[e[4]] + r[e[5]] + "-" + r[e[6]] + r[e[7]] + "-" + r[e[8]] + r[e[9]] + "-" + r[e[10]] + r[e[11]] + r[e[12]] + r[e[13]] + r[e[14]] + r[e[15]];
  }
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
    const r = Math.random() * 16 | 0;
    return (e === "x" ? r : r & 3 | 8).toString(16);
  });
}
const py = (e) => {
  const [r, t, n] = np([]), [a, i, o] = ap([]), [s, u] = U({ past: [], future: [] }), l = ce(() => {
    u((q) => ({
      past: [...q.past, JSON.stringify({ nodes: r, edges: a })].slice(-50),
      future: []
    }));
  }, [r, a]), c = ce(() => {
    if (s.past.length === 0) return;
    const q = s.past[s.past.length - 1], N = s.past.slice(0, -1), R = JSON.stringify({ nodes: r, edges: a }), { nodes: k, edges: S } = JSON.parse(q);
    t(k), i(S), u({
      past: N,
      future: [R, ...s.future]
    });
  }, [s, r, a, t, i]), d = ce(() => {
    if (s.future.length === 0) return;
    const q = s.future[0], N = s.future.slice(1), R = JSON.stringify({ nodes: r, edges: a }), { nodes: k, edges: S } = JSON.parse(q);
    t(k), i(S), u({
      past: [...s.past, R],
      future: N
    });
  }, [s, r, a, t, i]), h = ce((q) => {
    const N = (q.schedules || []).map((A) => {
      let P = pe.BottomUp;
      (A.direction === pe.TopDown || A.direction === 1 || A.direction === "TopDown") && (P = pe.TopDown);
      const G = {
        ...A,
        direction: P,
        // Ensure defaults
        isActive: A.isActive ?? !0,
        priority: typeof A.priority == "number" ? A.priority : 1,
        locationGroup: A.locationGroup || { groupId: "", nodeId: "" },
        approvalGroups: Array.isArray(A.approvalGroups) ? A.approvalGroups : [],
        resources: Array.isArray(A.resources) ? A.resources : [],
        requirements: Array.isArray(A.requirements) ? A.requirements : [],
        children: Array.isArray(A.children) ? A.children : [],
        parents: Array.isArray(A.parents) ? A.parents : []
      };
      return {
        id: G.scheduleId,
        position: { x: 0, y: 0 },
        data: G,
        type: "scheduleNode"
      };
    }), R = [], k = new Set(N.map((A) => A.id));
    (q.schedules || []).forEach((A) => {
      if (!A.scheduleId) return;
      (A.children || []).forEach((G) => {
        k.has(G) && k.has(A.scheduleId) && R.push({
          id: `${A.scheduleId}-${G}`,
          source: A.scheduleId,
          target: G,
          type: "smoothstep",
          animated: !1,
          markerEnd: { type: at.ArrowClosed, width: 20, height: 20, color: "#94a3b8" },
          style: { stroke: "#94a3b8", strokeWidth: 2 }
        });
      });
    });
    const { nodes: S, edges: E } = Eh(N, R, "TB");
    t(S), i(E), u({ past: [], future: [] });
  }, [t, i]);
  le(() => {
    h(e);
  }, [e, h]);
  const p = _e(() => r.map((q) => q.data.name).join("|"), [r]);
  le(() => {
    r.length !== 0 && t((q) => {
      const N = new Map(
        q.map((S) => [S.id, { ...S.data, parents: [], children: [] }])
      );
      a.forEach((S) => {
        const E = N.get(S.source), A = N.get(S.target);
        E && A && (E.children.push(S.target), A.parents.push(S.source));
      });
      const R = Array.from(N.values()), k = Ah(R);
      return q.map((S) => {
        const E = N.get(S.id);
        return E ? (E._inheritedResources = k.get(S.id) || [], { ...S, data: E }) : S;
      });
    });
  }, [a.length, a, p, t]);
  const x = ce((q) => {
    if (J0(a, q)) {
      alert("Cannot connect: This connection would create a cycle (loop) in the graph.");
      return;
    }
    l(), i((N) => ip({
      ...q,
      type: "smoothstep",
      animated: !1,
      markerEnd: { type: at.ArrowClosed, width: 20, height: 20, color: "#94a3b8" },
      style: { stroke: "#94a3b8", strokeWidth: 2 }
    }, N));
  }, [a, i, l]), v = ce((q, N, R) => {
    l(), t((k) => {
      const S = k.map((P) => {
        if (P.id === q) {
          const G = { ...P.data, [N]: R };
          return { ...P, data: G };
        }
        return P;
      }), E = S.map((P) => P.data), A = Ah(E);
      return S.map((P) => {
        const G = A.get(P.id) || [];
        return {
          ...P,
          data: {
            ...P.data,
            _inheritedResources: G
          }
        };
      });
    });
  }, [t, l]), m = ce(() => {
    l();
    const { nodes: q, edges: N } = Eh(r, a, "TB");
    t([...q]), i([...N]);
  }, [r, a, t, i, l]), b = ce((q) => {
    l();
    const N = Th(), R = {
      x: (-q.x + window.innerWidth / 2) / q.zoom,
      y: (-q.y + window.innerHeight / 2) / q.zoom
    }, k = {
      id: N,
      position: { x: R.x + Math.random() * 50, y: R.y + Math.random() * 50 },
      type: "scheduleNode",
      data: {
        scheduleId: N,
        isActive: !0,
        name: "New Schedule",
        time: "24/7",
        group: "Draft",
        purpose: "General",
        priority: 1,
        locationGroup: { groupId: "", nodeId: "" },
        approvalGroups: [],
        direction: pe.BottomUp,
        tags: [],
        attributes: [],
        configuration: {},
        securityLevelId: null,
        resources: [],
        children: [],
        parents: [],
        requirements: [],
        followUp: null,
        phaseOut: null
      }
    };
    t((S) => [...S, k]);
  }, [t, l]), g = ce((q, N) => {
    let R = pe.BottomUp;
    const k = N.direction;
    return (k === pe.TopDown || k === 1 || k === "TopDown") && (R = pe.TopDown), {
      scheduleId: q,
      isActive: N.isActive ?? !0,
      name: N.name ?? "New Schedule",
      time: N.time ?? "24/7",
      group: N.group ?? "Draft",
      purpose: N.purpose ?? "General",
      priority: typeof N.priority == "number" ? N.priority : 1,
      locationGroup: N.locationGroup || { groupId: "", nodeId: "" },
      approvalGroups: Array.isArray(N.approvalGroups) ? N.approvalGroups : [],
      direction: R,
      tags: Array.isArray(N.tags) ? N.tags : [],
      attributes: Array.isArray(N.attributes) ? N.attributes : [],
      configuration: N.configuration || {},
      securityLevelId: N.securityLevelId ?? null,
      followUp: N.followUp ?? null,
      phaseOut: N.phaseOut ?? null,
      resources: Array.isArray(N.resources) ? N.resources : [],
      children: [],
      parents: [],
      requirements: Array.isArray(N.requirements) ? N.requirements : []
    };
  }, []), y = ce((q) => {
    const N = q.scheduleId && String(q.scheduleId) || Th();
    return {
      id: N,
      position: { x: Math.random() * 400, y: Math.random() * 300 },
      type: "scheduleNode",
      data: g(N, q)
    };
  }, [g]), w = ce((q, N) => ({
    id: `${q}-${N}`,
    source: q,
    target: N,
    type: "smoothstep",
    animated: !1,
    markerEnd: { type: at.ArrowClosed, width: 20, height: 20, color: "#94a3b8" },
    style: { stroke: "#94a3b8", strokeWidth: 2 }
  }), []), I = ce((q, N) => {
    l(), t(q), i(N);
  }, [t, i, l]);
  return {
    nodes: r,
    edges: a,
    onNodesChange: n,
    onEdgesChange: o,
    onConnect: x,
    handleUpdateNode: v,
    handleLayout: m,
    handleAddNode: b,
    setNodes: t,
    setEdges: i,
    undo: c,
    redo: d,
    takeSnapshot: l,
    loadData: h,
    // Exposed for external updates (e.g. Import)
    // Pure builders + single apply path consumed by the AI capability
    // (it validates a candidate model before committing through applyModel).
    buildScheduleNode: y,
    makeEdge: w,
    applyModel: I,
    canUndo: s.past.length > 0,
    canRedo: s.future.length > 0
  };
}, my = "entitlement", vy = "This editor models an Entitlement (Title) as a directed acyclic graph of Schedule nodes. There is exactly one node/element type: 'schedule' (a permission schedule with scheduleId, name, time, group, purpose, priority, direction (0=BottomUp/inherits from parents, 1=TopDown/pushes to children), resources, approvalGroups, locationGroup, requirements, tags). Edges are parent->child links (source=parent, target=child) and the graph MUST stay acyclic — connecting two nodes that would form a loop is rejected. parents/children on a schedule are derived from edges and must not be set directly. Use add_schedule/update_schedule/delete_schedule to mutate nodes, connect_schedules/disconnect_schedules for links, validate to get current errors, and replace_model to swap the whole graph. Every mutation runs the editor's real validation against the proposed model; a change that introduces a validation error is rejected with a reason and nothing is applied. Viewport/selection tools help the user SEE what you mean without changing the model: focus_schedule centers + selects + opens a schedule's details; set_graph_selection highlights one-or-more schedules/links; fit_view frames the whole graph or a subset; set_canvas_view/get_canvas_view pan-zoom the canvas; auto_layout_graph re-runs the dagre layout. These reject (never throw) on unknown ids and never mutate the graph.", Cr = [
  "name",
  "time",
  "group",
  "purpose",
  "priority",
  "isActive",
  "direction",
  "tags",
  "attributes",
  "configuration",
  "securityLevelId",
  "followUp",
  "phaseOut",
  "resources",
  "approvalGroups",
  "locationGroup",
  "requirements"
], ve = (e) => ({ ok: !0, result: e }), B = (e) => ({ ok: !1, rejected: !0, reason: e });
function gy(e) {
  return {
    scheduleId: e.scheduleId,
    name: e.name,
    isActive: e.isActive,
    group: e.group,
    purpose: e.purpose,
    time: e.time,
    priority: e.priority,
    direction: e.direction,
    resourceCount: Array.isArray(e.resources) ? e.resources.length : 0,
    requirementCount: Array.isArray(e.requirements) ? e.requirements.length : 0,
    tags: e.tags || []
  };
}
function Or(e, r) {
  const t = [], n = /* @__PURE__ */ new Set();
  e.forEach((a) => {
    const i = a.data;
    i.scheduleId || t.push(`Node "${a.id}" is missing scheduleId.`), n.has(i.scheduleId) && t.push(`Duplicate scheduleId "${i.scheduleId}".`), n.add(i.scheduleId), (!i.name || !String(i.name).trim()) && t.push(`Schedule "${i.scheduleId}" has an empty name.`), typeof i.priority != "number" && t.push(`Schedule "${i.name || i.scheduleId}" has a non-numeric priority.`);
  }), r.forEach((a) => {
    n.has(a.source) || t.push(`Edge "${a.id}" references unknown source node "${a.source}".`), n.has(a.target) || t.push(`Edge "${a.id}" references unknown target node "${a.target}".`), a.source === a.target && t.push(`Edge "${a.id}" is a self-loop on "${a.source}".`);
  });
  for (let a = 0; a < r.length; a++) {
    const i = r[a], o = r.filter((s, u) => u !== a);
    if (J0(o, { source: i.source, target: i.target })) {
      t.push(`Edge "${i.source}->${i.target}" participates in a cycle.`);
      break;
    }
  }
  return t;
}
function Rr(e, r, t, n) {
  const a = new Set(Or(e, r));
  return Or(t, n).filter((i) => !a.has(i));
}
function by(e, r) {
  const t = (n) => typeof n == "object" && n !== null && !Array.isArray(n);
  switch (e) {
    case "name":
      return !r || !String(r).trim() ? '"name" cannot be empty.' : null;
    case "priority":
      return typeof r != "number" ? '"priority" must be a number.' : null;
    case "direction":
      return r !== 0 && r !== 1 ? '"direction" must be 0 (BottomUp) or 1 (TopDown).' : null;
    case "isActive":
      return typeof r != "boolean" ? '"isActive" must be a boolean.' : null;
    case "tags":
      return !Array.isArray(r) || r.some((n) => typeof n != "string") ? '"tags" must be an array of strings.' : null;
    case "time":
    case "group":
    case "purpose":
      return r != null && typeof r != "string" ? `"${e}" must be a string.` : null;
    case "securityLevelId":
    case "followUp":
      return r != null && typeof r != "string" ? `"${e}" must be a string or null.` : null;
    case "attributes":
      return r !== null && (!Array.isArray(r) || r.some((n) => typeof n != "string")) ? '"attributes" must be an array of strings or null.' : null;
    case "configuration":
      return t(r) ? null : '"configuration" must be an object.';
    case "locationGroup": {
      const n = r;
      return !t(r) || typeof n.groupId != "string" || typeof n.nodeId != "string" ? '"locationGroup" must be an object with string "groupId" and "nodeId".' : null;
    }
    case "approvalGroups": {
      if (!Array.isArray(r)) return '"approvalGroups" must be an array.';
      for (const n of r)
        if (!t(n) || typeof n.groupId != "string" || typeof n.nodeId != "string" || typeof n.type != "string")
          return 'Each "approvalGroups" entry needs string "groupId", "nodeId" and "type".';
      return null;
    }
    case "resources": {
      if (!Array.isArray(r)) return '"resources" must be an array.';
      for (const n of r) {
        if (!t(n) || typeof n.systemId != "string" || typeof n.resourceId != "string")
          return 'Each "resources" entry needs string "systemId" and "resourceId".';
        if (n.resourcePlanId != null && typeof n.resourcePlanId != "string")
          return '"resources" entry "resourcePlanId" must be a string or null.';
      }
      return null;
    }
    case "requirements": {
      if (!Array.isArray(r)) return '"requirements" must be an array.';
      for (const n of r)
        if (!t(n) || typeof n.testamentTypeId != "string" || !n.testamentTypeId.trim())
          return 'Each "requirements" entry needs a non-empty string "testamentTypeId".';
      return null;
    }
    case "phaseOut": {
      if (r === null) return null;
      const n = r;
      return !t(r) || typeof n.scheduleId != "string" || typeof n.duration != "string" ? '"phaseOut" must be null or an object with string "scheduleId" and "duration".' : null;
    }
    default:
      return null;
  }
}
const yy = [
  {
    name: "get_model",
    description: "Return the current entitlement graph as compact JSON: schedules (nodes) and links (parent->child edges). Use this before mutating.",
    parameters: { type: "object", properties: {}, additionalProperties: !1 }
  },
  {
    name: "list_node_types",
    description: "List the node/element types this editor supports. This editor has a single node type, 'schedule', plus 'link' edges (parent->child). Returns the editable fields of a schedule.",
    parameters: { type: "object", properties: {}, additionalProperties: !1 }
  },
  {
    name: "add_schedule",
    description: "Add a new schedule (permission node). Provide name and any optional fields. Returns the generated scheduleId. parents/children are derived from links and cannot be set here. Rejected if the resulting model fails validation.",
    parameters: {
      type: "object",
      properties: {
        name: { type: "string", description: "Display name (required)." },
        group: { type: "string" },
        purpose: { type: "string" },
        time: { type: "string", description: "e.g. '24/7' or '08:00-18:00'." },
        priority: { type: "number" },
        direction: {
          type: "number",
          enum: [0, 1],
          description: "0 = BottomUp (inherit from parents), 1 = TopDown (push to children)."
        },
        isActive: { type: "boolean" },
        tags: { type: "array", items: { type: "string" } }
      },
      required: ["name"],
      additionalProperties: !1
    }
  },
  {
    name: "update_schedule",
    description: "Update one field of an existing schedule. Rejects unknown scheduleId, attempts to set derived fields (parents/children), unknown fields, malformed values, or any change that introduces a validation error.",
    parameters: {
      type: "object",
      properties: {
        scheduleId: { type: "string" },
        field: { type: "string", enum: [...Cr] },
        value: { description: "New value for the field (type depends on the field)." }
      },
      required: ["scheduleId", "field", "value"],
      additionalProperties: !1
    }
  },
  {
    name: "delete_schedule",
    description: "Delete a schedule and all links touching it. Rejects unknown scheduleId.",
    parameters: {
      type: "object",
      properties: { scheduleId: { type: "string" } },
      required: ["scheduleId"],
      additionalProperties: !1
    }
  },
  {
    name: "connect_schedules",
    description: "Link a parent schedule to a child schedule (source=parent, target=child). Rejected if either id is unknown, the link already exists, or it would create a cycle.",
    parameters: {
      type: "object",
      properties: {
        parentId: { type: "string", description: "Source / parent scheduleId." },
        childId: { type: "string", description: "Target / child scheduleId." }
      },
      required: ["parentId", "childId"],
      additionalProperties: !1
    }
  },
  {
    name: "disconnect_schedules",
    description: "Remove the parent->child link. Rejects if the link does not exist.",
    parameters: {
      type: "object",
      properties: {
        parentId: { type: "string" },
        childId: { type: "string" }
      },
      required: ["parentId", "childId"],
      additionalProperties: !1
    }
  },
  {
    name: "replace_model",
    description: "Replace the entire graph with a new set of schedules and links. Rejected (with no mutation) if the proposed model fails validation.",
    parameters: {
      type: "object",
      properties: {
        schedules: {
          type: "array",
          description: "Full list of schedules. Each needs at least a name.",
          items: {
            type: "object",
            properties: {
              scheduleId: { type: "string" },
              name: { type: "string" },
              group: { type: "string" },
              purpose: { type: "string" },
              time: { type: "string" },
              priority: { type: "number" },
              direction: { type: "number", enum: [0, 1] },
              isActive: { type: "boolean" },
              tags: { type: "array", items: { type: "string" } }
            },
            required: ["name"]
          }
        },
        links: {
          type: "array",
          description: "Parent->child links between schedules.",
          items: {
            type: "object",
            properties: {
              parentId: { type: "string" },
              childId: { type: "string" }
            },
            required: ["parentId", "childId"]
          }
        }
      },
      required: ["schedules"],
      additionalProperties: !1
    }
  },
  {
    name: "validate",
    description: "Run the editor validation over the current graph and return the list of errors (empty array = valid).",
    parameters: { type: "object", properties: {}, additionalProperties: !1 }
  },
  // --- Viewport / selection tools (non-mutating UI affordances) ---
  {
    name: "get_canvas_view",
    description: "Return the current canvas viewport ({x,y,zoom}) plus the scheduleIds that are currently selected/highlighted. Read-only; does not change the graph or the view.",
    parameters: { type: "object", properties: {}, additionalProperties: !1 }
  },
  {
    name: "set_canvas_view",
    description: "Pan and/or zoom the canvas to an exact viewport. Any omitted axis keeps its current value. Zoom is clamped to the editor bounds (0.1–1.5). Does not mutate the graph. Rejects gracefully if the live canvas is unavailable.",
    parameters: {
      type: "object",
      properties: {
        x: { type: "number", description: "Viewport x translation (world px)." },
        y: { type: "number", description: "Viewport y translation (world px)." },
        zoom: { type: "number", description: "Zoom factor; clamped to [0.1, 1.5]." },
        durationMs: { type: "number", description: "Animation duration in ms (0 = instant)." }
      },
      additionalProperties: !1
    }
  },
  {
    name: "fit_view",
    description: 'Fit the whole graph into view, or just the given schedules when "scheduleIds" is provided. Rejects if any provided scheduleId is unknown. Does not mutate the graph.',
    parameters: {
      type: "object",
      properties: {
        scheduleIds: {
          type: "array",
          items: { type: "string" },
          description: "Optional subset to frame. Omit/empty to fit the entire graph."
        },
        padding: { type: "number", description: "Fractional padding around the bounds (e.g. 0.2)." },
        maxZoom: { type: "number", description: "Upper zoom clamp while fitting (<= 1.5)." },
        durationMs: { type: "number", description: "Animation duration in ms (0 = instant)." }
      },
      additionalProperties: !1
    }
  },
  {
    name: "focus_schedule",
    description: "Center the canvas on one schedule, select it, and open its details panel — the way to point the user at a specific node. Rejects an unknown scheduleId. Does not mutate the graph.",
    parameters: {
      type: "object",
      properties: {
        scheduleId: { type: "string", description: "The schedule to focus (required)." },
        zoom: { type: "number", description: "Zoom to center at; clamped to [0.1, 1.5]. Default 1.2." },
        durationMs: { type: "number", description: "Animation duration in ms (0 = instant)." }
      },
      required: ["scheduleId"],
      additionalProperties: !1
    }
  },
  {
    name: "set_graph_selection",
    description: "Highlight a set of schedules (and optionally parent->child links) via the canvas selection state, so the user sees exactly which nodes you mean. Pass empty arrays to clear the selection. Rejects if any scheduleId or link endpoint is unknown. Does not mutate the graph.",
    parameters: {
      type: "object",
      properties: {
        scheduleIds: {
          type: "array",
          items: { type: "string" },
          description: "Schedules to highlight. Empty array clears node selection."
        },
        links: {
          type: "array",
          description: "Parent->child links to highlight.",
          items: {
            type: "object",
            properties: {
              parentId: { type: "string" },
              childId: { type: "string" }
            },
            required: ["parentId", "childId"]
          }
        },
        fit: { type: "boolean", description: "When true, also fit the selected schedules into view." }
      },
      additionalProperties: !1
    }
  },
  {
    name: "auto_layout_graph",
    description: "Re-run the editor's automatic (dagre) layout to tidy node positions. This only repositions nodes; it does not add/remove/edit schedules or links. Optionally refits the view.",
    parameters: {
      type: "object",
      properties: {
        fitAfter: { type: "boolean", description: "Fit the whole graph into view after layout (default true)." },
        durationMs: { type: "number", description: "Fit animation duration in ms (0 = instant)." }
      },
      additionalProperties: !1
    }
  }
];
function xy(e) {
  const r = (i) => e.getNodes().find((o) => o.id === i || o.data.scheduleId === i), t = e.zoomBounds ?? { min: 0.1, max: 1.5 }, n = (i) => Math.min(t.max, Math.max(t.min, i));
  return { kind: my, guidelines: vy, tools: yy, invoke: async (i, o) => {
    var u, l;
    const s = o || {};
    try {
      switch (i) {
        case "get_model": {
          const c = e.getNodes(), d = e.getEdges();
          return ve({
            schedules: c.map((h) => gy(h.data)),
            links: d.map((h) => ({ parentId: h.source, childId: h.target }))
          });
        }
        case "list_node_types":
          return ve({
            nodeTypes: [
              {
                type: "schedule",
                description: "A permission schedule node.",
                fields: [...Cr],
                derived: ["parents", "children", "_inheritedResources"]
              }
            ],
            edgeType: { type: "link", description: "Directed parent->child link; graph stays acyclic." }
          });
        case "add_schedule": {
          if (!s.name || !String(s.name).trim())
            return B('add_schedule requires a non-empty "name".');
          if (s.direction !== void 0 && s.direction !== 0 && s.direction !== 1)
            return B('"direction" must be 0 (BottomUp) or 1 (TopDown).');
          const c = e.getNodes(), d = e.getEdges(), h = e.buildScheduleNode({
            name: String(s.name),
            group: s.group,
            purpose: s.purpose,
            time: s.time,
            priority: typeof s.priority == "number" ? s.priority : void 0,
            direction: s.direction,
            isActive: typeof s.isActive == "boolean" ? s.isActive : void 0,
            tags: Array.isArray(s.tags) ? s.tags : void 0
          }), p = [...c, h], x = Rr(c, d, p, d);
          return x.length ? B(x[0]) : (e.applyModel(p, d), ve({ scheduleId: h.data.scheduleId }));
        }
        case "update_schedule": {
          const { scheduleId: c, field: d, value: h } = s;
          if (!c) return B('update_schedule requires "scheduleId".');
          const p = r(c);
          if (!p)
            return B(`Unknown scheduleId "${String(c)}".`);
          if (d === "parents" || d === "children")
            return B(
              `Field "${String(d)}" is derived from links; use connect_schedules / disconnect_schedules instead.`
            );
          if (!Cr.includes(d))
            return B(
              `Unknown or non-editable field "${String(d)}". Editable: ${Cr.join(", ")}.`
            );
          const x = by(d, h);
          if (x) return B(x);
          const v = e.getNodes(), m = e.getEdges(), b = v.map(
            (y) => y.id === p.id ? { ...y, data: { ...y.data, [d]: h } } : y
          ), g = Rr(v, m, b, m);
          return g.length ? B(g[0]) : (e.applyModel(b, m), ve({ scheduleId: c, field: d, value: h }));
        }
        case "delete_schedule": {
          const { scheduleId: c } = s;
          if (!c) return B('delete_schedule requires "scheduleId".');
          const d = r(c);
          if (!d)
            return B(`Unknown scheduleId "${String(c)}".`);
          const h = e.getNodes(), p = e.getEdges(), x = h.filter((b) => b.id !== d.id), v = p.filter((b) => b.source !== d.id && b.target !== d.id), m = Rr(h, p, x, v);
          return m.length ? B(m[0]) : (e.applyModel(x, v), ve({ deleted: c }));
        }
        case "connect_schedules": {
          const { parentId: c, childId: d } = s;
          if (!c || !d)
            return B('connect_schedules requires "parentId" and "childId".');
          const h = r(c), p = r(d);
          if (!h) return B(`Unknown parentId "${String(c)}".`);
          if (!p) return B(`Unknown childId "${String(d)}".`);
          const x = e.getNodes(), v = e.getEdges();
          if (v.some((g) => g.source === h.id && g.target === p.id))
            return B("Connection rejected: this link already exists.");
          const m = [...v, e.makeEdge(h.id, p.id)], b = Rr(x, v, x, m);
          return b.length ? B(b[0]) : (e.applyModel(x, m), ve({ parentId: c, childId: d }));
        }
        case "disconnect_schedules": {
          const { parentId: c, childId: d } = s;
          if (!c || !d)
            return B('disconnect_schedules requires "parentId" and "childId".');
          const h = r(c), p = r(d), x = h ? h.id : String(c), v = p ? p.id : String(d), m = e.getNodes(), b = e.getEdges();
          if (!b.some((w) => w.source === x && w.target === v))
            return B(`No link from "${String(c)}" to "${String(d)}".`);
          const y = b.filter((w) => !(w.source === x && w.target === v));
          return e.applyModel(m, y), ve({ parentId: c, childId: d });
        }
        case "replace_model": {
          const c = s.schedules;
          if (!Array.isArray(c))
            return B('replace_model requires a "schedules" array.');
          const d = Array.isArray(s.links) ? s.links : [], h = [];
          for (const m of c) {
            if (!m || typeof m != "object")
              return B('Each schedule in "schedules" must be an object.');
            if (m.direction !== void 0 && m.direction !== 0 && m.direction !== 1)
              return B('Each schedule "direction" must be 0 (BottomUp) or 1 (TopDown).');
            h.push(
              e.buildScheduleNode({
                scheduleId: typeof m.scheduleId == "string" ? m.scheduleId : void 0,
                name: m.name,
                group: m.group,
                purpose: m.purpose,
                time: m.time,
                priority: typeof m.priority == "number" ? m.priority : void 0,
                direction: m.direction,
                isActive: typeof m.isActive == "boolean" ? m.isActive : void 0,
                tags: Array.isArray(m.tags) ? m.tags : void 0
              })
            );
          }
          const p = /* @__PURE__ */ new Map();
          h.forEach((m) => p.set(m.data.scheduleId, m.id));
          const x = [];
          for (const m of d) {
            const b = m.parentId, g = m.childId;
            if (typeof b != "string" || typeof g != "string")
              return B('Each link needs string "parentId" and "childId".');
            const y = p.get(b), w = p.get(g);
            if (!y) return B(`Link references unknown parentId "${b}".`);
            if (!w) return B(`Link references unknown childId "${g}".`);
            x.push(e.makeEdge(y, w));
          }
          const v = Or(h, x);
          return v.length ? B(v[0]) : (e.applyModel(h, x), ve({ scheduleCount: h.length, linkCount: x.length }));
        }
        case "validate": {
          const c = Or(e.getNodes(), e.getEdges());
          return ve({ valid: c.length === 0, errors: c });
        }
        case "get_canvas_view": {
          const c = e.getViewport ? e.getViewport() : null, d = e.getNodes().filter((p) => p.selected).map((p) => p.data.scheduleId), h = e.getEdges().filter((p) => p.selected).map((p) => {
            const x = e.getNodes().find((m) => m.id === p.source), v = e.getNodes().find((m) => m.id === p.target);
            return { parentId: (x == null ? void 0 : x.data.scheduleId) ?? p.source, childId: (v == null ? void 0 : v.data.scheduleId) ?? p.target };
          });
          return ve({ viewport: c, selectedScheduleIds: d, selectedLinks: h });
        }
        case "set_canvas_view": {
          if (!e.setViewport || !e.getViewport)
            return B("Canvas viewport is not available in this editor instance.");
          const c = e.getViewport(), { x: d, y: h, zoom: p, durationMs: x } = s;
          if (d !== void 0 && typeof d != "number") return B('"x" must be a number.');
          if (h !== void 0 && typeof h != "number") return B('"y" must be a number.');
          if (p !== void 0 && typeof p != "number") return B('"zoom" must be a number.');
          const v = {
            x: typeof d == "number" ? d : c.x,
            y: typeof h == "number" ? h : c.y,
            zoom: typeof p == "number" ? n(p) : c.zoom
          };
          return e.setViewport(v, { duration: typeof x == "number" ? x : 0 }), ve({ viewport: v });
        }
        case "fit_view": {
          if (!e.fitView)
            return B("Canvas fit-view is not available in this editor instance.");
          const { scheduleIds: c, padding: d, maxZoom: h, durationMs: p } = s;
          let x;
          if (Array.isArray(c) && c.length > 0) {
            x = [];
            for (const v of c) {
              const m = r(v);
              if (!m) return B(`Unknown scheduleId "${String(v)}".`);
              x.push({ id: m.id });
            }
          }
          return e.fitView({
            nodes: x,
            padding: typeof d == "number" ? d : void 0,
            maxZoom: typeof h == "number" ? n(h) : void 0,
            duration: typeof p == "number" ? p : 0
          }), ve({ fitted: x ? x.length : "all" });
        }
        case "focus_schedule": {
          const { scheduleId: c, zoom: d, durationMs: h } = s;
          if (!c) return B('focus_schedule requires "scheduleId".');
          const p = r(c);
          if (!p) return B(`Unknown scheduleId "${String(c)}".`);
          if (d !== void 0 && typeof d != "number") return B('"zoom" must be a number.');
          if ((u = e.setSelection) == null || u.call(e, [p.id], []), (l = e.openDetailsFor) == null || l.call(e, p.data), e.setCenter) {
            const x = p.width ?? 0, v = p.height ?? 0, m = p.position.x + x / 2, b = p.position.y + v / 2;
            e.setCenter(m, b, {
              zoom: n(typeof d == "number" ? d : 1.2),
              duration: typeof h == "number" ? h : 400
            });
          } else e.fitView && e.fitView({ nodes: [{ id: p.id }], duration: 400 });
          return ve({ focused: p.data.scheduleId });
        }
        case "set_graph_selection": {
          if (!e.setSelection)
            return B("Canvas selection is not available in this editor instance.");
          const { scheduleIds: c, links: d, fit: h } = s, p = [];
          if (c !== void 0) {
            if (!Array.isArray(c)) return B('"scheduleIds" must be an array.');
            for (const v of c) {
              const m = r(v);
              if (!m) return B(`Unknown scheduleId "${String(v)}".`);
              p.push(m.id);
            }
          }
          const x = [];
          if (d !== void 0) {
            if (!Array.isArray(d)) return B('"links" must be an array.');
            const v = e.getEdges();
            for (const m of d) {
              const b = r(m == null ? void 0 : m.parentId), g = r(m == null ? void 0 : m.childId);
              if (!b) return B(`Unknown parentId "${String(m == null ? void 0 : m.parentId)}".`);
              if (!g) return B(`Unknown childId "${String(m == null ? void 0 : m.childId)}".`);
              const y = v.find((w) => w.source === b.id && w.target === g.id);
              if (!y)
                return B(`No link from "${String(m == null ? void 0 : m.parentId)}" to "${String(m == null ? void 0 : m.childId)}".`);
              x.push(y.id);
            }
          }
          return e.setSelection(p, x), h === !0 && p.length && e.fitView && e.fitView({ nodes: p.map((v) => ({ id: v })), duration: 400 }), ve({ selectedScheduleIds: p.map((v) => {
            var m;
            return ((m = r(v)) == null ? void 0 : m.data.scheduleId) ?? v;
          }), selectedLinkCount: x.length });
        }
        case "auto_layout_graph": {
          if (!e.runLayout)
            return B("Auto-layout is not available in this editor instance.");
          const { fitAfter: c, durationMs: d } = s;
          return e.runLayout(), c !== !1 && e.fitView && e.fitView({ duration: typeof d == "number" ? d : 400 }), ve({ relayout: !0 });
        }
        default:
          return B(`Unknown tool "${i}".`);
      }
    } catch (c) {
      return B(`Tool "${i}" threw: ${(c == null ? void 0 : c.message) ?? String(c)}`);
    }
  } };
}
function _y(e, r) {
  const t = _e(() => xy(e), []), n = xe(r);
  return n.current = r, le(() => {
    var a;
    return (a = n.current) == null || a.call(n, t), () => {
      var i;
      return (i = n.current) == null ? void 0 : i.call(n, null);
    };
  }, [t]), t;
}
const wy = {
  scheduleNode: Tm
}, Ny = ({
  initialData: e,
  onSave: r,
  onSaveAndReturn: t,
  onBack: n,
  additionalCanvasMenuItems: a,
  additionalNodeMenuItems: i,
  onAiCapabilityReady: o,
  repositories: s
}) => {
  const u = dp(), l = s || u, {
    nodes: c,
    edges: d,
    onNodesChange: h,
    onEdgesChange: p,
    onConnect: x,
    handleUpdateNode: v,
    handleLayout: m,
    handleAddNode: b,
    setNodes: g,
    setEdges: y,
    undo: w,
    redo: I,
    canUndo: q,
    canRedo: N,
    takeSnapshot: R,
    loadData: k,
    buildScheduleNode: S,
    makeEdge: E,
    applyModel: A
  } = py(e), P = xe(c);
  P.current = c;
  const G = xe(d);
  G.current = d;
  const H = Ao(), { getViewport: ee, deleteElements: O, getNodes: z, getEdges: j } = H, [F, te] = U(null), ne = xe({ reactFlow: H, setNodes: g, setEdges: y, setSelectedNode: te, handleLayout: m });
  ne.current = { reactFlow: H, setNodes: g, setEdges: y, setSelectedNode: te, handleLayout: m };
  const ie = _e(() => ({
    getNodes: () => P.current,
    getEdges: () => G.current,
    buildScheduleNode: S,
    makeEdge: E,
    applyModel: A,
    getViewport: () => ne.current.reactFlow.getViewport(),
    setViewport: (D, V) => ne.current.reactFlow.setViewport(D, V),
    setCenter: (D, V, Z) => ne.current.reactFlow.setCenter(D, V, Z),
    fitView: (D) => ne.current.reactFlow.fitView(D),
    setSelection: (D, V) => {
      const Z = new Set(D), J = new Set(V);
      ne.current.setNodes(
        (X) => X.map((ge) => ({ ...ge, selected: Z.has(ge.id) }))
      ), ne.current.setEdges(
        (X) => X.map((ge) => ({ ...ge, selected: J.has(ge.id) }))
      );
    },
    openDetailsFor: (D) => ne.current.setSelectedNode(D),
    runLayout: () => ne.current.handleLayout(),
    zoomBounds: { min: 0.1, max: 1.5 }
  }), [S, E, A]);
  _y(ie, o);
  const [C, T] = U(!1), [M, L] = U(!1), [K, Q] = U(!1), [ae, fe] = U(0), [Te, oe] = U(null), [ue, Y] = U(!1), [me, W] = U({
    name: e.name,
    tags: e.tags,
    configuration: e.configuration
  }), [Me, Re] = U(() => {
    var Z;
    const D = ((Z = e.configuration) == null ? void 0 : Z.scheduleGroups) || [], V = /* @__PURE__ */ new Map();
    return tc.forEach((J) => V.set(J.name, J)), D.forEach((J) => V.set(J.name, J)), (e.schedules || []).forEach((J) => {
      J.group && !V.has(J.group) && V.set(J.group, { name: J.group, color: "slate" });
    }), Array.from(V.values());
  }), et = ce((D) => {
    Re((V) => {
      if (V.some((J) => J.name === D)) return V;
      const Z = [...V, { name: D, color: "slate" }];
      return W((J) => ({
        ...J,
        configuration: { ...J.configuration, scheduleGroups: Z }
      })), Z;
    });
  }, []), Ve = ce((D, V) => {
    Re((Z) => {
      const J = Z.map((X) => X.name === D ? { ...X, ...V, name: D } : X);
      return W((X) => ({
        ...X,
        configuration: { ...X.configuration, scheduleGroups: J }
      })), J;
    });
  }, []), Ie = xe(null), he = ce((D, V) => {
    te(V.data);
  }, []), He = ce(() => {
    te(null), oe(null);
  }, []), Ke = ce(() => {
    R();
  }, [R]), rt = () => {
    te(null), g((D) => D.map((V) => ({ ...V, selected: !1 })));
  }, Nr = () => {
    R();
    const D = z().filter((Z) => Z.selected), V = j().filter((Z) => Z.selected);
    O({ nodes: D, edges: V }), T(!1), F && D.some((Z) => Z.id === F.scheduleId) && te(null);
  }, De = (D) => {
    if (F) {
      const V = [...F.resources || [], ...D];
      v(F.scheduleId, "resources", V);
    }
  }, Ir = (D) => {
    if (F) {
      const V = F.requirements || [], Z = new Set(V.map((X) => X.testamentTypeId)), J = D.filter((X) => !Z.has(X.testamentTypeId)).map((X) => ({ testamentTypeId: X.testamentTypeId }));
      v(F.scheduleId, "requirements", [...V, ...J]);
    }
  }, We = () => ({
    ...e,
    // Keep original ObjectType etc
    name: me.name,
    tags: me.tags,
    configuration: { ...me.configuration, scheduleGroups: Me },
    schedules: c.map((D) => D.data)
  }), tt = () => {
    var D;
    (D = Ie.current) == null || D.click();
  }, qr = (D) => {
    var J;
    const V = (J = D.target.files) == null ? void 0 : J[0];
    if (!V) return;
    const Z = new FileReader();
    Z.onload = (X) => {
      var ge, ec;
      try {
        const nt = (ge = X.target) == null ? void 0 : ge.result, Fe = JSON.parse(nt);
        if (!Fe.schedules || !Array.isArray(Fe.schedules)) {
          alert("Invalid file format: Missing Schedules array.");
          return;
        }
        W({
          name: Fe.name || "",
          tags: Fe.tags || [],
          configuration: Fe.configuration || {}
        });
        const rp = ((ec = Fe.configuration) == null ? void 0 : ec.scheduleGroups) || [], nr = /* @__PURE__ */ new Map();
        tc.forEach((Ee) => nr.set(Ee.name, Ee)), rp.forEach((Ee) => nr.set(Ee.name, Ee)), (Fe.schedules || []).forEach((Ee) => {
          Ee.group && !nr.has(Ee.group) && nr.set(Ee.group, { name: Ee.group, color: "slate" });
        }), Re(Array.from(nr.values())), k(Fe);
      } catch (nt) {
        console.error(nt), alert("Failed to load file.");
      }
    }, Z.readAsText(V), D.target.value = "";
  }, Ce = () => {
    var ge;
    const D = We(), V = JSON.stringify(D, null, 2), Z = new Blob([V], { type: "application/json" }), J = URL.createObjectURL(Z), X = document.createElement("a");
    X.href = J, X.download = `${((ge = D.name) == null ? void 0 : ge.replace(/\s+/g, "_")) || "Entitlement"}.json`, document.body.appendChild(X), X.click(), document.body.removeChild(X), URL.revokeObjectURL(J);
  }, Oe = ce((D, V) => {
    D.preventDefault();
    const Z = i ? i(V.data) : [], J = Z.length > 0;
    oe({
      x: D.clientX,
      y: D.clientY,
      items: [
        ...Z,
        ...J ? [{ label: "Separator", disabled: !0, onClick: () => {
        }, icon: /* @__PURE__ */ f("div", { className: "h-px w-full bg-slate-200 my-1" }) }] : [],
        {
          label: "Delete Node",
          icon: /* @__PURE__ */ f(Oo, { size: 14 }),
          onClick: () => {
            fe(1), g((X) => X.map((ge) => ({ ...ge, selected: ge.id === V.id }))), T(!0);
          },
          danger: !0
        }
      ].filter((X) => X.label !== "Separator" || X.icon)
    });
  }, [g, i]), Q0 = ce((D) => {
    D.preventDefault();
    const V = a || [], Z = V.length > 0;
    oe({
      x: D.clientX,
      y: D.clientY,
      items: [
        {
          label: "Add New Node Here",
          icon: /* @__PURE__ */ f(gr, { size: 14 }),
          onClick: () => {
            b(ee());
          }
        },
        ...Z ? [{ label: "Separator", disabled: !0, onClick: () => {
        }, icon: /* @__PURE__ */ f("div", { className: "h-px w-full bg-slate-200 my-1" }) }] : [],
        ...V
      ]
    });
  }, [b, ee, a]);
  Co.useEffect(() => {
    if (F) {
      const D = c.find((V) => V.id === F.scheduleId);
      D && te(D.data);
    }
  }, [c]);
  const ep = _e(() => c.map((D) => D.data), [c]);
  return /* @__PURE__ */ f(up, { groups: Me, onAddGroup: et, onUpdateGroup: Ve, children: /* @__PURE__ */ _("div", { className: "flex flex-col h-full w-full bg-slate-50 overflow-hidden", children: [
    /* @__PURE__ */ f(
      "input",
      {
        type: "file",
        ref: Ie,
        onChange: qr,
        accept: ".json",
        className: "hidden"
      }
    ),
    /* @__PURE__ */ _("header", { className: "h-16 bg-white border-b border-slate-200 flex items-center justify-between px-2 md:px-6 shrink-0 z-50 shadow-sm relative gap-2", children: [
      /* @__PURE__ */ _("div", { className: "flex items-center gap-2 md:gap-4 overflow-hidden z-20 min-w-0", children: [
        n && /* @__PURE__ */ _(dr, { children: [
          /* @__PURE__ */ f(
            "button",
            {
              onClick: n,
              className: "p-1.5 md:p-2 -ml-2 text-slate-500 hover:text-slate-900 hover:bg-slate-100 rounded-lg transition-colors",
              children: /* @__PURE__ */ f(bp, { size: 20 })
            }
          ),
          /* @__PURE__ */ f("div", { className: "h-6 w-px bg-slate-200 mx-1 md:mx-2 hidden md:block" })
        ] }),
        /* @__PURE__ */ _("div", { className: "flex flex-col", children: [
          /* @__PURE__ */ f("h1", { className: "text-sm md:text-lg font-bold text-slate-900 truncate flex items-center gap-2", children: me.name || "Untitled Entitlement" }),
          /* @__PURE__ */ _("div", { className: "flex items-center gap-2 text-[10px] md:text-xs text-slate-500", children: [
            /* @__PURE__ */ _("span", { className: "bg-slate-100 px-1.5 py-0.5 rounded border border-slate-200 font-mono", children: [
              c.length,
              " Schedules"
            ] }),
            me.tags.length > 0 && /* @__PURE__ */ _("span", { className: "hidden md:inline-flex items-center gap-1", children: [
              /* @__PURE__ */ f("span", { className: "w-1 h-1 rounded-full bg-slate-300" }),
              me.tags.join(", ")
            ] })
          ] })
        ] })
      ] }),
      /* @__PURE__ */ _("div", { className: "flex items-center gap-1 md:gap-2", children: [
        /* @__PURE__ */ _("div", { className: "hidden md:flex items-center gap-1 mr-2 border-r border-slate-200 pr-2", children: [
          /* @__PURE__ */ f("button", { onClick: w, disabled: !q, className: "p-2 text-slate-400 hover:text-slate-700 disabled:opacity-30 rounded-lg", title: "Undo", children: /* @__PURE__ */ f(Im, { size: 18 }) }),
          /* @__PURE__ */ f("button", { onClick: I, disabled: !N, className: "p-2 text-slate-400 hover:text-slate-700 disabled:opacity-30 rounded-lg", title: "Redo", children: /* @__PURE__ */ f(im, { size: 18 }) })
        ] }),
        /* @__PURE__ */ f("button", { onClick: m, className: "p-2 text-slate-500 hover:text-teal-600 hover:bg-teal-50 rounded-lg transition-colors hidden sm:flex", title: "Auto Layout", children: /* @__PURE__ */ f(Wp, { size: 18 }) }),
        /* @__PURE__ */ f("button", { onClick: () => Y(!0), className: "p-2 text-slate-500 hover:text-teal-600 hover:bg-teal-50 rounded-lg transition-colors", title: "Settings", children: /* @__PURE__ */ f(Lr, { size: 18 }) }),
        /* @__PURE__ */ f("div", { className: "h-6 w-px bg-slate-200 mx-1" }),
        /* @__PURE__ */ _("div", { className: "flex items-center gap-1", children: [
          /* @__PURE__ */ f("button", { onClick: tt, className: "p-2 text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors", title: "Import JSON", children: /* @__PURE__ */ f(km, { size: 18 }) }),
          /* @__PURE__ */ f("button", { onClick: Ce, className: "p-2 text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors", title: "Export JSON", children: /* @__PURE__ */ f(Fp, { size: 18 }) })
        ] }),
        /* @__PURE__ */ _(
          "button",
          {
            onClick: () => {
              r && r(We());
            },
            className: "ml-2 bg-teal-600 hover:bg-teal-700 text-white px-3 md:px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-2 shadow-sm shadow-teal-600/20 transition-all",
            children: [
              /* @__PURE__ */ f(Hh, { size: 16 }),
              /* @__PURE__ */ f("span", { className: "hidden md:inline", children: "Save" })
            ]
          }
        ),
        t && /* @__PURE__ */ f(
          "button",
          {
            onClick: () => t(We()),
            className: "ml-1 p-2 text-teal-600 hover:bg-teal-50 rounded-lg",
            title: "Save & Return",
            children: /* @__PURE__ */ f(Zp, { size: 18 })
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ _("div", { className: "flex-1 relative bg-slate-50", children: [
      /* @__PURE__ */ f(Jm, { nodes: c, onSelectNode: te }),
      /* @__PURE__ */ _(
        tp,
        {
          nodes: c,
          edges: d,
          onNodesChange: h,
          onEdgesChange: p,
          onConnect: x,
          nodeTypes: wy,
          onNodeClick: he,
          onPaneClick: He,
          onNodeDragStart: Ke,
          onNodeContextMenu: Oe,
          onPaneContextMenu: Q0,
          fitView: !0,
          minZoom: 0.1,
          maxZoom: 1.5,
          connectionMode: sp.Loose,
          defaultEdgeOptions: {
            type: "smoothstep",
            animated: !1,
            style: { stroke: "#94a3b8", strokeWidth: 2 }
          },
          children: [
            /* @__PURE__ */ f(op, { color: "#e2e8f0", gap: 20 }),
            /* @__PURE__ */ f(cp, { className: "!bg-white !shadow-sm !border !border-slate-200 !m-4" })
          ]
        }
      ),
      Te && /* @__PURE__ */ f(
        Ym,
        {
          x: Te.x,
          y: Te.y,
          items: Te.items,
          onClose: () => oe(null)
        }
      ),
      F && /* @__PURE__ */ f(
        zm,
        {
          node: F,
          allNodes: ep,
          onClose: rt,
          onUpdate: v,
          onAddResourceRequest: () => L(!0),
          onAddRequirementRequest: () => Q(!0)
        }
      )
    ] }),
    /* @__PURE__ */ f(
      Bm,
      {
        isOpen: C,
        onClose: () => T(!1),
        onConfirm: Nr,
        count: ae
      }
    ),
    /* @__PURE__ */ f(
      Um,
      {
        isOpen: ue,
        onClose: () => Y(!1),
        data: me,
        onSave: (D) => {
          W(D);
        }
      }
    ),
    /* @__PURE__ */ f(
      Vm,
      {
        isOpen: M,
        onClose: () => L(!1),
        onConfirm: De,
        repositories: l
      }
    ),
    /* @__PURE__ */ f(
      Km,
      {
        isOpen: K,
        onClose: () => Q(!1),
        onConfirm: Ir,
        repository: l == null ? void 0 : l.testamentTypes,
        excludedIds: ((F == null ? void 0 : F.requirements) || []).map((D) => D.testamentTypeId)
      }
    )
  ] }) });
}, hr = [
  { groupName: "GlobalAdmins", nodeName: "Root", role: "Owner" },
  { groupName: "LocalOps", nodeName: "Berlin", role: "Operator" }
], be = {
  paramA: "value1",
  syncEnabled: !0
}, pr = "7a2e0fa0-d84f-81c8-387c-cba962518d94", ur = "10000000-0000-0000-0000-000000000001", Z0 = "10000000-0000-0000-0000-000000000002", mr = "10000000-0000-0000-0000-000000000003", lr = "10000000-0000-0000-0000-000000000004", Pr = [
  {
    id: pr,
    name: "Main Access Control",
    memberships: hr,
    resources: [],
    resourcePlans: []
  },
  {
    id: ur,
    name: "Internal Systems",
    memberships: [],
    resources: [],
    resourcePlans: []
  },
  {
    id: Z0,
    name: "IoT Devices",
    memberships: [],
    resources: [],
    resourcePlans: []
  },
  {
    id: mr,
    name: "Legacy Controller A",
    memberships: [],
    resources: [],
    resourcePlans: []
  },
  {
    id: lr,
    name: "Cloud Access Manager",
    memberships: hr,
    resources: [],
    resourcePlans: []
  }
], Ro = [
  // Existing Resources (Preserving IDs from INITIAL_DATA where possible)
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bbe", name: "Main Entrance Lobby", description: "Primary public entrance", referenceId: "EXT-001", resourceKind: de.Single, resourceType: "Door", memberships: [], configuration: be, systemId: pr },
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bbf", name: "Side Entrance Staff", description: "Staff only entrance", referenceId: "EXT-002", resourceKind: de.Single, resourceType: "Door", memberships: [], configuration: be, systemId: pr },
  // Mapped to Internal
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bbb", name: "Office 101 (North)", description: "Open space area north", referenceId: "INT-101", resourceKind: de.Collection, resourceType: "Zone", memberships: hr, configuration: be, systemId: ur },
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bbc", name: "Office 102 (North)", description: "Meeting rooms north", referenceId: "INT-102", resourceKind: de.Collection, resourceType: "Zone", memberships: [], configuration: be, systemId: ur },
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bbd", name: "Office 103 (East)", description: "Quiet zone east", referenceId: "INT-103", resourceKind: de.Collection, resourceType: "Zone", memberships: [], configuration: be, systemId: ur },
  // Mapped to Cloud
  { id: "899d0c8b-9ec8-aa62-3956-b770f75dd7ea", name: "Executive Suite", description: "High security area", referenceId: "SEC-900", resourceKind: de.Fixed, resourceType: "SecureZone", memberships: hr, configuration: be, systemId: lr },
  { id: "30000000-0000-0000-0000-000000000001", name: "Conference Room A", description: "Large conference room", referenceId: "CONF-A", resourceKind: de.Single, resourceType: "Room", memberships: [], configuration: be, systemId: lr },
  { id: "30000000-0000-0000-0000-000000000002", name: "Conference Room B", description: "Small meeting room", referenceId: "CONF-B", resourceKind: de.Single, resourceType: "Room", memberships: [], configuration: be, systemId: lr },
  // Mapped to Legacy
  { id: "a118c70c-0944-dc75-db81-26665a7ff674", name: "Server Room Rack A", description: "Main server rack access", referenceId: "SRV-A", resourceKind: de.Single, resourceType: "Cabinet", memberships: [], configuration: be, systemId: mr },
  { id: "30000000-0000-0000-0000-000000000003", name: "Cafeteria Turnstile", description: "Lunch area access", referenceId: "CAF-01", resourceKind: de.Single, resourceType: "Turnstile", memberships: [], configuration: be, systemId: mr },
  // Mapped to IoT
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bba", name: "Printer Room", description: "Common service area", referenceId: "SVC-001", resourceKind: de.Single, resourceType: "Room", memberships: [], configuration: be, systemId: Z0 }
];
for (let e = 1; e <= 60; e++) {
  const r = Math.floor((e - 1) / 15) + 1, t = Pr[e % Pr.length], n = `50000000-0000-0000-0000-${(1e11 + e).toString()}`;
  Ro.push({
    id: n,
    name: `Floor ${r} - Desk ${e}`,
    description: `Hot desk on floor ${r}`,
    referenceId: `DSK-${r}-${e}`,
    resourceKind: de.Single,
    resourceType: "Desk",
    memberships: [],
    configuration: {},
    systemId: t.id
  });
}
const Mh = [
  // Moved to Main Access Control to fix missing plans issue
  { id: "3430d084-b147-a576-0018-3a3726ecb4d7", name: "Standard Access Plan", description: "9-5 Access", referenceId: "PLN-STD", priority: 10, memberships: [], configuration: be, systemId: pr },
  { id: "20000000-0000-0000-0000-000000000005", name: "Emergency Access", description: "Override all locks", referenceId: "PLN-EMG", priority: 100, memberships: [], configuration: be, systemId: pr },
  // Cloud Plans
  { id: "20000000-0000-0000-0000-000000000001", name: "24/7 Unlimited", description: "All hours access", referenceId: "PLN-ALL", priority: 99, memberships: hr, configuration: be, systemId: lr },
  // Internal Plans
  { id: "20000000-0000-0000-0000-000000000002", name: "Working Hours (08:00 - 18:00)", description: "Standard business hours", referenceId: "PLN-BIZ", priority: 5, memberships: [], configuration: {}, systemId: ur },
  // Legacy Plans
  { id: "20000000-0000-0000-0000-000000000003", name: "Visitor Restricted", description: "Escort required", referenceId: "PLN-VIS", priority: 0, memberships: [], configuration: {}, systemId: mr },
  { id: "20000000-0000-0000-0000-000000000004", name: "Maintenance Access (Weekends)", description: "Weekend only", referenceId: "PLN-MNT", priority: 50, memberships: [], configuration: {}, systemId: mr }
], Oh = [
  { id: "10000000-0000-0000-0000-100000000002", groupId: "10000000-0000-0000-0000-100000000001", name: "Erfurt Office (HQ)", type: "Location" },
  { id: "40000000-0000-0000-0000-000000000001", groupId: "10000000-0000-0000-0000-100000000001", name: "Berlin Branch", type: "Location" },
  { id: "40000000-0000-0000-0000-000000000002", groupId: "10000000-0000-0000-0000-100000000001", name: "Munich Hub", type: "Location" },
  { id: "40000000-0000-0000-0000-000000000003", groupId: "10000000-0000-0000-0000-100000000001", name: "London Office", type: "Location" },
  { id: "40000000-0000-0000-0000-000000000004", groupId: "10000000-0000-0000-0000-100000000001", name: "US East (NY)", type: "Location" }
], Iy = [
  { id: "10000000-0000-0000-0000-200000000002", groupId: "10000000-0000-0000-0000-200000000001", name: "Facility Management", type: "Approval" },
  { id: "60000000-0000-0000-0000-000000000001", groupId: "10000000-0000-0000-0000-200000000001", name: "Security Team", type: "Approval" },
  { id: "60000000-0000-0000-0000-000000000002", groupId: "10000000-0000-0000-0000-200000000001", name: "Human Resources", type: "Approval" },
  { id: "60000000-0000-0000-0000-000000000003", groupId: "10000000-0000-0000-0000-200000000001", name: "IT Operations", type: "Approval" },
  { id: "60000000-0000-0000-0000-000000000004", groupId: "10000000-0000-0000-0000-200000000001", name: "Executive Board", type: "Approval" }
], X0 = [
  {
    testamentTypeId: "70000000-0000-0000-0000-000000000001",
    name: "Safety Training Certificate",
    description: "Confirms completed annual site safety training.",
    category: "Training",
    defaultValidityDays: 365,
    requiresDocument: !0,
    isRenewable: !0,
    isDeprecated: !1,
    isSuperseded: !1,
    version: 1
  },
  {
    testamentTypeId: "70000000-0000-0000-0000-000000000002",
    name: "NDA Confirmation",
    description: "Required for access to confidential project areas.",
    category: "Compliance",
    defaultValidityDays: null,
    requiresDocument: !1,
    isRenewable: !1,
    isDeprecated: !1,
    isSuperseded: !1,
    version: 1
  },
  {
    testamentTypeId: "70000000-0000-0000-0000-000000000003",
    name: "Medical Clearance",
    description: "Clearance for physically demanding or high-risk zones.",
    category: "Health",
    defaultValidityDays: 180,
    requiresDocument: !0,
    isRenewable: !0,
    isDeprecated: !1,
    isSuperseded: !1,
    version: 2
  },
  {
    testamentTypeId: "70000000-0000-0000-0000-000000000004",
    name: "Legacy Visitor Briefing",
    description: "Older visitor briefing, retained for existing schedules.",
    category: "Visitor",
    defaultValidityDays: 30,
    requiresDocument: !1,
    isRenewable: !0,
    isDeprecated: !0,
    deprecationReason: "Replaced by Standard Visitor Briefing",
    replacementTestamentTypeId: "70000000-0000-0000-0000-000000000005",
    isSuperseded: !1,
    version: 1
  },
  {
    testamentTypeId: "70000000-0000-0000-0000-000000000005",
    name: "Standard Visitor Briefing",
    description: "Current visitor briefing for temporary building access.",
    category: "Visitor",
    defaultValidityDays: 30,
    requiresDocument: !1,
    isRenewable: !0,
    isDeprecated: !1,
    isSuperseded: !1,
    version: 1
  }
], qy = 300, qe = (e) => new Promise((r) => setTimeout(() => r(e), qy)), ar = (e, r) => {
  let t = [...e];
  if (r != null && r.filter) {
    const a = r.filter.toLowerCase();
    t = t.filter((i) => (i.name || "").toLowerCase().includes(a) || i.id.toLowerCase().includes(a));
  }
  r != null && r.sortBy && t.sort((a, i) => {
    const o = a.name || "", s = i.name || "";
    return o.localeCompare(s);
  });
  const n = t.length;
  if ((r == null ? void 0 : r.page) !== void 0 && (r == null ? void 0 : r.pageSize) !== void 0) {
    const a = (r.page - 1) * r.pageSize;
    t = t.slice(a, a + r.pageSize);
  }
  return { items: t, total: n };
}, qo = (e, r) => {
  const t = /* @__PURE__ */ new Map(), n = new Set(r), a = new Map(e.map((i) => [i.id, i]));
  return n.forEach((i) => {
    const o = a.get(i);
    o && t.set(i, o);
  }), t;
}, ky = (e, r) => {
  const t = /* @__PURE__ */ new Map(), n = new Set(r);
  return e.forEach((a) => {
    n.has(a.id) && t.set(a.id, a.name);
  }), n.forEach((a) => {
    t.has(a) || t.set(a, a);
  }), t;
}, Sy = (e) => {
  const r = e.toLowerCase();
  return X0.filter((t) => [
    t.testamentTypeId,
    t.name,
    t.description || "",
    t.category || ""
  ].join(" ").toLowerCase().includes(r));
}, Ry = (e) => {
  const r = new Set(e);
  return X0.filter((t) => r.has(t.testamentTypeId));
}, My = {
  getSystems: (e) => qe(ar(Pr, e)),
  getResources: (e) => qe(ar(Ro, e)),
  getPlans: (e) => qe(ar(Mh, e)),
  getLocations: (e) => qe(ar(Oh, e)),
  getApprovalGroups: (e) => qe(ar(Iy, e)),
  resolveSystems: (e) => qe(qo(Pr, e)),
  resolveResources: (e) => qe(qo(Ro, e)),
  resolvePlans: (e) => qe(qo(Mh, e)),
  resolveLocations: (e) => qe(ky(Oh, e)),
  testamentTypes: {
    search: (e) => qe(Sy(e)),
    resolve: (e) => qe(Ry(e))
  }
}, Oy = ({
  initialData: e,
  onSave: r,
  onSaveAndReturn: t,
  onBack: n,
  onLoadRequest: a,
  additionalCanvasMenuItems: i,
  additionalNodeMenuItems: o,
  onAiCapabilityReady: s
}) => /* @__PURE__ */ f(
  Ny,
  {
    initialData: e,
    onSave: r,
    onSaveAndReturn: t,
    onBack: n,
    additionalCanvasMenuItems: i,
    additionalNodeMenuItems: o,
    onAiCapabilityReady: s
  },
  e.name
);
export {
  ir as ApprovalGroupType,
  tc as DEFAULT_SCHEDULE_GROUPS,
  pe as Direction,
  Ny as EntitlementEditor,
  Oy as EntitlementEditorWrapper,
  My as MockRepository,
  Ty as RepositoryProvider,
  de as ResourceKind,
  up as ScheduleGroupProvider,
  xy as buildAiCapability,
  Ny as default,
  lp as useRepositories,
  Dh as useScheduleGroups,
  Or as validateGraph
};
//# sourceMappingURL=index.js.map
