@opengis/bi 1.2.32 → 1.2.34

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 (74) hide show
  1. package/README.md +92 -92
  2. package/dist/bi.js +1 -1
  3. package/dist/bi.umd.cjs +68 -68
  4. package/dist/{import-file-D-ISqB7l.js → import-file-BwxPX622.js} +1132 -1079
  5. package/dist/style.css +1 -1
  6. package/dist/{vs-funnel-bar-aoZzvriV.js → vs-funnel-bar-BV18EA4K.js} +3 -3
  7. package/dist/{vs-list-CBkyJSBj.js → vs-list-WrrWQ5KF.js} +32 -53
  8. package/dist/{vs-map-C3C11qmT.js → vs-map-CYd9vdrd.js} +3 -3
  9. package/dist/{vs-map-cluster-BsPmHIMx.js → vs-map-cluster-5TnGPuBH.js} +3 -3
  10. package/dist/{vs-number-d58ftpH5.js → vs-number-DUeRr7uz.js} +3 -3
  11. package/dist/{vs-table-BHa5Velm.js → vs-table-CZJnXfUv.js} +6 -6
  12. package/dist/{vs-text-Bq87gMTx.js → vs-text-D3nCPkgk.js} +4 -4
  13. package/package.json +77 -77
  14. package/plugin.js +21 -21
  15. package/server/helpers/mdToHTML.js +17 -17
  16. package/server/migrations/bi.dataset.sql +46 -46
  17. package/server/migrations/bi.sql +114 -114
  18. package/server/plugins/docs.js +48 -48
  19. package/server/plugins/hook.js +89 -89
  20. package/server/routes/dashboard/controllers/dashboard.import.js +103 -103
  21. package/server/routes/dashboard/controllers/dashboard.js +158 -158
  22. package/server/routes/dashboard/controllers/dashboard.list.js +60 -60
  23. package/server/routes/dashboard/controllers/utils/yaml.js +11 -11
  24. package/server/routes/dashboard/index.mjs +26 -26
  25. package/server/routes/data/controllers/data.js +230 -230
  26. package/server/routes/data/controllers/util/chartSQL.js +49 -49
  27. package/server/routes/data/controllers/util/normalizeData.js +65 -65
  28. package/server/routes/data/index.mjs +38 -38
  29. package/server/routes/dataset/controllers/bi.dataset.list.js +29 -29
  30. package/server/routes/dataset/controllers/bi.db.list.js +19 -19
  31. package/server/routes/dataset/controllers/comment.js +55 -55
  32. package/server/routes/dataset/controllers/createDatasetPost.js +134 -134
  33. package/server/routes/dataset/controllers/data.js +149 -149
  34. package/server/routes/dataset/controllers/dbTablePreview.js +58 -58
  35. package/server/routes/dataset/controllers/dbTables.js +34 -34
  36. package/server/routes/dataset/controllers/delete.js +40 -40
  37. package/server/routes/dataset/controllers/deleteDataset.js +52 -52
  38. package/server/routes/dataset/controllers/editDataset.js +90 -90
  39. package/server/routes/dataset/controllers/export.js +214 -214
  40. package/server/routes/dataset/controllers/form.js +99 -99
  41. package/server/routes/dataset/controllers/format.js +46 -46
  42. package/server/routes/dataset/controllers/insert.js +47 -47
  43. package/server/routes/dataset/controllers/table.js +68 -68
  44. package/server/routes/dataset/controllers/update.js +43 -43
  45. package/server/routes/dataset/index.mjs +132 -132
  46. package/server/routes/dataset/utils/convertJSONToCSV.js +17 -17
  47. package/server/routes/dataset/utils/convertJSONToXls.js +47 -47
  48. package/server/routes/dataset/utils/createTableQuery.js +59 -59
  49. package/server/routes/dataset/utils/datasetForms.js +1 -1
  50. package/server/routes/dataset/utils/descriptionList.js +45 -45
  51. package/server/routes/dataset/utils/downloadRemoteFile.js +58 -58
  52. package/server/routes/dataset/utils/executeQuery.js +46 -46
  53. package/server/routes/dataset/utils/getLayersData.js +106 -106
  54. package/server/routes/dataset/utils/getTableData.js +46 -46
  55. package/server/routes/dataset/utils/insertDataQuery.js +12 -12
  56. package/server/routes/dataset/utils/metaFormat.js +24 -24
  57. package/server/routes/edit/controllers/dashboard.add.js +36 -36
  58. package/server/routes/edit/controllers/dashboard.delete.js +39 -39
  59. package/server/routes/edit/controllers/dashboard.edit.js +61 -61
  60. package/server/routes/edit/controllers/widget.add.js +78 -78
  61. package/server/routes/edit/controllers/widget.del.js +58 -58
  62. package/server/routes/edit/controllers/widget.edit.js +115 -115
  63. package/server/routes/edit/index.mjs +33 -33
  64. package/server/routes/map/controllers/cluster.js +125 -125
  65. package/server/routes/map/controllers/clusterVtile.js +166 -166
  66. package/server/routes/map/controllers/geojson.js +127 -127
  67. package/server/routes/map/controllers/heatmap.js +118 -118
  68. package/server/routes/map/controllers/map.js +69 -69
  69. package/server/routes/map/controllers/utils/downloadClusterData.js +44 -44
  70. package/server/routes/map/controllers/vtile.js +183 -183
  71. package/server/routes/map/index.mjs +32 -32
  72. package/server/templates/page/login.html +58 -58
  73. package/server/utils/getWidget.js +118 -118
  74. package/utils.js +12 -12
package/dist/bi.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- (function(j,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-router")):typeof define=="function"&&define.amd?define(["exports","vue","vue-router"],e):(j=typeof globalThis<"u"?globalThis:j||self,e(j.bi={},j.Vue,j.vueRouter))})(this,function(j,e,K){"use strict";var Kc=Object.defineProperty;var Yc=(j,e,K)=>e in j?Kc(j,e,{enumerable:!0,configurable:!0,writable:!0,value:K}):j[e]=K;var O=(j,e,K)=>Yc(j,typeof e!="symbol"?e+"":e,K);/**
1
+ (function(R,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-router")):typeof define=="function"&&define.amd?define(["exports","vue","vue-router"],e):(R=typeof globalThis<"u"?globalThis:R||self,e(R.bi={},R.Vue,R.vueRouter))})(this,function(R,e,K){"use strict";var Kc=Object.defineProperty;var Yc=(R,e,K)=>e in R?Kc(R,e,{enumerable:!0,configurable:!0,writable:!0,value:K}):R[e]=K;var O=(R,e,K)=>Yc(R,typeof e!="symbol"?e+"":e,K);/**
2
2
  * @license lucide-vue-next v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const gr=(...r)=>r.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();/**
16
+ */const gr=(...r)=>r.filter((t,s,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===s).join(" ").trim();/**
17
17
  * @license lucide-vue-next v0.577.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
@@ -23,7 +23,7 @@
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const br=r=>r.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());/**
26
+ */const br=r=>r.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,s,n)=>n?n.toUpperCase():s.toLowerCase());/**
27
27
  * @license lucide-vue-next v0.577.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
@@ -38,12 +38,12 @@
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const xr=({name:r,iconNode:t,absoluteStrokeWidth:n,"absolute-stroke-width":s,strokeWidth:o,"stroke-width":l,size:a=ue.width,color:i=ue.stroke,...c},{slots:d})=>e.h("svg",{...ue,...c,width:a,height:a,stroke:i,"stroke-width":Ke(n)||Ke(s)||n===!0||s===!0?Number(o||l||ue["stroke-width"])*24/Number(a):o||l||ue["stroke-width"],class:gr("lucide",c.class,...r?[`lucide-${Ye(yr(r))}-icon`,`lucide-${Ye(r)}`]:["lucide-icon"]),...!d.default&&!fr(c)&&{"aria-hidden":"true"}},[...t.map(p=>e.h(...p)),...d.default?[d.default()]:[]]);/**
41
+ */const xr=({name:r,iconNode:t,absoluteStrokeWidth:s,"absolute-stroke-width":n,strokeWidth:o,"stroke-width":a,size:l=ue.width,color:i=ue.stroke,...c},{slots:d})=>e.h("svg",{...ue,...c,width:l,height:l,stroke:i,"stroke-width":Ke(s)||Ke(n)||s===!0||n===!0?Number(o||a||ue["stroke-width"])*24/Number(l):o||a||ue["stroke-width"],class:gr("lucide",c.class,...r?[`lucide-${Ye(yr(r))}-icon`,`lucide-${Ye(r)}`]:["lucide-icon"]),...!d.default&&!fr(c)&&{"aria-hidden":"true"}},[...t.map(p=>e.h(...p)),...d.default?[d.default()]:[]]);/**
42
42
  * @license lucide-vue-next v0.577.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
45
45
  * See the LICENSE file in the root directory of this source tree.
46
- */const G=(r,t)=>(n,{slots:s,attrs:o})=>e.h(xr,{...o,...n,iconNode:t,name:r},s);/**
46
+ */const G=(r,t)=>(s,{slots:n,attrs:o})=>e.h(xr,{...o,...s,iconNode:t,name:r},n);/**
47
47
  * @license lucide-vue-next v0.577.0 - ISC
48
48
  *
49
49
  * This source code is licensed under the ISC license.
@@ -83,17 +83,17 @@
83
83
  *
84
84
  * This source code is licensed under the ISC license.
85
85
  * See the LICENSE file in the root directory of this source tree.
86
- */const Vr=G("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
86
+ */const Dr=G("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
87
87
  * @license lucide-vue-next v0.577.0 - ISC
88
88
  *
89
89
  * This source code is licensed under the ISC license.
90
90
  * See the LICENSE file in the root directory of this source tree.
91
- */const Cr=G("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
91
+ */const Vr=G("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
92
92
  * @license lucide-vue-next v0.577.0 - ISC
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const Dr=G("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);/**
96
+ */const Cr=G("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);/**
97
97
  * @license lucide-vue-next v0.577.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
@@ -128,74 +128,74 @@
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const Tr=G("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/**
131
+ */const Ir=G("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/**
132
132
  * @license lucide-vue-next v0.577.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
135
135
  * See the LICENSE file in the root directory of this source tree.
136
- */const nt=G("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ie={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},Ir=["onClick"],Mr={class:"flex items-center justify-between w-full"},Pr={key:0},Fr=e.defineComponent({__name:"vs-bi-dropdown",props:{title:{},options:{},value:{default:null}},emits:["selected"],setup(r,{emit:t}){const n=r,s=t,o=e.ref(!1),l=e.ref(n.value??null),a=e.ref(null),i=e.computed(()=>{const f=n.options;return typeof f=="string"?f.split(",").map((u,y)=>({id:y,text:u.trim()})):Array.isArray(f)?f:[]}),c=e.computed(()=>{const f=i.value.find(u=>(u.id??u)===l.value);return f?f.text??String(f):n.title??""}),d=f=>{const u=(f==null?void 0:f.id)??f;l.value=u,o.value=!1,s("selected",u),document.removeEventListener("click",p)},p=f=>{a.value&&!a.value.contains(f.target)&&(o.value=!1,document.removeEventListener("click",p))},h=()=>{o.value=!o.value,o.value?setTimeout(()=>{document.addEventListener("click",p)},200):document.removeEventListener("click",p)},m=f=>(Ie==null?void 0:Ie[f])??f;return e.onUnmounted(()=>{document.removeEventListener("click",p)}),(f,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{type:"button","aria-expanded":"true",class:"hs-select-disabled:pointer-events-none hs-select-disabled:opacity-50 relative group pr-2 -ms-2 py-1.5 pl-2.5 inline-flex shrink-0 justify-center items-center gap-x-1.5 text-sm text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100 before:absolute before:inset-0 before:z-[1] dark:text-neutral-400 dark:hover:bg-neutral-800 dark:focus:bg-neutral-700",onClick:h},[e.createTextVNode(e.toDisplayString(m(c.value))+" ",1),u[0]||(u[0]=e.createElementVNode("svg",{class:"shrink-0 size-3.5 text-gray-600 dark:text-neutral-400",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"m6 9 6 6 6-6"})],-1))]),o.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"biDropdown",ref:a,"data-hs-select-dropdown":"",class:"absolute mt-2 z-50 w-48 p-1 space-y-0.5 bg-white rounded-xl shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] dark:bg-neutral-950 opened",role:"listbox",tabindex:"-1","aria-orientation":"vertical",style:{"margin-top":"10px"}},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,y=>(e.openBlock(),e.createElementBlock("div",{key:y.id||y,class:"cursor-pointer selected hs-selected:bg-gray-100 dark:hs-selected:bg-neutral-800 py-1.5 px-2 w-full text-[13px] text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:b=>d(y)},[e.createElementVNode("div",Mr,[e.createElementVNode("span",null,e.toDisplayString(m(y.text||y)),1),l.value===(y.id||y)?(e.openBlock(),e.createElementBlock("span",Pr,[...u[1]||(u[1]=[e.createElementVNode("svg",{class:"shrink-0 h-3.5 w-3.5 text-gray-800 dark:text-neutral-200",xmlns:"http:.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)])])):e.createCommentVNode("",!0)])],8,Ir))),128))],512)):e.createCommentVNode("",!0)],64))}}),Rr={class:"flex items-center space-x-2"},jr=e.defineComponent({__name:"vs-bi-switch",props:e.mergeModels({leftLabel:{},rightLabel:{},modelValue:{type:Boolean}},{modelValue:{default:()=>!1,type:Boolean},modelModifiers:{}}),emits:e.mergeModels(["update:is-enabled"],["update:modelValue"]),setup(r,{emit:t}){const n=t,s=e.useModel(r,"modelValue"),o=()=>{n("update:is-enabled",s)};return(l,a)=>(e.openBlock(),e.createElementBlock("div",Rr,[r.leftLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["transition-colors",{"text-blue-500":!s.value}])},e.toDisplayString(r.leftLabel),3)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=i=>s.value=i),type:"checkbox",class:"relative w-11 h-6 p-px bg-gray-100 border-transparent text-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:ring-blue-600 disabled:opacity-50 disabled:pointer-events-none checked:bg-none checked:text-blue-600 checked:border-blue-600 focus:checked:border-blue-600 dark:bg-neutral-800 dark:border-neutral-700 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-600 before:inline-block before:size-5 before:bg-white checked:before:bg-blue-200 before:translate-x-0 checked:before:translate-x-full before:rounded-full before:shadow before:h-5 before:w-5 before:transform before:ring-0 before:transition before:ease-in-out before:duration-200 dark:before:bg-neutral-400 dark:checked:before:bg-blue-200",onChange:o},null,544),[[e.vModelCheckbox,s.value]]),r.rightLabel?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["transition-colors",{"text-blue-500":s.value}])},e.toDisplayString(r.rightLabel),3)):e.createCommentVNode("",!0)]))}}),W=(r,t)=>{const n=r.__vccOpts||r;for(const[s,o]of t)n[s]=o;return n},Wr={},vr={class:"flex items-center justify-center h-full"};function Ar(r,t){return e.openBlock(),e.createElementBlock("div",vr,[...t[0]||(t[0]=[e.createElementVNode("div",{class:"text-center text-gray-500"},[e.createElementVNode("h2",{class:"text-2xl font-bold"},"No data available")],-1)])])}const Or=W(Wr,[["render",Ar]]),st={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ka)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>pi)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>gi)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ul)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>al)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>rl)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>dl)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Bl)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>li)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Fl)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ki)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>yc)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Rc)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Xc))};let ot="/api";function $e(r){ot=r||"/api"}function qr(r,t){const n=ot.replace(/\/$/,""),o=r.startsWith("http")||r.startsWith("//")||n&&r.startsWith(n)?r:`${n}${r.startsWith("/")?r:`/${r}`}`;if(!t||!Object.keys(t).length)return o;const l=new URLSearchParams;Object.entries(t).forEach(([i,c])=>{c!==void 0&&c!==""&&l.set(i,String(c))});const a=l.toString();return a?`${o}${o.includes("?")?"&":"?"}${a}`:o}async function Ee(r,t={}){const{params:n,...s}=t,o=qr(r,n),l={...s.headers};s.body!=null&&(l["Content-Type"]=l["Content-Type"]??"application/json");const a=await fetch(o,{...s,headers:l});if(!a.ok){const c=new Error(a.statusText);throw c.status=a.status,c}const i=await a.text();if(i)try{return JSON.parse(i)}catch{return i}}const H={get(r,t){return Ee(r,{...t,method:"GET"})},post(r,t){return Ee(r,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(r,t){return Ee(r,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(r){return Ee(r,{method:"DELETE"})}};function at(r){if(r==null)return"";const t=String(r);return/[",\n\r]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function Ur(r,t){const n=t.map(at).join(","),s=r.map(o=>t.map(l=>at(o[l])).join(",")).join(`\r
137
- `);return`${n}\r
138
- ${s}`}function lt(r,t,n){const s=new Blob([t],{type:`${n};charset=utf-8`}),o=URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=r,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)}function it(r,t){return((r||t).replace(/[<>:"/\\|?*\u0000-\u001f]/g,"_").trim()||t).slice(0,120)}function ee(r,t){const n=r&&typeof r=="object"&&"value"in r?r.value:r;if(n==null)return"";const s=Number(n);return Number.isNaN(s)?String(n):new Intl.NumberFormat("en",t??{notation:"compact"}).format(s)}function me(r){if(!(r!=null&&r.includes("T")))return r??"";const[t,n,s]=r.split("T")[0].split("-");return`${s}.${n}.${t}`}const ct={year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};function Me(r){if(r==null||r==="")return"";if(r instanceof Date&&!Number.isNaN(r.getTime()))return new Intl.DateTimeFormat("uk-UA",ct).format(r);const t=String(r).trim(),n=t.includes("T")?t:t.replace(/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})/,"$1T$2"),s=new Date(n);return Number.isNaN(s.getTime())?t:new Intl.DateTimeFormat("uk-UA",ct).format(s)}function Hr(r){return Intl.NumberFormat("en").format(r??0)}const Gr={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"},Zr={class:"flex items-center justify-between w-full gap-2"},Qr={class:"flex flex-col gap-0.5 min-w-0"},Jr={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},Xr={key:0,class:"text-xs text-gray-400 font-normal line-clamp-1"},Kr={class:"flex items-center gap-1 shrink-0"},Yr=["aria-expanded"],en={key:0,class:"absolute right-0 mt-1 z-50 min-w-[180px] p-1 bg-white rounded-xl shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] border border-gray-100",role:"menu"},tn={class:"flex flex-col justify-end"},rn={key:0,class:"flex items-center justify-end w-full gap-2"},nn={key:1,class:"text-xs text-gray-400 mb-2 shrink-0"},sn="Експорт даних віджета",on="Завантажити CSV",an="Завантажити JSON",ln="Експорт зображення (PNG)",fe=e.defineComponent({__name:"vs-widget",props:{config:{default:null},data:{default:null},dashboard:{},prefix:{default:""},widget:{},height:{},filterURl:{},dashboardWidgets:{},selectedWidget:{},prefetchedData:{default:null}},emits:["update:current-widget-data"],setup(r,{emit:t}){function n(g){if(g==null||g==="")return null;if(g instanceof Date)return g;if(typeof g=="object"){const _=g.widget,k=g.dashboard;return _!=null&&_!==""?_:k!=null&&k!==""?k:null}return g}const s=r,o=t,l=e.ref(null),a=e.ref(null),i=e.ref(null),c=e.ref({}),d=e.ref([]),p=e.ref(!1),h=e.ref(null),m=e.computed(()=>{const g=s.config;return s.widget||(g==null?void 0:g.widget)||(g==null?void 0:g.widgetId)||(g==null?void 0:g.id)||(g==null?void 0:g.name)||""}),f=e.computed(()=>{const g=s.config;return s.dashboard||(g==null?void 0:g.dashboard)||(g==null?void 0:g.dashboardId)||""}),u=e.computed(()=>{var g;return s.prefix||((g=s.config)==null?void 0:g.prefix)||""}),y=e.computed(()=>s.data||s.prefetchedData||null);function b(g){const _=g.source;if(Array.isArray(_)&&_[0]&&typeof _[0]=="object")return Object.keys(_[0]);const k=g.columns;return Array.isArray(k)&&k.length?k.map(z=>typeof z=="string"?z:(z==null?void 0:z.name)??"").filter(Boolean):[]}const $=e.computed(()=>{const g=c.value;if((g==null?void 0:g.status)!=null&&g.status>=400)return!1;const _=g==null?void 0:g.source;return Array.isArray(_)&&_.length>0&&b(g).length>0});function w(){p.value=!1,document.removeEventListener("click",x)}function x(g){const _=h.value;_&&!_.contains(g.target)&&w()}function D(){p.value=!p.value,p.value?setTimeout(()=>document.addEventListener("click",x),0):document.removeEventListener("click",x)}function L(){const g=c.value,_=g==null?void 0:g.source;if(!Array.isArray(_)||!_.length)return;const k=b(g);if(!k.length)return;const z=Ur(_,k),q=it(B.value||m.value||"widget","widget");lt(`${q}.csv`,`\uFEFF${z}`,"text/csv"),w()}function E(g,_){return g.map(k=>{const z={};for(const q of _)q in k&&(z[q]=k[q]);return z})}function C(){const g=c.value,_=g==null?void 0:g.source;if(!Array.isArray(_)||!_.length)return;const k=b(g),z=E(_,k),q={title:B.value,widget:m.value,columns:k,source:z},S=it(B.value||m.value||"widget","widget");lt(`${S}.json`,JSON.stringify(q,null,2),"application/json"),w()}const B=e.computed(()=>{var _,k,z;const g=(_=s.dashboardWidgets)==null?void 0:_.find(q=>q.name===m.value);return((k=g==null?void 0:g.data)==null?void 0:k.title)??(g==null?void 0:g.title)??((z=s.config)==null?void 0:z.title)??""}),T=e.computed(()=>{var S,oe,ae;const g=n((S=c.value)==null?void 0:S.last_update),_=n((oe=y.value)==null?void 0:oe.last_update),k=g??_;if(k!=null)return Me(k);const z=(ae=s.dashboardWidgets)==null?void 0:ae.find(le=>le.name===m.value),q=n(z==null?void 0:z.last_update)??(z==null?void 0:z.updated_at)??null;return Me(q)}),M=e.computed(()=>{var k,z,q;const g=(k=s.dashboardWidgets)==null?void 0:k.find(S=>S.name===m.value),_=(z=y.value)==null?void 0:z.type;return(g==null?void 0:g.type)??((q=s.config)==null?void 0:q.type)??_??"text"}),U=e.computed(()=>{var g,_,k;return s.height||((g=s.config)==null?void 0:g.height)||((k=(_=c.value)==null?void 0:_.style)==null?void 0:k.height)||480}),Z=e.computed(()=>{var _;const g=(_=c.value)==null?void 0:_.controls;return!g||typeof g=="boolean"?[]:Object.keys(g).map(k=>({name:k,options:g[k]}))}),Q=e.computed(()=>{const g=M.value?`bi-${M.value}`:"";return g&&g in st?st[g]:null});function N(g,_){var k,z;(z=(k=a.value)==null?void 0:k.changeStyle)==null||z.call(k,g,_)}function V(g,_){const k=d.value.find(z=>z.name===_);k?k.option=g:d.value.push({name:_,option:g}),P()}function P(){var _,k;let g=`/bi-data?dashboard=${f.value}&widget=${m.value}`;d.value.forEach(z=>{g+=`&${z.name}=${z.option}`}),(k=(_=a.value)==null?void 0:_.getDataFromURL)==null||k.call(_,g)}function A(){const g=i.value;if(g!=null&&g.getDataURL){const _=g.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),k=document.createElement("a");k.href=_,k.download="chart.png",document.body.appendChild(k),k.click(),document.body.removeChild(k)}}return e.onMounted(()=>{u.value&&$e(u.value)}),e.onUnmounted(()=>{document.removeEventListener("click",x)}),e.watch(()=>s.filterURl,g=>{var _,k;g&&((k=(_=a.value)==null?void 0:_.setFilter)==null||k.call(_,g))}),e.watch(()=>s.selectedWidget,(g,_)=>{var k;g!==_&&g===((k=c.value)==null?void 0:k.id)&&o("update:current-widget-data",c.value)}),e.watch(c,(g,_)=>{(g==null?void 0:g.id)!==(_==null?void 0:_.id)&&o("update:current-widget-data",g)},{deep:!0}),(g,_)=>{var k,z,q;return e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:l,class:"box-border relative p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto overflow-hidden mb-2 last:mb-0 flex flex-col min-h-0",style:e.normalizeStyle({height:U.value+"px",maxHeight:U.value+"px"})},[["text","cluster","map"].includes(M.value)?T.value?(e.openBlock(),e.createElementBlock("p",nn," Оновлено: "+e.toDisplayString(T.value),1)):e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Gr,[e.createElementVNode("div",Zr,[e.createElementVNode("div",Qr,[e.createElementVNode("span",Jr,e.toDisplayString(B.value),1),T.value?(e.openBlock(),e.createElementBlock("span",Xr," Оновлено: "+e.toDisplayString(T.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Kr,[$.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dataExportRootRef",ref:h,class:"relative"},[e.createElementVNode("button",{type:"button",class:"h-[32px] w-[32px] rounded-lg hover:bg-gray-100 duration-100 flex items-center justify-center",title:sn,"aria-haspopup":"menu","aria-expanded":p.value,onClick:e.withModifiers(D,["stop"])},[e.createVNode(e.unref(et),{size:16,class:"text-gray-800"})],8,Yr),p.value?(e.openBlock(),e.createElementBlock("div",en,[e.createElementVNode("button",{type:"button",role:"menuitem",class:"w-full text-left py-1.5 px-2 text-[13px] text-gray-800 rounded-lg hover:bg-gray-100",onClick:L},e.toDisplayString(on)),e.createElementVNode("button",{type:"button",role:"menuitem",class:"w-full text-left py-1.5 px-2 text-[13px] text-gray-800 rounded-lg hover:bg-gray-100",onClick:C},e.toDisplayString(an))])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),e.createElementVNode("div",tn,[(k=Z.value)!=null&&k.length?(e.openBlock(),e.createElementBlock("span",rn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((z=Z.value)==null?void 0:z.filter(S=>(S==null?void 0:S.options)&&(S==null?void 0:S.name)!=="export"),S=>{var oe,ae;return e.openBlock(),e.createElementBlock("div",{key:S==null?void 0:S.name},[Array.isArray(S==null?void 0:S.options)?(e.openBlock(),e.createBlock(Fr,{key:0,title:S==null?void 0:S.name,options:S==null?void 0:S.options,value:((ae=(oe=c.value)==null?void 0:oe.data)==null?void 0:ae[S==null?void 0:S.name])??null,onSelected:le=>V(le,S==null?void 0:S.name)},null,8,["title","options","value","onSelected"])):typeof S.options=="boolean"?(e.openBlock(),e.createBlock(jr,{key:1,"left-label":S==null?void 0:S.name,"model-value":!!(S!=null&&S.options),"onUpdate:isEnabled":le=>N(S==null?void 0:S.name,le)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(q=Z.value)!=null&&q.some(S=>(S==null?void 0:S.name)==="export")?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"h-[32px] w-[32px] rounded-lg hover:bg-gray-100 duration-100 flex items-center justify-center",title:ln,onClick:A},[e.createVNode(e.unref(_r),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])])),e.createElementVNode("div",{class:"w-full flex-1 min-h-0",onClick:_[2]||(_[2]=e.withModifiers(()=>{},["stop"]))},[Q.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(Q.value),{key:0,ref_key:"chartRef",ref:a,"current-widget":i.value,"onUpdate:currentWidget":_[0]||(_[0]=S=>i.value=S),"widget-data":c.value,"onUpdate:widgetData":_[1]||(_[1]=S=>c.value=S),config:r.config,dashboard:f.value,title:B.value,widget:m.value,prefix:u.value,"prefetched-data":y.value},null,40,["current-widget","widget-data","config","dashboard","title","widget","prefix","prefetched-data"])):(e.openBlock(),e.createBlock(Or,{key:1,class:"w-full h-full"}))])],4)}}}),cn={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},dn={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},pn={class:"max-w-sm mx-auto mt-6"},hn={class:"font-medium text-gray-800 dark:text-neutral-200"},un={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},Be=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("div",cn,[e.createElementVNode("div",null,[e.createElementVNode("div",dn,[n[0]||(n[0]=e.createStaticVNode('<svg class="w-48 mx-auto" viewBox="0 0 178 90" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs></svg>',1)),e.createElementVNode("div",pn,[e.createElementVNode("p",hn,e.toDisplayString(r.title),1),e.createElementVNode("p",un,e.toDisplayString(r.text),1)])])])]))}}),mn={components:{filterIcon:{__name:"filter",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref($r),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},fn={class:"flex items-center"},gn={key:0,type:"button",class:"py-2 px-2.5 ml-3 h-[38px] inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 opacity-60 cursor-not-allowed",disabled:"",title:"Фільтри вимкнено (v3-filter видалено)"};function bn(r,t,n,s,o,l){const a=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",fn,[n.filterScheme?(e.openBlock(),e.createElementBlock("button",gn,[e.createVNode(a),t[0]||(t[0]=e.createTextVNode(" Фільтри ",-1))])):e.createCommentVNode("",!0)])}const yn={components:{VsFilterHeader:W(mn,[["render",bn]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},xn={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},kn={class:"grow"},wn={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},_n={key:0,class:"inline-flex items-center text-sm gap-x-2 text-stone-800 hover:text-stone-500 focus:outline-none focus:text-stone-500 dark:text-neutral-200 dark:hover:text-neutral-400 dark:focus:text-neutral-400"},$n={key:0,class:"flex items-center gap-3"};function En(r,t,n,s,o,l){var i,c,d;const a=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",xn,[e.createElementVNode("div",kn,[e.createElementVNode("h1",wn,e.toDisplayString((i=n.dashboardData)==null?void 0:i.title),1),(c=n.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",_n,e.toDisplayString((d=n.dashboardData)==null?void 0:d.description),1)):e.createCommentVNode("",!0)]),n.filters?(e.openBlock(),e.createElementBlock("div",$n,[e.createVNode(a,{filterScheme:n.filters,"onFilters:changed":t[0]||(t[0]=p=>r.$emit("filters:changed",p))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const Bn=W(yn,[["render",En]]),Vn={key:0,class:"text-gray-400 shrink-0"},Cn=["onClick"],Dn=["onClick"],Nn={key:4,class:"text-gray-900 font-medium truncate"},dt={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(r){const t=r,n=K.useRouter(),s=e.computed(()=>Array.isArray(t.items)?t.items:[]);function o(l){n!=null&&n.push?n.push(l):typeof l=="string"&&(window!=null&&window.location)&&(window.location.href=l)}return(l,a)=>{const i=e.resolveComponent("router-link");return e.openBlock(),e.createElementBlock("nav",{class:e.normalizeClass(["flex items-center gap-2 text-sm text-gray-600",r.compact?"py-1":"py-6"]),"aria-label":"Breadcrumb"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,(c,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d},[d>0?(e.openBlock(),e.createElementBlock("span",Vn,[e.createVNode(e.unref(wr),{class:"w-4 h-4"})])):e.createCommentVNode("",!0),typeof c.onClick=="function"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"hover:text-gray-900 transition-colors cursor-pointer",onClick:p=>c.onClick()},e.toDisplayString(c.label),9,Cn)):e.unref(n)&&c.to?(e.openBlock(),e.createBlock(i,{key:2,to:c.to,class:"hover:text-gray-900 transition-colors"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:2},1032,["to"])):c.to?(e.openBlock(),e.createElementBlock("span",{key:3,class:"hover:text-gray-900 transition-colors cursor-pointer",onClick:p=>o(c.to)},e.toDisplayString(c.label),9,Dn)):(e.openBlock(),e.createElementBlock("span",Nn,e.toDisplayString(c.label),1))],64))),128))],2)}}},Sn={components:{VsWidget:fe,VsNewNodata:Be,VsHeader:Bn,VsBreadcrumbs:dt},props:["id","prefix"],data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},async mounted(){$e(this.prefix||"/api"),await this.fetchData()},methods:{async fetchData(){if(this.id)try{const r=await H.get(`/bi-dashboard/${this.id}`);this.dashboardData=r}catch(r){console.error(r)}},columnClass(r){const t=r!=null&&r.col?r==null?void 0:r.col:12;return{1:"md:w-1/12 sm:w-full",2:"md:w-1/6 sm:w-full",3:"md:w-1/4 sm:w-full",4:"md:w-1/3 sm:w-full",6:"md:w-1/2 sm:w-full",8:"md:w-2/3 sm:w-full",10:"md:w-5/6 sm:w-full",12:"w-full"}[t]||"w-full"},async filterHandler(r){var n;this.filterURl="";let t="&filter=";(n=r==null?void 0:r.url)!=null&&n.length&&(r.url.split("|").forEach(o=>{const l=o.split("=");t+=`${l[0]}=${l[1]}`}),this.filterURl+=t)}}},zn={class:"w-full pb-8 overflow-y-auto mx-auto"},Ln={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function Tn(r,t,n,s,o,l){var c;const a=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",zn,[e.createElementVNode("div",Ln,[o.error||!o.dashboardData?(e.openBlock(),e.createBlock(a,{key:0,class:"col-span-12"})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(((c=o.dashboardData)==null?void 0:c.panels)||[],(d,p)=>{var h,m;return e.openBlock(),e.createElementBlock("div",{key:d.widget||((h=d.widgets)==null?void 0:h.join("-"))||p,class:e.normalizeClass([`col-span-12 lg:col-span-${d.col||12}`,"flex flex-col gap-[10px]"])},[(m=d.widgets)!=null&&m.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(d.widgets,f=>(e.openBlock(),e.createBlock(i,{key:f,dashboard:n.id,widget:f,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl,height:d.height},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl","height"]))),128)):(e.openBlock(),e.createBlock(i,{key:1,class:"flex flex-col",dashboard:n.id,widget:d.widget,"dashboard-widgets":o.dashboardData.widgets,height:d.height,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","height","filter-u-rl"]))],2)}),128))])])}const In=W(Sn,[["render",Tn]]);var pt=(r=>(r.Dashboard="/dashboard",r.BiPlatform="/bi-platform",r.EditorBase="/editor",r.AllDashboards="/dashboards",r.DashboardByName="/dashboards/:name",r))(pt||{}),ht;(r=>{(t=>{t.Bar="bar",t.ListBar="listbar",t.Number="number",t.Text="text",t.Pie="pie",t.Heatmap="heatmap",t.Calendar="calendar",t.Line="line",t.Stat="stat",t.Pivot="pivot",t.Funnel="funnel",t.Progress="progress"})(r.Types||(r.Types={}))})(ht||(ht={}));var J=(r=>(r.AllDashboards="all-dashboards",r.BiPlatform="bi-platform",r.Dashboard="dashboard",r.Erobota="erobota",r.Datatest="datatest",r.Sourcedate="sourcedate",r.Widgetwidget="widgetwidget",r.Test="test",r.Demo="demo",r.Crm="crm",r.Editor="editor-all-dashboards",r.EditorDashboard="editor-dashboard",r.EditorWidget="editor-widget",r.Editordetails="editordetails",r.Dbtables="dbtables",r.Biviewer="biviewer",r.Biviewerinner="biviewerinner",r.Bieditor="bieditor",r.Bieditorinner="bieditorinner",r))(J||{});const Mn={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},Pn={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},Fn={class:"font-medium text-gray-800 dark:text-white"},Rn={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},jn={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},ge=W({__name:"vs-modal",props:{visible:{type:Boolean,default:!1},title:{type:String,default:""},size:{type:String,default:"medium"},closeClickBack:{type:Boolean,default:!1},teleport:{type:String,default:"#modal"}},emits:["close","update:visible"],setup(r,{emit:t}){const n=r,s=t,o=e.computed(()=>n.size==="small"?"md:max-w-[40%] w-full max-w-md":n.size==="lg"?"md:max-w-[70%] w-full max-w-4xl":"md:max-w-[50%] w-full max-w-lg");function l(){s("update:visible",!1),s("close")}function a(i){i.key==="Escape"&&l()}return e.onMounted(()=>{window.addEventListener("keydown",a)}),e.onUnmounted(()=>{window.removeEventListener("keydown",a)}),(i,c)=>(e.openBlock(),e.createBlock(e.Teleport,{to:r.teleport},[r.visible?(e.openBlock(),e.createElementBlock("div",Mn,[e.createElementVNode("div",{class:"absolute inset-0 bg-black/50","aria-hidden":"true",onMousedown:c[0]||(c[0]=d=>r.closeClickBack&&d.target===d.currentTarget&&l())},null,32),e.createVNode(e.Transition,{name:"vs-modal",appear:""},{default:e.withCtx(()=>[r.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["vs-modal-panel relative flex flex-col bg-white dark:bg-[#1A1A1A] rounded-xl shadow-xl max-h-[85vh] min-w-0 border border-gray-200 dark:border-[#454545]",o.value]),role:"dialog","aria-modal":"true",onMousedown:c[1]||(c[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",Pn,[e.createElementVNode("h3",Fn,e.toDisplayString(r.title),1),e.createElementVNode("button",{type:"button",class:"size-8 inline-flex justify-center items-center rounded-full bg-gray-100 text-gray-800 hover:bg-gray-200 dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-300","aria-label":"Закрити",onClick:l},[...c[2]||(c[2]=[e.createElementVNode("svg",{class:"w-4 h-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)])])]),e.createElementVNode("div",Rn,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",jn,[e.renderSlot(i.$slots,"footer",{},void 0,!0)])):e.createCommentVNode("",!0)],34)):e.createCommentVNode("",!0)]),_:3})])):e.createCommentVNode("",!0)],8,["to"]))}},[["__scopeId","data-v-72958ba5"]]),Wn={__name:"icon-plus",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(tt),e.mergeProps(t.$attrs,{size:24}),null,16))}},vn={class:"mb-4 overflow-auto scrollbar max-h-96"},An={__name:"vs-editor-create-widget",props:{columns:{type:Array,default:()=>[]},selectedDashboard:String,inline:{type:Boolean,default:!1}},emits:["update-data"],setup(r,{expose:t,emit:n}){var u;const s=e.defineAsyncComponent(()=>import("@opengis/form")),o=(u=e.getCurrentInstance().proxy)==null?void 0:u.$notify,l=n,a=r,i=e.ref(!1),c=e.ref({}),d=e.ref();function p(){i.value=!0}function h(){i.value=!1}t({open:p,close:h});const m=async()=>{var y;try{const b=(y=d.value)==null?void 0:y.doValidation;typeof b=="function"&&await b(),await H.post(`/bi-dashboard/${a.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await l("update-data"),c.value={},i.value=!1}catch(b){const $=(b==null?void 0:b.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:$})}},f=e.computed(()=>{var y,b,$,w;return{title:{type:"text",label:"Назва віджета",placeholder:"Назва віджета",validators:["required"]},x:{type:"select",label:"Вісь X",view:"buttons",style:{size:"xs"},validators:["required"],options:(b=(y=a.columns)==null?void 0:y.filter(x=>(x==null?void 0:x.type)=="text"||(x==null?void 0:x.type)==="date"||(x==null?void 0:x.type)==="timestamp without time zone"||(x==null?void 0:x.type)==="boolean"||(x==null?void 0:x.type)==="integer"))==null?void 0:b.map(({name:x,type:D})=>({id:x,text:x,type:D}))},metric:{type:"select",label:"Вісь Y",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(w=($=a.columns)==null?void 0:$.filter(x=>(x==null?void 0:x.type)==="numeric"||(x==null?void 0:x.type)==="double precision"))==null?void 0:w.map(({name:x,type:D})=>({id:x,text:x,type:D}))]},col:{type:"select",label:"Кількість колонок",validators:["required"],options:[{id:1,label:1},{id:2,text:2},{id:3,text:3},{id:4,text:4},{id:6,text:6},{id:9,text:9},{id:12,text:12}]},height:{type:"Text",label:"Висота",placeholder:"Висота"},type:{type:"select",view:"buttons",label:"Тип віджета",validators:["required"],options:[{label:"Bar",id:"bar"},{label:"Funnel",id:"funnel"},{label:"Line",id:"line"},{label:"List bar",id:"listbar"},{label:"Number",id:"number"},{label:"Pie",id:"pie"},{label:"Donut",id:"donut"},{label:"Pivot",id:"pivot"},{label:"Table",id:"table"},{label:"Progress",id:"progress"},{label:"Stat",id:"stat"},{label:"Text",id:"text"},{label:"Map",id:"map"}]},text:{type:"Text",ua:"Текст",placeholder:"Текст",conditions:["type","==","text"]},table:{type:"Text",ua:"Таблиця",placeholder:"Таблиця"},query:{type:"Text",ua:"Запит (query)",placeholder:"Запит (query)"},cls:{type:"Text",ua:"Клас (cls)",placeholder:"Клас (cls)"}}});return(y,b)=>{const $=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[r.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock($,{key:0,placement:"right",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("button",{class:"z-50 flex items-center justify-center h-[50px] !w-[50px] text-2xl text-white transition-colors bg-blue-500 rounded-full cursor-pointer hover:bg-blue-700",onClick:p},[e.createVNode(Wn,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[b[1]||(b[1]=e.createTextVNode(" Створити віджет ",-1))]),_:1})),e.createVNode(ge,{teleport:"#modal",visible:i.value,title:"Створити віджет",onClose:h},{footer:e.withCtx(()=>[e.createElementVNode("div",{class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:h,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:m,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Створити ")])]),default:e.withCtx(()=>[e.createElementVNode("div",vn,[e.createVNode(e.unref(s),{ref_key:"form",ref:d,schema:f.value,values:c.value,"onUpdate:values":b[0]||(b[0]=w=>c.value=w)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},ut={__name:"delete",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(Tr),e.mergeProps(t.$attrs,{size:24}),null,16))}},Pe={__name:"close",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(nt),e.mergeProps(t.$attrs,{size:24}),null,16))}},mt={__name:"edit",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(Sr),e.mergeProps(t.$attrs,{size:24}),null,16))}},On={class:"space-y-4"},qn={__name:"vs-editor-form-style",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}}},emits:["update-dashboard"],setup(r,{expose:t,emit:n}){var D,L,E,C;const s=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=n,a=r,i=e.ref(null),c=e.computed(()=>a.dashboardId||i.value),d=((D=a.data)==null?void 0:D.type)||((E=(L=a.data)==null?void 0:L.data)==null?void 0:E.type),h={pie:{label:!1,legend:!0,tooltip:!0},donut:{label:!1,legend:!0,tooltip:!0},bar:{label:!1,legend:!1,tooltip:!0},line:{label:!1,legend:!1,tooltip:!0},funnel:{label:!1,legend:!1,tooltip:!0}}[d]||{label:!1,legend:!1,tooltip:!0},m={show:{label:"Легенда",type:"switcher",title:"Показати легенду"}},f={show:{label:"Тултіп",type:"switcher",title:"Показати тултіп"}},u=(C=a.data)==null?void 0:C.style,y=e.ref(u!=null&&u.label?{...u.label}:{show:h.label}),b=e.ref(u!=null&&u.legend?{...u.legend}:{show:h.legend}),$=e.ref(u!=null&&u.tooltip?{...u.tooltip}:{show:h.tooltip}),w=()=>{const B=new CustomEvent(`update-style-${a.widgetName}`);B.chartId=a.widgetName,B.options={options:{legend:b.value,tooltip:$.value,label:y.value},seriesOptions:y.value},window.dispatchEvent(B)};e.watch(y,w,{deep:!0}),e.watch(b,w,{deep:!0}),e.watch($,w,{deep:!0});const x=async()=>{try{await H.put(`/bi-dashboard/${c.value}/${a.widgetName}`,{style:{legend:b.value,tooltip:$.value,label:y.value}});const B=new CustomEvent(`update-style-${a.widgetName}`);B.chartId=a.widgetName,B.options={options:{legend:b.value,tooltip:$.value,label:y.value},seriesOptions:y.value},window.dispatchEvent(B),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const B=new URLSearchParams(window.top.location.search);i.value=B.get("dashboard"),w()}),t({requestUpdateWidget:x}),(B,T)=>(e.openBlock(),e.createElementBlock("div",On,[e.createVNode(e.unref(s),{schema:m,values:b.value,"onUpdate:values":T[0]||(T[0]=M=>b.value=M),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(s),{schema:f,values:$.value,"onUpdate:values":T[1]||(T[1]=M=>$.value=M),class:"p-0"},null,8,["values"])]))}};function Fe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ie=Fe();function ft(r){ie=r}const gt=/[&<>"']/,Un=new RegExp(gt.source,"g"),bt=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Hn=new RegExp(bt.source,"g"),Gn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},yt=r=>Gn[r];function Y(r,t){if(t){if(gt.test(r))return r.replace(Un,yt)}else if(bt.test(r))return r.replace(Hn,yt);return r}const Zn=/(^|[^\[])\^/g;function v(r,t){let n=typeof r=="string"?r:r.source;t=t||"";const s={replace:(o,l)=>{let a=typeof l=="string"?l:l.source;return a=a.replace(Zn,"$1"),n=n.replace(o,a),s},getRegex:()=>new RegExp(n,t)};return s}function xt(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}const be={exec:()=>null};function kt(r,t){const n=r.replace(/\|/g,(l,a,i)=>{let c=!1,d=a;for(;--d>=0&&i[d]==="\\";)c=!c;return c?"|":" |"}),s=n.split(/ \|/);let o=0;if(s[0].trim()||s.shift(),s.length>0&&!s[s.length-1].trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;o<s.length;o++)s[o]=s[o].trim().replace(/\\\|/g,"|");return s}function ye(r,t,n){const s=r.length;if(s===0)return"";let o=0;for(;o<s&&r.charAt(s-o-1)===t;)o++;return r.slice(0,s-o)}function Qn(r,t){if(r.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<r.length;s++)if(r[s]==="\\")s++;else if(r[s]===t[0])n++;else if(r[s]===t[1]&&(n--,n<0))return s;return-1}function wt(r,t,n,s){const o=t.href,l=t.title?Y(t.title):null,a=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){s.state.inLink=!0;const i={type:"link",raw:n,href:o,title:l,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,i}return{type:"image",raw:n,href:o,title:l,text:Y(a)}}function Jn(r,t){const n=r.match(/^(\s+)(?:```)/);if(n===null)return t;const s=n[1];return t.split(`
139
- `).map(o=>{const l=o.match(/^\s+/);if(l===null)return o;const[a]=l;return a.length>=s.length?o.slice(s.length):o}).join(`
140
- `)}class Ve{constructor(t){O(this,"options");O(this,"rules");O(this,"lexer");this.options=t||ie}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const s=n[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?s:ye(s,`
141
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const s=n[0],o=Jn(s,n[3]||"");return{type:"code",raw:s,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let s=n[2].trim();if(/#$/.test(s)){const o=ye(s,"#");(this.options.pedantic||!o||/ $/.test(o))&&(s=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:ye(n[0],`
142
- `)}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){let s=ye(n[0],`
136
+ */const st=G("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Te={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},Tr=["onClick"],Mr={class:"flex items-center justify-between w-full"},Pr={key:0},Fr=e.defineComponent({__name:"vs-bi-dropdown",props:{title:{},options:{},value:{default:null}},emits:["selected"],setup(r,{emit:t}){const s=r,n=t,o=e.ref(!1),a=e.ref(s.value??null),l=e.ref(null),i=e.computed(()=>{const f=s.options;return typeof f=="string"?f.split(",").map((u,y)=>({id:y,text:u.trim()})):Array.isArray(f)?f:[]}),c=e.computed(()=>{const f=i.value.find(u=>(u.id??u)===a.value);return f?f.text??String(f):s.title??""}),d=f=>{const u=(f==null?void 0:f.id)??f;a.value=u,o.value=!1,n("selected",u),document.removeEventListener("click",p)},p=f=>{l.value&&!l.value.contains(f.target)&&(o.value=!1,document.removeEventListener("click",p))},h=()=>{o.value=!o.value,o.value?setTimeout(()=>{document.addEventListener("click",p)},200):document.removeEventListener("click",p)},m=f=>(Te==null?void 0:Te[f])??f;return e.onUnmounted(()=>{document.removeEventListener("click",p)}),(f,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{type:"button","aria-expanded":"true",class:"hs-select-disabled:pointer-events-none hs-select-disabled:opacity-50 relative group pr-2 -ms-2 py-1.5 pl-2.5 inline-flex shrink-0 justify-center items-center gap-x-1.5 text-sm text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100 before:absolute before:inset-0 before:z-[1] dark:text-neutral-400 dark:hover:bg-neutral-800 dark:focus:bg-neutral-700",onClick:h},[e.createTextVNode(e.toDisplayString(m(c.value))+" ",1),u[0]||(u[0]=e.createElementVNode("svg",{class:"shrink-0 size-3.5 text-gray-600 dark:text-neutral-400",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"m6 9 6 6 6-6"})],-1))]),o.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"biDropdown",ref:l,"data-hs-select-dropdown":"",class:"absolute mt-2 z-50 w-48 p-1 space-y-0.5 bg-white rounded-xl shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] dark:bg-neutral-950 opened",role:"listbox",tabindex:"-1","aria-orientation":"vertical",style:{"margin-top":"10px"}},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,y=>(e.openBlock(),e.createElementBlock("div",{key:y.id||y,class:"cursor-pointer selected hs-selected:bg-gray-100 dark:hs-selected:bg-neutral-800 py-1.5 px-2 w-full text-[13px] text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:b=>d(y)},[e.createElementVNode("div",Mr,[e.createElementVNode("span",null,e.toDisplayString(m(y.text||y)),1),a.value===(y.id||y)?(e.openBlock(),e.createElementBlock("span",Pr,u[1]||(u[1]=[e.createElementVNode("svg",{class:"shrink-0 h-3.5 w-3.5 text-gray-800 dark:text-neutral-200",xmlns:"http:.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)]))):e.createCommentVNode("",!0)])],8,Tr))),128))],512)):e.createCommentVNode("",!0)],64))}}),jr={class:"flex items-center space-x-2"},Rr=e.defineComponent({__name:"vs-bi-switch",props:e.mergeModels({leftLabel:{},rightLabel:{},modelValue:{type:Boolean}},{modelValue:{default:()=>!1,type:Boolean},modelModifiers:{}}),emits:e.mergeModels(["update:is-enabled"],["update:modelValue"]),setup(r,{emit:t}){const s=t,n=e.useModel(r,"modelValue"),o=()=>{s("update:is-enabled",n)};return(a,l)=>(e.openBlock(),e.createElementBlock("div",jr,[a.leftLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["transition-colors",{"text-blue-500":!n.value}])},e.toDisplayString(a.leftLabel),3)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":l[0]||(l[0]=i=>n.value=i),type:"checkbox",class:"relative w-11 h-6 p-px bg-gray-100 border-transparent text-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:ring-blue-600 disabled:opacity-50 disabled:pointer-events-none checked:bg-none checked:text-blue-600 checked:border-blue-600 focus:checked:border-blue-600 dark:bg-neutral-800 dark:border-neutral-700 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-600 before:inline-block before:size-5 before:bg-white checked:before:bg-blue-200 before:translate-x-0 checked:before:translate-x-full before:rounded-full before:shadow before:h-5 before:w-5 before:transform before:ring-0 before:transition before:ease-in-out before:duration-200 dark:before:bg-neutral-400 dark:checked:before:bg-blue-200",onChange:o},null,544),[[e.vModelCheckbox,n.value]]),a.rightLabel?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["transition-colors",{"text-blue-500":n.value}])},e.toDisplayString(a.rightLabel),3)):e.createCommentVNode("",!0)]))}}),W=(r,t)=>{const s=r.__vccOpts||r;for(const[n,o]of t)s[n]=o;return s},Wr={},vr={class:"flex items-center justify-center h-full"};function Ar(r,t){return e.openBlock(),e.createElementBlock("div",vr,t[0]||(t[0]=[e.createElementVNode("div",{class:"text-center text-gray-500"},[e.createElementVNode("h2",{class:"text-2xl font-bold"},"No data available")],-1)]))}const Or=W(Wr,[["render",Ar]]),nt={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ka)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>pi)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>gi)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ul)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>al)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>rl)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>dl)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Bl)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>li)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Fl)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ki)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>yc)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>jc)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Xc))};let ot="/api";function $e(r){ot=r||"/api"}function qr(r,t){const s=ot.replace(/\/$/,""),o=r.startsWith("http")||r.startsWith("//")||s&&r.startsWith(s)?r:`${s}${r.startsWith("/")?r:`/${r}`}`;if(!t||!Object.keys(t).length)return o;const a=new URLSearchParams;Object.entries(t).forEach(([i,c])=>{c!==void 0&&c!==""&&a.set(i,String(c))});const l=a.toString();return l?`${o}${o.includes("?")?"&":"?"}${l}`:o}async function Ee(r,t={}){const{params:s,...n}=t,o=qr(r,s),a={...n.headers};n.body!=null&&(a["Content-Type"]=a["Content-Type"]??"application/json");const l=await fetch(o,{...n,headers:a});if(!l.ok){const c=new Error(l.statusText);throw c.status=l.status,c}const i=await l.text();if(i)try{return JSON.parse(i)}catch{return i}}const H={get(r,t){return Ee(r,{...t,method:"GET"})},post(r,t){return Ee(r,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(r,t){return Ee(r,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(r){return Ee(r,{method:"DELETE"})}};function at(r){if(r==null)return"";const t=String(r);return/[",\n\r]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function Ur(r,t){const s=t.map(at).join(","),n=r.map(o=>t.map(a=>at(o[a])).join(",")).join(`\r
137
+ `);return`${s}\r
138
+ ${n}`}function lt(r,t,s){const n=new Blob([t],{type:`${s};charset=utf-8`}),o=URL.createObjectURL(n),a=document.createElement("a");a.href=o,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(o)}function it(r,t){return((r||t).replace(/[<>:"/\\|?*\u0000-\u001f]/g,"_").trim()||t).slice(0,120)}function ee(r,t){const s=r&&typeof r=="object"&&"value"in r?r.value:r;if(s==null)return"";const n=Number(s);return Number.isNaN(n)?String(s):new Intl.NumberFormat("en",t??{notation:"compact"}).format(n)}function me(r){if(!(r!=null&&r.includes("T")))return r??"";const[t,s,n]=r.split("T")[0].split("-");return`${n}.${s}.${t}`}const ct={year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};function Me(r){if(r==null||r==="")return"";if(r instanceof Date&&!Number.isNaN(r.getTime()))return new Intl.DateTimeFormat("uk-UA",ct).format(r);const t=String(r).trim(),s=t.includes("T")?t:t.replace(/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})/,"$1T$2"),n=new Date(s);return Number.isNaN(n.getTime())?t:new Intl.DateTimeFormat("uk-UA",ct).format(n)}function Hr(r){return Intl.NumberFormat("en").format(r??0)}const Gr={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"},Zr={class:"flex items-center justify-between w-full gap-2"},Qr={class:"flex flex-col gap-0.5 min-w-0"},Jr={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},Xr={key:0,class:"text-xs text-gray-400 font-normal line-clamp-1"},Kr={class:"flex items-center gap-1 shrink-0"},Yr=["aria-expanded"],es={key:0,class:"absolute right-0 mt-1 z-50 min-w-[180px] p-1 bg-white rounded-xl shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] border border-gray-100",role:"menu"},ts={class:"flex flex-col justify-end"},rs={key:0,class:"flex items-center justify-end w-full gap-2"},ss={key:1,class:"text-xs text-gray-400 mb-2 shrink-0"},ns="Експорт даних віджета",os="Завантажити CSV",as="Завантажити JSON",ls="Експорт зображення (PNG)",fe=e.defineComponent({__name:"vs-widget",props:{config:{default:null},data:{default:null},dashboard:{},prefix:{default:""},widget:{},height:{},filterURl:{},dashboardWidgets:{},selectedWidget:{},prefetchedData:{default:null}},emits:["update:current-widget-data"],setup(r,{emit:t}){function s(g){if(g==null||g==="")return null;if(g instanceof Date)return g;if(typeof g=="object"){const _=g.widget,k=g.dashboard;return _!=null&&_!==""?_:k!=null&&k!==""?k:null}return g}const n=r,o=t,a=e.ref(null),l=e.ref(null),i=e.ref(null),c=e.ref({}),d=e.ref([]),p=e.ref(!1),h=e.ref(null),m=e.computed(()=>{const g=n.config;return n.widget||(g==null?void 0:g.widget)||(g==null?void 0:g.widgetId)||(g==null?void 0:g.id)||(g==null?void 0:g.name)||""}),f=e.computed(()=>{const g=n.config;return n.dashboard||(g==null?void 0:g.dashboard)||(g==null?void 0:g.dashboardId)||""}),u=e.computed(()=>{var g;return n.prefix||((g=n.config)==null?void 0:g.prefix)||""}),y=e.computed(()=>n.data||n.prefetchedData||null);function b(g){const _=g.source;if(Array.isArray(_)&&_[0]&&typeof _[0]=="object")return Object.keys(_[0]);const k=g.columns;return Array.isArray(k)&&k.length?k.map(z=>typeof z=="string"?z:(z==null?void 0:z.name)??"").filter(Boolean):[]}const $=e.computed(()=>{const g=c.value;if((g==null?void 0:g.status)!=null&&g.status>=400)return!1;const _=g==null?void 0:g.source;return Array.isArray(_)&&_.length>0&&b(g).length>0});function w(){p.value=!1,document.removeEventListener("click",x)}function x(g){const _=h.value;_&&!_.contains(g.target)&&w()}function C(){p.value=!p.value,p.value?setTimeout(()=>document.addEventListener("click",x),0):document.removeEventListener("click",x)}function L(){const g=c.value,_=g==null?void 0:g.source;if(!Array.isArray(_)||!_.length)return;const k=b(g);if(!k.length)return;const z=Ur(_,k),q=it(B.value||m.value||"widget","widget");lt(`${q}.csv`,`\uFEFF${z}`,"text/csv"),w()}function E(g,_){return g.map(k=>{const z={};for(const q of _)q in k&&(z[q]=k[q]);return z})}function V(){const g=c.value,_=g==null?void 0:g.source;if(!Array.isArray(_)||!_.length)return;const k=b(g),z=E(_,k),q={title:B.value,widget:m.value,columns:k,source:z},S=it(B.value||m.value||"widget","widget");lt(`${S}.json`,JSON.stringify(q,null,2),"application/json"),w()}const B=e.computed(()=>{var _,k,z;const g=(_=n.dashboardWidgets)==null?void 0:_.find(q=>q.name===m.value);return((k=g==null?void 0:g.data)==null?void 0:k.title)??(g==null?void 0:g.title)??((z=n.config)==null?void 0:z.title)??""}),I=e.computed(()=>{var S,oe,ae;const g=s((S=c.value)==null?void 0:S.last_update),_=s((oe=y.value)==null?void 0:oe.last_update),k=g??_;if(k!=null)return Me(k);const z=(ae=n.dashboardWidgets)==null?void 0:ae.find(le=>le.name===m.value),q=s(z==null?void 0:z.last_update)??(z==null?void 0:z.updated_at)??null;return Me(q)}),M=e.computed(()=>{var k,z,q;const g=(k=n.dashboardWidgets)==null?void 0:k.find(S=>S.name===m.value),_=(z=y.value)==null?void 0:z.type;return(g==null?void 0:g.type)??((q=n.config)==null?void 0:q.type)??_??"text"}),U=e.computed(()=>{var g,_,k;return n.height||((g=n.config)==null?void 0:g.height)||((k=(_=c.value)==null?void 0:_.style)==null?void 0:k.height)||480}),Z=e.computed(()=>{var _;const g=(_=c.value)==null?void 0:_.controls;return!g||typeof g=="boolean"?[]:Object.keys(g).map(k=>({name:k,options:g[k]}))}),Q=e.computed(()=>{const g=M.value?`bi-${M.value}`:"";return g&&g in nt?nt[g]:null});function N(g,_){var k,z;(z=(k=l.value)==null?void 0:k.changeStyle)==null||z.call(k,g,_)}function D(g,_){const k=d.value.find(z=>z.name===_);k?k.option=g:d.value.push({name:_,option:g}),P()}function P(){var _,k;let g=`/bi-data?dashboard=${f.value}&widget=${m.value}`;d.value.forEach(z=>{g+=`&${z.name}=${z.option}`}),(k=(_=l.value)==null?void 0:_.getDataFromURL)==null||k.call(_,g)}function A(){const g=i.value;if(g!=null&&g.getDataURL){const _=g.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),k=document.createElement("a");k.href=_,k.download="chart.png",document.body.appendChild(k),k.click(),document.body.removeChild(k)}}return e.onMounted(()=>{u.value&&$e(u.value)}),e.onUnmounted(()=>{document.removeEventListener("click",x)}),e.watch(()=>n.filterURl,g=>{var _,k;g&&((k=(_=l.value)==null?void 0:_.setFilter)==null||k.call(_,g))}),e.watch(()=>n.selectedWidget,(g,_)=>{var k;g!==_&&g===((k=c.value)==null?void 0:k.id)&&o("update:current-widget-data",c.value)}),e.watch(c,(g,_)=>{(g==null?void 0:g.id)!==(_==null?void 0:_.id)&&o("update:current-widget-data",g)},{deep:!0}),(g,_)=>{var k,z,q;return e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:a,class:"box-border relative p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto overflow-hidden mb-2 last:mb-0 flex flex-col min-h-0",style:e.normalizeStyle({height:U.value+"px",maxHeight:U.value+"px"})},[["text","cluster","map"].includes(M.value)?I.value?(e.openBlock(),e.createElementBlock("p",ss," Оновлено: "+e.toDisplayString(I.value),1)):e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Gr,[e.createElementVNode("div",Zr,[e.createElementVNode("div",Qr,[e.createElementVNode("span",Jr,e.toDisplayString(B.value),1),I.value?(e.openBlock(),e.createElementBlock("span",Xr," Оновлено: "+e.toDisplayString(I.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Kr,[$.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dataExportRootRef",ref:h,class:"relative"},[e.createElementVNode("button",{type:"button",class:"h-[32px] w-[32px] rounded-lg hover:bg-gray-100 duration-100 flex items-center justify-center",title:ns,"aria-haspopup":"menu","aria-expanded":p.value,onClick:e.withModifiers(C,["stop"])},[e.createVNode(e.unref(et),{size:16,class:"text-gray-800"})],8,Yr),p.value?(e.openBlock(),e.createElementBlock("div",es,[e.createElementVNode("button",{type:"button",role:"menuitem",class:"w-full text-left py-1.5 px-2 text-[13px] text-gray-800 rounded-lg hover:bg-gray-100",onClick:L},e.toDisplayString(os)),e.createElementVNode("button",{type:"button",role:"menuitem",class:"w-full text-left py-1.5 px-2 text-[13px] text-gray-800 rounded-lg hover:bg-gray-100",onClick:V},e.toDisplayString(as))])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),e.createElementVNode("div",ts,[(k=Z.value)!=null&&k.length?(e.openBlock(),e.createElementBlock("span",rs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((z=Z.value)==null?void 0:z.filter(S=>(S==null?void 0:S.options)&&(S==null?void 0:S.name)!=="export"),S=>{var oe,ae;return e.openBlock(),e.createElementBlock("div",{key:S==null?void 0:S.name},[Array.isArray(S==null?void 0:S.options)?(e.openBlock(),e.createBlock(Fr,{key:0,title:S==null?void 0:S.name,options:S==null?void 0:S.options,value:((ae=(oe=c.value)==null?void 0:oe.data)==null?void 0:ae[S==null?void 0:S.name])??null,onSelected:le=>D(le,S==null?void 0:S.name)},null,8,["title","options","value","onSelected"])):typeof S.options=="boolean"?(e.openBlock(),e.createBlock(Rr,{key:1,"left-label":S==null?void 0:S.name,"model-value":!!(S!=null&&S.options),"onUpdate:isEnabled":le=>N(S==null?void 0:S.name,le)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(q=Z.value)!=null&&q.some(S=>(S==null?void 0:S.name)==="export")?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"h-[32px] w-[32px] rounded-lg hover:bg-gray-100 duration-100 flex items-center justify-center",title:ls,onClick:A},[e.createVNode(e.unref(_r),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])])),e.createElementVNode("div",{class:"w-full flex-1 min-h-0",onClick:_[2]||(_[2]=e.withModifiers(()=>{},["stop"]))},[Q.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(Q.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":i.value,"onUpdate:currentWidget":_[0]||(_[0]=S=>i.value=S),"widget-data":c.value,"onUpdate:widgetData":_[1]||(_[1]=S=>c.value=S),config:g.config,dashboard:f.value,title:B.value,widget:m.value,prefix:u.value,"prefetched-data":y.value},null,40,["current-widget","widget-data","config","dashboard","title","widget","prefix","prefetched-data"])):(e.openBlock(),e.createBlock(Or,{key:1,class:"w-full h-full"}))])],4)}}}),is={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},cs={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},ds={class:"max-w-sm mx-auto mt-6"},ps={class:"font-medium text-gray-800 dark:text-neutral-200"},hs={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},Be=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(r){return(t,s)=>(e.openBlock(),e.createElementBlock("div",is,[e.createElementVNode("div",null,[e.createElementVNode("div",cs,[s[0]||(s[0]=e.createStaticVNode('<svg class="w-48 mx-auto" viewBox="0 0 178 90" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs></svg>',1)),e.createElementVNode("div",ds,[e.createElementVNode("p",ps,e.toDisplayString(t.title),1),e.createElementVNode("p",hs,e.toDisplayString(t.text),1)])])])]))}}),us={components:{filterIcon:{__name:"filter",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref($r),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},ms={class:"flex items-center"},fs={key:0,type:"button",class:"py-2 px-2.5 ml-3 h-[38px] inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 opacity-60 cursor-not-allowed",disabled:"",title:"Фільтри вимкнено (v3-filter видалено)"};function gs(r,t,s,n,o,a){const l=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",ms,[s.filterScheme?(e.openBlock(),e.createElementBlock("button",fs,[e.createVNode(l),t[0]||(t[0]=e.createTextVNode(" Фільтри "))])):e.createCommentVNode("",!0)])}const bs={components:{VsFilterHeader:W(us,[["render",gs]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},ys={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},xs={class:"grow"},ks={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},ws={key:0,class:"inline-flex items-center text-sm gap-x-2 text-stone-800 hover:text-stone-500 focus:outline-none focus:text-stone-500 dark:text-neutral-200 dark:hover:text-neutral-400 dark:focus:text-neutral-400"},_s={key:0,class:"flex items-center gap-3"};function $s(r,t,s,n,o,a){var i,c,d;const l=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",ys,[e.createElementVNode("div",xs,[e.createElementVNode("h1",ks,e.toDisplayString((i=s.dashboardData)==null?void 0:i.title),1),(c=s.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",ws,e.toDisplayString((d=s.dashboardData)==null?void 0:d.description),1)):e.createCommentVNode("",!0)]),s.filters?(e.openBlock(),e.createElementBlock("div",_s,[e.createVNode(l,{filterScheme:s.filters,"onFilters:changed":t[0]||(t[0]=p=>r.$emit("filters:changed",p))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const Es=W(bs,[["render",$s]]),Bs={key:0,class:"text-gray-400 shrink-0"},Ds=["onClick"],Vs=["onClick"],Cs={key:4,class:"text-gray-900 font-medium truncate"},dt={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(r){const t=r,s=K.useRouter(),n=e.computed(()=>Array.isArray(t.items)?t.items:[]);function o(a){s!=null&&s.push?s.push(a):typeof a=="string"&&(window!=null&&window.location)&&(window.location.href=a)}return(a,l)=>{const i=e.resolveComponent("router-link");return e.openBlock(),e.createElementBlock("nav",{class:e.normalizeClass(["flex items-center gap-2 text-sm text-gray-600",r.compact?"py-1":"py-6"]),"aria-label":"Breadcrumb"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(c,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d},[d>0?(e.openBlock(),e.createElementBlock("span",Bs,[e.createVNode(e.unref(wr),{class:"w-4 h-4"})])):e.createCommentVNode("",!0),typeof c.onClick=="function"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"hover:text-gray-900 transition-colors cursor-pointer",onClick:p=>c.onClick()},e.toDisplayString(c.label),9,Ds)):e.unref(s)&&c.to?(e.openBlock(),e.createBlock(i,{key:2,to:c.to,class:"hover:text-gray-900 transition-colors"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:2},1032,["to"])):c.to?(e.openBlock(),e.createElementBlock("span",{key:3,class:"hover:text-gray-900 transition-colors cursor-pointer",onClick:p=>o(c.to)},e.toDisplayString(c.label),9,Vs)):(e.openBlock(),e.createElementBlock("span",Cs,e.toDisplayString(c.label),1))],64))),128))],2)}}},Ns={components:{VsWidget:fe,VsNewNodata:Be,VsHeader:Es,VsBreadcrumbs:dt},props:{id:{type:String,default:""},prefix:{type:String,default:""},config:{type:Object,default:null},data:{type:Object,default:null}},data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},computed:{resolvedDashboardId(){var r,t,s;return this.id||((r=this.config)==null?void 0:r.dashboard)||((t=this.config)==null?void 0:t.dashboardId)||((s=this.config)==null?void 0:s.id)||""},resolvedPrefix(){var r;return this.prefix||((r=this.config)==null?void 0:r.prefix)||"/api"},resolvedDashboardData(){var r;return this.data?(r=this.data)!=null&&r.dashboardData&&typeof this.data.dashboardData=="object"?this.data.dashboardData:this.data:this.dashboardData},widgetPrefetchedMap(){return!this.data||typeof this.data!="object"?null:[this.data.widgetResponses,this.data.widgetsData,this.data.prefetchedData,this.data.data].find(t=>t&&typeof t=="object"&&!Array.isArray(t))||null}},watch:{data:{immediate:!0,handler(r){r&&(this.dashboardData=r,this.error=!1)}},resolvedPrefix:{immediate:!0,handler(r){$e(r||"/api")}},async resolvedDashboardId(r,t){!this.data&&r&&r!==t&&await this.fetchData()}},async mounted(){if(this.data){this.dashboardData=this.data;return}await this.fetchData()},methods:{async fetchData(){if(!(this.data||!this.resolvedDashboardId))try{const r=await H.get(`/bi-dashboard/${this.resolvedDashboardId}`);this.dashboardData=r,this.error=!1}catch(r){this.error=!0,console.error(r)}},columnClass(r){const t=r!=null&&r.col?r==null?void 0:r.col:12;return{1:"md:w-1/12 sm:w-full",2:"md:w-1/6 sm:w-full",3:"md:w-1/4 sm:w-full",4:"md:w-1/3 sm:w-full",6:"md:w-1/2 sm:w-full",8:"md:w-2/3 sm:w-full",10:"md:w-5/6 sm:w-full",12:"w-full"}[t]||"w-full"},async filterHandler(r){var s;this.filterURl="";let t="&filter=";(s=r==null?void 0:r.url)!=null&&s.length&&(r.url.split("|").forEach(o=>{const a=o.split("=");t+=`${a[0]}=${a[1]}`}),this.filterURl+=t)},getPrefetchedWidgetData(r){return!r||!this.widgetPrefetchedMap?null:this.widgetPrefetchedMap[r]||null}}},Ss={class:"w-full pb-8 overflow-y-auto mx-auto"},zs={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function Ls(r,t,s,n,o,a){var c;const l=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",Ss,[e.createElementVNode("div",zs,[o.error||!a.resolvedDashboardData?(e.openBlock(),e.createBlock(l,{key:0,class:"col-span-12"})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(((c=a.resolvedDashboardData)==null?void 0:c.panels)||[],(d,p)=>{var h,m;return e.openBlock(),e.createElementBlock("div",{key:d.widget||((h=d.widgets)==null?void 0:h.join("-"))||p,class:e.normalizeClass([`col-span-12 lg:col-span-${d.col||12}`,"flex flex-col gap-[10px]"])},[(m=d.widgets)!=null&&m.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(d.widgets,f=>(e.openBlock(),e.createBlock(i,{key:f,dashboard:a.resolvedDashboardId,widget:f,"dashboard-widgets":a.resolvedDashboardData.widgets,"prefetched-data":a.getPrefetchedWidgetData(f),"filter-u-rl":o.filterURl,height:d.height},null,8,["dashboard","widget","dashboard-widgets","prefetched-data","filter-u-rl","height"]))),128)):(e.openBlock(),e.createBlock(i,{key:1,class:"flex flex-col",dashboard:a.resolvedDashboardId,widget:d.widget,"dashboard-widgets":a.resolvedDashboardData.widgets,"prefetched-data":a.getPrefetchedWidgetData(d.widget),height:d.height,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","prefetched-data","height","filter-u-rl"]))],2)}),128))])])}const Is=W(Ns,[["render",Ls]]);var pt=(r=>(r.Dashboard="/dashboard",r.BiPlatform="/bi-platform",r.EditorBase="/editor",r.AllDashboards="/dashboards",r.DashboardByName="/dashboards/:name",r))(pt||{}),ht;(r=>{(t=>{t.Bar="bar",t.ListBar="listbar",t.Number="number",t.Text="text",t.Pie="pie",t.Heatmap="heatmap",t.Calendar="calendar",t.Line="line",t.Stat="stat",t.Pivot="pivot",t.Funnel="funnel",t.Progress="progress"})(r.Types||(r.Types={}))})(ht||(ht={}));var J=(r=>(r.AllDashboards="all-dashboards",r.BiPlatform="bi-platform",r.Dashboard="dashboard",r.Erobota="erobota",r.Datatest="datatest",r.Sourcedate="sourcedate",r.Widgetwidget="widgetwidget",r.Test="test",r.Demo="demo",r.Crm="crm",r.Editor="editor-all-dashboards",r.EditorDashboard="editor-dashboard",r.EditorWidget="editor-widget",r.Editordetails="editordetails",r.Dbtables="dbtables",r.Biviewer="biviewer",r.Biviewerinner="biviewerinner",r.Bieditor="bieditor",r.Bieditorinner="bieditorinner",r))(J||{});const Ts={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},Ms={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},Ps={class:"font-medium text-gray-800 dark:text-white"},Fs={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},js={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},ge=W({__name:"vs-modal",props:{visible:{type:Boolean,default:!1},title:{type:String,default:""},size:{type:String,default:"medium"},closeClickBack:{type:Boolean,default:!1},teleport:{type:String,default:"#modal"}},emits:["close","update:visible"],setup(r,{emit:t}){const s=r,n=t,o=e.computed(()=>s.size==="small"?"md:max-w-[40%] w-full max-w-md":s.size==="lg"?"md:max-w-[70%] w-full max-w-4xl":"md:max-w-[50%] w-full max-w-lg");function a(){n("update:visible",!1),n("close")}function l(i){i.key==="Escape"&&a()}return e.onMounted(()=>{window.addEventListener("keydown",l)}),e.onUnmounted(()=>{window.removeEventListener("keydown",l)}),(i,c)=>(e.openBlock(),e.createBlock(e.Teleport,{to:r.teleport},[r.visible?(e.openBlock(),e.createElementBlock("div",Ts,[e.createElementVNode("div",{class:"absolute inset-0 bg-black/50","aria-hidden":"true",onMousedown:c[0]||(c[0]=d=>r.closeClickBack&&d.target===d.currentTarget&&a())},null,32),e.createVNode(e.Transition,{name:"vs-modal",appear:""},{default:e.withCtx(()=>[r.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["vs-modal-panel relative flex flex-col bg-white dark:bg-[#1A1A1A] rounded-xl shadow-xl max-h-[85vh] min-w-0 border border-gray-200 dark:border-[#454545]",o.value]),role:"dialog","aria-modal":"true",onMousedown:c[1]||(c[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",Ms,[e.createElementVNode("h3",Ps,e.toDisplayString(r.title),1),e.createElementVNode("button",{type:"button",class:"size-8 inline-flex justify-center items-center rounded-full bg-gray-100 text-gray-800 hover:bg-gray-200 dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-300","aria-label":"Закрити",onClick:a},c[2]||(c[2]=[e.createElementVNode("svg",{class:"w-4 h-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)]))]),e.createElementVNode("div",Fs,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",js,[e.renderSlot(i.$slots,"footer",{},void 0,!0)])):e.createCommentVNode("",!0)],34)):e.createCommentVNode("",!0)]),_:3})])):e.createCommentVNode("",!0)],8,["to"]))}},[["__scopeId","data-v-5722a50f"]]),Rs={__name:"icon-plus",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(tt),e.mergeProps(t.$attrs,{size:24}),null,16))}},Ws={class:"mb-4 overflow-auto scrollbar max-h-96"},vs={__name:"vs-editor-create-widget",props:{columns:{type:Array,default:()=>[]},selectedDashboard:String,inline:{type:Boolean,default:!1}},emits:["update-data"],setup(r,{expose:t,emit:s}){var u;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(u=e.getCurrentInstance().proxy)==null?void 0:u.$notify,a=s,l=r,i=e.ref(!1),c=e.ref({}),d=e.ref();function p(){i.value=!0}function h(){i.value=!1}t({open:p,close:h});const m=async()=>{var y;try{const b=(y=d.value)==null?void 0:y.doValidation;typeof b=="function"&&await b(),await H.post(`/bi-dashboard/${l.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await a("update-data"),c.value={},i.value=!1}catch(b){const $=(b==null?void 0:b.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:$})}},f=e.computed(()=>{var y,b,$,w;return{title:{type:"text",label:"Назва віджета",placeholder:"Назва віджета",validators:["required"]},x:{type:"select",label:"Вісь X",view:"buttons",style:{size:"xs"},validators:["required"],options:(b=(y=l.columns)==null?void 0:y.filter(x=>(x==null?void 0:x.type)=="text"||(x==null?void 0:x.type)==="date"||(x==null?void 0:x.type)==="timestamp without time zone"||(x==null?void 0:x.type)==="boolean"||(x==null?void 0:x.type)==="integer"))==null?void 0:b.map(({name:x,type:C})=>({id:x,text:x,type:C}))},metric:{type:"select",label:"Вісь Y",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(w=($=l.columns)==null?void 0:$.filter(x=>(x==null?void 0:x.type)==="numeric"||(x==null?void 0:x.type)==="double precision"))==null?void 0:w.map(({name:x,type:C})=>({id:x,text:x,type:C}))]},col:{type:"select",label:"Кількість колонок",validators:["required"],options:[{id:1,label:1},{id:2,text:2},{id:3,text:3},{id:4,text:4},{id:6,text:6},{id:9,text:9},{id:12,text:12}]},height:{type:"Text",label:"Висота",placeholder:"Висота"},type:{type:"select",view:"buttons",label:"Тип віджета",validators:["required"],options:[{label:"Bar",id:"bar"},{label:"Funnel",id:"funnel"},{label:"Line",id:"line"},{label:"List bar",id:"listbar"},{label:"Number",id:"number"},{label:"Pie",id:"pie"},{label:"Donut",id:"donut"},{label:"Pivot",id:"pivot"},{label:"Table",id:"table"},{label:"Progress",id:"progress"},{label:"Stat",id:"stat"},{label:"Text",id:"text"},{label:"Map",id:"map"}]},text:{type:"Text",ua:"Текст",placeholder:"Текст",conditions:["type","==","text"]},table:{type:"Text",ua:"Таблиця",placeholder:"Таблиця"},query:{type:"Text",ua:"Запит (query)",placeholder:"Запит (query)"},cls:{type:"Text",ua:"Клас (cls)",placeholder:"Клас (cls)"}}});return(y,b)=>{const $=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[r.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock($,{key:0,placement:"right",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("button",{class:"z-50 flex items-center justify-center h-[50px] !w-[50px] text-2xl text-white transition-colors bg-blue-500 rounded-full cursor-pointer hover:bg-blue-700",onClick:p},[e.createVNode(Rs,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[b[1]||(b[1]=e.createTextVNode(" Створити віджет "))]),_:1})),e.createVNode(ge,{teleport:"#modal",visible:i.value,title:"Створити віджет",onClose:h},{footer:e.withCtx(()=>[e.createElementVNode("div",{class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:h,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:m,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Створити ")])]),default:e.withCtx(()=>[e.createElementVNode("div",Ws,[e.createVNode(e.unref(n),{ref_key:"form",ref:d,schema:f.value,values:c.value,"onUpdate:values":b[0]||(b[0]=w=>c.value=w)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},ut={__name:"delete",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Ir),e.mergeProps(t.$attrs,{size:24}),null,16))}},Pe={__name:"close",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(st),e.mergeProps(t.$attrs,{size:24}),null,16))}},mt={__name:"edit",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Sr),e.mergeProps(t.$attrs,{size:24}),null,16))}},As={class:"space-y-4"},Os={__name:"vs-editor-form-style",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}}},emits:["update-dashboard"],setup(r,{expose:t,emit:s}){var C,L,E,V;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,a=s,l=r,i=e.ref(null),c=e.computed(()=>l.dashboardId||i.value),d=((C=l.data)==null?void 0:C.type)||((E=(L=l.data)==null?void 0:L.data)==null?void 0:E.type),h={pie:{label:!1,legend:!0,tooltip:!0},donut:{label:!1,legend:!0,tooltip:!0},bar:{label:!1,legend:!1,tooltip:!0},line:{label:!1,legend:!1,tooltip:!0},funnel:{label:!1,legend:!1,tooltip:!0}}[d]||{label:!1,legend:!1,tooltip:!0},m={show:{label:"Легенда",type:"switcher",title:"Показати легенду"}},f={show:{label:"Тултіп",type:"switcher",title:"Показати тултіп"}},u=(V=l.data)==null?void 0:V.style,y=e.ref(u!=null&&u.label?{...u.label}:{show:h.label}),b=e.ref(u!=null&&u.legend?{...u.legend}:{show:h.legend}),$=e.ref(u!=null&&u.tooltip?{...u.tooltip}:{show:h.tooltip}),w=()=>{const B=new CustomEvent(`update-style-${l.widgetName}`);B.chartId=l.widgetName,B.options={options:{legend:b.value,tooltip:$.value,label:y.value},seriesOptions:y.value},window.dispatchEvent(B)};e.watch(y,w,{deep:!0}),e.watch(b,w,{deep:!0}),e.watch($,w,{deep:!0});const x=async()=>{try{await H.put(`/bi-dashboard/${c.value}/${l.widgetName}`,{style:{legend:b.value,tooltip:$.value,label:y.value}});const B=new CustomEvent(`update-style-${l.widgetName}`);B.chartId=l.widgetName,B.options={options:{legend:b.value,tooltip:$.value,label:y.value},seriesOptions:y.value},window.dispatchEvent(B),a("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const B=new URLSearchParams(window.top.location.search);i.value=B.get("dashboard"),w()}),t({requestUpdateWidget:x}),(B,I)=>(e.openBlock(),e.createElementBlock("div",As,[e.createVNode(e.unref(n),{schema:m,values:b.value,"onUpdate:values":I[0]||(I[0]=M=>b.value=M),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:f,values:$.value,"onUpdate:values":I[1]||(I[1]=M=>$.value=M),class:"p-0"},null,8,["values"])]))}};function Fe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ie=Fe();function ft(r){ie=r}const gt=/[&<>"']/,qs=new RegExp(gt.source,"g"),bt=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Us=new RegExp(bt.source,"g"),Hs={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},yt=r=>Hs[r];function Y(r,t){if(t){if(gt.test(r))return r.replace(qs,yt)}else if(bt.test(r))return r.replace(Us,yt);return r}const Gs=/(^|[^\[])\^/g;function v(r,t){let s=typeof r=="string"?r:r.source;t=t||"";const n={replace:(o,a)=>{let l=typeof a=="string"?a:a.source;return l=l.replace(Gs,"$1"),s=s.replace(o,l),n},getRegex:()=>new RegExp(s,t)};return n}function xt(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}const be={exec:()=>null};function kt(r,t){const s=r.replace(/\|/g,(a,l,i)=>{let c=!1,d=l;for(;--d>=0&&i[d]==="\\";)c=!c;return c?"|":" |"}),n=s.split(/ \|/);let o=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;o<n.length;o++)n[o]=n[o].trim().replace(/\\\|/g,"|");return n}function ye(r,t,s){const n=r.length;if(n===0)return"";let o=0;for(;o<n&&r.charAt(n-o-1)===t;)o++;return r.slice(0,n-o)}function Zs(r,t){if(r.indexOf(t[1])===-1)return-1;let s=0;for(let n=0;n<r.length;n++)if(r[n]==="\\")n++;else if(r[n]===t[0])s++;else if(r[n]===t[1]&&(s--,s<0))return n;return-1}function wt(r,t,s,n){const o=t.href,a=t.title?Y(t.title):null,l=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){n.state.inLink=!0;const i={type:"link",raw:s,href:o,title:a,text:l,tokens:n.inlineTokens(l)};return n.state.inLink=!1,i}return{type:"image",raw:s,href:o,title:a,text:Y(l)}}function Qs(r,t){const s=r.match(/^(\s+)(?:```)/);if(s===null)return t;const n=s[1];return t.split(`
139
+ `).map(o=>{const a=o.match(/^\s+/);if(a===null)return o;const[l]=a;return l.length>=n.length?o.slice(n.length):o}).join(`
140
+ `)}class De{constructor(t){O(this,"options");O(this,"rules");O(this,"lexer");this.options=t||ie}space(t){const s=this.rules.block.newline.exec(t);if(s&&s[0].length>0)return{type:"space",raw:s[0]}}code(t){const s=this.rules.block.code.exec(t);if(s){const n=s[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:s[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ye(n,`
141
+ `)}}}fences(t){const s=this.rules.block.fences.exec(t);if(s){const n=s[0],o=Qs(n,s[3]||"");return{type:"code",raw:n,lang:s[2]?s[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):s[2],text:o}}}heading(t){const s=this.rules.block.heading.exec(t);if(s){let n=s[2].trim();if(/#$/.test(n)){const o=ye(n,"#");(this.options.pedantic||!o||/ $/.test(o))&&(n=o.trim())}return{type:"heading",raw:s[0],depth:s[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const s=this.rules.block.hr.exec(t);if(s)return{type:"hr",raw:ye(s[0],`
142
+ `)}}blockquote(t){const s=this.rules.block.blockquote.exec(t);if(s){let n=ye(s[0],`
143
143
  `).split(`
144
- `),o="",l="";const a=[];for(;s.length>0;){let i=!1;const c=[];let d;for(d=0;d<s.length;d++)if(/^ {0,3}>/.test(s[d]))c.push(s[d]),i=!0;else if(!i)c.push(s[d]);else break;s=s.slice(d);const p=c.join(`
144
+ `),o="",a="";const l=[];for(;n.length>0;){let i=!1;const c=[];let d;for(d=0;d<n.length;d++)if(/^ {0,3}>/.test(n[d]))c.push(n[d]),i=!0;else if(!i)c.push(n[d]);else break;n=n.slice(d);const p=c.join(`
145
145
  `),h=p.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
146
146
  $1`).replace(/^ {0,3}>[ \t]?/gm,"");o=o?`${o}
147
- ${p}`:p,l=l?`${l}
148
- ${h}`:h;const m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,a,!0),this.lexer.state.top=m,s.length===0)break;const f=a[a.length-1];if((f==null?void 0:f.type)==="code")break;if((f==null?void 0:f.type)==="blockquote"){const u=f,y=u.raw+`
149
- `+s.join(`
150
- `),b=this.blockquote(y);a[a.length-1]=b,o=o.substring(0,o.length-u.raw.length)+b.raw,l=l.substring(0,l.length-u.text.length)+b.text;break}else if((f==null?void 0:f.type)==="list"){const u=f,y=u.raw+`
151
- `+s.join(`
152
- `),b=this.list(y);a[a.length-1]=b,o=o.substring(0,o.length-f.raw.length)+b.raw,l=l.substring(0,l.length-u.raw.length)+b.raw,s=y.substring(a[a.length-1].raw.length).split(`
153
- `);continue}}return{type:"blockquote",raw:o,tokens:a,text:l}}}list(t){let n=this.rules.block.list.exec(t);if(n){let s=n[1].trim();const o=s.length>1,l={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");const a=new RegExp(`^( {0,3}${s})((?:[ ][^\\n]*)?(?:\\n|$))`);let i=!1;for(;t;){let c=!1,d="",p="";if(!(n=a.exec(t))||this.rules.block.hr.test(t))break;d=n[0],t=t.substring(d.length);let h=n[2].split(`
147
+ ${p}`:p,a=a?`${a}
148
+ ${h}`:h;const m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,l,!0),this.lexer.state.top=m,n.length===0)break;const f=l[l.length-1];if((f==null?void 0:f.type)==="code")break;if((f==null?void 0:f.type)==="blockquote"){const u=f,y=u.raw+`
149
+ `+n.join(`
150
+ `),b=this.blockquote(y);l[l.length-1]=b,o=o.substring(0,o.length-u.raw.length)+b.raw,a=a.substring(0,a.length-u.text.length)+b.text;break}else if((f==null?void 0:f.type)==="list"){const u=f,y=u.raw+`
151
+ `+n.join(`
152
+ `),b=this.list(y);l[l.length-1]=b,o=o.substring(0,o.length-f.raw.length)+b.raw,a=a.substring(0,a.length-u.raw.length)+b.raw,n=y.substring(l[l.length-1].raw.length).split(`
153
+ `);continue}}return{type:"blockquote",raw:o,tokens:l,text:a}}}list(t){let s=this.rules.block.list.exec(t);if(s){let n=s[1].trim();const o=n.length>1,a={type:"list",raw:"",ordered:o,start:o?+n.slice(0,-1):"",loose:!1,items:[]};n=o?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=o?n:"[*+-]");const l=new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);let i=!1;for(;t;){let c=!1,d="",p="";if(!(s=l.exec(t))||this.rules.block.hr.test(t))break;d=s[0],t=t.substring(d.length);let h=s[2].split(`
154
154
  `,1)[0].replace(/^\t+/,$=>" ".repeat(3*$.length)),m=t.split(`
155
- `,1)[0],f=!h.trim(),u=0;if(this.options.pedantic?(u=2,p=h.trimStart()):f?u=n[1].length+1:(u=n[2].search(/[^ ]/),u=u>4?1:u,p=h.slice(u),u+=n[1].length),f&&/^[ \t]*$/.test(m)&&(d+=m+`
156
- `,t=t.substring(m.length+1),c=!0),!c){const $=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),w=new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),x=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),D=new RegExp(`^ {0,${Math.min(3,u-1)}}#`),L=new RegExp(`^ {0,${Math.min(3,u-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const E=t.split(`
157
- `,1)[0];let C;if(m=E,this.options.pedantic?(m=m.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),C=m):C=m.replace(/\t/g," "),x.test(m)||D.test(m)||L.test(m)||$.test(m)||w.test(m))break;if(C.search(/[^ ]/)>=u||!m.trim())p+=`
158
- `+C.slice(u);else{if(f||h.replace(/\t/g," ").search(/[^ ]/)>=4||x.test(h)||D.test(h)||w.test(h))break;p+=`
155
+ `,1)[0],f=!h.trim(),u=0;if(this.options.pedantic?(u=2,p=h.trimStart()):f?u=s[1].length+1:(u=s[2].search(/[^ ]/),u=u>4?1:u,p=h.slice(u),u+=s[1].length),f&&/^[ \t]*$/.test(m)&&(d+=m+`
156
+ `,t=t.substring(m.length+1),c=!0),!c){const $=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),w=new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),x=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),C=new RegExp(`^ {0,${Math.min(3,u-1)}}#`),L=new RegExp(`^ {0,${Math.min(3,u-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const E=t.split(`
157
+ `,1)[0];let V;if(m=E,this.options.pedantic?(m=m.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),V=m):V=m.replace(/\t/g," "),x.test(m)||C.test(m)||L.test(m)||$.test(m)||w.test(m))break;if(V.search(/[^ ]/)>=u||!m.trim())p+=`
158
+ `+V.slice(u);else{if(f||h.replace(/\t/g," ").search(/[^ ]/)>=4||x.test(h)||C.test(h)||w.test(h))break;p+=`
159
159
  `+m}!f&&!m.trim()&&(f=!0),d+=E+`
160
- `,t=t.substring(E.length+1),h=C.slice(u)}}l.loose||(i?l.loose=!0:/\n[ \t]*\n[ \t]*$/.test(d)&&(i=!0));let y=null,b;this.options.gfm&&(y=/^\[[ xX]\] /.exec(p),y&&(b=y[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),l.items.push({type:"list_item",raw:d,task:!!y,checked:b,loose:!1,text:p,tokens:[]}),l.raw+=d}l.items[l.items.length-1].raw=l.items[l.items.length-1].raw.trimEnd(),l.items[l.items.length-1].text=l.items[l.items.length-1].text.trimEnd(),l.raw=l.raw.trimEnd();for(let c=0;c<l.items.length;c++)if(this.lexer.state.top=!1,l.items[c].tokens=this.lexer.blockTokens(l.items[c].text,[]),!l.loose){const d=l.items[c].tokens.filter(h=>h.type==="space"),p=d.length>0&&d.some(h=>/\n.*\n/.test(h.raw));l.loose=p}if(l.loose)for(let c=0;c<l.items.length;c++)l.items[c].loose=!0;return l}}html(t){const n=this.rules.block.html.exec(t);if(n)return{type:"html",block:!0,raw:n[0],pre:n[1]==="pre"||n[1]==="script"||n[1]==="style",text:n[0]}}def(t){const n=this.rules.block.def.exec(t);if(n){const s=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",l=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:s,raw:n[0],href:o,title:l}}}table(t){const n=this.rules.block.table.exec(t);if(!n||!/[:|]/.test(n[2]))return;const s=kt(n[1]),o=n[2].replace(/^\||\| *$/g,"").split("|"),l=n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
161
- `):[],a={type:"table",raw:n[0],header:[],align:[],rows:[]};if(s.length===o.length){for(const i of o)/^ *-+: *$/.test(i)?a.align.push("right"):/^ *:-+: *$/.test(i)?a.align.push("center"):/^ *:-+ *$/.test(i)?a.align.push("left"):a.align.push(null);for(let i=0;i<s.length;i++)a.header.push({text:s[i],tokens:this.lexer.inline(s[i]),header:!0,align:a.align[i]});for(const i of l)a.rows.push(kt(i,a.header.length).map((c,d)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[d]})));return a}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const s=n[1].charAt(n[1].length-1)===`
162
- `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:s,tokens:this.lexer.inline(s)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Y(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const s=n[2].trim();if(!this.options.pedantic&&/^</.test(s)){if(!/>$/.test(s))return;const a=ye(s.slice(0,-1),"\\");if((s.length-a.length)%2===0)return}else{const a=Qn(n[2],"()");if(a>-1){const c=(n[0].indexOf("!")===0?5:4)+n[1].length+a;n[2]=n[2].substring(0,a),n[0]=n[0].substring(0,c).trim(),n[3]=""}}let o=n[2],l="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);a&&(o=a[1],l=a[3])}else l=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(s)?o=o.slice(1):o=o.slice(1,-1)),wt(n,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer)}}reflink(t,n){let s;if((s=this.rules.inline.reflink.exec(t))||(s=this.rules.inline.nolink.exec(t))){const o=(s[2]||s[1]).replace(/\s+/g," "),l=n[o.toLowerCase()];if(!l){const a=s[0].charAt(0);return{type:"text",raw:a,text:a}}return wt(s,l,s[0],this.lexer)}}emStrong(t,n,s=""){let o=this.rules.inline.emStrongLDelim.exec(t);if(!o||o[3]&&s.match(/[\p{L}\p{N}]/u))return;if(!(o[1]||o[2]||"")||!s||this.rules.inline.punctuation.exec(s)){const a=[...o[0]].length-1;let i,c,d=a,p=0;const h=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,n=n.slice(-1*t.length+a);(o=h.exec(n))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i)continue;if(c=[...i].length,o[3]||o[4]){d+=c;continue}else if((o[5]||o[6])&&a%3&&!((a+c)%3)){p+=c;continue}if(d-=c,d>0)continue;c=Math.min(c,c+d+p);const m=[...o[0]][0].length,f=t.slice(0,a+o.index+m+c);if(Math.min(a,c)%2){const y=f.slice(1,-1);return{type:"em",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}const u=f.slice(2,-2);return{type:"strong",raw:f,text:u,tokens:this.lexer.inlineTokens(u)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let s=n[2].replace(/\n/g," ");const o=/[^ ]/.test(s),l=/^ /.test(s)&&/ $/.test(s);return o&&l&&(s=s.substring(1,s.length-1)),s=Y(s,!0),{type:"codespan",raw:n[0],text:s}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t){const n=this.rules.inline.autolink.exec(t);if(n){let s,o;return n[2]==="@"?(s=Y(n[1]),o="mailto:"+s):(s=Y(n[1]),o=s),{type:"link",raw:n[0],text:s,href:o,tokens:[{type:"text",raw:s,text:s}]}}}url(t){var s;let n;if(n=this.rules.inline.url.exec(t)){let o,l;if(n[2]==="@")o=Y(n[0]),l="mailto:"+o;else{let a;do a=n[0],n[0]=((s=this.rules.inline._backpedal.exec(n[0]))==null?void 0:s[0])??"";while(a!==n[0]);o=Y(n[0]),n[1]==="www."?l="http://"+n[0]:l=n[0]}return{type:"link",raw:n[0],text:o,href:l,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t){const n=this.rules.inline.text.exec(t);if(n){let s;return this.lexer.state.inRawBlock?s=n[0]:s=Y(n[0]),{type:"text",raw:n[0],text:s}}}}const Xn=/^(?:[ \t]*(?:\n|$))+/,Kn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Yn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,xe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,es=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_t=/(?:[*+-]|\d{1,9}[.)])/,$t=v(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,_t).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Re=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ts=/^[^\n]+/,je=/(?!\s*\])(?:\\.|[^\[\]\\])+/,rs=v(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",je).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ns=v(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_t).getRegex(),Ce="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",We=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ss=v("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",We).replace("tag",Ce).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Et=v(Re).replace("hr",xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ce).getRegex(),ve={blockquote:v(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Et).getRegex(),code:Kn,def:rs,fences:Yn,heading:es,hr:xe,html:ss,lheading:$t,list:ns,newline:Xn,paragraph:Et,table:be,text:ts},Bt=v("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ce).getRegex(),os={...ve,table:Bt,paragraph:v(Re).replace("hr",xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Bt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ce).getRegex()},as={...ve,html:v(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",We).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:be,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:v(Re).replace("hr",xe).replace("heading",` *#{1,6} *[^
163
- ]`).replace("lheading",$t).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Vt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ls=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ct=/^( {2,}|\\)\n(?!\s*$)/,is=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ke="\\p{P}\\p{S}",cs=v(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ke).getRegex(),ds=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ps=v(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ke).getRegex(),hs=v("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ke).getRegex(),us=v("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ke).getRegex(),ms=v(/\\([punct])/,"gu").replace(/punct/g,ke).getRegex(),fs=v(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),gs=v(We).replace("(?:-->|$)","-->").getRegex(),bs=v("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",gs).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),De=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ys=v(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",De).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Dt=v(/^!?\[(label)\]\[(ref)\]/).replace("label",De).replace("ref",je).getRegex(),Nt=v(/^!?\[(ref)\](?:\[\])?/).replace("ref",je).getRegex(),xs=v("reflink|nolink(?!\\()","g").replace("reflink",Dt).replace("nolink",Nt).getRegex(),Ae={_backpedal:be,anyPunctuation:ms,autolink:fs,blockSkip:ds,br:Ct,code:ls,del:be,emStrongLDelim:ps,emStrongRDelimAst:hs,emStrongRDelimUnd:us,escape:Vt,link:ys,nolink:Nt,punctuation:cs,reflink:Dt,reflinkSearch:xs,tag:bs,text:is,url:be},ks={...Ae,link:v(/^!?\[(label)\]\((.*?)\)/).replace("label",De).getRegex(),reflink:v(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",De).getRegex()},Oe={...Ae,escape:v(Vt).replace("])","~|])").getRegex(),url:v(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},ws={...Oe,br:v(Ct).replace("{2,}","*").getRegex(),text:v(Oe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ne={normal:ve,gfm:os,pedantic:as},we={normal:Ae,gfm:Oe,breaks:ws,pedantic:ks};class te{constructor(t){O(this,"tokens");O(this,"options");O(this,"state");O(this,"tokenizer");O(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ie,this.options.tokenizer=this.options.tokenizer||new Ve,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Ne.normal,inline:we.normal};this.options.pedantic?(n.block=Ne.pedantic,n.inline=we.pedantic):this.options.gfm&&(n.block=Ne.gfm,this.options.breaks?n.inline=we.breaks:n.inline=we.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ne,inline:we}}static lex(t,n){return new te(n).lex(t)}static lexInline(t,n){return new te(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
164
- `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){this.options.pedantic&&(t=t.replace(/\t/g," ").replace(/^ +$/gm,""));let o,l,a;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(i=>(o=i.call({lexer:this},t,n))?(t=t.substring(o.raw.length),n.push(o),!0):!1))){if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length),o.raw.length===1&&n.length>0?n[n.length-1].raw+=`
165
- `:n.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length),l=n[n.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
166
- `+o.raw,l.text+=`
167
- `+o.text,this.inlineQueue[this.inlineQueue.length-1].src=l.text):n.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length),l=n[n.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
168
- `+o.raw,l.text+=`
169
- `+o.raw,this.inlineQueue[this.inlineQueue.length-1].src=l.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title});continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),n.push(o);continue}if(a=t,this.options.extensions&&this.options.extensions.startBlock){let i=1/0;const c=t.slice(1);let d;this.options.extensions.startBlock.forEach(p=>{d=p.call({lexer:this},c),typeof d=="number"&&d>=0&&(i=Math.min(i,d))}),i<1/0&&i>=0&&(a=t.substring(0,i+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){l=n[n.length-1],s&&(l==null?void 0:l.type)==="paragraph"?(l.raw+=`
170
- `+o.raw,l.text+=`
171
- `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):n.push(o),s=a.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length),l=n[n.length-1],l&&l.type==="text"?(l.raw+=`
172
- `+o.raw,l.text+=`
173
- `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):n.push(o);continue}if(t){const i="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let s,o,l,a=t,i,c,d;if(this.tokens.links){const p=Object.keys(this.tokens.links);if(p.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)p.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,i.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(c||(d=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(p=>(s=p.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))){if(s=this.tokenizer.escape(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(t)){t=t.substring(s.raw.length),o=n[n.length-1],o&&s.type==="text"&&o.type==="text"?(o.raw+=s.raw,o.text+=s.text):n.push(s);continue}if(s=this.tokenizer.link(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(s.raw.length),o=n[n.length-1],o&&s.type==="text"&&o.type==="text"?(o.raw+=s.raw,o.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(t,a,d)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(t)){t=t.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(t))){t=t.substring(s.raw.length),n.push(s);continue}if(l=t,this.options.extensions&&this.options.extensions.startInline){let p=1/0;const h=t.slice(1);let m;this.options.extensions.startInline.forEach(f=>{m=f.call({lexer:this},h),typeof m=="number"&&m>=0&&(p=Math.min(p,m))}),p<1/0&&p>=0&&(l=t.substring(0,p+1))}if(s=this.tokenizer.inlineText(l)){t=t.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(d=s.raw.slice(-1)),c=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=s.raw,o.text+=s.text):n.push(s);continue}if(t){const p="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return n}}class Se{constructor(t){O(this,"options");O(this,"parser");this.options=t||ie}space(t){return""}code({text:t,lang:n,escaped:s}){var a;const o=(a=(n||"").match(/^\S*/))==null?void 0:a[0],l=t.replace(/\n$/,"")+`
174
- `;return o?'<pre><code class="language-'+Y(o)+'">'+(s?l:Y(l,!0))+`</code></pre>
175
- `:"<pre><code>"+(s?l:Y(l,!0))+`</code></pre>
160
+ `,t=t.substring(E.length+1),h=V.slice(u)}}a.loose||(i?a.loose=!0:/\n[ \t]*\n[ \t]*$/.test(d)&&(i=!0));let y=null,b;this.options.gfm&&(y=/^\[[ xX]\] /.exec(p),y&&(b=y[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:d,task:!!y,checked:b,loose:!1,text:p,tokens:[]}),a.raw+=d}a.items[a.items.length-1].raw=a.items[a.items.length-1].raw.trimEnd(),a.items[a.items.length-1].text=a.items[a.items.length-1].text.trimEnd(),a.raw=a.raw.trimEnd();for(let c=0;c<a.items.length;c++)if(this.lexer.state.top=!1,a.items[c].tokens=this.lexer.blockTokens(a.items[c].text,[]),!a.loose){const d=a.items[c].tokens.filter(h=>h.type==="space"),p=d.length>0&&d.some(h=>/\n.*\n/.test(h.raw));a.loose=p}if(a.loose)for(let c=0;c<a.items.length;c++)a.items[c].loose=!0;return a}}html(t){const s=this.rules.block.html.exec(t);if(s)return{type:"html",block:!0,raw:s[0],pre:s[1]==="pre"||s[1]==="script"||s[1]==="style",text:s[0]}}def(t){const s=this.rules.block.def.exec(t);if(s){const n=s[1].toLowerCase().replace(/\s+/g," "),o=s[2]?s[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=s[3]?s[3].substring(1,s[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):s[3];return{type:"def",tag:n,raw:s[0],href:o,title:a}}}table(t){const s=this.rules.block.table.exec(t);if(!s||!/[:|]/.test(s[2]))return;const n=kt(s[1]),o=s[2].replace(/^\||\| *$/g,"").split("|"),a=s[3]&&s[3].trim()?s[3].replace(/\n[ \t]*$/,"").split(`
161
+ `):[],l={type:"table",raw:s[0],header:[],align:[],rows:[]};if(n.length===o.length){for(const i of o)/^ *-+: *$/.test(i)?l.align.push("right"):/^ *:-+: *$/.test(i)?l.align.push("center"):/^ *:-+ *$/.test(i)?l.align.push("left"):l.align.push(null);for(let i=0;i<n.length;i++)l.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:l.align[i]});for(const i of a)l.rows.push(kt(i,l.header.length).map((c,d)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:l.align[d]})));return l}}lheading(t){const s=this.rules.block.lheading.exec(t);if(s)return{type:"heading",raw:s[0],depth:s[2].charAt(0)==="="?1:2,text:s[1],tokens:this.lexer.inline(s[1])}}paragraph(t){const s=this.rules.block.paragraph.exec(t);if(s){const n=s[1].charAt(s[1].length-1)===`
162
+ `?s[1].slice(0,-1):s[1];return{type:"paragraph",raw:s[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const s=this.rules.block.text.exec(t);if(s)return{type:"text",raw:s[0],text:s[0],tokens:this.lexer.inline(s[0])}}escape(t){const s=this.rules.inline.escape.exec(t);if(s)return{type:"escape",raw:s[0],text:Y(s[1])}}tag(t){const s=this.rules.inline.tag.exec(t);if(s)return!this.lexer.state.inLink&&/^<a /i.test(s[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(s[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(s[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(s[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:s[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:s[0]}}link(t){const s=this.rules.inline.link.exec(t);if(s){const n=s[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const l=ye(n.slice(0,-1),"\\");if((n.length-l.length)%2===0)return}else{const l=Zs(s[2],"()");if(l>-1){const c=(s[0].indexOf("!")===0?5:4)+s[1].length+l;s[2]=s[2].substring(0,l),s[0]=s[0].substring(0,c).trim(),s[3]=""}}let o=s[2],a="";if(this.options.pedantic){const l=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);l&&(o=l[1],a=l[3])}else a=s[3]?s[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(n)?o=o.slice(1):o=o.slice(1,-1)),wt(s,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},s[0],this.lexer)}}reflink(t,s){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const o=(n[2]||n[1]).replace(/\s+/g," "),a=s[o.toLowerCase()];if(!a){const l=n[0].charAt(0);return{type:"text",raw:l,text:l}}return wt(n,a,n[0],this.lexer)}}emStrong(t,s,n=""){let o=this.rules.inline.emStrongLDelim.exec(t);if(!o||o[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(o[1]||o[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const l=[...o[0]].length-1;let i,c,d=l,p=0;const h=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,s=s.slice(-1*t.length+l);(o=h.exec(s))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i)continue;if(c=[...i].length,o[3]||o[4]){d+=c;continue}else if((o[5]||o[6])&&l%3&&!((l+c)%3)){p+=c;continue}if(d-=c,d>0)continue;c=Math.min(c,c+d+p);const m=[...o[0]][0].length,f=t.slice(0,l+o.index+m+c);if(Math.min(l,c)%2){const y=f.slice(1,-1);return{type:"em",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}const u=f.slice(2,-2);return{type:"strong",raw:f,text:u,tokens:this.lexer.inlineTokens(u)}}}}codespan(t){const s=this.rules.inline.code.exec(t);if(s){let n=s[2].replace(/\n/g," ");const o=/[^ ]/.test(n),a=/^ /.test(n)&&/ $/.test(n);return o&&a&&(n=n.substring(1,n.length-1)),n=Y(n,!0),{type:"codespan",raw:s[0],text:n}}}br(t){const s=this.rules.inline.br.exec(t);if(s)return{type:"br",raw:s[0]}}del(t){const s=this.rules.inline.del.exec(t);if(s)return{type:"del",raw:s[0],text:s[2],tokens:this.lexer.inlineTokens(s[2])}}autolink(t){const s=this.rules.inline.autolink.exec(t);if(s){let n,o;return s[2]==="@"?(n=Y(s[1]),o="mailto:"+n):(n=Y(s[1]),o=n),{type:"link",raw:s[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let s;if(s=this.rules.inline.url.exec(t)){let o,a;if(s[2]==="@")o=Y(s[0]),a="mailto:"+o;else{let l;do l=s[0],s[0]=((n=this.rules.inline._backpedal.exec(s[0]))==null?void 0:n[0])??"";while(l!==s[0]);o=Y(s[0]),s[1]==="www."?a="http://"+s[0]:a=s[0]}return{type:"link",raw:s[0],text:o,href:a,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t){const s=this.rules.inline.text.exec(t);if(s){let n;return this.lexer.state.inRawBlock?n=s[0]:n=Y(s[0]),{type:"text",raw:s[0],text:n}}}}const Js=/^(?:[ \t]*(?:\n|$))+/,Xs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ks=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,xe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ys=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_t=/(?:[*+-]|\d{1,9}[.)])/,$t=v(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,_t).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),je=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,en=/^[^\n]+/,Re=/(?!\s*\])(?:\\.|[^\[\]\\])+/,tn=v(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Re).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),rn=v(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_t).getRegex(),Ve="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",We=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,sn=v("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",We).replace("tag",Ve).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Et=v(je).replace("hr",xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ve).getRegex(),ve={blockquote:v(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Et).getRegex(),code:Xs,def:tn,fences:Ks,heading:Ys,hr:xe,html:sn,lheading:$t,list:rn,newline:Js,paragraph:Et,table:be,text:en},Bt=v("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ve).getRegex(),nn={...ve,table:Bt,paragraph:v(je).replace("hr",xe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Bt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ve).getRegex()},on={...ve,html:v(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",We).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:be,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:v(je).replace("hr",xe).replace("heading",` *#{1,6} *[^
163
+ ]`).replace("lheading",$t).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Dt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,an=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Vt=/^( {2,}|\\)\n(?!\s*$)/,ln=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ke="\\p{P}\\p{S}",cn=v(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ke).getRegex(),dn=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,pn=v(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ke).getRegex(),hn=v("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ke).getRegex(),un=v("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ke).getRegex(),mn=v(/\\([punct])/,"gu").replace(/punct/g,ke).getRegex(),fn=v(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),gn=v(We).replace("(?:-->|$)","-->").getRegex(),bn=v("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",gn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ce=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,yn=v(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Ce).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ct=v(/^!?\[(label)\]\[(ref)\]/).replace("label",Ce).replace("ref",Re).getRegex(),Nt=v(/^!?\[(ref)\](?:\[\])?/).replace("ref",Re).getRegex(),xn=v("reflink|nolink(?!\\()","g").replace("reflink",Ct).replace("nolink",Nt).getRegex(),Ae={_backpedal:be,anyPunctuation:mn,autolink:fn,blockSkip:dn,br:Vt,code:an,del:be,emStrongLDelim:pn,emStrongRDelimAst:hn,emStrongRDelimUnd:un,escape:Dt,link:yn,nolink:Nt,punctuation:cn,reflink:Ct,reflinkSearch:xn,tag:bn,text:ln,url:be},kn={...Ae,link:v(/^!?\[(label)\]\((.*?)\)/).replace("label",Ce).getRegex(),reflink:v(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ce).getRegex()},Oe={...Ae,escape:v(Dt).replace("])","~|])").getRegex(),url:v(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},wn={...Oe,br:v(Vt).replace("{2,}","*").getRegex(),text:v(Oe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ne={normal:ve,gfm:nn,pedantic:on},we={normal:Ae,gfm:Oe,breaks:wn,pedantic:kn};class te{constructor(t){O(this,"tokens");O(this,"options");O(this,"state");O(this,"tokenizer");O(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ie,this.options.tokenizer=this.options.tokenizer||new De,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const s={block:Ne.normal,inline:we.normal};this.options.pedantic?(s.block=Ne.pedantic,s.inline=we.pedantic):this.options.gfm&&(s.block=Ne.gfm,this.options.breaks?s.inline=we.breaks:s.inline=we.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ne,inline:we}}static lex(t,s){return new te(s).lex(t)}static lexInline(t,s){return new te(s).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
164
+ `),this.blockTokens(t,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){const n=this.inlineQueue[s];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,s=[],n=!1){this.options.pedantic&&(t=t.replace(/\t/g," ").replace(/^ +$/gm,""));let o,a,l;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(i=>(o=i.call({lexer:this},t,s))?(t=t.substring(o.raw.length),s.push(o),!0):!1))){if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length),o.raw.length===1&&s.length>0?s[s.length-1].raw+=`
165
+ `:s.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length),a=s[s.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
166
+ `+o.raw,a.text+=`
167
+ `+o.text,this.inlineQueue[this.inlineQueue.length-1].src=a.text):s.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length),a=s[s.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
168
+ `+o.raw,a.text+=`
169
+ `+o.raw,this.inlineQueue[this.inlineQueue.length-1].src=a.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title});continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),s.push(o);continue}if(l=t,this.options.extensions&&this.options.extensions.startBlock){let i=1/0;const c=t.slice(1);let d;this.options.extensions.startBlock.forEach(p=>{d=p.call({lexer:this},c),typeof d=="number"&&d>=0&&(i=Math.min(i,d))}),i<1/0&&i>=0&&(l=t.substring(0,i+1))}if(this.state.top&&(o=this.tokenizer.paragraph(l))){a=s[s.length-1],n&&(a==null?void 0:a.type)==="paragraph"?(a.raw+=`
170
+ `+o.raw,a.text+=`
171
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):s.push(o),n=l.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length),a=s[s.length-1],a&&a.type==="text"?(a.raw+=`
172
+ `+o.raw,a.text+=`
173
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):s.push(o);continue}if(t){const i="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,s}inline(t,s=[]){return this.inlineQueue.push({src:t,tokens:s}),s}inlineTokens(t,s=[]){let n,o,a,l=t,i,c,d;if(this.tokens.links){const p=Object.keys(this.tokens.links);if(p.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(l))!=null;)p.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.blockSkip.exec(l))!=null;)l=l.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(l))!=null;)l=l.slice(0,i.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(c||(d=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(p=>(n=p.call({lexer:this},t,s))?(t=t.substring(n.raw.length),s.push(n),!0):!1))){if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),o=s[s.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):s.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length),o=s[s.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):s.push(n);continue}if(n=this.tokenizer.emStrong(t,l,d)){t=t.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.del(t)){t=t.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),s.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),s.push(n);continue}if(a=t,this.options.extensions&&this.options.extensions.startInline){let p=1/0;const h=t.slice(1);let m;this.options.extensions.startInline.forEach(f=>{m=f.call({lexer:this},h),typeof m=="number"&&m>=0&&(p=Math.min(p,m))}),p<1/0&&p>=0&&(a=t.substring(0,p+1))}if(n=this.tokenizer.inlineText(a)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(d=n.raw.slice(-1)),c=!0,o=s[s.length-1],o&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):s.push(n);continue}if(t){const p="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return s}}class Se{constructor(t){O(this,"options");O(this,"parser");this.options=t||ie}space(t){return""}code({text:t,lang:s,escaped:n}){var l;const o=(l=(s||"").match(/^\S*/))==null?void 0:l[0],a=t.replace(/\n$/,"")+`
174
+ `;return o?'<pre><code class="language-'+Y(o)+'">'+(n?a:Y(a,!0))+`</code></pre>
175
+ `:"<pre><code>"+(n?a:Y(a,!0))+`</code></pre>
176
176
  `}blockquote({tokens:t}){return`<blockquote>
177
177
  ${this.parser.parse(t)}</blockquote>
178
- `}html({text:t}){return t}heading({tokens:t,depth:n}){return`<h${n}>${this.parser.parseInline(t)}</h${n}>
178
+ `}html({text:t}){return t}heading({tokens:t,depth:s}){return`<h${s}>${this.parser.parseInline(t)}</h${s}>
179
179
  `}hr(t){return`<hr>
180
- `}list(t){const n=t.ordered,s=t.start;let o="";for(let i=0;i<t.items.length;i++){const c=t.items[i];o+=this.listitem(c)}const l=n?"ol":"ul",a=n&&s!==1?' start="'+s+'"':"";return"<"+l+a+`>
181
- `+o+"</"+l+`>
182
- `}listitem(t){let n="";if(t.task){const s=this.checkbox({checked:!!t.checked});t.loose?t.tokens.length>0&&t.tokens[0].type==="paragraph"?(t.tokens[0].text=s+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=s+" "+t.tokens[0].tokens[0].text)):t.tokens.unshift({type:"text",raw:s+" ",text:s+" "}):n+=s+" "}return n+=this.parser.parse(t.tokens,!!t.loose),`<li>${n}</li>
180
+ `}list(t){const s=t.ordered,n=t.start;let o="";for(let i=0;i<t.items.length;i++){const c=t.items[i];o+=this.listitem(c)}const a=s?"ol":"ul",l=s&&n!==1?' start="'+n+'"':"";return"<"+a+l+`>
181
+ `+o+"</"+a+`>
182
+ `}listitem(t){let s="";if(t.task){const n=this.checkbox({checked:!!t.checked});t.loose?t.tokens.length>0&&t.tokens[0].type==="paragraph"?(t.tokens[0].text=n+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=n+" "+t.tokens[0].tokens[0].text)):t.tokens.unshift({type:"text",raw:n+" ",text:n+" "}):s+=n+" "}return s+=this.parser.parse(t.tokens,!!t.loose),`<li>${s}</li>
183
183
  `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
184
- `}table(t){let n="",s="";for(let l=0;l<t.header.length;l++)s+=this.tablecell(t.header[l]);n+=this.tablerow({text:s});let o="";for(let l=0;l<t.rows.length;l++){const a=t.rows[l];s="";for(let i=0;i<a.length;i++)s+=this.tablecell(a[i]);o+=this.tablerow({text:s})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
184
+ `}table(t){let s="",n="";for(let a=0;a<t.header.length;a++)n+=this.tablecell(t.header[a]);s+=this.tablerow({text:n});let o="";for(let a=0;a<t.rows.length;a++){const l=t.rows[a];n="";for(let i=0;i<l.length;i++)n+=this.tablecell(l[i]);o+=this.tablerow({text:n})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
185
185
  <thead>
186
- `+n+`</thead>
186
+ `+s+`</thead>
187
187
  `+o+`</table>
188
188
  `}tablerow({text:t}){return`<tr>
189
189
  ${t}</tr>
190
- `}tablecell(t){const n=this.parser.parseInline(t.tokens),s=t.header?"th":"td";return(t.align?`<${s} align="${t.align}">`:`<${s}>`)+n+`</${s}>
191
- `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:s}){const o=this.parser.parseInline(s),l=xt(t);if(l===null)return o;t=l;let a='<a href="'+t+'"';return n&&(a+=' title="'+n+'"'),a+=">"+o+"</a>",a}image({href:t,title:n,text:s}){const o=xt(t);if(o===null)return s;t=o;let l=`<img src="${t}" alt="${s}"`;return n&&(l+=` title="${n}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class qe{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class re{constructor(t){O(this,"options");O(this,"renderer");O(this,"textRenderer");this.options=t||ie,this.options.renderer=this.options.renderer||new Se,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new qe}static parse(t,n){return new re(n).parse(t)}static parseInline(t,n){return new re(n).parseInline(t)}parse(t,n=!0){let s="";for(let o=0;o<t.length;o++){const l=t[o];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[l.type]){const i=l,c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(i.type)){s+=c||"";continue}}const a=l;switch(a.type){case"space":{s+=this.renderer.space(a);continue}case"hr":{s+=this.renderer.hr(a);continue}case"heading":{s+=this.renderer.heading(a);continue}case"code":{s+=this.renderer.code(a);continue}case"table":{s+=this.renderer.table(a);continue}case"blockquote":{s+=this.renderer.blockquote(a);continue}case"list":{s+=this.renderer.list(a);continue}case"html":{s+=this.renderer.html(a);continue}case"paragraph":{s+=this.renderer.paragraph(a);continue}case"text":{let i=a,c=this.renderer.text(i);for(;o+1<t.length&&t[o+1].type==="text";)i=t[++o],c+=`
192
- `+this.renderer.text(i);n?s+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c}]}):s+=c;continue}default:{const i='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return s}parseInline(t,n){n=n||this.renderer;let s="";for(let o=0;o<t.length;o++){const l=t[o];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[l.type]){const i=this.options.extensions.renderers[l.type].call({parser:this},l);if(i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){s+=i||"";continue}}const a=l;switch(a.type){case"escape":{s+=n.text(a);break}case"html":{s+=n.html(a);break}case"link":{s+=n.link(a);break}case"image":{s+=n.image(a);break}case"strong":{s+=n.strong(a);break}case"em":{s+=n.em(a);break}case"codespan":{s+=n.codespan(a);break}case"br":{s+=n.br(a);break}case"del":{s+=n.del(a);break}case"text":{s+=n.text(a);break}default:{const i='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return s}}class _e{constructor(t){O(this,"options");O(this,"block");this.options=t||ie}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?te.lex:te.lexInline}provideParser(){return this.block?re.parse:re.parseInline}}O(_e,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class _s{constructor(...t){O(this,"defaults",Fe());O(this,"options",this.setOptions);O(this,"parse",this.parseMarkdown(!0));O(this,"parseInline",this.parseMarkdown(!1));O(this,"Parser",re);O(this,"Renderer",Se);O(this,"TextRenderer",qe);O(this,"Lexer",te);O(this,"Tokenizer",Ve);O(this,"Hooks",_e);this.use(...t)}walkTokens(t,n){var o,l;let s=[];for(const a of t)switch(s=s.concat(n.call(this,a)),a.type){case"table":{const i=a;for(const c of i.header)s=s.concat(this.walkTokens(c.tokens,n));for(const c of i.rows)for(const d of c)s=s.concat(this.walkTokens(d.tokens,n));break}case"list":{const i=a;s=s.concat(this.walkTokens(i.items,n));break}default:{const i=a;(l=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&l[i.type]?this.defaults.extensions.childTokens[i.type].forEach(c=>{const d=i[c].flat(1/0);s=s.concat(this.walkTokens(d,n))}):i.tokens&&(s=s.concat(this.walkTokens(i.tokens,n)))}}return s}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(s=>{const o={...s};if(o.async=this.defaults.async||o.async||!1,s.extensions&&(s.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const a=n.renderers[l.name];a?n.renderers[l.name]=function(...i){let c=l.renderer.apply(this,i);return c===!1&&(c=a.apply(this,i)),c}:n.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=n[l.level];a?a.unshift(l.tokenizer):n[l.level]=[l.tokenizer],l.start&&(l.level==="block"?n.startBlock?n.startBlock.push(l.start):n.startBlock=[l.start]:l.level==="inline"&&(n.startInline?n.startInline.push(l.start):n.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(n.childTokens[l.name]=l.childTokens)}),o.extensions=n),s.renderer){const l=this.defaults.renderer||new Se(this.defaults);for(const a in s.renderer){if(!(a in l))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const i=a,c=s.renderer[i],d=l[i];l[i]=(...p)=>{let h=c.apply(l,p);return h===!1&&(h=d.apply(l,p)),h||""}}o.renderer=l}if(s.tokenizer){const l=this.defaults.tokenizer||new Ve(this.defaults);for(const a in s.tokenizer){if(!(a in l))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const i=a,c=s.tokenizer[i],d=l[i];l[i]=(...p)=>{let h=c.apply(l,p);return h===!1&&(h=d.apply(l,p)),h}}o.tokenizer=l}if(s.hooks){const l=this.defaults.hooks||new _e;for(const a in s.hooks){if(!(a in l))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const i=a,c=s.hooks[i],d=l[i];_e.passThroughHooks.has(a)?l[i]=p=>{if(this.defaults.async)return Promise.resolve(c.call(l,p)).then(m=>d.call(l,m));const h=c.call(l,p);return d.call(l,h)}:l[i]=(...p)=>{let h=c.apply(l,p);return h===!1&&(h=d.apply(l,p)),h}}o.hooks=l}if(s.walkTokens){const l=this.defaults.walkTokens,a=s.walkTokens;o.walkTokens=function(i){let c=[];return c.push(a.call(this,i)),l&&(c=c.concat(l.call(this,i))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return te.lex(t,n??this.defaults)}parser(t,n){return re.parse(t,n??this.defaults)}parseMarkdown(t){return(s,o)=>{const l={...o},a={...this.defaults,...l},i=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&l.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof s>"u"||s===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof s!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(s)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=t);const c=a.hooks?a.hooks.provideLexer():t?te.lex:te.lexInline,d=a.hooks?a.hooks.provideParser():t?re.parse:re.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(s):s).then(p=>c(p,a)).then(p=>a.hooks?a.hooks.processAllTokens(p):p).then(p=>a.walkTokens?Promise.all(this.walkTokens(p,a.walkTokens)).then(()=>p):p).then(p=>d(p,a)).then(p=>a.hooks?a.hooks.postprocess(p):p).catch(i);try{a.hooks&&(s=a.hooks.preprocess(s));let p=c(s,a);a.hooks&&(p=a.hooks.processAllTokens(p)),a.walkTokens&&this.walkTokens(p,a.walkTokens);let h=d(p,a);return a.hooks&&(h=a.hooks.postprocess(h)),h}catch(p){return i(p)}}}onError(t,n){return s=>{if(s.message+=`
193
- Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+Y(s.message+"",!0)+"</pre>";return n?Promise.resolve(o):o}if(n)return Promise.reject(s);throw s}}}const ce=new _s;function R(r,t){return ce.parse(r,t)}R.options=R.setOptions=function(r){return ce.setOptions(r),R.defaults=ce.defaults,ft(R.defaults),R},R.getDefaults=Fe,R.defaults=ie,R.use=function(...r){return ce.use(...r),R.defaults=ce.defaults,ft(R.defaults),R},R.walkTokens=function(r,t){return ce.walkTokens(r,t)},R.parseInline=ce.parseInline,R.Parser=re,R.parser=re.parse,R.Renderer=Se,R.TextRenderer=qe,R.Lexer=te,R.lexer=te.lex,R.Tokenizer=Ve,R.Hooks=_e,R.parse=R,R.options,R.setOptions,R.use,R.walkTokens,R.parseInline,re.parse,te.lex;const $s={class:"space-y-4"},Es={__name:"vs-editor-form-data",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}},columns:{type:Array,default:null}},emits:["update-dashboard"],setup(r,{expose:t,emit:n}){var L,E,C,B,T,M,U,Z,Q,N,V,P,A,g,_,k,z,q,S,oe,ae,le,Kt,Yt,er,tr,rr,nr,sr,or,ar,lr,ir,cr,dr,pr,hr,ur;const s=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=n,a=r,i=typeof window<"u"?new URLSearchParams(window.top.location.search):null,c=e.ref((i==null?void 0:i.get("dashboard"))||null),d=e.ref([]),p=e.computed(()=>{const I=a.columns??[];return I.length?I:d.value}),h=e.computed(()=>a.dashboardId||c.value);async function m(){if(a.columns!==null)return;const I=h.value;if(!(p.value.length||!I||!a.widgetName))try{const F=await H.get(`/bi-data?dashboard=${I}&widget=${a.widgetName}`);Array.isArray(F==null?void 0:F.columns)&&F.columns.length&&(d.value=F.columns)}catch{}}const f=I=>(I==null?void 0:I.name)!=null?{id:I.name,text:I.title||I.name}:null,u=I=>Array.isArray(I)?[...I].sort((F,ne)=>{const he=F.text&&F.text!==F.id,mr=ne.text&&ne.text!==ne.id;return he&&!mr?-1:!he&&mr?1:(F.text||"").localeCompare(ne.text||"",void 0,{sensitivity:"base"})}):I,y=e.computed(()=>{const I=(p.value??[]).filter(F=>(F==null?void 0:F.type)=="text"||(F==null?void 0:F.type)==="date"||(F==null?void 0:F.type)==="timestamp without time zone"||(F==null?void 0:F.type)==="boolean"||(F==null?void 0:F.type)==="integer").map(f).filter(Boolean);return u(I)}),b=e.computed(()=>`${a.widgetName}-${y.value.length}-${(p.value??[]).length}`),$=e.computed(()=>({text:{type:"Text",label:"Текст",conditions:["type","==","text"]},x:{type:"select",label:"Вісь X",style:{size:"xs"},conditions:["type","not_in",["text","table","map"]],options:[...y.value]},cls:{label:"Классифікатор вісі X",type:"text",conditions:["type","not_in",["text","table","map","cluster"]]},y_type:{label:"Тип вісі Y",type:"select",options:[{id:"columns",text:"columns"},{id:"function",text:"function"}],conditions:["type","not_in",["text","table","map","number","cluster"]]},tableSQL:{label:"Таблиця SQL",type:"text",hidden:!0},metric:{type:"select",label:"Вісь Y",conditions:[["type","not_in",["text","table","map","cluster"]],["y_type","!=","function"]],options:[{id:"count",text:"count"},...u(p.value.filter(I=>(I==null?void 0:I.type)==="numeric"||(I==null?void 0:I.type)==="double precision").map(f).filter(Boolean))]},fx:{type:"text",label:"Функція",conditions:[["y_type","==","function"]]},query:{label:"Запит (query)",type:"text",conditions:["type","not_in",["text","table","map","number"]]},groupby:{type:"select",label:"Групування",view:"buttons",style:{size:"xs"},options:[{id:"null",text:"null"},...u(p.value.filter(I=>(I==null?void 0:I.type)=="text"||(I==null?void 0:I.type)==="boolean"||(I==null?void 0:I.type)==="integer").map(f).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Колонки",style:{size:"xs"},options:u((p.value??[]).map(f).filter(Boolean)),conditions:["type","in",["table","map"]]},granularity:{type:"radio",label:"Гранулярність",options:[{id:"year",text:"year"},{id:"quarter",text:"quarter"},{id:"month",text:"month"},{id:"week",text:"week"}],conditions:["x.type","==","date"]},type:{type:"Text",hidden:!0}})),w=e.ref({x:((E=(L=a.data)==null?void 0:L.data)==null?void 0:E.x)||((C=a.data)==null?void 0:C.x)||null,metric:((T=(B=a.data)==null?void 0:B.data)==null?void 0:T.metric)||((M=a.data)==null?void 0:M.metric)||null,columns:((Z=(U=a.data)==null?void 0:U.data)==null?void 0:Z.columns)||((Q=a.data)==null?void 0:Q.columns)||null,granularity:((V=(N=a.data)==null?void 0:N.data)==null?void 0:V.granularity)||((P=a.data)==null?void 0:P.granularity)||null,type:((g=(A=a.data)==null?void 0:A.data)==null?void 0:g.type)||((_=a.data)==null?void 0:_.type)||null,groupby:((z=(k=a.data)==null?void 0:k.data)==null?void 0:z.groupby)||a.data.groupby||null,fx:((S=(q=a.data)==null?void 0:q.data)==null?void 0:S.fx)||((oe=a.data)==null?void 0:oe.fx)||null,query:((le=(ae=a.data)==null?void 0:ae.data)==null?void 0:le.query)||((Kt=a.data)==null?void 0:Kt.query)||null,y_type:((er=(Yt=a.data)==null?void 0:Yt.data)==null?void 0:er.y_type)||((tr=a.data)==null?void 0:tr.y_type)||null,tableSQL:((nr=(rr=a.data)==null?void 0:rr.data)==null?void 0:nr.tableSQL)||((sr=a.data)==null?void 0:sr.tableSQL)||null,cls:((ar=(or=a.data)==null?void 0:or.data)==null?void 0:ar.cls)||((lr=a.data)==null?void 0:lr.cls)||null,text:((cr=(ir=a.data)==null?void 0:ir.data)==null?void 0:cr.text)||((dr=a.data)==null?void 0:dr.text)||null,table:((hr=(pr=a.data)==null?void 0:pr.data)==null?void 0:hr.table)||((ur=a.data)==null?void 0:ur.table)||null}),x=async()=>{try{await H.put(`/bi-dashboard/${h.value}/${a.widgetName}`,{data:w.value});let I=`/bi-data?dashboard=${h.value}&widget=${a.widgetName}`;Object.entries(w.value).forEach(([ne,he])=>{I+=`&${ne}=${he}`});const F=new CustomEvent(`update-data-${a.widgetName}`);F.filterUrl=I,window.dispatchEvent(F),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},D=async()=>{try{let I=`/bi-data?dashboard=${h.value}&widget=${a.widgetName}`;Object.entries(w.value).forEach(([ne,he])=>{I+=`&${ne}=${he}`});const F=new CustomEvent(`update-data-${a.widgetName}`);F.filterUrl=I,window.dispatchEvent(F),l("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(w,()=>{D()},{deep:!0}),e.watch(()=>[a.widgetName,a.dashboardId,c.value],()=>{d.value=[],m()},{immediate:!0}),t({requestUpdateWidget:x}),(I,F)=>(e.openBlock(),e.createElementBlock("div",$s,[(e.openBlock(),e.createBlock(e.unref(s),{key:b.value,schema:$.value,values:w.value,"onUpdate:values":F[0]||(F[0]=ne=>w.value=ne)},null,8,["schema","values"]))]))}},Bs={class:"space-y-4"},Vs={__name:"vs-editor-form-yaml",props:{yamlValue:{type:null,default:()=>""},widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object}},emits:["update-dashboard"],setup(r,{expose:t,emit:n}){const s=typeof window<"u"?window.echarts:null,o=e.defineAsyncComponent(()=>import("@opengis/form").then(u=>u.VsInputMonaco)),l=e.ref(null),a=e.computed(()=>d.dashboardId||l.value),{$notify:i}=e.getCurrentInstance().proxy,c=n,d=r,p=(u,{dimensions:y,source:b})=>{const $=u.getOption(),{data:w,...x}=($==null?void 0:$.series)[0],[,...D]=y||[],L=D.map((E,C)=>({...($==null?void 0:$.series[C])||{},data:b.map(B=>B[C+1]),name:E}));u==null||u.setOption({...$||{},dataset:{dimensions:y,source:b},series:L,xAxis:{type:"category"},yAxis:{}},!0)},h=u=>{const y=document.getElementById(u);if(!y)return null;const b=s==null?void 0:s.getInstanceByDom(y);return b||null},m=e.ref(d.yamlValue),f=async()=>{try{await H.put(`/bi-dashboard/${a.value}/${d.widgetName}`,{yml:m.value});const u=h(d.widgetName);if(u){const y=await H.get(`/bi-data?dashboard=${l.value}&widget=${d.widgetName}`);p(u,y)}c("update-dashboard"),i({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{i({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const u=new URLSearchParams(window.top.location.search);l.value=u.get("dashboard")}),t({requestUpdateWidget:f}),(u,y)=>(e.openBlock(),e.createElementBlock("div",Bs,[e.createVNode(e.unref(o),{modelValue:m.value,"onUpdate:modelValue":y[0]||(y[0]=b=>m.value=b),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},Cs={class:"pt-[10px]"},St={"vs-editor-form-style":qn,"vs-editor-form-data":Es,"vs-editor-form-yaml":Vs,"vs-editor-form-controls":{__name:"vs-editor-form-controls",props:{widgetName:{type:String},controls:{type:Object,default:()=>{}},columns:{type:Array,default:()=>[]}},emits:["update-dashboard"],setup(r,{emit:t}){var p;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:s}=e.getCurrentInstance().proxy,o=t,l=r,a=e.ref(null),i={granularity:{ua:"Granularity",type:"checkbox",options:["week","month","quarter","year"]},export:{ua:"Export",type:"Switcher"},groupby:{ua:"Groupby",type:"checkbox",options:(p=l.columns)==null?void 0:p.map(({name:h})=>h)}},c=e.ref(l.controls||{}),d=async()=>{try{await H.put(`/bi-dashboard/${a.value}/${l.widgetName}`,{controls:c.value}),await s({type:"success",title:"Успішно!",message:"Дані успішно оновлено"}),staticTypes!=null&&staticTypes.includes(c.value.type)&&o("update-dashboard")}catch{await s({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const h=new URLSearchParams(window.top.location.search);a.value=h.get("dashboard")}),(h,m)=>{const f=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",Cs,[e.createVNode(f,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:d},{default:e.withCtx(()=>[...m[1]||(m[1]=[e.createTextVNode(" Зберегти ",-1)])]),_:1}),e.createVNode(e.unref(n),{schema:i,values:c.value,"onUpdate:values":m[0]||(m[0]=u=>c.value=u)},null,8,["values"])])}}}},Ds={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},zt={__name:"editor-tab-error-boundary",props:{tabComponent:{type:Object,default:null},tabKey:{type:[String,Number],default:""}},emits:["update-dashboard"],setup(r,{expose:t}){const n=r,s=e.ref(null);function o(){var a,i;(i=(a=s.value)==null?void 0:a.requestUpdateWidget)==null||i.call(a)}t({save:o});const l=e.ref(!1);return e.onErrorCaptured((a,i,c)=>(console.error("Editor tab error:",a,c),l.value=!0,!1)),e.watch(()=>n.tabComponent,()=>{l.value=!1},{immediate:!0}),(a,i)=>l.value?(e.openBlock(),e.createElementBlock("div",Ds," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.tabComponent),e.mergeProps({ref_key:"tabRef",ref:s,key:r.tabKey||"tab"},a.$attrs,{onUpdateDashboard:i[0]||(i[0]=c=>a.$emit("update-dashboard"))}),null,16))}},Ns={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},Ss={key:0,class:"flex flex-col min-h-0 flex-1"},zs={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},Ls={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},Ts=["onClick"],Is={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},Ms={class:"flex items-center gap-1 ml-auto shrink-0"},Ps={key:1,class:"flex-1 min-h-0 overflow-auto px-4 py-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},Fs={key:0},Rs={key:1},js={class:"p-4"},Ws={class:"flex justify-end mt-4 gap-x-3"},vs={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},As={__name:"vs-editor-forms",props:e.mergeModels({selectedWidgetData:{type:Object,required:!1,default:null},selectedDashboard:{type:String,default:()=>""},currentWidgetData:{type:Object,default:()=>""}},{selectedWidget:{},selectedWidgetModifiers:{}}),emits:e.mergeModels(["update-data"],["update:selectedWidget"]),setup(r,{emit:t}){var D,L;const n=e.defineAsyncComponent(()=>import("@opengis/form")),s=(L=(D=e.getCurrentInstance())==null?void 0:D.proxy)==null?void 0:L.$notify,o=K.useRouter(),l=t,a=e.ref(null),i=r,c=e.ref(!1),d=e.ref(!0),p=e.ref(!1),h=e.ref({}),m=e.useModel(r,"selectedWidget"),f=["table","text","number","stat","progress","listbar","map","pivot"],u=e.ref("data"),y=async()=>{try{await H.delete(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`),c.value=!1,l("update-data"),o.hasRoute(J.EditorDashboard)?await o.push({name:J.EditorDashboard,params:{dashboardId:i.selectedDashboard}}):m.value="",s({type:"success",title:"Успішно!",message:"Віджет успішно видалено"})}catch(E){console.error(E),s({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},b=e.computed(()=>{const E=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return E==null?void 0:E.filter(C=>{var B,T,M;return C.id==="style"?!(f!=null&&f.includes(((B=i.selectedWidgetData)==null?void 0:B.type)||((M=(T=i.selectedWidgetData)==null?void 0:T.data)==null?void 0:M.type))):!0})}),$=()=>{var E,C,B,T,M,U,Z,Q,N;h.value={title:(E=i.selectedWidgetData)==null?void 0:E.title,type:(C=i.selectedWidgetData)==null?void 0:C.type,table:(B=i.selectedWidgetData)==null?void 0:B.table_name,query:(M=(T=i.selectedWidgetData)==null?void 0:T.data)==null?void 0:M.query,x:(Z=(U=i.selectedWidgetData)==null?void 0:U.data)==null?void 0:Z.x,cls:(N=(Q=i.selectedWidgetData)==null?void 0:Q.data)==null?void 0:N.cls},p.value=!0},w=async()=>{try{await H.put(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`,h.value),s({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await l("update-data"),p.value=!1}catch{s({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(m,()=>{d.value=!1,setTimeout(()=>d.value=!0)});const x={title:{type:"text",ua:"Заголовок",placeholder:"Заголовок",validators:["required"]},type:{type:"select",view:"buttons",label:"Тип віджета",validators:["required"],options:[{label:"Bar",id:"bar"},{label:"Funnel",id:"funnel"},{label:"Line",id:"line"},{label:"List bar",id:"listbar"},{label:"Number",id:"number"},{label:"Pie",id:"pie"},{label:"Donut",id:"donut"},{label:"Pivot",id:"pivot"},{label:"Table",id:"table"},{label:"Progress",id:"progress"},{label:"Stat",id:"stat"},{label:"Text",id:"text"},{label:"Map",id:"map"}]},table:{type:"text",ua:"Таблиця",placeholder:"Таблиця"},query:{type:"Text",ua:"Запит (query)",placeholder:"Query"},x:{type:"Text",ua:"Вісь X",placeholder:"X Axis"},cls:{type:"Text",ua:"Клас (cls)",placeholder:"Cls"}};return(E,C)=>{var T,M,U,Z,Q,N,V,P,A,g,_;const B=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",Ns,[r.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",Ss,[e.createElementVNode("div",zs,[e.createElementVNode("nav",Ls,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,k=>(e.openBlock(),e.createElementBlock("button",{key:k.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",u.value===k.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:z=>u.value=k.id},[e.createTextVNode(e.toDisplayString(k.label)+" ",1),u.value===k.id?(e.openBlock(),e.createElementBlock("span",Is)):e.createCommentVNode("",!0)],10,Ts))),128))]),e.createElementVNode("div",Ms,[e.createVNode(B,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",title:"Зберегти",onClick:C[0]||(C[0]=k=>{var z,q;return(q=(z=a.value)==null?void 0:z.save)==null?void 0:q.call(z)})},[e.createVNode(e.unref(zr),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[C[9]||(C[9]=e.createTextVNode(" Зберегти ",-1))]),_:1}),e.createVNode(B,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",onClick:$},[e.createVNode(mt,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[C[10]||(C[10]=e.createTextVNode(" Редагувати віджет ",-1))]),_:1}),e.createVNode(B,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",onClick:C[1]||(C[1]=k=>c.value=!0)},[e.createVNode(e.unref(ut),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[C[11]||(C[11]=e.createTextVNode(" Видалити віджет ",-1))]),_:1})])]),(T=r.currentWidgetData)!=null&&T.status?(e.openBlock(),e.createBlock(Be,{key:0,title:(M=r.currentWidgetData)==null?void 0:M.title,text:(U=r.currentWidgetData)==null?void 0:U.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",Ps,[d.value&&r.currentWidgetData?(e.openBlock(),e.createElementBlock("div",Fs,[e.createVNode(zt,{ref_key:"tabPanelRef",ref:a,"tab-key":u.value,"tab-component":e.unref(St)["vs-editor-form-"+u.value],widgetName:(Z=r.selectedWidgetData)==null?void 0:Z.name,dashboardId:r.selectedDashboard,yamlValue:((Q=r.selectedWidgetData)==null?void 0:Q.yml)||"",data:r.selectedWidgetData,controls:(N=r.selectedWidgetData)==null?void 0:N.controls,columns:(V=r.currentWidgetData)==null?void 0:V.columns,onUpdateDashboard:C[2]||(C[2]=k=>E.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",Rs,[e.createVNode(zt,{ref_key:"tabPanelRef",ref:a,"tab-key":u.value,"tab-component":e.unref(St)["vs-editor-form-"+u.value],widgetName:(P=r.selectedWidgetData)==null?void 0:P.name,dashboardId:r.selectedDashboard,yamlValue:((A=r.selectedWidgetData)==null?void 0:A.yml)||"",data:r.selectedWidgetData,controls:(g=r.selectedWidgetData)==null?void 0:g.controls,columns:(_=r.currentWidgetData)==null?void 0:_.columns,onUpdateDashboard:C[3]||(C[3]=k=>E.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(ge,{teleport:"#modal",visible:c.value,title:"Ви впевнені?",onClose:C[5]||(C[5]=k=>c.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",js,[C[12]||(C[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",Ws,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-medium text-gray-800 bg-white border border-gray-200 rounded-lg shadow-sm gap-x-2 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:C[4]||(C[4]=k=>c.value=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-semibold text-white bg-red-500 border border-transparent rounded-lg gap-x-2 hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:y}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(Be,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(ge,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:C[8]||(C[8]=k=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",vs,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:C[7]||(C[7]=k=>p.value=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:w,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[x?(e.openBlock(),e.createBlock(e.unref(n),{key:0,schema:x,values:h.value,"onUpdate:values":C[6]||(C[6]=k=>h.value=k)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},Os={class:"overflow-hidden flex flex-col min-h-[480px]"},qs={class:"flex-1 flex min-h-0 gap-4"},Us={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},Hs={key:1,class:"flex items-center justify-center h-full"},Gs={class:"w-[400px] shrink-0 flex flex-col"},Zs={__name:"vs-widget-editor-panel",props:{selectedWidget:{type:String,default:""},selectedWidgetData:{type:Object,default:null},currentWidgetData:{type:Object,default:null},selectedDashboard:{type:String,default:""},dashboardWidgets:{type:Array,default:()=>[]}},emits:["update:selectedWidget","update-data"],setup(r,{emit:t}){const n=r,s=t,o=e.ref(null);async function l(){if(!(!n.selectedDashboard||!n.selectedWidget))try{o.value=await H.get(`/bi-data?dashboard=${n.selectedDashboard}&widget=${n.selectedWidget}`)}catch(c){console.error(c)}}function a(){s("update-data")}e.watch(()=>[n.selectedDashboard,n.selectedWidget],()=>{l()},{immediate:!0});const i=e.computed({get:()=>n.selectedWidget,set:c=>s("update:selectedWidget",c)});return(c,d)=>(e.openBlock(),e.createElementBlock("div",Os,[e.createElementVNode("div",qs,[e.createElementVNode("div",Us,[o.value?(e.openBlock(),e.createBlock(fe,{key:0,dashboard:r.selectedDashboard,widget:r.selectedWidget,"selected-widget":r.selectedWidget,"dashboard-widgets":r.dashboardWidgets,"prefetched-data":o.value,"filter-u-rl":void 0,class:"max-h-full"},null,8,["dashboard","widget","selected-widget","dashboard-widgets","prefetched-data"])):(e.openBlock(),e.createElementBlock("div",Hs,[...d[1]||(d[1]=[e.createElementVNode("span",{class:"text-sm text-gray-400"},"Завантаження...",-1)])]))]),e.createElementVNode("div",Gs,[e.createVNode(As,{selectedWidget:i.value,"onUpdate:selectedWidget":d[0]||(d[0]=p=>i.value=p),selectedWidgetData:r.selectedWidgetData,currentWidgetData:o.value||r.currentWidgetData||{columns:[]},selectedDashboard:r.selectedDashboard,onUpdateData:a},null,8,["selectedWidget","selectedWidgetData","currentWidgetData","selectedDashboard"])])])]))}},Lt={__name:"icon-grid",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(Cr),e.mergeProps(t.$attrs,{size:24}),null,16))}},Tt={__name:"icon-table",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(Lr),e.mergeProps(t.$attrs,{size:24}),null,16))}},Qs={__name:"icon-more",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(et),e.mergeProps(t.$attrs,{size:24}),null,16))}},Js=e.defineAsyncComponent(()=>import("@opengis/form")),Xs={components:{VsModal:ge,VForm:Js,deleteIcon:ut,editIcon:mt,IconGrid:Lt,IconMore:Qs,IconTable:Tt},watch:{dashboardData:{handler(r){var n,s;if(this.formEditValue={title:r==null?void 0:r.title,description:r==null?void 0:r.description,table_name:r==null?void 0:r.table_name,db:r==null?void 0:r.db,public:r==null?void 0:r.public,words:r==null?void 0:r.words},!((n=r==null?void 0:r.panels)!=null&&n.length)){this.formGridValue={panels:[]};return}const t=(s=r==null?void 0:r.panels)==null?void 0:s.map(o=>{var i,c;const{title:l="",type:a=""}=((c=(i=r==null?void 0:r.widgets)==null?void 0:i.find(d=>(d==null?void 0:d.name)===(o==null?void 0:o.widget)))==null?void 0:c.data)||{};return{title:l,type:a,...o}});this.formGridValue={panels:t}},immediate:!0}},data(){return{isDeleteConfirm:!1,isFormEdit:!1,isFormGrid:!1,isVisibleTableColumns:!1,formEditValue:{},formGridValue:{},editDashboardScheme:[{type:"Text",key:"title",label:"Заголовок",validators:["required"]},{type:"Text",key:"description",label:"Опис"},{type:"Select",key:"table_name",validators:["required"],data:"pg.table_name",label:"Назва таблиці"},{type:"Text",key:"words",label:"Ключові слова"},{type:"Text",key:"db",label:"База даних",original:{type:"Text",ua:"Назва",col:8}},{type:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}],editGridScheme:[{type:"DataTable",ua:"Панелі",key:"panels",actions:["search"],editable:!1,addition:!1,colModel:[{name:"title",ua:"Назва",type:"Text",key:"title"},{name:"type",ua:"Тип",type:"Text",key:"type",disabled:!0},{name:"widget",type:"Text",ua:"Віджет",key:"widget",hiddenCol:!0,disabled:!0},{name:"col",ua:"Кількість стовпчиків",type:"Text",key:"col"},{name:"height",ua:"Висота",type:"Text",key:"height"},{name:"category",ua:"Категорія",type:"Text",key:"category"}]}]}},props:{selected:{type:String,default:()=>""},dashboardData:{type:Object,default:()=>{}},selectedWidgetData:{type:Object,default:()=>{}},columns:{type:Array}},methods:{async editDashboard(){var r,t;try{const n=(t=(r=this.$refs)==null?void 0:r.formEdit)==null?void 0:t.validate();typeof n=="function"&&await n(),await H.put(`/bi-dashboard/${this.selected}`,this.formEditValue),await this.$notify({title:"Успішно!",type:"success",message:"Дані успішно оновлено"}),this.isFormEdit=!1,await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"при спробі оновити дані виникла помилка"})}},async editDashboardGrid(){var r,t;try{(t=(r=this.$refs)==null?void 0:r.formGrid)==null||t.doValidation(),await H.put(`/bi-dashboard/${this.selected}`,{...this.formEditValue,...this.formGridValue}),await this.$notify({title:"Успішно!",type:"success",message:"Дані успішно оновлено"}),this.isFormGrid=!1,await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі оновити дані виникла помилка"})}},async deleteDashboard(){try{await H.delete(`/bi-dashboard/${this.selected}`),this.isDeleteConfirm=!1,this.$emit("update:selected",""),this.$emit("update-editor"),this.$notify({title:"Успішно!",type:"success",message:"Дашборд видалено успішно"})}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі видалити дашборд виникла помилка"})}},closePopover(){document.body.click()}}},Ks={key:0,class:"flex items-center gap-4"},Ys={class:"h-[30px] w-[30px] flex items-center justify-center"},eo={class:"flex flex-col items-start -ml-2 -mr-2"},to={class:"p-4"},ro={class:"flex justify-end mt-4 gap-x-3"},no={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},so={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function oo(r,t,n,s,o,l){const a=e.resolveComponent("IconGrid"),i=e.resolveComponent("VsPopover"),c=e.resolveComponent("IconMore"),d=e.resolveComponent("VsModal"),p=e.resolveComponent("VForm");return e.openBlock(),e.createElementBlock("div",null,[n.selected?(e.openBlock(),e.createElementBlock("div",Ks,[e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{class:"h-[30px] w-[30px] flex items-center justify-center",onClick:t[0]||(t[0]=h=>o.isFormGrid=!0)},[e.createVNode(a,{class:"h-[20px] text-gray-500"})])]),default:e.withCtx(()=>[t[14]||(t[14]=e.createTextVNode(" Редагувати структуру дашборду ",-1))]),_:1}),e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createVNode(i,{placement:"bottom-left"},{reference:e.withCtx(()=>[e.createElementVNode("button",Ys,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",eo,[e.createElementVNode("button",{onClick:t[1]||(t[1]=h=>{l.closePopover(),o.isFormEdit=!0}),class:"px-[8px] py-[4px] hover:bg-gray-100 w-full text-start rounded-lg"}," Редагувати дашборд "),e.createElementVNode("button",{onClick:t[2]||(t[2]=h=>{l.closePopover(),o.isDeleteConfirm=!0}),class:"px-[8px] py-[4px] hover:bg-gray-100 w-full text-start rounded-lg"}," Видалити дашборд ")])]),_:1})]),default:e.withCtx(()=>[t[15]||(t[15]=e.createTextVNode(" Керування дашбордом ",-1))]),_:1})])):e.createCommentVNode("",!0),e.createVNode(d,{teleport:"#modal",visible:o.isDeleteConfirm,size:"small",title:"Ви впевнені?",onClose:t[5]||(t[5]=h=>o.isDeleteConfirm=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",to,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",ro,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-medium text-gray-800 bg-white border border-gray-200 rounded-lg shadow-sm gap-x-2 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:t[3]||(t[3]=h=>o.isDeleteConfirm=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-semibold text-white bg-red-500 border border-transparent rounded-lg gap-x-2 hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:t[4]||(t[4]=(...h)=>l.deleteDashboard&&l.deleteDashboard(...h))}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormEdit,title:"Редагувати дашборд",onClose:t[9]||(t[9]=h=>o.isFormEdit=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",no,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[7]||(t[7]=h=>o.isFormEdit=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:t[8]||(t[8]=(...h)=>l.editDashboard&&l.editDashboard(...h)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(p,{ref:"formEdit",schema:o.editDashboardScheme,values:o.formEditValue,"onUpdate:values":t[6]||(t[6]=h=>o.formEditValue=h)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormGrid,title:"Редагувати структуру дашборду",onClose:t[13]||(t[13]=h=>o.isFormGrid=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",so,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[11]||(t[11]=h=>o.isFormGrid=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:t[12]||(t[12]=(...h)=>l.editDashboardGrid&&l.editDashboardGrid(...h)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(p,{ref:"formgrid",schema:o.editGridScheme,values:o.formGridValue,"onUpdate:values":t[10]||(t[10]=h=>o.formGridValue=h)},null,8,["schema","values"])]),_:1},8,["visible"])])}const ao=W(Xs,[["render",oo]]),lo={class:"flex-1 min-w-0 flex flex-col overflow-auto"},io={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},co={class:"relative z-10 shrink-0 mt-4 mb-6"},po={class:"flex items-center text-sm text-gray-600"},ho={key:0,class:"flex items-center justify-between gap-4 mt-3"},uo={class:"min-w-0"},mo={class:"text-2xl font-bold text-gray-900"},fo={key:0,class:"mt-1.5 text-sm text-gray-600"},go={class:"flex items-center shrink-0"},bo={key:1,class:"grid flex-grow w-full grid-cols-12 gap-4 py-4 pr-[15px] min-h-0 overflow-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},yo=W({__name:"vs-editor",props:{prefix:String,customClass:{type:String,default:()=>"w-screen h-screen"},initialDashboardId:{type:String,default:""},initialWidgetId:{type:String,default:""}},emits:["back"],setup(r,{emit:t}){const n=r;$e(n.prefix||"/api");const s=t,o=K.useRouter(),l=e.computed(()=>o.hasRoute(J.EditorWidget)),a=e.inject("biClearDashboard",null),i=e.ref(n.initialDashboardId||""),c=e.ref(n.initialWidgetId||""),d=e.ref(null),p=e.ref(null),h=e.ref(null);e.watch(()=>n.initialWidgetId,w=>{c.value=w||""});const m=async()=>{if(!i.value){d.value=null;return}try{const w=await H.get(`/bi-dashboard/${i.value}`);d.value=w}catch(w){console.error(w)}},f=e.computed(()=>{var w,x,D;return(D=Array.isArray((w=d.value)==null?void 0:w.widgets)?(x=d.value)==null?void 0:x.widgets:[])==null?void 0:D.find(L=>(L==null?void 0:L.name)===c.value)});function u(w){l.value?o.push({name:J.EditorWidget,params:{dashboardId:i.value,widgetId:w}}):c.value=w}function y(){l.value?o.push({name:J.EditorDashboard,params:{dashboardId:i.value}}):c.value=""}function b(){l.value?o.push({name:J.Editor}):(typeof a=="function"&&a(),s("back"))}const $=e.computed(()=>{var D,L,E,C,B;const x=[l.value?{label:"Дашборди",to:{name:J.Editor}}:{label:"Дашборди",onClick:b}];if((D=d.value)!=null&&D.title||i.value){const T=((L=d.value)==null?void 0:L.title)||i.value||"Редактор";!!c.value?x.push(l.value?{label:T,to:{name:J.EditorDashboard,params:{dashboardId:i.value}}}:{label:T,onClick:()=>{c.value=""}}):x.push({label:T})}else x.push({label:"Редактор"});if(c.value&&f.value){const T=((C=(E=f.value)==null?void 0:E.data)==null?void 0:C.title)||((B=f.value)==null?void 0:B.title)||c.value;x.push({label:T})}return x});return e.watch(i,(w,x)=>{x&&(c.value=""),w?m():(d.value=null,b())}),e.onMounted(()=>{m()}),(w,x)=>{var D,L;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[r.customClass]])},[e.createElementVNode("div",lo,[e.createElementVNode("div",io,[e.createElementVNode("div",co,[e.createElementVNode("div",po,[e.createVNode(dt,{items:$.value,compact:""},null,8,["items"])]),i.value&&d.value?(e.openBlock(),e.createElementBlock("div",ho,[e.createElementVNode("div",uo,[e.createElementVNode("h1",mo,e.toDisplayString(d.value.title||i.value),1),d.value.description?(e.openBlock(),e.createElementBlock("p",fo,e.toDisplayString(d.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",go,[c.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors",onClick:y},[e.createVNode(e.unref(nt),{class:"w-4 h-4"}),x[5]||(x[5]=e.createTextVNode(" Закрити ",-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(ao,{selected:i.value,"onUpdate:selected":x[0]||(x[0]=E=>i.value=E),dashboardData:d.value,columns:(D=d.value)==null?void 0:D.columns,selectedWidgetData:f.value,prefix:r.prefix,onUpdateEditor:m},null,8,["selected","dashboardData","columns","selectedWidgetData","prefix"]),e.createElementVNode("button",{type:"button",class:"ml-4 flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors shadow-sm font-medium",onClick:x[1]||(x[1]=E=>{var C,B;return(B=(C=h.value)==null?void 0:C.open)==null?void 0:B.call(C)})},[...x[6]||(x[6]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ",-1)])]),i.value?(e.openBlock(),e.createBlock(An,{key:0,ref_key:"createWidgetRef",ref:h,inline:"",columns:(L=d.value)==null?void 0:L.columns,selectedDashboard:i.value,onUpdateData:m},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),c.value&&d.value?(e.openBlock(),e.createBlock(Zs,{key:0,"selected-widget":c.value,"onUpdate:selectedWidget":x[2]||(x[2]=E=>c.value=E),"selected-widget-data":f.value,"current-widget-data":p.value,"selected-dashboard":i.value,"dashboard-widgets":d.value.widgets||[],onUpdateData:m},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",bo,[d.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(d.value.panels,(E,C)=>{var B,T;return e.openBlock(),e.createElementBlock("div",{key:E.widget||((B=E.widgets)==null?void 0:B.join("-"))||C,class:e.normalizeClass([`md:col-span-${E.col||12} col-span-12`,"flex flex-col gap-[10px]"])},[(T=E.widgets)!=null&&T.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(E.widgets,M=>(e.openBlock(),e.createBlock(fe,{onClick:U=>u(M),"onUpdate:currentWidgetData":x[3]||(x[3]=U=>p.value=U),key:M,dashboard:i.value,widget:M,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(E.height??480),class:e.normalizeClass({"border border-blue-500":c.value===M})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","height","class"]))),128)):(e.openBlock(),e.createBlock(fe,{key:1,onClick:M=>u(E.widget),"onUpdate:currentWidgetData":x[4]||(x[4]=M=>p.value=M),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":c.value===E.widget}]),dashboard:i.value,widget:E.widget,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(E.height??480)},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets","height"]))],2)}),128)):(e.openBlock(),e.createBlock(Be,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-5400c793"]]),xo={class:"w-full h-screen"},It=e.defineComponent({__name:"vs-editor-page",props:{prefix:{default:"/api"},dashboardId:{default:""},widgetId:{default:""}},emits:["back"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("div",xo,[e.createVNode(yo,{customClass:"h-full w-full",prefix:r.prefix,"initial-dashboard-id":r.dashboardId,"initial-widget-id":r.widgetId,onBack:n[0]||(n[0]=s=>t.$emit("back"))},null,8,["prefix","initial-dashboard-id","initial-widget-id"])]))}}),se=(r,t)=>{const n=r.__vccOpts||r;for(const[s,o]of t)n[s]=o;return n},ko={},wo={xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-6 text-green-600"};function _o(r,t){return e.openBlock(),e.createElementBlock("svg",wo,[...t[0]||(t[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)])])}const $o=se(ko,[["render",_o]]),Eo={},Bo={xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"orange",class:"size-6 text-orange-600"};function Vo(r,t){return e.openBlock(),e.createElementBlock("svg",Bo,[...t[0]||(t[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)])])}const Co=se(Eo,[["render",Vo]]),Do={},No={xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-6 text-blue-600"};function So(r,t){return e.openBlock(),e.createElementBlock("svg",No,[...t[0]||(t[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"},null,-1)])])}const zo=se(Do,[["render",So]]),Lo={},To={xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"red",class:"size-6 text-red-600"};function Io(r,t){return e.openBlock(),e.createElementBlock("svg",To,[...t[0]||(t[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"},null,-1)])])}const Mo=se(Lo,[["render",Io]]),Po={class:"rounded-md border border-gray-300 bg-white p-4 shadow-sm"},Fo={class:"flex items-start gap-4 opacity-100 scale-5 transition-all duration-300"},Ro={class:"flex-1"},jo={class:"font-medium text-gray-900"},Wo={class:"mt-0.5 text-sm text-gray-700"},vo=e.defineComponent({__name:"vs-notify",props:{type:{},title:{},message:{}},setup(r){const t={success:$o,warning:Co,error:Mo,info:zo};return(n,s)=>(e.openBlock(),e.createElementBlock("div",Po,[e.createElementVNode("div",Fo,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t[n.type]))),e.createElementVNode("div",Ro,[e.createElementVNode("strong",jo,e.toDisplayString(n.title),1),e.createElementVNode("p",Wo,e.toDisplayString(n.message),1)]),s[0]||(s[0]=e.createElementVNode("button",{class:"m-3 rounded-full p-1.5 text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-700",type:"button","aria-label":"Dismiss notify"},[e.createElementVNode("span",{class:"sr-only"},"Dismiss popup"),e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})])],-1))])]))}}),ze={top:"top-4 left-1/2 transform -translate-x-1/2","left-bottom":"bottom-4 left-4 transform","right-bottom":"bottom-4 right-4 transform",bottom:"bottom-4 left-1/2 transform -translate-x-1/2"},Ao=r=>{var c;const{type:t="info",title:n,message:s,position:o="right-bottom"}=r||{};let l=document.querySelector("#notify-root");l||(l=document.createElement("div"),l.id="notify-root",l.className=`fixed z-[2000] flex flex-col gap-3 ${ze[o]} p-6 max-w-md mx-auto font-sans antialiased`,document.body.appendChild(l)),l.className.includes(ze[o])||(Object.values(ze).forEach(d=>{l.classList.remove(...d.split(" "))}),l.classList.add(...ze[o].split(" ")));const a=document.createElement("div");l.appendChild(a);const i=e.createApp({render(){return e.h(vo,{type:t,title:n,message:s,onClose:()=>{i.unmount(),a.remove()}})}});i.mount(a),(c=a.querySelector("button"))==null||c.addEventListener("click",()=>{a.classList.add("opacity-0","scale-95","transition-all","duration-300"),setTimeout(()=>{i.unmount(),a.remove()},350)}),setTimeout(()=>{a.classList.add("opacity-0","scale-95","transition-all","duration-300"),setTimeout(()=>{i.unmount(),a.remove()},350)},3500)};e.defineComponent({name:"Copy",props:{text:{type:String,default:""},width:{type:[String,Number],default:null},notify:{type:Boolean,default:!0},notifyOptions:{type:Object,default:()=>({})}},emits:["copied","copy-error"],data(){return{slotText:""}},computed:{rootClasses(){return["vs-copy inline-flex items-center gap-2 cursor-pointer select-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500"]},containerStyle(){return!this.width&&this.width!==0?{}:{width:typeof this.width=="number"?`${this.width}px`:this.width.trim()}},displayText(){return this.text||this.slotText}},mounted(){this.updateSlotText()},updated(){this.updateSlotText()},methods:{updateSlotText(){var t,n;const r=((n=(t=this.$refs.text)==null?void 0:t.textContent)==null?void 0:n.trim())||"";r!==this.slotText&&(this.slotText=r)},async handleCopy(){const r=this.displayText;if(r)try{await this.copyToClipboard(r),this.$emit("copied",r),this.showNotify(r)}catch(t){this.$emit("copy-error",t)}},async copyToClipboard(r){var n;if((n=navigator.clipboard)!=null&&n.writeText){await navigator.clipboard.writeText(r);return}const t=document.createElement("textarea");t.value=r,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("Copy command was unsuccessful")}finally{document.body.removeChild(t)}},showNotify(r){var n,s,o,l;if(!this.notify)return;const t={type:((n=this.notifyOptions)==null?void 0:n.type)??"success",title:((s=this.notifyOptions)==null?void 0:s.title)??"Copied",message:((o=this.notifyOptions)==null?void 0:o.message)??r,position:(l=this.notifyOptions)==null?void 0:l.position};Ao(t)}}}),e.defineComponent({props:{modelValue:{type:Boolean,default:()=>!1},title:{type:String,default:()=>""},disabled:{type:Boolean,default:()=>!1}},data(){return{}},mounted(){this.modelValue||this.$emit("update:modelValue",!1)},computed:{modelState:{get(){return this.modelValue},set(r){this.$emit("update:modelValue",r)}},labelCursorClasses(){return[{"cursor-not-allowed":this.disabled},{"cursor-pointer":!this.disabled}]}},methods:{handleEnterDown(r){const{keyCode:t}=r;t===13&&(this.modelState=!this.modelState)},addKeyHandler(){window.addEventListener("keydown",this.handleEnterDown)},removeKeyHandler(){window.removeEventListener("keydown",this.handleEnterDown)}}});const Oo={},qo={xmlns:"http://www.w3.org/2000/svg",class:"w-6 h-6",viewBox:"0 0 20 20",fill:"currentColor"};function Uo(r,t){return e.openBlock(),e.createElementBlock("svg",qo,[...t[0]||(t[0]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1)])])}const Ho=se(Oo,[["render",Uo]]),Go={},Zo={xmlns:"http://www.w3.org/2000/svg",class:"w-6 h-6",viewBox:"0 0 20 20",fill:"currentColor"};function Qo(r,t){return e.openBlock(),e.createElementBlock("svg",Zo,[...t[0]||(t[0]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z","clip-rule":"evenodd"},null,-1)])])}const Jo=se(Go,[["render",Qo]]),Xo={},Ko={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-chevron-down",height:"16",width:"16"};function Yo(r,t){return e.openBlock(),e.createElementBlock("svg",Ko,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M6 9l6 6l6 -6"},null,-1)])])}const ea=se(Xo,[["render",Yo]]),ta={},ra={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-check text-blue-600",width:"14",height:"14"};function na(r,t){return e.openBlock(),e.createElementBlock("svg",ra,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M5 12l5 5l10 -10"},null,-1)])])}const sa=se(ta,[["render",na]]),oa={class:"flex items-center justify-between w-full"},aa={class:"m-0 flex list-none justify-center gap-1 p-0 text-gray-900"},la=["onClick"],ia={key:1,class:"flex size-7 items-center justify-center px-1 text-gray-500 select-none","aria-hidden":"true"},ca={key:1},da={for:"Page"},pa=["value","max"],ha={key:2,class:"text-sm/8 font-medium tracking-widest"},ua={key:0,class:"flex justify-center items-center gap-x-5 ml-3"},ma={class:"hs-dropdown-menu z-50 bg-white shadow-md rounded-lg p-1 space-y-0.5 dark:bg-neutral-800 dark:border dark:border-neutral-700 right-0 dark:divide-neutral-700 absolute bottom-[100%]",role:"menu","aria-orientation":"vertical","aria-labelledby":"dropdown-button"},fa=["onClick"],ga=e.defineComponent({__name:"vs-pagination",props:{pageSize:{},page:{},total:{},view:{default:"button"},pageSizes:{default:()=>[10,20,30]},showPageSizes:{type:Boolean,default:!0},pageRange:{default:7},size:{default:7},color:{default:"teal"}},emits:["update:page","pageChange","pageSizeChange"],setup(r,{emit:t}){const n=r,s=t,o=e.ref(n.page),l=e.computed(()=>Math.ceil(n.total/n.pageSize)),a=e.computed(()=>{const b=Math.floor(n.pageRange/2);let $=o.value-b,w=o.value+b;$<1&&(w+=1-$,$=1),w>l.value&&($-=w-l.value,w=l.value),$=Math.max(1,$);const x=[];for(let D=$;D<=w;D+=1)x.push(D);return x}),i=e.computed(()=>{const b=a.value,$=l.value;if($<=1)return b.map(L=>({type:"page",value:L}));const w=b.length>0&&b[0]>1,x=b.length>0&&b[b.length-1]<$,D=[];return w&&(D.push({type:"page",value:1}),D.push({type:"ellipsis"})),b.forEach(L=>D.push({type:"page",value:L})),x&&(D.push({type:"ellipsis"}),D.push({type:"page",value:$})),D}),c=b=>{o.value=b,s("update:page",b),s("pageChange",b)},d=()=>{o.value>1&&c(o.value-1)},p=()=>{o.value<l.value&&c(o.value+1)};e.watch(()=>n.page,b=>{o.value=b});const h=e.ref(n.pageSize),m=e.ref(!1),f=e.ref(null);e.watch(()=>n.pageSize,b=>{h.value=b});const u=(b=h.value)=>{h.value=b,m.value=!1,o.value=1,s("update:page",o.value),s("pageSizeChange",h.value)},y=b=>{if(!m.value)return;const $=b.target;f.value&&$&&!f.value.contains($)&&(m.value=!1)};return e.onMounted(()=>{document.addEventListener("click",y)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",y)}),(b,$)=>(e.openBlock(),e.createElementBlock("div",oa,[e.createElementVNode("ul",aa,[e.createElementVNode("li",null,[e.createElementVNode("button",{class:e.normalizeClass(["grid size-7 cursor-pointer place-content-center rounded border border-gray-200 transition-colors hover:bg-gray-50 rtl:rotate-180",{"opacity-50 pointer-events-none":o.value===1}]),"aria-label":"Previous page",onClick:d},[e.createVNode(Ho)],2)]),b.view==="button"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(i.value,(w,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:w.type==="page"?w.value:`ellipsis-${x}`},[w.type==="page"?(e.openBlock(),e.createElementBlock("li",{key:0,class:e.normalizeClass([[`size-${n.size} text-sm/${n.size} px-1.5`,w.value===o.value&&b.color?`bg-[${b.color}]`:"",w.value===o.value?`block rounded border border-${b.color}-600 text-center font-medium text-white`:"block rounded border border-gray-200 text-center font-medium transition-colors hover:bg-gray-50"],"cursor-pointer"]),onClick:D=>c(w.value)},e.toDisplayString(w.value),11,la)):(e.openBlock(),e.createElementBlock("li",ia," … "))],64))),128)):b.view==="input"?(e.openBlock(),e.createElementBlock("li",ca,[e.createElementVNode("label",da,[$[2]||($[2]=e.createElementVNode("span",{class:"sr-only"}," Page ",-1)),e.createElementVNode("input",{type:"number",id:"Page",value:o.value,min:"1",max:l.value,onInput:$[0]||($[0]=w=>c(Number(w))),class:"pagination-input block h-8 w-16 rounded border border-gray-300 px-3 py-2 text-base leading-6 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"},null,40,pa)])])):b.view==="xy"?(e.openBlock(),e.createElementBlock("li",ha,e.toDisplayString(o.value)+"/"+e.toDisplayString(l.value),1)):e.createCommentVNode("",!0),e.createElementVNode("li",null,[e.createElementVNode("button",{onClick:p,class:e.normalizeClass(["grid size-7 cursor-pointer place-content-center rounded border border-gray-200 transition-colors hover:bg-gray-50 rtl:rotate-180",{"opacity-50 pointer-events-none":o.value===l.value}]),"aria-label":"Next page"},[e.createVNode(Jo)],2)])]),b.showPageSizes?(e.openBlock(),e.createElementBlock("div",ua,[e.createElementVNode("div",{class:"relative",ref_key:"dropdownRef",ref:f},[e.withDirectives(e.createElementVNode("div",ma,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.pageSizes,w=>(e.openBlock(),e.createElementBlock("button",{type:"button",key:w,onClick:x=>u(w),class:"flex w-full items-center gap-x-3.5 rounded-lg px-3 py-2 text-sm text-gray-800 hover:bg-gray-100 focus:bg-gray-100 focus:outline-none dark:text-neutral-400 dark:hover:bg-neutral-700 dark:hover:text-neutral-300 dark:focus:bg-neutral-700"},[e.createTextVNode(e.toDisplayString(w)+" ",1),h.value===w?(e.openBlock(),e.createBlock(sa,{key:0})):e.createCommentVNode("",!0)],8,fa))),128))],512),[[e.vShow,m.value]]),e.createElementVNode("button",{type:"button",class:"inline-flex min-w-[32px] text-sm/7 items-center gap-x-1 rounded-md border border-gray-200 px-1.5 h-[1.75rem] text-base text-gray-800 shadow-sm hover:bg-gray-50 focus:bg-gray-100 focus:outline-none disabled:pointer-events-none disabled:opacity-50 dark:border-neutral-700 dark:text-white dark:hover:bg-neutral-700 dark:focus:bg-neutral-700","aria-haspopup":"menu","aria-expanded":"false","aria-label":"Dropdown",onClick:$[1]||($[1]=w=>m.value=!m.value)},[e.createTextVNode(e.toDisplayString(h.value)+" ",1),e.createVNode(ea)])],512)])):e.createCommentVNode("",!0)]))}}),ba=se(ga,[["__scopeId","data-v-36d0267f"]]);e.reactive({visible:!0});const ya={class:"relative group h-full"},xa={class:"flex items-start gap-3 flex-1 min-h-0"},ka={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},wa={class:"flex-1 min-w-0 flex flex-col min-h-0"},_a={class:"font-semibold text-gray-900 mb-1 truncate"},$a={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},Ea={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},Ba={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},Va={key:3,class:"text-xs text-gray-400 mt-2 shrink-0"},Ca=W({__name:"dashboard-card",props:{title:String,description:String,lastUpdate:{type:[String,Date],default:null},name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function},setup(r){const t=r,n=e.computed(()=>Me(t.lastUpdate??null)),s=K.useRouter(),o=e.ref(!1);function l(){t.dashboardRouteName&&(s.hasRoute(J.EditorDashboard)?s.push({name:J.EditorDashboard,params:{dashboardId:t.dashboardRouteName}}):t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):s.push({path:"/editor",query:{dashboard:t.dashboardRouteName}}))}function a(i){i.target.closest(".dashboard-card-menu")||(o.value=!1)}return e.onMounted(()=>document.addEventListener("click",a)),e.onUnmounted(()=>document.removeEventListener("click",a)),(i,c)=>(e.openBlock(),e.createElementBlock("div",ya,[e.createElementVNode("button",{type:"button",class:"w-full h-full bg-white border border-gray-200 rounded-lg p-6 hover:shadow-md hover:border-blue-200 transition-all text-left animate-fade-in flex flex-col",onClick:l},[e.createElementVNode("div",xa,[e.createElementVNode("div",ka,[e.createVNode(e.unref(Vr),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",wa,[e.createElementVNode("h3",_a,e.toDisplayString(r.title),1),r.description?(e.openBlock(),e.createElementBlock("p",$a,e.toDisplayString(r.description),1)):(e.openBlock(),e.createElementBlock("p",Ea,"   ")),r.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",Ba,e.toDisplayString(r.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0),n.value?(e.openBlock(),e.createElementBlock("p",Va," Оновлено: "+e.toDisplayString(n.value),1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-6c4cd6c6"]]),Da=[{type:"Text",key:"name",label:"Назва",validators:["required"],original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"title",label:"Заголовок",validators:["required"],original:{type:"Text",ua:"Титул",col:8}},{type:"Text",key:"description",label:"Опис",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"words",label:"Ключові слова",original:{type:"Text",ua:"Назва",col:8}},{type:"Select",data:"pg.table_name",key:"table_name",validators:["required"],label:"Назва таблиці",original:{type:"select",ua:"Назва",col:8,data:"pg.table_name"}},{type:"Text",key:"db",label:"База даних",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"category",label:"Категорія",original:{type:"Text",ua:"Категорія",col:8}},{type:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}];function Na(r){return!Array.isArray(r)||r.length===0?{}:r.reduce((t,n)=>{if(!n||n.key==null)return t;const{key:s,...o}=n;return t[s]=o,t},{})}const Sa={class:"flex-1 bg-gray-50"},za={class:"max-w-7xl mx-auto px-6 py-8"},La={class:"mb-6"},Ta={class:"flex items-center justify-between mb-6"},Ia={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Ma={class:"flex items-center space-x-4"},Pa={class:"flex-1 relative"},Fa={class:"relative"},Ra={class:"relative min-h-[280px]"},ja={key:0,class:"absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-white/55 backdrop-blur-[2px]","aria-busy":"true","aria-live":"polite"},Wa={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},va={class:"mt-[20px]"},Aa={key:2,class:"flex flex-col items-center justify-center py-20 text-center"},Oa={class:"mt-1 text-sm text-gray-400"},qa={class:"font-medium text-gray-500"},Mt=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(r){const t=e.defineAsyncComponent(()=>import("@opengis/form")),n=Na(Da),s=e.ref([]),o=e.ref([]),l=K.useRouter(),a=K.useRoute();function i(N){const V=Array.isArray(N)?N[0]:N,P=typeof V=="string"?parseInt(V,10):NaN;return!Number.isNaN(P)&&P>=1?P:1}function c(N){const V=Array.isArray(N)?N[0]:N;return typeof V=="string"?V:""}function d(N){const V=N.trim().toLowerCase();return V?V.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):""}const p=e.inject("biSetDashboard",void 0),h=r,m=e.ref(null),f=e.ref(!1),u=e.ref({}),y=e.ref(""),b=e.ref("title-asc"),$=e.ref(21),w=e.ref(0),x=e.ref(1),D=e.ref(!1),L=e.computed(()=>{const N=b.value==="title-asc"?1:-1;return[...s.value].sort((V,P)=>N*V.title.localeCompare(P.title,"uk"))});async function E(){D.value=!0;try{const N=d(y.value),V=await H.get("/bi-dashboard",{params:{type:"db",page:x.value,limit:$.value,...N?{search:N}:{}}}),P=Array.isArray(V==null?void 0:V.rows)?V.rows:[];w.value=(V==null?void 0:V.filtered)||(V==null?void 0:V.total)||0,o.value=P,s.value=P.map(A=>({routeName:String(A.name??""),title:A.title??A.name??"Без назви",description:A.description??null,last_update:A.last_update!=null?String(A.last_update):null,name:String(A.name??"")}))}catch(N){console.error("Failed to load dashboards",N),o.value=[],s.value=[]}finally{D.value=!1}}async function C(){var V,P,A;const N=(P=(V=e.getCurrentInstance())==null?void 0:V.proxy)==null?void 0:P.$notify;try{const g=(A=m.value)==null?void 0:A.validate();typeof g=="function"&&await g();const{name:_,title:k,table_name:z}=u.value;if(!_||!k||!z){N==null||N({type:"error",title:"Помилка!",message:"Заповніть усі обов'язкові поля"});return}await H.post("/bi-dashboard",u.value),f.value=!1,u.value={},N==null||N({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),l.hasRoute(J.EditorDashboard)?l.push({name:J.EditorDashboard,params:{dashboardId:_}}):p?p(_):await E()}catch{N==null||N({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}let B=null;e.onMounted(()=>{$e(h.prefix||"/api"),x.value=i(a.query.page),y.value=c(a.query.search),E()}),e.watch(y,N=>{B&&clearTimeout(B),B=setTimeout(()=>{B=null;const V=N.trim(),P=c(a.query.search);if(V===P)return;const A={...a.query};V?A.search=V:delete A.search,delete A.page,l.replace({query:A})},300)}),e.watch(()=>[a.query.page,a.query.search],()=>{const N=i(a.query.page),V=c(a.query.search);x.value=N,y.value=V,E()});const T=e.ref(1),M=()=>{const N=window.innerWidth;T.value=N>=1024?3:N>=768?2:1};e.onMounted(()=>{M(),window.addEventListener("resize",M)}),e.onUnmounted(()=>{B&&clearTimeout(B),window.removeEventListener("resize",M)});const U=N=>N?N.trim().length>70?2:1:0,Z=N=>{const V=T.value||1,A=Math.floor(N/V)*V,g=A+V,_=L.value.slice(A,g);let k=0;for(const z of _){const q=U(z.description??null);if(q>k&&(k=q),k===2)break}return k},Q=N=>{const V={...a.query};N===1?delete V.page:V.page=String(N),l.push({query:V})};return(N,V)=>(e.openBlock(),e.createElementBlock("div",Sa,[e.createElementVNode("div",za,[e.createElementVNode("div",La,[e.createElementVNode("div",Ta,[V[7]||(V[7]=e.createElementVNode("div",null,[e.createElementVNode("h1",{class:"text-3xl font-bold text-gray-900"},"Дашборди"),e.createElementVNode("p",{class:"mt-2 text-gray-600"}," Керуйте та переглядайте свої аналітичні дашборди ")],-1)),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 px-4 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors shadow-sm font-medium",onClick:V[0]||(V[0]=P=>f.value=!0)},[e.createVNode(e.unref(tt),{size:24,class:"w-4 h-4"}),V[6]||(V[6]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(ge,{teleport:"#modal",visible:f.value,title:"Створити дашборд",onClose:V[3]||(V[3]=P=>f.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Ia,[e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border border-gray-200 rounded-lg hover:bg-gray-100 duration-300",onClick:V[2]||(V[2]=P=>f.value=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg hover:bg-blue-700 duration-300",onClick:C}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:m,schema:e.unref(n),values:u.value,"onUpdate:values":V[1]||(V[1]=P=>u.value=P)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",Ma,[e.createElementVNode("div",Pa,[e.createVNode(e.unref(rt),{size:24,class:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[4]||(V[4]=P=>y.value=P),type:"text",placeholder:"Пошук дашбордів...",class:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},null,512),[[e.vModelText,y.value]])]),e.createElementVNode("div",Fa,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[5]||(V[5]=P=>b.value=P),class:"appearance-none pl-3 pr-8 py-2 border border-gray-300 rounded-lg bg-white text-sm text-gray-700 cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500"},[...V[8]||(V[8]=[e.createElementVNode("option",{value:"title-asc"},"Назва (А → Я)",-1),e.createElementVNode("option",{value:"title-desc"},"Назва (Я → А)",-1)])],512),[[e.vModelSelect,b.value]]),e.createVNode(e.unref(kr),{size:16,class:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 pointer-events-none"})])])]),e.createElementVNode("div",Ra,[D.value?(e.openBlock(),e.createElementBlock("div",ja,[...V[9]||(V[9]=[e.createElementVNode("div",{class:"h-11 w-11 animate-spin rounded-full border-[3px] border-blue-100 border-t-blue-600 shadow-sm",role:"status"},null,-1)])])):e.createCommentVNode("",!0),L.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",Wa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.value,(P,A)=>(e.openBlock(),e.createElementBlock("div",{key:P.routeName,class:"cursor-pointer h-full"},[e.createVNode(Ca,{title:P.title,description:P.description,"last-update":P.last_update,name:P.name,reserveLines:Z(A),"dashboard-route-name":P.routeName,"on-open-editor":e.unref(p)},null,8,["title","description","last-update","name","reserveLines","dashboard-route-name","on-open-editor"])]))),128))]),e.createElementVNode("div",va,[e.createVNode(e.unref(ba),{total:w.value,showPageSizes:!1,page:x.value,pageSize:$.value,"onUpdate:page":Q,color:"#2563eb"},null,8,["total","page","pageSize"])])],64)):D.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Aa,[e.createVNode(e.unref(rt),{size:48,class:"text-gray-300 mb-4"}),V[12]||(V[12]=e.createElementVNode("p",{class:"text-lg font-medium text-gray-500"},"Дашбордів не знайдено",-1)),e.createElementVNode("p",Oa,[V[10]||(V[10]=e.createTextVNode(" За запитом «",-1)),e.createElementVNode("span",qa,e.toDisplayString(y.value),1),V[11]||(V[11]=e.createTextVNode("» нічого не знайдено. Спробуйте змінити пошуковий запит. ",-1))])]))])])]))}}),Ua=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(r){const t=r,n=e.computed(()=>t.prefix),s=K.useRouter(),o=K.useRoute(),l=e.computed(()=>s.hasRoute(J.EditorDashboard)),a=e.ref("");e.onMounted(()=>{var c;if(!l.value){const d=(c=o==null?void 0:o.query)==null?void 0:c.dashboard;d!=null&&typeof d=="string"&&(a.value=d.trim())}});const i=e.computed(()=>a.value.length>0);return e.provide("biSetDashboard",c=>{a.value=c||""}),e.provide("biClearDashboard",()=>{a.value=""}),e.provide("biSelectedDashboardId",e.readonly(a)),(c,d)=>{const p=e.resolveComponent("router-view");return l.value?(e.openBlock(),e.createBlock(p,{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[i.value?(e.openBlock(),e.createBlock(It,{key:`editor-${a.value}`,prefix:n.value,"dashboard-id":a.value,onBack:d[0]||(d[0]=h=>a.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock(Mt,{key:0,prefix:n.value},null,8,["prefix"]))],64))}}});class Ha{static getTooltipOptions(t=!0){return{show:t,confine:!0,appendToBody:!1,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const Ga={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function Za(){const r="0123456789ABCDEF";let t="#";for(let n=0;n<6;n+=1)t+=r[Math.floor(Math.random()*16)];return t}function de(r=Ga){var n,s,o;const t={label:{show:((n=r==null?void 0:r.label)==null?void 0:n.show)??(r==null?void 0:r.show_label)??!1,formatter:(r==null?void 0:r.formatter)??(l=>ee(l)),...(r==null?void 0:r.label)||{}},legend:{...(r==null?void 0:r.legend)||{},[((s=r==null?void 0:r.legend)==null?void 0:s.position)||"bottom"]:"0",show:((o=r==null?void 0:r.legend)==null?void 0:o.show)??(r==null?void 0:r.show_legend)??!1},barWidth:"70%",grid:{borderColor:"#e5e7eb"},title:{...(r==null?void 0:r.title)||{}}};return(r!=null&&r.colors||r!=null&&r.color)&&(t.color=(r==null?void 0:r.colors)||(r==null?void 0:r.color)||null),t}function Pt(r){return{color:"#9ca3af",fontSize:10,fontFamily:"Inter, ui-sans-serif, system-ui",fontWeight:400,label:r==null?void 0:r.label,show:!0,formatter:(r==null?void 0:r.formatter)??(t=>ee(t)),margin:(r==null?void 0:r.margin)??7,interval:(r==null?void 0:r.interval)??"auto",rotate:(r==null?void 0:r.rotate)??0}}const Ft=["#d3c7e6","#bedae3","#f8e9cb","#ff8c8c","#c5d8be","#ffc6c6","#ffc39a","#fff7c5","#d8ffc0","#d4f7ff"];class Le{static getLabelOptions(t={}){return{show:(t==null?void 0:t.show_label)||(t==null?void 0:t.show)||!1,fontSize:"10",position:(t==null?void 0:t.position)||"inside",formatter:(t==null?void 0:t.formatter)||"{d}%",...t}}static getLegendOpions(t={}){return{...t,position:(t==null?void 0:t.position)||"bottom"}}}const pe=typeof window<"u"?window.echarts:null,X={props:["source","style","widget","dashboard","config","title","currentWidget","widgetData","prefix","prefetchedData"],data(){return{sourceData:null,styleData:null,widgetName:"",dimensions:[],dashboardName:"",titleCharts:"",eventWidgetId:"",widgetInstance:null}},mounted(){this.eventWidgetId=this.resolveWidgetId(),window.addEventListener("resize",this.handleResize),this.eventWidgetId&&(window.addEventListener(`update-data-${this.eventWidgetId}`,this.checkCustomEvent),window.addEventListener(`update-style-${this.eventWidgetId}`,this.checkCustomStyleEvent))},unmounted(){this.eventWidgetId&&(window.removeEventListener(`update-data-${this.eventWidgetId}`,this.checkCustomEvent),window.removeEventListener(`update-style-${this.eventWidgetId}`,this.checkCustomStyleEvent))},watch:{sourceData:{async handler(){setTimeout(()=>{this==null||this.onChangedData()},0)}}},methods:{resolveWidgetId(){var r,t,n,s;return this.widget||((r=this.config)==null?void 0:r.widget)||((t=this.config)==null?void 0:t.widgetId)||((n=this.config)==null?void 0:n.id)||((s=this.config)==null?void 0:s.name)||""},resolveDashboardId(){var r,t;return this.dashboard||((r=this.config)==null?void 0:r.dashboard)||((t=this.config)==null?void 0:t.dashboardId)||""},resolvePrefix(){var r;return this.prefix||((r=this.config)==null?void 0:r.prefix)||""},checkCustomStyleEvent(r){this.changeOptionsByName(r.chartId,r.options)},checkCustomEvent({filterUrl:r}){this.getDataFromURL(r)},handleResize(){this.widgetInstance&&this.widgetInstance.resize()},async getDataFromURL(r){try{const t=await H.get(r);this.applyResponse(t)}catch(t){const n={message:"Дані не знайдено",title:"Помилка!",type:"error",status:400,id:this.widgetName};(t==null?void 0:t.status)=="404"&&(n.status=404,n.message="Дані не знайдено"),(t==null?void 0:t.status)=="400"&&(n.message="Перевірте налаштування або зверніться до адміністратора"),(t==null?void 0:t.status)=="500"&&(n.message="Сталася помилка сервера"),this.$emit("update:widgetData",n)}},getValues(){return this.sourceData.map(r=>{var t;return parseFloat(r[(t=this.columns)==null?void 0:t[1]])})},formatDate(r){const t=new Date(r);if(isNaN(t))return r;const n=String(t.getDate()).padStart(2,"0"),o=["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"][t.getMonth()],l=t.getFullYear();return`${n} ${o} ${l}`},applyResponse(r){var t;this.sourceData=(r==null?void 0:r.source)||[],this.$emit("update:widgetData",r),this.dimensions=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{}),this.titleCharts=this.style?this.style:(r==null?void 0:r.title)||"",this.styleData=(r==null?void 0:r.style)||{}},async getData(){var r,t;try{const n=this.resolveWidgetId(),s=this.resolveDashboardId(),o=this.resolvePrefix();if(this.source)this.sourceData=[...this.source],this.styleData=this.style,this.titleCharts=this.title||((r=this.config)==null?void 0:r.title),this.dimensions=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{});else if(this.prefetchedData)this.widgetName=n,this.dashboardName=s,this.applyResponse(this.prefetchedData);else{this.widgetName=n,this.dashboardName=s;const l=this.dashboardName?`${o}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}`:`${o}/bi-data?&widget=${this.widgetName}`;await this.getDataFromURL(l)}}catch(n){console.error(n)}},async initChart(r,t,n){var s,o,l,a,i,c,d,p,h;this.widgetInstance&&this.widgetInstance.clear();try{const m=this.$refs.chart,f=pe==null?void 0:pe.init(m);if(!f)return;const u={tooltip:{show:((o=(s=this.styleData)==null?void 0:s.tooltip)==null?void 0:o.show)!==!1,trigger:"axis",confine:!0,appendToBody:!1,axisPointer:{type:"shadow"},backgroundColor:"transparent",shadowColor:"transparent",padding:[0,0,0,0],borderWidth:0,position:(y,b,$,w,x)=>{const[D,L]=y,[E,C]=x.contentSize,[B,T]=x.viewSize;let M=D+14,U=L-C/2;return M+E>B&&(M=D-E-14),M<0&&(M=0),U+C>T&&(U=T-C),U<0&&(U=0),[M,U]},formatter:y=>{var C;const $=(C=y[0])==null?void 0:C.axisValue,w=$?this.formatDate($):"N/A",x=[...y].filter(B=>{var T;return parseFloat(B==null?void 0:B.data)||((T=B==null?void 0:B.data)==null?void 0:T.value)}).sort((B,T)=>{var Z,Q;const M=parseFloat(((Z=B==null?void 0:B.data)==null?void 0:Z.value)??(B==null?void 0:B.data))||0;return(parseFloat(((Q=T==null?void 0:T.data)==null?void 0:Q.value)??(T==null?void 0:T.data))||0)-M}),D=x.slice(0,8),L=x.length-D.length;let E=`
190
+ `}tablecell(t){const s=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+s+`</${n}>
191
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:s,tokens:n}){const o=this.parser.parseInline(n),a=xt(t);if(a===null)return o;t=a;let l='<a href="'+t+'"';return s&&(l+=' title="'+s+'"'),l+=">"+o+"</a>",l}image({href:t,title:s,text:n}){const o=xt(t);if(o===null)return n;t=o;let a=`<img src="${t}" alt="${n}"`;return s&&(a+=` title="${s}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class qe{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class re{constructor(t){O(this,"options");O(this,"renderer");O(this,"textRenderer");this.options=t||ie,this.options.renderer=this.options.renderer||new Se,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new qe}static parse(t,s){return new re(s).parse(t)}static parseInline(t,s){return new re(s).parseInline(t)}parse(t,s=!0){let n="";for(let o=0;o<t.length;o++){const a=t[o];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const i=a,c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(i.type)){n+=c||"";continue}}const l=a;switch(l.type){case"space":{n+=this.renderer.space(l);continue}case"hr":{n+=this.renderer.hr(l);continue}case"heading":{n+=this.renderer.heading(l);continue}case"code":{n+=this.renderer.code(l);continue}case"table":{n+=this.renderer.table(l);continue}case"blockquote":{n+=this.renderer.blockquote(l);continue}case"list":{n+=this.renderer.list(l);continue}case"html":{n+=this.renderer.html(l);continue}case"paragraph":{n+=this.renderer.paragraph(l);continue}case"text":{let i=l,c=this.renderer.text(i);for(;o+1<t.length&&t[o+1].type==="text";)i=t[++o],c+=`
192
+ `+this.renderer.text(i);s?n+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c}]}):n+=c;continue}default:{const i='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}parseInline(t,s){s=s||this.renderer;let n="";for(let o=0;o<t.length;o++){const a=t[o];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const i=this.options.extensions.renderers[a.type].call({parser:this},a);if(i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=i||"";continue}}const l=a;switch(l.type){case"escape":{n+=s.text(l);break}case"html":{n+=s.html(l);break}case"link":{n+=s.link(l);break}case"image":{n+=s.image(l);break}case"strong":{n+=s.strong(l);break}case"em":{n+=s.em(l);break}case"codespan":{n+=s.codespan(l);break}case"br":{n+=s.br(l);break}case"del":{n+=s.del(l);break}case"text":{n+=s.text(l);break}default:{const i='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}}class _e{constructor(t){O(this,"options");O(this,"block");this.options=t||ie}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?te.lex:te.lexInline}provideParser(){return this.block?re.parse:re.parseInline}}O(_e,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class _n{constructor(...t){O(this,"defaults",Fe());O(this,"options",this.setOptions);O(this,"parse",this.parseMarkdown(!0));O(this,"parseInline",this.parseMarkdown(!1));O(this,"Parser",re);O(this,"Renderer",Se);O(this,"TextRenderer",qe);O(this,"Lexer",te);O(this,"Tokenizer",De);O(this,"Hooks",_e);this.use(...t)}walkTokens(t,s){var o,a;let n=[];for(const l of t)switch(n=n.concat(s.call(this,l)),l.type){case"table":{const i=l;for(const c of i.header)n=n.concat(this.walkTokens(c.tokens,s));for(const c of i.rows)for(const d of c)n=n.concat(this.walkTokens(d.tokens,s));break}case"list":{const i=l;n=n.concat(this.walkTokens(i.items,s));break}default:{const i=l;(a=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&a[i.type]?this.defaults.extensions.childTokens[i.type].forEach(c=>{const d=i[c].flat(1/0);n=n.concat(this.walkTokens(d,s))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,s)))}}return n}use(...t){const s=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const l=s.renderers[a.name];l?s.renderers[a.name]=function(...i){let c=a.renderer.apply(this,i);return c===!1&&(c=l.apply(this,i)),c}:s.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const l=s[a.level];l?l.unshift(a.tokenizer):s[a.level]=[a.tokenizer],a.start&&(a.level==="block"?s.startBlock?s.startBlock.push(a.start):s.startBlock=[a.start]:a.level==="inline"&&(s.startInline?s.startInline.push(a.start):s.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(s.childTokens[a.name]=a.childTokens)}),o.extensions=s),n.renderer){const a=this.defaults.renderer||new Se(this.defaults);for(const l in n.renderer){if(!(l in a))throw new Error(`renderer '${l}' does not exist`);if(["options","parser"].includes(l))continue;const i=l,c=n.renderer[i],d=a[i];a[i]=(...p)=>{let h=c.apply(a,p);return h===!1&&(h=d.apply(a,p)),h||""}}o.renderer=a}if(n.tokenizer){const a=this.defaults.tokenizer||new De(this.defaults);for(const l in n.tokenizer){if(!(l in a))throw new Error(`tokenizer '${l}' does not exist`);if(["options","rules","lexer"].includes(l))continue;const i=l,c=n.tokenizer[i],d=a[i];a[i]=(...p)=>{let h=c.apply(a,p);return h===!1&&(h=d.apply(a,p)),h}}o.tokenizer=a}if(n.hooks){const a=this.defaults.hooks||new _e;for(const l in n.hooks){if(!(l in a))throw new Error(`hook '${l}' does not exist`);if(["options","block"].includes(l))continue;const i=l,c=n.hooks[i],d=a[i];_e.passThroughHooks.has(l)?a[i]=p=>{if(this.defaults.async)return Promise.resolve(c.call(a,p)).then(m=>d.call(a,m));const h=c.call(a,p);return d.call(a,h)}:a[i]=(...p)=>{let h=c.apply(a,p);return h===!1&&(h=d.apply(a,p)),h}}o.hooks=a}if(n.walkTokens){const a=this.defaults.walkTokens,l=n.walkTokens;o.walkTokens=function(i){let c=[];return c.push(l.call(this,i)),a&&(c=c.concat(a.call(this,i))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,s){return te.lex(t,s??this.defaults)}parser(t,s){return re.parse(t,s??this.defaults)}parseMarkdown(t){return(n,o)=>{const a={...o},l={...this.defaults,...a},i=this.onError(!!l.silent,!!l.async);if(this.defaults.async===!0&&a.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));l.hooks&&(l.hooks.options=l,l.hooks.block=t);const c=l.hooks?l.hooks.provideLexer():t?te.lex:te.lexInline,d=l.hooks?l.hooks.provideParser():t?re.parse:re.parseInline;if(l.async)return Promise.resolve(l.hooks?l.hooks.preprocess(n):n).then(p=>c(p,l)).then(p=>l.hooks?l.hooks.processAllTokens(p):p).then(p=>l.walkTokens?Promise.all(this.walkTokens(p,l.walkTokens)).then(()=>p):p).then(p=>d(p,l)).then(p=>l.hooks?l.hooks.postprocess(p):p).catch(i);try{l.hooks&&(n=l.hooks.preprocess(n));let p=c(n,l);l.hooks&&(p=l.hooks.processAllTokens(p)),l.walkTokens&&this.walkTokens(p,l.walkTokens);let h=d(p,l);return l.hooks&&(h=l.hooks.postprocess(h)),h}catch(p){return i(p)}}}onError(t,s){return n=>{if(n.message+=`
193
+ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+Y(n.message+"",!0)+"</pre>";return s?Promise.resolve(o):o}if(s)return Promise.reject(n);throw n}}}const ce=new _n;function j(r,t){return ce.parse(r,t)}j.options=j.setOptions=function(r){return ce.setOptions(r),j.defaults=ce.defaults,ft(j.defaults),j},j.getDefaults=Fe,j.defaults=ie,j.use=function(...r){return ce.use(...r),j.defaults=ce.defaults,ft(j.defaults),j},j.walkTokens=function(r,t){return ce.walkTokens(r,t)},j.parseInline=ce.parseInline,j.Parser=re,j.parser=re.parse,j.Renderer=Se,j.TextRenderer=qe,j.Lexer=te,j.lexer=te.lex,j.Tokenizer=De,j.Hooks=_e,j.parse=j,j.options,j.setOptions,j.use,j.walkTokens,j.parseInline,re.parse,te.lex;const $n={class:"space-y-4"},En={__name:"vs-editor-form-data",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}},columns:{type:Array,default:null}},emits:["update-dashboard"],setup(r,{expose:t,emit:s}){var L,E,V,B,I,M,U,Z,Q,N,D,P,A,g,_,k,z,q,S,oe,ae,le,Kt,Yt,er,tr,rr,sr,nr,or,ar,lr,ir,cr,dr,pr,hr,ur;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,a=s,l=r,i=typeof window<"u"?new URLSearchParams(window.top.location.search):null,c=e.ref((i==null?void 0:i.get("dashboard"))||null),d=e.ref([]),p=e.computed(()=>{const T=l.columns??[];return T.length?T:d.value}),h=e.computed(()=>l.dashboardId||c.value);async function m(){if(l.columns!==null)return;const T=h.value;if(!(p.value.length||!T||!l.widgetName))try{const F=await H.get(`/bi-data?dashboard=${T}&widget=${l.widgetName}`);Array.isArray(F==null?void 0:F.columns)&&F.columns.length&&(d.value=F.columns)}catch{}}const f=T=>(T==null?void 0:T.name)!=null?{id:T.name,text:T.title||T.name}:null,u=T=>Array.isArray(T)?[...T].sort((F,se)=>{const he=F.text&&F.text!==F.id,mr=se.text&&se.text!==se.id;return he&&!mr?-1:!he&&mr?1:(F.text||"").localeCompare(se.text||"",void 0,{sensitivity:"base"})}):T,y=e.computed(()=>{const T=(p.value??[]).filter(F=>(F==null?void 0:F.type)=="text"||(F==null?void 0:F.type)==="date"||(F==null?void 0:F.type)==="timestamp without time zone"||(F==null?void 0:F.type)==="boolean"||(F==null?void 0:F.type)==="integer").map(f).filter(Boolean);return u(T)}),b=e.computed(()=>`${l.widgetName}-${y.value.length}-${(p.value??[]).length}`),$=e.computed(()=>({text:{type:"Text",label:"Текст",conditions:["type","==","text"]},x:{type:"select",label:"Вісь X",style:{size:"xs"},conditions:["type","not_in",["text","table","map"]],options:[...y.value]},cls:{label:"Классифікатор вісі X",type:"text",conditions:["type","not_in",["text","table","map","cluster"]]},y_type:{label:"Тип вісі Y",type:"select",options:[{id:"columns",text:"columns"},{id:"function",text:"function"}],conditions:["type","not_in",["text","table","map","number","cluster"]]},tableSQL:{label:"Таблиця SQL",type:"text",hidden:!0},metric:{type:"select",label:"Вісь Y",conditions:[["type","not_in",["text","table","map","cluster"]],["y_type","!=","function"]],options:[{id:"count",text:"count"},...u(p.value.filter(T=>(T==null?void 0:T.type)==="numeric"||(T==null?void 0:T.type)==="double precision").map(f).filter(Boolean))]},fx:{type:"text",label:"Функція",conditions:[["y_type","==","function"]]},query:{label:"Запит (query)",type:"text",conditions:["type","not_in",["text","table","map","number"]]},groupby:{type:"select",label:"Групування",view:"buttons",style:{size:"xs"},options:[{id:"null",text:"null"},...u(p.value.filter(T=>(T==null?void 0:T.type)=="text"||(T==null?void 0:T.type)==="boolean"||(T==null?void 0:T.type)==="integer").map(f).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Колонки",style:{size:"xs"},options:u((p.value??[]).map(f).filter(Boolean)),conditions:["type","in",["table","map"]]},granularity:{type:"radio",label:"Гранулярність",options:[{id:"year",text:"year"},{id:"quarter",text:"quarter"},{id:"month",text:"month"},{id:"week",text:"week"}],conditions:["x.type","==","date"]},type:{type:"Text",hidden:!0}})),w=e.ref({x:((E=(L=l.data)==null?void 0:L.data)==null?void 0:E.x)||((V=l.data)==null?void 0:V.x)||null,metric:((I=(B=l.data)==null?void 0:B.data)==null?void 0:I.metric)||((M=l.data)==null?void 0:M.metric)||null,columns:((Z=(U=l.data)==null?void 0:U.data)==null?void 0:Z.columns)||((Q=l.data)==null?void 0:Q.columns)||null,granularity:((D=(N=l.data)==null?void 0:N.data)==null?void 0:D.granularity)||((P=l.data)==null?void 0:P.granularity)||null,type:((g=(A=l.data)==null?void 0:A.data)==null?void 0:g.type)||((_=l.data)==null?void 0:_.type)||null,groupby:((z=(k=l.data)==null?void 0:k.data)==null?void 0:z.groupby)||l.data.groupby||null,fx:((S=(q=l.data)==null?void 0:q.data)==null?void 0:S.fx)||((oe=l.data)==null?void 0:oe.fx)||null,query:((le=(ae=l.data)==null?void 0:ae.data)==null?void 0:le.query)||((Kt=l.data)==null?void 0:Kt.query)||null,y_type:((er=(Yt=l.data)==null?void 0:Yt.data)==null?void 0:er.y_type)||((tr=l.data)==null?void 0:tr.y_type)||null,tableSQL:((sr=(rr=l.data)==null?void 0:rr.data)==null?void 0:sr.tableSQL)||((nr=l.data)==null?void 0:nr.tableSQL)||null,cls:((ar=(or=l.data)==null?void 0:or.data)==null?void 0:ar.cls)||((lr=l.data)==null?void 0:lr.cls)||null,text:((cr=(ir=l.data)==null?void 0:ir.data)==null?void 0:cr.text)||((dr=l.data)==null?void 0:dr.text)||null,table:((hr=(pr=l.data)==null?void 0:pr.data)==null?void 0:hr.table)||((ur=l.data)==null?void 0:ur.table)||null}),x=async()=>{try{await H.put(`/bi-dashboard/${h.value}/${l.widgetName}`,{data:w.value});let T=`/bi-data?dashboard=${h.value}&widget=${l.widgetName}`;Object.entries(w.value).forEach(([se,he])=>{T+=`&${se}=${he}`});const F=new CustomEvent(`update-data-${l.widgetName}`);F.filterUrl=T,window.dispatchEvent(F),a("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},C=async()=>{try{let T=`/bi-data?dashboard=${h.value}&widget=${l.widgetName}`;Object.entries(w.value).forEach(([se,he])=>{T+=`&${se}=${he}`});const F=new CustomEvent(`update-data-${l.widgetName}`);F.filterUrl=T,window.dispatchEvent(F),a("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(w,()=>{C()},{deep:!0}),e.watch(()=>[l.widgetName,l.dashboardId,c.value],()=>{d.value=[],m()},{immediate:!0}),t({requestUpdateWidget:x}),(T,F)=>(e.openBlock(),e.createElementBlock("div",$n,[(e.openBlock(),e.createBlock(e.unref(n),{key:b.value,schema:$.value,values:w.value,"onUpdate:values":F[0]||(F[0]=se=>w.value=se)},null,8,["schema","values"]))]))}},Bn={class:"space-y-4"},Dn={__name:"vs-editor-form-yaml",props:{yamlValue:{type:null,default:()=>""},widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object}},emits:["update-dashboard"],setup(r,{expose:t,emit:s}){const n=typeof window<"u"?window.echarts:null,o=e.defineAsyncComponent(()=>import("@opengis/form").then(u=>u.VsInputMonaco)),a=e.ref(null),l=e.computed(()=>d.dashboardId||a.value),{$notify:i}=e.getCurrentInstance().proxy,c=s,d=r,p=(u,{dimensions:y,source:b})=>{const $=u.getOption(),{data:w,...x}=($==null?void 0:$.series)[0],[,...C]=y||[],L=C.map((E,V)=>({...($==null?void 0:$.series[V])||{},data:b.map(B=>B[V+1]),name:E}));u==null||u.setOption({...$||{},dataset:{dimensions:y,source:b},series:L,xAxis:{type:"category"},yAxis:{}},!0)},h=u=>{const y=document.getElementById(u);if(!y)return null;const b=n==null?void 0:n.getInstanceByDom(y);return b||null},m=e.ref(d.yamlValue),f=async()=>{try{await H.put(`/bi-dashboard/${l.value}/${d.widgetName}`,{yml:m.value});const u=h(d.widgetName);if(u){const y=await H.get(`/bi-data?dashboard=${a.value}&widget=${d.widgetName}`);p(u,y)}c("update-dashboard"),i({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{i({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const u=new URLSearchParams(window.top.location.search);a.value=u.get("dashboard")}),t({requestUpdateWidget:f}),(u,y)=>(e.openBlock(),e.createElementBlock("div",Bn,[e.createVNode(e.unref(o),{modelValue:m.value,"onUpdate:modelValue":y[0]||(y[0]=b=>m.value=b),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},Vn={class:"pt-[10px]"},St={"vs-editor-form-style":Os,"vs-editor-form-data":En,"vs-editor-form-yaml":Dn,"vs-editor-form-controls":{__name:"vs-editor-form-controls",props:{widgetName:{type:String},controls:{type:Object,default:()=>{}},columns:{type:Array,default:()=>[]}},emits:["update-dashboard"],setup(r,{emit:t}){var p;const s=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:n}=e.getCurrentInstance().proxy,o=t,a=r,l=e.ref(null),i={granularity:{ua:"Granularity",type:"checkbox",options:["week","month","quarter","year"]},export:{ua:"Export",type:"Switcher"},groupby:{ua:"Groupby",type:"checkbox",options:(p=a.columns)==null?void 0:p.map(({name:h})=>h)}},c=e.ref(a.controls||{}),d=async()=>{try{await H.put(`/bi-dashboard/${l.value}/${a.widgetName}`,{controls:c.value}),await n({type:"success",title:"Успішно!",message:"Дані успішно оновлено"}),staticTypes!=null&&staticTypes.includes(c.value.type)&&o("update-dashboard")}catch{await n({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const h=new URLSearchParams(window.top.location.search);l.value=h.get("dashboard")}),(h,m)=>{const f=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",Vn,[e.createVNode(f,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:d},{default:e.withCtx(()=>m[1]||(m[1]=[e.createTextVNode(" Зберегти ")])),_:1}),e.createVNode(e.unref(s),{schema:i,values:c.value,"onUpdate:values":m[0]||(m[0]=u=>c.value=u)},null,8,["values"])])}}}},Cn={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},zt={__name:"editor-tab-error-boundary",props:{tabComponent:{type:Object,default:null},tabKey:{type:[String,Number],default:""}},emits:["update-dashboard"],setup(r,{expose:t}){const s=r,n=e.ref(null);function o(){var l,i;(i=(l=n.value)==null?void 0:l.requestUpdateWidget)==null||i.call(l)}t({save:o});const a=e.ref(!1);return e.onErrorCaptured((l,i,c)=>(console.error("Editor tab error:",l,c),a.value=!0,!1)),e.watch(()=>s.tabComponent,()=>{a.value=!1},{immediate:!0}),(l,i)=>a.value?(e.openBlock(),e.createElementBlock("div",Cn," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.tabComponent),e.mergeProps({ref_key:"tabRef",ref:n,key:r.tabKey||"tab"},l.$attrs,{onUpdateDashboard:i[0]||(i[0]=c=>l.$emit("update-dashboard"))}),null,16))}},Nn={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},Sn={key:0,class:"flex flex-col min-h-0 flex-1"},zn={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},Ln={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},In=["onClick"],Tn={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},Mn={class:"flex items-center gap-1 ml-auto shrink-0"},Pn={key:1,class:"flex-1 min-h-0 overflow-auto px-4 py-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},Fn={key:0},jn={key:1},Rn={class:"p-4"},Wn={class:"flex justify-end mt-4 gap-x-3"},vn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},An={__name:"vs-editor-forms",props:e.mergeModels({selectedWidgetData:{type:Object,required:!1,default:null},selectedDashboard:{type:String,default:()=>""},currentWidgetData:{type:Object,default:()=>""}},{selectedWidget:{},selectedWidgetModifiers:{}}),emits:e.mergeModels(["update-data"],["update:selectedWidget"]),setup(r,{emit:t}){var C,L;const s=e.defineAsyncComponent(()=>import("@opengis/form")),n=(L=(C=e.getCurrentInstance())==null?void 0:C.proxy)==null?void 0:L.$notify,o=K.useRouter(),a=t,l=e.ref(null),i=r,c=e.ref(!1),d=e.ref(!0),p=e.ref(!1),h=e.ref({}),m=e.useModel(r,"selectedWidget"),f=["table","text","number","stat","progress","listbar","map","pivot"],u=e.ref("data"),y=async()=>{try{await H.delete(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`),c.value=!1,a("update-data"),o.hasRoute(J.EditorDashboard)?await o.push({name:J.EditorDashboard,params:{dashboardId:i.selectedDashboard}}):m.value="",n({type:"success",title:"Успішно!",message:"Віджет успішно видалено"})}catch(E){console.error(E),n({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},b=e.computed(()=>{const E=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return E==null?void 0:E.filter(V=>{var B,I,M;return V.id==="style"?!(f!=null&&f.includes(((B=i.selectedWidgetData)==null?void 0:B.type)||((M=(I=i.selectedWidgetData)==null?void 0:I.data)==null?void 0:M.type))):!0})}),$=()=>{var E,V,B,I,M,U,Z,Q,N;h.value={title:(E=i.selectedWidgetData)==null?void 0:E.title,type:(V=i.selectedWidgetData)==null?void 0:V.type,table:(B=i.selectedWidgetData)==null?void 0:B.table_name,query:(M=(I=i.selectedWidgetData)==null?void 0:I.data)==null?void 0:M.query,x:(Z=(U=i.selectedWidgetData)==null?void 0:U.data)==null?void 0:Z.x,cls:(N=(Q=i.selectedWidgetData)==null?void 0:Q.data)==null?void 0:N.cls},p.value=!0},w=async()=>{try{await H.put(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`,h.value),n({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await a("update-data"),p.value=!1}catch{n({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(m,()=>{d.value=!1,setTimeout(()=>d.value=!0)});const x={title:{type:"text",ua:"Заголовок",placeholder:"Заголовок",validators:["required"]},type:{type:"select",view:"buttons",label:"Тип віджета",validators:["required"],options:[{label:"Bar",id:"bar"},{label:"Funnel",id:"funnel"},{label:"Line",id:"line"},{label:"List bar",id:"listbar"},{label:"Number",id:"number"},{label:"Pie",id:"pie"},{label:"Donut",id:"donut"},{label:"Pivot",id:"pivot"},{label:"Table",id:"table"},{label:"Progress",id:"progress"},{label:"Stat",id:"stat"},{label:"Text",id:"text"},{label:"Map",id:"map"}]},table:{type:"text",ua:"Таблиця",placeholder:"Таблиця"},query:{type:"Text",ua:"Запит (query)",placeholder:"Query"},x:{type:"Text",ua:"Вісь X",placeholder:"X Axis"},cls:{type:"Text",ua:"Клас (cls)",placeholder:"Cls"}};return(E,V)=>{var I,M,U,Z,Q,N,D,P,A,g,_;const B=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",Nn,[r.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",Sn,[e.createElementVNode("div",zn,[e.createElementVNode("nav",Ln,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,k=>(e.openBlock(),e.createElementBlock("button",{key:k.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",u.value===k.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:z=>u.value=k.id},[e.createTextVNode(e.toDisplayString(k.label)+" ",1),u.value===k.id?(e.openBlock(),e.createElementBlock("span",Tn)):e.createCommentVNode("",!0)],10,In))),128))]),e.createElementVNode("div",Mn,[e.createVNode(B,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",title:"Зберегти",onClick:V[0]||(V[0]=k=>{var z,q;return(q=(z=l.value)==null?void 0:z.save)==null?void 0:q.call(z)})},[e.createVNode(e.unref(zr),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[V[9]||(V[9]=e.createTextVNode(" Зберегти "))]),_:1}),e.createVNode(B,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",onClick:$},[e.createVNode(mt,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[V[10]||(V[10]=e.createTextVNode(" Редагувати віджет "))]),_:1}),e.createVNode(B,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",onClick:V[1]||(V[1]=k=>c.value=!0)},[e.createVNode(e.unref(ut),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[V[11]||(V[11]=e.createTextVNode(" Видалити віджет "))]),_:1})])]),(I=r.currentWidgetData)!=null&&I.status?(e.openBlock(),e.createBlock(Be,{key:0,title:(M=r.currentWidgetData)==null?void 0:M.title,text:(U=r.currentWidgetData)==null?void 0:U.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",Pn,[d.value&&r.currentWidgetData?(e.openBlock(),e.createElementBlock("div",Fn,[e.createVNode(zt,{ref_key:"tabPanelRef",ref:l,"tab-key":u.value,"tab-component":e.unref(St)["vs-editor-form-"+u.value],widgetName:(Z=r.selectedWidgetData)==null?void 0:Z.name,dashboardId:r.selectedDashboard,yamlValue:((Q=r.selectedWidgetData)==null?void 0:Q.yml)||"",data:r.selectedWidgetData,controls:(N=r.selectedWidgetData)==null?void 0:N.controls,columns:(D=r.currentWidgetData)==null?void 0:D.columns,onUpdateDashboard:V[2]||(V[2]=k=>E.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",jn,[e.createVNode(zt,{ref_key:"tabPanelRef",ref:l,"tab-key":u.value,"tab-component":e.unref(St)["vs-editor-form-"+u.value],widgetName:(P=r.selectedWidgetData)==null?void 0:P.name,dashboardId:r.selectedDashboard,yamlValue:((A=r.selectedWidgetData)==null?void 0:A.yml)||"",data:r.selectedWidgetData,controls:(g=r.selectedWidgetData)==null?void 0:g.controls,columns:(_=r.currentWidgetData)==null?void 0:_.columns,onUpdateDashboard:V[3]||(V[3]=k=>E.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(ge,{teleport:"#modal",visible:c.value,title:"Ви впевнені?",onClose:V[5]||(V[5]=k=>c.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",Rn,[V[12]||(V[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",Wn,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-medium text-gray-800 bg-white border border-gray-200 rounded-lg shadow-sm gap-x-2 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:V[4]||(V[4]=k=>c.value=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-semibold text-white bg-red-500 border border-transparent rounded-lg gap-x-2 hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:y}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(Be,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(ge,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:V[8]||(V[8]=k=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",vn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:V[7]||(V[7]=k=>p.value=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:w,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[x?(e.openBlock(),e.createBlock(e.unref(s),{key:0,schema:x,values:h.value,"onUpdate:values":V[6]||(V[6]=k=>h.value=k)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},On={class:"overflow-hidden flex flex-col min-h-[480px]"},qn={class:"flex-1 flex min-h-0 gap-4"},Un={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},Hn={key:1,class:"flex items-center justify-center h-full"},Gn={class:"w-[400px] shrink-0 flex flex-col"},Zn={__name:"vs-widget-editor-panel",props:{selectedWidget:{type:String,default:""},selectedWidgetData:{type:Object,default:null},currentWidgetData:{type:Object,default:null},selectedDashboard:{type:String,default:""},dashboardWidgets:{type:Array,default:()=>[]}},emits:["update:selectedWidget","update-data"],setup(r,{emit:t}){const s=r,n=t,o=e.ref(null);async function a(){if(!(!s.selectedDashboard||!s.selectedWidget))try{o.value=await H.get(`/bi-data?dashboard=${s.selectedDashboard}&widget=${s.selectedWidget}`)}catch(c){console.error(c)}}function l(){n("update-data")}e.watch(()=>[s.selectedDashboard,s.selectedWidget],()=>{a()},{immediate:!0});const i=e.computed({get:()=>s.selectedWidget,set:c=>n("update:selectedWidget",c)});return(c,d)=>(e.openBlock(),e.createElementBlock("div",On,[e.createElementVNode("div",qn,[e.createElementVNode("div",Un,[o.value?(e.openBlock(),e.createBlock(fe,{key:0,dashboard:r.selectedDashboard,widget:r.selectedWidget,"selected-widget":r.selectedWidget,"dashboard-widgets":r.dashboardWidgets,"prefetched-data":o.value,"filter-u-rl":void 0,class:"max-h-full"},null,8,["dashboard","widget","selected-widget","dashboard-widgets","prefetched-data"])):(e.openBlock(),e.createElementBlock("div",Hn,d[1]||(d[1]=[e.createElementVNode("span",{class:"text-sm text-gray-400"},"Завантаження...",-1)])))]),e.createElementVNode("div",Gn,[e.createVNode(An,{selectedWidget:i.value,"onUpdate:selectedWidget":d[0]||(d[0]=p=>i.value=p),selectedWidgetData:r.selectedWidgetData,currentWidgetData:o.value||r.currentWidgetData||{columns:[]},selectedDashboard:r.selectedDashboard,onUpdateData:l},null,8,["selectedWidget","selectedWidgetData","currentWidgetData","selectedDashboard"])])])]))}},Lt={__name:"icon-grid",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Vr),e.mergeProps(t.$attrs,{size:24}),null,16))}},It={__name:"icon-table",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Lr),e.mergeProps(t.$attrs,{size:24}),null,16))}},Qn={__name:"icon-more",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(et),e.mergeProps(t.$attrs,{size:24}),null,16))}},Jn=e.defineAsyncComponent(()=>import("@opengis/form")),Xn={components:{VsModal:ge,VForm:Jn,deleteIcon:ut,editIcon:mt,IconGrid:Lt,IconMore:Qn,IconTable:It},watch:{dashboardData:{handler(r){var s,n;if(this.formEditValue={title:r==null?void 0:r.title,description:r==null?void 0:r.description,table_name:r==null?void 0:r.table_name,db:r==null?void 0:r.db,public:r==null?void 0:r.public,words:r==null?void 0:r.words},!((s=r==null?void 0:r.panels)!=null&&s.length)){this.formGridValue={panels:[]};return}const t=(n=r==null?void 0:r.panels)==null?void 0:n.map(o=>{var i,c;const{title:a="",type:l=""}=((c=(i=r==null?void 0:r.widgets)==null?void 0:i.find(d=>(d==null?void 0:d.name)===(o==null?void 0:o.widget)))==null?void 0:c.data)||{};return{title:a,type:l,...o}});this.formGridValue={panels:t}},immediate:!0}},data(){return{isDeleteConfirm:!1,isFormEdit:!1,isFormGrid:!1,isVisibleTableColumns:!1,formEditValue:{},formGridValue:{},editDashboardScheme:[{type:"Text",key:"title",label:"Заголовок",validators:["required"]},{type:"Text",key:"description",label:"Опис"},{type:"Select",key:"table_name",validators:["required"],data:"pg.table_name",label:"Назва таблиці"},{type:"Text",key:"words",label:"Ключові слова"},{type:"Text",key:"db",label:"База даних",original:{type:"Text",ua:"Назва",col:8}},{type:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}],editGridScheme:[{type:"DataTable",ua:"Панелі",key:"panels",actions:["search"],editable:!1,addition:!1,colModel:[{name:"title",ua:"Назва",type:"Text",key:"title"},{name:"type",ua:"Тип",type:"Text",key:"type",disabled:!0},{name:"widget",type:"Text",ua:"Віджет",key:"widget",hiddenCol:!0,disabled:!0},{name:"col",ua:"Кількість стовпчиків",type:"Text",key:"col"},{name:"height",ua:"Висота",type:"Text",key:"height"},{name:"category",ua:"Категорія",type:"Text",key:"category"}]}]}},props:{selected:{type:String,default:()=>""},dashboardData:{type:Object,default:()=>{}},selectedWidgetData:{type:Object,default:()=>{}},columns:{type:Array}},methods:{async editDashboard(){var r,t;try{const s=(t=(r=this.$refs)==null?void 0:r.formEdit)==null?void 0:t.validate();typeof s=="function"&&await s(),await H.put(`/bi-dashboard/${this.selected}`,this.formEditValue),await this.$notify({title:"Успішно!",type:"success",message:"Дані успішно оновлено"}),this.isFormEdit=!1,await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"при спробі оновити дані виникла помилка"})}},async editDashboardGrid(){var r,t;try{(t=(r=this.$refs)==null?void 0:r.formGrid)==null||t.doValidation(),await H.put(`/bi-dashboard/${this.selected}`,{...this.formEditValue,...this.formGridValue}),await this.$notify({title:"Успішно!",type:"success",message:"Дані успішно оновлено"}),this.isFormGrid=!1,await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі оновити дані виникла помилка"})}},async deleteDashboard(){try{await H.delete(`/bi-dashboard/${this.selected}`),this.isDeleteConfirm=!1,this.$emit("update:selected",""),this.$emit("update-editor"),this.$notify({title:"Успішно!",type:"success",message:"Дашборд видалено успішно"})}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі видалити дашборд виникла помилка"})}},closePopover(){document.body.click()}}},Kn={key:0,class:"flex items-center gap-4"},Yn={class:"h-[30px] w-[30px] flex items-center justify-center"},eo={class:"flex flex-col items-start -ml-2 -mr-2"},to={class:"p-4"},ro={class:"flex justify-end mt-4 gap-x-3"},so={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},no={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function oo(r,t,s,n,o,a){const l=e.resolveComponent("IconGrid"),i=e.resolveComponent("VsPopover"),c=e.resolveComponent("IconMore"),d=e.resolveComponent("VsModal"),p=e.resolveComponent("VForm");return e.openBlock(),e.createElementBlock("div",null,[s.selected?(e.openBlock(),e.createElementBlock("div",Kn,[e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{class:"h-[30px] w-[30px] flex items-center justify-center",onClick:t[0]||(t[0]=h=>o.isFormGrid=!0)},[e.createVNode(l,{class:"h-[20px] text-gray-500"})])]),default:e.withCtx(()=>[t[14]||(t[14]=e.createTextVNode(" Редагувати структуру дашборду "))]),_:1}),e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createVNode(i,{placement:"bottom-left"},{reference:e.withCtx(()=>[e.createElementVNode("button",Yn,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",eo,[e.createElementVNode("button",{onClick:t[1]||(t[1]=h=>{a.closePopover(),o.isFormEdit=!0}),class:"px-[8px] py-[4px] hover:bg-gray-100 w-full text-start rounded-lg"}," Редагувати дашборд "),e.createElementVNode("button",{onClick:t[2]||(t[2]=h=>{a.closePopover(),o.isDeleteConfirm=!0}),class:"px-[8px] py-[4px] hover:bg-gray-100 w-full text-start rounded-lg"}," Видалити дашборд ")])]),_:1})]),default:e.withCtx(()=>[t[15]||(t[15]=e.createTextVNode(" Керування дашбордом "))]),_:1})])):e.createCommentVNode("",!0),e.createVNode(d,{teleport:"#modal",visible:o.isDeleteConfirm,size:"small",title:"Ви впевнені?",onClose:t[5]||(t[5]=h=>o.isDeleteConfirm=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",to,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",ro,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-medium text-gray-800 bg-white border border-gray-200 rounded-lg shadow-sm gap-x-2 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:t[3]||(t[3]=h=>o.isDeleteConfirm=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-semibold text-white bg-red-500 border border-transparent rounded-lg gap-x-2 hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:t[4]||(t[4]=(...h)=>a.deleteDashboard&&a.deleteDashboard(...h))}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormEdit,title:"Редагувати дашборд",onClose:t[9]||(t[9]=h=>o.isFormEdit=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",so,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[7]||(t[7]=h=>o.isFormEdit=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:t[8]||(t[8]=(...h)=>a.editDashboard&&a.editDashboard(...h)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(p,{ref:"formEdit",schema:o.editDashboardScheme,values:o.formEditValue,"onUpdate:values":t[6]||(t[6]=h=>o.formEditValue=h)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormGrid,title:"Редагувати структуру дашборду",onClose:t[13]||(t[13]=h=>o.isFormGrid=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",no,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[11]||(t[11]=h=>o.isFormGrid=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:t[12]||(t[12]=(...h)=>a.editDashboardGrid&&a.editDashboardGrid(...h)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(p,{ref:"formgrid",schema:o.editGridScheme,values:o.formGridValue,"onUpdate:values":t[10]||(t[10]=h=>o.formGridValue=h)},null,8,["schema","values"])]),_:1},8,["visible"])])}const ao=W(Xn,[["render",oo]]),lo={class:"flex-1 min-w-0 flex flex-col overflow-auto"},io={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},co={class:"relative z-10 shrink-0 mt-4 mb-6"},po={class:"flex items-center text-sm text-gray-600"},ho={key:0,class:"flex items-center justify-between gap-4 mt-3"},uo={class:"min-w-0"},mo={class:"text-2xl font-bold text-gray-900"},fo={key:0,class:"mt-1.5 text-sm text-gray-600"},go={class:"flex items-center shrink-0"},bo={key:1,class:"grid flex-grow w-full grid-cols-12 gap-4 py-4 pr-[15px] min-h-0 overflow-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},yo=W({__name:"vs-editor",props:{prefix:String,customClass:{type:String,default:()=>"w-screen h-screen"},initialDashboardId:{type:String,default:""},initialWidgetId:{type:String,default:""}},emits:["back"],setup(r,{emit:t}){const s=r;$e(s.prefix||"/api");const n=t,o=K.useRouter(),a=e.computed(()=>o.hasRoute(J.EditorWidget)),l=e.inject("biClearDashboard",null),i=e.ref(s.initialDashboardId||""),c=e.ref(s.initialWidgetId||""),d=e.ref(null),p=e.ref(null),h=e.ref(null);e.watch(()=>s.initialWidgetId,w=>{c.value=w||""});const m=async()=>{if(!i.value){d.value=null;return}try{const w=await H.get(`/bi-dashboard/${i.value}`);d.value=w}catch(w){console.error(w)}},f=e.computed(()=>{var w,x,C;return(C=Array.isArray((w=d.value)==null?void 0:w.widgets)?(x=d.value)==null?void 0:x.widgets:[])==null?void 0:C.find(L=>(L==null?void 0:L.name)===c.value)});function u(w){a.value?o.push({name:J.EditorWidget,params:{dashboardId:i.value,widgetId:w}}):c.value=w}function y(){a.value?o.push({name:J.EditorDashboard,params:{dashboardId:i.value}}):c.value=""}function b(){a.value?o.push({name:J.Editor}):(typeof l=="function"&&l(),n("back"))}const $=e.computed(()=>{var C,L,E,V,B;const x=[a.value?{label:"Дашборди",to:{name:J.Editor}}:{label:"Дашборди",onClick:b}];if((C=d.value)!=null&&C.title||i.value){const I=((L=d.value)==null?void 0:L.title)||i.value||"Редактор";!!c.value?x.push(a.value?{label:I,to:{name:J.EditorDashboard,params:{dashboardId:i.value}}}:{label:I,onClick:()=>{c.value=""}}):x.push({label:I})}else x.push({label:"Редактор"});if(c.value&&f.value){const I=((V=(E=f.value)==null?void 0:E.data)==null?void 0:V.title)||((B=f.value)==null?void 0:B.title)||c.value;x.push({label:I})}return x});return e.watch(i,(w,x)=>{x&&(c.value=""),w?m():(d.value=null,b())}),e.onMounted(()=>{m()}),(w,x)=>{var C,L;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[r.customClass]])},[e.createElementVNode("div",lo,[e.createElementVNode("div",io,[e.createElementVNode("div",co,[e.createElementVNode("div",po,[e.createVNode(dt,{items:$.value,compact:""},null,8,["items"])]),i.value&&d.value?(e.openBlock(),e.createElementBlock("div",ho,[e.createElementVNode("div",uo,[e.createElementVNode("h1",mo,e.toDisplayString(d.value.title||i.value),1),d.value.description?(e.openBlock(),e.createElementBlock("p",fo,e.toDisplayString(d.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",go,[c.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors",onClick:y},[e.createVNode(e.unref(st),{class:"w-4 h-4"}),x[5]||(x[5]=e.createTextVNode(" Закрити "))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(ao,{selected:i.value,"onUpdate:selected":x[0]||(x[0]=E=>i.value=E),dashboardData:d.value,columns:(C=d.value)==null?void 0:C.columns,selectedWidgetData:f.value,prefix:r.prefix,onUpdateEditor:m},null,8,["selected","dashboardData","columns","selectedWidgetData","prefix"]),e.createElementVNode("button",{type:"button",class:"ml-4 flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors shadow-sm font-medium",onClick:x[1]||(x[1]=E=>{var V,B;return(B=(V=h.value)==null?void 0:V.open)==null?void 0:B.call(V)})},x[6]||(x[6]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ")])),i.value?(e.openBlock(),e.createBlock(vs,{key:0,ref_key:"createWidgetRef",ref:h,inline:"",columns:(L=d.value)==null?void 0:L.columns,selectedDashboard:i.value,onUpdateData:m},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),c.value&&d.value?(e.openBlock(),e.createBlock(Zn,{key:0,"selected-widget":c.value,"onUpdate:selectedWidget":x[2]||(x[2]=E=>c.value=E),"selected-widget-data":f.value,"current-widget-data":p.value,"selected-dashboard":i.value,"dashboard-widgets":d.value.widgets||[],onUpdateData:m},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",bo,[d.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(d.value.panels,(E,V)=>{var B,I;return e.openBlock(),e.createElementBlock("div",{key:E.widget||((B=E.widgets)==null?void 0:B.join("-"))||V,class:e.normalizeClass([`md:col-span-${E.col||12} col-span-12`,"flex flex-col gap-[10px]"])},[(I=E.widgets)!=null&&I.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(E.widgets,M=>(e.openBlock(),e.createBlock(fe,{onClick:U=>u(M),"onUpdate:currentWidgetData":x[3]||(x[3]=U=>p.value=U),key:M,dashboard:i.value,widget:M,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(E.height??480),class:e.normalizeClass({"border border-blue-500":c.value===M})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","height","class"]))),128)):(e.openBlock(),e.createBlock(fe,{key:1,onClick:M=>u(E.widget),"onUpdate:currentWidgetData":x[4]||(x[4]=M=>p.value=M),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":c.value===E.widget}]),dashboard:i.value,widget:E.widget,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(E.height??480)},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets","height"]))],2)}),128)):(e.openBlock(),e.createBlock(Be,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-330ef797"]]),xo={class:"w-full h-screen"},Tt=e.defineComponent({__name:"vs-editor-page",props:{prefix:{default:"/api"},dashboardId:{default:""},widgetId:{default:""}},emits:["back"],setup(r){return(t,s)=>(e.openBlock(),e.createElementBlock("div",xo,[e.createVNode(yo,{customClass:"h-full w-full",prefix:t.prefix,"initial-dashboard-id":t.dashboardId,"initial-widget-id":t.widgetId,onBack:s[0]||(s[0]=n=>t.$emit("back"))},null,8,["prefix","initial-dashboard-id","initial-widget-id"])]))}}),ne=(r,t)=>{const s=r.__vccOpts||r;for(const[n,o]of t)s[n]=o;return s},ko={},wo={xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-6 text-green-600"};function _o(r,t){return e.openBlock(),e.createElementBlock("svg",wo,[...t[0]||(t[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)])])}const $o=ne(ko,[["render",_o]]),Eo={},Bo={xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"orange",class:"size-6 text-orange-600"};function Do(r,t){return e.openBlock(),e.createElementBlock("svg",Bo,[...t[0]||(t[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)])])}const Vo=ne(Eo,[["render",Do]]),Co={},No={xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-6 text-blue-600"};function So(r,t){return e.openBlock(),e.createElementBlock("svg",No,[...t[0]||(t[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"},null,-1)])])}const zo=ne(Co,[["render",So]]),Lo={},Io={xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"red",class:"size-6 text-red-600"};function To(r,t){return e.openBlock(),e.createElementBlock("svg",Io,[...t[0]||(t[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"},null,-1)])])}const Mo=ne(Lo,[["render",To]]),Po={class:"rounded-md border border-gray-300 bg-white p-4 shadow-sm"},Fo={class:"flex items-start gap-4 opacity-100 scale-5 transition-all duration-300"},jo={class:"flex-1"},Ro={class:"font-medium text-gray-900"},Wo={class:"mt-0.5 text-sm text-gray-700"},vo=e.defineComponent({__name:"vs-notify",props:{type:{},title:{},message:{}},setup(r){const t={success:$o,warning:Vo,error:Mo,info:zo};return(s,n)=>(e.openBlock(),e.createElementBlock("div",Po,[e.createElementVNode("div",Fo,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t[s.type]))),e.createElementVNode("div",jo,[e.createElementVNode("strong",Ro,e.toDisplayString(s.title),1),e.createElementVNode("p",Wo,e.toDisplayString(s.message),1)]),n[0]||(n[0]=e.createElementVNode("button",{class:"m-3 rounded-full p-1.5 text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-700",type:"button","aria-label":"Dismiss notify"},[e.createElementVNode("span",{class:"sr-only"},"Dismiss popup"),e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"size-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})])],-1))])]))}}),ze={top:"top-4 left-1/2 transform -translate-x-1/2","left-bottom":"bottom-4 left-4 transform","right-bottom":"bottom-4 right-4 transform",bottom:"bottom-4 left-1/2 transform -translate-x-1/2"},Ao=r=>{var c;const{type:t="info",title:s,message:n,position:o="right-bottom"}=r||{};let a=document.querySelector("#notify-root");a||(a=document.createElement("div"),a.id="notify-root",a.className=`fixed z-[2000] flex flex-col gap-3 ${ze[o]} p-6 max-w-md mx-auto font-sans antialiased`,document.body.appendChild(a)),a.className.includes(ze[o])||(Object.values(ze).forEach(d=>{a.classList.remove(...d.split(" "))}),a.classList.add(...ze[o].split(" ")));const l=document.createElement("div");a.appendChild(l);const i=e.createApp({render(){return e.h(vo,{type:t,title:s,message:n,onClose:()=>{i.unmount(),l.remove()}})}});i.mount(l),(c=l.querySelector("button"))==null||c.addEventListener("click",()=>{l.classList.add("opacity-0","scale-95","transition-all","duration-300"),setTimeout(()=>{i.unmount(),l.remove()},350)}),setTimeout(()=>{l.classList.add("opacity-0","scale-95","transition-all","duration-300"),setTimeout(()=>{i.unmount(),l.remove()},350)},3500)};e.defineComponent({name:"Copy",props:{text:{type:String,default:""},width:{type:[String,Number],default:null},notify:{type:Boolean,default:!0},notifyOptions:{type:Object,default:()=>({})}},emits:["copied","copy-error"],data(){return{slotText:""}},computed:{rootClasses(){return["vs-copy inline-flex items-center gap-2 cursor-pointer select-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500"]},containerStyle(){return!this.width&&this.width!==0?{}:{width:typeof this.width=="number"?`${this.width}px`:this.width.trim()}},displayText(){return this.text||this.slotText}},mounted(){this.updateSlotText()},updated(){this.updateSlotText()},methods:{updateSlotText(){var t,s;const r=((s=(t=this.$refs.text)==null?void 0:t.textContent)==null?void 0:s.trim())||"";r!==this.slotText&&(this.slotText=r)},async handleCopy(){const r=this.displayText;if(r)try{await this.copyToClipboard(r),this.$emit("copied",r),this.showNotify(r)}catch(t){this.$emit("copy-error",t)}},async copyToClipboard(r){var s;if((s=navigator.clipboard)!=null&&s.writeText){await navigator.clipboard.writeText(r);return}const t=document.createElement("textarea");t.value=r,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("Copy command was unsuccessful")}finally{document.body.removeChild(t)}},showNotify(r){var s,n,o,a;if(!this.notify)return;const t={type:((s=this.notifyOptions)==null?void 0:s.type)??"success",title:((n=this.notifyOptions)==null?void 0:n.title)??"Copied",message:((o=this.notifyOptions)==null?void 0:o.message)??r,position:(a=this.notifyOptions)==null?void 0:a.position};Ao(t)}}}),e.defineComponent({props:{modelValue:{type:Boolean,default:()=>!1},title:{type:String,default:()=>""},disabled:{type:Boolean,default:()=>!1}},data(){return{}},mounted(){this.modelValue||this.$emit("update:modelValue",!1)},computed:{modelState:{get(){return this.modelValue},set(r){this.$emit("update:modelValue",r)}},labelCursorClasses(){return[{"cursor-not-allowed":this.disabled},{"cursor-pointer":!this.disabled}]}},methods:{handleEnterDown(r){const{keyCode:t}=r;t===13&&(this.modelState=!this.modelState)},addKeyHandler(){window.addEventListener("keydown",this.handleEnterDown)},removeKeyHandler(){window.removeEventListener("keydown",this.handleEnterDown)}}});const Oo={},qo={xmlns:"http://www.w3.org/2000/svg",class:"w-6 h-6",viewBox:"0 0 20 20",fill:"currentColor"};function Uo(r,t){return e.openBlock(),e.createElementBlock("svg",qo,[...t[0]||(t[0]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1)])])}const Ho=ne(Oo,[["render",Uo]]),Go={},Zo={xmlns:"http://www.w3.org/2000/svg",class:"w-6 h-6",viewBox:"0 0 20 20",fill:"currentColor"};function Qo(r,t){return e.openBlock(),e.createElementBlock("svg",Zo,[...t[0]||(t[0]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z","clip-rule":"evenodd"},null,-1)])])}const Jo=ne(Go,[["render",Qo]]),Xo={},Ko={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-chevron-down",height:"16",width:"16"};function Yo(r,t){return e.openBlock(),e.createElementBlock("svg",Ko,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M6 9l6 6l6 -6"},null,-1)])])}const ea=ne(Xo,[["render",Yo]]),ta={},ra={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-check text-blue-600",width:"14",height:"14"};function sa(r,t){return e.openBlock(),e.createElementBlock("svg",ra,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M5 12l5 5l10 -10"},null,-1)])])}const na=ne(ta,[["render",sa]]),oa={class:"flex items-center justify-between w-full"},aa={class:"m-0 flex list-none justify-center gap-1 p-0 text-gray-900"},la=["onClick"],ia={key:1,class:"flex size-7 items-center justify-center px-1 text-gray-500 select-none","aria-hidden":"true"},ca={key:1},da={for:"Page"},pa=["value","max"],ha={key:2,class:"text-sm/8 font-medium tracking-widest"},ua={key:0,class:"flex justify-center items-center gap-x-5 ml-3"},ma={class:"hs-dropdown-menu z-50 bg-white shadow-md rounded-lg p-1 space-y-0.5 dark:bg-neutral-800 dark:border dark:border-neutral-700 right-0 dark:divide-neutral-700 absolute bottom-[100%]",role:"menu","aria-orientation":"vertical","aria-labelledby":"dropdown-button"},fa=["onClick"],ga=e.defineComponent({__name:"vs-pagination",props:{pageSize:{},page:{},total:{},view:{default:"button"},pageSizes:{default:()=>[10,20,30]},showPageSizes:{type:Boolean,default:!0},pageRange:{default:7},size:{default:7},color:{default:"teal"}},emits:["update:page","pageChange","pageSizeChange"],setup(r,{emit:t}){const s=r,n=t,o=e.ref(s.page),a=e.computed(()=>Math.ceil(s.total/s.pageSize)),l=e.computed(()=>{const b=Math.floor(s.pageRange/2);let $=o.value-b,w=o.value+b;$<1&&(w+=1-$,$=1),w>a.value&&($-=w-a.value,w=a.value),$=Math.max(1,$);const x=[];for(let C=$;C<=w;C+=1)x.push(C);return x}),i=e.computed(()=>{const b=l.value,$=a.value;if($<=1)return b.map(L=>({type:"page",value:L}));const w=b.length>0&&b[0]>1,x=b.length>0&&b[b.length-1]<$,C=[];return w&&(C.push({type:"page",value:1}),C.push({type:"ellipsis"})),b.forEach(L=>C.push({type:"page",value:L})),x&&(C.push({type:"ellipsis"}),C.push({type:"page",value:$})),C}),c=b=>{o.value=b,n("update:page",b),n("pageChange",b)},d=()=>{o.value>1&&c(o.value-1)},p=()=>{o.value<a.value&&c(o.value+1)};e.watch(()=>s.page,b=>{o.value=b});const h=e.ref(s.pageSize),m=e.ref(!1),f=e.ref(null);e.watch(()=>s.pageSize,b=>{h.value=b});const u=(b=h.value)=>{h.value=b,m.value=!1,o.value=1,n("update:page",o.value),n("pageSizeChange",h.value)},y=b=>{if(!m.value)return;const $=b.target;f.value&&$&&!f.value.contains($)&&(m.value=!1)};return e.onMounted(()=>{document.addEventListener("click",y)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",y)}),(b,$)=>(e.openBlock(),e.createElementBlock("div",oa,[e.createElementVNode("ul",aa,[e.createElementVNode("li",null,[e.createElementVNode("button",{class:e.normalizeClass(["grid size-7 cursor-pointer place-content-center rounded border border-gray-200 transition-colors hover:bg-gray-50 rtl:rotate-180",{"opacity-50 pointer-events-none":o.value===1}]),"aria-label":"Previous page",onClick:d},[e.createVNode(Ho)],2)]),b.view==="button"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(i.value,(w,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:w.type==="page"?w.value:`ellipsis-${x}`},[w.type==="page"?(e.openBlock(),e.createElementBlock("li",{key:0,class:e.normalizeClass([[`size-${s.size} text-sm/${s.size} px-1.5`,w.value===o.value&&b.color?`bg-[${b.color}]`:"",w.value===o.value?`block rounded border border-${b.color}-600 text-center font-medium text-white`:"block rounded border border-gray-200 text-center font-medium transition-colors hover:bg-gray-50"],"cursor-pointer"]),onClick:C=>c(w.value)},e.toDisplayString(w.value),11,la)):(e.openBlock(),e.createElementBlock("li",ia," … "))],64))),128)):b.view==="input"?(e.openBlock(),e.createElementBlock("li",ca,[e.createElementVNode("label",da,[$[2]||($[2]=e.createElementVNode("span",{class:"sr-only"}," Page ",-1)),e.createElementVNode("input",{type:"number",id:"Page",value:o.value,min:"1",max:a.value,onInput:$[0]||($[0]=w=>c(Number(w))),class:"pagination-input block h-8 w-16 rounded border border-gray-300 px-3 py-2 text-base leading-6 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"},null,40,pa)])])):b.view==="xy"?(e.openBlock(),e.createElementBlock("li",ha,e.toDisplayString(o.value)+"/"+e.toDisplayString(a.value),1)):e.createCommentVNode("",!0),e.createElementVNode("li",null,[e.createElementVNode("button",{onClick:p,class:e.normalizeClass(["grid size-7 cursor-pointer place-content-center rounded border border-gray-200 transition-colors hover:bg-gray-50 rtl:rotate-180",{"opacity-50 pointer-events-none":o.value===a.value}]),"aria-label":"Next page"},[e.createVNode(Jo)],2)])]),b.showPageSizes?(e.openBlock(),e.createElementBlock("div",ua,[e.createElementVNode("div",{class:"relative",ref_key:"dropdownRef",ref:f},[e.withDirectives(e.createElementVNode("div",ma,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.pageSizes,w=>(e.openBlock(),e.createElementBlock("button",{type:"button",key:w,onClick:x=>u(w),class:"flex w-full items-center gap-x-3.5 rounded-lg px-3 py-2 text-sm text-gray-800 hover:bg-gray-100 focus:bg-gray-100 focus:outline-none dark:text-neutral-400 dark:hover:bg-neutral-700 dark:hover:text-neutral-300 dark:focus:bg-neutral-700"},[e.createTextVNode(e.toDisplayString(w)+" ",1),h.value===w?(e.openBlock(),e.createBlock(na,{key:0})):e.createCommentVNode("",!0)],8,fa))),128))],512),[[e.vShow,m.value]]),e.createElementVNode("button",{type:"button",class:"inline-flex min-w-[32px] text-sm/7 items-center gap-x-1 rounded-md border border-gray-200 px-1.5 h-[1.75rem] text-base text-gray-800 shadow-sm hover:bg-gray-50 focus:bg-gray-100 focus:outline-none disabled:pointer-events-none disabled:opacity-50 dark:border-neutral-700 dark:text-white dark:hover:bg-neutral-700 dark:focus:bg-neutral-700","aria-haspopup":"menu","aria-expanded":"false","aria-label":"Dropdown",onClick:$[1]||($[1]=w=>m.value=!m.value)},[e.createTextVNode(e.toDisplayString(h.value)+" ",1),e.createVNode(ea)])],512)])):e.createCommentVNode("",!0)]))}}),ba=ne(ga,[["__scopeId","data-v-36d0267f"]]);e.reactive({visible:!0});const ya={class:"relative group h-full"},xa={class:"flex items-start gap-3 flex-1 min-h-0"},ka={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},wa={class:"flex-1 min-w-0 flex flex-col min-h-0"},_a={class:"font-semibold text-gray-900 mb-1 truncate"},$a={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},Ea={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},Ba={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},Da={key:3,class:"text-xs text-gray-400 mt-2 shrink-0"},Va=W({__name:"dashboard-card",props:{title:String,description:String,lastUpdate:{type:[String,Date],default:null},name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function},setup(r){const t=r,s=e.computed(()=>Me(t.lastUpdate??null)),n=K.useRouter(),o=e.ref(!1);function a(){t.dashboardRouteName&&(n.hasRoute(J.EditorDashboard)?n.push({name:J.EditorDashboard,params:{dashboardId:t.dashboardRouteName}}):t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):n.push({path:"/editor",query:{dashboard:t.dashboardRouteName}}))}function l(i){i.target.closest(".dashboard-card-menu")||(o.value=!1)}return e.onMounted(()=>document.addEventListener("click",l)),e.onUnmounted(()=>document.removeEventListener("click",l)),(i,c)=>(e.openBlock(),e.createElementBlock("div",ya,[e.createElementVNode("button",{type:"button",class:"w-full h-full bg-white border border-gray-200 rounded-lg p-6 hover:shadow-md hover:border-blue-200 transition-all text-left animate-fade-in flex flex-col",onClick:a},[e.createElementVNode("div",xa,[e.createElementVNode("div",ka,[e.createVNode(e.unref(Dr),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",wa,[e.createElementVNode("h3",_a,e.toDisplayString(r.title),1),r.description?(e.openBlock(),e.createElementBlock("p",$a,e.toDisplayString(r.description),1)):(e.openBlock(),e.createElementBlock("p",Ea,"   ")),r.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",Ba,e.toDisplayString(r.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("p",Da," Оновлено: "+e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-6f582e09"]]),Ca=[{type:"Text",key:"name",label:"Назва",validators:["required"],original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"title",label:"Заголовок",validators:["required"],original:{type:"Text",ua:"Титул",col:8}},{type:"Text",key:"description",label:"Опис",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"words",label:"Ключові слова",original:{type:"Text",ua:"Назва",col:8}},{type:"Select",data:"pg.table_name",key:"table_name",validators:["required"],label:"Назва таблиці",original:{type:"select",ua:"Назва",col:8,data:"pg.table_name"}},{type:"Text",key:"db",label:"База даних",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"category",label:"Категорія",original:{type:"Text",ua:"Категорія",col:8}},{type:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}];function Na(r){return!Array.isArray(r)||r.length===0?{}:r.reduce((t,s)=>{if(!s||s.key==null)return t;const{key:n,...o}=s;return t[n]=o,t},{})}const Sa={class:"flex-1 bg-gray-50"},za={class:"max-w-7xl mx-auto px-6 py-8"},La={class:"mb-6"},Ia={class:"flex items-center justify-between mb-6"},Ta={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Ma={class:"flex items-center space-x-4"},Pa={class:"flex-1 relative"},Fa={class:"relative"},ja={class:"relative min-h-[280px]"},Ra={key:0,class:"absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-white/55 backdrop-blur-[2px]","aria-busy":"true","aria-live":"polite"},Wa={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},va={class:"mt-[20px]"},Aa={key:2,class:"flex flex-col items-center justify-center py-20 text-center"},Oa={class:"mt-1 text-sm text-gray-400"},qa={class:"font-medium text-gray-500"},Mt=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(r){const t=e.defineAsyncComponent(()=>import("@opengis/form")),s=Na(Ca),n=e.ref([]),o=e.ref([]),a=K.useRouter(),l=K.useRoute();function i(N){const D=Array.isArray(N)?N[0]:N,P=typeof D=="string"?parseInt(D,10):NaN;return!Number.isNaN(P)&&P>=1?P:1}function c(N){const D=Array.isArray(N)?N[0]:N;return typeof D=="string"?D:""}function d(N){const D=N.trim().toLowerCase();return D?D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):""}const p=e.inject("biSetDashboard",void 0),h=r,m=e.ref(null),f=e.ref(!1),u=e.ref({}),y=e.ref(""),b=e.ref("title-asc"),$=e.ref(21),w=e.ref(0),x=e.ref(1),C=e.ref(!1),L=e.computed(()=>{const N=b.value==="title-asc"?1:-1;return[...n.value].sort((D,P)=>N*D.title.localeCompare(P.title,"uk"))});async function E(){C.value=!0;try{const N=d(y.value),D=await H.get("/bi-dashboard",{params:{type:"db",page:x.value,limit:$.value,...N?{search:N}:{}}}),P=Array.isArray(D==null?void 0:D.rows)?D.rows:[];w.value=(D==null?void 0:D.filtered)||(D==null?void 0:D.total)||0,o.value=P,n.value=P.map(A=>({routeName:String(A.name??""),title:A.title??A.name??"Без назви",description:A.description??null,last_update:A.last_update!=null?String(A.last_update):null,name:String(A.name??"")}))}catch(N){console.error("Failed to load dashboards",N),o.value=[],n.value=[]}finally{C.value=!1}}async function V(){var D,P,A;const N=(P=(D=e.getCurrentInstance())==null?void 0:D.proxy)==null?void 0:P.$notify;try{const g=(A=m.value)==null?void 0:A.validate();typeof g=="function"&&await g();const{name:_,title:k,table_name:z}=u.value;if(!_||!k||!z){N==null||N({type:"error",title:"Помилка!",message:"Заповніть усі обов'язкові поля"});return}await H.post("/bi-dashboard",u.value),f.value=!1,u.value={},N==null||N({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),a.hasRoute(J.EditorDashboard)?a.push({name:J.EditorDashboard,params:{dashboardId:_}}):p?p(_):await E()}catch{N==null||N({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}let B=null;e.onMounted(()=>{$e(h.prefix||"/api"),x.value=i(l.query.page),y.value=c(l.query.search),E()}),e.watch(y,N=>{B&&clearTimeout(B),B=setTimeout(()=>{B=null;const D=N.trim(),P=c(l.query.search);if(D===P)return;const A={...l.query};D?A.search=D:delete A.search,delete A.page,a.replace({query:A})},300)}),e.watch(()=>[l.query.page,l.query.search],()=>{const N=i(l.query.page),D=c(l.query.search);x.value=N,y.value=D,E()});const I=e.ref(1),M=()=>{const N=window.innerWidth;I.value=N>=1024?3:N>=768?2:1};e.onMounted(()=>{M(),window.addEventListener("resize",M)}),e.onUnmounted(()=>{B&&clearTimeout(B),window.removeEventListener("resize",M)});const U=N=>N?N.trim().length>70?2:1:0,Z=N=>{const D=I.value||1,A=Math.floor(N/D)*D,g=A+D,_=L.value.slice(A,g);let k=0;for(const z of _){const q=U(z.description??null);if(q>k&&(k=q),k===2)break}return k},Q=N=>{const D={...l.query};N===1?delete D.page:D.page=String(N),a.push({query:D})};return(N,D)=>(e.openBlock(),e.createElementBlock("div",Sa,[e.createElementVNode("div",za,[e.createElementVNode("div",La,[e.createElementVNode("div",Ia,[D[7]||(D[7]=e.createElementVNode("div",null,[e.createElementVNode("h1",{class:"text-3xl font-bold text-gray-900"},"Дашборди"),e.createElementVNode("p",{class:"mt-2 text-gray-600"}," Керуйте та переглядайте свої аналітичні дашборди ")],-1)),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 px-4 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors shadow-sm font-medium",onClick:D[0]||(D[0]=P=>f.value=!0)},[e.createVNode(e.unref(tt),{size:24,class:"w-4 h-4"}),D[6]||(D[6]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(ge,{teleport:"#modal",visible:f.value,title:"Створити дашборд",onClose:D[3]||(D[3]=P=>f.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Ta,[e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border border-gray-200 rounded-lg hover:bg-gray-100 duration-300",onClick:D[2]||(D[2]=P=>f.value=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg hover:bg-blue-700 duration-300",onClick:V}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:m,schema:e.unref(s),values:u.value,"onUpdate:values":D[1]||(D[1]=P=>u.value=P)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",Ma,[e.createElementVNode("div",Pa,[e.createVNode(e.unref(rt),{size:24,class:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":D[4]||(D[4]=P=>y.value=P),type:"text",placeholder:"Пошук дашбордів...",class:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},null,512),[[e.vModelText,y.value]])]),e.createElementVNode("div",Fa,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":D[5]||(D[5]=P=>b.value=P),class:"appearance-none pl-3 pr-8 py-2 border border-gray-300 rounded-lg bg-white text-sm text-gray-700 cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500"},D[8]||(D[8]=[e.createElementVNode("option",{value:"title-asc"},"Назва (А → Я)",-1),e.createElementVNode("option",{value:"title-desc"},"Назва (Я → А)",-1)]),512),[[e.vModelSelect,b.value]]),e.createVNode(e.unref(kr),{size:16,class:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 pointer-events-none"})])])]),e.createElementVNode("div",ja,[C.value?(e.openBlock(),e.createElementBlock("div",Ra,D[9]||(D[9]=[e.createElementVNode("div",{class:"h-11 w-11 animate-spin rounded-full border-[3px] border-blue-100 border-t-blue-600 shadow-sm",role:"status"},null,-1)]))):e.createCommentVNode("",!0),L.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",Wa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.value,(P,A)=>(e.openBlock(),e.createElementBlock("div",{key:P.routeName,class:"cursor-pointer h-full"},[e.createVNode(Va,{title:P.title,description:P.description,"last-update":P.last_update,name:P.name,reserveLines:Z(A),"dashboard-route-name":P.routeName,"on-open-editor":e.unref(p)},null,8,["title","description","last-update","name","reserveLines","dashboard-route-name","on-open-editor"])]))),128))]),e.createElementVNode("div",va,[e.createVNode(e.unref(ba),{total:w.value,showPageSizes:!1,page:x.value,pageSize:$.value,"onUpdate:page":Q,color:"#2563eb"},null,8,["total","page","pageSize"])])],64)):C.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Aa,[e.createVNode(e.unref(rt),{size:48,class:"text-gray-300 mb-4"}),D[12]||(D[12]=e.createElementVNode("p",{class:"text-lg font-medium text-gray-500"},"Дашбордів не знайдено",-1)),e.createElementVNode("p",Oa,[D[10]||(D[10]=e.createTextVNode(" За запитом «")),e.createElementVNode("span",qa,e.toDisplayString(y.value),1),D[11]||(D[11]=e.createTextVNode("» нічого не знайдено. Спробуйте змінити пошуковий запит. "))])]))])])]))}}),Ua=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(r){const t=r,s=e.computed(()=>t.prefix),n=K.useRouter(),o=K.useRoute(),a=e.computed(()=>n.hasRoute(J.EditorDashboard)),l=e.ref("");e.onMounted(()=>{var c;if(!a.value){const d=(c=o==null?void 0:o.query)==null?void 0:c.dashboard;d!=null&&typeof d=="string"&&(l.value=d.trim())}});const i=e.computed(()=>l.value.length>0);return e.provide("biSetDashboard",c=>{l.value=c||""}),e.provide("biClearDashboard",()=>{l.value=""}),e.provide("biSelectedDashboardId",e.readonly(l)),(c,d)=>{const p=e.resolveComponent("router-view");return a.value?(e.openBlock(),e.createBlock(p,{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[i.value?(e.openBlock(),e.createBlock(Tt,{key:`editor-${l.value}`,prefix:s.value,"dashboard-id":l.value,onBack:d[0]||(d[0]=h=>l.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock(Mt,{key:0,prefix:s.value},null,8,["prefix"]))],64))}}});class Ha{static getTooltipOptions(t=!0){return{show:t,confine:!0,appendToBody:!1,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const Ga={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function Za(){const r="0123456789ABCDEF";let t="#";for(let s=0;s<6;s+=1)t+=r[Math.floor(Math.random()*16)];return t}function de(r=Ga){var s,n,o;const t={label:{show:((s=r==null?void 0:r.label)==null?void 0:s.show)??(r==null?void 0:r.show_label)??!1,formatter:(r==null?void 0:r.formatter)??(a=>ee(a)),...(r==null?void 0:r.label)||{}},legend:{...(r==null?void 0:r.legend)||{},[((n=r==null?void 0:r.legend)==null?void 0:n.position)||"bottom"]:"0",show:((o=r==null?void 0:r.legend)==null?void 0:o.show)??(r==null?void 0:r.show_legend)??!1},barWidth:"70%",grid:{borderColor:"#e5e7eb"},title:{...(r==null?void 0:r.title)||{}}};return(r!=null&&r.colors||r!=null&&r.color)&&(t.color=(r==null?void 0:r.colors)||(r==null?void 0:r.color)||null),t}function Pt(r){return{color:"#9ca3af",fontSize:10,fontFamily:"Inter, ui-sans-serif, system-ui",fontWeight:400,label:r==null?void 0:r.label,show:!0,formatter:(r==null?void 0:r.formatter)??(t=>ee(t)),margin:(r==null?void 0:r.margin)??7,interval:(r==null?void 0:r.interval)??"auto",rotate:(r==null?void 0:r.rotate)??0}}const Ft=["#d3c7e6","#bedae3","#f8e9cb","#ff8c8c","#c5d8be","#ffc6c6","#ffc39a","#fff7c5","#d8ffc0","#d4f7ff"];class Le{static getLabelOptions(t={}){return{show:(t==null?void 0:t.show_label)||(t==null?void 0:t.show)||!1,fontSize:"10",position:(t==null?void 0:t.position)||"inside",formatter:(t==null?void 0:t.formatter)||"{d}%",...t}}static getLegendOpions(t={}){return{...t,position:(t==null?void 0:t.position)||"bottom"}}}const pe=typeof window<"u"?window.echarts:null,X={props:["source","style","widget","dashboard","config","title","currentWidget","widgetData","prefix","prefetchedData"],data(){return{sourceData:null,styleData:null,widgetName:"",dimensions:[],dashboardName:"",titleCharts:"",eventWidgetId:"",widgetInstance:null}},mounted(){this.eventWidgetId=this.resolveWidgetId(),window.addEventListener("resize",this.handleResize),this.eventWidgetId&&(window.addEventListener(`update-data-${this.eventWidgetId}`,this.checkCustomEvent),window.addEventListener(`update-style-${this.eventWidgetId}`,this.checkCustomStyleEvent))},unmounted(){this.eventWidgetId&&(window.removeEventListener(`update-data-${this.eventWidgetId}`,this.checkCustomEvent),window.removeEventListener(`update-style-${this.eventWidgetId}`,this.checkCustomStyleEvent))},watch:{sourceData:{async handler(){setTimeout(()=>{this==null||this.onChangedData()},0)}}},methods:{resolveWidgetId(){var r,t,s,n;return this.widget||((r=this.config)==null?void 0:r.widget)||((t=this.config)==null?void 0:t.widgetId)||((s=this.config)==null?void 0:s.id)||((n=this.config)==null?void 0:n.name)||""},resolveDashboardId(){var r,t;return this.dashboard||((r=this.config)==null?void 0:r.dashboard)||((t=this.config)==null?void 0:t.dashboardId)||""},resolvePrefix(){var r;return this.prefix||((r=this.config)==null?void 0:r.prefix)||""},checkCustomStyleEvent(r){this.changeOptionsByName(r.chartId,r.options)},checkCustomEvent({filterUrl:r}){this.getDataFromURL(r)},handleResize(){this.widgetInstance&&this.widgetInstance.resize()},async getDataFromURL(r){try{const t=await H.get(r);this.applyResponse(t)}catch(t){const s={message:"Дані не знайдено",title:"Помилка!",type:"error",status:400,id:this.widgetName};(t==null?void 0:t.status)=="404"&&(s.status=404,s.message="Дані не знайдено"),(t==null?void 0:t.status)=="400"&&(s.message="Перевірте налаштування або зверніться до адміністратора"),(t==null?void 0:t.status)=="500"&&(s.message="Сталася помилка сервера"),this.$emit("update:widgetData",s)}},getValues(){return this.sourceData.map(r=>{var t;return parseFloat(r[(t=this.columns)==null?void 0:t[1]])})},formatDate(r){const t=new Date(r);if(isNaN(t))return r;const s=String(t.getDate()).padStart(2,"0"),o=["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"][t.getMonth()],a=t.getFullYear();return`${s} ${o} ${a}`},applyResponse(r){var t;this.sourceData=(r==null?void 0:r.source)||[],this.$emit("update:widgetData",r),this.dimensions=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{}),this.titleCharts=this.style?this.style:(r==null?void 0:r.title)||"",this.styleData=(r==null?void 0:r.style)||{}},async getData(){var r,t;try{const s=this.resolveWidgetId(),n=this.resolveDashboardId(),o=this.resolvePrefix();if(this.source)this.sourceData=[...this.source],this.styleData=this.style,this.titleCharts=this.title||((r=this.config)==null?void 0:r.title),this.dimensions=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{});else if(this.prefetchedData)this.widgetName=s,this.dashboardName=n,this.applyResponse(this.prefetchedData);else{this.widgetName=s,this.dashboardName=n;const a=this.dashboardName?`${o}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}`:`${o}/bi-data?&widget=${this.widgetName}`;await this.getDataFromURL(a)}}catch(s){console.error(s)}},async initChart(r,t,s){var n,o,a,l,i,c,d,p,h;this.widgetInstance&&this.widgetInstance.clear();try{const m=this.$refs.chart,f=pe==null?void 0:pe.init(m);if(!f)return;const u={tooltip:{show:((o=(n=this.styleData)==null?void 0:n.tooltip)==null?void 0:o.show)!==!1,trigger:"axis",confine:!0,appendToBody:!1,axisPointer:{type:"shadow"},backgroundColor:"transparent",shadowColor:"transparent",padding:[0,0,0,0],borderWidth:0,position:(y,b,$,w,x)=>{const[C,L]=y,[E,V]=x.contentSize,[B,I]=x.viewSize;let M=C+14,U=L-V/2;return M+E>B&&(M=C-E-14),M<0&&(M=0),U+V>I&&(U=I-V),U<0&&(U=0),[M,U]},formatter:y=>{var V;const $=(V=y[0])==null?void 0:V.axisValue,w=$?this.formatDate($):"N/A",x=[...y].filter(B=>{var I;return parseFloat(B==null?void 0:B.data)||((I=B==null?void 0:B.data)==null?void 0:I.value)}).sort((B,I)=>{var Z,Q;const M=parseFloat(((Z=B==null?void 0:B.data)==null?void 0:Z.value)??(B==null?void 0:B.data))||0;return(parseFloat(((Q=I==null?void 0:I.data)==null?void 0:Q.value)??(I==null?void 0:I.data))||0)-M}),C=x.slice(0,8),L=x.length-C.length;let E=`
194
194
  <div style="background-color: rgba(255, 255, 255, 0.95)" class="border border-gray-200 text-gray-800 rounded-lg shadow-md dark:bg-neutral-800 dark:border-neutral-700 min-w-28">
195
195
  <div class="font-semibold text-sm border-b border-solid border-gray-200 text-gray-800 rounded-t-lg dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-200 px-2 py-1">
196
196
  ${w}
197
197
  </div>
198
- `;return D.forEach(B=>{E+=`
198
+ `;return C.forEach(B=>{E+=`
199
199
  <div class="flex justify-between items-center text-xs px-2 py-0.5 text-gray-500 dark:text-neutral-400">
200
200
  <span class="flex items-center">
201
201
  <span class="w-2.5 h-2.5 me-1.5 rounded-sm" style="background-color: ${B.color};"></span>
@@ -206,31 +206,31 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
206
206
  `}),L>0&&(E+=`
207
207
  <div class="text-xs px-2 py-0.5 text-gray-400 dark:text-neutral-500">
208
208
  ... ще ${L}
209
- </div>`),E+="</div>",E}},xAxis:{data:t!=null&&t.length?t:null,type:t?"category":"value",name:((a=(l=this.styleData)==null?void 0:l.x_axis)==null?void 0:a.name)||"",axisLabel:{...Pt((i=this.styleData)==null?void 0:i.x_axis),formatter:y=>{var $,w;const b=this.formatDate(y);return((w=($=this.styleData)==null?void 0:$.x_axis)==null?void 0:w.overflow)==="ellipsis"&&b.length>10?`${b.slice(0,10)}...`:b}}},yAxis:{data:n!=null&&n.length?n:null,type:n?"category":"value",name:((d=(c=this.styleData)==null?void 0:c.y_axis)==null?void 0:d.name)||"",axisLabel:Pt((p=this.styleData)==null?void 0:p.y_axis)},series:r!=null&&r.length?r:null,...de(this.styleData),grid:{bottom:"0%",right:"0%",left:"0%",top:"20px",containLabel:!0,...((h=this.styleData)==null?void 0:h.grid)||{}}};await f.setOption(u),f.resize(),this.widgetInstance=f,this.$emit("update:currentWidget",f)}catch(m){console.error(m)}},async setSeriesOption(r,t){const n=r.getOption(),{series:s=[]}=n,o=s.map(l=>({...l,...t}));r.setOption({...n,series:o})},async changeOptionsByName(r,t){const n=document.getElementById(r);if(!n)return null;const s=pe==null?void 0:pe.getInstanceByDom(n);if(!s)return null;const o=s.getOption();t.seriesOptions&&this.setSeriesOption(s,t.seriesOptions),s.setOption({...o,...t.options,tooltip:{...Ha.getTooltipOptions(t.options.tooltip.show)}})},async changeData(r){var t;try{const n=this.resolveWidgetId(),s=this.resolveDashboardId(),o=this.resolvePrefix();let l=s?`${o}/bi-data?dashboard=${s}&widget=${n}`:`${o}/bi-data?&widget=${n}`;(t=r==null?void 0:r.granularity)!=null&&t.length&&(l+=`&granularity=${r.granularity}`),r!=null&&r.metrics&&(l+=`&metrics=${r.metrics}`),this.getDataFromURL(l)}catch(n){console.error(n)}},async setFilter(r){const t=this.resolvePrefix(),n=this.dashboardName||this.resolveDashboardId(),s=this.widgetName||this.resolveWidgetId(),o=`${t}/bi-data?dashboard=${n}&widget=${s}${r||""}`;await this.getDataFromURL(o)},async changeStyle(r,t){this.styleData[r]=t,this.onChangedData()},getMetricValue(r){var s;const t=(r==null?void 0:r.metric)||r;return parseFloat(t)?(s=ee(t,{notation:"standard"}))==null?void 0:s.replaceAll(","," "):t}}},Qa={name:"VsBar",mixins:[X],data(){return{resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var t;this.getData(),this.onChangedData();const r=(t=this.$refs)==null?void 0:t.chart;r&&(this.resizeObserver=new ResizeObserver(()=>{var n;this.widgetInstance&&((n=this.widgetInstance)==null||n.resize())}),this.resizeObserver.observe(r))},unmounted(){this.resizeObserver.disconnect()},methods:{async onChangedData(){try{if(this.sourceData){await this.$nextTick();const{series:r,xs:t,ys:n}=this.prepareData();r&&(this==null||this.initChart(r,t,n))}}catch(r){console.error(r)}},prepareData(){var r,t,n,s,o,l;try{if(!((r=this.sourceData)!=null&&r.length))return{series:[],xs:[],ys:void 0};const a=Array.from(new Set(this.sourceData.filter(m=>m[this.dimensions[0]]).map(m=>m[this.dimensions[0]])));let i;this.dimensions[0].includes("date")?i=a.map(m=>me(m)):i=[...a];let c,d;((t=this.styleData)==null?void 0:t.horizontal)===!0?d=[...i]:c=[...i];const p=this.sourceData.filter(m=>parseFloat(m[this.dimensions[1]])&&m[this.dimensions[0]]).map(m=>parseFloat(m[this.dimensions[1]]));let h;return((n=this.styleData)==null?void 0:n.stack)!==!1?h=this.prepareStackData():((s=this.styleData)==null?void 0:s.negative_waterfall)===!0?h=this.prepareNegativeWaterfall():((o=this.styleData)==null?void 0:o.waterfall)===!0?h=this.prepareWaterfallData(p):((l=this.styleData)==null?void 0:l.accumulative)===!0?h=this.prepareAccumulative(p):h=this.dimensions.slice(1).map((f,u)=>({name:f,type:"bar",stack:`a${u}`,data:this.sourceData.filter(y=>parseFloat(y[f])&&f).map(y=>parseFloat(y[f]))})),{series:h,xs:c,ys:d}}catch(a){return console.error(a),{series:[],xs:[],ys:[]}}},prepareWaterfallData(r){let t=r.reduce((l,a)=>l+a,0);const n=[t,...r],s=n.map((l,a)=>{if(a===0)return 0;const i=t-l;return t-=l,i>=0?i:0});return[{type:"bar",stack:"Total",itemStyle:{borderColor:"transparent",color:"transparent"},data:s,tooltip:{show:!1}},{name:this.title?this.title:this.dimensions[0],type:"bar",stack:"Total",data:n}]},prepareStackData(){return this.dimensions.slice(1).map(n=>({name:n,type:"bar",stack:"a",data:this.sourceData.filter(s=>parseFloat(s[n])&&n).map(s=>parseFloat(s[n]))}))},prepareNegativeWaterfall(){const r=this.sourceData.map(l=>Number.isNaN(l[this.dimensions[1]])?0:Number(l[this.dimensions[1]])),t=this.sourceData.map(l=>Number.isNaN(l[this.dimensions[2]])?0:Number(l[this.dimensions[2]]));let n=0;const s=r.map((l,a)=>{const i=n;return n+=Number.isNaN(l)?0:l,a===0&&(n-=Number.isNaN(t[a])?0:t[a]),n-=Number.isNaN(t[a+1])?0:t[a+1],i>=0?i:0});return[{type:"bar",stack:"a",itemStyle:{borderColor:"transparent",color:"transparent"},data:s,tooltip:{show:!1}},{name:this.dimensions[1],type:"bar",stack:"a",data:r},{name:this.dimensions[2],type:"bar",stack:"a",data:t}]},prepareAccumulative(r){let t=0;const n=r.map(o=>(t+=o,t));return[{name:this.titleCharts,type:"bar",stack:"Total",data:n}]}}},Ja=["id"];function Xa(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full w-full min-h-[200px]"},null,8,Ja)}const Ue=W(Qa,[["render",Xa]]),Ka=Object.freeze(Object.defineProperty({__proto__:null,default:Ue},Symbol.toStringTag,{value:"Module"})),He=typeof window<"u"?window.echarts:null,Ya={name:"VsPie",props:["currentWidget"],mixins:[X],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var n;await this.$nextTick(),await this.getData();const{series:r}=this.prepareData()||{};r&&this.initChart(r);const t=(n=this.$refs)==null?void 0:n.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},beforeUnmount(){var r;(r=this.resizeObserver)==null||r.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:r,xs:t,ys:n}=this.prepareData();r&&this.initChart(r,t,n)}}catch(r){console.error(r)}},buildTooltipForDonut(r,t){const{name:n,value:s,percent:o}=r;return`
209
+ </div>`),E+="</div>",E}},xAxis:{data:t!=null&&t.length?t:null,type:t?"category":"value",name:((l=(a=this.styleData)==null?void 0:a.x_axis)==null?void 0:l.name)||"",axisLabel:{...Pt((i=this.styleData)==null?void 0:i.x_axis),formatter:y=>{var $,w;const b=this.formatDate(y);return((w=($=this.styleData)==null?void 0:$.x_axis)==null?void 0:w.overflow)==="ellipsis"&&b.length>10?`${b.slice(0,10)}...`:b}}},yAxis:{data:s!=null&&s.length?s:null,type:s?"category":"value",name:((d=(c=this.styleData)==null?void 0:c.y_axis)==null?void 0:d.name)||"",axisLabel:Pt((p=this.styleData)==null?void 0:p.y_axis)},series:r!=null&&r.length?r:null,...de(this.styleData),grid:{bottom:"0%",right:"0%",left:"0%",top:"20px",containLabel:!0,...((h=this.styleData)==null?void 0:h.grid)||{}}};await f.setOption(u),f.resize(),this.widgetInstance=f,this.$emit("update:currentWidget",f)}catch(m){console.error(m)}},async setSeriesOption(r,t){const s=r.getOption(),{series:n=[]}=s,o=n.map(a=>({...a,...t}));r.setOption({...s,series:o})},async changeOptionsByName(r,t){const s=document.getElementById(r);if(!s)return null;const n=pe==null?void 0:pe.getInstanceByDom(s);if(!n)return null;const o=n.getOption();t.seriesOptions&&this.setSeriesOption(n,t.seriesOptions),n.setOption({...o,...t.options,tooltip:{...Ha.getTooltipOptions(t.options.tooltip.show)}})},async changeData(r){var t;try{const s=this.resolveWidgetId(),n=this.resolveDashboardId(),o=this.resolvePrefix();let a=n?`${o}/bi-data?dashboard=${n}&widget=${s}`:`${o}/bi-data?&widget=${s}`;(t=r==null?void 0:r.granularity)!=null&&t.length&&(a+=`&granularity=${r.granularity}`),r!=null&&r.metrics&&(a+=`&metrics=${r.metrics}`),this.getDataFromURL(a)}catch(s){console.error(s)}},async setFilter(r){const t=this.resolvePrefix(),s=this.dashboardName||this.resolveDashboardId(),n=this.widgetName||this.resolveWidgetId(),o=`${t}/bi-data?dashboard=${s}&widget=${n}${r||""}`;await this.getDataFromURL(o)},async changeStyle(r,t){this.styleData[r]=t,this.onChangedData()},getMetricValue(r){var n;const t=(r==null?void 0:r.metric)||r;return parseFloat(t)?(n=ee(t,{notation:"standard"}))==null?void 0:n.replaceAll(","," "):t}}},Qa={name:"VsBar",mixins:[X],data(){return{resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var t;this.getData(),this.onChangedData();const r=(t=this.$refs)==null?void 0:t.chart;r&&(this.resizeObserver=new ResizeObserver(()=>{var s;this.widgetInstance&&((s=this.widgetInstance)==null||s.resize())}),this.resizeObserver.observe(r))},unmounted(){this.resizeObserver.disconnect()},methods:{async onChangedData(){try{if(this.sourceData){await this.$nextTick();const{series:r,xs:t,ys:s}=this.prepareData();r&&(this==null||this.initChart(r,t,s))}}catch(r){console.error(r)}},prepareData(){var r,t,s,n,o,a;try{if(!((r=this.sourceData)!=null&&r.length))return{series:[],xs:[],ys:void 0};const l=Array.from(new Set(this.sourceData.filter(m=>m[this.dimensions[0]]).map(m=>m[this.dimensions[0]])));let i;this.dimensions[0].includes("date")?i=l.map(m=>me(m)):i=[...l];let c,d;((t=this.styleData)==null?void 0:t.horizontal)===!0?d=[...i]:c=[...i];const p=this.sourceData.filter(m=>parseFloat(m[this.dimensions[1]])&&m[this.dimensions[0]]).map(m=>parseFloat(m[this.dimensions[1]]));let h;return((s=this.styleData)==null?void 0:s.stack)!==!1?h=this.prepareStackData():((n=this.styleData)==null?void 0:n.negative_waterfall)===!0?h=this.prepareNegativeWaterfall():((o=this.styleData)==null?void 0:o.waterfall)===!0?h=this.prepareWaterfallData(p):((a=this.styleData)==null?void 0:a.accumulative)===!0?h=this.prepareAccumulative(p):h=this.dimensions.slice(1).map((f,u)=>({name:f,type:"bar",stack:`a${u}`,data:this.sourceData.filter(y=>parseFloat(y[f])&&f).map(y=>parseFloat(y[f]))})),{series:h,xs:c,ys:d}}catch(l){return console.error(l),{series:[],xs:[],ys:[]}}},prepareWaterfallData(r){let t=r.reduce((a,l)=>a+l,0);const s=[t,...r],n=s.map((a,l)=>{if(l===0)return 0;const i=t-a;return t-=a,i>=0?i:0});return[{type:"bar",stack:"Total",itemStyle:{borderColor:"transparent",color:"transparent"},data:n,tooltip:{show:!1}},{name:this.title?this.title:this.dimensions[0],type:"bar",stack:"Total",data:s}]},prepareStackData(){return this.dimensions.slice(1).map(s=>({name:s,type:"bar",stack:"a",data:this.sourceData.filter(n=>parseFloat(n[s])&&s).map(n=>parseFloat(n[s]))}))},prepareNegativeWaterfall(){const r=this.sourceData.map(a=>Number.isNaN(a[this.dimensions[1]])?0:Number(a[this.dimensions[1]])),t=this.sourceData.map(a=>Number.isNaN(a[this.dimensions[2]])?0:Number(a[this.dimensions[2]]));let s=0;const n=r.map((a,l)=>{const i=s;return s+=Number.isNaN(a)?0:a,l===0&&(s-=Number.isNaN(t[l])?0:t[l]),s-=Number.isNaN(t[l+1])?0:t[l+1],i>=0?i:0});return[{type:"bar",stack:"a",itemStyle:{borderColor:"transparent",color:"transparent"},data:n,tooltip:{show:!1}},{name:this.dimensions[1],type:"bar",stack:"a",data:r},{name:this.dimensions[2],type:"bar",stack:"a",data:t}]},prepareAccumulative(r){let t=0;const s=r.map(o=>(t+=o,t));return[{name:this.titleCharts,type:"bar",stack:"Total",data:s}]}}},Ja=["id"];function Xa(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",{id:a.uniqueID,ref:"chart",class:"h-full w-full min-h-[200px]"},null,8,Ja)}const Ue=W(Qa,[["render",Xa]]),Ka=Object.freeze(Object.defineProperty({__proto__:null,default:Ue},Symbol.toStringTag,{value:"Module"})),He=typeof window<"u"?window.echarts:null,Ya={name:"VsPie",props:["currentWidget"],mixins:[X],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var s;await this.$nextTick(),await this.getData();const{series:r}=this.prepareData()||{};r&&this.initChart(r);const t=(s=this.$refs)==null?void 0:s.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},beforeUnmount(){var r;(r=this.resizeObserver)==null||r.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:r,xs:t,ys:s}=this.prepareData();r&&this.initChart(r,t,s)}}catch(r){console.error(r)}},buildTooltipForDonut(r,t){const{name:s,value:n,percent:o}=r;return`
210
210
  <div style="background-color:${t[0]}; font-size:12px; font-family:Helvetica, Arial, sans-serif; color:#ffff; padding:5px; border-radius:5px;">
211
- ${n==null?void 0:n.replace("null","Не визначено")}: ${ee(s)} (${o}%)
212
- </div>`},prepareData(){var r,t,n,s,o,l;try{if(this.styleData=this.styleData||{},!((r=this.sourceData)!=null&&r.length))return console.warn("No source data available"),null;const a=Array.from(new Set((this.sourceData||[]).map(u=>u[this.dimensions[0]]))),i=Array.from(new Set((this.sourceData||[]).map(u=>u[this.dimensions[1]]))),c=parseInt((this.sourceData||[]).reduce((u,y)=>u+parseFloat((y==null?void 0:y.metric)||0),0),10),d=a.map((u,y)=>{const b=(i[y]/c*100).toFixed(2);return{name:`${u} (${b}%)`,value:i[y]}}),p=((t=this.styleData)==null?void 0:t.innerRadius)||"80%",h=((n=this.styleData)==null?void 0:n.outerRadius)||"100%",m=[p,h];return this.styleData.legend=Le.getLegendOpions({borderRadius:10,height:"100%",padding:10,bottom:"0",type:"scroll",itemWidth:14,itemHeight:14,formatter:u=>{var y;return(y=u==null?void 0:u.replace("null","Не визначено"))==null?void 0:y.replace("NaN","0.00")},...((s=this.styleData)==null?void 0:s.legend)||{}}),this.styleData.label=Le.getLabelOptions((o=this.styleData)==null?void 0:o.label),this.styleData.show_legend=((l=this.styleData)==null?void 0:l.show_legend)??!0,{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"pie",radius:m,center:["50%","60%"],height:"75%",...de(this.styleData),data:d}]}}catch(a){return console.error("Error in prepareData:",a),null}},async initChart(r){var t,n;try{if(!r){console.warn("No series data available for chart initialization");return}const s=this.$refs.chart;if(!s){console.warn("Chart DOM element not found");return}if(this.chartInstance=He==null?void 0:He.init(s),!this.chartInstance)return;const o=parseInt((this.sourceData||[]).reduce((a,i)=>a+parseFloat((i==null?void 0:i.metric)||0),0),10),l={tooltip:{show:((n=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:n.show)!==!1,trigger:"item",confine:!0,formatter:a=>this.buildTooltipForDonut(a,[a.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:r,...de(this.styleData||{}),title:{text:ee(o),left:"center",top:"41%",textStyle:{color:"black",fontWeight:400,fontSize:"22px"}}};this.chartInstance.setOption(l),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var a;(a=this.chartInstance)==null||a.resize()})}catch(s){console.error("Error in initChart:",s)}}}},el=["id"];function tl(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,el)}const Rt=W(Ya,[["render",tl]]),rl=Object.freeze(Object.defineProperty({__proto__:null,default:Rt},Symbol.toStringTag,{value:"Module"})),Ge=typeof window<"u"?window.echarts:null,nl={name:"VsPie",props:["currentWidget"],mixins:[X],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var n;await this.$nextTick(),await this.getData();const{series:r}=this.prepareData()||{};r&&this.initChart(r);const t=(n=this.$refs)==null?void 0:n.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},unmounted(){var r;(r=this.resizeObserver)==null||r.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:r,xs:t,ys:n}=this.prepareData();r&&this.initChart(r,t,n)}}catch(r){console.error(r)}},buildTooltipForDonut(r,t){const{name:n,value:s,percent:o}=r;return`
211
+ ${s==null?void 0:s.replace("null","Не визначено")}: ${ee(n)} (${o}%)
212
+ </div>`},prepareData(){var r,t,s,n,o,a;try{if(this.styleData=this.styleData||{},!((r=this.sourceData)!=null&&r.length))return console.warn("No source data available"),null;const l=Array.from(new Set((this.sourceData||[]).map(u=>u[this.dimensions[0]]))),i=Array.from(new Set((this.sourceData||[]).map(u=>u[this.dimensions[1]]))),c=parseInt((this.sourceData||[]).reduce((u,y)=>u+parseFloat((y==null?void 0:y.metric)||0),0),10),d=l.map((u,y)=>{const b=(i[y]/c*100).toFixed(2);return{name:`${u} (${b}%)`,value:i[y]}}),p=((t=this.styleData)==null?void 0:t.innerRadius)||"80%",h=((s=this.styleData)==null?void 0:s.outerRadius)||"100%",m=[p,h];return this.styleData.legend=Le.getLegendOpions({borderRadius:10,height:"100%",padding:10,bottom:"0",type:"scroll",itemWidth:14,itemHeight:14,formatter:u=>{var y;return(y=u==null?void 0:u.replace("null","Не визначено"))==null?void 0:y.replace("NaN","0.00")},...((n=this.styleData)==null?void 0:n.legend)||{}}),this.styleData.label=Le.getLabelOptions((o=this.styleData)==null?void 0:o.label),this.styleData.show_legend=((a=this.styleData)==null?void 0:a.show_legend)??!0,{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"pie",radius:m,center:["50%","60%"],height:"75%",...de(this.styleData),data:d}]}}catch(l){return console.error("Error in prepareData:",l),null}},async initChart(r){var t,s;try{if(!r){console.warn("No series data available for chart initialization");return}const n=this.$refs.chart;if(!n){console.warn("Chart DOM element not found");return}if(this.chartInstance=He==null?void 0:He.init(n),!this.chartInstance)return;const o=parseInt((this.sourceData||[]).reduce((l,i)=>l+parseFloat((i==null?void 0:i.metric)||0),0),10),a={tooltip:{show:((s=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:s.show)!==!1,trigger:"item",confine:!0,formatter:l=>this.buildTooltipForDonut(l,[l.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:r,...de(this.styleData||{}),title:{text:ee(o),left:"center",top:"41%",textStyle:{color:"black",fontWeight:400,fontSize:"22px"}}};this.chartInstance.setOption(a),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var l;(l=this.chartInstance)==null||l.resize()})}catch(n){console.error("Error in initChart:",n)}}}},el=["id"];function tl(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",{id:a.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,el)}const jt=W(Ya,[["render",tl]]),rl=Object.freeze(Object.defineProperty({__proto__:null,default:jt},Symbol.toStringTag,{value:"Module"})),Ge=typeof window<"u"?window.echarts:null,sl={name:"VsPie",props:["currentWidget"],mixins:[X],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var s;await this.$nextTick(),await this.getData();const{series:r}=this.prepareData()||{};r&&this.initChart(r);const t=(s=this.$refs)==null?void 0:s.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},unmounted(){var r;(r=this.resizeObserver)==null||r.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:r,xs:t,ys:s}=this.prepareData();r&&this.initChart(r,t,s)}}catch(r){console.error(r)}},buildTooltipForDonut(r,t){const{name:s,value:n,percent:o}=r;return`
213
213
  <div style="background-color:${t[0]}; font-size:12px; font-family:Helvetica, Arial, sans-serif; color:#ffff; padding:5px; border-radius:5px;">
214
- ${n==null?void 0:n.replace("null","Не визначено")}: ${ee(s)} (${o}%)
215
- </div>`},prepareData(){var r,t,n,s,o;try{this.styleData=this.styleData||{};const l=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[0]]))),a=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[1]]))),i=parseInt((this.sourceData||[]).reduce((f,u)=>f+parseFloat(u==null?void 0:u.metric),0),10),c=l.map((f,u)=>{const y=(a[u]/i*100).toFixed(2);return{name:`${f} (${y}%)`,value:a[u]}}),d=((r=this.styleData)==null?void 0:r.innerRadius)||"0%",p=((t=this.styleData)==null?void 0:t.outerRadius)||"100%",h=[d,p];return this.styleData.legend=Le.getLegendOpions({borderRadius:10,height:"100%",padding:10,type:"scroll",itemWidth:14,itemHeight:14,formatter:f=>f==null?void 0:f.replace("null","Не визначено"),textStyle:{fontSize:"14px"},...((n=this.styleData)==null?void 0:n.legend)||{}}),this.styleData.label=Le.getLabelOptions((s=this.styleData)==null?void 0:s.label),this.styleData.show_legend=((o=this.styleData)==null?void 0:o.show_legend)??!0,{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"pie",radius:h,center:["50%","60%"],height:"75%",...de(this.styleData),data:c}]}}catch(l){return console.error("Error in prepareData:",l),null}},async initChart(r){var t,n;try{if(!r){console.warn("No series data available for chart initialization");return}const s=this.$refs.chart;if(!s){console.warn("Chart DOM element not found");return}if(this.chartInstance=Ge==null?void 0:Ge.init(s),!this.chartInstance)return;const o={tooltip:{show:((n=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:n.show)!==!1,trigger:"item",confine:!0,formatter:l=>this.buildTooltipForDonut(l,[l.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:r,...de(this.styleData||{})};this.chartInstance.setOption(o),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var l;(l=this.chartInstance)==null||l.resize()})}catch(s){console.error("Error in initChart:",s)}}}},sl=["id"];function ol(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,sl)}const jt=W(nl,[["render",ol]]),al=Object.freeze(Object.defineProperty({__proto__:null,default:jt},Symbol.toStringTag,{value:"Module"})),ll={name:"VsLine",mixins:[X],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:r,xs:t}=this.prepareData();r&&this.initChart(r,t)},methods:{onChangedData(){try{if(this.sourceData){const{series:r,xs:t,ys:n}=this.prepareData();r&&(this==null||this.initChart(r,t,n))}}catch(r){console.error(r)}},prepareData(){var r,t;try{const n=Array.from(new Set(this.sourceData.map(a=>a[this.dimensions[0]])));let s;this.dimensions[0].includes("date")?s=n.map(a=>me(a)):s=[...n];const o=this.sourceData.map(a=>parseFloat(a[this.dimensions[1]]));let l;return(r=this.styleData)!=null&&r.stack?l=this.dimensions.slice(1).map(i=>({name:i,type:"line",stack:"a",areaStyle:this.styleData.area?{}:null,data:this.sourceData.filter(c=>parseFloat(c[i])).map(c=>parseFloat(c[i]))})):l=[{name:this.title,type:"line",areaStyle:(t=this.styleData)!=null&&t.area?{}:null,data:o,stack:"a"}],{series:l,xs:s}}catch(n){return console.error(n),null}}}},il=["id"];function cl(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,ref:"chart",style:{height:"400px"}},null,8,il)}const Wt=W(ll,[["render",cl]]),dl=Object.freeze(Object.defineProperty({__proto__:null,default:Wt},Symbol.toStringTag,{value:"Module"})),pl={name:"VsStat",mixins:[X],data(){return{restDimensions:[],sumValue:0,columns:null,showTooltip:-1}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){this.columns=Object.keys(this.sourceData[0]);const r=this.getValues();this.sumValue=r.reduce((t,n)=>t+n,0),this.sourceData.forEach((t,n)=>{t.color=n<Ft.length-1?Ft[n]:Za()})},formattedValue(r){const t=parseFloat(r);return ee(t)}}},hl={class:"flex flex-col w-full h-full pt-[16px] rounded-xl"},ul={class:"flex flex-col justify-between w-full h-full"},ml={class:"w-full h-full pb-6 space-y-4"},fl={class:"flex w-full h-3 rounded-full gap-x-1 min-h-3 custom-x-scrollbar"},gl=["onMouseover"],bl={key:0,class:"absolute top-[-1] left-1/2 transform -translate-x-1/2 -translate-y-full bg-black text-white rounded px-2 py-1"},yl={class:"h-[calc(100%-40px)] w-full custom-scrollbar"},xl={class:"grid items-center justify-between grid-cols-2 py-2 gap-x-4"},kl={class:"flex items-center"},wl={class:"text-sm text-gray-800"},_l={class:"text-end"},$l={class:"text-sm text-gray-500"};function El(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",hl,[e.createElementVNode("div",ul,[e.createElementVNode("div",ml,[e.createElementVNode("div",fl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,(a,i)=>{var c,d,p,h;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex flex-col min-w-[5px] justify-center min-h-2.5 h-2.5 text-xs text-white text-center whitespace-nowrap",`bg-[${a.color}]`]),style:e.normalizeStyle({width:`${parseFloat(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])/o.sumValue*100}%`}),role:"progressbar","aria-valuenow":"42","aria-valuemin":"0","aria-valuemax":"100",onMouseover:m=>o.showTooltip=i,onMouseleave:t[0]||(t[0]=m=>o.showTooltip=-1)},[o.showTooltip>-1?(e.openBlock(),e.createElementBlock("div",bl,e.toDisplayString(r.sourceData[o.showTooltip][o.columns[0]])+" "+e.toDisplayString((parseFloat((h=(d=r.sourceData)==null?void 0:d[o.showTooltip])==null?void 0:h[(p=o.columns)==null?void 0:p[1]])/o.sumValue*100).toFixed(2))+"% ",1)):e.createCommentVNode("",!0)],46,gl)}),256))]),e.createElementVNode("ul",yl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,a=>{var i,c;return e.openBlock(),e.createElementBlock("li",xl,[e.createElementVNode("div",kl,[e.createElementVNode("span",{class:e.normalizeClass(["shrink-0 size-2.5 inline-block rounded-sm me-2.5 min-w-[10px] w-[10px] h-[10px] min-h-[10px]",`bg-[${a.color}]`])},null,2),e.createElementVNode("span",wl,e.toDisplayString((a==null?void 0:a[(i=o.columns)==null?void 0:i[0]])||"Не визначено"),1)]),e.createElementVNode("div",_l,[e.createElementVNode("span",$l,e.toDisplayString(l.formattedValue(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])||"-"),1)])])}),256))])])])])}const vt=W(pl,[["render",El]]),Bl=Object.freeze(Object.defineProperty({__proto__:null,default:vt},Symbol.toStringTag,{value:"Module"})),Vl={name:"VsProgressBar",mixins:[X],data(){return{restDimensions:[],maxValue:0,columns:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){var t;this.columns=Object.keys((t=this.sourceData)==null?void 0:t[0])||null;const r=this.getValues();this.maxValue=Math.max(...r)},formattedValue(r){return ee(r)}}},Cl={key:0,class:"flex flex-col h-full pt-[16px] rounded-xl"},Dl={class:"h-full pt-0 pb-6 space-y-4"},Nl={class:"h-full space-y-4 custom-scrollbar"},Sl={class:"flex items-center justify-between mr-2 gap-x-2"},zl={class:"grid items-center w-full grid-cols-2 gap-x-2"},Ll={class:"text-sm text-gray-800"},Tl={class:"flex justify-end",role:"progressbar","aria-valuenow":"100","aria-valuemin":"0","aria-valuemax":"100"},Il={class:"min-w-[60px] text-end"},Ml={class:"text-sm text-gray-500"};function Pl(r,t,n,s,o,l){return o.columns?(e.openBlock(),e.createElementBlock("div",Cl,[e.createElementVNode("div",Dl,[e.createElementVNode("ul",Nl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("li",Sl,[e.createElementVNode("div",zl,[e.createElementVNode("span",Ll,e.toDisplayString(a[o.columns[0]]),1),e.createElementVNode("div",Tl,[e.createElementVNode("div",{class:"h-1.5 flex flex-col justify-center overflow-hidden bg-indigo-500 rounded-full text-xs text-white text-center whitespace-nowrap",style:e.normalizeStyle({width:`${parseFloat(a[o.columns[1]])/o.maxValue*100}%`})},null,4)])]),e.createElementVNode("div",Il,[e.createElementVNode("span",Ml,e.toDisplayString(l.formattedValue(a[o.columns[1]])),1)])]))),256))])])])):e.createCommentVNode("",!0)}const At=W(Vl,[["render",Pl]]),Fl=Object.freeze(Object.defineProperty({__proto__:null,default:At},Symbol.toStringTag,{value:"Module"})),Rl={name:"VsListbar",mixins:[X],props:["source"],data(){return{restDimensions:[],maxValue:0,columns:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch(r){console.error(r)}},prepareData(){var t,n,s;this.columns=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{});const r=(n=this.sourceData)==null?void 0:n.map(o=>{var l;return o==null?void 0:o[(l=this.columns)==null?void 0:l[1]]});this.maxValue=Math.max(...r||[]),this.restDimensions=(s=this.columns)==null?void 0:s.filter((o,l)=>l!==0)},formattedValue(r){return ee(r)},getWidth(r){return`${r/this.maxValue*100}%`}}},jl={class:"h-full pt-[20px] list-bar flex flex-col min-h-0"},Wl={class:"space-y-2 custom-scrollbar flex-1 min-h-0 overflow-y-auto overflow-x-hidden"},vl={class:"relative w-full truncate"},Al={class:"relative z-[1] text-sm block py-1 px-2 w-full text-sm truncate text-gray-800"},Ol={class:"text-[14px] text-gray-500"};function ql(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",jl,[e.createElementVNode("ul",Wl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,(a,i)=>{var c,d,p;return e.openBlock(),e.createElementBlock("li",{key:i,class:"flex items-center justify-between w-full gap-x-2"},[e.createElementVNode("div",vl,[e.createElementVNode("span",Al,e.toDisplayString((a==null?void 0:a[(c=o.columns)==null?void 0:c[0]])||"Без категорії"),1),e.createElementVNode("div",{class:e.normalizeClass(["absolute inset-y-0 h-full rounded start-0",a!=null&&a[(d=o.columns)==null?void 0:d[0]]?"bg-indigo-100":"bg-gray-100"]),style:e.normalizeStyle({width:l.getWidth(a==null?void 0:a[(p=o.columns)==null?void 0:p[1]])})},null,6)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.restDimensions,(h,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:"w-20 mr-2 text-end"},[e.createElementVNode("span",Ol,e.toDisplayString(l.formattedValue(a==null?void 0:a[h])),1)]))),128))])}),128))])])}const Ot=W(Rl,[["render",ql]]),Ul=Object.freeze(Object.defineProperty({__proto__:null,default:Ot},Symbol.toStringTag,{value:"Module"})),Hl={name:"VsPivotTable",mixins:[X],data(){return{values:null,xs:null,products:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){try{const r=Array.from(new Set(this.sourceData.map(t=>t[this.dimensions[0]])));this.dimensions[0].includes("date")?this.xs=r.map(t=>me(t)):this.xs=[...r],this.products=this.dimensions.filter((t,n)=>n!=0),this.values=this.products.map((t,n)=>({name:t,data:this.sourceData.filter(s=>parseFloat(s[t])).map(s=>ee(parseFloat(s[t])))}))}catch(r){console.error(r)}}}},Gl={class:"flex flex-col h-full p-5 space-y-4 rounded-xl custom-scrollbar"},Zl={class:"overflow-x-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 custom-scrollbar"},Ql={class:"inline-block min-w-full align-middle"},Jl={class:"min-w-full divide-y divide-gray-200"},Xl={class:"space-x-2"},Kl={scope:"col",class:"xl:min-w-[120px] min-w-48"},Yl={class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"},ei={class:"divide-y divide-gray-200 text-[12px]"},ti={class:"py-3 size-px whitespace-nowrap"},ri={class:"flex items-center gap-x-3"},ni={class:"font-medium text-gray-800"},si={class:"py-3 size-px whitespace-nowrap"},oi={class:"text-gray-600"};function ai(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",Gl,[e.createElementVNode("div",Zl,[e.createElementVNode("div",Ql,[e.createElementVNode("table",Jl,[e.createElementVNode("thead",null,[e.createElementVNode("tr",Xl,[t[0]||(t[0]=e.createElementVNode("th",{scope:"col",class:"min-w-[200px]"},[e.createElementVNode("div",{class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"})],-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,a=>(e.openBlock(),e.createElementBlock("th",Kl,[e.createElementVNode("div",Yl,e.toDisplayString(a),1)]))),256))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.values,a=>(e.openBlock(),e.createElementBlock("tbody",ei,[e.createElementVNode("tr",null,[e.createElementVNode("td",ti,[e.createElementVNode("div",ri,[e.createElementVNode("span",ni,e.toDisplayString(a.name),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,(i,c)=>(e.openBlock(),e.createElementBlock("td",si,[e.createElementVNode("span",oi,e.toDisplayString(a.data[c]),1)]))),256))])]))),256))])])])])}const qt=W(Hl,[["render",ai]]),li=Object.freeze(Object.defineProperty({__proto__:null,default:qt},Symbol.toStringTag,{value:"Module"})),ii={name:"VsNumber",mixins:[X],data(){return{number:""}},computed:{formattedNumber(){return Hr(this.number)},prefix(){var r,t;return(r=this.styleData)!=null&&r.prefix?(t=this.styleData)==null?void 0:t.prefix:""}},watch:{sourceData:{async handler(){this.getNumber()},deep:!0}},async mounted(){await this.getData(),this.getNumber()},methods:{onChangedData(){try{this.sourceData&&this.getNumber()}catch(r){console.error(r)}},async getNumber(){var r,t;try{this.number=((t=this.sourceData[0])==null?void 0:t[Object.keys((r=this.sourceData)==null?void 0:r[0])])||0}catch(n){console.error(n)}}}},ci={class:"text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center"};function di(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",ci,e.toDisplayString(l.prefix)+e.toDisplayString(l.formattedNumber),1)}const pi=Object.freeze(Object.defineProperty({__proto__:null,default:W(ii,[["render",di]])},Symbol.toStringTag,{value:"Module"})),hi={name:"VsText",mixins:[X],props:{widget:{type:String,required:!0},widgetData:{type:Object,required:!0}},data(){return{markedText:null,uniqueID:null}},async mounted(){var r,t;this.uniqueID=this.widget;try{await this.getData(),this.markedText=R(((r=this.widgetData)==null?void 0:r.text)||((t=this.widgetData)==null?void 0:t.source))}catch(n){console.error(n)}},methods:{onChangedData(){return null}}},ui=["id"],mi=["innerHTML"];function fi(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,class:"relative select-auto h-full rounded-xl text-[12px] box-border bg-white custom-scrollbar text-widget"},[o.markedText?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:o.markedText},null,8,mi)):e.createCommentVNode("",!0)],8,ui)}const gi=Object.freeze(Object.defineProperty({__proto__:null,default:W(hi,[["render",fi]])},Symbol.toStringTag,{value:"Module"})),Ze=typeof window<"u"?window.echarts:null,bi={name:"VsFunnelBar",mixins:[X],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:r}=this.prepareData();r&&this.initChart(r)},methods:{buildTooltipForDonut(r,t){const{name:n,value:s,percent:o}=r;return`
214
+ ${s==null?void 0:s.replace("null","Не визначено")}: ${ee(n)} (${o}%)
215
+ </div>`},prepareData(){var r,t,s,n,o;try{this.styleData=this.styleData||{};const a=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[0]]))),l=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[1]]))),i=parseInt((this.sourceData||[]).reduce((f,u)=>f+parseFloat(u==null?void 0:u.metric),0),10),c=a.map((f,u)=>{const y=(l[u]/i*100).toFixed(2);return{name:`${f} (${y}%)`,value:l[u]}}),d=((r=this.styleData)==null?void 0:r.innerRadius)||"0%",p=((t=this.styleData)==null?void 0:t.outerRadius)||"100%",h=[d,p];return this.styleData.legend=Le.getLegendOpions({borderRadius:10,height:"100%",padding:10,type:"scroll",itemWidth:14,itemHeight:14,formatter:f=>f==null?void 0:f.replace("null","Не визначено"),textStyle:{fontSize:"14px"},...((s=this.styleData)==null?void 0:s.legend)||{}}),this.styleData.label=Le.getLabelOptions((n=this.styleData)==null?void 0:n.label),this.styleData.show_legend=((o=this.styleData)==null?void 0:o.show_legend)??!0,{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"pie",radius:h,center:["50%","60%"],height:"75%",...de(this.styleData),data:c}]}}catch(a){return console.error("Error in prepareData:",a),null}},async initChart(r){var t,s;try{if(!r){console.warn("No series data available for chart initialization");return}const n=this.$refs.chart;if(!n){console.warn("Chart DOM element not found");return}if(this.chartInstance=Ge==null?void 0:Ge.init(n),!this.chartInstance)return;const o={tooltip:{show:((s=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:s.show)!==!1,trigger:"item",confine:!0,formatter:a=>this.buildTooltipForDonut(a,[a.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:r,...de(this.styleData||{})};this.chartInstance.setOption(o),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var a;(a=this.chartInstance)==null||a.resize()})}catch(n){console.error("Error in initChart:",n)}}}},nl=["id"];function ol(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",{id:a.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,nl)}const Rt=W(sl,[["render",ol]]),al=Object.freeze(Object.defineProperty({__proto__:null,default:Rt},Symbol.toStringTag,{value:"Module"})),ll={name:"VsLine",mixins:[X],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:r,xs:t}=this.prepareData();r&&this.initChart(r,t)},methods:{onChangedData(){try{if(this.sourceData){const{series:r,xs:t,ys:s}=this.prepareData();r&&(this==null||this.initChart(r,t,s))}}catch(r){console.error(r)}},prepareData(){var r,t;try{const s=Array.from(new Set(this.sourceData.map(l=>l[this.dimensions[0]])));let n;this.dimensions[0].includes("date")?n=s.map(l=>me(l)):n=[...s];const o=this.sourceData.map(l=>parseFloat(l[this.dimensions[1]]));let a;return(r=this.styleData)!=null&&r.stack?a=this.dimensions.slice(1).map(i=>({name:i,type:"line",stack:"a",areaStyle:this.styleData.area?{}:null,data:this.sourceData.filter(c=>parseFloat(c[i])).map(c=>parseFloat(c[i]))})):a=[{name:this.title,type:"line",areaStyle:(t=this.styleData)!=null&&t.area?{}:null,data:o,stack:"a"}],{series:a,xs:n}}catch(s){return console.error(s),null}}}},il=["id"];function cl(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,ref:"chart",style:{height:"400px"}},null,8,il)}const Wt=W(ll,[["render",cl]]),dl=Object.freeze(Object.defineProperty({__proto__:null,default:Wt},Symbol.toStringTag,{value:"Module"})),pl={name:"VsStat",mixins:[X],data(){return{restDimensions:[],sumValue:0,columns:null,showTooltip:-1}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){this.columns=Object.keys(this.sourceData[0]);const r=this.getValues();this.sumValue=r.reduce((t,s)=>t+s,0),this.sourceData.forEach((t,s)=>{t.color=s<Ft.length-1?Ft[s]:Za()})},formattedValue(r){const t=parseFloat(r);return ee(t)}}},hl={class:"flex flex-col w-full h-full pt-[16px] rounded-xl"},ul={class:"flex flex-col justify-between w-full h-full"},ml={class:"w-full h-full pb-6 space-y-4"},fl={class:"flex w-full h-3 rounded-full gap-x-1 min-h-3 custom-x-scrollbar"},gl=["onMouseover"],bl={key:0,class:"absolute top-[-1] left-1/2 transform -translate-x-1/2 -translate-y-full bg-black text-white rounded px-2 py-1"},yl={class:"h-[calc(100%-40px)] w-full custom-scrollbar"},xl={class:"grid items-center justify-between grid-cols-2 py-2 gap-x-4"},kl={class:"flex items-center"},wl={class:"text-sm text-gray-800"},_l={class:"text-end"},$l={class:"text-sm text-gray-500"};function El(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",hl,[e.createElementVNode("div",ul,[e.createElementVNode("div",ml,[e.createElementVNode("div",fl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,(l,i)=>{var c,d,p,h;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex flex-col min-w-[5px] justify-center min-h-2.5 h-2.5 text-xs text-white text-center whitespace-nowrap",`bg-[${l.color}]`]),style:e.normalizeStyle({width:`${parseFloat(l==null?void 0:l[(c=o.columns)==null?void 0:c[1]])/o.sumValue*100}%`}),role:"progressbar","aria-valuenow":"42","aria-valuemin":"0","aria-valuemax":"100",onMouseover:m=>o.showTooltip=i,onMouseleave:t[0]||(t[0]=m=>o.showTooltip=-1)},[o.showTooltip>-1?(e.openBlock(),e.createElementBlock("div",bl,e.toDisplayString(r.sourceData[o.showTooltip][o.columns[0]])+" "+e.toDisplayString((parseFloat((h=(d=r.sourceData)==null?void 0:d[o.showTooltip])==null?void 0:h[(p=o.columns)==null?void 0:p[1]])/o.sumValue*100).toFixed(2))+"% ",1)):e.createCommentVNode("",!0)],46,gl)}),256))]),e.createElementVNode("ul",yl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,l=>{var i,c;return e.openBlock(),e.createElementBlock("li",xl,[e.createElementVNode("div",kl,[e.createElementVNode("span",{class:e.normalizeClass(["shrink-0 size-2.5 inline-block rounded-sm me-2.5 min-w-[10px] w-[10px] h-[10px] min-h-[10px]",`bg-[${l.color}]`])},null,2),e.createElementVNode("span",wl,e.toDisplayString((l==null?void 0:l[(i=o.columns)==null?void 0:i[0]])||"Не визначено"),1)]),e.createElementVNode("div",_l,[e.createElementVNode("span",$l,e.toDisplayString(a.formattedValue(l==null?void 0:l[(c=o.columns)==null?void 0:c[1]])||"-"),1)])])}),256))])])])])}const vt=W(pl,[["render",El]]),Bl=Object.freeze(Object.defineProperty({__proto__:null,default:vt},Symbol.toStringTag,{value:"Module"})),Dl={name:"VsProgressBar",mixins:[X],data(){return{restDimensions:[],maxValue:0,columns:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){var t;this.columns=Object.keys((t=this.sourceData)==null?void 0:t[0])||null;const r=this.getValues();this.maxValue=Math.max(...r)},formattedValue(r){return ee(r)}}},Vl={key:0,class:"flex flex-col h-full pt-[16px] rounded-xl"},Cl={class:"h-full pt-0 pb-6 space-y-4"},Nl={class:"h-full space-y-4 custom-scrollbar"},Sl={class:"flex items-center justify-between mr-2 gap-x-2"},zl={class:"grid items-center w-full grid-cols-2 gap-x-2"},Ll={class:"text-sm text-gray-800"},Il={class:"flex justify-end",role:"progressbar","aria-valuenow":"100","aria-valuemin":"0","aria-valuemax":"100"},Tl={class:"min-w-[60px] text-end"},Ml={class:"text-sm text-gray-500"};function Pl(r,t,s,n,o,a){return o.columns?(e.openBlock(),e.createElementBlock("div",Vl,[e.createElementVNode("div",Cl,[e.createElementVNode("ul",Nl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,(l,i)=>(e.openBlock(),e.createElementBlock("li",Sl,[e.createElementVNode("div",zl,[e.createElementVNode("span",Ll,e.toDisplayString(l[o.columns[0]]),1),e.createElementVNode("div",Il,[e.createElementVNode("div",{class:"h-1.5 flex flex-col justify-center overflow-hidden bg-indigo-500 rounded-full text-xs text-white text-center whitespace-nowrap",style:e.normalizeStyle({width:`${parseFloat(l[o.columns[1]])/o.maxValue*100}%`})},null,4)])]),e.createElementVNode("div",Tl,[e.createElementVNode("span",Ml,e.toDisplayString(a.formattedValue(l[o.columns[1]])),1)])]))),256))])])])):e.createCommentVNode("",!0)}const At=W(Dl,[["render",Pl]]),Fl=Object.freeze(Object.defineProperty({__proto__:null,default:At},Symbol.toStringTag,{value:"Module"})),jl={name:"VsListbar",mixins:[X],props:["source"],data(){return{restDimensions:[],maxValue:0,columns:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch(r){console.error(r)}},prepareData(){var t,s,n;this.columns=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{});const r=(s=this.sourceData)==null?void 0:s.map(o=>{var a;return o==null?void 0:o[(a=this.columns)==null?void 0:a[1]]});this.maxValue=Math.max(...r||[]),this.restDimensions=(n=this.columns)==null?void 0:n.filter((o,a)=>a!==0)},formattedValue(r){return ee(r)},getWidth(r){return`${r/this.maxValue*100}%`}}},Rl={class:"h-full pt-[20px] list-bar flex flex-col min-h-0"},Wl={class:"space-y-2 custom-scrollbar flex-1 min-h-0 overflow-y-auto overflow-x-hidden"},vl={class:"relative w-full truncate"},Al={class:"relative z-[1] text-sm block py-1 px-2 w-full text-sm truncate text-gray-800"},Ol={class:"text-[14px] text-gray-500"};function ql(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",Rl,[e.createElementVNode("ul",Wl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,(l,i)=>{var c,d,p;return e.openBlock(),e.createElementBlock("li",{key:i,class:"flex items-center justify-between w-full gap-x-2"},[e.createElementVNode("div",vl,[e.createElementVNode("span",Al,e.toDisplayString((l==null?void 0:l[(c=o.columns)==null?void 0:c[0]])||"Без категорії"),1),e.createElementVNode("div",{class:e.normalizeClass(["absolute inset-y-0 h-full rounded start-0",l!=null&&l[(d=o.columns)==null?void 0:d[0]]?"bg-indigo-100":"bg-gray-100"]),style:e.normalizeStyle({width:a.getWidth(l==null?void 0:l[(p=o.columns)==null?void 0:p[1]])})},null,6)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.restDimensions,(h,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:"w-20 mr-2 text-end"},[e.createElementVNode("span",Ol,e.toDisplayString(a.formattedValue(l==null?void 0:l[h])),1)]))),128))])}),128))])])}const Ot=W(jl,[["render",ql]]),Ul=Object.freeze(Object.defineProperty({__proto__:null,default:Ot},Symbol.toStringTag,{value:"Module"})),Hl={name:"VsPivotTable",mixins:[X],data(){return{values:null,xs:null,products:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){try{const r=Array.from(new Set(this.sourceData.map(t=>t[this.dimensions[0]])));this.dimensions[0].includes("date")?this.xs=r.map(t=>me(t)):this.xs=[...r],this.products=this.dimensions.filter((t,s)=>s!=0),this.values=this.products.map((t,s)=>({name:t,data:this.sourceData.filter(n=>parseFloat(n[t])).map(n=>ee(parseFloat(n[t])))}))}catch(r){console.error(r)}}}},Gl={class:"flex flex-col h-full p-5 space-y-4 rounded-xl custom-scrollbar"},Zl={class:"overflow-x-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 custom-scrollbar"},Ql={class:"inline-block min-w-full align-middle"},Jl={class:"min-w-full divide-y divide-gray-200"},Xl={class:"space-x-2"},Kl={scope:"col",class:"xl:min-w-[120px] min-w-48"},Yl={class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"},ei={class:"divide-y divide-gray-200 text-[12px]"},ti={class:"py-3 size-px whitespace-nowrap"},ri={class:"flex items-center gap-x-3"},si={class:"font-medium text-gray-800"},ni={class:"py-3 size-px whitespace-nowrap"},oi={class:"text-gray-600"};function ai(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",Gl,[e.createElementVNode("div",Zl,[e.createElementVNode("div",Ql,[e.createElementVNode("table",Jl,[e.createElementVNode("thead",null,[e.createElementVNode("tr",Xl,[t[0]||(t[0]=e.createElementVNode("th",{scope:"col",class:"min-w-[200px]"},[e.createElementVNode("div",{class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"})],-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,l=>(e.openBlock(),e.createElementBlock("th",Kl,[e.createElementVNode("div",Yl,e.toDisplayString(l),1)]))),256))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.values,l=>(e.openBlock(),e.createElementBlock("tbody",ei,[e.createElementVNode("tr",null,[e.createElementVNode("td",ti,[e.createElementVNode("div",ri,[e.createElementVNode("span",si,e.toDisplayString(l.name),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,(i,c)=>(e.openBlock(),e.createElementBlock("td",ni,[e.createElementVNode("span",oi,e.toDisplayString(l.data[c]),1)]))),256))])]))),256))])])])])}const qt=W(Hl,[["render",ai]]),li=Object.freeze(Object.defineProperty({__proto__:null,default:qt},Symbol.toStringTag,{value:"Module"})),ii={name:"VsNumber",mixins:[X],data(){return{number:""}},computed:{formattedNumber(){return Hr(this.number)},prefix(){var r,t;return(r=this.styleData)!=null&&r.prefix?(t=this.styleData)==null?void 0:t.prefix:""}},watch:{sourceData:{async handler(){this.getNumber()},deep:!0}},async mounted(){await this.getData(),this.getNumber()},methods:{onChangedData(){try{this.sourceData&&this.getNumber()}catch(r){console.error(r)}},async getNumber(){var r,t;try{this.number=((t=this.sourceData[0])==null?void 0:t[Object.keys((r=this.sourceData)==null?void 0:r[0])])||0}catch(s){console.error(s)}}}},ci={class:"text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center"};function di(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",ci,e.toDisplayString(a.prefix)+e.toDisplayString(a.formattedNumber),1)}const pi=Object.freeze(Object.defineProperty({__proto__:null,default:W(ii,[["render",di]])},Symbol.toStringTag,{value:"Module"})),hi={name:"VsText",mixins:[X],props:{widget:{type:String,required:!0},widgetData:{type:Object,required:!0}},data(){return{markedText:null,uniqueID:null}},async mounted(){var r,t;this.uniqueID=this.widget;try{await this.getData(),this.markedText=j(((r=this.widgetData)==null?void 0:r.text)||((t=this.widgetData)==null?void 0:t.source))}catch(s){console.error(s)}},methods:{onChangedData(){return null}}},ui=["id"],mi=["innerHTML"];function fi(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,class:"relative select-auto h-full rounded-xl text-[12px] box-border bg-white custom-scrollbar text-widget"},[o.markedText?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:o.markedText},null,8,mi)):e.createCommentVNode("",!0)],8,ui)}const gi=Object.freeze(Object.defineProperty({__proto__:null,default:W(hi,[["render",fi]])},Symbol.toStringTag,{value:"Module"})),Ze=typeof window<"u"?window.echarts:null,bi={name:"VsFunnelBar",mixins:[X],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:r}=this.prepareData();r&&this.initChart(r)},methods:{buildTooltipForDonut(r,t){const{name:s,value:n,percent:o}=r;return`
216
216
  <div style="background-color:${t[0]};font-size: 12px; font-family: Helvetica, Arial, sans-serif;color:#ffff; padding:5px; border-radius:5px; ![box-shadow:none]">
217
- ${me(n)}: ${ee(s)} (${o}%)
218
- </div>`},onChangedData(){try{if(this.sourceData){const{series:r,xs:t,ys:n}=this.prepareData();r&&(this==null||this.initChart(r,t,n))}}catch{}},prepareData(){try{const r=Array.from(new Set(this.sourceData.map(o=>o[this.dimensions[0]]))),t=Array.from(new Set(this.sourceData.map(o=>o[this.dimensions[1]]))),n=r.map((o,l)=>({name:o,value:t[l]}));return{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"funnel",...de(this.styleData),data:n,height:"80%",emphasis:{label:{show:!1}}}]}}catch(r){console.error(r)}},async initChart(r){var t,n;try{const s=this.$refs.chart,o=Ze==null?void 0:Ze.init(s);if(!o)return;const l={series:r,...de(this.styleData),tooltip:{show:((n=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:n.show)!==!1,trigger:"item",confine:!0,formatter:a=>this.buildTooltipForDonut(a,[a.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[10,15],shadowColor:"transparent",backgroundColor:"transparent"},itemStyle:{height:"15px"},legend:{borderRadius:10,type:"scroll",itemWidth:14,itemHeight:14,...this.styleData.legend},labelLine:{show:!1},grid:{bottom:"0"}};o.setOption(l),o.resize(),window.addEventListener("resize",()=>{o.resize()})}catch(s){console.error(s)}}}},yi=["id"];function xi(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",{ref:"chart",id:o.uniqueID,class:"h-[90%] custom-scrollbar min-h-[200px]"},null,8,yi)}const ki=Object.freeze(Object.defineProperty({__proto__:null,default:W(bi,[["render",xi]])},Symbol.toStringTag,{value:"Module"}));function wi(r){return[{type:"fill",paint:{"fill-color":r.color||"#ccc","fill-outline-color":r.color||"blue","fill-opacity":r.opacity||1}}]}function _i(r){return[{type:"line",paint:{"line-color":r.color||"#ccc","line-opacity":r.opacity||1}}]}function $i(r){return[{type:"circle",paint:{"circle-radius":r.radius||6,"circle-stroke-color":r.stroke||"#ccc","circle-stroke-width":r.width||1,"circle-color":r.color||"blue"}}]}function Ut(r){if(!r)return null;const t=r.type||"point";return t==="polygon"?wi(r):t==="line"?_i(r):$i(r)}const Qe={data(){return{layerList:[],activeLayer:""}},computed:{interactiveSources(){return this.layerList.filter(r=>r==null?void 0:r.interactive).map(r=>r.id)}},methods:{moveLayer(r,t=this.map){t.getStyle().layers.forEach(n=>{n.id.match(r)&&t.moveLayer(n.id)})},async setVisible(r,t=!0,n=this.map){if(!r)return;const s=(r==null?void 0:r.id)||r,o=this.layerList.find(a=>a.id===r)||r;if(!(o!=null&&o.id))throw new Error("MixinError: Layer has no id");const l=n.getStyle().layers.filter(a=>a.id.match(s));l.forEach(a=>{n.setLayoutProperty(a.id,"visibility",t?"visible":"none")}),!l.length&&t&&await this.addLayer(o)},async addLayer(r,t=this==null?void 0:this.map){var o,l;const n=this.layerList.find(a=>a.id===r)||r;!this.map.getStyle()||this.map.getStyle().layers.find(a=>a.id===n.id)||(this.layerList.find(a=>a.id===n.id)||this.layerList.push(n),(n.service==="vtile"||n.service==="vector"||(o=n.url)!=null&&o.includes(".vmt"))&&this.addVtileLayer(n,t),n.service==="geojson"&&this.addGeoJsonLayer(n,t),((l=n.url)!=null&&l.includes(".png")||["tms","raster"].includes(n.service))&&await this.addRasterLayer(n,t))},async addRasterLayer(r,t=this==null?void 0:this.map){var n,s;t.getSource(r.id)||(await t.addSource(r.id,{type:"raster",tiles:[r==null?void 0:r.url],tileSize:256,...r!=null&&r.scheme?{scheme:r==null?void 0:r.scheme}:{}}),await t.addLayer({id:r.id,type:"raster",source:r.id,minzoom:0,maxzoom:(r==null?void 0:r.maxzoom)||22},r.basemap?(s=(n=this.map.getStyle().layers)==null?void 0:n[0])==null?void 0:s.id:null))},async addVtileLayer(r,t=this==null?void 0:this.map){var l;const n=["props","pointZoom"].filter(a=>r[a]).map(a=>`&${a}=${r[a]}`),s={type:"vector",tiles:[`${(l=r==null?void 0:r.url)!=null&&l.startsWith("http")?"":window.location.origin}${r==null?void 0:r.url}${n}`],minzoom:r.minzoom||3,maxzoom:r.maxzoom||24};t.addSource(r.id,s),(Ut(r.style)||r.layers||[]).forEach((a,i)=>{const c={...a,id:`${r.id}-${i}`,source:r.id,"source-layer":a["source-layer"]||r.source||r.id,maxzoom:+a.maxzoom||24,minzoom:+a.minzoom||0};t.addLayer(c)})},async addGeoJsonLayer(r,t=this.map){var o;const n=r.data||((o=r==null?void 0:r.url)!=null&&o.startsWith("http")?"":window.location.origin)+r.url;t.addSource(r.id,{type:"geojson",data:n}),(Ut(r.style)||r.layers||[]).forEach(l=>{const a={...l,source:r.id,id:l.id||r.id,maxzoom:+l.maxzoom||24,minzoom:+l.minzoom||0,type:l.type||"circle"};t.addLayer(a)})},setLayerData(r,t){this.layerList=this.layerList.map(n=>n.id===r?{...n,...t}:n)},async removeLayer(r,t=this.map){t.getSource(r)&&(await t.getStyle().layers.forEach(async n=>{n.source===r&&await t.removeLayer(n.id)}),await t.removeSource(r))},async setFilter(r,t){var o;const n=this.layerList.find(l=>l.id===r),s=await((o=this.map)==null?void 0:o.getSource(r));if(s&&n.service==="vtile"){await s.setTiles([`${window.location.origin}${n.url}${n.url.includes("?")?"&":"?"}filter=${t}${n.props?`&props=${n.props}`:""}`]);return}s&&n.service},async changeBaseLayer(r){const t=r!=null&&r.id?r:this.layerList.find(s=>s.id===r),{id:n}=t;if(n&&n!==this.activeLayer){if(this.activeLayer&&this.map.setLayoutProperty(this.activeLayer,"visibility","none"),this.activeLayer=n,this.map.getLayer(n)){this.map.setLayoutProperty(n,"visibility","visible");return}await this.addRasterLayer(t)}},async refreshLayer(r,t=this.map){await t.getStyle().layers.forEach(n=>{n.source===r&&t.removeLayer(n.id)}),await t.removeSource(r),this.setVisible(r)}}},Ei="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.js",Bi="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.css";let Te=null;function Vi(r){return new Promise((t,n)=>{if(document.querySelector(`script[src="${r}"]`)){t();return}const s=document.createElement("script");s.src=r,s.onload=()=>t(),s.onerror=()=>n(new Error(`Failed to load ${r}`)),document.head.appendChild(s)})}function Ci(r){return new Promise((t,n)=>{if(document.querySelector(`link[href="${r}"]`)){t();return}const s=document.createElement("link");s.rel="stylesheet",s.href=r,s.onload=()=>t(),s.onerror=()=>n(new Error(`Failed to load ${r}`)),document.head.appendChild(s)})}function Ht(){return typeof window>"u"?Promise.resolve(null):window.maplibregl?Promise.resolve(window.maplibregl):Te||(Te=Ci(Bi).then(()=>Vi(Ei)).then(()=>window.maplibregl),Te)}const Je={__name:"legend",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(Dr),e.mergeProps(t.$attrs,{size:24}),null,16))}},Xe={pink:["#fde7e2","#feafbe","#fd58a4","#d7038e","#86007b"],blue:["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"],green:["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"],pink2:["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"],red:["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"],teal:["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"]},Di={components:{legendIcon:Je,closeIcon:Pe},props:{mapId:{type:String},colors:{type:Array},sizes:{type:Array,default:()=>[]},cluster:{type:[Boolean,String]},color:{type:String,default:"gray"},colorTitle:{type:String},sizesTitle:{type:String},resizeItem:{type:[Boolean,String],default:!1},changeOpacityItem:{type:[Boolean,String],default:!1}},data(){return{isOpenLegend:!1,palette:Xe}},computed:{borderRadius(){return this.cluster?"rounded-sm":"rounded-full"},sortedSizes(){return[...this.sizes].sort((r,t)=>r-t)},maxWidht(){var n;const r=((n=this.sizes)==null?void 0:n.length)-1;return this.calcSize(r)}},methods:{sizeClass(r){return this.resizeItem?`h-[${this.calcSize(r)}] w-[${this.calcSize(r)}] ${this.borderRadius}`:`h-[18px] w-[18px] ${this.borderRadius}`},calcSize(r){return`${10+r*2}px`},getOpacity(r){return(r+1)/this.sortedSizes.length}}},Ni={class:"w-full absolute max-w-[200px] bg-white border rounded-lg bottom-[10px] right-[50px]"},Si={class:"flex items-center justify-between border-b border-[#0000001A] px-2"},zi={class:"w-full flex flex-col gap-[8px] px-2 py-2 max-h-[200px] overflow-auto [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent"},Li={key:0,class:"flex flex-col w-full"},Ti={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},Ii={class:"flex flex-col gap-[6px]"},Mi={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"},Pi={key:1,class:"flex flex-col w-full"},Fi={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},Ri={class:"flex flex-col gap-[6px]"},ji={class:"flex flex-row items-center justify-start"},Wi={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"};function vi(r,t,n,s,o,l){var c,d;const a=e.resolveComponent("legendIcon"),i=e.resolveComponent("closeIcon");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]",onClick:t[0]||(t[0]=p=>o.isOpenLegend=!o.isOpenLegend)},[e.createVNode(a)]),o.isOpenLegend?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:`#wrapper-${n.mapId}`},[e.createElementVNode("div",Ni,[e.createElementVNode("div",Si,[t[2]||(t[2]=e.createElementVNode("h3",{class:"text-[16px] font-normal text-black"},"Легенда",-1)),e.createElementVNode("button",{type:"button",class:"inline-flex items-center text-sm font-medium text-gray-500 rounded-lg gap-x-2 focus:outline-none disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 dark:hover:text-blue-500 dark:focus:text-blue-500",onClick:t[1]||(t[1]=p=>o.isOpenLegend=!1)},[e.createVNode(i,{class:"w-[20px]"})])]),e.createElementVNode("div",zi,[(c=n.colors)!=null&&c.length?(e.openBlock(),e.createElementBlock("div",Li,[n.colorTitle?(e.openBlock(),e.createElementBlock("h4",Ti,e.toDisplayString(n.colorTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ii,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.colors,(p,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:"flex items-center gap-[10px]"},[p.color?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-[12px] h-[12px] rounded-full",style:e.normalizeStyle({backgroundColor:p.color})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("p",Mi,e.toDisplayString(p.text||p.val),1)]))),128))])])):e.createCommentVNode("",!0),(d=n.sizes)!=null&&d.length?(e.openBlock(),e.createElementBlock("div",Pi,[r.sizeTitle?(e.openBlock(),e.createElementBlock("h4",Fi,e.toDisplayString(r.sizeTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ri,[l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(p,h)=>{var m,f,u,y,b;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",ji,[e.createElementVNode("div",{class:e.normalizeClass([l.maxWidht?`w-[${l.maxWidht}]`:"","mr-[10px]"])},[e.createElementVNode("div",{class:e.normalizeClass(l.sizeClass(h)),style:e.normalizeStyle({backgroundColor:((f=(m=o.palette)==null?void 0:m[n.color])==null?void 0:f[h])||n.color})},null,6)],2),e.createElementVNode("p",Wi,e.toDisplayString(h===((u=l.sortedSizes)==null?void 0:u.length)-1?">"+p:h==((y=l.sortedSizes)==null?void 0:y.length)-1?">"+l.sortedSizes[((b=l.sortedSizes)==null?void 0:b.length)-1]:p+"-"+l.sortedSizes[h+1]),1)])])}),256)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])])],8,["to"])):e.createCommentVNode("",!0)],64)}const Ai=W(Di,[["render",vi]]),Oi={props:["map","coordinates"],data(){return{isMenuVisible:!1}},computed:{getCoordinates(){var t;return!(this!=null&&this.coordinates)||((t=this.coordinates)==null?void 0:t.length)!==2?"":(this==null?void 0:this.coordinates).slice().reverse().map(n=>Number(n).toFixed(5)).join(", ")}}},qi={class:"map__settings"},Ui={ref:"attribution",class:"map__settings-attribution map__settings-item mt-[3px]"};function Hi(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",qi,[e.createElementVNode("div",Ui,[e.withDirectives(e.createElementVNode("div",{ref:"mouse",class:"map__settings-item",style:{"min-width":"115px"}},e.toDisplayString(l.getCoordinates),513),[[e.vShow,l.getCoordinates]])],512)])}const Gt=W(Oi,[["render",Hi]]),Gi={mixins:[Qe],props:{map:{type:Object,default:()=>null}},data(){return{baseLayers:[{id:"orto10",name:"Ortophoto 1:10К",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",service:"TMS",image:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4954/2876.png"},{id:"graymap",name:"Сіра карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",service:"TMS",image:"https://data.gki.com.ua/api-user/rtile/positron/ua/10/601/348.png"}]}},watch:{map(r){r&&r.on("load",this.handleMapLoad)}},created(){this.baseLayers.forEach(r=>{const t={...r,basemap:!0};this.layerList.push(t)})},methods:{handleMapLoad(){this.changeBaseLayer("graymap")},isLayerInFocus(r){return r.id===this.activeLayer}}},Zi={class:"vs-map-slot-layers"},Qi=["onClick"],Ji=["src"];function Xi(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",Zi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.baseLayers,a=>(e.openBlock(),e.createElementBlock("div",{key:a.id,class:e.normalizeClass(["vs-map-slot-layers__layer",{focused:l.isLayerInFocus(a)}]),onClick:i=>r.changeBaseLayer(a.id)},[e.createElementVNode("img",{src:a.image,class:"vs-map-slot-layers__image"},null,8,Ji)],10,Qi))),128))])}const Zt=W(Gi,[["render",Xi]]);function Qt(r,t,n){if(r!==null)for(var s,o,l,a,i,c,d,p=0,h=0,m,f=r.type,u=f==="FeatureCollection",y=f==="Feature",b=u?r.features.length:1,$=0;$<b;$++){d=u?r.features[$].geometry:y?r.geometry:r,m=d?d.type==="GeometryCollection":!1,i=m?d.geometries.length:1;for(var w=0;w<i;w++){var x=0,D=0;if(a=m?d.geometries[w]:d,a!==null){c=a.coordinates;var L=a.type;switch(p=0,L){case null:break;case"Point":if(t(c,h,$,x,D)===!1)return!1;h++,x++;break;case"LineString":case"MultiPoint":for(s=0;s<c.length;s++){if(t(c[s],h,$,x,D)===!1)return!1;h++,L==="MultiPoint"&&x++}L==="LineString"&&x++;break;case"Polygon":case"MultiLineString":for(s=0;s<c.length;s++){for(o=0;o<c[s].length-p;o++){if(t(c[s][o],h,$,x,D)===!1)return!1;h++}L==="MultiLineString"&&x++,L==="Polygon"&&D++}L==="Polygon"&&x++;break;case"MultiPolygon":for(s=0;s<c.length;s++){for(D=0,o=0;o<c[s].length;o++){for(l=0;l<c[s][o].length-p;l++){if(t(c[s][o][l],h,$,x,D)===!1)return!1;h++}D++}x++}break;case"GeometryCollection":for(s=0;s<a.geometries.length;s++)if(Qt(a.geometries[s],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Ki(r,t={}){if(r.bbox!=null&&t.recompute!==!0)return r.bbox;const n=[1/0,1/0,-1/0,-1/0];return Qt(r,s=>{n[0]>s[0]&&(n[0]=s[0]),n[1]>s[1]&&(n[1]=s[1]),n[2]<s[0]&&(n[2]=s[0]),n[3]<s[1]&&(n[3]=s[1])}),n}const Yi={props:["bbox","map"],components:{homeIcon:{__name:"home",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(Br),e.mergeProps(t.$attrs,{size:24}),null,16))}}},methods:{setBounds(){const r={type:"Feature",geometry:this==null?void 0:this.bbox},t=Ki(r);this.map.fitBounds(t)}}},ec={class:"z-100 flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]"};function tc(r,t,n,s,o,l){const a=e.resolveComponent("homeIcon");return e.openBlock(),e.createElementBlock("div",ec,[e.createVNode(a,{onClick:l.setBounds},null,8,["onClick"])])}const Jt=W(Yi,[["render",tc]]),rc={components:{legendIcon:Je,menuIcon:{__name:"menu",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(Er),e.mergeProps(t.$attrs,{size:24}),null,16))}},closeIcon:Pe},props:["source","count","total","mapId"],data(){return{isOpenLegend:!1,palette:["#69D2E7","yellow","#FE4365"]}},methods:{calcSize(r){return r/this.maxValue*100*50/100}},computed:{maxValue(){var r,t,n,s,o,l;return((r=this.sizes)==null?void 0:r[0])>((n=this.sizes)==null?void 0:n[((t=this.sizes)==null?void 0:t.length)-1])?(s=this.sizes)==null?void 0:s[0]:(l=this.sizes)==null?void 0:l[((o=this.sizes)==null?void 0:o.length)-1]}}},nc={class:"w-full h-[calc(100%-40px)] bg-white"},sc={class:"w-full flex flex-col gap-[8px] h-[250px] overflow-auto [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent text-xs"},oc={class:"relative min-w-full bg-white text-[12px]"},ac={class:"divide-gray-200 dark:divide-neutral-700"},lc={class:"px-2 py-1"},ic={class:"px-2 py-1"};function cc(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",nc,[e.createElementVNode("div",sc,[e.createElementVNode("table",oc,[t[0]||(t[0]=e.createElementVNode("thead",{class:"sticky top-[-1px] z-[1] bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},[e.createElementVNode("tr",null,[e.createElementVNode("th",{class:"px-2 py-1 text-start"},"Назва"),e.createElementVNode("th",{class:"px-2 py-1 text-start"},"Метрика")])],-1)),e.createElementVNode("tbody",ac,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.source,a=>(e.openBlock(),e.createElementBlock("tr",{key:a.id,class:"border-b cursor-pointer hover:bg-gray-100 odd:bg-gray-50"},[e.createElementVNode("td",lc,e.toDisplayString(a.title||"—"),1),e.createElementVNode("td",ic,e.toDisplayString(a.metric),1)]))),128))])])])])}const Xt=W(rc,[["render",cc]]),dc={mixins:[X,Qe,{components:{VsMapSetting:Gt,VsMapSlotLayers:Zt,VsMapLegend:Ai,VsMapGoHome:Jt,VsList:Xt},data(){return{mapId:`map-${Math.floor(Math.random()*1e3)}`,layerId:`layer${Math.floor(Math.random()*1e3)}`,map:null,hoverData:null,data:null,coordinatesByMouse:[],showSetting:!1,popup:null,color:"#69D2E7"}},methods:{async createMap(){var n,s;const r=await Ht();if(!r)return;const t={version:8,glyphs:"https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=await new r.Map({container:this.mapId,style:t,center:[31,48.5],zoom:((s=(n=this.data)==null?void 0:n.style)==null?void 0:s.zoom)||5,minZoom:3,maxZoom:20,attributionControl:!1}),this.map.addControl(new r.NavigationControl({visualizePitch:!0})),this.map.on("load",()=>{this.loadHandler()}),this.map.on("mousemove",o=>{this.moveMouseHadler(o)}),this.map.on("mouseout",()=>{var o;this.showLegend=!1,this.showSetting=!1,this.coordinatesByMouse=0,(o=this.popup)==null||o.remove()})},getPopoverTitle(r){var t,n,s,o,l;return(n=(t=this.data)==null?void 0:t.colors)!=null&&n.find(a=>a.val===r)?(l=(o=(s=this.data)==null?void 0:s.colors)==null?void 0:o.find(a=>a.val===r))==null?void 0:l.text:r},moveMouseHadler(r){var t;try{const n=this.map.queryRenderedFeatures(r.point),s=((t=n[0])==null?void 0:t.properties)||{};if(!n.length){this.map.getCanvas().style.cursor="",this.popupElement&&this.popupElement.remove();return}this.map.getCanvas().style.cursor="pointer",this.popupElement&&this.popupElement.remove(),this.popupElement=document.createElement("div"),this.popupElement.className="absolute text-gray-800 border border-gray-200 rounded-lg shadow-md min-w-28",this.popupElement.style.backgroundColor="rgba(255, 255, 255, 0.7)",this.popupElement.innerHTML=`<div class="font-semibold text-sm border-b border-solid border-gray-200 text-gray-800 rounded-t-lg px-2 py-1">
219
- ${this.getPopoverTitle((s==null?void 0:s.x)||(s==null?void 0:s.title)||(s==null?void 0:s.name))||""}
217
+ ${me(s)}: ${ee(n)} (${o}%)
218
+ </div>`},onChangedData(){try{if(this.sourceData){const{series:r,xs:t,ys:s}=this.prepareData();r&&(this==null||this.initChart(r,t,s))}}catch{}},prepareData(){try{const r=Array.from(new Set(this.sourceData.map(o=>o[this.dimensions[0]]))),t=Array.from(new Set(this.sourceData.map(o=>o[this.dimensions[1]]))),s=r.map((o,a)=>({name:o,value:t[a]}));return{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"funnel",...de(this.styleData),data:s,height:"80%",emphasis:{label:{show:!1}}}]}}catch(r){console.error(r)}},async initChart(r){var t,s;try{const n=this.$refs.chart,o=Ze==null?void 0:Ze.init(n);if(!o)return;const a={series:r,...de(this.styleData),tooltip:{show:((s=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:s.show)!==!1,trigger:"item",confine:!0,formatter:l=>this.buildTooltipForDonut(l,[l.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[10,15],shadowColor:"transparent",backgroundColor:"transparent"},itemStyle:{height:"15px"},legend:{borderRadius:10,type:"scroll",itemWidth:14,itemHeight:14,...this.styleData.legend},labelLine:{show:!1},grid:{bottom:"0"}};o.setOption(a),o.resize(),window.addEventListener("resize",()=>{o.resize()})}catch(n){console.error(n)}}}},yi=["id"];function xi(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",{ref:"chart",id:o.uniqueID,class:"h-[90%] custom-scrollbar min-h-[200px]"},null,8,yi)}const ki=Object.freeze(Object.defineProperty({__proto__:null,default:W(bi,[["render",xi]])},Symbol.toStringTag,{value:"Module"}));function wi(r){return[{type:"fill",paint:{"fill-color":r.color||"#ccc","fill-outline-color":r.color||"blue","fill-opacity":r.opacity||1}}]}function _i(r){return[{type:"line",paint:{"line-color":r.color||"#ccc","line-opacity":r.opacity||1}}]}function $i(r){return[{type:"circle",paint:{"circle-radius":r.radius||6,"circle-stroke-color":r.stroke||"#ccc","circle-stroke-width":r.width||1,"circle-color":r.color||"blue"}}]}function Ut(r){if(!r)return null;const t=r.type||"point";return t==="polygon"?wi(r):t==="line"?_i(r):$i(r)}const Qe={data(){return{layerList:[],activeLayer:""}},computed:{interactiveSources(){return this.layerList.filter(r=>r==null?void 0:r.interactive).map(r=>r.id)}},methods:{moveLayer(r,t=this.map){t.getStyle().layers.forEach(s=>{s.id.match(r)&&t.moveLayer(s.id)})},async setVisible(r,t=!0,s=this.map){if(!r)return;const n=(r==null?void 0:r.id)||r,o=this.layerList.find(l=>l.id===r)||r;if(!(o!=null&&o.id))throw new Error("MixinError: Layer has no id");const a=s.getStyle().layers.filter(l=>l.id.match(n));a.forEach(l=>{s.setLayoutProperty(l.id,"visibility",t?"visible":"none")}),!a.length&&t&&await this.addLayer(o)},async addLayer(r,t=this==null?void 0:this.map){var o,a;const s=this.layerList.find(l=>l.id===r)||r;!this.map.getStyle()||this.map.getStyle().layers.find(l=>l.id===s.id)||(this.layerList.find(l=>l.id===s.id)||this.layerList.push(s),(s.service==="vtile"||s.service==="vector"||(o=s.url)!=null&&o.includes(".vmt"))&&this.addVtileLayer(s,t),s.service==="geojson"&&this.addGeoJsonLayer(s,t),((a=s.url)!=null&&a.includes(".png")||["tms","raster"].includes(s.service))&&await this.addRasterLayer(s,t))},async addRasterLayer(r,t=this==null?void 0:this.map){var s,n;t.getSource(r.id)||(await t.addSource(r.id,{type:"raster",tiles:[r==null?void 0:r.url],tileSize:256,...r!=null&&r.scheme?{scheme:r==null?void 0:r.scheme}:{}}),await t.addLayer({id:r.id,type:"raster",source:r.id,minzoom:0,maxzoom:(r==null?void 0:r.maxzoom)||22},r.basemap?(n=(s=this.map.getStyle().layers)==null?void 0:s[0])==null?void 0:n.id:null))},async addVtileLayer(r,t=this==null?void 0:this.map){var a;const s=["props","pointZoom"].filter(l=>r[l]).map(l=>`&${l}=${r[l]}`),n={type:"vector",tiles:[`${(a=r==null?void 0:r.url)!=null&&a.startsWith("http")?"":window.location.origin}${r==null?void 0:r.url}${s}`],minzoom:r.minzoom||3,maxzoom:r.maxzoom||24};t.addSource(r.id,n),(Ut(r.style)||r.layers||[]).forEach((l,i)=>{const c={...l,id:`${r.id}-${i}`,source:r.id,"source-layer":l["source-layer"]||r.source||r.id,maxzoom:+l.maxzoom||24,minzoom:+l.minzoom||0};t.addLayer(c)})},async addGeoJsonLayer(r,t=this.map){var o;const s=r.data||((o=r==null?void 0:r.url)!=null&&o.startsWith("http")?"":window.location.origin)+r.url;t.addSource(r.id,{type:"geojson",data:s}),(Ut(r.style)||r.layers||[]).forEach(a=>{const l={...a,source:r.id,id:a.id||r.id,maxzoom:+a.maxzoom||24,minzoom:+a.minzoom||0,type:a.type||"circle"};t.addLayer(l)})},setLayerData(r,t){this.layerList=this.layerList.map(s=>s.id===r?{...s,...t}:s)},async removeLayer(r,t=this.map){t.getSource(r)&&(await t.getStyle().layers.forEach(async s=>{s.source===r&&await t.removeLayer(s.id)}),await t.removeSource(r))},async setFilter(r,t){var o;const s=this.layerList.find(a=>a.id===r),n=await((o=this.map)==null?void 0:o.getSource(r));if(n&&s.service==="vtile"){await n.setTiles([`${window.location.origin}${s.url}${s.url.includes("?")?"&":"?"}filter=${t}${s.props?`&props=${s.props}`:""}`]);return}n&&s.service},async changeBaseLayer(r){const t=r!=null&&r.id?r:this.layerList.find(n=>n.id===r),{id:s}=t;if(s&&s!==this.activeLayer){if(this.activeLayer&&this.map.setLayoutProperty(this.activeLayer,"visibility","none"),this.activeLayer=s,this.map.getLayer(s)){this.map.setLayoutProperty(s,"visibility","visible");return}await this.addRasterLayer(t)}},async refreshLayer(r,t=this.map){await t.getStyle().layers.forEach(s=>{s.source===r&&t.removeLayer(s.id)}),await t.removeSource(r),this.setVisible(r)}}},Ei="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.js",Bi="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.css";let Ie=null;function Di(r){return new Promise((t,s)=>{if(document.querySelector(`script[src="${r}"]`)){t();return}const n=document.createElement("script");n.src=r,n.onload=()=>t(),n.onerror=()=>s(new Error(`Failed to load ${r}`)),document.head.appendChild(n)})}function Vi(r){return new Promise((t,s)=>{if(document.querySelector(`link[href="${r}"]`)){t();return}const n=document.createElement("link");n.rel="stylesheet",n.href=r,n.onload=()=>t(),n.onerror=()=>s(new Error(`Failed to load ${r}`)),document.head.appendChild(n)})}function Ht(){return typeof window>"u"?Promise.resolve(null):window.maplibregl?Promise.resolve(window.maplibregl):Ie||(Ie=Vi(Bi).then(()=>Di(Ei)).then(()=>window.maplibregl),Ie)}const Je={__name:"legend",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Cr),e.mergeProps(t.$attrs,{size:24}),null,16))}},Xe={pink:["#fde7e2","#feafbe","#fd58a4","#d7038e","#86007b"],blue:["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"],green:["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"],pink2:["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"],red:["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"],teal:["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"]},Ci={components:{legendIcon:Je,closeIcon:Pe},props:{mapId:{type:String},colors:{type:Array},sizes:{type:Array,default:()=>[]},cluster:{type:[Boolean,String]},color:{type:String,default:"gray"},colorTitle:{type:String},sizesTitle:{type:String},resizeItem:{type:[Boolean,String],default:!1},changeOpacityItem:{type:[Boolean,String],default:!1}},data(){return{isOpenLegend:!1,palette:Xe}},computed:{borderRadius(){return this.cluster?"rounded-sm":"rounded-full"},sortedSizes(){return[...this.sizes].sort((r,t)=>r-t)},maxWidht(){var s;const r=((s=this.sizes)==null?void 0:s.length)-1;return this.calcSize(r)}},methods:{sizeClass(r){return this.resizeItem?`h-[${this.calcSize(r)}] w-[${this.calcSize(r)}] ${this.borderRadius}`:`h-[18px] w-[18px] ${this.borderRadius}`},calcSize(r){return`${10+r*2}px`},getOpacity(r){return(r+1)/this.sortedSizes.length}}},Ni={class:"w-full absolute max-w-[200px] bg-white border rounded-lg bottom-[10px] right-[50px]"},Si={class:"flex items-center justify-between border-b border-[#0000001A] px-2"},zi={class:"w-full flex flex-col gap-[8px] px-2 py-2 max-h-[200px] overflow-auto [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent"},Li={key:0,class:"flex flex-col w-full"},Ii={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},Ti={class:"flex flex-col gap-[6px]"},Mi={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"},Pi={key:1,class:"flex flex-col w-full"},Fi={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},ji={class:"flex flex-col gap-[6px]"},Ri={class:"flex flex-row items-center justify-start"},Wi={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"};function vi(r,t,s,n,o,a){var c,d;const l=e.resolveComponent("legendIcon"),i=e.resolveComponent("closeIcon");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]",onClick:t[0]||(t[0]=p=>o.isOpenLegend=!o.isOpenLegend)},[e.createVNode(l)]),o.isOpenLegend?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:`#wrapper-${s.mapId}`},[e.createElementVNode("div",Ni,[e.createElementVNode("div",Si,[t[2]||(t[2]=e.createElementVNode("h3",{class:"text-[16px] font-normal text-black"},"Легенда",-1)),e.createElementVNode("button",{type:"button",class:"inline-flex items-center text-sm font-medium text-gray-500 rounded-lg gap-x-2 focus:outline-none disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 dark:hover:text-blue-500 dark:focus:text-blue-500",onClick:t[1]||(t[1]=p=>o.isOpenLegend=!1)},[e.createVNode(i,{class:"w-[20px]"})])]),e.createElementVNode("div",zi,[(c=s.colors)!=null&&c.length?(e.openBlock(),e.createElementBlock("div",Li,[s.colorTitle?(e.openBlock(),e.createElementBlock("h4",Ii,e.toDisplayString(s.colorTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ti,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.colors,(p,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:"flex items-center gap-[10px]"},[p.color?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-[12px] h-[12px] rounded-full",style:e.normalizeStyle({backgroundColor:p.color})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("p",Mi,e.toDisplayString(p.text||p.val),1)]))),128))])])):e.createCommentVNode("",!0),(d=s.sizes)!=null&&d.length?(e.openBlock(),e.createElementBlock("div",Pi,[r.sizeTitle?(e.openBlock(),e.createElementBlock("h4",Fi,e.toDisplayString(r.sizeTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",ji,[a.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(a.sortedSizes,(p,h)=>{var m,f,u,y,b;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",Ri,[e.createElementVNode("div",{class:e.normalizeClass([a.maxWidht?`w-[${a.maxWidht}]`:"","mr-[10px]"])},[e.createElementVNode("div",{class:e.normalizeClass(a.sizeClass(h)),style:e.normalizeStyle({backgroundColor:((f=(m=o.palette)==null?void 0:m[s.color])==null?void 0:f[h])||s.color})},null,6)],2),e.createElementVNode("p",Wi,e.toDisplayString(h===((u=a.sortedSizes)==null?void 0:u.length)-1?">"+p:h==((y=a.sortedSizes)==null?void 0:y.length)-1?">"+a.sortedSizes[((b=a.sortedSizes)==null?void 0:b.length)-1]:p+"-"+a.sortedSizes[h+1]),1)])])}),256)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])])],8,["to"])):e.createCommentVNode("",!0)],64)}const Ai=W(Ci,[["render",vi]]),Oi={props:["map","coordinates"],data(){return{isMenuVisible:!1}},computed:{getCoordinates(){var t;return!(this!=null&&this.coordinates)||((t=this.coordinates)==null?void 0:t.length)!==2?"":(this==null?void 0:this.coordinates).slice().reverse().map(s=>Number(s).toFixed(5)).join(", ")}}},qi={class:"map__settings"},Ui={ref:"attribution",class:"map__settings-attribution map__settings-item mt-[3px]"};function Hi(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",qi,[e.createElementVNode("div",Ui,[e.withDirectives(e.createElementVNode("div",{ref:"mouse",class:"map__settings-item",style:{"min-width":"115px"}},e.toDisplayString(a.getCoordinates),513),[[e.vShow,a.getCoordinates]])],512)])}const Gt=W(Oi,[["render",Hi]]),Gi={mixins:[Qe],props:{map:{type:Object,default:()=>null}},data(){return{baseLayers:[{id:"orto10",name:"Ortophoto 1:10К",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",service:"TMS",image:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4954/2876.png"},{id:"graymap",name:"Сіра карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",service:"TMS",image:"https://data.gki.com.ua/api-user/rtile/positron/ua/10/601/348.png"}]}},watch:{map(r){r&&r.on("load",this.handleMapLoad)}},created(){this.baseLayers.forEach(r=>{const t={...r,basemap:!0};this.layerList.push(t)})},methods:{handleMapLoad(){this.changeBaseLayer("graymap")},isLayerInFocus(r){return r.id===this.activeLayer}}},Zi={class:"vs-map-slot-layers"},Qi=["onClick"],Ji=["src"];function Xi(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",Zi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.baseLayers,l=>(e.openBlock(),e.createElementBlock("div",{key:l.id,class:e.normalizeClass(["vs-map-slot-layers__layer",{focused:a.isLayerInFocus(l)}]),onClick:i=>r.changeBaseLayer(l.id)},[e.createElementVNode("img",{src:l.image,class:"vs-map-slot-layers__image"},null,8,Ji)],10,Qi))),128))])}const Zt=W(Gi,[["render",Xi]]);function Qt(r,t,s){if(r!==null)for(var n,o,a,l,i,c,d,p=0,h=0,m,f=r.type,u=f==="FeatureCollection",y=f==="Feature",b=u?r.features.length:1,$=0;$<b;$++){d=u?r.features[$].geometry:y?r.geometry:r,m=d?d.type==="GeometryCollection":!1,i=m?d.geometries.length:1;for(var w=0;w<i;w++){var x=0,C=0;if(l=m?d.geometries[w]:d,l!==null){c=l.coordinates;var L=l.type;switch(p=0,L){case null:break;case"Point":if(t(c,h,$,x,C)===!1)return!1;h++,x++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,$,x,C)===!1)return!1;h++,L==="MultiPoint"&&x++}L==="LineString"&&x++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(o=0;o<c[n].length-p;o++){if(t(c[n][o],h,$,x,C)===!1)return!1;h++}L==="MultiLineString"&&x++,L==="Polygon"&&C++}L==="Polygon"&&x++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(C=0,o=0;o<c[n].length;o++){for(a=0;a<c[n][o].length-p;a++){if(t(c[n][o][a],h,$,x,C)===!1)return!1;h++}C++}x++}break;case"GeometryCollection":for(n=0;n<l.geometries.length;n++)if(Qt(l.geometries[n],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Ki(r,t={}){if(r.bbox!=null&&t.recompute!==!0)return r.bbox;const s=[1/0,1/0,-1/0,-1/0];return Qt(r,n=>{s[0]>n[0]&&(s[0]=n[0]),s[1]>n[1]&&(s[1]=n[1]),s[2]<n[0]&&(s[2]=n[0]),s[3]<n[1]&&(s[3]=n[1])}),s}const Yi={props:["bbox","map"],components:{homeIcon:{__name:"home",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Br),e.mergeProps(t.$attrs,{size:24}),null,16))}}},methods:{setBounds(){const r={type:"Feature",geometry:this==null?void 0:this.bbox},t=Ki(r);this.map.fitBounds(t)}}},ec={class:"z-100 flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]"};function tc(r,t,s,n,o,a){const l=e.resolveComponent("homeIcon");return e.openBlock(),e.createElementBlock("div",ec,[e.createVNode(l,{onClick:a.setBounds},null,8,["onClick"])])}const Jt=W(Yi,[["render",tc]]),rc={components:{legendIcon:Je,menuIcon:{__name:"menu",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Er),e.mergeProps(t.$attrs,{size:24}),null,16))}},closeIcon:Pe},props:["source","count","total","mapId"],data(){return{isOpenLegend:!1,palette:["#69D2E7","yellow","#FE4365"]}},methods:{calcSize(r){return r/this.maxValue*100*50/100}},computed:{maxValue(){var r,t,s,n,o,a;return((r=this.sizes)==null?void 0:r[0])>((s=this.sizes)==null?void 0:s[((t=this.sizes)==null?void 0:t.length)-1])?(n=this.sizes)==null?void 0:n[0]:(a=this.sizes)==null?void 0:a[((o=this.sizes)==null?void 0:o.length)-1]}}},sc={class:"w-full h-[calc(100%-40px)] bg-white"},nc={class:"w-full flex flex-col gap-[8px] h-[250px] overflow-auto [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent text-xs"},oc={class:"relative min-w-full bg-white text-[12px]"},ac={class:"divide-gray-200 dark:divide-neutral-700"},lc={class:"px-2 py-1"},ic={class:"px-2 py-1"};function cc(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",sc,[e.createElementVNode("div",nc,[e.createElementVNode("table",oc,[t[0]||(t[0]=e.createElementVNode("thead",{class:"sticky top-[-1px] z-[1] bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},[e.createElementVNode("tr",null,[e.createElementVNode("th",{class:"px-2 py-1 text-start"},"Назва"),e.createElementVNode("th",{class:"px-2 py-1 text-start"},"Метрика")])],-1)),e.createElementVNode("tbody",ac,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.source,l=>(e.openBlock(),e.createElementBlock("tr",{key:l.id,class:"border-b cursor-pointer hover:bg-gray-100 odd:bg-gray-50"},[e.createElementVNode("td",lc,e.toDisplayString(l.title||"—"),1),e.createElementVNode("td",ic,e.toDisplayString(l.metric),1)]))),128))])])])])}const Xt=W(rc,[["render",cc]]),dc={mixins:[X,Qe,{components:{VsMapSetting:Gt,VsMapSlotLayers:Zt,VsMapLegend:Ai,VsMapGoHome:Jt,VsList:Xt},data(){return{mapId:`map-${Math.floor(Math.random()*1e3)}`,layerId:`layer${Math.floor(Math.random()*1e3)}`,map:null,hoverData:null,data:null,coordinatesByMouse:[],showSetting:!1,popup:null,color:"#69D2E7"}},methods:{async createMap(){var s,n;const r=await Ht();if(!r)return;const t={version:8,glyphs:"https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=await new r.Map({container:this.mapId,style:t,center:[31,48.5],zoom:((n=(s=this.data)==null?void 0:s.style)==null?void 0:n.zoom)||5,minZoom:3,maxZoom:20,attributionControl:!1}),this.map.addControl(new r.NavigationControl({visualizePitch:!0})),this.map.on("load",()=>{this.loadHandler()}),this.map.on("mousemove",o=>{this.moveMouseHadler(o)}),this.map.on("mouseout",()=>{var o;this.showLegend=!1,this.showSetting=!1,this.coordinatesByMouse=0,(o=this.popup)==null||o.remove()})},getPopoverTitle(r){var t,s,n,o,a;return(s=(t=this.data)==null?void 0:t.colors)!=null&&s.find(l=>l.val===r)?(a=(o=(n=this.data)==null?void 0:n.colors)==null?void 0:o.find(l=>l.val===r))==null?void 0:a.text:r},moveMouseHadler(r){var t;try{const s=this.map.queryRenderedFeatures(r.point),n=((t=s[0])==null?void 0:t.properties)||{};if(!s.length){this.map.getCanvas().style.cursor="",this.popupElement&&this.popupElement.remove();return}this.map.getCanvas().style.cursor="pointer",this.popupElement&&this.popupElement.remove(),this.popupElement=document.createElement("div"),this.popupElement.className="absolute text-gray-800 border border-gray-200 rounded-lg shadow-md min-w-28",this.popupElement.style.backgroundColor="rgba(255, 255, 255, 0.7)",this.popupElement.innerHTML=`<div class="font-semibold text-sm border-b border-solid border-gray-200 text-gray-800 rounded-t-lg px-2 py-1">
219
+ ${this.getPopoverTitle((n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name))||""}
220
220
  </div>
221
221
 
222
222
  <div class="flex justify-between items-center text-xs px-2 py-0.5 text-gray-500 ">
223
223
  <span class="flex items-center">
224
224
  <span class="font-medium mr-[6px]">Значення</span>
225
225
  </span>
226
- <span>${(s==null?void 0:s.metric)||0}</span>
227
- </div>`;const o=this.map.project(r.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(n){console.error(n)}}}}],name:"VsMap",async mounted(){await this.getMapData(),await this.createMap()},methods:{async getMapData(){var l,a,i;if(this.prefetchedData){this.data=this.prefetchedData,this.$emit("update:widgetData",this.prefetchedData),setTimeout(()=>{var c;return(c=this.map)==null?void 0:c.resize()});return}const r=((l=this.resolveWidgetId)==null?void 0:l.call(this))||this.widget,t=((a=this.resolveDashboardId)==null?void 0:a.call(this))||this.dashboard,n=((i=this.resolvePrefix)==null?void 0:i.call(this))||"/api",o=await(await fetch(`${n}/bi-map?widget=${r}&dashboard=${t}`)).json();this.data=o,this.$emit("update:widgetData",o),setTimeout(()=>{var c;return(c=this.map)==null?void 0:c.resize()})},async loadHandler(){var c,d,p;const r=["#69D2E7","yellow","#FE4365"],t=this.data.colors?["match",["get","x"]].concat(this.data.colors.reduce((h,m,f)=>h.concat(m.val,(m==null?void 0:m.color)||r[f]),[])).concat(["gray"]):"blue",n=[5,7,9,11,13],s=this.data.sizes?["case"]:5;this.data.sizes&&(this.data.sizes.reverse().forEach((h,m)=>{s.push([">",["get","metric"],h]),s.push(n[m])}),s.push(5));const o={type:"circle",color:t,width:2,radius:s,stroke:"#eee"};Object.assign(o,this.data.style||{});const l=((c=this.resolveWidgetId)==null?void 0:c.call(this))||this.widget,a=((d=this.resolveDashboardId)==null?void 0:d.call(this))||this.dashboard,i=((p=this.resolvePrefix)==null?void 0:p.call(this))||"/api";this.addVtileLayer({id:"bi",url:`${window.top.location.origin}${i}/bi-vtile/{z}/{x}/{y}.vmt?widget=${l}&dashboard=${a}&nocache=1`,style:o})}}},pc={class:"w-full h-full"},hc={class:"flex items-start justify-between mb-[6px] w-full"},uc={class:"text-gray-800 font-[600]"},mc=["id"],fc=["id"],gc={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"};function bc(r,t,n,s,o,l){var p,h,m;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapLegend"),d=e.resolveComponent("VsMapGoHome");return e.openBlock(),e.createElementBlock("div",pc,[e.createElementVNode("div",hc,[e.createElementVNode("h5",uc,e.toDisplayString(r.title),1)]),e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${r.mapId}`},[e.createElementVNode("div",{id:r.mapId,class:"w-full flex items-end relative h-full min-h-[250px]"},null,8,fc),r.showSetting?(e.openBlock(),e.createBlock(a,{key:0,map:r.map,coordinates:r.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:r.map},null,8,["map"]),e.createElementVNode("div",gc,[e.createVNode(c,{mapId:r.mapId,colors:(p=r.data)==null?void 0:p.colors,sizes:(h=r.data)==null?void 0:h.sizes,color:r.color,resizeItem:"true"},null,8,["mapId","colors","sizes","color"]),e.createVNode(d,{map:r.map,bbox:(m=r.data)==null?void 0:m.bounds},null,8,["map","bbox"])])],8,mc)])}const yc=Object.freeze(Object.defineProperty({__proto__:null,default:W(dc,[["render",bc]])},Symbol.toStringTag,{value:"Module"})),xc={components:{legendIcon:Je,closeIcon:Pe},props:{mapId:{type:String},colors:{type:Array},sizes:{type:Array,default:()=>[]},cluster:{type:[Boolean,String]},color:{type:String,default:"gray"},colorTitle:{type:String},sizesTitle:{type:String},resizeItem:{type:[Boolean,String],default:!1},changeOpacityItem:{type:[Boolean,String],default:!1}},data(){return{isOpenLegend:!1,palette:Xe}},computed:{borderRadius(){return this.cluster?"rounded-sm":"rounded-full"},sortedSizes(){return[...this.sizes].sort((r,t)=>r-t)},maxWidht(){var n;const r=((n=this.sizes)==null?void 0:n.length)-1;return this.calcSize(r)}},methods:{sizeClass(r){return this.resizeItem?`h-[${this.calcSize(r)}] w-[${this.calcSize(r)}] ${this.borderRadius}`:`h-[10px] ${this.borderRadius}`},calcSize(r){return`${10+r*2}px`},getOpacity(r){return(r+1)/this.sortedSizes.length}}},kc={key:0,class:"absolute flex items-end w-fit bottom-[10px] max-w-[80%] left-[50%] translate-x-[-50%] bg-[rgba(255,255,255,0.7)] p-[10px] rounded"},wc={class:"w-[80px] mr-[10px]"},_c=["title"],$c={class:"text-[10px] mb-[2px] text-[#1F2937] font-normal leading-[1.2]"};function Ec(r,t,n,s,o,l){var a;return(a=n.sizes)!=null&&a.length?(e.openBlock(),e.createElementBlock("div",kc,[e.createElementVNode("div",wc,[t[0]||(t[0]=e.createElementVNode("p",{class:"text-[10px] mb-[2px] text-[#1F2937] leading-[1.2]"}," Дані відсутні ",-1)),e.createElementVNode("div",{class:e.normalizeClass([l.sizeClass(r.index),"w-full border border-gray-500"])},null,2)]),l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(i,c)=>{var d,p,h,m,f,u,y,b;return e.openBlock(),e.createElementBlock("div",{class:"w-[80px]",title:c===((d=l.sortedSizes)==null?void 0:d.length)-1?">"+i:c==((p=l.sortedSizes)==null?void 0:p.length)-1?">"+l.sortedSizes[((h=l.sortedSizes)==null?void 0:h.length)-1]:i+"-"+l.sortedSizes[c+1]},[e.createElementVNode("p",$c,e.toDisplayString(c===((m=l.sortedSizes)==null?void 0:m.length)-1?">"+parseInt(i):c==((f=l.sortedSizes)==null?void 0:f.length)-1?">"+parseInt(l.sortedSizes[((u=l.sortedSizes)==null?void 0:u.length)-1]):parseInt(i)+"-"+parseInt(l.sortedSizes[c+1])),1),e.createElementVNode("div",{class:e.normalizeClass([l.sizeClass(c),"w-full border border-r-0 border-gray-500"]),style:e.normalizeStyle({backgroundColor:((b=(y=o.palette)==null?void 0:y[n.color])==null?void 0:b[c])||n.color})},null,6)],8,_c)}),256)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const Bc=W(xc,[["render",Ec]]),Vc={__name:"icon-map",setup(r){return(t,n)=>(e.openBlock(),e.createBlock(e.unref(Nr),e.mergeProps(t.$attrs,{size:24}),null,16))}},Cc={mixins:[X,Qe],components:{VsMapSetting:Gt,VsClusterLegend:Bc,VsMapGoHome:Jt,VsList:Xt,VsMapSlotLayers:Zt,VsBar:Ue},data(){return{baseColor:"pink",kattotg:"",options:[{id:"map",text:"Карта",component:Vc},{id:"table",text:"Таблиця",component:Tt},{id:"chart",text:"Віджет",component:Lt}],activeTab:"map",mapId:`map-${Math.floor(Math.random()*1e3)}`,layerId:`layer${Math.floor(Math.random()*1e3)}`,map:null,hoverData:null,data:null,coordinatesByMouse:[],showSetting:!1,popup:null,color:"#69D2E7",label:"<div><icon-map/></div>"}},async mounted(){await this.getMapData(),await this.createMap()},watch:{kattotg(){this.loadHandler()}},methods:{async getMapData(){var s,o;if(this.prefetchedData){this.data=this.prefetchedData,this.$emit("update:widgetData",this.data),setTimeout(()=>{var l;return(l=this.map)==null?void 0:l.resize()});return}const r=((s=this.resolveWidgetId)==null?void 0:s.call(this))||this.widget,t=((o=this.resolveDashboardId)==null?void 0:o.call(this))||this.dashboard,n=await H.get(`/bi-cluster?widget=${r}&dashboard=${t}`);this.data=n,this.$emit("update:widgetData",this.data),setTimeout(()=>{var l;return(l=this.map)==null?void 0:l.resize()})},async loadHandler(){var a,i,c,d,p,h,m;this.baseColor=((a=this.data.style)==null?void 0:a.color)||"blue";const r=["case"];(d=(c=(i=this.data)==null?void 0:i.sizes)==null?void 0:c.toReversed())==null||d.forEach((f,u)=>{var y,b;r.push([">",["get","metric"],f]),r.push((b=(y=Xe[this.baseColor])==null?void 0:y.toReversed())==null?void 0:b[u]),u++}),r.push("gray");const t={type:"polygon",color:r,opacity:.4};Object.assign(t,this.data.style||{});const n=((p=this.resolveWidgetId)==null?void 0:p.call(this))||this.widget,s=((h=this.resolveDashboardId)==null?void 0:h.call(this))||this.dashboard,o=((m=this.resolvePrefix)==null?void 0:m.call(this))||"/api";this.map.getSource("bi")||this.addVtileLayer({id:"bi",url:`${window.location.origin}${o}/bi-cluster-vtile/{z}/{x}/{y}.vmt?widget=${n}&dashboard=${s}&nocache=1`,style:t}),this.map.getLayer("highlighted")&&this.map.removeLayer("highlighted"),this.map.getSource("highlighted")&&this.map.removeSource("highlighted");const l=["case"];this.kattotg&&l.push(["==",["to-string",["get","name"]],String(this.kattotg)],"red"),l.push("transparent"),this.map.addLayer({id:"highlighted",type:"fill",source:"bi","source-layer":"bi",paint:{"fill-color":l,"fill-opacity":.6}})},async createMap(){var n,s;const r=await Ht();if(!r)return;const t={version:8,glyphs:"https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=await new r.Map({container:this.mapId,style:t,center:[31,48.5],zoom:((s=(n=this.data)==null?void 0:n.style)==null?void 0:s.zoom)||5,minZoom:3,maxZoom:20,attributionControl:!1}),this.map.addControl(new r.NavigationControl({visualizePitch:!0})),this.map.on("load",()=>{this.loadHandler()}),this.map.on("mousemove",o=>{this.moveMouseHadler(o)}),this.map.on("mouseout",()=>{var o;this.showLegend=!1,this.showSetting=!1,this.coordinatesByMouse=0,(o=this.popup)==null||o.remove()})},moveMouseHadler(r){var t;try{const n=this.map.queryRenderedFeatures(r.point),s=((t=n[0])==null?void 0:t.properties)||{};if(!n.length){this.map.getCanvas().style.cursor="",this.popupElement&&this.popupElement.remove();return}this.map.getCanvas().style.cursor="pointer",this.popupElement&&this.popupElement.remove(),this.popupElement=document.createElement("div"),this.popupElement.className="absolute text-gray-800 border border-gray-200 rounded-lg shadow-md min-w-28",this.popupElement.style.backgroundColor="rgba(255, 255, 255, 0.7)",this.popupElement.innerHTML=`<div class="px-2 py-1 text-sm font-semibold text-gray-800 border-b border-gray-200 border-solid rounded-t-lg">
228
- ${(s==null?void 0:s.x)||(s==null?void 0:s.title)||(s==null?void 0:s.name)||""}
226
+ <span>${(n==null?void 0:n.metric)||0}</span>
227
+ </div>`;const o=this.map.project(r.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(s){console.error(s)}}}}],name:"VsMap",async mounted(){await this.getMapData(),await this.createMap()},methods:{async getMapData(){var a,l,i;if(this.prefetchedData){this.data=this.prefetchedData,this.$emit("update:widgetData",this.prefetchedData),setTimeout(()=>{var c;return(c=this.map)==null?void 0:c.resize()});return}const r=((a=this.resolveWidgetId)==null?void 0:a.call(this))||this.widget,t=((l=this.resolveDashboardId)==null?void 0:l.call(this))||this.dashboard,s=((i=this.resolvePrefix)==null?void 0:i.call(this))||"/api",o=await(await fetch(`${s}/bi-map?widget=${r}&dashboard=${t}`)).json();this.data=o,this.$emit("update:widgetData",o),setTimeout(()=>{var c;return(c=this.map)==null?void 0:c.resize()})},async loadHandler(){var c,d,p;const r=["#69D2E7","yellow","#FE4365"],t=this.data.colors?["match",["get","x"]].concat(this.data.colors.reduce((h,m,f)=>h.concat(m.val,(m==null?void 0:m.color)||r[f]),[])).concat(["gray"]):"blue",s=[5,7,9,11,13],n=this.data.sizes?["case"]:5;this.data.sizes&&(this.data.sizes.reverse().forEach((h,m)=>{n.push([">",["get","metric"],h]),n.push(s[m])}),n.push(5));const o={type:"circle",color:t,width:2,radius:n,stroke:"#eee"};Object.assign(o,this.data.style||{});const a=((c=this.resolveWidgetId)==null?void 0:c.call(this))||this.widget,l=((d=this.resolveDashboardId)==null?void 0:d.call(this))||this.dashboard,i=((p=this.resolvePrefix)==null?void 0:p.call(this))||"/api";this.addVtileLayer({id:"bi",url:`${window.top.location.origin}${i}/bi-vtile/{z}/{x}/{y}.vmt?widget=${a}&dashboard=${l}&nocache=1`,style:o})}}},pc={class:"w-full h-full"},hc={class:"flex items-start justify-between mb-[6px] w-full"},uc={class:"text-gray-800 font-[600]"},mc=["id"],fc=["id"],gc={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"};function bc(r,t,s,n,o,a){var p,h,m;const l=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapLegend"),d=e.resolveComponent("VsMapGoHome");return e.openBlock(),e.createElementBlock("div",pc,[e.createElementVNode("div",hc,[e.createElementVNode("h5",uc,e.toDisplayString(r.title),1)]),e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${r.mapId}`},[e.createElementVNode("div",{id:r.mapId,class:"w-full flex items-end relative h-full min-h-[250px]"},null,8,fc),r.showSetting?(e.openBlock(),e.createBlock(l,{key:0,map:r.map,coordinates:r.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:r.map},null,8,["map"]),e.createElementVNode("div",gc,[e.createVNode(c,{mapId:r.mapId,colors:(p=r.data)==null?void 0:p.colors,sizes:(h=r.data)==null?void 0:h.sizes,color:r.color,resizeItem:"true"},null,8,["mapId","colors","sizes","color"]),e.createVNode(d,{map:r.map,bbox:(m=r.data)==null?void 0:m.bounds},null,8,["map","bbox"])])],8,mc)])}const yc=Object.freeze(Object.defineProperty({__proto__:null,default:W(dc,[["render",bc]])},Symbol.toStringTag,{value:"Module"})),xc={components:{legendIcon:Je,closeIcon:Pe},props:{mapId:{type:String},colors:{type:Array},sizes:{type:Array,default:()=>[]},cluster:{type:[Boolean,String]},color:{type:String,default:"gray"},colorTitle:{type:String},sizesTitle:{type:String},resizeItem:{type:[Boolean,String],default:!1},changeOpacityItem:{type:[Boolean,String],default:!1}},data(){return{isOpenLegend:!1,palette:Xe}},computed:{borderRadius(){return this.cluster?"rounded-sm":"rounded-full"},sortedSizes(){return[...this.sizes].sort((r,t)=>r-t)},maxWidht(){var s;const r=((s=this.sizes)==null?void 0:s.length)-1;return this.calcSize(r)}},methods:{sizeClass(r){return this.resizeItem?`h-[${this.calcSize(r)}] w-[${this.calcSize(r)}] ${this.borderRadius}`:`h-[10px] ${this.borderRadius}`},calcSize(r){return`${10+r*2}px`},getOpacity(r){return(r+1)/this.sortedSizes.length}}},kc={key:0,class:"absolute flex items-end w-fit bottom-[10px] max-w-[80%] left-[50%] translate-x-[-50%] bg-[rgba(255,255,255,0.7)] p-[10px] rounded"},wc={class:"w-[80px] mr-[10px]"},_c=["title"],$c={class:"text-[10px] mb-[2px] text-[#1F2937] font-normal leading-[1.2]"};function Ec(r,t,s,n,o,a){var l;return(l=s.sizes)!=null&&l.length?(e.openBlock(),e.createElementBlock("div",kc,[e.createElementVNode("div",wc,[t[0]||(t[0]=e.createElementVNode("p",{class:"text-[10px] mb-[2px] text-[#1F2937] leading-[1.2]"}," Дані відсутні ",-1)),e.createElementVNode("div",{class:e.normalizeClass([a.sizeClass(r.index),"w-full border border-gray-500"])},null,2)]),a.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(a.sortedSizes,(i,c)=>{var d,p,h,m,f,u,y,b;return e.openBlock(),e.createElementBlock("div",{class:"w-[80px]",title:c===((d=a.sortedSizes)==null?void 0:d.length)-1?">"+i:c==((p=a.sortedSizes)==null?void 0:p.length)-1?">"+a.sortedSizes[((h=a.sortedSizes)==null?void 0:h.length)-1]:i+"-"+a.sortedSizes[c+1]},[e.createElementVNode("p",$c,e.toDisplayString(c===((m=a.sortedSizes)==null?void 0:m.length)-1?">"+parseInt(i):c==((f=a.sortedSizes)==null?void 0:f.length)-1?">"+parseInt(a.sortedSizes[((u=a.sortedSizes)==null?void 0:u.length)-1]):parseInt(i)+"-"+parseInt(a.sortedSizes[c+1])),1),e.createElementVNode("div",{class:e.normalizeClass([a.sizeClass(c),"w-full border border-r-0 border-gray-500"]),style:e.normalizeStyle({backgroundColor:((b=(y=o.palette)==null?void 0:y[s.color])==null?void 0:b[c])||s.color})},null,6)],8,_c)}),256)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const Bc=W(xc,[["render",Ec]]),Dc={__name:"icon-map",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Nr),e.mergeProps(t.$attrs,{size:24}),null,16))}},Vc={mixins:[X,Qe],components:{VsMapSetting:Gt,VsClusterLegend:Bc,VsMapGoHome:Jt,VsList:Xt,VsMapSlotLayers:Zt,VsBar:Ue},data(){return{baseColor:"pink",kattotg:"",options:[{id:"map",text:"Карта",component:Dc},{id:"table",text:"Таблиця",component:It},{id:"chart",text:"Віджет",component:Lt}],activeTab:"map",mapId:`map-${Math.floor(Math.random()*1e3)}`,layerId:`layer${Math.floor(Math.random()*1e3)}`,map:null,hoverData:null,data:null,coordinatesByMouse:[],showSetting:!1,popup:null,color:"#69D2E7",label:"<div><icon-map/></div>"}},async mounted(){await this.getMapData(),await this.createMap()},watch:{kattotg(){this.loadHandler()}},methods:{async getMapData(){var n,o;if(this.prefetchedData){this.data=this.prefetchedData,this.$emit("update:widgetData",this.data),setTimeout(()=>{var a;return(a=this.map)==null?void 0:a.resize()});return}const r=((n=this.resolveWidgetId)==null?void 0:n.call(this))||this.widget,t=((o=this.resolveDashboardId)==null?void 0:o.call(this))||this.dashboard,s=await H.get(`/bi-cluster?widget=${r}&dashboard=${t}`);this.data=s,this.$emit("update:widgetData",this.data),setTimeout(()=>{var a;return(a=this.map)==null?void 0:a.resize()})},async loadHandler(){var l,i,c,d,p,h,m;this.baseColor=((l=this.data.style)==null?void 0:l.color)||"blue";const r=["case"];(d=(c=(i=this.data)==null?void 0:i.sizes)==null?void 0:c.toReversed())==null||d.forEach((f,u)=>{var y,b;r.push([">",["get","metric"],f]),r.push((b=(y=Xe[this.baseColor])==null?void 0:y.toReversed())==null?void 0:b[u]),u++}),r.push("gray");const t={type:"polygon",color:r,opacity:.4};Object.assign(t,this.data.style||{});const s=((p=this.resolveWidgetId)==null?void 0:p.call(this))||this.widget,n=((h=this.resolveDashboardId)==null?void 0:h.call(this))||this.dashboard,o=((m=this.resolvePrefix)==null?void 0:m.call(this))||"/api";this.map.getSource("bi")||this.addVtileLayer({id:"bi",url:`${window.location.origin}${o}/bi-cluster-vtile/{z}/{x}/{y}.vmt?widget=${s}&dashboard=${n}&nocache=1`,style:t}),this.map.getLayer("highlighted")&&this.map.removeLayer("highlighted"),this.map.getSource("highlighted")&&this.map.removeSource("highlighted");const a=["case"];this.kattotg&&a.push(["==",["to-string",["get","name"]],String(this.kattotg)],"red"),a.push("transparent"),this.map.addLayer({id:"highlighted",type:"fill",source:"bi","source-layer":"bi",paint:{"fill-color":a,"fill-opacity":.6}})},async createMap(){var s,n;const r=await Ht();if(!r)return;const t={version:8,glyphs:"https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=await new r.Map({container:this.mapId,style:t,center:[31,48.5],zoom:((n=(s=this.data)==null?void 0:s.style)==null?void 0:n.zoom)||5,minZoom:3,maxZoom:20,attributionControl:!1}),this.map.addControl(new r.NavigationControl({visualizePitch:!0})),this.map.on("load",()=>{this.loadHandler()}),this.map.on("mousemove",o=>{this.moveMouseHadler(o)}),this.map.on("mouseout",()=>{var o;this.showLegend=!1,this.showSetting=!1,this.coordinatesByMouse=0,(o=this.popup)==null||o.remove()})},moveMouseHadler(r){var t;try{const s=this.map.queryRenderedFeatures(r.point),n=((t=s[0])==null?void 0:t.properties)||{};if(!s.length){this.map.getCanvas().style.cursor="",this.popupElement&&this.popupElement.remove();return}this.map.getCanvas().style.cursor="pointer",this.popupElement&&this.popupElement.remove(),this.popupElement=document.createElement("div"),this.popupElement.className="absolute text-gray-800 border border-gray-200 rounded-lg shadow-md min-w-28",this.popupElement.style.backgroundColor="rgba(255, 255, 255, 0.7)",this.popupElement.innerHTML=`<div class="px-2 py-1 text-sm font-semibold text-gray-800 border-b border-gray-200 border-solid rounded-t-lg">
228
+ ${(n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name)||""}
229
229
  </div>
230
230
 
231
231
  <div class="flex justify-between items-center text-xs px-2 py-0.5 text-gray-500 ">
232
232
  <span class="flex items-center">
233
233
  <span class="font-medium mr-[6px]">Значення</span>
234
234
  </span>
235
- <span>${(s==null?void 0:s.metric)||0}</span>
236
- </div>`;const o=this.map.project(r.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(n){console.error(n)}}}},Dc={class:"h-full"},Nc={class:"flex items-start justify-between mb-[6px] w-full"},Sc={class:"text-gray-800 font-[600]"},zc={class:"flex gap-2"},Lc=["onClick"],Tc=["id"],Ic=["id"],Mc={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"},Pc={class:"h-[calc(250px)]"};function Fc(r,t,n,s,o,l){var m,f,u,y,b,$,w,x,D,L;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapGoHome"),d=e.resolveComponent("VsClusterLegend"),p=e.resolveComponent("VsList"),h=e.resolveComponent("VsBar");return e.openBlock(),e.createElementBlock("div",Dc,[e.createElementVNode("div",Nc,[e.createElementVNode("h3",Sc,e.toDisplayString(r.title),1),e.createElementVNode("div",zc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,E=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["p-1 text-gray-700 border rounded",[o.activeTab===(E==null?void 0:E.id)?"ring-2 ring-blue-500":""]]),onClick:C=>o.activeTab=E==null?void 0:E.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(E==null?void 0:E.component),{height:"16",width:"16"}))],10,Lc))),256))])]),e.withDirectives(e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${o.mapId}`},[e.createElementVNode("div",{id:o.mapId,class:"h-full w-full flex items-end min-h-[250px]"},null,8,Ic),o.showSetting?(e.openBlock(),e.createBlock(a,{key:0,map:o.map,coordinates:o.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:o.map},null,8,["map"]),e.createElementVNode("div",Mc,[e.createVNode(c,{map:o.map,bbox:(m=o.data)==null?void 0:m.bounds},null,8,["map","bbox"])]),e.createVNode(d,{mapId:o.mapId,colors:(f=o.data)==null?void 0:f.colors,sizes:(u=o.data)==null?void 0:u.sizes,color:o.baseColor,changeOpacityItem:"true",cluster:"true"},null,8,["mapId","colors","sizes","color"])],8,Tc),[[e.vShow,o.activeTab=="map"]]),e.withDirectives(e.createVNode(p,{mapId:o.mapId,source:(y=o.data)==null?void 0:y.rows,total:((b=o.data)==null?void 0:b.total)||0,count:(($=o.data)==null?void 0:$.count)||0,onKattotg:t[0]||(t[0]=E=>o.kattotg=E)},null,8,["mapId","source","total","count"]),[[e.vShow,o.activeTab=="table"]]),e.withDirectives(e.createElementVNode("div",Pc,[(x=(w=o.data)==null?void 0:w.rows)!=null&&x.length?(e.openBlock(),e.createBlock(h,{key:0,source:(L=(D=o.data)==null?void 0:D.rows)==null?void 0:L.map(E=>({title:E==null?void 0:E.title,metric:E==null?void 0:E.metric}))},null,8,["source"])):e.createCommentVNode("",!0)],512),[[e.vShow,o.activeTab=="chart"]])])}const Rc=Object.freeze(Object.defineProperty({__proto__:null,default:W(Cc,[["render",Fc]])},Symbol.toStringTag,{value:"Module"})),jc={name:"VsTable",mixins:[X],data(){return{values:null,xs:null,products:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){try{const r=Array.from(new Set(this.sourceData.map(t=>t[this.dimensions[0]])));this.dimensions[0].includes("date")?this.xs=r.map(t=>me(t)):this.xs=[...r],this.products=this.dimensions.filter((t,n)=>n!=0),this.values=this.products.map((t,n)=>({name:t,data:this.sourceData.filter(s=>parseFloat(s[t])).map(s=>ee(parseFloat(s[t])))}))}catch(r){console.error(r)}}}},Wc={class:"flex flex-col h-full pt-[16px] pb-[16px] space-y-4 rounded-xl"},vc={class:"overflow-auto h-full [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300"},Ac={class:"inline-block min-w-full align-middle"},Oc={class:"relative min-w-full divide-y divide-gray-200 text-[12px]"},qc={class:"sticky top-0 bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},Uc={class:"space-x-2"},Hc={scope:"col",class:"xl:min-w-[120px] min-w-48"},Gc={class:"flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1"},Zc={class:"divide-y divide-gray-200"},Qc={class:"text-gray-600"};function Jc(r,t,n,s,o,l){return e.openBlock(),e.createElementBlock("div",Wc,[e.createElementVNode("div",vc,[e.createElementVNode("div",Ac,[e.createElementVNode("table",Oc,[e.createElementVNode("thead",qc,[e.createElementVNode("tr",Uc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.dimensions,a=>(e.openBlock(),e.createElementBlock("th",Hc,[e.createElementVNode("div",Gc,e.toDisplayString(a),1)]))),256))])]),e.createElementVNode("tbody",Zc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("tr",{key:i},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.dimensions,(c,d)=>(e.openBlock(),e.createElementBlock("td",{key:d,class:"py-3 whitespace-nowrap"},[e.createElementVNode("span",Qc,e.toDisplayString(a==null?void 0:a[c]),1)]))),128))]))),128))])])])])])}const Xc=Object.freeze(Object.defineProperty({__proto__:null,default:W(jc,[["render",Jc]])},Symbol.toStringTag,{value:"Module"}));j.AllDashboardsPage=Mt,j.EditorRootPage=Ua,j.ROUTES_NAMES=J,j.Urls=pt,j.VsBar=Ue,j.VsDashboard=In,j.VsDonut=Rt,j.VsEditorPage=It,j.VsLine=Wt,j.VsListBar=Ot,j.VsPie=jt,j.VsPivotTable=qt,j.VsProgressBar=At,j.VsStat=vt,j.VsWidget=fe,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
235
+ <span>${(n==null?void 0:n.metric)||0}</span>
236
+ </div>`;const o=this.map.project(r.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(s){console.error(s)}}}},Cc={class:"h-full"},Nc={class:"flex items-start justify-between mb-[6px] w-full"},Sc={class:"text-gray-800 font-[600]"},zc={class:"flex gap-2"},Lc=["onClick"],Ic=["id"],Tc=["id"],Mc={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"},Pc={class:"h-[calc(250px)]"};function Fc(r,t,s,n,o,a){var m,f,u,y,b,$,w,x,C,L;const l=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapGoHome"),d=e.resolveComponent("VsClusterLegend"),p=e.resolveComponent("VsList"),h=e.resolveComponent("VsBar");return e.openBlock(),e.createElementBlock("div",Cc,[e.createElementVNode("div",Nc,[e.createElementVNode("h3",Sc,e.toDisplayString(r.title),1),e.createElementVNode("div",zc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,E=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["p-1 text-gray-700 border rounded",[o.activeTab===(E==null?void 0:E.id)?"ring-2 ring-blue-500":""]]),onClick:V=>o.activeTab=E==null?void 0:E.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(E==null?void 0:E.component),{height:"16",width:"16"}))],10,Lc))),256))])]),e.withDirectives(e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${o.mapId}`},[e.createElementVNode("div",{id:o.mapId,class:"h-full w-full flex items-end min-h-[250px]"},null,8,Tc),o.showSetting?(e.openBlock(),e.createBlock(l,{key:0,map:o.map,coordinates:o.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:o.map},null,8,["map"]),e.createElementVNode("div",Mc,[e.createVNode(c,{map:o.map,bbox:(m=o.data)==null?void 0:m.bounds},null,8,["map","bbox"])]),e.createVNode(d,{mapId:o.mapId,colors:(f=o.data)==null?void 0:f.colors,sizes:(u=o.data)==null?void 0:u.sizes,color:o.baseColor,changeOpacityItem:"true",cluster:"true"},null,8,["mapId","colors","sizes","color"])],8,Ic),[[e.vShow,o.activeTab=="map"]]),e.withDirectives(e.createVNode(p,{mapId:o.mapId,source:(y=o.data)==null?void 0:y.rows,total:((b=o.data)==null?void 0:b.total)||0,count:(($=o.data)==null?void 0:$.count)||0,onKattotg:t[0]||(t[0]=E=>o.kattotg=E)},null,8,["mapId","source","total","count"]),[[e.vShow,o.activeTab=="table"]]),e.withDirectives(e.createElementVNode("div",Pc,[(x=(w=o.data)==null?void 0:w.rows)!=null&&x.length?(e.openBlock(),e.createBlock(h,{key:0,source:(L=(C=o.data)==null?void 0:C.rows)==null?void 0:L.map(E=>({title:E==null?void 0:E.title,metric:E==null?void 0:E.metric}))},null,8,["source"])):e.createCommentVNode("",!0)],512),[[e.vShow,o.activeTab=="chart"]])])}const jc=Object.freeze(Object.defineProperty({__proto__:null,default:W(Vc,[["render",Fc]])},Symbol.toStringTag,{value:"Module"})),Rc={name:"VsTable",mixins:[X],data(){return{values:null,xs:null,products:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){try{const r=Array.from(new Set(this.sourceData.map(t=>t[this.dimensions[0]])));this.dimensions[0].includes("date")?this.xs=r.map(t=>me(t)):this.xs=[...r],this.products=this.dimensions.filter((t,s)=>s!=0),this.values=this.products.map((t,s)=>({name:t,data:this.sourceData.filter(n=>parseFloat(n[t])).map(n=>ee(parseFloat(n[t])))}))}catch(r){console.error(r)}}}},Wc={class:"flex flex-col h-full pt-[16px] pb-[16px] space-y-4 rounded-xl"},vc={class:"overflow-auto h-full [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300"},Ac={class:"inline-block min-w-full align-middle"},Oc={class:"relative min-w-full divide-y divide-gray-200 text-[12px]"},qc={class:"sticky top-0 bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},Uc={class:"space-x-2"},Hc={scope:"col",class:"xl:min-w-[120px] min-w-48"},Gc={class:"flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1"},Zc={class:"divide-y divide-gray-200"},Qc={class:"text-gray-600"};function Jc(r,t,s,n,o,a){return e.openBlock(),e.createElementBlock("div",Wc,[e.createElementVNode("div",vc,[e.createElementVNode("div",Ac,[e.createElementVNode("table",Oc,[e.createElementVNode("thead",qc,[e.createElementVNode("tr",Uc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.dimensions,l=>(e.openBlock(),e.createElementBlock("th",Hc,[e.createElementVNode("div",Gc,e.toDisplayString(l),1)]))),256))])]),e.createElementVNode("tbody",Zc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,(l,i)=>(e.openBlock(),e.createElementBlock("tr",{key:i},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.dimensions,(c,d)=>(e.openBlock(),e.createElementBlock("td",{key:d,class:"py-3 whitespace-nowrap"},[e.createElementVNode("span",Qc,e.toDisplayString(l==null?void 0:l[c]),1)]))),128))]))),128))])])])])])}const Xc=Object.freeze(Object.defineProperty({__proto__:null,default:W(Rc,[["render",Jc]])},Symbol.toStringTag,{value:"Module"}));R.AllDashboardsPage=Mt,R.EditorRootPage=Ua,R.ROUTES_NAMES=J,R.Urls=pt,R.VsBar=Ue,R.VsDashboard=Is,R.VsDonut=jt,R.VsEditorPage=Tt,R.VsLine=Wt,R.VsListBar=Ot,R.VsPie=Rt,R.VsPivotTable=qt,R.VsProgressBar=At,R.VsStat=vt,R.VsWidget=fe,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});