
		import { Core as _autoloadCSSCore } from '../core/app.js';
		const fileNames = ['../assets/policy.css'].map(fileName => import.meta.resolve(fileName));
		_autoloadCSSCore.insertCSSLinkToPage(fileNames, true);
	
import { defineComponent as Q, mergeModels as H, useModel as re, ref as D, onMounted as fe, onUpdated as pe, createElementBlock as C, openBlock as m, normalizeClass as ve, createCommentVNode as M, Fragment as N, renderList as Y, createBlock as B, mergeProps as q, createSlots as j, withCtx as w, createTextVNode as V, toDisplayString as P, createVNode as ie, createElementVNode as ue, withModifiers as me, computed as K, watch as J, toRef as F, resolveComponent as te, resolveDirective as le, unref as c, renderSlot as he, withDirectives as ae, resolveDynamicComponent as ye } from "vue";
import { e as se, b as ge, C as G, d as Ae, u as Ie, s as Ce } from "./forms-BpbQYyEQ.es.js";
import { _ as Te, b as ne } from "./popupHint.vue_vue_type_style_index_0_lang-if4Qli-k.es.js";
import { _ as ke } from "./widgetInput.vue_vue_type_script_setup_true_lang-Dy8jWadl.es.js";
import { invertKeyboardLayout as Se } from "../utils/keyboard.js";
import { g as Le } from "./field-CyyFzM-Y.es.js";
const be = {
  key: 0,
  class: "top-menu_selectAll"
}, He = /* @__PURE__ */ Q({
  __name: "menu",
  props: /* @__PURE__ */ H({
    modelValue: {},
    items: {},
    isMultiple: { type: Boolean },
    canBeEmptyMultiple: { type: Boolean },
    styling: { default: "default" },
    selectAllItem: {}
  }, {
    modelValue: {
      required: !0
    },
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(e) {
    const s = e, a = re(e, "modelValue"), t = D();
    !s.isMultiple && typeof a.value != "string" && typeof a.value != "number" && console.warn('Type check failed for prop "modelValue". Expected String: ' + typeof a.value), s.isMultiple && !Array.isArray(a.value) && console.warn('Type check failed for prop "modelValue". Expected Array: ' + typeof a.value), s.isMultiple && !s.canBeEmptyMultiple && Array.isArray(a.value) && !a.value.length && s.items[0] && (a.value = [s.items[0]?.href ?? s.items[0]?.value]);
    const i = (u) => Array.isArray(a.value) ? a.value.includes(u.value) : u.value === a.value, T = (u, h = !1) => {
      if (Array.isArray(a.value)) {
        let r = a.value.slice();
        if (h) {
          r.length || (r = s.items.map((d) => d.value));
          const g = r.indexOf(u.value);
          g === -1 ? r.push(u.value) : r.splice(g, 1);
        } else
          r.length === 1 && r[0] === u.value ? r = [] : r = [u.value];
        !s.canBeEmptyMultiple && !r.length && (r = [u.value]), a.value = r;
        return;
      }
      a.value = u.value;
    }, v = (u) => {
      if (t.value.scrollWidth <= t.value.offsetWidth || u.shiftKey || Math.abs(u.deltaY) < 50) return;
      u.preventDefault();
      const h = u.deltaY > 0 ? 30 : -30;
      t.value.scrollLeft = t.value.scrollLeft + h;
    }, o = (u = !0) => {
      const h = t.value.querySelector(".top-active");
      if (!h) return;
      const r = 24, g = h.offsetLeft - t.value.offsetLeft - r, d = h.offsetLeft - t.value.offsetLeft + h.clientWidth + r, y = t.value.scrollLeft, L = t.value.clientWidth + t.value.scrollLeft;
      let I;
      g < y && (I = g), d > L && (I = d - t.value.clientWidth), I !== void 0 && (ge() ? G.$?.(t.value).animate({ scrollLeft: I }, u ? 200 : 0) : t.value.scrollTo({ left: I, behavior: u ? "smooth" : "auto" }));
    }, n = () => {
      if (Array.isArray(a.value)) {
        if (a.value.length === s.items.length) {
          a.value = [s.items[0].href ?? s.items[0].value];
          return;
        }
        a.value = s.items.map((u) => u.href ?? u.value);
      }
    };
    return fe(() => o(!1)), pe(() => o(!0)), (u, h) => (m(), C("div", {
      ref_key: "el",
      ref: t,
      class: ve({
        "top-menu": !0,
        ["top-style_" + e.styling]: !0
        // ['top-unwrap-x']: styling === 'default',
      }),
      onWheel: v
    }, [
      (m(!0), C(N, null, Y(e.items, (r) => (m(), B(se, q({ ref_for: !0 }, r, {
        class: "top-menu_item",
        color: "theme",
        onClick: (g) => T(r, g.ctrlKey || g.metaKey),
        isActive: i(r)
      }), j({ _: 2 }, [
        r.content ? {
          name: "default",
          fn: w(() => [
            V(P(r.content), 1)
          ]),
          key: "0"
        } : void 0
      ]), 1040, ["onClick", "isActive"]))), 256)),
      Array.isArray(a.value) && e.selectAllItem ? (m(), C("div", be, [
        ie(se, q(e.selectAllItem, {
          class: "top-menu_item",
          color: "theme",
          styling: "",
          onClick: h[0] || (h[0] = (r) => n()),
          isActive: a.value.length === e.items.length
        }), j({ _: 2 }, [
          e.selectAllItem.content ? {
            name: "default",
            fn: w(() => [
              V(P(e.selectAllItem.content), 1)
            ]),
            key: "0"
          } : void 0
        ]), 1040, ["isActive"])
      ])) : M("", !0)
    ], 34));
  }
}), Be = { class: "top-selector2_itemMulti top-ellipsis" }, we = /* @__PURE__ */ Q({
  __name: "itemMulti",
  props: {
    id: {},
    name: {}
  },
  emits: ["delete"],
  setup(e) {
    return (s, a) => (m(), C("div", Be, [
      V(P(e.name) + " ", 1),
      ue("span", {
        class: "top-selector2_itemMultiDelete",
        "data-top-icon": "",
        onClick: a[0] || (a[0] = (t) => s.$emit("delete", { id: e.id, name: e.name })),
        onMousedown: a[1] || (a[1] = me(() => {
        }, ["stop"]))
      }, null, 32)
    ]));
  }
}), R = /* @__PURE__ */ new Map(), xe = (e) => {
  R.get(e)?.clear();
}, Me = (e) => {
  const s = window.mo?.user?.id;
  return JSON.stringify(e.params) + ":" + e.url + ":" + s;
}, Pe = (e, s) => R.get(s)?.get(e), $e = (e, s, a) => {
  R.has(s) || R.set(s, /* @__PURE__ */ new Map()), R.get(s)?.set(e, a);
}, Fe = (e, s, a, t) => {
  const i = D([]), T = D(!1), v = D(0);
  let o = "", n;
  e && !e.params.limit && (e.params.limit = 100);
  const u = async () => {
    if (!e) return;
    const d = t ? Me(e) : void 0;
    if (d) {
      const I = Pe(d, e.path);
      if (I)
        return e.abortByFingerprint(), I;
    }
    const y = await e.call();
    if (y.errors) return;
    if (!Array.isArray(y.result)) {
      console.warn("Array expected in `res.result`");
      return;
    }
    const L = y.result.findIndex((I) => I.id === void 0 || I.name === void 0);
    if (L !== -1) {
      console.warn(`В result[${L}] нет id или name`);
      return;
    }
    return d && $e(d, e.path, y), y;
  }, h = async (d) => {
    if (!e) return;
    if (d) {
      if (!n || T.value) return;
      e.params.offset = n;
    } else
      e.params.offset = 0;
    s?.(e, o), T.value = !0;
    const y = await u();
    T.value = !1, v.value++, y && (n = y.nextOffset, d ? i.value = i.value.concat(y.result) : i.value = y.result);
  }, r = Ae(() => h(!1), 200);
  return {
    apiRequest: e,
    items: i,
    isLoading: T,
    countLoading: v,
    load: h,
    setSearchTextAndLoad: (d, y = !0) => {
      if (e) {
        if (d.length < a) {
          e.abortByFingerprint(), i.value = [];
          return;
        }
        d === o && i.value.length || (o = d, y ? r() : h(!1));
      }
    }
  };
}, ce = 0, W = null, oe = (e, s, a = !0) => a && s.id === W ? Array.isArray(e) ? e.some((t) => t.id === s.id && t.name === s.name) : s.name === e.name : Array.isArray(e) ? e.some((t) => t.id === s.id) : s.id === e.id, Ye = (e, s, a) => {
  let t = e.params.filters ?? [];
  t = t.filter((i) => i.name !== a), s && t.push(Le(a, "CONTAINS", [s])), e.changeParams({ filters: t });
}, De = (e, s, a, t, i, T, v, o, n, u, h, r, g) => {
  const d = D(""), y = {
    id: ce,
    name: Ie().Common.All
  }, L = () => {
    d.value = "";
  }, I = () => !(!g.apiRequest || d.value.length >= r), O = K(() => {
    const l = [];
    return !t && i.value && (typeof i.value == "string" && (y.name = i.value), l.push(y)), a.value?.forEach((b) => l.push({ ...b })), l;
  }), f = D([]), p = () => {
    f.value = E();
  }, E = () => {
    const l = d.value.toLowerCase(), b = Se(l);
    let S = [], $;
    const k = [], Z = () => {
      k.at(-1)?.listItemProps?.type === "delimiter" && k.pop(), k.length && ($ && S.push($), S.push(...k), k.length = 0);
    };
    for (const A of O.value)
      switch (A.listItemProps?.type) {
        case "title":
          Z(), $ = A;
          break;
        case "delimiter":
          if (k.length) {
            let x = k.length;
            k.at(-1)?.listItemProps?.type === "delimiter" && x--, k[x] = A;
          }
          break;
        default:
          const de = u.value?.includes("id"), _ = A.name.toLowerCase(), ee = u.value?.filter((x) => x !== "id").map((x) => typeof A[x] == "string" || typeof A[x] == "number" ? A[x] : "").join("☼").toLowerCase();
          (de && A.id === Number(l) || ee?.includes(l) || ee?.includes(b)) && (_ === l || _ === b ? k.unshift(A) : k.push(A));
      }
    if (Z(), S.push(...g.items.value), T.value && d.value && (!o.value || o.value(l)) && // предложить добавить элемент, если нет точного совпадения или разрешены дубликаты
    (v.value || !S.find((A) => A.name.toLowerCase() === l))) {
      const A = {
        id: W,
        name: d.value
      };
      n.value && (A.listItemProps = { closeByClick: !1 }), S.push(A);
    }
    return t && (S = S.filter((A) => !oe(e.value, A))), S;
  }, z = (l) => {
    l.listItemProps?.type === "title" || l.listItemProps?.type === "delimiter" || l.id === W && (s("appendItem", l), n.value) || (t && Array.isArray(e.value) ? oe(e.value, l) || (e.value = [...e.value, l]) : e.value = l, setTimeout(() => {
      L();
    }));
  };
  if (g.apiRequest) {
    const l = [a, g.items];
    t && l.push(e), J(l, () => {
      p();
    });
  } else
    J([e, a, d], () => {
      p();
    }, {
      immediate: !0,
      // слежение за изменениями `items`
      deep: 2
    });
  return {
    searchText: d,
    resetSearch: L,
    genIsShort: I,
    itemsForShow: f,
    selectItem: z,
    selectNextItem: () => {
      if (Array.isArray(e.value)) return;
      const l = f.value.filter(($) => !["title", "delimiter"].includes($.listItemProps?.type ?? "")), S = (l.findIndex(($) => $.id === e.value.id) + 1) % l.length;
      e.value = { ...l[S] };
    },
    deleteItemByItem: async (l) => {
      Array.isArray(e.value) && (e.value = e.value.filter((b) => b.id !== l.id || b.name !== l.name));
    }
  };
}, Ee = {
  key: 0,
  class: "top-selector2_activeItems"
}, Ve = {
  key: 1,
  class: "top-selector2_activeName top-ellipsis"
}, Ne = {
  key: 2,
  class: "top-selector2_placeholder top-ellipsis"
}, Re = { class: "top-selector2_searchWidget" }, je = /* @__PURE__ */ Q({
  __name: "selector2",
  props: /* @__PURE__ */ H({
    modelValue: {},
    items: { default: () => [] },
    title: {},
    disabled: { type: Boolean },
    icon: {},
    modificator: {},
    size: { default: "s" },
    isError: { type: Boolean },
    openByFocusInput: { type: Boolean, default: void 0 },
    searchType: { default: "popup" },
    searchFields: { default: () => ["id", "name"] },
    placeholder: {},
    hasCloserBtn: { type: Boolean },
    api: {},
    apiSetSearchParams: {},
    minLength: { default: 0 },
    useCache: { type: Boolean },
    appendSearchToResult: { type: Boolean },
    appendSearchAllowDuplicate: { type: Boolean },
    appendSearchToResultCond: {},
    appendWithoutSelect: { type: Boolean },
    multiselect: { type: Boolean },
    useAllItem: { type: [Boolean, String] },
    addChanger: { type: Boolean },
    buttonProps: {},
    selectedAsPlaceholder: { type: Boolean },
    openerShortcut: {}
  }, {
    modelValue: { required: !0 },
    modelModifiers: {}
  }),
  emits: /* @__PURE__ */ H(["appendItem", "open"], ["update:modelValue"]),
  setup(e, { expose: s, emit: a }) {
    const t = e, i = re(e, "modelValue"), T = a;
    s({
      /**
       * Сброс локального кеша и кеша api
       *
       * @param resetAPICache - Сбросить API кеш, по умолчанию не сбрасывается. Для случаев, когда загруженные данные становятся неактуальными
       */
      resetCache: (f = !1) => {
        o.apiRequest && (f && xe(o.apiRequest.path), o.items.value = [], o.countLoading.value = 0, o.apiRequest.params.offset = 0, requestAnimationFrame(() => {
          n.itemsForShow.value = [];
        }), r()?.elPopup && o.setSearchTextAndLoad(n.searchText.value));
      }
    });
    const v = K(() => t.searchType === "inline" && t.multiselect || t.searchType === "inline" && G.state.isMobile ? "popup" : t.searchType), o = Fe(t.api, t.apiSetSearchParams, t.minLength, t.useCache), n = De(
      i,
      T,
      F(t, "items"),
      t.multiselect,
      F(t, "useAllItem"),
      F(t, "appendSearchToResult"),
      F(t, "appendSearchAllowDuplicate"),
      F(t, "appendSearchToResultCond"),
      F(t, "appendWithoutSelect"),
      F(t, "searchFields"),
      v,
      t.minLength,
      o
    ), u = K(() => t.buttonProps ? "TopButton" : v.value === "inline" ? "TopInput" : "div"), h = D(null), r = () => h.value?.popup;
    o.apiRequest && J(n.searchText, () => {
      o.setSearchTextAndLoad(n.searchText.value);
    });
    const g = K(() => Array.isArray(i.value) || t.multiselect || !t.selectedAsPlaceholder && v.value !== "inline" ? t.placeholder : i.value?.name || t.placeholder), d = (f) => {
      let p = !1;
      switch (f.key) {
        case "Delete":
        case "Backspace":
          Array.isArray(i.value) && (f.preventDefault(), f.stopPropagation(), i.value.pop());
          break;
        case "ArrowUp":
        case "ArrowRight":
        case "ArrowDown":
        case "ArrowLeft":
        case "Enter":
        case " ":
          p = !0;
          break;
        case "Escape":
          v.value === "inline" && n.resetSearch();
          break;
      }
      const E = f.key.length === 1 && !f.ctrlKey && !f.metaKey;
      (v.value === "popup" || v.value === "inline") && E && (p = !0), r()?.elPopup && (p = !1), p && (v.value === "popup" && (f.preventDefault(), f.stopPropagation(), E && (n.searchText.value || (n.searchText.value = f.key))), f.currentTarget?.click());
    }, y = (f) => {
      f.preventDefault(), n.selectNextItem();
    }, L = () => {
      o.apiRequest && o.setSearchTextAndLoad(n.searchText.value, !1), T("open");
    }, I = () => {
      v.value === "popup" && n.searchText.value && n.resetSearch();
    }, O = (f) => {
      const p = f.target;
      p.scrollTop / (p.scrollHeight - p.offsetHeight) > 0.8 && o.load(!0);
    };
    return (f, p) => {
      const E = te("TopButton"), z = te("TopLoadbar"), U = le("top-focus"), X = le("top-shortcut");
      return m(), B(c(Te), {
        ref_key: "popupRef",
        ref: h,
        onOpen: p[3] || (p[3] = (l) => L()),
        onClose: p[4] || (p[4] = (l) => I()),
        onScrollContentList: p[5] || (p[5] = (l) => c(o) ? O(l) : void 0),
        notch: !1,
        transitionDuration: 0,
        openByFocusInput: v.value === "inline" && (e.openByFocusInput ?? !0),
        disabled: v.value === "inline" && c(n).genIsShort()
      }, j({
        opener: w(() => [
          ae((m(), B(ye(u.value), q(e.buttonProps, {
            class: {
              "top-selector2": !0,
              "top-selector2-multiselect": e.multiselect,
              ["top-selector2-" + e.modificator]: !!e.modificator,
              "top-as-input": !e.buttonProps && v.value !== "inline",
              "top-as-selector": !0,
              ["top-size_" + e.size]: !0,
              "top-disabled": e.disabled,
              "top-forms-focusable": !e.disabled,
              "top-error": e.isError
            },
            icon: e.icon,
            tabindex: "0",
            onKeydown: d,
            onBlur: p[0] || (p[0] = (l) => v.value === "inline" && c(n).resetSearch()),
            placeholder: g.value,
            title: e.title,
            captionType: v.value === "inline" && e.title !== void 0 ? "top" : void 0,
            modelValue: c(n).searchText.value,
            "onUpdate:modelValue": p[1] || (p[1] = (l) => c(n).searchText.value = l)
          }), {
            default: w(() => [
              e.multiselect ? (m(), C("div", Ee, [
                (m(!0), C(N, null, Y(i.value, (l) => (m(), B(we, {
                  id: l.id,
                  name: l.name,
                  onDelete: c(n).deleteItemByItem
                }, null, 8, ["id", "name", "onDelete"]))), 256))
              ])) : M("", !0),
              v.value !== "inline" && !e.multiselect ? (m(), C("span", Ve, P(Array.isArray(i.value) ? "" : i.value.name), 1)) : M("", !0),
              e.multiselect && !i.value.length ? (m(), C("span", Ne, P(g.value), 1)) : M("", !0),
              e.addChanger && !e.buttonProps && !e.multiselect && c(n).itemsForShow.value.length > 1 && !e.disabled ? (m(), C("span", {
                key: 3,
                class: "top-changer top-changer-selector",
                "data-top-popup-disabled": "true",
                onClick: y
              })) : M("", !0)
            ]),
            _: 1
          }, 16, ["class", "icon", "placeholder", "title", "captionType", "modelValue"])), [
            [
              U,
              e.isError,
              void 0,
              { onupdate: !0 }
            ],
            [X, e.openerShortcut]
          ])
        ]),
        contentList: w(() => [
          (m(!0), C(N, null, Y(c(n).itemsForShow.value, (l) => (m(), B(c(ne), q({
            key: l.id ?? void 0,
            class: {
              "top-active": !Array.isArray(i.value) && !e.multiselect && i.value.id === l.id && i.value.name === l.name,
              "top-selector2_item-all": l.id === c(ce),
              "top-selector2_item-new": l.id === c(W)
            },
            closeByClick: !e.multiselect || c(G).state.isMobile
          }, { ref_for: !0 }, l.listItemProps, {
            onClick: (b) => c(n).selectItem(l)
          }), {
            default: w(() => [
              f.$slots.item ? he(f.$slots, "item", {
                key: 0,
                item: l
              }) : (m(), C(N, { key: 1 }, [
                V(P(l.name), 1)
              ], 64))
            ]),
            _: 2
          }, 1040, ["class", "closeByClick", "onClick"]))), 128)),
          !c(n).itemsForShow.value.length && !c(n).genIsShort() ? (m(), B(c(ne), {
            key: 0,
            type: "regular"
          }, {
            default: w(() => [
              !c(o).isLoading.value || c(o).countLoading.value ? (m(), C(N, { key: 0 }, [
                V(P(f.$i18n.Common.No_results), 1)
              ], 64)) : (m(), B(c(Ce), {
                key: 1,
                type: "circles"
              }))
            ]),
            _: 1
          })) : M("", !0),
          c(o).countLoading.value && c(o).isLoading.value && v.value === "inline" ? (m(), B(z, { key: 1 })) : M("", !0)
        ]),
        _: 2
      }, [
        v.value === "popup" ? {
          name: "widget",
          fn: w(() => [
            ue("div", Re, [
              ae(ie(c(ke), {
                title: "Поиск",
                icon: "",
                modelValue: c(n).searchText.value,
                "onUpdate:modelValue": p[2] || (p[2] = (l) => c(n).searchText.value = l),
                isLoading: !!c(o).countLoading.value && c(o).isLoading.value,
                placeholder: g.value
              }, null, 8, ["modelValue", "isLoading", "placeholder"]), [
                [
                  U,
                  i.value,
                  void 0,
                  { onupdate: !0 }
                ]
              ]),
              e.hasCloserBtn && !f.$core.state.isMobile ? (m(), B(E, {
                key: 0,
                class: "closer",
                color: "theme"
              }, {
                default: w(() => [
                  V(P(f.$i18n.Common.Cancel), 1)
                ]),
                _: 1
              })) : M("", !0)
            ])
          ]),
          key: "0"
        } : void 0
      ]), 1032, ["openByFocusInput", "disabled"]);
    };
  }
});
export {
  W as I,
  je as _,
  He as a,
  Ye as b,
  ce as c
};
//# sourceMappingURL=policy.vue_vue_type_style_index_0_lang-BFldQm5e.es.js.map
