@topvisor/ui 1.0.26-0 → 1.0.26-10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/.chunks/dialog_selectorRegions-DZR64Wm8.es.js +181 -0
  2. package/.chunks/dialog_selectorRegions-DZR64Wm8.es.js.map +1 -0
  3. package/.chunks/dialog_selectorRegions-D_HXNjOX.amd.js +2 -0
  4. package/.chunks/dialog_selectorRegions-D_HXNjOX.amd.js.map +1 -0
  5. package/assets/extra.css +1 -0
  6. package/components/extra/extra.d.ts +3 -0
  7. package/components/extra/rive/rive.vue.d.ts +11 -0
  8. package/components/extra/rive/types.d.ts +7 -0
  9. package/components/formsExt/selector2/selector2.d.ts +4 -0
  10. package/components/formsExt/selector2/selector2.vue.d.ts +1 -0
  11. package/components/project/selectorRegion/dialog_selectorRegions/dialog_selectorRegions.vue.d.ts +3 -1
  12. package/components/project/selectorRegion/utils/utils.d.ts +3 -1
  13. package/core/app.amd.js +1 -1
  14. package/core/app.amd.js.map +1 -1
  15. package/core/app.js +24 -24
  16. package/core/app.js.map +1 -1
  17. package/core/utils/searchers.d.ts +1 -1
  18. package/extra/extra.amd.js +2 -0
  19. package/extra/extra.amd.js.map +1 -0
  20. package/extra/extra.d.ts +2 -0
  21. package/extra/extra.js +72 -0
  22. package/extra/extra.js.map +1 -0
  23. package/formsExt/formsExt.amd.js +1 -1
  24. package/formsExt/formsExt.amd.js.map +1 -1
  25. package/formsExt/formsExt.js +129 -123
  26. package/formsExt/formsExt.js.map +1 -1
  27. package/package.json +1 -1
  28. package/project/project.amd.js +1 -1
  29. package/project/project.amd.js.map +1 -1
  30. package/project/project.js +199 -196
  31. package/project/project.js.map +1 -1
  32. package/utils/searchers.amd.js.map +1 -1
  33. package/utils/searchers.js.map +1 -1
  34. package/.chunks/dialog_selectorRegions-BOPta9cH.amd.js +0 -2
  35. package/.chunks/dialog_selectorRegions-BOPta9cH.amd.js.map +0 -1
  36. package/.chunks/dialog_selectorRegions-Dy0AlECS.es.js +0 -140
  37. package/.chunks/dialog_selectorRegions-Dy0AlECS.es.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"formsExt.js","sources":["../../src/components/formsExt/editArea/editArea.vue","../../src/components/formsExt/editInput/editInput.vue","../../src/components/formsExt/radioGroup/radioGroup.vue","../../src/components/formsExt/selector2/api.ts","../../src/components/formsExt/selector2/selector2.vue","../../src/components/formsExt/formsExt.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\nimport Button from '@/components/forms/button/button.vue';\nimport type { Emits, Props } from './editArea';\nimport Textarea from '@/components/forms/textarea/textarea.vue';\n\nconst props = withDefaults(defineProps<Props>(), {\n\tdefaultValue: '',\n\tcancelText: 'Cancel',\n\tsubmitText: 'Send',\n\tcloseText: 'Close',\n\texpandable: true,\n});\n\nconst emit = defineEmits<Emits>();\n\nconst localValue = ref(props.defaultValue);\n\nconst isFocused = ref(props.isFocused);\n\nconst isChanged = computed(() => localValue.value !== props.defaultValue);\n\nconst submit = (value: string) => {\n\temit('submit', value);\n\n\tlocalValue.value = props.defaultValue;\n};\n\nconst cancel = () => {\n\tif (props.forceShowCloseBtn && !isChanged.value) {\n\t\temit('close');\n\n\t\treturn;\n\t}\n\n\tlocalValue.value = props.defaultValue;\n};\n\nconst clickOnTitle = () => {\n\tif (props.attachToKeyboard) emit('clickOnTitle');\n};\n</script>\n\n<template>\n\t<div\n\t\t:class=\"{\n\t\t\t'top-editArea': true,\n\t\t\t'top-editArea-attachedToKeyboard': attachToKeyboard,\n\t\t}\"\n\t>\n\t\t<div\n\t\t\tv-if=\"title\"\n\t\t\tclass=\"top-editArea_title\"\n\t\t\t@click=\"clickOnTitle()\"\n\t\t>\n\t\t\t{{ title }}\n\t\t</div>\n\n\t\t<div\n\t\t\t:class=\"{\n\t\t\t\t'top-editArea_form': true,\n\t\t\t\t'top-error': isError,\n\t\t\t\t'top-focus': isFocused,\n\t\t\t}\"\n\t\t>\n\t\t\t<Textarea\n\t\t\t\tv-model=\"localValue\"\n\t\t\t\t:name=\"name\"\n\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t:rows=\"rows\"\n\t\t\t\t:minHeight=\"minHeight\"\n\t\t\t\t:expandable=\"expandable\"\n\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t:readonly=\"readonly\"\n\t\t\t\t:isError=\"isError\"\n\t\t\t\t:hint=\"hint\"\n\t\t\t\tclass=\"top-editArea_element\"\n\t\t\t\t@focus=\"() => isFocused = true\"\n\t\t\t\t@blur=\"() => isFocused = false\"\n\t\t\t\t@keyup.esc=\"cancel\"\n\t\t\t\t@keyup.ctrl.enter=\"submit(localValue)\"\n\t\t\t/>\n\n\t\t\t<div class=\"top-editArea_footer\">\n\t\t\t\t<Button\n\t\t\t\t\tv-if=\"isChanged || forceShowCloseBtn\"\n\t\t\t\t\t:icon=\"$core.state.isMobile ? '': ''\"\n\t\t\t\t\tclass=\"top-editArea_button\"\n\t\t\t\t\tcolor=\"theme\"\n\t\t\t\t\tstyling=\"soft\"\n\t\t\t\t\t@click=\"cancel\"\n\t\t\t\t>\n\t\t\t\t\t<template\n\t\t\t\t\t\t#default\n\t\t\t\t\t\tv-if=\"!$core.state.isMobile\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{{ cancelText }}\n\t\t\t\t\t</template>\n\t\t\t\t</Button>\n\n\t\t\t\t<Button\n\t\t\t\t\tclass=\"top-editArea_button\"\n\t\t\t\t\tv-if=\"isChanged\"\n\t\t\t\t\t:icon=\"$core.state.isMobile ? '': ''\"\n\t\t\t\t\t@click=\"submit(localValue)\"\n\t\t\t\t>\n\t\t\t\t\t<template\n\t\t\t\t\t\t#default\n\t\t\t\t\t\tv-if=\"!$core.state.isMobile\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{{ submitText }}\n\t\t\t\t\t</template>\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</template>\n\n<style>\n.top-editArea {\n\t--top-editArea-bottom: env(keyboard-inset-height, 0px);\n\t--top-editArea-offset-bottom: 0px;\n\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n}\n\n.top-editArea_title {\n\tfont-size: 12px;\n}\n\n.top-editArea_form {\n\tflex-direction: column;\n\toutline: none;\n}\n\n.top-editArea_form:not(.top-error):hover,\n.top-editArea_form:not(.top-error).top-focus {\n\tborder-color: var(--top-forms-border-color-hover);\n}\n\n/* textarea в EditArea */\n.top-textarea {\n\twidth: 100%;\n}\n\n.top-editArea_element.top-textarea_textarea {\n\t--top-forms-border-width: 0px;\n\n\toutline: none;\n\tanimation: none;\n}\n\n/* footer */\n.top-editArea_footer {\n\tpadding: var(--top-forms-padding);\n\tdisplay: flex;\n\tmin-height: 32px;\n\talign-self: flex-end;\n\tjustify-content: flex-end;\n\tgap: var(--top-forms-padding);\n}\n\n/* attachedToKeyboard */\n.top-editArea-attachedToKeyboard {\n\tbackground: var(--top-forms-background-color);\n\tposition: fixed;\n\tbottom: calc(var(--top-editArea-offset-bottom) + var(--top-editArea-bottom));\n\tright: 0;\n\tleft: 0;\n\tz-index: 2;\n\tgap: 0;\n\ttransition: bottom var(--transition-fast);\n}\n\n.top-editArea-attachedToKeyboard .top-editArea_form {\n\tborder-radius: 0;\n\tborder: none;\n\tborder-top: 1px solid var(--top-forms-border-color);\n}\n\n.top-editArea-attachedToKeyboard .top-editArea_title {\n\tcursor: pointer;\n\tborder-top: 1px solid var(--color-line-2-opacity);\n\tpadding: var(--top-forms-padding);\n}\n\n.top-editArea-attachedToKeyboard .top-editArea_footer > [data-top-icon] {\n\tborder-radius: 100%;\n}\n\n@media screen and (max-width: 900px) {\n\t.top-editArea_form{\n\t\tflex-direction: row;\n\t}\n}\n</style>\n","<script setup lang=\"ts\">\nimport { ref, toRef, watch } from 'vue';\nimport type { Emits, Props } from './editInput';\nimport TopInput from '@/components/forms/input/input.vue';\nimport TopButton from '@/components/forms/button/button.vue';\n\nconst props = defineProps<Props>();\n\nconst intermediateValue = ref(props.modelValue);\n\nwatch(toRef(props.modelValue), () => {\n\tintermediateValue.value = props.modelValue;\n});\n\nconst emit = defineEmits<Emits>();\n\nconst submit = () => {\n\temit('update:modelValue', intermediateValue.value);\n};\n</script>\n\n<template>\n\t<div class=\"top-editInput\">\n\t\t<TopInput\n\t\t\t:=\"input\"\n\t\t\t@keydown.esc.capture.stop=\"intermediateValue = modelValue\"\n\t\t\t@keydown.enter.stop=\"submit\"\n\t\t\tv-model=\"intermediateValue\"\n\t\t/>\n\n\t\t<TopButton\n\t\t\tv-if=\"intermediateValue !== modelValue\"\n\t\t\ticon=\"\"\n\t\t\tstyling=\"soft\"\n\t\t\t:=\"button\"\n\t\t\t@click=\"submit\"\n\t\t/>\n\t</div>\n</template>\n\n<style>\n.top-editInput {\n\twidth: 220px;\n\tflex-grow: 1;\n\tdisplay: flex;\n\talign-items: flex-end;\n\tgap: var(--top-gap-1);\n}\n\n.top-editInput .top-input {\n\twidth: unset;\n\tflex-grow: 1;\n}\n</style>\n","<script setup lang=\"ts\">\nimport type { Ref } from '@vue/reactivity';\nimport { ref, watch } from 'vue';\nimport type { Props, Emits } from './radioGroup';\n\nconst model = defineModel<string>({\n\trequired: true,\n});\n\nconst props = withDefaults(defineProps<Props>(), {\n\tsize: 's',\n});\n\nconst emit = defineEmits<Emits>();\n\nconst elRef: Ref<HTMLElement | null> = ref(null);\n\nwatch(model, () => {\n\tif (!props.radiosProps?.some(item => item.value === model.value)) {\n\t\tmodel.value = props.radiosProps?.[0]?.value ?? '';\n\t}\n\n\telRef.value?.querySelector('.radioGroup_item-selected')?.scrollIntoView();\n}, { immediate: true });\n\nconst uid = 'radioGroup-' + Math.random();\n</script>\n\n<template>\n\t<div\n\t\tref=\"elRef\"\n\t\t:class=\"{\n\t\t\t['top-radioGroup']: true,\n\t\t\t['top-scrollBarXHidding']: true,\n\t\t\t['top-size_' + size]: !!size,\n\t\t\t['top-error']: isError,\n\t\t}\"\n\t>\n\t\t<label\n\t\t\tv-for=\"item of radiosProps\"\n\t\t\t:class=\"{\n\t\t\t\t['top-radioGroup_item-selected']: item.value === model,\n\t\t\t\t['top-radioGroup_item']: true,\n\t\t\t\t['top-forms-focusable']: true,\n\t\t\t\t['top-disabled']: item.disabled,\n\t\t\t}\"\n\t\t\t:data-top-icon=\"item.icon\"\n\t\t\t@click=\"model = item.value\"\n\t\t>\n\t\t\t{{ item.title }}\n\n\t\t\t<span\n\t\t\t\tv-if=\"showIndicator\"\n\t\t\t\tclass=\"top-radioGroup_circle\"\n\t\t\t></span>\n\n\t\t\t<!-- Для нативной навигации -->\n\t\t\t<input\n\t\t\t\tv-model=\"model\"\n\t\t\t\t:name=\"uid\"\n\t\t\t\ttype=\"radio\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t['top-unvisible']: true,\n\t\t\t\t}\"\n\t\t\t\t:value=\"item.value\"\n\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t/>\n\t\t</label>\n\t</div>\n</template>\n\n<style>\n@import \"./styles/top-scrollBar.css\";\n\n.top-radioGroup {\n\tuser-select: none;\n\tbox-sizing: border-box;\n\tborder-radius: 8px;\n\tbackground-color: var(--color-layout-middle);\n\theight: var(--top-forms-base-height);\n\tpadding: 2px;\n\tgap: 2px;\n\tdisplay: flex;\n\talign-items: flex-start;\n}\n\n.top-radioGroup_item {\n\tcolor: var(--color-text-2);\n\tcursor: pointer;\n\tbox-sizing: border-box;\n\tborder-radius: 6px;\n\theight: calc(var(--top-forms-base-height) - 4px);\n\tpadding: 0 16px;\n\tfont-weight: 400;\n\twhite-space: nowrap;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tflex-grow: 1;\n\tgap: 4px;\n}\n\n.top-radioGroup_item:hover {\n\tbackground-color: var(--color-layout-front-1);\n\tbox-shadow: 0px 4px 32px 0px rgba(4, 9, 84, 0.10), 0px 0px 4px 0px rgba(4, 9, 84, 0.08);\n}\n\n/* selected */\n.top-radioGroup_item-selected {\n\tcolor: var(--color-text-1);\n\tpointer-events: none;\n\tbackground-color: var(--color-bg-lightning-1);\n\tbox-shadow: 0px 4px 32px 0px rgba(4, 9, 84, 0.10), 0px 0px 4px 0px rgba(4, 9, 84, 0.08);\n}\n\n/* circle */\n.top-radioGroup_circle {\n\tcontent: \"\";\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--color-line-3-opacity);\n\tborder-radius: 50%;\n\tpadding: 3px;\n\tmargin-left: auto;\n\twidth: calc(var(--top-forms-option-height) - 3px * 2);\n\theight: calc(var(--top-forms-option-height) - 3px * 2);\n}\n\n.top-radioGroup_item:hover .top-radioGroup_circle:before {\n\tborder-color: var(--color-line-primary-1);\n}\n\n/* circle selected */\n.top-radioGroup_item-selected .top-radioGroup_circle {\n\tborder-color: var(--color-line-primary-1);\n\tborder-width: 5px;\n}\n\n.top-radioGroup_item-selected:hover .top-radioGroup_circle {\n\tborder-color: var(--color-line-primary-1);\n}\n\n/* top-error */\n.top-radioGroup.top-error .top-radioGroup_item:not(.top-disabled) .top-radioGroup_circle {\n\tborder-color: var(--color-line-negative-1);\n}\n</style>\n","import type { Ref } from 'vue';\nimport { ref } from 'vue';\nimport { debounce } from '@/core/utils/lodash';\nimport type { Item, Props } from './selector2';\n\nexport const useAPI = (apiRequest: Props['apiRequest'], minLength: number, useCache: Props['useCache']) => {\n\t/**\n\t * Список, полученный через API\n\t */\n\tconst items: Ref<Array<Item>> = ref([]);\n\n\t/**\n\t * Флаг - идет загрузка\n\t */\n\tconst isLoading = ref(false);\n\n\tlet _searchText = '';\n\tlet _nextOffset: number | undefined;\n\n\tif (apiRequest && !apiRequest.params.limit) {\n\t\tapiRequest.params.limit = 100;\n\t}\n\n\t/**\n\t * Выполнить обращение к API\n\t *\n\t * При ошибке вернет undefined\n\t */\n\tconst callAPIRequest = async (): Promise<{ nextOffset?: number, result: Array<Item> } | undefined> => {\n\t\tif (!apiRequest) return;\n\n\t\tlet res;\n\t\tlet cacheKey;\n\n\t\tif (useCache) {\n\t\t\t// кэш для полученных ответов через apiRequest\n\t\t\t// общий для всех компонентов, использующих apiRequest\n\t\t\tapiRequest.cache ??= new Map();\n\n\t\t\tcacheKey = JSON.stringify(apiRequest.params);\n\t\t\tres = apiRequest.cache.get(cacheKey);\n\n\t\t\tif (res) {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t}\n\n\t\tisLoading.value = true;\n\t\tres = await apiRequest.call();\n\t\tisLoading.value = false;\n\n\t\tif (res.errors) return;\n\n\t\tif (!Array.isArray(res.result)) {\n\t\t\tconsole.warn(`В result ожидался массив`);\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst indexWithError = (res.result as Array<Item | any>).findIndex(item => item.id === undefined || item.name === undefined);\n\t\tif (indexWithError !== -1) {\n\t\t\tconsole.warn(`В result[${indexWithError}] нет id или name`);\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (useCache) {\n\t\t\tapiRequest.cache.set(cacheKey as string, res);\n\t\t}\n\n\t\treturn res;\n\t};\n\n\t/**\n\t * Загрузить items\n\t */\n\tconst load = async () => {\n\t\tif (!apiRequest) return;\n\n\t\tapiRequest.params.offset = 0;\n\t\tapiRequest.params.search = _searchText;\n\n\t\tconst res = await callAPIRequest();\n\t\tif (!res) return;\n\n\t\t_nextOffset = res.nextOffset;\n\n\t\titems.value = res.result;\n\t};\n\n\t/**\n\t * Загрузить следующую страницу items\n\t */\n\tconst loadAppend = async () => {\n\t\tif (!apiRequest) return;\n\n\t\t// данных о следующих страницах не обнаружено\n\t\tif (!_nextOffset) return;\n\n\t\t// дозагружать нельзя, если не завершена предыдущшая загрузка\n\t\tif (isLoading.value) return;\n\n\t\tapiRequest.params.offset = _nextOffset;\n\t\tapiRequest.params.search = _searchText;\n\n\t\tconst res = await callAPIRequest();\n\t\tif (!res) return;\n\n\t\t_nextOffset = res.nextOffset;\n\n\t\titems.value = items.value.concat(res.result);\n\t};\n\n\tconst loadDebounce = debounce(() => load(), 200);\n\n\t/**\n\t * Выполнить поиск по указанному тексту\n\t *\n\t * Если длина текста меньше minLength, поиск не будет проивзеден\n\t *\n\t * Если текст не изменился, поиск не будет проивзеден\n\t * @param searchText - текст поиска\n\t * @param useDebounce - отложенное выполнение поиска\n\t */\n\tconst setSearchTextAndLoad = (searchText: string, useDebounce = true) => {\n\t\tif (!apiRequest) return;\n\n\t\tif (searchText.length < minLength) return;\n\n\t\t// условия поиска не поменялись, данные загружены\n\t\tif (searchText === _searchText && items.value.length) return;\n\n\t\t_searchText = searchText;\n\n\t\tif (useDebounce) {\n\t\t\tloadDebounce();\n\t\t} else {\n\t\t\tvoid load();\n\t\t}\n\t};\n\n\treturn {\n\t\titems,\n\t\tisLoading,\n\t\tloadAppend,\n\t\tsetSearchTextAndLoad,\n\t};\n};\n","<script setup lang=\"ts\">\nimport type { ComputedRef, ModelRef, ComponentInstance } from 'vue';\nimport { computed, ref, watch } from 'vue';\nimport Core from '@/core/core/core';\nimport { invertKeyboardLayout } from '@/core/utils/keyboard';\nimport { useI18n } from '@/core/plugins/i18n';\nimport { TopPopup, TopPopupListItem, TopPopupWidgetInput } from '@/components/popup/popup';\nimport type PopupClass from '@/components/popup/lib/popup';\nimport type { Item, Props, Slots } from './selector2';\nimport { useAPI } from './api';\nimport Selector2ItemMulti from './itemMulti.vue';\n\nconst props = withDefaults(defineProps<Props>(), {\n\titems: () => [] as Array<Item>,\n\tsize: 's',\n\tminLength: 0,\n\tshowSelectedInInput: true,\n});\n\nconst model = defineModel<Props['modelValue']>() as ModelRef<Props['modelValue']>;\n\ndefineSlots<Slots>();\n\n/**\n * Текст поиска по результатам\n */\nconst searchText = ref('');\n\n/**\n * Сброс поиска\n */\nconst resetSearch = () => {\n\tsearchText.value = '';\n\tAPI.items.value = [];\n};\n\n\nconst itemAll = {\n\tid: 0,\n\tname: useI18n().Common.All!,\n};\n\n/**\n * Экземпляр компонента Popup\n */\nconst popupRef = ref<ComponentInstance<typeof TopPopup> | null>(null);\n\n/**\n * Основной элемент селектора\n */\nconst elRef = ref<HTMLElement | null>(null);\n\n/**\n * Получить доступ к объекту popup\n */\nconst getPopup = (): PopupClass | undefined => {\n\treturn popupRef.value?.popup;\n};\n\n// для storybook\nif ((window as any).__STORYBOOK_PREVIEW__ && !props.modelValue) {\n\twatch(\n\t\t() => props.multiselect,\n\t\t() => {\n\t\t\tmodel.value = props.multiselect ? [] : { id: null, name: '' };\n\t\t},\n\t\t{ immediate: true },\n\t);\n}\n\nconst API = useAPI(props.apiRequest, props.minLength, props.useCache);\n\n/**\n * Варианты выбора: props.items + \"Выбрать все\"\n */\nconst localItems: ComputedRef<Array<Item>> = computed(() => {\n\tconst items: Array<Item> = [];\n\n\tif (!props.multiselect && props.appendAllValue) {\n\t\titems.push(itemAll);\n\t}\n\n\tprops.items.forEach(item => items.push({ ...item }));\n\n\treturn items;\n});\n\n/**\n * Проверить, что элемент выбран\n */\nconst isSelected = (item: Item, checkNameForNullId = true) => {\n\tif (checkNameForNullId && item.id === null) {\n\t\tif (Array.isArray(model.value)) {\n\t\t\treturn model.value.some(itemSelected => itemSelected.id === item.id && itemSelected.name === item.name);\n\t\t} else {\n\t\t\treturn item.name === model.value.name;\n\t\t}\n\t}\n\n\tif (Array.isArray(model.value)) {\n\t\treturn model.value.some(itemSelected => itemSelected.id === item.id);\n\t} else {\n\t\treturn item.id === model.value.id;\n\t}\n};\n\n/**\n * Варианты выбора, которые выводятся\n */\nconst itemsForShow = computed(() => {\n\tconst searchString = searchText.value.toLowerCase();\n\tconst searchStringInvertKeyboard = invertKeyboardLayout(searchString);\n\n\tlet items: typeof localItems.value = [];\n\n\tlocalItems.value.forEach((item) => {\n\t\tconst itemName = item.name.toLowerCase();\n\n\t\tif (\n\t\t\titem.id === Number(searchString) ||\n\t\t\titemName.includes(searchString) ||\n\t\t\titemName.includes(searchStringInvertKeyboard)\n\t\t) {\n\t\t\tif (itemName === searchString || itemName === searchStringInvertKeyboard) {\n\t\t\t\titems.unshift(item);\n\t\t\t} else {\n\t\t\t\titems.push(item);\n\t\t\t}\n\t\t}\n\t});\n\n\titems.push(...API.items.value);\n\n\tif (\n\t\tprops.appendSearchToResult &&\n\t\t!!searchText.value &&\n\t\t(!items.length || items[0].name.toLowerCase() !== searchString)\n\t) {\n\t\titems.push({\n\t\t\tid: null,\n\t\t\tname: searchText.value,\n\t\t});\n\t}\n\n\tif (props.multiselect) {\n\t\titems = items.filter(item => !isSelected(item));\n\t}\n\n\treturn items;\n});\n\n/**\n * Флаг - идет загрузка\n *\n * Скрывает вывод заглушки \"Нет результатов\" - для загрузки данных через API (multiselect = true) - (см. selectItem)\n */\nconst isLoading = ref(API.isLoading.value);\n\nwatch(API.isLoading, () => {\n\tisLoading.value = API.isLoading.value;\n});\n\n/**\n * Выбрать значение\n *\n * Управляет закрытием окна\n */\nconst selectItem = async (item: Item) => {\n\tif (props.multiselect) {\n\t\tif (!Array.isArray(model.value)) return;\n\n\t\tif (isSelected(item)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (props.apiRequest && searchText.value) {\n\t\t\tisLoading.value = true;\n\t\t}\n\n\t\tconst newModel = [...model.value];\n\t\tnewModel.push({ ...item });\n\t\tmodel.value = newModel;\n\n\t\tif (Core.state.isMobile) {\n\t\t\tgetPopup()?.close();\n\t\t} else {\n\t\t\tsetTimeout(() => {\n\t\t\t\tgetPopup()?.recalcPosition();\n\t\t\t\tgetPopup()?.elPopupWidget?.querySelector('input')?.focus();\n\n\t\t\t\tif (searchText.value) resetSearch();\n\t\t\t});\n\t\t}\n\t} else {\n\t\tif (JSON.stringify(item) !== JSON.stringify(model.value)) {\n\t\t\tmodel.value = { ...item };\n\t\t}\n\n\t\tgetPopup()?.close();\n\t}\n};\n\n/**\n * Выбрать следующее значение\n */\nconst selectNextItem = () => {\n\tif (!Array.isArray(model.value)) {\n\t\tconst currentIndex = localItems.value.findIndex(item => item.id === (model.value as Item).id);\n\t\tconst nextIndex = (currentIndex + 1) % localItems.value.length;\n\t\tmodel.value = { ...localItems.value[nextIndex] };\n\t}\n};\n\n/**\n * Удалить выбранное значение по id\n * @param id\n */\nconst deleteItemById = async (id: Item['id']) => {\n\tif (Array.isArray(model.value)) {\n\t\tmodel.value = model.value.filter(item => item.id !== id);\n\n\t\tsetTimeout(() => {\n\t\t\tgetPopup()?.recalcPosition();\n\t\t});\n\t}\n};\n\nconst isOpened = ref(false); // флаг попап открыт\n\nif (props.apiRequest) {\n\twatch(isOpened, () => {\n\t\tif (isOpened.value) {\n\t\t\t// при открытии сразу выполнить поиск\n\t\t\tAPI.setSearchTextAndLoad(searchText.value, false);\n\t\t}\n\t});\n\n\t// отложенный поиск при вводе текста\n\twatch(searchText, () => API.setSearchTextAndLoad(searchText.value));\n}\n\nconst onScrollContentList = (e: Event) => {\n\tconst el = e.target as HTMLElement;\n\n\tif (el.scrollTop / (el.scrollHeight - el.offsetHeight) > 0.8) {\n\t\tAPI.loadAppend();\n\t}\n};\n\nconst onClose = () => {\n\tisOpened.value = false;\n\n\telRef.value?.focus();\n\n\tif (searchText.value) resetSearch();\n};\n</script>\n\n<template>\n\t<TopPopup\n\t\tref=\"popupRef\"\n\t\t@open=\"isOpened = true\"\n\t\t@close=\"onClose()\"\n\t\t@scrollContentList=\"apiRequest ? onScrollContentList($event) : undefined\"\n\t\t:notch=\"false\"\n\t\t:transitionDuration=\"0\"\n\t>\n\t\t<template #opener>\n\t\t\t<div\n\t\t\t\tref=\"elRef\"\n\t\t\t\tv-top-focus.onupdate=\"isError\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t'top-selector2' : true,\n\t\t\t\t\t'top-selector2-multiselect': multiselect,\n\t\t\t\t\t['top-size_' + size]: true,\n\t\t\t\t\t['top-disabled']: disabled,\n\t\t\t\t\t['top-forms-focusable']: !disabled,\n\t\t\t\t\t['top-error']: isError,\n\t\t\t\t}\"\n\t\t\t\t@keydown.up.down.enter.space.stop.prevent=\"($event.currentTarget as HTMLElement).click()\"\n\t\t\t\t@keydown.delete=\"model = []\"\n\t\t\t\ttabindex=\"0\"\n\t\t\t>\n\t\t\t\t<template v-if=\"multiselect\">\n\t\t\t\t\t<div class=\"top-selector2_activeItems\">\n\t\t\t\t\t\t<Selector2ItemMulti\n\t\t\t\t\t\t\tv-for=\"item of model as Array<Item>\"\n\t\t\t\t\t\t\t:id=\"item.id\"\n\t\t\t\t\t\t\t:name=\"item.name\"\n\t\t\t\t\t\t\t@delete=\"deleteItemById\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</template>\n\n\t\t\t\t<span v-if=\"!multiselect\" class=\"top-selector2_activeName top-ellipsis\">\n\t\t\t\t\t{{ !Array.isArray(model) ? model.name : '' }}\n\t\t\t\t</span>\n\n\t\t\t\t<span\n\t\t\t\t\tv-if=\"addChanger && !multiselect && localItems.length > 1 && !disabled\"\n\t\t\t\t\tclass=\"top-changer top-changer-selector\"\n\t\t\t\t\t@click.stop=\"selectNextItem\"\n\t\t\t\t></span>\n\t\t\t</div>\n\t\t</template>\n\n\t\t<template #widget>\n\t\t\t<TopPopupWidgetInput\n\t\t\t\ttitle=\"Поиск\"\n\t\t\t\ticon=\"\"\n\t\t\t\tv-model=\"searchText\"\n\t\t\t\t:isLoading=\"isLoading\"\n\t\t\t\t:placeholder=\"!Array.isArray(model) && !multiselect && showSelectedInInput ? model.name : placeholder\"\n\t\t\t/>\n\t\t</template>\n\n\t\t<template #contentList>\n\t\t\t<TopPopupListItem\n\t\t\t\tv-for=\"item of itemsForShow\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t'top-active': !Array.isArray(model) && !multiselect && model.name === item.name\n\t\t\t\t}\"\n\t\t\t\t:key=\"item.id ?? undefined\"\n\t\t\t\t@click.stop=\"selectItem(item)\"\n\t\t\t>\n\t\t\t\t<slot\n\t\t\t\t\tv-if=\"$slots.item\"\n\t\t\t\t\tname=\"item\"\n\t\t\t\t\t:item=\"item\"\n\t\t\t\t></slot>\n\n\t\t\t\t<template\n\t\t\t\t\tv-else\n\t\t\t\t>\n\t\t\t\t\t{{ item.name }}\n\t\t\t\t</template>\n\t\t\t</TopPopupListItem>\n\n\t\t\t<TopPopupListItem\n\t\t\t\tv-if=\"!isLoading && !itemsForShow.length\"\n\t\t\t\ttype=\"regular\"\n\t\t\t>\n\t\t\t\t{{ $i18n.Common.No_results }}\n\t\t\t</TopPopupListItem>\n\t\t</template>\n\t</TopPopup>\n</template>\n\n<style>\n.top-selector2 {\n\twidth: 180px;\n\tmin-height: var(--top-forms-base-height);\n\tbox-sizing: border-box;\n\tposition: relative;\n\tdisplay: flex;\n\toverflow: hidden;\n\tpadding: var(--top-padding-1) var(--top-forms-padding);\n\tcolor: var(--top-forms-placeholder-color);\n\n\tborder-radius: var(--top-radius-2);\n\tborder: 1px solid var(--top-forms-border-color);\n\tbackground: var(--top-forms-background-color);\n}\n\n.top-selector2-multiselect {\n\twidth: unset;\n\tmin-width: 180px;\n\tpadding: var(--top-padding-1);\n}\n\n.top-selector2.top-active {\n\t--top-forms-border-color: var(--top-forms-border-color-hover);\n}\n\n.top-selector2_activeItems {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: var(--top-padding-1);\n\tmax-width: 100%;\n}\n\n.top-selector2_activeName {\n\twhite-space: nowrap;\n}\n\n.top-changer-selector {\n\ttransform: translateX(-16px);\n}\n</style>\n","import type { ComponentCustomProps } from 'vue';\n\nimport EditArea from './editArea/editArea.vue';\nimport EditInput from './editInput/editInput.vue';\nimport RadioGroup from './radioGroup/radioGroup.vue';\nimport Selector2 from './selector2/selector2.vue';\nimport Menu from './menu/menu.vue';\nimport Info from './info/info.vue';\n\nexport const TopEditArea = EditArea as typeof EditArea & ComponentCustomProps;\nexport const TopEditInput = EditInput as typeof EditInput & ComponentCustomProps;\nexport const TopRadioGroup = RadioGroup as typeof RadioGroup & ComponentCustomProps;\nexport const TopSelector2 = Selector2 as typeof Selector2 & ComponentCustomProps;\nexport const TopMenu = Menu as typeof Menu & ComponentCustomProps;\nexport const TopInfo = Info as typeof Info & ComponentCustomProps;\n"],"names":["props","__props","emit","__emit","localValue","ref","isFocused","isChanged","computed","submit","value","cancel","clickOnTitle","intermediateValue","watch","toRef","model","useModel","elRef","_a","item","_c","_b","_e","_d","uid","useAPI","apiRequest","minLength","useCache","items","isLoading","_searchText","_nextOffset","callAPIRequest","res","cacheKey","indexWithError","load","loadAppend","loadDebounce","debounce","searchText","useDebounce","resetSearch","API","itemAll","useI18n","popupRef","getPopup","localItems","isSelected","checkNameForNullId","itemSelected","itemsForShow","searchString","searchStringInvertKeyboard","invertKeyboardLayout","itemName","selectItem","newModel","Core","selectNextItem","nextIndex","deleteItemById","id","isOpened","onScrollContentList","e","el","onClose","TopEditArea","_sfc_main$5","TopEditInput","_sfc_main$4","TopRadioGroup","_sfc_main$3","TopSelector2","_sfc_main$1","TopMenu","_sfc_main$9","TopInfo","_sfc_main"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,UAAAA,IAAAC,GAQAC,IAAAC,GAEAC,IAAAC,EAAAL,EAAA,YAAA,GAEAM,IAAAD,EAAAL,EAAA,SAAA,GAEAO,IAAAC,EAAA,MAAAJ,EAAA,UAAAJ,EAAA,YAAA,GAEAS,IAAA,CAAAC,MAAA;AACC,MAAAR,EAAA,UAAAQ,CAAA,GAEAN,EAAA,QAAAJ,EAAA;AAAA,IAAyB,GAG1BW,IAAA,MAAA;AACC,UAAAX,EAAA,qBAAA,CAAAO,EAAA,OAAA;AACC,QAAAL,EAAA,OAAA;AAEA;AAAA,MAAA;AAGD,MAAAE,EAAA,QAAAJ,EAAA;AAAA,IAAyB,GAG1BY,IAAA,MAAA;AACC,MAAAZ,EAAA,oBAAAE,EAAA,cAAA;AAAA,IAA+C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjChD,UAAAF,IAAAC,GAEAY,IAAAR,EAAAL,EAAA,UAAA;AAEA,IAAAc,EAAAC,GAAAf,EAAA,UAAA,GAAA,MAAA;AAC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A/C,IAAAD,EAAA,UAAA,QAAAC,EAAA,SAEAuB,EAAA,SAAAE,EAAA;AAAA,IAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ICrP5B2B,KAAAC,IACAC,KAAAC,IACAC,KAAAC,IACAC,KAAAC,IACAC,KAAAC,IACAC,KAAAC;"}
1
+ {"version":3,"file":"formsExt.js","sources":["../../src/components/formsExt/editArea/editArea.vue","../../src/components/formsExt/editInput/editInput.vue","../../src/components/formsExt/radioGroup/radioGroup.vue","../../src/components/formsExt/selector2/api.ts","../../src/components/formsExt/selector2/selector2.vue","../../src/components/formsExt/formsExt.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\nimport Button from '@/components/forms/button/button.vue';\nimport type { Emits, Props } from './editArea';\nimport Textarea from '@/components/forms/textarea/textarea.vue';\n\nconst props = withDefaults(defineProps<Props>(), {\n\tdefaultValue: '',\n\tcancelText: 'Cancel',\n\tsubmitText: 'Send',\n\tcloseText: 'Close',\n\texpandable: true,\n});\n\nconst emit = defineEmits<Emits>();\n\nconst localValue = ref(props.defaultValue);\n\nconst isFocused = ref(props.isFocused);\n\nconst isChanged = computed(() => localValue.value !== props.defaultValue);\n\nconst submit = (value: string) => {\n\temit('submit', value);\n\n\tlocalValue.value = props.defaultValue;\n};\n\nconst cancel = () => {\n\tif (props.forceShowCloseBtn && !isChanged.value) {\n\t\temit('close');\n\n\t\treturn;\n\t}\n\n\tlocalValue.value = props.defaultValue;\n};\n\nconst clickOnTitle = () => {\n\tif (props.attachToKeyboard) emit('clickOnTitle');\n};\n</script>\n\n<template>\n\t<div\n\t\t:class=\"{\n\t\t\t'top-editArea': true,\n\t\t\t'top-editArea-attachedToKeyboard': attachToKeyboard,\n\t\t}\"\n\t>\n\t\t<div\n\t\t\tv-if=\"title\"\n\t\t\tclass=\"top-editArea_title\"\n\t\t\t@click=\"clickOnTitle()\"\n\t\t>\n\t\t\t{{ title }}\n\t\t</div>\n\n\t\t<div\n\t\t\t:class=\"{\n\t\t\t\t'top-editArea_form': true,\n\t\t\t\t'top-error': isError,\n\t\t\t\t'top-focus': isFocused,\n\t\t\t}\"\n\t\t>\n\t\t\t<Textarea\n\t\t\t\tv-model=\"localValue\"\n\t\t\t\t:name=\"name\"\n\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t:rows=\"rows\"\n\t\t\t\t:minHeight=\"minHeight\"\n\t\t\t\t:expandable=\"expandable\"\n\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t:readonly=\"readonly\"\n\t\t\t\t:isError=\"isError\"\n\t\t\t\t:hint=\"hint\"\n\t\t\t\tclass=\"top-editArea_element\"\n\t\t\t\t@focus=\"() => isFocused = true\"\n\t\t\t\t@blur=\"() => isFocused = false\"\n\t\t\t\t@keyup.esc=\"cancel\"\n\t\t\t\t@keyup.ctrl.enter=\"submit(localValue)\"\n\t\t\t/>\n\n\t\t\t<div class=\"top-editArea_footer\">\n\t\t\t\t<Button\n\t\t\t\t\tv-if=\"isChanged || forceShowCloseBtn\"\n\t\t\t\t\t:icon=\"$core.state.isMobile ? '': ''\"\n\t\t\t\t\tclass=\"top-editArea_button\"\n\t\t\t\t\tcolor=\"theme\"\n\t\t\t\t\tstyling=\"soft\"\n\t\t\t\t\t@click=\"cancel\"\n\t\t\t\t>\n\t\t\t\t\t<template\n\t\t\t\t\t\t#default\n\t\t\t\t\t\tv-if=\"!$core.state.isMobile\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{{ cancelText }}\n\t\t\t\t\t</template>\n\t\t\t\t</Button>\n\n\t\t\t\t<Button\n\t\t\t\t\tclass=\"top-editArea_button\"\n\t\t\t\t\tv-if=\"isChanged\"\n\t\t\t\t\t:icon=\"$core.state.isMobile ? '': ''\"\n\t\t\t\t\t@click=\"submit(localValue)\"\n\t\t\t\t>\n\t\t\t\t\t<template\n\t\t\t\t\t\t#default\n\t\t\t\t\t\tv-if=\"!$core.state.isMobile\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{{ submitText }}\n\t\t\t\t\t</template>\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</template>\n\n<style>\n.top-editArea {\n\t--top-editArea-bottom: env(keyboard-inset-height, 0px);\n\t--top-editArea-offset-bottom: 0px;\n\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n}\n\n.top-editArea_title {\n\tfont-size: 12px;\n}\n\n.top-editArea_form {\n\tflex-direction: column;\n\toutline: none;\n}\n\n.top-editArea_form:not(.top-error):hover,\n.top-editArea_form:not(.top-error).top-focus {\n\tborder-color: var(--top-forms-border-color-hover);\n}\n\n/* textarea в EditArea */\n.top-textarea {\n\twidth: 100%;\n}\n\n.top-editArea_element.top-textarea_textarea {\n\t--top-forms-border-width: 0px;\n\n\toutline: none;\n\tanimation: none;\n}\n\n/* footer */\n.top-editArea_footer {\n\tpadding: var(--top-forms-padding);\n\tdisplay: flex;\n\tmin-height: 32px;\n\talign-self: flex-end;\n\tjustify-content: flex-end;\n\tgap: var(--top-forms-padding);\n}\n\n/* attachedToKeyboard */\n.top-editArea-attachedToKeyboard {\n\tbackground: var(--top-forms-background-color);\n\tposition: fixed;\n\tbottom: calc(var(--top-editArea-offset-bottom) + var(--top-editArea-bottom));\n\tright: 0;\n\tleft: 0;\n\tz-index: 2;\n\tgap: 0;\n\ttransition: bottom var(--transition-fast);\n}\n\n.top-editArea-attachedToKeyboard .top-editArea_form {\n\tborder-radius: 0;\n\tborder: none;\n\tborder-top: 1px solid var(--top-forms-border-color);\n}\n\n.top-editArea-attachedToKeyboard .top-editArea_title {\n\tcursor: pointer;\n\tborder-top: 1px solid var(--color-line-2-opacity);\n\tpadding: var(--top-forms-padding);\n}\n\n.top-editArea-attachedToKeyboard .top-editArea_footer > [data-top-icon] {\n\tborder-radius: 100%;\n}\n\n@media screen and (max-width: 900px) {\n\t.top-editArea_form{\n\t\tflex-direction: row;\n\t}\n}\n</style>\n","<script setup lang=\"ts\">\nimport { ref, toRef, watch } from 'vue';\nimport type { Emits, Props } from './editInput';\nimport TopInput from '@/components/forms/input/input.vue';\nimport TopButton from '@/components/forms/button/button.vue';\n\nconst props = defineProps<Props>();\n\nconst intermediateValue = ref(props.modelValue);\n\nwatch(toRef(props.modelValue), () => {\n\tintermediateValue.value = props.modelValue;\n});\n\nconst emit = defineEmits<Emits>();\n\nconst submit = () => {\n\temit('update:modelValue', intermediateValue.value);\n};\n</script>\n\n<template>\n\t<div class=\"top-editInput\">\n\t\t<TopInput\n\t\t\t:=\"input\"\n\t\t\t@keydown.esc.capture.stop=\"intermediateValue = modelValue\"\n\t\t\t@keydown.enter.stop=\"submit\"\n\t\t\tv-model=\"intermediateValue\"\n\t\t/>\n\n\t\t<TopButton\n\t\t\tv-if=\"intermediateValue !== modelValue\"\n\t\t\ticon=\"\"\n\t\t\tstyling=\"soft\"\n\t\t\t:=\"button\"\n\t\t\t@click=\"submit\"\n\t\t/>\n\t</div>\n</template>\n\n<style>\n.top-editInput {\n\twidth: 220px;\n\tflex-grow: 1;\n\tdisplay: flex;\n\talign-items: flex-end;\n\tgap: var(--top-gap-1);\n}\n\n.top-editInput .top-input {\n\twidth: unset;\n\tflex-grow: 1;\n}\n</style>\n","<script setup lang=\"ts\">\nimport type { Ref } from '@vue/reactivity';\nimport { ref, watch } from 'vue';\nimport type { Props, Emits } from './radioGroup';\n\nconst model = defineModel<string>({\n\trequired: true,\n});\n\nconst props = withDefaults(defineProps<Props>(), {\n\tsize: 's',\n});\n\nconst emit = defineEmits<Emits>();\n\nconst elRef: Ref<HTMLElement | null> = ref(null);\n\nwatch(model, () => {\n\tif (!props.radiosProps?.some(item => item.value === model.value)) {\n\t\tmodel.value = props.radiosProps?.[0]?.value ?? '';\n\t}\n\n\telRef.value?.querySelector('.radioGroup_item-selected')?.scrollIntoView();\n}, { immediate: true });\n\nconst uid = 'radioGroup-' + Math.random();\n</script>\n\n<template>\n\t<div\n\t\tref=\"elRef\"\n\t\t:class=\"{\n\t\t\t['top-radioGroup']: true,\n\t\t\t['top-scrollBarXHidding']: true,\n\t\t\t['top-size_' + size]: !!size,\n\t\t\t['top-error']: isError,\n\t\t}\"\n\t>\n\t\t<label\n\t\t\tv-for=\"item of radiosProps\"\n\t\t\t:class=\"{\n\t\t\t\t['top-radioGroup_item-selected']: item.value === model,\n\t\t\t\t['top-radioGroup_item']: true,\n\t\t\t\t['top-forms-focusable']: true,\n\t\t\t\t['top-disabled']: item.disabled,\n\t\t\t}\"\n\t\t\t:data-top-icon=\"item.icon\"\n\t\t\t@click=\"model = item.value\"\n\t\t>\n\t\t\t{{ item.title }}\n\n\t\t\t<span\n\t\t\t\tv-if=\"showIndicator\"\n\t\t\t\tclass=\"top-radioGroup_circle\"\n\t\t\t></span>\n\n\t\t\t<!-- Для нативной навигации -->\n\t\t\t<input\n\t\t\t\tv-model=\"model\"\n\t\t\t\t:name=\"uid\"\n\t\t\t\ttype=\"radio\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t['top-unvisible']: true,\n\t\t\t\t}\"\n\t\t\t\t:value=\"item.value\"\n\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t/>\n\t\t</label>\n\t</div>\n</template>\n\n<style>\n@import \"./styles/top-scrollBar.css\";\n\n.top-radioGroup {\n\tuser-select: none;\n\tbox-sizing: border-box;\n\tborder-radius: 8px;\n\tbackground-color: var(--color-layout-middle);\n\theight: var(--top-forms-base-height);\n\tpadding: 2px;\n\tgap: 2px;\n\tdisplay: flex;\n\talign-items: flex-start;\n}\n\n.top-radioGroup_item {\n\tcolor: var(--color-text-2);\n\tcursor: pointer;\n\tbox-sizing: border-box;\n\tborder-radius: 6px;\n\theight: calc(var(--top-forms-base-height) - 4px);\n\tpadding: 0 16px;\n\tfont-weight: 400;\n\twhite-space: nowrap;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tflex-grow: 1;\n\tgap: 4px;\n}\n\n.top-radioGroup_item:hover {\n\tbackground-color: var(--color-layout-front-1);\n\tbox-shadow: 0px 4px 32px 0px rgba(4, 9, 84, 0.10), 0px 0px 4px 0px rgba(4, 9, 84, 0.08);\n}\n\n/* selected */\n.top-radioGroup_item-selected {\n\tcolor: var(--color-text-1);\n\tpointer-events: none;\n\tbackground-color: var(--color-bg-lightning-1);\n\tbox-shadow: 0px 4px 32px 0px rgba(4, 9, 84, 0.10), 0px 0px 4px 0px rgba(4, 9, 84, 0.08);\n}\n\n/* circle */\n.top-radioGroup_circle {\n\tcontent: \"\";\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--color-line-3-opacity);\n\tborder-radius: 50%;\n\tpadding: 3px;\n\tmargin-left: auto;\n\twidth: calc(var(--top-forms-option-height) - 3px * 2);\n\theight: calc(var(--top-forms-option-height) - 3px * 2);\n}\n\n.top-radioGroup_item:hover .top-radioGroup_circle:before {\n\tborder-color: var(--color-line-primary-1);\n}\n\n/* circle selected */\n.top-radioGroup_item-selected .top-radioGroup_circle {\n\tborder-color: var(--color-line-primary-1);\n\tborder-width: 5px;\n}\n\n.top-radioGroup_item-selected:hover .top-radioGroup_circle {\n\tborder-color: var(--color-line-primary-1);\n}\n\n/* top-error */\n.top-radioGroup.top-error .top-radioGroup_item:not(.top-disabled) .top-radioGroup_circle {\n\tborder-color: var(--color-line-negative-1);\n}\n</style>\n","import type { Ref } from 'vue';\nimport { ref } from 'vue';\nimport { debounce } from '@/core/utils/lodash';\nimport type { Item, Props } from './selector2';\n\nexport const useAPI = (apiRequest: Props['apiRequest'], minLength: number, useCache: Props['useCache']) => {\n\t/**\n\t * Список, полученный через API\n\t */\n\tconst items: Ref<Array<Item>> = ref([]);\n\n\t/**\n\t * Флаг - идет загрузка\n\t */\n\tconst isLoading = ref(false);\n\n\tlet _searchText = '';\n\tlet _nextOffset: number | undefined;\n\n\tif (apiRequest && !apiRequest.params.limit) {\n\t\tapiRequest.params.limit = 100;\n\t}\n\n\t/**\n\t * Выполнить обращение к API\n\t *\n\t * При ошибке вернет undefined\n\t */\n\tconst callAPIRequest = async (): Promise<{ nextOffset?: number, result: Array<Item> } | undefined> => {\n\t\tif (!apiRequest) return;\n\n\t\tlet res;\n\t\tlet cacheKey;\n\n\t\tif (useCache) {\n\t\t\t// кэш для полученных ответов через apiRequest\n\t\t\t// общий для всех компонентов, использующих apiRequest\n\t\t\tapiRequest.cache ??= new Map();\n\n\t\t\tcacheKey = JSON.stringify(apiRequest.params);\n\t\t\tres = apiRequest.cache.get(cacheKey);\n\n\t\t\tif (res) {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t}\n\n\t\tisLoading.value = true;\n\t\tres = await apiRequest.call();\n\t\tisLoading.value = false;\n\n\t\tif (res.errors) return;\n\n\t\tif (!Array.isArray(res.result)) {\n\t\t\tconsole.warn(`В result ожидался массив`);\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst indexWithError = (res.result as Array<Item | any>).findIndex(item => item.id === undefined || item.name === undefined);\n\t\tif (indexWithError !== -1) {\n\t\t\tconsole.warn(`В result[${indexWithError}] нет id или name`);\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (useCache) {\n\t\t\tapiRequest.cache.set(cacheKey as string, res);\n\t\t}\n\n\t\treturn res;\n\t};\n\n\t/**\n\t * Загрузить items\n\t */\n\tconst load = async () => {\n\t\tif (!apiRequest) return;\n\n\t\tapiRequest.params.offset = 0;\n\t\tapiRequest.params.search = _searchText;\n\n\t\tconst res = await callAPIRequest();\n\t\tif (!res) return;\n\n\t\t_nextOffset = res.nextOffset;\n\n\t\titems.value = res.result;\n\t};\n\n\t/**\n\t * Загрузить следующую страницу items\n\t */\n\tconst loadAppend = async () => {\n\t\tif (!apiRequest) return;\n\n\t\t// данных о следующих страницах не обнаружено\n\t\tif (!_nextOffset) return;\n\n\t\t// дозагружать нельзя, если не завершена предыдущшая загрузка\n\t\tif (isLoading.value) return;\n\n\t\tapiRequest.params.offset = _nextOffset;\n\t\tapiRequest.params.search = _searchText;\n\n\t\tconst res = await callAPIRequest();\n\t\tif (!res) return;\n\n\t\t_nextOffset = res.nextOffset;\n\n\t\titems.value = items.value.concat(res.result);\n\t};\n\n\tconst loadDebounce = debounce(() => load(), 200);\n\n\t/**\n\t * Выполнить поиск по указанному тексту\n\t *\n\t * Если длина текста меньше minLength, поиск не будет проивзеден\n\t *\n\t * Если текст не изменился, поиск не будет проивзеден\n\t * @param searchText - текст поиска\n\t * @param useDebounce - отложенное выполнение поиска\n\t */\n\tconst setSearchTextAndLoad = (searchText: string, useDebounce = true) => {\n\t\tif (!apiRequest) return;\n\n\t\tif (searchText.length < minLength) return;\n\n\t\t// условия поиска не поменялись, данные загружены\n\t\tif (searchText === _searchText && items.value.length) return;\n\n\t\t_searchText = searchText;\n\n\t\tif (useDebounce) {\n\t\t\tloadDebounce();\n\t\t} else {\n\t\t\tvoid load();\n\t\t}\n\t};\n\n\treturn {\n\t\titems,\n\t\tisLoading,\n\t\tloadAppend,\n\t\tsetSearchTextAndLoad,\n\t};\n};\n","<script setup lang=\"ts\">\nimport type { ComputedRef, ModelRef, ComponentInstance } from 'vue';\nimport { computed, ref, watch } from 'vue';\nimport Core from '@/core/core/core';\nimport { invertKeyboardLayout } from '@/core/utils/keyboard';\nimport { useI18n } from '@/core/plugins/i18n';\nimport { TopPopup, TopPopupListItem, TopPopupWidgetInput } from '@/components/popup/popup';\nimport type PopupClass from '@/components/popup/lib/popup';\nimport type { Item, Props, Slots } from './selector2';\nimport { useAPI } from './api';\nimport Selector2ItemMulti from './itemMulti.vue';\n\nconst props = withDefaults(defineProps<Props>(), {\n\titems: () => [] as Array<Item>,\n\tsize: 's',\n\tminLength: 0,\n\tshowSelectedInInput: true,\n\tshowSearch: true,\n});\n\nconst model = defineModel<Props['modelValue']>() as ModelRef<Props['modelValue']>;\n\ndefineSlots<Slots>();\n\n/**\n * Текст поиска по результатам\n */\nconst searchText = ref('');\n\n/**\n * Сброс поиска\n */\nconst resetSearch = () => {\n\tsearchText.value = '';\n\tAPI.items.value = [];\n};\n\n\nconst itemAll = {\n\tid: 0,\n\tname: useI18n().Common.All!,\n};\n\n/**\n * Экземпляр компонента Popup\n */\nconst popupRef = ref<ComponentInstance<typeof TopPopup> | null>(null);\n\n/**\n * Основной элемент селектора\n */\nconst elRef = ref<HTMLElement | null>(null);\n\n/**\n * Получить доступ к объекту popup\n */\nconst getPopup = (): PopupClass | undefined => {\n\treturn popupRef.value?.popup;\n};\n\n// для storybook\nif ((window as any).__STORYBOOK_PREVIEW__ && !props.modelValue) {\n\twatch(\n\t\t() => props.multiselect,\n\t\t() => {\n\t\t\tmodel.value = props.multiselect ? [] : { id: null, name: '' };\n\t\t},\n\t\t{ immediate: true },\n\t);\n}\n\nconst API = useAPI(props.apiRequest, props.minLength, props.useCache);\n\n/**\n * Варианты выбора: props.items + \"Выбрать все\"\n */\nconst localItems: ComputedRef<Array<Item>> = computed(() => {\n\tconst items: Array<Item> = [];\n\n\tif (!props.multiselect && props.appendAllValue) {\n\t\titems.push(itemAll);\n\t}\n\n\tprops.items.forEach(item => items.push({ ...item }));\n\n\treturn items;\n});\n\n/**\n * Проверить, что элемент выбран\n */\nconst isSelected = (item: Item, checkNameForNullId = true) => {\n\tif (checkNameForNullId && item.id === null) {\n\t\tif (Array.isArray(model.value)) {\n\t\t\treturn model.value.some(itemSelected => itemSelected.id === item.id && itemSelected.name === item.name);\n\t\t} else {\n\t\t\treturn item.name === model.value.name;\n\t\t}\n\t}\n\n\tif (Array.isArray(model.value)) {\n\t\treturn model.value.some(itemSelected => itemSelected.id === item.id);\n\t} else {\n\t\treturn item.id === model.value.id;\n\t}\n};\n\n/**\n * Варианты выбора, которые выводятся\n */\nconst itemsForShow = computed(() => {\n\tconst searchString = searchText.value.toLowerCase();\n\tconst searchStringInvertKeyboard = invertKeyboardLayout(searchString);\n\n\tlet items: typeof localItems.value = [];\n\n\tlocalItems.value.forEach((item) => {\n\t\tconst itemName = item.name.toLowerCase();\n\n\t\tif (\n\t\t\titem.id === Number(searchString) ||\n\t\t\titemName.includes(searchString) ||\n\t\t\titemName.includes(searchStringInvertKeyboard)\n\t\t) {\n\t\t\tif (itemName === searchString || itemName === searchStringInvertKeyboard) {\n\t\t\t\titems.unshift(item);\n\t\t\t} else {\n\t\t\t\titems.push(item);\n\t\t\t}\n\t\t}\n\t});\n\n\titems.push(...API.items.value);\n\n\tif (\n\t\tprops.appendSearchToResult &&\n\t\t!!searchText.value &&\n\t\t(!items.length || items[0].name.toLowerCase() !== searchString)\n\t) {\n\t\titems.push({\n\t\t\tid: null,\n\t\t\tname: searchText.value,\n\t\t});\n\t}\n\n\tif (props.multiselect) {\n\t\titems = items.filter(item => !isSelected(item));\n\t}\n\n\treturn items;\n});\n\n/**\n * Флаг - идет загрузка\n *\n * Скрывает вывод заглушки \"Нет результатов\" - для загрузки данных через API (multiselect = true) - (см. selectItem)\n */\nconst isLoading = ref(API.isLoading.value);\n\nwatch(API.isLoading, () => {\n\tisLoading.value = API.isLoading.value;\n});\n\n/**\n * Выбрать значение\n *\n * Управляет закрытием окна\n */\nconst selectItem = async (item: Item) => {\n\tif (props.multiselect) {\n\t\tif (!Array.isArray(model.value)) return;\n\n\t\tif (isSelected(item)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (props.apiRequest && searchText.value) {\n\t\t\tisLoading.value = true;\n\t\t}\n\n\t\tconst newModel = [...model.value];\n\t\tnewModel.push({ ...item });\n\t\tmodel.value = newModel;\n\n\t\tif (Core.state.isMobile) {\n\t\t\tgetPopup()?.close();\n\t\t} else {\n\t\t\tsetTimeout(() => {\n\t\t\t\tgetPopup()?.recalcPosition();\n\t\t\t\tgetPopup()?.elPopupWidget?.querySelector('input')?.focus();\n\n\t\t\t\tif (searchText.value) resetSearch();\n\t\t\t});\n\t\t}\n\t} else {\n\t\tif (JSON.stringify(item) !== JSON.stringify(model.value)) {\n\t\t\tmodel.value = { ...item };\n\t\t}\n\n\t\tgetPopup()?.close();\n\t}\n};\n\n/**\n * Выбрать следующее значение\n */\nconst selectNextItem = () => {\n\tif (!Array.isArray(model.value)) {\n\t\tconst currentIndex = localItems.value.findIndex(item => item.id === (model.value as Item).id);\n\t\tconst nextIndex = (currentIndex + 1) % localItems.value.length;\n\t\tmodel.value = { ...localItems.value[nextIndex] };\n\t}\n};\n\n/**\n * Удалить выбранное значение по id\n * @param id\n */\nconst deleteItemById = async (id: Item['id']) => {\n\tif (Array.isArray(model.value)) {\n\t\tmodel.value = model.value.filter(item => item.id !== id);\n\n\t\tsetTimeout(() => {\n\t\t\tgetPopup()?.recalcPosition();\n\t\t});\n\t}\n};\n\nconst isOpened = ref(false); // флаг попап открыт\n\nif (props.apiRequest) {\n\twatch(isOpened, () => {\n\t\tif (isOpened.value) {\n\t\t\t// при открытии сразу выполнить поиск\n\t\t\tAPI.setSearchTextAndLoad(searchText.value, false);\n\t\t}\n\t});\n\n\t// отложенный поиск при вводе текста\n\twatch(searchText, () => API.setSearchTextAndLoad(searchText.value));\n}\n\nconst onScrollContentList = (e: Event) => {\n\tconst el = e.target as HTMLElement;\n\n\tif (el.scrollTop / (el.scrollHeight - el.offsetHeight) > 0.8) {\n\t\tAPI.loadAppend();\n\t}\n};\n\nconst onClose = () => {\n\tisOpened.value = false;\n\n\telRef.value?.focus();\n\n\tif (searchText.value) resetSearch();\n};\n</script>\n\n<template>\n\t<TopPopup\n\t\tref=\"popupRef\"\n\t\t@open=\"isOpened = true\"\n\t\t@close=\"onClose()\"\n\t\t@scrollContentList=\"apiRequest ? onScrollContentList($event) : undefined\"\n\t\t:notch=\"false\"\n\t\t:transitionDuration=\"0\"\n\t>\n\t\t<template #opener>\n\t\t\t<div\n\t\t\t\tref=\"elRef\"\n\t\t\t\tv-top-focus.onupdate=\"isError\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t'top-selector2' : true,\n\t\t\t\t\t'top-selector2-multiselect': multiselect,\n\t\t\t\t\t['top-size_' + size]: true,\n\t\t\t\t\t['top-disabled']: disabled,\n\t\t\t\t\t['top-forms-focusable']: !disabled,\n\t\t\t\t\t['top-error']: isError,\n\t\t\t\t}\"\n\t\t\t\t@keydown.up.down.enter.space.stop.prevent=\"($event.currentTarget as HTMLElement).click()\"\n\t\t\t\t@keydown.delete=\"model = []\"\n\t\t\t\ttabindex=\"0\"\n\t\t\t>\n\t\t\t\t<template v-if=\"multiselect\">\n\t\t\t\t\t<div class=\"top-selector2_activeItems\">\n\t\t\t\t\t\t<Selector2ItemMulti\n\t\t\t\t\t\t\tv-for=\"item of model as Array<Item>\"\n\t\t\t\t\t\t\t:id=\"item.id\"\n\t\t\t\t\t\t\t:name=\"item.name\"\n\t\t\t\t\t\t\t@delete=\"deleteItemById\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</template>\n\n\t\t\t\t<span v-if=\"!multiselect\" class=\"top-selector2_activeName top-ellipsis\">\n\t\t\t\t\t{{ !Array.isArray(model) ? model.name : '' }}\n\t\t\t\t</span>\n\n\t\t\t\t<span\n\t\t\t\t\tv-if=\"addChanger && !multiselect && localItems.length > 1 && !disabled\"\n\t\t\t\t\tclass=\"top-changer top-changer-selector\"\n\t\t\t\t\t@click.stop=\"selectNextItem\"\n\t\t\t\t></span>\n\t\t\t</div>\n\t\t</template>\n\n\t\t<template #widget v-if=\"showSearch\">\n\t\t\t<TopPopupWidgetInput\n\t\t\t\ttitle=\"Поиск\"\n\t\t\t\ticon=\"\"\n\t\t\t\tv-model=\"searchText\"\n\t\t\t\t:isLoading=\"isLoading\"\n\t\t\t\t:placeholder=\"!Array.isArray(model) && !multiselect && showSelectedInInput ? model.name : placeholder\"\n\t\t\t/>\n\t\t</template>\n\n\t\t<template #contentList>\n\t\t\t<TopPopupListItem\n\t\t\t\tv-for=\"item of itemsForShow\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t'top-active': !Array.isArray(model) && !multiselect && model.name === item.name\n\t\t\t\t}\"\n\t\t\t\t:key=\"item.id ?? undefined\"\n\t\t\t\t@click.stop=\"selectItem(item)\"\n\t\t\t>\n\t\t\t\t<slot\n\t\t\t\t\tv-if=\"$slots.item\"\n\t\t\t\t\tname=\"item\"\n\t\t\t\t\t:item=\"item\"\n\t\t\t\t></slot>\n\n\t\t\t\t<template\n\t\t\t\t\tv-else\n\t\t\t\t>\n\t\t\t\t\t{{ item.name }}\n\t\t\t\t</template>\n\t\t\t</TopPopupListItem>\n\n\t\t\t<TopPopupListItem\n\t\t\t\tv-if=\"!isLoading && !itemsForShow.length\"\n\t\t\t\ttype=\"regular\"\n\t\t\t>\n\t\t\t\t{{ $i18n.Common.No_results }}\n\t\t\t</TopPopupListItem>\n\t\t</template>\n\t</TopPopup>\n</template>\n\n<style>\n.top-selector2 {\n\twidth: 180px;\n\tmin-height: var(--top-forms-base-height);\n\tbox-sizing: border-box;\n\tposition: relative;\n\tdisplay: flex;\n\toverflow: hidden;\n\tpadding: var(--top-padding-1) var(--top-forms-padding);\n\tcolor: var(--top-forms-placeholder-color);\n\n\tborder-radius: var(--top-radius-2);\n\tborder: 1px solid var(--top-forms-border-color);\n\tbackground: var(--top-forms-background-color);\n}\n\n.top-selector2-multiselect {\n\twidth: unset;\n\tmin-width: 180px;\n\tpadding: var(--top-padding-1);\n}\n\n.top-selector2.top-active {\n\t--top-forms-border-color: var(--top-forms-border-color-hover);\n}\n\n.top-selector2_activeItems {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: var(--top-padding-1);\n\tmax-width: 100%;\n}\n\n.top-selector2_activeName {\n\twhite-space: nowrap;\n}\n\n.top-changer-selector {\n\ttransform: translateX(-16px);\n}\n</style>\n","import type { ComponentCustomProps } from 'vue';\n\nimport EditArea from './editArea/editArea.vue';\nimport EditInput from './editInput/editInput.vue';\nimport RadioGroup from './radioGroup/radioGroup.vue';\nimport Selector2 from './selector2/selector2.vue';\nimport Menu from './menu/menu.vue';\nimport Info from './info/info.vue';\n\nexport const TopEditArea = EditArea as typeof EditArea & ComponentCustomProps;\nexport const TopEditInput = EditInput as typeof EditInput & ComponentCustomProps;\nexport const TopRadioGroup = RadioGroup as typeof RadioGroup & ComponentCustomProps;\nexport const TopSelector2 = Selector2 as typeof Selector2 & ComponentCustomProps;\nexport const TopMenu = Menu as typeof Menu & ComponentCustomProps;\nexport const TopInfo = Info as typeof Info & ComponentCustomProps;\n"],"names":["props","__props","emit","__emit","localValue","ref","isFocused","isChanged","computed","submit","value","cancel","clickOnTitle","intermediateValue","watch","toRef","model","useModel","elRef","_a","item","_c","_b","_e","_d","uid","useAPI","apiRequest","minLength","useCache","items","isLoading","_searchText","_nextOffset","callAPIRequest","res","cacheKey","indexWithError","load","loadAppend","loadDebounce","debounce","searchText","useDebounce","resetSearch","API","itemAll","useI18n","popupRef","getPopup","localItems","isSelected","checkNameForNullId","itemSelected","itemsForShow","searchString","searchStringInvertKeyboard","invertKeyboardLayout","itemName","selectItem","newModel","Core","selectNextItem","nextIndex","deleteItemById","id","isOpened","onScrollContentList","e","el","onClose","TopEditArea","_sfc_main$5","TopEditInput","_sfc_main$4","TopRadioGroup","_sfc_main$3","TopSelector2","_sfc_main$1","TopMenu","_sfc_main$9","TopInfo","_sfc_main"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,UAAAA,IAAAC,GAQAC,IAAAC,GAEAC,IAAAC,EAAAL,EAAA,YAAA,GAEAM,IAAAD,EAAAL,EAAA,SAAA,GAEAO,IAAAC,EAAA,MAAAJ,EAAA,UAAAJ,EAAA,YAAA,GAEAS,IAAA,CAAAC,MAAA;AACC,MAAAR,EAAA,UAAAQ,CAAA,GAEAN,EAAA,QAAAJ,EAAA;AAAA,IAAyB,GAG1BW,IAAA,MAAA;AACC,UAAAX,EAAA,qBAAA,CAAAO,EAAA,OAAA;AACC,QAAAL,EAAA,OAAA;AAEA;AAAA,MAAA;AAGD,MAAAE,EAAA,QAAAJ,EAAA;AAAA,IAAyB,GAG1BY,IAAA,MAAA;AACC,MAAAZ,EAAA,oBAAAE,EA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MAAAG,EAAA,qBAAAH,EAAA,KAAA,CAAA;AAGD,UAAAyB,IAAA,CAAAC,MAAA;AACC,YAAAC,IAAAD,EAAA;AAEA,MAAAC,EAAA,aAAAA,EAAA,eAAAA,EAAA,gBAAA,OACCxB,EAAA,WAAA;AAAA,IACD,GAGDyB,KAAA,MAAA;;AACC,MAAAJ,EAAA,QAAA,KAEA/C,IAAAD,EAAA,UAAA,QAAAC,EAAA,SAEAuB,EAAA,SAAAE,EAAA;AAAA,IAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ICtP5B2B,KAAAC,IACAC,KAAAC,IACAC,KAAAC,IACAC,KAAAC,IACAC,KAAAC,IACAC,KAAAC;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@topvisor/ui",
3
3
  "private": false,
4
- "version": "1.0.26-0",
4
+ "version": "1.0.26-10",
5
5
  "type": "module",
6
6
  "description": "Topvisor UI-kit Vue",
7
7
  "author": "Topvisor",
@@ -1,2 +1,2 @@
1
- define(["require","exports","vue","../.chunks/forms-B3bJpLOo.amd","../.chunks/listItem.vue_vue_type_script_setup_true_lang-DLF_Qnj6.amd","../.chunks/menu.vue_vue_type_style_index_0_lang-VpwRSIdl.amd","../.chunks/utils-CTjq0RlC.amd","../utils/searchers.amd","../utils/dom.amd","../popup/worker.amd","../require/css.amd!../assets/project.css"],function(ne,T,e,x,E,oe,le,P,_,ae){"use strict";if(typeof e>"u")var e=window.Vue;const re={class:"top-selectorCompetitors"},ie={class:"top-ellipsis1"},de=e.defineComponent({__name:"selectorCompetitors",props:e.mergeModels({modelValue:{},items:{},showSelectAllItem:{type:Boolean,default:!0}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const o=n,r=e.useModel(n,"modelValue"),t=e.computed(()=>{if(o.showSelectAllItem)return{icon:"",title:x.useI18n().Common.Select_all,value:"all",content:""}});return(d,l)=>(e.openBlock(),e.createElementBlock("div",re,[e.unref(x.Core).state.isMobile?(e.openBlock(),e.createBlock(E._sfc_main,{key:0},{opener:e.withCtx(()=>[e.createVNode(x._sfc_main,{class:"top-selectorCompetitors_opener",color:"theme",icon:"",icon2:""},{default:e.withCtx(()=>{var a;return[e.createTextVNode(e.toDisplayString((a=d.items.find(s=>{var f;return s.value===((f=r.value)==null?void 0:f[0])}))==null?void 0:a.content),1)]}),_:1})]),contentList:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.items,(a,s)=>{var f;return e.openBlock(),e.createBlock(E._sfc_main$1,{class:e.normalizeClass({"top-active":(f=r.value)==null?void 0:f.includes(a.value)}),"data-top-icon":a.icon,title:a.title,onClick:()=>r.value=[a.value]},{default:e.withCtx(()=>[e.createElementVNode("span",ie,e.toDisplayString(a.content),1)]),_:2},1032,["class","data-top-icon","title","onClick"])}),256))]),_:1})):(e.openBlock(),e.createBlock(oe._sfc_main,{key:1,modelValue:r.value,"onUpdate:modelValue":l[0]||(l[0]=a=>r.value=a),items:d.items,isMultiple:!0,styling:"bar",canBeEmptyMultiple:!1,selectAllItem:t.value},null,8,["modelValue","items","selectAllItem"]))]))}}),w=-1,y=-2,R=-1,ue={0:"Yandex",1:"Google",4:"YouTube",5:"Bing",7:"Seznam",8:"AppStore",9:"GoogleStore",20:"Yandex.com",21:"Yandex.com.tr"},J={key:y,name:"--",index:y},G={key:y,name:"--",regions:[J],regionByIndex:new Map([[y,J]])},A={key:y,name:"Autoselect",index:y},U={key:y,name:"Autoselect",regions:[A],regionByIndex:new Map([[y,A]])},Y={countryCode:"00",depth:1,device:0,key:R,index:R,lang:"ru",name:"Without region"},se=()=>(A.name=x.useI18n().Common.Autoselect,A),ce=()=>(se(),U.name=x.useI18n().Common.Autoselect,console.log(U),U),ge=()=>(Y.name=x.useI18n().Keywords.Without_region,Y),z=(n=!1,o=!1,r=[])=>{let t;return n?t=me(r):t=W(r),o&&t.set(y,ce()),t.size||t.set(y,G),t},W=(n,o=!0,r=[],t=!1)=>{const d=new Map;return n.forEach(l=>{if(!l.enabled||t&&typeof l.key=="number"&&l.key>1)return;const a={...l};a.regionByIndex=new Map,l.regions&&l.regions.forEach(s=>{if(o&&!s.enabled)return;const f={...s};a.regionByIndex.set(f.index,f)}),!a.regionByIndex.size&&r.length,(a.regionByIndex.size||r.length)&&typeof a.key=="number"&&d.set(a.key,a)}),r.forEach(l=>{if(d.has(l))return;const a={key:l,name:ue[l],regions:[],regionByIndex:new Map};d.set(a.key,a)}),d},me=n=>{const o=W(n,!1,[0,1],!0);if(o.has(2)){const r=o.get(2);r&&(r.regionByIndex=new Map)}return o.forEach(r=>{if(!r.regionByIndex)return;const t={...ge()};r.regionByIndex.set(t.index,t)}),o},H=(n,o,r=[])=>{const t=z(n,!1,r);let d;return t.forEach(l=>{if(!(o.searcher_key!==void 0&&o.searcher_key!=l.key)&&l.regions&&(l.regions.forEach(a=>{if(!d&&!(o.key!==void 0&&o.key!=a.key)&&!(o.index!==void 0&&o.index!=a.index)&&!(!n&&(o.lang!==void 0&&o.lang!=a.lang||o.device!==void 0&&o.device!=a.device)))return a.searcher_key=l.key,d=a,!1}),d))return!1}),d},Q=le.useAsyncTopDialog(()=>new Promise((n,o)=>ne(["../.chunks/dialog_selectorRegions-BOPta9cH.amd"],n,o))),fe=(n,o)=>{const r=x.useI18n(),t=e.ref(o.value.keys().next().value??y),d=e.computed(()=>{const l=new Map;if(o.value.forEach(a=>{let s={value:a.key,title:a.name};n.addSearcherIcon&&(s.icon=P.getSearcherGIcon(a.key)),l.set(a.key,s)}),n.addCompare&&!l.has(y)){const a={value:"",title:"--------------------",disabled:!0};l.set(a.value,a);const s={value:w,title:r.Common.Compare};l.set(s.value,s)}return l});return{searcherKey:t,optionBySearcherKey:d}},ve=(n,o)=>{var l,a,s;const r=x.useI18n(),t=e.ref(y);n.modelValue.length===1&&(t.value=n.modelValue[0]),t.value===y&&(n.forFrequency?t.value=((a=(l=o.value)==null?void 0:l.regionByIndex.values().next().value)==null?void 0:a.key)??y:t.value=((s=o.value)==null?void 0:s.regionByIndex.keys().next().value)??y);const d=e.computed(()=>{var h;const f=new Map;return(h=o.value.regionByIndex)==null||h.forEach(S=>{let i=S.name;if(n.forFrequency){const I={value:S.key,title:i};f.has(S.key)||f.set(S.key,I);return}S.device&&(i+=" ("+r.Common["Device_"+S.device]+")");const m=P.getLangLabel(o.value.key||0,S.lang??"");m&&(i+=" / "+m);const c={value:S.index,title:i,icon:S.device?P.getDeviceGIcon(S.device):void 0};f.set(S.index,c)}),f});return e.watch(d,(f,h)=>{var c;if(n.onlySearcher||t.value!==void 0&&f.get(t.value))return;let S=f.keys().next().value;if(t.value===y||S===y){t.value=S;return}let i=((c=h==null?void 0:h.get(t.value))==null?void 0:c.title)||"",m=-1;for(const[I,B]of f.entries()){const C=B.title;if(typeof C!="string"||typeof I=="string")break;if(C===i){S=I;break}const V=new RegExp(` \\((${r.Common.Device_1}|${r.Common.Device_2})\\)`);let v=i,u=3;C.indexOf(v)===-1&&(v=i.replace(/^[^a-zа-я]/i,"").replace(V,""),u--),C.indexOf(v)===-1&&(v=i.replace(/ \/.*/,""),u--),C.indexOf(v)===-1&&(v=i.replace(/ \/.*/,""),v=v.replace(/^[^a-zа-я]/i,"").replace(V,""),u--),C.indexOf(v)!==-1&&(u<=m||(m=u,S=I))}t.value=S}),{regionIndex:t,optionByRegionIndex:d}},pe=(n,o,r)=>{const t=e.ref([]),d=()=>{if(n.onlySearcher&&o.value){t.value=Array.from(o.value.keys());return}let a=[];if(n.modelValue.length>1)a=[...n.modelValue];else try{a=JSON.parse(localStorage.getItem("ui:project:regionSelector"+n.projectId+":regionsIndexes"))??[]}catch{}a.length&&(a=a.filter(s=>r.value.has(s))),a.length||(a=Array.from(r.value)),t.value=[...a]},l=()=>{t.value.length?localStorage.setItem("ui:project:regionSelector:"+n.projectId+":regionsIndexes",JSON.stringify(t.value)):localStorage.removeItem("ui:project:regionSelector:"+n.projectId+":regionsIndexes")};return e.watch(t,()=>{l()}),n.addCompare&&d(),{regionsIndexes:t}},ye=n=>{const o=e.computed(()=>z(n.forFrequency,n.autoRegion,n.searchers)),r=e.computed(()=>o.value.get(d.searcherKey.value)||G),t=e.computed(()=>{const i=new Set;return o.value.forEach(m=>{m.regionByIndex.forEach(c=>{c.index!==R&&c.index!==y&&i.add(c.index)})}),i}),d=fe(n,o),l=ve(n,r),a=pe(n,o,t);e.watch(o,()=>{var m,c,I,B;if(n.onlySearcher?a.regionsIndexes.value=Array.from(o.value.keys()):a.regionsIndexes.value=a.regionsIndexes.value.filter(C=>t.value.has(C)),d.searcherKey.value===w)return;let i=o.value.keys().next().value;o.value.forEach(C=>{var V,v,u;if(n.onlySearcher&&C.key===d.searcherKey.value){i=d.searcherKey.value;return}if(l.regionIndex.value&&((V=C.regionByIndex)!=null&&V.has(l.regionIndex.value))&&(i=C.key),!n.onlySearcher){let g;i!==void 0&&(g=(v=o.value.get(i))==null?void 0:v.regionByIndex);const p=(u=o.value.get(C.key))==null?void 0:u.regionByIndex;g!=null&&g.has(y)&&!(p!=null&&p.has(y))&&(i=C.key)}}),i!==void 0&&(d.searcherKey.value=i),l.regionIndex.value!==void 0&&!((c=(m=r.value)==null?void 0:m.regionByIndex)!=null&&c.has(l.regionIndex.value))&&(l.regionIndex.value=(B=(I=r.value)==null?void 0:I.regions)==null?void 0:B.keys().next().value)},{immediate:!0});const s=()=>{if(!(d.searcherKey.value===w||d.searcherKey.value===y))return d.searcherKey.value},f=()=>{if(n.onlySearcher||l.regionIndex.value===y)return;let i=l.regionIndex.value;if(n.forFrequency){const m=l.regionIndex.value,c=H(n.forFrequency,{searcher_key:s(),key:m},n.searchers);i=c==null?void 0:c.index}return i},h=()=>{const i=s();if(i!==void 0)return o.value.get(i)};return{selectSearcher:d,selectRegion:l,compare:a,searcherByKey:o,allRegionsIndexes:t,getSearcher:h,getRegion:()=>{var m,c;const i=f();if(i!==void 0)return(c=(m=h())==null?void 0:m.regionByIndex)==null?void 0:c.get(i)}}},he=e.defineComponent({__name:"selectorRegion",props:e.mergeModels({projectId:{},searchers:{default:()=>[]},modelValue:{},modelValueSingle:{},addCompare:{type:Boolean},forFrequency:{type:Boolean},autoRegion:{type:Boolean},onlySearcher:{type:Boolean},addChanger:{type:Boolean,default:!0},addSearcherIcon:{type:Boolean,default:!0},addRegionIcon:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{},modelValueSingle:{},modelValueSingleModifiers:{}}),emits:["update:modelValue","update:modelValueSingle"],setup(n,{expose:o}){const r=n,t=e.useModel(n,"modelValue"),d=e.useModel(n,"modelValueSingle"),{selectSearcher:l,selectRegion:a,compare:s,searcherByKey:f,allRegionsIndexes:h,getSearcher:S,getRegion:i}=ye(r),m=()=>{const c=[];f.value.forEach(I=>{I.enabled&&I.regions.forEach(B=>{B.enabled&&c.push(B)})}),Q.open("selectorRegions",{regions:c,regionsIndexes:s.regionsIndexes.value,"@update:regionsIndexes":I=>s.regionsIndexes.value=I})};return e.watch([a.regionIndex,l.searcherKey,s.regionsIndexes],()=>{if(l.searcherKey.value===w&&s.regionsIndexes.value.length){if(JSON.stringify(t.value)===JSON.stringify(s.regionsIndexes.value))return;t.value=[...s.regionsIndexes.value]}else r.onlySearcher?(t.value=[l.searcherKey.value],l.searcherKey.value===y&&!r.autoRegion&&(t.value.length=0)):(t.value=[a.regionIndex.value],a.regionIndex.value===y&&!r.autoRegion&&(t.value.length=0));!r.onlySearcher&&!h.value.size&&(l.searcherKey.value=y)}),d.value&&e.watch(d,()=>{d.value&&(t.value=[d.value])},{immediate:!0}),e.watch(t,()=>{var c,I,B,C,V;if(t.value[0]&&(d.value=t.value[0]),r.onlySearcher){if(!t.value.length||t.value.length===1&&!f.value.has(t.value[0])){let v=f.value.keys().next().value;v===y&&!r.autoRegion&&(v=void 0,d.value=y),v!==void 0&&(t.value=[v]);return}if(t.value.length>1&&JSON.stringify(t.value)!==JSON.stringify(s.regionsIndexes.value)){t.value=[...s.regionsIndexes.value];return}}else{let v=[...new Set(t.value)],u=(I=(c=f.value.values().next().value)==null?void 0:c.regionByIndex)==null?void 0:I.keys().next().value;if(r.forFrequency&&(u=(V=(C=(B=f.value.values().next().value)==null?void 0:B.regionByIndex)==null?void 0:C.values().next().value)==null?void 0:V.key),u===y&&!r.autoRegion&&(u=void 0,d.value=y),!v.length)u!==void 0&&v.push(u);else if(v.length===1){let g=h.value;r.forFrequency&&(g=new Set,f.value.forEach(p=>{p.regionByIndex.forEach(k=>{k.index!==R&&k.index!==y&&g.add(k.key)})})),g.has(v[0])||(v=[],u!==void 0&&v.push(u))}else v=v.filter(g=>h.value.has(g)),!v.length&&u!==void 0&&v.push(u);if(JSON.stringify(t.value)!==JSON.stringify(v)){t.value=v;return}}if(!(t.value.length===1&&t.value[0]===(r.onlySearcher?l.searcherKey.value:a.regionIndex.value)))if(r.onlySearcher){if(t.value.length===1){l.searcherKey.value=t.value[0];return}l.searcherKey.value=w;return}else{if(!t.value.length)return;if(t.value.length===1&&l.searcherKey.value!==w){a.regionIndex.value=t.value[0];let v;for(const u of f.value.values()){for(const g of u.regionByIndex.values())if((r.forFrequency?g.key:g.index)===a.regionIndex.value){v=u.key;break}if(v!==void 0)break}v!==void 0&&(l.searcherKey.value=v)}else l.searcherKey.value=w,s.regionsIndexes.value=[...t.value]}},{immediate:!0}),o({getSearcher:S,getRegion:i}),(c,I)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-selectorRegion":!0,"top-selectorRegion-onlySearcher":c.onlySearcher})},[e.createVNode(x._sfc_main$4,{options:e.unref(l).optionBySearcherKey.value,modelValue:e.unref(l).searcherKey.value,"onUpdate:modelValue":I[0]||(I[0]=B=>e.unref(l).searcherKey.value=B),name:"searcher_key",addChanger:c.addChanger},null,8,["options","modelValue","addChanger"]),!c.onlySearcher&&e.unref(l).searcherKey.value!==e.unref(w)?(e.openBlock(),e.createBlock(x._sfc_main$4,{key:0,class:"top-select-region",options:e.unref(a).optionByRegionIndex.value,modelValue:e.unref(a).regionIndex.value,"onUpdate:modelValue":I[1]||(I[1]=B=>e.unref(a).regionIndex.value=B),name:c.forFrequency?"region_key":"region_index",addChanger:c.addChanger,"data-top-icon":c.addRegionIcon?"":void 0},null,8,["options","modelValue","name","addChanger","data-top-icon"])):e.createCommentVNode("",!0),c.addCompare&&!c.onlySearcher&&e.unref(l).searcherKey.value===e.unref(w)?(e.openBlock(),e.createBlock(x._sfc_main,{key:1,name:"compare",onClick:m,"data-count-compare-regions-indexes":e.unref(s).regionsIndexes.value.length},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.$i18n.Common.Selected_regions),1)]),_:1},8,["data-count-compare-regions-indexes"])):e.createCommentVNode("",!0)],2))}}),Se=[{id:"1",name:"Without Tag",color_id:"1"},{id:"2",name:"Red",color_id:"2"},{id:"3",name:"Orange",color_id:"3"},{id:"4",name:"Yellow",color_id:"4"},{id:"5",name:"Blue",color_id:"5"},{id:"6",name:"Purple",color_id:"6"},{id:"7",name:"Green",color_id:"7"},{id:"8",name:"Magenta",color_id:"8"},{id:"9",name:"Dark blue",color_id:"9"},{id:"10",name:"Turquoise",color_id:"10"}],X=n=>"-"+n,K=n=>n[0]==="-"?n.substring(1):n,O=(n,o)=>{n=K(n);const r=o.find(t=>t.id===n);if(r)return r},ke=["data-tag_id","data-tag_color_id","title"],D=e.defineComponent({__name:"tagIcon",props:{id:{},colorId:{},name:{},state:{}},setup(n){return(o,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-tagSelector_tagIcon":!0,"top-tagSelector-active":!!o.state,"top-tagSelector-excluded":o.state==="excluded"}),"data-tag_id":o.id,"data-tag_color_id":o.colorId,title:o.name},null,10,ke))}}),Ie=["contenteditable","onKeydown"],Z=e.defineComponent({__name:"tagPopupListItem",props:e.mergeModels({editable:{type:Boolean},disabled:{type:Boolean},canExclude:{type:Boolean},id:{},colorId:{},name:{},state:{}},{name:{required:!0},nameModifiers:{}}),emits:e.mergeModels(["update:name","unselect","exclude","select"],["update:name"]),setup(n,{emit:o}){const r=n,t=o,d=e.useModel(n,"name"),l=e.ref(null),a=e.computed(()=>navigator.userAgent.indexOf("Firefox")!=-1?{contenteditable:s.value,onpaste:m=>m.preventDefault()}:{}),s=e.ref(!1),f=async()=>{var m;s.value=!0,await e.nextTick(),(m=l.value)==null||m.focus()},h=()=>{var c;const m=(c=l.value)==null?void 0:c.innerText;if(!m)return S();l.value&&(l.value.innerText=m),s.value=!1,t("update:name",m)},S=async()=>{l.value&&(l.value.innerText=r.name),s.value=!1},i=m=>{if(s.value||r.disabled)return;let c="selected";r.canExclude&&(m.ctrlKey||m.metaKey)&&(c="excluded"),r.state==c&&(c=""),c===""&&t("unselect"),c==="selected"&&t("select"),c==="excluded"&&t("exclude")};return(m,c)=>(e.openBlock(),e.createBlock(E._sfc_main$1,{class:e.normalizeClass({"top-tagSelector_tagListItem":!0,"top-tagSelector_tagListItem-inEdit":s.value,"top-tagSelector_tagListItem-disabled":m.disabled,"top-tagSelector_tagListItem-canExclude":m.canExclude,"top-tagSelector-active":!!m.state,"top-tagSelector-excluded":m.state==="excluded"}),onClick:e.withModifiers(i,["stop"])},{default:e.withCtx(()=>[e.createVNode(D,{id:m.id,name:d.value,colorId:m.colorId,state:m.state},null,8,["id","name","colorId","state"]),e.createElementVNode("span",e.mergeProps({ref_key:"elName",ref:l,class:"top-tagSelector_tagListItemName",contenteditable:s.value?"plaintext-only":!1},a.value,{onKeydown:[e.withKeys(e.withModifiers(h,["stop"]),["enter"]),e.withKeys(e.withModifiers(S,["stop"]),["esc"])]}),e.toDisplayString(d.value),17,Ie),m.editable?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[s.value?(e.openBlock(),e.createElementBlock("span",{key:1,"data-top-icon":"",class:"top-tagSelector_edit",onClick:e.withModifiers(h,["stop"])})):(e.openBlock(),e.createElementBlock("span",{key:0,"data-top-icon":"",class:"top-tagSelector_edit",onClick:f}))],64)):e.createCommentVNode("",!0)]),_:1},8,["class"]))}}),xe={key:1},ee=e.defineComponent({inheritAttrs:!1,__name:"popupOpener",props:e.mergeModels({modelValue:{},id:{},tags:{},mode:{},targetId:{},filters:{},useTopButton:{type:Boolean},payload:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const o=n,r=e.useModel(n,"modelValue"),t=o.useTopButton?x._sfc_main:"div",d=o.useTopButton?"html":"default",l={model:r,mode:o.mode,targetId:o.targetId,filters:o.filters,payload:o.payload};return(a,s)=>{const f=e.resolveDirective("top-data");return e.openBlock(),e.createBlock(E._sfc_main$2,{id:a.id},{default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(t)),e.mergeProps({class:{"top-tagSelector":!0,"top-tagSelector-filter":o.mode==="filter","top-tagSelector-setter_single":o.mode==="setter"&&!a.filters,"top-tagSelector-setter_several":o.mode==="setter"&&a.filters,"top-tagSelector-selectedOne":!r.value.length||r.value.length===1,"top-tagSelector-toTwoLine":r.value.length>5},color:"theme",styling:""},a.$attrs),{[e.unref(d)]:e.withCtx(()=>[!r.value.length&&a.mode==="filter"?(e.openBlock(),e.createBlock(D,{key:0,id:"all",colorId:"",name:a.$i18n.Common.All_tags??"",state:""},null,8,["name"])):e.createCommentVNode("",!0),a.mode==="setter"&&a.filters?(e.openBlock(),e.createElementBlock("div",xe,[e.renderSlot(a.$slots,"default")])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(r.value,h=>{var S,i;return e.openBlock(),e.createBlock(D,{id:e.unref(K)(h),colorId:((S=e.unref(O)(h,a.tags))==null?void 0:S.color_id)??"",name:((i=e.unref(O)(h,a.tags))==null?void 0:i.name)??"",state:e.unref(K)(h)===h?"selected":"excluded"},null,8,["id","colorId","name","state"])}),256))]),_:2},1040,["class"])),[[f,l,"topTagSelectorTarget"]])]),_:3},8,["id"])}}}),Ce=e.defineComponent({__name:"tagSelector",props:e.mergeModels({modelValue:{},tags:{},tagsEditable:{type:Boolean},tagsMax:{default:10},id:{},singleMode:{type:Boolean},requiredForSetter:{type:Boolean,default:!0},maxTagsForSetter:{},emitDelay:{default:500}},{modelValue:{required:!0},modelModifiers:{},tags:{default:e.reactive(Se)},tagsModifiers:{}}),emits:e.mergeModels(["selector","setter","tagsChanged"],["update:modelValue","update:tags"]),setup(n,{emit:o}){const r=x.useI18n(),t=n,d=e.useModel(n,"modelValue"),l=e.useModel(n,"tags"),a=o,s=x.debounce((u,g)=>{a(u,g)},t.emitDelay);t.singleMode&&!d.value.length&&(d.value=[l.value[0].id]);const f=t.id??"top-popup-id-"+Math.random(),h=e.ref("add"),S=()=>{var p;const u=" "+((p=r.Common.Tags)==null?void 0:p.toLowerCase()),g=new Map;return g.set("add",{value:"add",title:r.Common.Add+u}),g.set("replace",{value:"replace",title:r.Common.Replace+u}),g.set("delete",{value:"delete",title:r.Common.Delete+u}),g};let i=e.shallowRef({model:d,mode:"filter",targetId:void 0,filters:void 0,payload:void 0});e.watch(d,()=>{s("selector",d.value)});const m=e.computed(()=>{if(i.value.mode==="setter"&&t.maxTagsForSetter&&!i.value.filters)return i.value.model.value.length>=t.maxTagsForSetter}),c=u=>{if(u!=="all"){if(i.value.model.value.includes(u))return"selected";if(i.value.model.value.includes(X(u)))return"excluded"}return u==="all"&&!i.value.model.value.length?"selected":""},I=(u,g)=>{const p=X(u);let k=i.value.model.value.filter(M=>M!==u&&M!==p);g==="select"&&k.push(u),g==="exclude"&&k.push(p),i.value.mode==="setter"&&i.value.targetId!==void 0&&t.requiredForSetter&&(k.length||k.push("1"),k.length===2&&i.value.model.value.length===1&&i.value.model.value[0]==="1"&&(k=k.filter(M=>M!=="1"))),t.singleMode&&!i.value.filters&&(k.length||(k=i.value.model.value),k.length>1&&(k=[k[k.length-1]])),k.sort((M,N)=>{if(!t.tags)return 0;const q=t.tags.findIndex(b=>b.id===M),L=t.tags.findIndex(b=>b.id===N);return q-L}),i.value.model.value=k,i.value.mode==="setter"&&i.value.targetId!==void 0&&s("setter",{tagsIds:k,targetId:i.value.targetId,payload:i.value.payload})},B=e.computed(()=>{let u="top-tagSelector_popup";return i.value.mode==="filter"&&(u+=" top-tagSelector_popup-filter"),i.value.mode==="setter"&&(u+=" top-tagSelector_popup-setter"),u}),C=()=>{const u=prompt("","New tag");if(!u||u==="New tag")return;const g=l.value.length+1;l.value.push({id:String(g),name:u,color_id:String((g-1)%10+1)}),a("tagsChanged",l.value)},V=u=>{var g;if(i.value=_.storage(u.elPopupOpener,"topTagSelectorTarget"),!i.value)throw new Error("Open popup TopTagSelector required v-data:topTagSelectorTarget");if(i.value.filters&&(h.value="add",i.value.model.value=[]),!((g=x.Core.$)!=null&&g.ui.sortable)){console.info("Для работы сортировки требуется глобальная загрузка jQuery UI Sortable");return}!x.Core.state.isMobile&&!x.Core.state.isMobileUA&&l.value&&$(u.elPopup).sortable({items:'li:has([data-tag_id]:not([data-tag_id="all"]))',cancel:'[contenteditable="plaintext-only"], [contenteditable="true"]',distance:10,stop:function(p,k){if(!l.value)return;const M=$(k.item).parent().find("[data-tag_id]"),N=[];M.each((q,L)=>{if(!l.value)return;const b=$(L).attr("data-tag_id");N.push(b)}),l.value.sort((q,L)=>{const b=N.findIndex(j=>j===q.id),Ke=N.findIndex(j=>j===L.id);return b-Ke}),s("tagsChanged",l.value)}})},v=u=>{var g;(g=x.Core.$)!=null&&g.ui.sortable&&$(u.elPopup).data("ui-sortable")&&$(u.elPopup).sortable("destroy")};return(u,g)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(ee,{class:"top-select_arrow",modelValue:d.value,"onUpdate:modelValue":g[0]||(g[0]=p=>d.value=p),id:e.unref(f),tags:l.value,mode:"filter",useTopButton:""},null,8,["modelValue","id","tags"]),e.createVNode(E._sfc_main,{id:e.unref(f),class:e.normalizeClass(B.value),onOpen:g[4]||(g[4]=p=>V(p)),onClose:g[5]||(g[5]=p=>v(p)),"transition-duration":50},e.createSlots({contentList:e.withCtx(()=>[e.unref(i).mode==="filter"&&!u.singleMode?(e.openBlock(),e.createBlock(Z,{key:0,id:"all",colorId:"",name:u.$i18n.Common.All_tags??"",state:e.unref(i).model.value.length?"":"selected",onSelect:g[3]||(g[3]=p=>e.unref(i).model.value=[])},null,8,["name","state"])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,p=>(e.openBlock(),e.createBlock(Z,{key:p.id,id:p.id,colorId:p.color_id,name:p.name,state:c(p.id),canExclude:e.unref(i).mode==="filter"&&!u.singleMode,editable:u.tagsEditable,disabled:m.value&&c(p.id)==="",onUnselect:k=>I(p.id,"unselect"),onSelect:k=>I(p.id,"select"),onExclude:k=>I(p.id,"exclude"),"onUpdate:name":k=>{p.name=k,e.unref(s)("tagsChanged",l.value)}},null,8,["id","colorId","name","state","canExclude","editable","disabled","onUnselect","onSelect","onExclude","onUpdate:name"]))),128)),u.tagsEditable&&l.value.length<u.tagsMax&&l.value.length<20?(e.openBlock(),e.createBlock(E._sfc_main$1,{key:1,"data-top-icon":"",onClick:e.withModifiers(C,["stop"])},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.$i18n.Common.Add),1)]),_:1})):e.createCommentVNode("",!0)]),_:2},[e.unref(i).mode==="setter"&&e.unref(i).filters?{name:"header",fn:e.withCtx(()=>[e.createVNode(x._sfc_main$4,{modelValue:h.value,"onUpdate:modelValue":g[1]||(g[1]=p=>h.value=p),options:S()},null,8,["modelValue","options"])]),key:"0"}:void 0,e.unref(i).mode==="setter"&&e.unref(i).filters?{name:"footer",fn:e.withCtx(()=>[e.createVNode(x._sfc_main,{color:"theme"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.$i18n.Common.Cancel),1)]),_:1}),e.createVNode(x._sfc_main,{onClick:g[2]||(g[2]=p=>e.unref(s)("setter",{tagsIds:e.unref(i).model.value,filters:e.unref(i).filters,filtersAction:h.value,payload:e.unref(i).payload}))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.value==="add"?u.$i18n.Common.Add:"")+" "+e.toDisplayString(h.value==="replace"?u.$i18n.Common.Replace:"")+" "+e.toDisplayString(h.value==="delete"?u.$i18n.Common.Remove:""),1)]),_:1})]),key:"1"}:void 0]),1032,["id","class"])],64))}}),Be=(n,o)=>e.computed(()=>e.toValue(n).filter(d=>d.on>=0||d.id===o).map(d=>({value:d.id,title:d.url+` [${d.id}]`,icon:d.id===e.toValue(o)?"":"",content:d.name}))),Te=(n,o,r)=>{o||(o={id:n.id}),o.id=n.id;const t=ae.TopPopupWorker.genElPopupOpener("div",o);return t.classList.add("top-tagSelector"),n.useTopButton&&t.classList.add("top-button","top-color_theme"),n.mode==="filter"&&t.classList.add("top-tagSelector-filter"),n.mode==="setter"&&!n.filters&&t.classList.add("top-tagSelector-setter_single"),n.mode==="setter"&&n.filters&&t.classList.add("top-tagSelector-setter_several"),t.onclick=d=>{d.preventDefault(),d.stopPropagation(),t.onclick=null;const l=e.ref(n.modelValue),a={model:l,mode:n.mode,targetId:n.targetId,filters:n.filters,payload:n.payload};_.storage(t,"topTagSelectorTarget",a),delete t.dataset.topPopupDisabled,e.isRef(n.modelValue)||e.watch(l,()=>{n.modelValue=l.value,F(t,n,r)}),t.click()},e.isRef(n.modelValue)?e.watch(n.modelValue,()=>F(t,n,r)):_.storage(t,"topTagSelectorRender",d=>{n.modelValue=d;const l=_.storage(t,"topTagSelectorTarget");l&&(l.model.value=d),F(t,n,r)}),F(t,n,r),t},Ve=(n,o)=>{var r;(r=_.storage(n,"topTagSelectorRender"))==null||r(o)},F=(n,o,r)=>{var d;const t=e.unref(o.modelValue);if(n.classList.toggle("top-tagSelector-selectedOne",!t.length||t.length===1),n.classList.toggle("top-tagSelector-toTwoLine",t.length>5),o.mode==="setter"&&o.filters){n.innerHTML=`<div>${r}</div>`;return}if(n.innerHTML="",!t.length&&o.mode==="filter"){const l=te({id:"all",colorId:"",name:((d=x.useI18n().Common)==null?void 0:d.All_tags)??"",state:""});n.append(l)}t.forEach(l=>{var s,f;const a=te({id:K(l),colorId:((s=O(l,o.tags))==null?void 0:s.color_id)??"",name:((f=O(l,o.tags))==null?void 0:f.name)??"",state:K(l)===l?"selected":"excluded"});n.append(a)})},te=n=>{const o=document.createElement("div");return o.classList.add("top-tagSelector_tagIcon"),o.classList.toggle("top-tagSelector-active",!!n.state),o.classList.toggle("top-tagSelector-excluded",n.state==="excluded"),o.dataset.tag_id=n.id,o.dataset.tag_color_id=n.colorId,o.title=n.name,o},we=de,Me=he,be=Ce,Ee=ee,_e=D;T.TopSelectorCompetitors=we,T.TopSelectorRegion=Me,T.TopTagSelector=be,T.TopTagSelectorPopupOpener=Ee,T.TopTagSelectorTagIcon=_e,T.dialogSelectorRegions=Q,T.findRegion=H,T.genElTopTagSelectorPopupOpener=Te,T.genSearcherByKey=z,T.renderElTopTagSelectorPopupOpener=Ve,T.useItemsFromCompetitors=Be,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
1
+ define(["require","exports","vue","../.chunks/forms-B3bJpLOo.amd","../.chunks/listItem.vue_vue_type_script_setup_true_lang-DLF_Qnj6.amd","../.chunks/menu.vue_vue_type_style_index_0_lang-VpwRSIdl.amd","../.chunks/utils-CTjq0RlC.amd","../utils/searchers.amd","../utils/dom.amd","../popup/worker.amd","../require/css.amd!../assets/project.css"],function(ne,T,e,x,E,oe,le,P,_,ae){"use strict";if(typeof e>"u")var e=window.Vue;const re={class:"top-selectorCompetitors"},ie={class:"top-ellipsis1"},de=e.defineComponent({__name:"selectorCompetitors",props:e.mergeModels({modelValue:{},items:{},showSelectAllItem:{type:Boolean,default:!0}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const l=n,r=e.useModel(n,"modelValue"),t=e.computed(()=>{if(l.showSelectAllItem)return{icon:"",title:x.useI18n().Common.Select_all,value:"all",content:""}});return(d,o)=>(e.openBlock(),e.createElementBlock("div",re,[e.unref(x.Core).state.isMobile?(e.openBlock(),e.createBlock(E._sfc_main,{key:0},{opener:e.withCtx(()=>[e.createVNode(x._sfc_main,{class:"top-selectorCompetitors_opener",color:"theme",icon:"",icon2:""},{default:e.withCtx(()=>{var a;return[e.createTextVNode(e.toDisplayString((a=d.items.find(s=>{var f;return s.value===((f=r.value)==null?void 0:f[0])}))==null?void 0:a.content),1)]}),_:1})]),contentList:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.items,(a,s)=>{var f;return e.openBlock(),e.createBlock(E._sfc_main$1,{class:e.normalizeClass({"top-active":(f=r.value)==null?void 0:f.includes(a.value)}),"data-top-icon":a.icon,title:a.title,onClick:()=>r.value=[a.value]},{default:e.withCtx(()=>[e.createElementVNode("span",ie,e.toDisplayString(a.content),1)]),_:2},1032,["class","data-top-icon","title","onClick"])}),256))]),_:1})):(e.openBlock(),e.createBlock(oe._sfc_main,{key:1,modelValue:r.value,"onUpdate:modelValue":o[0]||(o[0]=a=>r.value=a),items:d.items,isMultiple:!0,styling:"bar",canBeEmptyMultiple:!1,selectAllItem:t.value},null,8,["modelValue","items","selectAllItem"]))]))}}),w=-1,y=-2,L=-1,ue={0:"Yandex",1:"Google",4:"YouTube",5:"Bing",7:"Seznam",8:"AppStore",9:"GoogleStore",20:"Yandex.com",21:"Yandex.com.tr"},J={key:y,name:"--",index:y},G={key:y,name:"--",regions:[J],regionByIndex:new Map([[y,J]])},A={key:y,name:"Autoselect",index:y},U={key:y,name:"Autoselect",regions:[A],regionByIndex:new Map([[y,A]])},Y={countryCode:"00",depth:1,device:0,key:L,index:L,lang:"ru",name:"Without region"},se=()=>(A.name=x.useI18n().Common.Autoselect,A),ce=()=>(se(),U.name=x.useI18n().Common.Autoselect,console.log(U),U),ge=()=>(Y.name=x.useI18n().Keywords.Without_region,Y),z=(n=!1,l=!1,r=[])=>{let t;return n?t=me(r):t=W(r),l&&t.set(y,ce()),t.size||t.set(y,G),t},W=(n,l=!0,r=[],t=!1)=>{const d=new Map;return n.forEach(o=>{if(!o.enabled||t&&typeof o.key=="number"&&o.key>1)return;const a={...o};a.regionByIndex=new Map,o.regions&&o.regions.forEach(s=>{if(l&&!s.enabled)return;const f={...s};a.regionByIndex.set(f.index,f)}),!a.regionByIndex.size&&r.length,(!o.regions||a.regionByIndex.size||r.length)&&typeof a.key=="number"&&d.set(a.key,a)}),r.forEach(o=>{if(d.has(o))return;const a={key:o,name:ue[o],regions:[],regionByIndex:new Map};d.set(a.key,a)}),d},me=n=>{const l=W(n,!1,[0,1],!0);if(l.has(2)){const r=l.get(2);r&&(r.regionByIndex=new Map)}return l.forEach(r=>{if(!r.regionByIndex)return;const t={...ge()};r.regionByIndex.set(t.index,t)}),l},H=(n,l,r=[])=>{const t=z(n,!1,r);let d;return t.forEach(o=>{if(!(l.searcher_key!==void 0&&l.searcher_key!=o.key)&&o.regions&&(o.regions.forEach(a=>{if(!d&&!(l.key!==void 0&&l.key!=a.key)&&!(l.index!==void 0&&l.index!=a.index)&&!(!n&&(l.lang!==void 0&&l.lang!=a.lang||l.device!==void 0&&l.device!=a.device)))return a.searcher_key=o.key,d=a,!1}),d))return!1}),d},Q=le.useAsyncTopDialog(()=>new Promise((n,l)=>ne(["../.chunks/dialog_selectorRegions-D_HXNjOX.amd"],n,l))),fe=(n,l)=>{const r=x.useI18n(),t=e.ref(l.value.keys().next().value??y),d=e.computed(()=>{const o=new Map;if(l.value.forEach(a=>{let s={value:a.key,title:a.name};n.addSearcherIcon&&(s.icon=P.getSearcherGIcon(a.key)),o.set(a.key,s)}),n.addCompare&&!o.has(y)){const a={value:"",title:"--------------------",disabled:!0};o.set(a.value,a);const s={value:w,title:r.Common.Compare};o.set(s.value,s)}return o});return{searcherKey:t,optionBySearcherKey:d}},ve=(n,l)=>{var o,a,s;const r=x.useI18n(),t=e.ref(y);n.modelValue.length===1&&(t.value=n.modelValue[0]),t.value===y&&(n.forFrequency?t.value=((a=(o=l.value)==null?void 0:o.regionByIndex.values().next().value)==null?void 0:a.key)??y:t.value=((s=l.value)==null?void 0:s.regionByIndex.keys().next().value)??y);const d=e.computed(()=>{var h;const f=new Map;return(h=l.value.regionByIndex)==null||h.forEach(S=>{let i=S.name;if(n.forFrequency){const I={value:S.key,title:i};f.has(S.key)||f.set(S.key,I);return}S.device&&(i+=" ("+r.Common["Device_"+S.device]+")");const m=P.getLangLabel(l.value.key||0,S.lang??"");m&&(i+=" / "+m);const c={value:S.index,title:i,icon:S.device?P.getDeviceGIcon(S.device):void 0};f.set(S.index,c)}),f});return e.watch(d,(f,h)=>{var c;if(n.onlySearcher||t.value!==void 0&&f.get(t.value))return;let S=f.keys().next().value;if(t.value===y||S===y){t.value=S;return}let i=((c=h==null?void 0:h.get(t.value))==null?void 0:c.title)||"",m=-1;for(const[I,B]of f.entries()){const C=B.title;if(typeof C!="string"||typeof I=="string")break;if(C===i){S=I;break}const V=new RegExp(` \\((${r.Common.Device_1}|${r.Common.Device_2})\\)`);let v=i,u=3;C.indexOf(v)===-1&&(v=i.replace(/^[^a-zа-я]/i,"").replace(V,""),u--),C.indexOf(v)===-1&&(v=i.replace(/ \/.*/,""),u--),C.indexOf(v)===-1&&(v=i.replace(/ \/.*/,""),v=v.replace(/^[^a-zа-я]/i,"").replace(V,""),u--),C.indexOf(v)!==-1&&(u<=m||(m=u,S=I))}t.value=S}),{regionIndex:t,optionByRegionIndex:d}},pe=(n,l,r)=>{const t=e.ref([]),d=()=>{if(n.onlySearcher&&l.value){t.value=Array.from(l.value.keys());return}let a=[];if(n.modelValue.length>1)a=[...n.modelValue];else try{a=JSON.parse(localStorage.getItem("ui:project:regionSelector"+n.projectId+":regionsIndexes"))??[]}catch{}a.length&&(a=a.filter(s=>r.value.has(s))),a.length||(a=Array.from(r.value)),t.value=[...a]},o=()=>{t.value.length?localStorage.setItem("ui:project:regionSelector:"+n.projectId+":regionsIndexes",JSON.stringify(t.value)):localStorage.removeItem("ui:project:regionSelector:"+n.projectId+":regionsIndexes")};return e.watch(t,()=>{o()}),n.addCompare&&d(),{regionsIndexes:t}},ye=n=>{const l=e.computed(()=>z(n.forFrequency,n.autoRegion,n.searchers)),r=e.computed(()=>l.value.get(d.searcherKey.value)||G),t=e.computed(()=>{const i=new Set;return l.value.forEach(m=>{m.regionByIndex.forEach(c=>{c.index!==L&&c.index!==y&&i.add(c.index)})}),i}),d=fe(n,l),o=ve(n,r),a=pe(n,l,t);e.watch(l,()=>{var m,c,I,B;if(n.onlySearcher?a.regionsIndexes.value=Array.from(l.value.keys()):a.regionsIndexes.value=a.regionsIndexes.value.filter(C=>t.value.has(C)),d.searcherKey.value===w)return;let i=l.value.keys().next().value;l.value.forEach(C=>{var V,v,u;if(n.onlySearcher&&C.key===d.searcherKey.value){i=d.searcherKey.value;return}if(o.regionIndex.value&&((V=C.regionByIndex)!=null&&V.has(o.regionIndex.value))&&(i=C.key),!n.onlySearcher){let g;i!==void 0&&(g=(v=l.value.get(i))==null?void 0:v.regionByIndex);const p=(u=l.value.get(C.key))==null?void 0:u.regionByIndex;g!=null&&g.has(y)&&!(p!=null&&p.has(y))&&(i=C.key)}}),i!==void 0&&(d.searcherKey.value=i),o.regionIndex.value!==void 0&&!((c=(m=r.value)==null?void 0:m.regionByIndex)!=null&&c.has(o.regionIndex.value))&&(o.regionIndex.value=(B=(I=r.value)==null?void 0:I.regions)==null?void 0:B.keys().next().value)},{immediate:!0});const s=()=>{if(!(d.searcherKey.value===w||d.searcherKey.value===y))return d.searcherKey.value},f=()=>{if(n.onlySearcher||o.regionIndex.value===y)return;let i=o.regionIndex.value;if(n.forFrequency){const m=o.regionIndex.value,c=H(n.forFrequency,{searcher_key:s(),key:m},n.searchers);i=c==null?void 0:c.index}return i},h=()=>{const i=s();if(i!==void 0)return l.value.get(i)};return{selectSearcher:d,selectRegion:o,compare:a,searcherByKey:l,allRegionsIndexes:t,getSearcher:h,getRegion:()=>{var m,c;const i=f();if(i!==void 0)return(c=(m=h())==null?void 0:m.regionByIndex)==null?void 0:c.get(i)}}},he=e.defineComponent({__name:"selectorRegion",props:e.mergeModels({projectId:{},searchers:{default:()=>[]},modelValue:{},modelValueSingle:{},addCompare:{type:Boolean},forFrequency:{type:Boolean},autoRegion:{type:Boolean},onlySearcher:{type:Boolean},addChanger:{type:Boolean,default:!0},addSearcherIcon:{type:Boolean,default:!0},addRegionIcon:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{},modelValueSingle:{},modelValueSingleModifiers:{}}),emits:["update:modelValue","update:modelValueSingle"],setup(n,{expose:l}){const r=n,t=e.useModel(n,"modelValue"),d=e.useModel(n,"modelValueSingle"),{selectSearcher:o,selectRegion:a,compare:s,searcherByKey:f,allRegionsIndexes:h,getSearcher:S,getRegion:i}=ye(r),m=()=>{const c=[];f.value.forEach(I=>{I.enabled&&I.regions.forEach(B=>{B.enabled&&c.push(B)})}),Q.open("selectorRegions",{regions:c,regionsIndexes:s.regionsIndexes.value,"@update:regionsIndexes":I=>s.regionsIndexes.value=I})};return e.watch([a.regionIndex,o.searcherKey,s.regionsIndexes],()=>{if(o.searcherKey.value===w&&s.regionsIndexes.value.length){if(JSON.stringify(t.value)===JSON.stringify(s.regionsIndexes.value))return;t.value=[...s.regionsIndexes.value]}else r.onlySearcher?(t.value=[o.searcherKey.value],o.searcherKey.value===y&&!r.autoRegion&&(t.value.length=0)):(t.value=[a.regionIndex.value],a.regionIndex.value===y&&!r.autoRegion&&(t.value.length=0));!r.onlySearcher&&!h.value.size&&(o.searcherKey.value=y)}),d.value&&e.watch(d,()=>{d.value&&(t.value=[d.value])},{immediate:!0}),e.watch(t,()=>{var c,I,B,C,V;if(t.value[0]&&(d.value=t.value[0]),r.onlySearcher){if(!t.value.length||t.value.length===1&&!f.value.has(t.value[0])||t.value.length===1&&t.value[0]===y&&!r.autoRegion){let v=f.value.keys().next().value;v===y&&!r.autoRegion&&(v=void 0,d.value=y),v!==void 0?t.value=[v]:t.value.length=0;return}if(t.value.length>1&&JSON.stringify(t.value)!==JSON.stringify(s.regionsIndexes.value)){t.value=[...s.regionsIndexes.value];return}}else{let v=[...new Set(t.value)],u=(I=(c=f.value.values().next().value)==null?void 0:c.regionByIndex)==null?void 0:I.keys().next().value;if(r.forFrequency&&(u=(V=(C=(B=f.value.values().next().value)==null?void 0:B.regionByIndex)==null?void 0:C.values().next().value)==null?void 0:V.key),u===y&&!r.autoRegion&&(u=void 0,d.value=y),!v.length)u!==void 0&&v.push(u);else if(v.length===1){let g=h.value;r.forFrequency&&(g=new Set,f.value.forEach(p=>{p.regionByIndex.forEach(k=>{k.index!==L&&k.index!==y&&g.add(k.key)})})),g.has(v[0])||(v=[],u!==void 0&&v.push(u))}else v=v.filter(g=>h.value.has(g)),!v.length&&u!==void 0&&v.push(u);if(JSON.stringify(t.value)!==JSON.stringify(v)){t.value=v;return}}if(!(t.value.length===1&&t.value[0]===(r.onlySearcher?o.searcherKey.value:a.regionIndex.value)))if(r.onlySearcher){if(t.value.length===1){o.searcherKey.value=t.value[0];return}o.searcherKey.value=w;return}else{if(!t.value.length)return;if(t.value.length===1&&o.searcherKey.value!==w){a.regionIndex.value=t.value[0];let v;for(const u of f.value.values()){for(const g of u.regionByIndex.values())if((r.forFrequency?g.key:g.index)===a.regionIndex.value){v=u.key;break}if(v!==void 0)break}v!==void 0&&(o.searcherKey.value=v)}else o.searcherKey.value=w,s.regionsIndexes.value=[...t.value]}},{immediate:!0}),l({getSearcher:S,getRegion:i}),(c,I)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-selectorRegion":!0,"top-selectorRegion-onlySearcher":c.onlySearcher})},[e.createVNode(x._sfc_main$4,{options:e.unref(o).optionBySearcherKey.value,modelValue:e.unref(o).searcherKey.value,"onUpdate:modelValue":I[0]||(I[0]=B=>e.unref(o).searcherKey.value=B),name:"searcher_key",addChanger:c.addChanger},null,8,["options","modelValue","addChanger"]),!c.onlySearcher&&e.unref(o).searcherKey.value!==e.unref(w)?(e.openBlock(),e.createBlock(x._sfc_main$4,{key:0,class:"top-select-region",options:e.unref(a).optionByRegionIndex.value,modelValue:e.unref(a).regionIndex.value,"onUpdate:modelValue":I[1]||(I[1]=B=>e.unref(a).regionIndex.value=B),name:c.forFrequency?"region_key":"region_index",addChanger:c.addChanger,"data-top-icon":c.addRegionIcon?"":void 0},null,8,["options","modelValue","name","addChanger","data-top-icon"])):e.createCommentVNode("",!0),c.addCompare&&!c.onlySearcher&&e.unref(o).searcherKey.value===e.unref(w)?(e.openBlock(),e.createBlock(x._sfc_main,{key:1,name:"compare",onClick:m,"data-count-compare-regions-indexes":e.unref(s).regionsIndexes.value.length},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.$i18n.Common.Selected_regions),1)]),_:1},8,["data-count-compare-regions-indexes"])):e.createCommentVNode("",!0)],2))}}),Se=[{id:"1",name:"Without Tag",color_id:"1"},{id:"2",name:"Red",color_id:"2"},{id:"3",name:"Orange",color_id:"3"},{id:"4",name:"Yellow",color_id:"4"},{id:"5",name:"Blue",color_id:"5"},{id:"6",name:"Purple",color_id:"6"},{id:"7",name:"Green",color_id:"7"},{id:"8",name:"Magenta",color_id:"8"},{id:"9",name:"Dark blue",color_id:"9"},{id:"10",name:"Turquoise",color_id:"10"}],X=n=>"-"+n,K=n=>n[0]==="-"?n.substring(1):n,O=(n,l)=>{n=K(n);const r=l.find(t=>t.id===n);if(r)return r},ke=["data-tag_id","data-tag_color_id","title"],D=e.defineComponent({__name:"tagIcon",props:{id:{},colorId:{},name:{},state:{}},setup(n){return(l,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-tagSelector_tagIcon":!0,"top-tagSelector-active":!!l.state,"top-tagSelector-excluded":l.state==="excluded"}),"data-tag_id":l.id,"data-tag_color_id":l.colorId,title:l.name},null,10,ke))}}),Ie=["contenteditable","onKeydown"],Z=e.defineComponent({__name:"tagPopupListItem",props:e.mergeModels({editable:{type:Boolean},disabled:{type:Boolean},canExclude:{type:Boolean},id:{},colorId:{},name:{},state:{}},{name:{required:!0},nameModifiers:{}}),emits:e.mergeModels(["update:name","unselect","exclude","select"],["update:name"]),setup(n,{emit:l}){const r=n,t=l,d=e.useModel(n,"name"),o=e.ref(null),a=e.computed(()=>navigator.userAgent.indexOf("Firefox")!=-1?{contenteditable:s.value,onpaste:m=>m.preventDefault()}:{}),s=e.ref(!1),f=async()=>{var m;s.value=!0,await e.nextTick(),(m=o.value)==null||m.focus()},h=()=>{var c;const m=(c=o.value)==null?void 0:c.innerText;if(!m)return S();o.value&&(o.value.innerText=m),s.value=!1,t("update:name",m)},S=async()=>{o.value&&(o.value.innerText=r.name),s.value=!1},i=m=>{if(s.value||r.disabled)return;let c="selected";r.canExclude&&(m.ctrlKey||m.metaKey)&&(c="excluded"),r.state==c&&(c=""),c===""&&t("unselect"),c==="selected"&&t("select"),c==="excluded"&&t("exclude")};return(m,c)=>(e.openBlock(),e.createBlock(E._sfc_main$1,{class:e.normalizeClass({"top-tagSelector_tagListItem":!0,"top-tagSelector_tagListItem-inEdit":s.value,"top-tagSelector_tagListItem-disabled":m.disabled,"top-tagSelector_tagListItem-canExclude":m.canExclude,"top-tagSelector-active":!!m.state,"top-tagSelector-excluded":m.state==="excluded"}),onClick:e.withModifiers(i,["stop"])},{default:e.withCtx(()=>[e.createVNode(D,{id:m.id,name:d.value,colorId:m.colorId,state:m.state},null,8,["id","name","colorId","state"]),e.createElementVNode("span",e.mergeProps({ref_key:"elName",ref:o,class:"top-tagSelector_tagListItemName",contenteditable:s.value?"plaintext-only":!1},a.value,{onKeydown:[e.withKeys(e.withModifiers(h,["stop"]),["enter"]),e.withKeys(e.withModifiers(S,["stop"]),["esc"])]}),e.toDisplayString(d.value),17,Ie),m.editable?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[s.value?(e.openBlock(),e.createElementBlock("span",{key:1,"data-top-icon":"",class:"top-tagSelector_edit",onClick:e.withModifiers(h,["stop"])})):(e.openBlock(),e.createElementBlock("span",{key:0,"data-top-icon":"",class:"top-tagSelector_edit",onClick:f}))],64)):e.createCommentVNode("",!0)]),_:1},8,["class"]))}}),xe={key:1},ee=e.defineComponent({inheritAttrs:!1,__name:"popupOpener",props:e.mergeModels({modelValue:{},id:{},tags:{},mode:{},targetId:{},filters:{},useTopButton:{type:Boolean},payload:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const l=n,r=e.useModel(n,"modelValue"),t=l.useTopButton?x._sfc_main:"div",d=l.useTopButton?"html":"default",o={model:r,mode:l.mode,targetId:l.targetId,filters:l.filters,payload:l.payload};return(a,s)=>{const f=e.resolveDirective("top-data");return e.openBlock(),e.createBlock(E._sfc_main$2,{id:a.id},{default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(t)),e.mergeProps({class:{"top-tagSelector":!0,"top-tagSelector-filter":l.mode==="filter","top-tagSelector-setter_single":l.mode==="setter"&&!a.filters,"top-tagSelector-setter_several":l.mode==="setter"&&a.filters,"top-tagSelector-selectedOne":!r.value.length||r.value.length===1,"top-tagSelector-toTwoLine":r.value.length>5},color:"theme",styling:""},a.$attrs),{[e.unref(d)]:e.withCtx(()=>[!r.value.length&&a.mode==="filter"?(e.openBlock(),e.createBlock(D,{key:0,id:"all",colorId:"",name:a.$i18n.Common.All_tags??"",state:""},null,8,["name"])):e.createCommentVNode("",!0),a.mode==="setter"&&a.filters?(e.openBlock(),e.createElementBlock("div",xe,[e.renderSlot(a.$slots,"default")])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(r.value,h=>{var S,i;return e.openBlock(),e.createBlock(D,{id:e.unref(K)(h),colorId:((S=e.unref(O)(h,a.tags))==null?void 0:S.color_id)??"",name:((i=e.unref(O)(h,a.tags))==null?void 0:i.name)??"",state:e.unref(K)(h)===h?"selected":"excluded"},null,8,["id","colorId","name","state"])}),256))]),_:2},1040,["class"])),[[f,o,"topTagSelectorTarget"]])]),_:3},8,["id"])}}}),Ce=e.defineComponent({__name:"tagSelector",props:e.mergeModels({modelValue:{},tags:{},tagsEditable:{type:Boolean},tagsMax:{default:10},id:{},singleMode:{type:Boolean},requiredForSetter:{type:Boolean,default:!0},maxTagsForSetter:{},emitDelay:{default:500}},{modelValue:{required:!0},modelModifiers:{},tags:{default:e.reactive(Se)},tagsModifiers:{}}),emits:e.mergeModels(["selector","setter","tagsChanged"],["update:modelValue","update:tags"]),setup(n,{emit:l}){const r=x.useI18n(),t=n,d=e.useModel(n,"modelValue"),o=e.useModel(n,"tags"),a=l,s=x.debounce((u,g)=>{a(u,g)},t.emitDelay);t.singleMode&&!d.value.length&&(d.value=[o.value[0].id]);const f=t.id??"top-popup-id-"+Math.random(),h=e.ref("add"),S=()=>{var p;const u=" "+((p=r.Common.Tags)==null?void 0:p.toLowerCase()),g=new Map;return g.set("add",{value:"add",title:r.Common.Add+u}),g.set("replace",{value:"replace",title:r.Common.Replace+u}),g.set("delete",{value:"delete",title:r.Common.Delete+u}),g};let i=e.shallowRef({model:d,mode:"filter",targetId:void 0,filters:void 0,payload:void 0});e.watch(d,()=>{s("selector",d.value)});const m=e.computed(()=>{if(i.value.mode==="setter"&&t.maxTagsForSetter&&!i.value.filters)return i.value.model.value.length>=t.maxTagsForSetter}),c=u=>{if(u!=="all"){if(i.value.model.value.includes(u))return"selected";if(i.value.model.value.includes(X(u)))return"excluded"}return u==="all"&&!i.value.model.value.length?"selected":""},I=(u,g)=>{const p=X(u);let k=i.value.model.value.filter(M=>M!==u&&M!==p);g==="select"&&k.push(u),g==="exclude"&&k.push(p),i.value.mode==="setter"&&i.value.targetId!==void 0&&t.requiredForSetter&&(k.length||k.push("1"),k.length===2&&i.value.model.value.length===1&&i.value.model.value[0]==="1"&&(k=k.filter(M=>M!=="1"))),t.singleMode&&!i.value.filters&&(k.length||(k=i.value.model.value),k.length>1&&(k=[k[k.length-1]])),k.sort((M,N)=>{if(!t.tags)return 0;const q=t.tags.findIndex(b=>b.id===M),R=t.tags.findIndex(b=>b.id===N);return q-R}),i.value.model.value=k,i.value.mode==="setter"&&i.value.targetId!==void 0&&s("setter",{tagsIds:k,targetId:i.value.targetId,payload:i.value.payload})},B=e.computed(()=>{let u="top-tagSelector_popup";return i.value.mode==="filter"&&(u+=" top-tagSelector_popup-filter"),i.value.mode==="setter"&&(u+=" top-tagSelector_popup-setter"),u}),C=()=>{const u=prompt("","New tag");if(!u||u==="New tag")return;const g=o.value.length+1;o.value.push({id:String(g),name:u,color_id:String((g-1)%10+1)}),a("tagsChanged",o.value)},V=u=>{var g;if(i.value=_.storage(u.elPopupOpener,"topTagSelectorTarget"),!i.value)throw new Error("Open popup TopTagSelector required v-data:topTagSelectorTarget");if(i.value.filters&&(h.value="add",i.value.model.value=[]),!((g=x.Core.$)!=null&&g.ui.sortable)){console.info("Для работы сортировки требуется глобальная загрузка jQuery UI Sortable");return}!x.Core.state.isMobile&&!x.Core.state.isMobileUA&&o.value&&$(u.elPopup).sortable({items:'li:has([data-tag_id]:not([data-tag_id="all"]))',cancel:'[contenteditable="plaintext-only"], [contenteditable="true"]',distance:10,stop:function(p,k){if(!o.value)return;const M=$(k.item).parent().find("[data-tag_id]"),N=[];M.each((q,R)=>{if(!o.value)return;const b=$(R).attr("data-tag_id");N.push(b)}),o.value.sort((q,R)=>{const b=N.findIndex(j=>j===q.id),Ke=N.findIndex(j=>j===R.id);return b-Ke}),s("tagsChanged",o.value)}})},v=u=>{var g;(g=x.Core.$)!=null&&g.ui.sortable&&$(u.elPopup).data("ui-sortable")&&$(u.elPopup).sortable("destroy")};return(u,g)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(ee,{class:"top-select_arrow",modelValue:d.value,"onUpdate:modelValue":g[0]||(g[0]=p=>d.value=p),id:e.unref(f),tags:o.value,mode:"filter",useTopButton:""},null,8,["modelValue","id","tags"]),e.createVNode(E._sfc_main,{id:e.unref(f),class:e.normalizeClass(B.value),onOpen:g[4]||(g[4]=p=>V(p)),onClose:g[5]||(g[5]=p=>v(p)),"transition-duration":50},e.createSlots({contentList:e.withCtx(()=>[e.unref(i).mode==="filter"&&!u.singleMode?(e.openBlock(),e.createBlock(Z,{key:0,id:"all",colorId:"",name:u.$i18n.Common.All_tags??"",state:e.unref(i).model.value.length?"":"selected",onSelect:g[3]||(g[3]=p=>e.unref(i).model.value=[])},null,8,["name","state"])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,p=>(e.openBlock(),e.createBlock(Z,{key:p.id,id:p.id,colorId:p.color_id,name:p.name,state:c(p.id),canExclude:e.unref(i).mode==="filter"&&!u.singleMode,editable:u.tagsEditable,disabled:m.value&&c(p.id)==="",onUnselect:k=>I(p.id,"unselect"),onSelect:k=>I(p.id,"select"),onExclude:k=>I(p.id,"exclude"),"onUpdate:name":k=>{p.name=k,e.unref(s)("tagsChanged",o.value)}},null,8,["id","colorId","name","state","canExclude","editable","disabled","onUnselect","onSelect","onExclude","onUpdate:name"]))),128)),u.tagsEditable&&o.value.length<u.tagsMax&&o.value.length<20?(e.openBlock(),e.createBlock(E._sfc_main$1,{key:1,"data-top-icon":"",onClick:e.withModifiers(C,["stop"])},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.$i18n.Common.Add),1)]),_:1})):e.createCommentVNode("",!0)]),_:2},[e.unref(i).mode==="setter"&&e.unref(i).filters?{name:"header",fn:e.withCtx(()=>[e.createVNode(x._sfc_main$4,{modelValue:h.value,"onUpdate:modelValue":g[1]||(g[1]=p=>h.value=p),options:S()},null,8,["modelValue","options"])]),key:"0"}:void 0,e.unref(i).mode==="setter"&&e.unref(i).filters?{name:"footer",fn:e.withCtx(()=>[e.createVNode(x._sfc_main,{color:"theme"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.$i18n.Common.Cancel),1)]),_:1}),e.createVNode(x._sfc_main,{onClick:g[2]||(g[2]=p=>e.unref(s)("setter",{tagsIds:e.unref(i).model.value,filters:e.unref(i).filters,filtersAction:h.value,payload:e.unref(i).payload}))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.value==="add"?u.$i18n.Common.Add:"")+" "+e.toDisplayString(h.value==="replace"?u.$i18n.Common.Replace:"")+" "+e.toDisplayString(h.value==="delete"?u.$i18n.Common.Remove:""),1)]),_:1})]),key:"1"}:void 0]),1032,["id","class"])],64))}}),Be=(n,l)=>e.computed(()=>e.toValue(n).filter(d=>d.on>=0||d.id===l).map(d=>({value:d.id,title:d.url+` [${d.id}]`,icon:d.id===e.toValue(l)?"":"",content:d.name}))),Te=(n,l,r)=>{l||(l={id:n.id}),l.id=n.id;const t=ae.TopPopupWorker.genElPopupOpener("div",l);return t.classList.add("top-tagSelector"),n.useTopButton&&t.classList.add("top-button","top-color_theme"),n.mode==="filter"&&t.classList.add("top-tagSelector-filter"),n.mode==="setter"&&!n.filters&&t.classList.add("top-tagSelector-setter_single"),n.mode==="setter"&&n.filters&&t.classList.add("top-tagSelector-setter_several"),t.onclick=d=>{d.preventDefault(),d.stopPropagation(),t.onclick=null;const o=e.ref(n.modelValue),a={model:o,mode:n.mode,targetId:n.targetId,filters:n.filters,payload:n.payload};_.storage(t,"topTagSelectorTarget",a),delete t.dataset.topPopupDisabled,e.isRef(n.modelValue)||e.watch(o,()=>{n.modelValue=o.value,F(t,n,r)}),t.click()},e.isRef(n.modelValue)?e.watch(n.modelValue,()=>F(t,n,r)):_.storage(t,"topTagSelectorRender",d=>{n.modelValue=d;const o=_.storage(t,"topTagSelectorTarget");o&&(o.model.value=d),F(t,n,r)}),F(t,n,r),t},Ve=(n,l)=>{var r;(r=_.storage(n,"topTagSelectorRender"))==null||r(l)},F=(n,l,r)=>{var d;const t=e.unref(l.modelValue);if(n.classList.toggle("top-tagSelector-selectedOne",!t.length||t.length===1),n.classList.toggle("top-tagSelector-toTwoLine",t.length>5),l.mode==="setter"&&l.filters){n.innerHTML=`<div>${r}</div>`;return}if(n.innerHTML="",!t.length&&l.mode==="filter"){const o=te({id:"all",colorId:"",name:((d=x.useI18n().Common)==null?void 0:d.All_tags)??"",state:""});n.append(o)}t.forEach(o=>{var s,f;const a=te({id:K(o),colorId:((s=O(o,l.tags))==null?void 0:s.color_id)??"",name:((f=O(o,l.tags))==null?void 0:f.name)??"",state:K(o)===o?"selected":"excluded"});n.append(a)})},te=n=>{const l=document.createElement("div");return l.classList.add("top-tagSelector_tagIcon"),l.classList.toggle("top-tagSelector-active",!!n.state),l.classList.toggle("top-tagSelector-excluded",n.state==="excluded"),l.dataset.tag_id=n.id,l.dataset.tag_color_id=n.colorId,l.title=n.name,l},we=de,Me=he,be=Ce,Ee=ee,_e=D;T.TopSelectorCompetitors=we,T.TopSelectorRegion=Me,T.TopTagSelector=be,T.TopTagSelectorPopupOpener=Ee,T.TopTagSelectorTagIcon=_e,T.dialogSelectorRegions=Q,T.findRegion=H,T.genElTopTagSelectorPopupOpener=Te,T.genSearcherByKey=z,T.renderElTopTagSelectorPopupOpener=Ve,T.useItemsFromCompetitors=Be,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=project.amd.js.map