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