@opengis/bi 1.2.23 → 1.2.24

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.umd.cjs CHANGED
@@ -1,134 +1,159 @@
1
- (function(z,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(z=typeof globalThis<"u"?globalThis:z||self,e(z.bi={},z.Vue))})(this,function(z,e){"use strict";var Ci=Object.defineProperty;var Di=(z,e,X)=>e in z?Ci(z,e,{enumerable:!0,configurable:!0,writable:!0,value:X}):z[e]=X;var S=(z,e,X)=>Di(z,typeof e!="symbol"?e+"":e,X);/**
2
- * @license lucide-vue-next v0.546.0 - ISC
1
+ (function(I,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(I=typeof globalThis<"u"?globalThis:I||self,e(I.bi={},I.Vue))})(this,function(I,e){"use strict";var Di=Object.defineProperty;var Ni=(I,e,J)=>e in I?Di(I,e,{enumerable:!0,configurable:!0,writable:!0,value:J}):I[e]=J;var T=(I,e,J)=>Ni(I,typeof e!="symbol"?e+"":e,J);/**
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 X=s=>s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ts=s=>s.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),ss=s=>{const t=ts(s);return t.charAt(0).toUpperCase()+t.slice(1)},rs=(...s)=>s.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Ue=s=>s==="";/**
7
- * @license lucide-vue-next v0.546.0 - ISC
6
+ */const J=s=>{for(const t in s)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
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
- */var se={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"};/**
12
- * @license lucide-vue-next v0.546.0 - ISC
11
+ */const ve=s=>s==="";/**
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 ns=({name:s,iconNode:t,absoluteStrokeWidth:r,"absolute-stroke-width":n,strokeWidth:o,"stroke-width":l,size:a=se.width,color:i=se.stroke,...c},{slots:p})=>e.h("svg",{...se,...c,width:a,height:a,stroke:i,"stroke-width":Ue(r)||Ue(n)||r===!0||n===!0?Number(o||l||se["stroke-width"])*24/Number(a):o||l||se["stroke-width"],class:rs("lucide",c.class,...s?[`lucide-${X(ss(s))}-icon`,`lucide-${X(s)}`]:["lucide-icon"])},[...t.map(d=>e.h(...d)),...p.default?[p.default()]:[]]);/**
17
- * @license lucide-vue-next v0.546.0 - ISC
16
+ */const ss=(...s)=>s.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim();/**
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 M=(s,t)=>(r,{slots:n,attrs:o})=>e.h(ns,{...o,...r,iconNode:t,name:s},n);/**
22
- * @license lucide-vue-next v0.546.0 - ISC
21
+ */const Ue=s=>s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
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 os=M("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
27
- * @license lucide-vue-next v0.546.0 - ISC
26
+ */const rs=s=>s.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase());/**
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 as=M("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"}]]);/**
32
- * @license lucide-vue-next v0.546.0 - ISC
31
+ */const ns=s=>{const t=rs(s);return t.charAt(0).toUpperCase()+t.slice(1)};/**
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
- */const ls=M("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"}]]);/**
37
- * @license lucide-vue-next v0.546.0 - ISC
36
+ */var ee={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
+ * @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 is=M("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"}]]);/**
42
- * @license lucide-vue-next v0.546.0 - ISC
41
+ */const os=({name:s,iconNode:t,absoluteStrokeWidth:r,"absolute-stroke-width":n,strokeWidth:o,"stroke-width":l,size:a=ee.width,color:i=ee.stroke,...c},{slots:p})=>e.h("svg",{...ee,...c,width:a,height:a,stroke:i,"stroke-width":ve(r)||ve(n)||r===!0||n===!0?Number(o||l||ee["stroke-width"])*24/Number(a):o||l||ee["stroke-width"],class:ss("lucide",c.class,...s?[`lucide-${Ue(ns(s))}-icon`,`lucide-${Ue(s)}`]:["lucide-icon"]),...!p.default&&!J(c)&&{"aria-hidden":"true"}},[...t.map(d=>e.h(...d)),...p.default?[p.default()]:[]]);/**
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 cs=M("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"}]]);/**
47
- * @license lucide-vue-next v0.546.0 - ISC
46
+ */const F=(s,t)=>(r,{slots:n,attrs:o})=>e.h(os,{...o,...r,iconNode:t,name:s},n);/**
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 ds=M("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"}]]);/**
52
- * @license lucide-vue-next v0.546.0 - ISC
51
+ */const as=F("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
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 ps=M("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"}]]);/**
57
- * @license lucide-vue-next v0.546.0 - ISC
56
+ */const ls=F("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"}]]);/**
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 hs=M("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"}]]);/**
62
- * @license lucide-vue-next v0.546.0 - ISC
61
+ */const is=F("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"}]]);/**
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 ms=M("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"}]]);/**
67
- * @license lucide-vue-next v0.546.0 - ISC
66
+ */const cs=F("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"}]]);/**
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 us=M("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"}]]);/**
72
- * @license lucide-vue-next v0.546.0 - ISC
71
+ */const ds=F("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"}]]);/**
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 fs=M("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"}]]);/**
77
- * @license lucide-vue-next v0.546.0 - ISC
76
+ */const ps=F("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"}]]);/**
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 ve=M("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
82
- * @license lucide-vue-next v0.546.0 - ISC
81
+ */const hs=F("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"}]]);/**
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 gs=M("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"}]]);/**
87
- * @license lucide-vue-next v0.546.0 - ISC
86
+ */const us=F("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"}]]);/**
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 bs=M("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/**
92
- * @license lucide-vue-next v0.546.0 - ISC
91
+ */const ms=F("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"}]]);/**
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 ys=M("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"}]]);/**
97
- * @license lucide-vue-next v0.546.0 - ISC
96
+ */const fs=F("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"}]]);/**
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 xs=M("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"}]]);/**
102
- * @license lucide-vue-next v0.546.0 - ISC
101
+ */const gs=F("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"}]]);/**
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 He=M("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Be={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},ks=["onClick"],ws={class:"flex items-center justify-between w-full"},_s={key:0},$s=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 f=r.options;return typeof f=="string"?f.split(",").map((m,x)=>({id:x,text:m.trim()})):Array.isArray(f)?f:[]}),c=e.computed(()=>{const f=i.value.find(m=>(m.id??m)===l.value);return f?f.text??String(f):r.title??""}),p=f=>{const m=(f==null?void 0:f.id)??f;l.value=m,o.value=!1,n("selected",m),document.removeEventListener("click",d)},d=f=>{a.value&&!a.value.contains(f.target)&&(o.value=!1,document.removeEventListener("click",d))},h=()=>{o.value=!o.value,o.value?setTimeout(()=>{document.addEventListener("click",d)},200):document.removeEventListener("click",d)},g=f=>(Be==null?void 0:Be[f])??f;return e.onUnmounted(()=>{document.removeEventListener("click",d)}),(f,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(g(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,x=>(e.openBlock(),e.createElementBlock("div",{key:x.id||x,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:k=>p(x)},[e.createElementVNode("div",ws,[e.createElementVNode("span",null,e.toDisplayString(g(x.text||x)),1),l.value===(x.id||x)?(e.openBlock(),e.createElementBlock("span",_s,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,ks))),128))],512)):e.createCommentVNode("",!0)],64))}}),Vs={class:"flex items-center space-x-2"},Es=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",Vs,[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)]))}}),D=(s,t)=>{const r=s.__vccOpts||s;for(const[n,o]of t)r[n]=o;return r},Bs={},Cs={class:"flex items-center justify-center h-full"};function Ds(s,t){return e.openBlock(),e.createElementBlock("div",Cs,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 Ns=D(Bs,[["render",Ds]]),Ge={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Co)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Oa)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>va)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ka)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Mo)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>zo)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ao)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ea)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Pa)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ha)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Qa)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Gl)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>mi)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Bi))};let Ze="/api";function ge(s){Ze=s||"/api"}function Ss(s,t){const r=Ze.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 be(s,t={}){const{params:r,...n}=t,o=Ss(s,r),l=await fetch(o,{...n,headers:{"Content-Type":"application/json",...n.headers}});if(!l.ok){const i=new Error(l.statusText);throw i.status=l.status,i}const a=await l.text();if(a)try{return JSON.parse(a)}catch{return a}}const T={get(s,t){return be(s,{...t,method:"GET"})},post(s,t){return be(s,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(s,t){return be(s,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(s){return be(s,{method:"DELETE"})}},zs={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"},Ls={class:"flex items-center justify-between w-full gap-2"},Ts={class:"flex items-center gap-2 min-w-0"},Is={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},Ms={class:"flex flex-col justify-end"},Ps={key:0,class:"flex items-center justify-end w-full gap-2"},Rs={class:"w-full h-full"},re=e.defineComponent({__name:"vs-widget",props:{dashboard:{},prefix:{default:""},widget:{},filterURl:{},dashboardWidgets:{},selectedWidget:{}},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([]),p=e.computed(()=>{var y,b;const u=(y=r.dashboardWidgets)==null?void 0:y.find(_=>_.name===r.widget);return((b=u==null?void 0:u.data)==null?void 0:b.title)??(u==null?void 0:u.title)??""}),d=e.computed(()=>{var y;const u=(y=r.dashboardWidgets)==null?void 0:y.find(b=>b.name===r.widget);return(u==null?void 0:u.type)??"text"}),h=e.computed(()=>{var y;const u=(y=i.value)==null?void 0:y.controls;return!u||typeof u=="boolean"?[]:Object.keys(u).map(b=>({name:b,options:u[b]}))}),g=e.computed(()=>{const u=d.value?`bi-${d.value}`:"";return u&&u in Ge?Ge[u]:null});function f(u,y){var b,_;(_=(b=l.value)==null?void 0:b.changeStyle)==null||_.call(b,u,y)}function m(u,y){const b=c.value.find(_=>_.name===y);b?b.option=u:c.value.push({name:y,option:u}),x()}function x(){var y,b;let u=`/bi-data?dashboard=${r.dashboard}&widget=${r.widget}`;c.value.forEach(_=>{u+=`&${_.name}=${_.option}`}),(b=(y=l.value)==null?void 0:y.getDataFromURL)==null||b.call(y,u)}function k(){const u=a.value;if(u!=null&&u.getDataURL){const y=u.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),b=document.createElement("a");b.href=y,b.download="chart.png",document.body.appendChild(b),b.click(),document.body.removeChild(b)}}return e.onMounted(()=>{r.prefix&&ge(r.prefix)}),e.watch(()=>r.filterURl,u=>{var y,b;u&&((b=(y=l.value)==null?void 0:y.setFilter)==null||b.call(y,u))}),e.watch(()=>r.selectedWidget,(u,y)=>{var b;u!==y&&u===((b=i.value)==null?void 0:b.id)&&n("update:current-widget-data",i.value)}),e.watch(i,(u,y)=>{if((u==null?void 0:u.id)===(y==null?void 0:y.id))return;const b=typeof window<"u"?new URLSearchParams(window.top.location.search).get("widget"):null;b&&b===(u==null?void 0:u.id)&&n("update:current-widget-data",u)},{deep:!0}),(u,y)=>{var b,_,$,w,L,P,F,q,U;return e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:o,class:e.normalizeClass(["box-border relative h-full p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto",[(_=(b=i.value)==null?void 0:b.style)!=null&&_.height?`max-h-[${(w=($=i.value)==null?void 0:$.style)==null?void 0:w.height}px] h-[${(P=(L=i.value)==null?void 0:L.style)==null?void 0:P.height}px]`:"max-h-[460px]"]])},[["text","cluster","map"].includes(d.value)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",zs,[e.createElementVNode("div",Ls,[e.createElementVNode("div",Ts,[e.createElementVNode("span",Is,e.toDisplayString(p.value),1)]),e.createElementVNode("div",Ms,[(F=h.value)!=null&&F.length?(e.openBlock(),e.createElementBlock("span",Ps,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((q=h.value)==null?void 0:q.filter(V=>(V==null?void 0:V.options)&&(V==null?void 0:V.name)!=="export"),V=>{var v,Z;return e.openBlock(),e.createElementBlock("div",{key:V==null?void 0:V.name},[Array.isArray(V==null?void 0:V.options)?(e.openBlock(),e.createBlock($s,{key:0,title:V==null?void 0:V.name,options:V==null?void 0:V.options,value:((Z=(v=i.value)==null?void 0:v.data)==null?void 0:Z[V==null?void 0:V.name])??null,onSelected:G=>m(G,V==null?void 0:V.name)},null,8,["title","options","value","onSelected"])):typeof V.options=="boolean"?(e.openBlock(),e.createBlock(Es,{key:1,"left-label":V==null?void 0:V.name,"model-value":!!(V!=null&&V.options),"onUpdate:isEnabled":G=>f(V==null?void 0:V.name,G)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(U=h.value)!=null&&U.some(V=>(V==null?void 0:V.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:k},[e.createVNode(e.unref(as),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])),e.createElementVNode("div",Rs,[g.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(g.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":a.value,"onUpdate:currentWidget":y[0]||(y[0]=V=>a.value=V),"widget-data":i.value,"onUpdate:widgetData":y[1]||(y[1]=V=>i.value=V),dashboard:u.dashboard,title:p.value,widget:u.widget},null,40,["current-widget","widget-data","dashboard","title","widget"])):(e.openBlock(),e.createBlock(Ns,{key:1,class:"w-full h-full"}))])],2)}}}),Fs={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},As={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},Os={class:"max-w-sm mx-auto mt-6"},js={class:"font-medium text-gray-800 dark:text-neutral-200"},Ws={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},ye=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",Fs,[e.createElementVNode("div",null,[e.createElementVNode("div",As,[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",Os,[e.createElementVNode("p",js,e.toDisplayString(t.title),1),e.createElementVNode("p",Ws,e.toDisplayString(t.text),1)])])])]))}}),qs={components:{filterIcon:{__name:"filter",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(is),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},Us={class:"flex items-center"},vs={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 Hs(s,t,r,n,o,l){const a=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",Us,[r.filterScheme?(e.openBlock(),e.createElementBlock("button",vs,[e.createVNode(a),t[0]||(t[0]=e.createTextVNode(" Фільтри "))])):e.createCommentVNode("",!0)])}const Gs={components:{VsFilterHeader:D(qs,[["render",Hs]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},Zs={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},Qs={class:"grow"},Xs={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},Js={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"},Ks={key:0,class:"flex items-center gap-3"};function Ys(s,t,r,n,o,l){var i,c,p;const a=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",Zs,[e.createElementVNode("div",Qs,[e.createElementVNode("h1",Xs,e.toDisplayString((i=r.dashboardData)==null?void 0:i.title),1),(c=r.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",Js,e.toDisplayString((p=r.dashboardData)==null?void 0:p.description),1)):e.createCommentVNode("",!0)]),r.filters?(e.openBlock(),e.createElementBlock("div",Ks,[e.createVNode(a,{filterScheme:r.filters,"onFilters:changed":t[0]||(t[0]=d=>s.$emit("filters:changed",d))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const er=D(Gs,[["render",Ys]]);var Qe={},Xe;(function(s){s.pop="pop",s.push="push"})(Xe||(Xe={}));var Je;(function(s){s.back="back",s.forward="forward",s.unknown=""})(Je||(Je={}));var Ke;(function(s){s[s.aborted=4]="aborted",s[s.cancelled=8]="cancelled",s[s.duplicated=16]="duplicated"})(Ke||(Ke={}));const tr=Symbol(Qe.NODE_ENV!=="production"?"router":""),sr=Symbol(Qe.NODE_ENV!=="production"?"route location":"");function Ce(){return e.inject(tr)}function rr(s){return e.inject(sr)}const nr={key:0,class:"text-gray-400 shrink-0"},or=["onClick"],ar=["onClick"],lr={key:4,class:"text-gray-900 font-medium truncate"},Ye={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(s){const t=s,r=Ce(),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,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:p},[p>0?(e.openBlock(),e.createElementBlock("span",nr,[e.createVNode(e.unref(os),{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:d=>c.onClick()},e.toDisplayString(c.label),9,or)):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:d=>o(c.to)},e.toDisplayString(c.label),9,ar)):(e.openBlock(),e.createElementBlock("span",lr,e.toDisplayString(c.label),1))],64))),128))],2)}}},ir={components:{VsWidget:re,VsNewNodata:ye,VsHeader:er,VsBreadcrumbs:Ye},props:["id","prefix"],data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},async mounted(){ge(this.prefix||"/api"),await this.fetchData()},methods:{async fetchData(){if(this.id)try{const s=await T.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)}}},cr={class:"w-full pb-8 overflow-y-auto mx-auto"},dr={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function pr(s,t,r,n,o,l){var c;const a=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",cr,[e.createElementVNode("div",dr,[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)||[],(p,d)=>{var h;return e.openBlock(),e.createElementBlock("div",{key:d,class:e.normalizeClass([`col-span-${p.col||12}`,"flex flex-col gap-[10px]"])},[(h=p.widgets)!=null&&h.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(p.widgets,g=>(e.openBlock(),e.createBlock(i,{key:g,dashboard:r.id,widget:g,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))),128)):(e.openBlock(),e.createBlock(i,{key:1,class:"flex flex-col",dashboard:r.id,widget:p.widget,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))],2)}),128))])])}const hr=D(ir,[["render",pr]]),mr={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},ur={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},fr={class:"font-medium text-gray-800 dark:text-white"},gr={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},br={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},ne=D({__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",mr,[e.createElementVNode("div",{class:"absolute inset-0 bg-black/50","aria-hidden":"true",onMousedown:c[0]||(c[0]=p=>s.closeClickBack&&p.target===p.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",ur,[e.createElementVNode("h3",fr,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",gr,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",br,[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"]]),yr={__name:"icon-plus",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ve),e.mergeProps(t.$attrs,{size:24}),null,16))}},xr={class:"mb-4 overflow-auto scrollbar max-h-96"},kr={__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 m;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(m=e.getCurrentInstance().proxy)==null?void 0:m.$notify,l=r,a=s,i=e.ref(!1),c=e.ref({}),p=e.ref();function d(){i.value=!0}function h(){i.value=!1}t({open:d,close:h});const g=async()=>{var x;try{const k=(x=p.value)==null?void 0:x.doValidation;typeof k=="function"&&await k(),await T.post(`/bi-dashboard/${a.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await l("update-data"),c.value={},i.value=!1}catch(k){const u=(k==null?void 0:k.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:u})}},f=e.computed(()=>{var x,k,u,y;return{title:{type:"text",label:"Widget title",placeholder:"Widget title",validators:["required"]},x:{type:"select",label:"X Axis",view:"buttons",style:{size:"xs"},validators:["required"],options:(k=(x=a.columns)==null?void 0:x.filter(b=>(b==null?void 0:b.type)=="text"||(b==null?void 0:b.type)==="date"||(b==null?void 0:b.type)==="timestamp without time zone"||(b==null?void 0:b.type)==="boolean"||(b==null?void 0:b.type)==="integer"))==null?void 0:k.map(({name:b,type:_})=>({id:b,text:b,type:_}))},metric:{type:"select",label:"Y Axis",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(y=(u=a.columns)==null?void 0:u.filter(b=>(b==null?void 0:b.type)==="numeric"||(b==null?void 0:b.type)==="double precision"))==null?void 0:y.map(({name:b,type:_})=>({id:b,text:b,type:_}))]},col:{type:"select",label:"Columns count",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}]},type:{type:"select",view:"buttons",label:"Type",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:"Table",placeholder:"Table"},query:{type:"Text",ua:"Query",placeholder:"Query"},cls:{type:"Text",ua:"Cls",placeholder:"Cls"}}});return(x,k)=>{const u=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[s.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(u,{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:d},[e.createVNode(yr,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[k[1]||(k[1]=e.createTextVNode(" Створити віджет "))]),_: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:g,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",xr,[e.createVNode(e.unref(n),{ref_key:"form",ref:p,schema:f.value,values:c.value,"onUpdate:values":k[0]||(k[0]=y=>c.value=y)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},et={__name:"delete",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(xs),e.mergeProps(t.$attrs,{size:24}),null,16))}},De={__name:"close",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(He),e.mergeProps(t.$attrs,{size:24}),null,16))}},tt={__name:"edit",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(fs),e.mergeProps(t.$attrs,{size:24}),null,16))}},wr={class:"space-y-4"},_r={__name:"vs-editor-form-style",props:{widgetName:{type:String},data:{type:Object,default:()=>{}}},setup(s,{expose:t}){var m,x,k,u,y,b;const r=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:n}=e.getCurrentInstance().proxy,o=s,l=e.ref(null),a={show:{label:"Label",type:"switcher",title:"Show label"},rotate:{type:"number",label:"Rotate angel",conditions:["show","==",!0]},align:{type:"select",view:"buttons",label:"Align",conditions:["show","==",!0],options:[{id:"center",text:"Center"},{id:"left",text:"Left"},{id:"right",text:"Right"}]},position:{type:"select",label:"Position",conditions:["show","==",!0],options:[{id:"top",text:"Top"},{id:"right",text:"Right"},{id:"left",text:"Left"},{id:"bottom",text:"Bottom"}]}},i={show:{label:"Legend",type:"switcher",title:"Show legend"}},c={show:{label:"Tooltip ",type:"switcher",title:"Show tooltip"}},p=e.ref({...((x=(m=o.data)==null?void 0:m.style)==null?void 0:x.label)||{}}),d=e.ref({...((u=(k=o.data)==null?void 0:k.style)==null?void 0:u.legend)||{}}),h=e.ref({...((b=(y=o.data)==null?void 0:y.style)==null?void 0:b.tooltip)||{}}),g=()=>{const _=new CustomEvent(`update-style-${o.widgetName}`);_.chartId=o.widgetName,_.options={options:{legend:d.value,tooltip:h.value,label:p.value},seriesOptions:p.value},window.dispatchEvent(_)};e.watch(p,g,{deep:!0}),e.watch(d,g,{deep:!0}),e.watch(h,g,{deep:!0});const f=async()=>{try{await T.put(`/bi-dashboard/${l.value}/${o.widgetName}`,{style:{legend:d.value,tooltip:h.value,label:p.value}});const _=new CustomEvent(`update-style-${o.widgetName}`);_.chartId=o.widgetName,_.options={options:{legend:d.value,tooltip:h.value,label:p.value},seriesOptions:p.value},window.dispatchEvent(_),n({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{n({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const _=new URLSearchParams(window.top.location.search);l.value=_.get("dashboard")}),t({requestUpdateWidget:f}),(_,$)=>(e.openBlock(),e.createElementBlock("div",wr,[e.createVNode(e.unref(r),{schema:a,values:p.value,"onUpdate:values":$[0]||($[0]=w=>p.value=w),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(r),{schema:i,values:d.value,"onUpdate:values":$[1]||($[1]=w=>d.value=w),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(r),{schema:c,values:h.value,"onUpdate:values":$[2]||($[2]=w=>h.value=w),class:"p-0"},null,8,["values"])]))}};function Ne(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let J=Ne();function st(s){J=s}const rt=/[&<>"']/,$r=new RegExp(rt.source,"g"),nt=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Vr=new RegExp(nt.source,"g"),Er={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ot=s=>Er[s];function A(s,t){if(t){if(rt.test(s))return s.replace($r,ot)}else if(nt.test(s))return s.replace(Vr,ot);return s}const Br=/(^|[^\[])\^/g;function N(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(Br,"$1"),r=r.replace(o,a),n},getRegex:()=>new RegExp(r,t)};return n}function at(s){try{s=encodeURI(s).replace(/%25/g,"%")}catch{return null}return s}const oe={exec:()=>null};function lt(s,t){const r=s.replace(/\|/g,(l,a,i)=>{let c=!1,p=a;for(;--p>=0&&i[p]==="\\";)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 Cr(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 it(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 Dr(s,t){const r=s.match(/^(\s+)(?:```)/);if(r===null)return t;const n=r[1];return t.split(`
106
+ */const He=F("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
107
+ * @license lucide-vue-next v0.577.0 - ISC
108
+ *
109
+ * This source code is licensed under the ISC license.
110
+ * See the LICENSE file in the root directory of this source tree.
111
+ */const bs=F("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"}]]);/**
112
+ * @license lucide-vue-next v0.577.0 - ISC
113
+ *
114
+ * This source code is licensed under the ISC license.
115
+ * See the LICENSE file in the root directory of this source tree.
116
+ */const ys=F("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/**
117
+ * @license lucide-vue-next v0.577.0 - ISC
118
+ *
119
+ * This source code is licensed under the ISC license.
120
+ * See the LICENSE file in the root directory of this source tree.
121
+ */const xs=F("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"}]]);/**
122
+ * @license lucide-vue-next v0.577.0 - ISC
123
+ *
124
+ * This source code is licensed under the ISC license.
125
+ * See the LICENSE file in the root directory of this source tree.
126
+ */const ks=F("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"}]]);/**
127
+ * @license lucide-vue-next v0.577.0 - ISC
128
+ *
129
+ * This source code is licensed under the ISC license.
130
+ * See the LICENSE file in the root directory of this source tree.
131
+ */const Ge=F("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Be={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},ws=["onClick"],_s={class:"flex items-center justify-between w-full"},$s={key:0},Vs=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 u=r.options;return typeof u=="string"?u.split(",").map((m,b)=>({id:b,text:m.trim()})):Array.isArray(u)?u:[]}),c=e.computed(()=>{const u=i.value.find(m=>(m.id??m)===l.value);return u?u.text??String(u):r.title??""}),p=u=>{const m=(u==null?void 0:u.id)??u;l.value=m,o.value=!1,n("selected",m),document.removeEventListener("click",d)},d=u=>{a.value&&!a.value.contains(u.target)&&(o.value=!1,document.removeEventListener("click",d))},h=()=>{o.value=!o.value,o.value?setTimeout(()=>{document.addEventListener("click",d)},200):document.removeEventListener("click",d)},x=u=>(Be==null?void 0:Be[u])??u;return e.onUnmounted(()=>{document.removeEventListener("click",d)}),(u,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(x(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,b=>(e.openBlock(),e.createElementBlock("div",{key:b.id||b,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:y=>p(b)},[e.createElementVNode("div",_s,[e.createElementVNode("span",null,e.toDisplayString(x(b.text||b)),1),l.value===(b.id||b)?(e.openBlock(),e.createElementBlock("span",$s,[...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,ws))),128))],512)):e.createCommentVNode("",!0)],64))}}),Es={class:"flex items-center space-x-2"},Bs=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",Es,[s.leftLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["transition-colors",{"text-blue-500":!n.value}])},e.toDisplayString(s.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]]),s.rightLabel?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["transition-colors",{"text-blue-500":n.value}])},e.toDisplayString(s.rightLabel),3)):e.createCommentVNode("",!0)]))}}),S=(s,t)=>{const r=s.__vccOpts||s;for(const[n,o]of t)r[n]=o;return r},Cs={},Ds={class:"flex items-center justify-center h-full"};function Ns(s,t){return e.openBlock(),e.createElementBlock("div",Ds,[...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 Ss=S(Cs,[["render",Ns]]),Ze={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Do)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ja)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ha)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>wa)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Po)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Lo)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ao)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ta)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ra)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ua)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Xa)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Zl)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>mi)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ci))};let Qe="/api";function ge(s){Qe=s||"/api"}function zs(s,t){const r=Qe.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 be(s,t={}){const{params:r,...n}=t,o=zs(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 P={get(s,t){return be(s,{...t,method:"GET"})},post(s,t){return be(s,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(s,t){return be(s,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(s){return be(s,{method:"DELETE"})}},Ls={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"},Ts={class:"flex items-center justify-between w-full gap-2"},Is={class:"flex items-center gap-2 min-w-0"},Ms={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},Ps={class:"flex flex-col justify-end"},Rs={key:0,class:"flex items-center justify-end w-full gap-2"},Fs={class:"w-full h-full"},te=e.defineComponent({__name:"vs-widget",props:{dashboard:{},prefix:{default:""},widget:{},height:{},filterURl:{},dashboardWidgets:{},selectedWidget:{}},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([]),p=e.computed(()=>{var f,w;const g=(f=r.dashboardWidgets)==null?void 0:f.find(V=>V.name===r.widget);return((w=g==null?void 0:g.data)==null?void 0:w.title)??(g==null?void 0:g.title)??""}),d=e.computed(()=>{var f;const g=(f=r.dashboardWidgets)==null?void 0:f.find(w=>w.name===r.widget);return(g==null?void 0:g.type)??"text"}),h=e.computed(()=>{var g,f;return r.height||((f=(g=i.value)==null?void 0:g.style)==null?void 0:f.height)||480}),x=e.computed(()=>{var f;const g=(f=i.value)==null?void 0:f.controls;return!g||typeof g=="boolean"?[]:Object.keys(g).map(w=>({name:w,options:g[w]}))}),u=e.computed(()=>{const g=d.value?`bi-${d.value}`:"";return g&&g in Ze?Ze[g]:null});function m(g,f){var w,V;(V=(w=l.value)==null?void 0:w.changeStyle)==null||V.call(w,g,f)}function b(g,f){const w=c.value.find(V=>V.name===f);w?w.option=g:c.value.push({name:f,option:g}),y()}function y(){var f,w;let g=`/bi-data?dashboard=${r.dashboard}&widget=${r.widget}`;c.value.forEach(V=>{g+=`&${V.name}=${V.option}`}),(w=(f=l.value)==null?void 0:f.getDataFromURL)==null||w.call(f,g)}function k(){const g=a.value;if(g!=null&&g.getDataURL){const f=g.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),w=document.createElement("a");w.href=f,w.download="chart.png",document.body.appendChild(w),w.click(),document.body.removeChild(w)}}return e.onMounted(()=>{r.prefix&&ge(r.prefix)}),e.watch(()=>r.filterURl,g=>{var f,w;g&&((w=(f=l.value)==null?void 0:f.setFilter)==null||w.call(f,g))}),e.watch(()=>r.selectedWidget,(g,f)=>{var w;g!==f&&g===((w=i.value)==null?void 0:w.id)&&n("update:current-widget-data",i.value)}),e.watch(i,(g,f)=>{if((g==null?void 0:g.id)===(f==null?void 0:f.id))return;const w=typeof window<"u"?new URLSearchParams(window.top.location.search).get("widget"):null;w&&w===(g==null?void 0:g.id)&&n("update:current-widget-data",g)},{deep:!0}),(g,f)=>{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(d.value)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ls,[e.createElementVNode("div",Ts,[e.createElementVNode("div",Is,[e.createElementVNode("span",Ms,e.toDisplayString(p.value),1)]),e.createElementVNode("div",Ps,[(w=x.value)!=null&&w.length?(e.openBlock(),e.createElementBlock("span",Rs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((V=x.value)==null?void 0:V.filter($=>($==null?void 0:$.options)&&($==null?void 0:$.name)!=="export"),$=>{var E,C;return e.openBlock(),e.createElementBlock("div",{key:$==null?void 0:$.name},[Array.isArray($==null?void 0:$.options)?(e.openBlock(),e.createBlock(Vs,{key:0,title:$==null?void 0:$.name,options:$==null?void 0:$.options,value:((C=(E=i.value)==null?void 0:E.data)==null?void 0:C[$==null?void 0:$.name])??null,onSelected:L=>b(L,$==null?void 0:$.name)},null,8,["title","options","value","onSelected"])):typeof $.options=="boolean"?(e.openBlock(),e.createBlock(Bs,{key:1,"left-label":$==null?void 0:$.name,"model-value":!!($!=null&&$.options),"onUpdate:isEnabled":L=>m($==null?void 0:$.name,L)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(_=x.value)!=null&&_.some($=>($==null?void 0:$.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:k},[e.createVNode(e.unref(ls),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])),e.createElementVNode("div",Fs,[u.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":a.value,"onUpdate:currentWidget":f[0]||(f[0]=$=>a.value=$),"widget-data":i.value,"onUpdate:widgetData":f[1]||(f[1]=$=>i.value=$),dashboard:s.dashboard,title:p.value,widget:s.widget},null,40,["current-widget","widget-data","dashboard","title","widget"])):(e.openBlock(),e.createBlock(Ss,{key:1,class:"w-full h-full"}))])],4)}}}),Os={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},As={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},js={class:"max-w-sm mx-auto mt-6"},Ws={class:"font-medium text-gray-800 dark:text-neutral-200"},qs={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},ye=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",Os,[e.createElementVNode("div",null,[e.createElementVNode("div",As,[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",js,[e.createElementVNode("p",Ws,e.toDisplayString(s.title),1),e.createElementVNode("p",qs,e.toDisplayString(s.text),1)])])])]))}}),vs={components:{filterIcon:{__name:"filter",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(cs),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},Us={class:"flex items-center"},Hs={key:0,type:"button",class:"py-2 px-2.5 ml-3 h-[38px] inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 opacity-60 cursor-not-allowed",disabled:"",title:"Фільтри вимкнено (v3-filter видалено)"};function Gs(s,t,r,n,o,l){const a=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",Us,[r.filterScheme?(e.openBlock(),e.createElementBlock("button",Hs,[e.createVNode(a),t[0]||(t[0]=e.createTextVNode(" Фільтри ",-1))])):e.createCommentVNode("",!0)])}const Zs={components:{VsFilterHeader:S(vs,[["render",Gs]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},Qs={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},Xs={class:"grow"},Js={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},Ks={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"},Ys={key:0,class:"flex items-center gap-3"};function er(s,t,r,n,o,l){var i,c,p;const a=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",Qs,[e.createElementVNode("div",Xs,[e.createElementVNode("h1",Js,e.toDisplayString((i=r.dashboardData)==null?void 0:i.title),1),(c=r.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",Ks,e.toDisplayString((p=r.dashboardData)==null?void 0:p.description),1)):e.createCommentVNode("",!0)]),r.filters?(e.openBlock(),e.createElementBlock("div",Ys,[e.createVNode(a,{filterScheme:r.filters,"onFilters:changed":t[0]||(t[0]=d=>s.$emit("filters:changed",d))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const tr=S(Zs,[["render",er]]);var Xe={};const sr=Symbol(Xe.NODE_ENV!=="production"?"router":""),rr=Symbol(Xe.NODE_ENV!=="production"?"route location":"");function Ce(){return e.inject(sr)}function nr(s){return e.inject(rr)}const or={key:0,class:"text-gray-400 shrink-0"},ar=["onClick"],lr=["onClick"],ir={key:4,class:"text-gray-900 font-medium truncate"},Je={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(s){const t=s,r=Ce(),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,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:p},[p>0?(e.openBlock(),e.createElementBlock("span",or,[e.createVNode(e.unref(as),{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:d=>c.onClick()},e.toDisplayString(c.label),9,ar)):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:d=>o(c.to)},e.toDisplayString(c.label),9,lr)):(e.openBlock(),e.createElementBlock("span",ir,e.toDisplayString(c.label),1))],64))),128))],2)}}},cr={components:{VsWidget:te,VsNewNodata:ye,VsHeader:tr,VsBreadcrumbs:Je},props:["id","prefix"],data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},async mounted(){ge(this.prefix||"/api"),await this.fetchData()},methods:{async fetchData(){if(this.id)try{const s=await P.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)}}},dr={class:"w-full pb-8 overflow-y-auto mx-auto"},pr={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function hr(s,t,r,n,o,l){var c;const a=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",dr,[e.createElementVNode("div",pr,[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)||[],(p,d)=>{var h;return e.openBlock(),e.createElementBlock("div",{key:d,class:e.normalizeClass([`col-span-12 lg:col-span-${p.col||12}`,"flex flex-col gap-[10px]"])},[(h=p.widgets)!=null&&h.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(p.widgets,x=>(e.openBlock(),e.createBlock(i,{key:x,dashboard:r.id,widget:x,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))),128)):(e.openBlock(),e.createBlock(i,{key:1,class:"flex flex-col",dashboard:r.id,widget:p.widget,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))],2)}),128))])])}const ur=S(cr,[["render",hr]]),mr={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},fr={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},gr={class:"font-medium text-gray-800 dark:text-white"},br={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},yr={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},se=S({__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",mr,[e.createElementVNode("div",{class:"absolute inset-0 bg-black/50","aria-hidden":"true",onMousedown:c[0]||(c[0]=p=>s.closeClickBack&&p.target===p.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",fr,[e.createElementVNode("h3",gr,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",br,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",yr,[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"]]),xr={__name:"icon-plus",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(He),e.mergeProps(t.$attrs,{size:24}),null,16))}},kr={class:"mb-4 overflow-auto scrollbar max-h-96"},wr={__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 m;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(m=e.getCurrentInstance().proxy)==null?void 0:m.$notify,l=r,a=s,i=e.ref(!1),c=e.ref({}),p=e.ref();function d(){i.value=!0}function h(){i.value=!1}t({open:d,close:h});const x=async()=>{var b;try{const y=(b=p.value)==null?void 0:b.doValidation;typeof y=="function"&&await y(),await P.post(`/bi-dashboard/${a.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await l("update-data"),c.value={},i.value=!1}catch(y){const k=(y==null?void 0:y.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:k})}},u=e.computed(()=>{var b,y,k,g;return{title:{type:"text",label:"Назва віджета",placeholder:"Назва віджета",validators:["required"]},x:{type:"select",label:"Вісь X",view:"buttons",style:{size:"xs"},validators:["required"],options:(y=(b=a.columns)==null?void 0:b.filter(f=>(f==null?void 0:f.type)=="text"||(f==null?void 0:f.type)==="date"||(f==null?void 0:f.type)==="timestamp without time zone"||(f==null?void 0:f.type)==="boolean"||(f==null?void 0:f.type)==="integer"))==null?void 0:y.map(({name:f,type:w})=>({id:f,text:f,type:w}))},metric:{type:"select",label:"Вісь Y",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(g=(k=a.columns)==null?void 0:k.filter(f=>(f==null?void 0:f.type)==="numeric"||(f==null?void 0:f.type)==="double precision"))==null?void 0:g.map(({name:f,type:w})=>({id:f,text:f,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(b,y)=>{const k=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[s.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(k,{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:d},[e.createVNode(xr,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[y[1]||(y[1]=e.createTextVNode(" Створити віджет ",-1))]),_:1})),e.createVNode(se,{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: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 !border-gray-200 hover:bg-blue-700 duration-300"}," Створити ")])]),default:e.withCtx(()=>[e.createElementVNode("div",kr,[e.createVNode(e.unref(n),{ref_key:"form",ref:p,schema:u.value,values:c.value,"onUpdate:values":y[0]||(y[0]=g=>c.value=g)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},Ke={__name:"delete",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ks),e.mergeProps(t.$attrs,{size:24}),null,16))}},De={__name:"close",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Ge),e.mergeProps(t.$attrs,{size:24}),null,16))}},Ye={__name:"edit",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(gs),e.mergeProps(t.$attrs,{size:24}),null,16))}},_r={class:"space-y-4"},$r={__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 V,_,$,E;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),p=((V=a.data)==null?void 0:V.type)||(($=(_=a.data)==null?void 0:_.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}}[p]||{label:!1,legend:!1,tooltip:!0},x={show:{label:"Підпис",type:"switcher",title:"Показати підпис"},rotate:{type:"number",label:"Rotate angel",conditions:["show","==",!0]},align:{type:"select",view:"buttons",label:"Align",conditions:["show","==",!0],options:[{id:"center",text:"Center"},{id:"left",text:"Left"},{id:"right",text:"Right"}]},position:{type:"select",label:"Position",conditions:["show","==",!0],options:[{id:"top",text:"Top"},{id:"right",text:"Right"},{id:"left",text:"Left"},{id:"bottom",text:"Bottom"}]}},u={show:{label:"Легенда",type:"switcher",title:"Показати легенду"}},m={show:{label:"Тултіп",type:"switcher",title:"Показати тултіп"}},b=(E=a.data)==null?void 0:E.style,y=e.ref(b!=null&&b.label?{...b.label}:{show:h.label}),k=e.ref(b!=null&&b.legend?{...b.legend}:{show:h.legend}),g=e.ref(b!=null&&b.tooltip?{...b.tooltip}:{show:h.tooltip}),f=()=>{const C=new CustomEvent(`update-style-${a.widgetName}`);C.chartId=a.widgetName,C.options={options:{legend:k.value,tooltip:g.value,label:y.value},seriesOptions:y.value},window.dispatchEvent(C)};e.watch(y,f,{deep:!0}),e.watch(k,f,{deep:!0}),e.watch(g,f,{deep:!0});const w=async()=>{try{await P.put(`/bi-dashboard/${c.value}/${a.widgetName}`,{style:{legend:k.value,tooltip:g.value,label:y.value}});const C=new CustomEvent(`update-style-${a.widgetName}`);C.chartId=a.widgetName,C.options={options:{legend:k.value,tooltip:g.value,label:y.value},seriesOptions:y.value},window.dispatchEvent(C),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const C=new URLSearchParams(window.top.location.search);i.value=C.get("dashboard"),f()}),t({requestUpdateWidget:w}),(C,L)=>(e.openBlock(),e.createElementBlock("div",_r,[e.createVNode(e.unref(n),{schema:x,values:y.value,"onUpdate:values":L[0]||(L[0]=M=>y.value=M),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:u,values:k.value,"onUpdate:values":L[1]||(L[1]=M=>k.value=M),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:m,values:g.value,"onUpdate:values":L[2]||(L[2]=M=>g.value=M),class:"p-0"},null,8,["values"])]))}};function Ne(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Z=Ne();function et(s){Z=s}const tt=/[&<>"']/,Vr=new RegExp(tt.source,"g"),st=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Er=new RegExp(st.source,"g"),Br={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},rt=s=>Br[s];function A(s,t){if(t){if(tt.test(s))return s.replace(Vr,rt)}else if(st.test(s))return s.replace(Er,rt);return s}const Cr=/(^|[^\[])\^/g;function z(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(Cr,"$1"),r=r.replace(o,a),n},getRegex:()=>new RegExp(r,t)};return n}function nt(s){try{s=encodeURI(s).replace(/%25/g,"%")}catch{return null}return s}const re={exec:()=>null};function ot(s,t){const r=s.replace(/\|/g,(l,a,i)=>{let c=!1,p=a;for(;--p>=0&&i[p]==="\\";)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 ne(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 Dr(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 at(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 Nr(s,t){const r=s.match(/^(\s+)(?:```)/);if(r===null)return t;const n=r[1];return t.split(`
107
132
  `).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(`
108
- `)}class xe{constructor(t){S(this,"options");S(this,"rules");S(this,"lexer");this.options=t||J}space(t){const r=this.rules.block.newline.exec(t);if(r&&r[0].length>0)return{type:"space",raw:r[0]}}code(t){const r=this.rules.block.code.exec(t);if(r){const n=r[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:r[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ae(n,`
109
- `)}}}fences(t){const r=this.rules.block.fences.exec(t);if(r){const n=r[0],o=Dr(n,r[3]||"");return{type:"code",raw:n,lang:r[2]?r[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):r[2],text:o}}}heading(t){const r=this.rules.block.heading.exec(t);if(r){let n=r[2].trim();if(/#$/.test(n)){const o=ae(n,"#");(this.options.pedantic||!o||/ $/.test(o))&&(n=o.trim())}return{type:"heading",raw:r[0],depth:r[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const r=this.rules.block.hr.exec(t);if(r)return{type:"hr",raw:ae(r[0],`
110
- `)}}blockquote(t){const r=this.rules.block.blockquote.exec(t);if(r){let n=ae(r[0],`
133
+ `)}class xe{constructor(t){T(this,"options");T(this,"rules");T(this,"lexer");this.options=t||Z}space(t){const r=this.rules.block.newline.exec(t);if(r&&r[0].length>0)return{type:"space",raw:r[0]}}code(t){const r=this.rules.block.code.exec(t);if(r){const n=r[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:r[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ne(n,`
134
+ `)}}}fences(t){const r=this.rules.block.fences.exec(t);if(r){const n=r[0],o=Nr(n,r[3]||"");return{type:"code",raw:n,lang:r[2]?r[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):r[2],text:o}}}heading(t){const r=this.rules.block.heading.exec(t);if(r){let n=r[2].trim();if(/#$/.test(n)){const o=ne(n,"#");(this.options.pedantic||!o||/ $/.test(o))&&(n=o.trim())}return{type:"heading",raw:r[0],depth:r[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const r=this.rules.block.hr.exec(t);if(r)return{type:"hr",raw:ne(r[0],`
135
+ `)}}blockquote(t){const r=this.rules.block.blockquote.exec(t);if(r){let n=ne(r[0],`
111
136
  `).split(`
112
137
  `),o="",l="";const a=[];for(;n.length>0;){let i=!1;const c=[];let p;for(p=0;p<n.length;p++)if(/^ {0,3}>/.test(n[p]))c.push(n[p]),i=!0;else if(!i)c.push(n[p]);else break;n=n.slice(p);const d=c.join(`
113
138
  `),h=d.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
114
139
  $1`).replace(/^ {0,3}>[ \t]?/gm,"");o=o?`${o}
115
140
  ${d}`:d,l=l?`${l}
116
- ${h}`:h;const g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,a,!0),this.lexer.state.top=g,n.length===0)break;const f=a[a.length-1];if((f==null?void 0:f.type)==="code")break;if((f==null?void 0:f.type)==="blockquote"){const m=f,x=m.raw+`
141
+ ${h}`:h;const x=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,a,!0),this.lexer.state.top=x,n.length===0)break;const u=a[a.length-1];if((u==null?void 0:u.type)==="code")break;if((u==null?void 0:u.type)==="blockquote"){const m=u,b=m.raw+`
117
142
  `+n.join(`
118
- `),k=this.blockquote(x);a[a.length-1]=k,o=o.substring(0,o.length-m.raw.length)+k.raw,l=l.substring(0,l.length-m.text.length)+k.text;break}else if((f==null?void 0:f.type)==="list"){const m=f,x=m.raw+`
143
+ `),y=this.blockquote(b);a[a.length-1]=y,o=o.substring(0,o.length-m.raw.length)+y.raw,l=l.substring(0,l.length-m.text.length)+y.text;break}else if((u==null?void 0:u.type)==="list"){const m=u,b=m.raw+`
119
144
  `+n.join(`
120
- `),k=this.list(x);a[a.length-1]=k,o=o.substring(0,o.length-f.raw.length)+k.raw,l=l.substring(0,l.length-m.raw.length)+k.raw,n=x.substring(a[a.length-1].raw.length).split(`
145
+ `),y=this.list(b);a[a.length-1]=y,o=o.substring(0,o.length-u.raw.length)+y.raw,l=l.substring(0,l.length-m.raw.length)+y.raw,n=b.substring(a[a.length-1].raw.length).split(`
121
146
  `);continue}}return{type:"blockquote",raw:o,tokens:a,text:l}}}list(t){let r=this.rules.block.list.exec(t);if(r){let n=r[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,p="",d="";if(!(r=a.exec(t))||this.rules.block.hr.test(t))break;p=r[0],t=t.substring(p.length);let h=r[2].split(`
122
- `,1)[0].replace(/^\t+/,u=>" ".repeat(3*u.length)),g=t.split(`
123
- `,1)[0],f=!h.trim(),m=0;if(this.options.pedantic?(m=2,d=h.trimStart()):f?m=r[1].length+1:(m=r[2].search(/[^ ]/),m=m>4?1:m,d=h.slice(m),m+=r[1].length),f&&/^[ \t]*$/.test(g)&&(p+=g+`
124
- `,t=t.substring(g.length+1),c=!0),!c){const u=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),y=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),b=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),_=new RegExp(`^ {0,${Math.min(3,m-1)}}#`),$=new RegExp(`^ {0,${Math.min(3,m-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const w=t.split(`
125
- `,1)[0];let L;if(g=w,this.options.pedantic?(g=g.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),L=g):L=g.replace(/\t/g," "),b.test(g)||_.test(g)||$.test(g)||u.test(g)||y.test(g))break;if(L.search(/[^ ]/)>=m||!g.trim())d+=`
126
- `+L.slice(m);else{if(f||h.replace(/\t/g," ").search(/[^ ]/)>=4||b.test(h)||_.test(h)||y.test(h))break;d+=`
127
- `+g}!f&&!g.trim()&&(f=!0),p+=w+`
128
- `,t=t.substring(w.length+1),h=L.slice(m)}}l.loose||(i?l.loose=!0:/\n[ \t]*\n[ \t]*$/.test(p)&&(i=!0));let x=null,k;this.options.gfm&&(x=/^\[[ xX]\] /.exec(d),x&&(k=x[0]!=="[ ] ",d=d.replace(/^\[[ xX]\] +/,""))),l.items.push({type:"list_item",raw:p,task:!!x,checked:k,loose:!1,text:d,tokens:[]}),l.raw+=p}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 p=l.items[c].tokens.filter(h=>h.type==="space"),d=p.length>0&&p.some(h=>/\n.*\n/.test(h.raw));l.loose=d}if(l.loose)for(let c=0;c<l.items.length;c++)l.items[c].loose=!0;return l}}html(t){const r=this.rules.block.html.exec(t);if(r)return{type:"html",block:!0,raw:r[0],pre:r[1]==="pre"||r[1]==="script"||r[1]==="style",text:r[0]}}def(t){const r=this.rules.block.def.exec(t);if(r){const n=r[1].toLowerCase().replace(/\s+/g," "),o=r[2]?r[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",l=r[3]?r[3].substring(1,r[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):r[3];return{type:"def",tag:n,raw:r[0],href:o,title:l}}}table(t){const r=this.rules.block.table.exec(t);if(!r||!/[:|]/.test(r[2]))return;const n=lt(r[1]),o=r[2].replace(/^\||\| *$/g,"").split("|"),l=r[3]&&r[3].trim()?r[3].replace(/\n[ \t]*$/,"").split(`
129
- `):[],a={type:"table",raw:r[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(lt(i,a.header.length).map((c,p)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[p]})));return a}}lheading(t){const r=this.rules.block.lheading.exec(t);if(r)return{type:"heading",raw:r[0],depth:r[2].charAt(0)==="="?1:2,text:r[1],tokens:this.lexer.inline(r[1])}}paragraph(t){const r=this.rules.block.paragraph.exec(t);if(r){const n=r[1].charAt(r[1].length-1)===`
130
- `?r[1].slice(0,-1):r[1];return{type:"paragraph",raw:r[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const r=this.rules.block.text.exec(t);if(r)return{type:"text",raw:r[0],text:r[0],tokens:this.lexer.inline(r[0])}}escape(t){const r=this.rules.inline.escape.exec(t);if(r)return{type:"escape",raw:r[0],text:A(r[1])}}tag(t){const r=this.rules.inline.tag.exec(t);if(r)return!this.lexer.state.inLink&&/^<a /i.test(r[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(r[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:r[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:r[0]}}link(t){const r=this.rules.inline.link.exec(t);if(r){const n=r[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const a=ae(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{const a=Cr(r[2],"()");if(a>-1){const c=(r[0].indexOf("!")===0?5:4)+r[1].length+a;r[2]=r[2].substring(0,a),r[0]=r[0].substring(0,c).trim(),r[3]=""}}let o=r[2],l="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);a&&(o=a[1],l=a[3])}else l=r[3]?r[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(n)?o=o.slice(1):o=o.slice(1,-1)),it(r,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},r[0],this.lexer)}}reflink(t,r){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=r[o.toLowerCase()];if(!l){const a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return it(n,l,n[0],this.lexer)}}emStrong(t,r,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,p=a,d=0;const h=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,r=r.slice(-1*t.length+a);(o=h.exec(r))!=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]){p+=c;continue}else if((o[5]||o[6])&&a%3&&!((a+c)%3)){d+=c;continue}if(p-=c,p>0)continue;c=Math.min(c,c+p+d);const g=[...o[0]][0].length,f=t.slice(0,a+o.index+g+c);if(Math.min(a,c)%2){const x=f.slice(1,-1);return{type:"em",raw:f,text:x,tokens:this.lexer.inlineTokens(x)}}const m=f.slice(2,-2);return{type:"strong",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(t){const r=this.rules.inline.code.exec(t);if(r){let n=r[2].replace(/\n/g," ");const o=/[^ ]/.test(n),l=/^ /.test(n)&&/ $/.test(n);return o&&l&&(n=n.substring(1,n.length-1)),n=A(n,!0),{type:"codespan",raw:r[0],text:n}}}br(t){const r=this.rules.inline.br.exec(t);if(r)return{type:"br",raw:r[0]}}del(t){const r=this.rules.inline.del.exec(t);if(r)return{type:"del",raw:r[0],text:r[2],tokens:this.lexer.inlineTokens(r[2])}}autolink(t){const r=this.rules.inline.autolink.exec(t);if(r){let n,o;return r[2]==="@"?(n=A(r[1]),o="mailto:"+n):(n=A(r[1]),o=n),{type:"link",raw:r[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let r;if(r=this.rules.inline.url.exec(t)){let o,l;if(r[2]==="@")o=A(r[0]),l="mailto:"+o;else{let a;do a=r[0],r[0]=((n=this.rules.inline._backpedal.exec(r[0]))==null?void 0:n[0])??"";while(a!==r[0]);o=A(r[0]),r[1]==="www."?l="http://"+r[0]:l=r[0]}return{type:"link",raw:r[0],text:o,href:l,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t){const r=this.rules.inline.text.exec(t);if(r){let n;return this.lexer.state.inRawBlock?n=r[0]:n=A(r[0]),{type:"text",raw:r[0],text:n}}}}const Nr=/^(?:[ \t]*(?:\n|$))+/,Sr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,le=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Lr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ct=/(?:[*+-]|\d{1,9}[.)])/,dt=N(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,ct).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(),Se=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Tr=/^[^\n]+/,ze=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ir=N(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ze).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Mr=N(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ct).getRegex(),ke="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",Le=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pr=N("^ {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",Le).replace("tag",ke).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),pt=N(Se).replace("hr",le).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",ke).getRegex(),Te={blockquote:N(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",pt).getRegex(),code:Sr,def:Ir,fences:zr,heading:Lr,hr:le,html:Pr,lheading:dt,list:Mr,newline:Nr,paragraph:pt,table:oe,text:Tr},ht=N("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",le).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",ke).getRegex(),Rr={...Te,table:ht,paragraph:N(Se).replace("hr",le).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ht).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",ke).getRegex()},Fr={...Te,html:N(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Le).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:oe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:N(Se).replace("hr",le).replace("heading",` *#{1,6} *[^
131
- ]`).replace("lheading",dt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},mt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ar=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ut=/^( {2,}|\\)\n(?!\s*$)/,Or=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ie="\\p{P}\\p{S}",jr=N(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ie).getRegex(),Wr=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,qr=N(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ie).getRegex(),Ur=N("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ie).getRegex(),vr=N("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ie).getRegex(),Hr=N(/\\([punct])/,"gu").replace(/punct/g,ie).getRegex(),Gr=N(/^<(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(),Zr=N(Le).replace("(?:-->|$)","-->").getRegex(),Qr=N("^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",Zr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),we=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Xr=N(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",we).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ft=N(/^!?\[(label)\]\[(ref)\]/).replace("label",we).replace("ref",ze).getRegex(),gt=N(/^!?\[(ref)\](?:\[\])?/).replace("ref",ze).getRegex(),Jr=N("reflink|nolink(?!\\()","g").replace("reflink",ft).replace("nolink",gt).getRegex(),Ie={_backpedal:oe,anyPunctuation:Hr,autolink:Gr,blockSkip:Wr,br:ut,code:Ar,del:oe,emStrongLDelim:qr,emStrongRDelimAst:Ur,emStrongRDelimUnd:vr,escape:mt,link:Xr,nolink:gt,punctuation:jr,reflink:ft,reflinkSearch:Jr,tag:Qr,text:Or,url:oe},Kr={...Ie,link:N(/^!?\[(label)\]\((.*?)\)/).replace("label",we).getRegex(),reflink:N(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",we).getRegex()},Me={...Ie,escape:N(mt).replace("])","~|])").getRegex(),url:N(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Yr={...Me,br:N(ut).replace("{2,}","*").getRegex(),text:N(Me.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},_e={normal:Te,gfm:Rr,pedantic:Fr},ce={normal:Ie,gfm:Me,breaks:Yr,pedantic:Kr};class O{constructor(t){S(this,"tokens");S(this,"options");S(this,"state");S(this,"tokenizer");S(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||J,this.options.tokenizer=this.options.tokenizer||new xe,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 r={block:_e.normal,inline:ce.normal};this.options.pedantic?(r.block=_e.pedantic,r.inline=ce.pedantic):this.options.gfm&&(r.block=_e.gfm,this.options.breaks?r.inline=ce.breaks:r.inline=ce.gfm),this.tokenizer.rules=r}static get rules(){return{block:_e,inline:ce}}static lex(t,r){return new O(r).lex(t)}static lexInline(t,r){return new O(r).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
147
+ `,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),x=t.split(`
148
+ `,1)[0],u=!h.trim(),m=0;if(this.options.pedantic?(m=2,d=h.trimStart()):u?m=r[1].length+1:(m=r[2].search(/[^ ]/),m=m>4?1:m,d=h.slice(m),m+=r[1].length),u&&/^[ \t]*$/.test(x)&&(p+=x+`
149
+ `,t=t.substring(x.length+1),c=!0),!c){const k=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),g=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),f=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(`
150
+ `,1)[0];let $;if(x=_,this.options.pedantic?(x=x.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),$=x):$=x.replace(/\t/g," "),f.test(x)||w.test(x)||V.test(x)||k.test(x)||g.test(x))break;if($.search(/[^ ]/)>=m||!x.trim())d+=`
151
+ `+$.slice(m);else{if(u||h.replace(/\t/g," ").search(/[^ ]/)>=4||f.test(h)||w.test(h)||g.test(h))break;d+=`
152
+ `+x}!u&&!x.trim()&&(u=!0),p+=_+`
153
+ `,t=t.substring(_.length+1),h=$.slice(m)}}l.loose||(i?l.loose=!0:/\n[ \t]*\n[ \t]*$/.test(p)&&(i=!0));let b=null,y;this.options.gfm&&(b=/^\[[ xX]\] /.exec(d),b&&(y=b[0]!=="[ ] ",d=d.replace(/^\[[ xX]\] +/,""))),l.items.push({type:"list_item",raw:p,task:!!b,checked:y,loose:!1,text:d,tokens:[]}),l.raw+=p}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 p=l.items[c].tokens.filter(h=>h.type==="space"),d=p.length>0&&p.some(h=>/\n.*\n/.test(h.raw));l.loose=d}if(l.loose)for(let c=0;c<l.items.length;c++)l.items[c].loose=!0;return l}}html(t){const r=this.rules.block.html.exec(t);if(r)return{type:"html",block:!0,raw:r[0],pre:r[1]==="pre"||r[1]==="script"||r[1]==="style",text:r[0]}}def(t){const r=this.rules.block.def.exec(t);if(r){const n=r[1].toLowerCase().replace(/\s+/g," "),o=r[2]?r[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",l=r[3]?r[3].substring(1,r[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):r[3];return{type:"def",tag:n,raw:r[0],href:o,title:l}}}table(t){const r=this.rules.block.table.exec(t);if(!r||!/[:|]/.test(r[2]))return;const n=ot(r[1]),o=r[2].replace(/^\||\| *$/g,"").split("|"),l=r[3]&&r[3].trim()?r[3].replace(/\n[ \t]*$/,"").split(`
154
+ `):[],a={type:"table",raw:r[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(ot(i,a.header.length).map((c,p)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[p]})));return a}}lheading(t){const r=this.rules.block.lheading.exec(t);if(r)return{type:"heading",raw:r[0],depth:r[2].charAt(0)==="="?1:2,text:r[1],tokens:this.lexer.inline(r[1])}}paragraph(t){const r=this.rules.block.paragraph.exec(t);if(r){const n=r[1].charAt(r[1].length-1)===`
155
+ `?r[1].slice(0,-1):r[1];return{type:"paragraph",raw:r[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const r=this.rules.block.text.exec(t);if(r)return{type:"text",raw:r[0],text:r[0],tokens:this.lexer.inline(r[0])}}escape(t){const r=this.rules.inline.escape.exec(t);if(r)return{type:"escape",raw:r[0],text:A(r[1])}}tag(t){const r=this.rules.inline.tag.exec(t);if(r)return!this.lexer.state.inLink&&/^<a /i.test(r[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(r[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:r[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:r[0]}}link(t){const r=this.rules.inline.link.exec(t);if(r){const n=r[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const a=ne(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{const a=Dr(r[2],"()");if(a>-1){const c=(r[0].indexOf("!")===0?5:4)+r[1].length+a;r[2]=r[2].substring(0,a),r[0]=r[0].substring(0,c).trim(),r[3]=""}}let o=r[2],l="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);a&&(o=a[1],l=a[3])}else l=r[3]?r[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(n)?o=o.slice(1):o=o.slice(1,-1)),at(r,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},r[0],this.lexer)}}reflink(t,r){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=r[o.toLowerCase()];if(!l){const a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return at(n,l,n[0],this.lexer)}}emStrong(t,r,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,p=a,d=0;const h=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,r=r.slice(-1*t.length+a);(o=h.exec(r))!=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]){p+=c;continue}else if((o[5]||o[6])&&a%3&&!((a+c)%3)){d+=c;continue}if(p-=c,p>0)continue;c=Math.min(c,c+p+d);const x=[...o[0]][0].length,u=t.slice(0,a+o.index+x+c);if(Math.min(a,c)%2){const b=u.slice(1,-1);return{type:"em",raw:u,text:b,tokens:this.lexer.inlineTokens(b)}}const m=u.slice(2,-2);return{type:"strong",raw:u,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(t){const r=this.rules.inline.code.exec(t);if(r){let n=r[2].replace(/\n/g," ");const o=/[^ ]/.test(n),l=/^ /.test(n)&&/ $/.test(n);return o&&l&&(n=n.substring(1,n.length-1)),n=A(n,!0),{type:"codespan",raw:r[0],text:n}}}br(t){const r=this.rules.inline.br.exec(t);if(r)return{type:"br",raw:r[0]}}del(t){const r=this.rules.inline.del.exec(t);if(r)return{type:"del",raw:r[0],text:r[2],tokens:this.lexer.inlineTokens(r[2])}}autolink(t){const r=this.rules.inline.autolink.exec(t);if(r){let n,o;return r[2]==="@"?(n=A(r[1]),o="mailto:"+n):(n=A(r[1]),o=n),{type:"link",raw:r[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let r;if(r=this.rules.inline.url.exec(t)){let o,l;if(r[2]==="@")o=A(r[0]),l="mailto:"+o;else{let a;do a=r[0],r[0]=((n=this.rules.inline._backpedal.exec(r[0]))==null?void 0:n[0])??"";while(a!==r[0]);o=A(r[0]),r[1]==="www."?l="http://"+r[0]:l=r[0]}return{type:"link",raw:r[0],text:o,href:l,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t){const r=this.rules.inline.text.exec(t);if(r){let n;return this.lexer.state.inRawBlock?n=r[0]:n=A(r[0]),{type:"text",raw:r[0],text:n}}}}const Sr=/^(?:[ \t]*(?:\n|$))+/,zr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Lr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,oe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Tr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,lt=/(?:[*+-]|\d{1,9}[.)])/,it=z(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,lt).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(),Se=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ir=/^[^\n]+/,ze=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Mr=z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ze).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Pr=z(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,lt).getRegex(),ke="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",Le=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Rr=z("^ {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",Le).replace("tag",ke).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ct=z(Se).replace("hr",oe).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",ke).getRegex(),Te={blockquote:z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ct).getRegex(),code:zr,def:Mr,fences:Lr,heading:Tr,hr:oe,html:Rr,lheading:it,list:Pr,newline:Sr,paragraph:ct,table:re,text:Ir},dt=z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",oe).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",ke).getRegex(),Fr={...Te,table:dt,paragraph:z(Se).replace("hr",oe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",dt).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",ke).getRegex()},Or={...Te,html:z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Le).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:re,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:z(Se).replace("hr",oe).replace("heading",` *#{1,6} *[^
156
+ ]`).replace("lheading",it).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},pt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ar=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ht=/^( {2,}|\\)\n(?!\s*$)/,jr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ae="\\p{P}\\p{S}",Wr=z(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ae).getRegex(),qr=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,vr=z(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ae).getRegex(),Ur=z("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ae).getRegex(),Hr=z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ae).getRegex(),Gr=z(/\\([punct])/,"gu").replace(/punct/g,ae).getRegex(),Zr=z(/^<(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(),Qr=z(Le).replace("(?:-->|$)","-->").getRegex(),Xr=z("^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",Qr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),we=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Jr=z(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",we).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ut=z(/^!?\[(label)\]\[(ref)\]/).replace("label",we).replace("ref",ze).getRegex(),mt=z(/^!?\[(ref)\](?:\[\])?/).replace("ref",ze).getRegex(),Kr=z("reflink|nolink(?!\\()","g").replace("reflink",ut).replace("nolink",mt).getRegex(),Ie={_backpedal:re,anyPunctuation:Gr,autolink:Zr,blockSkip:qr,br:ht,code:Ar,del:re,emStrongLDelim:vr,emStrongRDelimAst:Ur,emStrongRDelimUnd:Hr,escape:pt,link:Jr,nolink:mt,punctuation:Wr,reflink:ut,reflinkSearch:Kr,tag:Xr,text:jr,url:re},Yr={...Ie,link:z(/^!?\[(label)\]\((.*?)\)/).replace("label",we).getRegex(),reflink:z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",we).getRegex()},Me={...Ie,escape:z(pt).replace("])","~|])").getRegex(),url:z(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},en={...Me,br:z(ht).replace("{2,}","*").getRegex(),text:z(Me.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},_e={normal:Te,gfm:Fr,pedantic:Or},le={normal:Ie,gfm:Me,breaks:en,pedantic:Yr};class j{constructor(t){T(this,"tokens");T(this,"options");T(this,"state");T(this,"tokenizer");T(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Z,this.options.tokenizer=this.options.tokenizer||new xe,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 r={block:_e.normal,inline:le.normal};this.options.pedantic?(r.block=_e.pedantic,r.inline=le.pedantic):this.options.gfm&&(r.block=_e.gfm,this.options.breaks?r.inline=le.breaks:r.inline=le.gfm),this.tokenizer.rules=r}static get rules(){return{block:_e,inline:le}}static lex(t,r){return new j(r).lex(t)}static lexInline(t,r){return new j(r).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
132
157
  `),this.blockTokens(t,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){const n=this.inlineQueue[r];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,r=[],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,r))?(t=t.substring(o.raw.length),r.push(o),!0):!1))){if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length),o.raw.length===1&&r.length>0?r[r.length-1].raw+=`
133
158
  `:r.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length),l=r[r.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
134
159
  `+o.raw,l.text+=`
@@ -138,7 +163,7 @@ ${h}`:h;const g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
138
163
  `+o.raw,l.text+=`
139
164
  `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):r.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=r[r.length-1],l&&l.type==="text"?(l.raw+=`
140
165
  `+o.raw,l.text+=`
141
- `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):r.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,r}inline(t,r=[]){return this.inlineQueue.push({src:t,tokens:r}),r}inlineTokens(t,r=[]){let n,o,l,a=t,i,c,p;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)d.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||(p=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(n=d.call({lexer:this},t,r))?(t=t.substring(n.raw.length),r.push(n),!0):!1))){if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),o=r[r.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length),o=r[r.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(n=this.tokenizer.emStrong(t,a,p)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.del(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),r.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),r.push(n);continue}if(l=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const h=t.slice(1);let g;this.options.extensions.startInline.forEach(f=>{g=f.call({lexer:this},h),typeof g=="number"&&g>=0&&(d=Math.min(d,g))}),d<1/0&&d>=0&&(l=t.substring(0,d+1))}if(n=this.tokenizer.inlineText(l)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(p=n.raw.slice(-1)),c=!0,o=r[r.length-1],o&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return r}}class $e{constructor(t){S(this,"options");S(this,"parser");this.options=t||J}space(t){return""}code({text:t,lang:r,escaped:n}){var a;const o=(a=(r||"").match(/^\S*/))==null?void 0:a[0],l=t.replace(/\n$/,"")+`
166
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):r.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,r}inline(t,r=[]){return this.inlineQueue.push({src:t,tokens:r}),r}inlineTokens(t,r=[]){let n,o,l,a=t,i,c,p;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)d.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||(p=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(n=d.call({lexer:this},t,r))?(t=t.substring(n.raw.length),r.push(n),!0):!1))){if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),o=r[r.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length),o=r[r.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(n=this.tokenizer.emStrong(t,a,p)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.del(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),r.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),r.push(n);continue}if(l=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const h=t.slice(1);let x;this.options.extensions.startInline.forEach(u=>{x=u.call({lexer:this},h),typeof x=="number"&&x>=0&&(d=Math.min(d,x))}),d<1/0&&d>=0&&(l=t.substring(0,d+1))}if(n=this.tokenizer.inlineText(l)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(p=n.raw.slice(-1)),c=!0,o=r[r.length-1],o&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return r}}class $e{constructor(t){T(this,"options");T(this,"parser");this.options=t||Z}space(t){return""}code({text:t,lang:r,escaped:n}){var a;const o=(a=(r||"").match(/^\S*/))==null?void 0:a[0],l=t.replace(/\n$/,"")+`
142
167
  `;return o?'<pre><code class="language-'+A(o)+'">'+(n?l:A(l,!0))+`</code></pre>
143
168
  `:"<pre><code>"+(n?l:A(l,!0))+`</code></pre>
144
169
  `}blockquote({tokens:t}){return`<blockquote>
@@ -156,31 +181,34 @@ ${this.parser.parse(t)}</blockquote>
156
181
  `}tablerow({text:t}){return`<tr>
157
182
  ${t}</tr>
158
183
  `}tablecell(t){const r=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+r+`</${n}>
159
- `}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:r,tokens:n}){const o=this.parser.parseInline(n),l=at(t);if(l===null)return o;t=l;let a='<a href="'+t+'"';return r&&(a+=' title="'+r+'"'),a+=">"+o+"</a>",a}image({href:t,title:r,text:n}){const o=at(t);if(o===null)return n;t=o;let l=`<img src="${t}" alt="${n}"`;return r&&(l+=` title="${r}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class Pe{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 j{constructor(t){S(this,"options");S(this,"renderer");S(this,"textRenderer");this.options=t||J,this.options.renderer=this.options.renderer||new $e,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Pe}static parse(t,r){return new j(r).parse(t)}static parseInline(t,r){return new j(r).parseInline(t)}parse(t,r=!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+=`
160
- `+this.renderer.text(i);r?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,r){r=r||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+=r.text(a);break}case"html":{n+=r.html(a);break}case"link":{n+=r.link(a);break}case"image":{n+=r.image(a);break}case"strong":{n+=r.strong(a);break}case"em":{n+=r.em(a);break}case"codespan":{n+=r.codespan(a);break}case"br":{n+=r.br(a);break}case"del":{n+=r.del(a);break}case"text":{n+=r.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 de{constructor(t){S(this,"options");S(this,"block");this.options=t||J}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?O.lex:O.lexInline}provideParser(){return this.block?j.parse:j.parseInline}}S(de,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class en{constructor(...t){S(this,"defaults",Ne());S(this,"options",this.setOptions);S(this,"parse",this.parseMarkdown(!0));S(this,"parseInline",this.parseMarkdown(!1));S(this,"Parser",j);S(this,"Renderer",$e);S(this,"TextRenderer",Pe);S(this,"Lexer",O);S(this,"Tokenizer",xe);S(this,"Hooks",de);this.use(...t)}walkTokens(t,r){var o,l;let n=[];for(const a of t)switch(n=n.concat(r.call(this,a)),a.type){case"table":{const i=a;for(const c of i.header)n=n.concat(this.walkTokens(c.tokens,r));for(const c of i.rows)for(const p of c)n=n.concat(this.walkTokens(p.tokens,r));break}case"list":{const i=a;n=n.concat(this.walkTokens(i.items,r));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 p=i[c].flat(1/0);n=n.concat(this.walkTokens(p,r))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,r)))}}return n}use(...t){const r=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=r.renderers[l.name];a?r.renderers[l.name]=function(...i){let c=l.renderer.apply(this,i);return c===!1&&(c=a.apply(this,i)),c}:r.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=r[l.level];a?a.unshift(l.tokenizer):r[l.level]=[l.tokenizer],l.start&&(l.level==="block"?r.startBlock?r.startBlock.push(l.start):r.startBlock=[l.start]:l.level==="inline"&&(r.startInline?r.startInline.push(l.start):r.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(r.childTokens[l.name]=l.childTokens)}),o.extensions=r),n.renderer){const l=this.defaults.renderer||new $e(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],p=l[i];l[i]=(...d)=>{let h=c.apply(l,d);return h===!1&&(h=p.apply(l,d)),h||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new xe(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],p=l[i];l[i]=(...d)=>{let h=c.apply(l,d);return h===!1&&(h=p.apply(l,d)),h}}o.tokenizer=l}if(n.hooks){const l=this.defaults.hooks||new de;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],p=l[i];de.passThroughHooks.has(a)?l[i]=d=>{if(this.defaults.async)return Promise.resolve(c.call(l,d)).then(g=>p.call(l,g));const h=c.call(l,d);return p.call(l,h)}:l[i]=(...d)=>{let h=c.apply(l,d);return h===!1&&(h=p.apply(l,d)),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,r){return O.lex(t,r??this.defaults)}parser(t,r){return j.parse(t,r??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?O.lex:O.lexInline,p=a.hooks?a.hooks.provideParser():t?j.parse:j.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(n):n).then(d=>c(d,a)).then(d=>a.hooks?a.hooks.processAllTokens(d):d).then(d=>a.walkTokens?Promise.all(this.walkTokens(d,a.walkTokens)).then(()=>d):d).then(d=>p(d,a)).then(d=>a.hooks?a.hooks.postprocess(d):d).catch(i);try{a.hooks&&(n=a.hooks.preprocess(n));let d=c(n,a);a.hooks&&(d=a.hooks.processAllTokens(d)),a.walkTokens&&this.walkTokens(d,a.walkTokens);let h=p(d,a);return a.hooks&&(h=a.hooks.postprocess(h)),h}catch(d){return i(d)}}}onError(t,r){return n=>{if(n.message+=`
161
- 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 en;function C(s,t){return K.parse(s,t)}C.options=C.setOptions=function(s){return K.setOptions(s),C.defaults=K.defaults,st(C.defaults),C},C.getDefaults=Ne,C.defaults=J,C.use=function(...s){return K.use(...s),C.defaults=K.defaults,st(C.defaults),C},C.walkTokens=function(s,t){return K.walkTokens(s,t)},C.parseInline=K.parseInline,C.Parser=j,C.parser=j.parse,C.Renderer=$e,C.TextRenderer=Pe,C.Lexer=O,C.lexer=O.lex,C.Tokenizer=xe,C.Hooks=de,C.parse=C,C.options,C.setOptions,C.use,C.walkTokens,C.parseInline,j.parse,O.lex;const tn={class:"space-y-4"},sn={__name:"vs-editor-form-data",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}},columns:{type:Array,default:()=>[]}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){var _,$,w,L,P,F,q,U,V,v,Z,G,he,me,ue,I,Q,fe,Ot,jt,Wt,qt,Ut,vt,Ht,Gt,Zt,Qt,Xt,Jt,Kt,Yt;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,i=e.ref(null),c=e.ref([]),p=e.computed(()=>{const E=a.columns??[];return E.length?E:c.value}),d=e.computed(()=>a.dashboardId||i.value);async function h(){const E=d.value;if(!(p.value.length||!E||!a.widgetName))try{const B=await T.get(`/bi-data?dashboard=${E}&widget=${a.widgetName}`);Array.isArray(B==null?void 0:B.columns)&&B.columns.length&&(c.value=B.columns)}catch{}}const g=E=>(E==null?void 0:E.name)!=null?{id:E.name,text:E.title||E.name}:null,f=E=>Array.isArray(E)?[...E].sort((B,H)=>{const te=B.text&&B.text!==B.id,es=H.text&&H.text!==H.id;return te&&!es?-1:!te&&es?1:(B.text||"").localeCompare(H.text||"",void 0,{sensitivity:"base"})}):E,m=e.computed(()=>{const E=(p.value??[]).filter(B=>(B==null?void 0:B.type)=="text"||(B==null?void 0:B.type)==="date"||(B==null?void 0:B.type)==="timestamp without time zone"||(B==null?void 0:B.type)==="boolean"||(B==null?void 0:B.type)==="integer").map(g).filter(Boolean);return f(E)}),x=e.computed(()=>`${a.widgetName}-${m.value.length}-${(p.value??[]).length}`),k=e.computed(()=>({text:{type:"Text",label:"Text",conditions:["type","==","text"]},x:{type:"select",label:"X Axis",style:{size:"xs"},conditions:["type","not_in",["text","table","map"]],options:[...m.value]},cls:{label:"X Axis classifier",type:"text",conditions:["type","not_in",["text","table","map","cluster"]]},y_type:{label:"Y type",type:"select",options:[{id:"columns",text:"columns"},{id:"function",text:"function"}],conditions:["type","not_in",["text","table","map","number","cluster"]]},tableSQL:{label:"tableSQL",type:"text",hidden:!0},metric:{type:"select",label:"Y Axis",conditions:[["type","not_in",["text","table","map","cluster"]],["y_type","!=","function"]],options:[{id:"count",text:"count"},...f(p.value.filter(E=>(E==null?void 0:E.type)==="numeric"||(E==null?void 0:E.type)==="double precision").map(g).filter(Boolean))]},fx:{type:"text",label:"Function",conditions:[["y_type","==","function"]]},query:{label:"Query",type:"text",conditions:["type","not_in",["text","table","map","number"]]},groupby:{type:"select",label:"Groupby",view:"buttons",style:{size:"xs"},options:[{id:"null",text:"null"},...f(p.value.filter(E=>(E==null?void 0:E.type)=="text"||(E==null?void 0:E.type)==="boolean"||(E==null?void 0:E.type)==="integer").map(g).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Columns",style:{size:"xs"},options:f((p.value??[]).map(g).filter(Boolean)),conditions:["type","in",["table","map"]]},granularity:{type:"radio",label:"Granularity",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}})),u=e.ref({x:(($=(_=a.data)==null?void 0:_.data)==null?void 0:$.x)||((w=a.data)==null?void 0:w.x)||null,metric:((P=(L=a.data)==null?void 0:L.data)==null?void 0:P.metric)||((F=a.data)==null?void 0:F.metric)||null,columns:((U=(q=a.data)==null?void 0:q.data)==null?void 0:U.columns)||((V=a.data)==null?void 0:V.columns)||null,granularity:((Z=(v=a.data)==null?void 0:v.data)==null?void 0:Z.granularity)||((G=a.data)==null?void 0:G.granularity)||null,type:((me=(he=a.data)==null?void 0:he.data)==null?void 0:me.type)||((ue=a.data)==null?void 0:ue.type)||null,groupby:((Q=(I=a.data)==null?void 0:I.data)==null?void 0:Q.groupby)||a.data.groupby||null,fx:((Ot=(fe=a.data)==null?void 0:fe.data)==null?void 0:Ot.fx)||((jt=a.data)==null?void 0:jt.fx)||null,query:((qt=(Wt=a.data)==null?void 0:Wt.data)==null?void 0:qt.query)||((Ut=a.data)==null?void 0:Ut.query)||null,y_type:((Ht=(vt=a.data)==null?void 0:vt.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}),y=async()=>{try{await T.put(`/bi-dashboard/${d.value}/${a.widgetName}`,{data:u.value});let E=`/bi-data?dashboard=${d.value}&widget=${a.widgetName}`;Object.entries(u.value).forEach(([H,te])=>{E+=`&${H}=${te}`});const B=new CustomEvent(`update-data-${a.widgetName}`);B.filterUrl=E,window.dispatchEvent(B),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},b=async()=>{try{let E=`/bi-data?dashboard=${d.value}&widget=${a.widgetName}`;Object.entries(u.value).forEach(([H,te])=>{E+=`&${H}=${te}`});const B=new CustomEvent(`update-data-${a.widgetName}`);B.filterUrl=E,window.dispatchEvent(B),l("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(u,()=>{b()},{deep:!0}),e.onMounted(()=>{const E=new URLSearchParams(window.top.location.search);i.value=E.get("dashboard"),h()}),e.watch(()=>[a.widgetName,a.dashboardId,i.value],()=>{c.value=[],h()},{immediate:!0}),t({requestUpdateWidget:y}),(E,B)=>(e.openBlock(),e.createElementBlock("div",tn,[(e.openBlock(),e.createBlock(e.unref(n),{key:x.value,schema:k.value,values:u.value,"onUpdate:values":B[0]||(B[0]=H=>u.value=H)},null,8,["schema","values"]))]))}},rn={class:"space-y-4"},nn={__name:"vs-editor-form-yaml",props:{yamlValue:{type:null,default:()=>""},widgetName:{type:String},data:{type:Object}},setup(s,{expose:t}){const r=typeof window<"u"?window.echarts:null,n=e.defineAsyncComponent(()=>import("@opengis/form").then(h=>h.VsInputMonaco)),o=e.ref(null),{$notify:l}=e.getCurrentInstance().proxy,a=s,i=(h,{dimensions:g,source:f})=>{const m=h.getOption(),{data:x,...k}=(m==null?void 0:m.series)[0],[,...u]=g||[],y=u.map((b,_)=>({...(m==null?void 0:m.series[_])||{},data:f.map($=>$[_+1]),name:b}));h==null||h.setOption({...m||{},dataset:{dimensions:g,source:f},series:y,xAxis:{type:"category"},yAxis:{}},!0)},c=h=>{const g=document.getElementById(h);if(!g)return null;const f=r==null?void 0:r.getInstanceByDom(g);return f||null},p=e.ref(a.yamlValue),d=async()=>{try{await T.put(`/bi-dashboard/${o.value}/${a.widgetName}`,{yml:p.value});const h=c(a.widgetName);if(h){const g=await T.get(`/bi-data?dashboard=${o.value}&widget=${a.widgetName}`);i(h,g)}l({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{l({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const h=new URLSearchParams(window.top.location.search);o.value=h.get("dashboard")}),t({requestUpdateWidget:d}),(h,g)=>(e.openBlock(),e.createElementBlock("div",rn,[e.createVNode(e.unref(n),{modelValue:p.value,"onUpdate:modelValue":g[0]||(g[0]=f=>p.value=f),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},on={class:"pt-[10px]"},bt={"vs-editor-form-style":_r,"vs-editor-form-data":sn,"vs-editor-form-yaml":nn,"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 d;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:(d=l.columns)==null?void 0:d.map(({name:h})=>h)}},c=e.ref(l.controls||{}),p=async()=>{try{await T.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,g)=>{const f=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",on,[e.createVNode(f,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:p},{default:e.withCtx(()=>g[1]||(g[1]=[e.createTextVNode(" Зберегти ")])),_:1}),e.createVNode(e.unref(r),{schema:i,values:c.value,"onUpdate:values":g[0]||(g[0]=m=>c.value=m)},null,8,["values"])])}}}},an={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},yt={__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",an," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(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))}},ln={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},cn={key:0,class:"flex flex-col min-h-0 flex-1"},dn={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},pn={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},hn=["onClick"],mn={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},un={class:"flex items-center gap-1 ml-auto shrink-0"},fn={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"},gn={key:0},bn={key:1},yn={class:"p-4"},xn={class:"flex justify-end mt-4 gap-x-3"},kn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},wn={__name:"vs-editor-forms",props:e.mergeModels({selectedWidgetData:{type:Object,required:!1,default:null},selectedDashboard:{type:String,default:()=>""},currentWidgetData:{type:String,default:()=>""}},{selectedWidget:{},selectedWidgetModifiers:{}}),emits:e.mergeModels(["update-data"],["update:selectedWidget"]),setup(s,{emit:t}){var b,_;const r=e.defineAsyncComponent(()=>import("@opengis/form")),n=(_=(b=e.getCurrentInstance())==null?void 0:b.proxy)==null?void 0:_.$notify,o=t,l=e.ref(null),a=s,i=e.ref(!1),c=e.ref(!0),p=e.ref(!1),d=e.ref({}),h=e.useModel(s,"selectedWidget"),g=["table","text","number","stat","progress","listbar","map","pivot"],f=e.ref("data"),m=async()=>{try{await T.delete(`/bi-dashboard/${a.selectedDashboard}/${a.selectedWidgetData.name}`);const $=new URL(window.top.location.href);$.searchParams.set("dashboard",a.selectedDashboard),$.searchParams.delete("widget"),window.top.history.pushState({},"",$),o("update-data"),i.value=!1,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(w=>{var L,P,F;return w.id==="style"?!(g!=null&&g.includes(((L=a.selectedWidgetData)==null?void 0:L.type)||((F=(P=a.selectedWidgetData)==null?void 0:P.data)==null?void 0:F.type))):!0})}),k=()=>{var $,w,L,P,F,q,U,V,v;d.value={title:($=a.selectedWidgetData)==null?void 0:$.title,type:(w=a.selectedWidgetData)==null?void 0:w.type,table:(L=a.selectedWidgetData)==null?void 0:L.table_name,query:(F=(P=a.selectedWidgetData)==null?void 0:P.data)==null?void 0:F.query,x:(U=(q=a.selectedWidgetData)==null?void 0:q.data)==null?void 0:U.x,cls:(v=(V=a.selectedWidgetData)==null?void 0:V.data)==null?void 0:v.cls},p.value=!0},u=async()=>{try{await T.put(`/bi-dashboard/${a.selectedDashboard}/${a.selectedWidgetData.name}`,d.value),n({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await o("update-data"),p.value=!1}catch{n({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(h,$=>{c.value=!1;const w=new URL(window.top.location.href);$?(w.searchParams.set("widget",$),window.top.history.pushState({},"",w)):(w.searchParams.delete("widget"),window.top.history.pushState({},"",w)),setTimeout(()=>c.value=!0)});const y={title:{type:"text",ua:"Заголовок",placeholder:"Заголовок",validators:["required"]},type:{type:"radio",view:"buttons",validators:["required"],slots:{label:'<div style="width: 120px; height:160px" class="flex gap-[12px] flex-col"><img class="block" style="height: calc(100% - 40px)" :src="`https://cdn.softpro.ua/data/icons/bi/${id}.png`"/><span class="font-[500]">{{ label }}</span></div>'},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 Axis",placeholder:"X Axis"},cls:{type:"Text",ua:"Cls",placeholder:"Cls"}};return($,w)=>{var P,F,q,U,V,v,Z,G,he,me,ue;const L=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ln,[s.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",cn,[e.createElementVNode("div",dn,[e.createElementVNode("nav",pn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,I=>(e.openBlock(),e.createElementBlock("button",{key:I.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",f.value===I.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:Q=>f.value=I.id},[e.createTextVNode(e.toDisplayString(I.label)+" ",1),f.value===I.id?(e.openBlock(),e.createElementBlock("span",mn)):e.createCommentVNode("",!0)],10,hn))),128))]),e.createElementVNode("div",un,[e.createVNode(L,{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:w[0]||(w[0]=I=>{var Q,fe;return(fe=(Q=l.value)==null?void 0:Q.save)==null?void 0:fe.call(Q)})},[e.createVNode(e.unref(gs),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[w[9]||(w[9]=e.createTextVNode(" Зберегти "))]),_:1}),e.createVNode(L,{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:k},[e.createVNode(tt,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[w[10]||(w[10]=e.createTextVNode(" Редагувати віджет "))]),_:1}),e.createVNode(L,{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:w[1]||(w[1]=I=>i.value=!0)},[e.createVNode(e.unref(et),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[w[11]||(w[11]=e.createTextVNode(" Видалити віджет "))]),_:1})])]),(P=s.currentWidgetData)!=null&&P.status?(e.openBlock(),e.createBlock(ye,{key:0,title:(F=s.currentWidgetData)==null?void 0:F.title,text:(q=s.currentWidgetData)==null?void 0:q.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",fn,[c.value&&s.currentWidgetData?(e.openBlock(),e.createElementBlock("div",gn,[e.createVNode(yt,{ref_key:"tabPanelRef",ref:l,"tab-key":f.value,"tab-component":e.unref(bt)["vs-editor-form-"+f.value],widgetName:(U=s.selectedWidgetData)==null?void 0:U.name,dashboardId:s.selectedDashboard,yamlValue:((V=s.selectedWidgetData)==null?void 0:V.yml)||"",data:s.selectedWidgetData,controls:(v=s.selectedWidgetData)==null?void 0:v.controls,columns:(Z=s.currentWidgetData)==null?void 0:Z.columns,onUpdateDashboard:w[2]||(w[2]=I=>$.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",bn,[e.createVNode(yt,{ref_key:"tabPanelRef",ref:l,"tab-key":f.value,"tab-component":e.unref(bt)["vs-editor-form-"+f.value],widgetName:(G=s.selectedWidgetData)==null?void 0:G.name,dashboardId:s.selectedDashboard,yamlValue:((he=s.selectedWidgetData)==null?void 0:he.yml)||"",data:s.selectedWidgetData,controls:(me=s.selectedWidgetData)==null?void 0:me.controls,columns:(ue=s.currentWidgetData)==null?void 0:ue.columns,onUpdateDashboard:w[3]||(w[3]=I=>$.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(ne,{teleport:"#modal",visible:i.value,title:"Ви впевнені?",onClose:w[5]||(w[5]=I=>i.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",yn,[w[12]||(w[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",xn,[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:w[4]||(w[4]=I=>i.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:m}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(ye,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(ne,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:w[8]||(w[8]=I=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",kn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:w[7]||(w[7]=I=>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:u,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(()=>[y?(e.openBlock(),e.createBlock(e.unref(r),{key:0,schema:y,values:d.value,"onUpdate:values":w[6]||(w[6]=I=>d.value=I)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},_n={class:"overflow-hidden flex flex-col min-h-[480px]"},$n={class:"flex-1 flex min-h-0 gap-4"},Vn={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},En={class:"w-[400px] shrink-0 flex flex-col"},Bn={__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.computed({get:()=>r.selectedWidget,set:l=>n("update:selectedWidget",l)});return(l,a)=>(e.openBlock(),e.createElementBlock("div",_n,[e.createElementVNode("div",$n,[e.createElementVNode("div",Vn,[e.createVNode(re,{dashboard:s.selectedDashboard,widget:s.selectedWidget,"selected-widget":s.selectedWidget,"dashboard-widgets":s.dashboardWidgets,"filter-u-rl":void 0,class:"max-h-full"},null,8,["dashboard","widget","selected-widget","dashboard-widgets"])]),e.createElementVNode("div",En,[e.createVNode(wn,{selectedWidget:o.value,"onUpdate:selectedWidget":a[0]||(a[0]=i=>o.value=i),selectedWidgetData:s.selectedWidgetData,currentWidgetData:s.currentWidgetData,selectedDashboard:s.selectedDashboard,onUpdateData:a[1]||(a[1]=i=>l.$emit("update-data"))},null,8,["selectedWidget","selectedWidgetData","currentWidgetData","selectedDashboard"])])])]))}},xt={__name:"icon-grid",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(hs),e.mergeProps(t.$attrs,{size:24}),null,16))}},kt={__name:"icon-table",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ys),e.mergeProps(t.$attrs,{size:24}),null,16))}},Cn={__name:"icon-more",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ls),e.mergeProps(t.$attrs,{size:24}),null,16))}},Dn=e.defineAsyncComponent(()=>import("@opengis/form")),Nn={components:{VsModal:ne,VForm:Dn,deleteIcon:et,editIcon:tt,IconGrid:xt,IconMore:Cn,IconTable:kt},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(p=>(p==null?void 0:p.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:"Text",key:"table_name",validators:["required"],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",editable:!1,addition:!1,colModel:[{name:"title",ua:"Назва",type:"Text",key:"col"},{name:"type",ua:"Тип",type:"Text",key:"col",disabled:!0},{name:"widget",type:"Text",ua:"Назва",key:"widget",hiddenCol:!0},{name:"col",ua:"Кількість стовпчиків",type:"Text",key:"col"}]}]}},props:{selected:{type:String,default:()=>""},dashboardData:{type:Object,default:()=>{}},selectedWidgetData:{type:Object,default:()=>{}},columns:{type:Array}},methods:{async editDashboard(){var s,t;try{(t=(s=this.$refs)==null?void 0:s.formEdit)==null||t.doValidation(),await T.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 T.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 T.delete(`/bi-dashboard/${this.selected}`);const s=new URL(window.top.location.href);s.searchParams.delete("dashboard"),s.searchParams.delete("widget"),window.history.pushState({},"",s),await this.$notify({title:"Успішно!",type:"success",message:"Дашборд видалено успішно"}),this.isDeleteConfirm=!1,await this.$emit("update:selected",null),await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі видалити дашборд виникла помилка"})}},closePopover(){document.body.click()}}},Sn={key:0,class:"flex items-center gap-4"},zn={class:"h-[30px] w-[30px] flex items-center justify-center"},Ln={class:"flex flex-col items-start -ml-2 -mr-2"},Tn={class:"p-4"},In={class:"flex justify-end mt-4 gap-x-3"},Mn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Pn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function Rn(s,t,r,n,o,l){const a=e.resolveComponent("IconGrid"),i=e.resolveComponent("VsPopover"),c=e.resolveComponent("IconMore"),p=e.resolveComponent("VsModal"),d=e.resolveComponent("VForm");return e.openBlock(),e.createElementBlock("div",null,[r.selected?(e.openBlock(),e.createElementBlock("div",Sn,[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}),e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createVNode(i,{placement:"bottom-left"},{reference:e.withCtx(()=>[e.createElementVNode("button",zn,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",Ln,[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})])):e.createCommentVNode("",!0),e.createVNode(p,{teleport:"#modal",visible:o.isDeleteConfirm,size:"small",title:"Ви впевнені?",onClose:t[5]||(t[5]=h=>o.isDeleteConfirm=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",Tn,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",In,[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(p,{teleport:"#modal",visible:o.isFormEdit,title:"Редагувати дашборд",onClose:t[9]||(t[9]=h=>o.isFormEdit=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Mn,[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(d,{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(p,{teleport:"#modal",visible:o.isFormGrid,title:"Редагувати структуру дашборду",onClose:t[13]||(t[13]=h=>o.isFormGrid=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Pn,[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(d,{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 Fn=D(Nn,[["render",Rn]]),An={class:"flex-1 min-w-0 flex flex-col overflow-auto"},On={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},jn={class:"relative z-10 shrink-0 mt-4 mb-6"},Wn={class:"flex items-center text-sm text-gray-600"},qn={key:0,class:"flex items-center justify-between gap-4 mt-3"},Un={class:"min-w-0"},vn={class:"text-2xl font-bold text-gray-900"},Hn={key:0,class:"mt-1.5 text-sm text-gray-600"},Gn={class:"flex items-center shrink-0"},Zn={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"},Qn=D({__name:"vs-editor",props:{prefix:String,customClass:{type:String,default:()=>"w-screen h-screen"},initialDashboardId:{type:String,default:""}},emits:["back"],setup(s,{emit:t}){const r=s;ge(r.prefix||"/api");const n=t,o=e.inject("biClearDashboard",null),l=e.ref(r.initialDashboardId||""),a=e.ref(""),i=e.ref(null),c=e.ref(null),p=e.ref(null),d=async()=>{if(!l.value){i.value=null;return}try{const f=await T.get(`/bi-dashboard/${l.value}`);i.value=f}catch(f){console.error(f)}},h=e.computed(()=>{var f,m,x;return(x=Array.isArray((f=i.value)==null?void 0:f.widgets)?(m=i.value)==null?void 0:m.widgets:[])==null?void 0:x.find(k=>(k==null?void 0:k.name)===a.value)}),g=e.computed(()=>{var x,k,u,y,b;const m=[o?{label:"Дашборди",onClick:()=>{o(),n("back")}}:{label:"Дашборди",to:"/editor"}];if((x=i.value)!=null&&x.title||l.value){const _=((k=i.value)==null?void 0:k.title)||l.value||"Редактор",$=!!a.value;m.push({label:_,...$?{onClick:()=>{a.value=""}}:{}})}else m.push({label:"Редактор"});if(a.value&&h.value){const _=((y=(u=h.value)==null?void 0:u.data)==null?void 0:y.title)||((b=h.value)==null?void 0:b.title)||a.value;m.push({label:_})}return m});return e.watch(l,(f,m)=>{var k,u,y;m&&(a.value="");const x=new URL(window.top.location.href);f?((k=x==null?void 0:x.searchParams)==null||k.set("dashboard",f),(y=(u=window.top)==null?void 0:u.history)==null||y.pushState({},"",x),d()):(x==null||x.searchParams.delete("dashboard"),x==null||x.searchParams.delete("widget"))}),e.onMounted(()=>{var f,m;if(r.initialDashboardId)l.value=r.initialDashboardId;else{const x=new URLSearchParams(((m=(f=window.top)==null?void 0:f.location)==null?void 0:m.search)||""),k=x.get("dashboard");k&&(l.value=k),a.value=x.get("widget")||""}d()}),(f,m)=>{var x,k;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[s.customClass]])},[e.createElementVNode("div",An,[e.createElementVNode("div",On,[e.createElementVNode("div",jn,[e.createElementVNode("div",Wn,[e.createVNode(Ye,{items:g.value,compact:""},null,8,["items"])]),l.value&&i.value?(e.openBlock(),e.createElementBlock("div",qn,[e.createElementVNode("div",Un,[e.createElementVNode("h1",vn,e.toDisplayString(i.value.title||l.value),1),i.value.description?(e.openBlock(),e.createElementBlock("p",Hn,e.toDisplayString(i.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Gn,[a.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:m[0]||(m[0]=u=>a.value="")},[e.createVNode(e.unref(He),{class:"w-4 h-4"}),m[6]||(m[6]=e.createTextVNode(" Закрити "))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(Fn,{selected:l.value,"onUpdate:selected":m[1]||(m[1]=u=>l.value=u),dashboardData:i.value,columns:(x=i.value)==null?void 0:x.columns,selectedWidgetData:h.value,prefix:s.prefix,onUpdateEditor:d},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[2]||(m[2]=u=>{var y,b;return(b=(y=p.value)==null?void 0:y.open)==null?void 0:b.call(y)})},m[7]||(m[7]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ")])),l.value?(e.openBlock(),e.createBlock(kr,{key:0,ref_key:"createWidgetRef",ref:p,inline:"",columns:(k=i.value)==null?void 0:k.columns,selectedDashboard:l.value,onUpdateData:d},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),a.value&&i.value?(e.openBlock(),e.createBlock(Bn,{key:0,"selected-widget":a.value,"onUpdate:selectedWidget":m[3]||(m[3]=u=>a.value=u),"selected-widget-data":h.value,"current-widget-data":c.value,"selected-dashboard":l.value,"dashboard-widgets":i.value.widgets||[],onUpdateData:d},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",Zn,[i.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(i.value.panels,(u,y)=>{var b;return e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass([`col-span-${u.col||12}`,"flex flex-col gap-[10px]"])},[(b=u.widgets)!=null&&b.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(u.widgets,_=>(e.openBlock(),e.createBlock(re,{onClick:$=>a.value=_,"onUpdate:currentWidgetData":m[4]||(m[4]=$=>c.value=$),key:_,dashboard:l.value,widget:_,selectedWidget:a.value,"dashboard-widgets":i.value.widgets,class:e.normalizeClass({"border border-blue-500":a.value===_})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","class"]))),128)):(e.openBlock(),e.createBlock(re,{key:1,onClick:_=>a.value=u.widget,"onUpdate:currentWidgetData":m[5]||(m[5]=_=>c.value=_),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":a.value===u.widget}]),dashboard:l.value,widget:u.widget,selectedWidget:a.value,"dashboard-widgets":i.value.widgets},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets"]))],2)}),128)):(e.openBlock(),e.createBlock(ye,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-cc75be6a"]]),Xn={class:"w-full h-screen"},Jn=e.defineComponent({__name:"vs-editor-page",props:{prefix:{default:"/api"},dashboardId:{default:""}},emits:["back"],setup(s){const t=s,r=t.prefix,n=t.dashboardId;return(o,l)=>(e.openBlock(),e.createElementBlock("div",Xn,[e.createVNode(Qn,{customClass:"h-full w-full",prefix:e.unref(r),"initial-dashboard-id":e.unref(n),onBack:l[0]||(l[0]=a=>o.$emit("back"))},null,8,["prefix","initial-dashboard-id"])]))}}),Kn={class:"relative group h-full"},Yn={class:"flex items-start gap-3 flex-1 min-h-0"},eo={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},to={class:"flex-1 min-w-0 flex flex-col min-h-0"},so={class:"font-semibold text-gray-900 mb-1 truncate"},ro={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},no={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},oo={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},ao=D({__name:"dashboard-card",props:{title:String,description:String,modified:String,name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function,onOpenView:Function},setup(s){const t=s,r=Ce(),n=e.ref(!1);function o(){var a;t.dashboardRouteName&&(t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):(a=r==null?void 0:r.push)==null||a.call(r,{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",Kn,[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",Yn,[e.createElementVNode("div",eo,[e.createVNode(e.unref(ps),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",to,[e.createElementVNode("h3",so,e.toDisplayString(s.title),1),s.description?(e.openBlock(),e.createElementBlock("p",ro,e.toDisplayString(s.description),1)):(e.openBlock(),e.createElementBlock("p",no,"   ")),s.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",oo,e.toDisplayString(s.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-cde0f33b"]]),lo=[{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:"Text",key:"table_name",validators:["required"],label:"Назва таблиці",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"db",label:"База даних",original:{type:"Text",ua:"Назва",col:8}},{type:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}];function io(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 co={class:"flex-1 bg-gray-50"},po={class:"max-w-7xl mx-auto px-6 py-8"},ho={class:"mb-6"},mo={class:"flex items-center justify-between mb-6"},uo={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},fo={class:"flex items-center space-x-4"},go={class:"flex-1 relative"},bo={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},yo=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(s){const t=e.defineAsyncComponent(()=>import("@opengis/form")),r=io(lo),n=e.ref([]),o=e.ref([]);Ce();const l=e.inject("biSetDashboard"),a=s,i=e.ref(null),c=e.ref(!1),p=e.ref({});async function d(){try{const k=await T.get("/bi-dashboard?type=db"),u=Array.isArray(k==null?void 0:k.rows)?k.rows:[];o.value=u,n.value=u.map(y=>({routeName:String(y.name??""),title:y.title??y.name??"Без назви",description:y.description??null,modified:"-",name:"-"}))}catch(k){console.error("Failed to load dashboards",k),o.value=[],n.value=[]}}async function h(){var u,y,b;const k=(y=(u=e.getCurrentInstance())==null?void 0:u.proxy)==null?void 0:y.$notify;try{const _=(b=i.value)==null?void 0:b.doValidation;typeof _=="function"&&await _(),await T.post("/bi-dashboard",p.value),c.value=!1,p.value={},k==null||k({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),await d()}catch{k==null||k({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}e.onMounted(()=>{ge(a.prefix||"/api"),d()});const g=e.ref(1),f=()=>{const k=window.innerWidth;g.value=k>=1024?3:k>=768?2:1};e.onMounted(()=>{f(),window.addEventListener("resize",f)}),e.onUnmounted(()=>{window.removeEventListener("resize",f)});const m=k=>k?k.trim().length>70?2:1:0,x=k=>{const u=g.value||1,b=Math.floor(k/u)*u,_=b+u,$=n.value.slice(b,_);let w=0;for(const L of $){const P=m(L.description??null);if(P>w&&(w=P),w===2)break}return w};return e.ref("grid"),(k,u)=>(e.openBlock(),e.createElementBlock("div",co,[e.createElementVNode("div",po,[e.createElementVNode("div",ho,[e.createElementVNode("div",mo,[u[5]||(u[5]=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:u[0]||(u[0]=y=>c.value=!0)},[e.createVNode(e.unref(ve),{size:24,class:"w-4 h-4"}),u[4]||(u[4]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(ne,{teleport:"#modal",visible:c.value,title:"Створити дашборд",onClose:u[3]||(u[3]=y=>c.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",uo,[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:u[2]||(u[2]=y=>c.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:h}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:i,schema:e.unref(r),values:p.value,"onUpdate:values":u[1]||(u[1]=y=>p.value=y)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",fo,[e.createElementVNode("div",go,[e.createVNode(e.unref(bs),{size:24,class:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),u[6]||(u[6]=e.createElementVNode("input",{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",value:""},null,-1))])])]),e.createElementVNode("div",bo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(y,b)=>(e.openBlock(),e.createElementBlock("div",{key:b,class:"cursor-pointer h-full"},[e.createVNode(ao,{title:y.title,description:y.description,modified:y.modified,name:y.name,reserveLines:x(b),"dashboard-route-name":y.routeName,"on-open-editor":e.unref(l),"on-open-view":e.unref(l)},null,8,["title","description","modified","name","reserveLines","dashboard-route-name","on-open-editor","on-open-view"])]))),128))])])]))}}),xo=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(s){const t=s,r=e.computed(()=>t.prefix),n=e.ref(""),o=rr();e.onMounted(()=>{var i;const a=(i=o==null?void 0:o.query)==null?void 0:i.dashboard;a!=null&&typeof a=="string"&&(n.value=a.trim())});const l=e.computed(()=>n.value.length>0);return e.provide("biSetDashboard",a=>{n.value=a||""}),e.provide("biClearDashboard",()=>{n.value=""}),e.provide("biSelectedDashboardId",e.readonly(n)),(a,i)=>l.value?(e.openBlock(),e.createBlock(Jn,{key:`editor-${n.value}`,prefix:r.value,"dashboard-id":n.value,onBack:i[0]||(i[0]=c=>n.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock(yo,{key:0,prefix:r.value},null,8,["prefix"]))}});function W(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 ko(s){return Intl.NumberFormat("en").format(s??0)}class wo{static getTooltipOptions(t=!0){return{show:t,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const _o={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function $o(){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=_o){var r;const t={label:{show:s==null?void 0:s.show_label,formatter:(s==null?void 0:s.formatter)??(n=>W(n)),...(s==null?void 0:s.label)||{}},legend:{...(s==null?void 0:s.legend)||{},[((r=s==null?void 0:s.legend)==null?void 0:r.position)||"bottom"]:"0",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 wt(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=>W(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 _t=["#d3c7e6","#bedae3","#f8e9cb","#ff8c8c","#c5d8be","#ffc6c6","#ffc39a","#fff7c5","#d8ffc0","#d4f7ff"];class Ve{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,R={props:["source","style","widget","dashboard","title","currentWidget","widgetData","prefix"],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){var t;try{const r=await T.get(s);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)||{}}catch(r){const n={message:"Дані не знайдено",title:"Помилка!",type:"error",status:400,id:this.widgetName};(r==null?void 0:r.status)=="404"&&(n.status=404,n.message="Дані не знайдено"),(r==null?void 0:r.status)=="400"&&(n.message="Перевірте налаштування або зверніться до адміністратора"),(r==null?void 0:r.status)=="500"&&(n.message="Сталася помилка сервера"),this.$emit("update:widgetData",n)}},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}`},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{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,p;this.widgetInstance&&this.widgetInstance.clear();try{const d=this.$refs.chart,h=ee==null?void 0:ee.init(d);if(!h)return;const g={tooltip:{trigger:"axis",axisPointer:{type:"shadow"},backgroundColor:"transparent",shadowColor:"transparent",padding:[0,0,0,0],borderWidth:0,formatter:f=>{var u;const m=(u=f[0])==null?void 0:u.axisValue;let k=`
162
- <div style="background-color: rgba(255, 255, 255, 0.7)" class="border border-gray-200 text-gray-800 rounded-lg shadow-md dark:bg-neutral-800 dark:border-neutral-700 min-w-28">
184
+ `}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:r,tokens:n}){const o=this.parser.parseInline(n),l=nt(t);if(l===null)return o;t=l;let a='<a href="'+t+'"';return r&&(a+=' title="'+r+'"'),a+=">"+o+"</a>",a}image({href:t,title:r,text:n}){const o=nt(t);if(o===null)return n;t=o;let l=`<img src="${t}" alt="${n}"`;return r&&(l+=` title="${r}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class Pe{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 W{constructor(t){T(this,"options");T(this,"renderer");T(this,"textRenderer");this.options=t||Z,this.options.renderer=this.options.renderer||new $e,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Pe}static parse(t,r){return new W(r).parse(t)}static parseInline(t,r){return new W(r).parseInline(t)}parse(t,r=!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+=`
185
+ `+this.renderer.text(i);r?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,r){r=r||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+=r.text(a);break}case"html":{n+=r.html(a);break}case"link":{n+=r.link(a);break}case"image":{n+=r.image(a);break}case"strong":{n+=r.strong(a);break}case"em":{n+=r.em(a);break}case"codespan":{n+=r.codespan(a);break}case"br":{n+=r.br(a);break}case"del":{n+=r.del(a);break}case"text":{n+=r.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 ie{constructor(t){T(this,"options");T(this,"block");this.options=t||Z}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?j.lex:j.lexInline}provideParser(){return this.block?W.parse:W.parseInline}}T(ie,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class tn{constructor(...t){T(this,"defaults",Ne());T(this,"options",this.setOptions);T(this,"parse",this.parseMarkdown(!0));T(this,"parseInline",this.parseMarkdown(!1));T(this,"Parser",W);T(this,"Renderer",$e);T(this,"TextRenderer",Pe);T(this,"Lexer",j);T(this,"Tokenizer",xe);T(this,"Hooks",ie);this.use(...t)}walkTokens(t,r){var o,l;let n=[];for(const a of t)switch(n=n.concat(r.call(this,a)),a.type){case"table":{const i=a;for(const c of i.header)n=n.concat(this.walkTokens(c.tokens,r));for(const c of i.rows)for(const p of c)n=n.concat(this.walkTokens(p.tokens,r));break}case"list":{const i=a;n=n.concat(this.walkTokens(i.items,r));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 p=i[c].flat(1/0);n=n.concat(this.walkTokens(p,r))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,r)))}}return n}use(...t){const r=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=r.renderers[l.name];a?r.renderers[l.name]=function(...i){let c=l.renderer.apply(this,i);return c===!1&&(c=a.apply(this,i)),c}:r.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=r[l.level];a?a.unshift(l.tokenizer):r[l.level]=[l.tokenizer],l.start&&(l.level==="block"?r.startBlock?r.startBlock.push(l.start):r.startBlock=[l.start]:l.level==="inline"&&(r.startInline?r.startInline.push(l.start):r.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(r.childTokens[l.name]=l.childTokens)}),o.extensions=r),n.renderer){const l=this.defaults.renderer||new $e(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],p=l[i];l[i]=(...d)=>{let h=c.apply(l,d);return h===!1&&(h=p.apply(l,d)),h||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new xe(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],p=l[i];l[i]=(...d)=>{let h=c.apply(l,d);return h===!1&&(h=p.apply(l,d)),h}}o.tokenizer=l}if(n.hooks){const l=this.defaults.hooks||new ie;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],p=l[i];ie.passThroughHooks.has(a)?l[i]=d=>{if(this.defaults.async)return Promise.resolve(c.call(l,d)).then(x=>p.call(l,x));const h=c.call(l,d);return p.call(l,h)}:l[i]=(...d)=>{let h=c.apply(l,d);return h===!1&&(h=p.apply(l,d)),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,r){return j.lex(t,r??this.defaults)}parser(t,r){return W.parse(t,r??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?j.lex:j.lexInline,p=a.hooks?a.hooks.provideParser():t?W.parse:W.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(n):n).then(d=>c(d,a)).then(d=>a.hooks?a.hooks.processAllTokens(d):d).then(d=>a.walkTokens?Promise.all(this.walkTokens(d,a.walkTokens)).then(()=>d):d).then(d=>p(d,a)).then(d=>a.hooks?a.hooks.postprocess(d):d).catch(i);try{a.hooks&&(n=a.hooks.preprocess(n));let d=c(n,a);a.hooks&&(d=a.hooks.processAllTokens(d)),a.walkTokens&&this.walkTokens(d,a.walkTokens);let h=p(d,a);return a.hooks&&(h=a.hooks.postprocess(h)),h}catch(d){return i(d)}}}onError(t,r){return n=>{if(n.message+=`
186
+ 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 Q=new tn;function N(s,t){return Q.parse(s,t)}N.options=N.setOptions=function(s){return Q.setOptions(s),N.defaults=Q.defaults,et(N.defaults),N},N.getDefaults=Ne,N.defaults=Z,N.use=function(...s){return Q.use(...s),N.defaults=Q.defaults,et(N.defaults),N},N.walkTokens=function(s,t){return Q.walkTokens(s,t)},N.parseInline=Q.parseInline,N.Parser=W,N.parser=W.parse,N.Renderer=$e,N.TextRenderer=Pe,N.Lexer=j,N.lexer=j.lex,N.Tokenizer=xe,N.Hooks=ie,N.parse=N,N.options,N.setOptions,N.use,N.walkTokens,N.parseInline,W.parse,j.lex;const sn={class:"space-y-4"},rn={__name:"vs-editor-form-data",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}},columns:{type:Array,default:()=>[]}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){var w,V,_,$,E,C,L,M,v,U,de,pe,he,ue,me,R,G,fe,Ft,Ot,At,jt,Wt,qt,vt,Ut,Ht,Gt,Zt,Qt,Xt,Jt,Kt,Yt,es;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,i=e.ref(null),c=e.ref([]),p=e.computed(()=>{const B=a.columns??[];return B.length?B:c.value}),d=e.computed(()=>a.dashboardId||i.value);async function h(){const B=d.value;if(!(p.value.length||!B||!a.widgetName))try{const D=await P.get(`/bi-data?dashboard=${B}&widget=${a.widgetName}`);Array.isArray(D==null?void 0:D.columns)&&D.columns.length&&(c.value=D.columns)}catch{}}const x=B=>(B==null?void 0:B.name)!=null?{id:B.name,text:B.title||B.name}:null,u=B=>Array.isArray(B)?[...B].sort((D,H)=>{const Y=D.text&&D.text!==D.id,ts=H.text&&H.text!==H.id;return Y&&!ts?-1:!Y&&ts?1:(D.text||"").localeCompare(H.text||"",void 0,{sensitivity:"base"})}):B,m=e.computed(()=>{const B=(p.value??[]).filter(D=>(D==null?void 0:D.type)=="text"||(D==null?void 0:D.type)==="date"||(D==null?void 0:D.type)==="timestamp without time zone"||(D==null?void 0:D.type)==="boolean"||(D==null?void 0:D.type)==="integer").map(x).filter(Boolean);return u(B)}),b=e.computed(()=>`${a.widgetName}-${m.value.length}-${(p.value??[]).length}`),y=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:[...m.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(B=>(B==null?void 0:B.type)==="numeric"||(B==null?void 0:B.type)==="double precision").map(x).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(B=>(B==null?void 0:B.type)=="text"||(B==null?void 0:B.type)==="boolean"||(B==null?void 0:B.type)==="integer").map(x).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Колонки",style:{size:"xs"},options:u((p.value??[]).map(x).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}})),k=e.ref({x:((V=(w=a.data)==null?void 0:w.data)==null?void 0:V.x)||((_=a.data)==null?void 0:_.x)||null,metric:((E=($=a.data)==null?void 0:$.data)==null?void 0:E.metric)||((C=a.data)==null?void 0:C.metric)||null,columns:((M=(L=a.data)==null?void 0:L.data)==null?void 0:M.columns)||((v=a.data)==null?void 0:v.columns)||null,granularity:((de=(U=a.data)==null?void 0:U.data)==null?void 0:de.granularity)||((pe=a.data)==null?void 0:pe.granularity)||null,type:((ue=(he=a.data)==null?void 0:he.data)==null?void 0:ue.type)||((me=a.data)==null?void 0:me.type)||null,groupby:((G=(R=a.data)==null?void 0:R.data)==null?void 0:G.groupby)||a.data.groupby||null,fx:((Ft=(fe=a.data)==null?void 0:fe.data)==null?void 0:Ft.fx)||((Ot=a.data)==null?void 0:Ot.fx)||null,query:((jt=(At=a.data)==null?void 0:At.data)==null?void 0:jt.query)||((Wt=a.data)==null?void 0:Wt.query)||null,y_type:((vt=(qt=a.data)==null?void 0:qt.data)==null?void 0:vt.y_type)||((Ut=a.data)==null?void 0:Ut.y_type)||null,tableSQL:((Gt=(Ht=a.data)==null?void 0:Ht.data)==null?void 0:Gt.tableSQL)||((Zt=a.data)==null?void 0:Zt.tableSQL)||null,cls:((Xt=(Qt=a.data)==null?void 0:Qt.data)==null?void 0:Xt.cls)||((Jt=a.data)==null?void 0:Jt.cls)||null,text:((Yt=(Kt=a.data)==null?void 0:Kt.data)==null?void 0:Yt.text)||((es=a.data)==null?void 0:es.text)||null}),g=async()=>{try{await P.put(`/bi-dashboard/${d.value}/${a.widgetName}`,{data:k.value});let B=`/bi-data?dashboard=${d.value}&widget=${a.widgetName}`;Object.entries(k.value).forEach(([H,Y])=>{B+=`&${H}=${Y}`});const D=new CustomEvent(`update-data-${a.widgetName}`);D.filterUrl=B,window.dispatchEvent(D),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},f=async()=>{try{let B=`/bi-data?dashboard=${d.value}&widget=${a.widgetName}`;Object.entries(k.value).forEach(([H,Y])=>{B+=`&${H}=${Y}`});const D=new CustomEvent(`update-data-${a.widgetName}`);D.filterUrl=B,window.dispatchEvent(D),l("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(k,()=>{f()},{deep:!0}),e.onMounted(()=>{const B=new URLSearchParams(window.top.location.search);i.value=B.get("dashboard"),h()}),e.watch(()=>[a.widgetName,a.dashboardId,i.value],()=>{c.value=[],h()},{immediate:!0}),t({requestUpdateWidget:g}),(B,D)=>(e.openBlock(),e.createElementBlock("div",sn,[(e.openBlock(),e.createBlock(e.unref(n),{key:b.value,schema:y.value,values:k.value,"onUpdate:values":D[0]||(D[0]=H=>k.value=H)},null,8,["schema","values"]))]))}},nn={class:"space-y-4"},on={__name:"vs-editor-form-yaml",props:{yamlValue:{type:null,default:()=>""},widgetName:{type:String},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),{$notify:a}=e.getCurrentInstance().proxy,i=r,c=s,p=(u,{dimensions:m,source:b})=>{const y=u.getOption(),{data:k,...g}=(y==null?void 0:y.series)[0],[,...f]=m||[],w=f.map((V,_)=>({...(y==null?void 0:y.series[_])||{},data:b.map($=>$[_+1]),name:V}));u==null||u.setOption({...y||{},dataset:{dimensions:m,source:b},series:w,xAxis:{type:"category"},yAxis:{}},!0)},d=u=>{const m=document.getElementById(u);if(!m)return null;const b=n==null?void 0:n.getInstanceByDom(m);return b||null},h=e.ref(c.yamlValue),x=async()=>{try{await P.put(`/bi-dashboard/${l.value}/${c.widgetName}`,{yml:h.value});const u=d(c.widgetName);if(u){const m=await P.get(`/bi-data?dashboard=${l.value}&widget=${c.widgetName}`);p(u,m)}i("update-dashboard"),a({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{a({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const u=new URLSearchParams(window.top.location.search);l.value=u.get("dashboard")}),t({requestUpdateWidget:x}),(u,m)=>(e.openBlock(),e.createElementBlock("div",nn,[e.createVNode(e.unref(o),{modelValue:h.value,"onUpdate:modelValue":m[0]||(m[0]=b=>h.value=b),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},an={class:"pt-[10px]"},ft={"vs-editor-form-style":$r,"vs-editor-form-data":rn,"vs-editor-form-yaml":on,"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 d;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:(d=l.columns)==null?void 0:d.map(({name:h})=>h)}},c=e.ref(l.controls||{}),p=async()=>{try{await P.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,x)=>{const u=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",an,[e.createVNode(u,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:p},{default:e.withCtx(()=>[...x[1]||(x[1]=[e.createTextVNode(" Зберегти ",-1)])]),_:1}),e.createVNode(e.unref(r),{schema:i,values:c.value,"onUpdate:values":x[0]||(x[0]=m=>c.value=m)},null,8,["values"])])}}}},ln={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},gt={__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",ln," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(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))}},cn={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},dn={key:0,class:"flex flex-col min-h-0 flex-1"},pn={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},hn={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},un=["onClick"],mn={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},fn={class:"flex items-center gap-1 ml-auto shrink-0"},gn={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"},bn={key:0},yn={key:1},xn={class:"p-4"},kn={class:"flex justify-end mt-4 gap-x-3"},wn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},_n={__name:"vs-editor-forms",props:e.mergeModels({selectedWidgetData:{type:Object,required:!1,default:null},selectedDashboard:{type:String,default:()=>""},currentWidgetData:{type:String,default:()=>""}},{selectedWidget:{},selectedWidgetModifiers:{}}),emits:e.mergeModels(["update-data"],["update:selectedWidget"]),setup(s,{emit:t}){var f,w;const r=e.defineAsyncComponent(()=>import("@opengis/form")),n=(w=(f=e.getCurrentInstance())==null?void 0:f.proxy)==null?void 0:w.$notify,o=t,l=e.ref(null),a=s,i=e.ref(!1),c=e.ref(!0),p=e.ref(!1),d=e.ref({}),h=e.useModel(s,"selectedWidget"),x=["table","text","number","stat","progress","listbar","map","pivot"],u=e.ref("data"),m=async()=>{try{await P.delete(`/bi-dashboard/${a.selectedDashboard}/${a.selectedWidgetData.name}`);const V=new URL(window.top.location.href);V.searchParams.set("dashboard",a.selectedDashboard),V.searchParams.delete("widget"),window.top.history.pushState({},"",V),o("update-data"),i.value=!1,n({type:"success",title:"Успішно!",message:"Віджет успішно видалено"})}catch(V){console.error(V),n({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},b=e.computed(()=>{const V=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return V==null?void 0:V.filter(_=>{var $,E,C;return _.id==="style"?!(x!=null&&x.includes((($=a.selectedWidgetData)==null?void 0:$.type)||((C=(E=a.selectedWidgetData)==null?void 0:E.data)==null?void 0:C.type))):!0})}),y=()=>{var V,_,$,E,C,L,M,v,U;d.value={title:(V=a.selectedWidgetData)==null?void 0:V.title,type:(_=a.selectedWidgetData)==null?void 0:_.type,table:($=a.selectedWidgetData)==null?void 0:$.table_name,query:(C=(E=a.selectedWidgetData)==null?void 0:E.data)==null?void 0:C.query,x:(M=(L=a.selectedWidgetData)==null?void 0:L.data)==null?void 0:M.x,cls:(U=(v=a.selectedWidgetData)==null?void 0:v.data)==null?void 0:U.cls},p.value=!0},k=async()=>{try{await P.put(`/bi-dashboard/${a.selectedDashboard}/${a.selectedWidgetData.name}`,d.value),n({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await o("update-data"),p.value=!1}catch{n({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(h,V=>{c.value=!1;const _=new URL(window.top.location.href);V?(_.searchParams.set("widget",V),window.top.history.pushState({},"",_)):(_.searchParams.delete("widget"),window.top.history.pushState({},"",_)),setTimeout(()=>c.value=!0)});const g={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(V,_)=>{var E,C,L,M,v,U,de,pe,he,ue,me;const $=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",cn,[s.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",dn,[e.createElementVNode("div",pn,[e.createElementVNode("nav",hn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.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",u.value===R.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:G=>u.value=R.id},[e.createTextVNode(e.toDisplayString(R.label)+" ",1),u.value===R.id?(e.openBlock(),e.createElementBlock("span",mn)):e.createCommentVNode("",!0)],10,un))),128))]),e.createElementVNode("div",fn,[e.createVNode($,{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:_[0]||(_[0]=R=>{var G,fe;return(fe=(G=l.value)==null?void 0:G.save)==null?void 0:fe.call(G)})},[e.createVNode(e.unref(bs),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[_[9]||(_[9]=e.createTextVNode(" Зберегти ",-1))]),_:1}),e.createVNode($,{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},[e.createVNode(Ye,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[_[10]||(_[10]=e.createTextVNode(" Редагувати віджет ",-1))]),_:1}),e.createVNode($,{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:_[1]||(_[1]=R=>i.value=!0)},[e.createVNode(e.unref(Ke),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[_[11]||(_[11]=e.createTextVNode(" Видалити віджет ",-1))]),_:1})])]),(E=s.currentWidgetData)!=null&&E.status?(e.openBlock(),e.createBlock(ye,{key:0,title:(C=s.currentWidgetData)==null?void 0:C.title,text:(L=s.currentWidgetData)==null?void 0:L.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",gn,[c.value&&s.currentWidgetData?(e.openBlock(),e.createElementBlock("div",bn,[e.createVNode(gt,{ref_key:"tabPanelRef",ref:l,"tab-key":u.value,"tab-component":e.unref(ft)["vs-editor-form-"+u.value],widgetName:(M=s.selectedWidgetData)==null?void 0:M.name,dashboardId:s.selectedDashboard,yamlValue:((v=s.selectedWidgetData)==null?void 0:v.yml)||"",data:s.selectedWidgetData,controls:(U=s.selectedWidgetData)==null?void 0:U.controls,columns:(de=s.currentWidgetData)==null?void 0:de.columns,onUpdateDashboard:_[2]||(_[2]=R=>V.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",yn,[e.createVNode(gt,{ref_key:"tabPanelRef",ref:l,"tab-key":u.value,"tab-component":e.unref(ft)["vs-editor-form-"+u.value],widgetName:(pe=s.selectedWidgetData)==null?void 0:pe.name,dashboardId:s.selectedDashboard,yamlValue:((he=s.selectedWidgetData)==null?void 0:he.yml)||"",data:s.selectedWidgetData,controls:(ue=s.selectedWidgetData)==null?void 0:ue.controls,columns:(me=s.currentWidgetData)==null?void 0:me.columns,onUpdateDashboard:_[3]||(_[3]=R=>V.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(se,{teleport:"#modal",visible:i.value,title:"Ви впевнені?",onClose:_[5]||(_[5]=R=>i.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",xn,[_[12]||(_[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",kn,[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:_[4]||(_[4]=R=>i.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:m}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(ye,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(se,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:_[8]||(_[8]=R=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",wn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:_[7]||(_[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:k,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(()=>[g?(e.openBlock(),e.createBlock(e.unref(r),{key:0,schema:g,values:d.value,"onUpdate:values":_[6]||(_[6]=R=>d.value=R)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},$n={class:"overflow-hidden flex flex-col min-h-[480px]"},Vn={class:"flex-1 flex min-h-0 gap-4"},En={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},Bn={class:"w-[400px] shrink-0 flex flex-col"},Cn={__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.computed({get:()=>r.selectedWidget,set:l=>n("update:selectedWidget",l)});return(l,a)=>(e.openBlock(),e.createElementBlock("div",$n,[e.createElementVNode("div",Vn,[e.createElementVNode("div",En,[e.createVNode(te,{dashboard:s.selectedDashboard,widget:s.selectedWidget,"selected-widget":s.selectedWidget,"dashboard-widgets":s.dashboardWidgets,"filter-u-rl":void 0,class:"max-h-full"},null,8,["dashboard","widget","selected-widget","dashboard-widgets"])]),e.createElementVNode("div",Bn,[e.createVNode(_n,{selectedWidget:o.value,"onUpdate:selectedWidget":a[0]||(a[0]=i=>o.value=i),selectedWidgetData:s.selectedWidgetData,currentWidgetData:s.currentWidgetData,selectedDashboard:s.selectedDashboard,onUpdateData:a[1]||(a[1]=i=>l.$emit("update-data"))},null,8,["selectedWidget","selectedWidgetData","currentWidgetData","selectedDashboard"])])])]))}},bt={__name:"icon-grid",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(us),e.mergeProps(t.$attrs,{size:24}),null,16))}},yt={__name:"icon-table",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(xs),e.mergeProps(t.$attrs,{size:24}),null,16))}},Dn={__name:"icon-more",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(is),e.mergeProps(t.$attrs,{size:24}),null,16))}},Nn=e.defineAsyncComponent(()=>import("@opengis/form")),Sn={components:{VsModal:se,VForm:Nn,deleteIcon:Ke,editIcon:Ye,IconGrid:bt,IconMore:Dn,IconTable:yt},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(p=>(p==null?void 0:p.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:"Text",key:"table_name",validators:["required"],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 P.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 P.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 P.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()}}},zn={key:0,class:"flex items-center gap-4"},Ln={class:"h-[30px] w-[30px] flex items-center justify-center"},Tn={class:"flex flex-col items-start -ml-2 -mr-2"},In={class:"p-4"},Mn={class:"flex justify-end mt-4 gap-x-3"},Pn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Rn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function Fn(s,t,r,n,o,l){const a=e.resolveComponent("IconGrid"),i=e.resolveComponent("VsPopover"),c=e.resolveComponent("IconMore"),p=e.resolveComponent("VsModal"),d=e.resolveComponent("VForm");return e.openBlock(),e.createElementBlock("div",null,[r.selected?(e.openBlock(),e.createElementBlock("div",zn,[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",Ln,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",Tn,[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(p,{teleport:"#modal",visible:o.isDeleteConfirm,size:"small",title:"Ви впевнені?",onClose:t[5]||(t[5]=h=>o.isDeleteConfirm=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",In,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",Mn,[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(p,{teleport:"#modal",visible:o.isFormEdit,title:"Редагувати дашборд",onClose:t[9]||(t[9]=h=>o.isFormEdit=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Pn,[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(d,{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(p,{teleport:"#modal",visible:o.isFormGrid,title:"Редагувати структуру дашборду",onClose:t[13]||(t[13]=h=>o.isFormGrid=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Rn,[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(d,{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 On=S(Sn,[["render",Fn]]),An={class:"flex-1 min-w-0 flex flex-col overflow-auto"},jn={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},Wn={class:"relative z-10 shrink-0 mt-4 mb-6"},qn={class:"flex items-center text-sm text-gray-600"},vn={key:0,class:"flex items-center justify-between gap-4 mt-3"},Un={class:"min-w-0"},Hn={class:"text-2xl font-bold text-gray-900"},Gn={key:0,class:"mt-1.5 text-sm text-gray-600"},Zn={class:"flex items-center shrink-0"},Qn={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"},Xn=S({__name:"vs-editor",props:{prefix:String,customClass:{type:String,default:()=>"w-screen h-screen"},initialDashboardId:{type:String,default:""}},emits:["back"],setup(s,{emit:t}){const r=s;ge(r.prefix||"/api");const n=t,o=e.inject("biClearDashboard",null),l=e.ref(r.initialDashboardId||""),a=e.ref(""),i=e.ref(null),c=e.ref(null),p=e.ref(null),d=async()=>{if(!l.value){i.value=null;return}try{const u=await P.get(`/bi-dashboard/${l.value}`);i.value=u}catch(u){console.error(u)}},h=e.computed(()=>{var u,m,b;return(b=Array.isArray((u=i.value)==null?void 0:u.widgets)?(m=i.value)==null?void 0:m.widgets:[])==null?void 0:b.find(y=>(y==null?void 0:y.name)===a.value)}),x=e.computed(()=>{var b,y,k,g,f;const m=[o?{label:"Дашборди",onClick:()=>{o(),n("back")}}:{label:"Дашборди",to:"/editor"}];if((b=i.value)!=null&&b.title||l.value){const w=((y=i.value)==null?void 0:y.title)||l.value||"Редактор",V=!!a.value;m.push({label:w,...V?{onClick:()=>{a.value=""}}:{}})}else m.push({label:"Редактор"});if(a.value&&h.value){const w=((g=(k=h.value)==null?void 0:k.data)==null?void 0:g.title)||((f=h.value)==null?void 0:f.title)||a.value;m.push({label:w})}return m});return e.watch(l,(u,m)=>{var y,k,g,f,w;m&&(a.value="");const b=new URL(window.top.location.href);u?((y=b==null?void 0:b.searchParams)==null||y.set("dashboard",u),(g=(k=window.top)==null?void 0:k.history)==null||g.pushState({},"",b),d()):(b==null||b.searchParams.delete("dashboard"),b==null||b.searchParams.delete("widget"),(w=(f=window.top)==null?void 0:f.history)==null||w.pushState({},"",b),i.value=null,typeof o=="function"?o():n("back"))}),e.onMounted(()=>{var u,m;if(r.initialDashboardId)l.value=r.initialDashboardId;else{const b=new URLSearchParams(((m=(u=window.top)==null?void 0:u.location)==null?void 0:m.search)||""),y=b.get("dashboard");y&&(l.value=y),a.value=b.get("widget")||""}d()}),(u,m)=>{var b,y;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[s.customClass]])},[e.createElementVNode("div",An,[e.createElementVNode("div",jn,[e.createElementVNode("div",Wn,[e.createElementVNode("div",qn,[e.createVNode(Je,{items:x.value,compact:""},null,8,["items"])]),l.value&&i.value?(e.openBlock(),e.createElementBlock("div",vn,[e.createElementVNode("div",Un,[e.createElementVNode("h1",Hn,e.toDisplayString(i.value.title||l.value),1),i.value.description?(e.openBlock(),e.createElementBlock("p",Gn,e.toDisplayString(i.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Zn,[a.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:m[0]||(m[0]=k=>a.value="")},[e.createVNode(e.unref(Ge),{class:"w-4 h-4"}),m[6]||(m[6]=e.createTextVNode(" Закрити ",-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(On,{selected:l.value,"onUpdate:selected":m[1]||(m[1]=k=>l.value=k),dashboardData:i.value,columns:(b=i.value)==null?void 0:b.columns,selectedWidgetData:h.value,prefix:s.prefix,onUpdateEditor:d},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[2]||(m[2]=k=>{var g,f;return(f=(g=p.value)==null?void 0:g.open)==null?void 0:f.call(g)})},[...m[7]||(m[7]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ",-1)])]),l.value?(e.openBlock(),e.createBlock(wr,{key:0,ref_key:"createWidgetRef",ref:p,inline:"",columns:(y=i.value)==null?void 0:y.columns,selectedDashboard:l.value,onUpdateData:d},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),a.value&&i.value?(e.openBlock(),e.createBlock(Cn,{key:0,"selected-widget":a.value,"onUpdate:selectedWidget":m[3]||(m[3]=k=>a.value=k),"selected-widget-data":h.value,"current-widget-data":c.value,"selected-dashboard":l.value,"dashboard-widgets":i.value.widgets||[],onUpdateData:d},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",Qn,[i.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(i.value.panels,(k,g)=>{var f;return e.openBlock(),e.createElementBlock("div",{key:g,class:e.normalizeClass([`md:col-span-${k.col||12} col-span-12`,"flex flex-col gap-[10px]"])},[(f=k.widgets)!=null&&f.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(k.widgets,w=>(e.openBlock(),e.createBlock(te,{onClick:V=>a.value=w,"onUpdate:currentWidgetData":m[4]||(m[4]=V=>c.value=V),key:w,dashboard:l.value,widget:w,selectedWidget:a.value,"dashboard-widgets":i.value.widgets,height:Number(k.height??480),class:e.normalizeClass({"border border-blue-500":a.value===w})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","height","class"]))),128)):(e.openBlock(),e.createBlock(te,{key:1,onClick:w=>a.value=k.widget,"onUpdate:currentWidgetData":m[5]||(m[5]=w=>c.value=w),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":a.value===k.widget}]),dashboard:l.value,widget:k.widget,selectedWidget:a.value,"dashboard-widgets":i.value.widgets,height:Number(k.height??480)},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets","height"]))],2)}),128)):(e.openBlock(),e.createBlock(ye,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-f1be901f"]]),Jn={class:"w-full h-screen"},Kn=e.defineComponent({__name:"vs-editor-page",props:{prefix:{default:"/api"},dashboardId:{default:""}},emits:["back"],setup(s){const t=s,r=t.prefix,n=t.dashboardId;return(o,l)=>(e.openBlock(),e.createElementBlock("div",Jn,[e.createVNode(Xn,{customClass:"h-full w-full",prefix:e.unref(r),"initial-dashboard-id":e.unref(n),onBack:l[0]||(l[0]=a=>o.$emit("back"))},null,8,["prefix","initial-dashboard-id"])]))}}),Yn={class:"relative group h-full"},eo={class:"flex items-start gap-3 flex-1 min-h-0"},to={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},so={class:"flex-1 min-w-0 flex flex-col min-h-0"},ro={class:"font-semibold text-gray-900 mb-1 truncate"},no={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},oo={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},ao={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},lo=S({__name:"dashboard-card",props:{title:String,description:String,modified:String,name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function,onOpenView:Function},setup(s){const t=s,r=Ce(),n=e.ref(!1);function o(){var a;t.dashboardRouteName&&(t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):(a=r==null?void 0:r.push)==null||a.call(r,{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",Yn,[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",eo,[e.createElementVNode("div",to,[e.createVNode(e.unref(hs),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",so,[e.createElementVNode("h3",ro,e.toDisplayString(s.title),1),s.description?(e.openBlock(),e.createElementBlock("p",no,e.toDisplayString(s.description),1)):(e.openBlock(),e.createElementBlock("p",oo,"   ")),s.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",ao,e.toDisplayString(s.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-cde0f33b"]]),io=[{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:"Text",key:"table_name",validators:["required"],label:"Назва таблиці",original:{type:"Text",ua:"Назва",col:8}},{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 co(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 po={class:"flex-1 bg-gray-50"},ho={class:"max-w-7xl mx-auto px-6 py-8"},uo={class:"mb-6"},mo={class:"flex items-center justify-between mb-6"},fo={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},go={class:"flex items-center space-x-4"},bo={class:"flex-1 relative"},yo={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},xo=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(s){const t=e.defineAsyncComponent(()=>import("@opengis/form")),r=co(io),n=e.ref([]),o=e.ref([]);Ce();const l=e.inject("biSetDashboard"),a=s,i=e.ref(null),c=e.ref(!1),p=e.ref({});async function d(){try{const y=await P.get("/bi-dashboard?type=db"),k=Array.isArray(y==null?void 0:y.rows)?y.rows:[];o.value=k,n.value=k.map(g=>({routeName:String(g.name??""),title:g.title??g.name??"Без назви",description:g.description??null,modified:"-",name:"-"}))}catch(y){console.error("Failed to load dashboards",y),o.value=[],n.value=[]}}async function h(){var k,g,f;const y=(g=(k=e.getCurrentInstance())==null?void 0:k.proxy)==null?void 0:g.$notify;try{const w=(f=i.value)==null?void 0:f.validate();typeof w=="function"&&await w();const{name:V,title:_,table_name:$}=p.value;if(!V||!_||!$){y==null||y({type:"error",title:"Помилка!",message:"Заповніть усі обов'язкові поля"});return}await P.post("/bi-dashboard",p.value),c.value=!1,p.value={},y==null||y({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),l?l(V):await d()}catch{y==null||y({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}e.onMounted(()=>{ge(a.prefix||"/api"),d()});const x=e.ref(1),u=()=>{const y=window.innerWidth;x.value=y>=1024?3:y>=768?2:1};e.onMounted(()=>{u(),window.addEventListener("resize",u)}),e.onUnmounted(()=>{window.removeEventListener("resize",u)});const m=y=>y?y.trim().length>70?2:1:0,b=y=>{const k=x.value||1,f=Math.floor(y/k)*k,w=f+k,V=n.value.slice(f,w);let _=0;for(const $ of V){const E=m($.description??null);if(E>_&&(_=E),_===2)break}return _};return e.ref("grid"),(y,k)=>(e.openBlock(),e.createElementBlock("div",po,[e.createElementVNode("div",ho,[e.createElementVNode("div",uo,[e.createElementVNode("div",mo,[k[5]||(k[5]=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:k[0]||(k[0]=g=>c.value=!0)},[e.createVNode(e.unref(He),{size:24,class:"w-4 h-4"}),k[4]||(k[4]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(se,{teleport:"#modal",visible:c.value,title:"Створити дашборд",onClose:k[3]||(k[3]=g=>c.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",fo,[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:k[2]||(k[2]=g=>c.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:h}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:i,schema:e.unref(r),values:p.value,"onUpdate:values":k[1]||(k[1]=g=>p.value=g)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",go,[e.createElementVNode("div",bo,[e.createVNode(e.unref(ys),{size:24,class:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),k[6]||(k[6]=e.createElementVNode("input",{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",value:""},null,-1))])])]),e.createElementVNode("div",yo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(g,f)=>(e.openBlock(),e.createElementBlock("div",{key:f,class:"cursor-pointer h-full"},[e.createVNode(lo,{title:g.title,description:g.description,modified:g.modified,name:g.name,reserveLines:b(f),"dashboard-route-name":g.routeName,"on-open-editor":e.unref(l),"on-open-view":e.unref(l)},null,8,["title","description","modified","name","reserveLines","dashboard-route-name","on-open-editor","on-open-view"])]))),128))])])]))}}),ko=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(s){const t=s,r=e.computed(()=>t.prefix),n=e.ref(""),o=nr();e.onMounted(()=>{var i;const a=(i=o==null?void 0:o.query)==null?void 0:i.dashboard;a!=null&&typeof a=="string"&&(n.value=a.trim())});const l=e.computed(()=>n.value.length>0);return e.provide("biSetDashboard",a=>{n.value=a||""}),e.provide("biClearDashboard",()=>{n.value=""}),e.provide("biSelectedDashboardId",e.readonly(n)),(a,i)=>l.value?(e.openBlock(),e.createBlock(Kn,{key:`editor-${n.value}`,prefix:r.value,"dashboard-id":n.value,onBack:i[0]||(i[0]=c=>n.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock(xo,{key:0,prefix:r.value},null,8,["prefix"]))}});function q(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 ce(s){if(!(s!=null&&s.includes("T")))return s??"";const[t,r,n]=s.split("T")[0].split("-");return`${n}.${r}.${t}`}function wo(s){return Intl.NumberFormat("en").format(s??0)}class _o{static getTooltipOptions(t=!0){return{show:t,confine:!0,appendToBody:!1,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const $o={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function Vo(){const s="0123456789ABCDEF";let t="#";for(let r=0;r<6;r+=1)t+=s[Math.floor(Math.random()*16)];return t}function X(s=$o){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=>q(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 xt(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=>q(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 kt=["#d3c7e6","#bedae3","#f8e9cb","#ff8c8c","#c5d8be","#ffc6c6","#ffc39a","#fff7c5","#d8ffc0","#d4f7ff"];class Ve{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 K=typeof window<"u"?window.echarts:null,O={props:["source","style","widget","dashboard","title","currentWidget","widgetData","prefix"],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){var t;try{const r=await P.get(s);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)||{}}catch(r){const n={message:"Дані не знайдено",title:"Помилка!",type:"error",status:400,id:this.widgetName};(r==null?void 0:r.status)=="404"&&(n.status=404,n.message="Дані не знайдено"),(r==null?void 0:r.status)=="400"&&(n.message="Перевірте налаштування або зверніться до адміністратора"),(r==null?void 0:r.status)=="500"&&(n.message="Сталася помилка сервера"),this.$emit("update:widgetData",n)}},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}`},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{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,p,d,h;this.widgetInstance&&this.widgetInstance.clear();try{const x=this.$refs.chart,u=K==null?void 0:K.init(x);if(!u)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:(b,y,k,g,f)=>{const[w,V]=b,[_,$]=f.contentSize,[E,C]=f.viewSize;let L=w+14,M=V-$/2;return L+_>E&&(L=w-_-14),L<0&&(L=0),M+$>C&&(M=C-$),M<0&&(M=0),[L,M]},formatter:b=>{var $;const k=($=b[0])==null?void 0:$.axisValue,g=k?this.formatDate(k):"N/A",f=[...b].filter(E=>{var C;return parseFloat(E==null?void 0:E.data)||((C=E==null?void 0:E.data)==null?void 0:C.value)}).sort((E,C)=>{var v,U;const L=parseFloat(((v=E==null?void 0:E.data)==null?void 0:v.value)??(E==null?void 0:E.data))||0;return(parseFloat(((U=C==null?void 0:C.data)==null?void 0:U.value)??(C==null?void 0:C.data))||0)-L}),w=f.slice(0,8),V=f.length-w.length;let _=`
187
+ <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">
163
188
  <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">
164
- ${m?this.formatDate(m):"N/A"}
189
+ ${g}
165
190
  </div>
166
- `;return f.forEach(y=>{k+=`
191
+ `;return w.forEach(E=>{_+=`
167
192
  <div class="flex justify-between items-center text-xs px-2 py-0.5 text-gray-500 dark:text-neutral-400">
168
193
  <span class="flex items-center">
169
- <span class="w-2.5 h-2.5 me-1.5 rounded-sm" style="background-color: ${y.color};"></span>
170
- <span class="font-medium mr-[6px]">${(y==null?void 0:y.seriesName)==="metric"?"Значення":y==null?void 0:y.seriesName}</span>
194
+ <span class="w-2.5 h-2.5 me-1.5 rounded-sm" style="background-color: ${E.color};"></span>
195
+ <span class="font-medium mr-[6px]">${(E==null?void 0:E.seriesName)==="metric"?"Значення":E==null?void 0:E.seriesName}</span>
171
196
  </span>
172
- <span>${this.getMetricValue(y==null?void 0:y.data)}</span>
197
+ <span>${this.getMetricValue(E==null?void 0:E.data)}</span>
173
198
  </div>
174
- `}),k+="</div>",k}},xAxis:{data:t!=null&&t.length?t:null,type:t?"category":"value",name:((o=(n=this.styleData)==null?void 0:n.x_axis)==null?void 0:o.name)||"",axisLabel:{...wt((l=this.styleData)==null?void 0:l.x_axis),formatter:f=>{var x,k;const m=this.formatDate(f);return((k=(x=this.styleData)==null?void 0:x.x_axis)==null?void 0:k.overflow)==="ellipsis"&&m.length>10?`${m.slice(0,10)}...`:m}}},yAxis:{data:r!=null&&r.length?r:null,type:r?"category":"value",name:((i=(a=this.styleData)==null?void 0:a.y_axis)==null?void 0:i.name)||"",axisLabel:wt((c=this.styleData)==null?void 0:c.y_axis)},series:s!=null&&s.length?s:null,...Y(this.styleData),grid:{bottom:"0%",right:"0%",left:"0%",top:"20px",containLabel:!0,...((p=this.styleData)==null?void 0:p.grid)||{}}};await h.setOption(g),h.resize(),this.widgetInstance=h,this.$emit("update:currentWidget",h)}catch(d){console.error(d)}},async setSeriesOption(s,t){const r=s.getOption(),{series:n=[]}=r,o=n.map(l=>({...l,...t}));s.setOption({...r,series:o})},async changeOptionsByName(s,t){const r=document.getElementById(s);if(!r)return null;const n=ee==null?void 0:ee.getInstanceByDom(r);if(!n)return null;const o=n.getOption();t.seriesOptions&&this.setSeriesOption(n,t.seriesOptions),n.setOption({...o,...t.options,tooltip:{...wo.getTooltipOptions(t.options.tooltip.show)}})},async changeData(s){var t;try{let r=this.dashboard?`${this.prefix||""}/bi-data?dashboard=${this.dashboard}&widget=${this.widget}`:`${this.prefix||""}/bi-data?&widget=${this.widget}`;(t=s==null?void 0:s.granularity)!=null&&t.length&&(r+=`&granularity=${s.granularity}`),s!=null&&s.metrics&&(r+=`&metrics=${s.metrics}`),this.getDataFromURL(r)}catch(r){console.error(r)}},async setFilter(s){const t=`${this.prefix||""}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}${s||""}`;await this.getDataFromURL(t)},async changeStyle(s,t){this.styleData[s]=t,this.onChangedData()},getMetricValue(s){var n;const t=(s==null?void 0:s.metric)||s;return parseFloat(t)?(n=W(t,{notation:"standard"}))==null?void 0:n.replaceAll(","," "):t}}},Vo={name:"VsBar",mixins:[R],data(){return{resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var t;this.getData(),this.onChangedData();const s=(t=this.$refs)==null?void 0:t.chart;s&&(this.resizeObserver=new ResizeObserver(()=>{var r;this.widgetInstance&&((r=this.widgetInstance)==null||r.resize())}),this.resizeObserver.observe(s))},unmounted(){this.resizeObserver.disconnect()},methods:{async onChangedData(){try{if(this.sourceData){await this.$nextTick();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,r,n,o,l;try{if(!((s=this.sourceData)!=null&&s.length))return{series:[],xs:[],ys:void 0};const a=Array.from(new Set(this.sourceData.filter(g=>g[this.dimensions[0]]).map(g=>g[this.dimensions[0]])));let i;this.dimensions[0].includes("date")?i=a.map(g=>pe(g)):i=[...a];let c,p;((t=this.styleData)==null?void 0:t.horizontal)===!0?p=[...i]:c=[...i];const d=this.sourceData.filter(g=>parseFloat(g[this.dimensions[1]])&&g[this.dimensions[0]]).map(g=>parseFloat(g[this.dimensions[1]]));let h;return((r=this.styleData)==null?void 0:r.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(d):((l=this.styleData)==null?void 0:l.accumulative)===!0?h=this.prepareAccumulative(d):h=this.dimensions.slice(1).map((f,m)=>({name:f,type:"bar",stack:`a${m}`,data:this.sourceData.filter(x=>parseFloat(x[f])&&f).map(x=>parseFloat(x[f]))})),{series:h,xs:c,ys:p}}catch(a){return console.error(a),{series:[],xs:[],ys:[]}}},prepareWaterfallData(s){let t=s.reduce((l,a)=>l+a,0);const r=[t,...s],n=r.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:r}]},prepareStackData(){return this.dimensions.slice(1).map(r=>({name:r,type:"bar",stack:"a",data:this.sourceData.filter(n=>parseFloat(n[r])&&r).map(n=>parseFloat(n[r]))}))},prepareNegativeWaterfall(){const s=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 r=0;const n=s.map((l,a)=>{const i=r;return r+=Number.isNaN(l)?0:l,a===0&&(r-=Number.isNaN(t[a])?0:t[a]),r-=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:s},{name:this.dimensions[2],type:"bar",stack:"a",data:t}]},prepareAccumulative(s){let t=0;const r=s.map(o=>(t+=o,t));return[{name:this.titleCharts,type:"bar",stack:"Total",data:r}]}}},Eo=["id"];function Bo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full w-full min-h-[200px]"},null,8,Eo)}const Re=D(Vo,[["render",Bo]]),Co=Object.freeze(Object.defineProperty({__proto__:null,default:Re},Symbol.toStringTag,{value:"Module"}));var $t=(s=>(s.Dashboard="/dashboard",s.BiPlatform="/bi-platform",s.EditorBase="/editor",s.AllDashboards="/dashboards",s.DashboardByName="/dashboards/:name",s))($t||{}),Vt;(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={}))})(Vt||(Vt={}));var Et=(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",s.Editordetails="editordetails",s.Dbtables="dbtables",s.Biviewer="biviewer",s.Biviewerinner="biviewerinner",s.Bieditor="bieditor",s.Bieditorinner="bieditorinner",s))(Et||{});const Fe=typeof window<"u"?window.echarts:null,Do={name:"VsPie",props:["currentWidget"],mixins:[R],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var r;await this.$nextTick(),await this.getData();const{series:s}=this.prepareData()||{};s&&this.initChart(s);const t=(r=this.$refs)==null?void 0:r.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},beforeUnmount(){var s;(s=this.resizeObserver)==null||s.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&this.initChart(s,t,r)}}catch(s){console.error(s)}},buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
199
+ `}),V>0&&(_+=`
200
+ <div class="text-xs px-2 py-0.5 text-gray-400 dark:text-neutral-500">
201
+ ... ще ${V}
202
+ </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:{...xt((i=this.styleData)==null?void 0:i.x_axis),formatter:b=>{var k,g;const y=this.formatDate(b);return((g=(k=this.styleData)==null?void 0:k.x_axis)==null?void 0:g.overflow)==="ellipsis"&&y.length>10?`${y.slice(0,10)}...`:y}}},yAxis:{data:r!=null&&r.length?r:null,type:r?"category":"value",name:((p=(c=this.styleData)==null?void 0:c.y_axis)==null?void 0:p.name)||"",axisLabel:xt((d=this.styleData)==null?void 0:d.y_axis)},series:s!=null&&s.length?s:null,...X(this.styleData),grid:{bottom:"0%",right:"0%",left:"0%",top:"20px",containLabel:!0,...((h=this.styleData)==null?void 0:h.grid)||{}}};await u.setOption(m),u.resize(),this.widgetInstance=u,this.$emit("update:currentWidget",u)}catch(x){console.error(x)}},async setSeriesOption(s,t){const r=s.getOption(),{series:n=[]}=r,o=n.map(l=>({...l,...t}));s.setOption({...r,series:o})},async changeOptionsByName(s,t){const r=document.getElementById(s);if(!r)return null;const n=K==null?void 0:K.getInstanceByDom(r);if(!n)return null;const o=n.getOption();t.seriesOptions&&this.setSeriesOption(n,t.seriesOptions),n.setOption({...o,...t.options,tooltip:{..._o.getTooltipOptions(t.options.tooltip.show)}})},async changeData(s){var t;try{let r=this.dashboard?`${this.prefix||""}/bi-data?dashboard=${this.dashboard}&widget=${this.widget}`:`${this.prefix||""}/bi-data?&widget=${this.widget}`;(t=s==null?void 0:s.granularity)!=null&&t.length&&(r+=`&granularity=${s.granularity}`),s!=null&&s.metrics&&(r+=`&metrics=${s.metrics}`),this.getDataFromURL(r)}catch(r){console.error(r)}},async setFilter(s){const t=`${this.prefix||""}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}${s||""}`;await this.getDataFromURL(t)},async changeStyle(s,t){this.styleData[s]=t,this.onChangedData()},getMetricValue(s){var n;const t=(s==null?void 0:s.metric)||s;return parseFloat(t)?(n=q(t,{notation:"standard"}))==null?void 0:n.replaceAll(","," "):t}}},Eo={name:"VsBar",mixins:[O],data(){return{resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var t;this.getData(),this.onChangedData();const s=(t=this.$refs)==null?void 0:t.chart;s&&(this.resizeObserver=new ResizeObserver(()=>{var r;this.widgetInstance&&((r=this.widgetInstance)==null||r.resize())}),this.resizeObserver.observe(s))},unmounted(){this.resizeObserver.disconnect()},methods:{async onChangedData(){try{if(this.sourceData){await this.$nextTick();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,r,n,o,l;try{if(!((s=this.sourceData)!=null&&s.length))return{series:[],xs:[],ys:void 0};const a=Array.from(new Set(this.sourceData.filter(x=>x[this.dimensions[0]]).map(x=>x[this.dimensions[0]])));let i;this.dimensions[0].includes("date")?i=a.map(x=>ce(x)):i=[...a];let c,p;((t=this.styleData)==null?void 0:t.horizontal)===!0?p=[...i]:c=[...i];const d=this.sourceData.filter(x=>parseFloat(x[this.dimensions[1]])&&x[this.dimensions[0]]).map(x=>parseFloat(x[this.dimensions[1]]));let h;return((r=this.styleData)==null?void 0:r.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(d):((l=this.styleData)==null?void 0:l.accumulative)===!0?h=this.prepareAccumulative(d):h=this.dimensions.slice(1).map((u,m)=>({name:u,type:"bar",stack:`a${m}`,data:this.sourceData.filter(b=>parseFloat(b[u])&&u).map(b=>parseFloat(b[u]))})),{series:h,xs:c,ys:p}}catch(a){return console.error(a),{series:[],xs:[],ys:[]}}},prepareWaterfallData(s){let t=s.reduce((l,a)=>l+a,0);const r=[t,...s],n=r.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:r}]},prepareStackData(){return this.dimensions.slice(1).map(r=>({name:r,type:"bar",stack:"a",data:this.sourceData.filter(n=>parseFloat(n[r])&&r).map(n=>parseFloat(n[r]))}))},prepareNegativeWaterfall(){const s=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 r=0;const n=s.map((l,a)=>{const i=r;return r+=Number.isNaN(l)?0:l,a===0&&(r-=Number.isNaN(t[a])?0:t[a]),r-=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:s},{name:this.dimensions[2],type:"bar",stack:"a",data:t}]},prepareAccumulative(s){let t=0;const r=s.map(o=>(t+=o,t));return[{name:this.titleCharts,type:"bar",stack:"Total",data:r}]}}},Bo=["id"];function Co(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full w-full min-h-[200px]"},null,8,Bo)}const Re=S(Eo,[["render",Co]]),Do=Object.freeze(Object.defineProperty({__proto__:null,default:Re},Symbol.toStringTag,{value:"Module"}));var wt=(s=>(s.Dashboard="/dashboard",s.BiPlatform="/bi-platform",s.EditorBase="/editor",s.AllDashboards="/dashboards",s.DashboardByName="/dashboards/:name",s))(wt||{}),_t;(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={}))})(_t||(_t={}));var $t=(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",s.Editordetails="editordetails",s.Dbtables="dbtables",s.Biviewer="biviewer",s.Biviewerinner="biviewerinner",s.Bieditor="bieditor",s.Bieditorinner="bieditorinner",s))($t||{});const Fe=typeof window<"u"?window.echarts:null,No={name:"VsPie",props:["currentWidget"],mixins:[O],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var r;await this.$nextTick(),await this.getData();const{series:s}=this.prepareData()||{};s&&this.initChart(s);const t=(r=this.$refs)==null?void 0:r.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},beforeUnmount(){var s;(s=this.resizeObserver)==null||s.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&this.initChart(s,t,r)}}catch(s){console.error(s)}},buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
175
203
  <div style="background-color:${t[0]}; font-size:12px; font-family:Helvetica, Arial, sans-serif; color:#ffff; padding:5px; border-radius:5px;">
176
- ${r==null?void 0:r.replace("null","Не визначено")}: ${W(n)} (${o}%)
177
- </div>`},prepareData(){var s,t,r,n,o,l;try{if(this.styleData=this.styleData||{},!((s=this.sourceData)!=null&&s.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,x)=>m+parseFloat((x==null?void 0:x.metric)||0),0),10),p=a.map((m,x)=>{const k=(i[x]/c*100).toFixed(2);return{name:`${m} (${k}%)`,value:i[x]}}),d=((t=this.styleData)==null?void 0:t.innerRadius)||"80%",h=((r=this.styleData)==null?void 0:r.outerRadius)||"100%",g=[d,h];return this.styleData.legend=Ve.getLegendOpions({borderRadius:10,height:"100%",padding:10,bottom:"0",type:"scroll",itemWidth:14,itemHeight:14,formatter:m=>{var x;return(x=m==null?void 0:m.replace("null","Не визначено"))==null?void 0:x.replace("NaN","0.00")},...((n=this.styleData)==null?void 0:n.legend)||{}}),this.styleData.label=Ve.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:g,center:["50%","60%"],height:"75%",...Y(this.styleData),data:p}]}}catch(a){return console.error("Error in prepareData:",a),null}},async initChart(s){try{if(!s){console.warn("No series data available for chart initialization");return}const t=this.$refs.chart;if(!t){console.warn("Chart DOM element not found");return}if(this.chartInstance=Fe==null?void 0:Fe.init(t),!this.chartInstance)return;const r=parseInt((this.sourceData||[]).reduce((o,l)=>o+parseFloat((l==null?void 0:l.metric)||0),0),10),n={tooltip:{trigger:"item",formatter:o=>this.buildTooltipForDonut(o,[o.color]),borderWidth:0,appendToBody:!0,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:s,...Y(this.styleData||{}),title:{text:W(r),left:"center",top:"41%",textStyle:{color:"black",fontWeight:400,fontSize:"22px"}}};this.chartInstance.setOption(n),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var o;(o=this.chartInstance)==null||o.resize()})}catch(t){console.error("Error in initChart:",t)}}}},No=["id"];function So(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,No)}const Bt=D(Do,[["render",So]]),zo=Object.freeze(Object.defineProperty({__proto__:null,default:Bt},Symbol.toStringTag,{value:"Module"})),Ae=typeof window<"u"?window.echarts:null,Lo={name:"VsPie",props:["currentWidget"],mixins:[R],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var r;await this.$nextTick(),await this.getData();const{series:s}=this.prepareData()||{};s&&this.initChart(s);const t=(r=this.$refs)==null?void 0:r.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},unmounted(){var s;(s=this.resizeObserver)==null||s.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&this.initChart(s,t,r)}}catch(s){console.error(s)}},buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
204
+ ${r==null?void 0:r.replace("null","Не визначено")}: ${q(n)} (${o}%)
205
+ </div>`},prepareData(){var s,t,r,n,o,l;try{if(this.styleData=this.styleData||{},!((s=this.sourceData)!=null&&s.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,b)=>m+parseFloat((b==null?void 0:b.metric)||0),0),10),p=a.map((m,b)=>{const y=(i[b]/c*100).toFixed(2);return{name:`${m} (${y}%)`,value:i[b]}}),d=((t=this.styleData)==null?void 0:t.innerRadius)||"80%",h=((r=this.styleData)==null?void 0:r.outerRadius)||"100%",x=[d,h];return this.styleData.legend=Ve.getLegendOpions({borderRadius:10,height:"100%",padding:10,bottom:"0",type:"scroll",itemWidth:14,itemHeight:14,formatter:m=>{var b;return(b=m==null?void 0:m.replace("null","Не визначено"))==null?void 0:b.replace("NaN","0.00")},...((n=this.styleData)==null?void 0:n.legend)||{}}),this.styleData.label=Ve.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:x,center:["50%","60%"],height:"75%",...X(this.styleData),data:p}]}}catch(a){return console.error("Error in prepareData:",a),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=Fe==null?void 0:Fe.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:((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:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:s,...X(this.styleData||{}),title:{text:q(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)}}}},So=["id"];function zo(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,So)}const Vt=S(No,[["render",zo]]),Lo=Object.freeze(Object.defineProperty({__proto__:null,default:Vt},Symbol.toStringTag,{value:"Module"})),Oe=typeof window<"u"?window.echarts:null,To={name:"VsPie",props:["currentWidget"],mixins:[O],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var r;await this.$nextTick(),await this.getData();const{series:s}=this.prepareData()||{};s&&this.initChart(s);const t=(r=this.$refs)==null?void 0:r.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},unmounted(){var s;(s=this.resizeObserver)==null||s.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&this.initChart(s,t,r)}}catch(s){console.error(s)}},buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
178
206
  <div style="background-color:${t[0]}; font-size:12px; font-family:Helvetica, Arial, sans-serif; color:#ffff; padding:5px; border-radius:5px;">
179
- ${r==null?void 0:r.replace("null","Не визначено")}: ${W(n)} (${o}%)
180
- </div>`},prepareData(){var s,t,r,n,o;try{this.styleData=this.styleData||{};const l=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[0]]))),a=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[1]]))),i=parseInt((this.sourceData||[]).reduce((f,m)=>f+parseFloat(m==null?void 0:m.metric),0),10),c=l.map((f,m)=>{const x=(a[m]/i*100).toFixed(2);return{name:`${f} (${x}%)`,value:a[m]}}),p=((s=this.styleData)==null?void 0:s.innerRadius)||"0%",d=((t=this.styleData)==null?void 0:t.outerRadius)||"100%",h=[p,d];return this.styleData.legend=Ve.getLegendOpions({borderRadius:10,height:"100%",padding:10,type:"scroll",itemWidth:14,itemHeight:14,formatter:f=>f==null?void 0:f.replace("null","Не визначено"),textStyle:{fontSize:"14px"},...((r=this.styleData)==null?void 0:r.legend)||{}}),this.styleData.label=Ve.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){try{if(!s){console.warn("No series data available for chart initialization");return}const t=this.$refs.chart;if(!t){console.warn("Chart DOM element not found");return}if(this.chartInstance=Ae==null?void 0:Ae.init(t),!this.chartInstance)return;const r={tooltip:{trigger:"item",formatter:n=>this.buildTooltipForDonut(n,[n.color]),borderWidth:0,appendToBody:!0,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:s,...Y(this.styleData||{})};this.chartInstance.setOption(r),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var n;(n=this.chartInstance)==null||n.resize()})}catch(t){console.error("Error in initChart:",t)}}}},To=["id"];function Io(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,To)}const Ct=D(Lo,[["render",Io]]),Mo=Object.freeze(Object.defineProperty({__proto__:null,default:Ct},Symbol.toStringTag,{value:"Module"})),Po={name:"VsLine",mixins:[R],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}}}},Ro=["id"];function Fo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,ref:"chart",style:{height:"400px"}},null,8,Ro)}const Dt=D(Po,[["render",Fo]]),Ao=Object.freeze(Object.defineProperty({__proto__:null,default:Dt},Symbol.toStringTag,{value:"Module"})),Oo={name:"VsStat",mixins:[R],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<_t.length-1?_t[r]:$o()})},formattedValue(s){const t=parseFloat(s);return W(t)}}},jo={class:"flex flex-col w-full h-full pt-[16px] rounded-xl"},Wo={class:"flex flex-col justify-between w-full h-full"},qo={class:"w-full h-full pb-6 space-y-4"},Uo={class:"flex w-full h-3 rounded-full gap-x-1 min-h-3 custom-x-scrollbar"},vo=["onMouseover"],Ho={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"},Go={class:"h-[calc(100%-20px)] w-full custom-scrollbar"},Zo={class:"grid items-center justify-between grid-cols-2 py-2 gap-x-4"},Qo={class:"flex items-center"},Xo={class:"text-sm text-gray-800"},Jo={class:"text-end"},Ko={class:"text-sm text-gray-500"};function Yo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",jo,[e.createElementVNode("div",Wo,[e.createElementVNode("div",qo,[e.createElementVNode("div",Uo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>{var c,p,d,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:g=>o.showTooltip=i,onMouseleave:t[0]||(t[0]=g=>o.showTooltip=-1)},[o.showTooltip>-1?(e.openBlock(),e.createElementBlock("div",Ho,e.toDisplayString(s.sourceData[o.showTooltip][o.columns[0]])+" "+e.toDisplayString((parseFloat((h=(p=s.sourceData)==null?void 0:p[o.showTooltip])==null?void 0:h[(d=o.columns)==null?void 0:d[1]])/o.sumValue*100).toFixed(2))+"% ",1)):e.createCommentVNode("",!0)],46,vo)}),256))]),e.createElementVNode("ul",Go,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,a=>{var i,c;return e.openBlock(),e.createElementBlock("li",Zo,[e.createElementVNode("div",Qo,[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",Xo,e.toDisplayString((a==null?void 0:a[(i=o.columns)==null?void 0:i[0]])||"Не визначено"),1)]),e.createElementVNode("div",Jo,[e.createElementVNode("span",Ko,e.toDisplayString(l.formattedValue(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])||"-"),1)])])}),256))])])])])}const Nt=D(Oo,[["render",Yo]]),ea=Object.freeze(Object.defineProperty({__proto__:null,default:Nt},Symbol.toStringTag,{value:"Module"})),ta={name:"VsProgressBar",mixins:[R],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 W(s)}}},sa={key:0,class:"flex flex-col h-full pt-[16px] rounded-xl"},ra={class:"h-full pt-0 pb-6 space-y-4"},na={class:"h-full space-y-4 custom-scrollbar"},oa={class:"flex items-center justify-between mr-2 gap-x-2"},aa={class:"grid items-center w-full grid-cols-2 gap-x-2"},la={class:"text-sm text-gray-800"},ia={class:"flex justify-end",role:"progressbar","aria-valuenow":"100","aria-valuemin":"0","aria-valuemax":"100"},ca={class:"min-w-[60px] text-end"},da={class:"text-sm text-gray-500"};function pa(s,t,r,n,o,l){return o.columns?(e.openBlock(),e.createElementBlock("div",sa,[e.createElementVNode("div",ra,[e.createElementVNode("ul",na,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("li",oa,[e.createElementVNode("div",aa,[e.createElementVNode("span",la,e.toDisplayString(a[o.columns[0]]),1),e.createElementVNode("div",ia,[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",ca,[e.createElementVNode("span",da,e.toDisplayString(l.formattedValue(a[o.columns[1]])),1)])]))),256))])])])):e.createCommentVNode("",!0)}const St=D(ta,[["render",pa]]),ha=Object.freeze(Object.defineProperty({__proto__:null,default:St},Symbol.toStringTag,{value:"Module"})),ma={name:"VsListbar",mixins:[R],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 W(s)},getWidth(s){return`${s/this.maxValue*100}%`}}},ua={class:"h-full pt-[20px] list-bar"},fa={class:"space-y-2 custom-scrollbar h-full h-[calc(100%-20px)]"},ga={class:"relative w-full truncate"},ba={class:"relative z-[1] text-sm block py-1 px-2 w-full text-sm truncate text-gray-800"},ya={class:"text-[14px] text-gray-500"};function xa(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",ua,[e.createElementVNode("ul",fa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>{var c,p,d;return e.openBlock(),e.createElementBlock("li",{key:i,class:"flex items-center justify-between w-full gap-x-2"},[e.createElementVNode("div",ga,[e.createElementVNode("span",ba,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[(p=o.columns)==null?void 0:p[0]]?"bg-indigo-100":"bg-gray-100"]),style:e.normalizeStyle({width:l.getWidth(a==null?void 0:a[(d=o.columns)==null?void 0:d[1]])})},null,6)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.restDimensions,(h,g)=>(e.openBlock(),e.createElementBlock("div",{key:g,class:"w-20 mr-2 text-end"},[e.createElementVNode("span",ya,e.toDisplayString(l.formattedValue(a==null?void 0:a[h])),1)]))),128))])}),128))])])}const zt=D(ma,[["render",xa]]),ka=Object.freeze(Object.defineProperty({__proto__:null,default:zt},Symbol.toStringTag,{value:"Module"})),wa={name:"VsPivotTable",mixins:[R],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=>W(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},_a={class:"flex flex-col h-full p-5 space-y-4 rounded-xl custom-scrollbar"},$a={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"},Va={class:"inline-block min-w-full align-middle"},Ea={class:"min-w-full divide-y divide-gray-200"},Ba={class:"space-x-2"},Ca={scope:"col",class:"xl:min-w-[120px] min-w-48"},Da={class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"},Na={class:"divide-y divide-gray-200 text-[12px]"},Sa={class:"py-3 size-px whitespace-nowrap"},za={class:"flex items-center gap-x-3"},La={class:"font-medium text-gray-800"},Ta={class:"py-3 size-px whitespace-nowrap"},Ia={class:"text-gray-600"};function Ma(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",_a,[e.createElementVNode("div",$a,[e.createElementVNode("div",Va,[e.createElementVNode("table",Ea,[e.createElementVNode("thead",null,[e.createElementVNode("tr",Ba,[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",Ca,[e.createElementVNode("div",Da,e.toDisplayString(a),1)]))),256))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.values,a=>(e.openBlock(),e.createElementBlock("tbody",Na,[e.createElementVNode("tr",null,[e.createElementVNode("td",Sa,[e.createElementVNode("div",za,[e.createElementVNode("span",La,e.toDisplayString(a.name),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,(i,c)=>(e.openBlock(),e.createElementBlock("td",Ta,[e.createElementVNode("span",Ia,e.toDisplayString(a.data[c]),1)]))),256))])]))),256))])])])])}const Lt=D(wa,[["render",Ma]]),Pa=Object.freeze(Object.defineProperty({__proto__:null,default:Lt},Symbol.toStringTag,{value:"Module"})),Ra={name:"VsNumber",mixins:[R],data(){return{number:""}},computed:{formattedNumber(){return ko(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)}}}},Fa={class:"text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center"};function Aa(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Fa,e.toDisplayString(l.prefix)+e.toDisplayString(l.formattedNumber),1)}const Oa=Object.freeze(Object.defineProperty({__proto__:null,default:D(Ra,[["render",Aa]])},Symbol.toStringTag,{value:"Module"})),ja={name:"VsText",mixins:[R],data(){return{markedText:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget;try{await this.getData(),this.markedText=C(this.sourceData)}catch(s){console.error(s)}},methods:{onChangedData(){return null}}},Wa=["id"],qa=["innerHTML"];function Ua(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,Wa)}const va=Object.freeze(Object.defineProperty({__proto__:null,default:D(ja,[["render",Ua]])},Symbol.toStringTag,{value:"Module"})),Oe=typeof window<"u"?window.echarts:null,Ha={name:"VsFunnelBar",mixins:[R],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`
207
+ ${r==null?void 0:r.replace("null","Не визначено")}: ${q(n)} (${o}%)
208
+ </div>`},prepareData(){var s,t,r,n,o;try{this.styleData=this.styleData||{};const l=Array.from(new Set((this.sourceData||[]).map(u=>u[this.dimensions[0]]))),a=Array.from(new Set((this.sourceData||[]).map(u=>u[this.dimensions[1]]))),i=parseInt((this.sourceData||[]).reduce((u,m)=>u+parseFloat(m==null?void 0:m.metric),0),10),c=l.map((u,m)=>{const b=(a[m]/i*100).toFixed(2);return{name:`${u} (${b}%)`,value:a[m]}}),p=((s=this.styleData)==null?void 0:s.innerRadius)||"0%",d=((t=this.styleData)==null?void 0:t.outerRadius)||"100%",h=[p,d];return this.styleData.legend=Ve.getLegendOpions({borderRadius:10,height:"100%",padding:10,type:"scroll",itemWidth:14,itemHeight:14,formatter:u=>u==null?void 0:u.replace("null","Не визначено"),textStyle:{fontSize:"14px"},...((r=this.styleData)==null?void 0:r.legend)||{}}),this.styleData.label=Ve.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%",...X(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=Oe==null?void 0:Oe.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,...X(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)}}}},Io=["id"];function Mo(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,Io)}const Et=S(To,[["render",Mo]]),Po=Object.freeze(Object.defineProperty({__proto__:null,default:Et},Symbol.toStringTag,{value:"Module"})),Ro={name:"VsLine",mixins:[O],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=>ce(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}}}},Fo=["id"];function Oo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,ref:"chart",style:{height:"400px"}},null,8,Fo)}const Bt=S(Ro,[["render",Oo]]),Ao=Object.freeze(Object.defineProperty({__proto__:null,default:Bt},Symbol.toStringTag,{value:"Module"})),jo={name:"VsStat",mixins:[O],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<kt.length-1?kt[r]:Vo()})},formattedValue(s){const t=parseFloat(s);return q(t)}}},Wo={class:"flex flex-col w-full h-full pt-[16px] rounded-xl"},qo={class:"flex flex-col justify-between w-full h-full"},vo={class:"w-full h-full pb-6 space-y-4"},Uo={class:"flex w-full h-3 rounded-full gap-x-1 min-h-3 custom-x-scrollbar"},Ho=["onMouseover"],Go={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"},Zo={class:"h-[calc(100%-20px)] w-full custom-scrollbar"},Qo={class:"grid items-center justify-between grid-cols-2 py-2 gap-x-4"},Xo={class:"flex items-center"},Jo={class:"text-sm text-gray-800"},Ko={class:"text-end"},Yo={class:"text-sm text-gray-500"};function ea(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Wo,[e.createElementVNode("div",qo,[e.createElementVNode("div",vo,[e.createElementVNode("div",Uo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>{var c,p,d,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:x=>o.showTooltip=i,onMouseleave:t[0]||(t[0]=x=>o.showTooltip=-1)},[o.showTooltip>-1?(e.openBlock(),e.createElementBlock("div",Go,e.toDisplayString(s.sourceData[o.showTooltip][o.columns[0]])+" "+e.toDisplayString((parseFloat((h=(p=s.sourceData)==null?void 0:p[o.showTooltip])==null?void 0:h[(d=o.columns)==null?void 0:d[1]])/o.sumValue*100).toFixed(2))+"% ",1)):e.createCommentVNode("",!0)],46,Ho)}),256))]),e.createElementVNode("ul",Zo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,a=>{var i,c;return e.openBlock(),e.createElementBlock("li",Qo,[e.createElementVNode("div",Xo,[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",Jo,e.toDisplayString((a==null?void 0:a[(i=o.columns)==null?void 0:i[0]])||"Не визначено"),1)]),e.createElementVNode("div",Ko,[e.createElementVNode("span",Yo,e.toDisplayString(l.formattedValue(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])||"-"),1)])])}),256))])])])])}const Ct=S(jo,[["render",ea]]),ta=Object.freeze(Object.defineProperty({__proto__:null,default:Ct},Symbol.toStringTag,{value:"Module"})),sa={name:"VsProgressBar",mixins:[O],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 q(s)}}},ra={key:0,class:"flex flex-col h-full pt-[16px] rounded-xl"},na={class:"h-full pt-0 pb-6 space-y-4"},oa={class:"h-full space-y-4 custom-scrollbar"},aa={class:"flex items-center justify-between mr-2 gap-x-2"},la={class:"grid items-center w-full grid-cols-2 gap-x-2"},ia={class:"text-sm text-gray-800"},ca={class:"flex justify-end",role:"progressbar","aria-valuenow":"100","aria-valuemin":"0","aria-valuemax":"100"},da={class:"min-w-[60px] text-end"},pa={class:"text-sm text-gray-500"};function ha(s,t,r,n,o,l){return o.columns?(e.openBlock(),e.createElementBlock("div",ra,[e.createElementVNode("div",na,[e.createElementVNode("ul",oa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("li",aa,[e.createElementVNode("div",la,[e.createElementVNode("span",ia,e.toDisplayString(a[o.columns[0]]),1),e.createElementVNode("div",ca,[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",da,[e.createElementVNode("span",pa,e.toDisplayString(l.formattedValue(a[o.columns[1]])),1)])]))),256))])])])):e.createCommentVNode("",!0)}const Dt=S(sa,[["render",ha]]),ua=Object.freeze(Object.defineProperty({__proto__:null,default:Dt},Symbol.toStringTag,{value:"Module"})),ma={name:"VsListbar",mixins:[O],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 q(s)},getWidth(s){return`${s/this.maxValue*100}%`}}},fa={class:"h-full pt-[20px] list-bar"},ga={class:"space-y-2 custom-scrollbar h-full h-[calc(100%-20px)]"},ba={class:"relative w-full truncate"},ya={class:"relative z-[1] text-sm block py-1 px-2 w-full text-sm truncate text-gray-800"},xa={class:"text-[14px] text-gray-500"};function ka(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",fa,[e.createElementVNode("ul",ga,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>{var c,p,d;return e.openBlock(),e.createElementBlock("li",{key:i,class:"flex items-center justify-between w-full gap-x-2"},[e.createElementVNode("div",ba,[e.createElementVNode("span",ya,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[(p=o.columns)==null?void 0:p[0]]?"bg-indigo-100":"bg-gray-100"]),style:e.normalizeStyle({width:l.getWidth(a==null?void 0:a[(d=o.columns)==null?void 0:d[1]])})},null,6)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.restDimensions,(h,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"w-20 mr-2 text-end"},[e.createElementVNode("span",xa,e.toDisplayString(l.formattedValue(a==null?void 0:a[h])),1)]))),128))])}),128))])])}const Nt=S(ma,[["render",ka]]),wa=Object.freeze(Object.defineProperty({__proto__:null,default:Nt},Symbol.toStringTag,{value:"Module"})),_a={name:"VsPivotTable",mixins:[O],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=>ce(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=>q(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},$a={class:"flex flex-col h-full p-5 space-y-4 rounded-xl custom-scrollbar"},Va={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"},Ea={class:"inline-block min-w-full align-middle"},Ba={class:"min-w-full divide-y divide-gray-200"},Ca={class:"space-x-2"},Da={scope:"col",class:"xl:min-w-[120px] min-w-48"},Na={class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"},Sa={class:"divide-y divide-gray-200 text-[12px]"},za={class:"py-3 size-px whitespace-nowrap"},La={class:"flex items-center gap-x-3"},Ta={class:"font-medium text-gray-800"},Ia={class:"py-3 size-px whitespace-nowrap"},Ma={class:"text-gray-600"};function Pa(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",$a,[e.createElementVNode("div",Va,[e.createElementVNode("div",Ea,[e.createElementVNode("table",Ba,[e.createElementVNode("thead",null,[e.createElementVNode("tr",Ca,[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",Da,[e.createElementVNode("div",Na,e.toDisplayString(a),1)]))),256))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.values,a=>(e.openBlock(),e.createElementBlock("tbody",Sa,[e.createElementVNode("tr",null,[e.createElementVNode("td",za,[e.createElementVNode("div",La,[e.createElementVNode("span",Ta,e.toDisplayString(a.name),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,(i,c)=>(e.openBlock(),e.createElementBlock("td",Ia,[e.createElementVNode("span",Ma,e.toDisplayString(a.data[c]),1)]))),256))])]))),256))])])])])}const St=S(_a,[["render",Pa]]),Ra=Object.freeze(Object.defineProperty({__proto__:null,default:St},Symbol.toStringTag,{value:"Module"})),Fa={name:"VsNumber",mixins:[O],data(){return{number:""}},computed:{formattedNumber(){return wo(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)}}}},Oa={class:"text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center"};function Aa(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Oa,e.toDisplayString(l.prefix)+e.toDisplayString(l.formattedNumber),1)}const ja=Object.freeze(Object.defineProperty({__proto__:null,default:S(Fa,[["render",Aa]])},Symbol.toStringTag,{value:"Module"})),Wa={name:"VsText",mixins:[O],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=N(((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}}},qa=["id"],va=["innerHTML"];function Ua(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,va)):e.createCommentVNode("",!0)],8,qa)}const Ha=Object.freeze(Object.defineProperty({__proto__:null,default:S(Wa,[["render",Ua]])},Symbol.toStringTag,{value:"Module"})),Ae=typeof window<"u"?window.echarts:null,Ga={name:"VsFunnelBar",mixins:[O],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`
181
209
  <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]">
182
- ${pe(r)}: ${W(n)} (${o}%)
183
- </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){try{const t=this.$refs.chart,r=Oe==null?void 0:Oe.init(t);if(!r)return;const n={series:s,...Y(this.styleData),tooltip:{trigger:"item",formatter:o=>this.buildTooltipForDonut(o,[o.color]),borderWidth:0,appendToBody:!0,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"}};r.setOption(n),r.resize(),window.addEventListener("resize",()=>{r.resize()})}catch(t){console.error(t)}}}},Ga=["id"];function Za(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,Ga)}const Qa=Object.freeze(Object.defineProperty({__proto__:null,default:D(Ha,[["render",Za]])},Symbol.toStringTag,{value:"Module"}));function Xa(s){return[{type:"fill",paint:{"fill-color":s.color||"#ccc","fill-outline-color":s.color||"blue","fill-opacity":s.opacity||1}}]}function Ja(s){return[{type:"line",paint:{"line-color":s.color||"#ccc","line-opacity":s.opacity||1}}]}function Ka(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"?Xa(s):t==="line"?Ja(s):Ka(s)}const je={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)}}},Ya="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.js",el="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.css";let Ee=null;function tl(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 sl(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):Ee||(Ee=sl(el).then(()=>tl(Ya)).then(()=>window.maplibregl),Ee)}const We={__name:"legend",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ms),e.mergeProps(t.$attrs,{size:24}),null,16))}},qe={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"]},rl={components:{legendIcon:We,closeIcon:De},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:qe}},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}}},nl={class:"w-full absolute max-w-[200px] bg-white border rounded-lg bottom-[10px] right-[50px]"},ol={class:"flex items-center justify-between border-b border-[#0000001A] px-2"},al={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"},ll={key:0,class:"flex flex-col w-full"},il={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},cl={class:"flex flex-col gap-[6px]"},dl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"},pl={key:1,class:"flex flex-col w-full"},hl={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},ml={class:"flex flex-col gap-[6px]"},ul={class:"flex flex-row items-center justify-start"},fl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"};function gl(s,t,r,n,o,l){var c,p;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]=d=>o.isOpenLegend=!o.isOpenLegend)},[e.createVNode(a)]),o.isOpenLegend?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:`#wrapper-${r.mapId}`},[e.createElementVNode("div",nl,[e.createElementVNode("div",ol,[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]=d=>o.isOpenLegend=!1)},[e.createVNode(i,{class:"w-[20px]"})])]),e.createElementVNode("div",al,[(c=r.colors)!=null&&c.length?(e.openBlock(),e.createElementBlock("div",ll,[r.colorTitle?(e.openBlock(),e.createElementBlock("h4",il,e.toDisplayString(r.colorTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",cl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.colors,(d,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:"flex items-center gap-[10px]"},[d.color?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-[12px] h-[12px] rounded-full",style:e.normalizeStyle({backgroundColor:d.color})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("p",dl,e.toDisplayString(d.text||d.val),1)]))),128))])])):e.createCommentVNode("",!0),(p=r.sizes)!=null&&p.length?(e.openBlock(),e.createElementBlock("div",pl,[s.sizeTitle?(e.openBlock(),e.createElementBlock("h4",hl,e.toDisplayString(s.sizeTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",ml,[l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(d,h)=>{var g,f,m,x,k;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",ul,[e.createElementVNode("div",{class:e.normalizeClass([l.maxWidht?`w-[${l.maxWidht}]`:"","mr-[10px]"])},[e.createElementVNode("div",{class:e.normalizeClass(l.sizeClass(h)),style:e.normalizeStyle({backgroundColor:((f=(g=o.palette)==null?void 0:g[r.color])==null?void 0:f[h])||r.color})},null,6)],2),e.createElementVNode("p",fl,e.toDisplayString(h===((m=l.sortedSizes)==null?void 0:m.length)-1?">"+d:h==((x=l.sortedSizes)==null?void 0:x.length)-1?">"+l.sortedSizes[((k=l.sortedSizes)==null?void 0:k.length)-1]:d+"-"+l.sortedSizes[h+1]),1)])])}),256)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])])],8,["to"])):e.createCommentVNode("",!0)],64)}const bl=D(rl,[["render",gl]]),yl={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(", ")}}},xl={class:"map__settings"},kl={ref:"attribution",class:"map__settings-attribution map__settings-item mt-[3px]"};function wl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",xl,[e.createElementVNode("div",kl,[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=D(yl,[["render",wl]]),_l={mixins:[je],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}}},$l={class:"vs-map-slot-layers"},Vl=["onClick"],El=["src"];function Bl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",$l,[(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,El)],10,Vl))),128))])}const Pt=D(_l,[["render",Bl]]);function Rt(s,t,r){if(s!==null)for(var n,o,l,a,i,c,p,d=0,h=0,g,f=s.type,m=f==="FeatureCollection",x=f==="Feature",k=m?s.features.length:1,u=0;u<k;u++){p=m?s.features[u].geometry:x?s.geometry:s,g=p?p.type==="GeometryCollection":!1,i=g?p.geometries.length:1;for(var y=0;y<i;y++){var b=0,_=0;if(a=g?p.geometries[y]:p,a!==null){c=a.coordinates;var $=a.type;switch(d=0,$){case null:break;case"Point":if(t(c,h,u,b,_)===!1)return!1;h++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,u,b,_)===!1)return!1;h++,$==="MultiPoint"&&b++}$==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(o=0;o<c[n].length-d;o++){if(t(c[n][o],h,u,b,_)===!1)return!1;h++}$==="MultiLineString"&&b++,$==="Polygon"&&_++}$==="Polygon"&&b++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(_=0,o=0;o<c[n].length;o++){for(l=0;l<c[n][o].length-d;l++){if(t(c[n][o][l],h,u,b,_)===!1)return!1;h++}_++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(Rt(a.geometries[n],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Cl(s,t={}){if(s.bbox!=null&&t.recompute!==!0)return s.bbox;const r=[1/0,1/0,-1/0,-1/0];return Rt(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 Dl={props:["bbox","map"],components:{homeIcon:{__name:"home",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ds),e.mergeProps(t.$attrs,{size:24}),null,16))}}},methods:{setBounds(){const s={type:"Feature",geometry:this==null?void 0:this.bbox},t=Cl(s);this.map.fitBounds(t)}}},Nl={class:"z-100 flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]"};function Sl(s,t,r,n,o,l){const a=e.resolveComponent("homeIcon");return e.openBlock(),e.createElementBlock("div",Nl,[e.createVNode(a,{onClick:l.setBounds},null,8,["onClick"])])}const Ft=D(Dl,[["render",Sl]]),zl={components:{legendIcon:We,menuIcon:{__name:"menu",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(cs),e.mergeProps(t.$attrs,{size:24}),null,16))}},closeIcon:De},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]}}},Ll={class:"w-full h-[calc(100%-40px)] bg-white"},Tl={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"},Il={class:"relative min-w-full bg-white text-[12px]"},Ml={class:"divide-gray-200 dark:divide-neutral-700"},Pl={class:"px-2 py-1"},Rl={class:"px-2 py-1"};function Fl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Ll,[e.createElementVNode("div",Tl,[e.createElementVNode("table",Il,[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",Ml,[(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",Pl,e.toDisplayString(a.title||"—"),1),e.createElementVNode("td",Rl,e.toDisplayString(a.metric),1)]))),128))])])])])}const At=D(zl,[["render",Fl]]),Al={mixins:[R,je,{components:{VsMapSetting:Mt,VsMapSlotLayers:Pt,VsMapLegend:bl,VsMapGoHome:Ft,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 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">
210
+ ${ce(r)}: ${q(n)} (${o}%)
211
+ </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",...X(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=Ae==null?void 0:Ae.init(n);if(!o)return;const l={series:s,...X(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)}}}},Za=["id"];function Qa(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,Za)}const Xa=Object.freeze(Object.defineProperty({__proto__:null,default:S(Ga,[["render",Qa]])},Symbol.toStringTag,{value:"Module"}));function Ja(s){return[{type:"fill",paint:{"fill-color":s.color||"#ccc","fill-outline-color":s.color||"blue","fill-opacity":s.opacity||1}}]}function Ka(s){return[{type:"line",paint:{"line-color":s.color||"#ccc","line-opacity":s.opacity||1}}]}function Ya(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 zt(s){if(!s)return null;const t=s.type||"point";return t==="polygon"?Ja(s):t==="line"?Ka(s):Ya(s)}const je={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),(zt(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}),(zt(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)}}},el="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.js",tl="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.css";let Ee=null;function sl(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 rl(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 Lt(){return typeof window>"u"?Promise.resolve(null):window.maplibregl?Promise.resolve(window.maplibregl):Ee||(Ee=rl(tl).then(()=>sl(el)).then(()=>window.maplibregl),Ee)}const We={__name:"legend",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ms),e.mergeProps(t.$attrs,{size:24}),null,16))}},qe={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"]},nl={components:{legendIcon:We,closeIcon:De},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:qe}},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}}},ol={class:"w-full absolute max-w-[200px] bg-white border rounded-lg bottom-[10px] right-[50px]"},al={class:"flex items-center justify-between border-b border-[#0000001A] px-2"},ll={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"},il={key:0,class:"flex flex-col w-full"},cl={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},dl={class:"flex flex-col gap-[6px]"},pl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"},hl={key:1,class:"flex flex-col w-full"},ul={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},ml={class:"flex flex-col gap-[6px]"},fl={class:"flex flex-row items-center justify-start"},gl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"};function bl(s,t,r,n,o,l){var c,p;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]=d=>o.isOpenLegend=!o.isOpenLegend)},[e.createVNode(a)]),o.isOpenLegend?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:`#wrapper-${r.mapId}`},[e.createElementVNode("div",ol,[e.createElementVNode("div",al,[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]=d=>o.isOpenLegend=!1)},[e.createVNode(i,{class:"w-[20px]"})])]),e.createElementVNode("div",ll,[(c=r.colors)!=null&&c.length?(e.openBlock(),e.createElementBlock("div",il,[r.colorTitle?(e.openBlock(),e.createElementBlock("h4",cl,e.toDisplayString(r.colorTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",dl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.colors,(d,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:"flex items-center gap-[10px]"},[d.color?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-[12px] h-[12px] rounded-full",style:e.normalizeStyle({backgroundColor:d.color})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("p",pl,e.toDisplayString(d.text||d.val),1)]))),128))])])):e.createCommentVNode("",!0),(p=r.sizes)!=null&&p.length?(e.openBlock(),e.createElementBlock("div",hl,[s.sizeTitle?(e.openBlock(),e.createElementBlock("h4",ul,e.toDisplayString(s.sizeTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",ml,[l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(d,h)=>{var x,u,m,b,y;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",fl,[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:((u=(x=o.palette)==null?void 0:x[r.color])==null?void 0:u[h])||r.color})},null,6)],2),e.createElementVNode("p",gl,e.toDisplayString(h===((m=l.sortedSizes)==null?void 0:m.length)-1?">"+d:h==((b=l.sortedSizes)==null?void 0:b.length)-1?">"+l.sortedSizes[((y=l.sortedSizes)==null?void 0:y.length)-1]:d+"-"+l.sortedSizes[h+1]),1)])])}),256)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])])],8,["to"])):e.createCommentVNode("",!0)],64)}const yl=S(nl,[["render",bl]]),xl={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(", ")}}},kl={class:"map__settings"},wl={ref:"attribution",class:"map__settings-attribution map__settings-item mt-[3px]"};function _l(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",kl,[e.createElementVNode("div",wl,[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 Tt=S(xl,[["render",_l]]),$l={mixins:[je],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}}},Vl={class:"vs-map-slot-layers"},El=["onClick"],Bl=["src"];function Cl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Vl,[(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,Bl)],10,El))),128))])}const It=S($l,[["render",Cl]]);function Mt(s,t,r){if(s!==null)for(var n,o,l,a,i,c,p,d=0,h=0,x,u=s.type,m=u==="FeatureCollection",b=u==="Feature",y=m?s.features.length:1,k=0;k<y;k++){p=m?s.features[k].geometry:b?s.geometry:s,x=p?p.type==="GeometryCollection":!1,i=x?p.geometries.length:1;for(var g=0;g<i;g++){var f=0,w=0;if(a=x?p.geometries[g]:p,a!==null){c=a.coordinates;var V=a.type;switch(d=0,V){case null:break;case"Point":if(t(c,h,k,f,w)===!1)return!1;h++,f++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,k,f,w)===!1)return!1;h++,V==="MultiPoint"&&f++}V==="LineString"&&f++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(o=0;o<c[n].length-d;o++){if(t(c[n][o],h,k,f,w)===!1)return!1;h++}V==="MultiLineString"&&f++,V==="Polygon"&&w++}V==="Polygon"&&f++;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-d;l++){if(t(c[n][o][l],h,k,f,w)===!1)return!1;h++}w++}f++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(Mt(a.geometries[n],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Dl(s,t={}){if(s.bbox!=null&&t.recompute!==!0)return s.bbox;const r=[1/0,1/0,-1/0,-1/0];return Mt(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 Nl={props:["bbox","map"],components:{homeIcon:{__name:"home",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ps),e.mergeProps(t.$attrs,{size:24}),null,16))}}},methods:{setBounds(){const s={type:"Feature",geometry:this==null?void 0:this.bbox},t=Dl(s);this.map.fitBounds(t)}}},Sl={class:"z-100 flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]"};function zl(s,t,r,n,o,l){const a=e.resolveComponent("homeIcon");return e.openBlock(),e.createElementBlock("div",Sl,[e.createVNode(a,{onClick:l.setBounds},null,8,["onClick"])])}const Pt=S(Nl,[["render",zl]]),Ll={components:{legendIcon:We,menuIcon:{__name:"menu",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ds),e.mergeProps(t.$attrs,{size:24}),null,16))}},closeIcon:De},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]}}},Tl={class:"w-full h-[calc(100%-40px)] bg-white"},Il={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"},Ml={class:"relative min-w-full bg-white text-[12px]"},Pl={class:"divide-gray-200 dark:divide-neutral-700"},Rl={class:"px-2 py-1"},Fl={class:"px-2 py-1"};function Ol(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Tl,[e.createElementVNode("div",Il,[e.createElementVNode("table",Ml,[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",Pl,[(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",Rl,e.toDisplayString(a.title||"—"),1),e.createElementVNode("td",Fl,e.toDisplayString(a.metric),1)]))),128))])])])])}const Rt=S(Ll,[["render",Ol]]),Al={mixins:[O,je,{components:{VsMapSetting:Tt,VsMapSlotLayers:It,VsMapLegend:yl,VsMapGoHome:Pt,VsList:Rt},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 Lt();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">
184
212
  ${this.getPopoverTitle((n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name))||""}
185
213
  </div>
186
214
 
@@ -189,7 +217,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
189
217
  <span class="font-medium mr-[6px]">Значення</span>
190
218
  </span>
191
219
  <span>${(n==null?void 0:n.metric)||0}</span>
192
- </div>`;const o=this.map.project(s.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(r){console.error(r)}}}}],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 r;return(r=this.map)==null?void 0:r.resize()})},async loadHandler(){const s=["#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)||s[i]),[])).concat(["gray"]):"blue",r=[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(r[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})}}},Ol={class:"w-full h-full"},jl={class:"flex items-start justify-between mb-[6px] w-full"},Wl={class:"text-gray-800 font-[600]"},ql=["id"],Ul=["id"],vl={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"};function Hl(s,t,r,n,o,l){var d,h,g;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapLegend"),p=e.resolveComponent("VsMapGoHome");return e.openBlock(),e.createElementBlock("div",Ol,[e.createElementVNode("div",jl,[e.createElementVNode("h5",Wl,e.toDisplayString(s.title),1)]),e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${s.mapId}`},[e.createElementVNode("div",{id:s.mapId,class:"w-full flex items-end relative h-full min-h-[250px]"},null,8,Ul),s.showSetting?(e.openBlock(),e.createBlock(a,{key:0,map:s.map,coordinates:s.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:s.map},null,8,["map"]),e.createElementVNode("div",vl,[e.createVNode(c,{mapId:s.mapId,colors:(d=s.data)==null?void 0:d.colors,sizes:(h=s.data)==null?void 0:h.sizes,color:s.color,resizeItem:"true"},null,8,["mapId","colors","sizes","color"]),e.createVNode(p,{map:s.map,bbox:(g=s.data)==null?void 0:g.bounds},null,8,["map","bbox"])])],8,ql)])}const Gl=Object.freeze(Object.defineProperty({__proto__:null,default:D(Al,[["render",Hl]])},Symbol.toStringTag,{value:"Module"})),Zl={components:{legendIcon:We,closeIcon:De},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:qe}},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-[10px] ${this.borderRadius}`},calcSize(s){return`${10+s*2}px`},getOpacity(s){return(s+1)/this.sortedSizes.length}}},Ql={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"},Xl={class:"w-[80px] mr-[10px]"},Jl=["title"],Kl={class:"text-[10px] mb-[2px] text-[#1F2937] font-normal leading-[1.2]"};function Yl(s,t,r,n,o,l){var a;return(a=r.sizes)!=null&&a.length?(e.openBlock(),e.createElementBlock("div",Ql,[e.createElementVNode("div",Xl,[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(s.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 p,d,h,g,f,m,x,k;return e.openBlock(),e.createElementBlock("div",{class:"w-[80px]",title:c===((p=l.sortedSizes)==null?void 0:p.length)-1?">"+i:c==((d=l.sortedSizes)==null?void 0:d.length)-1?">"+l.sortedSizes[((h=l.sortedSizes)==null?void 0:h.length)-1]:i+"-"+l.sortedSizes[c+1]},[e.createElementVNode("p",Kl,e.toDisplayString(c===((g=l.sortedSizes)==null?void 0:g.length)-1?">"+parseInt(i):c==((f=l.sortedSizes)==null?void 0:f.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:((k=(x=o.palette)==null?void 0:x[r.color])==null?void 0:k[c])||r.color})},null,6)],8,Jl)}),256)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const ei=D(Zl,[["render",Yl]]),ti={__name:"icon-map",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(us),e.mergeProps(t.$attrs,{size:24}),null,16))}},si={mixins:[R,je],components:{VsMapSetting:Mt,VsClusterLegend:ei,VsMapGoHome:Ft,VsList:At,VsMapSlotLayers:Pt,VsBar:Re},data(){return{baseColor:"pink",kattotg:"",options:[{id:"map",text:"Карта",component:ti},{id:"table",text:"Таблиця",component:kt},{id:"chart",text:"Віджет",component:xt}],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 s=await T.get(`/bi-cluster?widget=${this.widget}&dashboard=${this.dashboard}`);this.data=s,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 s=["case"];(a=(l=(o=this.data)==null?void 0:o.sizes)==null?void 0:l.toReversed())==null||a.forEach((i,c)=>{var p,d;s.push([">",["get","metric"],i]),s.push((d=(p=qe[this.baseColor])==null?void 0:p.toReversed())==null?void 0:d[c]),c++}),s.push("gray");const t={type:"polygon",color:s,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 r=["case"];this.kattotg&&r.push(["==",["to-string",["get","name"]],String(this.kattotg)],"red"),r.push("transparent"),this.map.addLayer({id:"highlighted",type:"fill",source:"bi","source-layer":"bi",paint:{"fill-color":r,"fill-opacity":.6}})},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()})},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="px-2 py-1 text-sm font-semibold text-gray-800 border-b border-gray-200 border-solid rounded-t-lg">
220
+ </div>`;const o=this.map.project(s.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(r){console.error(r)}}}}],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 r;return(r=this.map)==null?void 0:r.resize()})},async loadHandler(){const s=["#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)||s[i]),[])).concat(["gray"]):"blue",r=[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(r[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})}}},jl={class:"w-full h-full"},Wl={class:"flex items-start justify-between mb-[6px] w-full"},ql={class:"text-gray-800 font-[600]"},vl=["id"],Ul=["id"],Hl={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"};function Gl(s,t,r,n,o,l){var d,h,x;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapLegend"),p=e.resolveComponent("VsMapGoHome");return e.openBlock(),e.createElementBlock("div",jl,[e.createElementVNode("div",Wl,[e.createElementVNode("h5",ql,e.toDisplayString(s.title),1)]),e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${s.mapId}`},[e.createElementVNode("div",{id:s.mapId,class:"w-full flex items-end relative h-full min-h-[250px]"},null,8,Ul),s.showSetting?(e.openBlock(),e.createBlock(a,{key:0,map:s.map,coordinates:s.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:s.map},null,8,["map"]),e.createElementVNode("div",Hl,[e.createVNode(c,{mapId:s.mapId,colors:(d=s.data)==null?void 0:d.colors,sizes:(h=s.data)==null?void 0:h.sizes,color:s.color,resizeItem:"true"},null,8,["mapId","colors","sizes","color"]),e.createVNode(p,{map:s.map,bbox:(x=s.data)==null?void 0:x.bounds},null,8,["map","bbox"])])],8,vl)])}const Zl=Object.freeze(Object.defineProperty({__proto__:null,default:S(Al,[["render",Gl]])},Symbol.toStringTag,{value:"Module"})),Ql={components:{legendIcon:We,closeIcon:De},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:qe}},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-[10px] ${this.borderRadius}`},calcSize(s){return`${10+s*2}px`},getOpacity(s){return(s+1)/this.sortedSizes.length}}},Xl={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"},Jl={class:"w-[80px] mr-[10px]"},Kl=["title"],Yl={class:"text-[10px] mb-[2px] text-[#1F2937] font-normal leading-[1.2]"};function ei(s,t,r,n,o,l){var a;return(a=r.sizes)!=null&&a.length?(e.openBlock(),e.createElementBlock("div",Xl,[e.createElementVNode("div",Jl,[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(s.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 p,d,h,x,u,m,b,y;return e.openBlock(),e.createElementBlock("div",{class:"w-[80px]",title:c===((p=l.sortedSizes)==null?void 0:p.length)-1?">"+i:c==((d=l.sortedSizes)==null?void 0:d.length)-1?">"+l.sortedSizes[((h=l.sortedSizes)==null?void 0:h.length)-1]:i+"-"+l.sortedSizes[c+1]},[e.createElementVNode("p",Yl,e.toDisplayString(c===((x=l.sortedSizes)==null?void 0:x.length)-1?">"+parseInt(i):c==((u=l.sortedSizes)==null?void 0:u.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:((y=(b=o.palette)==null?void 0:b[r.color])==null?void 0:y[c])||r.color})},null,6)],8,Kl)}),256)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const ti=S(Ql,[["render",ei]]),si={__name:"icon-map",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(fs),e.mergeProps(t.$attrs,{size:24}),null,16))}},ri={mixins:[O,je],components:{VsMapSetting:Tt,VsClusterLegend:ti,VsMapGoHome:Pt,VsList:Rt,VsMapSlotLayers:It,VsBar:Re},data(){return{baseColor:"pink",kattotg:"",options:[{id:"map",text:"Карта",component:si},{id:"table",text:"Таблиця",component:yt},{id:"chart",text:"Віджет",component:bt}],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 s=await P.get(`/bi-cluster?widget=${this.widget}&dashboard=${this.dashboard}`);this.data=s,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 s=["case"];(a=(l=(o=this.data)==null?void 0:o.sizes)==null?void 0:l.toReversed())==null||a.forEach((i,c)=>{var p,d;s.push([">",["get","metric"],i]),s.push((d=(p=qe[this.baseColor])==null?void 0:p.toReversed())==null?void 0:d[c]),c++}),s.push("gray");const t={type:"polygon",color:s,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 r=["case"];this.kattotg&&r.push(["==",["to-string",["get","name"]],String(this.kattotg)],"red"),r.push("transparent"),this.map.addLayer({id:"highlighted",type:"fill",source:"bi","source-layer":"bi",paint:{"fill-color":r,"fill-opacity":.6}})},async createMap(){var r,n;const s=await Lt();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()})},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="px-2 py-1 text-sm font-semibold text-gray-800 border-b border-gray-200 border-solid rounded-t-lg">
193
221
  ${(n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name)||""}
194
222
  </div>
195
223
 
@@ -198,4 +226,4 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
198
226
  <span class="font-medium mr-[6px]">Значення</span>
199
227
  </span>
200
228
  <span>${(n==null?void 0:n.metric)||0}</span>
201
- </div>`;const o=this.map.project(s.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(r){console.error(r)}}}},ri={class:"h-full"},ni={class:"flex items-start justify-between mb-[6px] w-full"},oi={class:"text-gray-800 font-[600]"},ai={class:"flex gap-2"},li=["onClick"],ii=["id"],ci=["id"],di={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"},pi={class:"h-[calc(250px)]"};function hi(s,t,r,n,o,l){var g,f,m,x,k,u,y,b,_,$;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapGoHome"),p=e.resolveComponent("VsClusterLegend"),d=e.resolveComponent("VsList"),h=e.resolveComponent("VsBar");return e.openBlock(),e.createElementBlock("div",ri,[e.createElementVNode("div",ni,[e.createElementVNode("h3",oi,e.toDisplayString(s.title),1),e.createElementVNode("div",ai,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,w=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["p-1 text-gray-700 border rounded",[o.activeTab===(w==null?void 0:w.id)?"ring-2 ring-blue-500":""]]),onClick:L=>o.activeTab=w==null?void 0:w.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(w==null?void 0:w.component),{height:"16",width:"16"}))],10,li))),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,ci),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",di,[e.createVNode(c,{map:o.map,bbox:(g=o.data)==null?void 0:g.bounds},null,8,["map","bbox"])]),e.createVNode(p,{mapId:o.mapId,colors:(f=o.data)==null?void 0:f.colors,sizes:(m=o.data)==null?void 0:m.sizes,color:o.baseColor,changeOpacityItem:"true",cluster:"true"},null,8,["mapId","colors","sizes","color"])],8,ii),[[e.vShow,o.activeTab=="map"]]),e.withDirectives(e.createVNode(d,{mapId:o.mapId,source:(x=o.data)==null?void 0:x.rows,total:((k=o.data)==null?void 0:k.total)||0,count:((u=o.data)==null?void 0:u.count)||0,onKattotg:t[0]||(t[0]=w=>o.kattotg=w)},null,8,["mapId","source","total","count"]),[[e.vShow,o.activeTab=="table"]]),e.withDirectives(e.createElementVNode("div",pi,[(b=(y=o.data)==null?void 0:y.rows)!=null&&b.length?(e.openBlock(),e.createBlock(h,{key:0,source:($=(_=o.data)==null?void 0:_.rows)==null?void 0:$.map(w=>({title:w==null?void 0:w.title,metric:w==null?void 0:w.metric}))},null,8,["source"])):e.createCommentVNode("",!0)],512),[[e.vShow,o.activeTab=="chart"]])])}const mi=Object.freeze(Object.defineProperty({__proto__:null,default:D(si,[["render",hi]])},Symbol.toStringTag,{value:"Module"})),ui={name:"VsTable",mixins:[R],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=>W(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},fi={class:"flex flex-col h-full pt-[16px] pb-[16px] space-y-4 rounded-xl"},gi={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"},bi={class:"inline-block min-w-full align-middle"},yi={class:"relative min-w-full divide-y divide-gray-200 text-[12px]"},xi={class:"sticky top-0 bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},ki={class:"space-x-2"},wi={scope:"col",class:"xl:min-w-[120px] min-w-48"},_i={class:"flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1"},$i={class:"divide-y divide-gray-200"},Vi={class:"text-gray-600"};function Ei(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",fi,[e.createElementVNode("div",gi,[e.createElementVNode("div",bi,[e.createElementVNode("table",yi,[e.createElementVNode("thead",xi,[e.createElementVNode("tr",ki,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.dimensions,a=>(e.openBlock(),e.createElementBlock("th",wi,[e.createElementVNode("div",_i,e.toDisplayString(a),1)]))),256))])]),e.createElementVNode("tbody",$i,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("tr",{key:i},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.dimensions,(c,p)=>(e.openBlock(),e.createElementBlock("td",{key:p,class:"py-3 whitespace-nowrap"},[e.createElementVNode("span",Vi,e.toDisplayString(a==null?void 0:a[c]),1)]))),128))]))),128))])])])])])}const Bi=Object.freeze(Object.defineProperty({__proto__:null,default:D(ui,[["render",Ei]])},Symbol.toStringTag,{value:"Module"}));z.EditorRootPage=xo,z.ROUTES_NAMES=Et,z.Urls=$t,z.VsBar=Re,z.VsDashboard=hr,z.VsDonut=Bt,z.VsLine=Dt,z.VsListBar=zt,z.VsPie=Ct,z.VsPivotTable=Lt,z.VsProgressBar=St,z.VsStat=Nt,z.VsWidget=re,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
229
+ </div>`;const o=this.map.project(s.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(r){console.error(r)}}}},ni={class:"h-full"},oi={class:"flex items-start justify-between mb-[6px] w-full"},ai={class:"text-gray-800 font-[600]"},li={class:"flex gap-2"},ii=["onClick"],ci=["id"],di=["id"],pi={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"},hi={class:"h-[calc(250px)]"};function ui(s,t,r,n,o,l){var x,u,m,b,y,k,g,f,w,V;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapGoHome"),p=e.resolveComponent("VsClusterLegend"),d=e.resolveComponent("VsList"),h=e.resolveComponent("VsBar");return e.openBlock(),e.createElementBlock("div",ni,[e.createElementVNode("div",oi,[e.createElementVNode("h3",ai,e.toDisplayString(s.title),1),e.createElementVNode("div",li,[(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:$=>o.activeTab=_==null?void 0:_.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(_==null?void 0:_.component),{height:"16",width:"16"}))],10,ii))),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,di),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",pi,[e.createVNode(c,{map:o.map,bbox:(x=o.data)==null?void 0:x.bounds},null,8,["map","bbox"])]),e.createVNode(p,{mapId:o.mapId,colors:(u=o.data)==null?void 0:u.colors,sizes:(m=o.data)==null?void 0:m.sizes,color:o.baseColor,changeOpacityItem:"true",cluster:"true"},null,8,["mapId","colors","sizes","color"])],8,ci),[[e.vShow,o.activeTab=="map"]]),e.withDirectives(e.createVNode(d,{mapId:o.mapId,source:(b=o.data)==null?void 0:b.rows,total:((y=o.data)==null?void 0:y.total)||0,count:((k=o.data)==null?void 0:k.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",hi,[(f=(g=o.data)==null?void 0:g.rows)!=null&&f.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 mi=Object.freeze(Object.defineProperty({__proto__:null,default:S(ri,[["render",ui]])},Symbol.toStringTag,{value:"Module"})),fi={name:"VsTable",mixins:[O],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=>ce(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=>q(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},gi={class:"flex flex-col h-full pt-[16px] pb-[16px] space-y-4 rounded-xl"},bi={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"},yi={class:"inline-block min-w-full align-middle"},xi={class:"relative min-w-full divide-y divide-gray-200 text-[12px]"},ki={class:"sticky top-0 bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},wi={class:"space-x-2"},_i={scope:"col",class:"xl:min-w-[120px] min-w-48"},$i={class:"flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1"},Vi={class:"divide-y divide-gray-200"},Ei={class:"text-gray-600"};function Bi(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",gi,[e.createElementVNode("div",bi,[e.createElementVNode("div",yi,[e.createElementVNode("table",xi,[e.createElementVNode("thead",ki,[e.createElementVNode("tr",wi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.dimensions,a=>(e.openBlock(),e.createElementBlock("th",_i,[e.createElementVNode("div",$i,e.toDisplayString(a),1)]))),256))])]),e.createElementVNode("tbody",Vi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("tr",{key:i},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.dimensions,(c,p)=>(e.openBlock(),e.createElementBlock("td",{key:p,class:"py-3 whitespace-nowrap"},[e.createElementVNode("span",Ei,e.toDisplayString(a==null?void 0:a[c]),1)]))),128))]))),128))])])])])])}const Ci=Object.freeze(Object.defineProperty({__proto__:null,default:S(fi,[["render",Bi]])},Symbol.toStringTag,{value:"Module"}));I.EditorRootPage=ko,I.ROUTES_NAMES=$t,I.Urls=wt,I.VsBar=Re,I.VsDashboard=ur,I.VsDonut=Vt,I.VsLine=Bt,I.VsListBar=Nt,I.VsPie=Et,I.VsPivotTable=St,I.VsProgressBar=Dt,I.VsStat=Ct,I.VsWidget=te,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});