import { jsx as f, jsxs as x, Fragment as lr } from "react/jsx-runtime";
import Ro, { createContext as M0, useContext as Co, forwardRef as P0, createElement as Io, useState as B, useRef as _e, useMemo as ge, useEffect as oe, useCallback as ie } from "react";
import Qh, { useReactFlow as Eo, Handle as ec, Position as Cr, useNodesState as ep, useEdgesState as rp, MarkerType as nt, addEdge as tp, ConnectionMode as np, Background as ap, Controls as ip } from "reactflow";
var ue = /* @__PURE__ */ ((e) => (e.Single = "Single", e.Collection = "Collection", e.Fixed = "Fixed", e))(ue || {}), pe = /* @__PURE__ */ ((e) => (e[e.BottomUp = 0] = "BottomUp", e[e.TopDown = 1] = "TopDown", e))(pe || {}), ar = /* @__PURE__ */ ((e) => (e.Room = "Room", e.Area = "Area", e.Global = "Global", e))(ar || {});
const rc = [
  { 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" }
], L0 = M0({
  groups: [],
  addGroup: () => {
  },
  updateGroup: () => {
  }
}), sp = ({
  children: e,
  groups: r,
  onAddGroup: n,
  onUpdateGroup: t
}) => /* @__PURE__ */ f(L0.Provider, { value: { groups: r, addGroup: n, updateGroup: t }, children: e }), D0 = () => Co(L0), Ao = M0(null), Cy = ({
  children: e,
  repositories: r
}) => /* @__PURE__ */ f(Ao.Provider, { value: r, children: e }), op = () => {
  const e = Co(Ao);
  if (!e)
    throw new Error("useRepositories must be used within RepositoryProvider");
  return e;
}, cp = () => Co(Ao);
/**
 * @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 = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), lp = (e) => e.replace(
  /^([A-Z])|[\s-_]+(\w)/g,
  (r, n, t) => t ? t.toUpperCase() : n.toLowerCase()
), tc = (e) => {
  const r = lp(e);
  return r.charAt(0).toUpperCase() + r.slice(1);
}, j0 = (...e) => e.filter((r, n, t) => !!r && r.trim() !== "" && t.indexOf(r) === n).join(" ").trim(), dp = (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 fp = {
  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 hp = P0(
  ({
    color: e = "currentColor",
    size: r = 24,
    strokeWidth: n = 2,
    absoluteStrokeWidth: t,
    className: a = "",
    children: i,
    iconNode: o,
    ...s
  }, c) => Io(
    "svg",
    {
      ref: c,
      ...fp,
      width: r,
      height: r,
      stroke: e,
      strokeWidth: t ? Number(n) * 24 / Number(r) : n,
      className: j0("lucide", a),
      ...!i && !dp(s) && { "aria-hidden": "true" },
      ...s
    },
    [
      ...o.map(([l, u]) => Io(l, u)),
      ...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 U = (e, r) => {
  const n = P0(
    ({ className: t, ...a }, i) => Io(hp, {
      ref: i,
      iconNode: r,
      className: j0(
        `lucide-${up(tc(e))}`,
        `lucide-${e}`,
        t
      ),
      ...a
    })
  );
  return n.displayName = tc(e), n;
};
/**
 * @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 pp = [
  ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
  ["path", { d: "M19 12H5", key: "x3x0zl" }]
], mp = U("arrow-left", pp);
/**
 * @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: "M5 12h14", key: "1ays0h" }],
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
], gp = U("arrow-right", 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 bp = [
  [
    "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" }]
], dr = U("box", 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 yp = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], Er = U("check", 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 xp = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], _p = U("chevron-down", 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 wp = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], Np = U("chevron-right", 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 qp = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]], G0 = U("chevron-left", 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 Ip = [
  ["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" }]
], kp = U("circle-alert", Ip);
/**
 * @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 = [
  ["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" }]
], F0 = U("circle-arrow-down", 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" }],
  ["path", { d: "m16 12-4-4-4 4", key: "177agl" }],
  ["path", { d: "M12 16V8", key: "1sbj14" }]
], z0 = U("circle-arrow-up", 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 Cp = [
  ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
  ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
], Ep = U("circle-check-big", Cp);
/**
 * @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: "m9 12 2 2 4-4", key: "dzmm74" }]
], Tp = U("circle-check", 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 Op = [
  ["path", { d: "M12 6v6l4 2", key: "mmk7yg" }],
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
], mr = U("clock", 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 Mp = [
  [
    "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" }]
], B0 = U("crown", Mp);
/**
 * @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 Pp = [
  ["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" }]
], Lp = U("download", Pp);
/**
 * @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: "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" }]
], To = U("file-check-corner", 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 jp = [
  [
    "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 = U("file-text", 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 Gp = [
  [
    "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"
    }
  ]
], Mo = U("funnel", 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 Fp = [
  ["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" }]
], zp = U("globe", Fp);
/**
 * @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: "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"
    }
  ]
], Up = U("layers", 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 $p = [
  ["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" }]
], Hp = U("layout-dashboard", $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 Vp = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], U0 = U("loader-circle", 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 = [
  ["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" }]
], Wp = U("log-out", 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: "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" }]
], Jp = U("map-pin", 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 Zp = [
  [
    "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"
    }
  ]
], $0 = U("moon", 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 Xp = [
  ["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" }]
], Qp = U("network", 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: "M5 12h14", key: "1ays0h" }],
  ["path", { d: "M12 5v14", key: "s699le" }]
], vr = U("plus", 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 = [
  ["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" }]
], tm = U("redo-2", 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: "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" }]
], am = U("refresh-cw", 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 im = [
  [
    "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" }]
], H0 = U("save", im);
/**
 * @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: "m21 21-4.34-4.34", key: "14j7rj" }],
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
], We = U("search", 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 om = [
  [
    "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" }]
], Pr = U("settings", om);
/**
 * @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 = [
  ["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" }]
], V0 = U("share-2", 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: "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" }]
], K0 = U("shield-alert", 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: "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" }]
], dm = U("shield-check", 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 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"
    }
  ]
], hm = U("shield", 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 pm = [
  ["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" }]
], mm = U("timer", pm);
/**
 * @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 vm = [
  ["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" }]
], Ye = U("trash-2", vm);
/**
 * @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 = [
  [
    "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" }]
], Je = U("triangle-alert", 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 bm = [
  ["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" }]
], ym = U("trophy", bm);
/**
 * @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: "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" }]
], _m = U("undo-2", 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 wm = [
  ["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" }]
], Nm = U("upload", wm);
/**
 * @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: "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"
    }
  ]
], W0 = U("wrench", 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 Im = [
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
], Ae = U("x", Im), Y0 = {
  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" }
}, km = Y0.slate, Sm = {
  AlertTriangle: Je,
  Crown: B0,
  Clock: mr,
  Moon: $0,
  ShieldAlert: K0,
  Wrench: W0
}, Rm = ({ id: e, data: r, selected: n }) => {
  var y, w;
  const { setNodes: t } = Eo(), { groups: a } = D0(), [i, o] = B(!1), [s, c] = B(r.name), l = _e(null), u = r.isActive, d = ge(
    () => a.find((N) => N.name === r.group),
    [a, r.group]
  ), h = (d == null ? void 0 : d.color) && Y0[d.color] || km, p = d != null && d.icon ? Sm[d.icon] : void 0;
  oe(() => {
    c(r.name);
  }, [r.name]);
  const q = (N) => {
    N == null || N.stopPropagation(), o(!0), c(r.name);
  }, g = () => {
    o(!1), c(r.name);
  }, v = () => {
    s.trim() && s !== r.name && t((N) => N.map((I) => I.id === e ? { ...I, data: { ...I.data, name: s } } : I)), o(!1);
  }, b = (N) => {
    N.key === "Enter" && (N.preventDefault(), N.stopPropagation(), v()), N.key === "Escape" && (N.preventDefault(), N.stopPropagation(), g());
  };
  oe(() => {
    i && l.current && (l.current.focus(), l.current.select());
  }, [i]), oe(() => {
    if (!n) return;
    const N = (I) => {
      (I.ctrlKey || I.metaKey) && I.key === "r" && (I.preventDefault(), q());
    };
    return window.addEventListener("keydown", N), () => window.removeEventListener("keydown", N);
  }, [n]);
  const m = ge(() => {
    const N = r._inheritedResources || [], I = r.resources, _ = /* @__PURE__ */ new Map();
    return I.forEach((R) => {
      _.set(R.resourceId, r.priority);
    }), N.forEach((R) => {
      const k = _.get(R.resourceId);
      (k === void 0 || R.sourceNodePriority > k) && _.set(R.resourceId, R.sourceNodePriority);
    }), _.size;
  }, [r.resources, r._inheritedResources, r.priority]);
  return /* @__PURE__ */ x(
    "div",
    {
      className: `relative w-[280px] shadow-sm rounded-xl border-2 transition-all duration-200 bg-white
      ${n ? "border-teal-500 ring-2 ring-teal-100" : "border-slate-200"}
      ${u ? "" : "opacity-70 grayscale"}
      `,
      children: [
        /* @__PURE__ */ f(ec, { type: "target", position: Cr.Top, className: "!bg-slate-400 !w-3 !h-3" }),
        /* @__PURE__ */ x("div", { className: `px-4 py-2 rounded-t-xl flex items-center justify-between border-b ${h.bg} ${h.border}`, children: [
          /* @__PURE__ */ x("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__ */ x("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(z0, { size: 14, className: "text-slate-400" }) }),
            r.direction === pe.TopDown && /* @__PURE__ */ f("span", { title: "Inherits from Children", className: "flex items-center", children: /* @__PURE__ */ f(F0, { size: 14, className: "text-slate-400" }) }),
            /* @__PURE__ */ x("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__ */ x("div", { className: "p-4", children: [
          i ? /* @__PURE__ */ f("div", { className: "mb-3", children: /* @__PURE__ */ f(
            "input",
            {
              ref: l,
              type: "text",
              value: s,
              onChange: (N) => c(N.target.value),
              onKeyDown: b,
              onBlur: v,
              className: "w-full text-sm font-semibold text-slate-800 border-2 border-teal-500 rounded p-1 focus:outline-none",
              onClick: (N) => N.stopPropagation()
            }
          ) }) : /* @__PURE__ */ x(
            "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: q,
              children: [
                /* @__PURE__ */ f(hm, { size: 16, className: "text-teal-600 flex-shrink-0" }),
                r.name
              ]
            }
          ),
          /* @__PURE__ */ x("div", { className: "space-y-2", children: [
            /* @__PURE__ */ x("div", { className: "flex items-center text-xs text-slate-600 gap-2", children: [
              /* @__PURE__ */ f(mr, { 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__ */ x("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__ */ x("div", { className: "flex items-center justify-between pt-2 border-t border-slate-100 mt-2", children: [
              /* @__PURE__ */ x("div", { className: "flex items-center text-xs text-slate-500 gap-1.5", title: "Effective Resources (After Priority Resolution)", children: [
                /* @__PURE__ */ f(dr, { size: 14, className: "text-teal-600" }),
                /* @__PURE__ */ f("span", { className: "font-bold text-slate-700 font-mono", children: m }),
                /* @__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__ */ x("div", { className: "flex items-center text-xs text-slate-400 gap-1", title: "Workflow Type", children: [
                /* @__PURE__ */ f(Up, { size: 14 }),
                /* @__PURE__ */ x("span", { children: [
                  "Type ",
                  r.configuration.workflow.type
                ] })
              ] })
            ] })
          ] })
        ] }),
        /* @__PURE__ */ f(ec, { type: "source", position: Cr.Bottom, className: "!bg-slate-400 !w-3 !h-3" })
      ]
    }
  );
}, Cm = Ro.memo(Rm), ko = ({ tags: e, onChange: r, placeholder: n = "Add tag...", colorClass: t = "bg-slate-100 text-slate-700 border-slate-200", id: a }) => {
  const [i, o] = B(""), s = (l) => {
    l.key === "Enter" && i.trim() && (l.preventDefault(), e.includes(i.trim()) || r([...e, i.trim()]), o(""));
  }, c = (l) => {
    r(e.filter((u) => u !== l));
  };
  return /* @__PURE__ */ x("div", { className: "space-y-2", children: [
    /* @__PURE__ */ f("div", { className: "flex flex-wrap gap-2 mb-2", children: e.map((l) => /* @__PURE__ */ x(
      "span",
      {
        className: `inline-flex items-center px-2 py-1 rounded text-xs font-medium border ${t}`,
        children: [
          l,
          /* @__PURE__ */ f(
            "button",
            {
              onClick: () => c(l),
              className: "ml-1.5 p-0.5 hover:bg-black/10 rounded-full transition-colors",
              children: /* @__PURE__ */ f(Ae, { size: 10 })
            }
          )
        ]
      },
      l
    )) }),
    /* @__PURE__ */ x("div", { className: "relative", children: [
      /* @__PURE__ */ f(
        "input",
        {
          id: a,
          type: "text",
          value: i,
          onChange: (l) => o(l.target.value),
          onKeyDown: s,
          placeholder: n,
          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(vr, { size: 16 })
        }
      )
    ] })
  ] });
};
function Ar({
  items: e,
  height: r,
  itemHeight: n,
  renderItem: t,
  className: a = "",
  overscan: i = 5
}) {
  const [o, s] = B(0), c = _e(null), l = e.length * n, { startIndex: u, endIndex: d } = ge(() => {
    var m;
    let g = 0;
    typeof r == "number" ? g = r : g = ((m = c.current) == null ? void 0 : m.clientHeight) || 500;
    const v = Math.floor(o / n), b = Math.ceil((o + g) / n);
    return {
      startIndex: Math.max(0, v - i),
      endIndex: Math.min(e.length, b + i)
    };
  }, [o, e.length, n, r, i]), h = e.slice(u, d), p = u * n, q = (g) => {
    s(g.currentTarget.scrollTop);
  };
  return oe(() => {
    const g = () => {
      c.current;
    };
    return window.addEventListener("resize", g), () => window.removeEventListener("resize", g);
  }, []), /* @__PURE__ */ f(
    "div",
    {
      ref: c,
      className: `overflow-y-auto relative ${a}`,
      style: { height: r },
      onScroll: q,
      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((g, v) => t(g, u + v))
        }
      ) })
    }
  );
}
const nc = (e) => e.isOpen ? /* @__PURE__ */ f(Em, { ...e }) : null, Em = ({
  onClose: e,
  onSelect: r,
  schedules: n,
  title: t = "Select Schedule",
  excludeId: a
}) => {
  const [i, o] = B(""), s = ge(() => {
    const c = i.toLowerCase();
    return n.filter((l) => !a || l.scheduleId !== a).filter(
      (l) => l.name.toLowerCase().includes(c) || l.scheduleId.toLowerCase().includes(c) || l.group.toLowerCase().includes(c)
    );
  }, [n, 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__ */ x("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__ */ x("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: t }),
      /* @__PURE__ */ f("button", { onClick: e, className: "p-2 hover:bg-slate-200 rounded-full text-slate-400 transition-colors", children: /* @__PURE__ */ f(Ae, { size: 20 }) })
    ] }),
    /* @__PURE__ */ x("div", { className: "p-4 border-b border-slate-100 flex gap-4 bg-white flex-shrink-0", children: [
      /* @__PURE__ */ x("div", { className: "relative flex-1", children: [
        /* @__PURE__ */ f(We, { 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: (c) => o(c.target.value)
          }
        )
      ] }),
      /* @__PURE__ */ x("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(Mo, { 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(
      Ar,
      {
        items: s,
        height: "100%",
        itemHeight: 64,
        renderItem: (c) => /* @__PURE__ */ f("div", { className: "pb-1", children: /* @__PURE__ */ x(
          "button",
          {
            onClick: () => {
              r(c.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__ */ x("div", { children: [
                /* @__PURE__ */ f("div", { className: "font-semibold text-slate-800 text-sm truncate", children: c.name }),
                /* @__PURE__ */ x("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: c.group }),
                  /* @__PURE__ */ f("span", { className: "text-[10px] font-mono text-slate-400 truncate max-w-[150px]", children: c.scheduleId })
                ] })
              ] }),
              /* @__PURE__ */ f("div", { className: "opacity-0 group-hover:opacity-100 text-teal-600 transition-opacity", children: /* @__PURE__ */ f(Er, { size: 18 }) })
            ]
          }
        ) }, c.scheduleId)
      }
    ) })
  ] }) });
}, Am = ["slate", "red", "purple", "amber", "indigo", "orange", "blue", "emerald", "teal", "pink"], Tm = [
  { 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" }
], at = {
  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"
}, ac = {
  AlertTriangle: Je,
  Crown: B0,
  Clock: mr,
  Moon: $0,
  ShieldAlert: K0,
  Wrench: W0
}, Om = ({ node: e, handleUpdate: r, allNodes: n, getScheduleName: t }) => {
  const [a, i] = B(!1), [o, s] = B(!1), { groups: c, addGroup: l, updateGroup: u } = D0(), [d, h] = B(!1), [p, q] = B(""), g = _e(null), [v, b] = B(null);
  oe(() => {
    const k = (S) => {
      g.current && !g.current.contains(S.target) && h(!1);
    };
    return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
  }, []);
  const m = ge(
    () => c.filter((k) => k.name.toLowerCase().includes(p.toLowerCase())),
    [c, p]
  ), y = (k) => {
    r("group", k), q(""), h(!1);
  }, w = (k) => {
    q(k), r("group", k), d || h(!0);
  }, N = () => {
    e.group && !c.some((k) => k.name === e.group) && l(e.group);
  }, I = (k) => {
    k ? r("followUp", "") : r("followUp", null);
  }, _ = (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__ */ x("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ x("div", { className: "flex items-center justify-between bg-slate-50 p-3 rounded-lg border border-slate-200", children: [
      /* @__PURE__ */ x("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(Ep, { size: 20 }) : /* @__PURE__ */ f(Je, { size: 20 }) }),
        /* @__PURE__ */ x("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__ */ x("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__ */ x("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__ */ x("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__ */ x("div", { className: "grid grid-cols-2 gap-4", children: [
        /* @__PURE__ */ x("div", { ref: g, className: "relative", children: [
          /* @__PURE__ */ f("label", { htmlFor: "gen-group", className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Group" }),
          /* @__PURE__ */ x("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), q("");
                },
                onBlur: N,
                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(_p, { size: 14 })
              }
            )
          ] }),
          d && /* @__PURE__ */ x("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: [
            m.map((k) => {
              const S = k.icon ? ac[k.icon] : void 0, E = at[k.color || "slate"] || at.slate;
              return /* @__PURE__ */ x(
                "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__ */ x(
                      "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(Pr, { size: 12 })
                      }
                    )
                  ]
                },
                k.name
              );
            }),
            m.length === 0 && p && /* @__PURE__ */ x("div", { className: "px-3 py-2 text-xs text-slate-400 italic", children: [
              'Press Tab to add "',
              p,
              '" as custom group'
            ] })
          ] })
        ] }),
        /* @__PURE__ */ x("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__ */ x("div", { children: [
        /* @__PURE__ */ x("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(
          ko,
          {
            id: "gen-tags",
            tags: e.tags || [],
            onChange: (k) => r("tags", k)
          }
        )
      ] }),
      /* @__PURE__ */ x("div", { children: [
        /* @__PURE__ */ x("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(
          ko,
          {
            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__ */ x("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__ */ x("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__ */ x("div", { className: "flex items-center justify-between mb-2", children: [
          /* @__PURE__ */ x("div", { className: "flex items-center gap-3", children: [
            /* @__PURE__ */ f(V0, { 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__ */ x("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) => I(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__ */ x("div", { children: [
          /* @__PURE__ */ f("span", { className: "text-xs text-slate-500 mb-1 block", children: "Target Schedule" }),
          /* @__PURE__ */ x("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 ? t(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(Ye, { size: 14 })
              }
            )
          ] })
        ] }) })
      ] }),
      /* @__PURE__ */ x("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__ */ x("div", { className: "flex items-center justify-between mb-2", children: [
          /* @__PURE__ */ x("div", { className: "flex items-center gap-3", children: [
            /* @__PURE__ */ f(mm, { 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__ */ x("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__ */ x("div", { className: "mt-3 space-y-3 pl-2 border-l-2 border-amber-200", children: [
          /* @__PURE__ */ x("div", { children: [
            /* @__PURE__ */ f("span", { className: "text-xs text-slate-500 mb-1 block", children: "Replacement Schedule" }),
            /* @__PURE__ */ x("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: t(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: () => _("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(Ye, { size: 14 })
                }
              )
            ] })
          ] }),
          /* @__PURE__ */ x("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) => _("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(
      nc,
      {
        isOpen: a,
        onClose: () => i(!1),
        schedules: n,
        onSelect: (k) => r("followUp", k),
        title: "Select Follow Up Schedule",
        excludeId: e.scheduleId
      }
    ),
    /* @__PURE__ */ f(
      nc,
      {
        isOpen: o,
        onClose: () => s(!1),
        schedules: n,
        onSelect: (k) => _("scheduleId", k),
        title: "Select Replacement Schedule",
        excludeId: e.scheduleId
      }
    ),
    v && (() => {
      const k = c.find((S) => S.name === v);
      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__ */ x("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__ */ x("div", { className: "flex items-center justify-between mb-4", children: [
          /* @__PURE__ */ x("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(Ae, { size: 16 }) })
        ] }),
        /* @__PURE__ */ x("div", { className: "space-y-4", children: [
          /* @__PURE__ */ x("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: Am.map((S) => /* @__PURE__ */ f(
              "button",
              {
                type: "button",
                onClick: () => u(k.name, { color: S }),
                className: `w-7 h-7 rounded-full border-2 transition-all ${at[S]} ${(k.color || "slate") === S ? "border-slate-800 scale-110" : "border-transparent hover:border-slate-300"}`,
                title: S
              },
              S
            )) })
          ] }),
          /* @__PURE__ */ x("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: Tm.map((S) => {
              const E = S.name ? ac[S.name] : void 0, A = (k.icon || "") === S.name;
              return /* @__PURE__ */ x(
                "button",
                {
                  type: "button",
                  onClick: () => u(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;
    })()
  ] });
}, Mm = ({ node: e, handleUpdate: r, availableLocations: n, availableApprovalGroups: t }) => {
  const a = (c) => {
    const [l, u] = c.split("|");
    l && u && r("locationGroup", { groupId: l, nodeId: u });
  }, i = () => {
    const c = t[0], l = {
      groupId: c ? c.groupId : "",
      nodeId: c ? c.id : "",
      type: ar.Room
    };
    r("approvalGroups", [...e.approvalGroups || [], l]);
  }, o = (c) => {
    const l = (e.approvalGroups || []).filter((u, d) => d !== c);
    r("approvalGroups", l);
  }, s = (c, l, u) => {
    const d = [...e.approvalGroups || []];
    if (l === "combined") {
      const [h, p] = u.split("|");
      d[c] = { ...d[c], groupId: h, nodeId: p };
    } else
      d[c] = { ...d[c], [l]: u };
    r("approvalGroups", d);
  };
  return /* @__PURE__ */ x("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ x("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__ */ x("div", { className: "flex items-center justify-between p-4 bg-white border border-slate-200 rounded-xl shadow-sm", children: [
        /* @__PURE__ */ x("div", { children: [
          /* @__PURE__ */ f("div", { className: "text-xs text-slate-500 font-bold uppercase tracking-wider mb-1", children: "Priority Level" }),
          /* @__PURE__ */ x("div", { className: "text-3xl font-mono font-bold text-slate-900", children: [
            "P",
            e.priority
          ] })
        ] }),
        /* @__PURE__ */ x("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__ */ x("div", { className: "grid grid-cols-2 gap-4", children: [
      /* @__PURE__ */ x("div", { children: [
        /* @__PURE__ */ f("label", { htmlFor: "logic-time", className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Time Schedule" }),
        /* @__PURE__ */ x("div", { className: "relative", children: [
          /* @__PURE__ */ f(mr, { 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: (c) => r("time", c.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__ */ x("div", { children: [
        /* @__PURE__ */ f("span", { className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Inheritance Direction" }),
        /* @__PURE__ */ x("div", { className: "flex bg-slate-100 p-1 rounded-lg", children: [
          /* @__PURE__ */ x(
            "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(z0, { size: 12 }),
                " Bottom Up"
              ]
            }
          ),
          /* @__PURE__ */ x(
            "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(F0, { size: 12 }),
                " Top Down"
              ]
            }
          )
        ] })
      ] })
    ] }),
    /* @__PURE__ */ x("div", { children: [
      /* @__PURE__ */ f("label", { htmlFor: "logic-location", className: "text-xs font-semibold text-slate-500 mb-1 block", children: "Location Context" }),
      /* @__PURE__ */ x("div", { className: "relative", children: [
        /* @__PURE__ */ f(Jp, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", size: 14 }),
        /* @__PURE__ */ x(
          "select",
          {
            id: "logic-location",
            value: `${e.locationGroup.groupId}|${e.locationGroup.nodeId}`,
            onChange: (c) => a(c.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..." }),
              n.map((c) => /* @__PURE__ */ f("option", { value: `${c.groupId}|${c.id}`, children: c.name }, c.id))
            ]
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ x("div", { children: [
      /* @__PURE__ */ x("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__ */ x(
          "button",
          {
            onClick: i,
            className: "text-xs text-teal-600 hover:text-teal-700 font-medium flex items-center gap-1",
            children: [
              /* @__PURE__ */ f(vr, { size: 12 }),
              " Add"
            ]
          }
        )
      ] }),
      /* @__PURE__ */ x("div", { className: "space-y-2", children: [
        (e.approvalGroups || []).map((c, l) => /* @__PURE__ */ x("div", { className: "flex gap-2 items-start", children: [
          /* @__PURE__ */ f(
            "select",
            {
              value: `${c.groupId}|${c.nodeId}`,
              onChange: (u) => s(l, "combined", u.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: t.map((u) => /* @__PURE__ */ f("option", { value: `${u.groupId}|${u.id}`, children: u.name }, u.id))
            }
          ),
          /* @__PURE__ */ x(
            "select",
            {
              value: c.type,
              onChange: (u) => s(l, "type", u.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: ar.Room, children: "Room" }),
                /* @__PURE__ */ f("option", { value: ar.Area, children: "Area" }),
                /* @__PURE__ */ f("option", { value: ar.Global, children: "Global" })
              ]
            }
          ),
          /* @__PURE__ */ f(
            "button",
            {
              onClick: () => o(l),
              className: "p-2 text-slate-400 hover:text-red-500 transition-colors",
              children: /* @__PURE__ */ f(Ae, { size: 14 })
            }
          )
        ] }, `${c.groupId}-${c.nodeId}-${c.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" })
      ] })
    ] })
  ] });
}, Pm = ({
  node: e,
  handleUpdate: r,
  inheritedResources: n,
  resourceStatusMap: t,
  resourceMap: a,
  systemMap: i,
  planMap: o,
  loading: s,
  onAddResourceRequest: c
}) => {
  const l = (p) => {
    const q = e.resources.filter((g, v) => v !== p);
    r("resources", q);
  }, u = (p) => a.get(p), d = (p) => i.get(p), h = (p) => p ? o.get(p) : void 0;
  return /* @__PURE__ */ x("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ x("div", { className: "grid grid-cols-2 gap-3", children: [
      /* @__PURE__ */ x("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__ */ x("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: n.length }),
        /* @__PURE__ */ f("div", { className: "text-xs text-indigo-600 font-medium", children: "Inherited" })
      ] })
    ] }),
    /* @__PURE__ */ x("div", { children: [
      /* @__PURE__ */ x("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__ */ x(
          "button",
          {
            onClick: c,
            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(vr, { size: 12 }),
              " Add Resource"
            ]
          }
        )
      ] }),
      /* @__PURE__ */ x("div", { className: "space-y-2", children: [
        e.resources.map((p, q) => {
          const g = t.get(p.resourceId), v = (g == null ? void 0 : g.priority) === e.priority, b = u(p.resourceId), m = d(p.systemId), y = h(p.resourcePlanId);
          return /* @__PURE__ */ x("div", { className: `p-3 rounded-lg border flex flex-col group transition-all ${v ? "bg-white border-slate-200 shadow-sm" : "bg-slate-50 border-slate-100 opacity-60"}`, children: [
            /* @__PURE__ */ x("div", { className: "flex items-center justify-between mb-1", children: [
              /* @__PURE__ */ x("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 }),
                v && /* @__PURE__ */ f("span", { title: "Active (Winning Priority)", children: /* @__PURE__ */ f(dm, { size: 14, className: "text-teal-500" }) })
              ] }),
              /* @__PURE__ */ f(
                "button",
                {
                  onClick: () => l(q),
                  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(Ye, { size: 14 })
                }
              )
            ] }),
            (b == null ? void 0 : b.description) && /* @__PURE__ */ f("div", { className: "text-xs text-slate-500 mb-2 italic", children: b.description }),
            /* @__PURE__ */ x("div", { className: "grid grid-cols-2 gap-2 mt-1", children: [
              /* @__PURE__ */ x("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(dr, { size: 10, className: "text-slate-400" }),
                /* @__PURE__ */ f("span", { className: "truncate", children: s ? "..." : (m == null ? void 0 : m.name) || p.systemId })
              ] }),
              /* @__PURE__ */ x("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(mr, { 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." })
      ] })
    ] }),
    n.length > 0 && /* @__PURE__ */ x("div", { children: [
      /* @__PURE__ */ x("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: n.length })
      ] }),
      /* @__PURE__ */ f("div", { className: "space-y-2 opacity-80", children: n.map((p, q) => {
        const g = t.get(p.resourceId), v = (g == null ? void 0 : g.priority) === p.sourceNodePriority, b = u(p.resourceId);
        return /* @__PURE__ */ f("div", { className: `p-3 rounded-lg border border-slate-100 flex items-center justify-between ${v ? "bg-indigo-50/50" : "bg-slate-50 opacity-60"}`, children: /* @__PURE__ */ x("div", { className: "flex-1 min-w-0", children: [
          /* @__PURE__ */ x("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 }),
            v ? /* @__PURE__ */ f("span", { title: "Winning Inherited Resource", children: /* @__PURE__ */ f(ym, { size: 12, className: "text-indigo-500" }) }) : /* @__PURE__ */ f("span", { title: "Overridden by higher priority", children: /* @__PURE__ */ f(kp, { size: 12, className: "text-slate-300" }) })
          ] }),
          /* @__PURE__ */ x("div", { className: "text-xs text-indigo-400 flex items-center gap-1", children: [
            /* @__PURE__ */ f(V0, { size: 10 }),
            "Inherited from: ",
            /* @__PURE__ */ f("span", { className: "font-semibold", children: p.sourceNodeName }),
            " (P",
            p.sourceNodePriority,
            ")"
          ] })
        ] }) }, `inh-${p.resourceId}`);
      }) })
    ] })
  ] });
}, Lm = ({
  node: e,
  handleUpdate: r,
  testamentTypeMap: n,
  loading: t,
  repositoryAvailable: a,
  onAddRequirementRequest: i
}) => {
  const o = e.requirements || [], s = (c) => {
    r("requirements", o.filter((l, u) => u !== c));
  };
  return /* @__PURE__ */ x("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ x("div", { className: "grid grid-cols-2 gap-3", children: [
      /* @__PURE__ */ x("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__ */ x("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: n.size }),
        /* @__PURE__ */ f("div", { className: "text-xs text-slate-500 font-medium", children: "Resolved Names" })
      ] })
    ] }),
    /* @__PURE__ */ x("div", { children: [
      /* @__PURE__ */ x("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__ */ x(
          "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(vr, { size: 12 }),
              " Add Requirement"
            ]
          }
        )
      ] }),
      !a && /* @__PURE__ */ x("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(Je, { size: 14, className: "mt-0.5 flex-shrink-0" }),
        /* @__PURE__ */ f("span", { children: "Testament type repository is not configured." })
      ] }),
      /* @__PURE__ */ x("div", { className: "space-y-2", children: [
        o.map((c, l) => {
          const u = n.get(c.testamentTypeId);
          return /* @__PURE__ */ f("div", { className: "p-3 rounded-lg border border-slate-200 bg-white shadow-sm group transition-all", children: /* @__PURE__ */ x("div", { className: "flex items-start justify-between gap-3", children: [
            /* @__PURE__ */ x("div", { className: "flex items-start gap-2 min-w-0", children: [
              /* @__PURE__ */ f(To, { size: 16, className: "text-teal-600 mt-0.5 flex-shrink-0" }),
              /* @__PURE__ */ x("div", { className: "min-w-0", children: [
                /* @__PURE__ */ x("div", { className: "flex items-center gap-2", children: [
                  /* @__PURE__ */ f("span", { className: "font-semibold text-sm text-slate-900 truncate", title: c.testamentTypeId, children: t ? "Loading..." : (u == null ? void 0 : u.name) || c.testamentTypeId }),
                  (u == null ? void 0 : u.isDeprecated) && /* @__PURE__ */ f("span", { className: "text-[10px] bg-amber-50 text-amber-700 px-1.5 rounded border border-amber-200", children: "Deprecated" })
                ] }),
                (u == null ? void 0 : u.description) && /* @__PURE__ */ f("div", { className: "text-xs text-slate-500 mt-1 line-clamp-2", children: u.description }),
                /* @__PURE__ */ x("div", { className: "flex flex-wrap gap-1.5 mt-2 text-[10px] text-slate-500", children: [
                  (u == null ? void 0 : u.category) && /* @__PURE__ */ f("span", { className: "bg-slate-100 px-1.5 py-0.5 rounded border border-slate-200", children: u.category }),
                  (u == null ? void 0 : u.requiresDocument) && /* @__PURE__ */ f("span", { className: "bg-indigo-50 text-indigo-700 px-1.5 py-0.5 rounded border border-indigo-100", children: "Document" }),
                  (u == null ? void 0 : u.isRenewable) && /* @__PURE__ */ x("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(am, { 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(Ye, { size: 14 })
              }
            )
          ] }) }, `${c.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." })
      ] })
    ] })
  ] });
}, Dm = ({ node: e, handleUpdate: r }) => {
  const [n, t] = B(null), [a, i] = B("");
  oe(() => {
    i(JSON.stringify(e.configuration, null, 2)), t(null);
  }, [e.configuration]);
  const o = (s) => {
    i(s);
    try {
      const c = JSON.parse(s);
      r("configuration", c), t(null);
    } catch {
      t("Invalid JSON");
    }
  };
  return /* @__PURE__ */ x("div", { className: "h-full flex flex-col animate-in fade-in slide-in-from-bottom-2 duration-300", children: [
    /* @__PURE__ */ x("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__ */ x("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 ${n ? "border-red-500 focus:border-red-500 bg-red-50" : "border-slate-300 focus:border-teal-500 bg-slate-50"}`
        }
      ),
      n && /* @__PURE__ */ x("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(Je, { size: 14 }),
        n
      ] })
    ] })
  ] });
}, Ir = ({ id: e, label: r, icon: n, activeTab: t, onSelect: a }) => /* @__PURE__ */ x(
  "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 ${t === e ? "border-teal-600 text-teal-700" : "border-transparent text-slate-500 hover:text-slate-700 hover:border-slate-300"}`,
    children: [
      n,
      r
    ]
  }
), jm = ({ node: e, allNodes: r, onClose: n, onUpdate: t, onAddResourceRequest: a, onAddRequirementRequest: i }) => {
  const o = op(), [s, c] = B("general"), l = !!o.testamentTypes, [u, d] = B([]), [h, p] = B([]), [q, g] = B({
    resourceMap: /* @__PURE__ */ new Map(),
    systemMap: /* @__PURE__ */ new Map(),
    planMap: /* @__PURE__ */ new Map(),
    testamentTypeMap: /* @__PURE__ */ new Map(),
    loading: !1,
    requirementsLoading: !1
  });
  oe(() => {
    (async () => {
      try {
        const [w, N] = await Promise.all([
          o.getLocations({ pageSize: 100 }),
          o.getApprovalGroups({ pageSize: 100 })
        ]);
        d(w.items), p(N.items);
      } catch (w) {
        console.error("Failed to load options", w);
      }
    })();
  }, [o]), oe(() => {
    e && (async () => {
      g((_) => ({ ..._, loading: !0 }));
      const w = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set();
      if ([...e.resources, ...e._inheritedResources || []].forEach((_) => {
        w.add(_.resourceId), _.systemId && N.add(_.systemId), _.resourcePlanId && I.add(_.resourcePlanId);
      }), w.size > 0 || N.size > 0 || I.size > 0) {
        const [_, R, k] = await Promise.all([
          o.resolveResources(Array.from(w)),
          o.resolveSystems(Array.from(N)),
          o.resolvePlans(Array.from(I))
        ]);
        g((S) => ({ ...S, resourceMap: _, systemMap: R, planMap: k, loading: !1 }));
      } else
        g((_) => ({ ..._, loading: !1 }));
    })();
  }, [e == null ? void 0 : e.scheduleId, e == null ? void 0 : e.resources, e == null ? void 0 : e._inheritedResources, o]), oe(() => {
    if (!e || !o.testamentTypes) return;
    (async () => {
      const w = Array.from(new Set((e.requirements || []).map((N) => N.testamentTypeId).filter(Boolean)));
      if (w.length === 0) {
        g((N) => ({ ...N, testamentTypeMap: /* @__PURE__ */ new Map(), requirementsLoading: !1 }));
        return;
      }
      g((N) => ({ ...N, requirementsLoading: !0 }));
      try {
        const N = await o.testamentTypes.resolve(w);
        g((I) => ({
          ...I,
          testamentTypeMap: new Map(N.map((_) => [_.testamentTypeId, _])),
          requirementsLoading: !1
        }));
      } catch (N) {
        console.error("Failed to resolve testament types", N), g((I) => ({ ...I, requirementsLoading: !1 }));
      }
    })();
  }, [e == null ? void 0 : e.scheduleId, e == null ? void 0 : e.requirements, o]), oe(() => {
    !l && s === "requirements" && c("general");
  }, [s, l]);
  const v = ge(() => {
    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 N = y.get(w.resourceId);
      (!N || w.sourceNodePriority > N.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) => {
    t(e.scheduleId, y, w);
  }, m = (y) => {
    if (!y) return "";
    const w = r.find((N) => N.scheduleId === y);
    return w ? w.name : y;
  };
  return /* @__PURE__ */ f(lr, { children: /* @__PURE__ */ x("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__ */ x("div", { className: "p-6 pb-0 flex-none", children: [
      /* @__PURE__ */ x("div", { className: "flex items-center justify-between mb-4", children: [
        /* @__PURE__ */ x("div", { children: [
          /* @__PURE__ */ f("h2", { className: "text-xl font-bold text-slate-900", children: "Edit Schedule" }),
          /* @__PURE__ */ x("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__ */ x("div", { className: "flex items-center gap-1", children: [
          /* @__PURE__ */ f(
            "button",
            {
              onClick: () => c("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(Pr, { size: 18 })
            }
          ),
          /* @__PURE__ */ f("button", { onClick: n, className: "p-2 hover:bg-slate-100 rounded-full text-slate-500 hover:text-teal-600 transition-colors", children: /* @__PURE__ */ f(Ae, { size: 20 }) })
        ] })
      ] }),
      /* @__PURE__ */ x("div", { className: "flex gap-3 border-b border-slate-200 overflow-x-auto", children: [
        /* @__PURE__ */ f(Ir, { id: "general", label: "General", icon: /* @__PURE__ */ f(Oo, { size: 14 }), activeTab: s, onSelect: c }),
        /* @__PURE__ */ f(Ir, { id: "logic", label: "Logic", icon: /* @__PURE__ */ f(Qp, { size: 14 }), activeTab: s, onSelect: c }),
        /* @__PURE__ */ f(Ir, { id: "resources", label: "Resources", icon: /* @__PURE__ */ f(dr, { size: 14 }), activeTab: s, onSelect: c }),
        l && /* @__PURE__ */ f(Ir, { id: "requirements", label: "Requirements", icon: /* @__PURE__ */ f(To, { size: 14 }), activeTab: s, onSelect: c })
      ] })
    ] }),
    /* @__PURE__ */ x("div", { className: "flex-1 overflow-y-auto p-6 space-y-8", children: [
      s === "general" && /* @__PURE__ */ f(
        Om,
        {
          node: e,
          handleUpdate: b,
          allNodes: r,
          getScheduleName: m
        }
      ),
      s === "logic" && /* @__PURE__ */ f(
        Mm,
        {
          node: e,
          handleUpdate: b,
          availableLocations: u,
          availableApprovalGroups: h
        }
      ),
      s === "resources" && /* @__PURE__ */ f(
        Pm,
        {
          node: e,
          handleUpdate: b,
          inheritedResources: e._inheritedResources || [],
          resourceStatusMap: v,
          resourceMap: q.resourceMap,
          systemMap: q.systemMap,
          planMap: q.planMap,
          loading: q.loading,
          onAddResourceRequest: a
        }
      ),
      s === "requirements" && /* @__PURE__ */ f(
        Lm,
        {
          node: e,
          handleUpdate: b,
          testamentTypeMap: q.testamentTypeMap,
          loading: q.requirementsLoading,
          repositoryAvailable: l,
          onAddRequirementRequest: i
        }
      ),
      s === "config" && /* @__PURE__ */ f(
        Dm,
        {
          node: e,
          handleUpdate: b
        }
      )
    ] })
  ] }) });
}, Gm = ({ isOpen: e, onClose: r, onConfirm: n, count: t }) => 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__ */ x("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(Je, { size: 24 }) }),
  /* @__PURE__ */ x("h3", { className: "text-lg font-bold text-slate-900 mb-2", children: [
    "Delete ",
    t,
    " Selected Node",
    t !== 1 ? "s" : "",
    "?"
  ] }),
  /* @__PURE__ */ x("p", { className: "text-sm text-slate-500 mb-6", children: [
    "This action cannot be undone. Any connections to ",
    t !== 1 ? "these nodes" : "this node",
    " will also be removed."
  ] }),
  /* @__PURE__ */ x("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__ */ x(
      "button",
      {
        onClick: n,
        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(Ye, { size: 16 }),
          " Delete"
        ]
      }
    )
  ] })
] }) }) }) : null, Fm = (e) => e.isOpen ? /* @__PURE__ */ f(zm, { ...e }) : null, zm = ({ onClose: e, data: r, onSave: n }) => {
  const [t, a] = B(() => ({ ...r })), [i, o] = B(null), [s, c] = B(() => JSON.stringify(r.configuration, null, 2)), l = (d) => {
    c(d);
    try {
      const h = JSON.parse(d);
      a((p) => ({ ...p, configuration: h })), o(null);
    } catch {
      o("Invalid JSON format");
    }
  }, u = () => {
    i || (n(t), 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__ */ x("div", { className: "bg-white rounded-xl shadow-2xl w-full max-w-lg overflow-hidden border border-slate-200", children: [
    /* @__PURE__ */ x("div", { className: "flex items-center justify-between px-6 py-4 border-b border-slate-100 bg-slate-50", children: [
      /* @__PURE__ */ x("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(zp, { 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(Ae, { size: 20 }) })
    ] }),
    /* @__PURE__ */ x("div", { className: "p-6 space-y-5 max-h-[70vh] overflow-y-auto", children: [
      /* @__PURE__ */ x("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: t.name,
            onChange: (d) => a({ ...t, 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__ */ x("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(
          ko,
          {
            id: "gs-tags",
            tags: t.tags,
            onChange: (d) => a({ ...t, tags: d }),
            colorClass: "bg-teal-50 text-teal-700 border-teal-200"
          }
        )
      ] }),
      /* @__PURE__ */ x("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__ */ x("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__ */ x(
        "button",
        {
          onClick: u,
          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(H0, { size: 16 }),
            " Save Changes"
          ]
        }
      )
    ] })
  ] }) });
}, Bm = (e) => e.isOpen ? /* @__PURE__ */ f(Um, { ...e }) : null, Um = ({ onClose: e, onConfirm: r, repositories: n }) => {
  const [t, a] = B(1), [i, o] = B(/* @__PURE__ */ new Set()), [s, c] = B(""), [l, u] = B({}), [d, h] = B(""), [p, q] = B([]), [g, v] = B([]), [b, m] = B(/* @__PURE__ */ new Map()), [y, w] = B(!1), N = _e(null);
  oe(() => {
    I(), _("");
  }, []);
  const I = async () => {
    try {
      const M = await n.getPlans({ pageSize: 100 });
      v(M.items);
    } catch (M) {
      console.error("Failed to fetch plans", M);
    }
  }, _ = async (M) => {
    w(!0);
    try {
      const G = await n.getResources({
        filter: M,
        pageSize: 1e3
        // Increase page size now that we have virtualization
      });
      q(G.items);
      const D = /* @__PURE__ */ new Set();
      if (G.items.forEach(($) => {
        $.systemId && D.add($.systemId);
      }), D.size > 0) {
        const $ = await n.resolveSystems(Array.from(D));
        m((le) => new Map([...le, ...$]));
      }
    } catch (G) {
      console.error("Failed to fetch resources", G);
    } finally {
      w(!1);
    }
  }, R = (M) => {
    const G = M.target.value;
    c(G), N.current && clearTimeout(N.current), N.current = setTimeout(() => {
      _(G);
    }, 300);
  }, k = (M) => {
    const G = new Set(i);
    if (G.has(M)) {
      G.delete(M);
      const D = { ...l };
      delete D[M], u(D);
    } else
      G.add(M), u((D) => ({
        ...D,
        [M]: { planId: "" }
        // Initialize empty config
      }));
    o(G);
  }, S = (M, G, D) => {
    u(($) => ({
      ...$,
      [M]: {
        ...$[M],
        [G]: D
      }
    }));
  }, E = (M) => {
    if (h(M), !M) return;
    const G = g.find((D) => D.id === M);
    G && u((D) => {
      const $ = { ...D };
      return i.forEach((le) => {
        const de = p.find((ne) => ne.id === le);
        de && de.systemId === G.systemId && de.resourceKind !== ue.Fixed && $[le] && ($[le] = { ...$[le], planId: M });
      }), $;
    });
  }, A = (M) => {
    const G = new Set(i);
    G.delete(M), o(G);
    const D = { ...l };
    delete D[M], u(D), G.size === 0 && a(1);
  }, P = () => {
    const M = [];
    i.forEach((G) => {
      const D = l[G], $ = p.find((le) => le.id === G);
      $ && $.systemId && ($.resourceKind === ue.Fixed ? M.push({
        systemId: $.systemId,
        resourceId: G,
        resourcePlanId: null
        // Fixed resources do not need a plan
      }) : D && D.planId && M.push({
        systemId: $.systemId,
        resourceId: G,
        resourcePlanId: D.planId
      }));
    }), r(M), e();
  }, z = () => Array.from(i).every((M) => {
    const G = p.find(($) => $.id === M);
    if ((G == null ? void 0 : G.resourceKind) === ue.Fixed) return !0;
    const D = l[M];
    return D && D.planId;
  }), F = (M) => {
    if (!M) return "Unknown";
    const G = b.get(M);
    return G ? G.name : M;
  }, J = ge(() => {
    const M = /* @__PURE__ */ new Map();
    return g.forEach((G) => {
      var $;
      const D = G.systemId;
      M.has(D) || M.set(D, []), ($ = M.get(D)) == null || $.push(G);
    }), M;
  }, [g]);
  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__ */ x("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__ */ x("div", { className: "px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50", children: [
      /* @__PURE__ */ x("div", { children: [
        /* @__PURE__ */ f("h2", { className: "text-lg font-bold text-slate-900", children: "Add Resources" }),
        /* @__PURE__ */ x("div", { className: "flex items-center gap-2 text-xs text-slate-500 mt-1", children: [
          /* @__PURE__ */ f("span", { className: t === 1 ? "text-teal-600 font-semibold" : "", children: "1. Select Resources" }),
          /* @__PURE__ */ f("span", { className: "text-slate-300", children: "/" }),
          /* @__PURE__ */ f("span", { className: t === 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(Ae, { size: 20 }) })
    ] }),
    /* @__PURE__ */ x("div", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
      t === 1 && /* @__PURE__ */ x(lr, { children: [
        /* @__PURE__ */ x("div", { className: "p-4 border-b border-slate-100 flex gap-4 bg-white flex-shrink-0", children: [
          /* @__PURE__ */ x("div", { className: "relative flex-1", children: [
            /* @__PURE__ */ f(We, { 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(U0, { size: 16, className: "animate-spin text-teal-600" }) : /* @__PURE__ */ x(lr, { children: [
            /* @__PURE__ */ f(Mo, { size: 16 }),
            /* @__PURE__ */ x("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__ */ x("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__ */ x("div", { className: "flex-1 overflow-hidden bg-slate-50 relative", children: [
          p.length === 0 && !y && /* @__PURE__ */ x("div", { className: "absolute inset-0 flex flex-col items-center justify-center text-slate-400", children: [
            /* @__PURE__ */ f(We, { size: 32, className: "mx-auto mb-2 opacity-20" }),
            'No resources found matching "',
            s,
            '"'
          ] }),
          /* @__PURE__ */ f(
            Ar,
            {
              items: p,
              height: "100%",
              itemHeight: 64,
              renderItem: (M, G) => {
                const D = i.has(M.id);
                return /* @__PURE__ */ x(
                  "div",
                  {
                    role: "button",
                    tabIndex: 0,
                    onClick: () => k(M.id),
                    onKeyDown: ($) => {
                      ($.key === "Enter" || $.key === " ") && ($.preventDefault(), k(M.id));
                    },
                    className: `
                                            flex items-center text-sm border-b border-slate-100 cursor-pointer transition-colors h-[64px]
                                            ${D ? "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
                                                ${D ? "bg-teal-500 border-teal-500 text-white" : "border-slate-300 bg-white"}
                                            `, children: D && /* @__PURE__ */ f(Er, { size: 10, strokeWidth: 4 }) }) }),
                      /* @__PURE__ */ x("div", { className: "px-4 flex-1 min-w-0", children: [
                        /* @__PURE__ */ f("div", { className: `font-medium truncate ${D ? "text-teal-900" : "text-slate-900"}`, children: M.name }),
                        /* @__PURE__ */ x("div", { className: "flex gap-2 text-[10px] mt-1", children: [
                          /* @__PURE__ */ f("span", { className: "font-mono text-slate-400", children: M.id }),
                          /* @__PURE__ */ f("span", { className: "bg-slate-100 px-1 rounded text-slate-500 border border-slate-200", children: M.resourceKind })
                        ] })
                      ] }),
                      /* @__PURE__ */ f("div", { className: "px-4 w-[25%] hidden md:block text-slate-500 truncate", children: M.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: M.resourceType }),
                      /* @__PURE__ */ x("div", { className: "px-4 w-[20%] flex items-center gap-1.5 text-slate-600 truncate", children: [
                        /* @__PURE__ */ f(dr, { size: 14, className: "text-slate-400 flex-shrink-0" }),
                        /* @__PURE__ */ f("span", { className: "truncate", children: F(M.systemId) })
                      ] })
                    ]
                  },
                  M.id
                );
              }
            }
          )
        ] })
      ] }),
      t === 2 && /* @__PURE__ */ x("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__ */ x("div", { className: "flex items-center gap-4", children: [
          /* @__PURE__ */ x("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__ */ x("div", { className: "relative", children: [
            /* @__PURE__ */ f(Pr, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", size: 14 }),
            /* @__PURE__ */ x(
              "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: (M) => E(M.target.value),
                children: [
                  /* @__PURE__ */ f("option", { value: "", children: "Select Plan..." }),
                  Array.from(J.keys()).map((M) => {
                    const G = F(M), D = J.get(M) || [];
                    return /* @__PURE__ */ f("optgroup", { label: G, children: D.map(($) => /* @__PURE__ */ f("option", { value: $.id, children: $.name }, $.id)) }, M);
                  })
                ]
              }
            )
          ] }) })
        ] }) }),
        /* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto p-4 relative", children: /* @__PURE__ */ x("div", { className: "bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden h-full flex flex-col", children: [
          /* @__PURE__ */ x("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(
            Ar,
            {
              items: Array.from(i),
              height: "100%",
              itemHeight: 64,
              renderItem: (M, G) => {
                const D = p.find((ne) => ne.id === M), $ = l[M] || { planId: "" }, le = (D == null ? void 0 : D.resourceKind) === ue.Fixed, de = g.filter((ne) => ne.systemId === (D == null ? void 0 : D.systemId));
                return /* @__PURE__ */ x("div", { className: "flex items-center text-sm border-b border-slate-100 h-[64px] bg-white group hover:bg-slate-50", children: [
                  /* @__PURE__ */ x("div", { className: "px-4 w-[40%]", children: [
                    /* @__PURE__ */ f("div", { className: "font-medium text-slate-900 truncate", children: (D == null ? void 0 : D.name) || M }),
                    /* @__PURE__ */ x("div", { className: "flex gap-2 text-[10px] mt-0.5", children: [
                      /* @__PURE__ */ f("span", { className: "text-slate-400 font-mono", children: M }),
                      /* @__PURE__ */ f("span", { className: "bg-slate-100 px-1 rounded text-slate-500 border border-slate-200", children: D == null ? void 0 : D.resourceKind })
                    ] })
                  ] }),
                  /* @__PURE__ */ f("div", { className: "px-4 w-[25%]", children: /* @__PURE__ */ x("div", { className: "flex items-center gap-1.5 text-slate-500 text-xs truncate", children: [
                    /* @__PURE__ */ f(dr, { size: 12, className: "text-slate-400 flex-shrink-0" }),
                    /* @__PURE__ */ f("span", { className: "truncate", children: F(D == null ? void 0 : D.systemId) })
                  ] }) }),
                  /* @__PURE__ */ f("div", { className: "px-4 w-[30%]", children: le ? /* @__PURE__ */ x("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__ */ x(
                    "select",
                    {
                      className: `w-full p-2 border rounded-lg text-xs focus:outline-none focus:border-teal-500 transition-colors ${$.planId ? "border-slate-200" : "border-red-200 bg-red-50 text-red-800"}`,
                      value: $.planId,
                      onChange: (ne) => S(M, "planId", ne.target.value),
                      disabled: de.length === 0,
                      children: [
                        /* @__PURE__ */ f("option", { value: "", children: de.length === 0 ? "No plans" : "Select Plan..." }),
                        de.map((ne) => /* @__PURE__ */ x("option", { value: ne.id, children: [
                          ne.name,
                          " (P",
                          ne.priority,
                          ")"
                        ] }, ne.id))
                      ]
                    }
                  ) }),
                  /* @__PURE__ */ f("div", { className: "px-4 flex-1 text-right", children: /* @__PURE__ */ f(
                    "button",
                    {
                      onClick: () => A(M),
                      className: "p-2 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors",
                      title: "Remove",
                      children: /* @__PURE__ */ f(Ye, { size: 16 })
                    }
                  ) })
                ] }, M);
              }
            }
          ) })
        ] }) })
      ] })
    ] }),
    /* @__PURE__ */ x("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__ */ x("span", { className: "font-medium text-slate-900", children: [
        i.size,
        " resources selected"
      ] }) }),
      /* @__PURE__ */ x("div", { className: "flex gap-3", children: [
        t === 2 && /* @__PURE__ */ x(
          "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(G0, { size: 16 }),
              " Back"
            ]
          }
        ),
        t === 1 ? /* @__PURE__ */ x(
          "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(gp, { size: 16 })
            ]
          }
        ) : /* @__PURE__ */ x(
          "button",
          {
            onClick: P,
            disabled: !z(),
            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(Tp, { size: 18 }),
              " Confirm & Add Resources"
            ]
          }
        )
      ] })
    ] })
  ] }) });
}, $m = (e) => e.isOpen ? /* @__PURE__ */ f(Hm, { ...e }) : null, Hm = ({
  onClose: e,
  onConfirm: r,
  repository: n,
  excludedIds: t
}) => {
  const [a, i] = B(""), [o, s] = B([]), [c, l] = B(/* @__PURE__ */ new Set()), [u, d] = B(!1), h = _e(null), p = new Set(t);
  oe(() => (q(""), () => {
    h.current && clearTimeout(h.current);
  }), []);
  const q = async (m) => {
    if (n) {
      d(!0);
      try {
        const y = await n.search(m);
        s(y);
      } catch (y) {
        console.error("Failed to fetch testament types", y);
      } finally {
        d(!1);
      }
    }
  }, g = (m) => {
    const y = m.target.value;
    i(y), h.current && clearTimeout(h.current), h.current = setTimeout(() => {
      q(y);
    }, 300);
  }, v = (m) => {
    if (p.has(m)) return;
    const y = new Set(c);
    y.has(m) ? y.delete(m) : y.add(m), l(y);
  }, b = () => {
    r(o.filter((m) => c.has(m.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__ */ x("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__ */ x("div", { className: "px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50", children: [
      /* @__PURE__ */ x("div", { children: [
        /* @__PURE__ */ f("h2", { className: "text-lg font-bold text-slate-900", children: "Add Requirements" }),
        /* @__PURE__ */ x("div", { className: "text-xs text-slate-500 mt-1", children: [
          c.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(Ae, { size: 20 }) })
    ] }),
    /* @__PURE__ */ x("div", { className: "p-4 border-b border-slate-100 flex gap-4 bg-white flex-shrink-0", children: [
      /* @__PURE__ */ x("div", { className: "relative flex-1", children: [
        /* @__PURE__ */ f(We, { 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: g
          }
        )
      ] }),
      /* @__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: u ? /* @__PURE__ */ f(U0, { size: 16, className: "animate-spin text-teal-600" }) : /* @__PURE__ */ x(lr, { children: [
        /* @__PURE__ */ f(Mo, { size: 16 }),
        /* @__PURE__ */ x("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__ */ x("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__ */ x("div", { className: "flex-1 overflow-hidden bg-slate-50 relative", children: [
      o.length === 0 && !u && /* @__PURE__ */ x("div", { className: "absolute inset-0 flex flex-col items-center justify-center text-slate-400", children: [
        /* @__PURE__ */ f(We, { size: 32, className: "mx-auto mb-2 opacity-20" }),
        'No testament types found matching "',
        a,
        '"'
      ] }),
      /* @__PURE__ */ f(
        Ar,
        {
          items: o,
          height: "100%",
          itemHeight: 72,
          renderItem: (m) => {
            const y = m.testamentTypeId, w = c.has(y), N = p.has(y);
            return /* @__PURE__ */ x(
              "div",
              {
                role: "button",
                tabIndex: N ? -1 : 0,
                onClick: () => v(y),
                onKeyDown: (I) => {
                  (I.key === "Enter" || I.key === " ") && (I.preventDefault(), v(y));
                },
                className: `
                    flex items-center text-sm border-b border-slate-100 h-[72px] transition-colors
                    ${N ? "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(Er, { size: 10, strokeWidth: 4 }) }) }),
                  /* @__PURE__ */ x("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: m.name }),
                    /* @__PURE__ */ x("div", { className: "flex gap-2 text-[10px] mt-1", children: [
                      /* @__PURE__ */ f("span", { className: "font-mono text-slate-400", children: y }),
                      N && /* @__PURE__ */ f("span", { className: "bg-slate-200 px-1 rounded text-slate-500 border border-slate-300", children: "Already added" }),
                      m.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: m.category || /* @__PURE__ */ f("span", { className: "text-slate-300 italic", children: "Uncategorized" }) }),
                  /* @__PURE__ */ x("div", { className: "px-4 w-[25%] flex flex-wrap gap-1.5 text-[10px] text-slate-500", children: [
                    m.requiresDocument && /* @__PURE__ */ x("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(To, { size: 9 }),
                      " Document"
                    ] }),
                    m.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__ */ x("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: c.size > 0 && /* @__PURE__ */ x("span", { className: "font-medium text-slate-900", children: [
        c.size,
        " requirements selected"
      ] }) }),
      /* @__PURE__ */ x("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__ */ x(
          "button",
          {
            onClick: b,
            disabled: c.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(Er, { size: 18 }),
              " Add Requirements"
            ]
          }
        )
      ] })
    ] })
  ] }) });
}, Vm = ({ x: e, y: r, items: n, onClose: t }) => {
  const a = _e(null);
  return oe(() => {
    const i = (o) => {
      a.current && !a.current.contains(o.target) && t();
    };
    return document.addEventListener("mousedown", i), () => document.removeEventListener("mousedown", i);
  }, [t]), /* @__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: n.map((i) => /* @__PURE__ */ f(Ro.Fragment, { children: /* @__PURE__ */ x(
        "button",
        {
          onClick: () => {
            i.disabled || (i.onClick(), t());
          },
          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))
    }
  );
}, Km = ({ nodes: e, onSelectNode: r }) => {
  const [n, t] = B(""), [a, i] = B(0), [o, s] = B(!0), c = _e(null), { setCenter: l, setNodes: u } = Eo(), d = ge(() => {
    if (!n.trim()) return [];
    const b = n.toLowerCase();
    return e.filter((m) => {
      const y = m.data;
      return y.name.toLowerCase().includes(b) || y.purpose.toLowerCase().includes(b) || y.group.toLowerCase().includes(b);
    });
  }, [e, n]);
  oe(() => {
    const b = (m) => {
      var y;
      (m.ctrlKey || m.metaKey) && m.key === "f" && (m.preventDefault(), s(!0), (y = c.current) == null || y.focus());
    };
    return window.addEventListener("keydown", b), () => window.removeEventListener("keydown", b);
  }, []);
  const h = (b, m = !1) => {
    const y = d[b];
    if (!y) return;
    r(y.data), u(
      (I) => I.map((_) => ({
        ..._,
        selected: _.id === y.id
      }))
    );
    const w = y.position.x + 140, N = y.position.y + 60;
    l(w, N, {
      zoom: 1.2,
      duration: m ? 800 : 600
    });
  }, p = (b) => {
    const m = b.target.value;
    t(m), i(0);
  };
  oe(() => {
    d.length > 0 && n && h(a, !0);
  }, [n]);
  const q = (b) => {
    if (b == null || b.preventDefault(), d.length === 0) return;
    const m = (a + 1) % d.length;
    i(m), h(m, !1);
  }, g = (b) => {
    if (b == null || b.preventDefault(), d.length === 0) return;
    const m = (a - 1 + d.length) % d.length;
    i(m), h(m, !1);
  }, v = (b) => {
    var m;
    b.key === "Enter" && q(), b.key === "Escape" && (t(""), (m = c.current) == null || m.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__ */ x("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(We, { size: 18 }) }),
    /* @__PURE__ */ f(
      "input",
      {
        ref: c,
        type: "text",
        value: n,
        onChange: p,
        onKeyDown: v,
        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"
      }
    ),
    n && /* @__PURE__ */ x("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__ */ x("div", { className: "flex", children: [
        /* @__PURE__ */ f(
          "button",
          {
            onClick: g,
            disabled: d.length <= 1,
            className: "p-1 text-slate-400 hover:text-teal-600 disabled:opacity-30 rounded transition-colors",
            children: /* @__PURE__ */ f(G0, { size: 14 })
          }
        ),
        /* @__PURE__ */ f(
          "button",
          {
            onClick: q,
            disabled: d.length <= 1,
            className: "p-1 text-slate-400 hover:text-teal-600 disabled:opacity-30 rounded transition-colors",
            children: /* @__PURE__ */ f(Np, { size: 14 })
          }
        )
      ] }),
      /* @__PURE__ */ f(
        "button",
        {
          onClick: () => t(""),
          className: "p-1 text-slate-400 hover:text-red-500 rounded transition-colors",
          children: /* @__PURE__ */ f(Ae, { size: 14 })
        }
      )
    ] })
  ] }) }) : null;
};
var kr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Wm(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function Po(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 it, ic;
function Ym() {
  if (ic) return it;
  ic = 1;
  function e() {
    this.__data__ = [], this.size = 0;
  }
  return it = e, it;
}
var st, sc;
function Ze() {
  if (sc) return st;
  sc = 1;
  function e(r, n) {
    return r === n || r !== r && n !== n;
  }
  return st = e, st;
}
var ot, oc;
function Lr() {
  if (oc) return ot;
  oc = 1;
  var e = Ze();
  function r(n, t) {
    for (var a = n.length; a--; )
      if (e(n[a][0], t))
        return a;
    return -1;
  }
  return ot = r, ot;
}
var ct, cc;
function Jm() {
  if (cc) return ct;
  cc = 1;
  var e = Lr(), r = Array.prototype, n = r.splice;
  function t(a) {
    var i = this.__data__, o = e(i, a);
    if (o < 0)
      return !1;
    var s = i.length - 1;
    return o == s ? i.pop() : n.call(i, o, 1), --this.size, !0;
  }
  return ct = t, ct;
}
var ut, uc;
function Zm() {
  if (uc) return ut;
  uc = 1;
  var e = Lr();
  function r(n) {
    var t = this.__data__, a = e(t, n);
    return a < 0 ? void 0 : t[a][1];
  }
  return ut = r, ut;
}
var lt, lc;
function Xm() {
  if (lc) return lt;
  lc = 1;
  var e = Lr();
  function r(n) {
    return e(this.__data__, n) > -1;
  }
  return lt = r, lt;
}
var dt, dc;
function Qm() {
  if (dc) return dt;
  dc = 1;
  var e = Lr();
  function r(n, t) {
    var a = this.__data__, i = e(a, n);
    return i < 0 ? (++this.size, a.push([n, t])) : a[i][1] = t, this;
  }
  return dt = r, dt;
}
var ft, fc;
function Dr() {
  if (fc) return ft;
  fc = 1;
  var e = Ym(), r = Jm(), n = Zm(), t = Xm(), a = Qm();
  function i(o) {
    var s = -1, c = o == null ? 0 : o.length;
    for (this.clear(); ++s < c; ) {
      var l = o[s];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = e, i.prototype.delete = r, i.prototype.get = n, i.prototype.has = t, i.prototype.set = a, ft = i, ft;
}
var ht, hc;
function ev() {
  if (hc) return ht;
  hc = 1;
  var e = Dr();
  function r() {
    this.__data__ = new e(), this.size = 0;
  }
  return ht = r, ht;
}
var pt, pc;
function rv() {
  if (pc) return pt;
  pc = 1;
  function e(r) {
    var n = this.__data__, t = n.delete(r);
    return this.size = n.size, t;
  }
  return pt = e, pt;
}
var mt, mc;
function tv() {
  if (mc) return mt;
  mc = 1;
  function e(r) {
    return this.__data__.get(r);
  }
  return mt = e, mt;
}
var vt, vc;
function nv() {
  if (vc) return vt;
  vc = 1;
  function e(r) {
    return this.__data__.has(r);
  }
  return vt = e, vt;
}
var gt, gc;
function J0() {
  if (gc) return gt;
  gc = 1;
  var e = typeof kr == "object" && kr && kr.Object === Object && kr;
  return gt = e, gt;
}
var bt, bc;
function Ne() {
  if (bc) return bt;
  bc = 1;
  var e = J0(), r = typeof self == "object" && self && self.Object === Object && self, n = e || r || Function("return this")();
  return bt = n, bt;
}
var yt, yc;
function Xe() {
  if (yc) return yt;
  yc = 1;
  var e = Ne(), r = e.Symbol;
  return yt = r, yt;
}
var xt, xc;
function av() {
  if (xc) return xt;
  xc = 1;
  var e = Xe(), r = Object.prototype, n = r.hasOwnProperty, t = r.toString, a = e ? e.toStringTag : void 0;
  function i(o) {
    var s = n.call(o, a), c = o[a];
    try {
      o[a] = void 0;
      var l = !0;
    } catch {
    }
    var u = t.call(o);
    return l && (s ? o[a] = c : delete o[a]), u;
  }
  return xt = i, xt;
}
var _t, _c;
function iv() {
  if (_c) return _t;
  _c = 1;
  var e = Object.prototype, r = e.toString;
  function n(t) {
    return r.call(t);
  }
  return _t = n, _t;
}
var wt, wc;
function Fe() {
  if (wc) return wt;
  wc = 1;
  var e = Xe(), r = av(), n = iv(), t = "[object Null]", a = "[object Undefined]", i = e ? e.toStringTag : void 0;
  function o(s) {
    return s == null ? s === void 0 ? a : t : i && i in Object(s) ? r(s) : n(s);
  }
  return wt = o, wt;
}
var Nt, Nc;
function be() {
  if (Nc) return Nt;
  Nc = 1;
  function e(r) {
    var n = typeof r;
    return r != null && (n == "object" || n == "function");
  }
  return Nt = e, Nt;
}
var qt, qc;
function gr() {
  if (qc) return qt;
  qc = 1;
  var e = Fe(), r = be(), n = "[object AsyncFunction]", t = "[object Function]", a = "[object GeneratorFunction]", i = "[object Proxy]";
  function o(s) {
    if (!r(s))
      return !1;
    var c = e(s);
    return c == t || c == a || c == n || c == i;
  }
  return qt = o, qt;
}
var It, Ic;
function sv() {
  if (Ic) return It;
  Ic = 1;
  var e = Ne(), r = e["__core-js_shared__"];
  return It = r, It;
}
var kt, kc;
function ov() {
  if (kc) return kt;
  kc = 1;
  var e = sv(), r = (function() {
    var t = /[^.]+$/.exec(e && e.keys && e.keys.IE_PROTO || "");
    return t ? "Symbol(src)_1." + t : "";
  })();
  function n(t) {
    return !!r && r in t;
  }
  return kt = n, kt;
}
var St, Sc;
function Z0() {
  if (Sc) return St;
  Sc = 1;
  var e = Function.prototype, r = e.toString;
  function n(t) {
    if (t != null) {
      try {
        return r.call(t);
      } catch {
      }
      try {
        return t + "";
      } catch {
      }
    }
    return "";
  }
  return St = n, St;
}
var Rt, Rc;
function cv() {
  if (Rc) return Rt;
  Rc = 1;
  var e = gr(), r = ov(), n = be(), t = Z0(), a = /[\\^$.*+?()[\]{}|]/g, i = /^\[object .+?Constructor\]$/, o = Function.prototype, s = Object.prototype, c = o.toString, l = s.hasOwnProperty, u = RegExp(
    "^" + c.call(l).replace(a, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
  );
  function d(h) {
    if (!n(h) || r(h))
      return !1;
    var p = e(h) ? u : i;
    return p.test(t(h));
  }
  return Rt = d, Rt;
}
var Ct, Cc;
function uv() {
  if (Cc) return Ct;
  Cc = 1;
  function e(r, n) {
    return r == null ? void 0 : r[n];
  }
  return Ct = e, Ct;
}
var Et, Ec;
function ze() {
  if (Ec) return Et;
  Ec = 1;
  var e = cv(), r = uv();
  function n(t, a) {
    var i = r(t, a);
    return e(i) ? i : void 0;
  }
  return Et = n, Et;
}
var At, Ac;
function Lo() {
  if (Ac) return At;
  Ac = 1;
  var e = ze(), r = Ne(), n = e(r, "Map");
  return At = n, At;
}
var Tt, Tc;
function jr() {
  if (Tc) return Tt;
  Tc = 1;
  var e = ze(), r = e(Object, "create");
  return Tt = r, Tt;
}
var Ot, Oc;
function lv() {
  if (Oc) return Ot;
  Oc = 1;
  var e = jr();
  function r() {
    this.__data__ = e ? e(null) : {}, this.size = 0;
  }
  return Ot = r, Ot;
}
var Mt, Mc;
function dv() {
  if (Mc) return Mt;
  Mc = 1;
  function e(r) {
    var n = this.has(r) && delete this.__data__[r];
    return this.size -= n ? 1 : 0, n;
  }
  return Mt = e, Mt;
}
var Pt, Pc;
function fv() {
  if (Pc) return Pt;
  Pc = 1;
  var e = jr(), r = "__lodash_hash_undefined__", n = Object.prototype, t = n.hasOwnProperty;
  function a(i) {
    var o = this.__data__;
    if (e) {
      var s = o[i];
      return s === r ? void 0 : s;
    }
    return t.call(o, i) ? o[i] : void 0;
  }
  return Pt = a, Pt;
}
var Lt, Lc;
function hv() {
  if (Lc) return Lt;
  Lc = 1;
  var e = jr(), r = Object.prototype, n = r.hasOwnProperty;
  function t(a) {
    var i = this.__data__;
    return e ? i[a] !== void 0 : n.call(i, a);
  }
  return Lt = t, Lt;
}
var Dt, Dc;
function pv() {
  if (Dc) return Dt;
  Dc = 1;
  var e = jr(), r = "__lodash_hash_undefined__";
  function n(t, a) {
    var i = this.__data__;
    return this.size += this.has(t) ? 0 : 1, i[t] = e && a === void 0 ? r : a, this;
  }
  return Dt = n, Dt;
}
var jt, jc;
function mv() {
  if (jc) return jt;
  jc = 1;
  var e = lv(), r = dv(), n = fv(), t = hv(), a = pv();
  function i(o) {
    var s = -1, c = o == null ? 0 : o.length;
    for (this.clear(); ++s < c; ) {
      var l = o[s];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = e, i.prototype.delete = r, i.prototype.get = n, i.prototype.has = t, i.prototype.set = a, jt = i, jt;
}
var Gt, Gc;
function vv() {
  if (Gc) return Gt;
  Gc = 1;
  var e = mv(), r = Dr(), n = Lo();
  function t() {
    this.size = 0, this.__data__ = {
      hash: new e(),
      map: new (n || r)(),
      string: new e()
    };
  }
  return Gt = t, Gt;
}
var Ft, Fc;
function gv() {
  if (Fc) return Ft;
  Fc = 1;
  function e(r) {
    var n = typeof r;
    return n == "string" || n == "number" || n == "symbol" || n == "boolean" ? r !== "__proto__" : r === null;
  }
  return Ft = e, Ft;
}
var zt, zc;
function Gr() {
  if (zc) return zt;
  zc = 1;
  var e = gv();
  function r(n, t) {
    var a = n.__data__;
    return e(t) ? a[typeof t == "string" ? "string" : "hash"] : a.map;
  }
  return zt = r, zt;
}
var Bt, Bc;
function bv() {
  if (Bc) return Bt;
  Bc = 1;
  var e = Gr();
  function r(n) {
    var t = e(this, n).delete(n);
    return this.size -= t ? 1 : 0, t;
  }
  return Bt = r, Bt;
}
var Ut, Uc;
function yv() {
  if (Uc) return Ut;
  Uc = 1;
  var e = Gr();
  function r(n) {
    return e(this, n).get(n);
  }
  return Ut = r, Ut;
}
var $t, $c;
function xv() {
  if ($c) return $t;
  $c = 1;
  var e = Gr();
  function r(n) {
    return e(this, n).has(n);
  }
  return $t = r, $t;
}
var Ht, Hc;
function _v() {
  if (Hc) return Ht;
  Hc = 1;
  var e = Gr();
  function r(n, t) {
    var a = e(this, n), i = a.size;
    return a.set(n, t), this.size += a.size == i ? 0 : 1, this;
  }
  return Ht = r, Ht;
}
var Vt, Vc;
function Do() {
  if (Vc) return Vt;
  Vc = 1;
  var e = vv(), r = bv(), n = yv(), t = xv(), a = _v();
  function i(o) {
    var s = -1, c = o == null ? 0 : o.length;
    for (this.clear(); ++s < c; ) {
      var l = o[s];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = e, i.prototype.delete = r, i.prototype.get = n, i.prototype.has = t, i.prototype.set = a, Vt = i, Vt;
}
var Kt, Kc;
function wv() {
  if (Kc) return Kt;
  Kc = 1;
  var e = Dr(), r = Lo(), n = Do(), t = 200;
  function a(i, o) {
    var s = this.__data__;
    if (s instanceof e) {
      var c = s.__data__;
      if (!r || c.length < t - 1)
        return c.push([i, o]), this.size = ++s.size, this;
      s = this.__data__ = new n(c);
    }
    return s.set(i, o), this.size = s.size, this;
  }
  return Kt = a, Kt;
}
var Wt, Wc;
function Fr() {
  if (Wc) return Wt;
  Wc = 1;
  var e = Dr(), r = ev(), n = rv(), t = tv(), a = nv(), i = wv();
  function o(s) {
    var c = this.__data__ = new e(s);
    this.size = c.size;
  }
  return o.prototype.clear = r, o.prototype.delete = n, o.prototype.get = t, o.prototype.has = a, o.prototype.set = i, Wt = o, Wt;
}
var Yt, Yc;
function jo() {
  if (Yc) return Yt;
  Yc = 1;
  function e(r, n) {
    for (var t = -1, a = r == null ? 0 : r.length; ++t < a && n(r[t], t, r) !== !1; )
      ;
    return r;
  }
  return Yt = e, Yt;
}
var Jt, Jc;
function X0() {
  if (Jc) return Jt;
  Jc = 1;
  var e = ze(), r = (function() {
    try {
      var n = e(Object, "defineProperty");
      return n({}, "", {}), n;
    } catch {
    }
  })();
  return Jt = r, Jt;
}
var Zt, Zc;
function zr() {
  if (Zc) return Zt;
  Zc = 1;
  var e = X0();
  function r(n, t, a) {
    t == "__proto__" && e ? e(n, t, {
      configurable: !0,
      enumerable: !0,
      value: a,
      writable: !0
    }) : n[t] = a;
  }
  return Zt = r, Zt;
}
var Xt, Xc;
function Br() {
  if (Xc) return Xt;
  Xc = 1;
  var e = zr(), r = Ze(), n = Object.prototype, t = n.hasOwnProperty;
  function a(i, o, s) {
    var c = i[o];
    (!(t.call(i, o) && r(c, s)) || s === void 0 && !(o in i)) && e(i, o, s);
  }
  return Xt = a, Xt;
}
var Qt, Qc;
function br() {
  if (Qc) return Qt;
  Qc = 1;
  var e = Br(), r = zr();
  function n(t, a, i, o) {
    var s = !i;
    i || (i = {});
    for (var c = -1, l = a.length; ++c < l; ) {
      var u = a[c], d = o ? o(i[u], t[u], u, i, t) : void 0;
      d === void 0 && (d = t[u]), s ? r(i, u, d) : e(i, u, d);
    }
    return i;
  }
  return Qt = n, Qt;
}
var en, eu;
function Nv() {
  if (eu) return en;
  eu = 1;
  function e(r, n) {
    for (var t = -1, a = Array(r); ++t < r; )
      a[t] = n(t);
    return a;
  }
  return en = e, en;
}
var rn, ru;
function Se() {
  if (ru) return rn;
  ru = 1;
  function e(r) {
    return r != null && typeof r == "object";
  }
  return rn = e, rn;
}
var tn, tu;
function qv() {
  if (tu) return tn;
  tu = 1;
  var e = Fe(), r = Se(), n = "[object Arguments]";
  function t(a) {
    return r(a) && e(a) == n;
  }
  return tn = t, tn;
}
var nn, nu;
function yr() {
  if (nu) return nn;
  nu = 1;
  var e = qv(), r = Se(), n = Object.prototype, t = n.hasOwnProperty, a = n.propertyIsEnumerable, i = e(/* @__PURE__ */ (function() {
    return arguments;
  })()) ? e : function(o) {
    return r(o) && t.call(o, "callee") && !a.call(o, "callee");
  };
  return nn = i, nn;
}
var an, au;
function ae() {
  if (au) return an;
  au = 1;
  var e = Array.isArray;
  return an = e, an;
}
var ir = { exports: {} }, sn, iu;
function Iv() {
  if (iu) return sn;
  iu = 1;
  function e() {
    return !1;
  }
  return sn = e, sn;
}
ir.exports;
var su;
function Qe() {
  return su || (su = 1, (function(e, r) {
    var n = Ne(), t = Iv(), a = r && !r.nodeType && r, i = a && !0 && e && !e.nodeType && e, o = i && i.exports === a, s = o ? n.Buffer : void 0, c = s ? s.isBuffer : void 0, l = c || t;
    e.exports = l;
  })(ir, ir.exports)), ir.exports;
}
var on, ou;
function Ur() {
  if (ou) return on;
  ou = 1;
  var e = 9007199254740991, r = /^(?:0|[1-9]\d*)$/;
  function n(t, a) {
    var i = typeof t;
    return a = a ?? e, !!a && (i == "number" || i != "symbol" && r.test(t)) && t > -1 && t % 1 == 0 && t < a;
  }
  return on = n, on;
}
var cn, cu;
function Go() {
  if (cu) return cn;
  cu = 1;
  var e = 9007199254740991;
  function r(n) {
    return typeof n == "number" && n > -1 && n % 1 == 0 && n <= e;
  }
  return cn = r, cn;
}
var un, uu;
function kv() {
  if (uu) return un;
  uu = 1;
  var e = Fe(), r = Go(), n = Se(), t = "[object Arguments]", a = "[object Array]", i = "[object Boolean]", o = "[object Date]", s = "[object Error]", c = "[object Function]", l = "[object Map]", u = "[object Number]", d = "[object Object]", h = "[object RegExp]", p = "[object Set]", q = "[object String]", g = "[object WeakMap]", v = "[object ArrayBuffer]", b = "[object DataView]", m = "[object Float32Array]", y = "[object Float64Array]", w = "[object Int8Array]", N = "[object Int16Array]", I = "[object Int32Array]", _ = "[object Uint8Array]", R = "[object Uint8ClampedArray]", k = "[object Uint16Array]", S = "[object Uint32Array]", E = {};
  E[m] = E[y] = E[w] = E[N] = E[I] = E[_] = E[R] = E[k] = E[S] = !0, E[t] = E[a] = E[v] = E[i] = E[b] = E[o] = E[s] = E[c] = E[l] = E[u] = E[d] = E[h] = E[p] = E[q] = E[g] = !1;
  function A(P) {
    return n(P) && r(P.length) && !!E[e(P)];
  }
  return un = A, un;
}
var ln, lu;
function $r() {
  if (lu) return ln;
  lu = 1;
  function e(r) {
    return function(n) {
      return r(n);
    };
  }
  return ln = e, ln;
}
var sr = { exports: {} };
sr.exports;
var du;
function Fo() {
  return du || (du = 1, (function(e, r) {
    var n = J0(), t = r && !r.nodeType && r, a = t && !0 && e && !e.nodeType && e, i = a && a.exports === t, o = i && n.process, s = (function() {
      try {
        var c = a && a.require && a.require("util").types;
        return c || o && o.binding && o.binding("util");
      } catch {
      }
    })();
    e.exports = s;
  })(sr, sr.exports)), sr.exports;
}
var dn, fu;
function xr() {
  if (fu) return dn;
  fu = 1;
  var e = kv(), r = $r(), n = Fo(), t = n && n.isTypedArray, a = t ? r(t) : e;
  return dn = a, dn;
}
var fn, hu;
function Q0() {
  if (hu) return fn;
  hu = 1;
  var e = Nv(), r = yr(), n = ae(), t = Qe(), a = Ur(), i = xr(), o = Object.prototype, s = o.hasOwnProperty;
  function c(l, u) {
    var d = n(l), h = !d && r(l), p = !d && !h && t(l), q = !d && !h && !p && i(l), g = d || h || p || q, v = g ? e(l.length, String) : [], b = v.length;
    for (var m in l)
      (u || s.call(l, m)) && !(g && // Safari 9 has enumerable `arguments.length` in strict mode.
      (m == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
      p && (m == "offset" || m == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
      q && (m == "buffer" || m == "byteLength" || m == "byteOffset") || // Skip index properties.
      a(m, b))) && v.push(m);
    return v;
  }
  return fn = c, fn;
}
var hn, pu;
function Hr() {
  if (pu) return hn;
  pu = 1;
  var e = Object.prototype;
  function r(n) {
    var t = n && n.constructor, a = typeof t == "function" && t.prototype || e;
    return n === a;
  }
  return hn = r, hn;
}
var pn, mu;
function eh() {
  if (mu) return pn;
  mu = 1;
  function e(r, n) {
    return function(t) {
      return r(n(t));
    };
  }
  return pn = e, pn;
}
var mn, vu;
function Sv() {
  if (vu) return mn;
  vu = 1;
  var e = eh(), r = e(Object.keys, Object);
  return mn = r, mn;
}
var vn, gu;
function zo() {
  if (gu) return vn;
  gu = 1;
  var e = Hr(), r = Sv(), n = Object.prototype, t = n.hasOwnProperty;
  function a(i) {
    if (!e(i))
      return r(i);
    var o = [];
    for (var s in Object(i))
      t.call(i, s) && s != "constructor" && o.push(s);
    return o;
  }
  return vn = a, vn;
}
var gn, bu;
function Te() {
  if (bu) return gn;
  bu = 1;
  var e = gr(), r = Go();
  function n(t) {
    return t != null && r(t.length) && !e(t);
  }
  return gn = n, gn;
}
var bn, yu;
function Ge() {
  if (yu) return bn;
  yu = 1;
  var e = Q0(), r = zo(), n = Te();
  function t(a) {
    return n(a) ? e(a) : r(a);
  }
  return bn = t, bn;
}
var yn, xu;
function Rv() {
  if (xu) return yn;
  xu = 1;
  var e = br(), r = Ge();
  function n(t, a) {
    return t && e(a, r(a), t);
  }
  return yn = n, yn;
}
var xn, _u;
function Cv() {
  if (_u) return xn;
  _u = 1;
  function e(r) {
    var n = [];
    if (r != null)
      for (var t in Object(r))
        n.push(t);
    return n;
  }
  return xn = e, xn;
}
var _n, wu;
function Ev() {
  if (wu) return _n;
  wu = 1;
  var e = be(), r = Hr(), n = Cv(), t = Object.prototype, a = t.hasOwnProperty;
  function i(o) {
    if (!e(o))
      return n(o);
    var s = r(o), c = [];
    for (var l in o)
      l == "constructor" && (s || !a.call(o, l)) || c.push(l);
    return c;
  }
  return _n = i, _n;
}
var wn, Nu;
function Be() {
  if (Nu) return wn;
  Nu = 1;
  var e = Q0(), r = Ev(), n = Te();
  function t(a) {
    return n(a) ? e(a, !0) : r(a);
  }
  return wn = t, wn;
}
var Nn, qu;
function Av() {
  if (qu) return Nn;
  qu = 1;
  var e = br(), r = Be();
  function n(t, a) {
    return t && e(a, r(a), t);
  }
  return Nn = n, Nn;
}
var or = { exports: {} };
or.exports;
var Iu;
function rh() {
  return Iu || (Iu = 1, (function(e, r) {
    var n = Ne(), t = r && !r.nodeType && r, a = t && !0 && e && !e.nodeType && e, i = a && a.exports === t, o = i ? n.Buffer : void 0, s = o ? o.allocUnsafe : void 0;
    function c(l, u) {
      if (u)
        return l.slice();
      var d = l.length, h = s ? s(d) : new l.constructor(d);
      return l.copy(h), h;
    }
    e.exports = c;
  })(or, or.exports)), or.exports;
}
var qn, ku;
function th() {
  if (ku) return qn;
  ku = 1;
  function e(r, n) {
    var t = -1, a = r.length;
    for (n || (n = Array(a)); ++t < a; )
      n[t] = r[t];
    return n;
  }
  return qn = e, qn;
}
var In, Su;
function nh() {
  if (Su) return In;
  Su = 1;
  function e(r, n) {
    for (var t = -1, a = r == null ? 0 : r.length, i = 0, o = []; ++t < a; ) {
      var s = r[t];
      n(s, t, r) && (o[i++] = s);
    }
    return o;
  }
  return In = e, In;
}
var kn, Ru;
function ah() {
  if (Ru) return kn;
  Ru = 1;
  function e() {
    return [];
  }
  return kn = e, kn;
}
var Sn, Cu;
function Bo() {
  if (Cu) return Sn;
  Cu = 1;
  var e = nh(), r = ah(), n = Object.prototype, t = n.propertyIsEnumerable, a = Object.getOwnPropertySymbols, i = a ? function(o) {
    return o == null ? [] : (o = Object(o), e(a(o), function(s) {
      return t.call(o, s);
    }));
  } : r;
  return Sn = i, Sn;
}
var Rn, Eu;
function Tv() {
  if (Eu) return Rn;
  Eu = 1;
  var e = br(), r = Bo();
  function n(t, a) {
    return e(t, r(t), a);
  }
  return Rn = n, Rn;
}
var Cn, Au;
function Uo() {
  if (Au) return Cn;
  Au = 1;
  function e(r, n) {
    for (var t = -1, a = n.length, i = r.length; ++t < a; )
      r[i + t] = n[t];
    return r;
  }
  return Cn = e, Cn;
}
var En, Tu;
function Vr() {
  if (Tu) return En;
  Tu = 1;
  var e = eh(), r = e(Object.getPrototypeOf, Object);
  return En = r, En;
}
var An, Ou;
function ih() {
  if (Ou) return An;
  Ou = 1;
  var e = Uo(), r = Vr(), n = Bo(), t = ah(), a = Object.getOwnPropertySymbols, i = a ? function(o) {
    for (var s = []; o; )
      e(s, n(o)), o = r(o);
    return s;
  } : t;
  return An = i, An;
}
var Tn, Mu;
function Ov() {
  if (Mu) return Tn;
  Mu = 1;
  var e = br(), r = ih();
  function n(t, a) {
    return e(t, r(t), a);
  }
  return Tn = n, Tn;
}
var On, Pu;
function sh() {
  if (Pu) return On;
  Pu = 1;
  var e = Uo(), r = ae();
  function n(t, a, i) {
    var o = a(t);
    return r(t) ? o : e(o, i(t));
  }
  return On = n, On;
}
var Mn, Lu;
function oh() {
  if (Lu) return Mn;
  Lu = 1;
  var e = sh(), r = Bo(), n = Ge();
  function t(a) {
    return e(a, n, r);
  }
  return Mn = t, Mn;
}
var Pn, Du;
function Mv() {
  if (Du) return Pn;
  Du = 1;
  var e = sh(), r = ih(), n = Be();
  function t(a) {
    return e(a, n, r);
  }
  return Pn = t, Pn;
}
var Ln, ju;
function Pv() {
  if (ju) return Ln;
  ju = 1;
  var e = ze(), r = Ne(), n = e(r, "DataView");
  return Ln = n, Ln;
}
var Dn, Gu;
function Lv() {
  if (Gu) return Dn;
  Gu = 1;
  var e = ze(), r = Ne(), n = e(r, "Promise");
  return Dn = n, Dn;
}
var jn, Fu;
function ch() {
  if (Fu) return jn;
  Fu = 1;
  var e = ze(), r = Ne(), n = e(r, "Set");
  return jn = n, jn;
}
var Gn, zu;
function Dv() {
  if (zu) return Gn;
  zu = 1;
  var e = ze(), r = Ne(), n = e(r, "WeakMap");
  return Gn = n, Gn;
}
var Fn, Bu;
function er() {
  if (Bu) return Fn;
  Bu = 1;
  var e = Pv(), r = Lo(), n = Lv(), t = ch(), a = Dv(), i = Fe(), o = Z0(), s = "[object Map]", c = "[object Object]", l = "[object Promise]", u = "[object Set]", d = "[object WeakMap]", h = "[object DataView]", p = o(e), q = o(r), g = o(n), v = o(t), b = o(a), m = i;
  return (e && m(new e(new ArrayBuffer(1))) != h || r && m(new r()) != s || n && m(n.resolve()) != l || t && m(new t()) != u || a && m(new a()) != d) && (m = function(y) {
    var w = i(y), N = w == c ? y.constructor : void 0, I = N ? o(N) : "";
    if (I)
      switch (I) {
        case p:
          return h;
        case q:
          return s;
        case g:
          return l;
        case v:
          return u;
        case b:
          return d;
      }
    return w;
  }), Fn = m, Fn;
}
var zn, Uu;
function jv() {
  if (Uu) return zn;
  Uu = 1;
  var e = Object.prototype, r = e.hasOwnProperty;
  function n(t) {
    var a = t.length, i = new t.constructor(a);
    return a && typeof t[0] == "string" && r.call(t, "index") && (i.index = t.index, i.input = t.input), i;
  }
  return zn = n, zn;
}
var Bn, $u;
function uh() {
  if ($u) return Bn;
  $u = 1;
  var e = Ne(), r = e.Uint8Array;
  return Bn = r, Bn;
}
var Un, Hu;
function $o() {
  if (Hu) return Un;
  Hu = 1;
  var e = uh();
  function r(n) {
    var t = new n.constructor(n.byteLength);
    return new e(t).set(new e(n)), t;
  }
  return Un = r, Un;
}
var $n, Vu;
function Gv() {
  if (Vu) return $n;
  Vu = 1;
  var e = $o();
  function r(n, t) {
    var a = t ? e(n.buffer) : n.buffer;
    return new n.constructor(a, n.byteOffset, n.byteLength);
  }
  return $n = r, $n;
}
var Hn, Ku;
function Fv() {
  if (Ku) return Hn;
  Ku = 1;
  var e = /\w*$/;
  function r(n) {
    var t = new n.constructor(n.source, e.exec(n));
    return t.lastIndex = n.lastIndex, t;
  }
  return Hn = r, Hn;
}
var Vn, Wu;
function zv() {
  if (Wu) return Vn;
  Wu = 1;
  var e = Xe(), r = e ? e.prototype : void 0, n = r ? r.valueOf : void 0;
  function t(a) {
    return n ? Object(n.call(a)) : {};
  }
  return Vn = t, Vn;
}
var Kn, Yu;
function lh() {
  if (Yu) return Kn;
  Yu = 1;
  var e = $o();
  function r(n, t) {
    var a = t ? e(n.buffer) : n.buffer;
    return new n.constructor(a, n.byteOffset, n.length);
  }
  return Kn = r, Kn;
}
var Wn, Ju;
function Bv() {
  if (Ju) return Wn;
  Ju = 1;
  var e = $o(), r = Gv(), n = Fv(), t = zv(), a = lh(), i = "[object Boolean]", o = "[object Date]", s = "[object Map]", c = "[object Number]", l = "[object RegExp]", u = "[object Set]", d = "[object String]", h = "[object Symbol]", p = "[object ArrayBuffer]", q = "[object DataView]", g = "[object Float32Array]", v = "[object Float64Array]", b = "[object Int8Array]", m = "[object Int16Array]", y = "[object Int32Array]", w = "[object Uint8Array]", N = "[object Uint8ClampedArray]", I = "[object Uint16Array]", _ = "[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 q:
        return r(k, E);
      case g:
      case v:
      case b:
      case m:
      case y:
      case w:
      case N:
      case I:
      case _:
        return a(k, E);
      case s:
        return new A();
      case c:
      case d:
        return new A(k);
      case l:
        return n(k);
      case u:
        return new A();
      case h:
        return t(k);
    }
  }
  return Wn = R, Wn;
}
var Yn, Zu;
function dh() {
  if (Zu) return Yn;
  Zu = 1;
  var e = be(), r = Object.create, n = /* @__PURE__ */ (function() {
    function t() {
    }
    return function(a) {
      if (!e(a))
        return {};
      if (r)
        return r(a);
      t.prototype = a;
      var i = new t();
      return t.prototype = void 0, i;
    };
  })();
  return Yn = n, Yn;
}
var Jn, Xu;
function fh() {
  if (Xu) return Jn;
  Xu = 1;
  var e = dh(), r = Vr(), n = Hr();
  function t(a) {
    return typeof a.constructor == "function" && !n(a) ? e(r(a)) : {};
  }
  return Jn = t, Jn;
}
var Zn, Qu;
function Uv() {
  if (Qu) return Zn;
  Qu = 1;
  var e = er(), r = Se(), n = "[object Map]";
  function t(a) {
    return r(a) && e(a) == n;
  }
  return Zn = t, Zn;
}
var Xn, el;
function $v() {
  if (el) return Xn;
  el = 1;
  var e = Uv(), r = $r(), n = Fo(), t = n && n.isMap, a = t ? r(t) : e;
  return Xn = a, Xn;
}
var Qn, rl;
function Hv() {
  if (rl) return Qn;
  rl = 1;
  var e = er(), r = Se(), n = "[object Set]";
  function t(a) {
    return r(a) && e(a) == n;
  }
  return Qn = t, Qn;
}
var ea, tl;
function Vv() {
  if (tl) return ea;
  tl = 1;
  var e = Hv(), r = $r(), n = Fo(), t = n && n.isSet, a = t ? r(t) : e;
  return ea = a, ea;
}
var ra, nl;
function hh() {
  if (nl) return ra;
  nl = 1;
  var e = Fr(), r = jo(), n = Br(), t = Rv(), a = Av(), i = rh(), o = th(), s = Tv(), c = Ov(), l = oh(), u = Mv(), d = er(), h = jv(), p = Bv(), q = fh(), g = ae(), v = Qe(), b = $v(), m = be(), y = Vv(), w = Ge(), N = Be(), I = 1, _ = 2, R = 4, k = "[object Arguments]", S = "[object Array]", E = "[object Boolean]", A = "[object Date]", P = "[object Error]", z = "[object Function]", F = "[object GeneratorFunction]", J = "[object Map]", M = "[object Number]", G = "[object Object]", D = "[object RegExp]", $ = "[object Set]", le = "[object String]", de = "[object Symbol]", ne = "[object WeakMap]", C = "[object ArrayBuffer]", T = "[object DataView]", O = "[object Float32Array]", L = "[object Float64Array]", H = "[object Int8Array]", Y = "[object Int16Array]", Q = "[object Int32Array]", ce = "[object Uint8Array]", Me = "[object Uint8ClampedArray]", fe = "[object Uint16Array]", se = "[object Uint32Array]", V = {};
  V[k] = V[S] = V[C] = V[T] = V[E] = V[A] = V[O] = V[L] = V[H] = V[Y] = V[Q] = V[J] = V[M] = V[G] = V[D] = V[$] = V[le] = V[de] = V[ce] = V[Me] = V[fe] = V[se] = !0, V[P] = V[z] = V[ne] = !1;
  function Re(W, Pe, Ce, Qr, $e, qe) {
    var he, He = Pe & I, Ve = Pe & _, et = Pe & R;
    if (Ce && (he = $e ? Ce(W, Qr, $e, qe) : Ce(W)), he !== void 0)
      return he;
    if (!m(W))
      return W;
    var Ke = g(W);
    if (Ke) {
      if (he = h(W), !He)
        return o(W, he);
    } else {
      var Le = d(W), wr = Le == z || Le == F;
      if (v(W))
        return i(W, He);
      if (Le == G || Le == k || wr && !$e) {
        if (he = Ve || wr ? {} : q(W), !He)
          return Ve ? c(W, a(he, W)) : s(W, t(he, W));
      } else {
        if (!V[Le])
          return $e ? W : {};
        he = p(W, Le, He);
      }
    }
    qe || (qe = new e());
    var Nr = qe.get(W);
    if (Nr)
      return Nr;
    qe.set(W, he), y(W) ? W.forEach(function(Ie) {
      he.add(Re(Ie, Pe, Ce, Ie, W, qe));
    }) : b(W) && W.forEach(function(Ie, j) {
      he.set(j, Re(Ie, Pe, Ce, j, W, qe));
    });
    var rt = et ? Ve ? u : l : Ve ? N : w, qr = Ke ? void 0 : rt(W);
    return r(qr || W, function(Ie, j) {
      qr && (j = Ie, Ie = W[j]), n(he, j, Re(Ie, Pe, Ce, j, W, qe));
    }), he;
  }
  return ra = Re, ra;
}
var ta, al;
function Kv() {
  if (al) return ta;
  al = 1;
  var e = hh(), r = 4;
  function n(t) {
    return e(t, r);
  }
  return ta = n, ta;
}
var na, il;
function Ho() {
  if (il) return na;
  il = 1;
  function e(r) {
    return function() {
      return r;
    };
  }
  return na = e, na;
}
var aa, sl;
function Wv() {
  if (sl) return aa;
  sl = 1;
  function e(r) {
    return function(n, t, a) {
      for (var i = -1, o = Object(n), s = a(n), c = s.length; c--; ) {
        var l = s[r ? c : ++i];
        if (t(o[l], l, o) === !1)
          break;
      }
      return n;
    };
  }
  return aa = e, aa;
}
var ia, ol;
function Vo() {
  if (ol) return ia;
  ol = 1;
  var e = Wv(), r = e();
  return ia = r, ia;
}
var sa, cl;
function Ko() {
  if (cl) return sa;
  cl = 1;
  var e = Vo(), r = Ge();
  function n(t, a) {
    return t && e(t, a, r);
  }
  return sa = n, sa;
}
var oa, ul;
function Yv() {
  if (ul) return oa;
  ul = 1;
  var e = Te();
  function r(n, t) {
    return function(a, i) {
      if (a == null)
        return a;
      if (!e(a))
        return n(a, i);
      for (var o = a.length, s = t ? o : -1, c = Object(a); (t ? s-- : ++s < o) && i(c[s], s, c) !== !1; )
        ;
      return a;
    };
  }
  return oa = r, oa;
}
var ca, ll;
function Kr() {
  if (ll) return ca;
  ll = 1;
  var e = Ko(), r = Yv(), n = r(e);
  return ca = n, ca;
}
var ua, dl;
function Ue() {
  if (dl) return ua;
  dl = 1;
  function e(r) {
    return r;
  }
  return ua = e, ua;
}
var la, fl;
function ph() {
  if (fl) return la;
  fl = 1;
  var e = Ue();
  function r(n) {
    return typeof n == "function" ? n : e;
  }
  return la = r, la;
}
var da, hl;
function mh() {
  if (hl) return da;
  hl = 1;
  var e = jo(), r = Kr(), n = ph(), t = ae();
  function a(i, o) {
    var s = t(i) ? e : r;
    return s(i, n(o));
  }
  return da = a, da;
}
var fa, pl;
function vh() {
  return pl || (pl = 1, fa = mh()), fa;
}
var ha, ml;
function Jv() {
  if (ml) return ha;
  ml = 1;
  var e = Kr();
  function r(n, t) {
    var a = [];
    return e(n, function(i, o, s) {
      t(i, o, s) && a.push(i);
    }), a;
  }
  return ha = r, ha;
}
var pa, vl;
function Zv() {
  if (vl) return pa;
  vl = 1;
  var e = "__lodash_hash_undefined__";
  function r(n) {
    return this.__data__.set(n, e), this;
  }
  return pa = r, pa;
}
var ma, gl;
function Xv() {
  if (gl) return ma;
  gl = 1;
  function e(r) {
    return this.__data__.has(r);
  }
  return ma = e, ma;
}
var va, bl;
function gh() {
  if (bl) return va;
  bl = 1;
  var e = Do(), r = Zv(), n = Xv();
  function t(a) {
    var i = -1, o = a == null ? 0 : a.length;
    for (this.__data__ = new e(); ++i < o; )
      this.add(a[i]);
  }
  return t.prototype.add = t.prototype.push = r, t.prototype.has = n, va = t, va;
}
var ga, yl;
function Qv() {
  if (yl) return ga;
  yl = 1;
  function e(r, n) {
    for (var t = -1, a = r == null ? 0 : r.length; ++t < a; )
      if (n(r[t], t, r))
        return !0;
    return !1;
  }
  return ga = e, ga;
}
var ba, xl;
function bh() {
  if (xl) return ba;
  xl = 1;
  function e(r, n) {
    return r.has(n);
  }
  return ba = e, ba;
}
var ya, _l;
function yh() {
  if (_l) return ya;
  _l = 1;
  var e = gh(), r = Qv(), n = bh(), t = 1, a = 2;
  function i(o, s, c, l, u, d) {
    var h = c & t, p = o.length, q = s.length;
    if (p != q && !(h && q > p))
      return !1;
    var g = d.get(o), v = d.get(s);
    if (g && v)
      return g == s && v == o;
    var b = -1, m = !0, y = c & a ? new e() : void 0;
    for (d.set(o, s), d.set(s, o); ++b < p; ) {
      var w = o[b], N = s[b];
      if (l)
        var I = h ? l(N, w, b, s, o, d) : l(w, N, b, o, s, d);
      if (I !== void 0) {
        if (I)
          continue;
        m = !1;
        break;
      }
      if (y) {
        if (!r(s, function(_, R) {
          if (!n(y, R) && (w === _ || u(w, _, c, l, d)))
            return y.push(R);
        })) {
          m = !1;
          break;
        }
      } else if (!(w === N || u(w, N, c, l, d))) {
        m = !1;
        break;
      }
    }
    return d.delete(o), d.delete(s), m;
  }
  return ya = i, ya;
}
var xa, wl;
function eg() {
  if (wl) return xa;
  wl = 1;
  function e(r) {
    var n = -1, t = Array(r.size);
    return r.forEach(function(a, i) {
      t[++n] = [i, a];
    }), t;
  }
  return xa = e, xa;
}
var _a, Nl;
function Wo() {
  if (Nl) return _a;
  Nl = 1;
  function e(r) {
    var n = -1, t = Array(r.size);
    return r.forEach(function(a) {
      t[++n] = a;
    }), t;
  }
  return _a = e, _a;
}
var wa, ql;
function rg() {
  if (ql) return wa;
  ql = 1;
  var e = Xe(), r = uh(), n = Ze(), t = yh(), a = eg(), i = Wo(), o = 1, s = 2, c = "[object Boolean]", l = "[object Date]", u = "[object Error]", d = "[object Map]", h = "[object Number]", p = "[object RegExp]", q = "[object Set]", g = "[object String]", v = "[object Symbol]", b = "[object ArrayBuffer]", m = "[object DataView]", y = e ? e.prototype : void 0, w = y ? y.valueOf : void 0;
  function N(I, _, R, k, S, E, A) {
    switch (R) {
      case m:
        if (I.byteLength != _.byteLength || I.byteOffset != _.byteOffset)
          return !1;
        I = I.buffer, _ = _.buffer;
      case b:
        return !(I.byteLength != _.byteLength || !E(new r(I), new r(_)));
      case c:
      case l:
      case h:
        return n(+I, +_);
      case u:
        return I.name == _.name && I.message == _.message;
      case p:
      case g:
        return I == _ + "";
      case d:
        var P = a;
      case q:
        var z = k & o;
        if (P || (P = i), I.size != _.size && !z)
          return !1;
        var F = A.get(I);
        if (F)
          return F == _;
        k |= s, A.set(I, _);
        var J = t(P(I), P(_), k, S, E, A);
        return A.delete(I), J;
      case v:
        if (w)
          return w.call(I) == w.call(_);
    }
    return !1;
  }
  return wa = N, wa;
}
var Na, Il;
function tg() {
  if (Il) return Na;
  Il = 1;
  var e = oh(), r = 1, n = Object.prototype, t = n.hasOwnProperty;
  function a(i, o, s, c, l, u) {
    var d = s & r, h = e(i), p = h.length, q = e(o), g = q.length;
    if (p != g && !d)
      return !1;
    for (var v = p; v--; ) {
      var b = h[v];
      if (!(d ? b in o : t.call(o, b)))
        return !1;
    }
    var m = u.get(i), y = u.get(o);
    if (m && y)
      return m == o && y == i;
    var w = !0;
    u.set(i, o), u.set(o, i);
    for (var N = d; ++v < p; ) {
      b = h[v];
      var I = i[b], _ = o[b];
      if (c)
        var R = d ? c(_, I, b, o, i, u) : c(I, _, b, i, o, u);
      if (!(R === void 0 ? I === _ || l(I, _, s, c, u) : R)) {
        w = !1;
        break;
      }
      N || (N = b == "constructor");
    }
    if (w && !N) {
      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 u.delete(i), u.delete(o), w;
  }
  return Na = a, Na;
}
var qa, kl;
function ng() {
  if (kl) return qa;
  kl = 1;
  var e = Fr(), r = yh(), n = rg(), t = tg(), a = er(), i = ae(), o = Qe(), s = xr(), c = 1, l = "[object Arguments]", u = "[object Array]", d = "[object Object]", h = Object.prototype, p = h.hasOwnProperty;
  function q(g, v, b, m, y, w) {
    var N = i(g), I = i(v), _ = N ? u : a(g), R = I ? u : a(v);
    _ = _ == l ? d : _, R = R == l ? d : R;
    var k = _ == d, S = R == d, E = _ == R;
    if (E && o(g)) {
      if (!o(v))
        return !1;
      N = !0, k = !1;
    }
    if (E && !k)
      return w || (w = new e()), N || s(g) ? r(g, v, b, m, y, w) : n(g, v, _, b, m, y, w);
    if (!(b & c)) {
      var A = k && p.call(g, "__wrapped__"), P = S && p.call(v, "__wrapped__");
      if (A || P) {
        var z = A ? g.value() : g, F = P ? v.value() : v;
        return w || (w = new e()), y(z, F, b, m, w);
      }
    }
    return E ? (w || (w = new e()), t(g, v, b, m, y, w)) : !1;
  }
  return qa = q, qa;
}
var Ia, Sl;
function xh() {
  if (Sl) return Ia;
  Sl = 1;
  var e = ng(), r = Se();
  function n(t, a, i, o, s) {
    return t === a ? !0 : t == null || a == null || !r(t) && !r(a) ? t !== t && a !== a : e(t, a, i, o, n, s);
  }
  return Ia = n, Ia;
}
var ka, Rl;
function ag() {
  if (Rl) return ka;
  Rl = 1;
  var e = Fr(), r = xh(), n = 1, t = 2;
  function a(i, o, s, c) {
    var l = s.length, u = l, d = !c;
    if (i == null)
      return !u;
    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 < u; ) {
      h = s[l];
      var p = h[0], q = i[p], g = h[1];
      if (d && h[2]) {
        if (q === void 0 && !(p in i))
          return !1;
      } else {
        var v = new e();
        if (c)
          var b = c(q, g, p, i, o, v);
        if (!(b === void 0 ? r(g, q, n | t, c, v) : b))
          return !1;
      }
    }
    return !0;
  }
  return ka = a, ka;
}
var Sa, Cl;
function _h() {
  if (Cl) return Sa;
  Cl = 1;
  var e = be();
  function r(n) {
    return n === n && !e(n);
  }
  return Sa = r, Sa;
}
var Ra, El;
function ig() {
  if (El) return Ra;
  El = 1;
  var e = _h(), r = Ge();
  function n(t) {
    for (var a = r(t), i = a.length; i--; ) {
      var o = a[i], s = t[o];
      a[i] = [o, s, e(s)];
    }
    return a;
  }
  return Ra = n, Ra;
}
var Ca, Al;
function wh() {
  if (Al) return Ca;
  Al = 1;
  function e(r, n) {
    return function(t) {
      return t == null ? !1 : t[r] === n && (n !== void 0 || r in Object(t));
    };
  }
  return Ca = e, Ca;
}
var Ea, Tl;
function sg() {
  if (Tl) return Ea;
  Tl = 1;
  var e = ag(), r = ig(), n = wh();
  function t(a) {
    var i = r(a);
    return i.length == 1 && i[0][2] ? n(i[0][0], i[0][1]) : function(o) {
      return o === a || e(o, a, i);
    };
  }
  return Ea = t, Ea;
}
var Aa, Ol;
function rr() {
  if (Ol) return Aa;
  Ol = 1;
  var e = Fe(), r = Se(), n = "[object Symbol]";
  function t(a) {
    return typeof a == "symbol" || r(a) && e(a) == n;
  }
  return Aa = t, Aa;
}
var Ta, Ml;
function Yo() {
  if (Ml) return Ta;
  Ml = 1;
  var e = ae(), r = rr(), n = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, t = /^\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 : t.test(i) || !n.test(i) || o != null && i in Object(o);
  }
  return Ta = a, Ta;
}
var Oa, Pl;
function og() {
  if (Pl) return Oa;
  Pl = 1;
  var e = Do(), r = "Expected a function";
  function n(t, a) {
    if (typeof t != "function" || a != null && typeof a != "function")
      throw new TypeError(r);
    var i = function() {
      var o = arguments, s = a ? a.apply(this, o) : o[0], c = i.cache;
      if (c.has(s))
        return c.get(s);
      var l = t.apply(this, o);
      return i.cache = c.set(s, l) || c, l;
    };
    return i.cache = new (n.Cache || e)(), i;
  }
  return n.Cache = e, Oa = n, Oa;
}
var Ma, Ll;
function cg() {
  if (Ll) return Ma;
  Ll = 1;
  var e = og(), r = 500;
  function n(t) {
    var a = e(t, function(o) {
      return i.size === r && i.clear(), o;
    }), i = a.cache;
    return a;
  }
  return Ma = n, Ma;
}
var Pa, Dl;
function ug() {
  if (Dl) return Pa;
  Dl = 1;
  var e = cg(), r = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, n = /\\(\\)?/g, t = e(function(a) {
    var i = [];
    return a.charCodeAt(0) === 46 && i.push(""), a.replace(r, function(o, s, c, l) {
      i.push(c ? l.replace(n, "$1") : s || o);
    }), i;
  });
  return Pa = t, Pa;
}
var La, jl;
function Wr() {
  if (jl) return La;
  jl = 1;
  function e(r, n) {
    for (var t = -1, a = r == null ? 0 : r.length, i = Array(a); ++t < a; )
      i[t] = n(r[t], t, r);
    return i;
  }
  return La = e, La;
}
var Da, Gl;
function lg() {
  if (Gl) return Da;
  Gl = 1;
  var e = Xe(), r = Wr(), n = ae(), t = rr(), a = e ? e.prototype : void 0, i = a ? a.toString : void 0;
  function o(s) {
    if (typeof s == "string")
      return s;
    if (n(s))
      return r(s, o) + "";
    if (t(s))
      return i ? i.call(s) : "";
    var c = s + "";
    return c == "0" && 1 / s == -1 / 0 ? "-0" : c;
  }
  return Da = o, Da;
}
var ja, Fl;
function Nh() {
  if (Fl) return ja;
  Fl = 1;
  var e = lg();
  function r(n) {
    return n == null ? "" : e(n);
  }
  return ja = r, ja;
}
var Ga, zl;
function Yr() {
  if (zl) return Ga;
  zl = 1;
  var e = ae(), r = Yo(), n = ug(), t = Nh();
  function a(i, o) {
    return e(i) ? i : r(i, o) ? [i] : n(t(i));
  }
  return Ga = a, Ga;
}
var Fa, Bl;
function _r() {
  if (Bl) return Fa;
  Bl = 1;
  var e = rr();
  function r(n) {
    if (typeof n == "string" || e(n))
      return n;
    var t = n + "";
    return t == "0" && 1 / n == -1 / 0 ? "-0" : t;
  }
  return Fa = r, Fa;
}
var za, Ul;
function Jr() {
  if (Ul) return za;
  Ul = 1;
  var e = Yr(), r = _r();
  function n(t, a) {
    a = e(a, t);
    for (var i = 0, o = a.length; t != null && i < o; )
      t = t[r(a[i++])];
    return i && i == o ? t : void 0;
  }
  return za = n, za;
}
var Ba, $l;
function dg() {
  if ($l) return Ba;
  $l = 1;
  var e = Jr();
  function r(n, t, a) {
    var i = n == null ? void 0 : e(n, t);
    return i === void 0 ? a : i;
  }
  return Ba = r, Ba;
}
var Ua, Hl;
function fg() {
  if (Hl) return Ua;
  Hl = 1;
  function e(r, n) {
    return r != null && n in Object(r);
  }
  return Ua = e, Ua;
}
var $a, Vl;
function qh() {
  if (Vl) return $a;
  Vl = 1;
  var e = Yr(), r = yr(), n = ae(), t = Ur(), a = Go(), i = _r();
  function o(s, c, l) {
    c = e(c, s);
    for (var u = -1, d = c.length, h = !1; ++u < d; ) {
      var p = i(c[u]);
      if (!(h = s != null && l(s, p)))
        break;
      s = s[p];
    }
    return h || ++u != d ? h : (d = s == null ? 0 : s.length, !!d && a(d) && t(p, d) && (n(s) || r(s)));
  }
  return $a = o, $a;
}
var Ha, Kl;
function Ih() {
  if (Kl) return Ha;
  Kl = 1;
  var e = fg(), r = qh();
  function n(t, a) {
    return t != null && r(t, a, e);
  }
  return Ha = n, Ha;
}
var Va, Wl;
function hg() {
  if (Wl) return Va;
  Wl = 1;
  var e = xh(), r = dg(), n = Ih(), t = Yo(), a = _h(), i = wh(), o = _r(), s = 1, c = 2;
  function l(u, d) {
    return t(u) && a(d) ? i(o(u), d) : function(h) {
      var p = r(h, u);
      return p === void 0 && p === d ? n(h, u) : e(d, p, s | c);
    };
  }
  return Va = l, Va;
}
var Ka, Yl;
function kh() {
  if (Yl) return Ka;
  Yl = 1;
  function e(r) {
    return function(n) {
      return n == null ? void 0 : n[r];
    };
  }
  return Ka = e, Ka;
}
var Wa, Jl;
function pg() {
  if (Jl) return Wa;
  Jl = 1;
  var e = Jr();
  function r(n) {
    return function(t) {
      return e(t, n);
    };
  }
  return Wa = r, Wa;
}
var Ya, Zl;
function mg() {
  if (Zl) return Ya;
  Zl = 1;
  var e = kh(), r = pg(), n = Yo(), t = _r();
  function a(i) {
    return n(i) ? e(t(i)) : r(i);
  }
  return Ya = a, Ya;
}
var Ja, Xl;
function Oe() {
  if (Xl) return Ja;
  Xl = 1;
  var e = sg(), r = hg(), n = Ue(), t = ae(), a = mg();
  function i(o) {
    return typeof o == "function" ? o : o == null ? n : typeof o == "object" ? t(o) ? r(o[0], o[1]) : e(o) : a(o);
  }
  return Ja = i, Ja;
}
var Za, Ql;
function Sh() {
  if (Ql) return Za;
  Ql = 1;
  var e = nh(), r = Jv(), n = Oe(), t = ae();
  function a(i, o) {
    var s = t(i) ? e : r;
    return s(i, n(o, 3));
  }
  return Za = a, Za;
}
var Xa, ed;
function vg() {
  if (ed) return Xa;
  ed = 1;
  var e = Object.prototype, r = e.hasOwnProperty;
  function n(t, a) {
    return t != null && r.call(t, a);
  }
  return Xa = n, Xa;
}
var Qa, rd;
function Rh() {
  if (rd) return Qa;
  rd = 1;
  var e = vg(), r = qh();
  function n(t, a) {
    return t != null && r(t, a, e);
  }
  return Qa = n, Qa;
}
var ei, td;
function gg() {
  if (td) return ei;
  td = 1;
  var e = zo(), r = er(), n = yr(), t = ae(), a = Te(), i = Qe(), o = Hr(), s = xr(), c = "[object Map]", l = "[object Set]", u = Object.prototype, d = u.hasOwnProperty;
  function h(p) {
    if (p == null)
      return !0;
    if (a(p) && (t(p) || typeof p == "string" || typeof p.splice == "function" || i(p) || s(p) || n(p)))
      return !p.length;
    var q = r(p);
    if (q == c || q == l)
      return !p.size;
    if (o(p))
      return !e(p).length;
    for (var g in p)
      if (d.call(p, g))
        return !1;
    return !0;
  }
  return ei = h, ei;
}
var ri, nd;
function Ch() {
  if (nd) return ri;
  nd = 1;
  function e(r) {
    return r === void 0;
  }
  return ri = e, ri;
}
var ti, ad;
function Eh() {
  if (ad) return ti;
  ad = 1;
  var e = Kr(), r = Te();
  function n(t, a) {
    var i = -1, o = r(t) ? Array(t.length) : [];
    return e(t, function(s, c, l) {
      o[++i] = a(s, c, l);
    }), o;
  }
  return ti = n, ti;
}
var ni, id;
function Ah() {
  if (id) return ni;
  id = 1;
  var e = Wr(), r = Oe(), n = Eh(), t = ae();
  function a(i, o) {
    var s = t(i) ? e : n;
    return s(i, r(o, 3));
  }
  return ni = a, ni;
}
var ai, sd;
function bg() {
  if (sd) return ai;
  sd = 1;
  function e(r, n, t, a) {
    var i = -1, o = r == null ? 0 : r.length;
    for (a && o && (t = r[++i]); ++i < o; )
      t = n(t, r[i], i, r);
    return t;
  }
  return ai = e, ai;
}
var ii, od;
function yg() {
  if (od) return ii;
  od = 1;
  function e(r, n, t, a, i) {
    return i(r, function(o, s, c) {
      t = a ? (a = !1, o) : n(t, o, s, c);
    }), t;
  }
  return ii = e, ii;
}
var si, cd;
function Th() {
  if (cd) return si;
  cd = 1;
  var e = bg(), r = Kr(), n = Oe(), t = yg(), a = ae();
  function i(o, s, c) {
    var l = a(o) ? e : t, u = arguments.length < 3;
    return l(o, n(s, 4), c, u, r);
  }
  return si = i, si;
}
var oi, ud;
function xg() {
  if (ud) return oi;
  ud = 1;
  var e = Fe(), r = ae(), n = Se(), t = "[object String]";
  function a(i) {
    return typeof i == "string" || !r(i) && n(i) && e(i) == t;
  }
  return oi = a, oi;
}
var ci, ld;
function _g() {
  if (ld) return ci;
  ld = 1;
  var e = kh(), r = e("length");
  return ci = r, ci;
}
var ui, dd;
function wg() {
  if (dd) return ui;
  dd = 1;
  var e = "\\ud800-\\udfff", r = "\\u0300-\\u036f", n = "\\ufe20-\\ufe2f", t = "\\u20d0-\\u20ff", a = r + n + t, i = "\\ufe0e\\ufe0f", o = "\\u200d", s = RegExp("[" + o + e + a + i + "]");
  function c(l) {
    return s.test(l);
  }
  return ui = c, ui;
}
var li, fd;
function Ng() {
  if (fd) return li;
  fd = 1;
  var e = "\\ud800-\\udfff", r = "\\u0300-\\u036f", n = "\\ufe20-\\ufe2f", t = "\\u20d0-\\u20ff", a = r + n + t, i = "\\ufe0e\\ufe0f", o = "[" + e + "]", s = "[" + a + "]", c = "\\ud83c[\\udffb-\\udfff]", l = "(?:" + s + "|" + c + ")", u = "[^" + e + "]", d = "(?:\\ud83c[\\udde6-\\uddff]){2}", h = "[\\ud800-\\udbff][\\udc00-\\udfff]", p = "\\u200d", q = l + "?", g = "[" + i + "]?", v = "(?:" + p + "(?:" + [u, d, h].join("|") + ")" + g + q + ")*", b = g + q + v, m = "(?:" + [u + s + "?", s, d, h, o].join("|") + ")", y = RegExp(c + "(?=" + c + ")|" + m + b, "g");
  function w(N) {
    for (var I = y.lastIndex = 0; y.test(N); )
      ++I;
    return I;
  }
  return li = w, li;
}
var di, hd;
function qg() {
  if (hd) return di;
  hd = 1;
  var e = _g(), r = wg(), n = Ng();
  function t(a) {
    return r(a) ? n(a) : e(a);
  }
  return di = t, di;
}
var fi, pd;
function Ig() {
  if (pd) return fi;
  pd = 1;
  var e = zo(), r = er(), n = Te(), t = xg(), a = qg(), i = "[object Map]", o = "[object Set]";
  function s(c) {
    if (c == null)
      return 0;
    if (n(c))
      return t(c) ? a(c) : c.length;
    var l = r(c);
    return l == i || l == o ? c.size : e(c).length;
  }
  return fi = s, fi;
}
var hi, md;
function kg() {
  if (md) return hi;
  md = 1;
  var e = jo(), r = dh(), n = Ko(), t = Oe(), a = Vr(), i = ae(), o = Qe(), s = gr(), c = be(), l = xr();
  function u(d, h, p) {
    var q = i(d), g = q || o(d) || l(d);
    if (h = t(h, 4), p == null) {
      var v = d && d.constructor;
      g ? p = q ? new v() : [] : c(d) ? p = s(v) ? r(a(d)) : {} : p = {};
    }
    return (g ? e : n)(d, function(b, m, y) {
      return h(p, b, m, y);
    }), p;
  }
  return hi = u, hi;
}
var pi, vd;
function Sg() {
  if (vd) return pi;
  vd = 1;
  var e = Xe(), r = yr(), n = ae(), t = e ? e.isConcatSpreadable : void 0;
  function a(i) {
    return n(i) || r(i) || !!(t && i && i[t]);
  }
  return pi = a, pi;
}
var mi, gd;
function Jo() {
  if (gd) return mi;
  gd = 1;
  var e = Uo(), r = Sg();
  function n(t, a, i, o, s) {
    var c = -1, l = t.length;
    for (i || (i = r), s || (s = []); ++c < l; ) {
      var u = t[c];
      a > 0 && i(u) ? a > 1 ? n(u, a - 1, i, o, s) : e(s, u) : o || (s[s.length] = u);
    }
    return s;
  }
  return mi = n, mi;
}
var vi, bd;
function Rg() {
  if (bd) return vi;
  bd = 1;
  function e(r, n, t) {
    switch (t.length) {
      case 0:
        return r.call(n);
      case 1:
        return r.call(n, t[0]);
      case 2:
        return r.call(n, t[0], t[1]);
      case 3:
        return r.call(n, t[0], t[1], t[2]);
    }
    return r.apply(n, t);
  }
  return vi = e, vi;
}
var gi, yd;
function Oh() {
  if (yd) return gi;
  yd = 1;
  var e = Rg(), r = Math.max;
  function n(t, a, i) {
    return a = r(a === void 0 ? t.length - 1 : a, 0), function() {
      for (var o = arguments, s = -1, c = r(o.length - a, 0), l = Array(c); ++s < c; )
        l[s] = o[a + s];
      s = -1;
      for (var u = Array(a + 1); ++s < a; )
        u[s] = o[s];
      return u[a] = i(l), e(t, this, u);
    };
  }
  return gi = n, gi;
}
var bi, xd;
function Cg() {
  if (xd) return bi;
  xd = 1;
  var e = Ho(), r = X0(), n = Ue(), t = r ? function(a, i) {
    return r(a, "toString", {
      configurable: !0,
      enumerable: !1,
      value: e(i),
      writable: !0
    });
  } : n;
  return bi = t, bi;
}
var yi, _d;
function Eg() {
  if (_d) return yi;
  _d = 1;
  var e = 800, r = 16, n = Date.now;
  function t(a) {
    var i = 0, o = 0;
    return function() {
      var s = n(), c = r - (s - o);
      if (o = s, c > 0) {
        if (++i >= e)
          return arguments[0];
      } else
        i = 0;
      return a.apply(void 0, arguments);
    };
  }
  return yi = t, yi;
}
var xi, wd;
function Mh() {
  if (wd) return xi;
  wd = 1;
  var e = Cg(), r = Eg(), n = r(e);
  return xi = n, xi;
}
var _i, Nd;
function Zr() {
  if (Nd) return _i;
  Nd = 1;
  var e = Ue(), r = Oh(), n = Mh();
  function t(a, i) {
    return n(r(a, i, e), a + "");
  }
  return _i = t, _i;
}
var wi, qd;
function Ph() {
  if (qd) return wi;
  qd = 1;
  function e(r, n, t, a) {
    for (var i = r.length, o = t + (a ? 1 : -1); a ? o-- : ++o < i; )
      if (n(r[o], o, r))
        return o;
    return -1;
  }
  return wi = e, wi;
}
var Ni, Id;
function Ag() {
  if (Id) return Ni;
  Id = 1;
  function e(r) {
    return r !== r;
  }
  return Ni = e, Ni;
}
var qi, kd;
function Tg() {
  if (kd) return qi;
  kd = 1;
  function e(r, n, t) {
    for (var a = t - 1, i = r.length; ++a < i; )
      if (r[a] === n)
        return a;
    return -1;
  }
  return qi = e, qi;
}
var Ii, Sd;
function Og() {
  if (Sd) return Ii;
  Sd = 1;
  var e = Ph(), r = Ag(), n = Tg();
  function t(a, i, o) {
    return i === i ? n(a, i, o) : e(a, r, o);
  }
  return Ii = t, Ii;
}
var ki, Rd;
function Mg() {
  if (Rd) return ki;
  Rd = 1;
  var e = Og();
  function r(n, t) {
    var a = n == null ? 0 : n.length;
    return !!a && e(n, t, 0) > -1;
  }
  return ki = r, ki;
}
var Si, Cd;
function Pg() {
  if (Cd) return Si;
  Cd = 1;
  function e(r, n, t) {
    for (var a = -1, i = r == null ? 0 : r.length; ++a < i; )
      if (t(n, r[a]))
        return !0;
    return !1;
  }
  return Si = e, Si;
}
var Ri, Ed;
function Lg() {
  if (Ed) return Ri;
  Ed = 1;
  function e() {
  }
  return Ri = e, Ri;
}
var Ci, Ad;
function Dg() {
  if (Ad) return Ci;
  Ad = 1;
  var e = ch(), r = Lg(), n = Wo(), t = 1 / 0, a = e && 1 / n(new e([, -0]))[1] == t ? function(i) {
    return new e(i);
  } : r;
  return Ci = a, Ci;
}
var Ei, Td;
function jg() {
  if (Td) return Ei;
  Td = 1;
  var e = gh(), r = Mg(), n = Pg(), t = bh(), a = Dg(), i = Wo(), o = 200;
  function s(c, l, u) {
    var d = -1, h = r, p = c.length, q = !0, g = [], v = g;
    if (u)
      q = !1, h = n;
    else if (p >= o) {
      var b = l ? null : a(c);
      if (b)
        return i(b);
      q = !1, h = t, v = new e();
    } else
      v = l ? [] : g;
    e:
      for (; ++d < p; ) {
        var m = c[d], y = l ? l(m) : m;
        if (m = u || m !== 0 ? m : 0, q && y === y) {
          for (var w = v.length; w--; )
            if (v[w] === y)
              continue e;
          l && v.push(y), g.push(m);
        } else h(v, y, u) || (v !== g && v.push(y), g.push(m));
      }
    return g;
  }
  return Ei = s, Ei;
}
var Ai, Od;
function Lh() {
  if (Od) return Ai;
  Od = 1;
  var e = Te(), r = Se();
  function n(t) {
    return r(t) && e(t);
  }
  return Ai = n, Ai;
}
var Ti, Md;
function Gg() {
  if (Md) return Ti;
  Md = 1;
  var e = Jo(), r = Zr(), n = jg(), t = Lh(), a = r(function(i) {
    return n(e(i, 1, t, !0));
  });
  return Ti = a, Ti;
}
var Oi, Pd;
function Fg() {
  if (Pd) return Oi;
  Pd = 1;
  var e = Wr();
  function r(n, t) {
    return e(t, function(a) {
      return n[a];
    });
  }
  return Oi = r, Oi;
}
var Mi, Ld;
function Dh() {
  if (Ld) return Mi;
  Ld = 1;
  var e = Fg(), r = Ge();
  function n(t) {
    return t == null ? [] : e(t, r(t));
  }
  return Mi = n, Mi;
}
var Pi, Dd;
function ye() {
  if (Dd) return Pi;
  Dd = 1;
  var e;
  if (typeof Po == "function")
    try {
      e = {
        clone: Kv(),
        constant: Ho(),
        each: vh(),
        filter: Sh(),
        has: Rh(),
        isArray: ae(),
        isEmpty: gg(),
        isFunction: gr(),
        isUndefined: Ch(),
        keys: Ge(),
        map: Ah(),
        reduce: Th(),
        size: Ig(),
        transform: kg(),
        union: Gg(),
        values: Dh()
      };
    } catch {
    }
  return e || (e = window._), Pi = e, Pi;
}
var Li, jd;
function Zo() {
  if (jd) return Li;
  jd = 1;
  var e = ye();
  Li = a;
  var r = "\0", n = "\0", t = "";
  function a(u) {
    this._isDirected = e.has(u, "directed") ? u.directed : !0, this._isMultigraph = e.has(u, "multigraph") ? u.multigraph : !1, this._isCompound = e.has(u, "compound") ? u.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[n] = {}), 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(u) {
    return this._label = u, this;
  }, a.prototype.graph = function() {
    return this._label;
  }, a.prototype.setDefaultNodeLabel = function(u) {
    return e.isFunction(u) || (u = e.constant(u)), this._defaultNodeLabelFn = u, this;
  }, a.prototype.nodeCount = function() {
    return this._nodeCount;
  }, a.prototype.nodes = function() {
    return e.keys(this._nodes);
  }, a.prototype.sources = function() {
    var u = this;
    return e.filter(this.nodes(), function(d) {
      return e.isEmpty(u._in[d]);
    });
  }, a.prototype.sinks = function() {
    var u = this;
    return e.filter(this.nodes(), function(d) {
      return e.isEmpty(u._out[d]);
    });
  }, a.prototype.setNodes = function(u, d) {
    var h = arguments, p = this;
    return e.each(u, function(q) {
      h.length > 1 ? p.setNode(q, d) : p.setNode(q);
    }), this;
  }, a.prototype.setNode = function(u, d) {
    return e.has(this._nodes, u) ? (arguments.length > 1 && (this._nodes[u] = d), this) : (this._nodes[u] = arguments.length > 1 ? d : this._defaultNodeLabelFn(u), this._isCompound && (this._parent[u] = n, this._children[u] = {}, this._children[n][u] = !0), this._in[u] = {}, this._preds[u] = {}, this._out[u] = {}, this._sucs[u] = {}, ++this._nodeCount, this);
  }, a.prototype.node = function(u) {
    return this._nodes[u];
  }, a.prototype.hasNode = function(u) {
    return e.has(this._nodes, u);
  }, a.prototype.removeNode = function(u) {
    var d = this;
    if (e.has(this._nodes, u)) {
      var h = function(p) {
        d.removeEdge(d._edgeObjs[p]);
      };
      delete this._nodes[u], this._isCompound && (this._removeFromParentsChildList(u), delete this._parent[u], e.each(this.children(u), function(p) {
        d.setParent(p);
      }), delete this._children[u]), e.each(e.keys(this._in[u]), h), delete this._in[u], delete this._preds[u], e.each(e.keys(this._out[u]), h), delete this._out[u], delete this._sucs[u], --this._nodeCount;
    }
    return this;
  }, a.prototype.setParent = function(u, d) {
    if (!this._isCompound)
      throw new Error("Cannot set parent in a non-compound graph");
    if (e.isUndefined(d))
      d = n;
    else {
      d += "";
      for (var h = d; !e.isUndefined(h); h = this.parent(h))
        if (h === u)
          throw new Error("Setting " + d + " as parent of " + u + " would create a cycle");
      this.setNode(d);
    }
    return this.setNode(u), this._removeFromParentsChildList(u), this._parent[u] = d, this._children[d][u] = !0, this;
  }, a.prototype._removeFromParentsChildList = function(u) {
    delete this._children[this._parent[u]][u];
  }, a.prototype.parent = function(u) {
    if (this._isCompound) {
      var d = this._parent[u];
      if (d !== n)
        return d;
    }
  }, a.prototype.children = function(u) {
    if (e.isUndefined(u) && (u = n), this._isCompound) {
      var d = this._children[u];
      if (d)
        return e.keys(d);
    } else {
      if (u === n)
        return this.nodes();
      if (this.hasNode(u))
        return [];
    }
  }, a.prototype.predecessors = function(u) {
    var d = this._preds[u];
    if (d)
      return e.keys(d);
  }, a.prototype.successors = function(u) {
    var d = this._sucs[u];
    if (d)
      return e.keys(d);
  }, a.prototype.neighbors = function(u) {
    var d = this.predecessors(u);
    if (d)
      return e.union(d, this.successors(u));
  }, a.prototype.isLeaf = function(u) {
    var d;
    return this.isDirected() ? d = this.successors(u) : d = this.neighbors(u), d.length === 0;
  }, a.prototype.filterNodes = function(u) {
    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(g, v) {
      u(v) && d.setNode(v, g);
    }), e.each(this._edgeObjs, function(g) {
      d.hasNode(g.v) && d.hasNode(g.w) && d.setEdge(g, h.edge(g));
    });
    var p = {};
    function q(g) {
      var v = h.parent(g);
      return v === void 0 || d.hasNode(v) ? (p[g] = v, v) : v in p ? p[v] : q(v);
    }
    return this._isCompound && e.each(d.nodes(), function(g) {
      d.setParent(g, q(g));
    }), d;
  }, a.prototype.setDefaultEdgeLabel = function(u) {
    return e.isFunction(u) || (u = e.constant(u)), this._defaultEdgeLabelFn = u, this;
  }, a.prototype.edgeCount = function() {
    return this._edgeCount;
  }, a.prototype.edges = function() {
    return e.values(this._edgeObjs);
  }, a.prototype.setPath = function(u, d) {
    var h = this, p = arguments;
    return e.reduce(u, function(q, g) {
      return p.length > 1 ? h.setEdge(q, g, d) : h.setEdge(q, g), g;
    }), this;
  }, a.prototype.setEdge = function() {
    var u, d, h, p, q = !1, g = arguments[0];
    typeof g == "object" && g !== null && "v" in g ? (u = g.v, d = g.w, h = g.name, arguments.length === 2 && (p = arguments[1], q = !0)) : (u = g, d = arguments[1], h = arguments[3], arguments.length > 2 && (p = arguments[2], q = !0)), u = "" + u, d = "" + d, e.isUndefined(h) || (h = "" + h);
    var v = s(this._isDirected, u, d, h);
    if (e.has(this._edgeLabels, v))
      return q && (this._edgeLabels[v] = p), this;
    if (!e.isUndefined(h) && !this._isMultigraph)
      throw new Error("Cannot set a named edge when isMultigraph = false");
    this.setNode(u), this.setNode(d), this._edgeLabels[v] = q ? p : this._defaultEdgeLabelFn(u, d, h);
    var b = c(this._isDirected, u, d, h);
    return u = b.v, d = b.w, Object.freeze(b), this._edgeObjs[v] = b, i(this._preds[d], u), i(this._sucs[u], d), this._in[d][v] = b, this._out[u][v] = b, this._edgeCount++, this;
  }, a.prototype.edge = function(u, d, h) {
    var p = arguments.length === 1 ? l(this._isDirected, arguments[0]) : s(this._isDirected, u, d, h);
    return this._edgeLabels[p];
  }, a.prototype.hasEdge = function(u, d, h) {
    var p = arguments.length === 1 ? l(this._isDirected, arguments[0]) : s(this._isDirected, u, d, h);
    return e.has(this._edgeLabels, p);
  }, a.prototype.removeEdge = function(u, d, h) {
    var p = arguments.length === 1 ? l(this._isDirected, arguments[0]) : s(this._isDirected, u, d, h), q = this._edgeObjs[p];
    return q && (u = q.v, d = q.w, delete this._edgeLabels[p], delete this._edgeObjs[p], o(this._preds[d], u), o(this._sucs[u], d), delete this._in[d][p], delete this._out[u][p], this._edgeCount--), this;
  }, a.prototype.inEdges = function(u, d) {
    var h = this._in[u];
    if (h) {
      var p = e.values(h);
      return d ? e.filter(p, function(q) {
        return q.v === d;
      }) : p;
    }
  }, a.prototype.outEdges = function(u, d) {
    var h = this._out[u];
    if (h) {
      var p = e.values(h);
      return d ? e.filter(p, function(q) {
        return q.w === d;
      }) : p;
    }
  }, a.prototype.nodeEdges = function(u, d) {
    var h = this.inEdges(u, d);
    if (h)
      return h.concat(this.outEdges(u, d));
  };
  function i(u, d) {
    u[d] ? u[d]++ : u[d] = 1;
  }
  function o(u, d) {
    --u[d] || delete u[d];
  }
  function s(u, d, h, p) {
    var q = "" + d, g = "" + h;
    if (!u && q > g) {
      var v = q;
      q = g, g = v;
    }
    return q + t + g + t + (e.isUndefined(p) ? r : p);
  }
  function c(u, d, h, p) {
    var q = "" + d, g = "" + h;
    if (!u && q > g) {
      var v = q;
      q = g, g = v;
    }
    var b = { v: q, w: g };
    return p && (b.name = p), b;
  }
  function l(u, d) {
    return s(u, d.v, d.w, d.name);
  }
  return Li;
}
var Di, Gd;
function zg() {
  return Gd || (Gd = 1, Di = "2.1.8"), Di;
}
var ji, Fd;
function Bg() {
  return Fd || (Fd = 1, ji = {
    Graph: Zo(),
    version: zg()
  }), ji;
}
var Gi, zd;
function Ug() {
  if (zd) return Gi;
  zd = 1;
  var e = ye(), r = Zo();
  Gi = {
    write: n,
    read: i
  };
  function n(o) {
    var s = {
      options: {
        directed: o.isDirected(),
        multigraph: o.isMultigraph(),
        compound: o.isCompound()
      },
      nodes: t(o),
      edges: a(o)
    };
    return e.isUndefined(o.graph()) || (s.value = e.clone(o.graph())), s;
  }
  function t(o) {
    return e.map(o.nodes(), function(s) {
      var c = o.node(s), l = o.parent(s), u = { v: s };
      return e.isUndefined(c) || (u.value = c), e.isUndefined(l) || (u.parent = l), u;
    });
  }
  function a(o) {
    return e.map(o.edges(), function(s) {
      var c = o.edge(s), l = { v: s.v, w: s.w };
      return e.isUndefined(s.name) || (l.name = s.name), e.isUndefined(c) || (l.value = c), l;
    });
  }
  function i(o) {
    var s = new r(o.options).setGraph(o.value);
    return e.each(o.nodes, function(c) {
      s.setNode(c.v, c.value), c.parent && s.setParent(c.v, c.parent);
    }), e.each(o.edges, function(c) {
      s.setEdge({ v: c.v, w: c.w, name: c.name }, c.value);
    }), s;
  }
  return Gi;
}
var Fi, Bd;
function $g() {
  if (Bd) return Fi;
  Bd = 1;
  var e = ye();
  Fi = r;
  function r(n) {
    var t = {}, a = [], i;
    function o(s) {
      e.has(t, s) || (t[s] = !0, i.push(s), e.each(n.successors(s), o), e.each(n.predecessors(s), o));
    }
    return e.each(n.nodes(), function(s) {
      i = [], o(s), i.length && a.push(i);
    }), a;
  }
  return Fi;
}
var zi, Ud;
function jh() {
  if (Ud) return zi;
  Ud = 1;
  var e = ye();
  zi = 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(n) {
      return n.key;
    });
  }, r.prototype.has = function(n) {
    return e.has(this._keyIndices, n);
  }, r.prototype.priority = function(n) {
    var t = this._keyIndices[n];
    if (t !== void 0)
      return this._arr[t].priority;
  }, r.prototype.min = function() {
    if (this.size() === 0)
      throw new Error("Queue underflow");
    return this._arr[0].key;
  }, r.prototype.add = function(n, t) {
    var a = this._keyIndices;
    if (n = String(n), !e.has(a, n)) {
      var i = this._arr, o = i.length;
      return a[n] = o, i.push({ key: n, priority: t }), this._decrease(o), !0;
    }
    return !1;
  }, r.prototype.removeMin = function() {
    this._swap(0, this._arr.length - 1);
    var n = this._arr.pop();
    return delete this._keyIndices[n.key], this._heapify(0), n.key;
  }, r.prototype.decrease = function(n, t) {
    var a = this._keyIndices[n];
    if (t > this._arr[a].priority)
      throw new Error("New priority is greater than current priority. Key: " + n + " Old: " + this._arr[a].priority + " New: " + t);
    this._arr[a].priority = t, this._decrease(a);
  }, r.prototype._heapify = function(n) {
    var t = this._arr, a = 2 * n, i = a + 1, o = n;
    a < t.length && (o = t[a].priority < t[o].priority ? a : o, i < t.length && (o = t[i].priority < t[o].priority ? i : o), o !== n && (this._swap(n, o), this._heapify(o)));
  }, r.prototype._decrease = function(n) {
    for (var t = this._arr, a = t[n].priority, i; n !== 0 && (i = n >> 1, !(t[i].priority < a)); )
      this._swap(n, i), n = i;
  }, r.prototype._swap = function(n, t) {
    var a = this._arr, i = this._keyIndices, o = a[n], s = a[t];
    a[n] = s, a[t] = o, i[s.key] = n, i[o.key] = t;
  }, zi;
}
var Bi, $d;
function Gh() {
  if ($d) return Bi;
  $d = 1;
  var e = ye(), r = jh();
  Bi = t;
  var n = e.constant(1);
  function t(i, o, s, c) {
    return a(
      i,
      String(o),
      s || n,
      c || function(l) {
        return i.outEdges(l);
      }
    );
  }
  function a(i, o, s, c) {
    var l = {}, u = new r(), d, h, p = function(q) {
      var g = q.v !== d ? q.v : q.w, v = l[g], b = s(q), m = h.distance + b;
      if (b < 0)
        throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + q + " Weight: " + b);
      m < v.distance && (v.distance = m, v.predecessor = d, u.decrease(g, m));
    };
    for (i.nodes().forEach(function(q) {
      var g = q === o ? 0 : Number.POSITIVE_INFINITY;
      l[q] = { distance: g }, u.add(q, g);
    }); u.size() > 0 && (d = u.removeMin(), h = l[d], h.distance !== Number.POSITIVE_INFINITY); )
      c(d).forEach(p);
    return l;
  }
  return Bi;
}
var Ui, Hd;
function Hg() {
  if (Hd) return Ui;
  Hd = 1;
  var e = Gh(), r = ye();
  Ui = n;
  function n(t, a, i) {
    return r.transform(t.nodes(), function(o, s) {
      o[s] = e(t, s, a, i);
    }, {});
  }
  return Ui;
}
var $i, Vd;
function Fh() {
  if (Vd) return $i;
  Vd = 1;
  var e = ye();
  $i = r;
  function r(n) {
    var t = 0, a = [], i = {}, o = [];
    function s(c) {
      var l = i[c] = {
        onStack: !0,
        lowlink: t,
        index: t++
      };
      if (a.push(c), n.successors(c).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 u = [], d;
        do
          d = a.pop(), i[d].onStack = !1, u.push(d);
        while (c !== d);
        o.push(u);
      }
    }
    return n.nodes().forEach(function(c) {
      e.has(i, c) || s(c);
    }), o;
  }
  return $i;
}
var Hi, Kd;
function Vg() {
  if (Kd) return Hi;
  Kd = 1;
  var e = ye(), r = Fh();
  Hi = n;
  function n(t) {
    return e.filter(r(t), function(a) {
      return a.length > 1 || a.length === 1 && t.hasEdge(a[0], a[0]);
    });
  }
  return Hi;
}
var Vi, Wd;
function Kg() {
  if (Wd) return Vi;
  Wd = 1;
  var e = ye();
  Vi = n;
  var r = e.constant(1);
  function n(a, i, o) {
    return t(
      a,
      i || r,
      o || function(s) {
        return a.outEdges(s);
      }
    );
  }
  function t(a, i, o) {
    var s = {}, c = a.nodes();
    return c.forEach(function(l) {
      s[l] = {}, s[l][l] = { distance: 0 }, c.forEach(function(u) {
        l !== u && (s[l][u] = { distance: Number.POSITIVE_INFINITY });
      }), o(l).forEach(function(u) {
        var d = u.v === l ? u.w : u.v, h = i(u);
        s[l][d] = { distance: h, predecessor: l };
      });
    }), c.forEach(function(l) {
      var u = s[l];
      c.forEach(function(d) {
        var h = s[d];
        c.forEach(function(p) {
          var q = h[l], g = u[p], v = h[p], b = q.distance + g.distance;
          b < v.distance && (v.distance = b, v.predecessor = g.predecessor);
        });
      });
    }), s;
  }
  return Vi;
}
var Ki, Yd;
function zh() {
  if (Yd) return Ki;
  Yd = 1;
  var e = ye();
  Ki = r, r.CycleException = n;
  function r(t) {
    var a = {}, i = {}, o = [];
    function s(c) {
      if (e.has(i, c))
        throw new n();
      e.has(a, c) || (i[c] = !0, a[c] = !0, e.each(t.predecessors(c), s), delete i[c], o.push(c));
    }
    if (e.each(t.sinks(), s), e.size(a) !== t.nodeCount())
      throw new n();
    return o;
  }
  function n() {
  }
  return n.prototype = new Error(), Ki;
}
var Wi, Jd;
function Wg() {
  if (Jd) return Wi;
  Jd = 1;
  var e = zh();
  Wi = r;
  function r(n) {
    try {
      e(n);
    } catch (t) {
      if (t instanceof e.CycleException)
        return !1;
      throw t;
    }
    return !0;
  }
  return Wi;
}
var Yi, Zd;
function Bh() {
  if (Zd) return Yi;
  Zd = 1;
  var e = ye();
  Yi = r;
  function r(t, a, i) {
    e.isArray(a) || (a = [a]);
    var o = (t.isDirected() ? t.successors : t.neighbors).bind(t), s = [], c = {};
    return e.each(a, function(l) {
      if (!t.hasNode(l))
        throw new Error("Graph does not have node: " + l);
      n(t, l, i === "post", c, o, s);
    }), s;
  }
  function n(t, a, i, o, s, c) {
    e.has(o, a) || (o[a] = !0, i || c.push(a), e.each(s(a), function(l) {
      n(t, l, i, o, s, c);
    }), i && c.push(a));
  }
  return Yi;
}
var Ji, Xd;
function Yg() {
  if (Xd) return Ji;
  Xd = 1;
  var e = Bh();
  Ji = r;
  function r(n, t) {
    return e(n, t, "post");
  }
  return Ji;
}
var Zi, Qd;
function Jg() {
  if (Qd) return Zi;
  Qd = 1;
  var e = Bh();
  Zi = r;
  function r(n, t) {
    return e(n, t, "pre");
  }
  return Zi;
}
var Xi, ef;
function Zg() {
  if (ef) return Xi;
  ef = 1;
  var e = ye(), r = Zo(), n = jh();
  Xi = t;
  function t(a, i) {
    var o = new r(), s = {}, c = new n(), l;
    function u(h) {
      var p = h.v === l ? h.w : h.v, q = c.priority(p);
      if (q !== void 0) {
        var g = i(h);
        g < q && (s[p] = l, c.decrease(p, g));
      }
    }
    if (a.nodeCount() === 0)
      return o;
    e.each(a.nodes(), function(h) {
      c.add(h, Number.POSITIVE_INFINITY), o.setNode(h);
    }), c.decrease(a.nodes()[0], 0);
    for (var d = !1; c.size() > 0; ) {
      if (l = c.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(u);
    }
    return o;
  }
  return Xi;
}
var Qi, rf;
function Xg() {
  return rf || (rf = 1, Qi = {
    components: $g(),
    dijkstra: Gh(),
    dijkstraAll: Hg(),
    findCycles: Vg(),
    floydWarshall: Kg(),
    isAcyclic: Wg(),
    postorder: Yg(),
    preorder: Jg(),
    prim: Zg(),
    tarjan: Fh(),
    topsort: zh()
  }), Qi;
}
var es, tf;
function Qg() {
  if (tf) return es;
  tf = 1;
  var e = Bg();
  return es = {
    Graph: e.Graph,
    json: Ug(),
    alg: Xg(),
    version: e.version
  }, es;
}
var rs, nf;
function we() {
  if (nf) return rs;
  nf = 1;
  var e;
  if (typeof Po == "function")
    try {
      e = Qg();
    } catch {
    }
  return e || (e = window.graphlib), rs = e, rs;
}
var ts, af;
function eb() {
  if (af) return ts;
  af = 1;
  var e = hh(), r = 1, n = 4;
  function t(a) {
    return e(a, r | n);
  }
  return ts = t, ts;
}
var ns, sf;
function Xr() {
  if (sf) return ns;
  sf = 1;
  var e = Ze(), r = Te(), n = Ur(), t = be();
  function a(i, o, s) {
    if (!t(s))
      return !1;
    var c = typeof o;
    return (c == "number" ? r(s) && n(o, s.length) : c == "string" && o in s) ? e(s[o], i) : !1;
  }
  return ns = a, ns;
}
var as, of;
function rb() {
  if (of) return as;
  of = 1;
  var e = Zr(), r = Ze(), n = Xr(), t = Be(), a = Object.prototype, i = a.hasOwnProperty, o = e(function(s, c) {
    s = Object(s);
    var l = -1, u = c.length, d = u > 2 ? c[2] : void 0;
    for (d && n(c[0], c[1], d) && (u = 1); ++l < u; )
      for (var h = c[l], p = t(h), q = -1, g = p.length; ++q < g; ) {
        var v = p[q], b = s[v];
        (b === void 0 || r(b, a[v]) && !i.call(s, v)) && (s[v] = h[v]);
      }
    return s;
  });
  return as = o, as;
}
var is, cf;
function tb() {
  if (cf) return is;
  cf = 1;
  var e = Oe(), r = Te(), n = Ge();
  function t(a) {
    return function(i, o, s) {
      var c = Object(i);
      if (!r(i)) {
        var l = e(o, 3);
        i = n(i), o = function(d) {
          return l(c[d], d, c);
        };
      }
      var u = a(i, o, s);
      return u > -1 ? c[l ? i[u] : u] : void 0;
    };
  }
  return is = t, is;
}
var ss, uf;
function nb() {
  if (uf) return ss;
  uf = 1;
  var e = /\s/;
  function r(n) {
    for (var t = n.length; t-- && e.test(n.charAt(t)); )
      ;
    return t;
  }
  return ss = r, ss;
}
var os, lf;
function ab() {
  if (lf) return os;
  lf = 1;
  var e = nb(), r = /^\s+/;
  function n(t) {
    return t && t.slice(0, e(t) + 1).replace(r, "");
  }
  return os = n, os;
}
var cs, df;
function ib() {
  if (df) return cs;
  df = 1;
  var e = ab(), r = be(), n = rr(), t = NaN, a = /^[-+]0x[0-9a-f]+$/i, i = /^0b[01]+$/i, o = /^0o[0-7]+$/i, s = parseInt;
  function c(l) {
    if (typeof l == "number")
      return l;
    if (n(l))
      return t;
    if (r(l)) {
      var u = typeof l.valueOf == "function" ? l.valueOf() : l;
      l = r(u) ? u + "" : u;
    }
    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) ? t : +l;
  }
  return cs = c, cs;
}
var us, ff;
function Uh() {
  if (ff) return us;
  ff = 1;
  var e = ib(), r = 1 / 0, n = 17976931348623157e292;
  function t(a) {
    if (!a)
      return a === 0 ? a : 0;
    if (a = e(a), a === r || a === -r) {
      var i = a < 0 ? -1 : 1;
      return i * n;
    }
    return a === a ? a : 0;
  }
  return us = t, us;
}
var ls, hf;
function sb() {
  if (hf) return ls;
  hf = 1;
  var e = Uh();
  function r(n) {
    var t = e(n), a = t % 1;
    return t === t ? a ? t - a : t : 0;
  }
  return ls = r, ls;
}
var ds, pf;
function ob() {
  if (pf) return ds;
  pf = 1;
  var e = Ph(), r = Oe(), n = sb(), t = Math.max;
  function a(i, o, s) {
    var c = i == null ? 0 : i.length;
    if (!c)
      return -1;
    var l = s == null ? 0 : n(s);
    return l < 0 && (l = t(c + l, 0)), e(i, r(o, 3), l);
  }
  return ds = a, ds;
}
var fs, mf;
function cb() {
  if (mf) return fs;
  mf = 1;
  var e = tb(), r = ob(), n = e(r);
  return fs = n, fs;
}
var hs, vf;
function $h() {
  if (vf) return hs;
  vf = 1;
  var e = Jo();
  function r(n) {
    var t = n == null ? 0 : n.length;
    return t ? e(n, 1) : [];
  }
  return hs = r, hs;
}
var ps, gf;
function ub() {
  if (gf) return ps;
  gf = 1;
  var e = Vo(), r = ph(), n = Be();
  function t(a, i) {
    return a == null ? a : e(a, r(i), n);
  }
  return ps = t, ps;
}
var ms, bf;
function lb() {
  if (bf) return ms;
  bf = 1;
  function e(r) {
    var n = r == null ? 0 : r.length;
    return n ? r[n - 1] : void 0;
  }
  return ms = e, ms;
}
var vs, yf;
function db() {
  if (yf) return vs;
  yf = 1;
  var e = zr(), r = Ko(), n = Oe();
  function t(a, i) {
    var o = {};
    return i = n(i, 3), r(a, function(s, c, l) {
      e(o, c, i(s, c, l));
    }), o;
  }
  return vs = t, vs;
}
var gs, xf;
function Xo() {
  if (xf) return gs;
  xf = 1;
  var e = rr();
  function r(n, t, a) {
    for (var i = -1, o = n.length; ++i < o; ) {
      var s = n[i], c = t(s);
      if (c != null && (l === void 0 ? c === c && !e(c) : a(c, l)))
        var l = c, u = s;
    }
    return u;
  }
  return gs = r, gs;
}
var bs, _f;
function fb() {
  if (_f) return bs;
  _f = 1;
  function e(r, n) {
    return r > n;
  }
  return bs = e, bs;
}
var ys, wf;
function hb() {
  if (wf) return ys;
  wf = 1;
  var e = Xo(), r = fb(), n = Ue();
  function t(a) {
    return a && a.length ? e(a, n, r) : void 0;
  }
  return ys = t, ys;
}
var xs, Nf;
function Hh() {
  if (Nf) return xs;
  Nf = 1;
  var e = zr(), r = Ze();
  function n(t, a, i) {
    (i !== void 0 && !r(t[a], i) || i === void 0 && !(a in t)) && e(t, a, i);
  }
  return xs = n, xs;
}
var _s, qf;
function pb() {
  if (qf) return _s;
  qf = 1;
  var e = Fe(), r = Vr(), n = Se(), t = "[object Object]", a = Function.prototype, i = Object.prototype, o = a.toString, s = i.hasOwnProperty, c = o.call(Object);
  function l(u) {
    if (!n(u) || e(u) != t)
      return !1;
    var d = r(u);
    if (d === null)
      return !0;
    var h = s.call(d, "constructor") && d.constructor;
    return typeof h == "function" && h instanceof h && o.call(h) == c;
  }
  return _s = l, _s;
}
var ws, If;
function Vh() {
  if (If) return ws;
  If = 1;
  function e(r, n) {
    if (!(n === "constructor" && typeof r[n] == "function") && n != "__proto__")
      return r[n];
  }
  return ws = e, ws;
}
var Ns, kf;
function mb() {
  if (kf) return Ns;
  kf = 1;
  var e = br(), r = Be();
  function n(t) {
    return e(t, r(t));
  }
  return Ns = n, Ns;
}
var qs, Sf;
function vb() {
  if (Sf) return qs;
  Sf = 1;
  var e = Hh(), r = rh(), n = lh(), t = th(), a = fh(), i = yr(), o = ae(), s = Lh(), c = Qe(), l = gr(), u = be(), d = pb(), h = xr(), p = Vh(), q = mb();
  function g(v, b, m, y, w, N, I) {
    var _ = p(v, m), R = p(b, m), k = I.get(R);
    if (k) {
      e(v, m, k);
      return;
    }
    var S = N ? N(_, R, m + "", v, b, I) : void 0, E = S === void 0;
    if (E) {
      var A = o(R), P = !A && c(R), z = !A && !P && h(R);
      S = R, A || P || z ? o(_) ? S = _ : s(_) ? S = t(_) : P ? (E = !1, S = r(R, !0)) : z ? (E = !1, S = n(R, !0)) : S = [] : d(R) || i(R) ? (S = _, i(_) ? S = q(_) : (!u(_) || l(_)) && (S = a(R))) : E = !1;
    }
    E && (I.set(R, S), w(S, R, y, N, I), I.delete(R)), e(v, m, S);
  }
  return qs = g, qs;
}
var Is, Rf;
function gb() {
  if (Rf) return Is;
  Rf = 1;
  var e = Fr(), r = Hh(), n = Vo(), t = vb(), a = be(), i = Be(), o = Vh();
  function s(c, l, u, d, h) {
    c !== l && n(l, function(p, q) {
      if (h || (h = new e()), a(p))
        t(c, l, q, u, s, d, h);
      else {
        var g = d ? d(o(c, q), p, q + "", c, l, h) : void 0;
        g === void 0 && (g = p), r(c, q, g);
      }
    }, i);
  }
  return Is = s, Is;
}
var ks, Cf;
function bb() {
  if (Cf) return ks;
  Cf = 1;
  var e = Zr(), r = Xr();
  function n(t) {
    return e(function(a, i) {
      var o = -1, s = i.length, c = s > 1 ? i[s - 1] : void 0, l = s > 2 ? i[2] : void 0;
      for (c = t.length > 3 && typeof c == "function" ? (s--, c) : void 0, l && r(i[0], i[1], l) && (c = s < 3 ? void 0 : c, s = 1), a = Object(a); ++o < s; ) {
        var u = i[o];
        u && t(a, u, o, c);
      }
      return a;
    });
  }
  return ks = n, ks;
}
var Ss, Ef;
function yb() {
  if (Ef) return Ss;
  Ef = 1;
  var e = gb(), r = bb(), n = r(function(t, a, i) {
    e(t, a, i);
  });
  return Ss = n, Ss;
}
var Rs, Af;
function Kh() {
  if (Af) return Rs;
  Af = 1;
  function e(r, n) {
    return r < n;
  }
  return Rs = e, Rs;
}
var Cs, Tf;
function xb() {
  if (Tf) return Cs;
  Tf = 1;
  var e = Xo(), r = Kh(), n = Ue();
  function t(a) {
    return a && a.length ? e(a, n, r) : void 0;
  }
  return Cs = t, Cs;
}
var Es, Of;
function _b() {
  if (Of) return Es;
  Of = 1;
  var e = Xo(), r = Oe(), n = Kh();
  function t(a, i) {
    return a && a.length ? e(a, r(i, 2), n) : void 0;
  }
  return Es = t, Es;
}
var As, Mf;
function wb() {
  if (Mf) return As;
  Mf = 1;
  var e = Ne(), r = function() {
    return e.Date.now();
  };
  return As = r, As;
}
var Ts, Pf;
function Nb() {
  if (Pf) return Ts;
  Pf = 1;
  var e = Br(), r = Yr(), n = Ur(), t = be(), a = _r();
  function i(o, s, c, l) {
    if (!t(o))
      return o;
    s = r(s, o);
    for (var u = -1, d = s.length, h = d - 1, p = o; p != null && ++u < d; ) {
      var q = a(s[u]), g = c;
      if (q === "__proto__" || q === "constructor" || q === "prototype")
        return o;
      if (u != h) {
        var v = p[q];
        g = l ? l(v, q, p) : void 0, g === void 0 && (g = t(v) ? v : n(s[u + 1]) ? [] : {});
      }
      e(p, q, g), p = p[q];
    }
    return o;
  }
  return Ts = i, Ts;
}
var Os, Lf;
function qb() {
  if (Lf) return Os;
  Lf = 1;
  var e = Jr(), r = Nb(), n = Yr();
  function t(a, i, o) {
    for (var s = -1, c = i.length, l = {}; ++s < c; ) {
      var u = i[s], d = e(a, u);
      o(d, u) && r(l, n(u, a), d);
    }
    return l;
  }
  return Os = t, Os;
}
var Ms, Df;
function Ib() {
  if (Df) return Ms;
  Df = 1;
  var e = qb(), r = Ih();
  function n(t, a) {
    return e(t, a, function(i, o) {
      return r(t, o);
    });
  }
  return Ms = n, Ms;
}
var Ps, jf;
function kb() {
  if (jf) return Ps;
  jf = 1;
  var e = $h(), r = Oh(), n = Mh();
  function t(a) {
    return n(r(a, void 0, e), a + "");
  }
  return Ps = t, Ps;
}
var Ls, Gf;
function Sb() {
  if (Gf) return Ls;
  Gf = 1;
  var e = Ib(), r = kb(), n = r(function(t, a) {
    return t == null ? {} : e(t, a);
  });
  return Ls = n, Ls;
}
var Ds, Ff;
function Rb() {
  if (Ff) return Ds;
  Ff = 1;
  var e = Math.ceil, r = Math.max;
  function n(t, a, i, o) {
    for (var s = -1, c = r(e((a - t) / (i || 1)), 0), l = Array(c); c--; )
      l[o ? c : ++s] = t, t += i;
    return l;
  }
  return Ds = n, Ds;
}
var js, zf;
function Cb() {
  if (zf) return js;
  zf = 1;
  var e = Rb(), r = Xr(), n = Uh();
  function t(a) {
    return function(i, o, s) {
      return s && typeof s != "number" && r(i, o, s) && (o = s = void 0), i = n(i), o === void 0 ? (o = i, i = 0) : o = n(o), s = s === void 0 ? i < o ? 1 : -1 : n(s), e(i, o, s, a);
    };
  }
  return js = t, js;
}
var Gs, Bf;
function Eb() {
  if (Bf) return Gs;
  Bf = 1;
  var e = Cb(), r = e();
  return Gs = r, Gs;
}
var Fs, Uf;
function Ab() {
  if (Uf) return Fs;
  Uf = 1;
  function e(r, n) {
    var t = r.length;
    for (r.sort(n); t--; )
      r[t] = r[t].value;
    return r;
  }
  return Fs = e, Fs;
}
var zs, $f;
function Tb() {
  if ($f) return zs;
  $f = 1;
  var e = rr();
  function r(n, t) {
    if (n !== t) {
      var a = n !== void 0, i = n === null, o = n === n, s = e(n), c = t !== void 0, l = t === null, u = t === t, d = e(t);
      if (!l && !d && !s && n > t || s && c && u && !l && !d || i && c && u || !a && u || !o)
        return 1;
      if (!i && !s && !d && n < t || d && a && o && !i && !s || l && a && o || !c && o || !u)
        return -1;
    }
    return 0;
  }
  return zs = r, zs;
}
var Bs, Hf;
function Ob() {
  if (Hf) return Bs;
  Hf = 1;
  var e = Tb();
  function r(n, t, a) {
    for (var i = -1, o = n.criteria, s = t.criteria, c = o.length, l = a.length; ++i < c; ) {
      var u = e(o[i], s[i]);
      if (u) {
        if (i >= l)
          return u;
        var d = a[i];
        return u * (d == "desc" ? -1 : 1);
      }
    }
    return n.index - t.index;
  }
  return Bs = r, Bs;
}
var Us, Vf;
function Mb() {
  if (Vf) return Us;
  Vf = 1;
  var e = Wr(), r = Jr(), n = Oe(), t = Eh(), a = Ab(), i = $r(), o = Ob(), s = Ue(), c = ae();
  function l(u, d, h) {
    d.length ? d = e(d, function(g) {
      return c(g) ? function(v) {
        return r(v, g.length === 1 ? g[0] : g);
      } : g;
    }) : d = [s];
    var p = -1;
    d = e(d, i(n));
    var q = t(u, function(g, v, b) {
      var m = e(d, function(y) {
        return y(g);
      });
      return { criteria: m, index: ++p, value: g };
    });
    return a(q, function(g, v) {
      return o(g, v, h);
    });
  }
  return Us = l, Us;
}
var $s, Kf;
function Pb() {
  if (Kf) return $s;
  Kf = 1;
  var e = Jo(), r = Mb(), n = Zr(), t = Xr(), a = n(function(i, o) {
    if (i == null)
      return [];
    var s = o.length;
    return s > 1 && t(i, o[0], o[1]) ? o = [] : s > 2 && t(o[0], o[1], o[2]) && (o = [o[0]]), r(i, e(o, 1), []);
  });
  return $s = a, $s;
}
var Hs, Wf;
function Lb() {
  if (Wf) return Hs;
  Wf = 1;
  var e = Nh(), r = 0;
  function n(t) {
    var a = ++r;
    return e(t) + a;
  }
  return Hs = n, Hs;
}
var Vs, Yf;
function Db() {
  if (Yf) return Vs;
  Yf = 1;
  function e(r, n, t) {
    for (var a = -1, i = r.length, o = n.length, s = {}; ++a < i; ) {
      var c = a < o ? n[a] : void 0;
      t(s, r[a], c);
    }
    return s;
  }
  return Vs = e, Vs;
}
var Ks, Jf;
function jb() {
  if (Jf) return Ks;
  Jf = 1;
  var e = Br(), r = Db();
  function n(t, a) {
    return r(t || [], a || [], e);
  }
  return Ks = n, Ks;
}
var Ws, Zf;
function te() {
  if (Zf) return Ws;
  Zf = 1;
  var e;
  if (typeof Po == "function")
    try {
      e = {
        cloneDeep: eb(),
        constant: Ho(),
        defaults: rb(),
        each: vh(),
        filter: Sh(),
        find: cb(),
        flatten: $h(),
        forEach: mh(),
        forIn: ub(),
        has: Rh(),
        isUndefined: Ch(),
        last: lb(),
        map: Ah(),
        mapValues: db(),
        max: hb(),
        merge: yb(),
        min: xb(),
        minBy: _b(),
        now: wb(),
        pick: Sb(),
        range: Eb(),
        reduce: Th(),
        sortBy: Pb(),
        uniqueId: Lb(),
        values: Dh(),
        zipObject: jb()
      };
    } catch {
    }
  return e || (e = window._), Ws = e, Ws;
}
var Ys, Xf;
function Gb() {
  if (Xf) return Ys;
  Xf = 1, Ys = e;
  function e() {
    var t = {};
    t._next = t._prev = t, this._sentinel = t;
  }
  e.prototype.dequeue = function() {
    var t = this._sentinel, a = t._prev;
    if (a !== t)
      return r(a), a;
  }, e.prototype.enqueue = function(t) {
    var a = this._sentinel;
    t._prev && t._next && r(t), t._next = a._next, a._next._prev = t, a._next = t, t._prev = a;
  }, e.prototype.toString = function() {
    for (var t = [], a = this._sentinel, i = a._prev; i !== a; )
      t.push(JSON.stringify(i, n)), i = i._prev;
    return "[" + t.join(", ") + "]";
  };
  function r(t) {
    t._prev._next = t._next, t._next._prev = t._prev, delete t._next, delete t._prev;
  }
  function n(t, a) {
    if (t !== "_next" && t !== "_prev")
      return a;
  }
  return Ys;
}
var Js, Qf;
function Fb() {
  if (Qf) return Js;
  Qf = 1;
  var e = te(), r = we().Graph, n = Gb();
  Js = a;
  var t = e.constant(1);
  function a(l, u) {
    if (l.nodeCount() <= 1)
      return [];
    var d = s(l, u || t), 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, u, d) {
    for (var h = [], p = u[u.length - 1], q = u[0], g; l.nodeCount(); ) {
      for (; g = q.dequeue(); )
        o(l, u, d, g);
      for (; g = p.dequeue(); )
        o(l, u, d, g);
      if (l.nodeCount()) {
        for (var v = u.length - 2; v > 0; --v)
          if (g = u[v].dequeue(), g) {
            h = h.concat(o(l, u, d, g, !0));
            break;
          }
      }
    }
    return h;
  }
  function o(l, u, d, h, p) {
    var q = p ? [] : void 0;
    return e.forEach(l.inEdges(h.v), function(g) {
      var v = l.edge(g), b = l.node(g.v);
      p && q.push({ v: g.v, w: g.w }), b.out -= v, c(u, d, b);
    }), e.forEach(l.outEdges(h.v), function(g) {
      var v = l.edge(g), b = g.w, m = l.node(b);
      m.in -= v, c(u, d, m);
    }), l.removeNode(h.v), q;
  }
  function s(l, u) {
    var d = new r(), h = 0, p = 0;
    e.forEach(l.nodes(), function(v) {
      d.setNode(v, { v, in: 0, out: 0 });
    }), e.forEach(l.edges(), function(v) {
      var b = d.edge(v.v, v.w) || 0, m = u(v), y = b + m;
      d.setEdge(v.v, v.w, y), p = Math.max(p, d.node(v.v).out += m), h = Math.max(h, d.node(v.w).in += m);
    });
    var q = e.range(p + h + 3).map(function() {
      return new n();
    }), g = h + 1;
    return e.forEach(d.nodes(), function(v) {
      c(q, g, d.node(v));
    }), { graph: d, buckets: q, zeroIdx: g };
  }
  function c(l, u, d) {
    d.out ? d.in ? l[d.out - d.in + u].enqueue(d) : l[l.length - 1].enqueue(d) : l[0].enqueue(d);
  }
  return Js;
}
var Zs, e0;
function zb() {
  if (e0) return Zs;
  e0 = 1;
  var e = te(), r = Fb();
  Zs = {
    run: n,
    undo: a
  };
  function n(i) {
    var o = i.graph().acyclicer === "greedy" ? r(i, s(i)) : t(i);
    e.forEach(o, function(c) {
      var l = i.edge(c);
      i.removeEdge(c), l.forwardName = c.name, l.reversed = !0, i.setEdge(c.w, c.v, l, e.uniqueId("rev"));
    });
    function s(c) {
      return function(l) {
        return c.edge(l).weight;
      };
    }
  }
  function t(i) {
    var o = [], s = {}, c = {};
    function l(u) {
      e.has(c, u) || (c[u] = !0, s[u] = !0, e.forEach(i.outEdges(u), function(d) {
        e.has(s, d.w) ? o.push(d) : l(d.w);
      }), delete s[u]);
    }
    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 c = s.forwardName;
        delete s.reversed, delete s.forwardName, i.setEdge(o.w, o.v, s, c);
      }
    });
  }
  return Zs;
}
var Xs, r0;
function ve() {
  if (r0) return Xs;
  r0 = 1;
  var e = te(), r = we().Graph;
  Xs = {
    addDummyNode: n,
    simplify: t,
    asNonCompoundGraph: a,
    successorWeights: i,
    predecessorWeights: o,
    intersectRect: s,
    buildLayerMatrix: c,
    normalizeRanks: l,
    removeEmptyRanks: u,
    addBorderNode: d,
    maxRank: h,
    partition: p,
    time: q,
    notime: g
  };
  function n(v, b, m, y) {
    var w;
    do
      w = e.uniqueId(y);
    while (v.hasNode(w));
    return m.dummy = b, v.setNode(w, m), w;
  }
  function t(v) {
    var b = new r().setGraph(v.graph());
    return e.forEach(v.nodes(), function(m) {
      b.setNode(m, v.node(m));
    }), e.forEach(v.edges(), function(m) {
      var y = b.edge(m.v, m.w) || { weight: 0, minlen: 1 }, w = v.edge(m);
      b.setEdge(m.v, m.w, {
        weight: y.weight + w.weight,
        minlen: Math.max(y.minlen, w.minlen)
      });
    }), b;
  }
  function a(v) {
    var b = new r({ multigraph: v.isMultigraph() }).setGraph(v.graph());
    return e.forEach(v.nodes(), function(m) {
      v.children(m).length || b.setNode(m, v.node(m));
    }), e.forEach(v.edges(), function(m) {
      b.setEdge(m, v.edge(m));
    }), b;
  }
  function i(v) {
    var b = e.map(v.nodes(), function(m) {
      var y = {};
      return e.forEach(v.outEdges(m), function(w) {
        y[w.w] = (y[w.w] || 0) + v.edge(w).weight;
      }), y;
    });
    return e.zipObject(v.nodes(), b);
  }
  function o(v) {
    var b = e.map(v.nodes(), function(m) {
      var y = {};
      return e.forEach(v.inEdges(m), function(w) {
        y[w.v] = (y[w.v] || 0) + v.edge(w).weight;
      }), y;
    });
    return e.zipObject(v.nodes(), b);
  }
  function s(v, b) {
    var m = v.x, y = v.y, w = b.x - m, N = b.y - y, I = v.width / 2, _ = v.height / 2;
    if (!w && !N)
      throw new Error("Not possible to find intersection inside of the rectangle");
    var R, k;
    return Math.abs(N) * I > Math.abs(w) * _ ? (N < 0 && (_ = -_), R = _ * w / N, k = _) : (w < 0 && (I = -I), R = I, k = I * N / w), { x: m + R, y: y + k };
  }
  function c(v) {
    var b = e.map(e.range(h(v) + 1), function() {
      return [];
    });
    return e.forEach(v.nodes(), function(m) {
      var y = v.node(m), w = y.rank;
      e.isUndefined(w) || (b[w][y.order] = m);
    }), b;
  }
  function l(v) {
    var b = e.min(e.map(v.nodes(), function(m) {
      return v.node(m).rank;
    }));
    e.forEach(v.nodes(), function(m) {
      var y = v.node(m);
      e.has(y, "rank") && (y.rank -= b);
    });
  }
  function u(v) {
    var b = e.min(e.map(v.nodes(), function(N) {
      return v.node(N).rank;
    })), m = [];
    e.forEach(v.nodes(), function(N) {
      var I = v.node(N).rank - b;
      m[I] || (m[I] = []), m[I].push(N);
    });
    var y = 0, w = v.graph().nodeRankFactor;
    e.forEach(m, function(N, I) {
      e.isUndefined(N) && I % w !== 0 ? --y : y && e.forEach(N, function(_) {
        v.node(_).rank += y;
      });
    });
  }
  function d(v, b, m, y) {
    var w = {
      width: 0,
      height: 0
    };
    return arguments.length >= 4 && (w.rank = m, w.order = y), n(v, "border", w, b);
  }
  function h(v) {
    return e.max(e.map(v.nodes(), function(b) {
      var m = v.node(b).rank;
      if (!e.isUndefined(m))
        return m;
    }));
  }
  function p(v, b) {
    var m = { lhs: [], rhs: [] };
    return e.forEach(v, function(y) {
      b(y) ? m.lhs.push(y) : m.rhs.push(y);
    }), m;
  }
  function q(v, b) {
    var m = e.now();
    try {
      return b();
    } finally {
      console.log(v + " time: " + (e.now() - m) + "ms");
    }
  }
  function g(v, b) {
    return b();
  }
  return Xs;
}
var Qs, t0;
function Bb() {
  if (t0) return Qs;
  t0 = 1;
  var e = te(), r = ve();
  Qs = {
    run: n,
    undo: a
  };
  function n(i) {
    i.graph().dummyChains = [], e.forEach(i.edges(), function(o) {
      t(i, o);
    });
  }
  function t(i, o) {
    var s = o.v, c = i.node(s).rank, l = o.w, u = i.node(l).rank, d = o.name, h = i.edge(o), p = h.labelRank;
    if (u !== c + 1) {
      i.removeEdge(o);
      var q, g, v;
      for (v = 0, ++c; c < u; ++v, ++c)
        h.points = [], g = {
          width: 0,
          height: 0,
          edgeLabel: h,
          edgeObj: o,
          rank: c
        }, q = r.addDummyNode(i, "edge", g, "_d"), c === p && (g.width = h.width, g.height = h.height, g.dummy = "edge-label", g.labelpos = h.labelpos), i.setEdge(s, q, { weight: h.weight }, d), v === 0 && i.graph().dummyChains.push(q), s = q;
      i.setEdge(s, l, { weight: h.weight }, d);
    }
  }
  function a(i) {
    e.forEach(i.graph().dummyChains, function(o) {
      var s = i.node(o), c = s.edgeLabel, l;
      for (i.setEdge(s.edgeObj, c); s.dummy; )
        l = i.successors(o)[0], i.removeNode(o), c.points.push({ x: s.x, y: s.y }), s.dummy === "edge-label" && (c.x = s.x, c.y = s.y, c.width = s.width, c.height = s.height), o = l, s = i.node(o);
    });
  }
  return Qs;
}
var eo, n0;
function Tr() {
  if (n0) return eo;
  n0 = 1;
  var e = te();
  eo = {
    longestPath: r,
    slack: n
  };
  function r(t) {
    var a = {};
    function i(o) {
      var s = t.node(o);
      if (e.has(a, o))
        return s.rank;
      a[o] = !0;
      var c = e.min(e.map(t.outEdges(o), function(l) {
        return i(l.w) - t.edge(l).minlen;
      }));
      return (c === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3
      c === void 0 || // return value of _.map([]) for Lodash 4
      c === null) && (c = 0), s.rank = c;
    }
    e.forEach(t.sources(), i);
  }
  function n(t, a) {
    return t.node(a.w).rank - t.node(a.v).rank - t.edge(a).minlen;
  }
  return eo;
}
var ro, a0;
function Wh() {
  if (a0) return ro;
  a0 = 1;
  var e = te(), r = we().Graph, n = Tr().slack;
  ro = t;
  function t(s) {
    var c = new r({ directed: !1 }), l = s.nodes()[0], u = s.nodeCount();
    c.setNode(l, {});
    for (var d, h; a(c, s) < u; )
      d = i(c, s), h = c.hasNode(d.v) ? n(s, d) : -n(s, d), o(c, s, h);
    return c;
  }
  function a(s, c) {
    function l(u) {
      e.forEach(c.nodeEdges(u), function(d) {
        var h = d.v, p = u === h ? d.w : h;
        !s.hasNode(p) && !n(c, d) && (s.setNode(p, {}), s.setEdge(u, p, {}), l(p));
      });
    }
    return e.forEach(s.nodes(), l), s.nodeCount();
  }
  function i(s, c) {
    return e.minBy(c.edges(), function(l) {
      if (s.hasNode(l.v) !== s.hasNode(l.w))
        return n(c, l);
    });
  }
  function o(s, c, l) {
    e.forEach(s.nodes(), function(u) {
      c.node(u).rank += l;
    });
  }
  return ro;
}
var to, i0;
function Ub() {
  if (i0) return to;
  i0 = 1;
  var e = te(), r = Wh(), n = Tr().slack, t = Tr().longestPath, a = we().alg.preorder, i = we().alg.postorder, o = ve().simplify;
  to = s, s.initLowLimValues = d, s.initCutValues = c, s.calcCutValue = u, s.leaveEdge = p, s.enterEdge = q, s.exchangeEdges = g;
  function s(y) {
    y = o(y), t(y);
    var w = r(y);
    d(w), c(w, y);
    for (var N, I; N = p(w); )
      I = q(w, y, N), g(w, y, N, I);
  }
  function c(y, w) {
    var N = i(y, y.nodes());
    N = N.slice(0, N.length - 1), e.forEach(N, function(I) {
      l(y, w, I);
    });
  }
  function l(y, w, N) {
    var I = y.node(N), _ = I.parent;
    y.edge(N, _).cutvalue = u(y, w, N);
  }
  function u(y, w, N) {
    var I = y.node(N), _ = I.parent, R = !0, k = w.edge(N, _), S = 0;
    return k || (R = !1, k = w.edge(_, N)), S = k.weight, e.forEach(w.nodeEdges(N), function(E) {
      var A = E.v === N, P = A ? E.w : E.v;
      if (P !== _) {
        var z = A === R, F = w.edge(E).weight;
        if (S += z ? F : -F, b(y, N, P)) {
          var J = y.edge(N, P).cutvalue;
          S += z ? -J : J;
        }
      }
    }), S;
  }
  function d(y, w) {
    arguments.length < 2 && (w = y.nodes()[0]), h(y, {}, 1, w);
  }
  function h(y, w, N, I, _) {
    var R = N, k = y.node(I);
    return w[I] = !0, e.forEach(y.neighbors(I), function(S) {
      e.has(w, S) || (N = h(y, w, N, S, I));
    }), k.low = R, k.lim = N++, _ ? k.parent = _ : delete k.parent, N;
  }
  function p(y) {
    return e.find(y.edges(), function(w) {
      return y.edge(w).cutvalue < 0;
    });
  }
  function q(y, w, N) {
    var I = N.v, _ = N.w;
    w.hasEdge(I, _) || (I = N.w, _ = N.v);
    var R = y.node(I), k = y.node(_), S = R, E = !1;
    R.lim > k.lim && (S = k, E = !0);
    var A = e.filter(w.edges(), function(P) {
      return E === m(y, y.node(P.v), S) && E !== m(y, y.node(P.w), S);
    });
    return e.minBy(A, function(P) {
      return n(w, P);
    });
  }
  function g(y, w, N, I) {
    var _ = N.v, R = N.w;
    y.removeEdge(_, R), y.setEdge(I.v, I.w, {}), d(y), c(y, w), v(y, w);
  }
  function v(y, w) {
    var N = e.find(y.nodes(), function(_) {
      return !w.node(_).parent;
    }), I = a(y, N);
    I = I.slice(1), e.forEach(I, function(_) {
      var R = y.node(_).parent, k = w.edge(_, R), S = !1;
      k || (k = w.edge(R, _), S = !0), w.node(_).rank = w.node(R).rank + (S ? k.minlen : -k.minlen);
    });
  }
  function b(y, w, N) {
    return y.hasEdge(w, N);
  }
  function m(y, w, N) {
    return N.low <= w.lim && w.lim <= N.lim;
  }
  return to;
}
var no, s0;
function $b() {
  if (s0) return no;
  s0 = 1;
  var e = Tr(), r = e.longestPath, n = Wh(), t = Ub();
  no = a;
  function a(c) {
    switch (c.graph().ranker) {
      case "network-simplex":
        s(c);
        break;
      case "tight-tree":
        o(c);
        break;
      case "longest-path":
        i(c);
        break;
      default:
        s(c);
    }
  }
  var i = r;
  function o(c) {
    r(c), n(c);
  }
  function s(c) {
    t(c);
  }
  return no;
}
var ao, o0;
function Hb() {
  if (o0) return ao;
  o0 = 1;
  var e = te();
  ao = r;
  function r(a) {
    var i = t(a);
    e.forEach(a.graph().dummyChains, function(o) {
      for (var s = a.node(o), c = s.edgeObj, l = n(a, i, c.v, c.w), u = l.path, d = l.lca, h = 0, p = u[h], q = !0; o !== c.w; ) {
        if (s = a.node(o), q) {
          for (; (p = u[h]) !== d && a.node(p).maxRank < s.rank; )
            h++;
          p === d && (q = !1);
        }
        if (!q) {
          for (; h < u.length - 1 && a.node(p = u[h + 1]).minRank <= s.rank; )
            h++;
          p = u[h];
        }
        a.setParent(o, p), o = a.successors(o)[0];
      }
    });
  }
  function n(a, i, o, s) {
    var c = [], l = [], u = 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), c.push(h);
    while (h && (i[h].low > u || d > i[h].lim));
    for (p = h, h = s; (h = a.parent(h)) !== p; )
      l.push(h);
    return { path: c.concat(l.reverse()), lca: p };
  }
  function t(a) {
    var i = {}, o = 0;
    function s(c) {
      var l = o;
      e.forEach(a.children(c), s), i[c] = { low: l, lim: o++ };
    }
    return e.forEach(a.children(), s), i;
  }
  return ao;
}
var io, c0;
function Vb() {
  if (c0) return io;
  c0 = 1;
  var e = te(), r = ve();
  io = {
    run: n,
    cleanup: o
  };
  function n(s) {
    var c = r.addDummyNode(s, "root", {}, "_root"), l = a(s), u = e.max(e.values(l)) - 1, d = 2 * u + 1;
    s.graph().nestingRoot = c, e.forEach(s.edges(), function(p) {
      s.edge(p).minlen *= d;
    });
    var h = i(s) + 1;
    e.forEach(s.children(), function(p) {
      t(s, c, d, h, u, l, p);
    }), s.graph().nodeRankFactor = d;
  }
  function t(s, c, l, u, d, h, p) {
    var q = s.children(p);
    if (!q.length) {
      p !== c && s.setEdge(c, p, { weight: 0, minlen: l });
      return;
    }
    var g = r.addBorderNode(s, "_bt"), v = r.addBorderNode(s, "_bb"), b = s.node(p);
    s.setParent(g, p), b.borderTop = g, s.setParent(v, p), b.borderBottom = v, e.forEach(q, function(m) {
      t(s, c, l, u, d, h, m);
      var y = s.node(m), w = y.borderTop ? y.borderTop : m, N = y.borderBottom ? y.borderBottom : m, I = y.borderTop ? u : 2 * u, _ = w !== N ? 1 : d - h[p] + 1;
      s.setEdge(g, w, {
        weight: I,
        minlen: _,
        nestingEdge: !0
      }), s.setEdge(N, v, {
        weight: I,
        minlen: _,
        nestingEdge: !0
      });
    }), s.parent(p) || s.setEdge(c, g, { weight: 0, minlen: d + h[p] });
  }
  function a(s) {
    var c = {};
    function l(u, d) {
      var h = s.children(u);
      h && h.length && e.forEach(h, function(p) {
        l(p, d + 1);
      }), c[u] = d;
    }
    return e.forEach(s.children(), function(u) {
      l(u, 1);
    }), c;
  }
  function i(s) {
    return e.reduce(s.edges(), function(c, l) {
      return c + s.edge(l).weight;
    }, 0);
  }
  function o(s) {
    var c = s.graph();
    s.removeNode(c.nestingRoot), delete c.nestingRoot, e.forEach(s.edges(), function(l) {
      var u = s.edge(l);
      u.nestingEdge && s.removeEdge(l);
    });
  }
  return io;
}
var so, u0;
function Kb() {
  if (u0) return so;
  u0 = 1;
  var e = te(), r = ve();
  so = n;
  function n(a) {
    function i(o) {
      var s = a.children(o), c = a.node(o);
      if (s.length && e.forEach(s, i), e.has(c, "minRank")) {
        c.borderLeft = [], c.borderRight = [];
        for (var l = c.minRank, u = c.maxRank + 1; l < u; ++l)
          t(a, "borderLeft", "_bl", o, c, l), t(a, "borderRight", "_br", o, c, l);
      }
    }
    e.forEach(a.children(), i);
  }
  function t(a, i, o, s, c, l) {
    var u = { width: 0, height: 0, rank: l, borderType: i }, d = c[i][l - 1], h = r.addDummyNode(a, "border", u, o);
    c[i][l] = h, a.setParent(h, s), d && a.setEdge(d, h, { weight: 1 });
  }
  return so;
}
var oo, l0;
function Wb() {
  if (l0) return oo;
  l0 = 1;
  var e = te();
  oo = {
    adjust: r,
    undo: n
  };
  function r(l) {
    var u = l.graph().rankdir.toLowerCase();
    (u === "lr" || u === "rl") && t(l);
  }
  function n(l) {
    var u = l.graph().rankdir.toLowerCase();
    (u === "bt" || u === "rl") && i(l), (u === "lr" || u === "rl") && (s(l), t(l));
  }
  function t(l) {
    e.forEach(l.nodes(), function(u) {
      a(l.node(u));
    }), e.forEach(l.edges(), function(u) {
      a(l.edge(u));
    });
  }
  function a(l) {
    var u = l.width;
    l.width = l.height, l.height = u;
  }
  function i(l) {
    e.forEach(l.nodes(), function(u) {
      o(l.node(u));
    }), e.forEach(l.edges(), function(u) {
      var d = l.edge(u);
      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(u) {
      c(l.node(u));
    }), e.forEach(l.edges(), function(u) {
      var d = l.edge(u);
      e.forEach(d.points, c), e.has(d, "x") && c(d);
    });
  }
  function c(l) {
    var u = l.x;
    l.x = l.y, l.y = u;
  }
  return oo;
}
var co, d0;
function Yb() {
  if (d0) return co;
  d0 = 1;
  var e = te();
  co = r;
  function r(n) {
    var t = {}, a = e.filter(n.nodes(), function(l) {
      return !n.children(l).length;
    }), i = e.max(e.map(a, function(l) {
      return n.node(l).rank;
    })), o = e.map(e.range(i + 1), function() {
      return [];
    });
    function s(l) {
      if (!e.has(t, l)) {
        t[l] = !0;
        var u = n.node(l);
        o[u.rank].push(l), e.forEach(n.successors(l), s);
      }
    }
    var c = e.sortBy(a, function(l) {
      return n.node(l).rank;
    });
    return e.forEach(c, s), o;
  }
  return co;
}
var uo, f0;
function Jb() {
  if (f0) return uo;
  f0 = 1;
  var e = te();
  uo = r;
  function r(t, a) {
    for (var i = 0, o = 1; o < a.length; ++o)
      i += n(t, a[o - 1], a[o]);
    return i;
  }
  function n(t, 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(t.outEdges(h), function(p) {
        return { pos: o[p.w], weight: t.edge(p).weight };
      }), "pos");
    }), !0), c = 1; c < i.length; ) c <<= 1;
    var l = 2 * c - 1;
    c -= 1;
    var u = e.map(new Array(l), function() {
      return 0;
    }), d = 0;
    return e.forEach(s.forEach(function(h) {
      var p = h.pos + c;
      u[p] += h.weight;
      for (var q = 0; p > 0; )
        p % 2 && (q += u[p + 1]), p = p - 1 >> 1, u[p] += h.weight;
      d += h.weight * q;
    })), d;
  }
  return uo;
}
var lo, h0;
function Zb() {
  if (h0) return lo;
  h0 = 1;
  var e = te();
  lo = r;
  function r(n, t) {
    return e.map(t, function(a) {
      var i = n.inEdges(a);
      if (i.length) {
        var o = e.reduce(i, function(s, c) {
          var l = n.edge(c), u = n.node(c.v);
          return {
            sum: s.sum + l.weight * u.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 lo;
}
var fo, p0;
function Xb() {
  if (p0) return fo;
  p0 = 1;
  var e = te();
  fo = r;
  function r(a, i) {
    var o = {};
    e.forEach(a, function(c, l) {
      var u = o[c.v] = {
        indegree: 0,
        in: [],
        out: [],
        vs: [c.v],
        i: l
      };
      e.isUndefined(c.barycenter) || (u.barycenter = c.barycenter, u.weight = c.weight);
    }), e.forEach(i.edges(), function(c) {
      var l = o[c.v], u = o[c.w];
      !e.isUndefined(l) && !e.isUndefined(u) && (u.indegree++, l.out.push(o[c.w]));
    });
    var s = e.filter(o, function(c) {
      return !c.indegree;
    });
    return n(s);
  }
  function n(a) {
    var i = [];
    function o(l) {
      return function(u) {
        u.merged || (e.isUndefined(u.barycenter) || e.isUndefined(l.barycenter) || u.barycenter >= l.barycenter) && t(l, u);
      };
    }
    function s(l) {
      return function(u) {
        u.in.push(l), --u.indegree === 0 && a.push(u);
      };
    }
    for (; a.length; ) {
      var c = a.pop();
      i.push(c), e.forEach(c.in.reverse(), o(c)), e.forEach(c.out, s(c));
    }
    return e.map(
      e.filter(i, function(l) {
        return !l.merged;
      }),
      function(l) {
        return e.pick(l, ["vs", "i", "barycenter", "weight"]);
      }
    );
  }
  function t(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 fo;
}
var ho, m0;
function Qb() {
  if (m0) return ho;
  m0 = 1;
  var e = te(), r = ve();
  ho = n;
  function n(i, o) {
    var s = r.partition(i, function(g) {
      return e.has(g, "barycenter");
    }), c = s.lhs, l = e.sortBy(s.rhs, function(g) {
      return -g.i;
    }), u = [], d = 0, h = 0, p = 0;
    c.sort(a(!!o)), p = t(u, l, p), e.forEach(c, function(g) {
      p += g.vs.length, u.push(g.vs), d += g.barycenter * g.weight, h += g.weight, p = t(u, l, p);
    });
    var q = { vs: e.flatten(u, !0) };
    return h && (q.barycenter = d / h, q.weight = h), q;
  }
  function t(i, o, s) {
    for (var c; o.length && (c = e.last(o)).i <= s; )
      o.pop(), i.push(c.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 ho;
}
var po, v0;
function ey() {
  if (v0) return po;
  v0 = 1;
  var e = te(), r = Zb(), n = Xb(), t = Qb();
  po = a;
  function a(s, c, l, u) {
    var d = s.children(c), h = s.node(c), p = h ? h.borderLeft : void 0, q = h ? h.borderRight : void 0, g = {};
    p && (d = e.filter(d, function(N) {
      return N !== p && N !== q;
    }));
    var v = r(s, d);
    e.forEach(v, function(N) {
      if (s.children(N.v).length) {
        var I = a(s, N.v, l, u);
        g[N.v] = I, e.has(I, "barycenter") && o(N, I);
      }
    });
    var b = n(v, l);
    i(b, g);
    var m = t(b, u);
    if (p && (m.vs = e.flatten([p, m.vs, q], !0), s.predecessors(p).length)) {
      var y = s.node(s.predecessors(p)[0]), w = s.node(s.predecessors(q)[0]);
      e.has(m, "barycenter") || (m.barycenter = 0, m.weight = 0), m.barycenter = (m.barycenter * m.weight + y.order + w.order) / (m.weight + 2), m.weight += 2;
    }
    return m;
  }
  function i(s, c) {
    e.forEach(s, function(l) {
      l.vs = e.flatten(l.vs.map(function(u) {
        return c[u] ? c[u].vs : u;
      }), !0);
    });
  }
  function o(s, c) {
    e.isUndefined(s.barycenter) ? (s.barycenter = c.barycenter, s.weight = c.weight) : (s.barycenter = (s.barycenter * s.weight + c.barycenter * c.weight) / (s.weight + c.weight), s.weight += c.weight);
  }
  return po;
}
var mo, g0;
function ry() {
  if (g0) return mo;
  g0 = 1;
  var e = te(), r = we().Graph;
  mo = n;
  function n(a, i, o) {
    var s = t(a), c = new r({ compound: !0 }).setGraph({ root: s }).setDefaultNodeLabel(function(l) {
      return a.node(l);
    });
    return e.forEach(a.nodes(), function(l) {
      var u = a.node(l), d = a.parent(l);
      (u.rank === i || u.minRank <= i && i <= u.maxRank) && (c.setNode(l), c.setParent(l, d || s), e.forEach(a[o](l), function(h) {
        var p = h.v === l ? h.w : h.v, q = c.edge(p, l), g = e.isUndefined(q) ? 0 : q.weight;
        c.setEdge(p, l, { weight: a.edge(h).weight + g });
      }), e.has(u, "minRank") && c.setNode(l, {
        borderLeft: u.borderLeft[i],
        borderRight: u.borderRight[i]
      }));
    }), c;
  }
  function t(a) {
    for (var i; a.hasNode(i = e.uniqueId("_root")); ) ;
    return i;
  }
  return mo;
}
var vo, b0;
function ty() {
  if (b0) return vo;
  b0 = 1;
  var e = te();
  vo = r;
  function r(n, t, a) {
    var i = {}, o;
    e.forEach(a, function(s) {
      for (var c = n.parent(s), l, u; c; ) {
        if (l = n.parent(c), l ? (u = i[l], i[l] = c) : (u = o, o = c), u && u !== c) {
          t.setEdge(u, c);
          return;
        }
        c = l;
      }
    });
  }
  return vo;
}
var go, y0;
function ny() {
  if (y0) return go;
  y0 = 1;
  var e = te(), r = Yb(), n = Jb(), t = ey(), a = ry(), i = ty(), o = we().Graph, s = ve();
  go = c;
  function c(h) {
    var p = s.maxRank(h), q = l(h, e.range(1, p + 1), "inEdges"), g = l(h, e.range(p - 1, -1, -1), "outEdges"), v = r(h);
    d(h, v);
    for (var b = Number.POSITIVE_INFINITY, m, y = 0, w = 0; w < 4; ++y, ++w) {
      u(y % 2 ? q : g, y % 4 >= 2), v = s.buildLayerMatrix(h);
      var N = n(h, v);
      N < b && (w = 0, m = e.cloneDeep(v), b = N);
    }
    d(h, m);
  }
  function l(h, p, q) {
    return e.map(p, function(g) {
      return a(h, g, q);
    });
  }
  function u(h, p) {
    var q = new o();
    e.forEach(h, function(g) {
      var v = g.graph().root, b = t(g, v, q, p);
      e.forEach(b.vs, function(m, y) {
        g.node(m).order = y;
      }), i(g, q, b.vs);
    });
  }
  function d(h, p) {
    e.forEach(p, function(q) {
      e.forEach(q, function(g, v) {
        h.node(g).order = v;
      });
    });
  }
  return go;
}
var bo, x0;
function ay() {
  if (x0) return bo;
  x0 = 1;
  var e = te(), r = we().Graph, n = ve();
  bo = {
    positionX: q,
    findType1Conflicts: t,
    findType2Conflicts: a,
    addConflict: o,
    hasConflict: s,
    verticalAlignment: c,
    horizontalCompaction: l,
    alignCoordinates: h,
    findSmallestWidthAlignment: d,
    balance: p
  };
  function t(b, m) {
    var y = {};
    function w(N, I) {
      var _ = 0, R = 0, k = N.length, S = e.last(I);
      return e.forEach(I, function(E, A) {
        var P = i(b, E), z = P ? b.node(P).order : k;
        (P || E === S) && (e.forEach(I.slice(R, A + 1), function(F) {
          e.forEach(b.predecessors(F), function(J) {
            var M = b.node(J), G = M.order;
            (G < _ || z < G) && !(M.dummy && b.node(F).dummy) && o(y, J, F);
          });
        }), R = A + 1, _ = z);
      }), I;
    }
    return e.reduce(m, w), y;
  }
  function a(b, m) {
    var y = {};
    function w(I, _, R, k, S) {
      var E;
      e.forEach(e.range(_, R), function(A) {
        E = I[A], b.node(E).dummy && e.forEach(b.predecessors(E), function(P) {
          var z = b.node(P);
          z.dummy && (z.order < k || z.order > S) && o(y, P, E);
        });
      });
    }
    function N(I, _) {
      var R = -1, k, S = 0;
      return e.forEach(_, function(E, A) {
        if (b.node(E).dummy === "border") {
          var P = b.predecessors(E);
          P.length && (k = b.node(P[0]).order, w(_, S, A, R, k), S = A, R = k);
        }
        w(_, S, _.length, k, I.length);
      }), _;
    }
    return e.reduce(m, N), y;
  }
  function i(b, m) {
    if (b.node(m).dummy)
      return e.find(b.predecessors(m), function(y) {
        return b.node(y).dummy;
      });
  }
  function o(b, m, y) {
    if (m > y) {
      var w = m;
      m = y, y = w;
    }
    var N = b[m];
    N || (b[m] = N = {}), N[y] = !0;
  }
  function s(b, m, y) {
    if (m > y) {
      var w = m;
      m = y, y = w;
    }
    return e.has(b[m], y);
  }
  function c(b, m, y, w) {
    var N = {}, I = {}, _ = {};
    return e.forEach(m, function(R) {
      e.forEach(R, function(k, S) {
        N[k] = k, I[k] = k, _[k] = S;
      });
    }), e.forEach(m, function(R) {
      var k = -1;
      e.forEach(R, function(S) {
        var E = w(S);
        if (E.length) {
          E = e.sortBy(E, function(J) {
            return _[J];
          });
          for (var A = (E.length - 1) / 2, P = Math.floor(A), z = Math.ceil(A); P <= z; ++P) {
            var F = E[P];
            I[S] === S && k < _[F] && !s(y, S, F) && (I[F] = S, I[S] = N[S] = N[F], k = _[F]);
          }
        }
      });
    }), { root: N, align: I };
  }
  function l(b, m, y, w, N) {
    var I = {}, _ = u(b, m, y, N), R = N ? "borderLeft" : "borderRight";
    function k(A, P) {
      for (var z = _.nodes(), F = z.pop(), J = {}; F; )
        J[F] ? A(F) : (J[F] = !0, z.push(F), z = z.concat(P(F))), F = z.pop();
    }
    function S(A) {
      I[A] = _.inEdges(A).reduce(function(P, z) {
        return Math.max(P, I[z.v] + _.edge(z));
      }, 0);
    }
    function E(A) {
      var P = _.outEdges(A).reduce(function(F, J) {
        return Math.min(F, I[J.w] - _.edge(J));
      }, Number.POSITIVE_INFINITY), z = b.node(A);
      P !== Number.POSITIVE_INFINITY && z.borderType !== R && (I[A] = Math.max(I[A], P));
    }
    return k(S, _.predecessors.bind(_)), k(E, _.successors.bind(_)), e.forEach(w, function(A) {
      I[A] = I[y[A]];
    }), I;
  }
  function u(b, m, y, w) {
    var N = new r(), I = b.graph(), _ = g(I.nodesep, I.edgesep, w);
    return e.forEach(m, function(R) {
      var k;
      e.forEach(R, function(S) {
        var E = y[S];
        if (N.setNode(E), k) {
          var A = y[k], P = N.edge(A, E);
          N.setEdge(A, E, Math.max(_(b, S, k), P || 0));
        }
        k = S;
      });
    }), N;
  }
  function d(b, m) {
    return e.minBy(e.values(m), function(y) {
      var w = Number.NEGATIVE_INFINITY, N = Number.POSITIVE_INFINITY;
      return e.forIn(y, function(I, _) {
        var R = v(b, _) / 2;
        w = Math.max(I + R, w), N = Math.min(I - R, N);
      }), w - N;
    });
  }
  function h(b, m) {
    var y = e.values(m), w = e.min(y), N = e.max(y);
    e.forEach(["u", "d"], function(I) {
      e.forEach(["l", "r"], function(_) {
        var R = I + _, k = b[R], S;
        if (k !== m) {
          var E = e.values(k);
          S = _ === "l" ? w - e.min(E) : N - e.max(E), S && (b[R] = e.mapValues(k, function(A) {
            return A + S;
          }));
        }
      });
    });
  }
  function p(b, m) {
    return e.mapValues(b.ul, function(y, w) {
      if (m)
        return b[m.toLowerCase()][w];
      var N = e.sortBy(e.map(b, w));
      return (N[1] + N[2]) / 2;
    });
  }
  function q(b) {
    var m = n.buildLayerMatrix(b), y = e.merge(
      t(b, m),
      a(b, m)
    ), w = {}, N;
    e.forEach(["u", "d"], function(_) {
      N = _ === "u" ? m : e.values(m).reverse(), e.forEach(["l", "r"], function(R) {
        R === "r" && (N = e.map(N, function(A) {
          return e.values(A).reverse();
        }));
        var k = (_ === "u" ? b.predecessors : b.successors).bind(b), S = c(b, N, y, k), E = l(
          b,
          N,
          S.root,
          S.align,
          R === "r"
        );
        R === "r" && (E = e.mapValues(E, function(A) {
          return -A;
        })), w[_ + R] = E;
      });
    });
    var I = d(b, w);
    return h(w, I), p(w, b.graph().align);
  }
  function g(b, m, y) {
    return function(w, N, I) {
      var _ = w.node(N), R = w.node(I), k = 0, S;
      if (k += _.width / 2, e.has(_, "labelpos"))
        switch (_.labelpos.toLowerCase()) {
          case "l":
            S = -_.width / 2;
            break;
          case "r":
            S = _.width / 2;
            break;
        }
      if (S && (k += y ? S : -S), S = 0, k += (_.dummy ? m : b) / 2, k += (R.dummy ? m : 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 v(b, m) {
    return b.node(m).width;
  }
  return bo;
}
var yo, _0;
function iy() {
  if (_0) return yo;
  _0 = 1;
  var e = te(), r = ve(), n = ay().positionX;
  yo = t;
  function t(i) {
    i = r.asNonCompoundGraph(i), a(i), e.forEach(n(i), function(o, s) {
      i.node(s).x = o;
    });
  }
  function a(i) {
    var o = r.buildLayerMatrix(i), s = i.graph().ranksep, c = 0;
    e.forEach(o, function(l) {
      var u = e.max(e.map(l, function(d) {
        return i.node(d).height;
      }));
      e.forEach(l, function(d) {
        i.node(d).y = c + u / 2;
      }), c += u + s;
    });
  }
  return yo;
}
var xo, w0;
function sy() {
  if (w0) return xo;
  w0 = 1;
  var e = te(), r = zb(), n = Bb(), t = $b(), a = ve().normalizeRanks, i = Hb(), o = ve().removeEmptyRanks, s = Vb(), c = Kb(), l = Wb(), u = ny(), d = iy(), h = ve(), p = we().Graph;
  xo = q;
  function q(C, T) {
    var O = T && T.debugTiming ? h.time : h.notime;
    O("layout", function() {
      var L = O("  buildLayoutGraph", function() {
        return k(C);
      });
      O("  runLayout", function() {
        g(L, O);
      }), O("  updateInputGraph", function() {
        v(C, L);
      });
    });
  }
  function g(C, T) {
    T("    makeSpaceForEdgeLabels", function() {
      S(C);
    }), T("    removeSelfEdges", function() {
      D(C);
    }), T("    acyclic", function() {
      r.run(C);
    }), T("    nestingGraph.run", function() {
      s.run(C);
    }), T("    rank", function() {
      t(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() {
      n.run(C);
    }), T("    parentDummyChains", function() {
      i(C);
    }), T("    addBorderSegments", function() {
      c(C);
    }), T("    order", function() {
      u(C);
    }), T("    insertSelfEdges", function() {
      $(C);
    }), T("    adjustCoordinateSystem", function() {
      l.adjust(C);
    }), T("    position", function() {
      d(C);
    }), T("    positionSelfEdges", function() {
      le(C);
    }), T("    removeBorderNodes", function() {
      G(C);
    }), T("    normalize.undo", function() {
      n.undo(C);
    }), T("    fixupEdgeLabelCoords", function() {
      J(C);
    }), T("    undoCoordinateSystem", function() {
      l.undo(C);
    }), T("    translateGraph", function() {
      z(C);
    }), T("    assignNodeIntersects", function() {
      F(C);
    }), T("    reversePoints", function() {
      M(C);
    }), T("    acyclic.undo", function() {
      r.undo(C);
    });
  }
  function v(C, T) {
    e.forEach(C.nodes(), function(O) {
      var L = C.node(O), H = T.node(O);
      L && (L.x = H.x, L.y = H.y, T.children(O).length && (L.width = H.width, L.height = H.height));
    }), e.forEach(C.edges(), function(O) {
      var L = C.edge(O), H = T.edge(O);
      L.points = H.points, e.has(H, "x") && (L.x = H.x, L.y = H.y);
    }), C.graph().width = T.graph().width, C.graph().height = T.graph().height;
  }
  var b = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"], m = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" }, y = ["acyclicer", "ranker", "rankdir", "align"], w = ["width", "height"], N = { width: 0, height: 0 }, I = ["minlen", "weight", "width", "height", "labeloffset"], _ = {
    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 }), O = ne(C.graph());
    return T.setGraph(e.merge(
      {},
      m,
      de(O, b),
      e.pick(O, y)
    )), e.forEach(C.nodes(), function(L) {
      var H = ne(C.node(L));
      T.setNode(L, e.defaults(de(H, w), N)), T.setParent(L, C.parent(L));
    }), e.forEach(C.edges(), function(L) {
      var H = ne(C.edge(L));
      T.setEdge(L, e.merge(
        {},
        _,
        de(H, I),
        e.pick(H, R)
      ));
    }), T;
  }
  function S(C) {
    var T = C.graph();
    T.ranksep /= 2, e.forEach(C.edges(), function(O) {
      var L = C.edge(O);
      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 O = C.edge(T);
      if (O.width && O.height) {
        var L = C.node(T.v), H = C.node(T.w), Y = { rank: (H.rank - L.rank) / 2 + L.rank, e: T };
        h.addDummyNode(C, "edge-proxy", Y, "_ep");
      }
    });
  }
  function A(C) {
    var T = 0;
    e.forEach(C.nodes(), function(O) {
      var L = C.node(O);
      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 O = C.node(T);
      O.dummy === "edge-proxy" && (C.edge(O.e).labelRank = O.rank, C.removeNode(T));
    });
  }
  function z(C) {
    var T = Number.POSITIVE_INFINITY, O = 0, L = Number.POSITIVE_INFINITY, H = 0, Y = C.graph(), Q = Y.marginx || 0, ce = Y.marginy || 0;
    function Me(fe) {
      var se = fe.x, V = fe.y, Re = fe.width, W = fe.height;
      T = Math.min(T, se - Re / 2), O = Math.max(O, se + Re / 2), L = Math.min(L, V - W / 2), H = Math.max(H, V + W / 2);
    }
    e.forEach(C.nodes(), function(fe) {
      Me(C.node(fe));
    }), e.forEach(C.edges(), function(fe) {
      var se = C.edge(fe);
      e.has(se, "x") && Me(se);
    }), T -= Q, L -= ce, e.forEach(C.nodes(), function(fe) {
      var se = C.node(fe);
      se.x -= T, se.y -= L;
    }), e.forEach(C.edges(), function(fe) {
      var se = C.edge(fe);
      e.forEach(se.points, function(V) {
        V.x -= T, V.y -= L;
      }), e.has(se, "x") && (se.x -= T), e.has(se, "y") && (se.y -= L);
    }), Y.width = O - T + Q, Y.height = H - L + ce;
  }
  function F(C) {
    e.forEach(C.edges(), function(T) {
      var O = C.edge(T), L = C.node(T.v), H = C.node(T.w), Y, Q;
      O.points ? (Y = O.points[0], Q = O.points[O.points.length - 1]) : (O.points = [], Y = H, Q = L), O.points.unshift(h.intersectRect(L, Y)), O.points.push(h.intersectRect(H, Q));
    });
  }
  function J(C) {
    e.forEach(C.edges(), function(T) {
      var O = C.edge(T);
      if (e.has(O, "x"))
        switch ((O.labelpos === "l" || O.labelpos === "r") && (O.width -= O.labeloffset), O.labelpos) {
          case "l":
            O.x -= O.width / 2 + O.labeloffset;
            break;
          case "r":
            O.x += O.width / 2 + O.labeloffset;
            break;
        }
    });
  }
  function M(C) {
    e.forEach(C.edges(), function(T) {
      var O = C.edge(T);
      O.reversed && O.points.reverse();
    });
  }
  function G(C) {
    e.forEach(C.nodes(), function(T) {
      if (C.children(T).length) {
        var O = C.node(T), L = C.node(O.borderTop), H = C.node(O.borderBottom), Y = C.node(e.last(O.borderLeft)), Q = C.node(e.last(O.borderRight));
        O.width = Math.abs(Q.x - Y.x), O.height = Math.abs(H.y - L.y), O.x = Y.x + O.width / 2, O.y = L.y + O.height / 2;
      }
    }), e.forEach(C.nodes(), function(T) {
      C.node(T).dummy === "border" && C.removeNode(T);
    });
  }
  function D(C) {
    e.forEach(C.edges(), function(T) {
      if (T.v === T.w) {
        var O = C.node(T.v);
        O.selfEdges || (O.selfEdges = []), O.selfEdges.push({ e: T, label: C.edge(T) }), C.removeEdge(T);
      }
    });
  }
  function $(C) {
    var T = h.buildLayerMatrix(C);
    e.forEach(T, function(O) {
      var L = 0;
      e.forEach(O, function(H, Y) {
        var Q = C.node(H);
        Q.order = Y + L, e.forEach(Q.selfEdges, function(ce) {
          h.addDummyNode(C, "selfedge", {
            width: ce.label.width,
            height: ce.label.height,
            rank: Q.rank,
            order: Y + ++L,
            e: ce.e,
            label: ce.label
          }, "_se");
        }), delete Q.selfEdges;
      });
    });
  }
  function le(C) {
    e.forEach(C.nodes(), function(T) {
      var O = C.node(T);
      if (O.dummy === "selfedge") {
        var L = C.node(O.e.v), H = L.x + L.width / 2, Y = L.y, Q = O.x - H, ce = L.height / 2;
        C.setEdge(O.e, O.label), C.removeNode(T), O.label.points = [
          { x: H + 2 * Q / 3, y: Y - ce },
          { x: H + 5 * Q / 6, y: Y - ce },
          { x: H + Q, y: Y },
          { x: H + 5 * Q / 6, y: Y + ce },
          { x: H + 2 * Q / 3, y: Y + ce }
        ], O.label.x = O.x, O.label.y = O.y;
      }
    });
  }
  function de(C, T) {
    return e.mapValues(e.pick(C, T), Number);
  }
  function ne(C) {
    var T = {};
    return e.forEach(C, function(O, L) {
      T[L.toLowerCase()] = O;
    }), T;
  }
  return xo;
}
var _o, N0;
function oy() {
  if (N0) return _o;
  N0 = 1;
  var e = te(), r = ve(), n = we().Graph;
  _o = {
    debugOrdering: t
  };
  function t(a) {
    var i = r.buildLayerMatrix(a), o = new n({ 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, c) {
      var l = "layer" + c;
      o.setNode(l, { rank: "same" }), e.reduce(s, function(u, d) {
        return o.setEdge(u, d, { style: "invis" }), d;
      });
    }), o;
  }
  return _o;
}
var wo, q0;
function cy() {
  return q0 || (q0 = 1, wo = "0.8.5"), wo;
}
var No, I0;
function uy() {
  return I0 || (I0 = 1, No = {
    graphlib: we(),
    layout: sy(),
    debug: oy(),
    util: {
      time: ve().time,
      notime: ve().notime
    },
    version: cy()
  }), No;
}
var ly = uy();
const k0 = /* @__PURE__ */ Wm(ly), S0 = 280, R0 = 120, C0 = (e, r, n = "TB") => {
  const t = new k0.graphlib.Graph();
  return t.setDefaultEdgeLabel(() => ({})), t.setGraph({
    rankdir: n,
    ranksep: 140,
    // Increased vertical spacing (was default ~50, prev 100)
    nodesep: 140
    // Increased horizontal spacing (was default ~50, prev 80)
  }), e.forEach((i) => {
    t.setNode(i.id, { width: S0, height: R0 });
  }), r.forEach((i) => {
    t.setEdge(i.source, i.target);
  }), k0.layout(t), { nodes: e.map((i) => {
    const o = t.node(i.id);
    return {
      ...i,
      targetPosition: Cr.Top,
      sourcePosition: Cr.Bottom,
      position: {
        x: o.x - S0 / 2,
        y: o.y - R0 / 2
      }
    };
  }), edges: r };
}, E0 = (e) => {
  const r = new Map(e.map((t) => [t.scheduleId, t])), n = /* @__PURE__ */ new Map();
  return e.forEach((t) => {
    const a = [], i = /* @__PURE__ */ new Set();
    i.add(t.scheduleId);
    const o = t.direction === pe.TopDown ? [...t.children] : [...t.parents];
    for (; o.length > 0; ) {
      const s = o.shift();
      if (i.has(s)) continue;
      i.add(s);
      const c = r.get(s);
      c && (c.resources.forEach((l) => {
        a.push({
          ...l,
          sourceNodeId: c.scheduleId,
          sourceNodeName: c.name,
          sourceNodePriority: c.priority,
          isInherited: !0
        });
      }), t.direction === pe.TopDown ? o.push(...c.children) : o.push(...c.parents));
    }
    n.set(t.scheduleId, a);
  }), n;
}, Yh = (e, r) => {
  const n = r.target, t = r.source;
  if (!n || !t || n === t) return !0;
  const a = /* @__PURE__ */ new Map();
  e.forEach((s) => {
    var c;
    a.has(s.source) || a.set(s.source, []), (c = a.get(s.source)) == null || c.push(s.target);
  });
  const i = /* @__PURE__ */ new Set(), o = [n];
  for (; o.length > 0; ) {
    const s = o.pop();
    if (s === t) return !0;
    if (!i.has(s)) {
      i.add(s);
      const c = a.get(s) || [];
      for (const l of c)
        i.has(l) || o.push(l);
    }
  }
  return !1;
};
function A0() {
  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 n = 0; n < 256; n++)
      r.push((n + 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 dy = (e) => {
  const [r, n, t] = ep([]), [a, i, o] = rp([]), [s, c] = B({ past: [], future: [] }), l = ie(() => {
    c((I) => ({
      past: [...I.past, JSON.stringify({ nodes: r, edges: a })].slice(-50),
      future: []
    }));
  }, [r, a]), u = ie(() => {
    if (s.past.length === 0) return;
    const I = s.past[s.past.length - 1], _ = s.past.slice(0, -1), R = JSON.stringify({ nodes: r, edges: a }), { nodes: k, edges: S } = JSON.parse(I);
    n(k), i(S), c({
      past: _,
      future: [R, ...s.future]
    });
  }, [s, r, a, n, i]), d = ie(() => {
    if (s.future.length === 0) return;
    const I = s.future[0], _ = s.future.slice(1), R = JSON.stringify({ nodes: r, edges: a }), { nodes: k, edges: S } = JSON.parse(I);
    n(k), i(S), c({
      past: [...s.past, R],
      future: _
    });
  }, [s, r, a, n, i]), h = ie((I) => {
    const _ = (I.schedules || []).map((A) => {
      let P = pe.BottomUp;
      (A.direction === pe.TopDown || A.direction === 1 || A.direction === "TopDown") && (P = pe.TopDown);
      const z = {
        ...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: z.scheduleId,
        position: { x: 0, y: 0 },
        data: z,
        type: "scheduleNode"
      };
    }), R = [], k = new Set(_.map((A) => A.id));
    (I.schedules || []).forEach((A) => {
      if (!A.scheduleId) return;
      (A.children || []).forEach((z) => {
        k.has(z) && k.has(A.scheduleId) && R.push({
          id: `${A.scheduleId}-${z}`,
          source: A.scheduleId,
          target: z,
          type: "smoothstep",
          animated: !1,
          markerEnd: { type: nt.ArrowClosed, width: 20, height: 20, color: "#94a3b8" },
          style: { stroke: "#94a3b8", strokeWidth: 2 }
        });
      });
    });
    const { nodes: S, edges: E } = C0(_, R, "TB");
    n(S), i(E), c({ past: [], future: [] });
  }, [n, i]);
  oe(() => {
    h(e);
  }, [e, h]);
  const p = ge(() => r.map((I) => I.data.name).join("|"), [r]);
  oe(() => {
    r.length !== 0 && n((I) => {
      const _ = new Map(
        I.map((S) => [S.id, { ...S.data, parents: [], children: [] }])
      );
      a.forEach((S) => {
        const E = _.get(S.source), A = _.get(S.target);
        E && A && (E.children.push(S.target), A.parents.push(S.source));
      });
      const R = Array.from(_.values()), k = E0(R);
      return I.map((S) => {
        const E = _.get(S.id);
        return E ? (E._inheritedResources = k.get(S.id) || [], { ...S, data: E }) : S;
      });
    });
  }, [a.length, a, p, n]);
  const q = ie((I) => {
    if (Yh(a, I)) {
      alert("Cannot connect: This connection would create a cycle (loop) in the graph.");
      return;
    }
    l(), i((_) => tp({
      ...I,
      type: "smoothstep",
      animated: !1,
      markerEnd: { type: nt.ArrowClosed, width: 20, height: 20, color: "#94a3b8" },
      style: { stroke: "#94a3b8", strokeWidth: 2 }
    }, _));
  }, [a, i, l]), g = ie((I, _, R) => {
    l(), n((k) => {
      const S = k.map((P) => {
        if (P.id === I) {
          const z = { ...P.data, [_]: R };
          return { ...P, data: z };
        }
        return P;
      }), E = S.map((P) => P.data), A = E0(E);
      return S.map((P) => {
        const z = A.get(P.id) || [];
        return {
          ...P,
          data: {
            ...P.data,
            _inheritedResources: z
          }
        };
      });
    });
  }, [n, l]), v = ie(() => {
    l();
    const { nodes: I, edges: _ } = C0(r, a, "TB");
    n([...I]), i([..._]);
  }, [r, a, n, i, l]), b = ie((I) => {
    l();
    const _ = A0(), R = {
      x: (-I.x + window.innerWidth / 2) / I.zoom,
      y: (-I.y + window.innerHeight / 2) / I.zoom
    }, k = {
      id: _,
      position: { x: R.x + Math.random() * 50, y: R.y + Math.random() * 50 },
      type: "scheduleNode",
      data: {
        scheduleId: _,
        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
      }
    };
    n((S) => [...S, k]);
  }, [n, l]), m = ie((I, _) => {
    let R = pe.BottomUp;
    const k = _.direction;
    return (k === pe.TopDown || k === 1 || k === "TopDown") && (R = pe.TopDown), {
      scheduleId: I,
      isActive: _.isActive ?? !0,
      name: _.name ?? "New Schedule",
      time: _.time ?? "24/7",
      group: _.group ?? "Draft",
      purpose: _.purpose ?? "General",
      priority: typeof _.priority == "number" ? _.priority : 1,
      locationGroup: _.locationGroup || { groupId: "", nodeId: "" },
      approvalGroups: Array.isArray(_.approvalGroups) ? _.approvalGroups : [],
      direction: R,
      tags: Array.isArray(_.tags) ? _.tags : [],
      attributes: Array.isArray(_.attributes) ? _.attributes : [],
      configuration: _.configuration || {},
      securityLevelId: _.securityLevelId ?? null,
      followUp: _.followUp ?? null,
      phaseOut: _.phaseOut ?? null,
      resources: Array.isArray(_.resources) ? _.resources : [],
      children: [],
      parents: [],
      requirements: Array.isArray(_.requirements) ? _.requirements : []
    };
  }, []), y = ie((I) => {
    const _ = I.scheduleId && String(I.scheduleId) || A0();
    return {
      id: _,
      position: { x: Math.random() * 400, y: Math.random() * 300 },
      type: "scheduleNode",
      data: m(_, I)
    };
  }, [m]), w = ie((I, _) => ({
    id: `${I}-${_}`,
    source: I,
    target: _,
    type: "smoothstep",
    animated: !1,
    markerEnd: { type: nt.ArrowClosed, width: 20, height: 20, color: "#94a3b8" },
    style: { stroke: "#94a3b8", strokeWidth: 2 }
  }), []), N = ie((I, _) => {
    l(), n(I), i(_);
  }, [n, i, l]);
  return {
    nodes: r,
    edges: a,
    onNodesChange: t,
    onEdgesChange: o,
    onConnect: q,
    handleUpdateNode: g,
    handleLayout: v,
    handleAddNode: b,
    setNodes: n,
    setEdges: i,
    undo: u,
    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: N,
    canUndo: s.past.length > 0,
    canRedo: s.future.length > 0
  };
}, fy = "entitlement", hy = "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.", Rr = [
  "name",
  "time",
  "group",
  "purpose",
  "priority",
  "isActive",
  "direction",
  "tags",
  "attributes",
  "configuration",
  "securityLevelId",
  "followUp",
  "phaseOut",
  "resources",
  "approvalGroups",
  "locationGroup",
  "requirements"
], Ee = (e) => ({ ok: !0, result: e }), X = (e) => ({ ok: !1, rejected: !0, reason: e });
function py(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 n = [], t = /* @__PURE__ */ new Set();
  e.forEach((a) => {
    const i = a.data;
    i.scheduleId || n.push(`Node "${a.id}" is missing scheduleId.`), t.has(i.scheduleId) && n.push(`Duplicate scheduleId "${i.scheduleId}".`), t.add(i.scheduleId), (!i.name || !String(i.name).trim()) && n.push(`Schedule "${i.scheduleId}" has an empty name.`), typeof i.priority != "number" && n.push(`Schedule "${i.name || i.scheduleId}" has a non-numeric priority.`);
  }), r.forEach((a) => {
    t.has(a.source) || n.push(`Edge "${a.id}" references unknown source node "${a.source}".`), t.has(a.target) || n.push(`Edge "${a.id}" references unknown target node "${a.target}".`), a.source === a.target && n.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, c) => c !== a);
    if (Yh(o, { source: i.source, target: i.target })) {
      n.push(`Edge "${i.source}->${i.target}" participates in a cycle.`);
      break;
    }
  }
  return n;
}
function Sr(e, r, n, t) {
  const a = new Set(Or(e, r));
  return Or(n, t).filter((i) => !a.has(i));
}
function my(e, r) {
  const n = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
  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((t) => typeof t != "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((t) => typeof t != "string")) ? '"attributes" must be an array of strings or null.' : null;
    case "configuration":
      return n(r) ? null : '"configuration" must be an object.';
    case "locationGroup": {
      const t = r;
      return !n(r) || typeof t.groupId != "string" || typeof t.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 t of r)
        if (!n(t) || typeof t.groupId != "string" || typeof t.nodeId != "string" || typeof t.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 t of r) {
        if (!n(t) || typeof t.systemId != "string" || typeof t.resourceId != "string")
          return 'Each "resources" entry needs string "systemId" and "resourceId".';
        if (t.resourcePlanId != null && typeof t.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 t of r)
        if (!n(t) || typeof t.testamentTypeId != "string" || !t.testamentTypeId.trim())
          return 'Each "requirements" entry needs a non-empty string "testamentTypeId".';
      return null;
    }
    case "phaseOut": {
      if (r === null) return null;
      const t = r;
      return !n(r) || typeof t.scheduleId != "string" || typeof t.duration != "string" ? '"phaseOut" must be null or an object with string "scheduleId" and "duration".' : null;
    }
    default:
      return null;
  }
}
const vy = [
  {
    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: [...Rr] },
        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 }
  }
];
function gy(e) {
  const r = (t) => e.getNodes().find((a) => a.id === t || a.data.scheduleId === t);
  return { kind: fy, guidelines: hy, tools: vy, invoke: async (t, a) => {
    const i = a || {};
    try {
      switch (t) {
        case "get_model": {
          const o = e.getNodes(), s = e.getEdges();
          return Ee({
            schedules: o.map((c) => py(c.data)),
            links: s.map((c) => ({ parentId: c.source, childId: c.target }))
          });
        }
        case "list_node_types":
          return Ee({
            nodeTypes: [
              {
                type: "schedule",
                description: "A permission schedule node.",
                fields: [...Rr],
                derived: ["parents", "children", "_inheritedResources"]
              }
            ],
            edgeType: { type: "link", description: "Directed parent->child link; graph stays acyclic." }
          });
        case "add_schedule": {
          if (!i.name || !String(i.name).trim())
            return X('add_schedule requires a non-empty "name".');
          if (i.direction !== void 0 && i.direction !== 0 && i.direction !== 1)
            return X('"direction" must be 0 (BottomUp) or 1 (TopDown).');
          const o = e.getNodes(), s = e.getEdges(), c = e.buildScheduleNode({
            name: String(i.name),
            group: i.group,
            purpose: i.purpose,
            time: i.time,
            priority: typeof i.priority == "number" ? i.priority : void 0,
            direction: i.direction,
            isActive: typeof i.isActive == "boolean" ? i.isActive : void 0,
            tags: Array.isArray(i.tags) ? i.tags : void 0
          }), l = [...o, c], u = Sr(o, s, l, s);
          return u.length ? X(u[0]) : (e.applyModel(l, s), Ee({ scheduleId: c.data.scheduleId }));
        }
        case "update_schedule": {
          const { scheduleId: o, field: s, value: c } = i;
          if (!o) return X('update_schedule requires "scheduleId".');
          const l = r(o);
          if (!l)
            return X(`Unknown scheduleId "${String(o)}".`);
          if (s === "parents" || s === "children")
            return X(
              `Field "${String(s)}" is derived from links; use connect_schedules / disconnect_schedules instead.`
            );
          if (!Rr.includes(s))
            return X(
              `Unknown or non-editable field "${String(s)}". Editable: ${Rr.join(", ")}.`
            );
          const u = my(s, c);
          if (u) return X(u);
          const d = e.getNodes(), h = e.getEdges(), p = d.map(
            (g) => g.id === l.id ? { ...g, data: { ...g.data, [s]: c } } : g
          ), q = Sr(d, h, p, h);
          return q.length ? X(q[0]) : (e.applyModel(p, h), Ee({ scheduleId: o, field: s, value: c }));
        }
        case "delete_schedule": {
          const { scheduleId: o } = i;
          if (!o) return X('delete_schedule requires "scheduleId".');
          const s = r(o);
          if (!s)
            return X(`Unknown scheduleId "${String(o)}".`);
          const c = e.getNodes(), l = e.getEdges(), u = c.filter((p) => p.id !== s.id), d = l.filter((p) => p.source !== s.id && p.target !== s.id), h = Sr(c, l, u, d);
          return h.length ? X(h[0]) : (e.applyModel(u, d), Ee({ deleted: o }));
        }
        case "connect_schedules": {
          const { parentId: o, childId: s } = i;
          if (!o || !s)
            return X('connect_schedules requires "parentId" and "childId".');
          const c = r(o), l = r(s);
          if (!c) return X(`Unknown parentId "${String(o)}".`);
          if (!l) return X(`Unknown childId "${String(s)}".`);
          const u = e.getNodes(), d = e.getEdges();
          if (d.some((q) => q.source === c.id && q.target === l.id))
            return X("Connection rejected: this link already exists.");
          const h = [...d, e.makeEdge(c.id, l.id)], p = Sr(u, d, u, h);
          return p.length ? X(p[0]) : (e.applyModel(u, h), Ee({ parentId: o, childId: s }));
        }
        case "disconnect_schedules": {
          const { parentId: o, childId: s } = i;
          if (!o || !s)
            return X('disconnect_schedules requires "parentId" and "childId".');
          const c = r(o), l = r(s), u = c ? c.id : String(o), d = l ? l.id : String(s), h = e.getNodes(), p = e.getEdges();
          if (!p.some((v) => v.source === u && v.target === d))
            return X(`No link from "${String(o)}" to "${String(s)}".`);
          const g = p.filter((v) => !(v.source === u && v.target === d));
          return e.applyModel(h, g), Ee({ parentId: o, childId: s });
        }
        case "replace_model": {
          const o = i.schedules;
          if (!Array.isArray(o))
            return X('replace_model requires a "schedules" array.');
          const s = Array.isArray(i.links) ? i.links : [], c = [];
          for (const h of o) {
            if (!h || typeof h != "object")
              return X('Each schedule in "schedules" must be an object.');
            if (h.direction !== void 0 && h.direction !== 0 && h.direction !== 1)
              return X('Each schedule "direction" must be 0 (BottomUp) or 1 (TopDown).');
            c.push(
              e.buildScheduleNode({
                scheduleId: typeof h.scheduleId == "string" ? h.scheduleId : void 0,
                name: h.name,
                group: h.group,
                purpose: h.purpose,
                time: h.time,
                priority: typeof h.priority == "number" ? h.priority : void 0,
                direction: h.direction,
                isActive: typeof h.isActive == "boolean" ? h.isActive : void 0,
                tags: Array.isArray(h.tags) ? h.tags : void 0
              })
            );
          }
          const l = /* @__PURE__ */ new Map();
          c.forEach((h) => l.set(h.data.scheduleId, h.id));
          const u = [];
          for (const h of s) {
            const p = h.parentId, q = h.childId;
            if (typeof p != "string" || typeof q != "string")
              return X('Each link needs string "parentId" and "childId".');
            const g = l.get(p), v = l.get(q);
            if (!g) return X(`Link references unknown parentId "${p}".`);
            if (!v) return X(`Link references unknown childId "${q}".`);
            u.push(e.makeEdge(g, v));
          }
          const d = Or(c, u);
          return d.length ? X(d[0]) : (e.applyModel(c, u), Ee({ scheduleCount: c.length, linkCount: u.length }));
        }
        case "validate": {
          const o = Or(e.getNodes(), e.getEdges());
          return Ee({ valid: o.length === 0, errors: o });
        }
        default:
          return X(`Unknown tool "${t}".`);
      }
    } catch (o) {
      return X(`Tool "${t}" threw: ${(o == null ? void 0 : o.message) ?? String(o)}`);
    }
  } };
}
function by(e, r) {
  const n = ge(() => gy(e), []), t = _e(r);
  return t.current = r, oe(() => {
    var a;
    return (a = t.current) == null || a.call(t, n), () => {
      var i;
      return (i = t.current) == null ? void 0 : i.call(t, null);
    };
  }, [n]), n;
}
const yy = {
  scheduleNode: Cm
}, xy = ({
  initialData: e,
  onSave: r,
  onSaveAndReturn: n,
  onBack: t,
  additionalCanvasMenuItems: a,
  additionalNodeMenuItems: i,
  onAiCapabilityReady: o,
  repositories: s
}) => {
  const c = cp(), l = s || c, {
    nodes: u,
    edges: d,
    onNodesChange: h,
    onEdgesChange: p,
    onConnect: q,
    handleUpdateNode: g,
    handleLayout: v,
    handleAddNode: b,
    setNodes: m,
    undo: y,
    redo: w,
    canUndo: N,
    canRedo: I,
    takeSnapshot: _,
    loadData: R,
    buildScheduleNode: k,
    makeEdge: S,
    applyModel: E
  } = dy(e), A = _e(u);
  A.current = u;
  const P = _e(d);
  P.current = d;
  const z = ge(() => ({
    getNodes: () => A.current,
    getEdges: () => P.current,
    buildScheduleNode: k,
    makeEdge: S,
    applyModel: E
  }), [k, S, E]);
  by(z, o);
  const [F, J] = B(null), [M, G] = B(!1), [D, $] = B(!1), [le, de] = B(!1), [ne, C] = B(0), [T, O] = B(null), [L, H] = B(!1), [Y, Q] = B({
    name: e.name,
    tags: e.tags,
    configuration: e.configuration
  }), [ce, Me] = B(() => {
    var ee;
    const j = ((ee = e.configuration) == null ? void 0 : ee.scheduleGroups) || [], K = /* @__PURE__ */ new Map();
    return rc.forEach((Z) => K.set(Z.name, Z)), j.forEach((Z) => K.set(Z.name, Z)), (e.schedules || []).forEach((Z) => {
      Z.group && !K.has(Z.group) && K.set(Z.group, { name: Z.group, color: "slate" });
    }), Array.from(K.values());
  }), fe = ie((j) => {
    Me((K) => {
      if (K.some((Z) => Z.name === j)) return K;
      const ee = [...K, { name: j, color: "slate" }];
      return Q((Z) => ({
        ...Z,
        configuration: { ...Z.configuration, scheduleGroups: ee }
      })), ee;
    });
  }, []), se = ie((j, K) => {
    Me((ee) => {
      const Z = ee.map((re) => re.name === j ? { ...re, ...K, name: j } : re);
      return Q((re) => ({
        ...re,
        configuration: { ...re.configuration, scheduleGroups: Z }
      })), Z;
    });
  }, []), { getViewport: V, deleteElements: Re, getNodes: W, getEdges: Pe } = Eo(), Ce = _e(null), Qr = ie((j, K) => {
    J(K.data);
  }, []), $e = ie(() => {
    J(null), O(null);
  }, []), qe = ie(() => {
    _();
  }, [_]), he = () => {
    J(null), m((j) => j.map((K) => ({ ...K, selected: !1 })));
  }, He = () => {
    _();
    const j = W().filter((ee) => ee.selected), K = Pe().filter((ee) => ee.selected);
    Re({ nodes: j, edges: K }), G(!1), F && j.some((ee) => ee.id === F.scheduleId) && J(null);
  }, Ve = (j) => {
    if (F) {
      const K = [...F.resources || [], ...j];
      g(F.scheduleId, "resources", K);
    }
  }, et = (j) => {
    if (F) {
      const K = F.requirements || [], ee = new Set(K.map((re) => re.testamentTypeId)), Z = j.filter((re) => !ee.has(re.testamentTypeId)).map((re) => ({ testamentTypeId: re.testamentTypeId }));
      g(F.scheduleId, "requirements", [...K, ...Z]);
    }
  }, Ke = () => ({
    ...e,
    // Keep original ObjectType etc
    name: Y.name,
    tags: Y.tags,
    configuration: { ...Y.configuration, scheduleGroups: ce },
    schedules: u.map((j) => j.data)
  }), Le = () => {
    var j;
    (j = Ce.current) == null || j.click();
  }, wr = (j) => {
    var Z;
    const K = (Z = j.target.files) == null ? void 0 : Z[0];
    if (!K) return;
    const ee = new FileReader();
    ee.onload = (re) => {
      var De, Qo;
      try {
        const tt = (De = re.target) == null ? void 0 : De.result, je = JSON.parse(tt);
        if (!je.schedules || !Array.isArray(je.schedules)) {
          alert("Invalid file format: Missing Schedules array.");
          return;
        }
        Q({
          name: je.name || "",
          tags: je.tags || [],
          configuration: je.configuration || {}
        });
        const Xh = ((Qo = je.configuration) == null ? void 0 : Qo.scheduleGroups) || [], tr = /* @__PURE__ */ new Map();
        rc.forEach((ke) => tr.set(ke.name, ke)), Xh.forEach((ke) => tr.set(ke.name, ke)), (je.schedules || []).forEach((ke) => {
          ke.group && !tr.has(ke.group) && tr.set(ke.group, { name: ke.group, color: "slate" });
        }), Me(Array.from(tr.values())), R(je);
      } catch (tt) {
        console.error(tt), alert("Failed to load file.");
      }
    }, ee.readAsText(K), j.target.value = "";
  }, Nr = () => {
    var De;
    const j = Ke(), K = JSON.stringify(j, null, 2), ee = new Blob([K], { type: "application/json" }), Z = URL.createObjectURL(ee), re = document.createElement("a");
    re.href = Z, re.download = `${((De = j.name) == null ? void 0 : De.replace(/\s+/g, "_")) || "Entitlement"}.json`, document.body.appendChild(re), re.click(), document.body.removeChild(re), URL.revokeObjectURL(Z);
  }, rt = ie((j, K) => {
    j.preventDefault();
    const ee = i ? i(K.data) : [], Z = ee.length > 0;
    O({
      x: j.clientX,
      y: j.clientY,
      items: [
        ...ee,
        ...Z ? [{ 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: () => {
            C(1), m((re) => re.map((De) => ({ ...De, selected: De.id === K.id }))), G(!0);
          },
          danger: !0
        }
      ].filter((re) => re.label !== "Separator" || re.icon)
    });
  }, [m, i]), qr = ie((j) => {
    j.preventDefault();
    const K = a || [], ee = K.length > 0;
    O({
      x: j.clientX,
      y: j.clientY,
      items: [
        {
          label: "Add New Node Here",
          icon: /* @__PURE__ */ f(vr, { size: 14 }),
          onClick: () => {
            b(V());
          }
        },
        ...ee ? [{ label: "Separator", disabled: !0, onClick: () => {
        }, icon: /* @__PURE__ */ f("div", { className: "h-px w-full bg-slate-200 my-1" }) }] : [],
        ...K
      ]
    });
  }, [b, V, a]);
  Ro.useEffect(() => {
    if (F) {
      const j = u.find((K) => K.id === F.scheduleId);
      j && J(j.data);
    }
  }, [u]);
  const Ie = ge(() => u.map((j) => j.data), [u]);
  return /* @__PURE__ */ f(sp, { groups: ce, onAddGroup: fe, onUpdateGroup: se, children: /* @__PURE__ */ x("div", { className: "flex flex-col h-full w-full bg-slate-50 overflow-hidden", children: [
    /* @__PURE__ */ f(
      "input",
      {
        type: "file",
        ref: Ce,
        onChange: wr,
        accept: ".json",
        className: "hidden"
      }
    ),
    /* @__PURE__ */ x("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__ */ x("div", { className: "flex items-center gap-2 md:gap-4 overflow-hidden z-20 min-w-0", children: [
        t && /* @__PURE__ */ x(lr, { children: [
          /* @__PURE__ */ f(
            "button",
            {
              onClick: t,
              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(mp, { size: 20 })
            }
          ),
          /* @__PURE__ */ f("div", { className: "h-6 w-px bg-slate-200 mx-1 md:mx-2 hidden md:block" })
        ] }),
        /* @__PURE__ */ x("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: Y.name || "Untitled Entitlement" }),
          /* @__PURE__ */ x("div", { className: "flex items-center gap-2 text-[10px] md:text-xs text-slate-500", children: [
            /* @__PURE__ */ x("span", { className: "bg-slate-100 px-1.5 py-0.5 rounded border border-slate-200 font-mono", children: [
              u.length,
              " Schedules"
            ] }),
            Y.tags.length > 0 && /* @__PURE__ */ x("span", { className: "hidden md:inline-flex items-center gap-1", children: [
              /* @__PURE__ */ f("span", { className: "w-1 h-1 rounded-full bg-slate-300" }),
              Y.tags.join(", ")
            ] })
          ] })
        ] })
      ] }),
      /* @__PURE__ */ x("div", { className: "flex items-center gap-1 md:gap-2", children: [
        /* @__PURE__ */ x("div", { className: "hidden md:flex items-center gap-1 mr-2 border-r border-slate-200 pr-2", children: [
          /* @__PURE__ */ f("button", { onClick: y, disabled: !N, className: "p-2 text-slate-400 hover:text-slate-700 disabled:opacity-30 rounded-lg", title: "Undo", children: /* @__PURE__ */ f(_m, { size: 18 }) }),
          /* @__PURE__ */ f("button", { onClick: w, disabled: !I, className: "p-2 text-slate-400 hover:text-slate-700 disabled:opacity-30 rounded-lg", title: "Redo", children: /* @__PURE__ */ f(tm, { size: 18 }) })
        ] }),
        /* @__PURE__ */ f("button", { onClick: v, 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(Hp, { size: 18 }) }),
        /* @__PURE__ */ f("button", { onClick: () => H(!0), className: "p-2 text-slate-500 hover:text-teal-600 hover:bg-teal-50 rounded-lg transition-colors", title: "Settings", children: /* @__PURE__ */ f(Pr, { size: 18 }) }),
        /* @__PURE__ */ f("div", { className: "h-6 w-px bg-slate-200 mx-1" }),
        /* @__PURE__ */ x("div", { className: "flex items-center gap-1", children: [
          /* @__PURE__ */ f("button", { onClick: Le, className: "p-2 text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors", title: "Import JSON", children: /* @__PURE__ */ f(Nm, { size: 18 }) }),
          /* @__PURE__ */ f("button", { onClick: Nr, className: "p-2 text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors", title: "Export JSON", children: /* @__PURE__ */ f(Lp, { size: 18 }) })
        ] }),
        /* @__PURE__ */ x(
          "button",
          {
            onClick: () => {
              r && r(Ke());
            },
            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(H0, { size: 16 }),
              /* @__PURE__ */ f("span", { className: "hidden md:inline", children: "Save" })
            ]
          }
        ),
        n && /* @__PURE__ */ f(
          "button",
          {
            onClick: () => n(Ke()),
            className: "ml-1 p-2 text-teal-600 hover:bg-teal-50 rounded-lg",
            title: "Save & Return",
            children: /* @__PURE__ */ f(Wp, { size: 18 })
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ x("div", { className: "flex-1 relative bg-slate-50", children: [
      /* @__PURE__ */ f(Km, { nodes: u, onSelectNode: J }),
      /* @__PURE__ */ x(
        Qh,
        {
          nodes: u,
          edges: d,
          onNodesChange: h,
          onEdgesChange: p,
          onConnect: q,
          nodeTypes: yy,
          onNodeClick: Qr,
          onPaneClick: $e,
          onNodeDragStart: qe,
          onNodeContextMenu: rt,
          onPaneContextMenu: qr,
          fitView: !0,
          minZoom: 0.1,
          maxZoom: 1.5,
          connectionMode: np.Loose,
          defaultEdgeOptions: {
            type: "smoothstep",
            animated: !1,
            style: { stroke: "#94a3b8", strokeWidth: 2 }
          },
          children: [
            /* @__PURE__ */ f(ap, { color: "#e2e8f0", gap: 20 }),
            /* @__PURE__ */ f(ip, { className: "!bg-white !shadow-sm !border !border-slate-200 !m-4" })
          ]
        }
      ),
      T && /* @__PURE__ */ f(
        Vm,
        {
          x: T.x,
          y: T.y,
          items: T.items,
          onClose: () => O(null)
        }
      ),
      F && /* @__PURE__ */ f(
        jm,
        {
          node: F,
          allNodes: Ie,
          onClose: he,
          onUpdate: g,
          onAddResourceRequest: () => $(!0),
          onAddRequirementRequest: () => de(!0)
        }
      )
    ] }),
    /* @__PURE__ */ f(
      Gm,
      {
        isOpen: M,
        onClose: () => G(!1),
        onConfirm: He,
        count: ne
      }
    ),
    /* @__PURE__ */ f(
      Fm,
      {
        isOpen: L,
        onClose: () => H(!1),
        data: Y,
        onSave: (j) => {
          Q(j);
        }
      }
    ),
    /* @__PURE__ */ f(
      Bm,
      {
        isOpen: D,
        onClose: () => $(!1),
        onConfirm: Ve,
        repositories: l
      }
    ),
    /* @__PURE__ */ f(
      $m,
      {
        isOpen: le,
        onClose: () => de(!1),
        onConfirm: et,
        repository: l == null ? void 0 : l.testamentTypes,
        excludedIds: ((F == null ? void 0 : F.requirements) || []).map((j) => j.testamentTypeId)
      }
    )
  ] }) });
}, fr = [
  { groupName: "GlobalAdmins", nodeName: "Root", role: "Owner" },
  { groupName: "LocalOps", nodeName: "Berlin", role: "Operator" }
], me = {
  paramA: "value1",
  syncEnabled: !0
}, hr = "7a2e0fa0-d84f-81c8-387c-cba962518d94", cr = "10000000-0000-0000-0000-000000000001", Jh = "10000000-0000-0000-0000-000000000002", pr = "10000000-0000-0000-0000-000000000003", ur = "10000000-0000-0000-0000-000000000004", Mr = [
  {
    id: hr,
    name: "Main Access Control",
    memberships: fr,
    resources: [],
    resourcePlans: []
  },
  {
    id: cr,
    name: "Internal Systems",
    memberships: [],
    resources: [],
    resourcePlans: []
  },
  {
    id: Jh,
    name: "IoT Devices",
    memberships: [],
    resources: [],
    resourcePlans: []
  },
  {
    id: pr,
    name: "Legacy Controller A",
    memberships: [],
    resources: [],
    resourcePlans: []
  },
  {
    id: ur,
    name: "Cloud Access Manager",
    memberships: fr,
    resources: [],
    resourcePlans: []
  }
], So = [
  // 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: ue.Single, resourceType: "Door", memberships: [], configuration: me, systemId: hr },
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bbf", name: "Side Entrance Staff", description: "Staff only entrance", referenceId: "EXT-002", resourceKind: ue.Single, resourceType: "Door", memberships: [], configuration: me, systemId: hr },
  // Mapped to Internal
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bbb", name: "Office 101 (North)", description: "Open space area north", referenceId: "INT-101", resourceKind: ue.Collection, resourceType: "Zone", memberships: fr, configuration: me, systemId: cr },
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bbc", name: "Office 102 (North)", description: "Meeting rooms north", referenceId: "INT-102", resourceKind: ue.Collection, resourceType: "Zone", memberships: [], configuration: me, systemId: cr },
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bbd", name: "Office 103 (East)", description: "Quiet zone east", referenceId: "INT-103", resourceKind: ue.Collection, resourceType: "Zone", memberships: [], configuration: me, systemId: cr },
  // Mapped to Cloud
  { id: "899d0c8b-9ec8-aa62-3956-b770f75dd7ea", name: "Executive Suite", description: "High security area", referenceId: "SEC-900", resourceKind: ue.Fixed, resourceType: "SecureZone", memberships: fr, configuration: me, systemId: ur },
  { id: "30000000-0000-0000-0000-000000000001", name: "Conference Room A", description: "Large conference room", referenceId: "CONF-A", resourceKind: ue.Single, resourceType: "Room", memberships: [], configuration: me, systemId: ur },
  { id: "30000000-0000-0000-0000-000000000002", name: "Conference Room B", description: "Small meeting room", referenceId: "CONF-B", resourceKind: ue.Single, resourceType: "Room", memberships: [], configuration: me, systemId: ur },
  // Mapped to Legacy
  { id: "a118c70c-0944-dc75-db81-26665a7ff674", name: "Server Room Rack A", description: "Main server rack access", referenceId: "SRV-A", resourceKind: ue.Single, resourceType: "Cabinet", memberships: [], configuration: me, systemId: pr },
  { id: "30000000-0000-0000-0000-000000000003", name: "Cafeteria Turnstile", description: "Lunch area access", referenceId: "CAF-01", resourceKind: ue.Single, resourceType: "Turnstile", memberships: [], configuration: me, systemId: pr },
  // Mapped to IoT
  { id: "fabd7570-34c7-141c-4aac-ffcf1e4e5bba", name: "Printer Room", description: "Common service area", referenceId: "SVC-001", resourceKind: ue.Single, resourceType: "Room", memberships: [], configuration: me, systemId: Jh }
];
for (let e = 1; e <= 60; e++) {
  const r = Math.floor((e - 1) / 15) + 1, n = Mr[e % Mr.length], t = `50000000-0000-0000-0000-${(1e11 + e).toString()}`;
  So.push({
    id: t,
    name: `Floor ${r} - Desk ${e}`,
    description: `Hot desk on floor ${r}`,
    referenceId: `DSK-${r}-${e}`,
    resourceKind: ue.Single,
    resourceType: "Desk",
    memberships: [],
    configuration: {},
    systemId: n.id
  });
}
const T0 = [
  // 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: me, systemId: hr },
  { id: "20000000-0000-0000-0000-000000000005", name: "Emergency Access", description: "Override all locks", referenceId: "PLN-EMG", priority: 100, memberships: [], configuration: me, systemId: hr },
  // Cloud Plans
  { id: "20000000-0000-0000-0000-000000000001", name: "24/7 Unlimited", description: "All hours access", referenceId: "PLN-ALL", priority: 99, memberships: fr, configuration: me, systemId: ur },
  // 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: cr },
  // Legacy Plans
  { id: "20000000-0000-0000-0000-000000000003", name: "Visitor Restricted", description: "Escort required", referenceId: "PLN-VIS", priority: 0, memberships: [], configuration: {}, systemId: pr },
  { id: "20000000-0000-0000-0000-000000000004", name: "Maintenance Access (Weekends)", description: "Weekend only", referenceId: "PLN-MNT", priority: 50, memberships: [], configuration: {}, systemId: pr }
], O0 = [
  { 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" }
], _y = [
  { 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" }
], Zh = [
  {
    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
  }
], wy = 300, xe = (e) => new Promise((r) => setTimeout(() => r(e), wy)), nr = (e, r) => {
  let n = [...e];
  if (r != null && r.filter) {
    const a = r.filter.toLowerCase();
    n = n.filter((i) => (i.name || "").toLowerCase().includes(a) || i.id.toLowerCase().includes(a));
  }
  r != null && r.sortBy && n.sort((a, i) => {
    const o = a.name || "", s = i.name || "";
    return o.localeCompare(s);
  });
  const t = n.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;
    n = n.slice(a, a + r.pageSize);
  }
  return { items: n, total: t };
}, qo = (e, r) => {
  const n = /* @__PURE__ */ new Map(), t = new Set(r), a = new Map(e.map((i) => [i.id, i]));
  return t.forEach((i) => {
    const o = a.get(i);
    o && n.set(i, o);
  }), n;
}, Ny = (e, r) => {
  const n = /* @__PURE__ */ new Map(), t = new Set(r);
  return e.forEach((a) => {
    t.has(a.id) && n.set(a.id, a.name);
  }), t.forEach((a) => {
    n.has(a) || n.set(a, a);
  }), n;
}, qy = (e) => {
  const r = e.toLowerCase();
  return Zh.filter((n) => [
    n.testamentTypeId,
    n.name,
    n.description || "",
    n.category || ""
  ].join(" ").toLowerCase().includes(r));
}, Iy = (e) => {
  const r = new Set(e);
  return Zh.filter((n) => r.has(n.testamentTypeId));
}, Ey = {
  getSystems: (e) => xe(nr(Mr, e)),
  getResources: (e) => xe(nr(So, e)),
  getPlans: (e) => xe(nr(T0, e)),
  getLocations: (e) => xe(nr(O0, e)),
  getApprovalGroups: (e) => xe(nr(_y, e)),
  resolveSystems: (e) => xe(qo(Mr, e)),
  resolveResources: (e) => xe(qo(So, e)),
  resolvePlans: (e) => xe(qo(T0, e)),
  resolveLocations: (e) => xe(Ny(O0, e)),
  testamentTypes: {
    search: (e) => xe(qy(e)),
    resolve: (e) => xe(Iy(e))
  }
}, Ay = ({
  initialData: e,
  onSave: r,
  onSaveAndReturn: n,
  onBack: t,
  onLoadRequest: a,
  additionalCanvasMenuItems: i,
  additionalNodeMenuItems: o,
  onAiCapabilityReady: s
}) => /* @__PURE__ */ f(
  xy,
  {
    initialData: e,
    onSave: r,
    onSaveAndReturn: n,
    onBack: t,
    additionalCanvasMenuItems: i,
    additionalNodeMenuItems: o,
    onAiCapabilityReady: s
  },
  e.name
);
export {
  ar as ApprovalGroupType,
  rc as DEFAULT_SCHEDULE_GROUPS,
  pe as Direction,
  xy as EntitlementEditor,
  Ay as EntitlementEditorWrapper,
  Ey as MockRepository,
  Cy as RepositoryProvider,
  ue as ResourceKind,
  sp as ScheduleGroupProvider,
  gy as buildAiCapability,
  xy as default,
  op as useRepositories,
  D0 as useScheduleGroups,
  Or as validateGraph
};
//# sourceMappingURL=index.js.map
