@topvisor/ui 1.3.3-piniaTPAPluginClearHash.0 → 1.3.4-0

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 (75) hide show
  1. package/.chunks/{core-BrkcXLtM.es.js → core-PgN-H_aP.es.js} +4 -4
  2. package/.chunks/{core-BrkcXLtM.es.js.map → core-PgN-H_aP.es.js.map} +1 -1
  3. package/.chunks/{datepicker-Dfl91fRZ.es.js → datepicker-lHzfJ7vE.es.js} +2 -2
  4. package/.chunks/{datepicker-Dfl91fRZ.es.js.map → datepicker-lHzfJ7vE.es.js.map} +1 -1
  5. package/.chunks/{dialog_selectorRegions-QbGG0L91.es.js → dialog_selectorRegions-Ccsrpo2C.es.js} +55 -53
  6. package/.chunks/{dialog_selectorRegions-QbGG0L91.es.js.map → dialog_selectorRegions-Ccsrpo2C.es.js.map} +1 -1
  7. package/.chunks/{dialogs.vue_vue_type_script_setup_true_lang-8LLCo4IK.es.js → dialogs.vue_vue_type_script_setup_true_lang-Bei7eCOi.es.js} +2 -2
  8. package/.chunks/{dialogs.vue_vue_type_script_setup_true_lang-8LLCo4IK.es.js.map → dialogs.vue_vue_type_script_setup_true_lang-Bei7eCOi.es.js.map} +1 -1
  9. package/.chunks/{forms-BWoAyEVH.es.js → forms-CuEEAPvm.es.js} +5 -5
  10. package/.chunks/{forms-BWoAyEVH.es.js.map → forms-CuEEAPvm.es.js.map} +1 -1
  11. package/.chunks/listItem.vue_vue_type_script_setup_true_lang-_3WmLmPV.es.js +186 -0
  12. package/.chunks/{listItem.vue_vue_type_script_setup_true_lang-Dljef_xa.es.js.map → listItem.vue_vue_type_script_setup_true_lang-_3WmLmPV.es.js.map} +1 -1
  13. package/.chunks/{menu.vue_vue_type_style_index_0_lang-HDPVVgzy.es.js → menu.vue_vue_type_style_index_0_lang-Ct0tivnh.es.js} +35 -33
  14. package/.chunks/{menu.vue_vue_type_style_index_0_lang-HDPVVgzy.es.js.map → menu.vue_vue_type_style_index_0_lang-Ct0tivnh.es.js.map} +1 -1
  15. package/.chunks/notice-Aw2dLsyE.es.js +194 -0
  16. package/.chunks/{notice-DYd206Yd.es.js.map → notice-Aw2dLsyE.es.js.map} +1 -1
  17. package/.chunks/{page.vue_vue_type_script_setup_true_lang-B26E2LsY.es.js → page.vue_vue_type_script_setup_true_lang-x02Y0eiE.es.js} +4 -4
  18. package/.chunks/{page.vue_vue_type_script_setup_true_lang-B26E2LsY.es.js.map → page.vue_vue_type_script_setup_true_lang-x02Y0eiE.es.js.map} +1 -1
  19. package/.chunks/{popup-1pqtx_O5.es.js → popup-axQQEyIk.es.js} +2 -2
  20. package/.chunks/{popup-1pqtx_O5.es.js.map → popup-axQQEyIk.es.js.map} +1 -1
  21. package/.chunks/popupHint.vue_vue_type_style_index_0_lang-Cce9ZdtW.amd.js +2 -0
  22. package/.chunks/popupHint.vue_vue_type_style_index_0_lang-Cce9ZdtW.amd.js.map +1 -0
  23. package/.chunks/{utils-Dk7uXZsi.es.js → utils-BHW-ownM.es.js} +2 -2
  24. package/.chunks/{utils-Dk7uXZsi.es.js.map → utils-BHW-ownM.es.js.map} +1 -1
  25. package/.chunks/{utils-C_yz4vdX.es.js → utils-D1fvioEG.es.js} +3 -3
  26. package/.chunks/{utils-C_yz4vdX.es.js.map → utils-D1fvioEG.es.js.map} +1 -1
  27. package/.chunks/{widgetInput.vue_vue_type_script_setup_true_lang-Cr_jgOW4.es.js → widgetInput.vue_vue_type_script_setup_true_lang-IWJIVl4_.es.js} +2 -2
  28. package/.chunks/{widgetInput.vue_vue_type_script_setup_true_lang-Cr_jgOW4.es.js.map → widgetInput.vue_vue_type_script_setup_true_lang-IWJIVl4_.es.js.map} +1 -1
  29. package/assets/project.css +1 -1
  30. package/charts/charts.js +62 -60
  31. package/charts/charts.js.map +1 -1
  32. package/core/app.amd.js +1 -1
  33. package/core/app.amd.js.map +1 -1
  34. package/core/app.js +26 -26
  35. package/core/app.js.map +1 -1
  36. package/dialog/dialog.js +2 -2
  37. package/extra/extra.js +22 -20
  38. package/extra/extra.js.map +1 -1
  39. package/forms/forms.js +1 -1
  40. package/formsExt/formsExt.amd.js +1 -1
  41. package/formsExt/formsExt.amd.js.map +1 -1
  42. package/formsExt/formsExt.js +115 -113
  43. package/formsExt/formsExt.js.map +1 -1
  44. package/layout/layout.js +37 -35
  45. package/layout/layout.js.map +1 -1
  46. package/package.json +1 -1
  47. package/popup/popup.amd.js +1 -1
  48. package/popup/popup.amd.js.map +1 -1
  49. package/popup/popup.js +9 -4
  50. package/popup/worker.js +2 -2
  51. package/project/project.amd.js +1 -1
  52. package/project/project.amd.js.map +1 -1
  53. package/project/project.js +253 -248
  54. package/project/project.js.map +1 -1
  55. package/src/components/project/tagSelector/popupOpener/types.d.ts +6 -3
  56. package/src/components/project/tagSelector/tagSelector.vue.d.ts +1 -0
  57. package/src/components/project/tagSelector/types.d.ts +9 -2
  58. package/src/components/project/tagSelector/utils/el.d.ts +3 -3
  59. package/tabs/tabs.js +28 -26
  60. package/tabs/tabs.js.map +1 -1
  61. package/tabsView/tabsView.amd.js +1 -1
  62. package/tabsView/tabsView.amd.js.map +1 -1
  63. package/tabsView/tabsView.js +67 -65
  64. package/tabsView/tabsView.js.map +1 -1
  65. package/utils/clipboard.js +1 -1
  66. package/utils/date.js +1 -1
  67. package/utils/device.js +1 -1
  68. package/utils/lodash.js +1 -1
  69. package/utils/price.js +1 -1
  70. package/utils/searchers.js +3 -3
  71. package/utils/string.js +1 -1
  72. package/.chunks/listItem.vue_vue_type_script_setup_true_lang-Dljef_xa.es.js +0 -184
  73. package/.chunks/notice-DYd206Yd.es.js +0 -192
  74. package/.chunks/popupHint.vue_vue_type_style_index_0_lang-BCpRWeKK.amd.js +0 -2
  75. package/.chunks/popupHint.vue_vue_type_style_index_0_lang-BCpRWeKK.amd.js.map +0 -1
package/core/app.amd.js CHANGED
@@ -1,2 +1,2 @@
1
- define(["require","exports","../.chunks/forms-BfDSGwrU.amd","../.chunks/core-BU_5Yi6z.amd","vue","../utils/clipboard.amd","../utils/string.amd","../utils/route.amd","../.chunks/utils-C9dKr-gR.amd","../.chunks/dialogs.vue_vue_type_script_setup_true_lang-CTzGS920.amd"],(function(y,n,c,f,d,m,S,u,g,k){"use strict";if(typeof d>"u")var d=window.Vue;class E{#s;#t;#e;#i;#c;#a=[];#o=[];#n=[];#r=[];constructor(s){var t;this.#t=s.store,this.#s=this.#t.$id,this.#e=s.options.Page,this.#i=s.options.user,this.#c=s.options.Api,this.#a=s.options.tpaNamesUrlHash||[],this.#o=s.options.tpaNamesStorage||[],this.#n=s.options.tpaNamesStorageLocal||[],this.#r=s.options.tpaNamesGuestLink||[],s.store.genGuestLink=(i,a)=>this.genGuestLink(i,a),(t=this.#i.guest_data)!=null&&t.data||(this.#u(),this.#u(!0),this.#f()),this.#S(),this.#k();const e=c.debounce(()=>{this.#t.hasOwnProperty("_isMounted")&&!this.#t._isMounted?u.delHash(this.#t.$id):this.#m(),this.#p(),this.#p(!0)});s.store.$subscribe(e)}async genGuestLink(s,e){const t=this.#g();e=Object.assign(e,Object.fromEntries(t));const i=await this.#c.gen(s).setParams(e).call();if(i!=null&&i.errors)return;const a=i.result;await m.guestLinkToClipboard(a)}#g(){const s=new Map;return this.#r.forEach(e=>{const t=S.camelToSnakeCase(e);s.set(t,this.#t[e])}),s}#h(s){s.forEach((e,t)=>{const i=this.#t[t];if(e!=null&&i!==void 0&&e!=null&&e.constructor&&e.constructor===i.constructor){if(t.indexOf("date")===0&&!Array.isArray(e)){if(typeof e=="string"&&!/\d\d\d\d-\d\d-\d\d/.test(e))return}this.#t[t]=e}})}#l(s){const e=new Map;return s.forEach((t,i)=>{t!==null&&(t=JSON.stringify(t),e.set(i,t))}),e}#d(s){const e=new Map;return s.forEach((t,i)=>{if(!(t==null||t==="false")){try{if(typeof t=="string"&&!/^\d\d\d\d-\d\d-\d\d$/.test(t)&&(t=JSON.parse(t)),t==null||t==="false")return}catch{}e.set(i,t)}}),e}#f(){let s;try{s=JSON.parse(u.getHash(this.#s))}catch{}if(!s)return;const e=new Map;this.#a.forEach(t=>{const i=s[t];i&&e.set(t,i)}),this.#h(e)}#m(){const s=new Map;this.#a.forEach(i=>{const a=this.#t[i];s.set(i,a)});const e=Object.fromEntries(s),t=JSON.stringify(e);u.setHash(this.#s,t)}#u(s=!1){const e=new Map;let t=this.#o,i="state:"+this.#s;s&&(t=this.#n,i="state:"+this.#s+":"+location.pathname),t.forEach(o=>{const r=localStorage.getItem(i+":"+o);e.set(o,r)});const a=this.#d(e);this.#h(a)}#p(s=!1){const e=new Map;let t=this.#o,i="state:"+this.#s;s&&(t=this.#n,i="state:"+this.#s+":"+location.pathname),t.forEach(o=>{const r=this.#t[o];e.set(o,r)});const a=this.#l(e);t.forEach(o=>{const r=a.get(o);localStorage.setItem(i+":"+o,r)})}#S(){var a,o,r;const s=(o=(a=this.#i)==null?void 0:a.guest_data)==null?void 0:o.data;if(!s)return;this.#i.id===-1&&(this.#i.positionsReverseDates=s.positionsReverseDates);const e=new Map;this.#r.forEach(h=>{const p=s[h];e.set(h,p)});const t=this.#d(e);this.#h(t);const i=$(".mod_guest_title");if(((r=this.#t.competitorsIds)==null?void 0:r.length)===1&&this.#e.page.data.competitors){let h=this.#e.page.data.competitors.filter(p=>p.id===s.competitorsIds[0]);h.length&&($("a",i).attr("href","http://"+h[0].url),$("a",i).text(h[0].name))}}#k(){this.#t.regionsIndexes&&d.watch(this.#t.regionsIndexes,s=>{if(!s.length)return;s.forEach((i,a)=>s[a]=i);const e=TplProjectSelectorRegion.genSearchersMap(),t=[];e.forEach(i=>{i.regions.forEach(a=>{a.index!==-1&&t.push(a.index)})}),this.#t.regionsIndexes=s.filter(i=>t.includes(i))},{immediate:!0}),this.#t.competitorsIds&&d.watch(this.#t.competitorsIds,s=>{if(!s.length)return;s.forEach((t,i)=>s[i]=t);const e=[this.#e.page.data.project.id];this.#e.page.data.project.competitors.forEach(t=>{t.on>=0&&e.push(t.id)}),this.#t.competitorsIds=s.filter(t=>e.includes(t))},{immediate:!0})}}const w=l=>{var e,t,i,a;const s=l;!((e=s.options.tpaNamesUrlHash)!=null&&e.length)&&!((t=s.options.tpaNamesStorage)!=null&&t.length)&&!((i=s.options.tpaNamesStorageLocal)!=null&&i.length)&&!((a=s.options.tpaNamesGuestLink)!=null&&a.length)||new E(s)};n.Core=c.Core,n.i18nPlugin=c.i18n,n.useI18n=c.useI18n,n.useI18nLang=c.useI18nLang,n.corePlugin=f.core,n.useAsyncTopDialog=g.useAsyncTopDialog,n.useTopDialog=g.useTopDialog,n.TopDialogWorker=k.TopDialogWorker,n.piniaTPAPlugin=w,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
1
+ define(["require","exports","../.chunks/forms-BfDSGwrU.amd","../.chunks/core-BU_5Yi6z.amd","vue","../utils/clipboard.amd","../utils/string.amd","../utils/route.amd","../.chunks/utils-C9dKr-gR.amd","../.chunks/dialogs.vue_vue_type_script_setup_true_lang-CTzGS920.amd"],(function(y,n,c,f,d,m,S,g,p,k){"use strict";if(typeof d>"u")var d=window.Vue;class E{#s;#t;#e;#i;#c;#a=[];#o=[];#n=[];#r=[];constructor(s){var t;this.#t=s.store,this.#s=this.#t.$id,this.#e=s.options.Page,this.#i=s.options.user,this.#c=s.options.Api,this.#a=s.options.tpaNamesUrlHash||[],this.#o=s.options.tpaNamesStorage||[],this.#n=s.options.tpaNamesStorageLocal||[],this.#r=s.options.tpaNamesGuestLink||[],s.store.genGuestLink=(i,a)=>this.genGuestLink(i,a),(t=this.#i.guest_data)!=null&&t.data||(this.#u(),this.#u(!0),this.#f()),this.#S(),this.#k();const e=c.debounce(()=>{this.#m(),this.#g(),this.#g(!0)});s.store.$subscribe(e)}async genGuestLink(s,e){const t=this.#p();e=Object.assign(e,Object.fromEntries(t));const i=await this.#c.gen(s).setParams(e).call();if(i!=null&&i.errors)return;const a=i.result;await m.guestLinkToClipboard(a)}#p(){const s=new Map;return this.#r.forEach(e=>{const t=S.camelToSnakeCase(e);s.set(t,this.#t[e])}),s}#h(s){s.forEach((e,t)=>{const i=this.#t[t];if(e!=null&&i!==void 0&&e!=null&&e.constructor&&e.constructor===i.constructor){if(t.indexOf("date")===0&&!Array.isArray(e)){if(typeof e=="string"&&!/\d\d\d\d-\d\d-\d\d/.test(e))return}this.#t[t]=e}})}#l(s){const e=new Map;return s.forEach((t,i)=>{t!==null&&(t=JSON.stringify(t),e.set(i,t))}),e}#d(s){const e=new Map;return s.forEach((t,i)=>{if(!(t==null||t==="false")){try{if(typeof t=="string"&&!/^\d\d\d\d-\d\d-\d\d$/.test(t)&&(t=JSON.parse(t)),t==null||t==="false")return}catch{}e.set(i,t)}}),e}#f(){let s;try{s=JSON.parse(g.getHash(this.#s))}catch{}if(!s)return;const e=new Map;this.#a.forEach(t=>{const i=s[t];i&&e.set(t,i)}),this.#h(e)}#m(){const s=new Map;this.#a.forEach(i=>{const a=this.#t[i];s.set(i,a)});const e=Object.fromEntries(s),t=JSON.stringify(e);g.setHash(this.#s,t)}#u(s=!1){const e=new Map;let t=this.#o,i="state:"+this.#s;s&&(t=this.#n,i="state:"+this.#s+":"+location.pathname),t.forEach(o=>{const r=localStorage.getItem(i+":"+o);e.set(o,r)});const a=this.#d(e);this.#h(a)}#g(s=!1){const e=new Map;let t=this.#o,i="state:"+this.#s;s&&(t=this.#n,i="state:"+this.#s+":"+location.pathname),t.forEach(o=>{const r=this.#t[o];e.set(o,r)});const a=this.#l(e);t.forEach(o=>{const r=a.get(o);localStorage.setItem(i+":"+o,r)})}#S(){var a,o,r;const s=(o=(a=this.#i)==null?void 0:a.guest_data)==null?void 0:o.data;if(!s)return;this.#i.id===-1&&(this.#i.positionsReverseDates=s.positionsReverseDates);const e=new Map;this.#r.forEach(h=>{const u=s[h];e.set(h,u)});const t=this.#d(e);this.#h(t);const i=$(".mod_guest_title");if(((r=this.#t.competitorsIds)==null?void 0:r.length)===1&&this.#e.page.data.competitors){let h=this.#e.page.data.competitors.filter(u=>u.id===s.competitorsIds[0]);h.length&&($("a",i).attr("href","http://"+h[0].url),$("a",i).text(h[0].name))}}#k(){this.#t.regionsIndexes&&d.watch(this.#t.regionsIndexes,s=>{if(!s.length)return;s.forEach((i,a)=>s[a]=i);const e=TplProjectSelectorRegion.genSearchersMap(),t=[];e.forEach(i=>{i.regions.forEach(a=>{a.index!==-1&&t.push(a.index)})}),this.#t.regionsIndexes=s.filter(i=>t.includes(i))},{immediate:!0}),this.#t.competitorsIds&&d.watch(this.#t.competitorsIds,s=>{if(!s.length)return;s.forEach((t,i)=>s[i]=t);const e=[this.#e.page.data.project.id];this.#e.page.data.project.competitors.forEach(t=>{t.on>=0&&e.push(t.id)}),this.#t.competitorsIds=s.filter(t=>e.includes(t))},{immediate:!0})}}const w=l=>{var e,t,i,a;const s=l;!((e=s.options.tpaNamesUrlHash)!=null&&e.length)&&!((t=s.options.tpaNamesStorage)!=null&&t.length)&&!((i=s.options.tpaNamesStorageLocal)!=null&&i.length)&&!((a=s.options.tpaNamesGuestLink)!=null&&a.length)||new E(s)};n.Core=c.Core,n.i18nPlugin=c.i18n,n.useI18n=c.useI18n,n.useI18nLang=c.useI18nLang,n.corePlugin=f.core,n.useAsyncTopDialog=p.useAsyncTopDialog,n.useTopDialog=p.useTopDialog,n.TopDialogWorker=k.TopDialogWorker,n.piniaTPAPlugin=w,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
2
2
  //# sourceMappingURL=app.amd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.amd.js","sources":["../../src/core/plugins/piniaTPA.ts"],"sourcesContent":["import type { PiniaPluginContext, Store } from 'pinia';\nimport { watch } from 'vue';\nimport { debounce } from '@/core/utils/lodash';\nimport { guestLinkToClipboard } from '@/core/utils/clipboard';\nimport { camelToSnakeCase } from '@/core/utils/string.js';\nimport { getHash, setHash, delHash } from '@/core/utils/route';\n\nclass PiniaTPA {\n\n\treadonly #storeId: string;\n\treadonly #store: Store<string, any>;\n\n\t/**\n\t * @deprecated\n\t */\n\treadonly #Page: any;\n\n\treadonly #user: any;\n\treadonly #Api: Api.Client<Api.TV.Paths, true>;\n\n\treadonly #namesUrlHash: string[] = [];\n\treadonly #namesStorage: string[] = [];\n\treadonly #namesStorageLocal: string[] = [];\n\treadonly #namesGuestLink: string[] = [];\n\n\tconstructor(context: Context) {\n\t\tthis.#store = context.store;\n\t\tthis.#storeId = this.#store.$id;\n\n\t\tthis.#Page = context.options.Page;\n\n\t\tthis.#user = context.options.user;\n\t\tthis.#Api = context.options.Api;\n\n\t\tthis.#namesUrlHash = context.options.tpaNamesUrlHash || [];\n\t\tthis.#namesStorage = context.options.tpaNamesStorage || [];\n\t\tthis.#namesStorageLocal = context.options.tpaNamesStorageLocal || [];\n\t\tthis.#namesGuestLink = context.options.tpaNamesGuestLink || [];\n\n\t\tcontext.store.genGuestLink = <Path extends Api.TV.Path>(path: Path, params: Api.TV.Params<Path>) => this.genGuestLink(path, params);\n\n\t\tif (!this.#user.guest_data?.data) {\n\t\t\tthis.#loadFromStorage();\n\t\t\tthis.#loadFromStorage(true);\n\n\t\t\t// настройки URL hash имеют приоритет\n\t\t\tthis.#loadFromHash();\n\t\t}\n\n\t\t// настройки гостевой ссылки имеют приоритет\n\t\tthis.#loadFromGuestLink();\n\n\t\tthis.#prepareParams();\n\n\t\tconst save = debounce(() => {\n\t\t\tif (this.#store.hasOwnProperty('_isMounted') && !this.#store._isMounted) {\n\t\t\t\tdelHash(this.#store.$id, '');\n\t\t\t} else {\n\t\t\t\tthis.#saveInHash();\n\t\t\t}\n\n\t\t\tthis.#saveInStorage();\n\t\t\tthis.#saveInStorage(true);\n\t\t});\n\n\t\tcontext.store.$subscribe(save);\n\t}\n\n\t/**\n\t * Сгенерировать гостевую ссылку\n\t *\n\t * Метод, путь к которому указан в path, должен возвращать сгенерированную ссылку\n\t */\n\tasync genGuestLink<Path extends Api.TV.Path>(path: Path, params: Api.TV.Params<Path>) {\n\t\tconst dataGuestLink = this.#genOptionsForGuestLink();\n\t\tparams = Object.assign(params, Object.fromEntries(dataGuestLink));\n\n\t\tconst res = await this.#Api.gen(path).setParams(params).call();\n\t\tif (res?.errors) return;\n\n\t\tconst link = res.result as string;\n\n\t\tawait guestLinkToClipboard(link);\n\t}\n\n\t/**\n\t * Сгенерировать опции для гостевой ссылки\n\t */\n\t#genOptionsForGuestLink() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesGuestLink.forEach(name => {\n\t\t\t// формат параметров API: snake_case\n\t\t\tconst nameSnakeCase = camelToSnakeCase(name);\n\t\t\tdata.set(nameSnakeCase, this.#store[name]);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из объекта без фиксации состояния\n\t */\n\t#setOptions(data: Map<string, any>) {\n\t\tdata.forEach((value, name) => {\n\t\t\tconst currentValue = this.#store[name];\n\n\t\t\tif (value === null || value === undefined) return;\n\t\t\tif (currentValue === undefined) return;\n\t\t\tif (!value?.constructor) return;\n\t\t\tif (value.constructor !== currentValue.constructor) return;\n\n\t\t\t// дополнительная проверка на формат даты\n\t\t\tif (name.indexOf('date') === 0) {\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t// value.forEach((valueI) => {\n\t\t\t\t\t// \tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(valueI)) return;\n\t\t\t\t\t// });\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof (value) === 'string') {\n\t\t\t\t\t\tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(value)) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.#store[name] = value;\n\t\t});\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в виде json строк\n\t */\n\t#genDataFormat(data: Map<string, any>) {\n\t\tconst dataFormatted = new Map();\n\n\t\tdata.forEach((value, name) => {\n\t\t\tif (value === null) return;\n\n\t\t\tvalue = JSON.stringify(value);\n\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\treturn dataFormatted;\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в оригинальном виде\n\t */\n\t#genDataUnFormat(dataFormatted: Map<string, string>) {\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tdataFormatted.forEach((value, name) => {\n\t\t\tif (value === null || value === undefined || value === 'false') return;\n\n\t\t\ttry {\n\t\t\t\tif (typeof (value) === 'string' && !/^\\d\\d\\d\\d-\\d\\d-\\d\\d$/.test(value)) value = JSON.parse(value);\n\n\t\t\t\tif (value === null || value === undefined || value === 'false') return;\n\t\t\t} catch (e) {\n\t\t\t\t// не json строка\n\t\t\t}\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из хеша адреса страницы\n\t */\n\t#loadFromHash() {\n\t\tlet dataHash: any;\n\t\ttry {\n\t\t\tdataHash = JSON.parse(getHash(this.#storeId));\n\t\t} catch (e) {\n\n\t\t}\n\t\tif (!dataHash) return;\n\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = dataHash[name];\n\t\t\tif (!value) return;\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в хеш адреса страницы\n\t */\n\t#saveInHash() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataObject = Object.fromEntries(data);\n\t\tconst dataJSON = JSON.stringify(dataObject);\n\n\t\tsetHash(this.#storeId, dataJSON);\n\t};\n\n\t/**\n\t * Установить опции из localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#loadFromStorage(isLocal = false) {\n\t\tconst dataFormatted = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = localStorage.getItem(storageNamespace + ':' + name);\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#saveInStorage(isLocal = false) {\n\t\tconst data = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataFormatted = this.#genDataFormat(data);\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = dataFormatted.get(name);\n\n\t\t\tlocalStorage.setItem(storageNamespace + ':' + name, value);\n\t\t});\n\t}\n\n\t/**\n\t * Установить опции из гостевой ссылки\n\t */\n\t#loadFromGuestLink() {\n\t\tconst guestData = this.#user?.guest_data?.data;\n\t\tif (!guestData) return;\n\n\t\t// общие правила для гостевых сессий\n\t\tif (this.#user.id === -1) this.#user.positionsReverseDates = guestData.positionsReverseDates;\n\n\t\tconst dataFormatted = new Map();\n\n\t\tthis.#namesGuestLink.forEach((name) => {\n\t\t\tconst value = guestData[name];\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\n\t\tconst $guestTitle = $('.mod_guest_title');\n\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds?.length === 1 && this.#Page.page.data.competitors) {\n\t\t\tlet competitors = this.#Page.page.data.competitors.filter((competitor: any) => competitor.id === guestData.competitorsIds[0]);\n\t\t\tif (competitors.length) {\n\t\t\t\t$('a', $guestTitle).attr('href', 'http://' + competitors[0].url);\n\t\t\t\t$('a', $guestTitle).text(competitors[0].name);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Подготовить входные параметры перед инициализацией основного функционала\n\t *\n\t * Входные параметры устанавливаются при открытии страницы\n\t *\n\t * Входные параметры могут меняться пользоваталем и устаревать\n\t */\n\t#prepareParams() {\n\t\t// контролль за вводом регионов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.regionsIndexes) {\n\t\t\twatch(this.#store.regionsIndexes, (regionsIndexes) => {\n\t\t\t\tif (!regionsIndexes.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tregionsIndexes.forEach((regionIndex: number, index: number) => regionsIndexes[index] = regionIndex);\n\n\t\t\t\t// оставить только включенные регионы\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst mapSearchers = TplProjectSelectorRegion.genSearchersMap();\n\n\t\t\t\tconst availableRegionsIndexes: number[] = [];\n\t\t\t\tmapSearchers.forEach((searcher: any) => {\n\t\t\t\t\tsearcher.regions.forEach((region: any) => {\n\t\t\t\t\t\tif (region.index === -1) return;\n\n\t\t\t\t\t\tavailableRegionsIndexes.push(region.index);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tthis.#store.regionsIndexes = regionsIndexes.filter((regionIndex: number) => availableRegionsIndexes.includes(regionIndex));\n\t\t\t}, { immediate: true });\n\t\t}\n\n\t\t// контролль за вводом конкурентов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds) {\n\t\t\twatch(this.#store.competitorsIds, (competitorsIds) => {\n\t\t\t\tif (!competitorsIds.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tcompetitorsIds.forEach((competitorId: number, index: number) => competitorsIds[index] = competitorId);\n\n\t\t\t\t// оставить только включенных конкурентов\n\t\t\t\tconst availableCompetitorsIds = [this.#Page.page.data.project.id];\n\t\t\t\tthis.#Page.page.data.project.competitors.forEach((competitor: any) => {\n\t\t\t\t\tif (competitor.on >= 0) availableCompetitorsIds.push(competitor.id);\n\t\t\t\t});\n\n\t\t\t\tthis.#store.competitorsIds = competitorsIds.filter((competitorId: number) => availableCompetitorsIds.includes(competitorId));\n\t\t\t}, { immediate: true });\n\t\t}\n\t}\n\n}\n\ntype Options = {\n\t/**\n\t * TODO: Убрать из плагина\n\t */\n\tPage: any,\n\n\t/**\n\t * Объект с настройками пользователя\n\t */\n\tuser: any,\n\n\t/**\n\t * Объект для работы с API\n\t *\n\t * См. на сайте: @/component/api/core/api.ts\n\t */\n\tApi: Api.Client<Api.TV.Paths, true>;\n\n\t/**\n\t * Имена свойств для сохранения в URL\n\t */\n\ttpaNamesUrlHash?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage\n\t */\n\ttpaNamesStorage?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage с учетом пути URL\n\t *\n\t * Каждый URL будет работать со своим состоянием\n\t */\n\ttpaNamesStorageLocal?: string[],\n\n\t/**\n\t * Имена свойств для работы с гостевой ссылкой\n\t *\n\t * Для генерации гостевой ссылки используйте store.genGuestLink(data, url)\n\t */\n\ttpaNamesGuestLink?: string[],\n};\n\ntype Context = PiniaPluginContext & {\n\toptions: Options\n};\n\n/**\n * Плагин tpa (Third-party access) для pinia\n *\n * Добавляет возможность сохранять и загружать данные в/из:\n * \t- URL hash в адресе страницы\n * \t- localStorage\n * \t- гостевая ссылка\n *\n * Для подключения плагина нужно указань одну или несколько опций при определении defineStore():\n * - tpaNamesUrlHash\n * - tpaNamesStorage\n * - tpaNamesStorageLocal\n * - tpaNamesGuestLink\n */\nexport default (contextPinia: PiniaPluginContext) => {\n\tconst context = contextPinia as Context;\n\n\t// плагин подключать не нужно\n\tif (\n\t\t!context.options.tpaNamesUrlHash?.length &&\n\t\t!context.options.tpaNamesStorage?.length &&\n\t\t!context.options.tpaNamesStorageLocal?.length &&\n\t\t!context.options.tpaNamesGuestLink?.length\n\t) {\n\t\treturn;\n\t}\n\n\tnew PiniaTPA(context);\n}\n"],"names":["PiniaTPA","#storeId","#store","#Page","#user","#Api","context","path","params","#loadFromStorage","save","forms","utils_route","#saveInStorage","dataGuestLink","#genOptionsForGuestLink","res","link","utils_clipboard","data","nameSnakeCase","utils_string","name","currentValue","value","dataFormatted","#loadFromHash","dataHash","#setOptions","#saveInHash","dataJSON","isLocal","names","#namesStorage","storageNamespace","#namesStorageLocal","#loadFromGuestLink","guestData","$guestTitle","competitors","competitor","#prepareParams","regionsIndexes","regionIndex","index","mapSearchers","searcher","region","availableRegionsIndexes","competitorsIds","competitorId","availableCompetitorsIds","piniaTPA","contextPinia","_a","_b","_c","_d"],"mappings":"yVAOA,MAAAA,CAAA,CAAeC,GAELC,GACAC,GAKAC,GAEAC,gDASR,KAAAH,GAAAI,EAAA,6PAaAA,EAAA,MAAA,aAAA,CAAAC,EAAAC,IAAA,KAAA,aAAAD,EAAAC,CAAA,mDAIC,KAAAC,GAAA,EAAA,iCAWD,MAAAC,EAAAC,EAAA,SAAA,IAAA,CACC,KAAAT,GAAA,eAAA,YAAA,GAAA,CAAA,KAAAA,GAAA,WACCU,EAAA,QAAA,KAAAV,GAAA,GAAA,sBAMD,KAAAW,GAAA,EAAA,CAAwB,CAAA,EAGzBP,EAAA,MAAA,WAAAI,CAAA,EACD,MAAA,aAAAH,EAAAC,EAAA,CAQC,MAAAM,EAAA,KAAAC,GAAA,EACAP,EAAA,OAAA,OAAAA,EAAA,OAAA,YAAAM,CAAA,CAAA,EAEA,MAAAE,EAAA,MAAA,KAAAX,GAAA,IAAAE,CAAA,EAAA,UAAAC,CAAA,EAAA,KAAA,EACA,GAAAQ,GAAA,MAAAA,EAAA,OAAA,OAEA,MAAAC,EAAAD,EAAA,OAEA,MAAAE,EAAA,qBAAAD,CAAA,EACDF,IAAA,CAMC,MAAAI,EAAA,IAAA,+BAIC,MAAAC,EAAAC,EAAA,iBAAAC,CA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AAAC,EAAAN,IAAAK,EAAAL,CAAA,EAAAM,CAAA,EAGA,MAAAC,EAAA,CAAA,KAAAhD,GAAA,KAAA,KAAA,QAAA,EAAA,EACA,KAAAA,GAAA,KAAA,KAAA,QAAA,YAAA,QAAAqC,GAAA,CACCA,EAAA,IAAA,GAAAW,EAAA,KAAAX,EAAA,EAAA,CAAkE,CAAA,EAGnE,KAAAtC,GAAA,eAAA+C,EAAA,OAAAC,GAAAC,EAAA,SAAAD,CAAA,CAAA,CAA2H,EAAA,CAAA,UAAA,EAAA,CAAA,EAK/H,CA+DA,MAAAE,EAAAC,GAAA,uBAIC,GAAAC,EAAAhD,EAAA,QAAA,kBAAA,MAAAgD,EAAA,SAAA,GAAAC,EAAAjD,EAAA,QAAA,kBAAA,MAAAiD,EAAA,SAAA,GAAAC,EAAAlD,EAAA,QAAA,uBAAA,MAAAkD,EAAA,SAAA,GAAAC,EAAAnD,EAAA,QAAA,oBAAA,MAAAmD,EAAA,SASA,IAAAzD,EAAAM,CAAA"}
1
+ {"version":3,"file":"app.amd.js","sources":["../../src/core/plugins/piniaTPA.ts"],"sourcesContent":["import type { PiniaPluginContext, Store } from 'pinia';\nimport { watch } from 'vue';\nimport { debounce } from '@/core/utils/lodash';\nimport { guestLinkToClipboard } from '@/core/utils/clipboard';\nimport { camelToSnakeCase } from '@/core/utils/string.js';\nimport { getHash, setHash } from '@/core/utils/route';\n\nclass PiniaTPA {\n\n\treadonly #storeId: string;\n\treadonly #store: Store<string, any>;\n\n\t/**\n\t * @deprecated\n\t */\n\treadonly #Page: any;\n\n\treadonly #user: any;\n\treadonly #Api: Api.Client<Api.TV.Paths, true>;\n\n\treadonly #namesUrlHash: string[] = [];\n\treadonly #namesStorage: string[] = [];\n\treadonly #namesStorageLocal: string[] = [];\n\treadonly #namesGuestLink: string[] = [];\n\n\tconstructor(context: Context) {\n\t\tthis.#store = context.store;\n\t\tthis.#storeId = this.#store.$id;\n\n\t\tthis.#Page = context.options.Page;\n\n\t\tthis.#user = context.options.user;\n\t\tthis.#Api = context.options.Api;\n\n\t\tthis.#namesUrlHash = context.options.tpaNamesUrlHash || [];\n\t\tthis.#namesStorage = context.options.tpaNamesStorage || [];\n\t\tthis.#namesStorageLocal = context.options.tpaNamesStorageLocal || [];\n\t\tthis.#namesGuestLink = context.options.tpaNamesGuestLink || [];\n\n\t\tcontext.store.genGuestLink = <Path extends Api.TV.Path>(path: Path, params: Api.TV.Params<Path>) => this.genGuestLink(path, params);\n\n\t\tif (!this.#user.guest_data?.data) {\n\t\t\tthis.#loadFromStorage();\n\t\t\tthis.#loadFromStorage(true);\n\n\t\t\t// настройки URL hash имеют приоритет\n\t\t\tthis.#loadFromHash();\n\t\t}\n\n\t\t// настройки гостевой ссылки имеют приоритет\n\t\tthis.#loadFromGuestLink();\n\n\t\tthis.#prepareParams();\n\n\t\tconst save = debounce(() => {\n\t\t\tthis.#saveInHash();\n\t\t\tthis.#saveInStorage();\n\t\t\tthis.#saveInStorage(true);\n\t\t});\n\n\t\tcontext.store.$subscribe(save);\n\t}\n\n\t/**\n\t * Сгенерировать гостевую ссылку\n\t *\n\t * Метод, путь к которому указан в path, должен возвращать сгенерированную ссылку\n\t */\n\tasync genGuestLink<Path extends Api.TV.Path>(path: Path, params: Api.TV.Params<Path>) {\n\t\tconst dataGuestLink = this.#genOptionsForGuestLink();\n\t\tparams = Object.assign(params, Object.fromEntries(dataGuestLink));\n\n\t\tconst res = await this.#Api.gen(path).setParams(params).call();\n\t\tif (res?.errors) return;\n\n\t\tconst link = res.result as string;\n\n\t\tawait guestLinkToClipboard(link);\n\t}\n\n\t/**\n\t * Сгенерировать опции для гостевой ссылки\n\t */\n\t#genOptionsForGuestLink() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesGuestLink.forEach(name => {\n\t\t\t// формат параметров API: snake_case\n\t\t\tconst nameSnakeCase = camelToSnakeCase(name);\n\t\t\tdata.set(nameSnakeCase, this.#store[name]);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из объекта без фиксации состояния\n\t */\n\t#setOptions(data: Map<string, any>) {\n\t\tdata.forEach((value, name) => {\n\t\t\tconst currentValue = this.#store[name];\n\n\t\t\tif (value === null || value === undefined) return;\n\t\t\tif (currentValue === undefined) return;\n\t\t\tif (!value?.constructor) return;\n\t\t\tif (value.constructor !== currentValue.constructor) return;\n\n\t\t\t// дополнительная проверка на формат даты\n\t\t\tif (name.indexOf('date') === 0) {\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t// value.forEach((valueI) => {\n\t\t\t\t\t// \tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(valueI)) return;\n\t\t\t\t\t// });\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof (value) === 'string') {\n\t\t\t\t\t\tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(value)) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.#store[name] = value;\n\t\t});\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в виде json строк\n\t */\n\t#genDataFormat(data: Map<string, any>) {\n\t\tconst dataFormatted = new Map();\n\n\t\tdata.forEach((value, name) => {\n\t\t\tif (value === null) return;\n\n\t\t\tvalue = JSON.stringify(value);\n\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\treturn dataFormatted;\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в оригинальном виде\n\t */\n\t#genDataUnFormat(dataFormatted: Map<string, string>) {\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tdataFormatted.forEach((value, name) => {\n\t\t\tif (value === null || value === undefined || value === 'false') return;\n\n\t\t\ttry {\n\t\t\t\tif (typeof (value) === 'string' && !/^\\d\\d\\d\\d-\\d\\d-\\d\\d$/.test(value)) value = JSON.parse(value);\n\n\t\t\t\tif (value === null || value === undefined || value === 'false') return;\n\t\t\t} catch (e) {\n\t\t\t\t// не json строка\n\t\t\t}\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из хеша адреса страницы\n\t */\n\t#loadFromHash() {\n\t\tlet dataHash: any;\n\t\ttry {\n\t\t\tdataHash = JSON.parse(getHash(this.#storeId));\n\t\t} catch (e) {\n\n\t\t}\n\t\tif (!dataHash) return;\n\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = dataHash[name];\n\t\t\tif (!value) return;\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в хеш адреса страницы\n\t */\n\t#saveInHash() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataObject = Object.fromEntries(data);\n\t\tconst dataJSON = JSON.stringify(dataObject);\n\n\t\tsetHash(this.#storeId, dataJSON);\n\t};\n\n\t/**\n\t * Установить опции из localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#loadFromStorage(isLocal = false) {\n\t\tconst dataFormatted = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = localStorage.getItem(storageNamespace + ':' + name);\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#saveInStorage(isLocal = false) {\n\t\tconst data = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataFormatted = this.#genDataFormat(data);\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = dataFormatted.get(name);\n\n\t\t\tlocalStorage.setItem(storageNamespace + ':' + name, value);\n\t\t});\n\t}\n\n\t/**\n\t * Установить опции из гостевой ссылки\n\t */\n\t#loadFromGuestLink() {\n\t\tconst guestData = this.#user?.guest_data?.data;\n\t\tif (!guestData) return;\n\n\t\t// общие правила для гостевых сессий\n\t\tif (this.#user.id === -1) this.#user.positionsReverseDates = guestData.positionsReverseDates;\n\n\t\tconst dataFormatted = new Map();\n\n\t\tthis.#namesGuestLink.forEach((name) => {\n\t\t\tconst value = guestData[name];\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\n\t\tconst $guestTitle = $('.mod_guest_title');\n\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds?.length === 1 && this.#Page.page.data.competitors) {\n\t\t\tlet competitors = this.#Page.page.data.competitors.filter((competitor: any) => competitor.id === guestData.competitorsIds[0]);\n\t\t\tif (competitors.length) {\n\t\t\t\t$('a', $guestTitle).attr('href', 'http://' + competitors[0].url);\n\t\t\t\t$('a', $guestTitle).text(competitors[0].name);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Подготовить входные параметры перед инициализацией основного функционала\n\t *\n\t * Входные параметры устанавливаются при открытии страницы\n\t *\n\t * Входные параметры могут меняться пользоваталем и устаревать\n\t */\n\t#prepareParams() {\n\t\t// контролль за вводом регионов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.regionsIndexes) {\n\t\t\twatch(this.#store.regionsIndexes, (regionsIndexes) => {\n\t\t\t\tif (!regionsIndexes.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tregionsIndexes.forEach((regionIndex: number, index: number) => regionsIndexes[index] = regionIndex);\n\n\t\t\t\t// оставить только включенные регионы\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst mapSearchers = TplProjectSelectorRegion.genSearchersMap();\n\n\t\t\t\tconst availableRegionsIndexes: number[] = [];\n\t\t\t\tmapSearchers.forEach((searcher: any) => {\n\t\t\t\t\tsearcher.regions.forEach((region: any) => {\n\t\t\t\t\t\tif (region.index === -1) return;\n\n\t\t\t\t\t\tavailableRegionsIndexes.push(region.index);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tthis.#store.regionsIndexes = regionsIndexes.filter((regionIndex: number) => availableRegionsIndexes.includes(regionIndex));\n\t\t\t}, { immediate: true });\n\t\t}\n\n\t\t// контролль за вводом конкурентов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds) {\n\t\t\twatch(this.#store.competitorsIds, (competitorsIds) => {\n\t\t\t\tif (!competitorsIds.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tcompetitorsIds.forEach((competitorId: number, index: number) => competitorsIds[index] = competitorId);\n\n\t\t\t\t// оставить только включенных конкурентов\n\t\t\t\tconst availableCompetitorsIds = [this.#Page.page.data.project.id];\n\t\t\t\tthis.#Page.page.data.project.competitors.forEach((competitor: any) => {\n\t\t\t\t\tif (competitor.on >= 0) availableCompetitorsIds.push(competitor.id);\n\t\t\t\t});\n\n\t\t\t\tthis.#store.competitorsIds = competitorsIds.filter((competitorId: number) => availableCompetitorsIds.includes(competitorId));\n\t\t\t}, { immediate: true });\n\t\t}\n\t}\n\n}\n\ntype Options = {\n\t/**\n\t * TODO: Убрать из плагина\n\t */\n\tPage: any,\n\n\t/**\n\t * Объект с настройками пользователя\n\t */\n\tuser: any,\n\n\t/**\n\t * Объект для работы с API\n\t *\n\t * См. на сайте: @/component/api/core/api.ts\n\t */\n\tApi: Api.Client<Api.TV.Paths, true>;\n\n\t/**\n\t * Имена свойств для сохранения в URL\n\t */\n\ttpaNamesUrlHash?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage\n\t */\n\ttpaNamesStorage?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage с учетом пути URL\n\t *\n\t * Каждый URL будет работать со своим состоянием\n\t */\n\ttpaNamesStorageLocal?: string[],\n\n\t/**\n\t * Имена свойств для работы с гостевой ссылкой\n\t *\n\t * Для генерации гостевой ссылки используйте store.genGuestLink(data, url)\n\t */\n\ttpaNamesGuestLink?: string[],\n};\n\ntype Context = PiniaPluginContext & {\n\toptions: Options\n};\n\n/**\n * Плагин tpa (Third-party access) для pinia\n *\n * Добавляет возможность сохранять и загружать данные в/из:\n * \t- URL hash в адресе страницы\n * \t- localStorage\n * \t- гостевая ссылка\n *\n * Для подключения плагина нужно указань одну или несколько опций при определении defineStore():\n * - tpaNamesUrlHash\n * - tpaNamesStorage\n * - tpaNamesStorageLocal\n * - tpaNamesGuestLink\n */\nexport default (contextPinia: PiniaPluginContext) => {\n\tconst context = contextPinia as Context;\n\n\t// плагин подключать не нужно\n\tif (\n\t\t!context.options.tpaNamesUrlHash?.length &&\n\t\t!context.options.tpaNamesStorage?.length &&\n\t\t!context.options.tpaNamesStorageLocal?.length &&\n\t\t!context.options.tpaNamesGuestLink?.length\n\t) {\n\t\treturn;\n\t}\n\n\tnew PiniaTPA(context);\n}\n"],"names":["PiniaTPA","#storeId","#store","#Page","#user","#Api","context","path","params","#loadFromStorage","save","forms","#saveInStorage","dataGuestLink","#genOptionsForGuestLink","res","link","utils_clipboard","data","nameSnakeCase","utils_string","name","currentValue","value","dataFormatted","#loadFromHash","dataHash","utils_route","#setOptions","#saveInHash","dataJSON","isLocal","names","#namesStorage","storageNamespace","#namesStorageLocal","#loadFromGuestLink","guestData","$guestTitle","competitors","competitor","#prepareParams","regionsIndexes","regionIndex","index","mapSearchers","searcher","region","avail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A,SAAA,GAAAC,EAAAlD,EAAA,QAAA,uBAAA,MAAAkD,EAAA,SAAA,GAAAC,EAAAnD,EAAA,QAAA,oBAAA,MAAAmD,EAAA,SASA,IAAAzD,EAAAM,CAAA"}
package/core/app.js CHANGED
@@ -1,13 +1,13 @@
1
- import { d as p } from "../.chunks/forms-BWoAyEVH.es.js";
2
- import { C as I, i as M, u as T, a as b } from "../.chunks/forms-BWoAyEVH.es.js";
3
- import { c as G } from "../.chunks/core-BrkcXLtM.es.js";
4
- import { watch as d } from "vue";
1
+ import { d } from "../.chunks/forms-CuEEAPvm.es.js";
2
+ import { C as I, i as T, u as b, a as y } from "../.chunks/forms-CuEEAPvm.es.js";
3
+ import { c as G } from "../.chunks/core-PgN-H_aP.es.js";
4
+ import { watch as p } from "vue";
5
5
  import { guestLinkToClipboard as f } from "../utils/clipboard.js";
6
6
  import { camelToSnakeCase as g } from "../utils/string.js";
7
- import { delHash as l, getHash as m, setHash as u } from "../utils/route.js";
8
- import { u as A, a as D } from "../.chunks/utils-Dk7uXZsi.es.js";
9
- import { T as C } from "../.chunks/dialogs.vue_vue_type_script_setup_true_lang-8LLCo4IK.es.js";
10
- class S {
7
+ import { getHash as l, setHash as m } from "../utils/route.js";
8
+ import { u as A, a as D } from "../.chunks/utils-BHW-ownM.es.js";
9
+ import { T as j } from "../.chunks/dialogs.vue_vue_type_script_setup_true_lang-Bei7eCOi.es.js";
10
+ class u {
11
11
  #s;
12
12
  #t;
13
13
  /**
@@ -22,9 +22,9 @@ class S {
22
22
  #n = [];
23
23
  constructor(s) {
24
24
  var t;
25
- this.#t = s.store, this.#s = this.#t.$id, this.#e = s.options.Page, this.#a = s.options.user, this.#c = s.options.Api, this.#i = s.options.tpaNamesUrlHash || [], this.#o = s.options.tpaNamesStorage || [], this.#r = s.options.tpaNamesStorageLocal || [], this.#n = s.options.tpaNamesGuestLink || [], s.store.genGuestLink = (a, i) => this.genGuestLink(a, i), (t = this.#a.guest_data) != null && t.data || (this.#p(), this.#p(!0), this.#m()), this.#S(), this.#E();
26
- const e = p(() => {
27
- this.#t.hasOwnProperty("_isMounted") && !this.#t._isMounted ? l(this.#t.$id) : this.#u(), this.#f(), this.#f(!0);
25
+ this.#t = s.store, this.#s = this.#t.$id, this.#e = s.options.Page, this.#a = s.options.user, this.#c = s.options.Api, this.#i = s.options.tpaNamesUrlHash || [], this.#o = s.options.tpaNamesStorage || [], this.#r = s.options.tpaNamesStorageLocal || [], this.#n = s.options.tpaNamesGuestLink || [], s.store.genGuestLink = (a, i) => this.genGuestLink(a, i), (t = this.#a.guest_data) != null && t.data || (this.#d(), this.#d(!0), this.#m()), this.#S(), this.#E();
26
+ const e = d(() => {
27
+ this.#u(), this.#f(), this.#f(!0);
28
28
  });
29
29
  s.store.$subscribe(e);
30
30
  }
@@ -78,7 +78,7 @@ class S {
78
78
  /**
79
79
  * Сгенерировать Map объект с опциями со значениями в оригинальном виде
80
80
  */
81
- #d(s) {
81
+ #p(s) {
82
82
  const e = /* @__PURE__ */ new Map();
83
83
  return s.forEach((t, a) => {
84
84
  if (!(t == null || t === "false")) {
@@ -96,7 +96,7 @@ class S {
96
96
  #m() {
97
97
  let s;
98
98
  try {
99
- s = JSON.parse(m(this.#s));
99
+ s = JSON.parse(l(this.#s));
100
100
  } catch {
101
101
  }
102
102
  if (!s) return;
@@ -116,20 +116,20 @@ class S {
116
116
  s.set(a, i);
117
117
  });
118
118
  const e = Object.fromEntries(s), t = JSON.stringify(e);
119
- u(this.#s, t);
119
+ m(this.#s, t);
120
120
  }
121
121
  /**
122
122
  * Установить опции из localStorage
123
123
  * @param isLocal - сохранить с учетом адреса страницы
124
124
  */
125
- #p(s = !1) {
125
+ #d(s = !1) {
126
126
  const e = /* @__PURE__ */ new Map();
127
127
  let t = this.#o, a = "state:" + this.#s;
128
128
  s && (t = this.#r, a = "state:" + this.#s + ":" + location.pathname), t.forEach((o) => {
129
129
  const r = localStorage.getItem(a + ":" + o);
130
130
  e.set(o, r);
131
131
  });
132
- const i = this.#d(e);
132
+ const i = this.#p(e);
133
133
  this.#h(i);
134
134
  }
135
135
  /**
@@ -162,7 +162,7 @@ class S {
162
162
  const h = s[n];
163
163
  e.set(n, h);
164
164
  });
165
- const t = this.#d(e);
165
+ const t = this.#p(e);
166
166
  this.#h(t);
167
167
  const a = $(".mod_guest_title");
168
168
  if (((r = this.#t.competitorsIds) == null ? void 0 : r.length) === 1 && this.#e.page.data.competitors) {
@@ -178,7 +178,7 @@ class S {
178
178
  * Входные параметры могут меняться пользоваталем и устаревать
179
179
  */
180
180
  #E() {
181
- this.#t.regionsIndexes && d(this.#t.regionsIndexes, (s) => {
181
+ this.#t.regionsIndexes && p(this.#t.regionsIndexes, (s) => {
182
182
  if (!s.length) return;
183
183
  s.forEach((a, i) => s[i] = a);
184
184
  const e = TplProjectSelectorRegion.genSearchersMap(), t = [];
@@ -187,7 +187,7 @@ class S {
187
187
  i.index !== -1 && t.push(i.index);
188
188
  });
189
189
  }), this.#t.regionsIndexes = s.filter((a) => t.includes(a));
190
- }, { immediate: !0 }), this.#t.competitorsIds && d(this.#t.competitorsIds, (s) => {
190
+ }, { immediate: !0 }), this.#t.competitorsIds && p(this.#t.competitorsIds, (s) => {
191
191
  if (!s.length) return;
192
192
  s.forEach((t, a) => s[a] = t);
193
193
  const e = [this.#e.page.data.project.id];
@@ -197,20 +197,20 @@ class S {
197
197
  }, { immediate: !0 });
198
198
  }
199
199
  }
200
- const O = (c) => {
200
+ const w = (c) => {
201
201
  var e, t, a, i;
202
202
  const s = c;
203
- !((e = s.options.tpaNamesUrlHash) != null && e.length) && !((t = s.options.tpaNamesStorage) != null && t.length) && !((a = s.options.tpaNamesStorageLocal) != null && a.length) && !((i = s.options.tpaNamesGuestLink) != null && i.length) || new S(s);
203
+ !((e = s.options.tpaNamesUrlHash) != null && e.length) && !((t = s.options.tpaNamesStorage) != null && t.length) && !((a = s.options.tpaNamesStorageLocal) != null && a.length) && !((i = s.options.tpaNamesGuestLink) != null && i.length) || new u(s);
204
204
  };
205
205
  export {
206
206
  I as Core,
207
- C as TopDialogWorker,
207
+ j as TopDialogWorker,
208
208
  G as corePlugin,
209
- M as i18nPlugin,
210
- O as piniaTPAPlugin,
209
+ T as i18nPlugin,
210
+ w as piniaTPAPlugin,
211
211
  A as useAsyncTopDialog,
212
- T as useI18n,
213
- b as useI18nLang,
212
+ b as useI18n,
213
+ y as useI18nLang,
214
214
  D as useTopDialog
215
215
  };
216
216
  //# sourceMappingURL=app.js.map
package/core/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sources":["../../src/core/plugins/piniaTPA.ts"],"sourcesContent":["import type { PiniaPluginContext, Store } from 'pinia';\nimport { watch } from 'vue';\nimport { debounce } from '@/core/utils/lodash';\nimport { guestLinkToClipboard } from '@/core/utils/clipboard';\nimport { camelToSnakeCase } from '@/core/utils/string.js';\nimport { getHash, setHash, delHash } from '@/core/utils/route';\n\nclass PiniaTPA {\n\n\treadonly #storeId: string;\n\treadonly #store: Store<string, any>;\n\n\t/**\n\t * @deprecated\n\t */\n\treadonly #Page: any;\n\n\treadonly #user: any;\n\treadonly #Api: Api.Client<Api.TV.Paths, true>;\n\n\treadonly #namesUrlHash: string[] = [];\n\treadonly #namesStorage: string[] = [];\n\treadonly #namesStorageLocal: string[] = [];\n\treadonly #namesGuestLink: string[] = [];\n\n\tconstructor(context: Context) {\n\t\tthis.#store = context.store;\n\t\tthis.#storeId = this.#store.$id;\n\n\t\tthis.#Page = context.options.Page;\n\n\t\tthis.#user = context.options.user;\n\t\tthis.#Api = context.options.Api;\n\n\t\tthis.#namesUrlHash = context.options.tpaNamesUrlHash || [];\n\t\tthis.#namesStorage = context.options.tpaNamesStorage || [];\n\t\tthis.#namesStorageLocal = context.options.tpaNamesStorageLocal || [];\n\t\tthis.#namesGuestLink = context.options.tpaNamesGuestLink || [];\n\n\t\tcontext.store.genGuestLink = <Path extends Api.TV.Path>(path: Path, params: Api.TV.Params<Path>) => this.genGuestLink(path, params);\n\n\t\tif (!this.#user.guest_data?.data) {\n\t\t\tthis.#loadFromStorage();\n\t\t\tthis.#loadFromStorage(true);\n\n\t\t\t// настройки URL hash имеют приоритет\n\t\t\tthis.#loadFromHash();\n\t\t}\n\n\t\t// настройки гостевой ссылки имеют приоритет\n\t\tthis.#loadFromGuestLink();\n\n\t\tthis.#prepareParams();\n\n\t\tconst save = debounce(() => {\n\t\t\tif (this.#store.hasOwnProperty('_isMounted') && !this.#store._isMounted) {\n\t\t\t\tdelHash(this.#store.$id, '');\n\t\t\t} else {\n\t\t\t\tthis.#saveInHash();\n\t\t\t}\n\n\t\t\tthis.#saveInStorage();\n\t\t\tthis.#saveInStorage(true);\n\t\t});\n\n\t\tcontext.store.$subscribe(save);\n\t}\n\n\t/**\n\t * Сгенерировать гостевую ссылку\n\t *\n\t * Метод, путь к которому указан в path, должен возвращать сгенерированную ссылку\n\t */\n\tasync genGuestLink<Path extends Api.TV.Path>(path: Path, params: Api.TV.Params<Path>) {\n\t\tconst dataGuestLink = this.#genOptionsForGuestLink();\n\t\tparams = Object.assign(params, Object.fromEntries(dataGuestLink));\n\n\t\tconst res = await this.#Api.gen(path).setParams(params).call();\n\t\tif (res?.errors) return;\n\n\t\tconst link = res.result as string;\n\n\t\tawait guestLinkToClipboard(link);\n\t}\n\n\t/**\n\t * Сгенерировать опции для гостевой ссылки\n\t */\n\t#genOptionsForGuestLink() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesGuestLink.forEach(name => {\n\t\t\t// формат параметров API: snake_case\n\t\t\tconst nameSnakeCase = camelToSnakeCase(name);\n\t\t\tdata.set(nameSnakeCase, this.#store[name]);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из объекта без фиксации состояния\n\t */\n\t#setOptions(data: Map<string, any>) {\n\t\tdata.forEach((value, name) => {\n\t\t\tconst currentValue = this.#store[name];\n\n\t\t\tif (value === null || value === undefined) return;\n\t\t\tif (currentValue === undefined) return;\n\t\t\tif (!value?.constructor) return;\n\t\t\tif (value.constructor !== currentValue.constructor) return;\n\n\t\t\t// дополнительная проверка на формат даты\n\t\t\tif (name.indexOf('date') === 0) {\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t// value.forEach((valueI) => {\n\t\t\t\t\t// \tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(valueI)) return;\n\t\t\t\t\t// });\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof (value) === 'string') {\n\t\t\t\t\t\tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(value)) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.#store[name] = value;\n\t\t});\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в виде json строк\n\t */\n\t#genDataFormat(data: Map<string, any>) {\n\t\tconst dataFormatted = new Map();\n\n\t\tdata.forEach((value, name) => {\n\t\t\tif (value === null) return;\n\n\t\t\tvalue = JSON.stringify(value);\n\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\treturn dataFormatted;\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в оригинальном виде\n\t */\n\t#genDataUnFormat(dataFormatted: Map<string, string>) {\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tdataFormatted.forEach((value, name) => {\n\t\t\tif (value === null || value === undefined || value === 'false') return;\n\n\t\t\ttry {\n\t\t\t\tif (typeof (value) === 'string' && !/^\\d\\d\\d\\d-\\d\\d-\\d\\d$/.test(value)) value = JSON.parse(value);\n\n\t\t\t\tif (value === null || value === undefined || value === 'false') return;\n\t\t\t} catch (e) {\n\t\t\t\t// не json строка\n\t\t\t}\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из хеша адреса страницы\n\t */\n\t#loadFromHash() {\n\t\tlet dataHash: any;\n\t\ttry {\n\t\t\tdataHash = JSON.parse(getHash(this.#storeId));\n\t\t} catch (e) {\n\n\t\t}\n\t\tif (!dataHash) return;\n\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = dataHash[name];\n\t\t\tif (!value) return;\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в хеш адреса страницы\n\t */\n\t#saveInHash() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataObject = Object.fromEntries(data);\n\t\tconst dataJSON = JSON.stringify(dataObject);\n\n\t\tsetHash(this.#storeId, dataJSON);\n\t};\n\n\t/**\n\t * Установить опции из localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#loadFromStorage(isLocal = false) {\n\t\tconst dataFormatted = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = localStorage.getItem(storageNamespace + ':' + name);\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#saveInStorage(isLocal = false) {\n\t\tconst data = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataFormatted = this.#genDataFormat(data);\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = dataFormatted.get(name);\n\n\t\t\tlocalStorage.setItem(storageNamespace + ':' + name, value);\n\t\t});\n\t}\n\n\t/**\n\t * Установить опции из гостевой ссылки\n\t */\n\t#loadFromGuestLink() {\n\t\tconst guestData = this.#user?.guest_data?.data;\n\t\tif (!guestData) return;\n\n\t\t// общие правила для гостевых сессий\n\t\tif (this.#user.id === -1) this.#user.positionsReverseDates = guestData.positionsReverseDates;\n\n\t\tconst dataFormatted = new Map();\n\n\t\tthis.#namesGuestLink.forEach((name) => {\n\t\t\tconst value = guestData[name];\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\n\t\tconst $guestTitle = $('.mod_guest_title');\n\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds?.length === 1 && this.#Page.page.data.competitors) {\n\t\t\tlet competitors = this.#Page.page.data.competitors.filter((competitor: any) => competitor.id === guestData.competitorsIds[0]);\n\t\t\tif (competitors.length) {\n\t\t\t\t$('a', $guestTitle).attr('href', 'http://' + competitors[0].url);\n\t\t\t\t$('a', $guestTitle).text(competitors[0].name);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Подготовить входные параметры перед инициализацией основного функционала\n\t *\n\t * Входные параметры устанавливаются при открытии страницы\n\t *\n\t * Входные параметры могут меняться пользоваталем и устаревать\n\t */\n\t#prepareParams() {\n\t\t// контролль за вводом регионов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.regionsIndexes) {\n\t\t\twatch(this.#store.regionsIndexes, (regionsIndexes) => {\n\t\t\t\tif (!regionsIndexes.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tregionsIndexes.forEach((regionIndex: number, index: number) => regionsIndexes[index] = regionIndex);\n\n\t\t\t\t// оставить только включенные регионы\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst mapSearchers = TplProjectSelectorRegion.genSearchersMap();\n\n\t\t\t\tconst availableRegionsIndexes: number[] = [];\n\t\t\t\tmapSearchers.forEach((searcher: any) => {\n\t\t\t\t\tsearcher.regions.forEach((region: any) => {\n\t\t\t\t\t\tif (region.index === -1) return;\n\n\t\t\t\t\t\tavailableRegionsIndexes.push(region.index);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tthis.#store.regionsIndexes = regionsIndexes.filter((regionIndex: number) => availableRegionsIndexes.includes(regionIndex));\n\t\t\t}, { immediate: true });\n\t\t}\n\n\t\t// контролль за вводом конкурентов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds) {\n\t\t\twatch(this.#store.competitorsIds, (competitorsIds) => {\n\t\t\t\tif (!competitorsIds.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tcompetitorsIds.forEach((competitorId: number, index: number) => competitorsIds[index] = competitorId);\n\n\t\t\t\t// оставить только включенных конкурентов\n\t\t\t\tconst availableCompetitorsIds = [this.#Page.page.data.project.id];\n\t\t\t\tthis.#Page.page.data.project.competitors.forEach((competitor: any) => {\n\t\t\t\t\tif (competitor.on >= 0) availableCompetitorsIds.push(competitor.id);\n\t\t\t\t});\n\n\t\t\t\tthis.#store.competitorsIds = competitorsIds.filter((competitorId: number) => availableCompetitorsIds.includes(competitorId));\n\t\t\t}, { immediate: true });\n\t\t}\n\t}\n\n}\n\ntype Options = {\n\t/**\n\t * TODO: Убрать из плагина\n\t */\n\tPage: any,\n\n\t/**\n\t * Объект с настройками пользователя\n\t */\n\tuser: any,\n\n\t/**\n\t * Объект для работы с API\n\t *\n\t * См. на сайте: @/component/api/core/api.ts\n\t */\n\tApi: Api.Client<Api.TV.Paths, true>;\n\n\t/**\n\t * Имена свойств для сохранения в URL\n\t */\n\ttpaNamesUrlHash?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage\n\t */\n\ttpaNamesStorage?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage с учетом пути URL\n\t *\n\t * Каждый URL будет работать со своим состоянием\n\t */\n\ttpaNamesStorageLocal?: string[],\n\n\t/**\n\t * Имена свойств для работы с гостевой ссылкой\n\t *\n\t * Для генерации гостевой ссылки используйте store.genGuestLink(data, url)\n\t */\n\ttpaNamesGuestLink?: string[],\n};\n\ntype Context = PiniaPluginContext & {\n\toptions: Options\n};\n\n/**\n * Плагин tpa (Third-party access) для pinia\n *\n * Добавляет возможность сохранять и загружать данные в/из:\n * \t- URL hash в адресе страницы\n * \t- localStorage\n * \t- гостевая ссылка\n *\n * Для подключения плагина нужно указань одну или несколько опций при определении defineStore():\n * - tpaNamesUrlHash\n * - tpaNamesStorage\n * - tpaNamesStorageLocal\n * - tpaNamesGuestLink\n */\nexport default (contextPinia: PiniaPluginContext) => {\n\tconst context = contextPinia as Context;\n\n\t// плагин подключать не нужно\n\tif (\n\t\t!context.options.tpaNamesUrlHash?.length &&\n\t\t!context.options.tpaNamesStorage?.length &&\n\t\t!context.options.tpaNamesStorageLocal?.length &&\n\t\t!context.options.tpaNamesGuestLink?.length\n\t) {\n\t\treturn;\n\t}\n\n\tnew PiniaTPA(context);\n}\n"],"names":["PiniaTPA","#storeId","#store","#Page","#user","#Api","#namesUrlHash","#namesStorage","#namesStorageLocal","#namesGuestLink","context","path","params","_a","#loadFromStorage","#loadFromHash","#loadFromGuestLink","#prepareParams","save","debounce","delHash","#saveInHash","#saveInStorage","dataGuestLink","#genOptionsForGuestLink","res","link","guestLinkToClipboard","data","name","nameSnakeCase","camelToSnakeCase","#setOptions","value","currentValue","#genDataFormat","dataFormatted","#genDataUnFormat","dataHash","getHash","dataObject","dataJSON","setHash","isLocal","names","storageNamespace","guestData","_b","$guestTitle","_c","competitors","competitor","watch","regionsIndexes","regionIndex","index","mapSearchers","availableRegionsIndexes","searcher","region","competitorsIds","competitorId","availableCompetitorsIds","piniaTPA","contextPinia","_d"],"mappings":";;;;;;;;;AAOA,MAAMA,EAAS;AAAA,EAEL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AAG5B,MAAAA,EAAe,QAAQ,CAACC,GAAsBN,MAAkBK,EAAeL,CAAK,IAAIM,CAAY;AAGpG,YAAMC,IAA0B,CAAC,KAAK3D,GAAM,KAAK,KAAK,QAAQ,EAAE;AAChE,WAAKA,GAAM,KAAK,KAAK,QAAQ,YAAY,QAAQ,CAACgD,MAAoB;AACrE,QAAIA,EAAW,MAAM,KAAGW,EAAwB,KAAKX,EAAW,EAAE;AAAA,MACnE,CAAC,GAED,KAAKjD,GAAO,iBAAiB0D,EAAe,OAAO,CAACC,MAAyBC,EAAwB,SAASD,CAAY,CAAC;AAAA,IAC5H,GAAG,EAAE,WAAW,IAAM;AAAA,EAExB;AAED;AA+DA,MAAAE,IAAe,CAACC,MAAqC;;AACpD,QAAMtD,IAAUsD;AAGhB,EACC,GAACnD,IAAAH,EAAQ,QAAQ,oBAAhB,QAAAG,EAAiC,WAClC,GAACkC,IAAArC,EAAQ,QAAQ,oBAAhB,QAAAqC,EAAiC,WAClC,GAACE,IAAAvC,EAAQ,QAAQ,yBAAhB,QAAAuC,EAAsC,WACvC,GAACgB,IAAAvD,EAAQ,QAAQ,sBAAhB,QAAAuD,EAAmC,WAKrC,IAAIjE,EAASU,CAAO;AACrB;"}
1
+ {"version":3,"file":"app.js","sources":["../../src/core/plugins/piniaTPA.ts"],"sourcesContent":["import type { PiniaPluginContext, Store } from 'pinia';\nimport { watch } from 'vue';\nimport { debounce } from '@/core/utils/lodash';\nimport { guestLinkToClipboard } from '@/core/utils/clipboard';\nimport { camelToSnakeCase } from '@/core/utils/string.js';\nimport { getHash, setHash } from '@/core/utils/route';\n\nclass PiniaTPA {\n\n\treadonly #storeId: string;\n\treadonly #store: Store<string, any>;\n\n\t/**\n\t * @deprecated\n\t */\n\treadonly #Page: any;\n\n\treadonly #user: any;\n\treadonly #Api: Api.Client<Api.TV.Paths, true>;\n\n\treadonly #namesUrlHash: string[] = [];\n\treadonly #namesStorage: string[] = [];\n\treadonly #namesStorageLocal: string[] = [];\n\treadonly #namesGuestLink: string[] = [];\n\n\tconstructor(context: Context) {\n\t\tthis.#store = context.store;\n\t\tthis.#storeId = this.#store.$id;\n\n\t\tthis.#Page = context.options.Page;\n\n\t\tthis.#user = context.options.user;\n\t\tthis.#Api = context.options.Api;\n\n\t\tthis.#namesUrlHash = context.options.tpaNamesUrlHash || [];\n\t\tthis.#namesStorage = context.options.tpaNamesStorage || [];\n\t\tthis.#namesStorageLocal = context.options.tpaNamesStorageLocal || [];\n\t\tthis.#namesGuestLink = context.options.tpaNamesGuestLink || [];\n\n\t\tcontext.store.genGuestLink = <Path extends Api.TV.Path>(path: Path, params: Api.TV.Params<Path>) => this.genGuestLink(path, params);\n\n\t\tif (!this.#user.guest_data?.data) {\n\t\t\tthis.#loadFromStorage();\n\t\t\tthis.#loadFromStorage(true);\n\n\t\t\t// настройки URL hash имеют приоритет\n\t\t\tthis.#loadFromHash();\n\t\t}\n\n\t\t// настройки гостевой ссылки имеют приоритет\n\t\tthis.#loadFromGuestLink();\n\n\t\tthis.#prepareParams();\n\n\t\tconst save = debounce(() => {\n\t\t\tthis.#saveInHash();\n\t\t\tthis.#saveInStorage();\n\t\t\tthis.#saveInStorage(true);\n\t\t});\n\n\t\tcontext.store.$subscribe(save);\n\t}\n\n\t/**\n\t * Сгенерировать гостевую ссылку\n\t *\n\t * Метод, путь к которому указан в path, должен возвращать сгенерированную ссылку\n\t */\n\tasync genGuestLink<Path extends Api.TV.Path>(path: Path, params: Api.TV.Params<Path>) {\n\t\tconst dataGuestLink = this.#genOptionsForGuestLink();\n\t\tparams = Object.assign(params, Object.fromEntries(dataGuestLink));\n\n\t\tconst res = await this.#Api.gen(path).setParams(params).call();\n\t\tif (res?.errors) return;\n\n\t\tconst link = res.result as string;\n\n\t\tawait guestLinkToClipboard(link);\n\t}\n\n\t/**\n\t * Сгенерировать опции для гостевой ссылки\n\t */\n\t#genOptionsForGuestLink() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesGuestLink.forEach(name => {\n\t\t\t// формат параметров API: snake_case\n\t\t\tconst nameSnakeCase = camelToSnakeCase(name);\n\t\t\tdata.set(nameSnakeCase, this.#store[name]);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из объекта без фиксации состояния\n\t */\n\t#setOptions(data: Map<string, any>) {\n\t\tdata.forEach((value, name) => {\n\t\t\tconst currentValue = this.#store[name];\n\n\t\t\tif (value === null || value === undefined) return;\n\t\t\tif (currentValue === undefined) return;\n\t\t\tif (!value?.constructor) return;\n\t\t\tif (value.constructor !== currentValue.constructor) return;\n\n\t\t\t// дополнительная проверка на формат даты\n\t\t\tif (name.indexOf('date') === 0) {\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t// value.forEach((valueI) => {\n\t\t\t\t\t// \tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(valueI)) return;\n\t\t\t\t\t// });\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof (value) === 'string') {\n\t\t\t\t\t\tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(value)) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.#store[name] = value;\n\t\t});\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в виде json строк\n\t */\n\t#genDataFormat(data: Map<string, any>) {\n\t\tconst dataFormatted = new Map();\n\n\t\tdata.forEach((value, name) => {\n\t\t\tif (value === null) return;\n\n\t\t\tvalue = JSON.stringify(value);\n\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\treturn dataFormatted;\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в оригинальном виде\n\t */\n\t#genDataUnFormat(dataFormatted: Map<string, string>) {\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tdataFormatted.forEach((value, name) => {\n\t\t\tif (value === null || value === undefined || value === 'false') return;\n\n\t\t\ttry {\n\t\t\t\tif (typeof (value) === 'string' && !/^\\d\\d\\d\\d-\\d\\d-\\d\\d$/.test(value)) value = JSON.parse(value);\n\n\t\t\t\tif (value === null || value === undefined || value === 'false') return;\n\t\t\t} catch (e) {\n\t\t\t\t// не json строка\n\t\t\t}\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из хеша адреса страницы\n\t */\n\t#loadFromHash() {\n\t\tlet dataHash: any;\n\t\ttry {\n\t\t\tdataHash = JSON.parse(getHash(this.#storeId));\n\t\t} catch (e) {\n\n\t\t}\n\t\tif (!dataHash) return;\n\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = dataHash[name];\n\t\t\tif (!value) return;\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в хеш адреса страницы\n\t */\n\t#saveInHash() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataObject = Object.fromEntries(data);\n\t\tconst dataJSON = JSON.stringify(dataObject);\n\n\t\tsetHash(this.#storeId, dataJSON);\n\t};\n\n\t/**\n\t * Установить опции из localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#loadFromStorage(isLocal = false) {\n\t\tconst dataFormatted = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = localStorage.getItem(storageNamespace + ':' + name);\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#saveInStorage(isLocal = false) {\n\t\tconst data = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataFormatted = this.#genDataFormat(data);\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = dataFormatted.get(name);\n\n\t\t\tlocalStorage.setItem(storageNamespace + ':' + name, value);\n\t\t});\n\t}\n\n\t/**\n\t * Установить опции из гостевой ссылки\n\t */\n\t#loadFromGuestLink() {\n\t\tconst guestData = this.#user?.guest_data?.data;\n\t\tif (!guestData) return;\n\n\t\t// общие правила для гостевых сессий\n\t\tif (this.#user.id === -1) this.#user.positionsReverseDates = guestData.positionsReverseDates;\n\n\t\tconst dataFormatted = new Map();\n\n\t\tthis.#namesGuestLink.forEach((name) => {\n\t\t\tconst value = guestData[name];\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\n\t\tconst $guestTitle = $('.mod_guest_title');\n\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds?.length === 1 && this.#Page.page.data.competitors) {\n\t\t\tlet competitors = this.#Page.page.data.competitors.filter((competitor: any) => competitor.id === guestData.competitorsIds[0]);\n\t\t\tif (competitors.length) {\n\t\t\t\t$('a', $guestTitle).attr('href', 'http://' + competitors[0].url);\n\t\t\t\t$('a', $guestTitle).text(competitors[0].name);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Подготовить входные параметры перед инициализацией основного функционала\n\t *\n\t * Входные параметры устанавливаются при открытии страницы\n\t *\n\t * Входные параметры могут меняться пользоваталем и устаревать\n\t */\n\t#prepareParams() {\n\t\t// контролль за вводом регионов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.regionsIndexes) {\n\t\t\twatch(this.#store.regionsIndexes, (regionsIndexes) => {\n\t\t\t\tif (!regionsIndexes.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tregionsIndexes.forEach((regionIndex: number, index: number) => regionsIndexes[index] = regionIndex);\n\n\t\t\t\t// оставить только включенные регионы\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst mapSearchers = TplProjectSelectorRegion.genSearchersMap();\n\n\t\t\t\tconst availableRegionsIndexes: number[] = [];\n\t\t\t\tmapSearchers.forEach((searcher: any) => {\n\t\t\t\t\tsearcher.regions.forEach((region: any) => {\n\t\t\t\t\t\tif (region.index === -1) return;\n\n\t\t\t\t\t\tavailableRegionsIndexes.push(region.index);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tthis.#store.regionsIndexes = regionsIndexes.filter((regionIndex: number) => availableRegionsIndexes.includes(regionIndex));\n\t\t\t}, { immediate: true });\n\t\t}\n\n\t\t// контролль за вводом конкурентов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds) {\n\t\t\twatch(this.#store.competitorsIds, (competitorsIds) => {\n\t\t\t\tif (!competitorsIds.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tcompetitorsIds.forEach((competitorId: number, index: number) => competitorsIds[index] = competitorId);\n\n\t\t\t\t// оставить только включенных конкурентов\n\t\t\t\tconst availableCompetitorsIds = [this.#Page.page.data.project.id];\n\t\t\t\tthis.#Page.page.data.project.competitors.forEach((competitor: any) => {\n\t\t\t\t\tif (competitor.on >= 0) availableCompetitorsIds.push(competitor.id);\n\t\t\t\t});\n\n\t\t\t\tthis.#store.competitorsIds = competitorsIds.filter((competitorId: number) => availableCompetitorsIds.includes(competitorId));\n\t\t\t}, { immediate: true });\n\t\t}\n\t}\n\n}\n\ntype Options = {\n\t/**\n\t * TODO: Убрать из плагина\n\t */\n\tPage: any,\n\n\t/**\n\t * Объект с настройками пользователя\n\t */\n\tuser: any,\n\n\t/**\n\t * Объект для работы с API\n\t *\n\t * См. на сайте: @/component/api/core/api.ts\n\t */\n\tApi: Api.Client<Api.TV.Paths, true>;\n\n\t/**\n\t * Имена свойств для сохранения в URL\n\t */\n\ttpaNamesUrlHash?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage\n\t */\n\ttpaNamesStorage?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage с учетом пути URL\n\t *\n\t * Каждый URL будет работать со своим состоянием\n\t */\n\ttpaNamesStorageLocal?: string[],\n\n\t/**\n\t * Имена свойств для работы с гостевой ссылкой\n\t *\n\t * Для генерации гостевой ссылки используйте store.genGuestLink(data, url)\n\t */\n\ttpaNamesGuestLink?: string[],\n};\n\ntype Context = PiniaPluginContext & {\n\toptions: Options\n};\n\n/**\n * Плагин tpa (Third-party access) для pinia\n *\n * Добавляет возможность сохранять и загружать данные в/из:\n * \t- URL hash в адресе страницы\n * \t- localStorage\n * \t- гостевая ссылка\n *\n * Для подключения плагина нужно указань одну или несколько опций при определении defineStore():\n * - tpaNamesUrlHash\n * - tpaNamesStorage\n * - tpaNamesStorageLocal\n * - tpaNamesGuestLink\n */\nexport default (contextPinia: PiniaPluginContext) => {\n\tconst context = contextPinia as Context;\n\n\t// плагин подключать не нужно\n\tif (\n\t\t!context.options.tpaNamesUrlHash?.length &&\n\t\t!context.options.tpaNamesStorage?.length &&\n\t\t!context.options.tpaNamesStorageLocal?.length &&\n\t\t!context.options.tpaNamesGuestLink?.length\n\t) {\n\t\treturn;\n\t}\n\n\tnew PiniaTPA(context);\n}\n"],"names":["PiniaTPA","#storeId","#store","#Page","#user","#Api","#namesUrlHash","#namesStorage","#namesStorageLocal","#namesGuestLink","context","path","params","_a","#loadFromStorage","#loadFromHash","#loadFromGuestLink","#prepareParams","save","debounce","#saveInHash","#saveInStorage","dataGuestLink","#genOptionsForGuestLink","res","link","guestLinkToClipboard","data","name","nameSnakeCase","camelToSnakeCase","#setOptions","value","currentValue","#genDataFormat","dataFormatted","#genDataUnFormat","dataHash","getHash","dataObject","dataJSON","setHash","isLocal","names","storageNamespace","guestData","_b","$guestTitle","_c","competitors","competitor","watch","regionsIndexes","regionIndex","index","mapSearchers","availableRegionsIndexes","searcher","region","competitorsIds","competitorId","availableCompetitorsIds","piniaTPA","contextPinia","_d"],"mappings":";;;;;;;;;AAOA,MAAMA,EAAS;AAAA,EAELC;AAAA,EACAC;AAAA;AAAA;AAAA;AAAA,EAKAC;AAAA,EAEAC;AAAA,EACAC;AAAA,EAEAC,KAA0B,CAAA;AAAA,EAC1BC,KAA0B,CAAA;AAAA,EAC1BC,KAA+B,CAAA;AAAA,EAC/BC,KAA4B,CAAA;AAAA,EAErC,YAAYC,GAAkB;;AAC7B,SAAKR,KAASQ,EAAQ,OACtB,KAAKT,KAAW,KAAKC,GAAO,KAE5B,KAAKC,KAAQO,EAAQ,QAAQ,MAE7B,KAAKN,KAAQM,EAAQ,QAAQ,MAC7B,KAAKL,KAAOK,EAAQ,QAAQ,KAE5B,KAAKJ,KAAgBI,EAAQ,QAAQ,mBAAmB,CAAA,GACxD,KAAKH,KAAgBG,EAAQ,QAAQ,mBAAmB,CAAA,GACxD,KAAKF,KAAqBE,EAAQ,QAAQ,wBAAwB,CAAA,GAClE,KAAKD,KAAkBC,EAAQ,QAAQ,qBAAqB,CAAA,GAE5DA,EAAQ,MAAM,eAAe,CAA2BC,GAAYC,MAAgC,KAAK,aAAaD,GAAMC,CAAM,IAE7HC,IAAA,KAAKT,GAAM,eAAX,QAAAS,EAAuB,SAC3B,KAAKC,GAAA,GACL,KAAKA,GAAiB,EAAI,GAG1B,KAAKC,GAAA,IAIN,KAAKC,GAAA,GAEL,KAAKC,GAAA;AAEL,UAAMC,IAAOC,EAAS,MAAM;AAC3B,WAAKC,GAAA,GACL,KAAKC,GAAA,GACL,KAAKA,GAAe,EAAI;AAAA,IACzB,CA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AiBkD,EAAe,OAAO,CAACC,MAAwBG,EAAwB,SAASH,CAAW,CAAC;AAAA,IAC1H,GAAG,EAAE,WAAW,IAAM,GAKnB,KAAKnD,GAAO,kBACfiD,EAAM,KAAKjD,GAAO,gBAAgB,CAACyD,MAAmB;AACrD,UAAI,CAACA,EAAe,OAAQ;AAG5B,MAAAA,EAAe,QAAQ,CAACC,GAAsBN,MAAkBK,EAAeL,CAAK,IAAIM,CAAY;AAGpG,YAAMC,IAA0B,CAAC,KAAK1D,GAAM,KAAK,KAAK,QAAQ,EAAE;AAChE,WAAKA,GAAM,KAAK,KAAK,QAAQ,YAAY,QAAQ,CAAC+C,MAAoB;AACrE,QAAIA,EAAW,MAAM,KAAGW,EAAwB,KAAKX,EAAW,EAAE;AAAA,MACnE,CAAC,GAED,KAAKhD,GAAO,iBAAiByD,EAAe,OAAO,CAACC,MAAyBC,EAAwB,SAASD,CAAY,CAAC;AAAA,IAC5H,GAAG,EAAE,WAAW,IAAM;AAAA,EAExB;AAED;AA+DA,MAAAE,IAAe,CAACC,MAAqC;;AACpD,QAAMrD,IAAUqD;AAGhB,EACC,GAAClD,IAAAH,EAAQ,QAAQ,oBAAhB,QAAAG,EAAiC,WAClC,GAACiC,IAAApC,EAAQ,QAAQ,oBAAhB,QAAAoC,EAAiC,WAClC,GAACE,IAAAtC,EAAQ,QAAQ,yBAAhB,QAAAsC,EAAsC,WACvC,GAACgB,IAAAtD,EAAQ,QAAQ,sBAAhB,QAAAsD,EAAmC,WAKrC,IAAIhE,EAASU,CAAO;AACrB;"}
package/dialog/dialog.js CHANGED
@@ -1,6 +1,6 @@
1
- import { _ as k, a as B } from "../.chunks/page.vue_vue_type_script_setup_true_lang-B26E2LsY.es.js";
1
+ import { _ as k, a as B } from "../.chunks/page.vue_vue_type_script_setup_true_lang-x02Y0eiE.es.js";
2
2
  import { defineComponent as l, ref as i, onUpdated as u, createBlock as a, openBlock as p, KeepAlive as s, createCommentVNode as d, unref as g, resolveDynamicComponent as c, mergeProps as f } from "vue";
3
- import { b as v } from "../.chunks/utils-Dk7uXZsi.es.js";
3
+ import { b as v } from "../.chunks/utils-BHW-ownM.es.js";
4
4
  const C = {
5
5
  name: {
6
6
  type: String,
package/extra/extra.js CHANGED
@@ -1,8 +1,10 @@
1
- import { Core as v } from "../core/app.js";
2
- import { defineComponent as f, ref as m, watch as y, onUnmounted as B, createElementBlock as C, openBlock as L } from "vue";
3
- const d = ["../assets/extra.css"].map((a) => import.meta.resolve(a));
4
- v.insertCSSLinkToPage(d, !0);
5
- const h = /* @__PURE__ */ f({
1
+
2
+ import { Core as _autoloadCSSCore } from '../core/app.js';
3
+ const fileNames = ['../assets/extra.css'].map(fileName => import.meta.resolve(fileName));
4
+ _autoloadCSSCore.insertCSSLinkToPage(fileNames, true);
5
+
6
+ import { defineComponent as v, ref as d, watch as f, onUnmounted as y, createElementBlock as m, openBlock as B } from "vue";
7
+ const L = /* @__PURE__ */ v({
6
8
  __name: "rive",
7
9
  props: {
8
10
  src: {},
@@ -36,37 +38,37 @@ const h = /* @__PURE__ */ f({
36
38
  onloop: {},
37
39
  onstatechange: {}
38
40
  },
39
- setup(a, { expose: p }) {
40
- let t;
41
- const o = a, s = m(), n = {
41
+ setup(i, { expose: p }) {
42
+ let a;
43
+ const o = i, t = d(), n = {
42
44
  riveInstance: void 0
43
45
  };
44
- return y([s, o], async () => {
45
- var l;
46
- t || (t = await import("@rive-app/canvas-lite"));
47
- const e = s.value;
46
+ return f([t, o], async () => {
47
+ var s;
48
+ a || (a = await import("@rive-app/canvas-lite"));
49
+ const e = t.value;
48
50
  if (!e) return;
49
- (l = n.riveInstance) == null || l.cleanup();
51
+ (s = n.riveInstance) == null || s.cleanup();
50
52
  const r = {
51
53
  ...o,
52
54
  canvas: e,
53
55
  onLoad: (u) => {
54
- var i, c;
55
- (i = o.onLoad) == null || i.call(o, u), (c = n.riveInstance) == null || c.resizeDrawingSurfaceToCanvas();
56
+ var l, c;
57
+ (l = o.onLoad) == null || l.call(o, u), (c = n.riveInstance) == null || c.resizeDrawingSurfaceToCanvas();
56
58
  }
57
59
  };
58
- n.riveInstance = new t.Rive(r);
59
- }), B(() => {
60
+ n.riveInstance = new a.Rive(r);
61
+ }), y(() => {
60
62
  var e;
61
63
  (e = n.riveInstance) == null || e.cleanup();
62
- }), p(n), (e, r) => (L(), C("canvas", {
64
+ }), p(n), (e, r) => (B(), m("canvas", {
63
65
  ref_key: "el",
64
- ref: s,
66
+ ref: t,
65
67
  class: "top-rive"
66
68
  }, null, 512));
67
69
  }
68
70
  });
69
71
  export {
70
- h as TopRive
72
+ L as TopRive
71
73
  };
72
74
  //# sourceMappingURL=extra.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extra.js","sources":["../../src/components/extra/rive/rive.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { onUnmounted, ref, watch } from 'vue';\nimport type { Rive, RiveParameters } from '@rive-app/canvas-lite';\nimport type { Props } from './types';\n\nlet rive: typeof import('@rive-app/canvas-lite');\n\nconst props = withDefaults(defineProps<Props>(), {\n\tautoplay: true,\n});\n\nconst el = ref<HTMLCanvasElement>();\n\nconst topRive = {\n\triveInstance: undefined as Rive | undefined,\n};\n\nwatch([el, props], async () => {\n\tif (!rive) rive = await import('@rive-app/canvas-lite');\n\n\tconst canvas = el.value;\n\tif (!canvas) return;\n\n\ttopRive.riveInstance?.cleanup();\n\n\tconst options: RiveParameters = {\n\t\t...props,\n\t\tcanvas,\n\t\tonLoad: (e) => {\n\t\t\tprops.onLoad?.(e);\n\n\t\t\ttopRive.riveInstance?.resizeDrawingSurfaceToCanvas();\n\t\t},\n\t};\n\n\ttopRive.riveInstance = new rive.Rive(options);\n});\n\nonUnmounted(() => {\n\ttopRive.riveInstance?.cleanup();\n});\n\ndefineExpose(topRive);\n</script>\n\n<template>\n\t<canvas ref=\"el\" class=\"top-rive\"></canvas>\n</template>\n\n<style>\n.top-rive {\n\twidth: 100%;\n\theight: 100%;\n\tflex-grow: 1;\n}\n</style>\n"],"names":["rive","props","__props","el","ref","topRive","watch","canvas","_a","options","e","_b","onUnmounted","__expose"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,QAAAA;AAEA,UAAAC,IAAAC,GAIAC,IAAAC,EAAA,GAEAC,IAAA;AAAA,MAAgB,cAAA;AAAA,IACD;AAGf,WAAAC,EAAA,CAAAH,GAAAF,CAAA,GAAA,YAAA;;AACC,MAAAD,MAAAA,IAAA,MAAA,OAAA,uBAAA;AAEA,YAAAO,IAAAJ,EAAA;AACA,UAAA,CAAAI,EAAA;AAEA,OAAAC,IAAAH,EAAA,iBAAA,QAAAG,EAAA;AAEA,YAAAC,IAAA;AAAA,QAAgC,GAAAR;AAAA,QAC5B,QAAAM;AAAA,QACH,QAAA,CAAAG,MAAA;;AAEC,WAAAF,IAAAP,EAAA,WAAA,QAAAO,EAAA,KAAAP,GAAAS,KAEAC,IAAAN,EAAA,iBAAA,QAAAM,EAAA;AAAA,QAAmD;AAAA,MACpD;AAGD,MAAAN,EAAA,eAAA,IAAAL,EAAA,KAAAS,CAAA;AAAA,IAA4C,CAAA,GAG7CG,EAAA,MAAA;;AACC,OAAAJ,IAAAH,EAAA,iBAAA,QAAAG,EAAA;AAAA,IAA8B,CAAA,GAG/BK,EAAAR,CAAA;MAI4C,SAAA;AAAA,MAA/B,KAAAF;AAAA,MAAA,OAAA;AAAA,IAAW,GAAA,MAAA,GAAA;AAAA;;"}
1
+ {"version":3,"file":"extra.js","sources":["../../src/components/extra/rive/rive.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { onUnmounted, ref, watch } from 'vue';\nimport type { Rive, RiveParameters } from '@rive-app/canvas-lite';\nimport type { Props } from './types';\n\nlet rive: typeof import('@rive-app/canvas-lite');\n\nconst props = withDefaults(defineProps<Props>(), {\n\tautoplay: true,\n});\n\nconst el = ref<HTMLCanvasElement>();\n\nconst topRive = {\n\triveInstance: undefined as Rive | undefined,\n};\n\nwatch([el, props], async () => {\n\tif (!rive) rive = await import('@rive-app/canvas-lite');\n\n\tconst canvas = el.value;\n\tif (!canvas) return;\n\n\ttopRive.riveInstance?.cleanup();\n\n\tconst options: RiveParameters = {\n\t\t...props,\n\t\tcanvas,\n\t\tonLoad: (e) => {\n\t\t\tprops.onLoad?.(e);\n\n\t\t\ttopRive.riveInstance?.resizeDrawingSurfaceToCanvas();\n\t\t},\n\t};\n\n\ttopRive.riveInstance = new rive.Rive(options);\n});\n\nonUnmounted(() => {\n\ttopRive.riveInstance?.cleanup();\n});\n\ndefineExpose(topRive);\n</script>\n\n<template>\n\t<canvas ref=\"el\" class=\"top-rive\"></canvas>\n</template>\n\n<style>\n.top-rive {\n\twidth: 100%;\n\theight: 100%;\n\tflex-grow: 1;\n}\n</style>\n"],"names":["rive","props","__props","el","ref","topRive","watch","canvas","_a","options","e","_b","onUnmounted","__expose","_createElementBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,QAAIA;AAEJ,UAAMC,IAAQC,GAIRC,IAAKC,EAAA,GAELC,IAAU;AAAA,MACf,cAAc;AAAA,IAAA;AAGf,WAAAC,EAAM,CAACH,GAAIF,CAAK,GAAG,YAAY;;AAC9B,MAAKD,MAAMA,IAAO,MAAM,OAAO,uBAAuB;AAEtD,YAAMO,IAASJ,EAAG;AAClB,UAAI,CAACI,EAAQ;AAEb,OAAAC,IAAAH,EAAQ,iBAAR,QAAAG,EAAsB;AAEtB,YAAMC,IAA0B;AAAA,QAC/B,GAAGR;AAAA,QACH,QAAAM;AAAA,QACA,QAAQ,CAACG,MAAM;;AACd,WAAAF,IAAAP,EAAM,WAAN,QAAAO,EAAA,KAAAP,GAAeS,KAEfC,IAAAN,EAAQ,iBAAR,QAAAM,EAAsB;AAAA,QACvB;AAAA,MAAA;AAGD,MAAAN,EAAQ,eAAe,IAAIL,EAAK,KAAKS,CAAO;AAAA,IAC7C,CAAC,GAEDG,EAAY,MAAM;;AACjB,OAAAJ,IAAAH,EAAQ,iBAAR,QAAAG,EAAsB;AAAA,IACvB,CAAC,GAEDK,EAAaR,CAAO,mBAInBS,EAA2C,UAAA;AAAA,eAA/B;AAAA,MAAJ,KAAIX;AAAA,MAAK,OAAM;AAAA,IAAA;;;"}
package/forms/forms.js CHANGED
@@ -1,4 +1,4 @@
1
- import { h as p, c as T, Q as s, j as t, k as e, f as r, _ as n, l, m as c, T as i, r as u, n as b, o as d, p as h, q as x } from "../.chunks/forms-BWoAyEVH.es.js";
1
+ import { h as p, c as T, Q as s, j as t, k as e, f as r, _ as n, l, m as c, T as i, r as u, n as b, o as d, p as h, q as x } from "../.chunks/forms-CuEEAPvm.es.js";
2
2
  export {
3
3
  p as TopAvatar,
4
4
  T as TopButton,
@@ -1,2 +1,2 @@
1
- define(["require","exports","vue","../.chunks/forms-BfDSGwrU.amd","../.chunks/listItem.vue_vue_type_script_setup_true_lang-R7J0Cawj.amd","../.chunks/widgetInput.vue_vue_type_script_setup_true_lang-DVHWVUQM.amd","../.chunks/popupHint.vue_vue_type_style_index_0_lang-BCpRWeKK.amd","../utils/keyboard.amd","../.chunks/menu.vue_vue_type_style_index_0_lang-JZ-QwyLO.amd","../require/css.amd!../assets/formsExt.css"],(function(te,w,e,C,E,_,oe,I,S){"use strict";if(typeof e>"u")var e=window.Vue;const N={class:"top-editArea_footer"},M=e.defineComponent({__name:"editArea",props:{defaultValue:{default:""},title:{},cancelText:{default:"Cancel"},submitText:{default:"Send"},closeText:{default:"Close"},isFocused:{type:Boolean},forceShowCloseBtn:{type:Boolean},attachToKeyboard:{type:Boolean},modelValue:{},name:{},placeholder:{},styling:{},rows:{},minHeight:{},expandable:{type:Boolean,default:!0},disabled:{type:Boolean},readonly:{type:Boolean},isError:{type:Boolean},hint:{},maxLength:{}},emits:["submit","close","clickOnTitle"],setup(r,{emit:t}){const l=r,a=t,c=e.ref(l.defaultValue),s=e.ref(l.isFocused),n=e.computed(()=>c.value!==l.defaultValue),u=d=>{a("submit",d),c.value=l.defaultValue},p=()=>{if(l.forceShowCloseBtn&&!n.value){a("close");return}c.value=l.defaultValue},k=()=>{l.attachToKeyboard&&a("clickOnTitle")};return(d,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-editArea":!0,"top-editArea-attachedToKeyboard":d.attachToKeyboard})},[d.title?(e.openBlock(),e.createElementBlock("div",{key:0,class:"top-editArea_title",onClick:f[0]||(f[0]=B=>k())},e.toDisplayString(d.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass({"top-editArea_form":!0,"top-forms-focusable":!0,"top-as-input":!0,"top-error":d.isError,"top-focus":s.value})},[e.createVNode(C._sfc_main$11,{modelValue:c.value,"onUpdate:modelValue":f[1]||(f[1]=B=>c.value=B),name:d.name,placeholder:d.placeholder,rows:d.rows,minHeight:d.minHeight,expandable:d.expandable,disabled:d.disabled,readonly:d.readonly,isError:d.isError,hint:d.hint,class:"top-editArea_element",onFocus:f[2]||(f[2]=()=>s.value=!0),onBlur:f[3]||(f[3]=()=>s.value=!1),onKeyup:[e.withKeys(p,["esc"]),f[4]||(f[4]=e.withKeys(e.withModifiers(B=>u(c.value),["ctrl"]),["enter"]))]},null,8,["modelValue","name","placeholder","rows","minHeight","expandable","disabled","readonly","isError","hint"]),e.createElementVNode("div",N,[n.value||d.forceShowCloseBtn?(e.openBlock(),e.createBlock(C._sfc_main$1,{key:0,icon:d.$core.state.isMobile?"":"",class:"top-editArea_button",color:"theme",styling:"soft",onClick:p},e.createSlots({_:2},[d.$core.state.isMobile?void 0:{name:"default",fn:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.cancelText),1)]),key:"0"}]),1032,["icon"])):e.createCommentVNode("",!0),n.value?(e.openBlock(),e.createBlock(C._sfc_main$1,{key:1,class:"top-editArea_button",icon:d.$core.state.isMobile?"":"",onClick:f[5]||(f[5]=B=>u(c.value))},e.createSlots({_:2},[d.$core.state.isMobile?void 0:{name:"default",fn:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.submitText),1)]),key:"0"}]),1032,["icon"])):e.createCommentVNode("",!0)])],2)],2))}}),L={class:"top-editInput"},z=e.defineComponent({__name:"editInput",props:{modelValue:{},input:{},button:{}},emits:["update:modelValue"],setup(r,{emit:t}){const l=r,a=e.ref(l.modelValue);e.watch(e.toRef(l.modelValue),()=>{a.value=l.modelValue});const c=t,s=()=>{c("update:modelValue",a.value)};return(n,u)=>(e.openBlock(),e.createElementBlock("div",L,[e.createVNode(C._sfc_main,e.mergeProps(n.input,{onKeydownCapture:u[0]||(u[0]=e.withKeys(e.withModifiers(p=>a.value=n.modelValue,["stop"]),["esc"])),onKeydown:e.withKeys(e.withModifiers(s,["stop"]),["enter"]),modelValue:a.value,"onUpdate:modelValue":u[1]||(u[1]=p=>a.value=p)}),null,16,["onKeydown","modelValue"]),a.value!==n.modelValue?(e.openBlock(),e.createBlock(C._sfc_main$1,e.mergeProps({key:0,icon:"",styling:"soft"},n.button,{onClick:s}),null,16)):e.createCommentVNode("",!0)]))}}),$=e.defineComponent({__name:"optionGroup",props:e.mergeModels({modelValue:{},items:{},size:{default:"s"},showIndicator:{type:Boolean},isError:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=e.useModel(r,"modelValue"),l=r,a=e.ref(null);e.watch(t,()=>{var n,u;const s=l.items.map(p=>p.value);Array.isArray(t.value)?t.value.find(k=>!s.includes(k))&&(t.value=t.value.filter(k=>s.includes(k))):s.includes(t.value)||(t.value=s[0]??""),(u=(n=a.value)==null?void 0:n.querySelector(".radioGroup_item-selected"))==null||u.scrollIntoView()},{immediate:!0});const c="optionGroup-"+Math.random();return(s,n)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"elRef",ref:a,class:e.normalizeClass({"top-optionGroup":!0,["top-optionGroup-showIndicator_"+Number(s.showIndicator)]:!0,"top-scrollBarXHidding":!0,["top-size_"+s.size]:!!s.size,"top-error":s.isError})},[Array.isArray(t.value)?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(s.items,u=>(e.openBlock(),e.createBlock(C._sfc_main$4,{class:e.normalizeClass({"top-optionGroup_item-selected":t.value.includes(u.value),"top-optionGroup_item":!0}),modelValue:t.value,"onUpdate:modelValue":n[0]||(n[0]=p=>t.value=p),value:u.value,disabled:u.disabled,isError:s.isError,"data-top-icon":u.icon},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.title),1)]),_:2},1032,["class","modelValue","value","disabled","isError","data-top-icon"]))),256)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(s.items,u=>(e.openBlock(),e.createBlock(C._sfc_main$8,{class:e.normalizeClass({"top-optionGroup_item-selected":u.value===t.value,"top-optionGroup_item":!0}),modelValue:t.value,"onUpdate:modelValue":n[1]||(n[1]=p=>t.value=p),name:c,value:u.value,disabled:u.disabled,isError:s.isError,"data-top-icon":u.icon},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.title),1)]),_:2},1032,["class","modelValue","value","disabled","isError","data-top-icon"]))),256))],2))}}),D=e.defineComponent({__name:"radioGroup",props:e.mergeModels({modelValue:{},items:{},size:{},showIndicator:{type:Boolean},isError:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=e.useModel(r,"modelValue");return(l,a)=>(e.openBlock(),e.createBlock($,{class:"top-radioGroup",modelValue:t.value,"onUpdate:modelValue":a[0]||(a[0]=c=>t.value=c),items:l.$props.items,size:l.$props.size,showIndicator:l.$props.showIndicator,isError:l.$props.isError},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"default")]),_:3},8,["modelValue","items","size","showIndicator","isError"]))}}),K=e.defineComponent({__name:"checkboxGroup",props:e.mergeModels({modelValue:{},items:{},size:{},showIndicator:{type:Boolean},isError:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=e.useModel(r,"modelValue");return(l,a)=>(e.openBlock(),e.createBlock($,{class:"top-checkboxGroup",modelValue:t.value,"onUpdate:modelValue":a[0]||(a[0]=c=>t.value=c),items:l.$props.items,size:l.$props.size,showIndicator:l.$props.showIndicator,isError:l.$props.isError},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"default")]),_:3},8,["modelValue","items","size","showIndicator","isError"]))}}),R={class:"top-selector2_itemMulti top-ellipsis"},P=e.defineComponent({__name:"itemMulti",props:{id:{},name:{}},emits:["delete"],setup(r){return(t,l)=>(e.openBlock(),e.createElementBlock("div",R,[e.createTextVNode(e.toDisplayString(t.name)+" ",1),e.createElementVNode("span",{class:"top-selector2_itemMultiDelete","data-top-icon":"",onClick:l[0]||(l[0]=a=>t.$emit("delete",t.id)),onMousedown:l[1]||(l[1]=e.withModifiers(()=>{},["stop"]))},null,32)]))}}),G=(r,t,l,a)=>{const c=e.ref([]),s=new Map,n=e.ref(!1);let u="",p;r&&!r.params.limit&&(r.params.limit=100);const k=async()=>{if(!r)return;let v;if(a){v=JSON.stringify(r.params);const b=s.get(v);if(b)return b}n.value=!0;const h=await r.call();if(n.value=!1,h.errors)return;if(!Array.isArray(h.result)){console.warn("Array expected in `res.result`");return}const T=h.result.findIndex(b=>b.id===void 0||b.name===void 0);if(T!==-1){console.warn(`В result[${T}] нет id или name`);return}return v&&s.set(v,h),h},d=async v=>{if(!r)return;if(v){if(!p||n.value)return;r.params.offset=p}else r.params.offset=0;t==null||t(u);const h=await k();h&&(p=h.nextOffset,v?c.value=c.value.concat(h.result):c.value=h.result)},f=C.debounce(()=>d(!1),200);return{apiRequest:r,items:c,isLoading:n,load:d,setSearchTextAndLoad:(v,h=!0)=>{r&&(v.length<l||v===u&&c.value.length||(u=v,h?f():d(!1)))}}},O=0,A=(r,t,l=!0)=>l&&t.id===null?Array.isArray(r)?r.some(a=>a.id===t.id&&a.name===t.name):t.name===r.name:Array.isArray(r)?r.some(a=>a.id===t.id):t.id===r.id,q=(r,t,l,a,c,s,n,u)=>{const p=e.ref(""),k={id:O,name:C.useI18n().Common.All},d=()=>{p.value="",u.items.value=[]},f=()=>!(!u.apiRequest||s.value!=="inline"||p.value.length>=n),B=e.computed(()=>{var o;const y=[];return!l&&a.value&&y.push(k),(o=t.value)==null||o.forEach(i=>y.push({...i})),y}),v=e.computed(()=>{const y=p.value.toLowerCase(),o=I.invertKeyboardLayout(y);let i=[];return B.value.forEach(g=>{const m=g.name.toLowerCase();(g.id===Number(y)||m.includes(y)||m.includes(o))&&(m===y||m===o?i.unshift(g):i.push(g))}),i.push(...u.items.value),c.value&&p.value&&(!i.length||i[0].name.toLowerCase()!==y)&&i.push({id:null,name:p.value}),l&&(i=i.filter(g=>!A(r.value,g))),i});return{searchText:p,resetSearch:d,genIsShort:f,items:B,itemsForShow:v,selectItem:y=>{l&&Array.isArray(r.value)?A(r.value,y)||(r.value=[...r.value,y]):r.value=y},selectNextItem:()=>{if(!Array.isArray(r.value)){const o=(v.value.findIndex(i=>i.id===r.value.id)+1)%v.value.length;r.value={...v.value[o]}}},deleteItemById:async y=>{Array.isArray(r.value)&&(r.value=r.value.filter(o=>o.id!==y))}}},F={key:0,class:"top-selector2_activeItems"},H={key:1,class:"top-selector2_activeName top-ellipsis"},U={key:2,class:"top-selector2_placeholder top-ellipsis"},W=e.defineComponent({__name:"selector2",props:e.mergeModels({modelValue:{},items:{default:()=>[]},title:{},disabled:{type:Boolean},modificator:{},size:{default:"s"},isError:{type:Boolean},searchType:{default:"popup"},placeholder:{},api:{},apiSetSearchParams:{},minLength:{default:0},useCache:{type:Boolean},appendSearchToResult:{type:Boolean},multiselect:{type:Boolean},appendAllValue:{type:Boolean},addChanger:{type:Boolean},buttonProps:{},selectedAsPlaceholder:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,l=e.useModel(r,"modelValue"),a=e.computed(()=>t.searchType==="inline"&&t.multiselect||t.searchType==="inline"&&C.Core.state.isMobile?"popup":t.searchType);let c=0;a.value==="inline"&&t.minLength&&(c=t.minLength);const s=G(t.api,t.apiSetSearchParams,c,t.useCache),n=q(l,e.toRef(t,"items"),t.multiselect,e.toRef(t,"appendAllValue"),e.toRef(t,"appendSearchToResult"),a,c,s),u=e.computed(()=>t.buttonProps?"TopButton":a.value==="inline"?"TopInput":"div"),p=e.ref(null),k=()=>{var o;return(o=p.value)==null?void 0:o.popup};s.apiRequest&&e.watch(n.searchText,()=>{var o;s.setSearchTextAndLoad(n.searchText.value),a.value==="inline"&&n.genIsShort()&&((o=k())==null||o.close())}),e.watch(l,()=>{a.value==="inline"&&n.resetSearch()});const d=e.computed(()=>{var o;return Array.isArray(l.value)||t.multiselect||!t.selectedAsPlaceholder&&a.value!=="inline"?t.placeholder:((o=l.value)==null?void 0:o.name)||t.placeholder}),f=o=>{var m,V;let i=!1;switch(o.key){case"Delete":case"Backspace":Array.isArray(l.value)&&(o.preventDefault(),o.stopPropagation(),l.value.pop());break;case"ArrowUp":case"ArrowRight":case"ArrowDown":case"ArrowLeft":case"Enter":case" ":i=!0;break;case"Escape":a.value==="inline"&&n.resetSearch();break}const g=o.key.length===1&&!o.ctrlKey&&!o.metaKey;(a.value==="popup"||a.value==="inline")&&g&&(i=!0),(m=k())!=null&&m.elPopup&&(i=!1),i&&(a.value==="popup"&&(o.preventDefault(),o.stopPropagation(),g&&(n.searchText.value||(n.searchText.value=o.key))),(V=o.currentTarget)==null||V.click())};let B=!1;const v=o=>{var i;B||a.value==="inline"&&((i=o.currentTarget)==null||i.click())},h=o=>{var i,g;o.preventDefault(),B=!0,(g=(i=o.currentTarget)==null?void 0:i.parentElement)==null||g.focus(),B=!1,n.selectNextItem()},T=()=>{var o;if(B=!0,s.apiRequest){if(n.genIsShort()){(o=k())==null||o.close();return}s.setSearchTextAndLoad(n.searchText.value,!1)}},b=()=>{setTimeout(()=>{B=!1},100),a.value==="popup"&&n.searchText.value&&n.resetSearch()},y=o=>{const i=o.target;i.scrollTop/(i.scrollHeight-i.offsetHeight)>.8&&s.load(!0)};return window.__STORYBOOK_PREVIEW__&&(e.watch(()=>t.multiselect,()=>{t.multiselect?Array.isArray(l.value)||(l.value=[{id:1,name:"Выбери меня"}]):Array.isArray(l.value)&&(l.value={id:null,name:""})},{immediate:!0}),e.watch(()=>t.searchType,()=>{setTimeout(()=>{location.reload()},500)})),(o,i)=>{const g=e.resolveDirective("top-focus");return e.openBlock(),e.createBlock(e.unref(E._sfc_main),{ref_key:"popupRef",ref:p,onOpen:i[3]||(i[3]=m=>T()),onClose:i[4]||(i[4]=m=>b()),onScrollContentList:i[5]||(i[5]=m=>e.unref(s)?y(m):void 0),notch:a.value!=="inline",transitionDuration:0},e.createSlots({opener:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.value),e.mergeProps(o.buttonProps,{ref:"subcomponentSelector",class:{"top-selector2":!0,"top-selector2-multiselect":o.multiselect,["top-selector2-"+o.modificator]:!!o.modificator,"top-as-input":!o.buttonProps,"top-as-selector":!0,["top-size_"+o.size]:!0,"top-disabled":o.disabled,"top-forms-focusable":!o.disabled,"top-error":o.isError},tabindex:"0",onKeydown:f,placeholder:d.value,modelValue:e.unref(n).searchText.value,"onUpdate:modelValue":i[0]||(i[0]=m=>e.unref(n).searchText.value=m),onFocus:v,onBlur:i[1]||(i[1]=m=>{var V;return(V=k())!=null&&V.isClosed?e.unref(n).resetSearch():""})}),{default:e.withCtx(()=>[o.multiselect?(e.openBlock(),e.createElementBlock("div",F,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,m=>(e.openBlock(),e.createBlock(P,{id:m.id,name:m.name,onDelete:e.unref(n).deleteItemById},null,8,["id","name","onDelete"]))),256))])):e.createCommentVNode("",!0),a.value!=="inline"&&!o.multiselect?(e.openBlock(),e.createElementBlock("span",H,e.toDisplayString(Array.isArray(l.value)?"":l.value.name),1)):e.createCommentVNode("",!0),o.multiselect&&!l.value.length?(e.openBlock(),e.createElementBlock("span",U,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0),o.addChanger&&!o.buttonProps&&!o.multiselect&&e.unref(n).items.value.length>1&&!o.disabled?(e.openBlock(),e.createElementBlock("span",{key:3,class:"top-changer top-changer-selector top-popup_widget","data-top-popup-disabled":"true",onClick:h})):e.createCommentVNode("",!0)]),_:1},16,["class","placeholder","modelValue"])),[[g,o.isError,void 0,{onupdate:!0}]])]),contentList:e.withCtx(()=>{var m;return[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n).itemsForShow.value,V=>(e.openBlock(),e.createBlock(e.unref(E._sfc_main$2),{class:e.normalizeClass({"top-active":!Array.isArray(l.value)&&!o.multiselect&&l.value.id===V.id&&l.value.name===V.name}),key:V.id??void 0,closeByClick:!o.multiselect||e.unref(C.Core).state.isMobile,onClick:le=>e.unref(n).selectItem(V)},{default:e.withCtx(()=>[o.$slots.item?e.renderSlot(o.$slots,"item",{key:0,item:V}):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(V.name),1)],64))]),_:2},1032,["class","closeByClick","onClick"]))),128)),!e.unref(s).isLoading.value&&!e.unref(n).itemsForShow.value.length?(e.openBlock(),e.createBlock(e.unref(E._sfc_main$2),{key:0,type:"regular"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.$i18n.Common.No_results),1)]),_:1})):e.createCommentVNode("",!0),e.unref(s).isLoading.value&&(o.searchType!=="popup"||(m=e.unref(s).apiRequest)!=null&&m.params.offset)?(e.openBlock(),e.createBlock(e.unref(E._sfc_main$2),{key:1,type:"regular"},{default:e.withCtx(()=>[e.createVNode(e.unref(C._sfc_main$12),{type:"circles"})]),_:1})):e.createCommentVNode("",!0)]}),_:2},[a.value==="popup"?{name:"widget",fn:e.withCtx(()=>{var m;return[e.createVNode(e.unref(_._sfc_main),{title:"Поиск",icon:"",modelValue:e.unref(n).searchText.value,"onUpdate:modelValue":i[2]||(i[2]=V=>e.unref(n).searchText.value=V),isLoading:e.unref(s).isLoading.value&&!((m=e.unref(s).apiRequest)!=null&&m.params.offset),placeholder:d.value},null,8,["modelValue","isLoading","placeholder"])]}),key:"0"}:void 0]),1032,["notch"])}}}),j=["data-top-icon"],J={class:"top-info_text"},X={key:0,class:"top-info_value"},Y=e.defineComponent({__name:"info",props:{icon:{},styling:{default:"default"},size:{default:"default"}},setup(r){return(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-info":!0,["top-size_"+t.size]:!0,["top-info-styling_"+t.styling]:!0}),"data-top-icon":t.icon},[e.createElementVNode("div",J,[e.renderSlot(t.$slots,"default")]),t.$slots.additional?(e.openBlock(),e.createElementBlock("span",X,[e.renderSlot(t.$slots,"additional")])):e.createCommentVNode("",!0)],10,j))}}),Q={key:0,class:"top-policy"},Z={class:"top-policy_title"},x=["innerHTML"],ee=e.defineComponent({__name:"policy",props:{title:{},description:{},acceptText:{}},emits:["accept"],setup(r,{emit:t}){const l=t,a=e.ref(!0),c=()=>{a.value=!1,l("accept")};return(s,n)=>a.value?(e.openBlock(),e.createElementBlock("div",Q,[e.createElementVNode("div",Z,e.toDisplayString(s.title),1),e.createElementVNode("div",{class:"top-policy_description",innerHTML:s.description},null,8,x),e.createVNode(e.unref(C._sfc_main$1),{size:"m",onClick:c},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.acceptText),1)]),_:1})])):e.createCommentVNode("",!0)}});w.TopMenu=S._sfc_main,w.TopCheckboxGroup=K,w.TopEditArea=M,w.TopEditInput=z,w.TopInfo=Y,w.TopPolicy=ee,w.TopRadioGroup=D,w.TopSelector2=W,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
1
+ define(["require","exports","vue","../.chunks/forms-BfDSGwrU.amd","../.chunks/listItem.vue_vue_type_script_setup_true_lang-R7J0Cawj.amd","../.chunks/widgetInput.vue_vue_type_script_setup_true_lang-DVHWVUQM.amd","../.chunks/popupHint.vue_vue_type_style_index_0_lang-Cce9ZdtW.amd","../utils/keyboard.amd","../.chunks/menu.vue_vue_type_style_index_0_lang-JZ-QwyLO.amd","../require/css.amd!../assets/formsExt.css","../require/css.amd!../assets/popupHint.css"],(function(te,w,e,C,E,_,oe,I,S){"use strict";if(typeof e>"u")var e=window.Vue;const N={class:"top-editArea_footer"},M=e.defineComponent({__name:"editArea",props:{defaultValue:{default:""},title:{},cancelText:{default:"Cancel"},submitText:{default:"Send"},closeText:{default:"Close"},isFocused:{type:Boolean},forceShowCloseBtn:{type:Boolean},attachToKeyboard:{type:Boolean},modelValue:{},name:{},placeholder:{},styling:{},rows:{},minHeight:{},expandable:{type:Boolean,default:!0},disabled:{type:Boolean},readonly:{type:Boolean},isError:{type:Boolean},hint:{},maxLength:{}},emits:["submit","close","clickOnTitle"],setup(r,{emit:t}){const l=r,a=t,c=e.ref(l.defaultValue),s=e.ref(l.isFocused),n=e.computed(()=>c.value!==l.defaultValue),u=d=>{a("submit",d),c.value=l.defaultValue},p=()=>{if(l.forceShowCloseBtn&&!n.value){a("close");return}c.value=l.defaultValue},k=()=>{l.attachToKeyboard&&a("clickOnTitle")};return(d,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-editArea":!0,"top-editArea-attachedToKeyboard":d.attachToKeyboard})},[d.title?(e.openBlock(),e.createElementBlock("div",{key:0,class:"top-editArea_title",onClick:f[0]||(f[0]=B=>k())},e.toDisplayString(d.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass({"top-editArea_form":!0,"top-forms-focusable":!0,"top-as-input":!0,"top-error":d.isError,"top-focus":s.value})},[e.createVNode(C._sfc_main$11,{modelValue:c.value,"onUpdate:modelValue":f[1]||(f[1]=B=>c.value=B),name:d.name,placeholder:d.placeholder,rows:d.rows,minHeight:d.minHeight,expandable:d.expandable,disabled:d.disabled,readonly:d.readonly,isError:d.isError,hint:d.hint,class:"top-editArea_element",onFocus:f[2]||(f[2]=()=>s.value=!0),onBlur:f[3]||(f[3]=()=>s.value=!1),onKeyup:[e.withKeys(p,["esc"]),f[4]||(f[4]=e.withKeys(e.withModifiers(B=>u(c.value),["ctrl"]),["enter"]))]},null,8,["modelValue","name","placeholder","rows","minHeight","expandable","disabled","readonly","isError","hint"]),e.createElementVNode("div",N,[n.value||d.forceShowCloseBtn?(e.openBlock(),e.createBlock(C._sfc_main$1,{key:0,icon:d.$core.state.isMobile?"":"",class:"top-editArea_button",color:"theme",styling:"soft",onClick:p},e.createSlots({_:2},[d.$core.state.isMobile?void 0:{name:"default",fn:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.cancelText),1)]),key:"0"}]),1032,["icon"])):e.createCommentVNode("",!0),n.value?(e.openBlock(),e.createBlock(C._sfc_main$1,{key:1,class:"top-editArea_button",icon:d.$core.state.isMobile?"":"",onClick:f[5]||(f[5]=B=>u(c.value))},e.createSlots({_:2},[d.$core.state.isMobile?void 0:{name:"default",fn:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.submitText),1)]),key:"0"}]),1032,["icon"])):e.createCommentVNode("",!0)])],2)],2))}}),L={class:"top-editInput"},z=e.defineComponent({__name:"editInput",props:{modelValue:{},input:{},button:{}},emits:["update:modelValue"],setup(r,{emit:t}){const l=r,a=e.ref(l.modelValue);e.watch(e.toRef(l.modelValue),()=>{a.value=l.modelValue});const c=t,s=()=>{c("update:modelValue",a.value)};return(n,u)=>(e.openBlock(),e.createElementBlock("div",L,[e.createVNode(C._sfc_main,e.mergeProps(n.input,{onKeydownCapture:u[0]||(u[0]=e.withKeys(e.withModifiers(p=>a.value=n.modelValue,["stop"]),["esc"])),onKeydown:e.withKeys(e.withModifiers(s,["stop"]),["enter"]),modelValue:a.value,"onUpdate:modelValue":u[1]||(u[1]=p=>a.value=p)}),null,16,["onKeydown","modelValue"]),a.value!==n.modelValue?(e.openBlock(),e.createBlock(C._sfc_main$1,e.mergeProps({key:0,icon:"",styling:"soft"},n.button,{onClick:s}),null,16)):e.createCommentVNode("",!0)]))}}),$=e.defineComponent({__name:"optionGroup",props:e.mergeModels({modelValue:{},items:{},size:{default:"s"},showIndicator:{type:Boolean},isError:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=e.useModel(r,"modelValue"),l=r,a=e.ref(null);e.watch(t,()=>{var n,u;const s=l.items.map(p=>p.value);Array.isArray(t.value)?t.value.find(k=>!s.includes(k))&&(t.value=t.value.filter(k=>s.includes(k))):s.includes(t.value)||(t.value=s[0]??""),(u=(n=a.value)==null?void 0:n.querySelector(".radioGroup_item-selected"))==null||u.scrollIntoView()},{immediate:!0});const c="optionGroup-"+Math.random();return(s,n)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"elRef",ref:a,class:e.normalizeClass({"top-optionGroup":!0,["top-optionGroup-showIndicator_"+Number(s.showIndicator)]:!0,"top-scrollBarXHidding":!0,["top-size_"+s.size]:!!s.size,"top-error":s.isError})},[Array.isArray(t.value)?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(s.items,u=>(e.openBlock(),e.createBlock(C._sfc_main$4,{class:e.normalizeClass({"top-optionGroup_item-selected":t.value.includes(u.value),"top-optionGroup_item":!0}),modelValue:t.value,"onUpdate:modelValue":n[0]||(n[0]=p=>t.value=p),value:u.value,disabled:u.disabled,isError:s.isError,"data-top-icon":u.icon},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.title),1)]),_:2},1032,["class","modelValue","value","disabled","isError","data-top-icon"]))),256)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(s.items,u=>(e.openBlock(),e.createBlock(C._sfc_main$8,{class:e.normalizeClass({"top-optionGroup_item-selected":u.value===t.value,"top-optionGroup_item":!0}),modelValue:t.value,"onUpdate:modelValue":n[1]||(n[1]=p=>t.value=p),name:c,value:u.value,disabled:u.disabled,isError:s.isError,"data-top-icon":u.icon},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.title),1)]),_:2},1032,["class","modelValue","value","disabled","isError","data-top-icon"]))),256))],2))}}),D=e.defineComponent({__name:"radioGroup",props:e.mergeModels({modelValue:{},items:{},size:{},showIndicator:{type:Boolean},isError:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=e.useModel(r,"modelValue");return(l,a)=>(e.openBlock(),e.createBlock($,{class:"top-radioGroup",modelValue:t.value,"onUpdate:modelValue":a[0]||(a[0]=c=>t.value=c),items:l.$props.items,size:l.$props.size,showIndicator:l.$props.showIndicator,isError:l.$props.isError},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"default")]),_:3},8,["modelValue","items","size","showIndicator","isError"]))}}),K=e.defineComponent({__name:"checkboxGroup",props:e.mergeModels({modelValue:{},items:{},size:{},showIndicator:{type:Boolean},isError:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=e.useModel(r,"modelValue");return(l,a)=>(e.openBlock(),e.createBlock($,{class:"top-checkboxGroup",modelValue:t.value,"onUpdate:modelValue":a[0]||(a[0]=c=>t.value=c),items:l.$props.items,size:l.$props.size,showIndicator:l.$props.showIndicator,isError:l.$props.isError},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"default")]),_:3},8,["modelValue","items","size","showIndicator","isError"]))}}),R={class:"top-selector2_itemMulti top-ellipsis"},P=e.defineComponent({__name:"itemMulti",props:{id:{},name:{}},emits:["delete"],setup(r){return(t,l)=>(e.openBlock(),e.createElementBlock("div",R,[e.createTextVNode(e.toDisplayString(t.name)+" ",1),e.createElementVNode("span",{class:"top-selector2_itemMultiDelete","data-top-icon":"",onClick:l[0]||(l[0]=a=>t.$emit("delete",t.id)),onMousedown:l[1]||(l[1]=e.withModifiers(()=>{},["stop"]))},null,32)]))}}),q=(r,t,l,a)=>{const c=e.ref([]),s=new Map,n=e.ref(!1);let u="",p;r&&!r.params.limit&&(r.params.limit=100);const k=async()=>{if(!r)return;let v;if(a){v=JSON.stringify(r.params);const b=s.get(v);if(b)return b}n.value=!0;const h=await r.call();if(n.value=!1,h.errors)return;if(!Array.isArray(h.result)){console.warn("Array expected in `res.result`");return}const T=h.result.findIndex(b=>b.id===void 0||b.name===void 0);if(T!==-1){console.warn(`В result[${T}] нет id или name`);return}return v&&s.set(v,h),h},d=async v=>{if(!r)return;if(v){if(!p||n.value)return;r.params.offset=p}else r.params.offset=0;t==null||t(u);const h=await k();h&&(p=h.nextOffset,v?c.value=c.value.concat(h.result):c.value=h.result)},f=C.debounce(()=>d(!1),200);return{apiRequest:r,items:c,isLoading:n,load:d,setSearchTextAndLoad:(v,h=!0)=>{r&&(v.length<l||v===u&&c.value.length||(u=v,h?f():d(!1)))}}},G=0,A=(r,t,l=!0)=>l&&t.id===null?Array.isArray(r)?r.some(a=>a.id===t.id&&a.name===t.name):t.name===r.name:Array.isArray(r)?r.some(a=>a.id===t.id):t.id===r.id,O=(r,t,l,a,c,s,n,u)=>{const p=e.ref(""),k={id:G,name:C.useI18n().Common.All},d=()=>{p.value="",u.items.value=[]},f=()=>!(!u.apiRequest||s.value!=="inline"||p.value.length>=n),B=e.computed(()=>{var o;const y=[];return!l&&a.value&&y.push(k),(o=t.value)==null||o.forEach(i=>y.push({...i})),y}),v=e.computed(()=>{const y=p.value.toLowerCase(),o=I.invertKeyboardLayout(y);let i=[];return B.value.forEach(g=>{const m=g.name.toLowerCase();(g.id===Number(y)||m.includes(y)||m.includes(o))&&(m===y||m===o?i.unshift(g):i.push(g))}),i.push(...u.items.value),c.value&&p.value&&(!i.length||i[0].name.toLowerCase()!==y)&&i.push({id:null,name:p.value}),l&&(i=i.filter(g=>!A(r.value,g))),i});return{searchText:p,resetSearch:d,genIsShort:f,items:B,itemsForShow:v,selectItem:y=>{l&&Array.isArray(r.value)?A(r.value,y)||(r.value=[...r.value,y]):r.value=y},selectNextItem:()=>{if(!Array.isArray(r.value)){const o=(v.value.findIndex(i=>i.id===r.value.id)+1)%v.value.length;r.value={...v.value[o]}}},deleteItemById:async y=>{Array.isArray(r.value)&&(r.value=r.value.filter(o=>o.id!==y))}}},F={key:0,class:"top-selector2_activeItems"},H={key:1,class:"top-selector2_activeName top-ellipsis"},U={key:2,class:"top-selector2_placeholder top-ellipsis"},W=e.defineComponent({__name:"selector2",props:e.mergeModels({modelValue:{},items:{default:()=>[]},title:{},disabled:{type:Boolean},modificator:{},size:{default:"s"},isError:{type:Boolean},searchType:{default:"popup"},placeholder:{},api:{},apiSetSearchParams:{},minLength:{default:0},useCache:{type:Boolean},appendSearchToResult:{type:Boolean},multiselect:{type:Boolean},appendAllValue:{type:Boolean},addChanger:{type:Boolean},buttonProps:{},selectedAsPlaceholder:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(r){const t=r,l=e.useModel(r,"modelValue"),a=e.computed(()=>t.searchType==="inline"&&t.multiselect||t.searchType==="inline"&&C.Core.state.isMobile?"popup":t.searchType);let c=0;a.value==="inline"&&t.minLength&&(c=t.minLength);const s=q(t.api,t.apiSetSearchParams,c,t.useCache),n=O(l,e.toRef(t,"items"),t.multiselect,e.toRef(t,"appendAllValue"),e.toRef(t,"appendSearchToResult"),a,c,s),u=e.computed(()=>t.buttonProps?"TopButton":a.value==="inline"?"TopInput":"div"),p=e.ref(null),k=()=>{var o;return(o=p.value)==null?void 0:o.popup};s.apiRequest&&e.watch(n.searchText,()=>{var o;s.setSearchTextAndLoad(n.searchText.value),a.value==="inline"&&n.genIsShort()&&((o=k())==null||o.close())}),e.watch(l,()=>{a.value==="inline"&&n.resetSearch()});const d=e.computed(()=>{var o;return Array.isArray(l.value)||t.multiselect||!t.selectedAsPlaceholder&&a.value!=="inline"?t.placeholder:((o=l.value)==null?void 0:o.name)||t.placeholder}),f=o=>{var m,V;let i=!1;switch(o.key){case"Delete":case"Backspace":Array.isArray(l.value)&&(o.preventDefault(),o.stopPropagation(),l.value.pop());break;case"ArrowUp":case"ArrowRight":case"ArrowDown":case"ArrowLeft":case"Enter":case" ":i=!0;break;case"Escape":a.value==="inline"&&n.resetSearch();break}const g=o.key.length===1&&!o.ctrlKey&&!o.metaKey;(a.value==="popup"||a.value==="inline")&&g&&(i=!0),(m=k())!=null&&m.elPopup&&(i=!1),i&&(a.value==="popup"&&(o.preventDefault(),o.stopPropagation(),g&&(n.searchText.value||(n.searchText.value=o.key))),(V=o.currentTarget)==null||V.click())};let B=!1;const v=o=>{var i;B||a.value==="inline"&&((i=o.currentTarget)==null||i.click())},h=o=>{var i,g;o.preventDefault(),B=!0,(g=(i=o.currentTarget)==null?void 0:i.parentElement)==null||g.focus(),B=!1,n.selectNextItem()},T=()=>{var o;if(B=!0,s.apiRequest){if(n.genIsShort()){(o=k())==null||o.close();return}s.setSearchTextAndLoad(n.searchText.value,!1)}},b=()=>{setTimeout(()=>{B=!1},100),a.value==="popup"&&n.searchText.value&&n.resetSearch()},y=o=>{const i=o.target;i.scrollTop/(i.scrollHeight-i.offsetHeight)>.8&&s.load(!0)};return window.__STORYBOOK_PREVIEW__&&(e.watch(()=>t.multiselect,()=>{t.multiselect?Array.isArray(l.value)||(l.value=[{id:1,name:"Выбери меня"}]):Array.isArray(l.value)&&(l.value={id:null,name:""})},{immediate:!0}),e.watch(()=>t.searchType,()=>{setTimeout(()=>{location.reload()},500)})),(o,i)=>{const g=e.resolveDirective("top-focus");return e.openBlock(),e.createBlock(e.unref(E._sfc_main),{ref_key:"popupRef",ref:p,onOpen:i[3]||(i[3]=m=>T()),onClose:i[4]||(i[4]=m=>b()),onScrollContentList:i[5]||(i[5]=m=>e.unref(s)?y(m):void 0),notch:a.value!=="inline",transitionDuration:0},e.createSlots({opener:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.value),e.mergeProps(o.buttonProps,{ref:"subcomponentSelector",class:{"top-selector2":!0,"top-selector2-multiselect":o.multiselect,["top-selector2-"+o.modificator]:!!o.modificator,"top-as-input":!o.buttonProps,"top-as-selector":!0,["top-size_"+o.size]:!0,"top-disabled":o.disabled,"top-forms-focusable":!o.disabled,"top-error":o.isError},tabindex:"0",onKeydown:f,placeholder:d.value,modelValue:e.unref(n).searchText.value,"onUpdate:modelValue":i[0]||(i[0]=m=>e.unref(n).searchText.value=m),onFocus:v,onBlur:i[1]||(i[1]=m=>{var V;return(V=k())!=null&&V.isClosed?e.unref(n).resetSearch():""})}),{default:e.withCtx(()=>[o.multiselect?(e.openBlock(),e.createElementBlock("div",F,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,m=>(e.openBlock(),e.createBlock(P,{id:m.id,name:m.name,onDelete:e.unref(n).deleteItemById},null,8,["id","name","onDelete"]))),256))])):e.createCommentVNode("",!0),a.value!=="inline"&&!o.multiselect?(e.openBlock(),e.createElementBlock("span",H,e.toDisplayString(Array.isArray(l.value)?"":l.value.name),1)):e.createCommentVNode("",!0),o.multiselect&&!l.value.length?(e.openBlock(),e.createElementBlock("span",U,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0),o.addChanger&&!o.buttonProps&&!o.multiselect&&e.unref(n).items.value.length>1&&!o.disabled?(e.openBlock(),e.createElementBlock("span",{key:3,class:"top-changer top-changer-selector top-popup_widget","data-top-popup-disabled":"true",onClick:h})):e.createCommentVNode("",!0)]),_:1},16,["class","placeholder","modelValue"])),[[g,o.isError,void 0,{onupdate:!0}]])]),contentList:e.withCtx(()=>{var m;return[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n).itemsForShow.value,V=>(e.openBlock(),e.createBlock(e.unref(E._sfc_main$2),{class:e.normalizeClass({"top-active":!Array.isArray(l.value)&&!o.multiselect&&l.value.id===V.id&&l.value.name===V.name}),key:V.id??void 0,closeByClick:!o.multiselect||e.unref(C.Core).state.isMobile,onClick:le=>e.unref(n).selectItem(V)},{default:e.withCtx(()=>[o.$slots.item?e.renderSlot(o.$slots,"item",{key:0,item:V}):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(V.name),1)],64))]),_:2},1032,["class","closeByClick","onClick"]))),128)),!e.unref(s).isLoading.value&&!e.unref(n).itemsForShow.value.length?(e.openBlock(),e.createBlock(e.unref(E._sfc_main$2),{key:0,type:"regular"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.$i18n.Common.No_results),1)]),_:1})):e.createCommentVNode("",!0),e.unref(s).isLoading.value&&(o.searchType!=="popup"||(m=e.unref(s).apiRequest)!=null&&m.params.offset)?(e.openBlock(),e.createBlock(e.unref(E._sfc_main$2),{key:1,type:"regular"},{default:e.withCtx(()=>[e.createVNode(e.unref(C._sfc_main$12),{type:"circles"})]),_:1})):e.createCommentVNode("",!0)]}),_:2},[a.value==="popup"?{name:"widget",fn:e.withCtx(()=>{var m;return[e.createVNode(e.unref(_._sfc_main),{title:"Поиск",icon:"",modelValue:e.unref(n).searchText.value,"onUpdate:modelValue":i[2]||(i[2]=V=>e.unref(n).searchText.value=V),isLoading:e.unref(s).isLoading.value&&!((m=e.unref(s).apiRequest)!=null&&m.params.offset),placeholder:d.value},null,8,["modelValue","isLoading","placeholder"])]}),key:"0"}:void 0]),1032,["notch"])}}}),j=["data-top-icon"],J={class:"top-info_text"},X={key:0,class:"top-info_value"},Y=e.defineComponent({__name:"info",props:{icon:{},styling:{default:"default"},size:{default:"default"}},setup(r){return(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-info":!0,["top-size_"+t.size]:!0,["top-info-styling_"+t.styling]:!0}),"data-top-icon":t.icon},[e.createElementVNode("div",J,[e.renderSlot(t.$slots,"default")]),t.$slots.additional?(e.openBlock(),e.createElementBlock("span",X,[e.renderSlot(t.$slots,"additional")])):e.createCommentVNode("",!0)],10,j))}}),Q={key:0,class:"top-policy"},Z={class:"top-policy_title"},x=["innerHTML"],ee=e.defineComponent({__name:"policy",props:{title:{},description:{},acceptText:{}},emits:["accept"],setup(r,{emit:t}){const l=t,a=e.ref(!0),c=()=>{a.value=!1,l("accept")};return(s,n)=>a.value?(e.openBlock(),e.createElementBlock("div",Q,[e.createElementVNode("div",Z,e.toDisplayString(s.title),1),e.createElementVNode("div",{class:"top-policy_description",innerHTML:s.description},null,8,x),e.createVNode(e.unref(C._sfc_main$1),{size:"m",onClick:c},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.acceptText),1)]),_:1})])):e.createCommentVNode("",!0)}});w.TopMenu=S._sfc_main,w.TopCheckboxGroup=K,w.TopEditArea=M,w.TopEditInput=z,w.TopInfo=Y,w.TopPolicy=ee,w.TopRadioGroup=D,w.TopSelector2=W,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
2
2
  //# sourceMappingURL=formsExt.amd.js.map