@opengis/bi 1.2.29 → 1.2.30
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.
- package/dist/bi.js +1 -1
- package/dist/bi.umd.cjs +75 -75
- package/dist/{import-file-C1s2X9Kt.js → import-file-B4o9p2_2.js} +2365 -1798
- package/dist/{vs-funnel-bar-BuV_pQBq.js → vs-funnel-bar-BOWwPnjW.js} +1 -1
- package/dist/{vs-list-uhEudqNr.js → vs-list-D8jGusRT.js} +1 -1
- package/dist/{vs-map-qs7P1yfP.js → vs-map-BGplOwpB.js} +2 -2
- package/dist/{vs-map-cluster-CeJxLtZx.js → vs-map-cluster-CHQJV2As.js} +2 -2
- package/dist/{vs-number-BNnFUzs3.js → vs-number-jPqxFQ6d.js} +1 -1
- package/dist/{vs-table-BEvWIkoj.js → vs-table-BDgIvJbY.js} +1 -1
- package/dist/{vs-text-CPMz7TWB.js → vs-text-DcHOffy9.js} +1 -1
- package/package.json +1 -1
- package/server/routes/dashboard/controllers/utils/yaml.js +11 -11
- package/server/routes/map/controllers/cluster.js +125 -125
- package/server/routes/map/controllers/clusterVtile.js +166 -166
- package/server/routes/map/controllers/geojson.js +127 -127
- package/server/routes/map/controllers/map.js +69 -69
- package/server/routes/map/controllers/utils/downloadClusterData.js +44 -44
- package/server/routes/map/controllers/vtile.js +183 -183
- package/utils.js +12 -12
package/dist/bi.umd.cjs
CHANGED
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(I,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):(I=typeof globalThis<"u"?globalThis:I||self,e(I.bi={},I.Vue,I.vueRouter))})(this,function(I,e,U){"use strict";var Pc=Object.defineProperty;var Fc=(I,e,U)=>e in I?Pc(I,e,{enumerable:!0,configurable:!0,writable:!0,value:U}):I[e]=U;var F=(I,e,U)=>Fc(I,typeof e!="symbol"?e+"":e,U);/**
|
|
2
2
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const cr=r=>{for(const t in r)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
|
|
7
7
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const Ge=r=>r==="";/**
|
|
12
12
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
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
|
|
16
|
+
*/const dr=(...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.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Ze=r=>r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
22
22
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
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
|
|
26
|
+
*/const pr=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.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const hr=r=>{const t=pr(r);return t.charAt(0).toUpperCase()+t.slice(1)};/**
|
|
32
32
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/var
|
|
36
|
+
*/var ce={xmlns:"http://www.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"};/**
|
|
37
37
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
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
|
|
41
|
+
*/const ur=({name:r,iconNode:t,absoluteStrokeWidth:s,"absolute-stroke-width":n,strokeWidth:o,"stroke-width":l,size:a=ce.width,color:i=ce.stroke,...c},{slots:d})=>e.h("svg",{...ce,...c,width:a,height:a,stroke:i,"stroke-width":Ge(s)||Ge(n)||s===!0||n===!0?Number(o||l||ce["stroke-width"])*24/Number(a):o||l||ce["stroke-width"],class:dr("lucide",c.class,...r?[`lucide-${Ze(hr(r))}-icon`,`lucide-${Ze(r)}`]:["lucide-icon"]),...!d.default&&!cr(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
|
|
46
|
+
*/const W=(r,t)=>(s,{slots:n,attrs:o})=>e.h(ur,{...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.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const mr=W("arrow-up-down",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
|
|
52
52
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
56
|
+
*/const fr=W("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
57
57
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const gr=W("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);/**
|
|
62
62
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
66
|
+
*/const br=W("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/**
|
|
67
67
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
70
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const
|
|
71
|
+
*/const yr=W("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);/**
|
|
72
72
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
73
73
|
*
|
|
74
74
|
* This source code is licensed under the ISC license.
|
|
75
75
|
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const
|
|
76
|
+
*/const xr=W("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
|
|
77
77
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
78
78
|
*
|
|
79
79
|
* This source code is licensed under the ISC license.
|
|
80
80
|
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const
|
|
81
|
+
*/const kr=W("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]);/**
|
|
82
82
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
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
|
|
86
|
+
*/const wr=W("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
|
|
91
|
+
*/const _r=W("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
|
|
96
|
+
*/const $r=W("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.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const
|
|
101
|
+
*/const Er=W("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/**
|
|
102
102
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
103
103
|
*
|
|
104
104
|
* This source code is licensed under the ISC license.
|
|
105
105
|
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const
|
|
106
|
+
*/const Br=W("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
|
107
107
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
108
108
|
*
|
|
109
109
|
* This source code is licensed under the ISC license.
|
|
110
110
|
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const
|
|
111
|
+
*/const Qe=W("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
112
112
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
113
113
|
*
|
|
114
114
|
* This source code is licensed under the ISC license.
|
|
115
115
|
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const
|
|
116
|
+
*/const Vr=W("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
|
|
117
117
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
118
118
|
*
|
|
119
119
|
* This source code is licensed under the ISC license.
|
|
120
120
|
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const
|
|
121
|
+
*/const Xe=W("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/**
|
|
122
122
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
123
123
|
*
|
|
124
124
|
* This source code is licensed under the ISC license.
|
|
125
125
|
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const
|
|
126
|
+
*/const Cr=W("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/**
|
|
127
127
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
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
|
|
131
|
+
*/const Nr=W("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 Qe=P("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ce={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},Ds=["onClick"],Cs={class:"flex items-center justify-between w-full"},Ns={key:0},Ss=e.defineComponent({__name:"vs-bi-dropdown",props:{title:{},options:{},value:{default:null}},emits:["selected"],setup(s,{emit:t}){const r=s,n=t,o=e.ref(!1),l=e.ref(r.value??null),a=e.ref(null),i=e.computed(()=>{const g=r.options;return typeof g=="string"?g.split(",").map((u,w)=>({id:w,text:u.trim()})):Array.isArray(g)?g:[]}),c=e.computed(()=>{const g=i.value.find(u=>(u.id??u)===l.value);return g?g.text??String(g):r.title??""}),d=g=>{const u=(g==null?void 0:g.id)??g;l.value=u,o.value=!1,n("selected",u),document.removeEventListener("click",p)},p=g=>{a.value&&!a.value.contains(g.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)},b=g=>(Ce==null?void 0:Ce[g])??g;return e.onUnmounted(()=>{document.removeEventListener("click",p)}),(g,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(b(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,w=>(e.openBlock(),e.createElementBlock("div",{key:w.id||w,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:$=>d(w)},[e.createElementVNode("div",Cs,[e.createElementVNode("span",null,e.toDisplayString(b(w.text||w)),1),l.value===(w.id||w)?(e.openBlock(),e.createElementBlock("span",Ns,[...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,Ds))),128))],512)):e.createCommentVNode("",!0)],64))}}),zs={class:"flex items-center space-x-2"},Ls=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(s,{emit:t}){const r=t,n=e.useModel(s,"modelValue"),o=()=>{r("update:is-enabled",n)};return(l,a)=>(e.openBlock(),e.createElementBlock("div",zs,[l.leftLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["transition-colors",{"text-blue-500":!n.value}])},e.toDisplayString(l.leftLabel),3)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[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]]),l.rightLabel?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["transition-colors",{"text-blue-500":n.value}])},e.toDisplayString(l.rightLabel),3)):e.createCommentVNode("",!0)]))}}),L=(s,t)=>{const r=s.__vccOpts||s;for(const[n,o]of t)r[n]=o;return r},Ts={},Is={class:"flex items-center justify-center h-full"};function Ms(s,t){return e.openBlock(),e.createElementBlock("div",Is,[...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 Rs=L(Ts,[["render",Ms]]),Xe={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>To)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ha)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ja)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ba)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Oo)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Po)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Uo)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>aa)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Aa)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ya)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>tl)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Yl)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>xi)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Li))};let Je="/api";function ye(s){Je=s||"/api"}function Ps(s,t){const r=Je.replace(/\/$/,""),o=s.startsWith("http")||s.startsWith("//")||r&&s.startsWith(r)?s:`${r}${s.startsWith("/")?s:`/${s}`}`;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 xe(s,t={}){const{params:r,...n}=t,o=Ps(s,r),l={...n.headers};n.body!=null&&(l["Content-Type"]=l["Content-Type"]??"application/json");const a=await fetch(o,{...n,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 R={get(s,t){return xe(s,{...t,method:"GET"})},post(s,t){return xe(s,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(s,t){return xe(s,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(s){return xe(s,{method:"DELETE"})}},Fs={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"},js={class:"flex items-center justify-between w-full gap-2"},Ws={class:"flex items-center gap-2 min-w-0"},Os={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},As={class:"flex flex-col justify-end"},qs={key:0,class:"flex items-center justify-end w-full gap-2"},re=e.defineComponent({__name:"vs-widget",props:{dashboard:{},prefix:{default:""},widget:{},height:{},filterURl:{},dashboardWidgets:{},selectedWidget:{},prefetchedData:{default:null}},emits:["update:current-widget-data"],setup(s,{emit:t}){const r=s,n=t,o=e.ref(null),l=e.ref(null),a=e.ref(null),i=e.ref({}),c=e.ref([]),d=e.computed(()=>{var m,y;const x=(m=r.dashboardWidgets)==null?void 0:m.find(_=>_.name===r.widget);return((y=x==null?void 0:x.data)==null?void 0:y.title)??(x==null?void 0:x.title)??""}),p=e.computed(()=>{var m;const x=(m=r.dashboardWidgets)==null?void 0:m.find(y=>y.name===r.widget);return(x==null?void 0:x.type)??"text"}),h=e.computed(()=>{var x,m;return r.height||((m=(x=i.value)==null?void 0:x.style)==null?void 0:m.height)||480}),b=e.computed(()=>{var m;const x=(m=i.value)==null?void 0:m.controls;return!x||typeof x=="boolean"?[]:Object.keys(x).map(y=>({name:y,options:x[y]}))}),g=e.computed(()=>{const x=p.value?`bi-${p.value}`:"";return x&&x in Xe?Xe[x]:null});function u(x,m){var y,_;(_=(y=l.value)==null?void 0:y.changeStyle)==null||_.call(y,x,m)}function w(x,m){const y=c.value.find(_=>_.name===m);y?y.option=x:c.value.push({name:m,option:x}),$()}function $(){var m,y;let x=`/bi-data?dashboard=${r.dashboard}&widget=${r.widget}`;c.value.forEach(_=>{x+=`&${_.name}=${_.option}`}),(y=(m=l.value)==null?void 0:m.getDataFromURL)==null||y.call(m,x)}function V(){const x=a.value;if(x!=null&&x.getDataURL){const m=x.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),y=document.createElement("a");y.href=m,y.download="chart.png",document.body.appendChild(y),y.click(),document.body.removeChild(y)}}return e.onMounted(()=>{r.prefix&&ye(r.prefix)}),e.watch(()=>r.filterURl,x=>{var m,y;x&&((y=(m=l.value)==null?void 0:m.setFilter)==null||y.call(m,x))}),e.watch(()=>r.selectedWidget,(x,m)=>{var y;x!==m&&x===((y=i.value)==null?void 0:y.id)&&n("update:current-widget-data",i.value)}),e.watch(i,(x,m)=>{(x==null?void 0:x.id)!==(m==null?void 0:m.id)&&n("update:current-widget-data",x)},{deep:!0}),(x,m)=>{var y,_,k;return e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:o,class:"box-border relative p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto overflow-hidden",style:e.normalizeStyle({height:h.value+"px",maxHeight:h.value+"px"})},[["text","cluster","map"].includes(p.value)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Fs,[e.createElementVNode("div",js,[e.createElementVNode("div",Ws,[e.createElementVNode("span",Os,e.toDisplayString(d.value),1)]),e.createElementVNode("div",As,[(y=b.value)!=null&&y.length?(e.openBlock(),e.createElementBlock("span",qs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((_=b.value)==null?void 0:_.filter(f=>(f==null?void 0:f.options)&&(f==null?void 0:f.name)!=="export"),f=>{var E,B;return e.openBlock(),e.createElementBlock("div",{key:f==null?void 0:f.name},[Array.isArray(f==null?void 0:f.options)?(e.openBlock(),e.createBlock(Ss,{key:0,title:f==null?void 0:f.name,options:f==null?void 0:f.options,value:((B=(E=i.value)==null?void 0:E.data)==null?void 0:B[f==null?void 0:f.name])??null,onSelected:C=>w(C,f==null?void 0:f.name)},null,8,["title","options","value","onSelected"])):typeof f.options=="boolean"?(e.openBlock(),e.createBlock(Ls,{key:1,"left-label":f==null?void 0:f.name,"model-value":!!(f!=null&&f.options),"onUpdate:isEnabled":C=>u(f==null?void 0:f.name,C)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(k=b.value)!=null&&k.some(f=>(f==null?void 0:f.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",onClick:V},[e.createVNode(e.unref(ms),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])),e.createElementVNode("div",{class:"w-full h-full",onClick:m[2]||(m[2]=e.withModifiers(()=>{},["stop"]))},[g.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(g.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":a.value,"onUpdate:currentWidget":m[0]||(m[0]=f=>a.value=f),"widget-data":i.value,"onUpdate:widgetData":m[1]||(m[1]=f=>i.value=f),dashboard:x.dashboard,title:d.value,widget:x.widget,"prefetched-data":x.prefetchedData},null,40,["current-widget","widget-data","dashboard","title","widget","prefetched-data"])):(e.openBlock(),e.createBlock(Rs,{key:1,class:"w-full h-full"}))])],4)}}}),vs={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},Us={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},Hs={class:"max-w-sm mx-auto mt-6"},Gs={class:"font-medium text-gray-800 dark:text-neutral-200"},Zs={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},ke=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",vs,[e.createElementVNode("div",null,[e.createElementVNode("div",Us,[r[0]||(r[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",Hs,[e.createElementVNode("p",Gs,e.toDisplayString(t.title),1),e.createElementVNode("p",Zs,e.toDisplayString(t.text),1)])])])]))}}),Qs={components:{filterIcon:{__name:"filter",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(gs),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},Xs={class:"flex items-center"},Js={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 Ks(s,t,r,n,o,l){const a=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",Xs,[r.filterScheme?(e.openBlock(),e.createElementBlock("button",Js,[e.createVNode(a),t[0]||(t[0]=e.createTextVNode(" Фільтри ",-1))])):e.createCommentVNode("",!0)])}const Ys={components:{VsFilterHeader:L(Qs,[["render",Ks]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},er={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},tr={class:"grow"},sr={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},rr={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"},nr={key:0,class:"flex items-center gap-3"};function or(s,t,r,n,o,l){var i,c,d;const a=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",er,[e.createElementVNode("div",tr,[e.createElementVNode("h1",sr,e.toDisplayString((i=r.dashboardData)==null?void 0:i.title),1),(c=r.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",rr,e.toDisplayString((d=r.dashboardData)==null?void 0:d.description),1)):e.createCommentVNode("",!0)]),r.filters?(e.openBlock(),e.createElementBlock("div",nr,[e.createVNode(a,{filterScheme:r.filters,"onFilters:changed":t[0]||(t[0]=p=>s.$emit("filters:changed",p))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const ar=L(Ys,[["render",or]]),lr={key:0,class:"text-gray-400 shrink-0"},ir=["onClick"],cr=["onClick"],dr={key:4,class:"text-gray-900 font-medium truncate"},Ke={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(s){const t=s,r=q.useRouter(),n=e.computed(()=>Array.isArray(t.items)?t.items:[]);function o(l){r!=null&&r.push?r.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",s.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",lr,[e.createVNode(e.unref(us),{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,ir)):e.unref(r)&&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,cr)):(e.openBlock(),e.createElementBlock("span",dr,e.toDisplayString(c.label),1))],64))),128))],2)}}},pr={components:{VsWidget:re,VsNewNodata:ke,VsHeader:ar,VsBreadcrumbs:Ke},props:["id","prefix"],data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},async mounted(){ye(this.prefix||"/api"),await this.fetchData()},methods:{async fetchData(){if(this.id)try{const s=await R.get(`/bi-dashboard/${this.id}`);this.dashboardData=s}catch(s){console.error(s)}},columnClass(s){const t=s!=null&&s.col?s==null?void 0:s.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(s){var r;this.filterURl="";let t="&filter=";(r=s==null?void 0:s.url)!=null&&r.length&&(s.url.split("|").forEach(o=>{const l=o.split("=");t+=`${l[0]}=${l[1]}`}),this.filterURl+=t)}}},hr={class:"w-full pb-8 overflow-y-auto mx-auto"},ur={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function mr(s,t,r,n,o,l){var c;const a=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",hr,[e.createElementVNode("div",ur,[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,b;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]"])},[(b=d.widgets)!=null&&b.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(d.widgets,g=>(e.openBlock(),e.createBlock(i,{key:g,dashboard:r.id,widget:g,"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:r.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 fr=L(pr,[["render",mr]]);var Ye=(s=>(s.Dashboard="/dashboard",s.BiPlatform="/bi-platform",s.EditorBase="/editor",s.AllDashboards="/dashboards",s.DashboardByName="/dashboards/:name",s))(Ye||{}),et;(s=>{(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"})(s.Types||(s.Types={}))})(et||(et={}));var j=(s=>(s.AllDashboards="all-dashboards",s.BiPlatform="bi-platform",s.Dashboard="dashboard",s.Erobota="erobota",s.Datatest="datatest",s.Sourcedate="sourcedate",s.Widgetwidget="widgetwidget",s.Test="test",s.Demo="demo",s.Crm="crm",s.Editor="editor-all-dashboards",s.EditorDashboard="editor-dashboard",s.EditorWidget="editor-widget",s.Editordetails="editordetails",s.Dbtables="dbtables",s.Biviewer="biviewer",s.Biviewerinner="biviewerinner",s.Bieditor="bieditor",s.Bieditorinner="bieditorinner",s))(j||{});const gr={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},br={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},yr={class:"font-medium text-gray-800 dark:text-white"},xr={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},kr={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},ne=L({__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(s,{emit:t}){const r=s,n=t,o=e.computed(()=>r.size==="small"?"md:max-w-[40%] w-full max-w-md":r.size==="lg"?"md:max-w-[70%] w-full max-w-4xl":"md:max-w-[50%] w-full max-w-lg");function l(){n("update:visible",!1),n("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:s.teleport},[s.visible?(e.openBlock(),e.createElementBlock("div",gr,[e.createElementVNode("div",{class:"absolute inset-0 bg-black/50","aria-hidden":"true",onMousedown:c[0]||(c[0]=d=>s.closeClickBack&&d.target===d.currentTarget&&l())},null,32),e.createVNode(e.Transition,{name:"vs-modal",appear:""},{default:e.withCtx(()=>[s.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",br,[e.createElementVNode("h3",yr,e.toDisplayString(s.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",xr,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",kr,[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"]]),wr={__name:"icon-plus",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Ge),e.mergeProps(t.$attrs,{size:24}),null,16))}},_r={class:"mb-4 overflow-auto scrollbar max-h-96"},$r={__name:"vs-editor-create-widget",props:{columns:{type:Array,default:()=>[]},selectedDashboard:String,inline:{type:Boolean,default:!1}},emits:["update-data"],setup(s,{expose:t,emit:r}){var u;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(u=e.getCurrentInstance().proxy)==null?void 0:u.$notify,l=r,a=s,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 b=async()=>{var w;try{const $=(w=d.value)==null?void 0:w.doValidation;typeof $=="function"&&await $(),await R.post(`/bi-dashboard/${a.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await l("update-data"),c.value={},i.value=!1}catch($){const V=($==null?void 0:$.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:V})}},g=e.computed(()=>{var w,$,V,x;return{title:{type:"text",label:"Назва віджета",placeholder:"Назва віджета",validators:["required"]},x:{type:"select",label:"Вісь X",view:"buttons",style:{size:"xs"},validators:["required"],options:($=(w=a.columns)==null?void 0:w.filter(m=>(m==null?void 0:m.type)=="text"||(m==null?void 0:m.type)==="date"||(m==null?void 0:m.type)==="timestamp without time zone"||(m==null?void 0:m.type)==="boolean"||(m==null?void 0:m.type)==="integer"))==null?void 0:$.map(({name:m,type:y})=>({id:m,text:m,type:y}))},metric:{type:"select",label:"Вісь Y",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(x=(V=a.columns)==null?void 0:V.filter(m=>(m==null?void 0:m.type)==="numeric"||(m==null?void 0:m.type)==="double precision"))==null?void 0:x.map(({name:m,type:y})=>({id:m,text:m,type:y}))]},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(w,$)=>{const V=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[s.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(V,{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(wr,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[$[1]||($[1]=e.createTextVNode(" Створити віджет ",-1))]),_:1})),e.createVNode(ne,{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:b,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",_r,[e.createVNode(e.unref(n),{ref_key:"form",ref:d,schema:g.value,values:c.value,"onUpdate:values":$[0]||($[0]=x=>c.value=x)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},tt={__name:"delete",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Bs),e.mergeProps(t.$attrs,{size:24}),null,16))}},Ne={__name:"close",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Qe),e.mergeProps(t.$attrs,{size:24}),null,16))}},st={__name:"edit",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref($s),e.mergeProps(t.$attrs,{size:24}),null,16))}},Er={class:"space-y-4"},Vr={__name:"vs-editor-form-style",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){var y,_,k,f;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,i=e.ref(null),c=e.computed(()=>a.dashboardId||i.value),d=((y=a.data)==null?void 0:y.type)||((k=(_=a.data)==null?void 0:_.data)==null?void 0:k.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},b={show:{label:"Легенда",type:"switcher",title:"Показати легенду"}},g={show:{label:"Тултіп",type:"switcher",title:"Показати тултіп"}},u=(f=a.data)==null?void 0:f.style,w=e.ref(u!=null&&u.label?{...u.label}:{show:h.label}),$=e.ref(u!=null&&u.legend?{...u.legend}:{show:h.legend}),V=e.ref(u!=null&&u.tooltip?{...u.tooltip}:{show:h.tooltip}),x=()=>{const E=new CustomEvent(`update-style-${a.widgetName}`);E.chartId=a.widgetName,E.options={options:{legend:$.value,tooltip:V.value,label:w.value},seriesOptions:w.value},window.dispatchEvent(E)};e.watch(w,x,{deep:!0}),e.watch($,x,{deep:!0}),e.watch(V,x,{deep:!0});const m=async()=>{try{await R.put(`/bi-dashboard/${c.value}/${a.widgetName}`,{style:{legend:$.value,tooltip:V.value,label:w.value}});const E=new CustomEvent(`update-style-${a.widgetName}`);E.chartId=a.widgetName,E.options={options:{legend:$.value,tooltip:V.value,label:w.value},seriesOptions:w.value},window.dispatchEvent(E),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const E=new URLSearchParams(window.top.location.search);i.value=E.get("dashboard"),x()}),t({requestUpdateWidget:m}),(E,B)=>(e.openBlock(),e.createElementBlock("div",Er,[e.createVNode(e.unref(n),{schema:b,values:$.value,"onUpdate:values":B[0]||(B[0]=C=>$.value=C),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:g,values:V.value,"onUpdate:values":B[1]||(B[1]=C=>V.value=C),class:"p-0"},null,8,["values"])]))}};function Se(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let J=Se();function rt(s){J=s}const nt=/[&<>"']/,Br=new RegExp(nt.source,"g"),ot=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Dr=new RegExp(ot.source,"g"),Cr={"&":"&","<":"<",">":">",'"':""","'":"'"},at=s=>Cr[s];function A(s,t){if(t){if(nt.test(s))return s.replace(Br,at)}else if(ot.test(s))return s.replace(Dr,at);return s}const Nr=/(^|[^\[])\^/g;function T(s,t){let r=typeof s=="string"?s:s.source;t=t||"";const n={replace:(o,l)=>{let a=typeof l=="string"?l:l.source;return a=a.replace(Nr,"$1"),r=r.replace(o,a),n},getRegex:()=>new RegExp(r,t)};return n}function lt(s){try{s=encodeURI(s).replace(/%25/g,"%")}catch{return null}return s}const oe={exec:()=>null};function it(s,t){const r=s.replace(/\|/g,(l,a,i)=>{let c=!1,d=a;for(;--d>=0&&i[d]==="\\";)c=!c;return c?"|":" |"}),n=r.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 ae(s,t,r){const n=s.length;if(n===0)return"";let o=0;for(;o<n&&s.charAt(n-o-1)===t;)o++;return s.slice(0,n-o)}function Sr(s,t){if(s.indexOf(t[1])===-1)return-1;let r=0;for(let n=0;n<s.length;n++)if(s[n]==="\\")n++;else if(s[n]===t[0])r++;else if(s[n]===t[1]&&(r--,r<0))return n;return-1}function ct(s,t,r,n){const o=t.href,l=t.title?A(t.title):null,a=s[1].replace(/\\([\[\]])/g,"$1");if(s[0].charAt(0)!=="!"){n.state.inLink=!0;const i={type:"link",raw:r,href:o,title:l,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,i}return{type:"image",raw:r,href:o,title:l,text:A(a)}}function zr(s,t){const r=s.match(/^(\s+)(?:```)/);if(r===null)return t;const n=r[1];return t.split(`
|
|
136
|
+
*/const Je=W("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Se={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},Dr=["onClick"],Sr={class:"flex items-center justify-between w-full"},zr={key:0},Lr=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),l=e.ref(s.value??null),a=e.ref(null),i=e.computed(()=>{const g=s.options;return typeof g=="string"?g.split(",").map((m,k)=>({id:k,text:m.trim()})):Array.isArray(g)?g:[]}),c=e.computed(()=>{const g=i.value.find(m=>(m.id??m)===l.value);return g?g.text??String(g):s.title??""}),d=g=>{const m=(g==null?void 0:g.id)??g;l.value=m,o.value=!1,n("selected",m),document.removeEventListener("click",p)},p=g=>{a.value&&!a.value.contains(g.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)},b=g=>(Se==null?void 0:Se[g])??g;return e.onUnmounted(()=>{document.removeEventListener("click",p)}),(g,m)=>(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(b(c.value))+" ",1),m[0]||(m[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,k=>(e.openBlock(),e.createElementBlock("div",{key:k.id||k,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:x=>d(k)},[e.createElementVNode("div",Sr,[e.createElementVNode("span",null,e.toDisplayString(b(k.text||k)),1),l.value===(k.id||k)?(e.openBlock(),e.createElementBlock("span",zr,[...m[1]||(m[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,Dr))),128))],512)):e.createCommentVNode("",!0)],64))}}),Tr={class:"flex items-center space-x-2"},Ir=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(l,a)=>(e.openBlock(),e.createElementBlock("div",Tr,[r.leftLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["transition-colors",{"text-blue-500":!n.value}])},e.toDisplayString(r.leftLabel),3)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[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]]),r.rightLabel?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["transition-colors",{"text-blue-500":n.value}])},e.toDisplayString(r.rightLabel),3)):e.createCommentVNode("",!0)]))}}),M=(r,t)=>{const s=r.__vccOpts||r;for(const[n,o]of t)s[n]=o;return s},Mr={},Pr={class:"flex items-center justify-center h-full"};function Fr(r,t){return e.openBlock(),e.createElementBlock("div",Pr,[...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 Rr=M(Mr,[["render",Fr]]),Ke={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Pa)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ql)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ei)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Dl)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>va)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Oa)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Za)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>cl)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ul)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>wl)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ni)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>rc)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>_c)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Mc))};let Ye="/api";function xe(r){Ye=r||"/api"}function jr(r,t){const s=Ye.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 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 ke(r,t={}){const{params:s,...n}=t,o=jr(r,s),l={...n.headers};n.body!=null&&(l["Content-Type"]=l["Content-Type"]??"application/json");const a=await fetch(o,{...n,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 A={get(r,t){return ke(r,{...t,method:"GET"})},post(r,t){return ke(r,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(r,t){return ke(r,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(r){return ke(r,{method:"DELETE"})}},Or={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"},Ar={class:"flex items-center justify-between w-full gap-2"},Wr={class:"flex items-center gap-2 min-w-0"},qr={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},vr={class:"flex flex-col justify-end"},Ur={key:0,class:"flex items-center justify-end w-full gap-2"},de=e.defineComponent({__name:"vs-widget",props:{dashboard:{},prefix:{default:""},widget:{},height:{},filterURl:{},dashboardWidgets:{},selectedWidget:{},prefetchedData:{default:null}},emits:["update:current-widget-data"],setup(r,{emit:t}){const s=r,n=t,o=e.ref(null),l=e.ref(null),a=e.ref(null),i=e.ref({}),c=e.ref([]),d=e.computed(()=>{var u,w;const f=(u=s.dashboardWidgets)==null?void 0:u.find(V=>V.name===s.widget);return((w=f==null?void 0:f.data)==null?void 0:w.title)??(f==null?void 0:f.title)??""}),p=e.computed(()=>{var u;const f=(u=s.dashboardWidgets)==null?void 0:u.find(w=>w.name===s.widget);return(f==null?void 0:f.type)??"text"}),h=e.computed(()=>{var f,u;return s.height||((u=(f=i.value)==null?void 0:f.style)==null?void 0:u.height)||480}),b=e.computed(()=>{var u;const f=(u=i.value)==null?void 0:u.controls;return!f||typeof f=="boolean"?[]:Object.keys(f).map(w=>({name:w,options:f[w]}))}),g=e.computed(()=>{const f=p.value?`bi-${p.value}`:"";return f&&f in Ke?Ke[f]:null});function m(f,u){var w,V;(V=(w=l.value)==null?void 0:w.changeStyle)==null||V.call(w,f,u)}function k(f,u){const w=c.value.find(V=>V.name===u);w?w.option=f:c.value.push({name:u,option:f}),x()}function x(){var u,w;let f=`/bi-data?dashboard=${s.dashboard}&widget=${s.widget}`;c.value.forEach(V=>{f+=`&${V.name}=${V.option}`}),(w=(u=l.value)==null?void 0:u.getDataFromURL)==null||w.call(u,f)}function $(){const f=a.value;if(f!=null&&f.getDataURL){const u=f.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),w=document.createElement("a");w.href=u,w.download="chart.png",document.body.appendChild(w),w.click(),document.body.removeChild(w)}}return e.onMounted(()=>{s.prefix&&xe(s.prefix)}),e.watch(()=>s.filterURl,f=>{var u,w;f&&((w=(u=l.value)==null?void 0:u.setFilter)==null||w.call(u,f))}),e.watch(()=>s.selectedWidget,(f,u)=>{var w;f!==u&&f===((w=i.value)==null?void 0:w.id)&&n("update:current-widget-data",i.value)}),e.watch(i,(f,u)=>{(f==null?void 0:f.id)!==(u==null?void 0:u.id)&&n("update:current-widget-data",f)},{deep:!0}),(f,u)=>{var w,V,_;return e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:o,class:"box-border relative p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto overflow-hidden",style:e.normalizeStyle({height:h.value+"px",maxHeight:h.value+"px"})},[["text","cluster","map"].includes(p.value)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Or,[e.createElementVNode("div",Ar,[e.createElementVNode("div",Wr,[e.createElementVNode("span",qr,e.toDisplayString(d.value),1)]),e.createElementVNode("div",vr,[(w=b.value)!=null&&w.length?(e.openBlock(),e.createElementBlock("span",Ur,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((V=b.value)==null?void 0:V.filter(y=>(y==null?void 0:y.options)&&(y==null?void 0:y.name)!=="export"),y=>{var E,N;return e.openBlock(),e.createElementBlock("div",{key:y==null?void 0:y.name},[Array.isArray(y==null?void 0:y.options)?(e.openBlock(),e.createBlock(Lr,{key:0,title:y==null?void 0:y.name,options:y==null?void 0:y.options,value:((N=(E=i.value)==null?void 0:E.data)==null?void 0:N[y==null?void 0:y.name])??null,onSelected:S=>k(S,y==null?void 0:y.name)},null,8,["title","options","value","onSelected"])):typeof y.options=="boolean"?(e.openBlock(),e.createBlock(Ir,{key:1,"left-label":y==null?void 0:y.name,"model-value":!!(y!=null&&y.options),"onUpdate:isEnabled":S=>m(y==null?void 0:y.name,S)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(_=b.value)!=null&&_.some(y=>(y==null?void 0:y.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",onClick:$},[e.createVNode(e.unref(gr),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])),e.createElementVNode("div",{class:"w-full h-full",onClick:u[2]||(u[2]=e.withModifiers(()=>{},["stop"]))},[g.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(g.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":a.value,"onUpdate:currentWidget":u[0]||(u[0]=y=>a.value=y),"widget-data":i.value,"onUpdate:widgetData":u[1]||(u[1]=y=>i.value=y),dashboard:r.dashboard,title:d.value,widget:r.widget,"prefetched-data":r.prefetchedData},null,40,["current-widget","widget-data","dashboard","title","widget","prefetched-data"])):(e.openBlock(),e.createBlock(Rr,{key:1,class:"w-full h-full"}))])],4)}}}),Hr={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},Gr={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},Zr={class:"max-w-sm mx-auto mt-6"},Qr={class:"font-medium text-gray-800 dark:text-neutral-200"},Xr={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},we=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(r){return(t,s)=>(e.openBlock(),e.createElementBlock("div",Hr,[e.createElementVNode("div",null,[e.createElementVNode("div",Gr,[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",Zr,[e.createElementVNode("p",Qr,e.toDisplayString(r.title),1),e.createElementVNode("p",Xr,e.toDisplayString(r.text),1)])])])]))}}),Jr={components:{filterIcon:{__name:"filter",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(yr),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},Kr={class:"flex items-center"},Yr={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 es(r,t,s,n,o,l){const a=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",Kr,[s.filterScheme?(e.openBlock(),e.createElementBlock("button",Yr,[e.createVNode(a),t[0]||(t[0]=e.createTextVNode(" Фільтри ",-1))])):e.createCommentVNode("",!0)])}const ts={components:{VsFilterHeader:M(Jr,[["render",es]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},rs={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},ss={class:"grow"},ns={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},os={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"},as={key:0,class:"flex items-center gap-3"};function ls(r,t,s,n,o,l){var i,c,d;const a=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",rs,[e.createElementVNode("div",ss,[e.createElementVNode("h1",ns,e.toDisplayString((i=s.dashboardData)==null?void 0:i.title),1),(c=s.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",os,e.toDisplayString((d=s.dashboardData)==null?void 0:d.description),1)):e.createCommentVNode("",!0)]),s.filters?(e.openBlock(),e.createElementBlock("div",as,[e.createVNode(a,{filterScheme:s.filters,"onFilters:changed":t[0]||(t[0]=p=>r.$emit("filters:changed",p))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const is=M(ts,[["render",ls]]),cs={key:0,class:"text-gray-400 shrink-0"},ds=["onClick"],ps=["onClick"],hs={key:4,class:"text-gray-900 font-medium truncate"},et={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(r){const t=r,s=U.useRouter(),n=e.computed(()=>Array.isArray(t.items)?t.items:[]);function o(l){s!=null&&s.push?s.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(n.value,(c,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d},[d>0?(e.openBlock(),e.createElementBlock("span",cs,[e.createVNode(e.unref(fr),{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,ps)):(e.openBlock(),e.createElementBlock("span",hs,e.toDisplayString(c.label),1))],64))),128))],2)}}},us={components:{VsWidget:de,VsNewNodata:we,VsHeader:is,VsBreadcrumbs:et},props:["id","prefix"],data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},async mounted(){xe(this.prefix||"/api"),await this.fetchData()},methods:{async fetchData(){if(this.id)try{const r=await A.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 s;this.filterURl="";let t="&filter=";(s=r==null?void 0:r.url)!=null&&s.length&&(r.url.split("|").forEach(o=>{const l=o.split("=");t+=`${l[0]}=${l[1]}`}),this.filterURl+=t)}}},ms={class:"w-full pb-8 overflow-y-auto mx-auto"},fs={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function gs(r,t,s,n,o,l){var c;const a=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",ms,[e.createElementVNode("div",fs,[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,b;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]"])},[(b=d.widgets)!=null&&b.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(d.widgets,g=>(e.openBlock(),e.createBlock(i,{key:g,dashboard:s.id,widget:g,"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:s.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 bs=M(us,[["render",gs]]);var tt=(r=>(r.Dashboard="/dashboard",r.BiPlatform="/bi-platform",r.EditorBase="/editor",r.AllDashboards="/dashboards",r.DashboardByName="/dashboards/:name",r))(tt||{}),rt;(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={}))})(rt||(rt={}));var q=(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))(q||{});const ys={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},xs={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},ks={class:"font-medium text-gray-800 dark:text-white"},ws={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},_s={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},pe=M({__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 l(){n("update:visible",!1),n("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",ys,[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",xs,[e.createElementVNode("h3",ks,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",ws,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",_s,[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"]]),$s={__name:"icon-plus",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Qe),e.mergeProps(t.$attrs,{size:24}),null,16))}},Es={class:"mb-4 overflow-auto scrollbar max-h-96"},Bs={__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 m;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(m=e.getCurrentInstance().proxy)==null?void 0:m.$notify,l=s,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 b=async()=>{var k;try{const x=(k=d.value)==null?void 0:k.doValidation;typeof x=="function"&&await x(),await A.post(`/bi-dashboard/${a.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await l("update-data"),c.value={},i.value=!1}catch(x){const $=(x==null?void 0:x.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:$})}},g=e.computed(()=>{var k,x,$,f;return{title:{type:"text",label:"Назва віджета",placeholder:"Назва віджета",validators:["required"]},x:{type:"select",label:"Вісь X",view:"buttons",style:{size:"xs"},validators:["required"],options:(x=(k=a.columns)==null?void 0:k.filter(u=>(u==null?void 0:u.type)=="text"||(u==null?void 0:u.type)==="date"||(u==null?void 0:u.type)==="timestamp without time zone"||(u==null?void 0:u.type)==="boolean"||(u==null?void 0:u.type)==="integer"))==null?void 0:x.map(({name:u,type:w})=>({id:u,text:u,type:w}))},metric:{type:"select",label:"Вісь Y",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(f=($=a.columns)==null?void 0:$.filter(u=>(u==null?void 0:u.type)==="numeric"||(u==null?void 0:u.type)==="double precision"))==null?void 0:f.map(({name:u,type:w})=>({id:u,text:u,type:w}))]},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(k,x)=>{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($s,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[x[1]||(x[1]=e.createTextVNode(" Створити віджет ",-1))]),_:1})),e.createVNode(pe,{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:b,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",Es,[e.createVNode(e.unref(n),{ref_key:"form",ref:d,schema:g.value,values:c.value,"onUpdate:values":x[0]||(x[0]=f=>c.value=f)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},st={__name:"delete",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Nr),e.mergeProps(t.$attrs,{size:24}),null,16))}},ze={__name:"close",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Je),e.mergeProps(t.$attrs,{size:24}),null,16))}},nt={__name:"edit",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Br),e.mergeProps(t.$attrs,{size:24}),null,16))}},Vs={class:"space-y-4"},Cs={__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 w,V,_,y;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=s,a=r,i=e.ref(null),c=e.computed(()=>a.dashboardId||i.value),d=((w=a.data)==null?void 0:w.type)||((_=(V=a.data)==null?void 0:V.data)==null?void 0:_.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},b={show:{label:"Легенда",type:"switcher",title:"Показати легенду"}},g={show:{label:"Тултіп",type:"switcher",title:"Показати тултіп"}},m=(y=a.data)==null?void 0:y.style,k=e.ref(m!=null&&m.label?{...m.label}:{show:h.label}),x=e.ref(m!=null&&m.legend?{...m.legend}:{show:h.legend}),$=e.ref(m!=null&&m.tooltip?{...m.tooltip}:{show:h.tooltip}),f=()=>{const E=new CustomEvent(`update-style-${a.widgetName}`);E.chartId=a.widgetName,E.options={options:{legend:x.value,tooltip:$.value,label:k.value},seriesOptions:k.value},window.dispatchEvent(E)};e.watch(k,f,{deep:!0}),e.watch(x,f,{deep:!0}),e.watch($,f,{deep:!0});const u=async()=>{try{await A.put(`/bi-dashboard/${c.value}/${a.widgetName}`,{style:{legend:x.value,tooltip:$.value,label:k.value}});const E=new CustomEvent(`update-style-${a.widgetName}`);E.chartId=a.widgetName,E.options={options:{legend:x.value,tooltip:$.value,label:k.value},seriesOptions:k.value},window.dispatchEvent(E),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const E=new URLSearchParams(window.top.location.search);i.value=E.get("dashboard"),f()}),t({requestUpdateWidget:u}),(E,N)=>(e.openBlock(),e.createElementBlock("div",Vs,[e.createVNode(e.unref(n),{schema:b,values:x.value,"onUpdate:values":N[0]||(N[0]=S=>x.value=S),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:g,values:$.value,"onUpdate:values":N[1]||(N[1]=S=>$.value=S),class:"p-0"},null,8,["values"])]))}};function Le(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ne=Le();function ot(r){ne=r}const at=/[&<>"']/,Ns=new RegExp(at.source,"g"),lt=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Ds=new RegExp(lt.source,"g"),Ss={"&":"&","<":"<",">":">",'"':""","'":"'"},it=r=>Ss[r];function H(r,t){if(t){if(at.test(r))return r.replace(Ns,it)}else if(lt.test(r))return r.replace(Ds,it);return r}const zs=/(^|[^\[])\^/g;function P(r,t){let s=typeof r=="string"?r:r.source;t=t||"";const n={replace:(o,l)=>{let a=typeof l=="string"?l:l.source;return a=a.replace(zs,"$1"),s=s.replace(o,a),n},getRegex:()=>new RegExp(s,t)};return n}function ct(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}const he={exec:()=>null};function dt(r,t){const s=r.replace(/\|/g,(l,a,i)=>{let c=!1,d=a;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 ue(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 Ls(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 pt(r,t,s,n){const o=t.href,l=t.title?H(t.title):null,a=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){n.state.inLink=!0;const i={type:"link",raw:s,href:o,title:l,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,i}return{type:"image",raw:s,href:o,title:l,text:H(a)}}function Ts(r,t){const s=r.match(/^(\s+)(?:```)/);if(s===null)return t;const n=s[1];return t.split(`
|
|
137
137
|
`).map(o=>{const l=o.match(/^\s+/);if(l===null)return o;const[a]=l;return a.length>=n.length?o.slice(n.length):o}).join(`
|
|
138
|
-
`)}class
|
|
139
|
-
`)}}}fences(t){const
|
|
140
|
-
`)}}blockquote(t){const
|
|
138
|
+
`)}class _e{constructor(t){F(this,"options");F(this,"rules");F(this,"lexer");this.options=t||ne}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:ue(n,`
|
|
139
|
+
`)}}}fences(t){const s=this.rules.block.fences.exec(t);if(s){const n=s[0],o=Ts(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=ue(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:ue(s[0],`
|
|
140
|
+
`)}}blockquote(t){const s=this.rules.block.blockquote.exec(t);if(s){let n=ue(s[0],`
|
|
141
141
|
`).split(`
|
|
142
142
|
`),o="",l="";const a=[];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(`
|
|
143
143
|
`),h=p.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
|
|
144
144
|
$1`).replace(/^ {0,3}>[ \t]?/gm,"");o=o?`${o}
|
|
145
145
|
${p}`:p,l=l?`${l}
|
|
146
|
-
${h}`:h;const b=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,a,!0),this.lexer.state.top=b,n.length===0)break;const g=a[a.length-1];if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){const
|
|
146
|
+
${h}`:h;const b=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,a,!0),this.lexer.state.top=b,n.length===0)break;const g=a[a.length-1];if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){const m=g,k=m.raw+`
|
|
147
147
|
`+n.join(`
|
|
148
|
-
`)
|
|
148
|
+
`),x=this.blockquote(k);a[a.length-1]=x,o=o.substring(0,o.length-m.raw.length)+x.raw,l=l.substring(0,l.length-m.text.length)+x.text;break}else if((g==null?void 0:g.type)==="list"){const m=g,k=m.raw+`
|
|
149
149
|
`+n.join(`
|
|
150
|
-
`)
|
|
151
|
-
`);continue}}return{type:"blockquote",raw:o,tokens:a,text:l}}}list(t){let
|
|
152
|
-
`,1)[0].replace(/^\t
|
|
153
|
-
`,1)[0],g=!h.trim(),
|
|
154
|
-
`,t=t.substring(b.length+1),c=!0),!c){const
|
|
155
|
-
`,1)[0];let
|
|
156
|
-
`+
|
|
157
|
-
`+b}!g&&!b.trim()&&(g=!0),d+=
|
|
158
|
-
`,t=t.substring(
|
|
159
|
-
`):[],a={type:"table",raw:
|
|
160
|
-
`?
|
|
161
|
-
]`).replace("lheading",
|
|
162
|
-
`),this.blockTokens(t,this.tokens);for(let
|
|
163
|
-
`:
|
|
150
|
+
`),x=this.list(k);a[a.length-1]=x,o=o.substring(0,o.length-g.raw.length)+x.raw,l=l.substring(0,l.length-m.raw.length)+x.raw,n=k.substring(a[a.length-1].raw.length).split(`
|
|
151
|
+
`);continue}}return{type:"blockquote",raw:o,tokens:a,text:l}}}list(t){let s=this.rules.block.list.exec(t);if(s){let n=s[1].trim();const o=n.length>1,l={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 a=new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);let i=!1;for(;t;){let c=!1,d="",p="";if(!(s=a.exec(t))||this.rules.block.hr.test(t))break;d=s[0],t=t.substring(d.length);let h=s[2].split(`
|
|
152
|
+
`,1)[0].replace(/^\t+/,$=>" ".repeat(3*$.length)),b=t.split(`
|
|
153
|
+
`,1)[0],g=!h.trim(),m=0;if(this.options.pedantic?(m=2,p=h.trimStart()):g?m=s[1].length+1:(m=s[2].search(/[^ ]/),m=m>4?1:m,p=h.slice(m),m+=s[1].length),g&&/^[ \t]*$/.test(b)&&(d+=b+`
|
|
154
|
+
`,t=t.substring(b.length+1),c=!0),!c){const $=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),f=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),u=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),w=new RegExp(`^ {0,${Math.min(3,m-1)}}#`),V=new RegExp(`^ {0,${Math.min(3,m-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const _=t.split(`
|
|
155
|
+
`,1)[0];let y;if(b=_,this.options.pedantic?(b=b.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),y=b):y=b.replace(/\t/g," "),u.test(b)||w.test(b)||V.test(b)||$.test(b)||f.test(b))break;if(y.search(/[^ ]/)>=m||!b.trim())p+=`
|
|
156
|
+
`+y.slice(m);else{if(g||h.replace(/\t/g," ").search(/[^ ]/)>=4||u.test(h)||w.test(h)||f.test(h))break;p+=`
|
|
157
|
+
`+b}!g&&!b.trim()&&(g=!0),d+=_+`
|
|
158
|
+
`,t=t.substring(_.length+1),h=y.slice(m)}}l.loose||(i?l.loose=!0:/\n[ \t]*\n[ \t]*$/.test(d)&&(i=!0));let k=null,x;this.options.gfm&&(k=/^\[[ xX]\] /.exec(p),k&&(x=k[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),l.items.push({type:"list_item",raw:d,task:!!k,checked:x,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 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"):"",l=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:l}}}table(t){const s=this.rules.block.table.exec(t);if(!s||!/[:|]/.test(s[2]))return;const n=dt(s[1]),o=s[2].replace(/^\||\| *$/g,"").split("|"),l=s[3]&&s[3].trim()?s[3].replace(/\n[ \t]*$/,"").split(`
|
|
159
|
+
`):[],a={type:"table",raw:s[0],header:[],align:[],rows:[]};if(n.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<n.length;i++)a.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:a.align[i]});for(const i of l)a.rows.push(dt(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 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)===`
|
|
160
|
+
`?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:H(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 a=ue(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{const a=Ls(s[2],"()");if(a>-1){const c=(s[0].indexOf("!")===0?5:4)+s[1].length+a;s[2]=s[2].substring(0,a),s[0]=s[0].substring(0,c).trim(),s[3]=""}}let o=s[2],l="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);a&&(o=a[1],l=a[3])}else l=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)),pt(s,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.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," "),l=s[o.toLowerCase()];if(!l){const a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return pt(n,l,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 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,s=s.slice(-1*t.length+a);(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])&&a%3&&!((a+c)%3)){p+=c;continue}if(d-=c,d>0)continue;c=Math.min(c,c+d+p);const b=[...o[0]][0].length,g=t.slice(0,a+o.index+b+c);if(Math.min(a,c)%2){const k=g.slice(1,-1);return{type:"em",raw:g,text:k,tokens:this.lexer.inlineTokens(k)}}const m=g.slice(2,-2);return{type:"strong",raw:g,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(t){const s=this.rules.inline.code.exec(t);if(s){let n=s[2].replace(/\n/g," ");const o=/[^ ]/.test(n),l=/^ /.test(n)&&/ $/.test(n);return o&&l&&(n=n.substring(1,n.length-1)),n=H(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=H(s[1]),o="mailto:"+n):(n=H(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,l;if(s[2]==="@")o=H(s[0]),l="mailto:"+o;else{let a;do a=s[0],s[0]=((n=this.rules.inline._backpedal.exec(s[0]))==null?void 0:n[0])??"";while(a!==s[0]);o=H(s[0]),s[1]==="www."?l="http://"+s[0]:l=s[0]}return{type:"link",raw:s[0],text:o,href:l,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=H(s[0]),{type:"text",raw:s[0],text:n}}}}const Is=/^(?:[ \t]*(?:\n|$))+/,Ms=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ps=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,me=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Fs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ht=/(?:[*+-]|\d{1,9}[.)])/,ut=P(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,ht).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(),Te=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Rs=/^[^\n]+/,Ie=/(?!\s*\])(?:\\.|[^\[\]\\])+/,js=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ie).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Os=P(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ht).getRegex(),$e="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",Me=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,As=P("^ {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",Me).replace("tag",$e).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),mt=P(Te).replace("hr",me).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",$e).getRegex(),Pe={blockquote:P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",mt).getRegex(),code:Ms,def:js,fences:Ps,heading:Fs,hr:me,html:As,lheading:ut,list:Os,newline:Is,paragraph:mt,table:he,text:Rs},ft=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",me).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",$e).getRegex(),Ws={...Pe,table:ft,paragraph:P(Te).replace("hr",me).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ft).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",$e).getRegex()},qs={...Pe,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Me).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:he,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(Te).replace("hr",me).replace("heading",` *#{1,6} *[^
|
|
161
|
+
]`).replace("lheading",ut).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},gt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,vs=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,bt=/^( {2,}|\\)\n(?!\s*$)/,Us=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,fe="\\p{P}\\p{S}",Hs=P(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,fe).getRegex(),Gs=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Zs=P(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,fe).getRegex(),Qs=P("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,fe).getRegex(),Xs=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,fe).getRegex(),Js=P(/\\([punct])/,"gu").replace(/punct/g,fe).getRegex(),Ks=P(/^<(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(),Ys=P(Me).replace("(?:-->|$)","-->").getRegex(),en=P("^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",Ys).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ee=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,tn=P(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Ee).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),yt=P(/^!?\[(label)\]\[(ref)\]/).replace("label",Ee).replace("ref",Ie).getRegex(),xt=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ie).getRegex(),rn=P("reflink|nolink(?!\\()","g").replace("reflink",yt).replace("nolink",xt).getRegex(),Fe={_backpedal:he,anyPunctuation:Js,autolink:Ks,blockSkip:Gs,br:bt,code:vs,del:he,emStrongLDelim:Zs,emStrongRDelimAst:Qs,emStrongRDelimUnd:Xs,escape:gt,link:tn,nolink:xt,punctuation:Hs,reflink:yt,reflinkSearch:rn,tag:en,text:Us,url:he},sn={...Fe,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",Ee).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ee).getRegex()},Re={...Fe,escape:P(gt).replace("])","~|])").getRegex(),url:P(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},nn={...Re,br:P(bt).replace("{2,}","*").getRegex(),text:P(Re.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Be={normal:Pe,gfm:Ws,pedantic:qs},ge={normal:Fe,gfm:Re,breaks:nn,pedantic:sn};class Q{constructor(t){F(this,"tokens");F(this,"options");F(this,"state");F(this,"tokenizer");F(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ne,this.options.tokenizer=this.options.tokenizer||new _e,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:Be.normal,inline:ge.normal};this.options.pedantic?(s.block=Be.pedantic,s.inline=ge.pedantic):this.options.gfm&&(s.block=Be.gfm,this.options.breaks?s.inline=ge.breaks:s.inline=ge.gfm),this.tokenizer.rules=s}static get rules(){return{block:Be,inline:ge}}static lex(t,s){return new Q(s).lex(t)}static lexInline(t,s){return new Q(s).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
162
|
+
`),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,l,a;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+=`
|
|
163
|
+
`:s.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length),l=s[s.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
|
|
164
164
|
`+o.raw,l.text+=`
|
|
165
|
-
`+o.text,this.inlineQueue[this.inlineQueue.length-1].src=l.text):
|
|
165
|
+
`+o.text,this.inlineQueue[this.inlineQueue.length-1].src=l.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),l=s[s.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
|
|
166
166
|
`+o.raw,l.text+=`
|
|
167
|
-
`+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),
|
|
167
|
+
`+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),s.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),s.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=s[s.length-1],n&&(l==null?void 0:l.type)==="paragraph"?(l.raw+=`
|
|
168
168
|
`+o.raw,l.text+=`
|
|
169
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):
|
|
169
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):s.push(o),n=a.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length),l=s[s.length-1],l&&l.type==="text"?(l.raw+=`
|
|
170
170
|
`+o.raw,l.text+=`
|
|
171
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):
|
|
172
|
-
`;return o?'<pre><code class="language-'+
|
|
173
|
-
`:"<pre><code>"+(n?l:
|
|
171
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.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,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=>(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,a,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(l=t,this.options.extensions&&this.options.extensions.startInline){let p=1/0;const h=t.slice(1);let b;this.options.extensions.startInline.forEach(g=>{b=g.call({lexer:this},h),typeof b=="number"&&b>=0&&(p=Math.min(p,b))}),p<1/0&&p>=0&&(l=t.substring(0,p+1))}if(n=this.tokenizer.inlineText(l)){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 Ve{constructor(t){F(this,"options");F(this,"parser");this.options=t||ne}space(t){return""}code({text:t,lang:s,escaped:n}){var a;const o=(a=(s||"").match(/^\S*/))==null?void 0:a[0],l=t.replace(/\n$/,"")+`
|
|
172
|
+
`;return o?'<pre><code class="language-'+H(o)+'">'+(n?l:H(l,!0))+`</code></pre>
|
|
173
|
+
`:"<pre><code>"+(n?l:H(l,!0))+`</code></pre>
|
|
174
174
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
175
175
|
${this.parser.parse(t)}</blockquote>
|
|
176
|
-
`}html({text:t}){return t}heading({tokens:t,depth:
|
|
176
|
+
`}html({text:t}){return t}heading({tokens:t,depth:s}){return`<h${s}>${this.parser.parseInline(t)}</h${s}>
|
|
177
177
|
`}hr(t){return`<hr>
|
|
178
|
-
`}list(t){const
|
|
178
|
+
`}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 l=s?"ol":"ul",a=s&&n!==1?' start="'+n+'"':"";return"<"+l+a+`>
|
|
179
179
|
`+o+"</"+l+`>
|
|
180
|
-
`}listitem(t){let
|
|
180
|
+
`}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>
|
|
181
181
|
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
182
|
-
`}table(t){let
|
|
182
|
+
`}table(t){let s="",n="";for(let l=0;l<t.header.length;l++)n+=this.tablecell(t.header[l]);s+=this.tablerow({text:n});let o="";for(let l=0;l<t.rows.length;l++){const a=t.rows[l];n="";for(let i=0;i<a.length;i++)n+=this.tablecell(a[i]);o+=this.tablerow({text:n})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
|
|
183
183
|
<thead>
|
|
184
|
-
`+
|
|
184
|
+
`+s+`</thead>
|
|
185
185
|
`+o+`</table>
|
|
186
186
|
`}tablerow({text:t}){return`<tr>
|
|
187
187
|
${t}</tr>
|
|
188
|
-
`}tablecell(t){const
|
|
189
|
-
`}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:
|
|
190
|
-
`+this.renderer.text(i);
|
|
191
|
-
Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+A(n.message+"",!0)+"</pre>";return r?Promise.resolve(o):o}if(r)return Promise.reject(n);throw n}}}const K=new rn;function S(s,t){return K.parse(s,t)}S.options=S.setOptions=function(s){return K.setOptions(s),S.defaults=K.defaults,rt(S.defaults),S},S.getDefaults=Se,S.defaults=J,S.use=function(...s){return K.use(...s),S.defaults=K.defaults,rt(S.defaults),S},S.walkTokens=function(s,t){return K.walkTokens(s,t)},S.parseInline=K.parseInline,S.Parser=U,S.parser=U.parse,S.Renderer=Ve,S.TextRenderer=Pe,S.Lexer=v,S.lexer=v.lex,S.Tokenizer=we,S.Hooks=de,S.parse=S,S.options,S.setOptions,S.use,S.walkTokens,S.parseInline,U.parse,v.lex;const nn={class:"space-y-4"},on={__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(s,{expose:t,emit:r}){var _,k,f,E,B,C,M,O,G,Q,he,ue,me,fe,ge,F,X,be,Wt,Ot,At,qt,vt,Ut,Ht,Gt,Zt,Qt,Xt,Jt,Kt,Yt,es,ts,ss,rs,ns,os;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,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 D=a.columns??[];return D.length?D:d.value}),h=e.computed(()=>a.dashboardId||c.value);async function b(){if(a.columns!==null)return;const D=h.value;if(!(p.value.length||!D||!a.widgetName))try{const N=await R.get(`/bi-data?dashboard=${D}&widget=${a.widgetName}`);Array.isArray(N==null?void 0:N.columns)&&N.columns.length&&(d.value=N.columns)}catch{}}const g=D=>(D==null?void 0:D.name)!=null?{id:D.name,text:D.title||D.name}:null,u=D=>Array.isArray(D)?[...D].sort((N,Z)=>{const te=N.text&&N.text!==N.id,as=Z.text&&Z.text!==Z.id;return te&&!as?-1:!te&&as?1:(N.text||"").localeCompare(Z.text||"",void 0,{sensitivity:"base"})}):D,w=e.computed(()=>{const D=(p.value??[]).filter(N=>(N==null?void 0:N.type)=="text"||(N==null?void 0:N.type)==="date"||(N==null?void 0:N.type)==="timestamp without time zone"||(N==null?void 0:N.type)==="boolean"||(N==null?void 0:N.type)==="integer").map(g).filter(Boolean);return u(D)}),$=e.computed(()=>`${a.widgetName}-${w.value.length}-${(p.value??[]).length}`),V=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:[...w.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(D=>(D==null?void 0:D.type)==="numeric"||(D==null?void 0:D.type)==="double precision").map(g).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(D=>(D==null?void 0:D.type)=="text"||(D==null?void 0:D.type)==="boolean"||(D==null?void 0:D.type)==="integer").map(g).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Колонки",style:{size:"xs"},options:u((p.value??[]).map(g).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}})),x=e.ref({x:((k=(_=a.data)==null?void 0:_.data)==null?void 0:k.x)||((f=a.data)==null?void 0:f.x)||null,metric:((B=(E=a.data)==null?void 0:E.data)==null?void 0:B.metric)||((C=a.data)==null?void 0:C.metric)||null,columns:((O=(M=a.data)==null?void 0:M.data)==null?void 0:O.columns)||((G=a.data)==null?void 0:G.columns)||null,granularity:((he=(Q=a.data)==null?void 0:Q.data)==null?void 0:he.granularity)||((ue=a.data)==null?void 0:ue.granularity)||null,type:((fe=(me=a.data)==null?void 0:me.data)==null?void 0:fe.type)||((ge=a.data)==null?void 0:ge.type)||null,groupby:((X=(F=a.data)==null?void 0:F.data)==null?void 0:X.groupby)||a.data.groupby||null,fx:((Wt=(be=a.data)==null?void 0:be.data)==null?void 0:Wt.fx)||((Ot=a.data)==null?void 0:Ot.fx)||null,query:((qt=(At=a.data)==null?void 0:At.data)==null?void 0:qt.query)||((vt=a.data)==null?void 0:vt.query)||null,y_type:((Ht=(Ut=a.data)==null?void 0:Ut.data)==null?void 0:Ht.y_type)||((Gt=a.data)==null?void 0:Gt.y_type)||null,tableSQL:((Qt=(Zt=a.data)==null?void 0:Zt.data)==null?void 0:Qt.tableSQL)||((Xt=a.data)==null?void 0:Xt.tableSQL)||null,cls:((Kt=(Jt=a.data)==null?void 0:Jt.data)==null?void 0:Kt.cls)||((Yt=a.data)==null?void 0:Yt.cls)||null,text:((ts=(es=a.data)==null?void 0:es.data)==null?void 0:ts.text)||((ss=a.data)==null?void 0:ss.text)||null,table:((ns=(rs=a.data)==null?void 0:rs.data)==null?void 0:ns.table)||((os=a.data)==null?void 0:os.table)||null}),m=async()=>{try{await R.put(`/bi-dashboard/${h.value}/${a.widgetName}`,{data:x.value});let D=`/bi-data?dashboard=${h.value}&widget=${a.widgetName}`;Object.entries(x.value).forEach(([Z,te])=>{D+=`&${Z}=${te}`});const N=new CustomEvent(`update-data-${a.widgetName}`);N.filterUrl=D,window.dispatchEvent(N),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},y=async()=>{try{let D=`/bi-data?dashboard=${h.value}&widget=${a.widgetName}`;Object.entries(x.value).forEach(([Z,te])=>{D+=`&${Z}=${te}`});const N=new CustomEvent(`update-data-${a.widgetName}`);N.filterUrl=D,window.dispatchEvent(N),l("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(x,()=>{y()},{deep:!0}),e.watch(()=>[a.widgetName,a.dashboardId,c.value],()=>{d.value=[],b()},{immediate:!0}),t({requestUpdateWidget:m}),(D,N)=>(e.openBlock(),e.createElementBlock("div",nn,[(e.openBlock(),e.createBlock(e.unref(n),{key:$.value,schema:V.value,values:x.value,"onUpdate:values":N[0]||(N[0]=Z=>x.value=Z)},null,8,["schema","values"]))]))}},an={class:"space-y-4"},ln={__name:"vs-editor-form-yaml",props:{yamlValue:{type:null,default:()=>""},widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){const n=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=r,d=s,p=(u,{dimensions:w,source:$})=>{const V=u.getOption(),{data:x,...m}=(V==null?void 0:V.series)[0],[,...y]=w||[],_=y.map((k,f)=>({...(V==null?void 0:V.series[f])||{},data:$.map(E=>E[f+1]),name:k}));u==null||u.setOption({...V||{},dataset:{dimensions:w,source:$},series:_,xAxis:{type:"category"},yAxis:{}},!0)},h=u=>{const w=document.getElementById(u);if(!w)return null;const $=n==null?void 0:n.getInstanceByDom(w);return $||null},b=e.ref(d.yamlValue),g=async()=>{try{await R.put(`/bi-dashboard/${a.value}/${d.widgetName}`,{yml:b.value});const u=h(d.widgetName);if(u){const w=await R.get(`/bi-data?dashboard=${l.value}&widget=${d.widgetName}`);p(u,w)}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:g}),(u,w)=>(e.openBlock(),e.createElementBlock("div",an,[e.createVNode(e.unref(o),{modelValue:b.value,"onUpdate:modelValue":w[0]||(w[0]=$=>b.value=$),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},cn={class:"pt-[10px]"},yt={"vs-editor-form-style":Vr,"vs-editor-form-data":on,"vs-editor-form-yaml":ln,"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(s,{emit:t}){var p;const r=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:n}=e.getCurrentInstance().proxy,o=t,l=s,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 R.put(`/bi-dashboard/${a.value}/${l.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);a.value=h.get("dashboard")}),(h,b)=>{const g=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",cn,[e.createVNode(g,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:d},{default:e.withCtx(()=>[...b[1]||(b[1]=[e.createTextVNode(" Зберегти ",-1)])]),_:1}),e.createVNode(e.unref(r),{schema:i,values:c.value,"onUpdate:values":b[0]||(b[0]=u=>c.value=u)},null,8,["values"])])}}}},dn={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},xt={__name:"editor-tab-error-boundary",props:{tabComponent:{type:Object,default:null},tabKey:{type:[String,Number],default:""}},emits:["update-dashboard"],setup(s,{expose:t}){const r=s,n=e.ref(null);function o(){var a,i;(i=(a=n.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(()=>r.tabComponent,()=>{l.value=!1},{immediate:!0}),(a,i)=>l.value?(e.openBlock(),e.createElementBlock("div",dn," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.tabComponent),e.mergeProps({ref_key:"tabRef",ref:n,key:s.tabKey||"tab"},a.$attrs,{onUpdateDashboard:i[0]||(i[0]=c=>a.$emit("update-dashboard"))}),null,16))}},pn={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},hn={key:0,class:"flex flex-col min-h-0 flex-1"},un={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},mn={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},fn=["onClick"],gn={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},bn={class:"flex items-center gap-1 ml-auto shrink-0"},yn={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"},xn={key:0},kn={key:1},wn={class:"p-4"},_n={class:"flex justify-end mt-4 gap-x-3"},$n={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},En={__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(s,{emit:t}){var y,_;const r=e.defineAsyncComponent(()=>import("@opengis/form")),n=(_=(y=e.getCurrentInstance())==null?void 0:y.proxy)==null?void 0:_.$notify,o=q.useRouter(),l=t,a=e.ref(null),i=s,c=e.ref(!1),d=e.ref(!0),p=e.ref(!1),h=e.ref({}),b=e.useModel(s,"selectedWidget"),g=["table","text","number","stat","progress","listbar","map","pivot"],u=e.ref("data"),w=async()=>{try{await R.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}}):b.value="",n({type:"success",title:"Успішно!",message:"Віджет успішно видалено"})}catch(k){console.error(k),n({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},$=e.computed(()=>{const k=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return k==null?void 0:k.filter(f=>{var E,B,C;return f.id==="style"?!(g!=null&&g.includes(((E=i.selectedWidgetData)==null?void 0:E.type)||((C=(B=i.selectedWidgetData)==null?void 0:B.data)==null?void 0:C.type))):!0})}),V=()=>{var k,f,E,B,C,M,O,G,Q;h.value={title:(k=i.selectedWidgetData)==null?void 0:k.title,type:(f=i.selectedWidgetData)==null?void 0:f.type,table:(E=i.selectedWidgetData)==null?void 0:E.table_name,query:(C=(B=i.selectedWidgetData)==null?void 0:B.data)==null?void 0:C.query,x:(O=(M=i.selectedWidgetData)==null?void 0:M.data)==null?void 0:O.x,cls:(Q=(G=i.selectedWidgetData)==null?void 0:G.data)==null?void 0:Q.cls},p.value=!0},x=async()=>{try{await R.put(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`,h.value),n({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await l("update-data"),p.value=!1}catch{n({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(b,()=>{d.value=!1,setTimeout(()=>d.value=!0)});const m={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(k,f)=>{var B,C,M,O,G,Q,he,ue,me,fe,ge;const E=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",pn,[s.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",hn,[e.createElementVNode("div",un,[e.createElementVNode("nav",mn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.value,F=>(e.openBlock(),e.createElementBlock("button",{key:F.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",u.value===F.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:X=>u.value=F.id},[e.createTextVNode(e.toDisplayString(F.label)+" ",1),u.value===F.id?(e.openBlock(),e.createElementBlock("span",gn)):e.createCommentVNode("",!0)],10,fn))),128))]),e.createElementVNode("div",bn,[e.createVNode(E,{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:f[0]||(f[0]=F=>{var X,be;return(be=(X=a.value)==null?void 0:X.save)==null?void 0:be.call(X)})},[e.createVNode(e.unref(Es),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[f[9]||(f[9]=e.createTextVNode(" Зберегти ",-1))]),_:1}),e.createVNode(E,{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},[e.createVNode(st,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[f[10]||(f[10]=e.createTextVNode(" Редагувати віджет ",-1))]),_:1}),e.createVNode(E,{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:f[1]||(f[1]=F=>c.value=!0)},[e.createVNode(e.unref(tt),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[f[11]||(f[11]=e.createTextVNode(" Видалити віджет ",-1))]),_:1})])]),(B=s.currentWidgetData)!=null&&B.status?(e.openBlock(),e.createBlock(ke,{key:0,title:(C=s.currentWidgetData)==null?void 0:C.title,text:(M=s.currentWidgetData)==null?void 0:M.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",yn,[d.value&&s.currentWidgetData?(e.openBlock(),e.createElementBlock("div",xn,[e.createVNode(xt,{ref_key:"tabPanelRef",ref:a,"tab-key":u.value,"tab-component":e.unref(yt)["vs-editor-form-"+u.value],widgetName:(O=s.selectedWidgetData)==null?void 0:O.name,dashboardId:s.selectedDashboard,yamlValue:((G=s.selectedWidgetData)==null?void 0:G.yml)||"",data:s.selectedWidgetData,controls:(Q=s.selectedWidgetData)==null?void 0:Q.controls,columns:(he=s.currentWidgetData)==null?void 0:he.columns,onUpdateDashboard:f[2]||(f[2]=F=>k.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",kn,[e.createVNode(xt,{ref_key:"tabPanelRef",ref:a,"tab-key":u.value,"tab-component":e.unref(yt)["vs-editor-form-"+u.value],widgetName:(ue=s.selectedWidgetData)==null?void 0:ue.name,dashboardId:s.selectedDashboard,yamlValue:((me=s.selectedWidgetData)==null?void 0:me.yml)||"",data:s.selectedWidgetData,controls:(fe=s.selectedWidgetData)==null?void 0:fe.controls,columns:(ge=s.currentWidgetData)==null?void 0:ge.columns,onUpdateDashboard:f[3]||(f[3]=F=>k.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(ne,{teleport:"#modal",visible:c.value,title:"Ви впевнені?",onClose:f[5]||(f[5]=F=>c.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",wn,[f[12]||(f[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",_n,[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:f[4]||(f[4]=F=>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:w}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(ke,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(ne,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:f[8]||(f[8]=F=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",$n,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:f[7]||(f[7]=F=>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:x,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(()=>[m?(e.openBlock(),e.createBlock(e.unref(r),{key:0,schema:m,values:h.value,"onUpdate:values":f[6]||(f[6]=F=>h.value=F)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},Vn={class:"overflow-hidden flex flex-col min-h-[480px]"},Bn={class:"flex-1 flex min-h-0 gap-4"},Dn={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},Cn={key:1,class:"flex items-center justify-center h-full"},Nn={class:"w-[400px] shrink-0 flex flex-col"},Sn={__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(s,{emit:t}){const r=s,n=t,o=e.ref(null);async function l(){if(!(!r.selectedDashboard||!r.selectedWidget))try{o.value=await R.get(`/bi-data?dashboard=${r.selectedDashboard}&widget=${r.selectedWidget}`)}catch(c){console.error(c)}}function a(){n("update-data")}e.watch(()=>[r.selectedDashboard,r.selectedWidget],()=>{l()},{immediate:!0});const i=e.computed({get:()=>r.selectedWidget,set:c=>n("update:selectedWidget",c)});return(c,d)=>(e.openBlock(),e.createElementBlock("div",Vn,[e.createElementVNode("div",Bn,[e.createElementVNode("div",Dn,[o.value?(e.openBlock(),e.createBlock(re,{key:0,dashboard:s.selectedDashboard,widget:s.selectedWidget,"selected-widget":s.selectedWidget,"dashboard-widgets":s.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",Cn,[...d[1]||(d[1]=[e.createElementVNode("span",{class:"text-sm text-gray-400"},"Завантаження...",-1)])]))]),e.createElementVNode("div",Nn,[e.createVNode(En,{selectedWidget:i.value,"onUpdate:selectedWidget":d[0]||(d[0]=p=>i.value=p),selectedWidgetData:s.selectedWidgetData,currentWidgetData:o.value||s.currentWidgetData||{columns:[]},selectedDashboard:s.selectedDashboard,onUpdateData:a},null,8,["selectedWidget","selectedWidgetData","currentWidgetData","selectedDashboard"])])])]))}},kt={__name:"icon-grid",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ks),e.mergeProps(t.$attrs,{size:24}),null,16))}},wt={__name:"icon-table",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Vs),e.mergeProps(t.$attrs,{size:24}),null,16))}},zn={__name:"icon-more",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(fs),e.mergeProps(t.$attrs,{size:24}),null,16))}},Ln=e.defineAsyncComponent(()=>import("@opengis/form")),Tn={components:{VsModal:ne,VForm:Ln,deleteIcon:tt,editIcon:st,IconGrid:kt,IconMore:zn,IconTable:wt},watch:{dashboardData:{handler(s){var r,n;if(this.formEditValue={title:s==null?void 0:s.title,description:s==null?void 0:s.description,table_name:s==null?void 0:s.table_name,db:s==null?void 0:s.db,public:s==null?void 0:s.public,words:s==null?void 0:s.words},!((r=s==null?void 0:s.panels)!=null&&r.length)){this.formGridValue={panels:[]};return}const t=(n=s==null?void 0:s.panels)==null?void 0:n.map(o=>{var i,c;const{title:l="",type:a=""}=((c=(i=s==null?void 0:s.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 s,t;try{const r=(t=(s=this.$refs)==null?void 0:s.formEdit)==null?void 0:t.validate();typeof r=="function"&&await r(),await R.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 s,t;try{(t=(s=this.$refs)==null?void 0:s.formGrid)==null||t.doValidation(),await R.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 R.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()}}},In={key:0,class:"flex items-center gap-4"},Mn={class:"h-[30px] w-[30px] flex items-center justify-center"},Rn={class:"flex flex-col items-start -ml-2 -mr-2"},Pn={class:"p-4"},Fn={class:"flex justify-end mt-4 gap-x-3"},jn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Wn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function On(s,t,r,n,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,[r.selected?(e.openBlock(),e.createElementBlock("div",In,[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",Mn,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",Rn,[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",Pn,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",Fn,[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",jn,[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",Wn,[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 An=L(Tn,[["render",On]]),qn={class:"flex-1 min-w-0 flex flex-col overflow-auto"},vn={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},Un={class:"relative z-10 shrink-0 mt-4 mb-6"},Hn={class:"flex items-center text-sm text-gray-600"},Gn={key:0,class:"flex items-center justify-between gap-4 mt-3"},Zn={class:"min-w-0"},Qn={class:"text-2xl font-bold text-gray-900"},Xn={key:0,class:"mt-1.5 text-sm text-gray-600"},Jn={class:"flex items-center shrink-0"},Kn={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"},Yn=L({__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(s,{emit:t}){const r=s;ye(r.prefix||"/api");const n=t,o=q.useRouter(),l=e.computed(()=>o.hasRoute(j.EditorWidget)),a=e.inject("biClearDashboard",null),i=e.ref(r.initialDashboardId||""),c=e.ref(r.initialWidgetId||""),d=e.ref(null),p=e.ref(null),h=e.ref(null);e.watch(()=>r.initialWidgetId,x=>{c.value=x||""});const b=async()=>{if(!i.value){d.value=null;return}try{const x=await R.get(`/bi-dashboard/${i.value}`);d.value=x}catch(x){console.error(x)}},g=e.computed(()=>{var x,m,y;return(y=Array.isArray((x=d.value)==null?void 0:x.widgets)?(m=d.value)==null?void 0:m.widgets:[])==null?void 0:y.find(_=>(_==null?void 0:_.name)===c.value)});function u(x){l.value?o.push({name:j.EditorWidget,params:{dashboardId:i.value,widgetId:x}}):c.value=x}function w(){l.value?o.push({name:j.EditorDashboard,params:{dashboardId:i.value}}):c.value=""}function $(){l.value?o.push({name:j.Editor}):(typeof a=="function"&&a(),n("back"))}const V=e.computed(()=>{var y,_,k,f,E;const m=[l.value?{label:"Дашборди",to:{name:j.Editor}}:{label:"Дашборди",onClick:$}];if((y=d.value)!=null&&y.title||i.value){const B=((_=d.value)==null?void 0:_.title)||i.value||"Редактор";!!c.value?m.push(l.value?{label:B,to:{name:j.EditorDashboard,params:{dashboardId:i.value}}}:{label:B,onClick:()=>{c.value=""}}):m.push({label:B})}else m.push({label:"Редактор"});if(c.value&&g.value){const B=((f=(k=g.value)==null?void 0:k.data)==null?void 0:f.title)||((E=g.value)==null?void 0:E.title)||c.value;m.push({label:B})}return m});return e.watch(i,(x,m)=>{m&&(c.value=""),x?b():(d.value=null,$())}),e.onMounted(()=>{b()}),(x,m)=>{var y,_;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[s.customClass]])},[e.createElementVNode("div",qn,[e.createElementVNode("div",vn,[e.createElementVNode("div",Un,[e.createElementVNode("div",Hn,[e.createVNode(Ke,{items:V.value,compact:""},null,8,["items"])]),i.value&&d.value?(e.openBlock(),e.createElementBlock("div",Gn,[e.createElementVNode("div",Zn,[e.createElementVNode("h1",Qn,e.toDisplayString(d.value.title||i.value),1),d.value.description?(e.openBlock(),e.createElementBlock("p",Xn,e.toDisplayString(d.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Jn,[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:w},[e.createVNode(e.unref(Qe),{class:"w-4 h-4"}),m[5]||(m[5]=e.createTextVNode(" Закрити ",-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(An,{selected:i.value,"onUpdate:selected":m[0]||(m[0]=k=>i.value=k),dashboardData:d.value,columns:(y=d.value)==null?void 0:y.columns,selectedWidgetData:g.value,prefix:s.prefix,onUpdateEditor:b},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:m[1]||(m[1]=k=>{var f,E;return(E=(f=h.value)==null?void 0:f.open)==null?void 0:E.call(f)})},[...m[6]||(m[6]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ",-1)])]),i.value?(e.openBlock(),e.createBlock($r,{key:0,ref_key:"createWidgetRef",ref:h,inline:"",columns:(_=d.value)==null?void 0:_.columns,selectedDashboard:i.value,onUpdateData:b},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),c.value&&d.value?(e.openBlock(),e.createBlock(Sn,{key:0,"selected-widget":c.value,"onUpdate:selectedWidget":m[2]||(m[2]=k=>c.value=k),"selected-widget-data":g.value,"current-widget-data":p.value,"selected-dashboard":i.value,"dashboard-widgets":d.value.widgets||[],onUpdateData:b},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",Kn,[d.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(d.value.panels,(k,f)=>{var E,B;return e.openBlock(),e.createElementBlock("div",{key:k.widget||((E=k.widgets)==null?void 0:E.join("-"))||f,class:e.normalizeClass([`md:col-span-${k.col||12} col-span-12`,"flex flex-col gap-[10px]"])},[(B=k.widgets)!=null&&B.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(k.widgets,C=>(e.openBlock(),e.createBlock(re,{onClick:M=>u(C),"onUpdate:currentWidgetData":m[3]||(m[3]=M=>p.value=M),key:C,dashboard:i.value,widget:C,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(k.height??480),class:e.normalizeClass({"border border-blue-500":c.value===C})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","height","class"]))),128)):(e.openBlock(),e.createBlock(re,{key:1,onClick:C=>u(k.widget),"onUpdate:currentWidgetData":m[4]||(m[4]=C=>p.value=C),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":c.value===k.widget}]),dashboard:i.value,widget:k.widget,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(k.height??480)},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets","height"]))],2)}),128)):(e.openBlock(),e.createBlock(ke,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-330ef797"]]),eo={class:"w-full h-screen"},_t=e.defineComponent({__name:"vs-editor-page",props:{prefix:{default:"/api"},dashboardId:{default:""},widgetId:{default:""}},emits:["back"],setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",eo,[e.createVNode(Yn,{customClass:"h-full w-full",prefix:t.prefix,"initial-dashboard-id":t.dashboardId,"initial-widget-id":t.widgetId,onBack:r[0]||(r[0]=n=>t.$emit("back"))},null,8,["prefix","initial-dashboard-id","initial-widget-id"])]))}}),to={class:"relative group h-full"},so={class:"flex items-start gap-3 flex-1 min-h-0"},ro={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},no={class:"flex-1 min-w-0 flex flex-col min-h-0"},oo={class:"font-semibold text-gray-900 mb-1 truncate"},ao={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},lo={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},io={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},co=L({__name:"dashboard-card",props:{title:String,description:String,modified:String,name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function},setup(s){const t=s,r=q.useRouter(),n=e.ref(!1);function o(){t.dashboardRouteName&&(r.hasRoute(j.EditorDashboard)?r.push({name:j.EditorDashboard,params:{dashboardId:t.dashboardRouteName}}):t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):r.push({path:"/editor",query:{dashboard:t.dashboardRouteName}}))}function l(a){a.target.closest(".dashboard-card-menu")||(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",l)),e.onUnmounted(()=>document.removeEventListener("click",l)),(a,i)=>(e.openBlock(),e.createElementBlock("div",to,[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:o},[e.createElementVNode("div",so,[e.createElementVNode("div",ro,[e.createVNode(e.unref(xs),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",no,[e.createElementVNode("h3",oo,e.toDisplayString(s.title),1),s.description?(e.openBlock(),e.createElementBlock("p",ao,e.toDisplayString(s.description),1)):(e.openBlock(),e.createElementBlock("p",lo," ")),s.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",io,e.toDisplayString(s.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-716ced89"]]),po=[{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 ho(s){return!Array.isArray(s)||s.length===0?{}:s.reduce((t,r)=>{if(!r||r.key==null)return t;const{key:n,...o}=r;return t[n]=o,t},{})}const uo={class:"flex-1 bg-gray-50"},mo={class:"max-w-7xl mx-auto px-6 py-8"},fo={class:"mb-6"},go={class:"flex items-center justify-between mb-6"},bo={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},yo={class:"flex items-center space-x-4"},xo={class:"flex-1 relative"},ko={class:"relative"},wo={key:0,class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},_o={key:1,class:"flex flex-col items-center justify-center py-20 text-center"},$o={class:"mt-1 text-sm text-gray-400"},Eo={class:"font-medium text-gray-500"},$t=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(s){const t=e.defineAsyncComponent(()=>import("@opengis/form")),r=ho(po),n=e.ref([]),o=e.ref([]),l=q.useRouter(),a=e.inject("biSetDashboard",void 0),i=s,c=e.ref(null),d=e.ref(!1),p=e.ref({}),h=e.ref(""),b=e.ref("title-asc"),g=e.computed(()=>{const y=h.value.trim().toLowerCase();let _=n.value;y&&(_=_.filter(f=>f.title.toLowerCase().includes(y)));const k=b.value==="title-asc"?1:-1;return[..._].sort((f,E)=>k*f.title.localeCompare(E.title,"uk"))});async function u(){try{const y=await R.get("/bi-dashboard?type=db"),_=Array.isArray(y==null?void 0:y.rows)?y.rows:[];o.value=_,n.value=_.map(k=>({routeName:String(k.name??""),title:k.title??k.name??"Без назви",description:k.description??null,modified:"-",name:"-"}))}catch(y){console.error("Failed to load dashboards",y),o.value=[],n.value=[]}}async function w(){var _,k,f;const y=(k=(_=e.getCurrentInstance())==null?void 0:_.proxy)==null?void 0:k.$notify;try{const E=(f=c.value)==null?void 0:f.validate();typeof E=="function"&&await E();const{name:B,title:C,table_name:M}=p.value;if(!B||!C||!M){y==null||y({type:"error",title:"Помилка!",message:"Заповніть усі обов'язкові поля"});return}await R.post("/bi-dashboard",p.value),d.value=!1,p.value={},y==null||y({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),l.hasRoute(j.EditorDashboard)?l.push({name:j.EditorDashboard,params:{dashboardId:B}}):a?a(B):await u()}catch{y==null||y({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}e.onMounted(()=>{ye(i.prefix||"/api"),u()});const $=e.ref(1),V=()=>{const y=window.innerWidth;$.value=y>=1024?3:y>=768?2:1};e.onMounted(()=>{V(),window.addEventListener("resize",V)}),e.onUnmounted(()=>{window.removeEventListener("resize",V)});const x=y=>y?y.trim().length>70?2:1:0,m=y=>{const _=$.value||1,f=Math.floor(y/_)*_,E=f+_,B=g.value.slice(f,E);let C=0;for(const M of B){const O=x(M.description??null);if(O>C&&(C=O),C===2)break}return C};return e.ref("grid"),(y,_)=>(e.openBlock(),e.createElementBlock("div",uo,[e.createElementVNode("div",mo,[e.createElementVNode("div",fo,[e.createElementVNode("div",go,[_[7]||(_[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:_[0]||(_[0]=k=>d.value=!0)},[e.createVNode(e.unref(Ge),{size:24,class:"w-4 h-4"}),_[6]||(_[6]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(ne,{teleport:"#modal",visible:d.value,title:"Створити дашборд",onClose:_[3]||(_[3]=k=>d.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",bo,[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:_[2]||(_[2]=k=>d.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:w}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:c,schema:e.unref(r),values:p.value,"onUpdate:values":_[1]||(_[1]=k=>p.value=k)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",yo,[e.createElementVNode("div",xo,[e.createVNode(e.unref(Ze),{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":_[4]||(_[4]=k=>h.value=k),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,h.value]])]),e.createElementVNode("div",ko,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":_[5]||(_[5]=k=>b.value=k),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"},[..._[8]||(_[8]=[e.createElementVNode("option",{value:"title-asc"},"Назва (А → Я)",-1),e.createElementVNode("option",{value:"title-desc"},"Назва (Я → А)",-1)])],512),[[e.vModelSelect,b.value]]),e.createVNode(e.unref(hs),{size:16,class:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 pointer-events-none"})])])]),g.value.length?(e.openBlock(),e.createElementBlock("div",wo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(k,f)=>(e.openBlock(),e.createElementBlock("div",{key:k.routeName,class:"cursor-pointer h-full"},[e.createVNode(co,{title:k.title,description:k.description,modified:k.modified,name:k.name,reserveLines:m(f),"dashboard-route-name":k.routeName,"on-open-editor":e.unref(a)},null,8,["title","description","modified","name","reserveLines","dashboard-route-name","on-open-editor"])]))),128))])):(e.openBlock(),e.createElementBlock("div",_o,[e.createVNode(e.unref(Ze),{size:48,class:"text-gray-300 mb-4"}),_[11]||(_[11]=e.createElementVNode("p",{class:"text-lg font-medium text-gray-500"},"Дашбордів не знайдено",-1)),e.createElementVNode("p",$o,[_[9]||(_[9]=e.createTextVNode(" За запитом «",-1)),e.createElementVNode("span",Eo,e.toDisplayString(h.value),1),_[10]||(_[10]=e.createTextVNode("» нічого не знайдено. Спробуйте змінити пошуковий запит. ",-1))])]))])]))}}),Vo=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(s){const t=s,r=e.computed(()=>t.prefix),n=q.useRouter(),o=q.useRoute(),l=e.computed(()=>n.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(_t,{key:`editor-${a.value}`,prefix:r.value,"dashboard-id":a.value,onBack:d[0]||(d[0]=h=>a.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock($t,{key:0,prefix:r.value},null,8,["prefix"]))],64))}}});function H(s,t){const r=s&&typeof s=="object"&&"value"in s?s.value:s;if(r==null)return"";const n=Number(r);return Number.isNaN(n)?String(r):new Intl.NumberFormat("en",t??{notation:"compact"}).format(n)}function pe(s){if(!(s!=null&&s.includes("T")))return s??"";const[t,r,n]=s.split("T")[0].split("-");return`${n}.${r}.${t}`}function Bo(s){return Intl.NumberFormat("en").format(s??0)}class Do{static getTooltipOptions(t=!0){return{show:t,confine:!0,appendToBody:!1,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const Co={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function No(){const s="0123456789ABCDEF";let t="#";for(let r=0;r<6;r+=1)t+=s[Math.floor(Math.random()*16)];return t}function Y(s=Co){var r,n,o;const t={label:{show:((r=s==null?void 0:s.label)==null?void 0:r.show)??(s==null?void 0:s.show_label)??!1,formatter:(s==null?void 0:s.formatter)??(l=>H(l)),...(s==null?void 0:s.label)||{}},legend:{...(s==null?void 0:s.legend)||{},[((n=s==null?void 0:s.legend)==null?void 0:n.position)||"bottom"]:"0",show:((o=s==null?void 0:s.legend)==null?void 0:o.show)??(s==null?void 0:s.show_legend)??!1},barWidth:"70%",grid:{borderColor:"#e5e7eb"},title:{...(s==null?void 0:s.title)||{}}};return(s!=null&&s.colors||s!=null&&s.color)&&(t.color=(s==null?void 0:s.colors)||(s==null?void 0:s.color)||null),t}function Et(s){return{color:"#9ca3af",fontSize:10,fontFamily:"Inter, ui-sans-serif, system-ui",fontWeight:400,label:s==null?void 0:s.label,show:!0,formatter:(s==null?void 0:s.formatter)??(t=>H(t)),margin:(s==null?void 0:s.margin)??7,interval:(s==null?void 0:s.interval)??"auto",rotate:(s==null?void 0:s.rotate)??0}}const Vt=["#d3c7e6","#bedae3","#f8e9cb","#ff8c8c","#c5d8be","#ffc6c6","#ffc39a","#fff7c5","#d8ffc0","#d4f7ff"];class Be{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 ee=typeof window<"u"?window.echarts:null,W={props:["source","style","widget","dashboard","title","currentWidget","widgetData","prefix","prefetchedData"],data(){return{sourceData:null,styleData:null,widgetName:"",dimensions:[],dashboardName:"",titleCharts:"",widgetInstance:null}},mounted(){window.addEventListener("resize",this.handleResize),window.addEventListener(`update-data-${this.widget}`,this.checkCustomEvent),window.addEventListener(`update-style-${this.widget}`,this.checkCustomStyleEvent)},unmounted(){window.removeEventListener(`update-data-${this.widget}`,this.checkCustomEvent),window.removeEventListener(`update-style-${this.widget}`,this.checkCustomStyleEvent)},watch:{sourceData:{async handler(){setTimeout(()=>{this==null||this.onChangedData()},0)}}},methods:{checkCustomStyleEvent(s){this.changeOptionsByName(s.chartId,s.options)},checkCustomEvent({filterUrl:s}){this.getDataFromURL(s)},handleResize(){this.widgetInstance&&this.widgetInstance.resize()},async getDataFromURL(s){try{const t=await R.get(s);this.applyResponse(t)}catch(t){const r={message:"Дані не знайдено",title:"Помилка!",type:"error",status:400,id:this.widgetName};(t==null?void 0:t.status)=="404"&&(r.status=404,r.message="Дані не знайдено"),(t==null?void 0:t.status)=="400"&&(r.message="Перевірте налаштування або зверніться до адміністратора"),(t==null?void 0:t.status)=="500"&&(r.message="Сталася помилка сервера"),this.$emit("update:widgetData",r)}},getValues(){return this.sourceData.map(s=>{var t;return parseFloat(s[(t=this.columns)==null?void 0:t[1]])})},formatDate(s){const t=new Date(s);if(isNaN(t))return s;const r=String(t.getDate()).padStart(2,"0"),o=["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"][t.getMonth()],l=t.getFullYear();return`${r} ${o} ${l}`},applyResponse(s){var t;this.sourceData=(s==null?void 0:s.source)||[],this.$emit("update:widgetData",s),this.dimensions=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{}),this.titleCharts=this.style?this.style:(s==null?void 0:s.title)||"",this.styleData=(s==null?void 0:s.style)||{}},async getData(){var s;try{if(this.source)this.sourceData=[...this.source],this.styleData=this.style,this.titleCharts=this.title,this.dimensions=Object.keys(((s=this.sourceData)==null?void 0:s[0])||{});else if(this.prefetchedData)this.widgetName=this.widget,this.dashboardName=this.dashboard,this.applyResponse(this.prefetchedData);else{this.widgetName=this.widget,this.dashboardName=this.dashboard;const t=this.dashboardName?`${this.prefix||""}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}`:`${this.prefix||""}/bi-data?&widget=${this.widgetName}`;await this.getDataFromURL(t)}}catch(t){console.error(t)}},async initChart(s,t,r){var n,o,l,a,i,c,d,p,h;this.widgetInstance&&this.widgetInstance.clear();try{const b=this.$refs.chart,g=ee==null?void 0:ee.init(b);if(!g)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:(w,$,V,x,m)=>{const[y,_]=w,[k,f]=m.contentSize,[E,B]=m.viewSize;let C=y+14,M=_-f/2;return C+k>E&&(C=y-k-14),C<0&&(C=0),M+f>B&&(M=B-f),M<0&&(M=0),[C,M]},formatter:w=>{var f;const V=(f=w[0])==null?void 0:f.axisValue,x=V?this.formatDate(V):"N/A",m=[...w].filter(E=>{var B;return parseFloat(E==null?void 0:E.data)||((B=E==null?void 0:E.data)==null?void 0:B.value)}).sort((E,B)=>{var O,G;const C=parseFloat(((O=E==null?void 0:E.data)==null?void 0:O.value)??(E==null?void 0:E.data))||0;return(parseFloat(((G=B==null?void 0:B.data)==null?void 0:G.value)??(B==null?void 0:B.data))||0)-C}),y=m.slice(0,8),_=m.length-y.length;let k=`
|
|
188
|
+
`}tablecell(t){const s=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+s+`</${n}>
|
|
189
|
+
`}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),l=ct(t);if(l===null)return o;t=l;let a='<a href="'+t+'"';return s&&(a+=' title="'+s+'"'),a+=">"+o+"</a>",a}image({href:t,title:s,text:n}){const o=ct(t);if(o===null)return n;t=o;let l=`<img src="${t}" alt="${n}"`;return s&&(l+=` title="${s}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class je{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 X{constructor(t){F(this,"options");F(this,"renderer");F(this,"textRenderer");this.options=t||ne,this.options.renderer=this.options.renderer||new Ve,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new je}static parse(t,s){return new X(s).parse(t)}static parseInline(t,s){return new X(s).parseInline(t)}parse(t,s=!0){let n="";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)){n+=c||"";continue}}const a=l;switch(a.type){case"space":{n+=this.renderer.space(a);continue}case"hr":{n+=this.renderer.hr(a);continue}case"heading":{n+=this.renderer.heading(a);continue}case"code":{n+=this.renderer.code(a);continue}case"table":{n+=this.renderer.table(a);continue}case"blockquote":{n+=this.renderer.blockquote(a);continue}case"list":{n+=this.renderer.list(a);continue}case"html":{n+=this.renderer.html(a);continue}case"paragraph":{n+=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+=`
|
|
190
|
+
`+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 "'+a.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 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)){n+=i||"";continue}}const a=l;switch(a.type){case"escape":{n+=s.text(a);break}case"html":{n+=s.html(a);break}case"link":{n+=s.link(a);break}case"image":{n+=s.image(a);break}case"strong":{n+=s.strong(a);break}case"em":{n+=s.em(a);break}case"codespan":{n+=s.codespan(a);break}case"br":{n+=s.br(a);break}case"del":{n+=s.del(a);break}case"text":{n+=s.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 n}}class be{constructor(t){F(this,"options");F(this,"block");this.options=t||ne}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?Q.lex:Q.lexInline}provideParser(){return this.block?X.parse:X.parseInline}}F(be,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class on{constructor(...t){F(this,"defaults",Le());F(this,"options",this.setOptions);F(this,"parse",this.parseMarkdown(!0));F(this,"parseInline",this.parseMarkdown(!1));F(this,"Parser",X);F(this,"Renderer",Ve);F(this,"TextRenderer",je);F(this,"Lexer",Q);F(this,"Tokenizer",_e);F(this,"Hooks",be);this.use(...t)}walkTokens(t,s){var o,l;let n=[];for(const a of t)switch(n=n.concat(s.call(this,a)),a.type){case"table":{const i=a;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=a;n=n.concat(this.walkTokens(i.items,s));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);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(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const a=s.renderers[l.name];a?s.renderers[l.name]=function(...i){let c=l.renderer.apply(this,i);return c===!1&&(c=a.apply(this,i)),c}:s.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=s[l.level];a?a.unshift(l.tokenizer):s[l.level]=[l.tokenizer],l.start&&(l.level==="block"?s.startBlock?s.startBlock.push(l.start):s.startBlock=[l.start]:l.level==="inline"&&(s.startInline?s.startInline.push(l.start):s.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(s.childTokens[l.name]=l.childTokens)}),o.extensions=s),n.renderer){const l=this.defaults.renderer||new Ve(this.defaults);for(const a in n.renderer){if(!(a in l))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const i=a,c=n.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(n.tokenizer){const l=this.defaults.tokenizer||new _e(this.defaults);for(const a in n.tokenizer){if(!(a in l))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const i=a,c=n.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(n.hooks){const l=this.defaults.hooks||new be;for(const a in n.hooks){if(!(a in l))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const i=a,c=n.hooks[i],d=l[i];be.passThroughHooks.has(a)?l[i]=p=>{if(this.defaults.async)return Promise.resolve(c.call(l,p)).then(b=>d.call(l,b));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(n.walkTokens){const l=this.defaults.walkTokens,a=n.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,s){return Q.lex(t,s??this.defaults)}parser(t,s){return X.parse(t,s??this.defaults)}parseMarkdown(t){return(n,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 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"));a.hooks&&(a.hooks.options=a,a.hooks.block=t);const c=a.hooks?a.hooks.provideLexer():t?Q.lex:Q.lexInline,d=a.hooks?a.hooks.provideParser():t?X.parse:X.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(n):n).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&&(n=a.hooks.preprocess(n));let p=c(n,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,s){return n=>{if(n.message+=`
|
|
191
|
+
Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+H(n.message+"",!0)+"</pre>";return s?Promise.resolve(o):o}if(s)return Promise.reject(n);throw n}}}const oe=new on;function T(r,t){return oe.parse(r,t)}T.options=T.setOptions=function(r){return oe.setOptions(r),T.defaults=oe.defaults,ot(T.defaults),T},T.getDefaults=Le,T.defaults=ne,T.use=function(...r){return oe.use(...r),T.defaults=oe.defaults,ot(T.defaults),T},T.walkTokens=function(r,t){return oe.walkTokens(r,t)},T.parseInline=oe.parseInline,T.Parser=X,T.parser=X.parse,T.Renderer=Ve,T.TextRenderer=je,T.Lexer=Q,T.lexer=Q.lex,T.Tokenizer=_e,T.Hooks=be,T.parse=T,T.options,T.setOptions,T.use,T.walkTokens,T.parseInline,X.parse,Q.lex;const an={class:"space-y-4"},ln={__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 V,_,y,E,N,S,O,G,Z,C,B,z,j,Y,ee,R,K,se,Wt,qt,vt,Ut,Ht,Gt,Zt,Qt,Xt,Jt,Kt,Yt,er,tr,rr,sr,nr,or,ar,lr;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=s,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 D=a.columns??[];return D.length?D:d.value}),h=e.computed(()=>a.dashboardId||c.value);async function b(){if(a.columns!==null)return;const D=h.value;if(!(p.value.length||!D||!a.widgetName))try{const L=await A.get(`/bi-data?dashboard=${D}&widget=${a.widgetName}`);Array.isArray(L==null?void 0:L.columns)&&L.columns.length&&(d.value=L.columns)}catch{}}const g=D=>(D==null?void 0:D.name)!=null?{id:D.name,text:D.title||D.name}:null,m=D=>Array.isArray(D)?[...D].sort((L,te)=>{const ie=L.text&&L.text!==L.id,ir=te.text&&te.text!==te.id;return ie&&!ir?-1:!ie&&ir?1:(L.text||"").localeCompare(te.text||"",void 0,{sensitivity:"base"})}):D,k=e.computed(()=>{const D=(p.value??[]).filter(L=>(L==null?void 0:L.type)=="text"||(L==null?void 0:L.type)==="date"||(L==null?void 0:L.type)==="timestamp without time zone"||(L==null?void 0:L.type)==="boolean"||(L==null?void 0:L.type)==="integer").map(g).filter(Boolean);return m(D)}),x=e.computed(()=>`${a.widgetName}-${k.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:[...k.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"},...m(p.value.filter(D=>(D==null?void 0:D.type)==="numeric"||(D==null?void 0:D.type)==="double precision").map(g).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"},...m(p.value.filter(D=>(D==null?void 0:D.type)=="text"||(D==null?void 0:D.type)==="boolean"||(D==null?void 0:D.type)==="integer").map(g).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Колонки",style:{size:"xs"},options:m((p.value??[]).map(g).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}})),f=e.ref({x:((_=(V=a.data)==null?void 0:V.data)==null?void 0:_.x)||((y=a.data)==null?void 0:y.x)||null,metric:((N=(E=a.data)==null?void 0:E.data)==null?void 0:N.metric)||((S=a.data)==null?void 0:S.metric)||null,columns:((G=(O=a.data)==null?void 0:O.data)==null?void 0:G.columns)||((Z=a.data)==null?void 0:Z.columns)||null,granularity:((B=(C=a.data)==null?void 0:C.data)==null?void 0:B.granularity)||((z=a.data)==null?void 0:z.granularity)||null,type:((Y=(j=a.data)==null?void 0:j.data)==null?void 0:Y.type)||((ee=a.data)==null?void 0:ee.type)||null,groupby:((K=(R=a.data)==null?void 0:R.data)==null?void 0:K.groupby)||a.data.groupby||null,fx:((Wt=(se=a.data)==null?void 0:se.data)==null?void 0:Wt.fx)||((qt=a.data)==null?void 0:qt.fx)||null,query:((Ut=(vt=a.data)==null?void 0:vt.data)==null?void 0:Ut.query)||((Ht=a.data)==null?void 0:Ht.query)||null,y_type:((Zt=(Gt=a.data)==null?void 0:Gt.data)==null?void 0:Zt.y_type)||((Qt=a.data)==null?void 0:Qt.y_type)||null,tableSQL:((Jt=(Xt=a.data)==null?void 0:Xt.data)==null?void 0:Jt.tableSQL)||((Kt=a.data)==null?void 0:Kt.tableSQL)||null,cls:((er=(Yt=a.data)==null?void 0:Yt.data)==null?void 0:er.cls)||((tr=a.data)==null?void 0:tr.cls)||null,text:((sr=(rr=a.data)==null?void 0:rr.data)==null?void 0:sr.text)||((nr=a.data)==null?void 0:nr.text)||null,table:((ar=(or=a.data)==null?void 0:or.data)==null?void 0:ar.table)||((lr=a.data)==null?void 0:lr.table)||null}),u=async()=>{try{await A.put(`/bi-dashboard/${h.value}/${a.widgetName}`,{data:f.value});let D=`/bi-data?dashboard=${h.value}&widget=${a.widgetName}`;Object.entries(f.value).forEach(([te,ie])=>{D+=`&${te}=${ie}`});const L=new CustomEvent(`update-data-${a.widgetName}`);L.filterUrl=D,window.dispatchEvent(L),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},w=async()=>{try{let D=`/bi-data?dashboard=${h.value}&widget=${a.widgetName}`;Object.entries(f.value).forEach(([te,ie])=>{D+=`&${te}=${ie}`});const L=new CustomEvent(`update-data-${a.widgetName}`);L.filterUrl=D,window.dispatchEvent(L),l("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(f,()=>{w()},{deep:!0}),e.watch(()=>[a.widgetName,a.dashboardId,c.value],()=>{d.value=[],b()},{immediate:!0}),t({requestUpdateWidget:u}),(D,L)=>(e.openBlock(),e.createElementBlock("div",an,[(e.openBlock(),e.createBlock(e.unref(n),{key:x.value,schema:$.value,values:f.value,"onUpdate:values":L[0]||(L[0]=te=>f.value=te)},null,8,["schema","values"]))]))}},cn={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(m=>m.VsInputMonaco)),l=e.ref(null),a=e.computed(()=>d.dashboardId||l.value),{$notify:i}=e.getCurrentInstance().proxy,c=s,d=r,p=(m,{dimensions:k,source:x})=>{const $=m.getOption(),{data:f,...u}=($==null?void 0:$.series)[0],[,...w]=k||[],V=w.map((_,y)=>({...($==null?void 0:$.series[y])||{},data:x.map(E=>E[y+1]),name:_}));m==null||m.setOption({...$||{},dataset:{dimensions:k,source:x},series:V,xAxis:{type:"category"},yAxis:{}},!0)},h=m=>{const k=document.getElementById(m);if(!k)return null;const x=n==null?void 0:n.getInstanceByDom(k);return x||null},b=e.ref(d.yamlValue),g=async()=>{try{await A.put(`/bi-dashboard/${a.value}/${d.widgetName}`,{yml:b.value});const m=h(d.widgetName);if(m){const k=await A.get(`/bi-data?dashboard=${l.value}&widget=${d.widgetName}`);p(m,k)}c("update-dashboard"),i({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{i({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const m=new URLSearchParams(window.top.location.search);l.value=m.get("dashboard")}),t({requestUpdateWidget:g}),(m,k)=>(e.openBlock(),e.createElementBlock("div",cn,[e.createVNode(e.unref(o),{modelValue:b.value,"onUpdate:modelValue":k[0]||(k[0]=x=>b.value=x),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},pn={class:"pt-[10px]"},kt={"vs-editor-form-style":Cs,"vs-editor-form-data":ln,"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,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 A.put(`/bi-dashboard/${a.value}/${l.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);a.value=h.get("dashboard")}),(h,b)=>{const g=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",pn,[e.createVNode(g,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:d},{default:e.withCtx(()=>[...b[1]||(b[1]=[e.createTextVNode(" Зберегти ",-1)])]),_:1}),e.createVNode(e.unref(s),{schema:i,values:c.value,"onUpdate:values":b[0]||(b[0]=m=>c.value=m)},null,8,["values"])])}}}},hn={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},wt={__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 a,i;(i=(a=n.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(()=>s.tabComponent,()=>{l.value=!1},{immediate:!0}),(a,i)=>l.value?(e.openBlock(),e.createElementBlock("div",hn," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.tabComponent),e.mergeProps({ref_key:"tabRef",ref:n,key:r.tabKey||"tab"},a.$attrs,{onUpdateDashboard:i[0]||(i[0]=c=>a.$emit("update-dashboard"))}),null,16))}},un={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},mn={key:0,class:"flex flex-col min-h-0 flex-1"},fn={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},gn={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},bn=["onClick"],yn={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},xn={class:"flex items-center gap-1 ml-auto shrink-0"},kn={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"},wn={key:0},_n={key:1},$n={class:"p-4"},En={class:"flex justify-end mt-4 gap-x-3"},Bn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Vn={__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 w,V;const s=e.defineAsyncComponent(()=>import("@opengis/form")),n=(V=(w=e.getCurrentInstance())==null?void 0:w.proxy)==null?void 0:V.$notify,o=U.useRouter(),l=t,a=e.ref(null),i=r,c=e.ref(!1),d=e.ref(!0),p=e.ref(!1),h=e.ref({}),b=e.useModel(r,"selectedWidget"),g=["table","text","number","stat","progress","listbar","map","pivot"],m=e.ref("data"),k=async()=>{try{await A.delete(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`),c.value=!1,l("update-data"),o.hasRoute(q.EditorDashboard)?await o.push({name:q.EditorDashboard,params:{dashboardId:i.selectedDashboard}}):b.value="",n({type:"success",title:"Успішно!",message:"Віджет успішно видалено"})}catch(_){console.error(_),n({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},x=e.computed(()=>{const _=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return _==null?void 0:_.filter(y=>{var E,N,S;return y.id==="style"?!(g!=null&&g.includes(((E=i.selectedWidgetData)==null?void 0:E.type)||((S=(N=i.selectedWidgetData)==null?void 0:N.data)==null?void 0:S.type))):!0})}),$=()=>{var _,y,E,N,S,O,G,Z,C;h.value={title:(_=i.selectedWidgetData)==null?void 0:_.title,type:(y=i.selectedWidgetData)==null?void 0:y.type,table:(E=i.selectedWidgetData)==null?void 0:E.table_name,query:(S=(N=i.selectedWidgetData)==null?void 0:N.data)==null?void 0:S.query,x:(G=(O=i.selectedWidgetData)==null?void 0:O.data)==null?void 0:G.x,cls:(C=(Z=i.selectedWidgetData)==null?void 0:Z.data)==null?void 0:C.cls},p.value=!0},f=async()=>{try{await A.put(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`,h.value),n({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await l("update-data"),p.value=!1}catch{n({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(b,()=>{d.value=!1,setTimeout(()=>d.value=!0)});const u={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(_,y)=>{var N,S,O,G,Z,C,B,z,j,Y,ee;const E=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",un,[r.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",mn,[e.createElementVNode("div",fn,[e.createElementVNode("nav",gn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,R=>(e.openBlock(),e.createElementBlock("button",{key:R.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",m.value===R.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:K=>m.value=R.id},[e.createTextVNode(e.toDisplayString(R.label)+" ",1),m.value===R.id?(e.openBlock(),e.createElementBlock("span",yn)):e.createCommentVNode("",!0)],10,bn))),128))]),e.createElementVNode("div",xn,[e.createVNode(E,{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:y[0]||(y[0]=R=>{var K,se;return(se=(K=a.value)==null?void 0:K.save)==null?void 0:se.call(K)})},[e.createVNode(e.unref(Vr),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[y[9]||(y[9]=e.createTextVNode(" Зберегти ",-1))]),_:1}),e.createVNode(E,{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(nt,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[y[10]||(y[10]=e.createTextVNode(" Редагувати віджет ",-1))]),_:1}),e.createVNode(E,{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:y[1]||(y[1]=R=>c.value=!0)},[e.createVNode(e.unref(st),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[y[11]||(y[11]=e.createTextVNode(" Видалити віджет ",-1))]),_:1})])]),(N=r.currentWidgetData)!=null&&N.status?(e.openBlock(),e.createBlock(we,{key:0,title:(S=r.currentWidgetData)==null?void 0:S.title,text:(O=r.currentWidgetData)==null?void 0:O.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",kn,[d.value&&r.currentWidgetData?(e.openBlock(),e.createElementBlock("div",wn,[e.createVNode(wt,{ref_key:"tabPanelRef",ref:a,"tab-key":m.value,"tab-component":e.unref(kt)["vs-editor-form-"+m.value],widgetName:(G=r.selectedWidgetData)==null?void 0:G.name,dashboardId:r.selectedDashboard,yamlValue:((Z=r.selectedWidgetData)==null?void 0:Z.yml)||"",data:r.selectedWidgetData,controls:(C=r.selectedWidgetData)==null?void 0:C.controls,columns:(B=r.currentWidgetData)==null?void 0:B.columns,onUpdateDashboard:y[2]||(y[2]=R=>_.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",_n,[e.createVNode(wt,{ref_key:"tabPanelRef",ref:a,"tab-key":m.value,"tab-component":e.unref(kt)["vs-editor-form-"+m.value],widgetName:(z=r.selectedWidgetData)==null?void 0:z.name,dashboardId:r.selectedDashboard,yamlValue:((j=r.selectedWidgetData)==null?void 0:j.yml)||"",data:r.selectedWidgetData,controls:(Y=r.selectedWidgetData)==null?void 0:Y.controls,columns:(ee=r.currentWidgetData)==null?void 0:ee.columns,onUpdateDashboard:y[3]||(y[3]=R=>_.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(pe,{teleport:"#modal",visible:c.value,title:"Ви впевнені?",onClose:y[5]||(y[5]=R=>c.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",$n,[y[12]||(y[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",En,[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:y[4]||(y[4]=R=>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:k}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(we,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(pe,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:y[8]||(y[8]=R=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Bn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:y[7]||(y[7]=R=>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:f,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(()=>[u?(e.openBlock(),e.createBlock(e.unref(s),{key:0,schema:u,values:h.value,"onUpdate:values":y[6]||(y[6]=R=>h.value=R)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},Cn={class:"overflow-hidden flex flex-col min-h-[480px]"},Nn={class:"flex-1 flex min-h-0 gap-4"},Dn={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},Sn={key:1,class:"flex items-center justify-center h-full"},zn={class:"w-[400px] shrink-0 flex flex-col"},Ln={__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 l(){if(!(!s.selectedDashboard||!s.selectedWidget))try{o.value=await A.get(`/bi-data?dashboard=${s.selectedDashboard}&widget=${s.selectedWidget}`)}catch(c){console.error(c)}}function a(){n("update-data")}e.watch(()=>[s.selectedDashboard,s.selectedWidget],()=>{l()},{immediate:!0});const i=e.computed({get:()=>s.selectedWidget,set:c=>n("update:selectedWidget",c)});return(c,d)=>(e.openBlock(),e.createElementBlock("div",Cn,[e.createElementVNode("div",Nn,[e.createElementVNode("div",Dn,[o.value?(e.openBlock(),e.createBlock(de,{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",Sn,[...d[1]||(d[1]=[e.createElementVNode("span",{class:"text-sm text-gray-400"},"Завантаження...",-1)])]))]),e.createElementVNode("div",zn,[e.createVNode(Vn,{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"])])])]))}},_t={__name:"icon-grid",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(_r),e.mergeProps(t.$attrs,{size:24}),null,16))}},$t={__name:"icon-table",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Cr),e.mergeProps(t.$attrs,{size:24}),null,16))}},Tn={__name:"icon-more",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(br),e.mergeProps(t.$attrs,{size:24}),null,16))}},In=e.defineAsyncComponent(()=>import("@opengis/form")),Mn={components:{VsModal:pe,VForm:In,deleteIcon:st,editIcon:nt,IconGrid:_t,IconMore:Tn,IconTable:$t},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: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 s=(t=(r=this.$refs)==null?void 0:r.formEdit)==null?void 0:t.validate();typeof s=="function"&&await s(),await A.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 A.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 A.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()}}},Pn={key:0,class:"flex items-center gap-4"},Fn={class:"h-[30px] w-[30px] flex items-center justify-center"},Rn={class:"flex flex-col items-start -ml-2 -mr-2"},jn={class:"p-4"},On={class:"flex justify-end mt-4 gap-x-3"},An={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Wn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function qn(r,t,s,n,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,[s.selected?(e.openBlock(),e.createElementBlock("div",Pn,[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",Fn,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",Rn,[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",jn,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",On,[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",An,[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",Wn,[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 vn=M(Mn,[["render",qn]]),Un={class:"flex-1 min-w-0 flex flex-col overflow-auto"},Hn={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},Gn={class:"relative z-10 shrink-0 mt-4 mb-6"},Zn={class:"flex items-center text-sm text-gray-600"},Qn={key:0,class:"flex items-center justify-between gap-4 mt-3"},Xn={class:"min-w-0"},Jn={class:"text-2xl font-bold text-gray-900"},Kn={key:0,class:"mt-1.5 text-sm text-gray-600"},Yn={class:"flex items-center shrink-0"},eo={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"},to=M({__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;xe(s.prefix||"/api");const n=t,o=U.useRouter(),l=e.computed(()=>o.hasRoute(q.EditorWidget)),a=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,f=>{c.value=f||""});const b=async()=>{if(!i.value){d.value=null;return}try{const f=await A.get(`/bi-dashboard/${i.value}`);d.value=f}catch(f){console.error(f)}},g=e.computed(()=>{var f,u,w;return(w=Array.isArray((f=d.value)==null?void 0:f.widgets)?(u=d.value)==null?void 0:u.widgets:[])==null?void 0:w.find(V=>(V==null?void 0:V.name)===c.value)});function m(f){l.value?o.push({name:q.EditorWidget,params:{dashboardId:i.value,widgetId:f}}):c.value=f}function k(){l.value?o.push({name:q.EditorDashboard,params:{dashboardId:i.value}}):c.value=""}function x(){l.value?o.push({name:q.Editor}):(typeof a=="function"&&a(),n("back"))}const $=e.computed(()=>{var w,V,_,y,E;const u=[l.value?{label:"Дашборди",to:{name:q.Editor}}:{label:"Дашборди",onClick:x}];if((w=d.value)!=null&&w.title||i.value){const N=((V=d.value)==null?void 0:V.title)||i.value||"Редактор";!!c.value?u.push(l.value?{label:N,to:{name:q.EditorDashboard,params:{dashboardId:i.value}}}:{label:N,onClick:()=>{c.value=""}}):u.push({label:N})}else u.push({label:"Редактор"});if(c.value&&g.value){const N=((y=(_=g.value)==null?void 0:_.data)==null?void 0:y.title)||((E=g.value)==null?void 0:E.title)||c.value;u.push({label:N})}return u});return e.watch(i,(f,u)=>{u&&(c.value=""),f?b():(d.value=null,x())}),e.onMounted(()=>{b()}),(f,u)=>{var w,V;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[r.customClass]])},[e.createElementVNode("div",Un,[e.createElementVNode("div",Hn,[e.createElementVNode("div",Gn,[e.createElementVNode("div",Zn,[e.createVNode(et,{items:$.value,compact:""},null,8,["items"])]),i.value&&d.value?(e.openBlock(),e.createElementBlock("div",Qn,[e.createElementVNode("div",Xn,[e.createElementVNode("h1",Jn,e.toDisplayString(d.value.title||i.value),1),d.value.description?(e.openBlock(),e.createElementBlock("p",Kn,e.toDisplayString(d.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Yn,[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:k},[e.createVNode(e.unref(Je),{class:"w-4 h-4"}),u[5]||(u[5]=e.createTextVNode(" Закрити ",-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(vn,{selected:i.value,"onUpdate:selected":u[0]||(u[0]=_=>i.value=_),dashboardData:d.value,columns:(w=d.value)==null?void 0:w.columns,selectedWidgetData:g.value,prefix:r.prefix,onUpdateEditor:b},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:u[1]||(u[1]=_=>{var y,E;return(E=(y=h.value)==null?void 0:y.open)==null?void 0:E.call(y)})},[...u[6]||(u[6]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ",-1)])]),i.value?(e.openBlock(),e.createBlock(Bs,{key:0,ref_key:"createWidgetRef",ref:h,inline:"",columns:(V=d.value)==null?void 0:V.columns,selectedDashboard:i.value,onUpdateData:b},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),c.value&&d.value?(e.openBlock(),e.createBlock(Ln,{key:0,"selected-widget":c.value,"onUpdate:selectedWidget":u[2]||(u[2]=_=>c.value=_),"selected-widget-data":g.value,"current-widget-data":p.value,"selected-dashboard":i.value,"dashboard-widgets":d.value.widgets||[],onUpdateData:b},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",eo,[d.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(d.value.panels,(_,y)=>{var E,N;return e.openBlock(),e.createElementBlock("div",{key:_.widget||((E=_.widgets)==null?void 0:E.join("-"))||y,class:e.normalizeClass([`md:col-span-${_.col||12} col-span-12`,"flex flex-col gap-[10px]"])},[(N=_.widgets)!=null&&N.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(_.widgets,S=>(e.openBlock(),e.createBlock(de,{onClick:O=>m(S),"onUpdate:currentWidgetData":u[3]||(u[3]=O=>p.value=O),key:S,dashboard:i.value,widget:S,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(_.height??480),class:e.normalizeClass({"border border-blue-500":c.value===S})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","height","class"]))),128)):(e.openBlock(),e.createBlock(de,{key:1,onClick:S=>m(_.widget),"onUpdate:currentWidgetData":u[4]||(u[4]=S=>p.value=S),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":c.value===_.widget}]),dashboard:i.value,widget:_.widget,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(_.height??480)},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets","height"]))],2)}),128)):(e.openBlock(),e.createBlock(we,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-330ef797"]]),ro={class:"w-full h-screen"},Et=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",ro,[e.createVNode(to,{customClass:"h-full w-full",prefix:r.prefix,"initial-dashboard-id":r.dashboardId,"initial-widget-id":r.widgetId,onBack:s[0]||(s[0]=n=>t.$emit("back"))},null,8,["prefix","initial-dashboard-id","initial-widget-id"])]))}}),re=(r,t)=>{const s=r.__vccOpts||r;for(const[n,o]of t)s[n]=o;return s},so={},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-green-600"};function oo(r,t){return e.openBlock(),e.createElementBlock("svg",no,[...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 ao=re(so,[["render",oo]]),lo={},io={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 co(r,t){return e.openBlock(),e.createElementBlock("svg",io,[...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 po=re(lo,[["render",co]]),ho={},uo={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 mo(r,t){return e.openBlock(),e.createElementBlock("svg",uo,[...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 fo=re(ho,[["render",mo]]),go={},bo={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 yo(r,t){return e.openBlock(),e.createElementBlock("svg",bo,[...t[0]||(t[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"},null,-1)])])}const xo=re(go,[["render",yo]]),ko={class:"rounded-md border border-gray-300 bg-white p-4 shadow-sm"},wo={class:"flex items-start gap-4 opacity-100 scale-5 transition-all duration-300"},_o={class:"flex-1"},$o={class:"font-medium text-gray-900"},Eo={class:"mt-0.5 text-sm text-gray-700"},Bo=e.defineComponent({__name:"vs-notify",props:{type:{},title:{},message:{}},setup(r){const t={success:ao,warning:po,error:xo,info:fo};return(s,n)=>(e.openBlock(),e.createElementBlock("div",ko,[e.createElementVNode("div",wo,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t[s.type]))),e.createElementVNode("div",_o,[e.createElementVNode("strong",$o,e.toDisplayString(s.title),1),e.createElementVNode("p",Eo,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))])]))}}),Ce={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"},Vo=r=>{var c;const{type:t="info",title:s,message:n,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 ${Ce[o]} p-6 max-w-md mx-auto font-sans antialiased`,document.body.appendChild(l)),l.className.includes(Ce[o])||(Object.values(Ce).forEach(d=>{l.classList.remove(...d.split(" "))}),l.classList.add(...Ce[o].split(" ")));const a=document.createElement("div");l.appendChild(a);const i=e.createApp({render(){return e.h(Bo,{type:t,title:s,message:n,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,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,l;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:(l=this.notifyOptions)==null?void 0:l.position};Vo(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 Co={},No={xmlns:"http://www.w3.org/2000/svg",class:"w-6 h-6",viewBox:"0 0 20 20",fill:"currentColor"};function Do(r,t){return e.openBlock(),e.createElementBlock("svg",No,[...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 So=re(Co,[["render",Do]]),zo={},Lo={xmlns:"http://www.w3.org/2000/svg",class:"w-6 h-6",viewBox:"0 0 20 20",fill:"currentColor"};function To(r,t){return e.openBlock(),e.createElementBlock("svg",Lo,[...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 Io=re(zo,[["render",To]]),Mo={},Po={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 Fo(r,t){return e.openBlock(),e.createElementBlock("svg",Po,[...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 Ro=re(Mo,[["render",Fo]]),jo={},Oo={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 Ao(r,t){return e.openBlock(),e.createElementBlock("svg",Oo,[...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 Wo=re(jo,[["render",Ao]]),qo={class:"flex items-center justify-between w-full"},vo={class:"m-0 flex list-none justify-center gap-1 p-0 text-gray-900"},Uo=["onClick"],Ho={key:1,class:"flex size-7 items-center justify-center px-1 text-gray-500 select-none","aria-hidden":"true"},Go={key:1},Zo={for:"Page"},Qo=["value","max"],Xo={key:2,class:"text-sm/8 font-medium tracking-widest"},Jo={key:0,class:"flex justify-center items-center gap-x-5 ml-3"},Ko={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"},Yo=["onClick"],ea=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),l=e.computed(()=>Math.ceil(s.total/s.pageSize)),a=e.computed(()=>{const x=Math.floor(s.pageRange/2);let $=o.value-x,f=o.value+x;$<1&&(f+=1-$,$=1),f>l.value&&($-=f-l.value,f=l.value),$=Math.max(1,$);const u=[];for(let w=$;w<=f;w+=1)u.push(w);return u}),i=e.computed(()=>{const x=a.value,$=l.value;if($<=1)return x.map(V=>({type:"page",value:V}));const f=x.length>0&&x[0]>1,u=x.length>0&&x[x.length-1]<$,w=[];return f&&(w.push({type:"page",value:1}),w.push({type:"ellipsis"})),x.forEach(V=>w.push({type:"page",value:V})),u&&(w.push({type:"ellipsis"}),w.push({type:"page",value:$})),w}),c=x=>{o.value=x,n("update:page",x),n("pageChange",x)},d=()=>{o.value>1&&c(o.value-1)},p=()=>{o.value<l.value&&c(o.value+1)};e.watch(()=>s.page,x=>{o.value=x});const h=e.ref(s.pageSize),b=e.ref(!1),g=e.ref(null);e.watch(()=>s.pageSize,x=>{h.value=x});const m=(x=h.value)=>{h.value=x,b.value=!1,o.value=1,n("update:page",o.value),n("pageSizeChange",h.value)},k=x=>{if(!b.value)return;const $=x.target;g.value&&$&&!g.value.contains($)&&(b.value=!1)};return e.onMounted(()=>{document.addEventListener("click",k)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",k)}),(x,$)=>(e.openBlock(),e.createElementBlock("div",qo,[e.createElementVNode("ul",vo,[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(So)],2)]),x.view==="button"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(i.value,(f,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:f.type==="page"?f.value:`ellipsis-${u}`},[f.type==="page"?(e.openBlock(),e.createElementBlock("li",{key:0,class:e.normalizeClass([[`size-${s.size} text-sm/${s.size} px-1.5`,f.value===o.value&&x.color?`bg-[${x.color}]`:"",f.value===o.value?`block rounded border border-${x.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:w=>c(f.value)},e.toDisplayString(f.value),11,Uo)):(e.openBlock(),e.createElementBlock("li",Ho," … "))],64))),128)):x.view==="input"?(e.openBlock(),e.createElementBlock("li",Go,[e.createElementVNode("label",Zo,[$[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]=f=>c(Number(f))),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,Qo)])])):x.view==="xy"?(e.openBlock(),e.createElementBlock("li",Xo,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(Io)],2)])]),x.showPageSizes?(e.openBlock(),e.createElementBlock("div",Jo,[e.createElementVNode("div",{class:"relative",ref_key:"dropdownRef",ref:g},[e.withDirectives(e.createElementVNode("div",Ko,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.pageSizes,f=>(e.openBlock(),e.createElementBlock("button",{type:"button",key:f,onClick:u=>m(f),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(f)+" ",1),h.value===f?(e.openBlock(),e.createBlock(Wo,{key:0})):e.createCommentVNode("",!0)],8,Yo))),128))],512),[[e.vShow,b.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]=f=>b.value=!b.value)},[e.createTextVNode(e.toDisplayString(h.value)+" ",1),e.createVNode(Ro)])],512)])):e.createCommentVNode("",!0)]))}}),ta=re(ea,[["__scopeId","data-v-36d0267f"]]);e.reactive({visible:!0});const ra={class:"relative group h-full"},sa={class:"flex items-start gap-3 flex-1 min-h-0"},na={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},oa={class:"flex-1 min-w-0 flex flex-col min-h-0"},aa={class:"font-semibold text-gray-900 mb-1 truncate"},la={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},ia={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},ca={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},da=M({__name:"dashboard-card",props:{title:String,description:String,modified:String,name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function},setup(r){const t=r,s=U.useRouter(),n=e.ref(!1);function o(){t.dashboardRouteName&&(s.hasRoute(q.EditorDashboard)?s.push({name:q.EditorDashboard,params:{dashboardId:t.dashboardRouteName}}):t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):s.push({path:"/editor",query:{dashboard:t.dashboardRouteName}}))}function l(a){a.target.closest(".dashboard-card-menu")||(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",l)),e.onUnmounted(()=>document.removeEventListener("click",l)),(a,i)=>(e.openBlock(),e.createElementBlock("div",ra,[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:o},[e.createElementVNode("div",sa,[e.createElementVNode("div",na,[e.createVNode(e.unref(wr),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",oa,[e.createElementVNode("h3",aa,e.toDisplayString(r.title),1),r.description?(e.openBlock(),e.createElementBlock("p",la,e.toDisplayString(r.description),1)):(e.openBlock(),e.createElementBlock("p",ia," ")),r.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",ca,e.toDisplayString(r.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-716ced89"]]),pa=[{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 ha(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 ua={class:"flex-1 bg-gray-50"},ma={class:"max-w-7xl mx-auto px-6 py-8"},fa={class:"mb-6"},ga={class:"flex items-center justify-between mb-6"},ba={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},ya={class:"flex items-center space-x-4"},xa={class:"flex-1 relative"},ka={class:"relative"},wa={class:"relative min-h-[280px]"},_a={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"},$a={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},Ea={class:"mt-[20px]"},Ba={key:2,class:"flex flex-col items-center justify-center py-20 text-center"},Va={class:"mt-1 text-sm text-gray-400"},Ca={class:"font-medium text-gray-500"},Bt=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(r){const t=e.defineAsyncComponent(()=>import("@opengis/form")),s=ha(pa),n=e.ref([]),o=e.ref([]),l=U.useRouter(),a=U.useRoute();function i(C){const B=Array.isArray(C)?C[0]:C,z=typeof B=="string"?parseInt(B,10):NaN;return!Number.isNaN(z)&&z>=1?z:1}function c(C){const B=Array.isArray(C)?C[0]:C;return typeof B=="string"?B:""}function d(C){const B=C.trim().toLowerCase();return B?B.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):""}const p=e.inject("biSetDashboard",void 0),h=r,b=e.ref(null),g=e.ref(!1),m=e.ref({}),k=e.ref(""),x=e.ref("title-asc"),$=e.ref(20),f=e.ref(0),u=e.ref(1),w=e.ref(!1),V=e.computed(()=>{const C=x.value==="title-asc"?1:-1;return[...n.value].sort((B,z)=>C*B.title.localeCompare(z.title,"uk"))});async function _(){w.value=!0;try{const C=d(k.value),B=await A.get("/bi-dashboard",{params:{type:"db",page:u.value,limit:$.value,...C?{search:C}:{}}}),z=Array.isArray(B==null?void 0:B.rows)?B.rows:[];f.value=(B==null?void 0:B.filtered)||(B==null?void 0:B.total)||0,o.value=z,n.value=z.map(j=>({routeName:String(j.name??""),title:j.title??j.name??"Без назви",description:j.description??null,modified:"-",name:"-"}))}catch(C){console.error("Failed to load dashboards",C),o.value=[],n.value=[]}finally{w.value=!1}}async function y(){var B,z,j;const C=(z=(B=e.getCurrentInstance())==null?void 0:B.proxy)==null?void 0:z.$notify;try{const Y=(j=b.value)==null?void 0:j.validate();typeof Y=="function"&&await Y();const{name:ee,title:R,table_name:K}=m.value;if(!ee||!R||!K){C==null||C({type:"error",title:"Помилка!",message:"Заповніть усі обов'язкові поля"});return}await A.post("/bi-dashboard",m.value),g.value=!1,m.value={},C==null||C({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),l.hasRoute(q.EditorDashboard)?l.push({name:q.EditorDashboard,params:{dashboardId:ee}}):p?p(ee):await _()}catch{C==null||C({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}let E=null;e.onMounted(()=>{xe(h.prefix||"/api"),u.value=i(a.query.page),k.value=c(a.query.search),_()}),e.watch(k,C=>{E&&clearTimeout(E),E=setTimeout(()=>{E=null;const B=C.trim(),z=c(a.query.search);if(B===z)return;const j={...a.query};B?j.search=B:delete j.search,delete j.page,l.replace({query:j})},300)}),e.watch(()=>[a.query.page,a.query.search],()=>{const C=i(a.query.page),B=c(a.query.search);u.value=C,k.value=B,_()});const N=e.ref(1),S=()=>{const C=window.innerWidth;N.value=C>=1024?3:C>=768?2:1};e.onMounted(()=>{S(),window.addEventListener("resize",S)}),e.onUnmounted(()=>{E&&clearTimeout(E),window.removeEventListener("resize",S)});const O=C=>C?C.trim().length>70?2:1:0,G=C=>{const B=N.value||1,j=Math.floor(C/B)*B,Y=j+B,ee=V.value.slice(j,Y);let R=0;for(const K of ee){const se=O(K.description??null);if(se>R&&(R=se),R===2)break}return R},Z=C=>{const B={...a.query};C===1?delete B.page:B.page=String(C),l.push({query:B})};return(C,B)=>(e.openBlock(),e.createElementBlock("div",ua,[e.createElementVNode("div",ma,[e.createElementVNode("div",fa,[e.createElementVNode("div",ga,[B[7]||(B[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:B[0]||(B[0]=z=>g.value=!0)},[e.createVNode(e.unref(Qe),{size:24,class:"w-4 h-4"}),B[6]||(B[6]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(pe,{teleport:"#modal",visible:g.value,title:"Створити дашборд",onClose:B[3]||(B[3]=z=>g.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",ba,[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:B[2]||(B[2]=z=>g.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:y}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:b,schema:e.unref(s),values:m.value,"onUpdate:values":B[1]||(B[1]=z=>m.value=z)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",ya,[e.createElementVNode("div",xa,[e.createVNode(e.unref(Xe),{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":B[4]||(B[4]=z=>k.value=z),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,k.value]])]),e.createElementVNode("div",ka,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":B[5]||(B[5]=z=>x.value=z),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"},[...B[8]||(B[8]=[e.createElementVNode("option",{value:"title-asc"},"Назва (А → Я)",-1),e.createElementVNode("option",{value:"title-desc"},"Назва (Я → А)",-1)])],512),[[e.vModelSelect,x.value]]),e.createVNode(e.unref(mr),{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",wa,[w.value?(e.openBlock(),e.createElementBlock("div",_a,[...B[9]||(B[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),V.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",$a,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,(z,j)=>(e.openBlock(),e.createElementBlock("div",{key:z.routeName,class:"cursor-pointer h-full"},[e.createVNode(da,{title:z.title,description:z.description,modified:z.modified,name:z.name,reserveLines:G(j),"dashboard-route-name":z.routeName,"on-open-editor":e.unref(p)},null,8,["title","description","modified","name","reserveLines","dashboard-route-name","on-open-editor"])]))),128))]),e.createElementVNode("div",Ea,[e.createVNode(e.unref(ta),{total:f.value,showPageSizes:!1,page:u.value,pageSize:$.value,"onUpdate:page":Z,color:"#2563eb"},null,8,["total","page","pageSize"])])],64)):w.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ba,[e.createVNode(e.unref(Xe),{size:48,class:"text-gray-300 mb-4"}),B[12]||(B[12]=e.createElementVNode("p",{class:"text-lg font-medium text-gray-500"},"Дашбордів не знайдено",-1)),e.createElementVNode("p",Va,[B[10]||(B[10]=e.createTextVNode(" За запитом «",-1)),e.createElementVNode("span",Ca,e.toDisplayString(k.value),1),B[11]||(B[11]=e.createTextVNode("» нічого не знайдено. Спробуйте змінити пошуковий запит. ",-1))])]))])])]))}}),Na=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(r){const t=r,s=e.computed(()=>t.prefix),n=U.useRouter(),o=U.useRoute(),l=e.computed(()=>n.hasRoute(q.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(Et,{key:`editor-${a.value}`,prefix:s.value,"dashboard-id":a.value,onBack:d[0]||(d[0]=h=>a.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock(Bt,{key:0,prefix:s.value},null,8,["prefix"]))],64))}}});function J(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 ye(r){if(!(r!=null&&r.includes("T")))return r??"";const[t,s,n]=r.split("T")[0].split("-");return`${n}.${s}.${t}`}function Da(r){return Intl.NumberFormat("en").format(r??0)}class Sa{static getTooltipOptions(t=!0){return{show:t,confine:!0,appendToBody:!1,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const za={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function La(){const r="0123456789ABCDEF";let t="#";for(let s=0;s<6;s+=1)t+=r[Math.floor(Math.random()*16)];return t}function ae(r=za){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)??(l=>J(l)),...(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 Vt(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=>J(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 Ct=["#d3c7e6","#bedae3","#f8e9cb","#ff8c8c","#c5d8be","#ffc6c6","#ffc39a","#fff7c5","#d8ffc0","#d4f7ff"];class Ne{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 le=typeof window<"u"?window.echarts:null,v={props:["source","style","widget","dashboard","title","currentWidget","widgetData","prefix","prefetchedData"],data(){return{sourceData:null,styleData:null,widgetName:"",dimensions:[],dashboardName:"",titleCharts:"",widgetInstance:null}},mounted(){window.addEventListener("resize",this.handleResize),window.addEventListener(`update-data-${this.widget}`,this.checkCustomEvent),window.addEventListener(`update-style-${this.widget}`,this.checkCustomStyleEvent)},unmounted(){window.removeEventListener(`update-data-${this.widget}`,this.checkCustomEvent),window.removeEventListener(`update-style-${this.widget}`,this.checkCustomStyleEvent)},watch:{sourceData:{async handler(){setTimeout(()=>{this==null||this.onChangedData()},0)}}},methods:{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 A.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()],l=t.getFullYear();return`${s} ${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;try{if(this.source)this.sourceData=[...this.source],this.styleData=this.style,this.titleCharts=this.title,this.dimensions=Object.keys(((r=this.sourceData)==null?void 0:r[0])||{});else if(this.prefetchedData)this.widgetName=this.widget,this.dashboardName=this.dashboard,this.applyResponse(this.prefetchedData);else{this.widgetName=this.widget,this.dashboardName=this.dashboard;const t=this.dashboardName?`${this.prefix||""}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}`:`${this.prefix||""}/bi-data?&widget=${this.widgetName}`;await this.getDataFromURL(t)}}catch(t){console.error(t)}},async initChart(r,t,s){var n,o,l,a,i,c,d,p,h;this.widgetInstance&&this.widgetInstance.clear();try{const b=this.$refs.chart,g=le==null?void 0:le.init(b);if(!g)return;const m={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:(k,x,$,f,u)=>{const[w,V]=k,[_,y]=u.contentSize,[E,N]=u.viewSize;let S=w+14,O=V-y/2;return S+_>E&&(S=w-_-14),S<0&&(S=0),O+y>N&&(O=N-y),O<0&&(O=0),[S,O]},formatter:k=>{var y;const $=(y=k[0])==null?void 0:y.axisValue,f=$?this.formatDate($):"N/A",u=[...k].filter(E=>{var N;return parseFloat(E==null?void 0:E.data)||((N=E==null?void 0:E.data)==null?void 0:N.value)}).sort((E,N)=>{var G,Z;const S=parseFloat(((G=E==null?void 0:E.data)==null?void 0:G.value)??(E==null?void 0:E.data))||0;return(parseFloat(((Z=N==null?void 0:N.data)==null?void 0:Z.value)??(N==null?void 0:N.data))||0)-S}),w=u.slice(0,8),V=u.length-w.length;let _=`
|
|
192
192
|
<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">
|
|
193
193
|
<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">
|
|
194
|
-
${
|
|
194
|
+
${f}
|
|
195
195
|
</div>
|
|
196
|
-
`;return
|
|
196
|
+
`;return w.forEach(E=>{_+=`
|
|
197
197
|
<div class="flex justify-between items-center text-xs px-2 py-0.5 text-gray-500 dark:text-neutral-400">
|
|
198
198
|
<span class="flex items-center">
|
|
199
199
|
<span class="w-2.5 h-2.5 me-1.5 rounded-sm" style="background-color: ${E.color};"></span>
|
|
@@ -201,19 +201,19 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
|
|
|
201
201
|
</span>
|
|
202
202
|
<span>${this.getMetricValue(E==null?void 0:E.data)}</span>
|
|
203
203
|
</div>
|
|
204
|
-
`}),
|
|
204
|
+
`}),V>0&&(_+=`
|
|
205
205
|
<div class="text-xs px-2 py-0.5 text-gray-400 dark:text-neutral-500">
|
|
206
|
-
... ще ${
|
|
207
|
-
</div>`),
|
|
206
|
+
... ще ${V}
|
|
207
|
+
</div>`),_+="</div>",_}},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:{...Vt((i=this.styleData)==null?void 0:i.x_axis),formatter:k=>{var $,f;const x=this.formatDate(k);return((f=($=this.styleData)==null?void 0:$.x_axis)==null?void 0:f.overflow)==="ellipsis"&&x.length>10?`${x.slice(0,10)}...`:x}}},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:Vt((p=this.styleData)==null?void 0:p.y_axis)},series:r!=null&&r.length?r:null,...ae(this.styleData),grid:{bottom:"0%",right:"0%",left:"0%",top:"20px",containLabel:!0,...((h=this.styleData)==null?void 0:h.grid)||{}}};await g.setOption(m),g.resize(),this.widgetInstance=g,this.$emit("update:currentWidget",g)}catch(b){console.error(b)}},async setSeriesOption(r,t){const s=r.getOption(),{series:n=[]}=s,o=n.map(l=>({...l,...t}));r.setOption({...s,series:o})},async changeOptionsByName(r,t){const s=document.getElementById(r);if(!s)return null;const n=le==null?void 0:le.getInstanceByDom(s);if(!n)return null;const o=n.getOption();t.seriesOptions&&this.setSeriesOption(n,t.seriesOptions),n.setOption({...o,...t.options,tooltip:{...Sa.getTooltipOptions(t.options.tooltip.show)}})},async changeData(r){var t;try{let s=this.dashboard?`${this.prefix||""}/bi-data?dashboard=${this.dashboard}&widget=${this.widget}`:`${this.prefix||""}/bi-data?&widget=${this.widget}`;(t=r==null?void 0:r.granularity)!=null&&t.length&&(s+=`&granularity=${r.granularity}`),r!=null&&r.metrics&&(s+=`&metrics=${r.metrics}`),this.getDataFromURL(s)}catch(s){console.error(s)}},async setFilter(r){const t=`${this.prefix||""}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}${r||""}`;await this.getDataFromURL(t)},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=J(t,{notation:"standard"}))==null?void 0:n.replaceAll(","," "):t}}},Ta={name:"VsBar",mixins:[v],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,l;try{if(!((r=this.sourceData)!=null&&r.length))return{series:[],xs:[],ys:void 0};const a=Array.from(new Set(this.sourceData.filter(b=>b[this.dimensions[0]]).map(b=>b[this.dimensions[0]])));let i;this.dimensions[0].includes("date")?i=a.map(b=>ye(b)):i=[...a];let c,d;((t=this.styleData)==null?void 0:t.horizontal)===!0?d=[...i]:c=[...i];const p=this.sourceData.filter(b=>parseFloat(b[this.dimensions[1]])&&b[this.dimensions[0]]).map(b=>parseFloat(b[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):((l=this.styleData)==null?void 0:l.accumulative)===!0?h=this.prepareAccumulative(p):h=this.dimensions.slice(1).map((g,m)=>({name:g,type:"bar",stack:`a${m}`,data:this.sourceData.filter(k=>parseFloat(k[g])&&g).map(k=>parseFloat(k[g]))})),{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 s=[t,...r],n=s.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: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(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 s=0;const n=r.map((l,a)=>{const i=s;return s+=Number.isNaN(l)?0:l,a===0&&(s-=Number.isNaN(t[a])?0:t[a]),s-=Number.isNaN(t[a+1])?0:t[a+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}]}}},Ia=["id"];function Ma(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full w-full min-h-[200px]"},null,8,Ia)}const Oe=M(Ta,[["render",Ma]]),Pa=Object.freeze(Object.defineProperty({__proto__:null,default:Oe},Symbol.toStringTag,{value:"Module"})),Ae=typeof window<"u"?window.echarts:null,Fa={name:"VsPie",props:["currentWidget"],mixins:[v],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`
|
|
208
208
|
<div style="background-color:${t[0]}; font-size:12px; font-family:Helvetica, Arial, sans-serif; color:#ffff; padding:5px; border-radius:5px;">
|
|
209
|
-
${
|
|
210
|
-
</div>`},prepareData(){var
|
|
209
|
+
${s==null?void 0:s.replace("null","Не визначено")}: ${J(n)} (${o}%)
|
|
210
|
+
</div>`},prepareData(){var r,t,s,n,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(m=>m[this.dimensions[0]]))),i=Array.from(new Set((this.sourceData||[]).map(m=>m[this.dimensions[1]]))),c=parseInt((this.sourceData||[]).reduce((m,k)=>m+parseFloat((k==null?void 0:k.metric)||0),0),10),d=a.map((m,k)=>{const x=(i[k]/c*100).toFixed(2);return{name:`${m} (${x}%)`,value:i[k]}}),p=((t=this.styleData)==null?void 0:t.innerRadius)||"80%",h=((s=this.styleData)==null?void 0:s.outerRadius)||"100%",b=[p,h];return this.styleData.legend=Ne.getLegendOpions({borderRadius:10,height:"100%",padding:10,bottom:"0",type:"scroll",itemWidth:14,itemHeight:14,formatter:m=>{var k;return(k=m==null?void 0:m.replace("null","Не визначено"))==null?void 0:k.replace("NaN","0.00")},...((n=this.styleData)==null?void 0:n.legend)||{}}),this.styleData.label=Ne.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:b,center:["50%","60%"],height:"75%",...ae(this.styleData),data:d}]}}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=Ae==null?void 0:Ae.init(n),!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:((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,...ae(this.styleData||{}),title:{text:J(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(n){console.error("Error in initChart:",n)}}}},Ra=["id"];function ja(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,Ra)}const Nt=M(Fa,[["render",ja]]),Oa=Object.freeze(Object.defineProperty({__proto__:null,default:Nt},Symbol.toStringTag,{value:"Module"})),We=typeof window<"u"?window.echarts:null,Aa={name:"VsPie",props:["currentWidget"],mixins:[v],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`
|
|
211
211
|
<div style="background-color:${t[0]}; font-size:12px; font-family:Helvetica, Arial, sans-serif; color:#ffff; padding:5px; border-radius:5px;">
|
|
212
|
-
${
|
|
213
|
-
</div>`},prepareData(){var s,t,r,n,o;try{this.styleData=this.styleData||{};const l=Array.from(new Set((this.sourceData||[]).map(g=>g[this.dimensions[0]]))),a=Array.from(new Set((this.sourceData||[]).map(g=>g[this.dimensions[1]]))),i=parseInt((this.sourceData||[]).reduce((g,u)=>g+parseFloat(u==null?void 0:u.metric),0),10),c=l.map((g,u)=>{const w=(a[u]/i*100).toFixed(2);return{name:`${g} (${w}%)`,value:a[u]}}),d=((s=this.styleData)==null?void 0:s.innerRadius)||"0%",p=((t=this.styleData)==null?void 0:t.outerRadius)||"100%",h=[d,p];return this.styleData.legend=Be.getLegendOpions({borderRadius:10,height:"100%",padding:10,type:"scroll",itemWidth:14,itemHeight:14,formatter:g=>g==null?void 0:g.replace("null","Не визначено"),textStyle:{fontSize:"14px"},...((r=this.styleData)==null?void 0:r.legend)||{}}),this.styleData.label=Be.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%",...Y(this.styleData),data:c}]}}catch(l){return console.error("Error in prepareData:",l),null}},async initChart(s){var t,r;try{if(!s){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=We==null?void 0:We.init(n),!this.chartInstance)return;const o={tooltip:{show:((r=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:r.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:s,...Y(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(n){console.error("Error in initChart:",n)}}}},jo=["id"];function Wo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,jo)}const Dt=L(Fo,[["render",Wo]]),Oo=Object.freeze(Object.defineProperty({__proto__:null,default:Dt},Symbol.toStringTag,{value:"Module"})),Ao={name:"VsLine",mixins:[W],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:s,xs:t}=this.prepareData();s&&this.initChart(s,t)},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&(this==null||this.initChart(s,t,r))}}catch(s){console.error(s)}},prepareData(){var s,t;try{const r=Array.from(new Set(this.sourceData.map(a=>a[this.dimensions[0]])));let n;this.dimensions[0].includes("date")?n=r.map(a=>pe(a)):n=[...r];const o=this.sourceData.map(a=>parseFloat(a[this.dimensions[1]]));let l;return(s=this.styleData)!=null&&s.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:n}}catch(r){return console.error(r),null}}}},qo=["id"];function vo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,ref:"chart",style:{height:"400px"}},null,8,qo)}const Ct=L(Ao,[["render",vo]]),Uo=Object.freeze(Object.defineProperty({__proto__:null,default:Ct},Symbol.toStringTag,{value:"Module"})),Ho={name:"VsStat",mixins:[W],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 s=this.getValues();this.sumValue=s.reduce((t,r)=>t+r,0),this.sourceData.forEach((t,r)=>{t.color=r<Vt.length-1?Vt[r]:No()})},formattedValue(s){const t=parseFloat(s);return H(t)}}},Go={class:"flex flex-col w-full h-full pt-[16px] rounded-xl"},Zo={class:"flex flex-col justify-between w-full h-full"},Qo={class:"w-full h-full pb-6 space-y-4"},Xo={class:"flex w-full h-3 rounded-full gap-x-1 min-h-3 custom-x-scrollbar"},Jo=["onMouseover"],Ko={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"},Yo={class:"h-[calc(100%-40px)] w-full custom-scrollbar"},ea={class:"grid items-center justify-between grid-cols-2 py-2 gap-x-4"},ta={class:"flex items-center"},sa={class:"text-sm text-gray-800"},ra={class:"text-end"},na={class:"text-sm text-gray-500"};function oa(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Go,[e.createElementVNode("div",Zo,[e.createElementVNode("div",Qo,[e.createElementVNode("div",Xo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.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:b=>o.showTooltip=i,onMouseleave:t[0]||(t[0]=b=>o.showTooltip=-1)},[o.showTooltip>-1?(e.openBlock(),e.createElementBlock("div",Ko,e.toDisplayString(s.sourceData[o.showTooltip][o.columns[0]])+" "+e.toDisplayString((parseFloat((h=(d=s.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,Jo)}),256))]),e.createElementVNode("ul",Yo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,a=>{var i,c;return e.openBlock(),e.createElementBlock("li",ea,[e.createElementVNode("div",ta,[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",sa,e.toDisplayString((a==null?void 0:a[(i=o.columns)==null?void 0:i[0]])||"Не визначено"),1)]),e.createElementVNode("div",ra,[e.createElementVNode("span",na,e.toDisplayString(l.formattedValue(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])||"-"),1)])])}),256))])])])])}const Nt=L(Ho,[["render",oa]]),aa=Object.freeze(Object.defineProperty({__proto__:null,default:Nt},Symbol.toStringTag,{value:"Module"})),la={name:"VsProgressBar",mixins:[W],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 s=this.getValues();this.maxValue=Math.max(...s)},formattedValue(s){return H(s)}}},ia={key:0,class:"flex flex-col h-full pt-[16px] rounded-xl"},ca={class:"h-full pt-0 pb-6 space-y-4"},da={class:"h-full space-y-4 custom-scrollbar"},pa={class:"flex items-center justify-between mr-2 gap-x-2"},ha={class:"grid items-center w-full grid-cols-2 gap-x-2"},ua={class:"text-sm text-gray-800"},ma={class:"flex justify-end",role:"progressbar","aria-valuenow":"100","aria-valuemin":"0","aria-valuemax":"100"},fa={class:"min-w-[60px] text-end"},ga={class:"text-sm text-gray-500"};function ba(s,t,r,n,o,l){return o.columns?(e.openBlock(),e.createElementBlock("div",ia,[e.createElementVNode("div",ca,[e.createElementVNode("ul",da,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("li",pa,[e.createElementVNode("div",ha,[e.createElementVNode("span",ua,e.toDisplayString(a[o.columns[0]]),1),e.createElementVNode("div",ma,[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",fa,[e.createElementVNode("span",ga,e.toDisplayString(l.formattedValue(a[o.columns[1]])),1)])]))),256))])])])):e.createCommentVNode("",!0)}const St=L(la,[["render",ba]]),ya=Object.freeze(Object.defineProperty({__proto__:null,default:St},Symbol.toStringTag,{value:"Module"})),xa={name:"VsListbar",mixins:[W],props:["source"],data(){return{restDimensions:[],maxValue:0,columns:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch(s){console.error(s)}},prepareData(){var t,r,n;this.columns=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{});const s=(r=this.sourceData)==null?void 0:r.map(o=>{var l;return o==null?void 0:o[(l=this.columns)==null?void 0:l[1]]});this.maxValue=Math.max(...s||[]),this.restDimensions=(n=this.columns)==null?void 0:n.filter((o,l)=>l!==0)},formattedValue(s){return H(s)},getWidth(s){return`${s/this.maxValue*100}%`}}},ka={class:"h-full pt-[20px] list-bar"},wa={class:"space-y-2 custom-scrollbar h-[calc(100%-40px)]"},_a={class:"relative w-full truncate"},$a={class:"relative z-[1] text-sm block py-1 px-2 w-full text-sm truncate text-gray-800"},Ea={class:"text-[14px] text-gray-500"};function Va(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",ka,[e.createElementVNode("ul",wa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.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",_a,[e.createElementVNode("span",$a,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,b)=>(e.openBlock(),e.createElementBlock("div",{key:b,class:"w-20 mr-2 text-end"},[e.createElementVNode("span",Ea,e.toDisplayString(l.formattedValue(a==null?void 0:a[h])),1)]))),128))])}),128))])])}const zt=L(xa,[["render",Va]]),Ba=Object.freeze(Object.defineProperty({__proto__:null,default:zt},Symbol.toStringTag,{value:"Module"})),Da={name:"VsPivotTable",mixins:[W],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 s=Array.from(new Set(this.sourceData.map(t=>t[this.dimensions[0]])));this.dimensions[0].includes("date")?this.xs=s.map(t=>pe(t)):this.xs=[...s],this.products=this.dimensions.filter((t,r)=>r!=0),this.values=this.products.map((t,r)=>({name:t,data:this.sourceData.filter(n=>parseFloat(n[t])).map(n=>H(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},Ca={class:"flex flex-col h-full p-5 space-y-4 rounded-xl custom-scrollbar"},Na={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"},Sa={class:"inline-block min-w-full align-middle"},za={class:"min-w-full divide-y divide-gray-200"},La={class:"space-x-2"},Ta={scope:"col",class:"xl:min-w-[120px] min-w-48"},Ia={class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"},Ma={class:"divide-y divide-gray-200 text-[12px]"},Ra={class:"py-3 size-px whitespace-nowrap"},Pa={class:"flex items-center gap-x-3"},Fa={class:"font-medium text-gray-800"},ja={class:"py-3 size-px whitespace-nowrap"},Wa={class:"text-gray-600"};function Oa(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Ca,[e.createElementVNode("div",Na,[e.createElementVNode("div",Sa,[e.createElementVNode("table",za,[e.createElementVNode("thead",null,[e.createElementVNode("tr",La,[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",Ta,[e.createElementVNode("div",Ia,e.toDisplayString(a),1)]))),256))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.values,a=>(e.openBlock(),e.createElementBlock("tbody",Ma,[e.createElementVNode("tr",null,[e.createElementVNode("td",Ra,[e.createElementVNode("div",Pa,[e.createElementVNode("span",Fa,e.toDisplayString(a.name),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,(i,c)=>(e.openBlock(),e.createElementBlock("td",ja,[e.createElementVNode("span",Wa,e.toDisplayString(a.data[c]),1)]))),256))])]))),256))])])])])}const Lt=L(Da,[["render",Oa]]),Aa=Object.freeze(Object.defineProperty({__proto__:null,default:Lt},Symbol.toStringTag,{value:"Module"})),qa={name:"VsNumber",mixins:[W],data(){return{number:""}},computed:{formattedNumber(){return Bo(this.number)},prefix(){var s,t;return(s=this.styleData)!=null&&s.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(s){console.error(s)}},async getNumber(){var s,t;try{this.number=((t=this.sourceData[0])==null?void 0:t[Object.keys((s=this.sourceData)==null?void 0:s[0])])||0}catch(r){console.error(r)}}}},va={class:"text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center"};function Ua(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",va,e.toDisplayString(l.prefix)+e.toDisplayString(l.formattedNumber),1)}const Ha=Object.freeze(Object.defineProperty({__proto__:null,default:L(qa,[["render",Ua]])},Symbol.toStringTag,{value:"Module"})),Ga={name:"VsText",mixins:[W],props:{widget:{type:String,required:!0},widgetData:{type:Object,required:!0}},data(){return{markedText:null,uniqueID:null}},async mounted(){var s,t;this.uniqueID=this.widget;try{await this.getData(),this.markedText=S(((s=this.widgetData)==null?void 0:s.text)||((t=this.widgetData)==null?void 0:t.source))}catch(r){console.error(r)}},methods:{onChangedData(){return null}}},Za=["id"],Qa=["innerHTML"];function Xa(s,t,r,n,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,Qa)):e.createCommentVNode("",!0)],8,Za)}const Ja=Object.freeze(Object.defineProperty({__proto__:null,default:L(Ga,[["render",Xa]])},Symbol.toStringTag,{value:"Module"})),Oe=typeof window<"u"?window.echarts:null,Ka={name:"VsFunnelBar",mixins:[W],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:s}=this.prepareData();s&&this.initChart(s)},methods:{buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
|
|
212
|
+
${s==null?void 0:s.replace("null","Не визначено")}: ${J(n)} (${o}%)
|
|
213
|
+
</div>`},prepareData(){var r,t,s,n,o;try{this.styleData=this.styleData||{};const l=Array.from(new Set((this.sourceData||[]).map(g=>g[this.dimensions[0]]))),a=Array.from(new Set((this.sourceData||[]).map(g=>g[this.dimensions[1]]))),i=parseInt((this.sourceData||[]).reduce((g,m)=>g+parseFloat(m==null?void 0:m.metric),0),10),c=l.map((g,m)=>{const k=(a[m]/i*100).toFixed(2);return{name:`${g} (${k}%)`,value:a[m]}}),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=Ne.getLegendOpions({borderRadius:10,height:"100%",padding:10,type:"scroll",itemWidth:14,itemHeight:14,formatter:g=>g==null?void 0:g.replace("null","Не визначено"),textStyle:{fontSize:"14px"},...((s=this.styleData)==null?void 0:s.legend)||{}}),this.styleData.label=Ne.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%",...ae(this.styleData),data:c}]}}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=We==null?void 0:We.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:l=>this.buildTooltipForDonut(l,[l.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:r,...ae(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(n){console.error("Error in initChart:",n)}}}},Wa=["id"];function qa(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,Wa)}const Dt=M(Aa,[["render",qa]]),va=Object.freeze(Object.defineProperty({__proto__:null,default:Dt},Symbol.toStringTag,{value:"Module"})),Ua={name:"VsLine",mixins:[v],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(a=>a[this.dimensions[0]])));let n;this.dimensions[0].includes("date")?n=s.map(a=>ye(a)):n=[...s];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:n}}catch(s){return console.error(s),null}}}},Ha=["id"];function Ga(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,ref:"chart",style:{height:"400px"}},null,8,Ha)}const St=M(Ua,[["render",Ga]]),Za=Object.freeze(Object.defineProperty({__proto__:null,default:St},Symbol.toStringTag,{value:"Module"})),Qa={name:"VsStat",mixins:[v],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<Ct.length-1?Ct[s]:La()})},formattedValue(r){const t=parseFloat(r);return J(t)}}},Xa={class:"flex flex-col w-full h-full pt-[16px] rounded-xl"},Ja={class:"flex flex-col justify-between w-full h-full"},Ka={class:"w-full h-full pb-6 space-y-4"},Ya={class:"flex w-full h-3 rounded-full gap-x-1 min-h-3 custom-x-scrollbar"},el=["onMouseover"],tl={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"},rl={class:"h-[calc(100%-40px)] w-full custom-scrollbar"},sl={class:"grid items-center justify-between grid-cols-2 py-2 gap-x-4"},nl={class:"flex items-center"},ol={class:"text-sm text-gray-800"},al={class:"text-end"},ll={class:"text-sm text-gray-500"};function il(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",Xa,[e.createElementVNode("div",Ja,[e.createElementVNode("div",Ka,[e.createElementVNode("div",Ya,[(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:b=>o.showTooltip=i,onMouseleave:t[0]||(t[0]=b=>o.showTooltip=-1)},[o.showTooltip>-1?(e.openBlock(),e.createElementBlock("div",tl,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,el)}),256))]),e.createElementVNode("ul",rl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,a=>{var i,c;return e.openBlock(),e.createElementBlock("li",sl,[e.createElementVNode("div",nl,[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",ol,e.toDisplayString((a==null?void 0:a[(i=o.columns)==null?void 0:i[0]])||"Не визначено"),1)]),e.createElementVNode("div",al,[e.createElementVNode("span",ll,e.toDisplayString(l.formattedValue(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])||"-"),1)])])}),256))])])])])}const zt=M(Qa,[["render",il]]),cl=Object.freeze(Object.defineProperty({__proto__:null,default:zt},Symbol.toStringTag,{value:"Module"})),dl={name:"VsProgressBar",mixins:[v],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 J(r)}}},pl={key:0,class:"flex flex-col h-full pt-[16px] rounded-xl"},hl={class:"h-full pt-0 pb-6 space-y-4"},ul={class:"h-full space-y-4 custom-scrollbar"},ml={class:"flex items-center justify-between mr-2 gap-x-2"},fl={class:"grid items-center w-full grid-cols-2 gap-x-2"},gl={class:"text-sm text-gray-800"},bl={class:"flex justify-end",role:"progressbar","aria-valuenow":"100","aria-valuemin":"0","aria-valuemax":"100"},yl={class:"min-w-[60px] text-end"},xl={class:"text-sm text-gray-500"};function kl(r,t,s,n,o,l){return o.columns?(e.openBlock(),e.createElementBlock("div",pl,[e.createElementVNode("div",hl,[e.createElementVNode("ul",ul,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("li",ml,[e.createElementVNode("div",fl,[e.createElementVNode("span",gl,e.toDisplayString(a[o.columns[0]]),1),e.createElementVNode("div",bl,[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",yl,[e.createElementVNode("span",xl,e.toDisplayString(l.formattedValue(a[o.columns[1]])),1)])]))),256))])])])):e.createCommentVNode("",!0)}const Lt=M(dl,[["render",kl]]),wl=Object.freeze(Object.defineProperty({__proto__:null,default:Lt},Symbol.toStringTag,{value:"Module"})),_l={name:"VsListbar",mixins:[v],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 l;return o==null?void 0:o[(l=this.columns)==null?void 0:l[1]]});this.maxValue=Math.max(...r||[]),this.restDimensions=(n=this.columns)==null?void 0:n.filter((o,l)=>l!==0)},formattedValue(r){return J(r)},getWidth(r){return`${r/this.maxValue*100}%`}}},$l={class:"h-full pt-[20px] list-bar"},El={class:"space-y-2 custom-scrollbar h-[calc(100%-40px)]"},Bl={class:"relative w-full truncate"},Vl={class:"relative z-[1] text-sm block py-1 px-2 w-full text-sm truncate text-gray-800"},Cl={class:"text-[14px] text-gray-500"};function Nl(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",$l,[e.createElementVNode("ul",El,[(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",Bl,[e.createElementVNode("span",Vl,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,b)=>(e.openBlock(),e.createElementBlock("div",{key:b,class:"w-20 mr-2 text-end"},[e.createElementVNode("span",Cl,e.toDisplayString(l.formattedValue(a==null?void 0:a[h])),1)]))),128))])}),128))])])}const Tt=M(_l,[["render",Nl]]),Dl=Object.freeze(Object.defineProperty({__proto__:null,default:Tt},Symbol.toStringTag,{value:"Module"})),Sl={name:"VsPivotTable",mixins:[v],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=>ye(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=>J(parseFloat(n[t])))}))}catch(r){console.error(r)}}}},zl={class:"flex flex-col h-full p-5 space-y-4 rounded-xl custom-scrollbar"},Ll={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"},Tl={class:"inline-block min-w-full align-middle"},Il={class:"min-w-full divide-y divide-gray-200"},Ml={class:"space-x-2"},Pl={scope:"col",class:"xl:min-w-[120px] min-w-48"},Fl={class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"},Rl={class:"divide-y divide-gray-200 text-[12px]"},jl={class:"py-3 size-px whitespace-nowrap"},Ol={class:"flex items-center gap-x-3"},Al={class:"font-medium text-gray-800"},Wl={class:"py-3 size-px whitespace-nowrap"},ql={class:"text-gray-600"};function vl(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",zl,[e.createElementVNode("div",Ll,[e.createElementVNode("div",Tl,[e.createElementVNode("table",Il,[e.createElementVNode("thead",null,[e.createElementVNode("tr",Ml,[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",Pl,[e.createElementVNode("div",Fl,e.toDisplayString(a),1)]))),256))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.values,a=>(e.openBlock(),e.createElementBlock("tbody",Rl,[e.createElementVNode("tr",null,[e.createElementVNode("td",jl,[e.createElementVNode("div",Ol,[e.createElementVNode("span",Al,e.toDisplayString(a.name),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,(i,c)=>(e.openBlock(),e.createElementBlock("td",Wl,[e.createElementVNode("span",ql,e.toDisplayString(a.data[c]),1)]))),256))])]))),256))])])])])}const It=M(Sl,[["render",vl]]),Ul=Object.freeze(Object.defineProperty({__proto__:null,default:It},Symbol.toStringTag,{value:"Module"})),Hl={name:"VsNumber",mixins:[v],data(){return{number:""}},computed:{formattedNumber(){return Da(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)}}}},Gl={class:"text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center"};function Zl(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",Gl,e.toDisplayString(l.prefix)+e.toDisplayString(l.formattedNumber),1)}const Ql=Object.freeze(Object.defineProperty({__proto__:null,default:M(Hl,[["render",Zl]])},Symbol.toStringTag,{value:"Module"})),Xl={name:"VsText",mixins:[v],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=T(((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}}},Jl=["id"],Kl=["innerHTML"];function Yl(r,t,s,n,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,Kl)):e.createCommentVNode("",!0)],8,Jl)}const ei=Object.freeze(Object.defineProperty({__proto__:null,default:M(Xl,[["render",Yl]])},Symbol.toStringTag,{value:"Module"})),qe=typeof window<"u"?window.echarts:null,ti={name:"VsFunnelBar",mixins:[v],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`
|
|
214
214
|
<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]">
|
|
215
|
-
${
|
|
216
|
-
</div>`},onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&(this==null||this.initChart(s,t,r))}}catch{}},prepareData(){try{const s=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]]))),r=s.map((o,l)=>({name:o,value:t[l]}));return{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"funnel",...Y(this.styleData),data:r,height:"80%",emphasis:{label:{show:!1}}}]}}catch(s){console.error(s)}},async initChart(s){var t,r;try{const n=this.$refs.chart,o=Oe==null?void 0:Oe.init(n);if(!o)return;const l={series:s,...Y(this.styleData),tooltip:{show:((r=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:r.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(n){console.error(n)}}}},Ya=["id"];function el(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{ref:"chart",id:o.uniqueID,class:"h-[90%] custom-scrollbar min-h-[200px]"},null,8,Ya)}const tl=Object.freeze(Object.defineProperty({__proto__:null,default:L(Ka,[["render",el]])},Symbol.toStringTag,{value:"Module"}));function sl(s){return[{type:"fill",paint:{"fill-color":s.color||"#ccc","fill-outline-color":s.color||"blue","fill-opacity":s.opacity||1}}]}function rl(s){return[{type:"line",paint:{"line-color":s.color||"#ccc","line-opacity":s.opacity||1}}]}function nl(s){return[{type:"circle",paint:{"circle-radius":s.radius||6,"circle-stroke-color":s.stroke||"#ccc","circle-stroke-width":s.width||1,"circle-color":s.color||"blue"}}]}function Tt(s){if(!s)return null;const t=s.type||"point";return t==="polygon"?sl(s):t==="line"?rl(s):nl(s)}const Ae={data(){return{layerList:[],activeLayer:""}},computed:{interactiveSources(){return this.layerList.filter(s=>s==null?void 0:s.interactive).map(s=>s.id)}},methods:{moveLayer(s,t=this.map){t.getStyle().layers.forEach(r=>{r.id.match(s)&&t.moveLayer(r.id)})},async setVisible(s,t=!0,r=this.map){if(!s)return;const n=(s==null?void 0:s.id)||s,o=this.layerList.find(a=>a.id===s)||s;if(!(o!=null&&o.id))throw new Error("MixinError: Layer has no id");const l=r.getStyle().layers.filter(a=>a.id.match(n));l.forEach(a=>{r.setLayoutProperty(a.id,"visibility",t?"visible":"none")}),!l.length&&t&&await this.addLayer(o)},async addLayer(s,t=this==null?void 0:this.map){var o,l;const r=this.layerList.find(a=>a.id===s)||s;!this.map.getStyle()||this.map.getStyle().layers.find(a=>a.id===r.id)||(this.layerList.find(a=>a.id===r.id)||this.layerList.push(r),(r.service==="vtile"||r.service==="vector"||(o=r.url)!=null&&o.includes(".vmt"))&&this.addVtileLayer(r,t),r.service==="geojson"&&this.addGeoJsonLayer(r,t),((l=r.url)!=null&&l.includes(".png")||["tms","raster"].includes(r.service))&&await this.addRasterLayer(r,t))},async addRasterLayer(s,t=this==null?void 0:this.map){var r,n;t.getSource(s.id)||(await t.addSource(s.id,{type:"raster",tiles:[s==null?void 0:s.url],tileSize:256,...s!=null&&s.scheme?{scheme:s==null?void 0:s.scheme}:{}}),await t.addLayer({id:s.id,type:"raster",source:s.id,minzoom:0,maxzoom:(s==null?void 0:s.maxzoom)||22},s.basemap?(n=(r=this.map.getStyle().layers)==null?void 0:r[0])==null?void 0:n.id:null))},async addVtileLayer(s,t=this==null?void 0:this.map){var l;const r=["props","pointZoom"].filter(a=>s[a]).map(a=>`&${a}=${s[a]}`),n={type:"vector",tiles:[`${(l=s==null?void 0:s.url)!=null&&l.startsWith("http")?"":window.location.origin}${s==null?void 0:s.url}${r}`],minzoom:s.minzoom||3,maxzoom:s.maxzoom||24};t.addSource(s.id,n),(Tt(s.style)||s.layers||[]).forEach((a,i)=>{const c={...a,id:`${s.id}-${i}`,source:s.id,"source-layer":a["source-layer"]||s.source||s.id,maxzoom:+a.maxzoom||24,minzoom:+a.minzoom||0};t.addLayer(c)})},async addGeoJsonLayer(s,t=this.map){var o;const r=s.data||((o=s==null?void 0:s.url)!=null&&o.startsWith("http")?"":window.location.origin)+s.url;t.addSource(s.id,{type:"geojson",data:r}),(Tt(s.style)||s.layers||[]).forEach(l=>{const a={...l,source:s.id,id:l.id||s.id,maxzoom:+l.maxzoom||24,minzoom:+l.minzoom||0,type:l.type||"circle"};t.addLayer(a)})},setLayerData(s,t){this.layerList=this.layerList.map(r=>r.id===s?{...r,...t}:r)},async removeLayer(s,t=this.map){t.getSource(s)&&(await t.getStyle().layers.forEach(async r=>{r.source===s&&await t.removeLayer(r.id)}),await t.removeSource(s))},async setFilter(s,t){var o;const r=this.layerList.find(l=>l.id===s),n=await((o=this.map)==null?void 0:o.getSource(s));if(n&&r.service==="vtile"){await n.setTiles([`${window.location.origin}${r.url}${r.url.includes("?")?"&":"?"}filter=${t}${r.props?`&props=${r.props}`:""}`]);return}n&&r.service},async changeBaseLayer(s){const t=s!=null&&s.id?s:this.layerList.find(n=>n.id===s),{id:r}=t;if(r&&r!==this.activeLayer){if(this.activeLayer&&this.map.setLayoutProperty(this.activeLayer,"visibility","none"),this.activeLayer=r,this.map.getLayer(r)){this.map.setLayoutProperty(r,"visibility","visible");return}await this.addRasterLayer(t)}},async refreshLayer(s,t=this.map){await t.getStyle().layers.forEach(r=>{r.source===s&&t.removeLayer(r.id)}),await t.removeSource(s),this.setVisible(s)}}},ol="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.js",al="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.css";let De=null;function ll(s){return new Promise((t,r)=>{if(document.querySelector(`script[src="${s}"]`)){t();return}const n=document.createElement("script");n.src=s,n.onload=()=>t(),n.onerror=()=>r(new Error(`Failed to load ${s}`)),document.head.appendChild(n)})}function il(s){return new Promise((t,r)=>{if(document.querySelector(`link[href="${s}"]`)){t();return}const n=document.createElement("link");n.rel="stylesheet",n.href=s,n.onload=()=>t(),n.onerror=()=>r(new Error(`Failed to load ${s}`)),document.head.appendChild(n)})}function It(){return typeof window>"u"?Promise.resolve(null):window.maplibregl?Promise.resolve(window.maplibregl):De||(De=il(al).then(()=>ll(ol)).then(()=>window.maplibregl),De)}const qe={__name:"legend",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ws),e.mergeProps(t.$attrs,{size:24}),null,16))}},ve={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"]},cl={components:{legendIcon:qe,closeIcon:Ne},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:ve}},computed:{borderRadius(){return this.cluster?"rounded-sm":"rounded-full"},sortedSizes(){return[...this.sizes].sort((s,t)=>s-t)},maxWidht(){var r;const s=((r=this.sizes)==null?void 0:r.length)-1;return this.calcSize(s)}},methods:{sizeClass(s){return this.resizeItem?`h-[${this.calcSize(s)}] w-[${this.calcSize(s)}] ${this.borderRadius}`:`h-[18px] w-[18px] ${this.borderRadius}`},calcSize(s){return`${10+s*2}px`},getOpacity(s){return(s+1)/this.sortedSizes.length}}},dl={class:"w-full absolute max-w-[200px] bg-white border rounded-lg bottom-[10px] right-[50px]"},pl={class:"flex items-center justify-between border-b border-[#0000001A] px-2"},hl={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"},ul={key:0,class:"flex flex-col w-full"},ml={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},fl={class:"flex flex-col gap-[6px]"},gl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"},bl={key:1,class:"flex flex-col w-full"},yl={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},xl={class:"flex flex-col gap-[6px]"},kl={class:"flex flex-row items-center justify-start"},wl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"};function _l(s,t,r,n,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-${r.mapId}`},[e.createElementVNode("div",dl,[e.createElementVNode("div",pl,[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",hl,[(c=r.colors)!=null&&c.length?(e.openBlock(),e.createElementBlock("div",ul,[r.colorTitle?(e.openBlock(),e.createElementBlock("h4",ml,e.toDisplayString(r.colorTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",fl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.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",gl,e.toDisplayString(p.text||p.val),1)]))),128))])])):e.createCommentVNode("",!0),(d=r.sizes)!=null&&d.length?(e.openBlock(),e.createElementBlock("div",bl,[s.sizeTitle?(e.openBlock(),e.createElementBlock("h4",yl,e.toDisplayString(s.sizeTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",xl,[l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(p,h)=>{var b,g,u,w,$;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",kl,[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:((g=(b=o.palette)==null?void 0:b[r.color])==null?void 0:g[h])||r.color})},null,6)],2),e.createElementVNode("p",wl,e.toDisplayString(h===((u=l.sortedSizes)==null?void 0:u.length)-1?">"+p:h==((w=l.sortedSizes)==null?void 0:w.length)-1?">"+l.sortedSizes[(($=l.sortedSizes)==null?void 0:$.length)-1]:p+"-"+l.sortedSizes[h+1]),1)])])}),256)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])])],8,["to"])):e.createCommentVNode("",!0)],64)}const $l=L(cl,[["render",_l]]),El={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(r=>Number(r).toFixed(5)).join(", ")}}},Vl={class:"map__settings"},Bl={ref:"attribution",class:"map__settings-attribution map__settings-item mt-[3px]"};function Dl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Vl,[e.createElementVNode("div",Bl,[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 Mt=L(El,[["render",Dl]]),Cl={mixins:[Ae],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(s){s&&s.on("load",this.handleMapLoad)}},created(){this.baseLayers.forEach(s=>{const t={...s,basemap:!0};this.layerList.push(t)})},methods:{handleMapLoad(){this.changeBaseLayer("graymap")},isLayerInFocus(s){return s.id===this.activeLayer}}},Nl={class:"vs-map-slot-layers"},Sl=["onClick"],zl=["src"];function Ll(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Nl,[(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=>s.changeBaseLayer(a.id)},[e.createElementVNode("img",{src:a.image,class:"vs-map-slot-layers__image"},null,8,zl)],10,Sl))),128))])}const Rt=L(Cl,[["render",Ll]]);function Pt(s,t,r){if(s!==null)for(var n,o,l,a,i,c,d,p=0,h=0,b,g=s.type,u=g==="FeatureCollection",w=g==="Feature",$=u?s.features.length:1,V=0;V<$;V++){d=u?s.features[V].geometry:w?s.geometry:s,b=d?d.type==="GeometryCollection":!1,i=b?d.geometries.length:1;for(var x=0;x<i;x++){var m=0,y=0;if(a=b?d.geometries[x]:d,a!==null){c=a.coordinates;var _=a.type;switch(p=0,_){case null:break;case"Point":if(t(c,h,V,m,y)===!1)return!1;h++,m++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,V,m,y)===!1)return!1;h++,_==="MultiPoint"&&m++}_==="LineString"&&m++;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,V,m,y)===!1)return!1;h++}_==="MultiLineString"&&m++,_==="Polygon"&&y++}_==="Polygon"&&m++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(y=0,o=0;o<c[n].length;o++){for(l=0;l<c[n][o].length-p;l++){if(t(c[n][o][l],h,V,m,y)===!1)return!1;h++}y++}m++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(Pt(a.geometries[n],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Tl(s,t={}){if(s.bbox!=null&&t.recompute!==!0)return s.bbox;const r=[1/0,1/0,-1/0,-1/0];return Pt(s,n=>{r[0]>n[0]&&(r[0]=n[0]),r[1]>n[1]&&(r[1]=n[1]),r[2]<n[0]&&(r[2]=n[0]),r[3]<n[1]&&(r[3]=n[1])}),r}const Il={props:["bbox","map"],components:{homeIcon:{__name:"home",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ys),e.mergeProps(t.$attrs,{size:24}),null,16))}}},methods:{setBounds(){const s={type:"Feature",geometry:this==null?void 0:this.bbox},t=Tl(s);this.map.fitBounds(t)}}},Ml={class:"z-100 flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]"};function Rl(s,t,r,n,o,l){const a=e.resolveComponent("homeIcon");return e.openBlock(),e.createElementBlock("div",Ml,[e.createVNode(a,{onClick:l.setBounds},null,8,["onClick"])])}const Ft=L(Il,[["render",Rl]]),Pl={components:{legendIcon:qe,menuIcon:{__name:"menu",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(bs),e.mergeProps(t.$attrs,{size:24}),null,16))}},closeIcon:Ne},props:["source","count","total","mapId"],data(){return{isOpenLegend:!1,palette:["#69D2E7","yellow","#FE4365"]}},methods:{calcSize(s){return s/this.maxValue*100*50/100}},computed:{maxValue(){var s,t,r,n,o,l;return((s=this.sizes)==null?void 0:s[0])>((r=this.sizes)==null?void 0:r[((t=this.sizes)==null?void 0:t.length)-1])?(n=this.sizes)==null?void 0:n[0]:(l=this.sizes)==null?void 0:l[((o=this.sizes)==null?void 0:o.length)-1]}}},Fl={class:"w-full h-[calc(100%-40px)] bg-white"},jl={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"},Wl={class:"relative min-w-full bg-white text-[12px]"},Ol={class:"divide-gray-200 dark:divide-neutral-700"},Al={class:"px-2 py-1"},ql={class:"px-2 py-1"};function vl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Fl,[e.createElementVNode("div",jl,[e.createElementVNode("table",Wl,[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",Ol,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.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",Al,e.toDisplayString(a.title||"—"),1),e.createElementVNode("td",ql,e.toDisplayString(a.metric),1)]))),128))])])])])}const jt=L(Pl,[["render",vl]]),Ul={mixins:[W,Ae,{components:{VsMapSetting:Mt,VsMapSlotLayers:Rt,VsMapLegend:$l,VsMapGoHome:Ft,VsList:jt},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 r,n;const s=await It();if(!s)return;const t={version:8,glyphs:"https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=await new s.Map({container:this.mapId,style:t,center:[31,48.5],zoom:((n=(r=this.data)==null?void 0:r.style)==null?void 0:n.zoom)||5,minZoom:3,maxZoom:20,attributionControl:!1}),this.map.addControl(new s.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(s){var t,r,n,o,l;return(r=(t=this.data)==null?void 0:t.colors)!=null&&r.find(a=>a.val===s)?(l=(o=(n=this.data)==null?void 0:n.colors)==null?void 0:o.find(a=>a.val===s))==null?void 0:l.text:s},moveMouseHadler(s){var t;try{const r=this.map.queryRenderedFeatures(s.point),n=((t=r[0])==null?void 0:t.properties)||{};if(!r.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">
|
|
215
|
+
${ye(s)}: ${J(n)} (${o}%)
|
|
216
|
+
</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,l)=>({name:o,value:t[l]}));return{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"funnel",...ae(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=qe==null?void 0:qe.init(n);if(!o)return;const l={series:r,...ae(this.styleData),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:[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(n){console.error(n)}}}},ri=["id"];function si(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",{ref:"chart",id:o.uniqueID,class:"h-[90%] custom-scrollbar min-h-[200px]"},null,8,ri)}const ni=Object.freeze(Object.defineProperty({__proto__:null,default:M(ti,[["render",si]])},Symbol.toStringTag,{value:"Module"}));function oi(r){return[{type:"fill",paint:{"fill-color":r.color||"#ccc","fill-outline-color":r.color||"blue","fill-opacity":r.opacity||1}}]}function ai(r){return[{type:"line",paint:{"line-color":r.color||"#ccc","line-opacity":r.opacity||1}}]}function li(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 Mt(r){if(!r)return null;const t=r.type||"point";return t==="polygon"?oi(r):t==="line"?ai(r):li(r)}const ve={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(a=>a.id===r)||r;if(!(o!=null&&o.id))throw new Error("MixinError: Layer has no id");const l=s.getStyle().layers.filter(a=>a.id.match(n));l.forEach(a=>{s.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 s=this.layerList.find(a=>a.id===r)||r;!this.map.getStyle()||this.map.getStyle().layers.find(a=>a.id===s.id)||(this.layerList.find(a=>a.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),((l=s.url)!=null&&l.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 l;const s=["props","pointZoom"].filter(a=>r[a]).map(a=>`&${a}=${r[a]}`),n={type:"vector",tiles:[`${(l=r==null?void 0:r.url)!=null&&l.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),(Mt(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 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}),(Mt(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(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(l=>l.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)}}},ii="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.js",ci="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.css";let De=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 pi(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 Pt(){return typeof window>"u"?Promise.resolve(null):window.maplibregl?Promise.resolve(window.maplibregl):De||(De=pi(ci).then(()=>di(ii)).then(()=>window.maplibregl),De)}const Ue={__name:"legend",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref($r),e.mergeProps(t.$attrs,{size:24}),null,16))}},He={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"]},hi={components:{legendIcon:Ue,closeIcon:ze},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:He}},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}}},ui={class:"w-full absolute max-w-[200px] bg-white border rounded-lg bottom-[10px] right-[50px]"},mi={class:"flex items-center justify-between border-b border-[#0000001A] px-2"},fi={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"},gi={key:0,class:"flex flex-col w-full"},bi={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},yi={class:"flex flex-col gap-[6px]"},xi={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"},ki={key:1,class:"flex flex-col w-full"},wi={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},_i={class:"flex flex-col gap-[6px]"},$i={class:"flex flex-row items-center justify-start"},Ei={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"};function Bi(r,t,s,n,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-${s.mapId}`},[e.createElementVNode("div",ui,[e.createElementVNode("div",mi,[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",fi,[(c=s.colors)!=null&&c.length?(e.openBlock(),e.createElementBlock("div",gi,[s.colorTitle?(e.openBlock(),e.createElementBlock("h4",bi,e.toDisplayString(s.colorTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",yi,[(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",xi,e.toDisplayString(p.text||p.val),1)]))),128))])])):e.createCommentVNode("",!0),(d=s.sizes)!=null&&d.length?(e.openBlock(),e.createElementBlock("div",ki,[r.sizeTitle?(e.openBlock(),e.createElementBlock("h4",wi,e.toDisplayString(r.sizeTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",_i,[l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(p,h)=>{var b,g,m,k,x;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",$i,[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:((g=(b=o.palette)==null?void 0:b[s.color])==null?void 0:g[h])||s.color})},null,6)],2),e.createElementVNode("p",Ei,e.toDisplayString(h===((m=l.sortedSizes)==null?void 0:m.length)-1?">"+p:h==((k=l.sortedSizes)==null?void 0:k.length)-1?">"+l.sortedSizes[((x=l.sortedSizes)==null?void 0:x.length)-1]:p+"-"+l.sortedSizes[h+1]),1)])])}),256)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])])],8,["to"])):e.createCommentVNode("",!0)],64)}const Vi=M(hi,[["render",Bi]]),Ci={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(", ")}}},Ni={class:"map__settings"},Di={ref:"attribution",class:"map__settings-attribution map__settings-item mt-[3px]"};function Si(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",Ni,[e.createElementVNode("div",Di,[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 Ft=M(Ci,[["render",Si]]),zi={mixins:[ve],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}}},Li={class:"vs-map-slot-layers"},Ti=["onClick"],Ii=["src"];function Mi(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",Li,[(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,Ii)],10,Ti))),128))])}const Rt=M(zi,[["render",Mi]]);function jt(r,t,s){if(r!==null)for(var n,o,l,a,i,c,d,p=0,h=0,b,g=r.type,m=g==="FeatureCollection",k=g==="Feature",x=m?r.features.length:1,$=0;$<x;$++){d=m?r.features[$].geometry:k?r.geometry:r,b=d?d.type==="GeometryCollection":!1,i=b?d.geometries.length:1;for(var f=0;f<i;f++){var u=0,w=0;if(a=b?d.geometries[f]:d,a!==null){c=a.coordinates;var V=a.type;switch(p=0,V){case null:break;case"Point":if(t(c,h,$,u,w)===!1)return!1;h++,u++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,$,u,w)===!1)return!1;h++,V==="MultiPoint"&&u++}V==="LineString"&&u++;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,$,u,w)===!1)return!1;h++}V==="MultiLineString"&&u++,V==="Polygon"&&w++}V==="Polygon"&&u++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(w=0,o=0;o<c[n].length;o++){for(l=0;l<c[n][o].length-p;l++){if(t(c[n][o][l],h,$,u,w)===!1)return!1;h++}w++}u++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(jt(a.geometries[n],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Pi(r,t={}){if(r.bbox!=null&&t.recompute!==!0)return r.bbox;const s=[1/0,1/0,-1/0,-1/0];return jt(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 Fi={props:["bbox","map"],components:{homeIcon:{__name:"home",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(kr),e.mergeProps(t.$attrs,{size:24}),null,16))}}},methods:{setBounds(){const r={type:"Feature",geometry:this==null?void 0:this.bbox},t=Pi(r);this.map.fitBounds(t)}}},Ri={class:"z-100 flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]"};function ji(r,t,s,n,o,l){const a=e.resolveComponent("homeIcon");return e.openBlock(),e.createElementBlock("div",Ri,[e.createVNode(a,{onClick:l.setBounds},null,8,["onClick"])])}const Ot=M(Fi,[["render",ji]]),Oi={components:{legendIcon:Ue,menuIcon:{__name:"menu",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(xr),e.mergeProps(t.$attrs,{size:24}),null,16))}},closeIcon:ze},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,l;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]:(l=this.sizes)==null?void 0:l[((o=this.sizes)==null?void 0:o.length)-1]}}},Ai={class:"w-full h-[calc(100%-40px)] bg-white"},Wi={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"},qi={class:"relative min-w-full bg-white text-[12px]"},vi={class:"divide-gray-200 dark:divide-neutral-700"},Ui={class:"px-2 py-1"},Hi={class:"px-2 py-1"};function Gi(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",Ai,[e.createElementVNode("div",Wi,[e.createElementVNode("table",qi,[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",vi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.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",Ui,e.toDisplayString(a.title||"—"),1),e.createElementVNode("td",Hi,e.toDisplayString(a.metric),1)]))),128))])])])])}const At=M(Oi,[["render",Gi]]),Zi={mixins:[v,ve,{components:{VsMapSetting:Ft,VsMapSlotLayers:Rt,VsMapLegend:Vi,VsMapGoHome:Ot,VsList:At},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 Pt();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,l;return(s=(t=this.data)==null?void 0:t.colors)!=null&&s.find(a=>a.val===r)?(l=(o=(n=this.data)==null?void 0:n.colors)==null?void 0:o.find(a=>a.val===r))==null?void 0:l.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">
|
|
217
217
|
${this.getPopoverTitle((n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name))||""}
|
|
218
218
|
</div>
|
|
219
219
|
|
|
@@ -222,7 +222,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
|
|
|
222
222
|
<span class="font-medium mr-[6px]">Значення</span>
|
|
223
223
|
</span>
|
|
224
224
|
<span>${(n==null?void 0:n.metric)||0}</span>
|
|
225
|
-
</div>`;const o=this.map.project(
|
|
225
|
+
</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(){const t=await(await fetch(`/api/bi-map?widget=${this.widget}&dashboard=${this.dashboard}`)).json();this.data=t,this.$emit("update:widgetData",t),setTimeout(()=>{var s;return(s=this.map)==null?void 0:s.resize()})},async loadHandler(){const r=["#69D2E7","yellow","#FE4365"],t=this.data.colors?["match",["get","x"]].concat(this.data.colors.reduce((l,a,i)=>l.concat(a.val,(a==null?void 0:a.color)||r[i]),[])).concat(["gray"]):"blue",s=[5,7,9,11,13],n=this.data.sizes?["case"]:5;this.data.sizes&&(this.data.sizes.reverse().forEach((l,a)=>{n.push([">",["get","metric"],l]),n.push(s[a])}),n.push(5));const o={type:"circle",color:t,width:2,radius:n,stroke:"#eee"};Object.assign(o,this.data.style||{}),this.addVtileLayer({id:"bi",url:`${window.top.location.origin}/api/bi-vtile/{z}/{x}/{y}.vmt?widget=${this.widget}&dashboard=${this.dashboard}&nocache=1`,style:o})}}},Qi={class:"w-full h-full"},Xi={class:"flex items-start justify-between mb-[6px] w-full"},Ji={class:"text-gray-800 font-[600]"},Ki=["id"],Yi=["id"],ec={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"};function tc(r,t,s,n,o,l){var p,h,b;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapLegend"),d=e.resolveComponent("VsMapGoHome");return e.openBlock(),e.createElementBlock("div",Qi,[e.createElementVNode("div",Xi,[e.createElementVNode("h5",Ji,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,Yi),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",ec,[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:(b=r.data)==null?void 0:b.bounds},null,8,["map","bbox"])])],8,Ki)])}const rc=Object.freeze(Object.defineProperty({__proto__:null,default:M(Zi,[["render",tc]])},Symbol.toStringTag,{value:"Module"})),sc={components:{legendIcon:Ue,closeIcon:ze},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:He}},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}}},nc={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"},oc={class:"w-[80px] mr-[10px]"},ac=["title"],lc={class:"text-[10px] mb-[2px] text-[#1F2937] font-normal leading-[1.2]"};function ic(r,t,s,n,o,l){var a;return(a=s.sizes)!=null&&a.length?(e.openBlock(),e.createElementBlock("div",nc,[e.createElementVNode("div",oc,[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,b,g,m,k,x;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",lc,e.toDisplayString(c===((b=l.sortedSizes)==null?void 0:b.length)-1?">"+parseInt(i):c==((g=l.sortedSizes)==null?void 0:g.length)-1?">"+parseInt(l.sortedSizes[((m=l.sortedSizes)==null?void 0:m.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:((x=(k=o.palette)==null?void 0:k[s.color])==null?void 0:x[c])||s.color})},null,6)],8,ac)}),256)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const cc=M(sc,[["render",ic]]),dc={__name:"icon-map",setup(r){return(t,s)=>(e.openBlock(),e.createBlock(e.unref(Er),e.mergeProps(t.$attrs,{size:24}),null,16))}},pc={mixins:[v,ve],components:{VsMapSetting:Ft,VsClusterLegend:cc,VsMapGoHome:Ot,VsList:At,VsMapSlotLayers:Rt,VsBar:Oe},data(){return{baseColor:"pink",kattotg:"",options:[{id:"map",text:"Карта",component:dc},{id:"table",text:"Таблиця",component:$t},{id:"chart",text:"Віджет",component:_t}],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(){const r=await A.get(`/bi-cluster?widget=${this.widget}&dashboard=${this.dashboard}`);this.data=r,this.$emit("update:widgetData",this.data),setTimeout(()=>{var t;return(t=this.map)==null?void 0:t.resize()})},async loadHandler(){var n,o,l,a;this.baseColor=((n=this.data.style)==null?void 0:n.color)||"blue";const r=["case"];(a=(l=(o=this.data)==null?void 0:o.sizes)==null?void 0:l.toReversed())==null||a.forEach((i,c)=>{var d,p;r.push([">",["get","metric"],i]),r.push((p=(d=He[this.baseColor])==null?void 0:d.toReversed())==null?void 0:p[c]),c++}),r.push("gray");const t={type:"polygon",color:r,opacity:.4};Object.assign(t,this.data.style||{}),this.map.getSource("bi")||this.addVtileLayer({id:"bi",url:`${window.location.origin}/api/bi-cluster-vtile/{z}/{x}/{y}.vmt?widget=${this.widget}&dashboard=${this.dashboard}&nocache=1`,style:t}),this.map.getLayer("highlighted")&&this.map.removeLayer("highlighted"),this.map.getSource("highlighted")&&this.map.removeSource("highlighted");const s=["case"];this.kattotg&&s.push(["==",["to-string",["get","name"]],String(this.kattotg)],"red"),s.push("transparent"),this.map.addLayer({id:"highlighted",type:"fill",source:"bi","source-layer":"bi",paint:{"fill-color":s,"fill-opacity":.6}})},async createMap(){var s,n;const r=await Pt();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">
|
|
226
226
|
${(n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name)||""}
|
|
227
227
|
</div>
|
|
228
228
|
|
|
@@ -231,4 +231,4 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
|
|
|
231
231
|
<span class="font-medium mr-[6px]">Значення</span>
|
|
232
232
|
</span>
|
|
233
233
|
<span>${(n==null?void 0:n.metric)||0}</span>
|
|
234
|
-
</div>`;const o=this.map.project(
|
|
234
|
+
</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)}}}},hc={class:"h-full"},uc={class:"flex items-start justify-between mb-[6px] w-full"},mc={class:"text-gray-800 font-[600]"},fc={class:"flex gap-2"},gc=["onClick"],bc=["id"],yc=["id"],xc={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"},kc={class:"h-[calc(250px)]"};function wc(r,t,s,n,o,l){var b,g,m,k,x,$,f,u,w,V;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",hc,[e.createElementVNode("div",uc,[e.createElementVNode("h3",mc,e.toDisplayString(r.title),1),e.createElementVNode("div",fc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,_=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["p-1 text-gray-700 border rounded",[o.activeTab===(_==null?void 0:_.id)?"ring-2 ring-blue-500":""]]),onClick:y=>o.activeTab=_==null?void 0:_.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(_==null?void 0:_.component),{height:"16",width:"16"}))],10,gc))),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,yc),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",xc,[e.createVNode(c,{map:o.map,bbox:(b=o.data)==null?void 0:b.bounds},null,8,["map","bbox"])]),e.createVNode(d,{mapId:o.mapId,colors:(g=o.data)==null?void 0:g.colors,sizes:(m=o.data)==null?void 0:m.sizes,color:o.baseColor,changeOpacityItem:"true",cluster:"true"},null,8,["mapId","colors","sizes","color"])],8,bc),[[e.vShow,o.activeTab=="map"]]),e.withDirectives(e.createVNode(p,{mapId:o.mapId,source:(k=o.data)==null?void 0:k.rows,total:((x=o.data)==null?void 0:x.total)||0,count:(($=o.data)==null?void 0:$.count)||0,onKattotg:t[0]||(t[0]=_=>o.kattotg=_)},null,8,["mapId","source","total","count"]),[[e.vShow,o.activeTab=="table"]]),e.withDirectives(e.createElementVNode("div",kc,[(u=(f=o.data)==null?void 0:f.rows)!=null&&u.length?(e.openBlock(),e.createBlock(h,{key:0,source:(V=(w=o.data)==null?void 0:w.rows)==null?void 0:V.map(_=>({title:_==null?void 0:_.title,metric:_==null?void 0:_.metric}))},null,8,["source"])):e.createCommentVNode("",!0)],512),[[e.vShow,o.activeTab=="chart"]])])}const _c=Object.freeze(Object.defineProperty({__proto__:null,default:M(pc,[["render",wc]])},Symbol.toStringTag,{value:"Module"})),$c={name:"VsTable",mixins:[v],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=>ye(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=>J(parseFloat(n[t])))}))}catch(r){console.error(r)}}}},Ec={class:"flex flex-col h-full pt-[16px] pb-[16px] space-y-4 rounded-xl"},Bc={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"},Vc={class:"inline-block min-w-full align-middle"},Cc={class:"relative min-w-full divide-y divide-gray-200 text-[12px]"},Nc={class:"sticky top-0 bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},Dc={class:"space-x-2"},Sc={scope:"col",class:"xl:min-w-[120px] min-w-48"},zc={class:"flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1"},Lc={class:"divide-y divide-gray-200"},Tc={class:"text-gray-600"};function Ic(r,t,s,n,o,l){return e.openBlock(),e.createElementBlock("div",Ec,[e.createElementVNode("div",Bc,[e.createElementVNode("div",Vc,[e.createElementVNode("table",Cc,[e.createElementVNode("thead",Nc,[e.createElementVNode("tr",Dc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.dimensions,a=>(e.openBlock(),e.createElementBlock("th",Sc,[e.createElementVNode("div",zc,e.toDisplayString(a),1)]))),256))])]),e.createElementVNode("tbody",Lc,[(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",Tc,e.toDisplayString(a==null?void 0:a[c]),1)]))),128))]))),128))])])])])])}const Mc=Object.freeze(Object.defineProperty({__proto__:null,default:M($c,[["render",Ic]])},Symbol.toStringTag,{value:"Module"}));I.AllDashboardsPage=Bt,I.EditorRootPage=Na,I.ROUTES_NAMES=q,I.Urls=tt,I.VsBar=Oe,I.VsDashboard=bs,I.VsDonut=Nt,I.VsEditorPage=Et,I.VsLine=St,I.VsListBar=Tt,I.VsPie=Dt,I.VsPivotTable=It,I.VsProgressBar=Lt,I.VsStat=zt,I.VsWidget=de,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
|